@pi-r/chrome 0.8.4 → 0.8.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/index.js +20 -24
- 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 + '}';
|
|
@@ -3137,14 +3133,14 @@ class ChromeDocument extends Document {
|
|
|
3137
3133
|
continue;
|
|
3138
3134
|
}
|
|
3139
3135
|
try {
|
|
3140
|
-
let
|
|
3136
|
+
let unsafe = new Function('return ' + literal + ';').call(row);
|
|
3141
3137
|
if (!segment.startsWith('`')) {
|
|
3142
|
-
|
|
3138
|
+
unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
|
|
3143
3139
|
}
|
|
3144
3140
|
if (!segment.endsWith('`')) {
|
|
3145
|
-
|
|
3141
|
+
unsafe += segment.substring(segment.lastIndexOf('`') + 1);
|
|
3146
3142
|
}
|
|
3147
|
-
segment =
|
|
3143
|
+
segment = unsafe;
|
|
3148
3144
|
}
|
|
3149
3145
|
catch (err) {
|
|
3150
3146
|
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.5",
|
|
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.20",
|
|
25
|
+
"@e-mc/core": "^0.10.20",
|
|
26
|
+
"@e-mc/document": "^0.10.20",
|
|
27
|
+
"@e-mc/types": "^0.10.20"
|
|
28
28
|
}
|
|
29
29
|
}
|