[ESM] Convert the "cmaps"-task to use import()
syntax
This commit is contained in:
parent
42edc4d895
commit
f012fc5e70
@ -13,10 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
import fs from "fs";
|
||||||
const path = require("path");
|
import { optimizeCMap } from "./optimize.mjs";
|
||||||
const parseAdobeCMap = require("./parse.js").parseAdobeCMap;
|
import { parseAdobeCMap } from "./parse.mjs";
|
||||||
const optimizeCMap = require("./optimize.js").optimizeCMap;
|
import path from "path";
|
||||||
|
|
||||||
function compressCmap(srcPath, destPath, verify) {
|
function compressCmap(srcPath, destPath, verify) {
|
||||||
const content = fs.readFileSync(srcPath).toString();
|
const content = fs.readFileSync(srcPath).toString();
|
||||||
@ -469,7 +469,7 @@ function incHex(a) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.compressCmaps = function (src, dest, verify) {
|
function compressCmaps(src, dest, verify) {
|
||||||
const files = fs.readdirSync(src).filter(function (fn) {
|
const files = fs.readdirSync(src).filter(function (fn) {
|
||||||
return !fn.includes("."); // skipping files with the extension
|
return !fn.includes("."); // skipping files with the extension
|
||||||
});
|
});
|
||||||
@ -489,4 +489,6 @@ exports.compressCmaps = function (src, dest, verify) {
|
|||||||
"%"
|
"%"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export { compressCmaps };
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.optimizeCMap = function (data) {
|
function optimizeCMap(data) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
while (i < data.body.length) {
|
while (i < data.body.length) {
|
||||||
if (data.body[i - 1].type === data.body[i].type) {
|
if (data.body[i - 1].type === data.body[i].type) {
|
||||||
@ -206,7 +206,7 @@ exports.optimizeCMap = function (data) {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function incHex(a) {
|
function incHex(a) {
|
||||||
let c = 1,
|
let c = 1,
|
||||||
@ -223,3 +223,5 @@ function incHex(a) {
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { optimizeCMap };
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.parseAdobeCMap = function (content) {
|
function parseAdobeCMap(content) {
|
||||||
let m = /(\bbegincmap\b[\s\S]*?)\bendcmap\b/.exec(content);
|
let m = /(\bbegincmap\b[\s\S]*?)\bendcmap\b/.exec(content);
|
||||||
if (!m) {
|
if (!m) {
|
||||||
throw new Error("cmap was not found");
|
throw new Error("cmap was not found");
|
||||||
@ -100,4 +100,6 @@ exports.parseAdobeCMap = function (content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export { parseAdobeCMap };
|
@ -848,7 +848,7 @@ gulp.task("locale", function () {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("cmaps", function (done) {
|
gulp.task("cmaps", async function () {
|
||||||
const CMAP_INPUT = "external/cmaps";
|
const CMAP_INPUT = "external/cmaps";
|
||||||
const VIEWER_CMAP_OUTPUT = "external/bcmaps";
|
const VIEWER_CMAP_OUTPUT = "external/bcmaps";
|
||||||
|
|
||||||
@ -869,10 +869,10 @@ gulp.task("cmaps", function (done) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const compressCmaps =
|
const { compressCmaps } = await import(
|
||||||
require("./external/cmapscompress/compress.js").compressCmaps;
|
"./external/cmapscompress/compress.mjs"
|
||||||
|
);
|
||||||
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
|
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function preprocessCSS(source, defines) {
|
function preprocessCSS(source, defines) {
|
||||||
|
Loading…
Reference in New Issue
Block a user