@pi-r/chrome 0.3.3 → 0.3.5
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/index.js +97 -35
- package/package.json +5 -5
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/index.js
CHANGED
|
@@ -11,6 +11,9 @@ const transform_1 = require("@e-mc/document/transform");
|
|
|
11
11
|
const Document = require('@e-mc/document');
|
|
12
12
|
const CACHE_DBRESULT = new Map();
|
|
13
13
|
const CACHE_LOCALFILE = new Map();
|
|
14
|
+
const CACHE_ETAG = new Map();
|
|
15
|
+
const CACHE_CONTENT = new Map();
|
|
16
|
+
const CACHE_FORMAT = new Map();
|
|
14
17
|
const CACHE_DATASET = {};
|
|
15
18
|
const CACHE_ATRULES = {};
|
|
16
19
|
let CACHE_TOTAL = 0;
|
|
@@ -286,7 +289,7 @@ function hasSameOrigin(value, ...other) {
|
|
|
286
289
|
return false;
|
|
287
290
|
}
|
|
288
291
|
function restoreSearchParams(value, prefix = '__sqd') {
|
|
289
|
-
if (value
|
|
292
|
+
if ((value === null || value === void 0 ? void 0 : value.indexOf(prefix)) !== -1) {
|
|
290
293
|
const params = new URLSearchParams(value);
|
|
291
294
|
params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
|
|
292
295
|
if (value = params.toString()) {
|
|
@@ -378,6 +381,7 @@ function getSrcURL(parent, file) {
|
|
|
378
381
|
return [found ? joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl];
|
|
379
382
|
}
|
|
380
383
|
function transformURL(host, parent, type, source, importFile) {
|
|
384
|
+
var _a;
|
|
381
385
|
const related = [];
|
|
382
386
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
383
387
|
const isHtml = type === 'html';
|
|
@@ -443,12 +447,13 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
443
447
|
}
|
|
444
448
|
}
|
|
445
449
|
const setOutputURL = (value, asset) => {
|
|
450
|
+
var _a;
|
|
446
451
|
if (!value) {
|
|
447
452
|
return;
|
|
448
453
|
}
|
|
449
454
|
if (asset) {
|
|
450
455
|
if (!asset.inlineBase64) {
|
|
451
|
-
if (host.Cloud
|
|
456
|
+
if ((_a = host.Cloud) === null || _a === void 0 ? void 0 : _a.getStorage('upload', asset.cloudStorage)) {
|
|
452
457
|
const inlineUrlCloud = asset.inlineUrlCloud || (asset.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
453
458
|
(parent.inlineUrlCloudMap || (parent.inlineUrlCloudMap = {}))[inlineUrlCloud] = value;
|
|
454
459
|
value = inlineUrlCloud;
|
|
@@ -529,7 +534,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
529
534
|
url = trimQuote(content);
|
|
530
535
|
}
|
|
531
536
|
if (url.startsWith('data:')) {
|
|
532
|
-
const base64 = url.split(',')[1]
|
|
537
|
+
const base64 = (_a = url.split(',')[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
533
538
|
if (base64) {
|
|
534
539
|
for (const item of this.assets) {
|
|
535
540
|
if (item.base64 === base64) {
|
|
@@ -748,7 +753,7 @@ function transformJs(host, file, output) {
|
|
|
748
753
|
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
749
754
|
}
|
|
750
755
|
}
|
|
751
|
-
appending
|
|
756
|
+
appending === null || appending === void 0 ? void 0 : appending.forEach(item => item.order += order);
|
|
752
757
|
}
|
|
753
758
|
if ((0, types_1.isArray)(sourceFiles)) {
|
|
754
759
|
file.sourceFiles = sourceFiles;
|
|
@@ -867,7 +872,7 @@ const isIgnored = (item, exists) => item.invalid || (0, types_1.ignoreFlag)(item
|
|
|
867
872
|
const findFont = (value) => value && (Array.isArray(value) ? value : [value]).find(format => isFont(format));
|
|
868
873
|
const spliceString = (source, startIndex, endIndex, content) => source.substring(0, startIndex) + content + source.substring(endIndex);
|
|
869
874
|
const getEndIndex = (match) => match.index + match[0].length;
|
|
870
|
-
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url
|
|
875
|
+
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) : ''); };
|
|
871
876
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
872
877
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
873
878
|
class ChromeDocument extends Document {
|
|
@@ -937,10 +942,14 @@ class ChromeDocument extends Document {
|
|
|
937
942
|
}
|
|
938
943
|
CACHE_TOTAL = stored.length - result;
|
|
939
944
|
}
|
|
945
|
+
CACHE_ETAG.clear();
|
|
946
|
+
CACHE_CONTENT.clear();
|
|
947
|
+
CACHE_FORMAT.clear();
|
|
940
948
|
}
|
|
941
949
|
return result + (parent && result > 0 ? await super.purgeMemory(typeof parent === 'number' && parent > 0 ? parent : percent, limit, true) : 0);
|
|
942
950
|
}
|
|
943
951
|
static async finalize(instance) {
|
|
952
|
+
var _a;
|
|
944
953
|
if (instance.aborted) {
|
|
945
954
|
return Promise.reject((0, types_1.createAbortError)());
|
|
946
955
|
}
|
|
@@ -952,7 +961,7 @@ class ChromeDocument extends Document {
|
|
|
952
961
|
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
953
962
|
}
|
|
954
963
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
955
|
-
const incremental = htmlFile.incremental
|
|
964
|
+
const incremental = (_a = htmlFile.incremental) !== null && _a !== void 0 ? _a : this.incremental;
|
|
956
965
|
if (incremental === 'etag' || incremental === 'exists') {
|
|
957
966
|
const fetched = this.fetchedAssets;
|
|
958
967
|
const isHtmlOnly = () => !fetched.find(item => item !== htmlFile && assets.includes(item));
|
|
@@ -963,12 +972,27 @@ class ChromeDocument extends Document {
|
|
|
963
972
|
if (outHtml) {
|
|
964
973
|
const { etag, initialValue } = htmlFile;
|
|
965
974
|
let buffer;
|
|
966
|
-
if (!initialValue || !(etag && initialValue.etag === etag && (buffer = initialValue.buffer)) || fetched.find(item => item.
|
|
975
|
+
if (!initialValue || !(etag && initialValue.etag === etag && (buffer = initialValue.buffer)) || fetched.find(item => item !== htmlFile && item.etag && CACHE_ETAG.get(item.localUri) !== item.etag && (item.inlineContent || item.bundleReplace && (!Array.isArray(item.from) || item.from.includes('style'))))) {
|
|
976
|
+
const isValid = (item) => !!item.localUri && item !== htmlFile && !item.invalid;
|
|
977
|
+
for (const item of fetched) {
|
|
978
|
+
if (item.etag && !item.content && isValid(item)) {
|
|
979
|
+
CACHE_ETAG.set(item.localUri, item.etag);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
for (const item of instance.assets) {
|
|
983
|
+
if (isValid(item)) {
|
|
984
|
+
if (item.content) {
|
|
985
|
+
CACHE_CONTENT.set(item.localUri, item.content);
|
|
986
|
+
}
|
|
987
|
+
if (item.format) {
|
|
988
|
+
CACHE_FORMAT.set(item.localUri, item.format.toString());
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
967
992
|
break;
|
|
968
993
|
}
|
|
969
994
|
try {
|
|
970
|
-
|
|
971
|
-
fs.writeFileSync(localUri, buffer, (0, types_1.getEncoding)(encoding));
|
|
995
|
+
fs.writeFileSync(htmlFile.localUri, buffer, (0, types_1.getEncoding)(htmlFile.encoding));
|
|
972
996
|
htmlFile.buffer = buffer;
|
|
973
997
|
htmlFile.sourceUTF8 = undefined;
|
|
974
998
|
}
|
|
@@ -976,12 +1000,39 @@ class ChromeDocument extends Document {
|
|
|
976
1000
|
break;
|
|
977
1001
|
}
|
|
978
1002
|
}
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1003
|
+
const wasModified = (item) => {
|
|
1004
|
+
const localUri = item.localUri;
|
|
1005
|
+
let result = fetched.includes(item) || Array.isArray(item.from) && item.from.includes('style');
|
|
1006
|
+
if (localUri) {
|
|
1007
|
+
if (item.etag && !item.content && !item.invalid) {
|
|
1008
|
+
CACHE_ETAG.set(localUri, item.etag);
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
CACHE_ETAG.delete(localUri);
|
|
1012
|
+
}
|
|
1013
|
+
if (!item.content || item.invalid) {
|
|
1014
|
+
CACHE_CONTENT.delete(localUri);
|
|
1015
|
+
}
|
|
1016
|
+
else if (CACHE_CONTENT.get(localUri) !== item.content || !item.inlineContent && !Document.isPath(localUri)) {
|
|
1017
|
+
CACHE_CONTENT.set(localUri, item.content);
|
|
1018
|
+
result = true;
|
|
1019
|
+
}
|
|
1020
|
+
if (!item.format || item.invalid) {
|
|
1021
|
+
CACHE_FORMAT.delete(localUri);
|
|
1022
|
+
}
|
|
1023
|
+
else {
|
|
1024
|
+
const format = item.format.toString();
|
|
1025
|
+
if (CACHE_FORMAT.get(localUri) !== format || !item.inlineContent && !Document.isPath(localUri)) {
|
|
1026
|
+
CACHE_FORMAT.set(localUri, format);
|
|
1027
|
+
result = true;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return result || this.copiedAssets.includes(item) && (!(0, types_1.isEmpty)(item.bundleId) || !(0, types_1.isEmpty)(item.trailingContent));
|
|
1032
|
+
};
|
|
1033
|
+
const js = instance.jsFiles.filter(item => wasModified(item) || !!item.imports);
|
|
1034
|
+
const css = instance.cssFiles.filter(wasModified);
|
|
1035
|
+
const svg = instance.svgFiles.filter(wasModified);
|
|
985
1036
|
if (js.length || css.length || svg.length) {
|
|
986
1037
|
instance.jsFiles = js;
|
|
987
1038
|
instance.cssFiles = css;
|
|
@@ -1550,6 +1601,7 @@ class ChromeDocument extends Document {
|
|
|
1550
1601
|
}
|
|
1551
1602
|
resolveImports(file, code, baseFile) {
|
|
1552
1603
|
var _a;
|
|
1604
|
+
var _b;
|
|
1553
1605
|
if (!Array.isArray(file.imports)) {
|
|
1554
1606
|
return;
|
|
1555
1607
|
}
|
|
@@ -1565,7 +1617,7 @@ class ChromeDocument extends Document {
|
|
|
1565
1617
|
}
|
|
1566
1618
|
const importMap = {};
|
|
1567
1619
|
for (const item of file.imports) {
|
|
1568
|
-
(importMap[
|
|
1620
|
+
(importMap[_b = item.placeholder] || (importMap[_b] = [])).push(item);
|
|
1569
1621
|
}
|
|
1570
1622
|
for (const placeholder in importMap) {
|
|
1571
1623
|
const items = importMap[placeholder];
|
|
@@ -1575,7 +1627,7 @@ class ChromeDocument extends Document {
|
|
|
1575
1627
|
const { uri, original, type, dynamic } = items[i];
|
|
1576
1628
|
let value;
|
|
1577
1629
|
if (type === 'css') {
|
|
1578
|
-
const asset = this.host
|
|
1630
|
+
const asset = (_a = this.host) === null || _a === void 0 ? void 0 : _a.findAsset(uri);
|
|
1579
1631
|
if (asset) {
|
|
1580
1632
|
const [relativeUrl, sameDir] = getSrcURL.call(this, bundleMain || file, asset);
|
|
1581
1633
|
if (relativeUrl) {
|
|
@@ -1603,12 +1655,13 @@ class ChromeDocument extends Document {
|
|
|
1603
1655
|
}
|
|
1604
1656
|
}
|
|
1605
1657
|
replaceContent(source, statement, mimeType) {
|
|
1658
|
+
var _a;
|
|
1606
1659
|
switch (mimeType) {
|
|
1607
1660
|
case 'text/css': {
|
|
1608
1661
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1609
1662
|
if (match) {
|
|
1610
1663
|
const layer = match[1];
|
|
1611
|
-
const supports = match[3]
|
|
1664
|
+
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1612
1665
|
const query = match[4].trim();
|
|
1613
1666
|
if (layer || supports || query) {
|
|
1614
1667
|
const newline = (0, util_1.getNewline)(source);
|
|
@@ -1645,8 +1698,9 @@ class ChromeDocument extends Document {
|
|
|
1645
1698
|
}
|
|
1646
1699
|
}
|
|
1647
1700
|
writeImage(data) {
|
|
1701
|
+
var _a;
|
|
1648
1702
|
const { file, output, command } = data;
|
|
1649
|
-
if (output && command && file.element
|
|
1703
|
+
if (output && command && ((_a = file.element) === null || _a === void 0 ? void 0 : _a.outerXml)) {
|
|
1650
1704
|
const match = REGEXP_SRCSETSIZE.exec(command);
|
|
1651
1705
|
if (match) {
|
|
1652
1706
|
(file.srcSet || (file.srcSet = [])).push(toPosix(data.baseDirectory ? output.substring(data.baseDirectory.length + 1) : output), match[1] + match[2].toLowerCase());
|
|
@@ -1657,12 +1711,13 @@ class ChromeDocument extends Document {
|
|
|
1657
1711
|
return false;
|
|
1658
1712
|
}
|
|
1659
1713
|
cloudInit({ instance }) {
|
|
1714
|
+
var _a, _b;
|
|
1660
1715
|
this._cloudUrlMap = Object.create(null);
|
|
1661
1716
|
this._cloudUploaded = new Set();
|
|
1662
1717
|
this._cloudEndpoint = null;
|
|
1663
1718
|
const htmlFile = this.htmlFile;
|
|
1664
1719
|
if (htmlFile) {
|
|
1665
|
-
const endpoint = instance.getStorage('upload', htmlFile.cloudStorage)
|
|
1720
|
+
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;
|
|
1666
1721
|
if (endpoint) {
|
|
1667
1722
|
this._cloudEndpoint = new RegExp((0, types_1.escapePattern)(toPosix(endpoint)) + '/', 'g');
|
|
1668
1723
|
}
|
|
@@ -1675,6 +1730,7 @@ class ChromeDocument extends Document {
|
|
|
1675
1730
|
return this.editing.includes(file);
|
|
1676
1731
|
}
|
|
1677
1732
|
cloudUpload({ host }, file, url, active) {
|
|
1733
|
+
var _a;
|
|
1678
1734
|
if (active) {
|
|
1679
1735
|
const endpoint = this._cloudEndpoint;
|
|
1680
1736
|
const inlineUrlCloud = file.inlineUrlCloud;
|
|
@@ -1684,7 +1740,7 @@ class ChromeDocument extends Document {
|
|
|
1684
1740
|
const htmlFile = this.htmlFile;
|
|
1685
1741
|
const pattern = new RegExp((0, types_1.escapePattern)(inlineUrlCloud), 'g');
|
|
1686
1742
|
for (const item of this.editing) {
|
|
1687
|
-
if (item.inlineUrlCloudMap
|
|
1743
|
+
if ((_a = item.inlineUrlCloudMap) === null || _a === void 0 ? void 0 : _a[inlineUrlCloud]) {
|
|
1688
1744
|
const source = host.getUTF8String(item);
|
|
1689
1745
|
const output = source.replace(pattern, endpoint && item !== htmlFile && cloudUrl.indexOf('/') !== -1 ? url : cloudUrl);
|
|
1690
1746
|
if (source !== output) {
|
|
@@ -1699,6 +1755,7 @@ class ChromeDocument extends Document {
|
|
|
1699
1755
|
return Promise.resolve(false);
|
|
1700
1756
|
}
|
|
1701
1757
|
async cloudFinalize(state) {
|
|
1758
|
+
var _a;
|
|
1702
1759
|
if (this.aborted) {
|
|
1703
1760
|
return Promise.reject((0, types_1.createAbortError)());
|
|
1704
1761
|
}
|
|
@@ -1747,7 +1804,7 @@ class ChromeDocument extends Document {
|
|
|
1747
1804
|
for (const storage of cloudStorage) {
|
|
1748
1805
|
if (instance.hasCredential('storage', storage)) {
|
|
1749
1806
|
const { service, admin, bucket, upload } = storage;
|
|
1750
|
-
const website = admin
|
|
1807
|
+
const website = (_a = admin === null || admin === void 0 ? void 0 : admin.configBucket) === null || _a === void 0 ? void 0 : _a.website;
|
|
1751
1808
|
if ((0, types_1.isPlainObject)(website) && bucket && upload) {
|
|
1752
1809
|
let filename = joinPath(upload.pathname, upload.filename || path.basename(htmlFile.localUri));
|
|
1753
1810
|
if (website.indexPage === true) {
|
|
@@ -1783,7 +1840,7 @@ class ChromeDocument extends Document {
|
|
|
1783
1840
|
}
|
|
1784
1841
|
const main = watch.main;
|
|
1785
1842
|
let result;
|
|
1786
|
-
if (main
|
|
1843
|
+
if ((main === null || main === void 0 ? void 0 : main.editing) && main.mimeType === 'text/html') {
|
|
1787
1844
|
const inlineUrlCloudMap = main.inlineUrlCloudMap || {};
|
|
1788
1845
|
const using = [];
|
|
1789
1846
|
let found;
|
|
@@ -1820,6 +1877,7 @@ class ChromeDocument extends Document {
|
|
|
1820
1877
|
}
|
|
1821
1878
|
watchModified(watch, assets) {
|
|
1822
1879
|
return (files, errors, status) => {
|
|
1880
|
+
var _a;
|
|
1823
1881
|
if (!watch.server || watch.captured || watch.aborted) {
|
|
1824
1882
|
return;
|
|
1825
1883
|
}
|
|
@@ -1839,7 +1897,7 @@ class ChromeDocument extends Document {
|
|
|
1839
1897
|
search = next.url.search;
|
|
1840
1898
|
}
|
|
1841
1899
|
}
|
|
1842
|
-
search
|
|
1900
|
+
search !== null && search !== void 0 ? search : (search = restoreSearchParams((_a = asset.url) === null || _a === void 0 ? void 0 : _a.search));
|
|
1843
1901
|
status && (status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN));
|
|
1844
1902
|
watch.send(types_1.WATCH_EVENT.MODIFIED, {
|
|
1845
1903
|
action: pathname && watch.hot && !watch.main ? 'hot' : '',
|
|
@@ -1911,11 +1969,13 @@ class ChromeDocument extends Document {
|
|
|
1911
1969
|
}
|
|
1912
1970
|
}
|
|
1913
1971
|
findDataValue(name) {
|
|
1972
|
+
var _a;
|
|
1914
1973
|
if (this.hasEval('template')) {
|
|
1915
|
-
return this.templateMap.data
|
|
1974
|
+
return (_a = this.templateMap.data) === null || _a === void 0 ? void 0 : _a[name];
|
|
1916
1975
|
}
|
|
1917
1976
|
}
|
|
1918
1977
|
setInlinedAttributes({ host, startTime, hashed, contentMap, bufferMap, productionRelease }) {
|
|
1978
|
+
var _a, _b;
|
|
1919
1979
|
const readBase64 = (item, uuid) => {
|
|
1920
1980
|
if (!contentMap[uuid]) {
|
|
1921
1981
|
try {
|
|
@@ -1945,7 +2005,7 @@ class ChromeDocument extends Document {
|
|
|
1945
2005
|
const filename = createHash(host, item, bufferMap);
|
|
1946
2006
|
if (filename) {
|
|
1947
2007
|
for (const hash of this.assets) {
|
|
1948
|
-
const url = inlineUrl ? hash.inlineUrlMap
|
|
2008
|
+
const url = inlineUrl ? (_a = hash.inlineUrlMap) === null || _a === void 0 ? void 0 : _a[inlineUrl] : (_b = hash.inlineUrlCloudMap) === null || _b === void 0 ? void 0 : _b[inlineUrlCloud];
|
|
1949
2009
|
if (url) {
|
|
1950
2010
|
const search = url.indexOf('?');
|
|
1951
2011
|
const index = (search !== -1 ? url.substring(0, search) : url).lastIndexOf('/');
|
|
@@ -1993,10 +2053,10 @@ class ChromeDocument extends Document {
|
|
|
1993
2053
|
const sortNested = (a, b) => {
|
|
1994
2054
|
const { inlineUrlCloud: urlA, inlineUrlCloudMap: mapA } = a;
|
|
1995
2055
|
const { inlineUrlCloud: urlB, inlineUrlCloudMap: mapB } = b;
|
|
1996
|
-
if (urlA && mapB
|
|
2056
|
+
if (urlA && (mapB === null || mapB === void 0 ? void 0 : mapB[urlA])) {
|
|
1997
2057
|
return -1;
|
|
1998
2058
|
}
|
|
1999
|
-
if (urlB && mapA
|
|
2059
|
+
if (urlB && (mapA === null || mapA === void 0 ? void 0 : mapA[urlB])) {
|
|
2000
2060
|
return 1;
|
|
2001
2061
|
}
|
|
2002
2062
|
return 0;
|
|
@@ -2226,7 +2286,7 @@ class ChromeDocument extends Document {
|
|
|
2226
2286
|
}
|
|
2227
2287
|
}
|
|
2228
2288
|
if (uri && !(0, util_1.hasValue)(item.format, 'crossorigin') && item !== htmlFile) {
|
|
2229
|
-
if (cloud
|
|
2289
|
+
if (cloud === null || cloud === void 0 ? void 0 : cloud.getStorage('upload', item.cloudStorage)) {
|
|
2230
2290
|
const inlineUrlCloud = item.inlineUrlCloud || (item.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
2231
2291
|
((_a = htmlFile).inlineUrlCloudMap || (_a.inlineUrlCloudMap = {}))[inlineUrlCloud] = productionRelease ? this.removeServerRoot(uri) : uri;
|
|
2232
2292
|
uri = inlineUrlCloud;
|
|
@@ -2394,7 +2454,7 @@ class ChromeDocument extends Document {
|
|
|
2394
2454
|
batchGroup.push([item]);
|
|
2395
2455
|
break;
|
|
2396
2456
|
default:
|
|
2397
|
-
if (db
|
|
2457
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2398
2458
|
try {
|
|
2399
2459
|
await db.setCredential(item);
|
|
2400
2460
|
const credential = item.credential;
|
|
@@ -2427,6 +2487,7 @@ class ChromeDocument extends Document {
|
|
|
2427
2487
|
}
|
|
2428
2488
|
return this.allSettled(batchGroup.map(batch => {
|
|
2429
2489
|
return new Promise(async (resolve, reject) => {
|
|
2490
|
+
var _a, _b, _c;
|
|
2430
2491
|
const errorRemove = (item, reason) => {
|
|
2431
2492
|
removeElement(item);
|
|
2432
2493
|
reject(reason);
|
|
@@ -2485,7 +2546,7 @@ class ChromeDocument extends Document {
|
|
|
2485
2546
|
}
|
|
2486
2547
|
else {
|
|
2487
2548
|
this.abort(type);
|
|
2488
|
-
errorRemove(current, target ? errorDataSource('Not found', target) : errorDataSource('Not defined - ' + (this.settings.directory
|
|
2549
|
+
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));
|
|
2489
2550
|
return;
|
|
2490
2551
|
}
|
|
2491
2552
|
}
|
|
@@ -2614,7 +2675,7 @@ class ChromeDocument extends Document {
|
|
|
2614
2675
|
if (!getData) {
|
|
2615
2676
|
const { settings, encoding, persist = true } = current;
|
|
2616
2677
|
if (!target) {
|
|
2617
|
-
target = settings && this.settings.export
|
|
2678
|
+
target = settings && ((_b = this.settings.export) === null || _b === void 0 ? void 0 : _b[settings]) || pathname;
|
|
2618
2679
|
}
|
|
2619
2680
|
if (typeof target === 'function') {
|
|
2620
2681
|
getData = target;
|
|
@@ -2674,7 +2735,7 @@ class ChromeDocument extends Document {
|
|
|
2674
2735
|
break;
|
|
2675
2736
|
}
|
|
2676
2737
|
default:
|
|
2677
|
-
if (db
|
|
2738
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2678
2739
|
switch (type) {
|
|
2679
2740
|
case 'mongodb':
|
|
2680
2741
|
for (let j = 0; j < length; ++j) {
|
|
@@ -2898,7 +2959,7 @@ class ChromeDocument extends Document {
|
|
|
2898
2959
|
for (let j = 0, match; j < items.length; ++j) {
|
|
2899
2960
|
const row = items[j];
|
|
2900
2961
|
if ((0, types_1.isPlainObject)(row)) {
|
|
2901
|
-
row.__index__
|
|
2962
|
+
(_c = row.__index__) !== null && _c !== void 0 ? _c : (row.__index__ = j + 1);
|
|
2902
2963
|
}
|
|
2903
2964
|
let segment = template;
|
|
2904
2965
|
while (match = REGEXP_TEMPLATECONDITIONAL.exec(segment)) {
|
|
@@ -3181,6 +3242,7 @@ class ChromeDocument extends Document {
|
|
|
3181
3242
|
}
|
|
3182
3243
|
}
|
|
3183
3244
|
setProductionAttributes({ host, hashed, bufferMap, startTime }) {
|
|
3245
|
+
var _a;
|
|
3184
3246
|
for (const item of this.assets) {
|
|
3185
3247
|
if (isIgnored(item, true)) {
|
|
3186
3248
|
continue;
|
|
@@ -3188,7 +3250,7 @@ class ChromeDocument extends Document {
|
|
|
3188
3250
|
if (!hashed.has(item)) {
|
|
3189
3251
|
createHash(host, item, bufferMap);
|
|
3190
3252
|
}
|
|
3191
|
-
switch (item.element
|
|
3253
|
+
switch ((_a = item.element) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase()) {
|
|
3192
3254
|
case 'style':
|
|
3193
3255
|
if (!item.content) {
|
|
3194
3256
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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.6.
|
|
24
|
-
"@e-mc/core": "^0.6.
|
|
25
|
-
"@e-mc/document": "^0.6.
|
|
26
|
-
"@e-mc/types": "^0.6.
|
|
23
|
+
"@e-mc/cloud": "^0.6.7",
|
|
24
|
+
"@e-mc/core": "^0.6.7",
|
|
25
|
+
"@e-mc/document": "^0.6.7",
|
|
26
|
+
"@e-mc/types": "^0.6.7"
|
|
27
27
|
}
|
|
28
28
|
}
|