@pi-r/chrome 0.6.9 → 0.6.10
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 +17 -22
- 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) {
|
|
@@ -202,7 +202,7 @@ function hasCondition(data, condition) {
|
|
|
202
202
|
if (items.length && !isSpace(match[0][0])) {
|
|
203
203
|
return false;
|
|
204
204
|
}
|
|
205
|
-
items.push([match[1], match[2], match[3]]);
|
|
205
|
+
items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
|
|
206
206
|
}
|
|
207
207
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
208
208
|
const length = items.length;
|
|
@@ -213,18 +213,13 @@ function hasCondition(data, condition) {
|
|
|
213
213
|
if (!isNaN(+value)) {
|
|
214
214
|
return +value;
|
|
215
215
|
}
|
|
216
|
-
if (match = /^(["'])([\S\s]*)\1$/.exec(value)) {
|
|
217
|
-
return match[2];
|
|
218
|
-
}
|
|
219
216
|
return getObjectValue(data, value);
|
|
220
217
|
};
|
|
221
218
|
for (let i = 0; i < length; ++i) {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const arg2 = item[2];
|
|
225
|
-
let valid;
|
|
219
|
+
const [cmp, arg1, arg2] = items[i];
|
|
220
|
+
let valid = false;
|
|
226
221
|
if (arg2) {
|
|
227
|
-
switch (
|
|
222
|
+
switch (cmp) {
|
|
228
223
|
case 'eq':
|
|
229
224
|
valid = parseArg(arg1) == parseArg(arg2);
|
|
230
225
|
break;
|
|
@@ -247,7 +242,7 @@ function hasCondition(data, condition) {
|
|
|
247
242
|
return false;
|
|
248
243
|
}
|
|
249
244
|
}
|
|
250
|
-
else if (
|
|
245
|
+
else if (cmp) {
|
|
251
246
|
return false;
|
|
252
247
|
}
|
|
253
248
|
else {
|
|
@@ -586,7 +581,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
586
581
|
if (!isText) {
|
|
587
582
|
let j = startIndex;
|
|
588
583
|
while (isSpace(source[--j])) { }
|
|
589
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
584
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
590
585
|
}
|
|
591
586
|
else {
|
|
592
587
|
k = startIndex;
|
|
@@ -1690,14 +1685,14 @@ class ChromeDocument extends Document {
|
|
|
1690
1685
|
}
|
|
1691
1686
|
}
|
|
1692
1687
|
replaceContent(source, statement, mimeType) {
|
|
1693
|
-
var _a;
|
|
1688
|
+
var _a, _b;
|
|
1694
1689
|
switch (mimeType) {
|
|
1695
1690
|
case 'text/css': {
|
|
1696
1691
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1697
1692
|
if (match) {
|
|
1698
1693
|
const layer = match[1];
|
|
1699
1694
|
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1700
|
-
const query = match[4].trim();
|
|
1695
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1701
1696
|
if (layer || supports || query) {
|
|
1702
1697
|
const newline = (0, util_1.getNewline)(source);
|
|
1703
1698
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1705,8 +1700,8 @@ class ChromeDocument extends Document {
|
|
|
1705
1700
|
result += `@media ${query} {` + newline;
|
|
1706
1701
|
}
|
|
1707
1702
|
if (layer) {
|
|
1708
|
-
|
|
1709
|
-
result += '@layer ' + (name
|
|
1703
|
+
const name = (_b = match[2]) === null || _b === void 0 ? void 0 : _b.replace(/\s+/g, '');
|
|
1704
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1710
1705
|
}
|
|
1711
1706
|
else if (query) {
|
|
1712
1707
|
result += source + newline + '}';
|
|
@@ -3036,14 +3031,14 @@ class ChromeDocument extends Document {
|
|
|
3036
3031
|
continue;
|
|
3037
3032
|
}
|
|
3038
3033
|
try {
|
|
3039
|
-
let
|
|
3034
|
+
let unsafe = new Function('return ' + literal + ';').call(row);
|
|
3040
3035
|
if (!segment.startsWith('`')) {
|
|
3041
|
-
|
|
3036
|
+
unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
|
|
3042
3037
|
}
|
|
3043
3038
|
if (!segment.endsWith('`')) {
|
|
3044
|
-
|
|
3039
|
+
unsafe += segment.substring(segment.lastIndexOf('`') + 1);
|
|
3045
3040
|
}
|
|
3046
|
-
segment =
|
|
3041
|
+
segment = unsafe;
|
|
3047
3042
|
}
|
|
3048
3043
|
catch (err) {
|
|
3049
3044
|
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.6.
|
|
3
|
+
"version": "0.6.10",
|
|
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.8.
|
|
24
|
-
"@e-mc/core": "^0.8.
|
|
25
|
-
"@e-mc/document": "^0.8.
|
|
26
|
-
"@e-mc/types": "^0.8.
|
|
23
|
+
"@e-mc/cloud": "^0.8.29",
|
|
24
|
+
"@e-mc/core": "^0.8.29",
|
|
25
|
+
"@e-mc/document": "^0.8.29",
|
|
26
|
+
"@e-mc/types": "^0.8.29"
|
|
27
27
|
}
|
|
28
28
|
}
|