@pi-r/chrome 0.7.5 → 0.7.7
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 +16 -21
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ 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;
|
|
@@ -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*(?:,|$|[^)][^,]*,?)/g;
|
|
62
62
|
function removeNamespace(name, source, newline, comments) {
|
|
@@ -200,7 +200,7 @@ function hasCondition(data, condition) {
|
|
|
200
200
|
if (items.length && !isSpace(match[0][0])) {
|
|
201
201
|
return false;
|
|
202
202
|
}
|
|
203
|
-
items.push([match[1], trimQuote(match[2]), trimQuote(match[3])]);
|
|
203
|
+
items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
|
|
204
204
|
}
|
|
205
205
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
206
206
|
const length = items.length;
|
|
@@ -211,18 +211,13 @@ function hasCondition(data, condition) {
|
|
|
211
211
|
if (!isNaN(+value)) {
|
|
212
212
|
return +value;
|
|
213
213
|
}
|
|
214
|
-
if (match = /^(["'])([\S\s]*)\1$/.exec(value)) {
|
|
215
|
-
return match[2];
|
|
216
|
-
}
|
|
217
214
|
return getObjectValue(data, value);
|
|
218
215
|
};
|
|
219
216
|
for (let i = 0; i < length; ++i) {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
const arg2 = item[2];
|
|
223
|
-
let valid;
|
|
217
|
+
const [cmp, arg1, arg2] = items[i];
|
|
218
|
+
let valid = false;
|
|
224
219
|
if (arg2) {
|
|
225
|
-
switch (
|
|
220
|
+
switch (cmp) {
|
|
226
221
|
case 'eq':
|
|
227
222
|
valid = parseArg(arg1) == parseArg(arg2);
|
|
228
223
|
break;
|
|
@@ -245,7 +240,7 @@ function hasCondition(data, condition) {
|
|
|
245
240
|
return false;
|
|
246
241
|
}
|
|
247
242
|
}
|
|
248
|
-
else if (
|
|
243
|
+
else if (cmp) {
|
|
249
244
|
return false;
|
|
250
245
|
}
|
|
251
246
|
else {
|
|
@@ -582,7 +577,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
582
577
|
if (!isText) {
|
|
583
578
|
let j = startIndex;
|
|
584
579
|
while (isSpace(source[--j])) { }
|
|
585
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
580
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
586
581
|
}
|
|
587
582
|
else {
|
|
588
583
|
k = startIndex;
|
|
@@ -1689,7 +1684,7 @@ class ChromeDocument extends Document {
|
|
|
1689
1684
|
if (match) {
|
|
1690
1685
|
const layer = match[1];
|
|
1691
1686
|
const supports = match[3]?.trim();
|
|
1692
|
-
const query = match[4].trim();
|
|
1687
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1693
1688
|
if (layer || supports || query) {
|
|
1694
1689
|
const newline = (0, util_1.getNewline)(source);
|
|
1695
1690
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1697,8 +1692,8 @@ class ChromeDocument extends Document {
|
|
|
1697
1692
|
result += `@media ${query} {` + newline;
|
|
1698
1693
|
}
|
|
1699
1694
|
if (layer) {
|
|
1700
|
-
|
|
1701
|
-
result += '@layer ' + (name
|
|
1695
|
+
const name = match[2]?.replace(/\s+/g, '');
|
|
1696
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1702
1697
|
}
|
|
1703
1698
|
else if (query) {
|
|
1704
1699
|
result += source + newline + '}';
|
|
@@ -3007,14 +3002,14 @@ class ChromeDocument extends Document {
|
|
|
3007
3002
|
continue;
|
|
3008
3003
|
}
|
|
3009
3004
|
try {
|
|
3010
|
-
let
|
|
3005
|
+
let unsafe = new Function('return ' + literal + ';').call(row);
|
|
3011
3006
|
if (!segment.startsWith('`')) {
|
|
3012
|
-
|
|
3007
|
+
unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
|
|
3013
3008
|
}
|
|
3014
3009
|
if (!segment.endsWith('`')) {
|
|
3015
|
-
|
|
3010
|
+
unsafe += segment.substring(segment.lastIndexOf('`') + 1);
|
|
3016
3011
|
}
|
|
3017
|
-
segment =
|
|
3012
|
+
segment = unsafe;
|
|
3018
3013
|
}
|
|
3019
3014
|
catch (err) {
|
|
3020
3015
|
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.7.
|
|
3
|
+
"version": "0.7.7",
|
|
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.9.
|
|
24
|
-
"@e-mc/core": "^0.9.
|
|
25
|
-
"@e-mc/document": "^0.9.
|
|
26
|
-
"@e-mc/types": "^0.9.
|
|
23
|
+
"@e-mc/cloud": "^0.9.28",
|
|
24
|
+
"@e-mc/core": "^0.9.28",
|
|
25
|
+
"@e-mc/document": "^0.9.28",
|
|
26
|
+
"@e-mc/types": "^0.9.28"
|
|
27
27
|
}
|
|
28
28
|
}
|