extension-develop 4.0.5 → 4.0.6-canary.1783360784.dd7d1aae

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 (33) hide show
  1. package/dist/0~rspack-config.mjs +378 -35
  2. package/dist/101.mjs +1 -1
  3. package/dist/224.mjs +9 -1
  4. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  5. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -4
  6. package/dist/extension-js-devtools/chrome/pages/welcome.js +1 -1
  7. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  8. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -4
  9. package/dist/extension-js-devtools/chromium/pages/welcome.js +1 -1
  10. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  11. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -4
  12. package/dist/extension-js-devtools/edge/pages/welcome.js +1 -1
  13. package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +2 -2
  14. package/dist/extension-js-devtools/extension-js/chrome/ready.json +7 -7
  15. package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +2 -2
  16. package/dist/extension-js-devtools/extension-js/chromium/ready.json +7 -7
  17. package/dist/extension-js-devtools/extension-js/edge/events.ndjson +2 -2
  18. package/dist/extension-js-devtools/extension-js/edge/ready.json +7 -7
  19. package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +2 -2
  20. package/dist/extension-js-devtools/extension-js/firefox/ready.json +7 -7
  21. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  22. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -4
  23. package/dist/extension-js-devtools/firefox/pages/welcome.js +1 -1
  24. package/dist/extension-js-theme/chromium/Cached Theme.pak +0 -0
  25. package/dist/extension-js-theme/extension-js/chrome/events.ndjson +2 -2
  26. package/dist/extension-js-theme/extension-js/chrome/ready.json +7 -7
  27. package/dist/extension-js-theme/extension-js/chromium/events.ndjson +2 -2
  28. package/dist/extension-js-theme/extension-js/chromium/ready.json +7 -7
  29. package/dist/extension-js-theme/extension-js/edge/events.ndjson +2 -2
  30. package/dist/extension-js-theme/extension-js/edge/ready.json +7 -7
  31. package/dist/extension-js-theme/extension-js/firefox/events.ndjson +22 -6
  32. package/dist/extension-js-theme/extension-js/firefox/ready.json +7 -7
  33. package/package.json +1 -1
@@ -19,7 +19,7 @@ import { stripBom, parseJsonSafe } from "./23.mjs";
19
19
  import { scrubBrand, makeSanitizedConsole } from "./0~branding.mjs";
20
20
  import { cssIntegrationsEnabled, cssConfigsDetected, missingSassDependency, isUsingIntegration } from "./845.mjs";
21
21
  import { isUsingTypeScript, jsFrameworksIntegrationsEnabled, ensureTypeScriptConfig, ensureOptionalContractModuleLoaded, resolveDevelopInstallRoot, getUserTypeScriptConfigFile, isUsingCustomLoader, isUsingIntegration as messages_isUsingIntegration, loadOptionalContractModuleWithoutInstall, resolveOptionalContractPackageWithoutInstall, jsFrameworksHmrSummary, jsFrameworksConfigsDetected, hasDependency, resolveDevelopDistFile, optional_deps_resolver_ensureOptionalContractPackageResolved } from "./839.mjs";
22
- import { findNearestPackageJsonSync, backgroundIsRequiredMessageOnly } from "./224.mjs";
22
+ import { injectedFileDependencyMissing, findNearestPackageJsonSync, backgroundIsRequiredMessageOnly, importScriptsDependencyMissing } from "./224.mjs";
23
23
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
24
24
  import { dirname as __rspack_dirname } from "node:path";
25
25
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
@@ -376,6 +376,9 @@ function envInjectedPublicVars(count) {
376
376
  `${pintor.gray('INJECTED')} ${pintor.gray(String(count))} EXTENSION_PUBLIC_*`
377
377
  ].join('\n');
378
378
  }
379
+ function envNoMatchingFile(browser, mode, presentFiles, expectedCandidates) {
380
+ return `Found ${presentFiles.map((file)=>pintor.yellow(file)).join(', ')} but none match browser ${pintor.yellow(browser)} (mode ${pintor.yellow(mode)}), so EXTENSION_PUBLIC_* variables read from code will be ${pintor.yellow('undefined')} in this build.\nMatching names, in priority order: ${expectedCandidates.map((file)=>pintor.gray(file)).join(', ')}.\nFamily names apply to every family member — e.g. ${pintor.yellow('.env.chrome')} also matches ${pintor.yellow('chromium')} and ${pintor.yellow('edge')} targets.`;
381
+ }
379
382
  function isFromFilepathList(filePath, filepathList) {
380
383
  return Object.values(filepathList || {}).some((value)=>value === filePath);
381
384
  }
@@ -1025,6 +1028,32 @@ function resolveEnvPaths(projectPath, envFiles) {
1025
1028
  defaultsPath: localDefaultsPath
1026
1029
  };
1027
1030
  }
1031
+ function getEnvFileCandidates(browser, mode) {
1032
+ const browserName = String(browser);
1033
+ const isChromiumTarget = isChromiumBasedBrowser(browserName) || 'safari' === browserName || browserName.includes('webkit');
1034
+ const familyNames = isChromiumTarget ? [
1035
+ 'chromium',
1036
+ 'chrome',
1037
+ 'edge',
1038
+ 'chromium-based'
1039
+ ] : constants_isGeckoBasedBrowser(browserName) ? [
1040
+ 'firefox',
1041
+ 'gecko-based'
1042
+ ] : [];
1043
+ const names = [
1044
+ browserName,
1045
+ ...familyNames.filter((name)=>name !== browserName)
1046
+ ];
1047
+ return [
1048
+ ...names.flatMap((name)=>[
1049
+ `.env.${name}.${mode}`,
1050
+ `.env.${name}`
1051
+ ]),
1052
+ `.env.${mode}`,
1053
+ '.env.local',
1054
+ '.env'
1055
+ ];
1056
+ }
1028
1057
  class EnvPlugin {
1029
1058
  browser;
1030
1059
  manifestPath;
@@ -1035,23 +1064,22 @@ class EnvPlugin {
1035
1064
  apply(compiler) {
1036
1065
  const projectPath = compiler.options.context || (this.manifestPath ? __rspack_external_path.dirname(this.manifestPath) : '');
1037
1066
  const mode = compiler.options.mode || 'development';
1038
- const envFiles = [
1039
- `.env.${this.browser}.${mode}`,
1040
- `.env.${this.browser}`,
1041
- `.env.${mode}`,
1042
- '.env.local',
1043
- '.env'
1044
- ];
1067
+ const envFiles = getEnvFileCandidates(this.browser, mode);
1045
1068
  const { envPath, defaultsPath } = resolveEnvPaths(projectPath, envFiles);
1046
1069
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(envSelectedFile(envPath));
1047
- const envVars = envPath ? __rspack_external_dotenv.config({
1048
- path: envPath,
1049
- quiet: true
1050
- }).parsed || {} : {};
1051
- const defaultsVars = __rspack_external_fs.existsSync(defaultsPath) ? __rspack_external_dotenv.config({
1052
- path: defaultsPath,
1053
- quiet: true
1054
- }).parsed || {} : {};
1070
+ if (!envPath && projectPath) {
1071
+ let unmatchedEnvFiles = [];
1072
+ try {
1073
+ unmatchedEnvFiles = __rspack_external_fs.readdirSync(projectPath).filter((file)=>file.startsWith('.env') && '.env.defaults' !== file && '.env.example' !== file).sort();
1074
+ } catch {}
1075
+ if (unmatchedEnvFiles.length > 0) compiler.hooks.thisCompilation.tap('env:warn-unmatched', (compilation)=>{
1076
+ const warn = new core_WebpackError(envNoMatchingFile(String(this.browser), String(mode), unmatchedEnvFiles, envFiles));
1077
+ warn.name = 'EnvNoMatchingFile';
1078
+ compilation.warnings.push(warn);
1079
+ });
1080
+ }
1081
+ const envVars = envPath ? __rspack_external_dotenv.parse(__rspack_external_fs.readFileSync(envPath)) : {};
1082
+ const defaultsVars = __rspack_external_fs.existsSync(defaultsPath) ? __rspack_external_dotenv.parse(__rspack_external_fs.readFileSync(defaultsPath)) : {};
1055
1083
  const combinedVars = {
1056
1084
  ...defaultsVars,
1057
1085
  ...envVars,
@@ -1074,6 +1102,9 @@ class EnvPlugin {
1074
1102
  filteredEnvVars['import.meta.env.BROWSER'] = JSON.stringify(this.browser);
1075
1103
  filteredEnvVars['process.env.MODE'] = JSON.stringify(mode);
1076
1104
  filteredEnvVars['import.meta.env.MODE'] = JSON.stringify(mode);
1105
+ const importMetaEnvObject = {};
1106
+ for (const [key, value] of Object.entries(filteredEnvVars))if (key.startsWith('import.meta.env.')) importMetaEnvObject[key.slice(16)] = JSON.parse(value);
1107
+ filteredEnvVars['import.meta.env'] = JSON.stringify(importMetaEnvObject);
1077
1108
  filteredEnvVars['import.meta.dirname'] = 'undefined';
1078
1109
  filteredEnvVars['import.meta.filename'] = 'undefined';
1079
1110
  const injectedCount = Object.keys(filteredEnvVars).filter((k)=>k.startsWith('process.env.EXTENSION_PUBLIC_')).length;
@@ -2635,7 +2666,21 @@ function parseHtml(node, onResourceFound) {
2635
2666
  }
2636
2667
  if (!href) return;
2637
2668
  if (parse_html_isUrl(href)) return;
2638
- onResourceFound('dns-prefetch' === rel || 'icon' === rel || 'manifest' === rel || 'modulepreload' === rel || 'preconnect' === rel || 'prefetch' === rel || 'preload' === rel || 'prerender' === rel ? {
2669
+ const nonStylesheetRelTokens = [
2670
+ 'dns-prefetch',
2671
+ 'icon',
2672
+ 'apple-touch-icon',
2673
+ 'apple-touch-icon-precomposed',
2674
+ 'mask-icon',
2675
+ 'manifest',
2676
+ 'modulepreload',
2677
+ 'preconnect',
2678
+ 'prefetch',
2679
+ 'preload',
2680
+ 'prerender'
2681
+ ];
2682
+ const relTokens = rel ? rel.toLowerCase().split(/\s+/) : [];
2683
+ onResourceFound(relTokens.some((token)=>nonStylesheetRelTokens.includes(token)) ? {
2639
2684
  filePath: href,
2640
2685
  childNode: node,
2641
2686
  assetType: 'staticHref'
@@ -4896,6 +4941,22 @@ class AddAssetsToCompilation {
4896
4941
  });
4897
4942
  }
4898
4943
  }
4944
+ function isClassicScript(filePath) {
4945
+ try {
4946
+ const src = __rspack_external_fs.readFileSync(filePath, 'utf8');
4947
+ return !/^\s*import[\s{('"*]/m.test(src) && !/^\s*export[\s{*( ]/m.test(src);
4948
+ } catch {
4949
+ return false;
4950
+ }
4951
+ }
4952
+ function classicConcatEntry(feature, jsFiles) {
4953
+ const queryData = encodeURIComponent(JSON.stringify({
4954
+ feature,
4955
+ js: jsFiles,
4956
+ css: []
4957
+ }));
4958
+ return `${jsFiles[0]}?__extensionjs_classic_concat__=${queryData}`;
4959
+ }
4899
4960
  const WILDCARD_HOSTS = new Set([
4900
4961
  '0.0.0.0',
4901
4962
  '::',
@@ -5012,8 +5073,13 @@ class AddScriptsAndStylesToCompilation {
5012
5073
  const looksLikePublicRootUrl = (p)=>p.startsWith('/public/') || p.startsWith('/') && !p.startsWith(projectRoot) && hasPublicDir;
5013
5074
  const jsAssets = (htmlAssets?.js || []).filter((asset)=>!looksLikePublicRootUrl(asset) && !isRemoteUrl(asset));
5014
5075
  const cssAssets = (htmlAssets?.css || []).filter((asset)=>!looksLikePublicRootUrl(asset) && !isRemoteUrl(asset));
5076
+ const moduleJsAssets = new Set(htmlAssets?.moduleJs || []);
5077
+ const concatenateClassic = jsAssets.length > 1 && jsAssets.every((asset)=>!moduleJsAssets.has(asset) && /\.(js|cjs)$/i.test(asset) && isClassicScript(asset));
5078
+ const jsImports = concatenateClassic ? [
5079
+ classicConcatEntry(feature, jsAssets)
5080
+ ] : jsAssets;
5015
5081
  const fileAssets = [
5016
- ...jsAssets,
5082
+ ...jsImports,
5017
5083
  ...cssAssets
5018
5084
  ];
5019
5085
  if ('development' === compiler.options.mode) {
@@ -5504,23 +5570,8 @@ const isScriptsFolderFeature = (feature)=>feature.startsWith("scripts/");
5504
5570
  const isBackgroundScriptsFeature = (feature)=>"background/scripts" === feature;
5505
5571
  function createSequentialEntryModule(feature, scriptImports) {
5506
5572
  const jsFiles = scriptImports;
5507
- const isClassic = (p)=>{
5508
- try {
5509
- const src = __rspack_external_fs.readFileSync(p, 'utf8');
5510
- return !/^\s*import[\s{('"*]/m.test(src) && !/^\s*export[\s{*( ]/m.test(src);
5511
- } catch {
5512
- return false;
5513
- }
5514
- };
5515
- const concatenateClassic = jsFiles.length > 1 && jsFiles.every(isClassic);
5516
- if (concatenateClassic) {
5517
- const queryData = encodeURIComponent(JSON.stringify({
5518
- feature,
5519
- js: jsFiles,
5520
- css: []
5521
- }));
5522
- return `${jsFiles[0]}?__extensionjs_classic_concat__=${queryData}`;
5523
- }
5573
+ const concatenateClassic = jsFiles.length > 1 && jsFiles.every(isClassicScript);
5574
+ if (concatenateClassic) return classicConcatEntry(feature, jsFiles);
5524
5575
  const source = [
5525
5576
  `/* extension.js sequential entry: ${feature} */`,
5526
5577
  ...jsFiles.map((entryImport)=>`import ${JSON.stringify(String(entryImport))};`)
@@ -7817,6 +7868,295 @@ class StripContentScriptDevServerRuntime {
7817
7868
  });
7818
7869
  }
7819
7870
  }
7871
+ const EMITTED_WORKER_PATH = 'background/service_worker.js';
7872
+ const MAX_TRACE_DEPTH = 8;
7873
+ const SOURCE_SIBLING_EXTENSIONS = [
7874
+ '.ts',
7875
+ '.mts',
7876
+ '.tsx',
7877
+ '.jsx',
7878
+ '.mjs'
7879
+ ];
7880
+ class TraceRuntimeLoadedFiles {
7881
+ manifestPath;
7882
+ constructor(options){
7883
+ this.manifestPath = options.manifestPath;
7884
+ }
7885
+ apply(compiler) {
7886
+ compiler.hooks.thisCompilation.tap(TraceRuntimeLoadedFiles.name, (compilation)=>{
7887
+ compilation.hooks.processAssets.tap({
7888
+ name: TraceRuntimeLoadedFiles.name,
7889
+ stage: core_Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
7890
+ }, ()=>{
7891
+ this.traceWorkerImportScripts(compilation);
7892
+ this.traceInjectedFilePayloads(compilation);
7893
+ });
7894
+ });
7895
+ }
7896
+ readManifest() {
7897
+ try {
7898
+ return JSON.parse(__rspack_external_fs.readFileSync(this.manifestPath, 'utf-8'));
7899
+ } catch {
7900
+ return;
7901
+ }
7902
+ }
7903
+ traceWorkerImportScripts(compilation) {
7904
+ const manifest = this.readManifest();
7905
+ const workerRef = manifest?.background?.service_worker;
7906
+ if (!workerRef || manifest?.background?.type === 'module') return;
7907
+ const workerAsset = compilation.getAsset(EMITTED_WORKER_PATH);
7908
+ if (!workerAsset) return;
7909
+ const manifestDir = __rspack_external_path.dirname(this.manifestPath);
7910
+ const sourceWorkerPath = trace_runtime_loaded_files_unixify(String(workerRef)).replace(/^\/+/, '');
7911
+ let pending = [
7912
+ workerAsset.source.source().toString()
7913
+ ];
7914
+ const seen = new Set();
7915
+ for(let depth = 0; depth < MAX_TRACE_DEPTH && pending.length; depth++){
7916
+ const next = [];
7917
+ for (const content of pending)for (const literal of extractImportScriptsLiterals(content)){
7918
+ const sourceRel = resolveExtensionPath(literal, sourceWorkerPath);
7919
+ const distRel = resolveExtensionPath(literal, EMITTED_WORKER_PATH);
7920
+ if (!sourceRel || !distRel || seen.has(distRel)) continue;
7921
+ seen.add(distRel);
7922
+ const copied = copyThroughOrWarn(compilation, {
7923
+ manifestDir,
7924
+ sourceRel,
7925
+ distRel,
7926
+ warning: (expected, sourceSibling)=>importScriptsDependencyMissing(sourceWorkerPath, literal, expected, sourceSibling),
7927
+ warningName: 'ImportScriptsDependencyMissing',
7928
+ warningFile: EMITTED_WORKER_PATH
7929
+ });
7930
+ if (null != copied) {
7931
+ next.push(copied);
7932
+ if (sourceRel.endsWith('.js')) copyIfExists(compilation, __rspack_external_path.join(manifestDir, sourceRel.replace(/\.js$/, '_bg.wasm')), distRel.replace(/\.js$/, '_bg.wasm'));
7933
+ }
7934
+ }
7935
+ pending = next;
7936
+ }
7937
+ }
7938
+ traceInjectedFilePayloads(compilation) {
7939
+ const manifestDir = __rspack_external_path.dirname(this.manifestPath);
7940
+ const seen = new Set();
7941
+ const jsAssets = compilation.getAssets().filter((asset)=>/\.js$/i.test(asset.name));
7942
+ for (const asset of jsAssets){
7943
+ const content = asset.source.source().toString();
7944
+ for (const literal of extractInjectedFileLiterals(content)){
7945
+ const distRel = resolveExtensionPath(literal, '');
7946
+ if (!(!distRel || seen.has(distRel))) {
7947
+ seen.add(distRel);
7948
+ copyThroughOrWarn(compilation, {
7949
+ manifestDir,
7950
+ sourceRel: distRel,
7951
+ distRel,
7952
+ warning: (expected, sourceSibling)=>injectedFileDependencyMissing(asset.name, literal, expected, sourceSibling),
7953
+ warningName: 'InjectedScriptFilesMissing',
7954
+ warningFile: asset.name
7955
+ });
7956
+ }
7957
+ }
7958
+ }
7959
+ }
7960
+ }
7961
+ function copyIfExists(compilation, abs, distRel) {
7962
+ if (compilation.getAsset(distRel)) return;
7963
+ if (!__rspack_external_fs.existsSync(abs) || !__rspack_external_fs.statSync(abs).isFile()) return;
7964
+ compilation.emitAsset(distRel, new core_sources.RawSource(__rspack_external_fs.readFileSync(abs)));
7965
+ try {
7966
+ compilation.fileDependencies.add(abs);
7967
+ } catch {}
7968
+ }
7969
+ function copyThroughOrWarn(compilation, opts) {
7970
+ if (compilation.getAsset(opts.distRel)) return null;
7971
+ if (__rspack_external_fs.existsSync(__rspack_external_path.join(opts.manifestDir, 'public', opts.distRel))) return null;
7972
+ const abs = __rspack_external_path.join(opts.manifestDir, opts.sourceRel);
7973
+ if (__rspack_external_fs.existsSync(abs) && __rspack_external_fs.statSync(abs).isFile()) {
7974
+ const buffer = __rspack_external_fs.readFileSync(abs);
7975
+ compilation.emitAsset(opts.distRel, new core_sources.RawSource(buffer));
7976
+ try {
7977
+ compilation.fileDependencies.add(abs);
7978
+ } catch {}
7979
+ return buffer.toString();
7980
+ }
7981
+ const sourceSibling = trace_runtime_loaded_files_findSourceSibling(abs);
7982
+ const warn = new core_WebpackError(opts.warning(opts.sourceRel, sourceSibling ? trace_runtime_loaded_files_unixify(__rspack_external_path.relative(opts.manifestDir, sourceSibling)) : void 0));
7983
+ warn.name = opts.warningName;
7984
+ warn.file = opts.warningFile;
7985
+ compilation.warnings ||= [];
7986
+ compilation.warnings.push(warn);
7987
+ return null;
7988
+ }
7989
+ function trace_runtime_loaded_files_findSourceSibling(abs) {
7990
+ if (!abs.endsWith('.js')) return;
7991
+ const base = abs.slice(0, -3);
7992
+ return SOURCE_SIBLING_EXTENSIONS.map((ext)=>base + ext).find((candidate)=>__rspack_external_fs.existsSync(candidate));
7993
+ }
7994
+ function trace_runtime_loaded_files_unixify(filePath) {
7995
+ return filePath.replace(/\\/g, '/');
7996
+ }
7997
+ function resolveExtensionPath(literal, basePath) {
7998
+ const trimmed = literal.trim();
7999
+ if (!trimmed) return null;
8000
+ if (/^[a-zA-Z][\w+.-]*:/.test(trimmed)) return null;
8001
+ if (trimmed.startsWith('//')) return null;
8002
+ try {
8003
+ const base = new URL('chrome-extension://extension-js/' + trace_runtime_loaded_files_unixify(basePath));
8004
+ const resolved = new URL(trimmed, base);
8005
+ if ('extension-js' !== resolved.hostname) return null;
8006
+ const pathname = decodeURIComponent(resolved.pathname).replace(/^\/+/, '');
8007
+ return pathname || null;
8008
+ } catch {
8009
+ return null;
8010
+ }
8011
+ }
8012
+ function extractImportScriptsLiterals(source) {
8013
+ const code = blankComments(source);
8014
+ const literals = [];
8015
+ const callRe = /\bimportScripts\s*\(/g;
8016
+ let match;
8017
+ while(match = callRe.exec(code)){
8018
+ const args = readBalancedArgs(code, match.index + match[0].length - 1);
8019
+ if (null == args) continue;
8020
+ for (const arg of splitTopLevelArgs(args)){
8021
+ const literal = pureStringLiteral(arg);
8022
+ if (null != literal) literals.push(literal);
8023
+ }
8024
+ }
8025
+ return literals;
8026
+ }
8027
+ function extractInjectedFileLiterals(source) {
8028
+ const code = blankComments(source);
8029
+ const literals = [];
8030
+ const callRe = /\b(?:executeScript|insertCSS|removeCSS)\s*\(/g;
8031
+ let match;
8032
+ while(match = callRe.exec(code)){
8033
+ const args = readBalancedArgs(code, match.index + match[0].length - 1);
8034
+ if (null == args) continue;
8035
+ const filesRe = /["']?files["']?\s*:\s*\[([^\]]*)\]/g;
8036
+ let filesMatch;
8037
+ while(filesMatch = filesRe.exec(args))for (const element of splitTopLevelArgs(filesMatch[1])){
8038
+ const literal = pureStringLiteral(element);
8039
+ if (null != literal) literals.push(literal);
8040
+ }
8041
+ const fileRe = /["']?file["']?\s*:\s*(['"])((?:\\.|(?!\1)[^\\])*)\1/g;
8042
+ let fileMatch;
8043
+ while(fileMatch = fileRe.exec(args))literals.push(unescapeStringBody(fileMatch[2]));
8044
+ }
8045
+ return literals;
8046
+ }
8047
+ function blankComments(source) {
8048
+ let out = '';
8049
+ let i = 0;
8050
+ const n = source.length;
8051
+ while(i < n){
8052
+ const char = source[i];
8053
+ const next = source[i + 1];
8054
+ if ('/' === char && '/' === next) {
8055
+ while(i < n && '\n' !== source[i]){
8056
+ out += ' ';
8057
+ i++;
8058
+ }
8059
+ continue;
8060
+ }
8061
+ if ('/' === char && '*' === next) {
8062
+ out += ' ';
8063
+ i += 2;
8064
+ while(i < n && !('*' === source[i] && '/' === source[i + 1])){
8065
+ out += '\n' === source[i] ? '\n' : ' ';
8066
+ i++;
8067
+ }
8068
+ if (i < n) {
8069
+ out += ' ';
8070
+ i += 2;
8071
+ }
8072
+ continue;
8073
+ }
8074
+ if ('"' === char || "'" === char || '`' === char) {
8075
+ const quote = char;
8076
+ out += char;
8077
+ i++;
8078
+ while(i < n){
8079
+ if ('\\' === source[i]) {
8080
+ out += source[i] + (source[i + 1] ?? '');
8081
+ i += 2;
8082
+ continue;
8083
+ }
8084
+ out += source[i];
8085
+ if (source[i] === quote) {
8086
+ i++;
8087
+ break;
8088
+ }
8089
+ i++;
8090
+ }
8091
+ continue;
8092
+ }
8093
+ out += char;
8094
+ i++;
8095
+ }
8096
+ return out;
8097
+ }
8098
+ function readBalancedArgs(code, openIndex) {
8099
+ if ('(' !== code[openIndex]) return null;
8100
+ const cap = Math.min(code.length, openIndex + 5000);
8101
+ let depth = 0;
8102
+ for(let i = openIndex; i < cap; i++){
8103
+ const char = code[i];
8104
+ if ('"' === char || "'" === char || '`' === char) {
8105
+ i = skipString(code, i, cap);
8106
+ continue;
8107
+ }
8108
+ if ('(' === char) depth++;
8109
+ if (')' === char) {
8110
+ depth--;
8111
+ if (0 === depth) return code.slice(openIndex + 1, i);
8112
+ }
8113
+ }
8114
+ return null;
8115
+ }
8116
+ function skipString(code, start, cap) {
8117
+ const quote = code[start];
8118
+ for(let i = start + 1; i < cap; i++){
8119
+ if ('\\' === code[i]) {
8120
+ i++;
8121
+ continue;
8122
+ }
8123
+ if (code[i] === quote) return i;
8124
+ }
8125
+ return cap;
8126
+ }
8127
+ function splitTopLevelArgs(args) {
8128
+ const parts = [];
8129
+ let depth = 0;
8130
+ let current = '';
8131
+ for(let i = 0; i < args.length; i++){
8132
+ const char = args[i];
8133
+ if ('"' === char || "'" === char || '`' === char) {
8134
+ const end = skipString(args, i, args.length);
8135
+ current += args.slice(i, end + 1);
8136
+ i = end;
8137
+ continue;
8138
+ }
8139
+ if ('(' === char || '[' === char || '{' === char) depth++;
8140
+ if (')' === char || ']' === char || '}' === char) depth--;
8141
+ if (',' === char && 0 === depth) {
8142
+ parts.push(current);
8143
+ current = '';
8144
+ continue;
8145
+ }
8146
+ current += char;
8147
+ }
8148
+ if (current.trim()) parts.push(current);
8149
+ return parts;
8150
+ }
8151
+ function pureStringLiteral(arg) {
8152
+ const match = /^\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1\s*$/.exec(arg);
8153
+ if (!match) return null;
8154
+ if ('`' === match[1] && match[2].includes('${')) return null;
8155
+ return unescapeStringBody(match[2]);
8156
+ }
8157
+ function unescapeStringBody(body) {
8158
+ return body.replace(/\\(.)/g, '$1');
8159
+ }
7820
8160
  const basic = [
7821
8161
  'var isBrowser = !!(() => { try { return globalThis.browser.runtime.getURL("/") } catch(e) {} })()',
7822
8162
  'var isChrome = !!(() => { try { return globalThis.chrome.runtime.getURL("/") } catch(e) {} })()'
@@ -7884,6 +8224,9 @@ class ScriptsPlugin {
7884
8224
  manifestPath: this.manifestPath,
7885
8225
  includeList: this.includeList || {}
7886
8226
  }).apply(compiler);
8227
+ new TraceRuntimeLoadedFiles({
8228
+ manifestPath: this.manifestPath
8229
+ }).apply(compiler);
7887
8230
  new AddContentScriptWrapper({
7888
8231
  manifestPath: this.manifestPath,
7889
8232
  browser: this.browser
package/dist/101.mjs CHANGED
@@ -670,7 +670,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
670
670
  }
671
671
  return false;
672
672
  }
673
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.5","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","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.9","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.1.1","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.10","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","typescript":"5.9.3","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"}}');
673
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.6-canary.1783360784.dd7d1aae","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","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.9","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.1.1","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.10","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","typescript":"5.9.3","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"}}');
674
674
  function asAbsolute(p) {
675
675
  return __rspack_external_path.isAbsolute(p) ? p : __rspack_external_path.resolve(p);
676
676
  }
package/dist/224.mjs CHANGED
@@ -28,8 +28,16 @@ function findNearestPackageJsonSync(manifestPath) {
28
28
  function backgroundIsRequiredMessageOnly(backgroundChunkName) {
29
29
  return `Check the ${pintor.yellow(backgroundChunkName.replace('/', '.'))} field in your ${pintor.yellow('manifest.json')} file.`;
30
30
  }
31
+ function importScriptsDependencyMissing(workerPath, literal, expectedPath, sourceSibling) {
32
+ const sibling = sourceSibling ? `Found ${pintor.yellow(sourceSibling)}, but importScripts dependencies are copied as-is, not compiled.\n` : '';
33
+ return `The background service_worker ${pintor.yellow(workerPath)} calls importScripts(${pintor.yellow(`'${literal}'`)}), but ${pintor.yellow(expectedPath)} is not part of the output. The call will fail at runtime.\n` + sibling + `Move the file to ${pintor.yellow(expectedPath)} (or ${pintor.yellow('public/')}) so it ships with the extension, or import it from the worker so it ` + "gets bundled.";
34
+ }
35
+ function injectedFileDependencyMissing(assetName, literal, expectedPath, sourceSibling) {
36
+ const sibling = sourceSibling ? `Found ${pintor.yellow(sourceSibling)}, but injected files are copied as-is, not compiled.\n` : '';
37
+ return `${pintor.yellow(assetName)} injects ${pintor.yellow(`'${literal}'`)} via executeScript/insertCSS, but ${pintor.yellow(expectedPath)} is not part of the output. The injection will fail at runtime.\n` + sibling + `Move the file to ${pintor.yellow(expectedPath)} (or ${pintor.yellow('public/')}) so it ships with the extension.`;
38
+ }
31
39
  function reservedScriptsFolder(relPath, indicators) {
32
40
  const reasons = indicators.map((r)=>`- ${pintor.gray(r)}`).join('\n');
33
41
  return `${pintor.red('ERROR')} scripts/ is a reserved folder in Extension.js.\nEvery file under ${pintor.yellow("scripts/")} is wrapped with the browser content-script mount runtime, so Node.js-only files placed here will fail to parse or run.\nRename the folder at the project root (for example ${pintor.yellow('bin/')}, ${pintor.yellow('tools/')}, ${pintor.yellow('ops/')}, ${pintor.yellow('tasks/')}, or ${pintor.yellow("ci-scripts/")}) or move the file out of scripts/.\n\n${pintor.red('NODE.JS SHAPE')}\n${reasons}\n${pintor.red('NOT ALLOWED')} ${pintor.underline(relPath)}`;
34
42
  }
35
- export { backgroundIsRequiredMessageOnly, findNearestPackageJsonSync, reservedScriptsFolder };
43
+ export { backgroundIsRequiredMessageOnly, findNearestPackageJsonSync, importScriptsDependencyMissing, injectedFileDependencyMissing, reservedScriptsFolder };