extension-develop 4.1.10 → 4.1.11

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.
@@ -747,11 +747,14 @@ function sandbox(manifest) {
747
747
  }
748
748
  };
749
749
  }
750
- function storage(manifest) {
750
+ function storage(manifest, manifestPath) {
751
751
  return manifest.storage && {
752
752
  storage: {
753
753
  ...manifest.storage.managed_schema && {
754
- managed_schema: getFilename('storage/managed_schema.json', manifest.storage.managed_schema)
754
+ managed_schema: (()=>{
755
+ const raw = String(manifest.storage.managed_schema);
756
+ return getFilename(manifestPageOutputTarget(raw, 'storage/managed_schema.json', manifestPath), raw);
757
+ })()
755
758
  }
756
759
  }
757
760
  };
@@ -818,7 +821,7 @@ function manifestCommon(manifest, manifestPath) {
818
821
  ...optionsPage(manifest, manifestPath),
819
822
  ...optionsUi(manifest, manifestPath),
820
823
  ...sandbox(manifest),
821
- ...storage(manifest),
824
+ ...storage(manifest, manifestPath),
822
825
  ...theme_theme(manifest),
823
826
  ...userScripts(manifest),
824
827
  ...webAccessibleResources(manifest),
@@ -1003,14 +1006,14 @@ function backgroundServiceWorker(manifest) {
1003
1006
  }
1004
1007
  };
1005
1008
  }
1006
- function declarativeNetRequest(manifest) {
1009
+ function declarativeNetRequest(manifest, manifestPath) {
1007
1010
  return manifest.declarative_net_request && {
1008
1011
  declarative_net_request: {
1009
1012
  ...manifest.declarative_net_request,
1010
1013
  ...Array.isArray(manifest.declarative_net_request.rule_resources) && {
1011
1014
  rule_resources: manifest.declarative_net_request.rule_resources.map((resourceObj)=>({
1012
1015
  ...resourceObj,
1013
- path: resourceObj.path && getFilename(`declarative_net_request/${resourceObj.id}.json`, resourceObj.path)
1016
+ path: resourceObj.path && getFilename(manifestPageOutputTarget(resourceObj.path, `declarative_net_request/${resourceObj.id}.json`, manifestPath), resourceObj.path)
1014
1017
  }))
1015
1018
  }
1016
1019
  }
@@ -1034,11 +1037,11 @@ function sidePanel(manifest) {
1034
1037
  }
1035
1038
  };
1036
1039
  }
1037
- function manifestV3(manifest) {
1040
+ function manifestV3(manifest, manifestPath) {
1038
1041
  return {
1039
1042
  ...action_action(manifest),
1040
1043
  ...backgroundServiceWorker(manifest),
1041
- ...declarativeNetRequest(manifest),
1044
+ ...declarativeNetRequest(manifest, manifestPath),
1042
1045
  ...hostPermissions(manifest),
1043
1046
  ...sidePanel(manifest)
1044
1047
  };
@@ -1056,7 +1059,7 @@ function getManifestOverrides(manifestPath, manifest) {
1056
1059
  };
1057
1060
  const common = manifestCommon(manifestContent, manifestPath);
1058
1061
  const mv2 = manifestV2(manifestContent);
1059
- const mv3 = manifestV3(manifestContent);
1062
+ const mv3 = manifestV3(manifestContent, manifestPath);
1060
1063
  const backgroundMerged = {
1061
1064
  ...manifestContent.background || {},
1062
1065
  ...pickBackground(common),
@@ -2920,6 +2923,19 @@ function parse_html_isUrl(src) {
2920
2923
  return false;
2921
2924
  }
2922
2925
  }
2926
+ function emitSrcsetCandidates(srcset, node, assetType, attributeName, onResourceFound) {
2927
+ for (const candidate of srcset.split(',')){
2928
+ const url = candidate.trim().split(/\s+/)[0];
2929
+ if (!url) continue;
2930
+ const { cleanPath } = cleanAssetUrl(url);
2931
+ if (cleanPath && !parse_html_isUrl(cleanPath)) onResourceFound({
2932
+ filePath: url,
2933
+ childNode: node,
2934
+ assetType,
2935
+ attributeName
2936
+ });
2937
+ }
2938
+ }
2923
2939
  function parseHtml(node, onResourceFound) {
2924
2940
  if ('#comment' === node.nodeName || '#text' === node.nodeName) return;
2925
2941
  if ("script" === node.nodeName) {
@@ -2935,16 +2951,7 @@ function parseHtml(node, onResourceFound) {
2935
2951
  const href = node.attrs?.find((attr)=>'href' === attr.name)?.value;
2936
2952
  const rel = node.attrs?.find((attr)=>'rel' === attr.name)?.value;
2937
2953
  const imagesrcset = node.attrs?.find((attr)=>'imagesrcset' === attr.name)?.value;
2938
- if (imagesrcset) for (const candidate of imagesrcset.split(',')){
2939
- const url = candidate.trim().split(/\s+/)[0];
2940
- if (!url) continue;
2941
- const { cleanPath } = cleanAssetUrl(url);
2942
- if (cleanPath && !parse_html_isUrl(cleanPath)) onResourceFound({
2943
- filePath: cleanPath,
2944
- childNode: node,
2945
- assetType: 'staticHref'
2946
- });
2947
- }
2954
+ if (imagesrcset) emitSrcsetCandidates(imagesrcset, node, 'staticHref', 'imagesrcset', onResourceFound);
2948
2955
  if (!href) return;
2949
2956
  if (parse_html_isUrl(href)) return;
2950
2957
  const nonStylesheetRelTokens = [
@@ -2964,7 +2971,8 @@ function parseHtml(node, onResourceFound) {
2964
2971
  onResourceFound(relTokens.some((token)=>nonStylesheetRelTokens.includes(token)) ? {
2965
2972
  filePath: href,
2966
2973
  childNode: node,
2967
- assetType: 'staticHref'
2974
+ assetType: 'staticHref',
2975
+ attributeName: 'href'
2968
2976
  } : {
2969
2977
  filePath: href,
2970
2978
  childNode: node,
@@ -2972,38 +2980,22 @@ function parseHtml(node, onResourceFound) {
2972
2980
  });
2973
2981
  } else if ('audio' === node.nodeName || 'embed' === node.nodeName || 'iframe' === node.nodeName || 'img' === node.nodeName || 'input' === node.nodeName || 'source' === node.nodeName || 'track' === node.nodeName || 'video' === node.nodeName) {
2974
2982
  const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
2975
- if (!src) return;
2976
- if (parse_html_isUrl(src)) return;
2977
- onResourceFound({
2983
+ if (src && !parse_html_isUrl(src)) onResourceFound({
2978
2984
  filePath: src,
2979
2985
  childNode: node,
2980
- assetType: 'staticSrc'
2986
+ assetType: 'staticSrc',
2987
+ attributeName: 'src'
2981
2988
  });
2982
2989
  const srcset = node.attrs?.find((attr)=>'srcset' === attr.name)?.value;
2983
- if (srcset) {
2984
- const candidates = srcset.split(',');
2985
- for (const candidate of candidates){
2986
- const parts = candidate.trim().split(/\s+/);
2987
- const url = parts[0];
2988
- if (!url) continue;
2989
- const { cleanPath } = cleanAssetUrl(url);
2990
- if (cleanPath && !parse_html_isUrl(cleanPath)) onResourceFound({
2991
- filePath: cleanPath,
2992
- childNode: node,
2993
- assetType: 'staticSrc'
2994
- });
2995
- }
2996
- }
2990
+ if (srcset) emitSrcsetCandidates(srcset, node, 'staticSrc', 'srcset', onResourceFound);
2997
2991
  if ('video' === node.nodeName) {
2998
2992
  const poster = node.attrs?.find((attr)=>'poster' === attr.name)?.value;
2999
- if (poster && !parse_html_isUrl(poster)) {
3000
- const { cleanPath } = cleanAssetUrl(poster);
3001
- if (cleanPath) onResourceFound({
3002
- filePath: cleanPath,
3003
- childNode: node,
3004
- assetType: 'staticSrc'
3005
- });
3006
- }
2993
+ if (poster && !parse_html_isUrl(poster)) onResourceFound({
2994
+ filePath: poster,
2995
+ childNode: node,
2996
+ assetType: 'staticSrc',
2997
+ attributeName: 'poster'
2998
+ });
3007
2999
  }
3008
3000
  }
3009
3001
  const { childNodes = [] } = node;
@@ -3122,6 +3114,27 @@ function utils_isUrl(src) {
3122
3114
  return false;
3123
3115
  }
3124
3116
  }
3117
+ function resolveStaticAttributeName(assetType, attributeName) {
3118
+ if (attributeName) return attributeName;
3119
+ return 'staticSrc' === assetType ? 'src' : 'href';
3120
+ }
3121
+ function rewriteSrcsetCandidate(srcset, fromCleanPath, toUrl) {
3122
+ return srcset.split(',').map((candidate)=>{
3123
+ const match = candidate.match(/^(\s*)(\S+)(.*)$/);
3124
+ if (!match) return candidate;
3125
+ const [, lead, url, rest] = match;
3126
+ const { cleanPath } = cleanAssetUrl(url);
3127
+ if (cleanPath !== fromCleanPath && url !== fromCleanPath) return candidate;
3128
+ return `${lead}${toUrl}${rest}`;
3129
+ }).join(',');
3130
+ }
3131
+ function applyRewrittenStaticUrl(node, attributeName, cleanPath, value) {
3132
+ if ('srcset' === attributeName || 'imagesrcset' === attributeName) {
3133
+ const current = __rspack_external_parse5_utilities_78b19c6a.getAttribute(node, attributeName) || '';
3134
+ return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, rewriteSrcsetCandidate(current, cleanPath, value));
3135
+ }
3136
+ return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, value);
3137
+ }
3125
3138
  function cleanAssetUrl(url) {
3126
3139
  const hashIndex = url.indexOf('#');
3127
3140
  const queryIndex = url.indexOf('?');
@@ -8099,19 +8112,20 @@ function resolveCssAsset(compilation, feature) {
8099
8112
  href: void 0
8100
8113
  };
8101
8114
  }
8102
- function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, baseHref, includeList, extname, childNode) {
8115
+ function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, baseHref, includeList, extname, childNode, attributeName) {
8103
8116
  const isFilepathListEntry = isFromFilepathList(absolutePath, includeList);
8104
8117
  __rspack_external_node_path_c5b9b54f.posix.join('/', cleanPath);
8118
+ const attrName = resolveStaticAttributeName(assetType, attributeName);
8105
8119
  let node = childNode;
8106
8120
  if (isFilepathListEntry) {
8107
8121
  const filepath = getHtmlPageDeclaredAssetPath(includeList, absolutePath, extname);
8108
- node = __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, 'staticSrc' === assetType ? 'src' : 'href', filepath + (search || '') + (hash || ''));
8122
+ node = applyRewrittenStaticUrl(node, attrName, cleanPath, filepath + (search || '') + (hash || ''));
8109
8123
  return node;
8110
8124
  }
8111
8125
  if (cleanPath.startsWith('/')) {
8112
8126
  const projectDir = __rspack_external_node_path_c5b9b54f.dirname(__rspack_external_node_path_c5b9b54f.dirname(htmlEntry));
8113
8127
  __rspack_external_node_path_c5b9b54f.join(projectDir, 'public', cleanPath.slice(1));
8114
- node = __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, 'staticSrc' === assetType ? 'src' : 'href', cleanPath + (search || '') + (hash || ''));
8128
+ node = applyRewrittenStaticUrl(node, attrName, cleanPath, cleanPath + (search || '') + (hash || ''));
8115
8129
  return node;
8116
8130
  }
8117
8131
  const baseJoin = baseHref && !/^\w+:\/\//.test(baseHref) ? __rspack_external_node_path_c5b9b54f.resolve(htmlDir, baseHref) : htmlDir;
@@ -8120,7 +8134,7 @@ function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetT
8120
8134
  const relativeFromHtml = fromRoot && toRoot && String(fromRoot).toLowerCase() !== String(toRoot).toLowerCase() ? __rspack_external_node_path_c5b9b54f.basename(absolutePath) : __rspack_external_node_path_c5b9b54f.relative(baseJoin, absolutePath);
8121
8135
  const posixRelative = relativeFromHtml.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
8122
8136
  const filepath = joinEmittedAssetName('assets', posixRelative);
8123
- if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) node = __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, 'staticSrc' === assetType ? 'src' : 'href', getFilePath(filepath, '', true) + (search || '') + (hash || ''));
8137
+ if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) node = applyRewrittenStaticUrl(node, attrName, cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
8124
8138
  return node;
8125
8139
  }
8126
8140
  function injectJsScript(bodyNode, feature, firstScriptAttrs) {
@@ -8171,7 +8185,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
8171
8185
  let bodyNode;
8172
8186
  for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
8173
8187
  for (const htmlChildNode of node.childNodes){
8174
- if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType })=>{
8188
+ if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType, attributeName })=>{
8175
8189
  const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlEntry);
8176
8190
  const { cleanPath, hash, search } = cleanAssetUrl(filePath);
8177
8191
  const absolutePath = __rspack_external_node_path_c5b9b54f.resolve(htmlDir, cleanPath);
@@ -8201,7 +8215,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
8201
8215
  break;
8202
8216
  case 'staticHref':
8203
8217
  case 'staticSrc':
8204
- thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, baseHref, includeList, extname, thisChildNode);
8218
+ thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, baseHref, includeList, extname, thisChildNode, attributeName);
8205
8219
  break;
8206
8220
  default:
8207
8221
  break;
@@ -8239,11 +8253,12 @@ function patchHtmlNested(compilation, htmlEntry) {
8239
8253
  encoding: 'utf8'
8240
8254
  });
8241
8255
  const htmlDocument = __rspack_external_parse5_utilities_78b19c6a.parse(htmlFile);
8242
- for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) for (const htmlChildNode of node.childNodes){
8243
- if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType })=>{
8256
+ for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
8257
+ for (const htmlChildNode of node.childNodes)if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType, attributeName })=>{
8244
8258
  const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlEntry);
8245
8259
  const { cleanPath, hash, search } = cleanAssetUrl(filePath);
8246
8260
  const absolutePath = __rspack_external_node_path_c5b9b54f.resolve(htmlDir, cleanPath);
8261
+ const attrName = 'staticSrc' === assetType || 'staticHref' === assetType ? resolveStaticAttributeName(assetType, attributeName) : void 0;
8247
8262
  let thisChildNode = childNode;
8248
8263
  switch(assetType){
8249
8264
  case "script":
@@ -8262,12 +8277,12 @@ function patchHtmlNested(compilation, htmlEntry) {
8262
8277
  case 'staticSrc':
8263
8278
  if (cleanPath.startsWith('/')) {
8264
8279
  warnIfPublicRootAssetMissing(compilation, htmlEntry, cleanPath);
8265
- thisChildNode = __rspack_external_parse5_utilities_78b19c6a.setAttribute(thisChildNode, 'staticSrc' === assetType ? 'src' : 'href', cleanPath + (search || '') + (hash || ''));
8280
+ thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, cleanPath + (search || '') + (hash || ''));
8266
8281
  } else if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) {
8267
8282
  const relativeFromHtml = __rspack_external_node_path_c5b9b54f.relative(htmlDir, absolutePath);
8268
8283
  const posixRelative = relativeFromHtml.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
8269
8284
  const filepath = joinEmittedAssetName('assets', posixRelative);
8270
- thisChildNode = __rspack_external_parse5_utilities_78b19c6a.setAttribute(thisChildNode, 'staticSrc' === assetType ? 'src' : 'href', getFilePath(filepath, '', true) + (search || '') + (hash || ''));
8285
+ thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
8271
8286
  }
8272
8287
  break;
8273
8288
  default:
@@ -9352,7 +9367,7 @@ function jsonIncludeSummary(totalFeatures, criticalCount) {
9352
9367
  return `${messaging_prefix('debug')} json include features=${String(totalFeatures)} critical=${String(criticalCount)}`;
9353
9368
  }
9354
9369
  function isCriticalJsonFeature(feature) {
9355
- return feature.startsWith('declarative_net_request') || 'storage.managed_schema' === feature;
9370
+ return feature.startsWith('declarative_net_request') || 'storage.managed_schema' === feature || 'storage/managed_schema' === feature;
9356
9371
  }
9357
9372
  function isPlainObject(value) {
9358
9373
  return 'object' == typeof value && null !== value && !Array.isArray(value);
@@ -9417,6 +9432,34 @@ function validateJsonAsset(compilation, feature, filePath, buf) {
9417
9432
  }
9418
9433
  return true;
9419
9434
  }
9435
+ function isInsideDir(abs, dir) {
9436
+ const rel = __rspack_external_node_path_c5b9b54f.relative(dir, abs);
9437
+ return Boolean(rel && !rel.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel));
9438
+ }
9439
+ function firstExisting(candidates) {
9440
+ for (const candidate of candidates)if (candidate && __rspack_external_node_fs_5ea92f0c.existsSync(candidate)) return candidate;
9441
+ }
9442
+ function resolveJsonResource(thisResource, manifestDir, projectPath) {
9443
+ const publicDir = __rspack_external_node_path_c5b9b54f.join(projectPath, 'public');
9444
+ const rawRef = String(thisResource);
9445
+ const looksLikeRootRef = rawRef.startsWith('/') && !rawRef.startsWith('//') && !(projectPath && rawRef.startsWith(projectPath));
9446
+ const isPublicRoot = looksLikeRootRef && (!__rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) || __rspack_external_node_path_c5b9b54f.dirname(rawRef) === __rspack_external_node_path_c5b9b54f.parse(rawRef).root);
9447
+ const joined = __rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) ? rawRef : __rspack_external_node_path_c5b9b54f.join(manifestDir, rawRef);
9448
+ const publicFromProject = isInsideDir(joined, projectPath) ? __rspack_external_node_path_c5b9b54f.join(publicDir, __rspack_external_node_path_c5b9b54f.relative(projectPath, joined)) : '';
9449
+ const publicFromSlash = looksLikeRootRef ? __rspack_external_node_path_c5b9b54f.join(publicDir, rawRef.replace(/^\/+/, '')) : '';
9450
+ const publicFromRelative = __rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) || rawRef.startsWith('public/') ? '' : __rspack_external_node_path_c5b9b54f.join(publicDir, rawRef);
9451
+ const abs = firstExisting([
9452
+ joined,
9453
+ publicFromProject,
9454
+ publicFromSlash,
9455
+ publicFromRelative
9456
+ ]) || joined;
9457
+ return {
9458
+ abs,
9459
+ isUnderPublic: isInsideDir(abs, publicDir),
9460
+ isPublicRoot
9461
+ };
9462
+ }
9420
9463
  function getProjectPathFromCompilation(compilation, manifestPath) {
9421
9464
  return compilation.compiler.options.context || compilation.options.context || __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
9422
9465
  }
@@ -9442,14 +9485,10 @@ function processJsonAssets(compilation, manifestPath, includeList) {
9442
9485
  resource
9443
9486
  ];
9444
9487
  for (const thisResource of resourceArr)if (thisResource) {
9445
- const abs = __rspack_external_node_path_c5b9b54f.isAbsolute(thisResource) ? thisResource : __rspack_external_node_path_c5b9b54f.join(manifestDir, thisResource);
9446
- const relToPublic = __rspack_external_node_path_c5b9b54f.relative(publicDir, abs);
9447
- const isUnderPublic = relToPublic && !relToPublic.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(relToPublic);
9488
+ const { abs, isUnderPublic, isPublicRoot } = resolveJsonResource(thisResource, manifestDir, projectPath);
9448
9489
  if (!__rspack_external_node_fs_5ea92f0c.existsSync(abs)) {
9449
- const rawRef = String(thisResource);
9450
- const isPublicRoot = rawRef.startsWith('/') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rawRef);
9451
9490
  const outputRoot = compilation?.options?.output?.path || '';
9452
- const displayPath = isPublicRoot ? __rspack_external_node_path_c5b9b54f.join(outputRoot, rawRef.slice(1)) : abs;
9491
+ const displayPath = isPublicRoot ? __rspack_external_node_path_c5b9b54f.join(outputRoot || publicDir, String(thisResource).slice(1)) : abs;
9453
9492
  const isFatal = isCriticalJsonFeature(feature);
9454
9493
  const notFound = new core_WebpackError(jsonMissingFile(feature, displayPath, {
9455
9494
  publicRootHint: isPublicRoot,
@@ -9505,6 +9544,7 @@ function trackJsonDependencies(compilation, manifestPath, includeList) {
9505
9544
  if (compilation.errors?.length) return;
9506
9545
  const jsonFields = includeList || {};
9507
9546
  const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
9547
+ const projectPath = compilation.compiler.options.context || compilation.options.context || manifestDir;
9508
9548
  let added = 0;
9509
9549
  for (const field of Object.entries(jsonFields)){
9510
9550
  const [, resource] = field;
@@ -9512,7 +9552,7 @@ function trackJsonDependencies(compilation, manifestPath, includeList) {
9512
9552
  resource
9513
9553
  ];
9514
9554
  for (const thisResource of resourceArr)if (thisResource) {
9515
- const abs = __rspack_external_node_path_c5b9b54f.isAbsolute(thisResource) ? thisResource : __rspack_external_node_path_c5b9b54f.join(manifestDir, thisResource);
9555
+ const { abs } = resolveJsonResource(thisResource, manifestDir, projectPath);
9516
9556
  if (__rspack_external_node_fs_5ea92f0c.existsSync(abs) && !compilation.fileDependencies.has(abs)) {
9517
9557
  compilation.fileDependencies.add(abs);
9518
9558
  added++;
package/dist/101.mjs CHANGED
@@ -699,7 +699,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
699
699
  }
700
700
  return false;
701
701
  }
702
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.10","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.0","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
702
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.11","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.1","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
703
703
  function asAbsolute(p) {
704
704
  return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
705
705
  }
package/dist/839.mjs CHANGED
@@ -1255,28 +1255,79 @@ async function dispatchReload(instruction, executor) {
1255
1255
  if (warning) console.warn(warning);
1256
1256
  }
1257
1257
  }
1258
+ function isForcedFullPath(normalized) {
1259
+ return normalized.includes('manifest.json') || normalized.includes('_locales/');
1260
+ }
1261
+ function isHotAsset(normalized) {
1262
+ return normalized.startsWith('hot/') || normalized.includes('.hot-update.');
1263
+ }
1264
+ function normalizeChangedPath(file, contextDir) {
1265
+ const raw = String(file || '');
1266
+ if (!raw) return;
1267
+ const normalized = __rspack_external_node_path_c5b9b54f.isAbsolute(raw) ? __rspack_external_node_path_c5b9b54f.relative(contextDir, raw).replace(/\\/g, '/') : raw.replace(/\\/g, '/');
1268
+ if (!normalized) return;
1269
+ return normalized;
1270
+ }
1271
+ function pushChanged(into, file, contextDir, markForced) {
1272
+ const normalized = normalizeChangedPath(file, contextDir);
1273
+ if (!normalized) return;
1274
+ if (!into.includes(normalized)) into.push(normalized);
1275
+ if (isForcedFullPath(normalized)) markForced();
1276
+ }
1258
1277
  function createChangedSourcesTracker(compiler) {
1259
1278
  let forcedFull = false;
1260
1279
  let changedSources = [];
1280
+ let heldForcedFull = false;
1281
+ let heldSources = [];
1282
+ let writtenAssets = [];
1283
+ const contextDir = ()=>compiler.options.context || '';
1284
+ const ingest = (files, into, markForced)=>{
1285
+ if (!files) return;
1286
+ const ctx = contextDir();
1287
+ for (const file of files)pushChanged(into, file, ctx, markForced);
1288
+ };
1289
+ const foldRecoveryIntoCurrent = ()=>{
1290
+ const recovering = heldSources.length > 0 || heldForcedFull;
1291
+ if (!recovering) return;
1292
+ for (const file of heldSources)if (!changedSources.includes(file)) changedSources.push(file);
1293
+ for (const file of writtenAssets)if (!changedSources.includes(file)) changedSources.push(file);
1294
+ forcedFull = forcedFull || heldForcedFull || writtenAssets.some((file)=>isForcedFullPath(file));
1295
+ heldSources = [];
1296
+ heldForcedFull = false;
1297
+ };
1298
+ const markForced = ()=>{
1299
+ forcedFull = true;
1300
+ };
1261
1301
  compiler.hooks.watchRun.tap('extjs-reload-changed-sources', ()=>{
1262
1302
  forcedFull = false;
1263
1303
  changedSources = [];
1264
- const modifiedFiles = compiler.modifiedFiles;
1265
- if (!modifiedFiles || 0 === modifiedFiles.size) return;
1266
- const contextDir = compiler.options.context || '';
1267
- for (const file of modifiedFiles){
1268
- const normalized = __rspack_external_node_path_c5b9b54f.relative(contextDir, file).replace(/\\/g, '/');
1269
- if (normalized) {
1270
- changedSources.push(normalized);
1271
- if (normalized.includes('manifest.json') || normalized.includes('_locales/')) forcedFull = true;
1272
- }
1304
+ writtenAssets = [];
1305
+ ingest(compiler.modifiedFiles, changedSources, markForced);
1306
+ });
1307
+ compiler.hooks.done?.tap?.('extjs-reload-changed-sources-done', (stats)=>{
1308
+ const compilation = stats?.compilation;
1309
+ ingest(compilation?.modifiedFiles, changedSources, markForced);
1310
+ ingest(compiler.modifiedFiles, changedSources, markForced);
1311
+ if (compilation?.errors && compilation.errors.length > 0) {
1312
+ heldForcedFull = heldForcedFull || forcedFull;
1313
+ for (const file of changedSources)if (!heldSources.includes(file)) heldSources.push(file);
1314
+ return;
1273
1315
  }
1316
+ foldRecoveryIntoCurrent();
1317
+ });
1318
+ compiler.hooks.assetEmitted?.tap?.('extjs-reload-changed-sources-emitted', (file)=>{
1319
+ const normalized = normalizeChangedPath(file, contextDir());
1320
+ if (!normalized || isHotAsset(normalized)) return;
1321
+ if (!writtenAssets.includes(normalized)) writtenAssets.push(normalized);
1274
1322
  });
1275
1323
  return {
1276
- snapshot: ()=>({
1324
+ snapshot: ()=>{
1325
+ foldRecoveryIntoCurrent();
1326
+ return {
1277
1327
  forcedFull,
1278
1328
  changedSources
1279
- })
1329
+ };
1330
+ }
1280
1331
  };
1281
1332
  }
1282
1333
  function formatReloadContextLabel(context, files) {
@@ -1,17 +1,79 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  const GETURL_ARG = /\bruntime\s*\.\s*getURL\s*\(/;
3
3
  const BARE_IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
4
- function identifierBoundToGetURL(source, name) {
5
- const id = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
- const rhs = '[^;\\n]*\\bruntime\\s*\\.\\s*getURL\\s*\\(';
7
- const declared = new RegExp('\\b(?:const|let|var)\\s+' + id + '\\s*=' + rhs);
8
- const assigned = new RegExp('(?:^|[^\\w$.])' + id + '\\s*=(?!=)' + rhs);
9
- return declared.test(source) || assigned.test(source);
4
+ const MEMBER_PATH = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)+$/;
5
+ const escapeId = (name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
+ function codeOnly(source) {
7
+ let out = '';
8
+ const n = source.length;
9
+ let i = 0;
10
+ let prevSignificant = '';
11
+ while(i < n){
12
+ const char = source[i];
13
+ const next = source[i + 1];
14
+ if ('/' === char && '/' === next) {
15
+ while(i < n && '\n' !== source[i])i++;
16
+ continue;
17
+ }
18
+ if ('/' === char && '*' === next) {
19
+ const end = source.indexOf('*/', i + 2);
20
+ i = -1 === end ? n : end + 2;
21
+ continue;
22
+ }
23
+ if ('"' === char || "'" === char || '`' === char) {
24
+ const close = skipString(source, i, n);
25
+ out += source.slice(i, close + 1);
26
+ i = close + 1;
27
+ prevSignificant = char;
28
+ continue;
29
+ }
30
+ if ('/' === char && regexCanStart(prevSignificant)) {
31
+ i = skipRegex(source, i, n) + 1;
32
+ prevSignificant = '/';
33
+ continue;
34
+ }
35
+ out += char;
36
+ if (!/\s/.test(char)) prevSignificant = char;
37
+ i++;
38
+ }
39
+ return out;
40
+ }
41
+ const RHS = '[\\s\\S]{0,400}?\\bruntime\\s*\\.\\s*getURL\\s*\\(';
42
+ const TYPE_ANNOTATION = '(?:\\s*:[^=;\\n]{0,120})?';
43
+ function identifierBoundToGetURL(code, name) {
44
+ const id = escapeId(name);
45
+ const declared = new RegExp('\\b(?:const|let|var)\\s+' + id + TYPE_ANNOTATION + '\\s*=' + RHS);
46
+ const assigned = new RegExp('(?:^|[^\\w$.])' + id + '\\s*=(?!=)' + RHS);
47
+ return declared.test(code) || assigned.test(code);
48
+ }
49
+ function memberBoundToGetURL(code, path) {
50
+ const parts = path.split('.').map((p)=>p.trim());
51
+ const leaf = escapeId(parts[parts.length - 1]);
52
+ const root = escapeId(parts[0]);
53
+ const property = new RegExp('\\b(?:const|let|var)\\s+' + root + TYPE_ANNOTATION + '\\s*=[\\s\\S]{0,400}?\\b' + leaf + '\\s*:[^,}]{0,200}?\\bruntime\\s*\\.\\s*getURL\\s*\\(');
54
+ const assigned = new RegExp('(?:^|[^\\w$])' + escapeId(path.replace(/\s+/g, '')) + '\\s*=(?!=)' + RHS);
55
+ return property.test(code) || assigned.test(code.replace(/\s*\.\s*/g, '.'));
56
+ }
57
+ function firstArgument(args) {
58
+ let depth = 0;
59
+ for(let i = 0; i < args.length; i++){
60
+ const char = args[i];
61
+ if ('"' === char || "'" === char || '`' === char) {
62
+ i = skipString(args, i, args.length);
63
+ continue;
64
+ }
65
+ if ('(' === char || '[' === char || '{' === char) depth++;
66
+ else if (')' === char || ']' === char || '}' === char) depth--;
67
+ else if (',' === char && 0 === depth) return args.slice(0, i);
68
+ }
69
+ return args;
10
70
  }
11
71
  function annotateGetURLDynamicImports(source) {
12
72
  const insertions = [];
13
73
  const n = source.length;
14
74
  let i = 0;
75
+ let cachedCode = null;
76
+ const bindingSource = ()=>cachedCode ??= codeOnly(source);
15
77
  let prevSignificant = '';
16
78
  while(i < n){
17
79
  const char = source[i];
@@ -41,9 +103,11 @@ function annotateGetURLDynamicImports(source) {
41
103
  if ('(' === source[j]) {
42
104
  const args = readBalancedArgs(source, j);
43
105
  if (null != args && !args.includes('webpackIgnore')) {
44
- const direct = GETURL_ARG.test(args);
45
- const name = args.trim();
46
- if (direct || BARE_IDENTIFIER.test(name) && identifierBoundToGetURL(source, name)) insertions.push(j + 1);
106
+ const specifier = firstArgument(args);
107
+ const direct = GETURL_ARG.test(specifier);
108
+ const name = specifier.trim();
109
+ const code = bindingSource();
110
+ if (direct || BARE_IDENTIFIER.test(name) && identifierBoundToGetURL(code, name) || MEMBER_PATH.test(name) && memberBoundToGetURL(code, name)) insertions.push(j + 1);
47
111
  }
48
112
  }
49
113
  prevSignificant = 't';
@@ -17,7 +17,7 @@ export declare function dispatchReload(instruction: ReloadInstruction | undefine
17
17
  export interface ChangedSourcesSnapshot {
18
18
  /** A manifest.json / _locales change, forces a full reload regardless of which other files changed. */
19
19
  forcedFull: boolean;
20
- /** Project-relative, forward-slashed paths of every file changed since the last compile. */
20
+ /** Project-relative, forward-slashed paths of every file changed since the last successful compile. */
21
21
  changedSources: string[];
22
22
  }
23
23
  export interface ChangedSourcesTracker {
@@ -1,3 +1,4 @@
1
- import * as parse5utilities from 'parse5-utilities';
1
+ import type * as parse5utilities from 'parse5-utilities';
2
2
  import type { FilepathList } from '../../../types';
3
- export declare function handleStaticAsset(compilation: unknown, htmlEntry: string, htmlDir: string, absolutePath: string, assetType: 'staticSrc' | 'staticHref', cleanPath: string, search: string | undefined, hash: string | undefined, baseHref: string | undefined, includeList: FilepathList, extname: string, childNode: parse5utilities.ParsedNode): parse5utilities.ParsedNode;
3
+ import type { HtmlStaticAttribute } from './parse-html';
4
+ export declare function handleStaticAsset(compilation: unknown, htmlEntry: string, htmlDir: string, absolutePath: string, assetType: 'staticSrc' | 'staticHref', cleanPath: string, search: string | undefined, hash: string | undefined, baseHref: string | undefined, includeList: FilepathList, extname: string, childNode: parse5utilities.ParsedNode, attributeName?: HtmlStaticAttribute): parse5utilities.ParsedNode;
@@ -1,8 +1,10 @@
1
1
  import type * as parse5utilities from 'parse5-utilities';
2
+ export type HtmlStaticAttribute = 'src' | 'href' | 'poster' | 'srcset' | 'imagesrcset';
2
3
  interface OnResourceFoundOptions {
3
4
  filePath: string;
4
5
  childNode: ReturnType<typeof parse5utilities.createNode>;
5
6
  assetType: 'script' | 'css' | 'staticSrc' | 'staticHref';
7
+ attributeName?: HtmlStaticAttribute;
6
8
  }
7
9
  export declare function parseHtml(node: ReturnType<typeof parse5utilities.createNode>, onResourceFound: (options: OnResourceFoundOptions) => void): void;
8
10
  export {};
@@ -1,4 +1,6 @@
1
+ import * as parse5utilities from 'parse5-utilities';
1
2
  import type { FilepathList } from '../../../types';
3
+ import { type HtmlStaticAttribute } from './parse-html';
2
4
  export interface ParsedHtmlAsset {
3
5
  css?: string[];
4
6
  js?: string[];
@@ -12,6 +14,10 @@ export declare function getExtname(filePath: string): string;
12
14
  export declare function getFilePath(filePath: string, extension: string, isPublic: boolean): string;
13
15
  export declare function isFromIncludeList(filePath: string, includeList?: FilepathList): boolean;
14
16
  export declare function isUrl(src: string): boolean;
17
+ export type { HtmlStaticAttribute };
18
+ export declare function resolveStaticAttributeName(assetType: 'staticSrc' | 'staticHref', attributeName?: HtmlStaticAttribute): HtmlStaticAttribute;
19
+ export declare function rewriteSrcsetCandidate(srcset: string, fromCleanPath: string, toUrl: string): string;
20
+ export declare function applyRewrittenStaticUrl(node: parse5utilities.ParsedNode, attributeName: HtmlStaticAttribute, cleanPath: string, value: string): parse5utilities.ParsedNode;
15
21
  export declare function cleanAssetUrl(url: string): {
16
22
  cleanPath: string;
17
23
  hash: string;
@@ -0,0 +1,6 @@
1
+ export interface ResolvedJsonResource {
2
+ abs: string;
3
+ isUnderPublic: boolean;
4
+ isPublicRoot: boolean;
5
+ }
6
+ export declare function resolveJsonResource(thisResource: string, manifestDir: string, projectPath: string): ResolvedJsonResource;
@@ -1,5 +1,5 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function storage(manifest: Manifest): {
2
+ export declare function storage(manifest: Manifest, manifestPath?: string): {
3
3
  storage: {
4
4
  managed_schema?: string | undefined;
5
5
  };
@@ -1,2 +1,2 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function declarativeNetRequest(manifest: Manifest): any;
2
+ export declare function declarativeNetRequest(manifest: Manifest, manifestPath?: string): any;
@@ -1,2 +1,2 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function manifestV3(manifest: Manifest): any;
2
+ export declare function manifestV3(manifest: Manifest, manifestPath?: string): any;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.1.10",
46
+ "version": "4.1.11",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",
@@ -99,7 +99,7 @@
99
99
  "@rspack/plugin-react-refresh": "2.0.2",
100
100
  "@vue/compiler-sfc": "3.5.26",
101
101
  "acorn": "^8.16.0",
102
- "browser-extension-manifest-fields": "^2.3.0",
102
+ "browser-extension-manifest-fields": "^2.3.1",
103
103
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
104
104
  "content-security-policy-parser": "^0.6.0",
105
105
  "dotenv": "^17.2.3",