@pi-r/chrome 0.3.2 → 0.3.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 +52 -37
- 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/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");
|
|
@@ -25,6 +24,14 @@ const [PATTERN_STRING_SOME, PATTERN_STRING_MANY] = (function () {
|
|
|
25
24
|
const pattern = '(?:\\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}`)';
|
|
26
25
|
return [pattern + '*', pattern + '+'];
|
|
27
26
|
})();
|
|
27
|
+
const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function () {
|
|
28
|
+
const parenthesis = '(?:,[^()]+(?=\\))|[^()]|\\([^()]*\\(+|\\([^()]*\\)|(?:\\)[^()]+)?\\)*?)+';
|
|
29
|
+
return [
|
|
30
|
+
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'),
|
|
31
|
+
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
32
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(?:\\(([^)]*)\\)|\\b))?(?:\\s*supports\\((${parenthesis})\\))?(.*?);?$`)
|
|
33
|
+
];
|
|
34
|
+
})();
|
|
28
35
|
const REGEXP_COMMENT = new RegExp(dom_1.DomWriter.PATTERN_COMMENT, 'g');
|
|
29
36
|
const REGEXP_CONTENT = new RegExp(`\\bcontent${PATTERN_STRING_SOME}:${PATTERN_STRING_SOME}(?:"[^"]*"|'[^']*')`, 'gi');
|
|
30
37
|
const REGEXP_STYLE = new RegExp(`(<style${dom_1.DomWriter.PATTERN_TAGOPEN}*>)([\\S\\s]*?)(<\\/style\\s*>)`, 'gi');
|
|
@@ -32,12 +39,10 @@ const REGEXP_VARIABLES = new RegExp(`(\\s*)(--[^\\s:]*)${PATTERN_STRING_SOME}:[^
|
|
|
32
39
|
const REGEXP_FONTFACE = new RegExp(`(\\s*)@font-face${PATTERN_STRING_SOME}{([^}]+)}` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi');
|
|
33
40
|
const REGEXP_FONTFAMILY = new RegExp(`font-family${PATTERN_STRING_SOME}:([^;}]+)`, 'i');
|
|
34
41
|
const REGEXP_KEYFRAMES = new RegExp(`(\\s*)@keyframes${PATTERN_STRING_MANY}([^{]+){`, 'gi');
|
|
35
|
-
const REGEXP_NTHCHILD = new RegExp(`\\(${PATTERN_STRING_SOME}([+-])?(?:(\\d*)[nN]|(0))${PATTERN_STRING_SOME}([+-])?${PATTERN_STRING_SOME}(\\d*)${PATTERN_STRING_SOME}\\)`, 'g');
|
|
36
42
|
const REGEXP_VARIABLES_UNSAFE = new RegExp(`(\\s*)(--[^\\s:]*)\\s*:[^;}]*([;}])` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'g');
|
|
37
43
|
const REGEXP_FONTFACE_UNSAFE = new RegExp(`(\\s*)@font-face\\s*{([^}]+)}` + dom_1.DomWriter.PATTERN_TRAILINGSPACE, 'gi');
|
|
38
44
|
const REGEXP_FONTFAMILY_UNSAFE = /font-family\s*:([^;}]+)/i;
|
|
39
45
|
const REGEXP_KEYFRAMES_UNSAFE = /(\s*)@keyframes\s+([^{]+){/gi;
|
|
40
|
-
const REGEXP_NTHCHILD_UNSAFE = /\(\s*([+-])?(?:(\d*)[nN]|(0))\s*([+-])?\s*(\d*)\s*\)/g;
|
|
41
46
|
const REGEXP_OBJECT_NAME = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
|
|
42
47
|
const REGEXP_OBJECT_SUBSCRIPT = /\[\s*(["'])?(.+?)\1\s*\]/g;
|
|
43
48
|
const REGEXP_TEMPLATE_LEADING = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
|
|
@@ -281,7 +286,7 @@ function hasSameOrigin(value, ...other) {
|
|
|
281
286
|
return false;
|
|
282
287
|
}
|
|
283
288
|
function restoreSearchParams(value, prefix = '__sqd') {
|
|
284
|
-
if (value
|
|
289
|
+
if ((value === null || value === void 0 ? void 0 : value.indexOf(prefix)) !== -1) {
|
|
285
290
|
const params = new URLSearchParams(value);
|
|
286
291
|
params.forEach((_, key) => key.startsWith(prefix) && params.delete(key));
|
|
287
292
|
if (value = params.toString()) {
|
|
@@ -373,6 +378,7 @@ function getSrcURL(parent, file) {
|
|
|
373
378
|
return [found ? joinPath('../'.repeat(prefix.length), suffix.join('/'), file.filename) : '../'.repeat(prefix.length) + relativeUrl];
|
|
374
379
|
}
|
|
375
380
|
function transformURL(host, parent, type, source, importFile) {
|
|
381
|
+
var _a;
|
|
376
382
|
const related = [];
|
|
377
383
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
378
384
|
const isHtml = type === 'html';
|
|
@@ -438,12 +444,13 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
438
444
|
}
|
|
439
445
|
}
|
|
440
446
|
const setOutputURL = (value, asset) => {
|
|
447
|
+
var _a;
|
|
441
448
|
if (!value) {
|
|
442
449
|
return;
|
|
443
450
|
}
|
|
444
451
|
if (asset) {
|
|
445
452
|
if (!asset.inlineBase64) {
|
|
446
|
-
if (host.Cloud
|
|
453
|
+
if ((_a = host.Cloud) === null || _a === void 0 ? void 0 : _a.getStorage('upload', asset.cloudStorage)) {
|
|
447
454
|
const inlineUrlCloud = asset.inlineUrlCloud || (asset.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
448
455
|
(parent.inlineUrlCloudMap || (parent.inlineUrlCloudMap = {}))[inlineUrlCloud] = value;
|
|
449
456
|
value = inlineUrlCloud;
|
|
@@ -524,7 +531,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
524
531
|
url = trimQuote(content);
|
|
525
532
|
}
|
|
526
533
|
if (url.startsWith('data:')) {
|
|
527
|
-
const base64 = url.split(',')[1]
|
|
534
|
+
const base64 = (_a = url.split(',')[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
528
535
|
if (base64) {
|
|
529
536
|
for (const item of this.assets) {
|
|
530
537
|
if (item.base64 === base64) {
|
|
@@ -743,7 +750,7 @@ function transformJs(host, file, output) {
|
|
|
743
750
|
this.writeFail(["Unable to write file", path.basename(chunkUri)], err, 32);
|
|
744
751
|
}
|
|
745
752
|
}
|
|
746
|
-
appending
|
|
753
|
+
appending === null || appending === void 0 ? void 0 : appending.forEach(item => item.order += order);
|
|
747
754
|
}
|
|
748
755
|
if ((0, types_1.isArray)(sourceFiles)) {
|
|
749
756
|
file.sourceFiles = sourceFiles;
|
|
@@ -862,7 +869,7 @@ const isIgnored = (item, exists) => item.invalid || (0, types_1.ignoreFlag)(item
|
|
|
862
869
|
const findFont = (value) => value && (Array.isArray(value) ? value : [value]).find(format => isFont(format));
|
|
863
870
|
const spliceString = (source, startIndex, endIndex, content) => source.substring(0, startIndex) + content + source.substring(endIndex);
|
|
864
871
|
const getEndIndex = (match) => match.index + match[0].length;
|
|
865
|
-
const getRelativeURL = (file) => joinPath(file.moveTo, file.pathname, file.inlineFilename || file.filename) + (!file.static ? restoreSearchParams(file.url
|
|
872
|
+
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) : ''); };
|
|
866
873
|
const errorHtml = ({ tagName, tagIndex = -1 }) => (0, types_1.errorMessage)('html', 'Location did not resolve', tagName.toLowerCase() + (tagIndex >= 0 ? ': ' + tagIndex : ''));
|
|
867
874
|
const errorDataSource = (value, hint) => (0, types_1.errorMessage)('data-source', value, hint);
|
|
868
875
|
class ChromeDocument extends Document {
|
|
@@ -936,6 +943,7 @@ class ChromeDocument extends Document {
|
|
|
936
943
|
return result + (parent && result > 0 ? await super.purgeMemory(typeof parent === 'number' && parent > 0 ? parent : percent, limit, true) : 0);
|
|
937
944
|
}
|
|
938
945
|
static async finalize(instance) {
|
|
946
|
+
var _a;
|
|
939
947
|
if (instance.aborted) {
|
|
940
948
|
return Promise.reject((0, types_1.createAbortError)());
|
|
941
949
|
}
|
|
@@ -947,7 +955,7 @@ class ChromeDocument extends Document {
|
|
|
947
955
|
db.writeTimeElapsed('DB', ["Transactions were committed", db.moduleName], processing.startTime, { ...Document.LOG_STYLE_SUCCESS, type: 65536 });
|
|
948
956
|
}
|
|
949
957
|
if (instance.dataSource.length === 0 && outHtml) {
|
|
950
|
-
const incremental = htmlFile.incremental
|
|
958
|
+
const incremental = (_a = htmlFile.incremental) !== null && _a !== void 0 ? _a : this.incremental;
|
|
951
959
|
if (incremental === 'etag' || incremental === 'exists') {
|
|
952
960
|
const fetched = this.fetchedAssets;
|
|
953
961
|
const isHtmlOnly = () => !fetched.find(item => item !== htmlFile && assets.includes(item));
|
|
@@ -1545,6 +1553,7 @@ class ChromeDocument extends Document {
|
|
|
1545
1553
|
}
|
|
1546
1554
|
resolveImports(file, code, baseFile) {
|
|
1547
1555
|
var _a;
|
|
1556
|
+
var _b;
|
|
1548
1557
|
if (!Array.isArray(file.imports)) {
|
|
1549
1558
|
return;
|
|
1550
1559
|
}
|
|
@@ -1560,7 +1569,7 @@ class ChromeDocument extends Document {
|
|
|
1560
1569
|
}
|
|
1561
1570
|
const importMap = {};
|
|
1562
1571
|
for (const item of file.imports) {
|
|
1563
|
-
(importMap[
|
|
1572
|
+
(importMap[_b = item.placeholder] || (importMap[_b] = [])).push(item);
|
|
1564
1573
|
}
|
|
1565
1574
|
for (const placeholder in importMap) {
|
|
1566
1575
|
const items = importMap[placeholder];
|
|
@@ -1570,7 +1579,7 @@ class ChromeDocument extends Document {
|
|
|
1570
1579
|
const { uri, original, type, dynamic } = items[i];
|
|
1571
1580
|
let value;
|
|
1572
1581
|
if (type === 'css') {
|
|
1573
|
-
const asset = this.host
|
|
1582
|
+
const asset = (_a = this.host) === null || _a === void 0 ? void 0 : _a.findAsset(uri);
|
|
1574
1583
|
if (asset) {
|
|
1575
1584
|
const [relativeUrl, sameDir] = getSrcURL.call(this, bundleMain || file, asset);
|
|
1576
1585
|
if (relativeUrl) {
|
|
@@ -1598,16 +1607,17 @@ class ChromeDocument extends Document {
|
|
|
1598
1607
|
}
|
|
1599
1608
|
}
|
|
1600
1609
|
replaceContent(source, statement, mimeType) {
|
|
1610
|
+
var _a;
|
|
1601
1611
|
switch (mimeType) {
|
|
1602
1612
|
case 'text/css': {
|
|
1603
|
-
const match =
|
|
1613
|
+
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1604
1614
|
if (match) {
|
|
1605
1615
|
const layer = match[1];
|
|
1606
|
-
const supports = match[3]
|
|
1616
|
+
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1607
1617
|
const query = match[4].trim();
|
|
1608
1618
|
if (layer || supports || query) {
|
|
1609
1619
|
const newline = (0, util_1.getNewline)(source);
|
|
1610
|
-
let result = supports ? `@supports (${
|
|
1620
|
+
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
1611
1621
|
if (query) {
|
|
1612
1622
|
result += `@media ${query} {` + newline;
|
|
1613
1623
|
}
|
|
@@ -1640,8 +1650,9 @@ class ChromeDocument extends Document {
|
|
|
1640
1650
|
}
|
|
1641
1651
|
}
|
|
1642
1652
|
writeImage(data) {
|
|
1653
|
+
var _a;
|
|
1643
1654
|
const { file, output, command } = data;
|
|
1644
|
-
if (output && command && file.element
|
|
1655
|
+
if (output && command && ((_a = file.element) === null || _a === void 0 ? void 0 : _a.outerXml)) {
|
|
1645
1656
|
const match = REGEXP_SRCSETSIZE.exec(command);
|
|
1646
1657
|
if (match) {
|
|
1647
1658
|
(file.srcSet || (file.srcSet = [])).push(toPosix(data.baseDirectory ? output.substring(data.baseDirectory.length + 1) : output), match[1] + match[2].toLowerCase());
|
|
@@ -1652,12 +1663,13 @@ class ChromeDocument extends Document {
|
|
|
1652
1663
|
return false;
|
|
1653
1664
|
}
|
|
1654
1665
|
cloudInit({ instance }) {
|
|
1666
|
+
var _a, _b;
|
|
1655
1667
|
this._cloudUrlMap = Object.create(null);
|
|
1656
1668
|
this._cloudUploaded = new Set();
|
|
1657
1669
|
this._cloudEndpoint = null;
|
|
1658
1670
|
const htmlFile = this.htmlFile;
|
|
1659
1671
|
if (htmlFile) {
|
|
1660
|
-
const endpoint = instance.getStorage('upload', htmlFile.cloudStorage)
|
|
1672
|
+
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;
|
|
1661
1673
|
if (endpoint) {
|
|
1662
1674
|
this._cloudEndpoint = new RegExp((0, types_1.escapePattern)(toPosix(endpoint)) + '/', 'g');
|
|
1663
1675
|
}
|
|
@@ -1670,6 +1682,7 @@ class ChromeDocument extends Document {
|
|
|
1670
1682
|
return this.editing.includes(file);
|
|
1671
1683
|
}
|
|
1672
1684
|
cloudUpload({ host }, file, url, active) {
|
|
1685
|
+
var _a;
|
|
1673
1686
|
if (active) {
|
|
1674
1687
|
const endpoint = this._cloudEndpoint;
|
|
1675
1688
|
const inlineUrlCloud = file.inlineUrlCloud;
|
|
@@ -1679,7 +1692,7 @@ class ChromeDocument extends Document {
|
|
|
1679
1692
|
const htmlFile = this.htmlFile;
|
|
1680
1693
|
const pattern = new RegExp((0, types_1.escapePattern)(inlineUrlCloud), 'g');
|
|
1681
1694
|
for (const item of this.editing) {
|
|
1682
|
-
if (item.inlineUrlCloudMap
|
|
1695
|
+
if ((_a = item.inlineUrlCloudMap) === null || _a === void 0 ? void 0 : _a[inlineUrlCloud]) {
|
|
1683
1696
|
const source = host.getUTF8String(item);
|
|
1684
1697
|
const output = source.replace(pattern, endpoint && item !== htmlFile && cloudUrl.indexOf('/') !== -1 ? url : cloudUrl);
|
|
1685
1698
|
if (source !== output) {
|
|
@@ -1694,6 +1707,7 @@ class ChromeDocument extends Document {
|
|
|
1694
1707
|
return Promise.resolve(false);
|
|
1695
1708
|
}
|
|
1696
1709
|
async cloudFinalize(state) {
|
|
1710
|
+
var _a;
|
|
1697
1711
|
if (this.aborted) {
|
|
1698
1712
|
return Promise.reject((0, types_1.createAbortError)());
|
|
1699
1713
|
}
|
|
@@ -1742,7 +1756,7 @@ class ChromeDocument extends Document {
|
|
|
1742
1756
|
for (const storage of cloudStorage) {
|
|
1743
1757
|
if (instance.hasCredential('storage', storage)) {
|
|
1744
1758
|
const { service, admin, bucket, upload } = storage;
|
|
1745
|
-
const website = admin
|
|
1759
|
+
const website = (_a = admin === null || admin === void 0 ? void 0 : admin.configBucket) === null || _a === void 0 ? void 0 : _a.website;
|
|
1746
1760
|
if ((0, types_1.isPlainObject)(website) && bucket && upload) {
|
|
1747
1761
|
let filename = joinPath(upload.pathname, upload.filename || path.basename(htmlFile.localUri));
|
|
1748
1762
|
if (website.indexPage === true) {
|
|
@@ -1778,7 +1792,7 @@ class ChromeDocument extends Document {
|
|
|
1778
1792
|
}
|
|
1779
1793
|
const main = watch.main;
|
|
1780
1794
|
let result;
|
|
1781
|
-
if (main
|
|
1795
|
+
if ((main === null || main === void 0 ? void 0 : main.editing) && main.mimeType === 'text/html') {
|
|
1782
1796
|
const inlineUrlCloudMap = main.inlineUrlCloudMap || {};
|
|
1783
1797
|
const using = [];
|
|
1784
1798
|
let found;
|
|
@@ -1815,6 +1829,7 @@ class ChromeDocument extends Document {
|
|
|
1815
1829
|
}
|
|
1816
1830
|
watchModified(watch, assets) {
|
|
1817
1831
|
return (files, errors, status) => {
|
|
1832
|
+
var _a;
|
|
1818
1833
|
if (!watch.server || watch.captured || watch.aborted) {
|
|
1819
1834
|
return;
|
|
1820
1835
|
}
|
|
@@ -1834,7 +1849,7 @@ class ChromeDocument extends Document {
|
|
|
1834
1849
|
search = next.url.search;
|
|
1835
1850
|
}
|
|
1836
1851
|
}
|
|
1837
|
-
search
|
|
1852
|
+
search !== null && search !== void 0 ? search : (search = restoreSearchParams((_a = asset.url) === null || _a === void 0 ? void 0 : _a.search));
|
|
1838
1853
|
status && (status = status.filter(item => item.type >= types_1.STATUS_TYPE.FATAL && item.type <= types_1.STATUS_TYPE.WARN));
|
|
1839
1854
|
watch.send(types_1.WATCH_EVENT.MODIFIED, {
|
|
1840
1855
|
action: pathname && watch.hot && !watch.main ? 'hot' : '',
|
|
@@ -1906,11 +1921,13 @@ class ChromeDocument extends Document {
|
|
|
1906
1921
|
}
|
|
1907
1922
|
}
|
|
1908
1923
|
findDataValue(name) {
|
|
1924
|
+
var _a;
|
|
1909
1925
|
if (this.hasEval('template')) {
|
|
1910
|
-
return this.templateMap.data
|
|
1926
|
+
return (_a = this.templateMap.data) === null || _a === void 0 ? void 0 : _a[name];
|
|
1911
1927
|
}
|
|
1912
1928
|
}
|
|
1913
1929
|
setInlinedAttributes({ host, startTime, hashed, contentMap, bufferMap, productionRelease }) {
|
|
1930
|
+
var _a, _b;
|
|
1914
1931
|
const readBase64 = (item, uuid) => {
|
|
1915
1932
|
if (!contentMap[uuid]) {
|
|
1916
1933
|
try {
|
|
@@ -1940,7 +1957,7 @@ class ChromeDocument extends Document {
|
|
|
1940
1957
|
const filename = createHash(host, item, bufferMap);
|
|
1941
1958
|
if (filename) {
|
|
1942
1959
|
for (const hash of this.assets) {
|
|
1943
|
-
const url = inlineUrl ? hash.inlineUrlMap
|
|
1960
|
+
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];
|
|
1944
1961
|
if (url) {
|
|
1945
1962
|
const search = url.indexOf('?');
|
|
1946
1963
|
const index = (search !== -1 ? url.substring(0, search) : url).lastIndexOf('/');
|
|
@@ -1988,10 +2005,10 @@ class ChromeDocument extends Document {
|
|
|
1988
2005
|
const sortNested = (a, b) => {
|
|
1989
2006
|
const { inlineUrlCloud: urlA, inlineUrlCloudMap: mapA } = a;
|
|
1990
2007
|
const { inlineUrlCloud: urlB, inlineUrlCloudMap: mapB } = b;
|
|
1991
|
-
if (urlA && mapB
|
|
2008
|
+
if (urlA && (mapB === null || mapB === void 0 ? void 0 : mapB[urlA])) {
|
|
1992
2009
|
return -1;
|
|
1993
2010
|
}
|
|
1994
|
-
if (urlB && mapA
|
|
2011
|
+
if (urlB && (mapA === null || mapA === void 0 ? void 0 : mapA[urlB])) {
|
|
1995
2012
|
return 1;
|
|
1996
2013
|
}
|
|
1997
2014
|
return 0;
|
|
@@ -2221,7 +2238,7 @@ class ChromeDocument extends Document {
|
|
|
2221
2238
|
}
|
|
2222
2239
|
}
|
|
2223
2240
|
if (uri && !(0, util_1.hasValue)(item.format, 'crossorigin') && item !== htmlFile) {
|
|
2224
|
-
if (cloud
|
|
2241
|
+
if (cloud === null || cloud === void 0 ? void 0 : cloud.getStorage('upload', item.cloudStorage)) {
|
|
2225
2242
|
const inlineUrlCloud = item.inlineUrlCloud || (item.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
2226
2243
|
((_a = htmlFile).inlineUrlCloudMap || (_a.inlineUrlCloudMap = {}))[inlineUrlCloud] = productionRelease ? this.removeServerRoot(uri) : uri;
|
|
2227
2244
|
uri = inlineUrlCloud;
|
|
@@ -2389,7 +2406,7 @@ class ChromeDocument extends Document {
|
|
|
2389
2406
|
batchGroup.push([item]);
|
|
2390
2407
|
break;
|
|
2391
2408
|
default:
|
|
2392
|
-
if (db
|
|
2409
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2393
2410
|
try {
|
|
2394
2411
|
await db.setCredential(item);
|
|
2395
2412
|
const credential = item.credential;
|
|
@@ -2422,6 +2439,7 @@ class ChromeDocument extends Document {
|
|
|
2422
2439
|
}
|
|
2423
2440
|
return this.allSettled(batchGroup.map(batch => {
|
|
2424
2441
|
return new Promise(async (resolve, reject) => {
|
|
2442
|
+
var _a, _b, _c;
|
|
2425
2443
|
const errorRemove = (item, reason) => {
|
|
2426
2444
|
removeElement(item);
|
|
2427
2445
|
reject(reason);
|
|
@@ -2480,7 +2498,7 @@ class ChromeDocument extends Document {
|
|
|
2480
2498
|
}
|
|
2481
2499
|
else {
|
|
2482
2500
|
this.abort(type);
|
|
2483
|
-
errorRemove(current, target ? errorDataSource('Not found', target) : errorDataSource('Not defined - ' + (this.settings.directory
|
|
2501
|
+
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));
|
|
2484
2502
|
return;
|
|
2485
2503
|
}
|
|
2486
2504
|
}
|
|
@@ -2609,7 +2627,7 @@ class ChromeDocument extends Document {
|
|
|
2609
2627
|
if (!getData) {
|
|
2610
2628
|
const { settings, encoding, persist = true } = current;
|
|
2611
2629
|
if (!target) {
|
|
2612
|
-
target = settings && this.settings.export
|
|
2630
|
+
target = settings && ((_b = this.settings.export) === null || _b === void 0 ? void 0 : _b[settings]) || pathname;
|
|
2613
2631
|
}
|
|
2614
2632
|
if (typeof target === 'function') {
|
|
2615
2633
|
getData = target;
|
|
@@ -2669,7 +2687,7 @@ class ChromeDocument extends Document {
|
|
|
2669
2687
|
break;
|
|
2670
2688
|
}
|
|
2671
2689
|
default:
|
|
2672
|
-
if (db
|
|
2690
|
+
if (db === null || db === void 0 ? void 0 : db.hasSource(type)) {
|
|
2673
2691
|
switch (type) {
|
|
2674
2692
|
case 'mongodb':
|
|
2675
2693
|
for (let j = 0; j < length; ++j) {
|
|
@@ -2893,7 +2911,7 @@ class ChromeDocument extends Document {
|
|
|
2893
2911
|
for (let j = 0, match; j < items.length; ++j) {
|
|
2894
2912
|
const row = items[j];
|
|
2895
2913
|
if ((0, types_1.isPlainObject)(row)) {
|
|
2896
|
-
row.__index__
|
|
2914
|
+
(_c = row.__index__) !== null && _c !== void 0 ? _c : (row.__index__ = j + 1);
|
|
2897
2915
|
}
|
|
2898
2916
|
let segment = template;
|
|
2899
2917
|
while (match = REGEXP_TEMPLATECONDITIONAL.exec(segment)) {
|
|
@@ -3176,6 +3194,7 @@ class ChromeDocument extends Document {
|
|
|
3176
3194
|
}
|
|
3177
3195
|
}
|
|
3178
3196
|
setProductionAttributes({ host, hashed, bufferMap, startTime }) {
|
|
3197
|
+
var _a;
|
|
3179
3198
|
for (const item of this.assets) {
|
|
3180
3199
|
if (isIgnored(item, true)) {
|
|
3181
3200
|
continue;
|
|
@@ -3183,7 +3202,7 @@ class ChromeDocument extends Document {
|
|
|
3183
3202
|
if (!hashed.has(item)) {
|
|
3184
3203
|
createHash(host, item, bufferMap);
|
|
3185
3204
|
}
|
|
3186
|
-
switch (item.element
|
|
3205
|
+
switch ((_a = item.element) === null || _a === void 0 ? void 0 : _a.tagName.toLowerCase()) {
|
|
3187
3206
|
case 'style':
|
|
3188
3207
|
if (!item.content) {
|
|
3189
3208
|
break;
|
|
@@ -3235,7 +3254,7 @@ class ChromeDocument extends Document {
|
|
|
3235
3254
|
const parseSelector = (value) => {
|
|
3236
3255
|
const items = [];
|
|
3237
3256
|
const revised = value.replace(useUnsafeCssReplace ? REGEXP_NTHCHILD_UNSAFE : REGEXP_NTHCHILD, (...capture) => {
|
|
3238
|
-
return '`%' + (items.push('\\(' + getStringSome() + (capture[1] === '-' ? '\\x2d' : '\\x2b?') + (capture[2] || '[01]?') + (capture[3] === '0' ? !capture[1] && !capture[2] && !capture[4] && !capture[5] ? '[+-]?0[nN]?' : '0' : '[nN]') + getStringSome() + (capture[5] ? (capture[4] === '-' ? '\\x2d' : '\\x2b') + getStringSome() + capture[5] : `(?:[+-]${getStringSome()}0)?`) + getStringSome() + '\\)') - 1) + '`';
|
|
3257
|
+
return '`%' + (items.push('\\(' + getStringSome() + (capture[1] === '-' ? '\\x2d' : '\\x2b?') + (capture[2] || '[01]?') + (capture[3] === '0' ? !capture[1] && !capture[2] && !capture[4] && !capture[5] ? '[+-]?0[nN]?' : '0' : '[nN]') + getStringSome() + (capture[5] ? (capture[4] === '-' ? '\\x2d' : '\\x2b') + getStringSome() + capture[5] : `(?:[+-]${getStringSome()}0)?`) + (capture[6] ? getStringMany() + '[oO][fF]' + getStringMany() + capture[6].trim() : '') + getStringSome() + '\\)') - 1) + '`';
|
|
3239
3258
|
});
|
|
3240
3259
|
let selector = '';
|
|
3241
3260
|
for (let i = 0, length = revised.length, casing = false, attr = false, quote = false; i < length; i++) {
|
|
@@ -3568,9 +3587,5 @@ class ChromeDocument extends Document {
|
|
|
3568
3587
|
}
|
|
3569
3588
|
ChromeDocument.INTERNAL_ASSIGNUUID = '__assign__';
|
|
3570
3589
|
ChromeDocument.INTERNAL_SERVERROOT = '__serverroot__';
|
|
3571
|
-
exports.default = ChromeDocument;
|
|
3572
3590
|
|
|
3573
|
-
|
|
3574
|
-
module.exports = exports.default;
|
|
3575
|
-
module.exports.default = exports.default;
|
|
3576
|
-
}
|
|
3591
|
+
module.exports = ChromeDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.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.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.3",
|
|
24
|
+
"@e-mc/core": "^0.6.3",
|
|
25
|
+
"@e-mc/document": "^0.6.3",
|
|
26
|
+
"@e-mc/types": "^0.6.3"
|
|
27
27
|
}
|
|
28
28
|
}
|