@pi-r/chrome 0.5.6 → 0.5.8
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 +199 -202
- 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
|
|
59
|
+
const REGEXP_URL_CSS = /(?:\burl\(|@import\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], trimQuote(match[2]), trimQuote(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 {
|
|
@@ -391,9 +386,9 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
391
386
|
var _a;
|
|
392
387
|
const related = [];
|
|
393
388
|
const baseHref = getBaseURLs(importFile || parent, this.baseUrl);
|
|
394
|
-
const isHtml = type === 'html';
|
|
389
|
+
const isHtml = type === 'html' || type === 'svg';
|
|
395
390
|
const isJs = type === 'js';
|
|
396
|
-
const pattern = isJs ? REGEXP_URL_JS :
|
|
391
|
+
const pattern = isJs ? REGEXP_URL_JS : !isHtml ? REGEXP_URL_CSS : REGEXP_URL;
|
|
397
392
|
pattern.lastIndex = 0;
|
|
398
393
|
REGEXP_IMAGESET.lastIndex = 0;
|
|
399
394
|
let length = source.length, modified, match;
|
|
@@ -422,227 +417,229 @@ function transformURL(host, parent, type, source, importFile) {
|
|
|
422
417
|
const isUrl = !isText && !isHref;
|
|
423
418
|
const startIndex = match.index;
|
|
424
419
|
let quote = match[1], content = '', trailing = '', closed = -1, i = startIndex + match[0].length;
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
if (source[i - 1] !== '\\') {
|
|
435
|
-
if (isText) {
|
|
420
|
+
pass: {
|
|
421
|
+
for (let j = -1; i < length; ++i) {
|
|
422
|
+
const ch = source[i];
|
|
423
|
+
if (quote && ch === quote) {
|
|
424
|
+
if (!isText) {
|
|
425
|
+
content += ch;
|
|
426
|
+
}
|
|
427
|
+
if (isHref) {
|
|
436
428
|
break;
|
|
437
429
|
}
|
|
438
|
-
if (
|
|
439
|
-
|
|
430
|
+
if (source[i - 1] !== '\\') {
|
|
431
|
+
if (isText) {
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
if (closed === -1) {
|
|
435
|
+
closed = i + 1;
|
|
436
|
+
}
|
|
440
437
|
}
|
|
438
|
+
j = i + 1;
|
|
439
|
+
continue;
|
|
441
440
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
break;
|
|
441
|
+
if (!quote && (ch === '"' || ch === "'" || ch === '`' && isJs) && (isHref || !content.trim())) {
|
|
442
|
+
quote = ch;
|
|
443
|
+
}
|
|
444
|
+
else if (isHref && (ch === '#' || !quote && isSpace(ch)) && content.trim()) {
|
|
445
|
+
break pass;
|
|
446
|
+
}
|
|
447
|
+
else if (ch === ')') {
|
|
448
|
+
if (isUrl) {
|
|
449
|
+
if (quote && closed !== -1 || !quote && (isJs || source[i - 1] !== '\\')) {
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
j = i;
|
|
455
453
|
}
|
|
456
|
-
j = i;
|
|
457
454
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
455
|
+
else if (j !== -1 && (ch === '\n' ||
|
|
456
|
+
isText && (ch === ';' || ch === '{') ||
|
|
457
|
+
isHref && (ch === '=' || ch === '>') ||
|
|
458
|
+
isUrl && (ch === ';' ||
|
|
459
|
+
!isJs && (!isHtml && (ch === ':' && !isJs || ch === '}') ||
|
|
460
|
+
isHtml && (ch === '"' || ch === "'" || ch === ':' || ch === '>'))))) {
|
|
461
|
+
if (closed !== -1) {
|
|
462
|
+
i = closed;
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
content = content.substring(0, i = j);
|
|
466
|
+
}
|
|
467
|
+
break;
|
|
467
468
|
}
|
|
468
|
-
|
|
469
|
-
content
|
|
469
|
+
if (closed === -1) {
|
|
470
|
+
content += ch;
|
|
470
471
|
}
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
if (closed === -1) {
|
|
474
|
-
content += ch;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
const setOutputURL = (value, asset) => {
|
|
478
|
-
var _a;
|
|
479
|
-
if (!value) {
|
|
480
|
-
return;
|
|
481
472
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
473
|
+
const setOutputURL = (value, asset) => {
|
|
474
|
+
var _a;
|
|
475
|
+
if (!value) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (asset) {
|
|
479
|
+
if (!asset.inlineBase64) {
|
|
480
|
+
if ((_a = host.Cloud) === null || _a === void 0 ? void 0 : _a.getStorage('upload', asset.cloudStorage)) {
|
|
481
|
+
const inlineUrlCloud = asset.inlineUrlCloud || (asset.inlineUrlCloud = (0, types_1.generateUUID)());
|
|
482
|
+
(parent.inlineUrlCloudMap || (parent.inlineUrlCloudMap = {}))[inlineUrlCloud] = value;
|
|
483
|
+
value = inlineUrlCloud;
|
|
484
|
+
}
|
|
485
|
+
else if (asset.hash && this.productionRelease) {
|
|
486
|
+
const inlineUrl = asset.inlineUrl || (asset.inlineUrl = (0, types_1.generateUUID)());
|
|
487
|
+
(parent.inlineUrlMap || (parent.inlineUrlMap = {}))[inlineUrl] = value;
|
|
488
|
+
value = inlineUrl;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const font = findFont(asset.format);
|
|
492
|
+
if (font) {
|
|
493
|
+
found: {
|
|
494
|
+
for (let k = i + 1; k < length; ++k) {
|
|
495
|
+
switch (source[k]) {
|
|
496
|
+
case ')': {
|
|
497
|
+
const component = source.substring(i + 1, k + 1);
|
|
498
|
+
const format = /\s+format\([^)]+\)$/i.exec(component);
|
|
499
|
+
if (format) {
|
|
500
|
+
trailing = component.replace(format[0], ` format("${font}")`);
|
|
501
|
+
i = k;
|
|
502
|
+
break found;
|
|
503
|
+
}
|
|
504
|
+
break;
|
|
507
505
|
}
|
|
508
|
-
|
|
506
|
+
case ',':
|
|
507
|
+
case ';':
|
|
508
|
+
case ':':
|
|
509
|
+
case '}':
|
|
510
|
+
break found;
|
|
509
511
|
}
|
|
510
|
-
case ',':
|
|
511
|
-
case ';':
|
|
512
|
-
case ':':
|
|
513
|
-
case '}':
|
|
514
|
-
break found;
|
|
515
512
|
}
|
|
516
513
|
}
|
|
517
514
|
}
|
|
515
|
+
if (asset.initialValue && !asset.initialValue.cacheable) {
|
|
516
|
+
parent.flags |= 16;
|
|
517
|
+
}
|
|
518
|
+
related.push(asset);
|
|
518
519
|
}
|
|
519
|
-
if (
|
|
520
|
-
|
|
520
|
+
if (!quote && !isHtml && !isJs) {
|
|
521
|
+
if (value.indexOf('"') === -1) {
|
|
522
|
+
quote = '"';
|
|
523
|
+
}
|
|
524
|
+
else if (value.indexOf("'") === -1) {
|
|
525
|
+
quote = "'";
|
|
526
|
+
}
|
|
521
527
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
528
|
+
if (isUrl) {
|
|
529
|
+
const index = value.indexOf('#');
|
|
530
|
+
if (index !== -1) {
|
|
531
|
+
value = value.substring(0, index);
|
|
532
|
+
}
|
|
527
533
|
}
|
|
528
|
-
|
|
529
|
-
|
|
534
|
+
if (quote) {
|
|
535
|
+
value = quote + value + quote;
|
|
530
536
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
537
|
+
const revised = isJs ? 'import(' + value + trailing + ')' : isHref ? 'href=' + value : (isText ? '@import ' + value : `url(${value})`) + trailing;
|
|
538
|
+
source = spliceString(source, startIndex, i + 1, revised);
|
|
539
|
+
length = source.length;
|
|
540
|
+
pattern.lastIndex = startIndex + revised.length;
|
|
541
|
+
modified = true;
|
|
542
|
+
};
|
|
543
|
+
let url;
|
|
544
|
+
if (isJs) {
|
|
545
|
+
if (!quote) {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
const file = new RegExp('^\\s*(' + quote + '((?:[^' + quote + ']|(?<=\\\\)' + quote + ')+)' + quote + ')\\s*(,.+)$').exec(content);
|
|
549
|
+
if (file) {
|
|
550
|
+
url = file[1].trim();
|
|
551
|
+
trailing = file[2].trim();
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
url = trimQuote(content);
|
|
536
555
|
}
|
|
537
|
-
}
|
|
538
|
-
if (quote) {
|
|
539
|
-
value = quote + value + quote;
|
|
540
|
-
}
|
|
541
|
-
const revised = isJs ? 'import(' + value + trailing + ')' : isHref ? 'href=' + value : (isText ? '@import ' + value : `url(${value})`) + trailing;
|
|
542
|
-
source = spliceString(source, startIndex, i + 1, revised);
|
|
543
|
-
length = source.length;
|
|
544
|
-
pattern.lastIndex = startIndex + revised.length;
|
|
545
|
-
modified = true;
|
|
546
|
-
};
|
|
547
|
-
let url;
|
|
548
|
-
if (isJs) {
|
|
549
|
-
if (!quote) {
|
|
550
|
-
continue;
|
|
551
|
-
}
|
|
552
|
-
const file = new RegExp('^\\s*(' + quote + '((?:[^' + quote + ']|(?<=\\\\)' + quote + ')+)' + quote + ')\\s*(,.+)$').exec(content);
|
|
553
|
-
if (file) {
|
|
554
|
-
url = file[1].trim();
|
|
555
|
-
trailing = file[2].trim();
|
|
556
556
|
}
|
|
557
557
|
else {
|
|
558
558
|
url = trimQuote(content);
|
|
559
559
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (item.base64 === base64) {
|
|
569
|
-
setOutputURL(getSrcURL.call(this, parent, item)[0], item);
|
|
570
|
-
break;
|
|
560
|
+
if (url.startsWith('data:')) {
|
|
561
|
+
const base64 = (_a = url.split(',')[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
562
|
+
if (base64) {
|
|
563
|
+
for (const item of this.assets) {
|
|
564
|
+
if (item.base64 === base64) {
|
|
565
|
+
setOutputURL(getSrcURL.call(this, parent, item)[0], item);
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
571
568
|
}
|
|
572
569
|
}
|
|
573
570
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
571
|
+
else if (baseHref.length) {
|
|
572
|
+
let fullUrl, asset;
|
|
573
|
+
for (const parentUrl of baseHref) {
|
|
574
|
+
if (asset = host.findAsset(fullUrl = resolvePath(url, parentUrl), { replaced: true }) || (this.related.has(parent) ? host.findAsset(fullUrl, { assets: Array.from(this.related.get(parent)), replaced: true }) : undefined)) {
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
580
577
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
valid = source.substring(k = j - 6, j + 1) === '@import';
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
k = startIndex;
|
|
593
|
-
valid = true;
|
|
594
|
-
}
|
|
595
|
-
if (valid) {
|
|
596
|
-
let l = i, revised = transform_1.SourceMap.removeSourceMappingURL(host.getUTF8String(asset))[0];
|
|
597
|
-
for (let ch; l < length; ++l) {
|
|
598
|
-
if ((ch = source[l]) === ';' || ch === '\n') {
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
const layer = this.replaceContent(revised, source.substring(k, l + 1), 'text/css');
|
|
603
|
-
if (layer) {
|
|
604
|
-
revised = layer;
|
|
605
|
-
}
|
|
606
|
-
source = spliceString(source, k, l + 1, revised = transformURL.call(this, host, parent, type, this.removeServerRoot(revised), asset) || revised);
|
|
607
|
-
length = source.length;
|
|
608
|
-
pattern.lastIndex = k + revised.length;
|
|
609
|
-
if (!parent.watch) {
|
|
610
|
-
host.deleteFile(asset.localUri, { ignorePermission: true, emptyDir: true, all: true, id: asset.id });
|
|
611
|
-
asset.invalid = true;
|
|
578
|
+
if (asset && asset !== importFile) {
|
|
579
|
+
if (!(0, util_1.hasValue)(asset.format, 'base64')) {
|
|
580
|
+
if (asset.bundleReplace) {
|
|
581
|
+
let k, valid;
|
|
582
|
+
if (!isText) {
|
|
583
|
+
let j = startIndex;
|
|
584
|
+
while (isSpace(source[--j])) { }
|
|
585
|
+
valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
|
|
612
586
|
}
|
|
613
587
|
else {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
588
|
+
k = startIndex;
|
|
589
|
+
valid = true;
|
|
590
|
+
}
|
|
591
|
+
if (valid) {
|
|
592
|
+
let l = i, revised = transform_1.SourceMap.removeSourceMappingURL(host.getUTF8String(asset))[0];
|
|
593
|
+
for (let ch; l < length; ++l) {
|
|
594
|
+
if ((ch = source[l]) === ';' || ch === '\n') {
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const layer = this.replaceContent(revised, source.substring(k, l + 1), 'text/css');
|
|
599
|
+
if (layer) {
|
|
600
|
+
revised = layer;
|
|
601
|
+
}
|
|
602
|
+
source = spliceString(source, k, l + 1, revised = transformURL.call(this, host, parent, type, this.removeServerRoot(revised), asset) || revised);
|
|
603
|
+
length = source.length;
|
|
604
|
+
pattern.lastIndex = k + revised.length;
|
|
605
|
+
if (!parent.watch) {
|
|
606
|
+
host.deleteFile(asset.localUri, { ignorePermission: true, emptyDir: true, all: true, id: asset.id });
|
|
607
|
+
asset.invalid = true;
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
related.push(asset);
|
|
611
|
+
if (!(0, types_1.existsFlag)(asset.flags)) {
|
|
612
|
+
asset.flags |= 8;
|
|
613
|
+
}
|
|
617
614
|
}
|
|
615
|
+
modified = true;
|
|
616
|
+
continue;
|
|
618
617
|
}
|
|
619
|
-
modified = true;
|
|
620
|
-
continue;
|
|
621
618
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
619
|
+
if (hasSameOrigin(asset.url || fullUrl, ...baseHref)) {
|
|
620
|
+
let sameDir;
|
|
621
|
+
[fullUrl, sameDir] = getSrcURL.call(this, parent, asset);
|
|
622
|
+
if (sameDir && isJs) {
|
|
623
|
+
fullUrl = './' + fullUrl;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
const pathname = parent.pathname;
|
|
628
|
+
const count = pathname && pathname !== '/' && pathname !== '\\' ? pathname.split(/[\\/]/).length : 0;
|
|
629
|
+
fullUrl = (count ? '../'.repeat(count) : '') + asset.relativeUrl;
|
|
628
630
|
}
|
|
629
631
|
}
|
|
630
|
-
else {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
632
|
+
else if (!asset.invalid) {
|
|
633
|
+
fullUrl = asset.inlineBase64 || (asset.inlineBase64 = (0, types_1.generateUUID)());
|
|
634
|
+
}
|
|
635
|
+
if (url !== fullUrl) {
|
|
636
|
+
setOutputURL(fullUrl, asset);
|
|
634
637
|
}
|
|
635
638
|
}
|
|
636
|
-
else if (
|
|
637
|
-
fullUrl
|
|
638
|
-
}
|
|
639
|
-
if (url !== fullUrl) {
|
|
640
|
-
setOutputURL(fullUrl, asset);
|
|
639
|
+
else if (importFile && url !== fullUrl) {
|
|
640
|
+
setOutputURL(fullUrl);
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
else if (importFile && url !== fullUrl) {
|
|
644
|
-
setOutputURL(fullUrl);
|
|
645
|
-
}
|
|
646
643
|
}
|
|
647
644
|
}
|
|
648
645
|
if (modified) {
|
|
@@ -1689,14 +1686,14 @@ class ChromeDocument extends Document {
|
|
|
1689
1686
|
}
|
|
1690
1687
|
}
|
|
1691
1688
|
replaceContent(source, statement, mimeType) {
|
|
1692
|
-
var _a;
|
|
1689
|
+
var _a, _b;
|
|
1693
1690
|
switch (mimeType) {
|
|
1694
1691
|
case 'text/css': {
|
|
1695
1692
|
const match = REGEXP_REPLACECSS.exec((typeof statement === 'string' ? statement : statement[0]).trim());
|
|
1696
1693
|
if (match) {
|
|
1697
1694
|
const layer = match[1];
|
|
1698
1695
|
const supports = (_a = match[3]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
1699
|
-
const query = match[4].trim();
|
|
1696
|
+
const query = match[4].trim().replace(/;+$/, '');
|
|
1700
1697
|
if (layer || supports || query) {
|
|
1701
1698
|
const newline = (0, util_1.getNewline)(source);
|
|
1702
1699
|
let result = supports ? `@supports (${supports}) {` + newline : '';
|
|
@@ -1704,8 +1701,8 @@ class ChromeDocument extends Document {
|
|
|
1704
1701
|
result += `@media ${query} {` + newline;
|
|
1705
1702
|
}
|
|
1706
1703
|
if (layer) {
|
|
1707
|
-
|
|
1708
|
-
result += '@layer ' + (name
|
|
1704
|
+
const name = (_b = match[2]) === null || _b === void 0 ? void 0 : _b.replace(/\s+/g, '');
|
|
1705
|
+
result += '@layer ' + (name ? name.slice(1, -1) + ' ' : '') + `{${newline + source + newline}}` + (query ? newline + '}' : '');
|
|
1709
1706
|
}
|
|
1710
1707
|
else if (query) {
|
|
1711
1708
|
result += source + newline + '}';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/chrome",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
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.7.
|
|
24
|
-
"@e-mc/core": "^0.7.
|
|
25
|
-
"@e-mc/document": "^0.7.
|
|
26
|
-
"@e-mc/types": "^0.7.
|
|
23
|
+
"@e-mc/cloud": "^0.7.25",
|
|
24
|
+
"@e-mc/core": "^0.7.25",
|
|
25
|
+
"@e-mc/document": "^0.7.25",
|
|
26
|
+
"@e-mc/types": "^0.7.25"
|
|
27
27
|
}
|
|
28
28
|
}
|