@pi-r/chrome 0.5.3 → 0.5.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.d.ts +6 -6
- 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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
|
-
|
|
3
|
-
import type { ChromeDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
-
|
|
5
|
-
declare const Chrome: ChromeDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
-
|
|
1
|
+
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
|
+
|
|
3
|
+
import type { ChromeDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
+
|
|
5
|
+
declare const Chrome: ChromeDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
+
|
|
7
7
|
export = Chrome;
|
package/index.js
CHANGED
|
@@ -13,6 +13,9 @@ const CACHE_DBRESULT = new Map();
|
|
|
13
13
|
const CACHE_LOCALFILE = new Map();
|
|
14
14
|
const CACHE_QUERY = new Map();
|
|
15
15
|
const CACHE_SELECTOR = new Map();
|
|
16
|
+
const CACHE_ETAG = new Map();
|
|
17
|
+
const CACHE_CONTENT = new Map();
|
|
18
|
+
const CACHE_FORMAT = new Map();
|
|
16
19
|
const CACHE_DATASET = {};
|
|
17
20
|
const CACHE_ATRULES = {};
|
|
18
21
|
let CACHE_TOTAL = 0;
|
|
@@ -297,7 +300,7 @@ function hasSameOrigin(value, ...other) {
|
|
|
297
300
|
return false;
|
|
298
301
|
}
|
|
299
302
|
function restoreSearchParams(value, prefix = '__sqd') {
|
|
300
|
-
if (value
|
|
303
|
+
if ((value === null || value === void 0 ? void 0 : value.indexOf(prefix)) !== -1) {
|
|
301
304
|
const params = new URLSearchParams(value);
|
|
302
305
|
params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
|
|
303
306
|
if (value = params.toString()) {
|
|
@@ -385,6 +388,7 @@ function getSrcURL(parent, file) {
|
|
|
385
388
|
return [found ? joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl];
|
|
386
389
|
}
|
|
387
390
|
function transformURL(host, parent, type, source, importFile) {
|
|
391
|
+
var _a;
|
|
388
392
|
const related = [];
|
|
389
393
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
390
394
|
const isHtml = type === 'html';
|
|
@@ -471,12 +475,13 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
471
475
|
}
|
|
472
476
|
}
|
|
473
477
|
const setOutputURL = (value, asset) => {
|
|
478
|
+
var _a;
|
|
474
479
|
if (!value) {
|
|
475
480
|
return;
|
|
476
481
|
}
|
|
477
482
|
if (asset) {
|
|
478
483
|
if (!asset.inlineBase64) {
|
|
479
|
-
if (host.Cloud
|
|
484
|
+
if ((_a = host.Cloud) === null || _a === void 0 ? void 0 : _a.getStorage('upload', asset.cloudStorage)) {
|
|
480
485
|
const inlineUrlCloud = asset.inlineUrlCloud || (asset.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
481
486
|
(parent.inlineUrlCloudMap || (parent.inlineUrlCloudMap = {}))[inlineUrlCloud] = value;
|
|
482
487
|
value = inlineUrlCloud;
|
|
@@ -557,7 +562,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
557
562
|
url = trimQuote(content);
|
|
558
563
|
}
|
|
559
564
|
if (url.startsWith('data:')) {
|
|
560
|
-
const base64 = url.split(',')[1]
|
|
565
|
+
const base64 = (_a = url.split(',')[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
561
566
|
if (base64) {
|
|
562
567
|
for (const item of this.assets) {
|
|
563
568
|
if (item.base64 === base64) {
|
|
@@ -776,7 +781,7 @@ function transformJs(host, file, output) {
|
|
|
776
781
|
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
777
782
|
}
|
|
778
783
|
}
|
|
779
|
-
appending
|
|
784
|
+
appending === null || appending === void 0 ? void 0 : appending.forEach(item => item.order += order);
|
|
780
785
|
}
|
|
781
786
|
if ((0, types_1.isArray)(sourceFiles)) {
|
|
782
787
|
file.sourceFiles = sourceFiles;
|
|
@@ -897,7 +902,7 @@ const isIgnored = (item, exists) => item.invalid || (0, types_1.ignoreFlag)(item
|
|
|
897
902
|
const findFont = (value) => value && (Array.isArray(value) ? value : [value]).find(format => isFont(format));
|
|
898
903
|
const spliceString = (source, startIndex, endIndex, content) => source.substring(0, startIndex) + content + source.substring(endIndex);
|
|
899
904
|
const getEndIndex = (match) => match.index + match[0].length;
|
|
900
|
-
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url
|
|
905
|
+
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) : ''); };
|
|
901
906
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
902
907
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
903
908
|
class ChromeDocument extends Document {
|
|
@@ -971,10 +976,14 @@ class ChromeDocument extends Document {
|
|
|
971
976
|
}
|
|
972
977
|
CACHE_QUERY.clear();
|
|
973
978
|
CACHE_SELECTOR.clear();
|
|
979
|
+
CACHE_ETAG.clear();
|
|
980
|
+
CACHE_CONTENT.clear();
|
|
981
|
+
CACHE_FORMAT.clear();
|
|
974
982
|
}
|
|
975
983
|
return result + (parent && result > 0 ? await super.purgeMemory(typeof parent === 'number' && parent > 0 ? parent : percent, limit, true) : 0);
|
|
976
984
|
}
|
|
977
985
|
static async finalize(instance) {
|
|
986
|
+
var _a;
|
|
978
987
|
if (instance.aborted) {
|
|
979
988
|
return Promise.reject((0, types_1.createAbortError)());
|
|
980
989
|
}
|
|
@@ -986,7 +995,7 @@ class ChromeDocument extends Document {
|
|
|
986
995
|
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
987
996
|
}
|
|
988
997
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
989
|
-
const incremental = htmlFile.incremental
|
|
998
|
+
const incremental = (_a = htmlFile.incremental) !== null && _a !== void 0 ? _a : this.incremental;
|
|
990
999
|
if (incremental === 'etag' || incremental === 'exists') {
|
|
991
1000
|
const fetched = this.fetchedAssets;
|
|
992
1001
|
const isHtmlOnly = () => !fetched.find(item => item !== htmlFile && assets.includes(item));
|
|
@@ -997,12 +1006,27 @@ class ChromeDocument extends Document {
|
|
|
997
1006
|
if (outHtml) {
|
|
998
1007
|
const { etag, initialValue } = htmlFile;
|
|
999
1008
|
let buffer;
|
|
1000
|
-
if (!initialValue || !(etag && initialValue.etag === etag && (buffer = initialValue.buffer)) || fetched.find(item => item.
|
|
1009
|
+
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'))))) {
|
|
1010
|
+
const isValid = (item) => !!item.localUri && item !== htmlFile && !item.invalid;
|
|
1011
|
+
for (const item of fetched) {
|
|
1012
|
+
if (item.etag && !item.content && isValid(item)) {
|
|
1013
|
+
CACHE_ETAG.set(item.localUri, item.etag);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
for (const item of instance.assets) {
|
|
1017
|
+
if (isValid(item)) {
|
|
1018
|
+
if (item.content) {
|
|
1019
|
+
CACHE_CONTENT.set(item.localUri, item.content);
|
|
1020
|
+
}
|
|
1021
|
+
if (item.format) {
|
|
1022
|
+
CACHE_FORMAT.set(item.localUri, item.format.toString());
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1001
1026
|
break;
|
|
1002
1027
|
}
|
|
1003
1028
|
try {
|
|
1004
|
-
|
|
1005
|
-
fs.writeFileSync(localUri, buffer, (0, types_1.getEncoding)(encoding));
|
|
1029
|
+
fs.writeFileSync(htmlFile.localUri, buffer, (0, types_1.getEncoding)(htmlFile.encoding));
|
|
1006
1030
|
htmlFile.buffer = buffer;
|
|
1007
1031
|
htmlFile.sourceUTF8 = undefined;
|
|
1008
1032
|
}
|
|
@@ -1010,12 +1034,39 @@ class ChromeDocument extends Document {
|
|
|
1010
1034
|
break;
|
|
1011
1035
|
}
|
|
1012
1036
|
}
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1037
|
+
const wasModified = (item) => {
|
|
1038
|
+
const localUri = item.localUri;
|
|
1039
|
+
let result = fetched.includes(item) || Array.isArray(item.from) && item.from.includes('style');
|
|
1040
|
+
if (localUri) {
|
|
1041
|
+
if (item.etag && !item.content && !item.invalid) {
|
|
1042
|
+
CACHE_ETAG.set(localUri, item.etag);
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
CACHE_ETAG.delete(localUri);
|
|
1046
|
+
}
|
|
1047
|
+
if (!item.content || item.invalid) {
|
|
1048
|
+
CACHE_CONTENT.delete(localUri);
|
|
1049
|
+
}
|
|
1050
|
+
else if (CACHE_CONTENT.get(localUri) !== item.content || !item.inlineContent && !Document.isPath(localUri)) {
|
|
1051
|
+
CACHE_CONTENT.set(localUri, item.content);
|
|
1052
|
+
result = true;
|
|
1053
|
+
}
|
|
1054
|
+
if (!item.format || item.invalid) {
|
|
1055
|
+
CACHE_FORMAT.delete(localUri);
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
const format = item.format.toString();
|
|
1059
|
+
if (CACHE_FORMAT.get(localUri) !== format || !item.inlineContent && !Document.isPath(localUri)) {
|
|
1060
|
+
CACHE_FORMAT.set(localUri, format);
|
|
1061
|
+
result = true;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
return result || this.copiedAssets.includes(item) && (!(0, types_1.isEmpty)(item.bundleId) || !(0, types_1.isEmpty)(item.trailingContent));
|
|
1066
|
+
};
|
|
1067
|
+
const js = instance.jsFiles.filter(item => wasModified(item) || !!item.imports);
|
|
1068
|
+
const css = instance.cssFiles.filter(wasModified);
|
|
1069
|
+
const svg = instance.svgFiles.filter(wasModified);
|
|
1019
1070
|
if (js.length || css.length || svg.length) {
|
|
1020
1071
|
instance.jsFiles = js;
|
|
1021
1072
|
instance.cssFiles = css;
|
|
@@ -1581,6 +1632,7 @@ class ChromeDocument extends Document {
|
|
|
1581
1632
|
}
|
|
1582
1633
|
resolveImports(file, code, baseFile) {
|
|
1583
1634
|
var _a;
|
|
1635
|
+
var _b;
|
|
1584
1636
|
if (!Array.isArray(file.imports)) {
|
|
1585
1637
|
return;
|
|
1586
1638
|
}
|
|
@@ -1596,7 +1648,7 @@ class ChromeDocument extends Document {
|
|
|
1596
1648
|
}
|
|
1597
1649
|
const importMap = {};
|
|
1598
1650
|
for (const item of file.imports) {
|
|
1599
|
-
(importMap[
|
|
1651
|
+
(importMap[_b = item.placeholder] || (importMap[_b] = [])).push(item);
|
|
1600
1652
|
}
|
|
1601
1653
|
for (const placeholder in importMap) {
|
|
1602
1654
|
const items = importMap[placeholder];
|
|
@@ -1608,7 +1660,7 @@ class ChromeDocument extends Document {
|
|
|
1608
1660
|
const hosted = type === 'css';
|
|
1609
1661
|
let value;
|
|
1610
1662
|
if (hosted) {
|
|
1611
|
-
const asset = this.host
|
|
1663
|
+
const asset = (_a = this.host) === null || _a === void 0 ? void 0 : _a.findAsset(uri);
|
|
1612
1664
|
if (asset) {
|
|
1613
1665
|
const [relativeUrl, sameDir] = getSrcURL.call(this, bundleMain || file, asset);
|
|
1614
1666
|
if (relativeUrl) {
|
|
@@ -1637,12 +1689,13 @@ class ChromeDocument extends Document {
|
|
|
1637
1689
|
}
|
|
1638
1690
|
}
|
|
1639
1691
|
replaceContent(source, statement, mimeType) {
|
|
1692
|
+
var _a;
|
|
1640
1693
|
switch (mimeType) {
|
|
1641
1694
|
case 'text/css': {
|
|
1642
1695
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1643
1696
|
if (match) {
|
|
1644
1697
|
const layer = match[1];
|
|
1645
|
-
const supports = match[3]
|
|
1698
|
+
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1646
1699
|
const query = match[4].trim();
|
|
1647
1700
|
if (layer || supports || query) {
|
|
1648
1701
|
const newline = (0, util_1.getNewline)(source);
|
|
@@ -1679,8 +1732,9 @@ class ChromeDocument extends Document {
|
|
|
1679
1732
|
}
|
|
1680
1733
|
}
|
|
1681
1734
|
writeImage(data) {
|
|
1735
|
+
var _a;
|
|
1682
1736
|
const { file, output, command } = data;
|
|
1683
|
-
if (output && command && file.element
|
|
1737
|
+
if (output && command && ((_a = file.element) === null || _a === void 0 ? void 0 : _a.outerXml)) {
|
|
1684
1738
|
const match = REGEXP_SRCSETSIZE.exec(command);
|
|
1685
1739
|
if (match) {
|
|
1686
1740
|
(file.srcSet || (file.srcSet = [])).push(toPosix(data.baseDirectory ? output.substring(data.baseDirectory.length + 1) : output), match[1] + match[2].toLowerCase());
|
|
@@ -1691,12 +1745,13 @@ class ChromeDocument extends Document {
|
|
|
1691
1745
|
return false;
|
|
1692
1746
|
}
|
|
1693
1747
|
cloudInit({ instance }) {
|
|
1748
|
+
var _a, _b;
|
|
1694
1749
|
this._cloudUrlMap = Object.create(null);
|
|
1695
1750
|
this._cloudUploaded = new Set();
|
|
1696
1751
|
this._cloudEndpoint = null;
|
|
1697
1752
|
const htmlFile = this.htmlFile;
|
|
1698
1753
|
if (htmlFile) {
|
|
1699
|
-
const endpoint = instance.getStorage('upload', htmlFile.cloudStorage)
|
|
1754
|
+
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;
|
|
1700
1755
|
if (endpoint) {
|
|
1701
1756
|
this._cloudEndpoint = new RegExp((0, types_1.escapePattern)(toPosix(endpoint)) + '/', 'g');
|
|
1702
1757
|
}
|
|
@@ -1709,6 +1764,7 @@ class ChromeDocument extends Document {
|
|
|
1709
1764
|
return this.editing.includes(file);
|
|
1710
1765
|
}
|
|
1711
1766
|
cloudUpload({ host }, file, url, active) {
|
|
1767
|
+
var _a;
|
|
1712
1768
|
if (active) {
|
|
1713
1769
|
const endpoint = this._cloudEndpoint;
|
|
1714
1770
|
const inlineUrlCloud = file.inlineUrlCloud;
|
|
@@ -1718,7 +1774,7 @@ class ChromeDocument extends Document {
|
|
|
1718
1774
|
const htmlFile = this.htmlFile;
|
|
1719
1775
|
const pattern = new RegExp((0, types_1.escapePattern)(inlineUrlCloud), 'g');
|
|
1720
1776
|
for (const item of this.editing) {
|
|
1721
|
-
if (item.inlineUrlCloudMap
|
|
1777
|
+
if ((_a = item.inlineUrlCloudMap) === null || _a === void 0 ? void 0 : _a[inlineUrlCloud]) {
|
|
1722
1778
|
const source = host.getUTF8String(item);
|
|
1723
1779
|
const output = source.replace(pattern, endpoint && item !== htmlFile && cloudUrl.indexOf('/') !== -1 ? url : cloudUrl);
|
|
1724
1780
|
if (source !== output) {
|
|
@@ -1733,6 +1789,7 @@ class ChromeDocument extends Document {
|
|
|
1733
1789
|
return Promise.resolve(false);
|
|
1734
1790
|
}
|
|
1735
1791
|
async cloudFinalize(state) {
|
|
1792
|
+
var _a;
|
|
1736
1793
|
if (this.aborted) {
|
|
1737
1794
|
return Promise.reject((0, types_1.createAbortError)());
|
|
1738
1795
|
}
|
|
@@ -1781,7 +1838,7 @@ class ChromeDocument extends Document {
|
|
|
1781
1838
|
for (const storage of cloudStorage) {
|
|
1782
1839
|
if (instance.hasCredential('storage', storage)) {
|
|
1783
1840
|
const { service, admin, bucket, upload } = storage;
|
|
1784
|
-
const website = admin
|
|
1841
|
+
const website = (_a = admin === null || admin === void 0 ? void 0 : admin.configBucket) === null || _a === void 0 ? void 0 : _a.website;
|
|
1785
1842
|
if ((0, types_1.isPlainObject)(website) && bucket && upload) {
|
|
1786
1843
|
let filename = joinPath(upload.pathname, upload.filename || path.basename(htmlFile.localUri));
|
|
1787
1844
|
if (website.indexPage === true) {
|
|
@@ -1817,7 +1874,7 @@ class ChromeDocument extends Document {
|
|
|
1817
1874
|
}
|
|
1818
1875
|
const main = watch.main;
|
|
1819
1876
|
let result;
|
|
1820
|
-
if (main
|
|
1877
|
+
if ((main === null || main === void 0 ? void 0 : main.editing) && main.mimeType === 'text/html') {
|
|
1821
1878
|
const inlineUrlCloudMap = main.inlineUrlCloudMap || {};
|
|
1822
1879
|
const using = [];
|
|
1823
1880
|
let found;
|
|
@@ -1854,6 +1911,7 @@ class ChromeDocument extends Document {
|
|
|
1854
1911
|
}
|
|
1855
1912
|
watchModified(watch, assets) {
|
|
1856
1913
|
return (files, errors, status) => {
|
|
1914
|
+
var _a;
|
|
1857
1915
|
if (!watch.server || watch.captured || watch.aborted) {
|
|
1858
1916
|
return;
|
|
1859
1917
|
}
|
|
@@ -1873,7 +1931,7 @@ class ChromeDocument extends Document {
|
|
|
1873
1931
|
search = next.url.search;
|
|
1874
1932
|
}
|
|
1875
1933
|
}
|
|
1876
|
-
search
|
|
1934
|
+
search !== null && search !== void 0 ? search : (search = restoreSearchParams((_a = asset.url) === null || _a === void 0 ? void 0 : _a.search));
|
|
1877
1935
|
status && (status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN));
|
|
1878
1936
|
watch.send(types_1.WATCH_EVENT.MODIFIED, {
|
|
1879
1937
|
action: pathname && watch.hot && !watch.main ? 'hot' : '',
|
|
@@ -1945,11 +2003,13 @@ class ChromeDocument extends Document {
|
|
|
1945
2003
|
}
|
|
1946
2004
|
}
|
|
1947
2005
|
findDataValue(name) {
|
|
2006
|
+
var _a;
|
|
1948
2007
|
if (this.hasEval('template')) {
|
|
1949
|
-
return this.templateMap.data
|
|
2008
|
+
return (_a = this.templateMap.data) === null || _a === void 0 ? void 0 : _a[name];
|
|
1950
2009
|
}
|
|
1951
2010
|
}
|
|
1952
2011
|
setInlinedAttributes({ host, startTime, hashed, contentMap, bufferMap, productionRelease }) {
|
|
2012
|
+
var _a, _b;
|
|
1953
2013
|
const readBase64 = (item, uuid) => {
|
|
1954
2014
|
if (!contentMap[uuid]) {
|
|
1955
2015
|
try {
|
|
@@ -1979,7 +2039,7 @@ class ChromeDocument extends Document {
|
|
|
1979
2039
|
const filename = hash && createHash(host, item, hash, bufferMap);
|
|
1980
2040
|
if (filename) {
|
|
1981
2041
|
for (const asset of this.assets) {
|
|
1982
|
-
const url = inlineUrl ? asset.inlineUrlMap
|
|
2042
|
+
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];
|
|
1983
2043
|
if (url) {
|
|
1984
2044
|
const search = url.indexOf('?');
|
|
1985
2045
|
const index = (search !== -1 ? url.substring(0, search) : url).lastIndexOf('/');
|
|
@@ -2027,10 +2087,10 @@ class ChromeDocument extends Document {
|
|
|
2027
2087
|
const sortNested = (a, b) => {
|
|
2028
2088
|
const { inlineUrlCloud: urlA, inlineUrlCloudMap: mapA } = a;
|
|
2029
2089
|
const { inlineUrlCloud: urlB, inlineUrlCloudMap: mapB } = b;
|
|
2030
|
-
if (urlA && mapB
|
|
2090
|
+
if (urlA && (mapB === null || mapB === void 0 ? void 0 : mapB[urlA])) {
|
|
2031
2091
|
return -1;
|
|
2032
2092
|
}
|
|
2033
|
-
if (urlB && mapA
|
|
2093
|
+
if (urlB && (mapA === null || mapA === void 0 ? void 0 : mapA[urlB])) {
|
|
2034
2094
|
return 1;
|
|
2035
2095
|
}
|
|
2036
2096
|
return 0;
|
|
@@ -2260,7 +2320,7 @@ class ChromeDocument extends Document {
|
|
|
2260
2320
|
}
|
|
2261
2321
|
}
|
|
2262
2322
|
if (uri && !(0, util_1.hasValue)(item.format, 'crossorigin') && item !== htmlFile) {
|
|
2263
|
-
if (cloud
|
|
2323
|
+
if (cloud === null || cloud === void 0 ? void 0 : cloud.getStorage('upload', item.cloudStorage)) {
|
|
2264
2324
|
const inlineUrlCloud = item.inlineUrlCloud || (item.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
2265
2325
|
((_a = htmlFile).inlineUrlCloudMap || (_a.inlineUrlCloudMap = {}))[inlineUrlCloud] = productionRelease ? this.removeServerRoot(uri) : uri;
|
|
2266
2326
|
uri = inlineUrlCloud;
|
|
@@ -2428,7 +2488,7 @@ class ChromeDocument extends Document {
|
|
|
2428
2488
|
batchGroup.push([item]);
|
|
2429
2489
|
break;
|
|
2430
2490
|
default:
|
|
2431
|
-
if (db
|
|
2491
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2432
2492
|
try {
|
|
2433
2493
|
await db.setCredential(item);
|
|
2434
2494
|
const credential = item.credential;
|
|
@@ -2461,6 +2521,7 @@ class ChromeDocument extends Document {
|
|
|
2461
2521
|
}
|
|
2462
2522
|
return this.allSettled(batchGroup.map(batch => {
|
|
2463
2523
|
return new Promise(async (resolve, reject) => {
|
|
2524
|
+
var _a, _b, _c;
|
|
2464
2525
|
const errorRemove = (item, reason) => {
|
|
2465
2526
|
removeElement(item);
|
|
2466
2527
|
reject(reason);
|
|
@@ -2519,7 +2580,7 @@ class ChromeDocument extends Document {
|
|
|
2519
2580
|
}
|
|
2520
2581
|
else {
|
|
2521
2582
|
this.abort(type);
|
|
2522
|
-
errorRemove(current, target ? errorDataSource('Not found', target) : errorDataSource('Not defined - ' + (this.settings.directory
|
|
2583
|
+
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));
|
|
2523
2584
|
return;
|
|
2524
2585
|
}
|
|
2525
2586
|
}
|
|
@@ -2647,7 +2708,7 @@ class ChromeDocument extends Document {
|
|
|
2647
2708
|
}
|
|
2648
2709
|
if (!getData) {
|
|
2649
2710
|
const { settings, encoding, persist = true } = current;
|
|
2650
|
-
target || (target = settings && this.settings.export
|
|
2711
|
+
target || (target = settings && ((_b = this.settings.export) === null || _b === void 0 ? void 0 : _b[settings]) || pathname);
|
|
2651
2712
|
if (typeof target === 'function') {
|
|
2652
2713
|
getData = target;
|
|
2653
2714
|
hint = target.name;
|
|
@@ -2706,7 +2767,7 @@ class ChromeDocument extends Document {
|
|
|
2706
2767
|
break;
|
|
2707
2768
|
}
|
|
2708
2769
|
default:
|
|
2709
|
-
if (db
|
|
2770
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2710
2771
|
switch (type) {
|
|
2711
2772
|
case 'mongodb':
|
|
2712
2773
|
for (let j = 0; j < length; ++j) {
|
|
@@ -2930,7 +2991,7 @@ class ChromeDocument extends Document {
|
|
|
2930
2991
|
for (let j = 0, match; j < items.length; ++j) {
|
|
2931
2992
|
const row = items[j];
|
|
2932
2993
|
if ((0, types_1.isPlainObject)(row)) {
|
|
2933
|
-
row.__index__
|
|
2994
|
+
(_c = row.__index__) !== null && _c !== void 0 ? _c : (row.__index__ = j + 1);
|
|
2934
2995
|
}
|
|
2935
2996
|
let segment = template;
|
|
2936
2997
|
while (match = REGEXP_TEMPLATECONDITIONAL.exec(segment)) {
|
|
@@ -3216,6 +3277,7 @@ class ChromeDocument extends Document {
|
|
|
3216
3277
|
}
|
|
3217
3278
|
}
|
|
3218
3279
|
setProductionAttributes({ host, hashed, bufferMap, startTime }) {
|
|
3280
|
+
var _a;
|
|
3219
3281
|
for (const item of this.assets) {
|
|
3220
3282
|
if (isIgnored(item, true)) {
|
|
3221
3283
|
continue;
|
|
@@ -3223,7 +3285,7 @@ class ChromeDocument extends Document {
|
|
|
3223
3285
|
if (item.hash && !hashed.has(item)) {
|
|
3224
3286
|
createHash(host, item, item.hash, bufferMap);
|
|
3225
3287
|
}
|
|
3226
|
-
switch (item.element
|
|
3288
|
+
switch ((_a = item.element) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase()) {
|
|
3227
3289
|
case 'style':
|
|
3228
3290
|
if (!item.content) {
|
|
3229
3291
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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.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.10",
|
|
24
|
+
"@e-mc/core": "^0.7.10",
|
|
25
|
+
"@e-mc/document": "^0.7.10",
|
|
26
|
+
"@e-mc/types": "^0.7.10"
|
|
27
27
|
}
|
|
28
28
|
}
|