@pi-r/chrome 0.11.2 → 0.11.4

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.
Files changed (2) hide show
  1. package/index.js +211 -210
  2. 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(?:\\(([^)]+)\\))?)?(?:\\s*supports\\((${parenthesis})\\))?(.*)$`)
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 item = items[i];
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 (item[0]) {
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 (item[0]) {
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 (/\burl\(/i.test(source)) {
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]?.trim();
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 + '}';
@@ -2449,13 +2443,15 @@ class ChromeDocument extends Document {
2449
2443
  case 'mongodb':
2450
2444
  for (let j = 0; j < length; ++j) {
2451
2445
  const cmd = batch[j];
2452
- cmd.cacheObjectKey = typeof cmd.cascade === 'string' ? cmd.cascade : '';
2446
+ if (cmd.cascade) {
2447
+ cmd.cacheObjectKey ||= cmd.cascade;
2448
+ }
2453
2449
  }
2454
2450
  break;
2455
2451
  case 'redis':
2456
2452
  for (let j = 0; j < length; ++j) {
2457
2453
  const cmd = batch[j];
2458
- const { search, key, query, cascade } = cmd;
2454
+ const search = cmd.search;
2459
2455
  if ((0, types_1.isObject)(search) && typeof search.schema === 'string') {
2460
2456
  const pathname = this.resolveDir('schema', search.schema);
2461
2457
  if (pathname) {
@@ -2482,8 +2478,11 @@ class ChromeDocument extends Document {
2482
2478
  search.schema = undefined;
2483
2479
  }
2484
2480
  }
2485
- if (key) {
2486
- cmd.cacheObjectKey = ((0, types_1.isString)(cascade) ? cascade : '') + '_' + ((0, types_1.isString)(query) ? query : '');
2481
+ if (cmd.key) {
2482
+ const { cascade, query } = cmd;
2483
+ if (cascade || query) {
2484
+ cmd.cacheObjectKey ||= (cascade ? cascade : '') + '_' + (query ? Document.asString(query, true) : '');
2485
+ }
2487
2486
  }
2488
2487
  }
2489
2488
  break;
@@ -2674,20 +2673,20 @@ class ChromeDocument extends Document {
2674
2673
  segment = replaceMatch(match, segment, target[col] ? (!match[1] || target[col - 1].includes('\n') ? '' : match[1]) + target[col - 1] + target[col] : '', REGEXP_TEMPLATECONDITIONAL);
2675
2674
  }
2676
2675
  const literal = segment.trim();
2677
- if (literal.startsWith('`') && literal.endsWith('`')) {
2676
+ if (literal.at(0) === '`' && literal.at(-1) === '`') {
2678
2677
  if (!this.hasEval('function')) {
2679
2678
  errors = (0, types_1.errorMessage)('eval', "Unsupported access", 'function');
2680
2679
  continue;
2681
2680
  }
2682
2681
  try {
2683
- let content = new Function('return ' + literal + ';')(row);
2682
+ let unsafe = new Function('return ' + literal + ';').call(row);
2684
2683
  if (!segment.startsWith('`')) {
2685
- content = segment.substring(0, segment.indexOf('`')) + content;
2684
+ unsafe = segment.substring(0, segment.indexOf('`')) + unsafe;
2686
2685
  }
2687
2686
  if (!segment.endsWith('`')) {
2688
- content += segment.substring(segment.lastIndexOf('`') + 1);
2687
+ unsafe += segment.substring(segment.lastIndexOf('`') + 1);
2689
2688
  }
2690
- segment = content;
2689
+ segment = unsafe;
2691
2690
  }
2692
2691
  catch (err) {
2693
2692
  errors = err instanceof Error ? err : true;
@@ -2921,7 +2920,7 @@ class ChromeDocument extends Document {
2921
2920
  if (!empty && item.type !== 'display' || item.transactionFail) {
2922
2921
  const emptyResponse = (value, service = item.source) => {
2923
2922
  value ||= "Unknown";
2924
- return errorDataSource(service + ': ' + (errors instanceof Error ? errors.message : 'Empty'), value);
2923
+ return errorDataSource(errors instanceof Error ? errors.message : service + ': Empty', value);
2925
2924
  };
2926
2925
  switch (item.source) {
2927
2926
  case 'cloud': {
@@ -3548,10 +3547,10 @@ class ChromeDocument extends Document {
3548
3547
  processUrl(host, file, source, type, importFile) {
3549
3548
  const related = [];
3550
3549
  const baseHref = collectBaseUrl(importFile || file, this.baseUrl);
3551
- const isHtml = type === 'html';
3550
+ const isHtml = type === 'html' || type === 'svg';
3552
3551
  const isJs = type === 'js';
3553
3552
  const imageSet = /\b(?:-webkit-)?image-set\(/gi;
3554
- const pattern = isJs ? /\bimport\(/g : type === 'svg' ? /(?:\b[Uu][Rr][Ll]\(|@import\s+(["'])|\b([Hh][Rr][Ee][Ff])\s*=)/g : /(?:\b[Uu][Rr][Ll]\(|@import\s+(["'])|\b([Hh][Rr][Ee][Ff])\s*=)/g;
3553
+ const pattern = isJs ? /\b(?<!-)import\(/g : !isHtml ? /(?:\b(?<!-)url\(|@import\s+(["']))/gi : /(?:\b(?<!-)url\(|@import\s+(["'])|\b(?<!-)(href)\s*=)/gi;
3555
3554
  let length = source.length, modified = false, match;
3556
3555
  while (match = imageSet.exec(source)) {
3557
3556
  const startIndex = match.index + match[0].length;
@@ -3577,229 +3576,231 @@ class ChromeDocument extends Document {
3577
3576
  const isUrl = !isText && !isHref;
3578
3577
  const startIndex = match.index;
3579
3578
  let quote = match[1], content = '', trailing = '', closed = -1, i = startIndex + match[0].length;
3580
- for (let j = -1; i < length; ++i) {
3581
- const ch = source[i];
3582
- if (quote && ch === quote) {
3583
- if (!isText) {
3584
- content += ch;
3585
- }
3586
- if (isHref) {
3587
- break;
3588
- }
3589
- if (source[i - 1] !== '\\') {
3590
- if (isText) {
3579
+ pass: {
3580
+ for (let j = -1; i < length; ++i) {
3581
+ const ch = source[i];
3582
+ if (quote && ch === quote) {
3583
+ if (!isText) {
3584
+ content += ch;
3585
+ }
3586
+ if (isHref) {
3591
3587
  break;
3592
3588
  }
3593
- if (closed === -1) {
3594
- closed = i + 1;
3589
+ if (source[i - 1] !== '\\') {
3590
+ if (isText) {
3591
+ break;
3592
+ }
3593
+ if (closed === -1) {
3594
+ closed = i + 1;
3595
+ }
3595
3596
  }
3597
+ j = i + 1;
3598
+ continue;
3596
3599
  }
3597
- j = i + 1;
3598
- continue;
3599
- }
3600
- if (!quote && (ch === '"' || ch === "'" || ch === '`' && isJs) && (isHref || !content.trim())) {
3601
- quote = ch;
3602
- }
3603
- else if (isHref && !quote && isSpace(ch) && content.trim()) {
3604
- break;
3605
- }
3606
- else if (ch === ')') {
3607
- if (isUrl) {
3608
- if (quote && closed !== -1 || !quote && (isJs || source[i - 1] !== '\\')) {
3609
- break;
3600
+ if (!quote && (ch === '"' || ch === "'" || ch === '`' && isJs) && (isHref || !content.trim())) {
3601
+ quote = ch;
3602
+ }
3603
+ else if (isHref && (ch === '#' || !quote && isSpace(ch)) && content.trim()) {
3604
+ break pass;
3605
+ }
3606
+ else if (ch === ')') {
3607
+ if (isUrl) {
3608
+ if (quote && closed !== -1 || !quote && (isJs || source[i - 1] !== '\\')) {
3609
+ break;
3610
+ }
3611
+ j = i;
3610
3612
  }
3611
- j = i;
3612
3613
  }
3613
- }
3614
- else if (j !== -1 && (ch === '\n' ||
3615
- isText && (ch === ';' || ch === '{') ||
3616
- isHref && (ch === '=' || ch === '>') ||
3617
- isUrl && (ch === ';' ||
3618
- !isJs && (!isHtml && (ch === ':' && !isJs || ch === '}') ||
3619
- isHtml && (ch === '"' || ch === "'" || ch === ':' || ch === '>'))))) {
3620
- if (closed !== -1) {
3621
- i = closed;
3614
+ else if (j !== -1 && (ch === '\n' ||
3615
+ isText && (ch === ';' || ch === '{') ||
3616
+ isHref && (ch === '=' || ch === '>') ||
3617
+ isUrl && (ch === ';' ||
3618
+ !isJs && (!isHtml && (ch === ':' && !isJs || ch === '}') ||
3619
+ isHtml && (ch === '"' || ch === "'" || ch === ':' || ch === '>'))))) {
3620
+ if (closed !== -1) {
3621
+ i = closed;
3622
+ }
3623
+ else {
3624
+ content = content.substring(0, i = j);
3625
+ }
3626
+ break;
3622
3627
  }
3623
- else {
3624
- content = content.substring(0, i = j);
3628
+ if (closed === -1) {
3629
+ content += ch;
3625
3630
  }
3626
- break;
3627
- }
3628
- if (closed === -1) {
3629
- content += ch;
3630
- }
3631
- }
3632
- const setOutputURL = (value, asset) => {
3633
- if (!value) {
3634
- return;
3635
3631
  }
3636
- if (asset) {
3637
- if (!asset.inlineBase64) {
3638
- if (host.Cloud?.getStorage('upload', asset.cloudStorage)) {
3639
- const inlineUrlCloud = asset.inlineUrlCloud ||= (0, node_crypto_1.randomUUID)();
3640
- (file.inlineUrlCloudMap ||= {})[inlineUrlCloud] = value;
3641
- value = inlineUrlCloud;
3642
- }
3643
- else if (asset.hash && this.productionRelease) {
3644
- const inlineUrl = asset.inlineUrl ||= (0, node_crypto_1.randomUUID)();
3645
- (file.inlineUrlMap ||= {})[inlineUrl] = value;
3646
- value = inlineUrl;
3647
- }
3648
- }
3649
- const font = findFont(asset.format);
3650
- if (font) {
3651
- found: {
3652
- for (let k = i + 1; k < length; ++k) {
3653
- switch (source[k]) {
3654
- case ')': {
3655
- const component = source.substring(i + 1, k + 1);
3656
- const format = /\s+format\([^)]+\)$/i.exec(component);
3657
- if (format) {
3658
- trailing = component.replace(format[0], ` format("${font}")`);
3659
- i = k;
3660
- break found;
3632
+ const setOutputURL = (value, asset) => {
3633
+ if (!value) {
3634
+ return;
3635
+ }
3636
+ if (asset) {
3637
+ if (!asset.inlineBase64) {
3638
+ if (host.Cloud?.getStorage('upload', asset.cloudStorage)) {
3639
+ const inlineUrlCloud = asset.inlineUrlCloud ||= (0, node_crypto_1.randomUUID)();
3640
+ (file.inlineUrlCloudMap ||= {})[inlineUrlCloud] = value;
3641
+ value = inlineUrlCloud;
3642
+ }
3643
+ else if (asset.hash && this.productionRelease) {
3644
+ const inlineUrl = asset.inlineUrl ||= (0, node_crypto_1.randomUUID)();
3645
+ (file.inlineUrlMap ||= {})[inlineUrl] = value;
3646
+ value = inlineUrl;
3647
+ }
3648
+ }
3649
+ const font = findFont(asset.format);
3650
+ if (font) {
3651
+ found: {
3652
+ for (let k = i + 1; k < length; ++k) {
3653
+ switch (source[k]) {
3654
+ case ')': {
3655
+ const component = source.substring(i + 1, k + 1);
3656
+ const format = /\s+format\([^)]+\)$/i.exec(component);
3657
+ if (format) {
3658
+ trailing = component.replace(format[0], ` format("${font}")`);
3659
+ i = k;
3660
+ break found;
3661
+ }
3662
+ break;
3661
3663
  }
3662
- break;
3664
+ case ',':
3665
+ case ';':
3666
+ case ':':
3667
+ case '}':
3668
+ break found;
3663
3669
  }
3664
- case ',':
3665
- case ';':
3666
- case ':':
3667
- case '}':
3668
- break found;
3669
3670
  }
3670
3671
  }
3671
3672
  }
3673
+ if (asset.initialValue && !asset.initialValue.cacheable) {
3674
+ file.flags |= 16;
3675
+ }
3676
+ related.push(asset);
3672
3677
  }
3673
- if (asset.initialValue && !asset.initialValue.cacheable) {
3674
- file.flags |= 16;
3678
+ if (!quote && !isHtml && !isJs) {
3679
+ if (!value.includes('"')) {
3680
+ quote = '"';
3681
+ }
3682
+ else if (!value.includes("'")) {
3683
+ quote = "'";
3684
+ }
3675
3685
  }
3676
- related.push(asset);
3677
- }
3678
- if (!quote && !isHtml && !isJs) {
3679
- if (!value.includes('"')) {
3680
- quote = '"';
3686
+ if (isUrl) {
3687
+ const index = value.indexOf('#');
3688
+ if (index !== -1) {
3689
+ value = value.substring(0, index);
3690
+ }
3681
3691
  }
3682
- else if (!value.includes("'")) {
3683
- quote = "'";
3692
+ if (quote) {
3693
+ value = quote + value + quote;
3684
3694
  }
3685
- }
3686
- if (isUrl) {
3687
- const index = value.indexOf('#');
3688
- if (index !== -1) {
3689
- value = value.substring(0, index);
3695
+ const revised = isJs ? `import(${value + trailing})` : isHref ? 'href=' + value : (isText ? '@import ' + value : `url(${value})`) + trailing;
3696
+ source = (0, util_1.spliceString)(source, startIndex, i + 1, revised, pattern);
3697
+ length = source.length;
3698
+ modified = true;
3699
+ };
3700
+ let url;
3701
+ if (isJs) {
3702
+ if (!quote) {
3703
+ continue;
3704
+ }
3705
+ const target = new RegExp(`^\\s*(${quote}((?:[^${quote}]|(?<=\\\\)${quote})+)${quote})\\s*(,.+)$`).exec(content);
3706
+ if (target) {
3707
+ url = target[1].trim();
3708
+ trailing = target[2].trim();
3709
+ }
3710
+ else {
3711
+ url = (0, util_1.trimQuote)(content);
3690
3712
  }
3691
- }
3692
- if (quote) {
3693
- value = quote + value + quote;
3694
- }
3695
- const revised = isJs ? `import(${value + trailing})` : isHref ? 'href=' + value : (isText ? '@import ' + value : `url(${value})`) + trailing;
3696
- source = (0, util_1.spliceString)(source, startIndex, i + 1, revised, pattern);
3697
- length = source.length;
3698
- modified = true;
3699
- };
3700
- let url;
3701
- if (isJs) {
3702
- if (!quote) {
3703
- continue;
3704
- }
3705
- const target = new RegExp(`^\\s*(${quote}((?:[^${quote}]|(?<=\\\\)${quote})+)${quote})\\s*(,.+)$`).exec(content);
3706
- if (target) {
3707
- url = target[1].trim();
3708
- trailing = target[2].trim();
3709
3713
  }
3710
3714
  else {
3711
3715
  url = (0, util_1.trimQuote)(content);
3712
3716
  }
3713
- }
3714
- else {
3715
- url = (0, util_1.trimQuote)(content);
3716
- }
3717
- if (url.startsWith('data:')) {
3718
- const base64 = url.split(',')[1]?.trim();
3719
- if (base64) {
3720
- for (const item of this.assets) {
3721
- if (item.base64 === base64) {
3722
- setOutputURL(this.getSrcUrl(file, item)[0], item);
3723
- break;
3717
+ if (url.startsWith('data:')) {
3718
+ const base64 = url.split(',')[1]?.trim();
3719
+ if (base64) {
3720
+ for (const item of this.assets) {
3721
+ if (item.base64 === base64) {
3722
+ setOutputURL(this.getSrcUrl(file, item)[0], item);
3723
+ break;
3724
+ }
3724
3725
  }
3725
3726
  }
3726
3727
  }
3727
- }
3728
- else if (baseHref.length > 0) {
3729
- let fullUrl, asset;
3730
- for (const parentUrl of baseHref) {
3731
- asset = host.findAsset(fullUrl = Document.resolvePath(url, parentUrl), { replaced: true });
3732
- if (!asset) {
3733
- const assets = this.related.get(file);
3734
- asset = assets && host.findAsset(fullUrl, { assets: Array.from(assets), replaced: true });
3735
- }
3736
- if (asset) {
3737
- break;
3728
+ else if (baseHref.length > 0) {
3729
+ let fullUrl, asset;
3730
+ for (const parentUrl of baseHref) {
3731
+ asset = host.findAsset(fullUrl = Document.resolvePath(url, parentUrl), { replaced: true });
3732
+ if (!asset) {
3733
+ const assets = this.related.get(file);
3734
+ asset = assets && host.findAsset(fullUrl, { assets: Array.from(assets), replaced: true });
3735
+ }
3736
+ if (asset) {
3737
+ break;
3738
+ }
3738
3739
  }
3739
- }
3740
- if (asset && asset !== importFile) {
3741
- if (!(0, util_1.hasValue)(asset.format, 'base64')) {
3742
- if (asset.bundleReplace) {
3743
- let k = 0, valid = true;
3744
- if (!isText) {
3745
- let j = startIndex;
3746
- while (isSpace(source[--j])) { }
3747
- valid = source.substring(k = j - 6, j + 1) === '@import';
3748
- }
3749
- else {
3750
- k = startIndex;
3751
- }
3752
- if (valid) {
3753
- let l = i, revised = transform_1.SourceMap.removeSourceMappingURL(host.getUTF8String(asset))[0];
3754
- for (let ch; l < length; ++l) {
3755
- if ((ch = source[l]) === ';' || ch === '\n') {
3756
- break;
3757
- }
3740
+ if (asset && asset !== importFile) {
3741
+ if (!(0, util_1.hasValue)(asset.format, 'base64')) {
3742
+ if (asset.bundleReplace) {
3743
+ let k = 0, valid = true;
3744
+ if (!isText) {
3745
+ let j = startIndex;
3746
+ while (isSpace(source[--j])) { }
3747
+ valid = source.substring(k = j - 6, j + 1).toLowerCase() === '@import';
3758
3748
  }
3759
- const layer = this.replaceContent(revised, source.substring(k, l + 1), "text/css");
3760
- if (layer) {
3761
- revised = layer;
3749
+ else {
3750
+ k = startIndex;
3762
3751
  }
3763
- revised = this.processUrl(host, file, this.removeServerRoot(revised), type, asset) || revised;
3764
- source = (0, util_1.spliceString)(source, k, l + 1, revised, pattern);
3765
- length = source.length;
3766
- if (file.watch) {
3767
- related.push(asset);
3768
- if (!(0, types_1.existsFlag)(asset.flags)) {
3769
- asset.flags |= 8;
3752
+ if (valid) {
3753
+ let l = i, revised = transform_1.SourceMap.removeSourceMappingURL(host.getUTF8String(asset))[0];
3754
+ for (let ch; l < length; ++l) {
3755
+ if ((ch = source[l]) === ';' || ch === '\n') {
3756
+ break;
3757
+ }
3770
3758
  }
3759
+ const layer = this.replaceContent(revised, source.substring(k, l + 1), "text/css");
3760
+ if (layer) {
3761
+ revised = layer;
3762
+ }
3763
+ revised = this.processUrl(host, file, this.removeServerRoot(revised), type, asset) || revised;
3764
+ source = (0, util_1.spliceString)(source, k, l + 1, revised, pattern);
3765
+ length = source.length;
3766
+ if (file.watch) {
3767
+ related.push(asset);
3768
+ if (!(0, types_1.existsFlag)(asset.flags)) {
3769
+ asset.flags |= 8;
3770
+ }
3771
+ }
3772
+ else if (asset.localUri) {
3773
+ host.deleteFile(asset.localUri, { ignorePermission: true, emptyDir: true, all: true, id: asset.id });
3774
+ asset.invalid = true;
3775
+ }
3776
+ modified = true;
3777
+ continue;
3771
3778
  }
3772
- else if (asset.localUri) {
3773
- host.deleteFile(asset.localUri, { ignorePermission: true, emptyDir: true, all: true, id: asset.id });
3774
- asset.invalid = true;
3779
+ }
3780
+ if (hasSameOrigin(asset.url || fullUrl, ...baseHref)) {
3781
+ let sameDir = false;
3782
+ [fullUrl, sameDir] = this.getSrcUrl(file, asset);
3783
+ if (sameDir && isJs) {
3784
+ fullUrl = './' + fullUrl;
3775
3785
  }
3776
- modified = true;
3777
- continue;
3778
3786
  }
3779
- }
3780
- if (hasSameOrigin(asset.url || fullUrl, ...baseHref)) {
3781
- let sameDir = false;
3782
- [fullUrl, sameDir] = this.getSrcUrl(file, asset);
3783
- if (sameDir && isJs) {
3784
- fullUrl = './' + fullUrl;
3787
+ else {
3788
+ const pathname = file.pathname;
3789
+ const count = pathname && pathname !== '/' ? pathname.split('/').length : 0;
3790
+ fullUrl = (count ? '../'.repeat(count) : '') + asset.relativeUrl;
3785
3791
  }
3786
3792
  }
3787
- else {
3788
- const pathname = file.pathname;
3789
- const count = pathname && pathname !== '/' ? pathname.split('/').length : 0;
3790
- fullUrl = (count ? '../'.repeat(count) : '') + asset.relativeUrl;
3793
+ else if (!asset.invalid) {
3794
+ fullUrl = asset.inlineBase64 ||= (0, node_crypto_1.randomUUID)();
3795
+ }
3796
+ if (url !== fullUrl) {
3797
+ setOutputURL(fullUrl, asset);
3791
3798
  }
3792
3799
  }
3793
- else if (!asset.invalid) {
3794
- fullUrl = asset.inlineBase64 ||= (0, node_crypto_1.randomUUID)();
3795
- }
3796
- if (url !== fullUrl) {
3797
- setOutputURL(fullUrl, asset);
3800
+ else if (importFile && url !== fullUrl) {
3801
+ setOutputURL(fullUrl);
3798
3802
  }
3799
3803
  }
3800
- else if (importFile && url !== fullUrl) {
3801
- setOutputURL(fullUrl);
3802
- }
3803
3804
  }
3804
3805
  }
3805
3806
  if (modified) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/chrome",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
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.9",
24
- "@e-mc/core": "^0.13.9",
25
- "@e-mc/document": "^0.13.9",
26
- "@e-mc/types": "^0.13.9",
23
+ "@e-mc/cloud": "^0.13.12",
24
+ "@e-mc/core": "^0.13.12",
25
+ "@e-mc/document": "^0.13.12",
26
+ "@e-mc/types": "^0.13.12",
27
27
  "image-size": "^2.0.2"
28
28
  }
29
29
  }