@pi-r/chrome 0.11.2 → 0.11.3
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 -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;
|
|
@@ -177,10 +177,6 @@ function parseArg(data, value) {
|
|
|
177
177
|
if (!isNaN(n)) {
|
|
178
178
|
return n;
|
|
179
179
|
}
|
|
180
|
-
const match = /^(["'])(.*)\1$/s.exec(value);
|
|
181
|
-
if (match) {
|
|
182
|
-
return match[2];
|
|
183
|
-
}
|
|
184
180
|
return getObjectValue(data, value);
|
|
185
181
|
}
|
|
186
182
|
function hasCondition(data, condition) {
|
|
@@ -197,7 +193,7 @@ function hasCondition(data, condition) {
|
|
|
197
193
|
if (items.length > 0 && !isSpace(match[0][0])) {
|
|
198
194
|
return false;
|
|
199
195
|
}
|
|
200
|
-
items.push([match[1], (0, util_1.trimQuote)(match[2]), (0, util_1.trimQuote)(match[3])]);
|
|
196
|
+
items.push([match[1], (0, util_1.trimQuote)(match[2]), match[3] ? (0, util_1.trimQuote)(match[3]) : '']);
|
|
201
197
|
}
|
|
202
198
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
203
199
|
const length = items.length;
|
|
@@ -205,12 +201,10 @@ function hasCondition(data, condition) {
|
|
|
205
201
|
return false;
|
|
206
202
|
}
|
|
207
203
|
for (let i = 0; i < length; ++i) {
|
|
208
|
-
const
|
|
209
|
-
const arg1 = item[1];
|
|
210
|
-
const arg2 = item[2];
|
|
204
|
+
const [cmp, arg1, arg2] = items[i];
|
|
211
205
|
let valid = false;
|
|
212
206
|
if (arg2) {
|
|
213
|
-
switch (
|
|
207
|
+
switch (cmp) {
|
|
214
208
|
case 'eq':
|
|
215
209
|
valid = parseArg(data, arg1) == parseArg(data, arg2);
|
|
216
210
|
break;
|
|
@@ -233,7 +227,7 @@ function hasCondition(data, condition) {
|
|
|
233
227
|
return false;
|
|
234
228
|
}
|
|
235
229
|
}
|
|
236
|
-
else if (
|
|
230
|
+
else if (cmp) {
|
|
237
231
|
return false;
|
|
238
232
|
}
|
|
239
233
|
else {
|
|
@@ -1091,7 +1085,7 @@ class ChromeDocument extends Document {
|
|
|
1091
1085
|
}
|
|
1092
1086
|
case "image/svg+xml": {
|
|
1093
1087
|
const source = host.getUTF8String(file, localUri);
|
|
1094
|
-
if (/\
|
|
1088
|
+
if (/\b(?<!-)url\(/i.test(source)) {
|
|
1095
1089
|
file.editing = true;
|
|
1096
1090
|
this.editing.push(file);
|
|
1097
1091
|
this.svgFiles.push(file);
|
|
@@ -1377,8 +1371,8 @@ class ChromeDocument extends Document {
|
|
|
1377
1371
|
result += `@media ${query} {` + newline;
|
|
1378
1372
|
}
|
|
1379
1373
|
if (layer) {
|
|
1380
|
-
const name = match[2]?.
|
|
1381
|
-
result += '@layer ' + (name ? name + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1374
|
+
const name = match[2]?.replace(/\s+/g, '');
|
|
1375
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1382
1376
|
}
|
|
1383
1377
|
else if (query) {
|
|
1384
1378
|
result += source + newline + '}';
|
|
@@ -2674,20 +2668,20 @@ class ChromeDocument extends Document {
|
|
|
2674
2668
|
segment = replaceMatch(match, segment, target[col] ? (!match[1] || target[col - 1].includes('\n') ? '' : match[1]) + target[col - 1] + target[col] : '', REGEXP_TEMPLATECONDITIONAL);
|
|
2675
2669
|
}
|
|
2676
2670
|
const literal = segment.trim();
|
|
2677
|
-
if (literal.
|
|
2671
|
+
if (literal.at(0) === '`' && literal.at(-1) === '`') {
|
|
2678
2672
|
if (!this.hasEval('function')) {
|
|
2679
2673
|
errors = (0, types_1.errorMessage)('eval', "Unsupported access", 'function');
|
|
2680
2674
|
continue;
|
|
2681
2675
|
}
|
|
2682
2676
|
try {
|
|
2683
|
-
let
|
|
2677
|
+
let unsafe = new Function('return ' + literal + ';').call(row);
|
|
2684
2678
|
if (!segment.startsWith('`')) {
|
|
2685
|
-
|
|
2679
|
+
unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
|
|
2686
2680
|
}
|
|
2687
2681
|
if (!segment.endsWith('`')) {
|
|
2688
|
-
|
|
2682
|
+
unsafe += segment.substring(segment.lastIndexOf('`') + 1);
|
|
2689
2683
|
}
|
|
2690
|
-
segment =
|
|
2684
|
+
segment = unsafe;
|
|
2691
2685
|
}
|
|
2692
2686
|
catch (err) {
|
|
2693
2687
|
errors = err instanceof Error ? err : true;
|
|
@@ -2921,7 +2915,7 @@ class ChromeDocument extends Document {
|
|
|
2921
2915
|
if (!empty && item.type !== 'display' || item.transactionFail) {
|
|
2922
2916
|
const emptyResponse = (value, service = item.source) => {
|
|
2923
2917
|
value ||= "Unknown";
|
|
2924
|
-
return errorDataSource(
|
|
2918
|
+
return errorDataSource(errors instanceof Error ? errors.message : service + ': Empty', value);
|
|
2925
2919
|
};
|
|
2926
2920
|
switch (item.source) {
|
|
2927
2921
|
case 'cloud': {
|
|
@@ -3551,7 +3545,7 @@ class ChromeDocument extends Document {
|
|
|
3551
3545
|
const isHtml = type === 'html';
|
|
3552
3546
|
const isJs = type === 'js';
|
|
3553
3547
|
const imageSet = /\b(?:-webkit-)?image-set\(/gi;
|
|
3554
|
-
const pattern = isJs ? /\
|
|
3548
|
+
const pattern = isJs ? /\b(?<!-)import\(/g : type === 'svg' ? /(?:\b(?<!-)url\(|@import\s+(["'])|\b(?<!-)(href)\s*=)/gi : /(?:\b(?<!-)url\(|@import\s+(["'])|\b(?<!-)(href)\s*=)/gi;
|
|
3555
3549
|
let length = source.length, modified = false, match;
|
|
3556
3550
|
while (match = imageSet.exec(source)) {
|
|
3557
3551
|
const startIndex = match.index + match[0].length;
|
|
@@ -3744,7 +3738,7 @@ class ChromeDocument extends Document {
|
|
|
3744
3738
|
if (!isText) {
|
|
3745
3739
|
let j = startIndex;
|
|
3746
3740
|
while (isSpace(source[--j])) { }
|
|
3747
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
3741
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
3748
3742
|
}
|
|
3749
3743
|
else {
|
|
3750
3744
|
k = startIndex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Chrome document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.13.
|
|
24
|
-
"@e-mc/core": "^0.13.
|
|
25
|
-
"@e-mc/document": "^0.13.
|
|
26
|
-
"@e-mc/types": "^0.13.
|
|
23
|
+
"@e-mc/cloud": "^0.13.10",
|
|
24
|
+
"@e-mc/core": "^0.13.10",
|
|
25
|
+
"@e-mc/document": "^0.13.10",
|
|
26
|
+
"@e-mc/types": "^0.13.10",
|
|
27
27
|
"image-size": "^2.0.2"
|
|
28
28
|
}
|
|
29
29
|
}
|