@pi-r/chrome 0.2.13 → 0.2.14
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 +12 -17
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ const [REGEXP_NTHCHILD, REGEXP_NTHCHILD_UNSAFE, REGEXP_REPLACECSS] = (function (
|
|
|
32
32
|
return [
|
|
33
33
|
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'),
|
|
34
34
|
new RegExp(`\\(\\s*([+-])?(?:(\\d*)[nN]|(0))?\\s*([+-])?\\s*(\\d*)(?:\\s+[oO][fF]\\s+(${parenthesis})\\s*\\)|\\s*\\))`, 'g'),
|
|
35
|
-
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(
|
|
35
|
+
new RegExp(`^@import\\s+(?:url\\((?:[^)]|(?<=\\\\)\\))+\\)|"(?:[^"]|(?<=\\\\)")+"|'(?:[^']|(?<=\\\\)')+')(\\s*layer(\\([^)]*\\))?)?(?:\\s*supports\\((${parenthesis})\\))?(.*)$`, 'si')
|
|
36
36
|
];
|
|
37
37
|
})();
|
|
38
38
|
const REGEXP_COMMENT = new RegExp(dom_1.DomWriter.PATTERN_COMMENT, 'g');
|
|
@@ -184,7 +184,7 @@ function hasCondition(data, condition) {
|
|
|
184
184
|
if (items.length && !isSpace(match[0][0])) {
|
|
185
185
|
return false;
|
|
186
186
|
}
|
|
187
|
-
items.push([match[1], trimQuote(match[2]), trimQuote(match[3])]);
|
|
187
|
+
items.push([match[1], trimQuote(match[2]), match[3] ? trimQuote(match[3]) : '']);
|
|
188
188
|
}
|
|
189
189
|
REGEXP_TEMPLATECOMPARISON.lastIndex = 0;
|
|
190
190
|
const length = items.length;
|
|
@@ -195,18 +195,13 @@ function hasCondition(data, condition) {
|
|
|
195
195
|
if (!isNaN(+value)) {
|
|
196
196
|
return +value;
|
|
197
197
|
}
|
|
198
|
-
if (match = /^(["'])([\S\s]*)\1$/.exec(value)) {
|
|
199
|
-
return match[2];
|
|
200
|
-
}
|
|
201
198
|
return getObjectValue(data, value);
|
|
202
199
|
};
|
|
203
200
|
for (let i = 0; i < length; ++i) {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
const arg2 = item[2];
|
|
207
|
-
let valid;
|
|
201
|
+
const [cmp, arg1, arg2] = items[i];
|
|
202
|
+
let valid = false;
|
|
208
203
|
if (arg2) {
|
|
209
|
-
switch (
|
|
204
|
+
switch (cmp) {
|
|
210
205
|
case 'eq':
|
|
211
206
|
valid = parseArg(arg1) == parseArg(arg2);
|
|
212
207
|
break;
|
|
@@ -229,7 +224,7 @@ function hasCondition(data, condition) {
|
|
|
229
224
|
return false;
|
|
230
225
|
}
|
|
231
226
|
}
|
|
232
|
-
else if (
|
|
227
|
+
else if (cmp) {
|
|
233
228
|
return false;
|
|
234
229
|
}
|
|
235
230
|
else {
|
|
@@ -382,7 +377,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
382
377
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
383
378
|
const isHtml = type === 'html';
|
|
384
379
|
const isJs = type === 'js';
|
|
385
|
-
const pattern = isJs ? /\bimport\(/g : type === 'svg' ? /(?:\
|
|
380
|
+
const pattern = isJs ? /\bimport\(/g : type === 'svg' ? /(?:\burl\(|@import\s+(["'])|\b(href)\s*=)/gi : /\burl\(|@import\s+(["'])/gi;
|
|
386
381
|
let length = source.length, modified, match;
|
|
387
382
|
while (match = pattern.exec(source)) {
|
|
388
383
|
const isText = !!match[1];
|
|
@@ -554,7 +549,7 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
554
549
|
if (!isText) {
|
|
555
550
|
let j = startIndex;
|
|
556
551
|
while (isSpace(source[--j])) { }
|
|
557
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
552
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
558
553
|
}
|
|
559
554
|
else {
|
|
560
555
|
k = startIndex;
|
|
@@ -1630,14 +1625,14 @@ class ChromeDocument extends Document {
|
|
|
1630
1625
|
}
|
|
1631
1626
|
}
|
|
1632
1627
|
replaceContent(source, statement, mimeType) {
|
|
1633
|
-
var _a;
|
|
1628
|
+
var _a, _b;
|
|
1634
1629
|
switch (mimeType) {
|
|
1635
1630
|
case 'text/css': {
|
|
1636
1631
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1637
1632
|
if (match) {
|
|
1638
1633
|
const layer = match[1];
|
|
1639
1634
|
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1640
|
-
const query = match[4].trim();
|
|
1635
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1641
1636
|
if (layer || supports || query) {
|
|
1642
1637
|
const newline = (0, util_1.getNewline)(source);
|
|
1643
1638
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1645,8 +1640,8 @@ class ChromeDocument extends Document {
|
|
|
1645
1640
|
result += `@media ${query} {` + newline;
|
|
1646
1641
|
}
|
|
1647
1642
|
if (layer) {
|
|
1648
|
-
|
|
1649
|
-
result += '@layer ' + (name
|
|
1643
|
+
const name = (_b = match[2]) === null || _b === void 0 ? void 0 : _b.replace(/\s+/g, '');
|
|
1644
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1650
1645
|
}
|
|
1651
1646
|
else if (query) {
|
|
1652
1647
|
result += source + newline + '}';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
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.5.
|
|
24
|
-
"@e-mc/core": "^0.5.
|
|
25
|
-
"@e-mc/document": "^0.5.
|
|
26
|
-
"@e-mc/types": "^0.5.
|
|
23
|
+
"@e-mc/cloud": "^0.5.21",
|
|
24
|
+
"@e-mc/core": "^0.5.21",
|
|
25
|
+
"@e-mc/document": "^0.5.21",
|
|
26
|
+
"@e-mc/types": "^0.5.21"
|
|
27
27
|
}
|
|
28
28
|
}
|