Run gulp lint --fix
, to account for changes in Prettier version 2.2.1
Please refer to https://github.com/prettier/prettier/blob/master/CHANGELOG.md#221 for additional details.
This commit is contained in:
parent
cd2e6d803a
commit
c42029489e
16
external/builder/builder.js
vendored
16
external/builder/builder.js
vendored
@ -202,14 +202,14 @@ function preprocessCSS(mode, source, destination) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function expandImports(content, baseUrl) {
|
function expandImports(content, baseUrl) {
|
||||||
return content.replace(/^\s*@import\s+url\(([^)]+)\);\s*$/gm, function (
|
return content.replace(
|
||||||
all,
|
/^\s*@import\s+url\(([^)]+)\);\s*$/gm,
|
||||||
url
|
function (all, url) {
|
||||||
) {
|
var file = path.join(path.dirname(baseUrl), url);
|
||||||
var file = path.join(path.dirname(baseUrl), url);
|
var imported = fs.readFileSync(file, "utf8").toString();
|
||||||
var imported = fs.readFileSync(file, "utf8").toString();
|
return expandImports(imported, file);
|
||||||
return expandImports(imported, file);
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePrefixed(content, hasPrefixedFilter) {
|
function removePrefixed(content, hasPrefixedFilter) {
|
||||||
|
95
gulpfile.js
95
gulpfile.js
@ -577,45 +577,46 @@ gulp.task("buildnumber", function (done) {
|
|||||||
console.log();
|
console.log();
|
||||||
console.log("### Getting extension build number");
|
console.log("### Getting extension build number");
|
||||||
|
|
||||||
exec("git log --format=oneline " + config.baseVersion + "..", function (
|
exec(
|
||||||
err,
|
"git log --format=oneline " + config.baseVersion + "..",
|
||||||
stdout,
|
function (err, stdout, stderr) {
|
||||||
stderr
|
var buildNumber = 0;
|
||||||
) {
|
if (!err) {
|
||||||
var buildNumber = 0;
|
// Build number is the number of commits since base version
|
||||||
if (!err) {
|
buildNumber = stdout ? stdout.match(/\n/g).length : 0;
|
||||||
// Build number is the number of commits since base version
|
} else {
|
||||||
buildNumber = stdout ? stdout.match(/\n/g).length : 0;
|
console.log(
|
||||||
} else {
|
"This is not a Git repository; using default build number."
|
||||||
console.log("This is not a Git repository; using default build number.");
|
);
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Extension build number: " + buildNumber);
|
|
||||||
|
|
||||||
var version = config.versionPrefix + buildNumber;
|
|
||||||
|
|
||||||
exec('git log --format="%h" -n 1', function (err2, stdout2, stderr2) {
|
|
||||||
var buildCommit = "";
|
|
||||||
if (!err2) {
|
|
||||||
buildCommit = stdout2.replace("\n", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createStringSource(
|
console.log("Extension build number: " + buildNumber);
|
||||||
"version.json",
|
|
||||||
JSON.stringify(
|
var version = config.versionPrefix + buildNumber;
|
||||||
{
|
|
||||||
version: version,
|
exec('git log --format="%h" -n 1', function (err2, stdout2, stderr2) {
|
||||||
build: buildNumber,
|
var buildCommit = "";
|
||||||
commit: buildCommit,
|
if (!err2) {
|
||||||
},
|
buildCommit = stdout2.replace("\n", "");
|
||||||
null,
|
}
|
||||||
2
|
|
||||||
|
createStringSource(
|
||||||
|
"version.json",
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
version: version,
|
||||||
|
build: buildNumber,
|
||||||
|
commit: buildCommit,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
.pipe(gulp.dest(BUILD_DIR))
|
||||||
.pipe(gulp.dest(BUILD_DIR))
|
.on("end", done);
|
||||||
.on("end", done);
|
});
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("default_preferences-pre", function () {
|
gulp.task("default_preferences-pre", function () {
|
||||||
@ -1619,17 +1620,19 @@ gulp.task("baseline", function (done) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("git checkout " + baselineCommit, { cwd: workingDirectory }, function (
|
exec(
|
||||||
error2
|
"git checkout " + baselineCommit,
|
||||||
) {
|
{ cwd: workingDirectory },
|
||||||
if (error2) {
|
function (error2) {
|
||||||
done(new Error("Baseline commit checkout failed."));
|
if (error2) {
|
||||||
return;
|
done(new Error("Baseline commit checkout failed."));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Baseline commit "' + baselineCommit + '" checked out.');
|
console.log('Baseline commit "' + baselineCommit + '" checked out.');
|
||||||
done();
|
done();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -994,11 +994,13 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
var cMap = new CMap(true);
|
var cMap = new CMap(true);
|
||||||
|
|
||||||
if (compressionType === CMapCompressionType.BINARY) {
|
if (compressionType === CMapCompressionType.BINARY) {
|
||||||
return new BinaryCMapReader().process(cMapData, cMap, function (
|
return new BinaryCMapReader().process(
|
||||||
useCMap
|
cMapData,
|
||||||
) {
|
cMap,
|
||||||
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
|
function (useCMap) {
|
||||||
});
|
return extendCMap(cMap, fetchBuiltInCMap, useCMap);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (compressionType === CMapCompressionType.NONE) {
|
if (compressionType === CMapCompressionType.NONE) {
|
||||||
var lexer = new Lexer(new Stream(cMapData));
|
var lexer = new Lexer(new Stream(cMapData));
|
||||||
|
@ -533,101 +533,100 @@ class WorkerMessageHandler {
|
|||||||
return pdfManager.ensureDoc("calculationOrderIds");
|
return pdfManager.ensureDoc("calculationOrderIds");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("SaveDocument", function ({
|
handler.on(
|
||||||
numPages,
|
"SaveDocument",
|
||||||
annotationStorage,
|
function ({ numPages, annotationStorage, filename }) {
|
||||||
filename,
|
pdfManager.requestLoadedStream();
|
||||||
}) {
|
const promises = [
|
||||||
pdfManager.requestLoadedStream();
|
pdfManager.onLoadedStream(),
|
||||||
const promises = [
|
pdfManager.ensureCatalog("acroForm"),
|
||||||
pdfManager.onLoadedStream(),
|
pdfManager.ensureDoc("xref"),
|
||||||
pdfManager.ensureCatalog("acroForm"),
|
pdfManager.ensureDoc("startXRef"),
|
||||||
pdfManager.ensureDoc("xref"),
|
];
|
||||||
pdfManager.ensureDoc("startXRef"),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
|
for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
|
||||||
promises.push(
|
promises.push(
|
||||||
pdfManager.getPage(pageIndex).then(function (page) {
|
pdfManager.getPage(pageIndex).then(function (page) {
|
||||||
const task = new WorkerTask(`Save: page ${pageIndex}`);
|
const task = new WorkerTask(`Save: page ${pageIndex}`);
|
||||||
startWorkerTask(task);
|
startWorkerTask(task);
|
||||||
|
|
||||||
return page
|
return page
|
||||||
.save(handler, task, annotationStorage)
|
.save(handler, task, annotationStorage)
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
finishWorkerTask(task);
|
finishWorkerTask(task);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.all(promises).then(function ([
|
|
||||||
stream,
|
|
||||||
acroForm,
|
|
||||||
xref,
|
|
||||||
startXRef,
|
|
||||||
...refs
|
|
||||||
]) {
|
|
||||||
let newRefs = [];
|
|
||||||
for (const ref of refs) {
|
|
||||||
newRefs = ref
|
|
||||||
.filter(x => x !== null)
|
|
||||||
.reduce((a, b) => a.concat(b), newRefs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRefs.length === 0) {
|
return Promise.all(promises).then(function ([
|
||||||
// No new refs so just return the initial bytes
|
stream,
|
||||||
return stream.bytes;
|
acroForm,
|
||||||
}
|
|
||||||
|
|
||||||
const xfa = (acroForm instanceof Dict && acroForm.get("XFA")) || [];
|
|
||||||
let xfaDatasets = null;
|
|
||||||
if (Array.isArray(xfa)) {
|
|
||||||
for (let i = 0, ii = xfa.length; i < ii; i += 2) {
|
|
||||||
if (xfa[i] === "datasets") {
|
|
||||||
xfaDatasets = xfa[i + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// TODO: Support XFA streams.
|
|
||||||
warn("Unsupported XFA type.");
|
|
||||||
}
|
|
||||||
|
|
||||||
let newXrefInfo = Object.create(null);
|
|
||||||
if (xref.trailer) {
|
|
||||||
// Get string info from Info in order to compute fileId.
|
|
||||||
const infoObj = Object.create(null);
|
|
||||||
const xrefInfo = xref.trailer.get("Info") || null;
|
|
||||||
if (xrefInfo instanceof Dict) {
|
|
||||||
xrefInfo.forEach((key, value) => {
|
|
||||||
if (isString(key) && isString(value)) {
|
|
||||||
infoObj[key] = stringToPDFString(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
newXrefInfo = {
|
|
||||||
rootRef: xref.trailer.getRaw("Root") || null,
|
|
||||||
encrypt: xref.trailer.getRaw("Encrypt") || null,
|
|
||||||
newRef: xref.getNewRef(),
|
|
||||||
infoRef: xref.trailer.getRaw("Info") || null,
|
|
||||||
info: infoObj,
|
|
||||||
fileIds: xref.trailer.getRaw("ID") || null,
|
|
||||||
startXRef,
|
|
||||||
filename,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
xref.resetNewRef();
|
|
||||||
|
|
||||||
return incrementalUpdate({
|
|
||||||
originalData: stream.bytes,
|
|
||||||
xrefInfo: newXrefInfo,
|
|
||||||
newRefs,
|
|
||||||
xref,
|
xref,
|
||||||
datasetsRef: xfaDatasets,
|
startXRef,
|
||||||
|
...refs
|
||||||
|
]) {
|
||||||
|
let newRefs = [];
|
||||||
|
for (const ref of refs) {
|
||||||
|
newRefs = ref
|
||||||
|
.filter(x => x !== null)
|
||||||
|
.reduce((a, b) => a.concat(b), newRefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newRefs.length === 0) {
|
||||||
|
// No new refs so just return the initial bytes
|
||||||
|
return stream.bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
const xfa = (acroForm instanceof Dict && acroForm.get("XFA")) || [];
|
||||||
|
let xfaDatasets = null;
|
||||||
|
if (Array.isArray(xfa)) {
|
||||||
|
for (let i = 0, ii = xfa.length; i < ii; i += 2) {
|
||||||
|
if (xfa[i] === "datasets") {
|
||||||
|
xfaDatasets = xfa[i + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: Support XFA streams.
|
||||||
|
warn("Unsupported XFA type.");
|
||||||
|
}
|
||||||
|
|
||||||
|
let newXrefInfo = Object.create(null);
|
||||||
|
if (xref.trailer) {
|
||||||
|
// Get string info from Info in order to compute fileId.
|
||||||
|
const infoObj = Object.create(null);
|
||||||
|
const xrefInfo = xref.trailer.get("Info") || null;
|
||||||
|
if (xrefInfo instanceof Dict) {
|
||||||
|
xrefInfo.forEach((key, value) => {
|
||||||
|
if (isString(key) && isString(value)) {
|
||||||
|
infoObj[key] = stringToPDFString(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
newXrefInfo = {
|
||||||
|
rootRef: xref.trailer.getRaw("Root") || null,
|
||||||
|
encrypt: xref.trailer.getRaw("Encrypt") || null,
|
||||||
|
newRef: xref.getNewRef(),
|
||||||
|
infoRef: xref.trailer.getRaw("Info") || null,
|
||||||
|
info: infoObj,
|
||||||
|
fileIds: xref.trailer.getRaw("ID") || null,
|
||||||
|
startXRef,
|
||||||
|
filename,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
xref.resetNewRef();
|
||||||
|
|
||||||
|
return incrementalUpdate({
|
||||||
|
originalData: stream.bytes,
|
||||||
|
xrefInfo: newXrefInfo,
|
||||||
|
newRefs,
|
||||||
|
xref,
|
||||||
|
datasetsRef: xfaDatasets,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
|
handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
|
||||||
var pageIndex = data.pageIndex;
|
var pageIndex = data.pageIndex;
|
||||||
|
@ -70,140 +70,136 @@ class Util extends PDFObject {
|
|||||||
const ZERO = 4;
|
const ZERO = 4;
|
||||||
const HASH = 8;
|
const HASH = 8;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
return args[0].replace(pattern, function (
|
return args[0].replace(
|
||||||
match,
|
pattern,
|
||||||
nDecSep,
|
function (match, nDecSep, cFlags, nWidth, nPrecision, cConvChar) {
|
||||||
cFlags,
|
// cConvChar must be one of d, f, s, x
|
||||||
nWidth,
|
if (
|
||||||
nPrecision,
|
cConvChar !== "d" &&
|
||||||
cConvChar
|
cConvChar !== "f" &&
|
||||||
) {
|
cConvChar !== "s" &&
|
||||||
// cConvChar must be one of d, f, s, x
|
cConvChar !== "x"
|
||||||
if (
|
) {
|
||||||
cConvChar !== "d" &&
|
const buf = ["%"];
|
||||||
cConvChar !== "f" &&
|
for (const str of [nDecSep, cFlags, nWidth, nPrecision, cConvChar]) {
|
||||||
cConvChar !== "s" &&
|
if (str) {
|
||||||
cConvChar !== "x"
|
buf.push(str);
|
||||||
) {
|
}
|
||||||
const buf = ["%"];
|
}
|
||||||
for (const str of [nDecSep, cFlags, nWidth, nPrecision, cConvChar]) {
|
return buf.join("");
|
||||||
if (str) {
|
}
|
||||||
buf.push(str);
|
|
||||||
|
i++;
|
||||||
|
if (i === args.length) {
|
||||||
|
throw new Error("Not enough arguments in printf");
|
||||||
|
}
|
||||||
|
const arg = args[i];
|
||||||
|
|
||||||
|
if (cConvChar === "s") {
|
||||||
|
return arg.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
let flags = 0;
|
||||||
|
if (cFlags) {
|
||||||
|
for (const flag of cFlags) {
|
||||||
|
switch (flag) {
|
||||||
|
case "+":
|
||||||
|
flags |= PLUS;
|
||||||
|
break;
|
||||||
|
case " ":
|
||||||
|
flags |= SPACE;
|
||||||
|
break;
|
||||||
|
case "0":
|
||||||
|
flags |= ZERO;
|
||||||
|
break;
|
||||||
|
case "#":
|
||||||
|
flags |= HASH;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.join("");
|
cFlags = flags;
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
if (nWidth) {
|
||||||
if (i === args.length) {
|
nWidth = parseInt(nWidth);
|
||||||
throw new Error("Not enough arguments in printf");
|
}
|
||||||
}
|
|
||||||
const arg = args[i];
|
|
||||||
|
|
||||||
if (cConvChar === "s") {
|
let intPart = Math.trunc(arg);
|
||||||
return arg.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
let flags = 0;
|
if (cConvChar === "x") {
|
||||||
if (cFlags) {
|
let hex = Math.abs(intPart).toString(16).toUpperCase();
|
||||||
for (const flag of cFlags) {
|
if (nWidth !== undefined) {
|
||||||
switch (flag) {
|
hex = hex.padStart(nWidth, cFlags & ZERO ? "0" : " ");
|
||||||
case "+":
|
}
|
||||||
flags |= PLUS;
|
if (cFlags & HASH) {
|
||||||
break;
|
hex = `0x${hex}`;
|
||||||
case " ":
|
}
|
||||||
flags |= SPACE;
|
return hex;
|
||||||
break;
|
}
|
||||||
case "0":
|
|
||||||
flags |= ZERO;
|
if (nPrecision) {
|
||||||
break;
|
nPrecision = parseInt(nPrecision.substring(1));
|
||||||
case "#":
|
}
|
||||||
flags |= HASH;
|
|
||||||
break;
|
nDecSep = nDecSep ? nDecSep.substring(1) : "0";
|
||||||
|
const separators = {
|
||||||
|
0: [",", "."],
|
||||||
|
1: ["", "."],
|
||||||
|
2: [".", ","],
|
||||||
|
3: ["", ","],
|
||||||
|
4: ["'", "."],
|
||||||
|
};
|
||||||
|
const [thousandSep, decimalSep] = separators[nDecSep];
|
||||||
|
|
||||||
|
let decPart = "";
|
||||||
|
if (cConvChar === "f") {
|
||||||
|
if (nPrecision !== undefined) {
|
||||||
|
decPart = (arg - intPart).toFixed(nPrecision);
|
||||||
|
} else {
|
||||||
|
decPart = (arg - intPart).toString();
|
||||||
|
}
|
||||||
|
if (decPart.length > 2) {
|
||||||
|
decPart = `${decimalSep}${decPart.substring(2)}`;
|
||||||
|
} else if (cFlags & HASH) {
|
||||||
|
decPart = ".";
|
||||||
|
} else {
|
||||||
|
decPart = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cFlags = flags;
|
|
||||||
|
|
||||||
if (nWidth) {
|
let sign = "";
|
||||||
nWidth = parseInt(nWidth);
|
if (intPart < 0) {
|
||||||
}
|
sign = "-";
|
||||||
|
intPart = -intPart;
|
||||||
|
} else if (cFlags & PLUS) {
|
||||||
|
sign = "+";
|
||||||
|
} else if (cFlags & SPACE) {
|
||||||
|
sign = " ";
|
||||||
|
}
|
||||||
|
|
||||||
let intPart = Math.trunc(arg);
|
if (thousandSep && intPart >= 1000) {
|
||||||
|
const buf = [];
|
||||||
|
while (true) {
|
||||||
|
buf.push((intPart % 1000).toString().padStart(3, "0"));
|
||||||
|
intPart = Math.trunc(intPart / 1000);
|
||||||
|
if (intPart < 1000) {
|
||||||
|
buf.push(intPart.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intPart = buf.reverse().join(thousandSep);
|
||||||
|
} else {
|
||||||
|
intPart = intPart.toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (cConvChar === "x") {
|
let n = `${intPart}${decPart}`;
|
||||||
let hex = Math.abs(intPart).toString(16).toUpperCase();
|
|
||||||
if (nWidth !== undefined) {
|
if (nWidth !== undefined) {
|
||||||
hex = hex.padStart(nWidth, cFlags & ZERO ? "0" : " ");
|
n = n.padStart(nWidth - sign.length, cFlags & ZERO ? "0" : " ");
|
||||||
}
|
}
|
||||||
if (cFlags & HASH) {
|
|
||||||
hex = `0x${hex}`;
|
return `${sign}${n}`;
|
||||||
}
|
|
||||||
return hex;
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
if (nPrecision) {
|
|
||||||
nPrecision = parseInt(nPrecision.substring(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
nDecSep = nDecSep ? nDecSep.substring(1) : "0";
|
|
||||||
const separators = {
|
|
||||||
0: [",", "."],
|
|
||||||
1: ["", "."],
|
|
||||||
2: [".", ","],
|
|
||||||
3: ["", ","],
|
|
||||||
4: ["'", "."],
|
|
||||||
};
|
|
||||||
const [thousandSep, decimalSep] = separators[nDecSep];
|
|
||||||
|
|
||||||
let decPart = "";
|
|
||||||
if (cConvChar === "f") {
|
|
||||||
if (nPrecision !== undefined) {
|
|
||||||
decPart = (arg - intPart).toFixed(nPrecision);
|
|
||||||
} else {
|
|
||||||
decPart = (arg - intPart).toString();
|
|
||||||
}
|
|
||||||
if (decPart.length > 2) {
|
|
||||||
decPart = `${decimalSep}${decPart.substring(2)}`;
|
|
||||||
} else if (cFlags & HASH) {
|
|
||||||
decPart = ".";
|
|
||||||
} else {
|
|
||||||
decPart = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let sign = "";
|
|
||||||
if (intPart < 0) {
|
|
||||||
sign = "-";
|
|
||||||
intPart = -intPart;
|
|
||||||
} else if (cFlags & PLUS) {
|
|
||||||
sign = "+";
|
|
||||||
} else if (cFlags & SPACE) {
|
|
||||||
sign = " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thousandSep && intPart >= 1000) {
|
|
||||||
const buf = [];
|
|
||||||
while (true) {
|
|
||||||
buf.push((intPart % 1000).toString().padStart(3, "0"));
|
|
||||||
intPart = Math.trunc(intPart / 1000);
|
|
||||||
if (intPart < 1000) {
|
|
||||||
buf.push(intPart.toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intPart = buf.reverse().join(thousandSep);
|
|
||||||
} else {
|
|
||||||
intPart = intPart.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
let n = `${intPart}${decPart}`;
|
|
||||||
if (nWidth !== undefined) {
|
|
||||||
n = n.padStart(nWidth - sign.length, cFlags & ZERO ? "0" : " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${sign}${n}`;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iconStreamFromIcon() {
|
iconStreamFromIcon() {
|
||||||
@ -525,14 +521,14 @@ class Util extends PDFObject {
|
|||||||
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
|
const patterns = /(mmmm|mmm|mm|m|dddd|ddd|dd|d|yyyy|yy|HH|H|hh|h|MM|M|ss|s|tt|t)/g;
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
const re = escapedFormat.replace(patterns, function (
|
const re = escapedFormat.replace(
|
||||||
match,
|
patterns,
|
||||||
patternElement
|
function (match, patternElement) {
|
||||||
) {
|
const { pattern, action } = handlers[patternElement];
|
||||||
const { pattern, action } = handlers[patternElement];
|
actions.push(action);
|
||||||
actions.push(action);
|
return pattern;
|
||||||
return pattern;
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
this._scandCache.set(cFormat, [new RegExp(re, "g"), actions]);
|
this._scandCache.set(cFormat, [new RegExp(re, "g"), actions]);
|
||||||
}
|
}
|
||||||
|
@ -121,19 +121,22 @@ describe("evaluator", function () {
|
|||||||
resources.XObject = xObject;
|
resources.XObject = xObject;
|
||||||
|
|
||||||
const stream = new StringStream("/Res1 DoQ");
|
const stream = new StringStream("/Res1 DoQ");
|
||||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
runOperatorListCheck(
|
||||||
result
|
partialEvaluator,
|
||||||
) {
|
stream,
|
||||||
expect(result.fnArray.length).toEqual(3);
|
resources,
|
||||||
expect(result.fnArray[0]).toEqual(OPS.dependency);
|
function (result) {
|
||||||
expect(result.fnArray[1]).toEqual(OPS.paintImageXObject);
|
expect(result.fnArray.length).toEqual(3);
|
||||||
expect(result.fnArray[2]).toEqual(OPS.restore);
|
expect(result.fnArray[0]).toEqual(OPS.dependency);
|
||||||
expect(result.argsArray.length).toEqual(3);
|
expect(result.fnArray[1]).toEqual(OPS.paintImageXObject);
|
||||||
expect(result.argsArray[0]).toEqual(["img_p0_1"]);
|
expect(result.fnArray[2]).toEqual(OPS.restore);
|
||||||
expect(result.argsArray[1]).toEqual(["img_p0_1", 1, 1]);
|
expect(result.argsArray.length).toEqual(3);
|
||||||
expect(result.argsArray[2]).toEqual(null);
|
expect(result.argsArray[0]).toEqual(["img_p0_1"]);
|
||||||
done();
|
expect(result.argsArray[1]).toEqual(["img_p0_1", 1, 1]);
|
||||||
});
|
expect(result.argsArray[2]).toEqual(null);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle three glued operations", function (done) {
|
it("should handle three glued operations", function (done) {
|
||||||
@ -157,16 +160,19 @@ describe("evaluator", function () {
|
|||||||
const resources = new ResourcesMock();
|
const resources = new ResourcesMock();
|
||||||
resources.Res1 = {};
|
resources.Res1 = {};
|
||||||
const stream = new StringStream("B*Bf*");
|
const stream = new StringStream("B*Bf*");
|
||||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
runOperatorListCheck(
|
||||||
result
|
partialEvaluator,
|
||||||
) {
|
stream,
|
||||||
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
resources,
|
||||||
expect(result.fnArray.length).toEqual(3);
|
function (result) {
|
||||||
expect(result.fnArray[0]).toEqual(OPS.eoFillStroke);
|
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
|
||||||
expect(result.fnArray[1]).toEqual(OPS.fillStroke);
|
expect(result.fnArray.length).toEqual(3);
|
||||||
expect(result.fnArray[2]).toEqual(OPS.eoFill);
|
expect(result.fnArray[0]).toEqual(OPS.eoFillStroke);
|
||||||
done();
|
expect(result.fnArray[1]).toEqual(OPS.fillStroke);
|
||||||
});
|
expect(result.fnArray[2]).toEqual(OPS.eoFill);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle glued operations and operands", function (done) {
|
it("should handle glued operations and operands", function (done) {
|
||||||
@ -253,24 +259,27 @@ describe("evaluator", function () {
|
|||||||
resources.ExtGState = extGState;
|
resources.ExtGState = extGState;
|
||||||
|
|
||||||
const stream = new StringStream("/F2 /GS2 gs 5.711 Tf");
|
const stream = new StringStream("/F2 /GS2 gs 5.711 Tf");
|
||||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
runOperatorListCheck(
|
||||||
result
|
partialEvaluator,
|
||||||
) {
|
stream,
|
||||||
expect(result.fnArray.length).toEqual(3);
|
resources,
|
||||||
expect(result.fnArray[0]).toEqual(OPS.setGState);
|
function (result) {
|
||||||
expect(result.fnArray[1]).toEqual(OPS.dependency);
|
expect(result.fnArray.length).toEqual(3);
|
||||||
expect(result.fnArray[2]).toEqual(OPS.setFont);
|
expect(result.fnArray[0]).toEqual(OPS.setGState);
|
||||||
expect(result.argsArray.length).toEqual(3);
|
expect(result.fnArray[1]).toEqual(OPS.dependency);
|
||||||
expect(result.argsArray[0]).toEqual([
|
expect(result.fnArray[2]).toEqual(OPS.setFont);
|
||||||
[
|
expect(result.argsArray.length).toEqual(3);
|
||||||
["LW", 2],
|
expect(result.argsArray[0]).toEqual([
|
||||||
["CA", 0.5],
|
[
|
||||||
],
|
["LW", 2],
|
||||||
]);
|
["CA", 0.5],
|
||||||
expect(result.argsArray[1]).toEqual(["g_font_error"]);
|
],
|
||||||
expect(result.argsArray[2]).toEqual(["g_font_error", 5.711]);
|
]);
|
||||||
done();
|
expect(result.argsArray[1]).toEqual(["g_font_error"]);
|
||||||
});
|
expect(result.argsArray[2]).toEqual(["g_font_error", 5.711]);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it("should skip if too few arguments", function (done) {
|
it("should skip if too few arguments", function (done) {
|
||||||
const stream = new StringStream("5 d0");
|
const stream = new StringStream("5 d0");
|
||||||
@ -369,13 +378,16 @@ describe("evaluator", function () {
|
|||||||
resources.set("XObject", xobjs);
|
resources.set("XObject", xobjs);
|
||||||
|
|
||||||
const stream = new StringStream("/Res1 Do");
|
const stream = new StringStream("/Res1 Do");
|
||||||
runOperatorListCheck(partialEvaluator, stream, resources, function (
|
runOperatorListCheck(
|
||||||
result
|
partialEvaluator,
|
||||||
) {
|
stream,
|
||||||
expect(result.argsArray).toEqual([]);
|
resources,
|
||||||
expect(result.fnArray).toEqual([]);
|
function (result) {
|
||||||
done();
|
expect(result.argsArray).toEqual([]);
|
||||||
});
|
expect(result.fnArray).toEqual([]);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,29 +98,30 @@ describe("pdf_find_controller", function () {
|
|||||||
return a + b;
|
return a + b;
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.on("updatefindmatchescount", function onUpdateFindMatchesCount(
|
eventBus.on(
|
||||||
evt
|
"updatefindmatchescount",
|
||||||
) {
|
function onUpdateFindMatchesCount(evt) {
|
||||||
if (pdfFindController.pageMatches.length !== totalPages) {
|
if (pdfFindController.pageMatches.length !== totalPages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eventBus.off("updatefindmatchescount", onUpdateFindMatchesCount);
|
eventBus.off("updatefindmatchescount", onUpdateFindMatchesCount);
|
||||||
|
|
||||||
expect(evt.matchesCount.total).toBe(totalMatches);
|
expect(evt.matchesCount.total).toBe(totalMatches);
|
||||||
for (let i = 0; i < totalPages; i++) {
|
for (let i = 0; i < totalPages; i++) {
|
||||||
expect(pdfFindController.pageMatches[i].length).toEqual(
|
expect(pdfFindController.pageMatches[i].length).toEqual(
|
||||||
matchesPerPage[i]
|
matchesPerPage[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect(pdfFindController.selected.pageIdx).toEqual(
|
||||||
|
selectedMatch.pageIndex
|
||||||
|
);
|
||||||
|
expect(pdfFindController.selected.matchIdx).toEqual(
|
||||||
|
selectedMatch.matchIndex
|
||||||
);
|
);
|
||||||
}
|
|
||||||
expect(pdfFindController.selected.pageIdx).toEqual(
|
|
||||||
selectedMatch.pageIndex
|
|
||||||
);
|
|
||||||
expect(pdfFindController.selected.matchIdx).toEqual(
|
|
||||||
selectedMatch.matchIndex
|
|
||||||
);
|
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user