@pi-r/chrome 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/index.js +50 -37
- package/package.json +5 -5
- package/types/index.d.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const fs = require("fs");
|
|
5
4
|
const asset_1 = require("@e-mc/document/asset");
|
|
@@ -21,7 +20,14 @@ const [PATTERN_STRING_SOME, PATTERN_STRING_MANY] = (function () {
|
|
|
21
20
|
const grouping = '(?:\\s|' + dom_1.DomWriter.PATTERN_COMMENT + '|`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`)';
|
|
22
21
|
return [grouping + '*', grouping + '+'];
|
|
23
22
|
})();
|
|
24
|
-
const
|
|
23
|
+
const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function () {
|
|
24
|
+
const parenthesis = '(?:,[^()]+(?=\\))|[^()]|\\([^()]*\\(+|\\([^()]*\\)|(?:\\)[^()]+)?\\)*?)+';
|
|
25
|
+
return [
|
|
26
|
+
new RegExp(`\\(${PATTERN_STRING_SOME}([+-])?(?:(\\d*)[nN]|(0))?${PATTERN_STRING_SOME}([+-])?${PATTERN_STRING_SOME}(\\d*)(?:${PATTERN_STRING_MANY}[oO][fF]${PATTERN_STRING_MANY}(${parenthesis})${PATTERN_STRING_SOME}\\)|${PATTERN_STRING_SOME}\\))`, 'g'),
|
|
27
|
+
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
28
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(?:\\(([^)]*)\\)|\\b))?(?:\\s*supports\\((${parenthesis})\\))?(.*?);?$`)
|
|
29
|
+
];
|
|
30
|
+
})();
|
|
25
31
|
const REGEXP_SRCSETSIZE = /~\s*([\d.]+)\s*([wx])/i;
|
|
26
32
|
const REGEXP_TEMPLATECONDITIONAL = /(\n\s+)?\{\{if\s+((?:[^}]|}(?!}))+?)\}\}(\s*)([\S\s]*?)(?:\s*\{\{else(?:\s+if\s+((?:[^}]|}(?!}))+?))?\}\}(\s*)([\S\s]*?)\s*)?\s*\{\{end\}\}/g;
|
|
27
33
|
const REGEXP_TEMPLATECOMPARISON = /\s*\(\s*(?:\b(eq|ne|lt|le|gt|ge)\s+)?("[^"]+"|'[^']+'|[^\s)]+)(?:\s+("[^"]+"|'[^']+'|[^\s)]+))?\s*\)/g;
|
|
@@ -36,13 +42,11 @@ const REGEXP_FONTFACE = new RegExp(`(\\s*)@font-face${PATTERN_STRING_SOME}{([^}]
|
|
|
36
42
|
const REGEXP_FONTFAMILY = new RegExp(`\\bfont-family${PATTERN_STRING_SOME}:([^;}]+)`, 'i');
|
|
37
43
|
const REGEXP_KEYFRAMES = new RegExp(`(\\s*)@keyframes${PATTERN_STRING_MANY}([^{]+){`, 'gi');
|
|
38
44
|
const REGEXP_PROPERTY = new RegExp(`(\\s*)@property${PATTERN_STRING_MANY}(--[^\\s]+)${PATTERN_STRING_SOME}{`, 'gi');
|
|
39
|
-
const REGEXP_NTHCHILD = new RegExp(`\\(${PATTERN_STRING_SOME}([+-])?(?:(\\d*)[nN]|(0))?${PATTERN_STRING_SOME}([+-])?${PATTERN_STRING_SOME}(\\d*)(?:${PATTERN_STRING_MANY}[oO][fF]${PATTERN_STRING_MANY}(${PATTERN_PARENINLINE})${PATTERN_STRING_SOME}\\)|${PATTERN_STRING_SOME}\\))`, 'g');
|
|
40
45
|
const REGEXP_VARIABLES_UNSAFE = new RegExp(`(\\s*)(--[^\\s:]*)\\s*:[^;}]*([;}])` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'g');
|
|
41
46
|
const REGEXP_FONTFACE_UNSAFE = new RegExp(`(\\s*)@font-face\\s*{([^}]+)}` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi');
|
|
42
47
|
const REGEXP_FONTFAMILY_UNSAFE = /\bfont-family\s*:([^;}]+)/i;
|
|
43
48
|
const REGEXP_KEYFRAMES_UNSAFE = /(\s*)@keyframes\s+([^{]+){/gi;
|
|
44
49
|
const REGEXP_PROPERTY_UNSAFE = /(\s*)@property\s+(--[^\s]+)\s*{/gi;
|
|
45
|
-
const REGEXP_NTHCHILD_UNSAFE = new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${PATTERN_PARENINLINE})\\s*\\)|\\s*\\))`, 'g');
|
|
46
50
|
const REGEXP_OBJECT_NAME = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
|
|
47
51
|
const REGEXP_OBJECT_SUBSCRIPT = /\[\s*(["'])?(.+?)\1\s*\]/g;
|
|
48
52
|
const REGEXP_TEMPLATE_LEADING = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
|
|
@@ -52,7 +56,6 @@ const REGEXP_URL_JS = /\bimport\(/g;
|
|
|
52
56
|
const REGEXP_URL_SVG = /(?:\b[Uu][Rr][Ll]\(|@import\s+(["'])|\b([Hh][Rr][Ee][Ff])\s*=)/g;
|
|
53
57
|
const REGEXP_IMAGESET = /\b(?:-webkit-)?image-set\(/gi;
|
|
54
58
|
const REGEXP_IMAGESET_URL = /(?:^|[^(])\s*("(\s*[^)][^"]*)"|'(\s*[^)][^"]*)')\s*(?:,|$|[^)][^,]*,?)/g;
|
|
55
|
-
const REGEXP_REPLACECSS = /^@import\s+(?:url\((?:[^)]|(?<=\\)\))+\)|"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')(\s*layer(?:\(([^)]*)\)|\b))?(?:\s*supports\(((?:\([^(]+\(|\([^)]+\)|\)[^)]+\)|(?:(?!\))[^(])+|(?:(?!\()[^)])+)+)\))?(.*?);?$/;
|
|
56
59
|
function removeNamespace(name, source, newline, comments) {
|
|
57
60
|
if (source.indexOf('-' + name) !== -1) {
|
|
58
61
|
const [a, b, c, d, e] = CACHE_DATASET[name] || (CACHE_DATASET[name] = [
|
|
@@ -294,7 +297,7 @@ function hasSameOrigin(value, ...other) {
|
|
|
294
297
|
return false;
|
|
295
298
|
}
|
|
296
299
|
function restoreSearchParams(value, prefix = '__sqd') {
|
|
297
|
-
if (value
|
|
300
|
+
if ((value === null || value === void 0 ? void 0 : value.indexOf(prefix)) !== -1) {
|
|
298
301
|
const params = new URLSearchParams(value);
|
|
299
302
|
params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
|
|
300
303
|
if (value = params.toString()) {
|
|
@@ -382,6 +385,7 @@ function getSrcURL(parent, file) {
|
|
|
382
385
|
return [found ? joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl];
|
|
383
386
|
}
|
|
384
387
|
function transformURL(host, parent, type, source, importFile) {
|
|
388
|
+
var _a;
|
|
385
389
|
const related = [];
|
|
386
390
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
387
391
|
const isHtml = type === 'html';
|
|
@@ -468,12 +472,13 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
468
472
|
}
|
|
469
473
|
}
|
|
470
474
|
const setOutputURL = (value, asset) => {
|
|
475
|
+
var _a;
|
|
471
476
|
if (!value) {
|
|
472
477
|
return;
|
|
473
478
|
}
|
|
474
479
|
if (asset) {
|
|
475
480
|
if (!asset.inlineBase64) {
|
|
476
|
-
if (host.Cloud
|
|
481
|
+
if ((_a = host.Cloud) === null || _a === void 0 ? void 0 : _a.getStorage('upload', asset.cloudStorage)) {
|
|
477
482
|
const inlineUrlCloud = asset.inlineUrlCloud || (asset.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
478
483
|
(parent.inlineUrlCloudMap || (parent.inlineUrlCloudMap = {}))[inlineUrlCloud] = value;
|
|
479
484
|
value = inlineUrlCloud;
|
|
@@ -554,7 +559,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
554
559
|
url = trimQuote(content);
|
|
555
560
|
}
|
|
556
561
|
if (url.startsWith('data:')) {
|
|
557
|
-
const base64 = url.split(',')[1]
|
|
562
|
+
const base64 = (_a = url.split(',')[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
558
563
|
if (base64) {
|
|
559
564
|
for (const item of this.assets) {
|
|
560
565
|
if (item.base64 === base64) {
|
|
@@ -773,7 +778,7 @@ function transformJs(host, file, output) {
|
|
|
773
778
|
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
774
779
|
}
|
|
775
780
|
}
|
|
776
|
-
appending
|
|
781
|
+
appending === null || appending === void 0 ? void 0 : appending.forEach(item => item.order += order);
|
|
777
782
|
}
|
|
778
783
|
if ((0, types_1.isArray)(sourceFiles)) {
|
|
779
784
|
file.sourceFiles = sourceFiles;
|
|
@@ -894,7 +899,7 @@ const isIgnored = (item, exists) => item.invalid || (0, types_1.ignoreFlag)(item
|
|
|
894
899
|
const findFont = (value) => value && (Array.isArray(value) ? value : [value]).find(format => isFont(format));
|
|
895
900
|
const spliceString = (source, startIndex, endIndex, content) => source.substring(0, startIndex) + content + source.substring(endIndex);
|
|
896
901
|
const getEndIndex = (match) => match.index + match[0].length;
|
|
897
|
-
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url
|
|
902
|
+
const getRelativeURL = (file) => { var _a; return joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams((_a = file.url) === null || _a === void 0 ? void 0 : _a.search) : ''); };
|
|
898
903
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
899
904
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
900
905
|
class ChromeDocument extends Document {
|
|
@@ -972,6 +977,7 @@ class ChromeDocument extends Document {
|
|
|
972
977
|
return result + (parent && result > 0 ? await super.purgeMemory(typeof parent === 'number' && parent > 0 ? parent : percent, limit, true) : 0);
|
|
973
978
|
}
|
|
974
979
|
static async finalize(instance) {
|
|
980
|
+
var _a;
|
|
975
981
|
if (instance.aborted) {
|
|
976
982
|
return Promise.reject((0, types_1.createAbortError)());
|
|
977
983
|
}
|
|
@@ -983,7 +989,7 @@ class ChromeDocument extends Document {
|
|
|
983
989
|
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
984
990
|
}
|
|
985
991
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
986
|
-
const incremental = htmlFile.incremental
|
|
992
|
+
const incremental = (_a = htmlFile.incremental) !== null && _a !== void 0 ? _a : this.incremental;
|
|
987
993
|
if (incremental === 'etag' || incremental === 'exists') {
|
|
988
994
|
const fetched = this.fetchedAssets;
|
|
989
995
|
const isHtmlOnly = () => !fetched.find(item => item !== htmlFile && assets.includes(item));
|
|
@@ -1578,6 +1584,7 @@ class ChromeDocument extends Document {
|
|
|
1578
1584
|
}
|
|
1579
1585
|
resolveImports(file, code, baseFile) {
|
|
1580
1586
|
var _a;
|
|
1587
|
+
var _b;
|
|
1581
1588
|
if (!Array.isArray(file.imports)) {
|
|
1582
1589
|
return;
|
|
1583
1590
|
}
|
|
@@ -1593,7 +1600,7 @@ class ChromeDocument extends Document {
|
|
|
1593
1600
|
}
|
|
1594
1601
|
const importMap = {};
|
|
1595
1602
|
for (const item of file.imports) {
|
|
1596
|
-
(importMap[
|
|
1603
|
+
(importMap[_b = item.placeholder] || (importMap[_b] = [])).push(item);
|
|
1597
1604
|
}
|
|
1598
1605
|
for (const placeholder in importMap) {
|
|
1599
1606
|
const items = importMap[placeholder];
|
|
@@ -1605,7 +1612,7 @@ class ChromeDocument extends Document {
|
|
|
1605
1612
|
const hosted = type === 'css';
|
|
1606
1613
|
let value;
|
|
1607
1614
|
if (hosted) {
|
|
1608
|
-
const asset = this.host
|
|
1615
|
+
const asset = (_a = this.host) === null || _a === void 0 ? void 0 : _a.findAsset(uri);
|
|
1609
1616
|
if (asset) {
|
|
1610
1617
|
const [relativeUrl, sameDir] = getSrcURL.call(this, bundleMain || file, asset);
|
|
1611
1618
|
if (relativeUrl) {
|
|
@@ -1634,16 +1641,17 @@ class ChromeDocument extends Document {
|
|
|
1634
1641
|
}
|
|
1635
1642
|
}
|
|
1636
1643
|
replaceContent(source, statement, mimeType) {
|
|
1644
|
+
var _a;
|
|
1637
1645
|
switch (mimeType) {
|
|
1638
1646
|
case 'text/css': {
|
|
1639
1647
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1640
1648
|
if (match) {
|
|
1641
1649
|
const layer = match[1];
|
|
1642
|
-
const supports = match[3]
|
|
1650
|
+
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1643
1651
|
const query = match[4].trim();
|
|
1644
1652
|
if (layer || supports || query) {
|
|
1645
1653
|
const newline = (0, util_1.getNewline)(source);
|
|
1646
|
-
let result = supports ? `@supports (${
|
|
1654
|
+
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
1647
1655
|
if (query) {
|
|
1648
1656
|
result += `@media ${query} {` + newline;
|
|
1649
1657
|
}
|
|
@@ -1676,8 +1684,9 @@ class ChromeDocument extends Document {
|
|
|
1676
1684
|
}
|
|
1677
1685
|
}
|
|
1678
1686
|
writeImage(data) {
|
|
1687
|
+
var _a;
|
|
1679
1688
|
const { file, output, command } = data;
|
|
1680
|
-
if (output && command && file.element
|
|
1689
|
+
if (output && command && ((_a = file.element) === null || _a === void 0 ? void 0 : _a.outerXml)) {
|
|
1681
1690
|
const match = REGEXP_SRCSETSIZE.exec(command);
|
|
1682
1691
|
if (match) {
|
|
1683
1692
|
(file.srcSet || (file.srcSet = [])).push(toPosix(data.baseDirectory ? output.substring(data.baseDirectory.length + 1) : output), match[1] + match[2].toLowerCase());
|
|
@@ -1688,12 +1697,13 @@ class ChromeDocument extends Document {
|
|
|
1688
1697
|
return false;
|
|
1689
1698
|
}
|
|
1690
1699
|
cloudInit({ instance }) {
|
|
1700
|
+
var _a, _b;
|
|
1691
1701
|
this._cloudUrlMap = Object.create(null);
|
|
1692
1702
|
this._cloudUploaded = new Set();
|
|
1693
1703
|
this._cloudEndpoint = null;
|
|
1694
1704
|
const htmlFile = this.htmlFile;
|
|
1695
1705
|
if (htmlFile) {
|
|
1696
|
-
const endpoint = instance.getStorage('upload', htmlFile.cloudStorage)
|
|
1706
|
+
const endpoint = (_b = (_a = instance.getStorage('upload', htmlFile.cloudStorage)) === null || _a === void 0 ? void 0 : _a.upload) === null || _b === void 0 ? void 0 : _b.endpoint;
|
|
1697
1707
|
if (endpoint) {
|
|
1698
1708
|
this._cloudEndpoint = new RegExp((0, types_1.escapePattern)(toPosix(endpoint)) + '/', 'g');
|
|
1699
1709
|
}
|
|
@@ -1706,6 +1716,7 @@ class ChromeDocument extends Document {
|
|
|
1706
1716
|
return this.editing.includes(file);
|
|
1707
1717
|
}
|
|
1708
1718
|
cloudUpload({ host }, file, url, active) {
|
|
1719
|
+
var _a;
|
|
1709
1720
|
if (active) {
|
|
1710
1721
|
const endpoint = this._cloudEndpoint;
|
|
1711
1722
|
const inlineUrlCloud = file.inlineUrlCloud;
|
|
@@ -1715,7 +1726,7 @@ class ChromeDocument extends Document {
|
|
|
1715
1726
|
const htmlFile = this.htmlFile;
|
|
1716
1727
|
const pattern = new RegExp((0, types_1.escapePattern)(inlineUrlCloud), 'g');
|
|
1717
1728
|
for (const item of this.editing) {
|
|
1718
|
-
if (item.inlineUrlCloudMap
|
|
1729
|
+
if ((_a = item.inlineUrlCloudMap) === null || _a === void 0 ? void 0 : _a[inlineUrlCloud]) {
|
|
1719
1730
|
const source = host.getUTF8String(item);
|
|
1720
1731
|
const output = source.replace(pattern, endpoint && item !== htmlFile && cloudUrl.indexOf('/') !== -1 ? url : cloudUrl);
|
|
1721
1732
|
if (source !== output) {
|
|
@@ -1730,6 +1741,7 @@ class ChromeDocument extends Document {
|
|
|
1730
1741
|
return Promise.resolve(false);
|
|
1731
1742
|
}
|
|
1732
1743
|
async cloudFinalize(state) {
|
|
1744
|
+
var _a;
|
|
1733
1745
|
if (this.aborted) {
|
|
1734
1746
|
return Promise.reject((0, types_1.createAbortError)());
|
|
1735
1747
|
}
|
|
@@ -1778,7 +1790,7 @@ class ChromeDocument extends Document {
|
|
|
1778
1790
|
for (const storage of cloudStorage) {
|
|
1779
1791
|
if (instance.hasCredential('storage', storage)) {
|
|
1780
1792
|
const { service, admin, bucket, upload } = storage;
|
|
1781
|
-
const website = admin
|
|
1793
|
+
const website = (_a = admin === null || admin === void 0 ? void 0 : admin.configBucket) === null || _a === void 0 ? void 0 : _a.website;
|
|
1782
1794
|
if ((0, types_1.isPlainObject)(website) && bucket && upload) {
|
|
1783
1795
|
let filename = joinPath(upload.pathname, upload.filename || path.basename(htmlFile.localUri));
|
|
1784
1796
|
if (website.indexPage === true) {
|
|
@@ -1814,7 +1826,7 @@ class ChromeDocument extends Document {
|
|
|
1814
1826
|
}
|
|
1815
1827
|
const main = watch.main;
|
|
1816
1828
|
let result;
|
|
1817
|
-
if (main
|
|
1829
|
+
if ((main === null || main === void 0 ? void 0 : main.editing) && main.mimeType === 'text/html') {
|
|
1818
1830
|
const inlineUrlCloudMap = main.inlineUrlCloudMap || {};
|
|
1819
1831
|
const using = [];
|
|
1820
1832
|
let found;
|
|
@@ -1851,6 +1863,7 @@ class ChromeDocument extends Document {
|
|
|
1851
1863
|
}
|
|
1852
1864
|
watchModified(watch, assets) {
|
|
1853
1865
|
return (files, errors, status) => {
|
|
1866
|
+
var _a;
|
|
1854
1867
|
if (!watch.server || watch.captured || watch.aborted) {
|
|
1855
1868
|
return;
|
|
1856
1869
|
}
|
|
@@ -1870,7 +1883,7 @@ class ChromeDocument extends Document {
|
|
|
1870
1883
|
search = next.url.search;
|
|
1871
1884
|
}
|
|
1872
1885
|
}
|
|
1873
|
-
search
|
|
1886
|
+
search !== null && search !== void 0 ? search : (search = restoreSearchParams((_a = asset.url) === null || _a === void 0 ? void 0 : _a.search));
|
|
1874
1887
|
status && (status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN));
|
|
1875
1888
|
watch.send(types_1.WATCH_EVENT.MODIFIED, {
|
|
1876
1889
|
action: pathname && watch.hot && !watch.main ? 'hot' : '',
|
|
@@ -1942,11 +1955,13 @@ class ChromeDocument extends Document {
|
|
|
1942
1955
|
}
|
|
1943
1956
|
}
|
|
1944
1957
|
findDataValue(name) {
|
|
1958
|
+
var _a;
|
|
1945
1959
|
if (this.hasEval('template')) {
|
|
1946
|
-
return this.templateMap.data
|
|
1960
|
+
return (_a = this.templateMap.data) === null || _a === void 0 ? void 0 : _a[name];
|
|
1947
1961
|
}
|
|
1948
1962
|
}
|
|
1949
1963
|
setInlinedAttributes({ host, startTime, hashed, contentMap, bufferMap, productionRelease }) {
|
|
1964
|
+
var _a, _b;
|
|
1950
1965
|
const readBase64 = (item, uuid) => {
|
|
1951
1966
|
if (!contentMap[uuid]) {
|
|
1952
1967
|
try {
|
|
@@ -1976,7 +1991,7 @@ class ChromeDocument extends Document {
|
|
|
1976
1991
|
const filename = hash && createHash(host, item, hash, bufferMap);
|
|
1977
1992
|
if (filename) {
|
|
1978
1993
|
for (const asset of this.assets) {
|
|
1979
|
-
const url = inlineUrl ? asset.inlineUrlMap
|
|
1994
|
+
const url = inlineUrl ? (_a = asset.inlineUrlMap) === null || _a === void 0 ? void 0 : _a[inlineUrl] : (_b = asset.inlineUrlCloudMap) === null || _b === void 0 ? void 0 : _b[inlineUrlCloud];
|
|
1980
1995
|
if (url) {
|
|
1981
1996
|
const search = url.indexOf('?');
|
|
1982
1997
|
const index = (search !== -1 ? url.substring(0, search) : url).lastIndexOf('/');
|
|
@@ -2024,10 +2039,10 @@ class ChromeDocument extends Document {
|
|
|
2024
2039
|
const sortNested = (a, b) => {
|
|
2025
2040
|
const { inlineUrlCloud: urlA, inlineUrlCloudMap: mapA } = a;
|
|
2026
2041
|
const { inlineUrlCloud: urlB, inlineUrlCloudMap: mapB } = b;
|
|
2027
|
-
if (urlA && mapB
|
|
2042
|
+
if (urlA && (mapB === null || mapB === void 0 ? void 0 : mapB[urlA])) {
|
|
2028
2043
|
return -1;
|
|
2029
2044
|
}
|
|
2030
|
-
if (urlB && mapA
|
|
2045
|
+
if (urlB && (mapA === null || mapA === void 0 ? void 0 : mapA[urlB])) {
|
|
2031
2046
|
return 1;
|
|
2032
2047
|
}
|
|
2033
2048
|
return 0;
|
|
@@ -2257,7 +2272,7 @@ class ChromeDocument extends Document {
|
|
|
2257
2272
|
}
|
|
2258
2273
|
}
|
|
2259
2274
|
if (uri && !(0, util_1.hasValue)(item.format, 'crossorigin') && item !== htmlFile) {
|
|
2260
|
-
if (cloud
|
|
2275
|
+
if (cloud === null || cloud === void 0 ? void 0 : cloud.getStorage('upload', item.cloudStorage)) {
|
|
2261
2276
|
const inlineUrlCloud = item.inlineUrlCloud || (item.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
2262
2277
|
((_a = htmlFile).inlineUrlCloudMap || (_a.inlineUrlCloudMap = {}))[inlineUrlCloud] = productionRelease ? this.removeServerRoot(uri) : uri;
|
|
2263
2278
|
uri = inlineUrlCloud;
|
|
@@ -2425,7 +2440,7 @@ class ChromeDocument extends Document {
|
|
|
2425
2440
|
batchGroup.push([item]);
|
|
2426
2441
|
break;
|
|
2427
2442
|
default:
|
|
2428
|
-
if (db
|
|
2443
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2429
2444
|
try {
|
|
2430
2445
|
await db.setCredential(item);
|
|
2431
2446
|
const credential = item.credential;
|
|
@@ -2458,6 +2473,7 @@ class ChromeDocument extends Document {
|
|
|
2458
2473
|
}
|
|
2459
2474
|
return this.allSettled(batchGroup.map(batch => {
|
|
2460
2475
|
return new Promise(async (resolve, reject) => {
|
|
2476
|
+
var _a, _b, _c;
|
|
2461
2477
|
const errorRemove = (item, reason) => {
|
|
2462
2478
|
removeElement(item);
|
|
2463
2479
|
reject(reason);
|
|
@@ -2516,7 +2532,7 @@ class ChromeDocument extends Document {
|
|
|
2516
2532
|
}
|
|
2517
2533
|
else {
|
|
2518
2534
|
this.abort(type);
|
|
2519
|
-
errorRemove(current, target ? errorDataSource('Not found', target) : errorDataSource('Not defined - ' + (this.settings.directory
|
|
2535
|
+
errorRemove(current, target ? errorDataSource('Not found', target) : errorDataSource('Not defined - ' + (((_a = this.settings.directory) === null || _a === void 0 ? void 0 : _a.data) ? 'file' : 'directory'), type));
|
|
2520
2536
|
return;
|
|
2521
2537
|
}
|
|
2522
2538
|
}
|
|
@@ -2644,7 +2660,7 @@ class ChromeDocument extends Document {
|
|
|
2644
2660
|
}
|
|
2645
2661
|
if (!getData) {
|
|
2646
2662
|
const { settings, encoding, persist = true } = current;
|
|
2647
|
-
target || (target = settings && this.settings.export
|
|
2663
|
+
target || (target = settings && ((_b = this.settings.export) === null || _b === void 0 ? void 0 : _b[settings]) || pathname);
|
|
2648
2664
|
if (typeof target === 'function') {
|
|
2649
2665
|
getData = target;
|
|
2650
2666
|
hint = target.name;
|
|
@@ -2703,7 +2719,7 @@ class ChromeDocument extends Document {
|
|
|
2703
2719
|
break;
|
|
2704
2720
|
}
|
|
2705
2721
|
default:
|
|
2706
|
-
if (db
|
|
2722
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2707
2723
|
switch (type) {
|
|
2708
2724
|
case 'mongodb':
|
|
2709
2725
|
for (let j = 0; j < length; ++j) {
|
|
@@ -2927,7 +2943,7 @@ class ChromeDocument extends Document {
|
|
|
2927
2943
|
for (let j = 0, match; j < items.length; ++j) {
|
|
2928
2944
|
const row = items[j];
|
|
2929
2945
|
if ((0, types_1.isPlainObject)(row)) {
|
|
2930
|
-
row.__index__
|
|
2946
|
+
(_c = row.__index__) !== null && _c !== void 0 ? _c : (row.__index__ = j + 1);
|
|
2931
2947
|
}
|
|
2932
2948
|
let segment = template;
|
|
2933
2949
|
while (match = REGEXP_TEMPLATECONDITIONAL.exec(segment)) {
|
|
@@ -3213,6 +3229,7 @@ class ChromeDocument extends Document {
|
|
|
3213
3229
|
}
|
|
3214
3230
|
}
|
|
3215
3231
|
setProductionAttributes({ host, hashed, bufferMap, startTime }) {
|
|
3232
|
+
var _a;
|
|
3216
3233
|
for (const item of this.assets) {
|
|
3217
3234
|
if (isIgnored(item, true)) {
|
|
3218
3235
|
continue;
|
|
@@ -3220,7 +3237,7 @@ class ChromeDocument extends Document {
|
|
|
3220
3237
|
if (item.hash && !hashed.has(item)) {
|
|
3221
3238
|
createHash(host, item, item.hash, bufferMap);
|
|
3222
3239
|
}
|
|
3223
|
-
switch (item.element
|
|
3240
|
+
switch ((_a = item.element) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase()) {
|
|
3224
3241
|
case 'style':
|
|
3225
3242
|
if (!item.content) {
|
|
3226
3243
|
break;
|
|
@@ -3686,9 +3703,5 @@ class ChromeDocument extends Document {
|
|
|
3686
3703
|
}
|
|
3687
3704
|
ChromeDocument.INTERNAL_ASSIGNUUID = "__assign__";
|
|
3688
3705
|
ChromeDocument.INTERNAL_SERVERROOT = "__serverroot__";
|
|
3689
|
-
exports.default = ChromeDocument;
|
|
3690
3706
|
|
|
3691
|
-
|
|
3692
|
-
module.exports = exports.default;
|
|
3693
|
-
module.exports.default = exports.default;
|
|
3694
|
-
}
|
|
3707
|
+
module.exports = ChromeDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.7.
|
|
24
|
-
"@e-mc/core": "^0.7.
|
|
25
|
-
"@e-mc/document": "^0.7.
|
|
26
|
-
"@e-mc/types": "^0.7.
|
|
23
|
+
"@e-mc/cloud": "^0.7.5",
|
|
24
|
+
"@e-mc/core": "^0.7.5",
|
|
25
|
+
"@e-mc/document": "^0.7.5",
|
|
26
|
+
"@e-mc/types": "^0.7.5"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED