@pi-r/chrome 0.8.4 → 0.8.6
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/index.js +29 -28
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -28,11 +28,11 @@ const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function (
|
|
|
28
28
|
return [
|
|
29
29
|
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'),
|
|
30
30
|
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
31
|
-
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(
|
|
31
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(\\([^)]*\\))?)?(?:\\s*supports\\((${parenthesis})\\))?(.*)$`, 'si')
|
|
32
32
|
];
|
|
33
33
|
})();
|
|
34
34
|
const REGEXP_SRCSETSIZE = /~\s*([\d.]+)\s*([wx])/i;
|
|
35
|
-
const REGEXP_TEMPLATECONDITIONAL = /(\n\s+)?\{\{if\s+((?:[^}]|}(?!}))+?)\}\}(\s*)(
|
|
35
|
+
const REGEXP_TEMPLATECONDITIONAL = /(\n\s+)?\{\{if\s+((?:[^}]|}(?!}))+?)\}\}(\s*)([\S\s]*?)(?:\s*\{\{else(?:\s+if\s+((?:[^}]|}(?!}))+?))?\}\}(\s*)([\S\s]*?)\s*)?\s*\{\{end\}\}/g;
|
|
36
36
|
const REGEXP_TEMPLATECOMPARISON = /\s*\(\s*(?:\b(eq|ne|lt|le|gt|ge)\s+)?("[^"]+"|'[^']+'|[^\s)]+)(?:\s+("[^"]+"|'[^']+'|[^\s)]+))?\s*\)/g;
|
|
37
37
|
const REGEXP_TEMPLATEMATCH = new RegExp(`^(?:\\b(and|or|not)\\s+)?((?:${REGEXP_TEMPLATECOMPARISON.source})+)|(!|not\\s+)?([^\\s][\\S\\s]*)$`);
|
|
38
38
|
const REGEXP_IMPORTMODULE = /(?:(?:^|[\n;]+)\s*import\s+(?:("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')|.+?from\s+("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')(?:[ \t]+(?:assert|with)[ \t]+\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\})?)|\bimport\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*(?:,\s*\{((?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|`(?:[^`]|(?<=\\)`)+`|{[^{]*{|{[^}]*}|}[^}]*}|[^"'`]+)+)\}\s*)?\))/gd;
|
|
@@ -54,9 +54,9 @@ const REGEXP_OBJECT_NAME = /([^[.\s]+)((?:\s*\[[^\]]+\]\s*)+)?\s*\.?\s*/g;
|
|
|
54
54
|
const REGEXP_OBJECT_SUBSCRIPT = /\[\s*(["'])?(.+?)\1\s*\]/g;
|
|
55
55
|
const REGEXP_TEMPLATE_LEADING = /\s*\{\{- \s*((?:[^}]|}(?!}))+?)\}\}/g;
|
|
56
56
|
const REGEXP_TEMPLATE_TRAILING = /\{\{((?:[^}]|}(?!}))+?)\s*? -\}\}\s*/g;
|
|
57
|
-
const REGEXP_URL = /(?:\
|
|
57
|
+
const REGEXP_URL = /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi;
|
|
58
58
|
const REGEXP_URL_JS = /\bimport\(/g;
|
|
59
|
-
const REGEXP_URL_SVG = /(?:\
|
|
59
|
+
const REGEXP_URL_SVG = /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi;
|
|
60
60
|
const REGEXP_IMAGESET = /\b(?:-webkit-)?image-set\(/gi;
|
|
61
61
|
const REGEXP_IMAGESET_URL = /(?:^|[^(])\s*("(\s*[^)][^"]*)"|'(\s*[^)][^"]*)')\s*(?:,|$|[^)][^,]*,?)/gd;
|
|
62
62
|
const REGEXP_SANITIZEALL = new RegExp(`(?:\\s+|\\b)data-(?:pathname|filename|intl-locales|(?:use|exclude)-[^=\\s]+)\\s*${dom_1.DomWriter.PATTERN_ATTRVALUE}(?=(?:[^"<]+"[^"]*"|[^'<]+'[^']*')*[^<>]*>)`, 'g');
|
|
@@ -189,10 +189,6 @@ function parseArg(data, value) {
|
|
|
189
189
|
if (!isNaN(n)) {
|
|
190
190
|
return n;
|
|
191
191
|
}
|
|
192
|
-
const match = /^(["'])(.*)\1$/s.exec(value);
|
|
193
|
-
if (match) {
|
|
194
|
-
return match[2];
|
|
195
|
-
}
|
|
196
192
|
return getObjectValue(data, value);
|
|
197
193
|
}
|
|
198
194
|
function hasCondition(data, condition) {
|
|
@@ -209,18 +205,18 @@ function hasCondition(data, condition) {
|
|
|
209
205
|
if (items.length > 0 && !isSpace(match[0][0])) {
|
|
210
206
|
return false;
|
|
211
207
|
}
|
|
212
|
-
items.push([match[1], trimQuote(match[2]), trimQuote(match[3])]);
|
|
208
|
+
items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
|
|
213
209
|
}
|
|
214
210
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
215
|
-
|
|
211
|
+
const length = items.length;
|
|
212
|
+
if (length > 1 && !join) {
|
|
216
213
|
return false;
|
|
217
214
|
}
|
|
218
|
-
for (
|
|
219
|
-
const arg1 =
|
|
220
|
-
|
|
221
|
-
let valid;
|
|
215
|
+
for (let i = 0; i < length; ++i) {
|
|
216
|
+
const [cmp, arg1, arg2] = items[i];
|
|
217
|
+
let valid = false;
|
|
222
218
|
if (arg2) {
|
|
223
|
-
switch (
|
|
219
|
+
switch (cmp) {
|
|
224
220
|
case 'eq':
|
|
225
221
|
valid = parseArg(data, arg1) == parseArg(data, arg2);
|
|
226
222
|
break;
|
|
@@ -243,7 +239,7 @@ function hasCondition(data, condition) {
|
|
|
243
239
|
return false;
|
|
244
240
|
}
|
|
245
241
|
}
|
|
246
|
-
else if (
|
|
242
|
+
else if (cmp) {
|
|
247
243
|
return false;
|
|
248
244
|
}
|
|
249
245
|
else {
|
|
@@ -590,7 +586,7 @@ function transformURL(instance, host, parent, type, source, importFile) {
|
|
|
590
586
|
if (!isText) {
|
|
591
587
|
let j = startIndex;
|
|
592
588
|
while (isSpace(source[--j])) { }
|
|
593
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
589
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
594
590
|
}
|
|
595
591
|
else {
|
|
596
592
|
k = startIndex;
|
|
@@ -1822,7 +1818,7 @@ class ChromeDocument extends Document {
|
|
|
1822
1818
|
if (match) {
|
|
1823
1819
|
const layer = match[1];
|
|
1824
1820
|
const supports = match[3]?.trim();
|
|
1825
|
-
const query = match[4].trim();
|
|
1821
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1826
1822
|
if (layer || supports || query) {
|
|
1827
1823
|
const newline = (0, util_1.getNewline)(source);
|
|
1828
1824
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1830,8 +1826,8 @@ class ChromeDocument extends Document {
|
|
|
1830
1826
|
result += `@media ${query} {` + newline;
|
|
1831
1827
|
}
|
|
1832
1828
|
if (layer) {
|
|
1833
|
-
|
|
1834
|
-
result += '@layer ' + (name
|
|
1829
|
+
const name = match[2]?.replace(/\s+/g, '');
|
|
1830
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1835
1831
|
}
|
|
1836
1832
|
else if (query) {
|
|
1837
1833
|
result += source + newline + '}';
|
|
@@ -2915,13 +2911,15 @@ class ChromeDocument extends Document {
|
|
|
2915
2911
|
case 'mongodb':
|
|
2916
2912
|
for (let j = 0; j < length; ++j) {
|
|
2917
2913
|
const cmd = batch[j];
|
|
2918
|
-
|
|
2914
|
+
if (cmd.cascade) {
|
|
2915
|
+
cmd.cacheObjectKey ||= cmd.cascade;
|
|
2916
|
+
}
|
|
2919
2917
|
}
|
|
2920
2918
|
break;
|
|
2921
2919
|
case 'redis':
|
|
2922
2920
|
for (let j = 0; j < length; ++j) {
|
|
2923
2921
|
const cmd = batch[j];
|
|
2924
|
-
const
|
|
2922
|
+
const search = cmd.search;
|
|
2925
2923
|
if ((0, types_1.isObject)(search) && typeof search.schema === 'string') {
|
|
2926
2924
|
const pathname = this.resolveDir('schema', search.schema);
|
|
2927
2925
|
if (pathname) {
|
|
@@ -2947,8 +2945,11 @@ class ChromeDocument extends Document {
|
|
|
2947
2945
|
search.schema = undefined;
|
|
2948
2946
|
}
|
|
2949
2947
|
}
|
|
2950
|
-
if (key) {
|
|
2951
|
-
|
|
2948
|
+
if (cmd.key) {
|
|
2949
|
+
const { cascade, query } = cmd;
|
|
2950
|
+
if (cascade || query) {
|
|
2951
|
+
cmd.cacheObjectKey ||= (cascade ? cascade : '') + '_' + (query ? Document.asString(query, true) : '');
|
|
2952
|
+
}
|
|
2952
2953
|
}
|
|
2953
2954
|
}
|
|
2954
2955
|
break;
|
|
@@ -3137,14 +3138,14 @@ class ChromeDocument extends Document {
|
|
|
3137
3138
|
continue;
|
|
3138
3139
|
}
|
|
3139
3140
|
try {
|
|
3140
|
-
let
|
|
3141
|
+
let unsafe = new Function('return ' + literal + ';').call(row);
|
|
3141
3142
|
if (!segment.startsWith('`')) {
|
|
3142
|
-
|
|
3143
|
+
unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
|
|
3143
3144
|
}
|
|
3144
3145
|
if (!segment.endsWith('`')) {
|
|
3145
|
-
|
|
3146
|
+
unsafe += segment.substring(segment.lastIndexOf('`') + 1);
|
|
3146
3147
|
}
|
|
3147
|
-
segment =
|
|
3148
|
+
segment = unsafe;
|
|
3148
3149
|
}
|
|
3149
3150
|
catch (err) {
|
|
3150
3151
|
errors = err instanceof Error ? err : true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/cloud": "^0.10.
|
|
25
|
-
"@e-mc/core": "^0.10.
|
|
26
|
-
"@e-mc/document": "^0.10.
|
|
27
|
-
"@e-mc/types": "^0.10.
|
|
24
|
+
"@e-mc/cloud": "^0.10.21",
|
|
25
|
+
"@e-mc/core": "^0.10.21",
|
|
26
|
+
"@e-mc/document": "^0.10.21",
|
|
27
|
+
"@e-mc/types": "^0.10.21"
|
|
28
28
|
}
|
|
29
29
|
}
|