extension-develop 3.1.0-next.8 → 3.2.0-next.10

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/547.js +234 -77
  2. package/dist/928.js +21 -7
  3. package/dist/content-script-wrapper.js +4 -1
  4. package/dist/ensure-hmr-for-scripts.js +2 -0
  5. package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
  6. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -5
  7. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  8. package/dist/extension-js-devtools/chrome/pages/welcome.js +4 -4
  9. package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
  10. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -5
  11. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  12. package/dist/extension-js-devtools/chromium/pages/welcome.js +4 -4
  13. package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
  14. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -5
  15. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  16. package/dist/extension-js-devtools/edge/pages/welcome.js +4 -4
  17. package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
  18. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -5
  19. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  20. package/dist/extension-js-devtools/firefox/pages/welcome.js +4 -4
  21. package/dist/extension-js-theme/chrome/manifest.json +66 -0
  22. package/dist/extension-js-theme/chromium/manifest.json +66 -0
  23. package/dist/extension-js-theme/edge/manifest.json +66 -0
  24. package/dist/extension-js-theme/firefox/manifest.json +66 -0
  25. package/dist/module.js +653 -175
  26. package/package.json +1 -3
  27. package/dist/add-centralized-logger-script-background.js +0 -220
  28. package/dist/add-centralized-logger-script-content.js +0 -172
  29. package/dist/add-centralized-logger-script.js +0 -323
  30. package/dist/extension-js-devtools/chrome/logo.png +0 -0
  31. package/dist/extension-js-devtools/chromium/logo.png +0 -0
  32. package/dist/extension-js-devtools/edge/logo.png +0 -0
  33. package/dist/extension-js-devtools/firefox/logo.png +0 -0
package/dist/547.js CHANGED
@@ -146,6 +146,8 @@ exports.modules = {
146
146
  obj[`import.meta.env.${key}`] = JSON.stringify(combinedVars[key]);
147
147
  return obj;
148
148
  }, {});
149
+ filteredEnvVars['process.env'] = JSON.stringify({});
150
+ filteredEnvVars['process'] = '({env: {}})';
149
151
  filteredEnvVars['process.env.EXTENSION_PUBLIC_BROWSER'] = JSON.stringify(this.browser);
150
152
  filteredEnvVars['import.meta.env.EXTENSION_PUBLIC_BROWSER'] = JSON.stringify(this.browser);
151
153
  filteredEnvVars['process.env.EXTENSION_PUBLIC_MODE'] = JSON.stringify(mode);
@@ -424,9 +426,12 @@ exports.modules = {
424
426
  if (this.clean) new CleanDistFolderPlugin({
425
427
  browser: this.browser || 'chrome'
426
428
  }).apply(compiler);
427
- new core_.DefinePlugin({
428
- 'process.env.NODE_ENV': JSON.stringify(compiler.options.mode || 'development')
429
- });
429
+ try {
430
+ const hasRspackInternals = 'function' == typeof compiler.__internal__registerBuiltinPlugin;
431
+ if (hasRspackInternals) new core_.DefinePlugin({
432
+ 'process.env.NODE_ENV': JSON.stringify(compiler.options.mode || 'development')
433
+ }).apply(compiler);
434
+ } catch {}
430
435
  if ((this.zip || this.zipSource) && 'production' === compiler.options.mode) new ZipPlugin({
431
436
  manifestPath: this.manifestPath,
432
437
  browser: this.browser || 'chrome',
@@ -663,8 +668,8 @@ exports.modules = {
663
668
  const projectPath = compiler.options.context || process.cwd();
664
669
  const plugins = [];
665
670
  const manifestPath = this.manifestPath;
666
- const usingSass = (0, css_lib_integrations.w)(projectPath, 'sass');
667
- const usingLess = (0, css_lib_integrations.w)(projectPath, 'less');
671
+ const usingSass = (0, css_lib_integrations.ws)(projectPath, 'sass');
672
+ const usingLess = (0, css_lib_integrations.ws)(projectPath, 'less');
668
673
  const maybeInstallStylelint = await maybeUseStylelint(projectPath);
669
674
  plugins.push(...maybeInstallStylelint);
670
675
  const maybeInstallSass = await (0, sass.IZ)(projectPath);
@@ -707,8 +712,8 @@ exports.modules = {
707
712
  ].filter(Boolean);
708
713
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
709
714
  const integrations = [];
710
- const usingTailwind = (0, css_lib_integrations.w)(projectPath, 'tailwindcss');
711
- const usingPostcss = (0, css_lib_integrations.w)(projectPath, 'postcss') || void 0 !== findPostCssConfig(projectPath) || usingSass || usingLess || usingTailwind;
715
+ const usingTailwind = (0, css_lib_integrations.ws)(projectPath, 'tailwindcss');
716
+ const usingPostcss = (0, css_lib_integrations.ws)(projectPath, 'postcss') || void 0 !== findPostCssConfig(projectPath) || usingSass || usingLess || usingTailwind;
712
717
  if (usingPostcss) integrations.push('PostCSS');
713
718
  if (usingSass) integrations.push('Sass');
714
719
  if (usingLess) integrations.push('Less');
@@ -810,6 +815,12 @@ exports.modules = {
810
815
  }
811
816
  };
812
817
  const hasCustomSvgRule = compiler.options.module.rules.some((rule)=>rule && rule.test instanceof RegExp && rule.test.test('.svg') && void 0 !== rule.use);
818
+ const hasCustomFontsRule = compiler.options.module.rules.some((thisRule)=>{
819
+ const rule = thisRule;
820
+ if (!rule || !(rule.test instanceof RegExp)) return false;
821
+ if (!rule.test.test('.woff')) return false;
822
+ return void 0 !== rule.type || void 0 !== rule.use;
823
+ });
813
824
  const loaders = [
814
825
  ...hasCustomSvgRule ? [] : [
815
826
  defaultSvgRule
@@ -826,13 +837,15 @@ exports.modules = {
826
837
  }
827
838
  }
828
839
  },
829
- {
830
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
831
- type: 'asset',
832
- generator: {
833
- filename: filenamePattern
840
+ ...hasCustomFontsRule ? [] : [
841
+ {
842
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
843
+ type: 'asset',
844
+ generator: {
845
+ filename: filenamePattern
846
+ }
834
847
  }
835
- },
848
+ ],
836
849
  {
837
850
  test: /\.(txt|md|csv|tsv|xml|pdf|docx|doc|xls|xlsx|ppt|pptx|zip|gz|gzip|tgz)$/i,
838
851
  type: 'asset',
@@ -904,12 +917,63 @@ exports.modules = {
904
917
  return obj;
905
918
  }
906
919
  class JsFrameworksPlugin {
920
+ findVueLoaderRuleIndices(rules) {
921
+ const indices = [];
922
+ for(let i = 0; i < rules.length; i++){
923
+ const rule = rules[i];
924
+ const testStr = String(rule?.test?.toString?.() || rule?.test || '');
925
+ const isVueTest = testStr.includes('\\.vue') || testStr.includes('/.vue') || '.vue' === testStr;
926
+ if (!isVueTest) continue;
927
+ const use = rule?.use;
928
+ const loader = rule?.loader || (Array.isArray(use) ? use?.[0]?.loader : 'object' == typeof use ? use?.loader : void 0);
929
+ const loaderStr = String(loader || '');
930
+ if (loaderStr.includes('vue-loader')) indices.push(i);
931
+ }
932
+ return indices;
933
+ }
934
+ mergeVueRule(userRule, defaultRule) {
935
+ const merged = {
936
+ ...userRule
937
+ };
938
+ if (merged.use) {
939
+ if (Array.isArray(merged.use) && merged.use.length > 0) {
940
+ const first = merged.use[0];
941
+ merged.use = [
942
+ {
943
+ ...first,
944
+ loader: first?.loader || defaultRule?.loader,
945
+ options: {
946
+ ...defaultRule?.options || {},
947
+ ...first?.options || {}
948
+ }
949
+ },
950
+ ...merged.use.slice(1)
951
+ ];
952
+ } else if ('object' == typeof merged.use) merged.use = {
953
+ ...merged.use,
954
+ loader: merged.use?.loader || defaultRule?.loader,
955
+ options: {
956
+ ...defaultRule?.options || {},
957
+ ...merged.use?.options || {}
958
+ }
959
+ };
960
+ return merged;
961
+ }
962
+ merged.loader = merged.loader || defaultRule?.loader;
963
+ merged.options = {
964
+ ...defaultRule?.options || {},
965
+ ...merged.options || {}
966
+ };
967
+ return merged;
968
+ }
907
969
  async configureOptions(compiler) {
908
970
  const mode = compiler.options.mode || 'development';
909
971
  const projectPath = compiler.options.context;
972
+ const devtool = compiler.options.devtool;
973
+ const wantsSourceMaps = false !== devtool && ('development' === mode || null != devtool);
910
974
  const maybeInstallReact = await (0, react.b)(projectPath);
911
975
  const maybeInstallPreact = await (0, preact.b)(projectPath);
912
- const maybeInstallVue = await (0, vue.K)(projectPath);
976
+ const maybeInstallVue = await (0, vue.K)(projectPath, mode);
913
977
  const maybeInstallSvelte = await (0, svelte.X)(projectPath, mode);
914
978
  const tsConfigPath = (0, typescript.hB)(projectPath);
915
979
  const manifestDir = external_path_.dirname(this.manifestPath);
@@ -940,6 +1004,19 @@ exports.modules = {
940
1004
  ...maybeInstallSvelte?.alias || {},
941
1005
  ...compiler.options.resolve.alias
942
1006
  };
1007
+ const existingRules = Array.isArray(compiler.options.module.rules) ? [
1008
+ ...compiler.options.module.rules
1009
+ ] : [];
1010
+ let vueLoadersToAdd = maybeInstallVue?.loaders || [];
1011
+ if (maybeInstallVue?.loaders?.length) {
1012
+ const vueRuleIndices = this.findVueLoaderRuleIndices(existingRules);
1013
+ if (vueRuleIndices.length > 0) {
1014
+ const primary = vueRuleIndices[0];
1015
+ existingRules[primary] = this.mergeVueRule(existingRules[primary], maybeInstallVue.loaders[0]);
1016
+ for (const idx of vueRuleIndices.slice(1).reverse())existingRules.splice(idx, 1);
1017
+ vueLoadersToAdd = [];
1018
+ }
1019
+ }
943
1020
  compiler.options.module.rules = [
944
1021
  {
945
1022
  test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
@@ -959,7 +1036,7 @@ exports.modules = {
959
1036
  },
960
1037
  minify: 'production' === mode,
961
1038
  isModule: true,
962
- sourceMap: 'development' === this.mode,
1039
+ sourceMap: wantsSourceMaps,
963
1040
  env: {
964
1041
  targets
965
1042
  },
@@ -990,9 +1067,9 @@ exports.modules = {
990
1067
  },
991
1068
  ...maybeInstallReact?.loaders || [],
992
1069
  ...maybeInstallPreact?.loaders || [],
993
- ...maybeInstallVue?.loaders || [],
1070
+ ...vueLoadersToAdd,
994
1071
  ...maybeInstallSvelte?.loaders || [],
995
- ...compiler.options.module.rules
1072
+ ...existingRules
996
1073
  ].filter(Boolean);
997
1074
  maybeInstallReact?.plugins?.forEach((plugin)=>plugin.apply(compiler));
998
1075
  maybeInstallPreact?.plugins?.forEach((plugin)=>plugin.apply(compiler));
@@ -1671,6 +1748,33 @@ exports.modules = {
1671
1748
  return require(manifestPath);
1672
1749
  }
1673
1750
  }
1751
+ function manifest_filterKeysForThisBrowser(manifest, browser) {
1752
+ const CHROMIUM_BASED_BROWSERS = [
1753
+ 'chrome',
1754
+ 'edge'
1755
+ ];
1756
+ const GECKO_BASED_BROWSERS = [
1757
+ 'firefox'
1758
+ ];
1759
+ const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
1760
+ const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
1761
+ const chromiumPrefixes = new Set([
1762
+ 'chromium',
1763
+ 'chrome',
1764
+ 'edge'
1765
+ ]);
1766
+ const geckoPrefixes = new Set([
1767
+ 'gecko',
1768
+ 'firefox'
1769
+ ]);
1770
+ const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
1771
+ const indexOfColon = key.indexOf(':');
1772
+ if (-1 === indexOfColon) return value;
1773
+ const prefix = key.substring(0, indexOfColon);
1774
+ if (prefix === browser || isChromiumTarget && chromiumPrefixes.has(prefix) || isGeckoTarget && geckoPrefixes.has(prefix)) this[key.substring(indexOfColon + 1)] = value;
1775
+ });
1776
+ return patchedManifest;
1777
+ }
1674
1778
  function update_manifest_define_property(obj, key, value) {
1675
1779
  if (key in obj) Object.defineProperty(obj, key, {
1676
1780
  value: value,
@@ -1699,9 +1803,10 @@ exports.modules = {
1699
1803
  }, ()=>{
1700
1804
  if (compilation.errors.length > 0) return;
1701
1805
  const manifest = getManifestContent(compilation, this.manifestPath);
1702
- const overrides = getManifestOverrides(this.manifestPath, manifest);
1806
+ const manifestForBrowser = manifest_filterKeysForThisBrowser(manifest, this.browser);
1807
+ const overrides = getManifestOverrides(this.manifestPath, manifestForBrowser);
1703
1808
  const patchedManifest = {
1704
- ...manifest,
1809
+ ...manifestForBrowser,
1705
1810
  ...JSON.parse(overrides)
1706
1811
  };
1707
1812
  if ('development' === compiler.options.mode) {
@@ -1726,7 +1831,9 @@ exports.modules = {
1726
1831
  }
1727
1832
  constructor(options){
1728
1833
  update_manifest_define_property(this, "manifestPath", void 0);
1834
+ update_manifest_define_property(this, "browser", void 0);
1729
1835
  this.manifestPath = options.manifestPath;
1836
+ this.browser = options.browser || 'chrome';
1730
1837
  }
1731
1838
  }
1732
1839
  function add_dependencies_define_property(obj, key, value) {
@@ -1906,7 +2013,8 @@ exports.modules = {
1906
2013
  manifestPath: this.manifestPath
1907
2014
  }).apply(compiler);
1908
2015
  new UpdateManifest({
1909
- manifestPath: this.manifestPath
2016
+ manifestPath: this.manifestPath,
2017
+ browser: this.browser
1910
2018
  }).apply(compiler);
1911
2019
  new AddDependencies([
1912
2020
  this.manifestPath
@@ -1957,7 +2065,7 @@ exports.modules = {
1957
2065
  return lines.join('\n');
1958
2066
  }
1959
2067
  function fileNotFound(errorSourcePath, missingFilePath, opts) {
1960
- if (!errorSourcePath) throw new Error('This operation is impossible. Please report a bug.');
2068
+ if (!errorSourcePath) throw new Error('This state should not occur. Please report a bug.');
1961
2069
  switch(external_path_.extname(missingFilePath)){
1962
2070
  case '.js':
1963
2071
  case '.ts':
@@ -3476,7 +3584,7 @@ exports.modules = {
3476
3584
  ];
3477
3585
  const weakRuntimeCheck = [
3478
3586
  ...basic,
3479
- "var runtime = isBrowser ? browser : isChrome ? chrome : (typeof self === 'object' && self.addEventListener) ? { get runtime() { throw new Error(\"No chrome or browser runtime found\") } } : { runtime: { getURL: x => x } }"
3587
+ "var runtime = isBrowser ? browser : isChrome ? chrome : { runtime: { getURL: x => x } }"
3480
3588
  ];
3481
3589
  class AddPublicPathRuntimeModule {
3482
3590
  apply(compiler) {
@@ -4282,6 +4390,8 @@ Set background.noDynamicEntryWarning to true to disable this warning.
4282
4390
  protocol: 'ws'
4283
4391
  });
4284
4392
  setDefault(devServer.client.webSocketURL, 'protocol', 'ws');
4393
+ if (devServer.host) setDefault(devServer.client.webSocketURL, 'hostname', devServer.host);
4394
+ if (devServer.port) setDefault(devServer.client.webSocketURL, 'port', devServer.port);
4285
4395
  setDefault(devServer, 'allowedHosts', 'all');
4286
4396
  setDefault(devServer, 'headers', {
4287
4397
  'Access-Control-Allow-Origin': '*'
@@ -4931,7 +5041,7 @@ Set background.noDynamicEntryWarning to true to disable this warning.
4931
5041
  }
4932
5042
  }
4933
5043
  function manifestNotFoundMessageOnly(absPath) {
4934
- return `Check the manifest.json file.\n\nNOT FOUND ${absPath}`;
5044
+ return `Check for a valid manifest.json file.\n\nNOT FOUND ${absPath}`;
4935
5045
  }
4936
5046
  function entryNotFoundMessageOnly(manifestField, absPath) {
4937
5047
  const guidance = `Check the ${manifestField} field in your manifest.json file.`;
@@ -4939,24 +5049,24 @@ Set background.noDynamicEntryWarning to true to disable this warning.
4939
5049
  return guidance + suffix;
4940
5050
  }
4941
5051
  function defaultLocaleSpecifiedButLocalesMissing() {
4942
- return 'Default locale was specified, but _locales subtree is missing.';
5052
+ return 'default_locale is set, but the _locales folder is missing. Add _locales/<default>/messages.json.';
4943
5053
  }
4944
5054
  function defaultLocaleFolderMissing(defaultLocale) {
4945
- return `Default locale folder is missing: _locales/${defaultLocale}`;
5055
+ return `Default locale folder is missing: _locales/${defaultLocale}. Create it and add messages.json.`;
4946
5056
  }
4947
5057
  function defaultLocaleMessagesMissing(defaultLocale) {
4948
- return `Default locale messages.json is missing: _locales/${defaultLocale}/messages.json`;
5058
+ return `Default locale messages.json is missing: _locales/${defaultLocale}/messages.json. Create the file with your strings.`;
4949
5059
  }
4950
5060
  function localesPresentButNoDefaultLocale() {
4951
- return 'The _locales subtree exists but manifest.json is missing default_locale.';
5061
+ return 'The _locales folder exists, but manifest.json is missing default_locale. Add default_locale to manifest.json.';
4952
5062
  }
4953
5063
  function invalidMessagesJson(absPath) {
4954
- return `Invalid JSON in locale messages file: ${absPath}`;
5064
+ return `Invalid JSON in locale messages file: ${absPath}. Fix the JSON syntax and try again.`;
4955
5065
  }
4956
5066
  function missingManifestMessageKey(key, defaultLocale) {
4957
5067
  const header = 'Check the i18n placeholders in your manifest.json file.';
4958
5068
  const localePath = defaultLocale ? `_locales/${defaultLocale}/messages.json` : '_locales/<default>/messages.json';
4959
- const guidance = `The key "${key}" referenced via __MSG_${key}__ must be defined in ${localePath}.`;
5069
+ const guidance = `The key "${key}" referenced via __MSG_${key}__ must be defined in ${localePath}. Add the key to that file.`;
4960
5070
  const final = `MISSING KEY ${key} in ${localePath}`;
4961
5071
  return `${header}\n${guidance}\n\n${final}`;
4962
5072
  }
@@ -6418,6 +6528,44 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6418
6528
  });
6419
6529
  }
6420
6530
  }
6531
+ const fontExtRe = /\.(woff2?|eot|ttf|otf)$/i;
6532
+ if (3 === manifest.manifest_version) {
6533
+ const assetKeys = Object.keys(compilation.assets || {});
6534
+ const fontAssets = assetKeys.filter((k)=>fontExtRe.test(k)).filter((k)=>!k.startsWith('assets/')).filter((k)=>!k.startsWith("content_scripts/")).sort();
6535
+ if (fontAssets.length > 0) {
6536
+ const allMatches = Array.from(new Set((manifest.content_scripts || []).flatMap((cs)=>cs.matches || [])));
6537
+ const normalizedMatches = cleanMatches(allMatches);
6538
+ if (normalizedMatches.length > 0) {
6539
+ const existing = webAccessibleResourcesV3.find((entry)=>{
6540
+ const a = [
6541
+ ...entry.matches
6542
+ ].sort();
6543
+ const b = [
6544
+ ...normalizedMatches
6545
+ ].sort();
6546
+ return a.length === b.length && a.every((v, i)=>v === b[i]);
6547
+ });
6548
+ if (existing) {
6549
+ const candidates = fontAssets.filter((r)=>!existing.resources.includes(r) && !isCoveredByExistingGlobs(existing.resources, r));
6550
+ existing.resources = Array.from(new Set([
6551
+ ...existing.resources || [],
6552
+ ...candidates
6553
+ ])).sort();
6554
+ } else webAccessibleResourcesV3.push({
6555
+ resources: fontAssets,
6556
+ matches: [
6557
+ ...normalizedMatches
6558
+ ].sort()
6559
+ });
6560
+ }
6561
+ }
6562
+ } else if (2 === manifest.manifest_version) {
6563
+ const assetKeys = Object.keys(compilation.assets || {});
6564
+ const fontAssets = assetKeys.filter((k)=>fontExtRe.test(k)).sort();
6565
+ if (fontAssets.length > 0) {
6566
+ for (const r of fontAssets)if (!webAccessibleResourcesV2.includes(r)) webAccessibleResourcesV2.push(r);
6567
+ }
6568
+ }
6421
6569
  if (3 === manifest.manifest_version) {
6422
6570
  const assetKeys = Object.keys(compilation.assets || {});
6423
6571
  const cssUnderContentScripts = assetKeys.filter((k)=>k.startsWith("content_scripts/")).filter((k)=>k.endsWith('.css')).sort();
@@ -6527,9 +6675,8 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6527
6675
  this.browser = options.browser || 'chrome';
6528
6676
  }
6529
6677
  }
6530
- var external_chokidar_ = __webpack_require__("chokidar");
6531
6678
  function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
6532
- return `${external_pintor_default().red('ERROR')} in ${external_pintor_default().yellow('manifest.json')} entrypoint: ${addingOrRemoving} ${external_pintor_default().yellow(typeOfAsset)} in ${external_pintor_default().underline(folder + '/')} requires a server restart.`;
6679
+ return `${external_pintor_default().red('ERROR')} in ${external_pintor_default().yellow('manifest.json')} entrypoint: ${addingOrRemoving} ${external_pintor_default().yellow(typeOfAsset)} in ${external_pintor_default().underline(folder + '/')} requires a dev server restart to apply changes.`;
6533
6680
  }
6534
6681
  function specialFoldersSetupSummary(hasPublic, copyEnabled, ignoredCount) {
6535
6682
  return `Special folders setup — public=${String(hasPublic)}, copy=${String(copyEnabled)}, ignored=${String(ignoredCount)}`;
@@ -6537,6 +6684,16 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6537
6684
  function specialFolderChangeDetected(action, folder, relativePath) {
6538
6685
  return `Special folders change — ${action} in ${folder}/: ${relativePath}`;
6539
6686
  }
6687
+ function warn_upon_folder_changes_define_property(obj, key, value) {
6688
+ if (key in obj) Object.defineProperty(obj, key, {
6689
+ value: value,
6690
+ enumerable: true,
6691
+ configurable: true,
6692
+ writable: true
6693
+ });
6694
+ else obj[key] = value;
6695
+ return obj;
6696
+ }
6540
6697
  class WarnUponFolderChanges {
6541
6698
  throwCompilationError(compilation, folder, filePath, isAddition) {
6542
6699
  const addingOrRemoving = isAddition ? 'Adding' : 'Removing';
@@ -6556,58 +6713,57 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6556
6713
  err.details = `Removing from ${folder}/ breaks current build. Restart the dev server to recompile.`;
6557
6714
  compilation.errors?.push(err);
6558
6715
  }
6716
+ trackChange(projectPath, folder, change, filePath) {
6717
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add' === change ? 'add' : 'remove', folder, external_path_.relative(projectPath, filePath)));
6718
+ this.pendingChanges.push({
6719
+ type: change,
6720
+ folder,
6721
+ filePath
6722
+ });
6723
+ }
6724
+ collectChanges(compiler) {
6725
+ const projectPath = compiler.options.context || process.cwd();
6726
+ const pagesPath = external_path_.join(projectPath, 'pages') + external_path_.sep;
6727
+ const scriptsPath = external_path_.join(projectPath, "scripts") + external_path_.sep;
6728
+ const extensionsSupported = compiler.options.resolve?.extensions;
6729
+ const supportedScripts = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6730
+ const modifiedFiles = compiler.modifiedFiles || new Set();
6731
+ const removedFiles = compiler.removedFiles || new Set();
6732
+ for (const filePath of modifiedFiles){
6733
+ if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'add', filePath);
6734
+ if (filePath.startsWith(scriptsPath)) {
6735
+ const ext = external_path_.extname(filePath).toLowerCase();
6736
+ if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'add', filePath);
6737
+ }
6738
+ }
6739
+ for (const filePath of removedFiles){
6740
+ if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'remove', filePath);
6741
+ if (filePath.startsWith(scriptsPath)) {
6742
+ const ext = external_path_.extname(filePath).toLowerCase();
6743
+ if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'remove', filePath);
6744
+ }
6745
+ }
6746
+ }
6747
+ applyPendingChanges(compilation) {
6748
+ for (const change of this.pendingChanges)this.throwCompilationError(compilation, change.folder, change.filePath, 'add' === change.type);
6749
+ this.pendingChanges = [];
6750
+ }
6559
6751
  apply(compiler) {
6752
+ compiler.hooks.watchRun.tap('special-folders:warn-upon-folder-changes', ()=>{
6753
+ this.collectChanges(compiler);
6754
+ });
6560
6755
  compiler.hooks.thisCompilation.tap('special-folders:warn-upon-folder-changes', (compilation)=>{
6561
6756
  const projectPath = compiler.options.context || process.cwd();
6562
6757
  const pagesPath = external_path_.join(projectPath, 'pages');
6563
6758
  const scriptsPath = external_path_.join(projectPath, "scripts");
6564
- const pagesWatcher = external_chokidar_.watch(pagesPath, {
6565
- ignoreInitial: true
6566
- });
6567
- const scriptsWatcher = external_chokidar_.watch(scriptsPath, {
6568
- ignoreInitial: true
6569
- });
6570
- const extensionsSupported = compiler.options.resolve?.extensions;
6571
- pagesWatcher.on('add', (filePath)=>{
6572
- const ext = external_path_.extname(filePath).toLowerCase();
6573
- const isHtml = '.html' === ext;
6574
- if (isHtml) {
6575
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', 'pages', external_path_.relative(projectPath, filePath)));
6576
- this.throwCompilationError(compilation, 'pages', filePath, true);
6577
- }
6578
- });
6579
- pagesWatcher.on('unlink', (filePath)=>{
6580
- const ext = external_path_.extname(filePath).toLowerCase();
6581
- const isHtml = '.html' === ext;
6582
- if (isHtml) {
6583
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', 'pages', external_path_.relative(projectPath, filePath)));
6584
- this.throwCompilationError(compilation, 'pages', filePath);
6585
- }
6586
- });
6587
- scriptsWatcher.on('add', (filePath)=>{
6588
- const ext = external_path_.extname(filePath).toLowerCase();
6589
- const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6590
- const isScript = supported.has(ext);
6591
- if (isScript) {
6592
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', "scripts", external_path_.relative(projectPath, filePath)));
6593
- this.throwCompilationError(compilation, "scripts", filePath, true);
6594
- }
6595
- });
6596
- scriptsWatcher.on('unlink', (filePath)=>{
6597
- const ext = external_path_.extname(filePath).toLowerCase();
6598
- const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6599
- const isScript = supported.has(ext);
6600
- if (isScript) {
6601
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', "scripts", external_path_.relative(projectPath, filePath)));
6602
- this.throwCompilationError(compilation, "scripts", filePath);
6603
- }
6604
- });
6605
- compiler.hooks.watchClose.tap('WarnUponFolderChanges', ()=>{
6606
- pagesWatcher.close().catch(()=>{});
6607
- scriptsWatcher.close().catch(()=>{});
6608
- });
6759
+ compilation.contextDependencies?.add(pagesPath);
6760
+ compilation.contextDependencies?.add(scriptsPath);
6761
+ this.applyPendingChanges(compilation);
6609
6762
  });
6610
6763
  }
6764
+ constructor(){
6765
+ warn_upon_folder_changes_define_property(this, "pendingChanges", []);
6766
+ }
6611
6767
  }
6612
6768
  function checkManifestInPublic(compilation, publicDir) {
6613
6769
  try {
@@ -6798,8 +6954,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6798
6954
  try {
6799
6955
  const polyfillPath = require.resolve('webextension-polyfill/dist/browser-polyfill.js', {
6800
6956
  paths: [
6957
+ compiler.options.context,
6801
6958
  __dirname
6802
- ]
6959
+ ].filter(Boolean)
6803
6960
  });
6804
6961
  const currentResolve = compiler.options.resolve || {};
6805
6962
  const existingAlias = currentResolve.alias || {};
package/dist/928.js CHANGED
@@ -330,6 +330,13 @@ exports.modules = {
330
330
  const portAllocation = await portManager.allocatePorts(devOptions.browser, packageJsonDir, desiredPort);
331
331
  const currentInstance = portManager.getCurrentInstance();
332
332
  if (!currentInstance) throw new Error('Failed to create instance');
333
+ const port = portAllocation.port;
334
+ const devServerHost = '127.0.0.1';
335
+ const devServerWebSocketURL = {
336
+ protocol: 'ws',
337
+ hostname: devServerHost,
338
+ port
339
+ };
333
340
  const safeBrowserConfig = (0, sanitize.a)(browserConfig);
334
341
  const safeCommandConfig = (0, sanitize.a)(commandConfig);
335
342
  const safeDevOptions = (0, sanitize.a)(devOptions);
@@ -349,12 +356,23 @@ exports.modules = {
349
356
  const customWebpackConfig = await (0, config_loader.Tu)(manifestDir);
350
357
  const finalConfig = customWebpackConfig(baseConfig);
351
358
  const compilerConfig = (0, external_webpack_merge_.merge)(finalConfig, {});
359
+ compilerConfig.devServer = {
360
+ ...compilerConfig.devServer || {},
361
+ host: devServerHost,
362
+ port,
363
+ client: {
364
+ ...(compilerConfig.devServer || {}).client || {},
365
+ webSocketURL: {
366
+ ...((compilerConfig.devServer || {}).client || {}).webSocketURL || {},
367
+ ...devServerWebSocketURL
368
+ }
369
+ }
370
+ };
352
371
  const compiler = (0, core_.rspack)(compilerConfig);
353
372
  setupCompilerHooks(compiler, portAllocation.port);
354
- const port = portAllocation.port;
355
373
  if (void 0 !== devOptions.port && devOptions.port !== port) console.log(portInUse(devOptions.port, port));
356
374
  const serverConfig = {
357
- host: '127.0.0.1',
375
+ host: devServerHost,
358
376
  allowedHosts: 'all',
359
377
  static: {
360
378
  watch: {
@@ -382,11 +400,7 @@ exports.modules = {
382
400
  logging: 'none',
383
401
  progress: false,
384
402
  overlay: false,
385
- webSocketURL: {
386
- protocol: 'ws',
387
- hostname: '127.0.0.1',
388
- port
389
- }
403
+ webSocketURL: devServerWebSocketURL
390
404
  },
391
405
  headers: {
392
406
  'Access-Control-Allow-Origin': '*'
@@ -211,6 +211,8 @@ function content_script_wrapper(source) {
211
211
  if (source.includes('__EXTENSIONJS_MOUNT_WRAPPED__')) return source;
212
212
  const cssImportMatches = Array.from(source.matchAll(/import\s+(?:['\"](?<bare>[^'\"]+\.(css|sass|scss|less))['\"]|(?:(?:.+?)\s+from\s+['\"](?<from>[^'\"]+\.(css|sass|scss|less))['\"]))/g));
213
213
  const cssSpecifiers = cssImportMatches.map((m)=>m.groups?.bare || m.groups?.from);
214
+ const vueImportMatches = Array.from(source.matchAll(/import\s+(?:['\"](?<bare>[^'\"]+\.vue)['\"]|(?:(?:.+?)\s+from\s+['\"](?<from>[^'\"]+\.vue)['\"]))/g));
215
+ const vueSpecifiers = vueImportMatches.map((m)=>m.groups?.bare || m.groups?.from);
214
216
  const runtimeInline = "function __EXTENSIONJS_whenReady(runAt, cb){\n try {\n if (typeof document === 'undefined') { cb(); return function(){} }\n if (runAt === 'document_start') { cb(); return function(){} }\n var isDone = false;\n function isReady(){\n if (runAt === 'document_end') return document.readyState === 'interactive' || document.readyState === 'complete';\n if (runAt === 'document_idle') return document.readyState !== 'loading';\n return document.readyState === 'complete';\n }\n if (isReady()) { cb(); return function(){} }\n var onReady = function(){\n try {\n if (isDone) return;\n if (isReady()) { isDone = true; document.removeEventListener('readystatechange', onReady); cb(); }\n } catch (e) {}\n };\n document.addEventListener('readystatechange', onReady);\n return function(){ try { if (!isDone) document.removeEventListener('readystatechange', onReady); } catch (e) {} };\n } catch (e) { try { cb(); } catch (_) {} return function(){} }\n}\nfunction __EXTENSIONJS_mountWithHMR(mount, runAt){\n var cleanup;\n var cancelReady = function(){};\n if (typeof mount !== \"function\") { try { console.warn(\"[extension.js] content script default export must be a function; skipping mount\") } catch (_) {} return function(){} }\n function apply(){ try { cleanup = mount() } catch (e) { try { console.warn(\"[extension.js] content script default export failed to run\", e) } catch (_) {} } }\n function unmount(){ try { cancelReady && cancelReady(); } catch (e) {} try { if (typeof cleanup === 'function') cleanup() } catch (e2) {} }\n function remount(){ unmount(); apply(); }\n cancelReady = __EXTENSIONJS_whenReady(runAt, apply);\n if (import.meta.webpackHot) {\n if (typeof import.meta.webpackHot.accept === \"function\") import.meta.webpackHot.accept();\n if (typeof import.meta.webpackHot.dispose === \"function\") import.meta.webpackHot.dispose(unmount);\n if (typeof import.meta.webpackHot.addStatusHandler === \"function\") {\n import.meta.webpackHot.addStatusHandler(function(s){ if (s==='abort'||s==='fail') { console.warn('[extension.js] HMR status:', s) } });\n }\n }\n var cssEvt='__EXTENSIONJS_CSS_UPDATE__';\n var onCss=function(){ remount() };\n window.addEventListener(cssEvt, onCss);\n return function(){ window.removeEventListener(cssEvt, onCss); unmount(); };\n}\n";
215
217
  if (/\bexport\s+default\s+[A-Za-z_$][\w$]*\s*\(/.test(source) && !/\bexport\s+default\s+function\b/.test(source)) {
216
218
  this.emitWarning?.(new Error('Default export appears to be an invocation. Export a function reference instead: `export default function init(){}` or `export default init`.'));
@@ -236,7 +238,8 @@ function content_script_wrapper(source) {
236
238
  }
237
239
  }
238
240
  const cssAccepts = cssSpecifiers.length ? `\ntry {\n if (import.meta.webpackHot) {\n ${cssSpecifiers.map((s)=>`import.meta.webpackHot.accept(${JSON.stringify(s)}, () => { try { window.dispatchEvent(new CustomEvent('__EXTENSIONJS_CSS_UPDATE__')) } catch (error) {} })`).join('\n ')}\n }\n} catch (error) {}\n` : '';
239
- const injected = `${runtimeInline}${cleaned}\n;/* __EXTENSIONJS_MOUNT_WRAPPED__ */\ntry { __EXTENSIONJS_mountWithHMR(__EXTENSIONJS_default__, ${JSON.stringify(runAt)}) } catch (error) {}\n${cssAccepts}export default __EXTENSIONJS_default__\n`;
241
+ const vueAccepts = vueSpecifiers.length ? `\ntry {\n if (import.meta.webpackHot) {\n ${vueSpecifiers.map((s)=>`import.meta.webpackHot.accept(${JSON.stringify(s)}, () => { try { window.dispatchEvent(new CustomEvent('__EXTENSIONJS_CSS_UPDATE__')) } catch (error) {} })`).join('\n ')}\n }\n} catch (error) {}\n` : '';
242
+ const injected = `${runtimeInline}${cleaned}\n;/* __EXTENSIONJS_MOUNT_WRAPPED__ */\ntry { __EXTENSIONJS_mountWithHMR(__EXTENSIONJS_default__, ${JSON.stringify(runAt)}) } catch (error) {}\n${cssAccepts}${vueAccepts}export default __EXTENSIONJS_default__\n`;
240
243
  return injected;
241
244
  }
242
245
  exports["default"] = __webpack_exports__["default"];
@@ -43,6 +43,8 @@ const schema = {
43
43
  additionalProperties: false
44
44
  };
45
45
  function ensureHMRForScripts(source) {
46
+ const resourceQuery = String(this.resourceQuery || '');
47
+ if (resourceQuery.includes('vue&type=')) return source;
46
48
  const options = this.getOptions();
47
49
  try {
48
50
  (0, external_schema_utils_namespaceObject.validate)(schema, options, {