@pi-r/chrome 0.6.5 → 0.6.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 +26 -14
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -20,11 +20,12 @@ const [PATTERN_STRING_SOME, PATTERN_STRING_MANY] = (function () {
|
|
|
20
20
|
const grouping = '(?:\\s|' + dom_1.DomWriter.PATTERN_COMMENT + '|`[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}`)';
|
|
21
21
|
return [grouping + '*', grouping + '+'];
|
|
22
22
|
})();
|
|
23
|
-
const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE] = (function () {
|
|
23
|
+
const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function () {
|
|
24
24
|
const parenthesis = '(?:,[^()]+(?=\\))|[^()]|\\([^()]*\\(+|\\([^()]*\\)|(?:\\)[^()]+)?\\)*?)+';
|
|
25
25
|
return [
|
|
26
26
|
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'),
|
|
27
|
-
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g')
|
|
27
|
+
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
28
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(?:\\(([^)]*)\\)|\\b))?(?:\\s*supports\\((${parenthesis})\\))?(.*?);?$`)
|
|
28
29
|
];
|
|
29
30
|
})();
|
|
30
31
|
const REGEXP_SRCSETSIZE = /~\s*([\d.]+)\s*([wx])/i;
|
|
@@ -55,7 +56,6 @@ const REGEXP_URL_JS = /\bimport\(/g;
|
|
|
55
56
|
const REGEXP_URL_SVG = /(?:\b[Uu][Rr][Ll]\(|@import\s+(["'])|\b([Hh][Rr][Ee][Ff])\s*=)/g;
|
|
56
57
|
const REGEXP_IMAGESET = /\b(?:-webkit-)?image-set\(/gi;
|
|
57
58
|
const REGEXP_IMAGESET_URL = /(?:^|[^(])\s*("(\s*[^)][^"]*)"|'(\s*[^)][^"]*)')\s*(?:,|$|[^)][^,]*,?)/g;
|
|
58
|
-
const REGEXP_REPLACECSS = /^@import\s+(?:url\((?:[^)]|(?<=\\)\))+\)|"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')(\s*layer(?:\(([^)]*)\)|\b))?(?:\s*supports\(((?:\([^(]+\(|\([^)]+\)|\)[^)]+\)|(?:(?!\))[^(])+|(?:(?!\()[^)])+)+)\))?(.*?);?$/;
|
|
59
59
|
function removeNamespace(name, source, newline, comments) {
|
|
60
60
|
if (source.includes('-' + name)) {
|
|
61
61
|
const [a, b, c, d, e] = CACHE_DATASET[name] || (CACHE_DATASET[name] = [
|
|
@@ -1647,7 +1647,7 @@ class ChromeDocument extends Document {
|
|
|
1647
1647
|
const query = match[4].trim();
|
|
1648
1648
|
if (layer || supports || query) {
|
|
1649
1649
|
const newline = (0, util_1.getNewline)(source);
|
|
1650
|
-
let result = supports ? `@supports (${
|
|
1650
|
+
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
1651
1651
|
if (query) {
|
|
1652
1652
|
result += `@media ${query} {` + newline;
|
|
1653
1653
|
}
|
|
@@ -3407,7 +3407,7 @@ class ChromeDocument extends Document {
|
|
|
3407
3407
|
}
|
|
3408
3408
|
return selector.replace(/ +/g, getStringMany()) + getStringSome();
|
|
3409
3409
|
};
|
|
3410
|
-
const replaceUnunsed = (name, items) => {
|
|
3410
|
+
const replaceUnunsed = (name, items, nesting) => {
|
|
3411
3411
|
for (let value of items) {
|
|
3412
3412
|
const key = name + '_' + (value = value.trim()) + (useUnsafeCssReplace ? '_1' : '');
|
|
3413
3413
|
let pattern = queryMap.get(key), rule;
|
|
@@ -3460,11 +3460,24 @@ class ChromeDocument extends Document {
|
|
|
3460
3460
|
pattern.lastIndex = 0;
|
|
3461
3461
|
}
|
|
3462
3462
|
while (rule = pattern.exec(current)) {
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3463
|
+
invalid: {
|
|
3464
|
+
if (!nesting) {
|
|
3465
|
+
for (let i = rule.index - 1; i > 0; --i) {
|
|
3466
|
+
const ch = current[i];
|
|
3467
|
+
if (ch === '}') {
|
|
3468
|
+
break;
|
|
3469
|
+
}
|
|
3470
|
+
if (ch === '{') {
|
|
3471
|
+
break invalid;
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
const [endIndex, trailing] = findClosingIndex(current, getEndIndex(rule), '{');
|
|
3476
|
+
if (endIndex !== -1) {
|
|
3477
|
+
current = spliceSource(current, rule.index, endIndex, pattern, rule[1], trailing);
|
|
3478
|
+
(checkEmpty || (checkEmpty = {}))[name] = true;
|
|
3479
|
+
modified = true;
|
|
3480
|
+
}
|
|
3468
3481
|
}
|
|
3469
3482
|
}
|
|
3470
3483
|
}
|
|
@@ -3496,13 +3509,13 @@ class ChromeDocument extends Document {
|
|
|
3496
3509
|
}
|
|
3497
3510
|
}
|
|
3498
3511
|
if (unusedMedia) {
|
|
3499
|
-
replaceUnunsed('media', unusedMedia);
|
|
3512
|
+
replaceUnunsed('media', unusedMedia, true);
|
|
3500
3513
|
}
|
|
3501
3514
|
if (unusedSupports) {
|
|
3502
|
-
replaceUnunsed('supports', unusedSupports);
|
|
3515
|
+
replaceUnunsed('supports', unusedSupports, true);
|
|
3503
3516
|
}
|
|
3504
3517
|
if (unusedContainer) {
|
|
3505
|
-
replaceUnunsed('container', unusedContainer);
|
|
3518
|
+
replaceUnunsed('container', unusedContainer, false);
|
|
3506
3519
|
}
|
|
3507
3520
|
if (unusedStyles) {
|
|
3508
3521
|
current = (function recurse(target, child) {
|
|
@@ -3726,5 +3739,4 @@ class ChromeDocument extends Document {
|
|
|
3726
3739
|
}
|
|
3727
3740
|
ChromeDocument.INTERNAL_ASSIGNUUID = "__assign__";
|
|
3728
3741
|
ChromeDocument.INTERNAL_SERVERROOT = "__serverroot__";
|
|
3729
|
-
|
|
3730
3742
|
module.exports = ChromeDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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.7",
|
|
24
|
+
"@e-mc/core": "^0.8.7",
|
|
25
|
+
"@e-mc/document": "^0.8.7",
|
|
26
|
+
"@e-mc/types": "^0.8.7"
|
|
27
27
|
}
|
|
28
28
|
}
|