extension-develop 3.0.0-next.60 → 3.0.0-next.67

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 (70) hide show
  1. package/README.md +56 -16
  2. package/dist/content-script-wrapper.js +34 -11
  3. package/dist/extension-js-devtools/chrome/assets/logo.7dc70d61.png +0 -0
  4. package/dist/extension-js-devtools/chrome/background/service_worker.js +26 -0
  5. package/dist/extension-js-devtools/chrome/chrome_url_overrides/newtab.html +23 -0
  6. package/dist/extension-js-devtools/chrome/devtools/index.html +12 -0
  7. package/dist/extension-js-devtools/chrome/devtools/index.js +1 -0
  8. package/dist/extension-js-devtools/chrome/icons/logo.png +0 -0
  9. package/dist/extension-js-devtools/chrome/logo.png +0 -0
  10. package/dist/extension-js-devtools/chrome/manifest.json +44 -0
  11. package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +2 -0
  12. package/dist/extension-js-devtools/chrome/pages/centralized-logger.html +12 -0
  13. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +16 -0
  14. package/dist/extension-js-devtools/chrome/pages/welcome.css +2 -0
  15. package/dist/extension-js-devtools/chrome/pages/welcome.html +11 -0
  16. package/dist/extension-js-devtools/chrome/pages/welcome.js +21 -0
  17. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -0
  18. package/dist/extension-js-devtools/chromium/assets/logo.7dc70d61.png +0 -0
  19. package/dist/extension-js-devtools/chromium/background/service_worker.js +26 -0
  20. package/dist/extension-js-devtools/chromium/chrome_url_overrides/newtab.html +23 -0
  21. package/dist/extension-js-devtools/chromium/devtools/index.html +12 -0
  22. package/dist/extension-js-devtools/chromium/devtools/index.js +1 -0
  23. package/dist/extension-js-devtools/chromium/icons/logo.png +0 -0
  24. package/dist/extension-js-devtools/chromium/logo.png +0 -0
  25. package/dist/extension-js-devtools/chromium/manifest.json +44 -0
  26. package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +2 -0
  27. package/dist/extension-js-devtools/chromium/pages/centralized-logger.html +12 -0
  28. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +16 -0
  29. package/dist/extension-js-devtools/chromium/pages/welcome.css +2 -0
  30. package/dist/extension-js-devtools/chromium/pages/welcome.html +11 -0
  31. package/dist/extension-js-devtools/chromium/pages/welcome.js +21 -0
  32. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -0
  33. package/dist/extension-js-devtools/edge/assets/logo.7dc70d61.png +0 -0
  34. package/dist/extension-js-devtools/edge/background/service_worker.js +26 -0
  35. package/dist/extension-js-devtools/edge/chrome_url_overrides/newtab.html +23 -0
  36. package/dist/extension-js-devtools/edge/devtools/index.html +12 -0
  37. package/dist/extension-js-devtools/edge/devtools/index.js +1 -0
  38. package/dist/extension-js-devtools/edge/icons/logo.png +0 -0
  39. package/dist/extension-js-devtools/edge/logo.png +0 -0
  40. package/dist/extension-js-devtools/edge/manifest.json +44 -0
  41. package/dist/extension-js-devtools/edge/pages/centralized-logger.css +2 -0
  42. package/dist/extension-js-devtools/edge/pages/centralized-logger.html +12 -0
  43. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +16 -0
  44. package/dist/extension-js-devtools/edge/pages/welcome.css +2 -0
  45. package/dist/extension-js-devtools/edge/pages/welcome.html +11 -0
  46. package/dist/extension-js-devtools/edge/pages/welcome.js +21 -0
  47. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -0
  48. package/dist/extension-js-devtools/firefox/assets/logo.7dc70d61.png +0 -0
  49. package/dist/extension-js-devtools/firefox/background/scripts.js +26 -0
  50. package/dist/extension-js-devtools/firefox/devtools/index.html +12 -0
  51. package/dist/extension-js-devtools/firefox/devtools/index.js +1 -0
  52. package/dist/extension-js-devtools/firefox/icons/logo.png +0 -0
  53. package/dist/extension-js-devtools/firefox/logo.png +0 -0
  54. package/dist/extension-js-devtools/firefox/manifest.json +30 -0
  55. package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +2 -0
  56. package/dist/extension-js-devtools/firefox/pages/centralized-logger.html +12 -0
  57. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +16 -0
  58. package/dist/extension-js-devtools/firefox/pages/welcome.css +2 -0
  59. package/dist/extension-js-devtools/firefox/pages/welcome.html +11 -0
  60. package/dist/extension-js-devtools/firefox/pages/welcome.js +21 -0
  61. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -0
  62. package/dist/extension-js-theme/chrome/manifest.json +68 -0
  63. package/dist/extension-js-theme/chromium/manifest.json +68 -0
  64. package/dist/extension-js-theme/edge/manifest.json +68 -0
  65. package/dist/extension-js-theme/firefox/manifest.json +6 -0
  66. package/dist/main-world-bridge.js +97 -0
  67. package/dist/minimum-script-file.js +24 -0
  68. package/dist/module.js +2305 -1140
  69. package/dist/warn-no-default-export.js +5 -1
  70. package/package.json +10 -6
package/dist/module.js CHANGED
@@ -124489,7 +124489,9 @@ var __webpack_modules__ = {
124489
124489
  var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("path");
124490
124490
  var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("fs");
124491
124491
  var child_process__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("child_process");
124492
- var package_manager_detector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("package-manager-detector");
124492
+ var pintor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("pintor");
124493
+ var pintor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(pintor__WEBPACK_IMPORTED_MODULE_3__);
124494
+ var package_manager_detector__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("package-manager-detector");
124493
124495
  function parseJsonSafe(text) {
124494
124496
  const s = text && 0xfeff === text.charCodeAt(0) ? text.slice(1) : text;
124495
124497
  return JSON.parse(s || '{}');
@@ -124505,7 +124507,7 @@ var __webpack_modules__ = {
124505
124507
  }
124506
124508
  async function installOptionalDependencies(integration, dependencies) {
124507
124509
  try {
124508
- const pm = await (0, package_manager_detector__WEBPACK_IMPORTED_MODULE_3__.detect)();
124510
+ const pm = await (0, package_manager_detector__WEBPACK_IMPORTED_MODULE_4__.detect)();
124509
124511
  let installCommand = '';
124510
124512
  const quotedDir = JSON.stringify(__dirname);
124511
124513
  if ((null == pm ? void 0 : pm.name) === 'yarn') installCommand = `yarn --silent add ${dependencies.join(' ')} --cwd ${quotedDir} --optional`;
@@ -124521,7 +124523,7 @@ var __webpack_modules__ = {
124521
124523
  });
124522
124524
  await new Promise((r)=>setTimeout(r, 500));
124523
124525
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
124524
- console.log(`[${integration}] Installing root dependencies for dev...`);
124526
+ console.log(`${pintor__WEBPACK_IMPORTED_MODULE_3___default().brightMagenta("\u25BA\u25BA\u25BA Author says")} [${integration}] Installing root dependencies for dev...`);
124525
124527
  const devInstall = (null == pm ? void 0 : pm.name) === 'yarn' ? "yarn install --silent" : (null == pm ? void 0 : pm.name) === 'npm' || isFromNpx() ? "npm install --silent" : isFromPnpx() ? "pnpm install --silent" : `${'string' == typeof pm ? pm : (null == pm ? void 0 : pm.name) || 'npm'} install --silent`;
124526
124528
  (0, child_process__WEBPACK_IMPORTED_MODULE_2__.execSync)(devInstall, {
124527
124529
  stdio: 'ignore'
@@ -124573,6 +124575,7 @@ var __webpack_modules__ = {
124573
124575
  _n: ()=>writingTypeDefinitions,
124574
124576
  aP: ()=>unpackagedSuccessfully,
124575
124577
  cq: ()=>downloadingText,
124578
+ fH: ()=>noCompanionExtensionsResolved,
124576
124579
  hf: ()=>cantInstallDependencies,
124577
124580
  hv: ()=>treeWithDistFilesbrowser,
124578
124581
  iE: ()=>downloadingProjectPath,
@@ -124619,7 +124622,11 @@ var __webpack_modules__ = {
124619
124622
  }
124620
124623
  };
124621
124624
  function getLoggingPrefix(type) {
124622
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) return pintor__WEBPACK_IMPORTED_MODULE_2___default().brightMagenta('error' === type ? 'ERROR' : "\u25BA\u25BA\u25BA");
124625
+ const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
124626
+ if (isAuthor) {
124627
+ const base = 'error' === type ? 'ERROR Author says' : "\u25BA\u25BA\u25BA Author says";
124628
+ return pintor__WEBPACK_IMPORTED_MODULE_2___default().brightMagenta(base);
124629
+ }
124623
124630
  if ('error' === type) return pintor__WEBPACK_IMPORTED_MODULE_2___default().red('ERROR');
124624
124631
  if ('warn' === type) return pintor__WEBPACK_IMPORTED_MODULE_2___default().brightYellow("\u25BA\u25BA\u25BA");
124625
124632
  if ('info' === type) return pintor__WEBPACK_IMPORTED_MODULE_2___default().gray("\u25BA\u25BA\u25BA");
@@ -124631,18 +124638,14 @@ var __webpack_modules__ = {
124631
124638
  function manifestNotFoundError(manifestPath) {
124632
124639
  return `${getLoggingPrefix('error')} Manifest file not found.\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().red('Ensure the path to your extension exists and try again.')}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().red('NOT FOUND')}\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('PATH')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(manifestPath)}`;
124633
124640
  }
124634
- function runningInProduction(outputPath) {
124641
+ function runningInProduction(outputPath, browserLabel) {
124635
124642
  const manifestPath = path__WEBPACK_IMPORTED_MODULE_1__.join(outputPath, 'manifest.json');
124636
124643
  const manifest = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(manifestPath, 'utf-8'));
124637
124644
  const { name, version: version1, hostPermissions, permissions } = manifest;
124638
124645
  const hasHost = hostPermissions && hostPermissions.length;
124639
124646
  const hasPermissions = permissions && permissions.length;
124640
- return `${` \u{1F9E9} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().brightBlue('Extension.js')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(`${_package_json__WEBPACK_IMPORTED_MODULE_3__.i8}`)}`}
124641
- Extension Name ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(name)}
124642
- Extension Version ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(version1)}
124643
- Host Permissions ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(hasHost ? hostPermissions.join(', ') : 'Browser defaults')}
124644
- Permissions ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(hasPermissions ? permissions.join(', ') : 'Browser defaults')}
124645
- `;
124647
+ const browserDisplay = browserLabel && browserLabel.trim().length > 0 ? browserLabel.trim() : 'Unknown';
124648
+ return ` \u{1F9E9} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().brightBlue('Extension.js')} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(`${_package_json__WEBPACK_IMPORTED_MODULE_3__.i8}`)}\n Browser ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(browserDisplay)}\n Extension ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(version1 ? `${name} ${version1}` : name)}\n Permissions ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(hasPermissions ? permissions.join(', ') : 'Browser defaults')}\n Host Permissions ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(hasHost ? hostPermissions.join(', ') : 'Browser defaults')}`;
124646
124649
  }
124647
124650
  function previewing(browser) {
124648
124651
  return `${getLoggingPrefix('info')} Previewing the extension on ${capitalizedBrowserName(browser)}...`;
@@ -124797,6 +124800,9 @@ var __webpack_modules__ = {
124797
124800
  const list = extensions.map((e)=>`- ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline(e)}`).join('\n');
124798
124801
  return `${header}\n${list}`;
124799
124802
  }
124803
+ function noCompanionExtensionsResolved() {
124804
+ return `${getLoggingPrefix('warn')} No companion extensions resolved from ${pintor__WEBPACK_IMPORTED_MODULE_2___default().underline('extensions')} config.\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray('Ensure each companion extension is an unpacked extension directory containing a manifest.json (e.g., ./extensions/<name>/manifest.json).')}`;
124805
+ }
124800
124806
  function installingDependenciesFailed(gitCommand, gitArgs, code) {
124801
124807
  return `${getLoggingPrefix('error')} Command ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(gitCommand)} ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(gitArgs.join(' '))} failed.\n${pintor__WEBPACK_IMPORTED_MODULE_2___default().red(`exit code ${pintor__WEBPACK_IMPORTED_MODULE_2___default().gray(String(code))}`)}`;
124802
124808
  }
@@ -124827,26 +124833,10 @@ var __webpack_modules__ = {
124827
124833
  "use strict";
124828
124834
  module.exports = require("child_process");
124829
124835
  },
124830
- "chrome-location2": function(module) {
124831
- "use strict";
124832
- module.exports = require("chrome-location2");
124833
- },
124834
- "chromium-location": function(module) {
124835
- "use strict";
124836
- module.exports = require("chromium-location");
124837
- },
124838
124836
  crypto: function(module) {
124839
124837
  "use strict";
124840
124838
  module.exports = require("crypto");
124841
124839
  },
124842
- "edge-location": function(module) {
124843
- "use strict";
124844
- module.exports = require("edge-location");
124845
- },
124846
- "firefox-location2": function(module) {
124847
- "use strict";
124848
- module.exports = require("firefox-location2");
124849
- },
124850
124840
  fs: function(module) {
124851
124841
  "use strict";
124852
124842
  module.exports = require("fs");
@@ -124887,7 +124877,7 @@ var __webpack_modules__ = {
124887
124877
  },
124888
124878
  "./package.json": function(module) {
124889
124879
  "use strict";
124890
- module.exports = JSON.parse('{"i8":"3.0.0-next.60","HO":{"@rspack/core":"^1.6.3","@rspack/dev-server":"^1.1.4","@swc/core":"^1.13.2","@swc/helpers":"^0.5.15","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"3.2.1","chromium-location":"1.2.3","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","edge-location":"^2.1.1","firefox-location2":"2.1.1","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","magic-string":"^0.30.10","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.2.0","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"}}');
124880
+ module.exports = JSON.parse('{"i8":"3.0.0-next.67","HO":{"@rspack/core":"^1.6.3","@rspack/dev-server":"^1.1.4","@swc/core":"^1.13.2","@swc/helpers":"^0.5.15","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"4.0.0","chromium-location":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","edge-location":"2.2.0","firefox-location2":"3.0.0","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","magic-string":"^0.30.10","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.2.0","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"}}');
124891
124881
  }
124892
124882
  };
124893
124883
  var __webpack_module_cache__ = {};
@@ -124971,6 +124961,7 @@ var __webpack_exports__ = {};
124971
124961
  var external_path_ = __webpack_require__("path");
124972
124962
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
124973
124963
  var external_fs_ = __webpack_require__("fs");
124964
+ var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_);
124974
124965
  var webpack_lib_messages = __webpack_require__("./webpack/webpack-lib/messages.ts");
124975
124966
  async function findUpLocal(filename, options) {
124976
124967
  const root = external_path_.parse(options.cwd).root;
@@ -125158,10 +125149,27 @@ var __webpack_exports__ = {};
125158
125149
  };
125159
125150
  }
125160
125151
  const external_os_namespaceObject = require("os");
125152
+ const external_vm_namespaceObject = require("vm");
125161
125153
  const external_url_namespaceObject = require("url");
125162
125154
  var external_module_ = __webpack_require__("module");
125163
125155
  const external_dotenv_namespaceObject = require("dotenv");
125164
125156
  var external_dotenv_default = /*#__PURE__*/ __webpack_require__.n(external_dotenv_namespaceObject);
125157
+ function loadCommonJsConfigWithStableDirname(absolutePath) {
125158
+ var _module_exports;
125159
+ const code = external_fs_.readFileSync(absolutePath, 'utf-8');
125160
+ const dirname = external_path_.dirname(absolutePath);
125161
+ const requireFn = (0, external_module_.createRequire)(absolutePath);
125162
+ const module = {
125163
+ exports: {}
125164
+ };
125165
+ const exports1 = module.exports;
125166
+ const wrapped = `(function (exports, require, module, __filename, __dirname) {\n${code}\n})`;
125167
+ const fn = new external_vm_namespaceObject.Script(wrapped, {
125168
+ filename: absolutePath
125169
+ }).runInThisContext();
125170
+ fn(exports1, requireFn, module, absolutePath, dirname);
125171
+ return (null == (_module_exports = module.exports) ? void 0 : _module_exports.default) || module.exports;
125172
+ }
125165
125173
  function preloadEnvFiles(projectDir) {
125166
125174
  try {
125167
125175
  const defaultsPath = external_path_.join(projectDir, '.env.defaults');
@@ -125223,12 +125231,15 @@ var __webpack_exports__ = {};
125223
125231
  } catch (requireErr) {
125224
125232
  const message = String((null == error ? void 0 : error.message) || '') + ' ' + String((null == requireErr ? void 0 : requireErr.message) || '');
125225
125233
  const looksLikeCommonJsInEsm = message.includes('require is not defined in ES module scope') || message.includes('Cannot use import statement outside a module') || message.includes('ERR_REQUIRE_ESM');
125226
- if (looksLikeCommonJsInEsm) {
125234
+ if (looksLikeCommonJsInEsm) try {
125235
+ required = loadCommonJsConfigWithStableDirname(absolutePath);
125236
+ } catch {
125227
125237
  const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_namespaceObject.tmpdir(), 'extension-config-'));
125228
125238
  const tmpCjsPath = external_path_.join(tmpDir, external_path_.basename(absolutePath, external_path_.extname(absolutePath)) + '.cjs');
125229
125239
  external_fs_.copyFileSync(absolutePath, tmpCjsPath);
125230
125240
  required = requireFn(tmpCjsPath);
125231
- } else throw requireErr;
125241
+ }
125242
+ else throw requireErr;
125232
125243
  }
125233
125244
  return (null == required ? void 0 : required.default) || required;
125234
125245
  }
@@ -125280,7 +125291,14 @@ var __webpack_exports__ = {};
125280
125291
  if (configPath) {
125281
125292
  if (await isUsingExperimentalConfig(projectPath)) try {
125282
125293
  const userConfig = await loadConfigFile(configPath);
125283
- if (userConfig && userConfig.commands && userConfig.commands[command]) return userConfig.commands[command];
125294
+ const baseExtensions = userConfig && userConfig.extensions ? {
125295
+ extensions: userConfig.extensions
125296
+ } : {};
125297
+ const perCommand = userConfig && userConfig.commands && userConfig.commands[command] ? userConfig.commands[command] : {};
125298
+ return {
125299
+ ...baseExtensions,
125300
+ ...perCommand
125301
+ };
125284
125302
  } catch (err) {
125285
125303
  const error = err;
125286
125304
  console.error(webpack_lib_messages.rF(configPath, error));
@@ -125302,7 +125320,19 @@ var __webpack_exports__ = {};
125302
125320
  if (configPath) {
125303
125321
  if (await isUsingExperimentalConfig(projectPath)) try {
125304
125322
  const userConfig = await loadConfigFile(configPath);
125305
- if (userConfig && userConfig.browser && userConfig.browser[browser]) return userConfig.browser[browser];
125323
+ if (userConfig && userConfig.browser) {
125324
+ const browsers = userConfig.browser;
125325
+ if ('chromium-based' === browser) {
125326
+ if (browsers['chromium-based']) return browsers['chromium-based'];
125327
+ if (browsers.chromium) return browsers.chromium;
125328
+ } else if ('gecko-based' === browser) {
125329
+ if (browsers['gecko-based']) return browsers['gecko-based'];
125330
+ if (browsers.firefox) return browsers.firefox;
125331
+ } else {
125332
+ const direct = browsers[browser];
125333
+ if (direct) return direct;
125334
+ }
125335
+ }
125306
125336
  } catch (err) {
125307
125337
  const error = err;
125308
125338
  console.error(webpack_lib_messages.rF(configPath, error));
@@ -125419,19 +125449,6 @@ var __webpack_exports__ = {};
125419
125449
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(error);
125420
125450
  }
125421
125451
  }
125422
- function scrubBrand(txt, brand = 'Extension.js') {
125423
- if (!txt) return txt;
125424
- return txt.replace(/\bRspack\b/gi, brand).replace(/\bWebpack\b/gi, brand).replace(/\bwebpack-dev-server\b/gi, `${brand} dev server`).replace(/\bRspackDevServer\b/gi, `${brand} dev server`).replace(/ModuleBuildError:\s*/g, '').replace(/ModuleParseError:\s*/g, '').replace(/Error:\s*Module\s+build\s+failed.*?\n/gi, '').replace(/\n{3,}/g, '\n\n');
125425
- }
125426
- function makeSanitizedConsole(brand = 'Extension.js') {
125427
- const sanitize = (a)=>'string' == typeof a ? scrubBrand(a, brand) : a;
125428
- return {
125429
- log: (...args)=>console.log(...args.map(sanitize)),
125430
- info: (...args)=>console.info(...args.map(sanitize)),
125431
- warn: (...args)=>console.warn(...args.map(sanitize)),
125432
- error: (...args)=>console.error(...args.map(sanitize))
125433
- };
125434
- }
125435
125452
  function asAbsolute(p) {
125436
125453
  return external_path_.isAbsolute(p) ? p : external_path_.resolve(p);
125437
125454
  }
@@ -125510,6 +125527,52 @@ var __webpack_exports__ = {};
125510
125527
  return 'chrome';
125511
125528
  }
125512
125529
  }
125530
+ function getBuildSummary(browser, info) {
125531
+ const assets = (null == info ? void 0 : info.assets) || [];
125532
+ return {
125533
+ browser,
125534
+ total_assets: assets.length,
125535
+ total_bytes: assets.reduce((n, a)=>n + (a.size || 0), 0),
125536
+ largest_asset_bytes: assets.reduce((m, a)=>Math.max(m, a.size || 0), 0),
125537
+ warnings_count: ((null == info ? void 0 : info.warnings) || []).length,
125538
+ errors_count: ((null == info ? void 0 : info.errors) || []).length
125539
+ };
125540
+ }
125541
+ function scrubBrand(txt, brand = 'Extension.js') {
125542
+ if (!txt) return txt;
125543
+ return txt.replace(/\bRspack\b/gi, brand).replace(/\bWebpack\b/gi, brand).replace(/\bwebpack-dev-server\b/gi, `${brand} dev server`).replace(/\bRspackDevServer\b/gi, `${brand} dev server`).replace(/ModuleBuildError:\s*/g, '').replace(/ModuleParseError:\s*/g, '').replace(/Error:\s*Module\s+build\s+failed.*?\n/gi, '').replace(/\n{3,}/g, '\n\n');
125544
+ }
125545
+ function makeSanitizedConsole(brand = 'Extension.js') {
125546
+ const sanitize = (a)=>'string' == typeof a ? scrubBrand(a, brand) : a;
125547
+ return {
125548
+ log: (...args)=>console.log(...args.map(sanitize)),
125549
+ info: (...args)=>console.info(...args.map(sanitize)),
125550
+ warn: (...args)=>console.warn(...args.map(sanitize)),
125551
+ error: (...args)=>console.error(...args.map(sanitize))
125552
+ };
125553
+ }
125554
+ function handleStatsErrors(stats) {
125555
+ try {
125556
+ const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
125557
+ const str = stats.toString({
125558
+ colors: true,
125559
+ all: false,
125560
+ errors: true,
125561
+ warnings: !!verbose
125562
+ });
125563
+ if (str) console.error(scrubBrand(str));
125564
+ } catch {
125565
+ try {
125566
+ const str = stats.toString({
125567
+ colors: true,
125568
+ all: false,
125569
+ errors: true,
125570
+ warnings: true
125571
+ });
125572
+ if (str) console.error(str);
125573
+ } catch {}
125574
+ }
125575
+ }
125513
125576
  function filterKeysForThisBrowser(manifest, browser) {
125514
125577
  const CHROMIUM_BASED_BROWSERS = [
125515
125578
  'chrome',
@@ -125577,20 +125640,84 @@ var __webpack_exports__ = {};
125577
125640
  preferences: nextPreferences
125578
125641
  };
125579
125642
  }
125580
- function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath) {
125643
+ function computeExtensionsToLoad(baseDir, mode, browser, userExtensionOutputPath, extraExtensionDirs = []) {
125581
125644
  const list = [];
125582
125645
  try {
125583
125646
  const engine = devtoolsEngineFor(browser);
125584
- const devtoolsRoot = external_path_.resolve(baseDir, '../dist/extension-js-devtools');
125585
- const themeRoot = external_path_.resolve(baseDir, '../dist/extension-js-theme');
125647
+ const distRoot = external_path_.resolve(baseDir, 'dist');
125648
+ const devtoolsRoot = external_path_.join(distRoot, 'extension-js-devtools');
125649
+ const themeRoot = external_path_.join(distRoot, 'extension-js-theme');
125586
125650
  const devtoolsForBrowser = external_path_.join(devtoolsRoot, engine);
125587
125651
  const themeForBrowser = external_path_.join(themeRoot, engine);
125588
125652
  if ('production' !== mode && external_fs_.existsSync(devtoolsForBrowser)) list.push(devtoolsForBrowser);
125589
125653
  if (external_fs_.existsSync(themeForBrowser)) list.push(themeForBrowser);
125590
125654
  } catch {}
125655
+ for (const p of extraExtensionDirs)list.push(p);
125591
125656
  list.push(userExtensionOutputPath);
125592
125657
  return list;
125593
125658
  }
125659
+ function isDir(p) {
125660
+ try {
125661
+ return external_fs_.existsSync(p) && external_fs_.statSync(p).isDirectory();
125662
+ } catch {
125663
+ return false;
125664
+ }
125665
+ }
125666
+ function isFile(p) {
125667
+ try {
125668
+ return external_fs_.existsSync(p) && external_fs_.statSync(p).isFile();
125669
+ } catch {
125670
+ return false;
125671
+ }
125672
+ }
125673
+ function toAbs(projectRoot, p) {
125674
+ return external_path_.isAbsolute(p) ? p : external_path_.resolve(projectRoot, p);
125675
+ }
125676
+ function isValidExtensionRoot(dir) {
125677
+ if (!isDir(dir)) return false;
125678
+ return isFile(external_path_.join(dir, 'manifest.json'));
125679
+ }
125680
+ function resolveCompanionExtensionDirs(opts) {
125681
+ const { projectRoot, config } = opts;
125682
+ const explicitPaths = [];
125683
+ let scanDir;
125684
+ if (Array.isArray(config)) explicitPaths.push(...config.filter((p)=>'string' == typeof p));
125685
+ else if (config && 'object' == typeof config) {
125686
+ if (Array.isArray(config.paths)) explicitPaths.push(...config.paths.filter((p)=>'string' == typeof p));
125687
+ if ('string' == typeof config.dir && config.dir.trim().length > 0) scanDir = config.dir.trim();
125688
+ }
125689
+ const found = [];
125690
+ for (const p of explicitPaths){
125691
+ const abs = toAbs(projectRoot, p);
125692
+ if (isValidExtensionRoot(abs)) found.push(abs);
125693
+ }
125694
+ if (scanDir) {
125695
+ const absScan = toAbs(projectRoot, scanDir);
125696
+ if (isDir(absScan)) {
125697
+ let entries = [];
125698
+ try {
125699
+ entries = external_fs_.readdirSync(absScan, {
125700
+ withFileTypes: true
125701
+ });
125702
+ } catch {
125703
+ entries = [];
125704
+ }
125705
+ for (const ent of entries){
125706
+ if (!ent.isDirectory()) continue;
125707
+ if (ent.name.startsWith('.')) continue;
125708
+ const candidate = external_path_.join(absScan, ent.name);
125709
+ if (isValidExtensionRoot(candidate)) found.push(candidate);
125710
+ }
125711
+ }
125712
+ }
125713
+ const unique = [];
125714
+ const seen = new Set();
125715
+ for (const p of found)if (!seen.has(p)) {
125716
+ seen.add(p);
125717
+ unique.push(p);
125718
+ }
125719
+ return unique;
125720
+ }
125594
125721
  const external_case_sensitive_paths_webpack_plugin_namespaceObject = require("case-sensitive-paths-webpack-plugin");
125595
125722
  var external_case_sensitive_paths_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_case_sensitive_paths_webpack_plugin_namespaceObject);
125596
125723
  var external_pintor_ = __webpack_require__("pintor");
@@ -125934,10 +126061,7 @@ var __webpack_exports__ = {};
125934
126061
  const manifestName = boring_readJsonFileSafe(this.manifestPath).name;
125935
126062
  const line = boring(manifestName, duration, stats);
125936
126063
  try {
125937
- if ('function' == typeof stats.hasErrors && stats.hasErrors()) {
125938
- var _compiler_getInfrastructureLogger;
125939
- (null == (_compiler_getInfrastructureLogger = compiler.getInfrastructureLogger('plugin-boring')) ? void 0 : _compiler_getInfrastructureLogger.info) || console.error(line);
125940
- }
126064
+ console.log(line);
125941
126065
  } catch {}
125942
126066
  });
125943
126067
  }
@@ -126042,7 +126166,7 @@ var __webpack_exports__ = {};
126042
126166
  function isUsingSass(projectPath) {
126043
126167
  if ((0, css_lib_integrations.S)(projectPath, 'sass')) {
126044
126168
  if (!sass_userMessageDelivered) {
126045
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('SASS'));
126169
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('SASS')}`);
126046
126170
  sass_userMessageDelivered = true;
126047
126171
  }
126048
126172
  return true;
@@ -126142,7 +126266,7 @@ var __webpack_exports__ = {};
126142
126266
  function isUsingLess(projectPath) {
126143
126267
  if ((0, css_lib_integrations.S)(projectPath, 'less')) {
126144
126268
  if (!less_userMessageDelivered) {
126145
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('LESS'));
126269
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('LESS')}`);
126146
126270
  less_userMessageDelivered = true;
126147
126271
  }
126148
126272
  return true;
@@ -126228,7 +126352,7 @@ var __webpack_exports__ = {};
126228
126352
  const isUsingStylelint = !!configFile;
126229
126353
  if (isUsingStylelint) {
126230
126354
  if (!stylelint_userMessageDelivered) {
126231
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('Stylelint'));
126355
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('Stylelint')}`);
126232
126356
  stylelint_userMessageDelivered = true;
126233
126357
  }
126234
126358
  }
@@ -126243,7 +126367,7 @@ var __webpack_exports__ = {};
126243
126367
  const isUsingTailwind = (0, css_lib_integrations.S)(projectPath, 'tailwindcss') || (0, css_lib_integrations.S)(projectPath, '@tailwindcss/postcss');
126244
126368
  if (isUsingTailwind) {
126245
126369
  if (!tailwind_userMessageDelivered) {
126246
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('Tailwind'));
126370
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('Tailwind')}`);
126247
126371
  tailwind_userMessageDelivered = true;
126248
126372
  }
126249
126373
  }
@@ -126278,21 +126402,21 @@ var __webpack_exports__ = {};
126278
126402
  function isUsingPostCss(projectPath) {
126279
126403
  if ((0, css_lib_integrations.S)(projectPath, 'postcss')) {
126280
126404
  if (!postcss_userMessageDelivered) {
126281
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('PostCSS'));
126405
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('PostCSS')}`);
126282
126406
  postcss_userMessageDelivered = true;
126283
126407
  }
126284
126408
  return true;
126285
126409
  }
126286
126410
  if (findPostCssConfig(projectPath)) {
126287
126411
  if (!postcss_userMessageDelivered) {
126288
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('PostCSS'));
126412
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('PostCSS')}`);
126289
126413
  postcss_userMessageDelivered = true;
126290
126414
  }
126291
126415
  return true;
126292
126416
  }
126293
126417
  if (tailwind_isUsingTailwind(projectPath)) {
126294
126418
  if (!postcss_userMessageDelivered) {
126295
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(isUsingIntegration('PostCSS'));
126419
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${isUsingIntegration('PostCSS')}`);
126296
126420
  postcss_userMessageDelivered = true;
126297
126421
  }
126298
126422
  return true;
@@ -126369,9 +126493,9 @@ var __webpack_exports__ = {};
126369
126493
  };
126370
126494
  if (pluginsFromOptions) postcssOptions.plugins = pluginsFromOptions;
126371
126495
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) try {
126372
- console.log('[extension.js:postcss] projectPath=%s userPostCssConfig=%s pkgHasPostCss=%s tailwindPresent=%s', projectPath, userPostCssConfig || 'none', pkgHasPostCss, tailwindPresent);
126496
+ console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} [extension.js:postcss] projectPath=%s userPostCssConfig=%s pkgHasPostCss=%s tailwindPresent=%s`, projectPath, userPostCssConfig || 'none', pkgHasPostCss, tailwindPresent);
126373
126497
  const resolvedPluginsCount = Array.isArray(postcssOptions.plugins) ? postcssOptions.plugins.length : 0;
126374
- console.log('[extension.js:postcss] resolvedPlugins=%d config=%s cwd=%s', resolvedPluginsCount, String(postcssOptions.config), String(postcssOptions.cwd));
126498
+ console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} [extension.js:postcss] resolvedPlugins=%d config=%s cwd=%s`, resolvedPluginsCount, String(postcssOptions.config), String(postcssOptions.cwd));
126375
126499
  } catch {}
126376
126500
  return {
126377
126501
  test: /\.css$/,
@@ -126797,7 +126921,7 @@ var __webpack_exports__ = {};
126797
126921
  function isUsingPreact(projectPath) {
126798
126922
  if ((0, css_lib_integrations.S)(projectPath, 'preact')) {
126799
126923
  if (!preact_userMessageDelivered) {
126800
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages_isUsingIntegration('Preact'));
126924
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${messages_isUsingIntegration('Preact')}`);
126801
126925
  preact_userMessageDelivered = true;
126802
126926
  }
126803
126927
  return true;
@@ -126849,7 +126973,7 @@ var __webpack_exports__ = {};
126849
126973
  function isUsingReact(projectPath) {
126850
126974
  if ((0, css_lib_integrations.S)(projectPath, 'react')) {
126851
126975
  if (!react_userMessageDelivered) {
126852
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages_isUsingIntegration('React'));
126976
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${messages_isUsingIntegration('React')}`);
126853
126977
  react_userMessageDelivered = true;
126854
126978
  }
126855
126979
  return true;
@@ -126953,7 +127077,7 @@ var __webpack_exports__ = {};
126953
127077
  function isUsingVue(projectPath) {
126954
127078
  const using = (0, css_lib_integrations.S)(projectPath, 'vue');
126955
127079
  if (using && !vue_userMessageDelivered) {
126956
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages_isUsingIntegration('Vue'));
127080
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${messages_isUsingIntegration('Vue')}`);
126957
127081
  vue_userMessageDelivered = true;
126958
127082
  }
126959
127083
  return using;
@@ -127044,9 +127168,11 @@ var __webpack_exports__ = {};
127044
127168
  const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
127045
127169
  if (!hasShownUserMessage) {
127046
127170
  if (TypeScriptAsDevDep || TypeScriptAsDep || hasTsFiles) if (tsConfigFilePath) {
127047
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages_isUsingIntegration('TypeScript'));
127048
- } else if (hasTsFiles) console.warn('[Extension.js] TypeScript/TSX files detected but no tsconfig.json found near manifest. Consider adding src/tsconfig.json with { "extends": "../tsconfig.json" }.');
127049
- else {
127171
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(`${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA Author says")} ${messages_isUsingIntegration('TypeScript')}`);
127172
+ } else if (hasTsFiles) {
127173
+ const errorMessage = '[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.';
127174
+ throw new Error(errorMessage);
127175
+ } else {
127050
127176
  console.log(creatingTSConfig());
127051
127177
  writeTsConfig(projectPath);
127052
127178
  }
@@ -127082,12 +127208,10 @@ var __webpack_exports__ = {};
127082
127208
  };
127083
127209
  }
127084
127210
  function getUserTypeScriptConfigFile(projectPath) {
127085
- const local = external_path_.join(projectPath, 'tsconfig.json');
127086
- if (external_fs_.existsSync(local)) return local;
127087
127211
  const pkgDir = typescript_findNearestPackageJsonDirectory(projectPath);
127088
127212
  if (pkgDir) {
127089
- const rootTs = external_path_.join(pkgDir, 'tsconfig.json');
127090
- if (external_fs_.existsSync(rootTs)) return rootTs;
127213
+ const tsconfigPath = external_path_.join(pkgDir, 'tsconfig.json');
127214
+ if (external_fs_.existsSync(tsconfigPath)) return tsconfigPath;
127091
127215
  }
127092
127216
  }
127093
127217
  function writeTsConfig(projectPath) {
@@ -127482,7 +127606,7 @@ var __webpack_exports__ = {};
127482
127606
  if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
127483
127607
  return unixPath;
127484
127608
  }
127485
- function background(manifest) {
127609
+ function background_background(manifest) {
127486
127610
  return manifest.background && manifest.background.scripts && {
127487
127611
  background: {
127488
127612
  ...manifest.background,
@@ -127639,7 +127763,7 @@ var __webpack_exports__ = {};
127639
127763
  }
127640
127764
  function manifestV2(manifest) {
127641
127765
  return {
127642
- ...background(manifest),
127766
+ ...background_background(manifest),
127643
127767
  ...browserAction(manifest),
127644
127768
  ...pageAction(manifest),
127645
127769
  ...sidebarAction(manifest),
@@ -127699,7 +127823,7 @@ var __webpack_exports__ = {};
127699
127823
  }
127700
127824
  };
127701
127825
  }
127702
- function hostPermissions(manifest) {
127826
+ function host_permissions_hostPermissions(manifest) {
127703
127827
  return manifest.host_permissions && {
127704
127828
  host_permissions: manifest.host_permissions
127705
127829
  };
@@ -127724,7 +127848,7 @@ var __webpack_exports__ = {};
127724
127848
  ...action_action(manifest),
127725
127849
  ...backgroundServiceWorker(manifest),
127726
127850
  ...declarativeNetRequest(manifest),
127727
- ...hostPermissions(manifest),
127851
+ ...host_permissions_hostPermissions(manifest),
127728
127852
  ...sidePanel(manifest)
127729
127853
  };
127730
127854
  }
@@ -127773,25 +127897,41 @@ var __webpack_exports__ = {};
127773
127897
  }
127774
127898
  };
127775
127899
  }
127776
- function contentScripts(manifest) {
127777
- return manifest.content_scripts && {
127778
- content_scripts: manifest.content_scripts.map((contentObj, index)=>{
127779
- const contentJs = [
127780
- ...new Set(contentObj.js)
127781
- ];
127782
- const contentCss = [
127783
- ...new Set(contentObj.css)
127784
- ];
127785
- return {
127786
- ...contentObj,
127787
- js: [
127788
- ...contentJs.map((js)=>getFilename(`content_scripts/content-${index}.js`, js))
127789
- ],
127790
- css: [
127791
- ...contentCss.map((css)=>getFilename(`content_scripts/content-${index}.css`, css))
127792
- ]
127793
- };
127794
- })
127900
+ function content_scripts_contentScripts(manifest) {
127901
+ if (!manifest.content_scripts) return;
127902
+ const original = manifest.content_scripts;
127903
+ const originalCount = original.length;
127904
+ const result = [];
127905
+ for(let index = 0; index < original.length; index++){
127906
+ const contentObj = original[index] || {};
127907
+ const contentJs = [
127908
+ ...new Set(contentObj.js || [])
127909
+ ];
127910
+ const contentCss = [
127911
+ ...new Set(contentObj.css || [])
127912
+ ];
127913
+ result.push({
127914
+ ...original[index] || {},
127915
+ js: contentJs.map((js)=>getFilename(`content_scripts/content-${index}.js`, js)),
127916
+ css: contentCss.map((css)=>getFilename(`content_scripts/content-${index}.css`, css))
127917
+ });
127918
+ }
127919
+ let bridgeOrdinal = 0;
127920
+ for(let i = 0; i < original.length; i++){
127921
+ const cs = original[i];
127922
+ if (!cs || 'MAIN' !== cs.world) continue;
127923
+ const bridgeIndex = originalCount + bridgeOrdinal++;
127924
+ const { world: _ignoredWorld, js: _ignoredJs, css: _ignoredCss, ...rest } = cs;
127925
+ result.push({
127926
+ ...rest,
127927
+ js: [
127928
+ getFilename(`content_scripts/content-${bridgeIndex}.js`, 'main-world-bridge.js')
127929
+ ],
127930
+ css: []
127931
+ });
127932
+ }
127933
+ return {
127934
+ content_scripts: result
127795
127935
  };
127796
127936
  }
127797
127937
  function devtoolsPage(manifest) {
@@ -127822,7 +127962,7 @@ var __webpack_exports__ = {};
127822
127962
  commands: manifest.commands
127823
127963
  };
127824
127964
  }
127825
- function permissions(manifest) {
127965
+ function permissions_permissions(manifest) {
127826
127966
  return manifest.permissions && {
127827
127967
  permissions: manifest.permissions
127828
127968
  };
@@ -127934,11 +128074,11 @@ var __webpack_exports__ = {};
127934
128074
  return {
127935
128075
  ...backgroundPage(manifest),
127936
128076
  ...chromeUrlOverrides(manifest),
127937
- ...contentScripts(manifest),
128077
+ ...content_scripts_contentScripts(manifest),
127938
128078
  ...devtoolsPage(manifest),
127939
128079
  ...icons_icons(manifest),
127940
128080
  ...commands(manifest),
127941
- ...permissions(manifest),
128081
+ ...permissions_permissions(manifest),
127942
128082
  ...optionsPage(manifest),
127943
128083
  ...optionsUi(manifest),
127944
128084
  ...sandbox(manifest),
@@ -128041,23 +128181,6 @@ var __webpack_exports__ = {};
128041
128181
  const rawSource = new core_namespaceObject.sources.RawSource(source);
128042
128182
  compilation.updateAsset('manifest.json', rawSource);
128043
128183
  });
128044
- if ('production' === compiler.options.mode) compilation.hooks.processAssets.tap('manifest:update-manifest', ()=>{
128045
- if (compilation.errors.length > 0) return;
128046
- const manifest = getManifestContent(compilation, this.manifestPath);
128047
- const overrides = getManifestOverrides(this.manifestPath, manifest);
128048
- const patchedManifest = {
128049
- ...manifest,
128050
- ...JSON.parse(overrides)
128051
- };
128052
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) try {
128053
- const overrideObj = JSON.parse(overrides || '{}');
128054
- const overrideKeys = Object.keys(overrideObj || {}).length;
128055
- console.log(manifestOverridesSummary(overrideKeys, 0));
128056
- } catch {}
128057
- const source = JSON.stringify(patchedManifest, null, 2);
128058
- const rawSource = new core_namespaceObject.sources.RawSource(source);
128059
- compilation.updateAsset('manifest.json', rawSource);
128060
- });
128061
128184
  });
128062
128185
  }
128063
128186
  constructor(options){
@@ -129597,8 +129720,106 @@ var __webpack_exports__ = {};
129597
129720
  });
129598
129721
  return fileAssets;
129599
129722
  }
129600
- function scriptsIncludeSummary(featureCount, devMode, browser) {
129601
- return `Scripts include summary \u{2014} features=${external_pintor_default().gray(String(featureCount))}, dev=${external_pintor_default().gray(String(devMode))}, browser=${external_pintor_default().yellow(browser)}`;
129723
+ function getMainWorldBridgeScripts(manifestPath) {
129724
+ const bridgeScripts = {};
129725
+ try {
129726
+ const raw = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
129727
+ const contentScripts = Array.isArray(null == raw ? void 0 : raw.content_scripts) ? raw.content_scripts : [];
129728
+ const originalCount = contentScripts.length;
129729
+ const bridgeSourceCandidates = [
129730
+ external_path_default().resolve(__dirname, 'main-world-bridge.js'),
129731
+ external_path_default().resolve(__dirname, '../../../../../../main-world-bridge.js')
129732
+ ];
129733
+ const bridgeSource = bridgeSourceCandidates.find((p)=>external_fs_default().existsSync(p)) || bridgeSourceCandidates[0];
129734
+ let bridgeOrdinal = 0;
129735
+ for(let i = 0; i < contentScripts.length; i++){
129736
+ const cs = contentScripts[i];
129737
+ if ((null == cs ? void 0 : cs.world) !== 'MAIN') continue;
129738
+ const bridgeIndex = originalCount + bridgeOrdinal++;
129739
+ bridgeScripts[`content_scripts/content-${bridgeIndex}`] = bridgeSource;
129740
+ }
129741
+ } catch {}
129742
+ return bridgeScripts;
129743
+ }
129744
+ function add_content_script_wrapper_define_property(obj, key, value) {
129745
+ if (key in obj) Object.defineProperty(obj, key, {
129746
+ value: value,
129747
+ enumerable: true,
129748
+ configurable: true,
129749
+ writable: true
129750
+ });
129751
+ else obj[key] = value;
129752
+ return obj;
129753
+ }
129754
+ class AddContentScriptWrapper {
129755
+ static getBridgeScripts(manifestPath) {
129756
+ return getMainWorldBridgeScripts(manifestPath);
129757
+ }
129758
+ apply(compiler) {
129759
+ compiler.options.module.rules.push({
129760
+ test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
129761
+ include: [
129762
+ external_path_.dirname(this.manifestPath)
129763
+ ],
129764
+ exclude: [
129765
+ /([\\/])node_modules\1/
129766
+ ],
129767
+ use: [
129768
+ {
129769
+ loader: external_path_.resolve(__dirname, "content-script-wrapper"),
129770
+ options: {
129771
+ manifestPath: this.manifestPath,
129772
+ mode: compiler.options.mode
129773
+ }
129774
+ }
129775
+ ]
129776
+ });
129777
+ if ('production' !== compiler.options.mode) {
129778
+ compiler.options.module.rules.push({
129779
+ test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
129780
+ include: [
129781
+ external_path_.dirname(this.manifestPath)
129782
+ ],
129783
+ exclude: [
129784
+ /([\\/])node_modules\1/
129785
+ ],
129786
+ use: [
129787
+ {
129788
+ loader: external_path_.resolve(__dirname, 'warn-no-default-export'),
129789
+ options: {
129790
+ manifestPath: this.manifestPath,
129791
+ mode: compiler.options.mode
129792
+ }
129793
+ }
129794
+ ],
129795
+ enforce: 'pre'
129796
+ });
129797
+ compiler.options.module.rules.push({
129798
+ test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
129799
+ include: [
129800
+ external_path_.dirname(this.manifestPath)
129801
+ ],
129802
+ exclude: [
129803
+ /([\\/])node_modules\1/
129804
+ ],
129805
+ use: [
129806
+ {
129807
+ loader: external_path_.resolve(__dirname, 'add-hmr-accept-code'),
129808
+ options: {
129809
+ manifestPath: this.manifestPath,
129810
+ mode: compiler.options.mode
129811
+ }
129812
+ }
129813
+ ]
129814
+ });
129815
+ }
129816
+ }
129817
+ constructor(options){
129818
+ add_content_script_wrapper_define_property(this, "manifestPath", void 0);
129819
+ add_content_script_wrapper_define_property(this, "browser", void 0);
129820
+ this.manifestPath = options.manifestPath;
129821
+ this.browser = options.browser || 'chrome';
129822
+ }
129602
129823
  }
129603
129824
  function scriptsEntriesSummary(entriesAdded, publicTracked) {
129604
129825
  return `Scripts entries \u{2014} added=${external_pintor_default().gray(String(entriesAdded))}, publicTracked=${external_pintor_default().gray(String(publicTracked))}`;
@@ -129624,7 +129845,12 @@ var __webpack_exports__ = {};
129624
129845
  class AddScripts {
129625
129846
  apply(compiler) {
129626
129847
  var _compiler_hooks_thisCompilation, _compiler_hooks, _compiler_hooks_thisCompilation1, _compiler_hooks1;
129627
- const scriptFields = this.includeList || {};
129848
+ const bridgeScripts = AddContentScriptWrapper.getBridgeScripts(this.manifestPath);
129849
+ const mergedIncludeList = {
129850
+ ...this.includeList,
129851
+ ...bridgeScripts
129852
+ };
129853
+ const scriptFields = mergedIncludeList;
129628
129854
  if (null == compiler ? void 0 : null == (_compiler_hooks = compiler.hooks) ? void 0 : null == (_compiler_hooks_thisCompilation = _compiler_hooks.thisCompilation) ? void 0 : _compiler_hooks_thisCompilation.tap) compiler.hooks.thisCompilation.tap("scripts:validate-include-list", (compilation)=>{
129629
129855
  try {
129630
129856
  var _compilation_options_output, _compilation_options, _compiler_rspack;
@@ -129759,41 +129985,885 @@ var __webpack_exports__ = {};
129759
129985
  }
129760
129986
  return new PublicPathRuntimeModule();
129761
129987
  }
129762
- const external_webpack_target_webextension_namespaceObject = require("webpack-target-webextension");
129763
- var external_webpack_target_webextension_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_target_webextension_namespaceObject);
129764
- const external_node_module_namespaceObject = require("node:module");
129765
- function manifest_getManifestContent(compilation, manifestPath) {
129766
- var _compilation_getAsset, _compilation_assets;
129767
- if ((null == (_compilation_getAsset = compilation.getAsset) ? void 0 : _compilation_getAsset.call(compilation, 'manifest.json')) || (null == (_compilation_assets = compilation.assets) ? void 0 : _compilation_assets['manifest.json'])) {
129768
- var _compilation_assets_manifestjson_source, _compilation_assets_manifestjson;
129769
- const source = null == (_compilation_assets_manifestjson = compilation.assets['manifest.json']) ? void 0 : null == (_compilation_assets_manifestjson_source = _compilation_assets_manifestjson.source) ? void 0 : _compilation_assets_manifestjson_source.call(_compilation_assets_manifestjson);
129770
- const manifest = 'function' == typeof source ? source().toString() : String(source || '');
129771
- return JSON.parse(manifest || '{}');
129772
- }
129773
- try {
129774
- const text = external_fs_.readFileSync(manifestPath, 'utf8');
129775
- return JSON.parse(text);
129776
- } catch {
129777
- return require(manifestPath);
129988
+ function TemplateFn(compilation, Template) {
129989
+ return {
129990
+ f: (args, body)=>{
129991
+ if (!compilation) throw new TypeError('No compilation is found.');
129992
+ if (compilation.runtimeTemplate) return compilation.runtimeTemplate.basicFunction(args, body);
129993
+ return compilation.outputOptions.environment.arrowFunction ? `(${args}) => {\n${Template.indent(body)}\n}` : `function(${args}) {\n${Template.indent(body)}\n}`;
129994
+ },
129995
+ retF: (returnValue, args = '')=>{
129996
+ if (!compilation) throw new TypeError('No compilation is found.');
129997
+ if (compilation.runtimeTemplate) return compilation.runtimeTemplate.returningFunction(returnValue, args);
129998
+ return compilation.outputOptions.environment.arrowFunction ? `(${args}) => (${returnValue})` : `function(${args}) { return ${returnValue}; }`;
129999
+ }
130000
+ };
130001
+ }
130002
+ const RuntimeGlobal = '__webpack_require__.webExtRt';
130003
+ const RuntimeGlobalIsBrowser = '__webpack_require__.webExtRtModern';
130004
+ function BrowserRuntimeModule(webpack, acceptWeak) {
130005
+ const { RuntimeModule, Template } = webpack;
130006
+ class BrowserRuntime extends RuntimeModule {
130007
+ generate() {
130008
+ const { compilation } = this;
130009
+ if (!compilation) return Template.asString('/* [webpack-target-webextension] BrowserRuntimeModule skipped because no compilation is found. */');
130010
+ const optionalChaining = compilation.outputOptions.environment.optionalChaining;
130011
+ const _let = compilation.outputOptions.environment.const ? 'let' : 'var';
130012
+ return Template.asString([
130013
+ `${_let} isChrome, runtime;`,
130014
+ 'try {',
130015
+ Template.indent([
130016
+ `if (typeof browser !== "undefined" && ${optionalChaining ? 'typeof browser.runtime?.getURL === "function"' : 'typeof browser.runtime === "object" && typeof browser.runtime.getURL === "function"'}) {`,
130017
+ Template.indent([
130018
+ 'runtime = browser;'
130019
+ ]),
130020
+ '}'
130021
+ ]),
130022
+ '} catch (_) {}',
130023
+ 'if (!runtime) {',
130024
+ Template.indent([
130025
+ 'try {',
130026
+ Template.indent([
130027
+ `if (typeof chrome !== "undefined" && ${optionalChaining ? 'typeof chrome.runtime?.getURL === "function"' : 'typeof chrome.runtime === "object" && typeof chrome.runtime.getURL === "function"'}) {`,
130028
+ Template.indent([
130029
+ 'isChrome = true;',
130030
+ 'runtime = chrome;'
130031
+ ]),
130032
+ '}'
130033
+ ]),
130034
+ '} catch (_) {}'
130035
+ ]),
130036
+ '}',
130037
+ `${RuntimeGlobalIsBrowser} = !isChrome;`,
130038
+ `${RuntimeGlobal} = runtime || { runtime: null };`,
130039
+ acceptWeak ? 'if (!runtime && (typeof self !== "object" || !self.addEventListener)) {' : '',
130040
+ acceptWeak ? Template.indent([
130041
+ `${RuntimeGlobal} = { runtime: { getURL: String } };`
130042
+ ]) : '',
130043
+ acceptWeak ? '}' : ''
130044
+ ].filter(Boolean));
130045
+ }
130046
+ constructor(){
130047
+ super('WebExtensionBrowserRuntime', RuntimeModule.STAGE_NORMAL);
130048
+ }
129778
130049
  }
130050
+ return new BrowserRuntime();
129779
130051
  }
129780
- function scripts_lib_manifest_filterKeysForThisBrowser(manifest, browser) {
129781
- const CHROMIUM_BASED_BROWSERS = [
129782
- 'chrome',
129783
- 'edge'
129784
- ];
129785
- const GECKO_BASED_BROWSERS = [
129786
- 'firefox'
129787
- ];
129788
- const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
129789
- const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
129790
- const chromiumPrefixes = new Set([
129791
- 'chromium',
129792
- 'chrome',
129793
- 'edge'
129794
- ]);
129795
- const geckoPrefixes = new Set([
129796
- 'gecko',
130052
+ function LoadScript_define_property(obj, key, value) {
130053
+ if (key in obj) Object.defineProperty(obj, key, {
130054
+ value: value,
130055
+ enumerable: true,
130056
+ configurable: true,
130057
+ writable: true
130058
+ });
130059
+ else obj[key] = value;
130060
+ return obj;
130061
+ }
130062
+ const DYNAMIC_IMPORT_LOADER = 'dynamicImportLoader';
130063
+ const DOM_LOADER = "scriptLoader";
130064
+ const WORKER_LOADER = 'workerLoader';
130065
+ const CLASSIC_LOADER = 'classicLoader';
130066
+ const FALLBACK_LOADER = 'fallbackLoader';
130067
+ function LoadScriptRuntimeModule(webpack, supportDynamicImport, classicLoaderEnabled, contentScriptsMeta) {
130068
+ const { Template, RuntimeGlobals, RuntimeModule } = webpack;
130069
+ class LoadScriptRuntime extends RuntimeModule {
130070
+ generate() {
130071
+ const { compilation } = this;
130072
+ if (!compilation) return Template.asString('/* [webpack-target-webextension] ChunkLoaderFallbackRuntimeModule skipped because no compilation is found. */');
130073
+ const { f } = TemplateFn(compilation, Template);
130074
+ const _const = compilation.outputOptions.environment.const ? 'const' : 'var';
130075
+ const _let = compilation.outputOptions.environment.const ? 'let' : 'var';
130076
+ const chunkName = (this.chunk && this.chunk.name ? this.chunk.name : '') || (compilation && compilation.chunk && compilation.chunk.name ? compilation.chunk.name : '');
130077
+ const bundleId = chunkName ? `${chunkName}.js` : '';
130078
+ const world = bundleId && this.contentScriptsMeta[bundleId] ? this.contentScriptsMeta[bundleId].world : void 0;
130079
+ const isMainWorld = 'main' === world;
130080
+ const HasExtensionRuntime = `${_const} hasExtensionRuntime = (function(){ try {return ((typeof browser === "object" && browser && browser.runtime && typeof browser.runtime.sendMessage === "function") || (typeof chrome === "object" && chrome && chrome.runtime && typeof chrome.runtime.sendMessage === "function"));} catch (e) { return false; } })();`;
130081
+ const DynamicImportLoader = `${_const} ${DYNAMIC_IMPORT_LOADER} = ` + f('url, done, key, chunkId', `import(url).then(${f('', [
130082
+ 'if (isNotIframe) return done();',
130083
+ 'try {',
130084
+ Template.indent([
130085
+ "// It's a Chrome bug, if the import() is called in a sandboxed iframe, it _fails_ the script loading but _resolve_ the Promise.",
130086
+ `// we call ${RuntimeGlobals.ensureChunkHandlers}.j(chunkId) to check if it is loaded.`,
130087
+ '// if it is, this is a no-op. if it is not, it will throw a TypeError because this function requires 2 parameters.',
130088
+ '// This call will not trigger the chunk loading because it is already loading.',
130089
+ '// see https://github.com/awesome-webextension/webpack-target-webextension/issues/41',
130090
+ `chunkId !== undefined && ${RuntimeGlobals.ensureChunkHandlers}.j(chunkId);`,
130091
+ 'done();'
130092
+ ]),
130093
+ '}',
130094
+ 'catch (_) {',
130095
+ Template.indent([
130096
+ 'if (!bug816121warned) {',
130097
+ Template.indent([
130098
+ 'console.warn("Chrome bug https://crbug.com/816121 hit.");',
130099
+ 'bug816121warned = true;'
130100
+ ]),
130101
+ '}',
130102
+ `return ${FALLBACK_LOADER}(url, done, key, chunkId);`
130103
+ ]),
130104
+ '}'
130105
+ ])}, ${f('e', [
130106
+ 'console.warn("Dynamic import loader failed. Using fallback loader (see https://github.com/awesome-webextension/webpack-target-webextension#content-script).", e);',
130107
+ `${FALLBACK_LOADER}(url, done, key, chunkId);`
130108
+ ])});`);
130109
+ const DOMLoader = `${_const} ${DOM_LOADER} = ` + f('url, done', [
130110
+ `${_const} script = document.createElement('script');`,
130111
+ "script.src = url;",
130112
+ "script.onload = done;",
130113
+ "script.onerror = done;",
130114
+ "document.body.appendChild(script);"
130115
+ ]);
130116
+ const WorkerLoader = `${_const} ${WORKER_LOADER} = ` + f('url, done', [
130117
+ 'try {',
130118
+ Template.indent([
130119
+ 'importScripts(url);',
130120
+ 'done();'
130121
+ ]),
130122
+ '} catch (e) {',
130123
+ Template.indent([
130124
+ 'done(e);'
130125
+ ]),
130126
+ '}'
130127
+ ]);
130128
+ const ClassicLoader = `${_const} ${CLASSIC_LOADER} = ` + f('url, done', Template.asString([
130129
+ `${_const} msg = { type: "WTW_INJECT", file: url };`,
130130
+ `${_const} onError = ${f('e', 'done(Object.assign(e, { type: "missing" }))')};`,
130131
+ `if (${RuntimeGlobalIsBrowser}) {`,
130132
+ Template.indent([
130133
+ `${RuntimeGlobal}.runtime.sendMessage(msg).then(done, onError);`
130134
+ ]),
130135
+ '} else {',
130136
+ Template.indent([
130137
+ `${RuntimeGlobal}.runtime.sendMessage(msg, ${f('', [
130138
+ `${_const} error = ${RuntimeGlobal}.runtime.lastError;`,
130139
+ 'if (error) onError(error);',
130140
+ 'else done();'
130141
+ ])});`
130142
+ ]),
130143
+ '}'
130144
+ ])) + ';';
130145
+ const ClassicLoaderDisabled = `${_const} ${CLASSIC_LOADER} = ` + f('', [
130146
+ `throw new Error("[webpack-target-webextension] Failed to load async chunk in the content script. No script loader is found. You can either\\n - Set output.environment.dynamicImport to true if your environment supports native ES Module\\n - Specify the background entry to enable the fallback loader\\n - Set module.parser.javascript.dynamicImportMode to 'eager' to inline all async chunks.");`
130147
+ ]);
130148
+ return Template.asString([
130149
+ this.supportDynamicImport ? `${_let} bug816121warned, isNotIframe;` : '',
130150
+ this.supportDynamicImport ? Template.asString([
130151
+ 'try {',
130152
+ Template.indent([
130153
+ 'isNotIframe = typeof window === "object" ? window.top === window : true;'
130154
+ ]),
130155
+ '} catch(e) {',
130156
+ Template.indent([
130157
+ 'isNotIframe = false /* CORS error */;'
130158
+ ]),
130159
+ '}'
130160
+ ]) : '',
130161
+ HasExtensionRuntime,
130162
+ this.classicLoaderEnabled ? ClassicLoader : ClassicLoaderDisabled,
130163
+ this.supportDynamicImport ? DynamicImportLoader : '',
130164
+ DOMLoader,
130165
+ WorkerLoader,
130166
+ `${_const} isWorker = typeof importScripts === 'function'`,
130167
+ "if (typeof location === 'object' && location.protocol.includes('-extension:')) {",
130168
+ Template.indent([
130169
+ `${RuntimeGlobals.loadScript} = isWorker ? ${WORKER_LOADER} : ${DOM_LOADER};`
130170
+ ]),
130171
+ "}",
130172
+ isMainWorld ? Template.asString([
130173
+ `${_const} __extjsMark = "__extjs__";`,
130174
+ `${_const} __extjsReqType = "EXTJS_WTW_LOAD";`,
130175
+ `${_const} __extjsResType = "EXTJS_WTW_LOADED";`,
130176
+ `${_const} ${CLASSIC_LOADER} = ` + f('url, done', [
130177
+ `${_const} requestId = String(Date.now()) + "-" + Math.random().toString(16).slice(2);`,
130178
+ `${_const} onMessage = ${f('event', [
130179
+ 'try {',
130180
+ Template.indent([
130181
+ 'if (!event || event.source !== window) return;',
130182
+ `${_const} data = event.data || null;`,
130183
+ "if (!data || data[__extjsMark] !== true) return;",
130184
+ "if (data.type !== __extjsResType || data.requestId !== requestId) return;",
130185
+ 'window.removeEventListener("message", onMessage);',
130186
+ 'if (data.ok) done();',
130187
+ 'else done(Object.assign(new Error(data.error || "Bridge failed"), { type: "missing" }));'
130188
+ ]),
130189
+ '} catch (e) {',
130190
+ Template.indent([
130191
+ 'window.removeEventListener("message", onMessage);',
130192
+ 'done(Object.assign(e, { type: "missing" }));'
130193
+ ]),
130194
+ '}'
130195
+ ])};`,
130196
+ 'window.addEventListener("message", onMessage);',
130197
+ 'try {',
130198
+ Template.indent([
130199
+ 'window.postMessage({ [__extjsMark]: true, type: __extjsReqType, requestId: requestId, url: url }, "*");'
130200
+ ]),
130201
+ '} catch (e) {',
130202
+ Template.indent([
130203
+ 'window.removeEventListener("message", onMessage);',
130204
+ 'done(Object.assign(e, { type: "missing" }));'
130205
+ ]),
130206
+ '}',
130207
+ 'setTimeout(function(){ try { window.removeEventListener("message", onMessage); } catch(_){} done(Object.assign(new Error("Bridge timeout"), { type: "missing" })); }, 5000);'
130208
+ ]) + ';',
130209
+ `else if (!isWorker) ${RuntimeGlobals.loadScript} = ${CLASSIC_LOADER};`
130210
+ ]) : Template.asString([
130211
+ `else if (!isWorker && hasExtensionRuntime) ${RuntimeGlobals.loadScript} = ${CLASSIC_LOADER};`,
130212
+ `else if (!isWorker) ${RuntimeGlobals.loadScript} = ${DOM_LOADER};`
130213
+ ]),
130214
+ "else { throw new TypeError('Unable to determinate the chunk loader: content script + Worker'); }",
130215
+ this.supportDynamicImport ? `${_const} ${FALLBACK_LOADER} = ${RuntimeGlobals.loadScript};` : '',
130216
+ this.supportDynamicImport ? `${RuntimeGlobals.loadScript} = ${DYNAMIC_IMPORT_LOADER};` : ''
130217
+ ].filter(Boolean));
130218
+ }
130219
+ constructor(){
130220
+ super("load script", RuntimeModule.STAGE_BASIC), LoadScript_define_property(this, "supportDynamicImport", void 0), LoadScript_define_property(this, "classicLoaderEnabled", void 0), LoadScript_define_property(this, "contentScriptsMeta", void 0);
130221
+ this.supportDynamicImport = Boolean(supportDynamicImport);
130222
+ this.classicLoaderEnabled = Boolean(classicLoaderEnabled);
130223
+ this.contentScriptsMeta = contentScriptsMeta || {};
130224
+ }
130225
+ }
130226
+ return new LoadScriptRuntime();
130227
+ }
130228
+ function PublicPath_PublicPathRuntimeModule(webpack) {
130229
+ const { RuntimeGlobals, RuntimeModule, Template } = webpack;
130230
+ class PublicPathRuntime extends RuntimeModule {
130231
+ generate() {
130232
+ const { compilation } = this;
130233
+ if (!compilation) return Template.asString('/* [webpack-target-webextension] PublicPathRuntimeModule skipped because no compilation is found. */');
130234
+ const { publicPath } = compilation.outputOptions;
130235
+ const path = JSON.stringify(compilation.getPath(publicPath || '', {
130236
+ hash: compilation.hash || 'XXXX'
130237
+ }));
130238
+ return Template.asString([
130239
+ `if (${RuntimeGlobal} && ${RuntimeGlobal}.runtime && typeof ${RuntimeGlobal}.runtime.getURL === "function") {`,
130240
+ Template.indent([
130241
+ `${RuntimeGlobals.publicPath} = ${RuntimeGlobal}.runtime.getURL(${path});`
130242
+ ]),
130243
+ "} else {",
130244
+ Template.indent([
130245
+ `${RuntimeGlobals.publicPath} = "";`
130246
+ ]),
130247
+ "}"
130248
+ ]);
130249
+ }
130250
+ constructor(){
130251
+ super('publicPath', RuntimeModule.STAGE_BASIC);
130252
+ }
130253
+ }
130254
+ return new PublicPathRuntime();
130255
+ }
130256
+ function AutoPublicPathRuntimeModule(webpack) {
130257
+ const { RuntimeModule, RuntimeGlobals, Template, javascript: { JavascriptModulesPlugin }, HotUpdateChunk } = webpack;
130258
+ const getChunkFilenameTemplate = JavascriptModulesPlugin.getChunkFilenameTemplate || function(chunk, outputOptions) {
130259
+ if (chunk.filenameTemplate) return chunk.filenameTemplate;
130260
+ if ('function' == typeof HotUpdateChunk && chunk instanceof HotUpdateChunk) return outputOptions.hotUpdateChunkFilename;
130261
+ if (chunk.canBeInitial()) return outputOptions.filename;
130262
+ return outputOptions.chunkFilename;
130263
+ };
130264
+ class AutoPublicPathRuntime extends RuntimeModule {
130265
+ generate() {
130266
+ const { compilation } = this;
130267
+ if (!compilation || !this.chunk) return Template.asString('/* [webpack-target-webextension] AutoPublicPathRuntimeModule skipped because no compilation/chunk is found. */');
130268
+ const { scriptType, importMetaName } = compilation.outputOptions;
130269
+ const chunkName = compilation.getPath(getChunkFilenameTemplate(this.chunk, compilation.outputOptions), {
130270
+ chunk: this.chunk,
130271
+ contentHashType: "javascript"
130272
+ });
130273
+ const outputPath = compilation.outputOptions.path;
130274
+ if (!outputPath) return Template.asString('/* [webpack-target-webextension] AutoPublicPathRuntimeModule skipped because no output path is found. */');
130275
+ const undoPath = getUndoPath(chunkName, outputPath, false);
130276
+ const optionalChaining = compilation.outputOptions.environment.optionalChaining;
130277
+ const _const = compilation.outputOptions.environment.const ? 'const' : 'var';
130278
+ const _let = compilation.outputOptions.environment.const ? 'let' : 'var';
130279
+ return Template.asString([
130280
+ `${_let} scriptUrl;`,
130281
+ 'module' === scriptType ? `if (typeof ${importMetaName}.url === "string") scriptUrl = ${importMetaName}.url;` : Template.asString([
130282
+ `if (${RuntimeGlobals.global}.importScripts) scriptUrl = ${RuntimeGlobals.global}.location + "";`,
130283
+ `${_const} document = ${RuntimeGlobals.global}.document;`,
130284
+ `if (!scriptUrl && ${optionalChaining ? 'document?.currentScript' : 'document && document.currentScript'}) {`,
130285
+ Template.indent("scriptUrl = document.currentScript.src;"),
130286
+ '}'
130287
+ ]),
130288
+ '// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration',
130289
+ '// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.',
130290
+ "if (!scriptUrl) {",
130291
+ Template.indent([
130292
+ `if (${RuntimeGlobal} && ${RuntimeGlobal}.runtime && typeof ${RuntimeGlobal}.runtime.getURL === "function") {`,
130293
+ Template.indent(`scriptUrl = ${RuntimeGlobal}.runtime.getURL("/");`),
130294
+ "} else {",
130295
+ Template.indent('scriptUrl = "";'),
130296
+ "}"
130297
+ ]),
130298
+ '}',
130299
+ 'scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");',
130300
+ undoPath ? `${RuntimeGlobals.publicPath} = scriptUrl + ${JSON.stringify(undoPath)};` : `${RuntimeGlobals.publicPath} = scriptUrl;`
130301
+ ]);
130302
+ }
130303
+ constructor(){
130304
+ super('publicPath', RuntimeModule.STAGE_BASIC);
130305
+ }
130306
+ }
130307
+ return new AutoPublicPathRuntime();
130308
+ }
130309
+ function getUndoPath(filename, outputPath, enforceRelative) {
130310
+ let depth = -1;
130311
+ let append = '';
130312
+ outputPath = outputPath.replace(/[\\/]$/, '');
130313
+ for (const part of filename.split(/[/\\]+/))if ('..' === part) if (depth > -1) depth--;
130314
+ else {
130315
+ const i = outputPath.lastIndexOf('/');
130316
+ const j = outputPath.lastIndexOf('\\');
130317
+ const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
130318
+ if (pos < 0) return outputPath + '/';
130319
+ append = outputPath.slice(pos + 1) + '/' + append;
130320
+ outputPath = outputPath.slice(0, pos);
130321
+ }
130322
+ else if ('.' !== part) depth++;
130323
+ return depth > 0 ? `${'../'.repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
130324
+ }
130325
+ function ChunkLoaderFallbackRuntimeModule(webpack) {
130326
+ const { RuntimeModule, Template } = webpack;
130327
+ class ChunkLoaderFallbackRuntime extends RuntimeModule {
130328
+ generate() {
130329
+ const { compilation } = this;
130330
+ if (!compilation) return Template.asString('/* [webpack-target-webextension] ChunkLoaderFallbackRuntimeModule skipped because no compilation is found. */');
130331
+ const { f } = TemplateFn(compilation, Template);
130332
+ const optionalChain = compilation.outputOptions.environment.optionalChaining;
130333
+ const _const = compilation.outputOptions.environment.const ? 'const' : 'var';
130334
+ const _let = compilation.outputOptions.environment.const ? 'let' : 'var';
130335
+ return `${RuntimeGlobal}.runtime.onMessage.addListener(` + f('message, sender, sendResponse', [
130336
+ optionalChain ? 'if (message?.type != "WTW_INJECT" || typeof sender?.tab?.id != "number") return;' : 'if (!message || message.type != "WTW_INJECT" || !sender || !sender.tab || sender.tab.id == null) return;',
130337
+ `${_let} file = message.file;`,
130338
+ 'try {',
130339
+ Template.indent([
130340
+ 'file = new URL(file).pathname;'
130341
+ ]),
130342
+ '} catch (_) {}',
130343
+ 'if (!file) return;',
130344
+ `if (${RuntimeGlobal}.scripting) {`,
130345
+ Template.indent([
130346
+ `${RuntimeGlobal}.scripting.executeScript({`,
130347
+ Template.indent([
130348
+ 'target: { tabId: sender.tab.id, frameIds: [sender.frameId] },',
130349
+ 'files: [file],'
130350
+ ]),
130351
+ '}).then(sendResponse);'
130352
+ ]),
130353
+ "} else {",
130354
+ Template.indent([
130355
+ `${_const} details = { frameId: sender.frameId, file, matchAboutBlank: true };`,
130356
+ `if (${RuntimeGlobalIsBrowser}) {`,
130357
+ `${RuntimeGlobal}.tabs.executeScript(sender.tab.id, details).then(sendResponse);`,
130358
+ '} else {',
130359
+ `${RuntimeGlobal}.tabs.executeScript(sender.tab.id, details, sendResponse);`,
130360
+ '}'
130361
+ ]),
130362
+ '}',
130363
+ 'return true;'
130364
+ ]) + ');';
130365
+ }
130366
+ constructor(){
130367
+ super('chunk loader fallback', RuntimeModule.STAGE_TRIGGER);
130368
+ }
130369
+ }
130370
+ return new ChunkLoaderFallbackRuntime();
130371
+ }
130372
+ function ChunkLoader_define_property(obj, key, value) {
130373
+ if (key in obj) Object.defineProperty(obj, key, {
130374
+ value: value,
130375
+ enumerable: true,
130376
+ configurable: true,
130377
+ writable: true
130378
+ });
130379
+ else obj[key] = value;
130380
+ return obj;
130381
+ }
130382
+ class WebExtensionChuckLoaderRuntimePlugin {
130383
+ apply(compiler) {
130384
+ if ('rspack' in compiler) {
130385
+ const { output } = compiler.options;
130386
+ if (void 0 === output.publicPath || 'auto' === output.publicPath) {
130387
+ output.publicPath = '';
130388
+ this.rspackAutoPublicPath = true;
130389
+ }
130390
+ }
130391
+ compiler.hooks.compilation.tap(WebExtensionChuckLoaderRuntimePlugin.name, (compilation)=>{
130392
+ this.tap(compiler, compilation);
130393
+ });
130394
+ }
130395
+ tap(compiler, compilation) {
130396
+ const { RuntimeGlobals } = compiler.webpack;
130397
+ const { options } = this;
130398
+ compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.loadScript).tap(WebExtensionChuckLoaderRuntimePlugin.name, (_chunk, set)=>{
130399
+ set.add(RuntimeGlobal);
130400
+ compilation.addRuntimeModule(_chunk, LoadScriptRuntimeModule(compiler.webpack, false !== compilation.outputOptions.environment.dynamicImport, false !== options.classicLoader, this.contentScriptsMeta));
130401
+ return true;
130402
+ });
130403
+ compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobals.publicPath).tap(WebExtensionChuckLoaderRuntimePlugin.name, (chunk, set)=>{
130404
+ const { outputOptions } = compilation;
130405
+ const { publicPath, scriptType } = outputOptions;
130406
+ if ('auto' === publicPath || '' === publicPath && this.rspackAutoPublicPath) {
130407
+ const module = AutoPublicPathRuntimeModule(compiler.webpack);
130408
+ set.add(RuntimeGlobal);
130409
+ if ('module' !== scriptType) set.add(RuntimeGlobals.global);
130410
+ compilation.addRuntimeModule(chunk, module);
130411
+ } else {
130412
+ set.add(RuntimeGlobal);
130413
+ const module = PublicPath_PublicPathRuntimeModule(compiler.webpack);
130414
+ if ('string' != typeof publicPath || /\[(full)?hash\]/.test(publicPath)) module.fullHash = true;
130415
+ compilation.addRuntimeModule(chunk, module);
130416
+ }
130417
+ return true;
130418
+ });
130419
+ if (false !== options.classicLoader) compilation.hooks.afterOptimizeModules.tap(WebExtensionChuckLoaderRuntimePlugin.name, ()=>{
130420
+ const { pageEntry, serviceWorkerEntry } = options;
130421
+ const entryPoint1 = pageEntry && compilation.entrypoints.get(pageEntry);
130422
+ const entryPoint2 = serviceWorkerEntry && compilation.entrypoints.get(serviceWorkerEntry);
130423
+ if (entryPoint1) compilation.addRuntimeModule(entryPoint1.chunks[0], ChunkLoaderFallbackRuntimeModule(compiler.webpack));
130424
+ if (entryPoint2) compilation.addRuntimeModule(entryPoint2.chunks[0], ChunkLoaderFallbackRuntimeModule(compiler.webpack));
130425
+ });
130426
+ }
130427
+ constructor(options){
130428
+ ChunkLoader_define_property(this, "pluginOptions", void 0);
130429
+ ChunkLoader_define_property(this, "options", void 0);
130430
+ ChunkLoader_define_property(this, "contentScriptsMeta", void 0);
130431
+ ChunkLoader_define_property(this, "rspackAutoPublicPath", false);
130432
+ this.pluginOptions = options || {};
130433
+ this.options = this.pluginOptions.background || this.pluginOptions || {};
130434
+ this.contentScriptsMeta = this.pluginOptions.contentScriptsMeta || {};
130435
+ }
130436
+ }
130437
+ class NoDangerNamePlugin {
130438
+ apply(compiler) {
130439
+ const { Compilation, WebpackError } = compiler.webpack;
130440
+ compiler.hooks.thisCompilation.tap(NoDangerNamePlugin.name, (compilation)=>{
130441
+ compilation.hooks.processAssets.tap({
130442
+ name: NoDangerNamePlugin.name,
130443
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
130444
+ }, (assets)=>{
130445
+ for (const name of Object.keys(assets || {})){
130446
+ if (!name.startsWith('_')) continue;
130447
+ const e = new WebpackError(`[webpack-extension-target] Output file name ${JSON.stringify(name)} starts with "_" which is prohibited.`);
130448
+ e.stack = '';
130449
+ compilation.errors.push(e);
130450
+ }
130451
+ });
130452
+ });
130453
+ }
130454
+ }
130455
+ function EagerlyLoadChunks_define_property(obj, key, value) {
130456
+ if (key in obj) Object.defineProperty(obj, key, {
130457
+ value: value,
130458
+ enumerable: true,
130459
+ configurable: true,
130460
+ writable: true
130461
+ });
130462
+ else obj[key] = value;
130463
+ return obj;
130464
+ }
130465
+ function createEagerlyLoadChunksRuntimeModule(webpack) {
130466
+ const { RuntimeGlobals, RuntimeModule, Template } = webpack;
130467
+ return class extends RuntimeModule {
130468
+ generate() {
130469
+ const { compilation } = this;
130470
+ if (!compilation) return Template.asString('/* [webpack-target-webextension] EagerlyLoadChunksRuntimeModule skipped because no compilation is found. */');
130471
+ const _const = compilation.outputOptions.environment.const ? 'const' : 'var';
130472
+ return Template.asString([
130473
+ `${_const} __extjsChunkIds = ${JSON.stringify(this.chunkIds)};`,
130474
+ `${_const} __extjsLoad = ${RuntimeGlobals.ensureChunkHandlers};`,
130475
+ `for (${_const} __extjsId of __extjsChunkIds) __extjsLoad(__extjsId);`
130476
+ ]);
130477
+ }
130478
+ constructor(chunkIds){
130479
+ super('eagerly load chunks', RuntimeModule.STAGE_NORMAL), EagerlyLoadChunks_define_property(this, "chunkIds", void 0);
130480
+ this.chunkIds = chunkIds;
130481
+ }
130482
+ };
130483
+ }
130484
+ function ServiceWorkerPlugin_define_property(obj, key, value) {
130485
+ if (key in obj) Object.defineProperty(obj, key, {
130486
+ value: value,
130487
+ enumerable: true,
130488
+ configurable: true,
130489
+ writable: true
130490
+ });
130491
+ else obj[key] = value;
130492
+ return obj;
130493
+ }
130494
+ class WebExtensionServiceWorkerEntryPlugin {
130495
+ apply(compiler) {
130496
+ const { javascript, sources } = compiler.webpack;
130497
+ const entry = this.options.serviceWorkerEntry;
130498
+ if (void 0 === entry) return;
130499
+ if (!(compiler.options.output.module || compiler.options.experiments.outputModule)) {
130500
+ const hook = compiler.hooks.entryOption;
130501
+ hook.tap(WebExtensionServiceWorkerEntryPlugin.name, (_context, entries)=>{
130502
+ if ('function' == typeof entries) {
130503
+ if (this.options.noDynamicEntryWarning) return;
130504
+ console.warn(`[webpack-extension-target] Dynamic entry points not supported yet.
130505
+ You must manually set the chuck loading of entry point ${entry} to "import-scripts".
130506
+
130507
+ See https://webpack.js.org/configuration/entry-context/#entry-descriptor
130508
+
130509
+ Set background.noDynamicEntryWarning to true to disable this warning.
130510
+ `);
130511
+ }
130512
+ const selectedEntry = null == entries ? void 0 : entries[entry];
130513
+ if (!selectedEntry) throw new Error(`[webpack-extension-target] There is no entry called ${entry}.`);
130514
+ selectedEntry.chunkLoading = "import-scripts";
130515
+ });
130516
+ }
130517
+ if (false !== this.options.eagerChunkLoading) compiler.hooks.compilation.tap(WebExtensionServiceWorkerEntryPlugin.name, (compilation)=>{
130518
+ var _compilation_hooks_afterOptimizeChunkIds;
130519
+ null == (_compilation_hooks_afterOptimizeChunkIds = compilation.hooks.afterOptimizeChunkIds) || _compilation_hooks_afterOptimizeChunkIds.tap(WebExtensionServiceWorkerEntryPlugin.name, ()=>{
130520
+ const entryPoint = compilation.entrypoints.get(entry);
130521
+ if (!entryPoint) return;
130522
+ const entryChunk = entryPoint.getEntrypointChunk();
130523
+ const reachableChunks = getReachableChunks(entryPoint, new Set(entryPoint.chunks));
130524
+ const reachableChunkIds = new Set([
130525
+ ...reachableChunks
130526
+ ].map((x)=>x.id));
130527
+ for (const id of getInitialChunkIds(entryChunk, compilation.chunkGraph, chunkHasJs))reachableChunkIds.delete(id);
130528
+ if (reachableChunkIds.size) {
130529
+ const EagerlyLoadChunksRuntimeModule = createEagerlyLoadChunksRuntimeModule(compiler.webpack);
130530
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(EagerlyLoadChunksRuntimeModule.name, (chunk, set)=>{
130531
+ if (chunk.id !== entryChunk.id) return;
130532
+ set.add(compiler.webpack.RuntimeGlobals.ensureChunkHandlers);
130533
+ compilation.addRuntimeModule(entryChunk, new EagerlyLoadChunksRuntimeModule([
130534
+ ...reachableChunkIds
130535
+ ]));
130536
+ });
130537
+ }
130538
+ });
130539
+ });
130540
+ if (false !== this.options.tryCatchWrapper && 'module' !== compiler.options.output.chunkFormat && !this.backgroundOutputEmitted) compiler.hooks.compilation.tap(WebExtensionServiceWorkerEntryPlugin.name, (compilation)=>{
130541
+ const hooks = javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);
130542
+ if (hooks.renderContent) hooks.renderContent.tap(WebExtensionServiceWorkerEntryPlugin.name, (source, context)=>{
130543
+ const entryPoint = compilation.entrypoints.get(entry);
130544
+ const entryChunk = null == entryPoint ? void 0 : entryPoint.getEntrypointChunk();
130545
+ if (entryChunk !== context.chunk) return source;
130546
+ return new sources.ConcatSource('/******/ try { // If the initial code of the serviceWorkerEntry throws, the console cannot be opened.\n', source, '\n/******/ } catch (e) {\n/******/ \tPromise.reject(e);\n/******/ }');
130547
+ });
130548
+ });
130549
+ }
130550
+ constructor(options, backgroundOutputEmitted){
130551
+ ServiceWorkerPlugin_define_property(this, "options", void 0);
130552
+ ServiceWorkerPlugin_define_property(this, "backgroundOutputEmitted", void 0);
130553
+ this.options = options;
130554
+ this.backgroundOutputEmitted = backgroundOutputEmitted;
130555
+ }
130556
+ }
130557
+ function getInitialChunkIds(chunk, chunkGraph, filterFn) {
130558
+ const initialChunkIds = new Set(chunk.ids);
130559
+ for (const c of chunk.getAllInitialChunks())if (!(c === chunk || filterFn(c, chunkGraph)) && c.ids) for (const id of c.ids)initialChunkIds.add(id);
130560
+ return initialChunkIds;
130561
+ }
130562
+ function chunkHasJs(chunk, chunkGraph) {
130563
+ if (chunkGraph.getNumberOfEntryModules(chunk) > 0) return true;
130564
+ return !!chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript");
130565
+ }
130566
+ function getReachableChunks(chunkGroup, reachableChunks = new Set(), visitedChunkGroups = new Set()) {
130567
+ for (const x of chunkGroup.getChildren())if (!visitedChunkGroups.has(x)) {
130568
+ visitedChunkGroups.add(x);
130569
+ x.chunks.forEach((c)=>reachableChunks.add(c));
130570
+ getReachableChunks(x, reachableChunks, visitedChunkGroups);
130571
+ }
130572
+ return reachableChunks;
130573
+ }
130574
+ function InitialChunkFile_define_property(obj, key, value) {
130575
+ if (key in obj) Object.defineProperty(obj, key, {
130576
+ value: value,
130577
+ enumerable: true,
130578
+ configurable: true,
130579
+ writable: true
130580
+ });
130581
+ else obj[key] = value;
130582
+ return obj;
130583
+ }
130584
+ class WebExtensionContentScriptEntryPlugin {
130585
+ apply(compiler) {
130586
+ const { WebpackError, sources, Template } = compiler.webpack;
130587
+ const { experimental_output } = this.options;
130588
+ if (!experimental_output) return;
130589
+ {
130590
+ var _this_options_background;
130591
+ const sw = null == (_this_options_background = this.options.background) ? void 0 : _this_options_background.serviceWorkerEntry;
130592
+ if (sw && sw in experimental_output && 'function' == typeof experimental_output[sw]) throw new Error(`[webpack-extension-target] options.experimental_output[${JSON.stringify(sw)}] cannot be a function because it is a service worker entry. Use { file, touch(manifest, file) { manifest.background.service_worker = file; } } instead.`);
130593
+ }
130594
+ compiler.hooks.thisCompilation.tap(WebExtensionContentScriptEntryPlugin.name, (compilation)=>{
130595
+ compilation.hooks.processAssets.tap({
130596
+ name: WebExtensionContentScriptEntryPlugin.name,
130597
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED
130598
+ }, (assets)=>{
130599
+ var _this_options_background;
130600
+ let manifest;
130601
+ const serviceWorkerEntry = null == (_this_options_background = this.options.background) ? void 0 : _this_options_background.serviceWorkerEntry;
130602
+ var _getInitialFiles;
130603
+ if (serviceWorkerEntry && !(serviceWorkerEntry in experimental_output) && ((null == (_getInitialFiles = getInitialFiles(compilation, serviceWorkerEntry)) ? void 0 : _getInitialFiles.length) || 0) > 1) {
130604
+ const e = new WebpackError(`[webpack-extension-target] Entry ${JSON.stringify(serviceWorkerEntry)} is not specified in options.experimental_output.`);
130605
+ e.stack = '';
130606
+ compilation.warnings.push(e);
130607
+ }
130608
+ for(const entry in experimental_output){
130609
+ const isBackgroundEntry = entry === serviceWorkerEntry;
130610
+ const entryOption = experimental_output[entry];
130611
+ const initialFiles = getInitialFiles(compilation, entry);
130612
+ if (!initialFiles || 0 === initialFiles.length) {
130613
+ const name = JSON.stringify(entry);
130614
+ const e = new WebpackError(initialFiles ? `[webpack-extension-target] Entry ${name} does not emit any initial file (specified in options.experimental_output).` : `[webpack-extension-target] Entry ${name} does not exist (specified in options.experimental_output).`);
130615
+ e.stack = '';
130616
+ compilation.errors.push(e);
130617
+ continue;
130618
+ }
130619
+ if (false === entryOption) {
130620
+ if (initialFiles.length > 1) {
130621
+ const name = JSON.stringify(entry);
130622
+ const e = new WebpackError(`[webpack-extension-target] Entry ${name} emits more than one initial file which is prohibited (specified in options.experimental_output).`);
130623
+ e.stack = '';
130624
+ compilation.errors.push(e);
130625
+ }
130626
+ continue;
130627
+ }
130628
+ const emitFile = (entryOptionFile, files)=>{
130629
+ if (entryOptionFile in assets) {
130630
+ const e = new WebpackError(`[webpack-extension-target] Cannot override an existing file ${JSON.stringify(entryOptionFile)} (specified by options.experimental_output[${JSON.stringify(entry)}]).`);
130631
+ e.stack = '';
130632
+ compilation.errors.push(e);
130633
+ return;
130634
+ }
130635
+ let code;
130636
+ if (isBackgroundEntry) {
130637
+ const asyncAndSyncFiles = getInitialAndAsyncFiles(compilation, entry);
130638
+ code = 'module' === compilation.outputOptions.chunkFormat ? asyncAndSyncFiles.map((file)=>`import ${JSON.stringify('./' + file)};`) : [
130639
+ 'try {',
130640
+ Template.indent('importScripts(' + asyncAndSyncFiles.map((file)=>JSON.stringify(file)).join(', ') + ');'),
130641
+ '} catch (e) {',
130642
+ Template.indent('Promise.reject(e);'),
130643
+ '}'
130644
+ ];
130645
+ } else code = [
130646
+ ';(() => {',
130647
+ Template.indent([
130648
+ 'const getURL = typeof browser === "object" ? browser.runtime.getURL : chrome.runtime.getURL;',
130649
+ `${JSON.stringify(files)}.forEach(file => import(getURL(file)));`
130650
+ ]),
130651
+ '})();',
130652
+ 'null;'
130653
+ ];
130654
+ const source = new compiler.webpack.sources.RawSource(Template.asString(code));
130655
+ compilation.emitAsset(entryOptionFile, source);
130656
+ };
130657
+ if ('string' == typeof entryOption) {
130658
+ emitFile(entryOption, initialFiles);
130659
+ continue;
130660
+ }
130661
+ if (!manifest) {
130662
+ const manifestAsset = assets['manifest.json'];
130663
+ const name = JSON.stringify(entry);
130664
+ if (!manifestAsset) {
130665
+ const e = new WebpackError(`[webpack-extension-target] A manifest.json is required (required by options.experimental_output[${name}]). You can emit this file by using CopyPlugin or any other plugins.`);
130666
+ e.stack = '';
130667
+ compilation.errors.push(e);
130668
+ continue;
130669
+ }
130670
+ try {
130671
+ const source = manifestAsset.source();
130672
+ manifest = 'string' == typeof source ? JSON.parse(source) : JSON.parse(source.toString('utf-8'));
130673
+ } catch {
130674
+ const e = new WebpackError(`[webpack-extension-target] Failed to parse manifest.json (required by options.experimental_output[${name}]).`);
130675
+ e.stack = '';
130676
+ e.file = 'manifest.json';
130677
+ compilation.errors.push(e);
130678
+ continue;
130679
+ }
130680
+ }
130681
+ if ('function' == typeof entryOption) entryOption(manifest, initialFiles);
130682
+ else if ('object' == typeof entryOption) {
130683
+ emitFile(entryOption.file, initialFiles);
130684
+ entryOption.touch(manifest, entryOption.file);
130685
+ }
130686
+ }
130687
+ if (manifest) compilation.updateAsset('manifest.json', new sources.RawSource(JSON.stringify(manifest, void 0, 4)));
130688
+ });
130689
+ });
130690
+ }
130691
+ constructor(options){
130692
+ InitialChunkFile_define_property(this, "options", void 0);
130693
+ this.options = options;
130694
+ }
130695
+ }
130696
+ function getInitialFiles(compilation, entry) {
130697
+ const entryPoint = compilation.entrypoints.get(entry);
130698
+ if (!entryPoint) return;
130699
+ const files = new Set();
130700
+ const runtimeChunk = entryPoint.getRuntimeChunk();
130701
+ if (runtimeChunk) runtimeChunk.files.forEach((file)=>{
130702
+ if (!isJSFile(file)) return;
130703
+ const asset = compilation.getAsset(file);
130704
+ if (!asset) return;
130705
+ if (!asset.info.hotModuleReplacement) files.add(file);
130706
+ });
130707
+ entryPoint.getFiles().forEach((file)=>{
130708
+ if (!isJSFile(file)) return;
130709
+ const asset = compilation.getAsset(file);
130710
+ if (!asset) return;
130711
+ if (!asset.info.hotModuleReplacement) files.add(file);
130712
+ });
130713
+ return [
130714
+ ...files
130715
+ ];
130716
+ }
130717
+ function getInitialAndAsyncFiles(compilation, entry) {
130718
+ const entryPoint = compilation.entrypoints.get(entry);
130719
+ if (!entryPoint) return [];
130720
+ const files = new Set();
130721
+ const visitedChunk = new Set();
130722
+ function visit(chunk) {
130723
+ const chunkId = 'rspack' in compilation.compiler ? chunk.id && chunk.hash ? chunk.id + chunk.hash : Array.from(chunk.files).join('') : chunk;
130724
+ if (visitedChunk.has(chunkId)) return;
130725
+ visitedChunk.add(chunkId);
130726
+ chunk.files.forEach((file)=>{
130727
+ if (!isJSFile(file)) return;
130728
+ const asset = compilation.getAsset(file);
130729
+ if (!asset) return;
130730
+ if (!asset.info.hotModuleReplacement) files.add(file);
130731
+ });
130732
+ for (const child of chunk.getAllAsyncChunks())visit(child);
130733
+ }
130734
+ entryPoint.chunks.forEach(visit);
130735
+ const allFiles = [
130736
+ ...files
130737
+ ].filter((file)=>isJSFile(file) && compilation.getAsset(file));
130738
+ return allFiles;
130739
+ }
130740
+ function isJSFile(file) {
130741
+ return file.endsWith('.js') || file.endsWith('.mjs');
130742
+ }
130743
+ class DevServerConfigPlugin {
130744
+ apply(compiler) {
130745
+ if (!compiler.options.devServer) compiler.options.devServer = {};
130746
+ const devServer = compiler.options.devServer;
130747
+ setDefault(devServer, 'devMiddleware', {});
130748
+ setDefault(devServer.devMiddleware, 'writeToDisk', true);
130749
+ if (void 0 === devServer.hot) devServer.hot = 'only';
130750
+ if (!devServer.hot) return;
130751
+ setDefault(devServer, 'host', '127.0.0.1');
130752
+ setDefault(devServer, 'client', {
130753
+ overlay: false,
130754
+ progress: false,
130755
+ webSocketURL: {
130756
+ protocol: 'ws'
130757
+ }
130758
+ });
130759
+ setDefault(devServer.client, 'overlay', false);
130760
+ setDefault(devServer.client, 'progress', false);
130761
+ setDefault(devServer.client, 'webSocketURL', {
130762
+ protocol: 'ws'
130763
+ });
130764
+ setDefault(devServer.client.webSocketURL, 'protocol', 'ws');
130765
+ setDefault(devServer, 'allowedHosts', 'all');
130766
+ setDefault(devServer, 'headers', {
130767
+ 'Access-Control-Allow-Origin': '*'
130768
+ });
130769
+ setDefault(devServer, 'static', {
130770
+ watch: {
130771
+ ignored: /\bnode_modules\b/
130772
+ }
130773
+ });
130774
+ setDefault(devServer.static, 'watch', {
130775
+ ignored: /\bnode_modules\b/
130776
+ });
130777
+ isObject(devServer.static) && 'watch' in devServer.static && isObject(devServer.static.watch) && setDefault(devServer.static.watch, 'ignored', /\bnode_modules\b/);
130778
+ }
130779
+ }
130780
+ function setDefault(obj, key, val) {
130781
+ if (isObject(obj) && void 0 === obj[key]) obj[key] = val;
130782
+ }
130783
+ function isObject(x) {
130784
+ return 'object' == typeof x && null !== x;
130785
+ }
130786
+ function webpack5_define_property(obj, key, value) {
130787
+ if (key in obj) Object.defineProperty(obj, key, {
130788
+ value: value,
130789
+ enumerable: true,
130790
+ configurable: true,
130791
+ writable: true
130792
+ });
130793
+ else obj[key] = value;
130794
+ return obj;
130795
+ }
130796
+ class WebExtensionPlugin {
130797
+ apply(compiler) {
130798
+ const { background, experimental_output } = this.options;
130799
+ if (null == background ? void 0 : background.serviceWorkerEntry) {
130800
+ var _this_options_background, _this_options_experimental_output;
130801
+ const serviceWorkerEntry = null == (_this_options_background = this.options.background) ? void 0 : _this_options_background.serviceWorkerEntry;
130802
+ const output = serviceWorkerEntry ? null == (_this_options_experimental_output = this.options.experimental_output) ? void 0 : _this_options_experimental_output[serviceWorkerEntry] : false;
130803
+ new WebExtensionServiceWorkerEntryPlugin(background, !!output).apply(compiler);
130804
+ }
130805
+ if (experimental_output) new WebExtensionContentScriptEntryPlugin(this.options).apply(compiler);
130806
+ if (false !== this.options.hmrConfig) new DevServerConfigPlugin().apply(compiler);
130807
+ new WebExtensionChuckLoaderRuntimePlugin(this.options).apply(compiler);
130808
+ new NoDangerNamePlugin().apply(compiler);
130809
+ compiler.hooks.environment.tap(WebExtensionPlugin.name, ()=>{
130810
+ const { output } = compiler.options;
130811
+ if (false !== output.environment.dynamicImport) output.environment.dynamicImport = true;
130812
+ if (void 0 !== output.hotUpdateChunkFilename) output.hotUpdateChunkFilename = 'hot/[id].[fullhash].js';
130813
+ if (void 0 !== output.hotUpdateMainFilename) output.hotUpdateMainFilename = 'hot/[runtime].[fullhash].json';
130814
+ });
130815
+ compiler.hooks.compilation.tap(WebExtensionPlugin.name, (compilation)=>{
130816
+ compilation.hooks.runtimeRequirementInTree.for(RuntimeGlobal).tap(WebExtensionPlugin.name, (chunk)=>{
130817
+ compilation.addRuntimeModule(chunk, BrowserRuntimeModule(compiler.webpack, !!this.options.weakRuntimeCheck));
130818
+ return true;
130819
+ });
130820
+ });
130821
+ }
130822
+ constructor(options = {}){
130823
+ webpack5_define_property(this, "options", void 0);
130824
+ const { background } = options;
130825
+ if (background) {
130826
+ const { serviceWorkerEntry, pageEntry } = background;
130827
+ if ('entry' in background || 'manifest' in background) throw new Error('[webpack-extension-target] background.entry and background.manifest has been removed. Use background.pageEntry and/or background.serviceWorkerEntry instead.');
130828
+ if (serviceWorkerEntry && serviceWorkerEntry === pageEntry) throw new Error(`[webpack-extension-target] background.serviceWorkerEntry must not be the same as background.pageEntry. Service Worker entry only supports importScript, but importScript does not exist in background page (mv2) or limited event page (mv3).
130829
+ A possible fix is to create two new files to be the service worker entry and the page entry, then those two files imports the background entry.`);
130830
+ }
130831
+ this.options = options;
130832
+ }
130833
+ }
130834
+ const webpack_target_webextension_fork = WebExtensionPlugin;
130835
+ function manifest_getManifestContent(compilation, manifestPath) {
130836
+ var _compilation_getAsset, _compilation_assets;
130837
+ if ((null == (_compilation_getAsset = compilation.getAsset) ? void 0 : _compilation_getAsset.call(compilation, 'manifest.json')) || (null == (_compilation_assets = compilation.assets) ? void 0 : _compilation_assets['manifest.json'])) {
130838
+ var _compilation_assets_manifestjson_source, _compilation_assets_manifestjson;
130839
+ const source = null == (_compilation_assets_manifestjson = compilation.assets['manifest.json']) ? void 0 : null == (_compilation_assets_manifestjson_source = _compilation_assets_manifestjson.source) ? void 0 : _compilation_assets_manifestjson_source.call(_compilation_assets_manifestjson);
130840
+ const manifest = 'function' == typeof source ? source().toString() : String(source || '');
130841
+ return JSON.parse(manifest || '{}');
130842
+ }
130843
+ try {
130844
+ const text = external_fs_.readFileSync(manifestPath, 'utf8');
130845
+ return JSON.parse(text);
130846
+ } catch {
130847
+ return require(manifestPath);
130848
+ }
130849
+ }
130850
+ function scripts_lib_manifest_filterKeysForThisBrowser(manifest, browser) {
130851
+ const CHROMIUM_BASED_BROWSERS = [
130852
+ 'chrome',
130853
+ 'edge'
130854
+ ];
130855
+ const GECKO_BASED_BROWSERS = [
130856
+ 'firefox'
130857
+ ];
130858
+ const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
130859
+ const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
130860
+ const chromiumPrefixes = new Set([
130861
+ 'chromium',
130862
+ 'chrome',
130863
+ 'edge'
130864
+ ]);
130865
+ const geckoPrefixes = new Set([
130866
+ 'gecko',
129797
130867
  'firefox'
129798
130868
  ]);
129799
130869
  const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
@@ -130122,15 +131192,6 @@ var __webpack_exports__ = {};
130122
131192
  else obj[key] = value;
130123
131193
  return obj;
130124
131194
  }
130125
- const requireForEsm = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
130126
- function tryLoadWebExtensionFork() {
130127
- try {
130128
- const mod = requireForEsm('./webpack-target-webextension-fork');
130129
- return mod && (mod.default || mod);
130130
- } catch {
130131
- return null;
130132
- }
130133
- }
130134
131195
  class SetupReloadStrategy {
130135
131196
  getEntryName(manifest) {
130136
131197
  if (manifest.background) {
@@ -130142,126 +131203,72 @@ var __webpack_exports__ = {};
130142
131203
  if (3 === manifest.manifest_version) return {
130143
131204
  serviceWorkerEntry: 'background/service_worker',
130144
131205
  tryCatchWrapper: true,
130145
- eagerChunkLoading: false
130146
- };
130147
- if (2 === manifest.manifest_version) return {
130148
- pageEntry: "background/script",
130149
- tryCatchWrapper: true,
130150
- eagerChunkLoading: false
130151
- };
130152
- }
130153
- return {
130154
- pageEntry: 'background',
130155
- tryCatchWrapper: true,
130156
- eagerChunkLoading: false
130157
- };
130158
- }
130159
- apply(compiler) {
130160
- const manifest = JSON.parse(external_fs_.readFileSync(this.manifestPath, 'utf-8'));
130161
- const patchedManifest = scripts_lib_manifest_filterKeysForThisBrowser(manifest, this.browser);
130162
- new ApplyManifestDevDefaults({
130163
- manifestPath: this.manifestPath,
130164
- browser: this.browser
130165
- }).apply(compiler);
130166
- new SetupBackgroundEntry({
130167
- manifestPath: this.manifestPath,
130168
- browser: this.browser
130169
- }).apply(compiler);
130170
- const wantFork = 'true' === process.env.EXTENSION_EXPERIMENTAL_HMR;
130171
- if (wantFork) {
130172
- const Fork = tryLoadWebExtensionFork();
130173
- const PluginCtor = Fork || external_webpack_target_webextension_default();
130174
- new PluginCtor({
130175
- background: this.getEntryName(patchedManifest),
130176
- weakRuntimeCheck: true
130177
- }).apply(compiler);
130178
- return;
130179
- }
130180
- new (external_webpack_target_webextension_default())({
130181
- background: this.getEntryName(patchedManifest),
130182
- weakRuntimeCheck: true
130183
- }).apply(compiler);
130184
- }
130185
- constructor(options){
130186
- setup_reload_strategy_define_property(this, "manifestPath", void 0);
130187
- setup_reload_strategy_define_property(this, "browser", void 0);
130188
- this.manifestPath = options.manifestPath;
130189
- this.browser = options.browser || 'chrome';
130190
- }
130191
- }
130192
- function add_content_script_wrapper_define_property(obj, key, value) {
130193
- if (key in obj) Object.defineProperty(obj, key, {
130194
- value: value,
130195
- enumerable: true,
130196
- configurable: true,
130197
- writable: true
130198
- });
130199
- else obj[key] = value;
130200
- return obj;
130201
- }
130202
- class AddContentScriptWrapper {
130203
- apply(compiler) {
130204
- compiler.options.module.rules.push({
130205
- test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
130206
- include: [
130207
- external_path_.dirname(this.manifestPath)
130208
- ],
130209
- exclude: [
130210
- /([\\/])node_modules\1/
130211
- ],
130212
- use: [
130213
- {
130214
- loader: external_path_.resolve(__dirname, "content-script-wrapper"),
130215
- options: {
130216
- manifestPath: this.manifestPath,
130217
- mode: compiler.options.mode
130218
- }
130219
- }
130220
- ]
130221
- });
130222
- if ('production' !== compiler.options.mode) {
130223
- compiler.options.module.rules.push({
130224
- test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
130225
- include: [
130226
- external_path_.dirname(this.manifestPath)
130227
- ],
130228
- exclude: [
130229
- /([\\/])node_modules\1/
130230
- ],
130231
- use: [
130232
- {
130233
- loader: external_path_.resolve(__dirname, 'warn-no-default-export'),
130234
- options: {
130235
- manifestPath: this.manifestPath,
130236
- mode: compiler.options.mode
130237
- }
130238
- }
130239
- ],
130240
- enforce: 'pre'
130241
- });
130242
- compiler.options.module.rules.push({
130243
- test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
130244
- include: [
130245
- external_path_.dirname(this.manifestPath)
130246
- ],
130247
- exclude: [
130248
- /([\\/])node_modules\1/
130249
- ],
130250
- use: [
130251
- {
130252
- loader: external_path_.resolve(__dirname, 'add-hmr-accept-code'),
130253
- options: {
130254
- manifestPath: this.manifestPath,
130255
- mode: compiler.options.mode
130256
- }
130257
- }
130258
- ]
130259
- });
131206
+ eagerChunkLoading: false
131207
+ };
131208
+ if (2 === manifest.manifest_version) return {
131209
+ pageEntry: "background/script",
131210
+ tryCatchWrapper: true,
131211
+ eagerChunkLoading: false
131212
+ };
130260
131213
  }
131214
+ return {
131215
+ pageEntry: 'background',
131216
+ tryCatchWrapper: true,
131217
+ eagerChunkLoading: false
131218
+ };
131219
+ }
131220
+ apply(compiler) {
131221
+ const manifest = JSON.parse(external_fs_.readFileSync(this.manifestPath, 'utf-8'));
131222
+ const patchedManifest = scripts_lib_manifest_filterKeysForThisBrowser(manifest, this.browser);
131223
+ const contentScriptsMeta = {};
131224
+ try {
131225
+ const csList = Array.isArray(patchedManifest.content_scripts) ? patchedManifest.content_scripts : [];
131226
+ const originalCount = csList.length;
131227
+ let bridgeOrdinal = 0;
131228
+ for(let i = 0; i < csList.length; i++){
131229
+ const cs = csList[i];
131230
+ const bundleId = `content_scripts/content-${i}.js`;
131231
+ const isMain = (null == cs ? void 0 : cs.world) === 'MAIN';
131232
+ if (isMain) {
131233
+ const bridgeIndex = originalCount + bridgeOrdinal++;
131234
+ contentScriptsMeta[bundleId] = {
131235
+ index: i,
131236
+ bundleId,
131237
+ world: 'main',
131238
+ bridgeBundleId: `content_scripts/content-${bridgeIndex}.js`
131239
+ };
131240
+ const bridgeBundleId = `content_scripts/content-${bridgeIndex}.js`;
131241
+ contentScriptsMeta[bridgeBundleId] = {
131242
+ index: bridgeIndex,
131243
+ bundleId: bridgeBundleId,
131244
+ world: 'extension',
131245
+ role: 'main_world_bridge',
131246
+ mainBundleId: bundleId
131247
+ };
131248
+ } else contentScriptsMeta[bundleId] = {
131249
+ index: i,
131250
+ bundleId,
131251
+ world: 'extension'
131252
+ };
131253
+ }
131254
+ } catch {}
131255
+ new ApplyManifestDevDefaults({
131256
+ manifestPath: this.manifestPath,
131257
+ browser: this.browser
131258
+ }).apply(compiler);
131259
+ new SetupBackgroundEntry({
131260
+ manifestPath: this.manifestPath,
131261
+ browser: this.browser
131262
+ }).apply(compiler);
131263
+ new webpack_target_webextension_fork({
131264
+ background: this.getEntryName(patchedManifest),
131265
+ weakRuntimeCheck: true,
131266
+ contentScriptsMeta
131267
+ }).apply(compiler);
130261
131268
  }
130262
131269
  constructor(options){
130263
- add_content_script_wrapper_define_property(this, "manifestPath", void 0);
130264
- add_content_script_wrapper_define_property(this, "browser", void 0);
131270
+ setup_reload_strategy_define_property(this, "manifestPath", void 0);
131271
+ setup_reload_strategy_define_property(this, "browser", void 0);
130265
131272
  this.manifestPath = options.manifestPath;
130266
131273
  this.browser = options.browser || 'chrome';
130267
131274
  }
@@ -130286,6 +131293,9 @@ var __webpack_exports__ = {};
130286
131293
  const paths = [];
130287
131294
  for (const [, val] of Object.entries(scriptsMap))if (Array.isArray(val)) paths.push(...val.filter(Boolean));
130288
131295
  else if (val) paths.push(val);
131296
+ const bridgeScripts = AddContentScriptWrapper.getBridgeScripts(this.manifestPath);
131297
+ for (const [, value] of Object.entries(bridgeScripts))if (Array.isArray(value)) paths.push(...value.filter(Boolean));
131298
+ else if (value) paths.push(value);
130289
131299
  return paths;
130290
131300
  }
130291
131301
  async handleWatchRun(compilerWithModifiedFiles, callbackDone) {
@@ -130376,10 +131386,6 @@ var __webpack_exports__ = {};
130376
131386
  apply(compiler) {
130377
131387
  const hasValidManifest = !!this.manifestPath && external_fs_.existsSync(this.manifestPath) && external_fs_.lstatSync(this.manifestPath).isFile();
130378
131388
  if (!hasValidManifest) return;
130379
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
130380
- const featuresCount = Object.keys(this.includeList || {}).length;
130381
- console.log(scriptsIncludeSummary(featuresCount, 'production' !== compiler.options.mode, String(this.browser || 'chrome')));
130382
- }
130383
131389
  new AddScripts({
130384
131390
  manifestPath: this.manifestPath,
130385
131391
  includeList: this.includeList || {}
@@ -130396,7 +131402,6 @@ var __webpack_exports__ = {};
130396
131402
  }).apply(compiler);
130397
131403
  new ThrowIfManifestScriptsChange({
130398
131404
  manifestPath: this.manifestPath,
130399
- includeList: this.includeList || {},
130400
131405
  browser: this.browser
130401
131406
  }).apply(compiler);
130402
131407
  }
@@ -130453,6 +131458,101 @@ var __webpack_exports__ = {};
130453
131458
  function localesValidationDetected(issue) {
130454
131459
  return `Locales validation detected: ${issue}`;
130455
131460
  }
131461
+ function pushCompilationError(compiler, compilation, name, message, file) {
131462
+ var _compiler_rspack;
131463
+ const ErrorConstructor = (null == compiler ? void 0 : null == (_compiler_rspack = compiler.rspack) ? void 0 : _compiler_rspack.WebpackError) || Error;
131464
+ const error = new ErrorConstructor(message);
131465
+ error.name = name;
131466
+ if (file) error.file = file;
131467
+ if (!compilation.errors) compilation.errors = [];
131468
+ compilation.errors.push(error);
131469
+ }
131470
+ function validateLocales(compiler, compilation, manifestPath) {
131471
+ try {
131472
+ const manifestDir = external_path_.dirname(manifestPath);
131473
+ const manifestRaw = external_fs_.readFileSync(manifestPath, 'utf8');
131474
+ const manifest = JSON.parse(manifestRaw);
131475
+ const defaultLocale = null == manifest ? void 0 : manifest.default_locale;
131476
+ const localesRoot = external_path_.join(manifestDir, '_locales');
131477
+ const hasLocalesRoot = external_fs_.existsSync(localesRoot);
131478
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesIncludeSummary(true, hasLocalesRoot, 'string' == typeof defaultLocale ? defaultLocale : void 0));
131479
+ if ('string' == typeof defaultLocale && defaultLocale.trim()) {
131480
+ if (!hasLocalesRoot) {
131481
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected('default_locale set but _locales missing'));
131482
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleSpecifiedButLocalesMissing(), 'manifest.json');
131483
+ return false;
131484
+ }
131485
+ const defaultLocaleDir = external_path_.join(localesRoot, defaultLocale);
131486
+ if (!external_fs_.existsSync(defaultLocaleDir)) {
131487
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing _locales/${defaultLocale}`));
131488
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleFolderMissing(defaultLocale), 'manifest.json');
131489
+ return false;
131490
+ }
131491
+ const messagesJsonPath = external_path_.join(defaultLocaleDir, 'messages.json');
131492
+ if (!external_fs_.existsSync(messagesJsonPath)) {
131493
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing _locales/${defaultLocale}/messages.json`));
131494
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleMessagesMissing(defaultLocale), 'manifest.json');
131495
+ return false;
131496
+ }
131497
+ try {
131498
+ const content = external_fs_.readFileSync(messagesJsonPath, 'utf8');
131499
+ JSON.parse(content);
131500
+ } catch (e) {
131501
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`invalid JSON in _locales/${defaultLocale}/messages.json`));
131502
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', invalidMessagesJson(messagesJsonPath), 'manifest.json');
131503
+ return false;
131504
+ }
131505
+ try {
131506
+ const content = external_fs_.readFileSync(messagesJsonPath, 'utf8');
131507
+ const dict = JSON.parse(content);
131508
+ const collectMsgKeys = (value, acc)=>{
131509
+ if ('string' == typeof value) {
131510
+ const regex = /__MSG_([a-zA-Z0-9_]+)__/g;
131511
+ let matches;
131512
+ while(null !== (matches = regex.exec(value))){
131513
+ const key = matches[1];
131514
+ if (key) acc.add(key);
131515
+ }
131516
+ } else if (Array.isArray(value)) for (const item of value)collectMsgKeys(item, acc);
131517
+ else if (value && 'object' == typeof value) for (const v of Object.values(value))collectMsgKeys(v, acc);
131518
+ };
131519
+ const referenced = new Set();
131520
+ collectMsgKeys(manifest, referenced);
131521
+ for (const key of referenced){
131522
+ const entry = null == dict ? void 0 : dict[key];
131523
+ if (!entry || 'string' != typeof entry.message) {
131524
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing key "${key}" in default locale`));
131525
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
131526
+ return false;
131527
+ }
131528
+ }
131529
+ } catch {}
131530
+ } else if (hasLocalesRoot) {
131531
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected('_locales present but no default_locale'));
131532
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', localesPresentButNoDefaultLocale(), 'manifest.json');
131533
+ return false;
131534
+ }
131535
+ } catch {}
131536
+ try {
131537
+ const manifestDir = external_path_.dirname(manifestPath);
131538
+ const localesRoot = external_path_.join(manifestDir, '_locales');
131539
+ if (external_fs_.existsSync(localesRoot)) {
131540
+ const localeDirs = external_fs_.readdirSync(localesRoot).map((d)=>external_path_.join(localesRoot, d)).filter((p)=>external_fs_.statSync(p).isDirectory());
131541
+ for (const localeDir of localeDirs){
131542
+ const msgPath = external_path_.join(localeDir, 'messages.json');
131543
+ if (external_fs_.existsSync(msgPath)) try {
131544
+ const s = external_fs_.readFileSync(msgPath, 'utf8');
131545
+ JSON.parse(s);
131546
+ } catch {
131547
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`invalid JSON in ${msgPath}`));
131548
+ pushCompilationError(compiler, compilation, 'LocalesValidationError', invalidMessagesJson(msgPath), 'manifest.json');
131549
+ return false;
131550
+ }
131551
+ }
131552
+ }
131553
+ } catch {}
131554
+ return true;
131555
+ }
130456
131556
  function getLocales(manifestPath) {
130457
131557
  const localesFolder = external_path_.join(external_path_.dirname(manifestPath), '_locales');
130458
131558
  const localeFiles = [];
@@ -130462,6 +131562,62 @@ var __webpack_exports__ = {};
130462
131562
  }
130463
131563
  return localeFiles;
130464
131564
  }
131565
+ function processLocaleAssets(compiler, compilation, manifestPath) {
131566
+ if (compilation.errors.length > 0) return;
131567
+ const localesFields = getLocales(manifestPath);
131568
+ const discoveredList = getLocales(manifestPath) || [];
131569
+ let emittedCount = 0;
131570
+ let missingCount = 0;
131571
+ for (const field of Object.entries(localesFields || [])){
131572
+ const [feature, resource] = field;
131573
+ const thisResource = resource;
131574
+ if (thisResource) {
131575
+ if ('.json' !== external_path_.extname(thisResource)) continue;
131576
+ if (!external_fs_.existsSync(thisResource)) {
131577
+ var _compiler_rspack;
131578
+ const ErrorConstructor = (null == compiler ? void 0 : null == (_compiler_rspack = compiler.rspack) ? void 0 : _compiler_rspack.WebpackError) || Error;
131579
+ const warning = new ErrorConstructor(entryNotFoundMessageOnly(feature));
131580
+ warning.file = thisResource;
131581
+ warning.name = 'LocalesPluginMissingFile';
131582
+ if (!compilation.warnings) compilation.warnings = [];
131583
+ compilation.warnings.push(warning);
131584
+ missingCount++;
131585
+ continue;
131586
+ }
131587
+ const source = external_fs_.readFileSync(thisResource);
131588
+ const rawSource = new core_namespaceObject.sources.RawSource(source);
131589
+ const manifestDir = external_path_.dirname(manifestPath);
131590
+ const localesRoot = external_path_.join(manifestDir, '_locales');
131591
+ const relativeToLocales = external_path_.relative(localesRoot, thisResource);
131592
+ const normalizedRel = relativeToLocales.split(external_path_.sep).join('/');
131593
+ const filename = `_locales/${normalizedRel}`;
131594
+ compilation.emitAsset(filename, rawSource);
131595
+ emittedCount++;
131596
+ }
131597
+ }
131598
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesEmitSummary(emittedCount, missingCount, discoveredList.length));
131599
+ }
131600
+ function trackLocaleDependencies(compilation, manifestPath) {
131601
+ var _compilation_errors;
131602
+ if (null == (_compilation_errors = compilation.errors) ? void 0 : _compilation_errors.length) return;
131603
+ const localesFields = getLocales(manifestPath);
131604
+ let added = 0;
131605
+ for (const field of Object.entries(localesFields || [])){
131606
+ const [, resource] = field;
131607
+ if (resource) {
131608
+ const fileDependencies = new Set(compilation.fileDependencies);
131609
+ const fileResources = localesFields || [];
131610
+ for (const thisResource of fileResources)if (external_fs_.existsSync(thisResource) && '.json' === external_path_.extname(thisResource)) {
131611
+ if (!fileDependencies.has(thisResource)) {
131612
+ fileDependencies.add(thisResource);
131613
+ compilation.fileDependencies.add(thisResource);
131614
+ added++;
131615
+ }
131616
+ }
131617
+ }
131618
+ }
131619
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesDepsTracked(added));
131620
+ }
130465
131621
  function feature_locales_define_property(obj, key, value) {
130466
131622
  if (key in obj) Object.defineProperty(obj, key, {
130467
131623
  value: value,
@@ -130472,15 +131628,6 @@ var __webpack_exports__ = {};
130472
131628
  else obj[key] = value;
130473
131629
  return obj;
130474
131630
  }
130475
- function pushCompilationError(compiler, compilation, name, message, file) {
130476
- var _compiler_rspack;
130477
- const ErrorConstructor = (null == compiler ? void 0 : null == (_compiler_rspack = compiler.rspack) ? void 0 : _compiler_rspack.WebpackError) || Error;
130478
- const error = new ErrorConstructor(message);
130479
- error.name = name;
130480
- if (file) error.file = file;
130481
- if (!compilation.errors) compilation.errors = [];
130482
- compilation.errors.push(error);
130483
- }
130484
131631
  class LocalesPlugin {
130485
131632
  apply(compiler) {
130486
131633
  compiler.hooks.thisCompilation.tap('locales:module', (compilation)=>{
@@ -130498,122 +131645,9 @@ var __webpack_exports__ = {};
130498
131645
  compilation.errors.push(error);
130499
131646
  return;
130500
131647
  }
130501
- try {
130502
- const manifestDir = external_path_.dirname(this.manifestPath);
130503
- const manifestRaw = external_fs_.readFileSync(this.manifestPath, 'utf8');
130504
- const manifest = JSON.parse(manifestRaw);
130505
- const defaultLocale = null == manifest ? void 0 : manifest.default_locale;
130506
- const localesRoot = external_path_.join(manifestDir, '_locales');
130507
- const hasLocalesRoot = external_fs_.existsSync(localesRoot);
130508
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesIncludeSummary(true, hasLocalesRoot, 'string' == typeof defaultLocale ? defaultLocale : void 0));
130509
- if ('string' == typeof defaultLocale && defaultLocale.trim()) {
130510
- if (!hasLocalesRoot) {
130511
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected('default_locale set but _locales missing'));
130512
- pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleSpecifiedButLocalesMissing(), 'manifest.json');
130513
- return;
130514
- }
130515
- const defaultLocaleDir = external_path_.join(localesRoot, defaultLocale);
130516
- if (!external_fs_.existsSync(defaultLocaleDir)) {
130517
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing _locales/${defaultLocale}`));
130518
- pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleFolderMissing(defaultLocale), 'manifest.json');
130519
- return;
130520
- }
130521
- const messagesJsonPath = external_path_.join(defaultLocaleDir, 'messages.json');
130522
- if (!external_fs_.existsSync(messagesJsonPath)) {
130523
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing _locales/${defaultLocale}/messages.json`));
130524
- pushCompilationError(compiler, compilation, 'LocalesValidationError', defaultLocaleMessagesMissing(defaultLocale), 'manifest.json');
130525
- return;
130526
- }
130527
- try {
130528
- const content = external_fs_.readFileSync(messagesJsonPath, 'utf8');
130529
- JSON.parse(content);
130530
- } catch (e) {
130531
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`invalid JSON in _locales/${defaultLocale}/messages.json`));
130532
- pushCompilationError(compiler, compilation, 'LocalesValidationError', invalidMessagesJson(messagesJsonPath), 'manifest.json');
130533
- return;
130534
- }
130535
- try {
130536
- const content = external_fs_.readFileSync(messagesJsonPath, 'utf8');
130537
- const dict = JSON.parse(content);
130538
- const collectMsgKeys = (value, acc)=>{
130539
- if ('string' == typeof value) {
130540
- const regex = /__MSG_([a-zA-Z0-9_]+)__/g;
130541
- let matches;
130542
- while(null !== (matches = regex.exec(value))){
130543
- const key = matches[1];
130544
- if (key) acc.add(key);
130545
- }
130546
- } else if (Array.isArray(value)) for (const item of value)collectMsgKeys(item, acc);
130547
- else if (value && 'object' == typeof value) for (const v of Object.values(value))collectMsgKeys(v, acc);
130548
- };
130549
- const referenced = new Set();
130550
- collectMsgKeys(manifest, referenced);
130551
- for (const key of referenced){
130552
- const entry = null == dict ? void 0 : dict[key];
130553
- if (!entry || 'string' != typeof entry.message) {
130554
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`missing key "${key}" in default locale`));
130555
- pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
130556
- return;
130557
- }
130558
- }
130559
- } catch {}
130560
- } else if (hasLocalesRoot) {
130561
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected('_locales present but no default_locale'));
130562
- pushCompilationError(compiler, compilation, 'LocalesValidationError', localesPresentButNoDefaultLocale(), 'manifest.json');
130563
- return;
130564
- }
130565
- } catch {}
131648
+ if (!validateLocales(compiler, compilation, this.manifestPath)) return;
130566
131649
  if (compilation.errors.length > 0) return;
130567
- try {
130568
- const manifestDir = external_path_.dirname(this.manifestPath);
130569
- const localesRoot = external_path_.join(manifestDir, '_locales');
130570
- if (external_fs_.existsSync(localesRoot)) {
130571
- const localeDirs = external_fs_.readdirSync(localesRoot).map((d)=>external_path_.join(localesRoot, d)).filter((p)=>external_fs_.statSync(p).isDirectory());
130572
- for (const localeDir of localeDirs){
130573
- const msgPath = external_path_.join(localeDir, 'messages.json');
130574
- if (external_fs_.existsSync(msgPath)) try {
130575
- const s = external_fs_.readFileSync(msgPath, 'utf8');
130576
- JSON.parse(s);
130577
- } catch {
130578
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesValidationDetected(`invalid JSON in ${msgPath}`));
130579
- pushCompilationError(compiler, compilation, 'LocalesValidationError', invalidMessagesJson(msgPath), 'manifest.json');
130580
- return;
130581
- }
130582
- }
130583
- }
130584
- } catch {}
130585
- const localesFields = getLocales(this.manifestPath);
130586
- const discoveredList = getLocales(this.manifestPath) || [];
130587
- let emittedCount = 0;
130588
- let missingCount = 0;
130589
- for (const field of Object.entries(localesFields || [])){
130590
- const [feature, resource] = field;
130591
- const thisResource = resource;
130592
- if (thisResource) {
130593
- if ('.json' !== external_path_.extname(thisResource)) continue;
130594
- if (!external_fs_.existsSync(thisResource)) {
130595
- var _compiler_rspack1;
130596
- const ErrorConstructor = (null == compiler ? void 0 : null == (_compiler_rspack1 = compiler.rspack) ? void 0 : _compiler_rspack1.WebpackError) || Error;
130597
- const warning = new ErrorConstructor(entryNotFoundMessageOnly(feature));
130598
- warning.file = thisResource;
130599
- warning.name = 'LocalesPluginMissingFile';
130600
- if (!compilation.warnings) compilation.warnings = [];
130601
- compilation.warnings.push(warning);
130602
- missingCount++;
130603
- continue;
130604
- }
130605
- const source = external_fs_.readFileSync(thisResource);
130606
- const rawSource = new core_namespaceObject.sources.RawSource(source);
130607
- const manifestDir = external_path_.dirname(this.manifestPath);
130608
- const localesRoot = external_path_.join(manifestDir, '_locales');
130609
- const relativeToLocales = external_path_.relative(localesRoot, thisResource);
130610
- const normalizedRel = relativeToLocales.split(external_path_.sep).join('/');
130611
- const filename = `_locales/${normalizedRel}`;
130612
- compilation.emitAsset(filename, rawSource);
130613
- emittedCount++;
130614
- }
130615
- }
130616
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesEmitSummary(emittedCount, missingCount, discoveredList.length));
131650
+ processLocaleAssets(compiler, compilation, this.manifestPath);
130617
131651
  });
130618
131652
  });
130619
131653
  compiler.hooks.thisCompilation.tap('locales:module', (compilation)=>{
@@ -130621,25 +131655,7 @@ var __webpack_exports__ = {};
130621
131655
  name: 'locales:module',
130622
131656
  stage: core_namespaceObject.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
130623
131657
  }, ()=>{
130624
- var _compilation_errors;
130625
- if (null == (_compilation_errors = compilation.errors) ? void 0 : _compilation_errors.length) return;
130626
- const localesFields = getLocales(this.manifestPath);
130627
- let added = 0;
130628
- for (const field of Object.entries(localesFields || [])){
130629
- const [, resource] = field;
130630
- if (resource) {
130631
- const fileDependencies = new Set(compilation.fileDependencies);
130632
- const fileResources = localesFields || [];
130633
- for (const thisResource of fileResources)if (external_fs_.existsSync(thisResource) && '.json' === external_path_.extname(thisResource)) {
130634
- if (!fileDependencies.has(thisResource)) {
130635
- fileDependencies.add(thisResource);
130636
- compilation.fileDependencies.add(thisResource);
130637
- added++;
130638
- }
130639
- }
130640
- }
130641
- }
130642
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(localesDepsTracked(added));
131658
+ trackLocaleDependencies(compilation, this.manifestPath);
130643
131659
  });
130644
131660
  });
130645
131661
  }
@@ -130650,6 +131666,7 @@ var __webpack_exports__ = {};
130650
131666
  this.includeList = options.includeList;
130651
131667
  }
130652
131668
  }
131669
+ const external_node_module_namespaceObject = require("node:module");
130653
131670
  function jsonMissingFile(manifestField, filePath, opts) {
130654
131671
  const lines = [];
130655
131672
  lines.push(`Check the ${external_pintor_default().yellow(manifestField)} field in your ${external_pintor_default().yellow('manifest.json')} file.`);
@@ -130815,6 +131832,147 @@ var __webpack_exports__ = {};
130815
131832
  this.browser = options.browser || 'chrome';
130816
131833
  }
130817
131834
  }
131835
+ function isCriticalJsonFeature(feature) {
131836
+ return feature.startsWith('declarative_net_request') || 'storage.managed_schema' === feature;
131837
+ }
131838
+ function validateJsonAsset(compilation, feature, filePath, buf) {
131839
+ let parsed;
131840
+ try {
131841
+ parsed = JSON.parse(buf.toString('utf-8'));
131842
+ } catch (e) {
131843
+ const err = new core_namespaceObject.WebpackError(invalidJsonSyntax(feature, filePath, String((null == e ? void 0 : e.message) || e)));
131844
+ err.file = filePath;
131845
+ err.name = 'JSONInvalidSyntax';
131846
+ compilation.errors.push(err);
131847
+ return false;
131848
+ }
131849
+ if (feature.startsWith('declarative_net_request')) {
131850
+ if (!Array.isArray(parsed)) {
131851
+ const err = new core_namespaceObject.WebpackError(invalidRulesetStructure(feature, filePath));
131852
+ err.file = filePath;
131853
+ err.name = 'DNRInvalidRuleset';
131854
+ compilation.errors.push(err);
131855
+ return false;
131856
+ }
131857
+ } else if ('storage.managed_schema' === feature) {
131858
+ if (null === parsed || Array.isArray(parsed) || 'object' != typeof parsed) {
131859
+ const err = new core_namespaceObject.WebpackError(invalidManagedSchemaStructure(feature, filePath));
131860
+ err.file = filePath;
131861
+ err.name = 'ManagedSchemaInvalid';
131862
+ compilation.errors.push(err);
131863
+ return false;
131864
+ }
131865
+ }
131866
+ return true;
131867
+ }
131868
+ function getProjectPathFromCompilation(compilation, manifestPath) {
131869
+ return compilation.compiler.options.context || compilation.options.context || external_path_.dirname(manifestPath);
131870
+ }
131871
+ function processJsonAssets(compilation, manifestPath, includeList) {
131872
+ if (compilation.errors.length > 0) return;
131873
+ const jsonFields = includeList || {};
131874
+ const manifestDir = external_path_.dirname(manifestPath);
131875
+ const projectPath = getProjectPathFromCompilation(compilation, manifestPath);
131876
+ const publicDir = external_path_.join(projectPath, 'public');
131877
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
131878
+ const featureKeys = Object.keys(jsonFields || {});
131879
+ const criticalCount = featureKeys.filter((key)=>isCriticalJsonFeature(key)).length;
131880
+ console.log(jsonIncludeSummary(featureKeys.length, criticalCount));
131881
+ }
131882
+ for (const field of Object.entries(jsonFields)){
131883
+ const [feature, resource] = field;
131884
+ let emittedCount = 0;
131885
+ let underPublicCount = 0;
131886
+ let missingCount = 0;
131887
+ let validatedOk = 0;
131888
+ let invalid = 0;
131889
+ const resourceArr = Array.isArray(resource) ? resource : [
131890
+ resource
131891
+ ];
131892
+ for (const thisResource of resourceArr)if (thisResource) {
131893
+ const abs = external_path_.isAbsolute(thisResource) ? thisResource : external_path_.join(manifestDir, thisResource);
131894
+ const relToPublic = external_path_.relative(publicDir, abs);
131895
+ const isUnderPublic = relToPublic && !relToPublic.startsWith('..') && !external_path_.isAbsolute(relToPublic);
131896
+ if (!external_fs_.existsSync(abs)) {
131897
+ var _compilation_options_output, _compilation_options;
131898
+ const rawRef = String(thisResource);
131899
+ const isPublicRoot = rawRef.startsWith('/') && !external_path_.isAbsolute(rawRef);
131900
+ const outputRoot = (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || '';
131901
+ const displayPath = isPublicRoot ? external_path_.join(outputRoot, rawRef.slice(1)) : abs;
131902
+ const notFound = new core_namespaceObject.WebpackError(jsonMissingFile(feature, displayPath, {
131903
+ publicRootHint: isPublicRoot
131904
+ }));
131905
+ notFound.name = 'JSONMissingFile';
131906
+ notFound.file = 'manifest.json';
131907
+ if (isCriticalJsonFeature(feature)) compilation.errors.push(notFound);
131908
+ else compilation.warnings.push(notFound);
131909
+ missingCount++;
131910
+ continue;
131911
+ }
131912
+ if (isUnderPublic) {
131913
+ try {
131914
+ compilation.fileDependencies.add(abs);
131915
+ } catch {}
131916
+ if (isCriticalJsonFeature(feature)) {
131917
+ const ok = validateJsonAsset(compilation, feature, abs, external_fs_.readFileSync(abs));
131918
+ if (ok) validatedOk++;
131919
+ else invalid++;
131920
+ if (!ok) continue;
131921
+ }
131922
+ underPublicCount++;
131923
+ continue;
131924
+ }
131925
+ const source = external_fs_.readFileSync(abs);
131926
+ if (isCriticalJsonFeature(feature)) {
131927
+ const ok = validateJsonAsset(compilation, feature, abs, source);
131928
+ if (ok) validatedOk++;
131929
+ else invalid++;
131930
+ if (!ok) continue;
131931
+ }
131932
+ const rawSource = new core_namespaceObject.sources.RawSource(source);
131933
+ const assetName = feature + '.json';
131934
+ if ('function' == typeof compilation.getAsset && compilation.getAsset(assetName)) compilation.updateAsset(assetName, rawSource);
131935
+ else compilation.emitAsset(assetName, rawSource);
131936
+ emittedCount++;
131937
+ }
131938
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
131939
+ const entries = Array.isArray(resource) ? resource.length : resource ? 1 : 0;
131940
+ console.log(jsonEmitSummary(feature, {
131941
+ entries,
131942
+ underPublic: underPublicCount,
131943
+ emitted: emittedCount,
131944
+ missing: missingCount,
131945
+ validatedOk,
131946
+ invalid
131947
+ }));
131948
+ }
131949
+ }
131950
+ }
131951
+ function trackJsonDependencies(compilation, manifestPath, includeList) {
131952
+ var _compilation_errors;
131953
+ if (null == (_compilation_errors = compilation.errors) ? void 0 : _compilation_errors.length) return;
131954
+ const jsonFields = includeList || {};
131955
+ const manifestDir = external_path_.dirname(manifestPath);
131956
+ let added = 0;
131957
+ for (const field of Object.entries(jsonFields)){
131958
+ const [, resource] = field;
131959
+ const resourceArr = Array.isArray(resource) ? resource : [
131960
+ resource
131961
+ ];
131962
+ for (const thisResource of resourceArr)if (thisResource) {
131963
+ const abs = external_path_.isAbsolute(thisResource) ? thisResource : external_path_.join(manifestDir, thisResource);
131964
+ const fileDependencies = new Set(compilation.fileDependencies);
131965
+ if (external_fs_.existsSync(abs)) {
131966
+ if (!fileDependencies.has(abs)) {
131967
+ fileDependencies.add(abs);
131968
+ compilation.fileDependencies.add(abs);
131969
+ added++;
131970
+ }
131971
+ }
131972
+ }
131973
+ }
131974
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(jsonDepsTracked(added));
131975
+ }
130818
131976
  function feature_json_define_property(obj, key, value) {
130819
131977
  if (key in obj) Object.defineProperty(obj, key, {
130820
131978
  value: value,
@@ -130826,39 +131984,6 @@ var __webpack_exports__ = {};
130826
131984
  return obj;
130827
131985
  }
130828
131986
  class JsonPlugin {
130829
- isCriticalJsonFeature(feature) {
130830
- return feature.startsWith('declarative_net_request') || 'storage.managed_schema' === feature;
130831
- }
130832
- validateJsonAsset(compilation, feature, filePath, buf) {
130833
- let parsed;
130834
- try {
130835
- parsed = JSON.parse(buf.toString('utf-8'));
130836
- } catch (e) {
130837
- const err = new core_namespaceObject.WebpackError(invalidJsonSyntax(feature, filePath, String((null == e ? void 0 : e.message) || e)));
130838
- err.file = filePath;
130839
- err.name = 'JSONInvalidSyntax';
130840
- compilation.errors.push(err);
130841
- return false;
130842
- }
130843
- if (feature.startsWith('declarative_net_request')) {
130844
- if (!Array.isArray(parsed)) {
130845
- const err = new core_namespaceObject.WebpackError(invalidRulesetStructure(feature, filePath));
130846
- err.file = filePath;
130847
- err.name = 'DNRInvalidRuleset';
130848
- compilation.errors.push(err);
130849
- return false;
130850
- }
130851
- } else if ('storage.managed_schema' === feature) {
130852
- if (null === parsed || Array.isArray(parsed) || 'object' != typeof parsed) {
130853
- const err = new core_namespaceObject.WebpackError(invalidManagedSchemaStructure(feature, filePath));
130854
- err.file = filePath;
130855
- err.name = 'ManagedSchemaInvalid';
130856
- compilation.errors.push(err);
130857
- return false;
130858
- }
130859
- }
130860
- return true;
130861
- }
130862
131987
  apply(compiler) {
130863
131988
  new ThrowIfManifestJsonChange({
130864
131989
  manifestPath: this.manifestPath,
@@ -130870,85 +131995,7 @@ var __webpack_exports__ = {};
130870
131995
  name: 'json:module',
130871
131996
  stage: core_namespaceObject.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
130872
131997
  }, ()=>{
130873
- var _compiler_options;
130874
- if (compilation.errors.length > 0) return;
130875
- const jsonFields = this.includeList || {};
130876
- const manifestDir = external_path_.dirname(this.manifestPath);
130877
- const projectPath = (null == (_compiler_options = compiler.options) ? void 0 : _compiler_options.context) || external_path_.dirname(this.manifestPath);
130878
- const publicDir = external_path_.join(projectPath, 'public');
130879
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
130880
- const featureKeys = Object.keys(jsonFields || {});
130881
- const criticalCount = featureKeys.filter((k)=>this.isCriticalJsonFeature(k)).length;
130882
- console.log(jsonIncludeSummary(featureKeys.length, criticalCount));
130883
- }
130884
- for (const field of Object.entries(jsonFields)){
130885
- const [feature, resource] = field;
130886
- let emittedCount = 0;
130887
- let underPublicCount = 0;
130888
- let missingCount = 0;
130889
- let validatedOk = 0;
130890
- let invalid = 0;
130891
- const resourceArr = Array.isArray(resource) ? resource : [
130892
- resource
130893
- ];
130894
- for (const thisResource of resourceArr)if (thisResource) {
130895
- const abs = external_path_.isAbsolute(thisResource) ? thisResource : external_path_.join(manifestDir, thisResource);
130896
- const relToPublic = external_path_.relative(publicDir, abs);
130897
- const isUnderPublic = relToPublic && !relToPublic.startsWith('..') && !external_path_.isAbsolute(relToPublic);
130898
- if (!external_fs_.existsSync(abs)) {
130899
- var _compilation_options_output, _compilation_options;
130900
- const rawRef = String(thisResource);
130901
- const isPublicRoot = rawRef.startsWith('/') && !external_path_.isAbsolute(rawRef);
130902
- const outputRoot = (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || '';
130903
- const displayPath = isPublicRoot ? external_path_.join(outputRoot, rawRef.slice(1)) : abs;
130904
- const notFound = new core_namespaceObject.WebpackError(jsonMissingFile(feature, displayPath, {
130905
- publicRootHint: isPublicRoot
130906
- }));
130907
- notFound.name = 'JSONMissingFile';
130908
- notFound.file = 'manifest.json';
130909
- if (this.isCriticalJsonFeature(feature)) compilation.errors.push(notFound);
130910
- else compilation.warnings.push(notFound);
130911
- missingCount++;
130912
- continue;
130913
- }
130914
- if (isUnderPublic) {
130915
- try {
130916
- compilation.fileDependencies.add(abs);
130917
- } catch {}
130918
- if (this.isCriticalJsonFeature(feature)) {
130919
- const ok = this.validateJsonAsset(compilation, feature, abs, external_fs_.readFileSync(abs));
130920
- if (ok) validatedOk++;
130921
- else invalid++;
130922
- if (!ok) continue;
130923
- }
130924
- underPublicCount++;
130925
- continue;
130926
- }
130927
- const source = external_fs_.readFileSync(abs);
130928
- if (this.isCriticalJsonFeature(feature)) {
130929
- const ok = this.validateJsonAsset(compilation, feature, abs, source);
130930
- if (ok) validatedOk++;
130931
- else invalid++;
130932
- if (!ok) continue;
130933
- }
130934
- const rawSource = new core_namespaceObject.sources.RawSource(source);
130935
- const assetName = feature + '.json';
130936
- if ('function' == typeof compilation.getAsset && compilation.getAsset(assetName)) compilation.updateAsset(assetName, rawSource);
130937
- else compilation.emitAsset(assetName, rawSource);
130938
- emittedCount++;
130939
- }
130940
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
130941
- const entries = Array.isArray(resource) ? resource.length : resource ? 1 : 0;
130942
- console.log(jsonEmitSummary(feature, {
130943
- entries,
130944
- underPublic: underPublicCount,
130945
- emitted: emittedCount,
130946
- missing: missingCount,
130947
- validatedOk,
130948
- invalid
130949
- }));
130950
- }
130951
- }
131998
+ processJsonAssets(compilation, this.manifestPath, this.includeList || {});
130952
131999
  });
130953
132000
  });
130954
132001
  compiler.hooks.thisCompilation.tap('json:module', (compilation)=>{
@@ -130956,29 +132003,7 @@ var __webpack_exports__ = {};
130956
132003
  name: 'json:module',
130957
132004
  stage: core_namespaceObject.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
130958
132005
  }, ()=>{
130959
- var _compilation_errors;
130960
- if (null == (_compilation_errors = compilation.errors) ? void 0 : _compilation_errors.length) return;
130961
- const jsonFields = this.includeList || {};
130962
- const manifestDir = external_path_.dirname(this.manifestPath);
130963
- let added = 0;
130964
- for (const field of Object.entries(jsonFields)){
130965
- const [, resource] = field;
130966
- const resourceArr = Array.isArray(resource) ? resource : [
130967
- resource
130968
- ];
130969
- for (const thisResource of resourceArr)if (thisResource) {
130970
- const abs = external_path_.isAbsolute(thisResource) ? thisResource : external_path_.join(manifestDir, thisResource);
130971
- const fileDependencies = new Set(compilation.fileDependencies);
130972
- if (external_fs_.existsSync(abs)) {
130973
- if (!fileDependencies.has(abs)) {
130974
- fileDependencies.add(abs);
130975
- compilation.fileDependencies.add(abs);
130976
- added++;
130977
- }
130978
- }
130979
- }
130980
- }
130981
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(jsonDepsTracked(added));
132006
+ trackJsonDependencies(compilation, this.manifestPath, this.includeList || {});
130982
132007
  });
130983
132008
  });
130984
132009
  }
@@ -131087,17 +132112,47 @@ var __webpack_exports__ = {};
131087
132112
  for (const entry of stringEntries)if (entry) {
131088
132113
  const manifestDir = external_path_.dirname(this.manifestPath);
131089
132114
  let resolved = entry;
131090
- if (!external_fs_.existsSync(resolved)) resolved = entry.startsWith('/') ? external_path_.join(projectPath, entry.slice(1)) : external_path_.isAbsolute(entry) ? entry : external_path_.join(manifestDir, entry);
132115
+ if (!external_fs_.existsSync(resolved)) if (external_path_.isAbsolute(entry) && entry.startsWith(projectPath)) {
132116
+ const basename = external_path_.basename(entry);
132117
+ const publicCandidate = external_path_.join(publicDir, basename);
132118
+ if ('1' === process.env.EXTENSION_DEV_DEBUG_ICONS) console.log('[icons:emit-file] absolute entry', JSON.stringify({
132119
+ entry,
132120
+ projectPath,
132121
+ publicDir,
132122
+ basename,
132123
+ publicCandidate,
132124
+ exists: external_fs_.existsSync(publicCandidate)
132125
+ }));
132126
+ resolved = external_fs_.existsSync(publicCandidate) ? publicCandidate : entry;
132127
+ } else if (entry.startsWith('/')) {
132128
+ const publicCandidate = external_path_.join(projectPath, 'public', entry.slice(1));
132129
+ if ('1' === process.env.EXTENSION_DEV_DEBUG_ICONS) console.log('[icons:emit-file] leading-slash entry', JSON.stringify({
132130
+ entry,
132131
+ projectPath,
132132
+ publicCandidate,
132133
+ exists: external_fs_.existsSync(publicCandidate)
132134
+ }));
132135
+ resolved = external_fs_.existsSync(publicCandidate) ? publicCandidate : external_path_.join(projectPath, entry.slice(1));
132136
+ } else {
132137
+ const publicCandidate = external_path_.join(publicDir, entry);
132138
+ if ('1' === process.env.EXTENSION_DEV_DEBUG_ICONS) console.log('[icons:emit-file] relative entry', JSON.stringify({
132139
+ entry,
132140
+ projectPath,
132141
+ publicDir,
132142
+ publicCandidate,
132143
+ exists: external_fs_.existsSync(publicCandidate),
132144
+ manifestDir
132145
+ }));
132146
+ resolved = external_fs_.existsSync(publicCandidate) ? publicCandidate : external_path_.isAbsolute(entry) ? entry : external_path_.join(manifestDir, entry);
132147
+ }
131091
132148
  const relToPublic = external_path_.relative(publicDir, resolved);
131092
132149
  const isUnderPublic = relToPublic && !relToPublic.startsWith('..') && !external_path_.isAbsolute(relToPublic) || entry.startsWith('/') && external_fs_.existsSync(external_path_.join(projectPath, 'public', entry.slice(1)));
131093
132150
  if (!external_fs_.existsSync(resolved)) {
131094
- var _compilation_options_output, _compilation_options;
131095
- const isPublicRoot = entry.startsWith('/');
131096
- const outputRoot = (null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || '';
132151
+ const isPublicRoot = entry.startsWith('/') && !entry.startsWith(projectPath);
131097
132152
  const parts = String(feature).split('/');
131098
132153
  const group = parts[0];
131099
132154
  const sub = parts[1] || '';
131100
- const displayPath = !external_path_.isAbsolute(entry) && isPublicRoot ? outputRoot ? external_path_.join(outputRoot, entry.slice(1)) : entry : external_path_.isAbsolute(entry) ? entry : external_path_.join(projectPath, entry);
132155
+ const displayPath = !external_path_.isAbsolute(entry) && isPublicRoot ? external_path_.join(projectPath, 'public', entry.slice(1)) : external_path_.isAbsolute(entry) ? entry : external_path_.join(projectPath, entry);
131101
132156
  const isDefaultIconFamily = ('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group) && 'default_icon' === sub;
131102
132157
  const severity = 'icons' === group || isDefaultIconFamily ? 'error' : 'warning';
131103
132158
  emit_file_reportToCompilation(compilation, iconsMissingFile(feature, displayPath, {
@@ -131305,6 +132360,15 @@ var __webpack_exports__ = {};
131305
132360
  this.browser = options.browser || 'chrome';
131306
132361
  }
131307
132362
  }
132363
+ function normalizeIconIncludeKeys(icons) {
132364
+ const out = {};
132365
+ for (const [key, value] of Object.entries(icons || {}))if ('action' === key) out['action/default_icon'] = value;
132366
+ else if ('browser_action' === key) out['browser_action/default_icon'] = value;
132367
+ else if ('page_action' === key) out['page_action/default_icon'] = value;
132368
+ else if ('sidebar_action' === key) out['sidebar_action/default_icon'] = value;
132369
+ else out[key] = value;
132370
+ return out;
132371
+ }
131308
132372
  function feature_icons_define_property(obj, key, value) {
131309
132373
  if (key in obj) Object.defineProperty(obj, key, {
131310
132374
  value: value,
@@ -131317,15 +132381,6 @@ var __webpack_exports__ = {};
131317
132381
  }
131318
132382
  class IconsPlugin {
131319
132383
  apply(compiler) {
131320
- const normalizeIconIncludeKeys = (icons)=>{
131321
- const out = {};
131322
- for (const [key, value] of Object.entries(icons || {}))if ('action' === key) out['action/default_icon'] = value;
131323
- else if ('browser_action' === key) out['browser_action/default_icon'] = value;
131324
- else if ('page_action' === key) out['page_action/default_icon'] = value;
131325
- else if ('sidebar_action' === key) out['sidebar_action/default_icon'] = value;
131326
- else out[key] = value;
131327
- return out;
131328
- };
131329
132384
  const normalizedIncludeList = normalizeIconIncludeKeys(this.includeList);
131330
132385
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
131331
132386
  const beforeKeys = Object.keys(this.includeList || {});
@@ -131633,17 +132688,32 @@ var __webpack_exports__ = {};
131633
132688
  const handleOne = (matches, res)=>{
131634
132689
  compilation.errors = compilation.errors || [];
131635
132690
  compilation.warnings = compilation.warnings || [];
132691
+ const normalizedOutput = normalizeManifestOutputPath(res);
132692
+ const publicCandidate = external_path_.join(projectPath, 'public', normalizedOutput);
132693
+ if (external_fs_.existsSync(publicCandidate)) return void pushResource(matches, normalizedOutput);
131636
132694
  external_path_.isAbsolute(res) || external_path_.join(manifestDir, isPublicRootLike(res) ? toPublicOutput(res) : res);
131637
132695
  if (/[*?\[\]{}]/.test(res)) return void pushResource(matches, res);
131638
132696
  if (isPublicRootLike(res)) {
131639
- var _compilation_options_output, _compilation_options, _compilation_outputOptions;
131640
- const output = toPublicOutput(res);
132697
+ var _compilation_options_output, _compilation_options, _compilation_outputOptions, _compilation_options1;
132698
+ const output = normalizeManifestOutputPath(res);
131641
132699
  const publicAbs = external_path_.join(projectPath, 'public', output);
131642
132700
  const outputRoot = (null == (_compilation_options = compilation.options) ? void 0 : null == (_compilation_options_output = _compilation_options.output) ? void 0 : _compilation_options_output.path) || (null == (_compilation_outputOptions = compilation.outputOptions) ? void 0 : _compilation_outputOptions.path) || external_path_.join(external_path_.dirname(manifestPath), 'dist');
131643
132701
  const builtAbs = external_path_.join(outputRoot || '', output);
131644
132702
  const asset = 'function' == typeof compilation.getAsset ? compilation.getAsset(output) : void 0;
131645
132703
  const assetEmitted = Boolean(asset && asset.name === output) || external_fs_.existsSync(builtAbs);
131646
- if (!external_fs_.existsSync(publicAbs) && !assetEmitted) {
132704
+ const isDevMode = 'production' !== ((null == (_compilation_options1 = compilation.options) ? void 0 : _compilation_options1.mode) || 'development');
132705
+ if ('1' === process.env.EXTENSION_DEV_DEBUG_WAR) console.log('[web-resources:resolve-war] public-like resource', JSON.stringify({
132706
+ res,
132707
+ output,
132708
+ projectPath,
132709
+ publicAbs,
132710
+ outputRoot,
132711
+ builtAbs,
132712
+ publicExists: external_fs_.existsSync(publicAbs),
132713
+ builtExists: external_fs_.existsSync(builtAbs),
132714
+ assetEmitted
132715
+ }));
132716
+ if (!isDevMode && !external_fs_.existsSync(publicAbs) && !assetEmitted) {
131647
132717
  const overrideNotFoundPath = builtAbs;
131648
132718
  const msg = warFieldError(publicAbs, {
131649
132719
  overrideNotFoundPath,
@@ -131659,21 +132729,13 @@ var __webpack_exports__ = {};
131659
132729
  }
131660
132730
  const abs = external_path_.isAbsolute(res) ? res : external_path_.join(manifestDir, res);
131661
132731
  if (!external_fs_.existsSync(abs)) {
131662
- var _compilation_options_output1, _compilation_options1, _compilation_outputOptions1;
131663
- const outputRoot = (null == (_compilation_options1 = compilation.options) ? void 0 : null == (_compilation_options_output1 = _compilation_options1.output) ? void 0 : _compilation_options_output1.path) || (null == (_compilation_outputOptions1 = compilation.outputOptions) ? void 0 : _compilation_outputOptions1.path) || external_path_.join(external_path_.dirname(manifestPath), 'dist');
132732
+ var _compilation_options_output1, _compilation_options2, _compilation_outputOptions1;
132733
+ const outputRoot = (null == (_compilation_options2 = compilation.options) ? void 0 : null == (_compilation_options_output1 = _compilation_options2.output) ? void 0 : _compilation_options_output1.path) || (null == (_compilation_outputOptions1 = compilation.outputOptions) ? void 0 : _compilation_outputOptions1.path) || external_path_.join(external_path_.dirname(manifestPath), 'dist');
131664
132734
  const builtAbs = external_path_.join(outputRoot || '', res);
131665
132735
  const publicAbsMaybe = external_path_.join(projectPath, 'public', res);
131666
132736
  const asset2 = 'function' == typeof compilation.getAsset ? compilation.getAsset(res) : void 0;
131667
132737
  const assetEmitted = Boolean(asset2 && asset2.name === res) || external_fs_.existsSync(builtAbs);
131668
132738
  if (external_fs_.existsSync(publicAbsMaybe) || assetEmitted) {
131669
- const msg = warFieldError(publicAbsMaybe, {
131670
- publicRootHint: true,
131671
- relativeRef: res
131672
- });
131673
- const warn = new core_namespaceObject.WebpackError(msg);
131674
- warn.file = 'manifest.json';
131675
- warn.name = 'WARPublicRootPathMissingSlash';
131676
- compilation.warnings.push(warn);
131677
132739
  const output = toPublicOutput('/' + res);
131678
132740
  pushResource(matches, output);
131679
132741
  return;
@@ -132061,6 +133123,18 @@ var __webpack_exports__ = {};
132061
133123
  });
132062
133124
  }
132063
133125
  }
133126
+ function checkManifestInPublic(compilation, publicDir) {
133127
+ try {
133128
+ const manifestInPublic = external_path_.join(publicDir, 'manifest.json');
133129
+ if (external_fs_.existsSync(manifestInPublic)) {
133130
+ var _compilation_compiler_webpack;
133131
+ const ErrCtor = null == (_compilation_compiler_webpack = compilation.compiler.webpack) ? void 0 : _compilation_compiler_webpack.WebpackError;
133132
+ const err = new ErrCtor(`manifest.json must not be placed under public/: ${manifestInPublic}`);
133133
+ err.file = 'manifest.json';
133134
+ compilation.errors.push(err);
133135
+ }
133136
+ } catch {}
133137
+ }
132064
133138
  function feature_special_folders_define_property(obj, key, value) {
132065
133139
  if (key in obj) Object.defineProperty(obj, key, {
132066
133140
  value: value,
@@ -132082,16 +133156,7 @@ var __webpack_exports__ = {};
132082
133156
  name: `${SpecialFoldersPlugin.name}:guards`,
132083
133157
  stage: compilation.constructor.PROCESS_ASSETS_STAGE_PRE_PROCESS
132084
133158
  }, ()=>{
132085
- try {
132086
- const manifestInPublic = external_path_.join(publicDir, 'manifest.json');
132087
- if (external_fs_.existsSync(manifestInPublic)) {
132088
- var _compilation_compiler_webpack;
132089
- const ErrCtor = null == (_compilation_compiler_webpack = compilation.compiler.webpack) ? void 0 : _compilation_compiler_webpack.WebpackError;
132090
- const err = new ErrCtor(`manifest.json must not be placed under public/: ${manifestInPublic}`);
132091
- err.file = 'manifest.json';
132092
- compilation.errors.push(err);
132093
- }
132094
- } catch {}
133159
+ checkManifestInPublic(compilation, publicDir);
132095
133160
  });
132096
133161
  });
132097
133162
  new core_namespaceObject.rspack.CopyRspackPlugin({
@@ -132120,6 +133185,11 @@ var __webpack_exports__ = {};
132120
133185
  }
132121
133186
  }
132122
133187
  feature_special_folders_define_property(SpecialFoldersPlugin, "name", 'plugin-special-folders');
133188
+ function getSpecialFoldersDataForCompiler(compiler) {
133189
+ return (0, external_browser_extension_manifest_fields_namespaceObject.getSpecialFoldersData)({
133190
+ manifestPath: external_path_default().join(compiler.options.context || '', 'package.json')
133191
+ });
133192
+ }
132123
133193
  function plugin_extension_define_property(obj, key, value) {
132124
133194
  if (key in obj) Object.defineProperty(obj, key, {
132125
133195
  value: value,
@@ -132137,9 +133207,7 @@ var __webpack_exports__ = {};
132137
133207
  manifestPath,
132138
133208
  browser: this.browser
132139
133209
  });
132140
- const specialFoldersData = (0, external_browser_extension_manifest_fields_namespaceObject.getSpecialFoldersData)({
132141
- manifestPath: external_path_default().join(compiler.options.context || '', 'package.json')
132142
- });
133210
+ const specialFoldersData = getSpecialFoldersDataForCompiler(compiler);
132143
133211
  new ManifestPlugin({
132144
133212
  browser: this.browser,
132145
133213
  manifestPath,
@@ -132198,8 +133266,20 @@ var __webpack_exports__ = {};
132198
133266
  }
132199
133267
  }
132200
133268
  plugin_extension_define_property(ExtensionPlugin, "name", 'plugin-extension');
133269
+ function messages_getLoggingPrefix(type) {
133270
+ const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
133271
+ if (isAuthor) {
133272
+ const base = 'error' === type ? 'ERROR Author says' : "\u25BA\u25BA\u25BA Author says";
133273
+ return external_pintor_default().brightMagenta(base);
133274
+ }
133275
+ if ('error' === type) return external_pintor_default().red('ERROR');
133276
+ if ('warn' === type) return external_pintor_default().brightYellow("\u25BA\u25BA\u25BA");
133277
+ if ('info' === type) return external_pintor_default().gray("\u25BA\u25BA\u25BA");
133278
+ return external_pintor_default().green("\u25BA\u25BA\u25BA");
133279
+ }
133280
+ const messages_code = (text)=>external_pintor_default().blue(text);
132201
133281
  function webextensionPolyfillNotFound() {
132202
- return `Warning: webextension-polyfill not found. Browser API polyfill will not be available.\nTo fix this, install webextension-polyfill: npm install webextension-polyfill`;
133282
+ return `${messages_getLoggingPrefix('warn')} webextension-polyfill not found.\nInstall it to enable the browser API polyfill:\n${messages_code('npm install webextension-polyfill')}`;
132203
133283
  }
132204
133284
  function capitalizedBrowserName(browser) {
132205
133285
  const b = String(browser || '');
@@ -132425,8 +133505,21 @@ var __webpack_exports__ = {};
132425
133505
  instanceId: options.instanceId
132426
133506
  };
132427
133507
  }
132428
- function messages_getLoggingPrefix(type) {
132429
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) return external_pintor_default().brightMagenta('error' === type ? 'ERROR' : "\u25BA\u25BA\u25BA");
133508
+ const external_chrome_location2_namespaceObject = require("chrome-location2");
133509
+ var external_chrome_location2_default = /*#__PURE__*/ __webpack_require__.n(external_chrome_location2_namespaceObject);
133510
+ const external_chromium_location_namespaceObject = require("chromium-location");
133511
+ var external_chromium_location_default = /*#__PURE__*/ __webpack_require__.n(external_chromium_location_namespaceObject);
133512
+ const external_edge_location_namespaceObject = require("edge-location");
133513
+ var external_edge_location_default = /*#__PURE__*/ __webpack_require__.n(external_edge_location_namespaceObject);
133514
+ const external_firefox_location2_namespaceObject = require("firefox-location2");
133515
+ var external_firefox_location2_default = /*#__PURE__*/ __webpack_require__.n(external_firefox_location2_namespaceObject);
133516
+ const messages_require = (0, external_module_.createRequire)(__rslib_import_meta_url__);
133517
+ function browsers_lib_messages_getLoggingPrefix(type) {
133518
+ const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
133519
+ if (isAuthor) {
133520
+ const base = 'error' === type ? 'ERROR Author says' : "\u25BA\u25BA\u25BA Author says";
133521
+ return external_pintor_default().brightMagenta(base);
133522
+ }
132430
133523
  if ('error' === type) return external_pintor_default().red('ERROR');
132431
133524
  if ('warn' === type) return external_pintor_default().brightYellow("\u25BA\u25BA\u25BA");
132432
133525
  if ('info' === type) return external_pintor_default().gray("\u25BA\u25BA\u25BA");
@@ -132438,20 +133531,20 @@ var __webpack_exports__ = {};
132438
133531
  return String(maybe || error);
132439
133532
  }
132440
133533
  function messages_capitalizedBrowserName(browser) {
132441
- return external_pintor_default().yellow(`${browser.charAt(0).toUpperCase() + browser.slice(1)}`);
133534
+ return `${browser.charAt(0).toUpperCase() + browser.slice(1)}`;
132442
133535
  }
132443
133536
  function creatingUserProfile(profilePath) {
132444
- return `${messages_getLoggingPrefix('info')} Creating a fresh user profile at ${external_pintor_default().underline(profilePath)}...`;
133537
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Creating a fresh user profile at ${external_pintor_default().underline(profilePath)}...`;
132445
133538
  }
132446
133539
  function browserInstanceExited(browser) {
132447
- return `${messages_getLoggingPrefix('info')} ${messages_capitalizedBrowserName(browser)} instance exited.`;
133540
+ return `${browsers_lib_messages_getLoggingPrefix('info')} ${messages_capitalizedBrowserName(browser)} instance exited.`;
132448
133541
  }
132449
133542
  function stdoutData(browser, mode) {
132450
133543
  const extensionOutput = 'firefox' === browser || 'gecko-based' === browser ? 'Add-on' : 'Extension';
132451
- return `${messages_getLoggingPrefix('info')} ${messages_capitalizedBrowserName(browser)} ${extensionOutput} running in ${external_pintor_default().green(mode || 'unknown')} mode.`;
133544
+ return `${browsers_lib_messages_getLoggingPrefix('info')} ${messages_capitalizedBrowserName(browser)} ${extensionOutput} running in ${external_pintor_default().green(mode || 'unknown')} mode.`;
132452
133545
  }
132453
133546
  function cdpClientAttachedToTarget(sessionId, targetType) {
132454
- return `${messages_getLoggingPrefix('info')} Attached to target: ${targetType} (session ${sessionId})`;
133547
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Attached to target: ${targetType} (session ${sessionId})`;
132455
133548
  }
132456
133549
  function cdpPendingRejectFailed(message) {
132457
133550
  return `[CDP] Pending request reject failed: ${message}`;
@@ -132473,98 +133566,98 @@ var __webpack_exports__ = {};
132473
133566
  }
132474
133567
  function firefoxRdpReloadCapabilitySummary(mode) {
132475
133568
  const txt = 'native' === mode ? 'native reloadAddon' : 'reinstall fallback';
132476
- return `${messages_getLoggingPrefix('info')} Firefox RDP reload: ${txt}`;
133569
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Firefox RDP reload: ${txt}`;
132477
133570
  }
132478
133571
  function rdpAddTabFailed(message) {
132479
133572
  return `[RDP] addTab failed: ${message}`;
132480
133573
  }
132481
133574
  function skippingBrowserLaunchDueToCompileErrors() {
132482
- return `${messages_getLoggingPrefix('warn')} Skipping browser launch due to compile errors`;
133575
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Skipping browser launch due to compile errors`;
132483
133576
  }
132484
133577
  function browserNotInstalledError(browser, browserBinaryLocation) {
132485
133578
  const isUnreachable = 'null' == browserBinaryLocation ? `Browser ${messages_capitalizedBrowserName(browser)} is not installed\n` : `Can't find the path for browser ${messages_capitalizedBrowserName(browser)}\n`;
132486
- return `${messages_getLoggingPrefix('error')} ${isUnreachable}Either install the missing browser or choose a different one via ${external_pintor_default().blue('--browser')} ${external_pintor_default().gray('<chrome|edge|firefox>')}.\n\n${external_pintor_default().red('NOT FOUND')} ${external_pintor_default().underline(browserBinaryLocation || messages_capitalizedBrowserName(browser) + 'BROWSER')}`;
133579
+ return `${browsers_lib_messages_getLoggingPrefix('error')} ${isUnreachable}Either install the missing browser or choose a different one via ${external_pintor_default().blue('--browser')} ${external_pintor_default().gray('<chrome|edge|firefox>')}.\n\n${external_pintor_default().red('NOT FOUND')} ${external_pintor_default().underline(browserBinaryLocation || messages_capitalizedBrowserName(browser) + 'BROWSER')}`;
132487
133580
  }
132488
133581
  function browserLaunchError(browser, error) {
132489
- return `${messages_getLoggingPrefix('error')} Error launching ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
133582
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Error launching ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
132490
133583
  }
132491
133584
  function enhancedProcessManagementCleanup(browser) {
132492
- return `${messages_getLoggingPrefix('info')} Process Management cleanup for ${messages_capitalizedBrowserName(browser)}`;
133585
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Process Management cleanup for ${messages_capitalizedBrowserName(browser)}`;
132493
133586
  }
132494
133587
  function enhancedProcessManagementTerminating(browser) {
132495
- return `${messages_getLoggingPrefix('info')} Terminating ${messages_capitalizedBrowserName(browser)} process gracefully`;
133588
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Terminating ${messages_capitalizedBrowserName(browser)} process gracefully`;
132496
133589
  }
132497
133590
  function enhancedProcessManagementForceKill(browser) {
132498
- return `${messages_getLoggingPrefix('error')} Force killing ${messages_capitalizedBrowserName(browser)} process after timeout`;
133591
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Force killing ${messages_capitalizedBrowserName(browser)} process after timeout`;
132499
133592
  }
132500
133593
  function enhancedProcessManagementCleanupError(browser, error) {
132501
- return `${messages_getLoggingPrefix('error')} Error during ${messages_capitalizedBrowserName(browser)} cleanup:\n${external_pintor_default().red(errorDetail(error))}`;
133594
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Error during ${messages_capitalizedBrowserName(browser)} cleanup:\n${external_pintor_default().red(errorDetail(error))}`;
132502
133595
  }
132503
133596
  function enhancedProcessManagementUncaughtException(browser, error) {
132504
- return `${messages_getLoggingPrefix('error')} Uncaught exception in ${messages_capitalizedBrowserName(browser)} process:\n${external_pintor_default().red(errorDetail(error))}`;
133597
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Uncaught exception in ${messages_capitalizedBrowserName(browser)} process:\n${external_pintor_default().red(errorDetail(error))}`;
132505
133598
  }
132506
133599
  function enhancedProcessManagementUnhandledRejection(browser, reason) {
132507
- return `${messages_getLoggingPrefix('error')} Unhandled rejection in ${messages_capitalizedBrowserName(browser)} process:\n${external_pintor_default().red(errorDetail(reason))}`;
133600
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Unhandled rejection in ${messages_capitalizedBrowserName(browser)} process:\n${external_pintor_default().red(errorDetail(reason))}`;
132508
133601
  }
132509
133602
  function generalBrowserError(browser, error) {
132510
- return `${messages_getLoggingPrefix('error')} General error in ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
133603
+ return `${browsers_lib_messages_getLoggingPrefix('error')} General error in ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
132511
133604
  }
132512
133605
  function errorConnectingToBrowser(browser) {
132513
- return `${messages_getLoggingPrefix('error')} Unable to connect to ${messages_capitalizedBrowserName(browser)}. Too many retries.`;
133606
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Unable to connect to ${messages_capitalizedBrowserName(browser)}. Too many retries.`;
132514
133607
  }
132515
133608
  function addonInstallError(browser, message) {
132516
- return `${messages_getLoggingPrefix('error')} Can't install add-on into ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(message)}`;
133609
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Can't install add-on into ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(message)}`;
132517
133610
  }
132518
133611
  function messagingClientClosedError(browser) {
132519
- return `${messages_getLoggingPrefix('error')} Messaging client closed unexpectedly for ${messages_capitalizedBrowserName(browser)}`;
133612
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Messaging client closed unexpectedly for ${messages_capitalizedBrowserName(browser)}`;
132520
133613
  }
132521
133614
  function connectionClosedError(browser) {
132522
- return `${messages_getLoggingPrefix('error')} Connection closed unexpectedly for ${messages_capitalizedBrowserName(browser)}`;
133615
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Connection closed unexpectedly for ${messages_capitalizedBrowserName(browser)}`;
132523
133616
  }
132524
133617
  function targetActorHasActiveRequestError(browser, targetActor) {
132525
- return `${messages_getLoggingPrefix('error')} Target actor ${external_pintor_default().gray(targetActor)} has active request for ${messages_capitalizedBrowserName(browser)}`;
133618
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Target actor ${external_pintor_default().gray(targetActor)} has active request for ${messages_capitalizedBrowserName(browser)}`;
132526
133619
  }
132527
133620
  function parsingPacketError(browser, error) {
132528
- return `${messages_getLoggingPrefix('error')} Failed to parse packet from ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
133621
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to parse packet from ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(errorDetail(error))}`;
132529
133622
  }
132530
133623
  function messageWithoutSenderError(browser, message) {
132531
- return `${messages_getLoggingPrefix('error')} Message without sender from ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(JSON.stringify(message))}`;
133624
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Message without sender from ${messages_capitalizedBrowserName(browser)}:\n${external_pintor_default().red(JSON.stringify(message))}`;
132532
133625
  }
132533
133626
  function profileFallbackWarning(browser, reason) {
132534
- return `${external_pintor_default().brightYellow("\u25BA\u25BA\u25BA")} ${external_pintor_default().brightYellow('Dev')} ${messages_capitalizedBrowserName(browser)} falling back to per-instance profile` + (reason ? `: ${external_pintor_default().gray(reason)}` : '');
133627
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} ${messages_capitalizedBrowserName(browser)} falling back to per-instance profile` + (reason ? `: ${external_pintor_default().gray(reason)}` : '');
132535
133628
  }
132536
133629
  function chromeProcessExited(code) {
132537
- return `${messages_getLoggingPrefix('info')} Chrome process exited with code: ${external_pintor_default().gray(code.toString())}`;
133630
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome process exited with code: ${external_pintor_default().gray(code.toString())}`;
132538
133631
  }
132539
133632
  function chromeProcessError(error) {
132540
- return `${messages_getLoggingPrefix('error')} Chrome process error:\n${external_pintor_default().red(errorDetail(error))}`;
133633
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome process error:\n${external_pintor_default().red(errorDetail(error))}`;
132541
133634
  }
132542
133635
  function chromeFailedToSpawn(error) {
132543
- return `${messages_getLoggingPrefix('error')} Failed to spawn Chrome:\n${external_pintor_default().red(errorDetail(error))}`;
133636
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to spawn Chrome:\n${external_pintor_default().red(errorDetail(error))}`;
132544
133637
  }
132545
133638
  function chromeInitializingEnhancedReload() {
132546
- return `${messages_getLoggingPrefix('info')} Initializing enhanced reload service with direct spawn for Chrome`;
133639
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Initializing enhanced reload service with direct spawn for Chrome`;
132547
133640
  }
132548
133641
  function locatingBrowser(browser) {
132549
- return `${messages_getLoggingPrefix('info')} Locating ${messages_capitalizedBrowserName(browser)} browser binary...`;
133642
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Locating ${messages_capitalizedBrowserName(browser)} browser binary...`;
132550
133643
  }
132551
133644
  function devChromeProfilePath(path) {
132552
- return `${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA")} ${external_pintor_default().brightMagenta('Dev')} Chrome profile: ${external_pintor_default().underline(path)}`;
133645
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome profile: ${external_pintor_default().underline(path)}`;
132553
133646
  }
132554
133647
  function usingChromiumRunner(browser) {
132555
- return `${messages_getLoggingPrefix('info')} Using Chromium runner for ${messages_capitalizedBrowserName(browser)}`;
133648
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Using Chromium runner for ${messages_capitalizedBrowserName(browser)}`;
132556
133649
  }
132557
133650
  function usingFirefoxRunner(browser) {
132558
- return `${messages_getLoggingPrefix('info')} Using Firefox runner for ${messages_capitalizedBrowserName(browser)}`;
133651
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Using Firefox runner for ${messages_capitalizedBrowserName(browser)}`;
132559
133652
  }
132560
133653
  function chromiumDryRunNotLaunching() {
132561
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Dry run: not launching browser`;
133654
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Dry run: not launching browser`;
132562
133655
  }
132563
133656
  function chromiumDryRunBinary(path) {
132564
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Binary: ${external_pintor_default().underline(path)}`;
133657
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Binary: ${external_pintor_default().underline(path)}`;
132565
133658
  }
132566
133659
  function chromiumDryRunFlags(flags) {
132567
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Flags: ${external_pintor_default().gray(flags)}`;
133660
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Flags: ${external_pintor_default().gray(flags)}`;
132568
133661
  }
132569
133662
  function prettyPuppeteerInstallGuidance(browser, rawGuidance, cacheDir) {
132570
133663
  const dim = external_pintor_default().gray;
@@ -132575,23 +133668,19 @@ var __webpack_exports__ = {};
132575
133668
  if (looksMinimal) {
132576
133669
  const b = String(browser || '').toLowerCase();
132577
133670
  if ('chromium' === b || 'chromium-based' === b) try {
132578
- const loc = __webpack_require__("chromium-location");
132579
- const txt = 'function' == typeof (null == loc ? void 0 : loc.getInstallGuidance) ? loc.getInstallGuidance() : '';
133671
+ const txt = (0, external_chromium_location_namespaceObject.getInstallGuidance)();
132580
133672
  if (txt && 'string' == typeof txt) cleaned = String(txt).trim();
132581
133673
  } catch {}
132582
133674
  else if ('chrome' === b) try {
132583
- const loc = __webpack_require__("chrome-location2");
132584
- const txt = 'function' == typeof (null == loc ? void 0 : loc.getInstallGuidance) ? loc.getInstallGuidance() : '';
133675
+ const txt = (0, external_chrome_location2_namespaceObject.getInstallGuidance)();
132585
133676
  if (txt && 'string' == typeof txt) cleaned = String(txt).trim();
132586
133677
  } catch {}
132587
133678
  else if ('firefox' === b || 'gecko-based' === b) try {
132588
- const loc = __webpack_require__("firefox-location2");
132589
- const txt = 'function' == typeof (null == loc ? void 0 : loc.getInstallGuidance) ? loc.getInstallGuidance() : '';
133679
+ const txt = (0, external_firefox_location2_namespaceObject.getInstallGuidance)();
132590
133680
  if (txt && 'string' == typeof txt) cleaned = String(txt).trim();
132591
133681
  } catch {}
132592
133682
  else if ('edge' === b) try {
132593
- const loc = __webpack_require__("edge-location");
132594
- const txt = 'function' == typeof (null == loc ? void 0 : loc.getInstallGuidance) ? loc.getInstallGuidance() : '';
133683
+ const txt = (0, external_edge_location_namespaceObject.getInstallGuidance)();
132595
133684
  if (txt && 'string' == typeof txt) cleaned = String(txt).trim();
132596
133685
  } catch {}
132597
133686
  }
@@ -132627,163 +133716,163 @@ var __webpack_exports__ = {};
132627
133716
  return body.join('\n') + '\n';
132628
133717
  }
132629
133718
  function firefoxLaunchCalled() {
132630
- return `${messages_getLoggingPrefix('info')} launchFirefox called!`;
133719
+ return `${browsers_lib_messages_getLoggingPrefix('info')} launchFirefox called!`;
132631
133720
  }
132632
133721
  function firefoxBinaryArgsExtracted(args) {
132633
- return `${messages_getLoggingPrefix('info')} Firefox binary args extracted: ${external_pintor_default().gray(args)}`;
133722
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Firefox binary args extracted: ${external_pintor_default().gray(args)}`;
132634
133723
  }
132635
133724
  function firefoxNoBinaryArgsFound() {
132636
- return `${messages_getLoggingPrefix('info')} No Firefox binary args found`;
133725
+ return `${browsers_lib_messages_getLoggingPrefix('info')} No Firefox binary args found`;
132637
133726
  }
132638
133727
  function firefoxFailedToStart(error) {
132639
- return `${messages_getLoggingPrefix('error')} Firefox failed to start:\n${external_pintor_default().red(errorDetail(error))}`;
133728
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Firefox failed to start:\n${external_pintor_default().red(errorDetail(error))}`;
132640
133729
  }
132641
133730
  function firefoxDryRunNotLaunching() {
132642
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Dry run: not launching browser`;
133731
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Dry run: not launching browser`;
132643
133732
  }
132644
133733
  function firefoxDryRunBinary(path) {
132645
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Binary (detected): ${external_pintor_default().underline(path)}`;
133734
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Binary (detected): ${external_pintor_default().underline(path)}`;
132646
133735
  }
132647
133736
  function firefoxDryRunConfig(cfg) {
132648
- return `${messages_getLoggingPrefix('info')} [plugin-browsers] Config: ${external_pintor_default().gray(cfg)}`;
133737
+ return `${browsers_lib_messages_getLoggingPrefix('info')} [plugin-browsers] Config: ${external_pintor_default().gray(cfg)}`;
132649
133738
  }
132650
133739
  function sourceInspectorInitialized() {
132651
- return `${messages_getLoggingPrefix('info')} Chrome source inspector initialized successfully`;
133740
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome source inspector initialized successfully`;
132652
133741
  }
132653
133742
  function sourceInspectorInitializationFailed(error) {
132654
- return `${messages_getLoggingPrefix('error')} Failed to initialize Chrome source inspector: ${external_pintor_default().red(error)}`;
133743
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to initialize Chrome source inspector: ${external_pintor_default().red(error)}`;
132655
133744
  }
132656
133745
  function sourceInspectorChromeDebuggingRequired(port) {
132657
133746
  try {
132658
133747
  const p = Number(port);
132659
133748
  const shown = Number.isFinite(p) && p > 0 ? p : 9222;
132660
- return `${messages_getLoggingPrefix('error')} Chrome is not running with remote debugging enabled on port ${external_pintor_default().gray(shown.toString())}. Ensure Chrome is launched with ${external_pintor_default().blue('--remote-debugging-port')}=${external_pintor_default().gray(shown.toString())}`;
133749
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome is not running with remote debugging enabled on port ${external_pintor_default().gray(shown.toString())}. Ensure Chrome is launched with ${external_pintor_default().blue('--remote-debugging-port')}=${external_pintor_default().gray(shown.toString())}`;
132661
133750
  } catch {
132662
- return `${messages_getLoggingPrefix('error')} Chrome is not running with remote debugging enabled on port ${external_pintor_default().gray('9222')}. Ensure Chrome is launched with ${external_pintor_default().blue('--remote-debugging-port')}=${external_pintor_default().gray('9222')}`;
133751
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome is not running with remote debugging enabled on port ${external_pintor_default().gray('9222')}. Ensure Chrome is launched with ${external_pintor_default().blue('--remote-debugging-port')}=${external_pintor_default().gray('9222')}`;
132663
133752
  }
132664
133753
  }
132665
133754
  function sourceInspectorFirefoxDebuggingRequired(port) {
132666
- return `${messages_getLoggingPrefix('error')} Firefox is not running with remote debugging enabled on port ${external_pintor_default().gray(port.toString())}. Ensure Firefox is launched with ${external_pintor_default().blue('-start-debugger-server')} ${external_pintor_default().gray(port.toString())}`;
133755
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Firefox is not running with remote debugging enabled on port ${external_pintor_default().gray(port.toString())}. Ensure Firefox is launched with ${external_pintor_default().blue('-start-debugger-server')} ${external_pintor_default().gray(port.toString())}`;
132667
133756
  }
132668
133757
  function sourceInspectorWaitingForFirefox() {
132669
- return `${messages_getLoggingPrefix('info')} Waiting for Firefox to be ready with remote debugging...`;
133758
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Waiting for Firefox to be ready with remote debugging...`;
132670
133759
  }
132671
133760
  function firefoxRemoteDebuggingReady() {
132672
- return `${messages_getLoggingPrefix('success')} Firefox is ready with remote debugging!`;
133761
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Firefox is ready with remote debugging!`;
132673
133762
  }
132674
133763
  function sourceInspectorFirefoxNotReadyYet(retries, maxRetries) {
132675
- return `${messages_getLoggingPrefix('warn')} Firefox not ready yet, retrying... (${external_pintor_default().gray(retries.toString())}/${external_pintor_default().gray(maxRetries.toString())})`;
133764
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Firefox not ready yet, retrying... (${external_pintor_default().gray(retries.toString())}/${external_pintor_default().gray(maxRetries.toString())})`;
132676
133765
  }
132677
133766
  function sourceInspectorWaitingForChrome() {
132678
- return `${messages_getLoggingPrefix('info')} Waiting for Chrome to be ready with remote debugging...`;
133767
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Waiting for Chrome to be ready with remote debugging...`;
132679
133768
  }
132680
133769
  function chromeRemoteDebuggingReady() {
132681
- return `${messages_getLoggingPrefix('success')} Chrome is ready with remote debugging!`;
133770
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome is ready with remote debugging!`;
132682
133771
  }
132683
133772
  function sourceInspectorChromeNotReadyYet(retries, maxRetries) {
132684
- return `${messages_getLoggingPrefix('warn')} Chrome not ready yet, retrying... (${external_pintor_default().gray(retries.toString())}/${external_pintor_default().gray(maxRetries.toString())})`;
133773
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome not ready yet, retrying... (${external_pintor_default().gray(retries.toString())}/${external_pintor_default().gray(maxRetries.toString())})`;
132685
133774
  }
132686
133775
  function sourceInspectorOpeningUrl(url) {
132687
- return `${messages_getLoggingPrefix('info')} Chrome is opening URL: ${external_pintor_default().underline(url)}`;
133776
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is opening URL: ${external_pintor_default().underline(url)}`;
132688
133777
  }
132689
133778
  function sourceInspectorWaitingForPageLoad() {
132690
- return `${messages_getLoggingPrefix('info')} Chrome is waiting for the page to load...`;
133779
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is waiting for the page to load...`;
132691
133780
  }
132692
133781
  function sourceInspectorCreatingTarget() {
132693
- return `${messages_getLoggingPrefix('info')} Chrome is creating a new target...`;
133782
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is creating a new target...`;
132694
133783
  }
132695
133784
  function sourceInspectorFindingExistingTarget() {
132696
- return `${messages_getLoggingPrefix('info')} Chrome is finding an existing target...`;
133785
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is finding an existing target...`;
132697
133786
  }
132698
133787
  function sourceInspectorUsingExistingTarget(targetId) {
132699
- return `${messages_getLoggingPrefix('info')} Chrome is using existing target with ID: ${external_pintor_default().gray(targetId)}`;
133788
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is using existing target with ID: ${external_pintor_default().gray(targetId)}`;
132700
133789
  }
132701
133790
  function sourceInspectorTargetCreated(targetId) {
132702
- return `${messages_getLoggingPrefix('success')} Chrome created a target with ID: ${external_pintor_default().gray(targetId)}`;
133791
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome created a target with ID: ${external_pintor_default().gray(targetId)}`;
132703
133792
  }
132704
133793
  function sourceInspectorAttachingToTarget() {
132705
- return `${messages_getLoggingPrefix('info')} Chrome is attaching to the target...`;
133794
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is attaching to the target...`;
132706
133795
  }
132707
133796
  function sourceInspectorAttachedToTarget(sessionId) {
132708
- return `${messages_getLoggingPrefix('success')} Chrome is attached to the target with session ID: ${external_pintor_default().gray(sessionId)}`;
133797
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome is attached to the target with session ID: ${external_pintor_default().gray(sessionId)}`;
132709
133798
  }
132710
133799
  function sourceInspectorHTMLExtractionComplete() {
132711
- return `${messages_getLoggingPrefix('success')} Chrome HTML extraction is complete`;
133800
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome HTML extraction is complete`;
132712
133801
  }
132713
133802
  function sourceInspectorInspectionFailed(error) {
132714
- return `${messages_getLoggingPrefix('error')} Failed to inspect Chrome source: ${external_pintor_default().red(error)}`;
133803
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to inspect Chrome source: ${external_pintor_default().red(error)}`;
132715
133804
  }
132716
133805
  function sourceInspectorStartingWatchMode() {
132717
- return `${messages_getLoggingPrefix('info')} Chrome is starting watch mode for sources...`;
133806
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is starting watch mode for sources...`;
132718
133807
  }
132719
133808
  function sourceInspectorWatchModeActive() {
132720
- return `${messages_getLoggingPrefix('info')} Chrome HTML will be updated automatically when files change`;
133809
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome HTML will be updated automatically when files change`;
132721
133810
  }
132722
133811
  function sourceInspectorWatchModeStopped() {
132723
- return `${messages_getLoggingPrefix('warn')} Chrome source inspector watch mode stopped`;
133812
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome source inspector watch mode stopped`;
132724
133813
  }
132725
133814
  function sourceInspectorCDPConnectionMaintained() {
132726
- return `${messages_getLoggingPrefix('info')} Chrome CDP connection maintained for continuous monitoring`;
133815
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome CDP connection maintained for continuous monitoring`;
132727
133816
  }
132728
133817
  function sourceInspectorNoActiveSession() {
132729
- return `${messages_getLoggingPrefix('warn')} No active Chrome CDP session for file change monitoring`;
133818
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} No active Chrome CDP session for file change monitoring`;
132730
133819
  }
132731
133820
  function sourceInspectorReExtractingHTML() {
132732
- return `${messages_getLoggingPrefix('info')} Chrome is re-extracting page HTML after a file change...`;
133821
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is re-extracting page HTML after a file change...`;
132733
133822
  }
132734
133823
  function sourceInspectorAttemptingReconnection() {
132735
- return `${messages_getLoggingPrefix('warn')} Chrome is attempting to reconnect to the target...`;
133824
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome is attempting to reconnect to the target...`;
132736
133825
  }
132737
133826
  function sourceInspectorCannotReconnect() {
132738
- return `${messages_getLoggingPrefix('error')} Chrome cannot reconnect: missing CDP client or target ID`;
133827
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome cannot reconnect: missing CDP client or target ID`;
132739
133828
  }
132740
133829
  function sourceInspectorReconnectingToTarget() {
132741
- return `${messages_getLoggingPrefix('info')} Chrome is reconnecting to the target...`;
133830
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome is reconnecting to the target...`;
132742
133831
  }
132743
133832
  function sourceInspectorReconnectedToTarget(sessionId) {
132744
- return `${messages_getLoggingPrefix('success')} Chrome reconnected to target with session ID: ${external_pintor_default().gray(sessionId)}`;
133833
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome reconnected to target with session ID: ${external_pintor_default().gray(sessionId)}`;
132745
133834
  }
132746
133835
  function sourceInspectorReconnectionFailed(error) {
132747
- return `${messages_getLoggingPrefix('error')} Failed to reconnect to Chrome target: ${external_pintor_default().red(error)}`;
133836
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to reconnect to Chrome target: ${external_pintor_default().red(error)}`;
132748
133837
  }
132749
133838
  function sourceInspectorEnsuringNavigation() {
132750
- return `${messages_getLoggingPrefix('info')} Chrome ensuring target navigates to URL...`;
133839
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome ensuring target navigates to URL...`;
132751
133840
  }
132752
133841
  function sourceInspectorEnablingPageDomain() {
132753
- return `${messages_getLoggingPrefix('info')} Chrome enabling page domain for load events...`;
133842
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome enabling page domain for load events...`;
132754
133843
  }
132755
133844
  function sourceInspectorWaitingForContentScripts() {
132756
- return `${messages_getLoggingPrefix('info')} Chrome waiting for content scripts to inject...`;
133845
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome waiting for content scripts to inject...`;
132757
133846
  }
132758
133847
  function sourceInspectorWaitingForContentScriptReinjection() {
132759
- return `${messages_getLoggingPrefix('info')} Chrome waiting for content scripts to reinject...`;
133848
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome waiting for content scripts to reinject...`;
132760
133849
  }
132761
133850
  function sourceInspectorFileChanged() {
132762
- return `${messages_getLoggingPrefix('warn')} Chrome source file changed, updating HTML...`;
133851
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome source file changed, updating HTML...`;
132763
133852
  }
132764
133853
  function sourceInspectorHTMLUpdateFailed(error) {
132765
- return `${messages_getLoggingPrefix('error')} Failed to update Chrome HTML: ${external_pintor_default().red(error)}`;
133854
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to update Chrome HTML: ${external_pintor_default().red(error)}`;
132766
133855
  }
132767
133856
  function sourceInspectorCleanupComplete() {
132768
- return `${messages_getLoggingPrefix('success')} Chrome source inspector cleaned up`;
133857
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome source inspector cleaned up`;
132769
133858
  }
132770
133859
  function sourceInspectorCleanupError(error) {
132771
- return `${messages_getLoggingPrefix('error')} Error during Chrome cleanup: ${external_pintor_default().red(error)}`;
133860
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Error during Chrome cleanup: ${external_pintor_default().red(error)}`;
132772
133861
  }
132773
133862
  function sourceInspectorNotInitialized() {
132774
- return `${messages_getLoggingPrefix('error')} Chrome source inspector not initialized`;
133863
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome source inspector not initialized`;
132775
133864
  }
132776
133865
  function sourceInspectorInvalidWebSocketServer() {
132777
- return `${messages_getLoggingPrefix('warn')} Chrome invalid WebSocket server provided`;
133866
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome invalid WebSocket server provided`;
132778
133867
  }
132779
133868
  function sourceInspectorUrlRequired() {
132780
- return `${messages_getLoggingPrefix('error')} Chrome source inspection requires either ${external_pintor_default().blue('--source')} ${external_pintor_default().gray('<url>')} or ${external_pintor_default().blue('--starting-url')} ${external_pintor_default().gray('<url>')} to be specified`;
133869
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome source inspection requires either ${external_pintor_default().blue('--source')} ${external_pintor_default().gray('<url>')} or ${external_pintor_default().blue('--starting-url')} ${external_pintor_default().gray('<url>')} to be specified`;
132781
133870
  }
132782
133871
  function sourceInspectorWillInspect(url) {
132783
- return `${messages_getLoggingPrefix('info')} Chrome source inspection will inspect: ${external_pintor_default().underline(url)}`;
133872
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome source inspection will inspect: ${external_pintor_default().underline(url)}`;
132784
133873
  }
132785
133874
  function sourceInspectorSetupFailed(error) {
132786
- return `${messages_getLoggingPrefix('error')} Failed to setup Chrome source inspection: ${external_pintor_default().red(error)}`;
133875
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to setup Chrome source inspection: ${external_pintor_default().red(error)}`;
132787
133876
  }
132788
133877
  function sourceInspectorHTMLOutputHeader() {
132789
133878
  return '\n' + '='.repeat(80);
@@ -132795,62 +133884,63 @@ var __webpack_exports__ = {};
132795
133884
  return '='.repeat(80) + '\n';
132796
133885
  }
132797
133886
  function sourceInspectorClientNotInitialized() {
132798
- return `${messages_getLoggingPrefix('error')} Firefox source inspector client not initialized`;
133887
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Firefox source inspector client not initialized`;
132799
133888
  }
132800
133889
  function sourceInspectorNoTabActorAvailable() {
132801
- return `${messages_getLoggingPrefix('error')} No Firefox tab actor available for navigation`;
133890
+ return `${browsers_lib_messages_getLoggingPrefix('error')} No Firefox tab actor available for navigation`;
132802
133891
  }
132803
133892
  function sourceInspectorNoTabTargetFound() {
132804
- return `${messages_getLoggingPrefix('error')} No Firefox tab target found`;
133893
+ return `${browsers_lib_messages_getLoggingPrefix('error')} No Firefox tab target found`;
132805
133894
  }
132806
133895
  function sourceInspectorHtmlExtractFailed() {
132807
- return `${messages_getLoggingPrefix('error')} Failed to extract Firefox HTML after retries`;
133896
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to extract Firefox HTML after retries`;
132808
133897
  }
132809
133898
  function cdpClientFoundTargets(count) {
132810
- return `${messages_getLoggingPrefix('info')} Chrome found ${external_pintor_default().gray(count.toString())} targets`;
133899
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome found ${external_pintor_default().gray(count.toString())} targets`;
132811
133900
  }
132812
133901
  function cdpClientTargetWebSocketUrlStored() {
132813
- return `${messages_getLoggingPrefix('info')} Chrome target WebSocket URL stored for future connections`;
133902
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chrome target WebSocket URL stored for future connections`;
132814
133903
  }
132815
133904
  function cdpClientConnected(host, port) {
132816
- return `${messages_getLoggingPrefix('success')} Chrome CDP Client connected to ${external_pintor_default().gray(host)}:${external_pintor_default().gray(port.toString())}`;
133905
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome CDP Client connected to ${external_pintor_default().gray(host)}:${external_pintor_default().gray(port.toString())}`;
132817
133906
  }
132818
133907
  function cdpClientConnectionError(error) {
132819
- return `${messages_getLoggingPrefix('error')} Chrome CDP Client connection error: ${external_pintor_default().red(error)}`;
133908
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome CDP Client connection error: ${external_pintor_default().red(error)}`;
132820
133909
  }
132821
133910
  function cdpClientBrowserConnectionEstablished() {
132822
- return `${messages_getLoggingPrefix('success')} Chrome CDP Client browser connection established`;
133911
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Chrome CDP Client browser connection established`;
132823
133912
  }
132824
133913
  function cdpClientConnectionClosed() {
132825
- return `${messages_getLoggingPrefix('warn')} Chrome CDP connection is closed`;
133914
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome CDP connection is closed`;
132826
133915
  }
132827
133916
  function cdpClientLoadEventTimeout() {
132828
- return `${messages_getLoggingPrefix('warn')} Chrome load event timed out; proceeding anyway...`;
133917
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Chrome load event timed out; proceeding anyway...`;
132829
133918
  }
132830
133919
  function cdpClientExtensionReloadFailed(extensionId, error) {
132831
- return `${messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to force-reload extension ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
133920
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to force-reload extension ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
132832
133921
  }
132833
133922
  function cdpClientExtensionUnloadFailed(extensionId, error) {
132834
- return `${messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to unload extension ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
133923
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to unload extension ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
132835
133924
  }
132836
133925
  function cdpClientExtensionInfoFailed(extensionId, error) {
132837
- return `${messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to get extension info for ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
133926
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to get extension info for ${external_pintor_default().gray(extensionId)}: ${external_pintor_default().red(error)}`;
132838
133927
  }
132839
133928
  function cdpClientExtensionLoadFailed(path, error) {
132840
- return `${messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to load extension from ${external_pintor_default().underline(path)}: ${external_pintor_default().red(error)}`;
133929
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Chrome CDP Client: Failed to load extension from ${external_pintor_default().underline(path)}: ${external_pintor_default().red(error)}`;
132841
133930
  }
132842
133931
  function firefoxRdpClientConnected(host, port) {
132843
- return `${messages_getLoggingPrefix('success')} Connected to Firefox Remote Debugging Protocol on ${external_pintor_default().gray(host)}:${external_pintor_default().gray(port.toString())}`;
133932
+ return `${browsers_lib_messages_getLoggingPrefix('success')} Connected to Firefox Remote Debugging Protocol on ${external_pintor_default().gray(host)}:${external_pintor_default().gray(port.toString())}`;
132844
133933
  }
132845
133934
  function firefoxRdpClientTestingEvaluation() {
132846
- return `${messages_getLoggingPrefix('info')} Testing basic Firefox RDP evaluation...`;
133935
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Testing basic Firefox RDP evaluation...`;
132847
133936
  }
132848
133937
  function firefoxRdpClientFailedToGetMainHTML() {
132849
- return `${messages_getLoggingPrefix('error')} Failed to get Firefox main HTML`;
133938
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Failed to get Firefox main HTML`;
132850
133939
  }
132851
- function runningInDevelopment(manifest, browser, message) {
133940
+ function runningInDevelopment(manifest, browser, message, browserVersionLine) {
132852
133941
  const capitalize = (str)=>str.charAt(0).toUpperCase() + str.slice(1);
132853
133942
  const manifestName = manifest.name || 'Extension.js';
133943
+ const { hostPermissions, permissions } = manifest;
132854
133944
  let browserDevToolsUrl;
132855
133945
  switch(browser){
132856
133946
  case 'chrome':
@@ -132865,14 +133955,74 @@ var __webpack_exports__ = {};
132865
133955
  default:
132866
133956
  browserDevToolsUrl = '';
132867
133957
  }
132868
- if (!message.data) return `${messages_getLoggingPrefix('error')} No Client Data Received for ${manifestName}\n\n${external_pintor_default().red("This error happens when the program can't get the data from your extension.")}\n${external_pintor_default().red('There are many reasons this might happen. To fix, ensure that:')}\n\n- Your extension is set as enabled in ${external_pintor_default().underline(browserDevToolsUrl)}\n- No previous ${capitalize(browser)} browser instance is open\n\nIf that is not the case, restart both the ${external_pintor_default().yellow(manifest.name || '')} and the\n${external_pintor_default().yellow('Manager Extension')} in ${external_pintor_default().underline(browserDevToolsUrl)} and try again.\nIf the issue still persists, please report a bug:\n` + external_pintor_default().underline("https://github.com/extension-js/extension.js/issues");
133958
+ if (!message.data) return `${browsers_lib_messages_getLoggingPrefix('error')} No Client Data Received for ${manifestName}\n\n${external_pintor_default().red("This error happens when the program can't get the data from your extension.")}\n${external_pintor_default().red('There are many reasons this might happen. To fix, ensure that:')}\n\n- Your extension is set as enabled in ${external_pintor_default().underline(browserDevToolsUrl)}\n- No previous ${capitalize(browser)} browser instance is open\n\nIf that is not the case, restart both the ${external_pintor_default().yellow(manifest.name || '')} and the\n${external_pintor_default().yellow('Manager Extension')} in ${external_pintor_default().underline(browserDevToolsUrl)} and try again.\nIf the issue still persists, please report a bug:\n` + external_pintor_default().underline("https://github.com/extension-js/extension.js/issues");
132869
133959
  const { id = '', management } = message.data;
132870
133960
  if (!management) {
132871
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) return `${messages_getLoggingPrefix('error')} No management API info received from client for ${manifestName}. Investigate.`;
133961
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) return `${browsers_lib_messages_getLoggingPrefix('error')} No management API info received from client for ${manifestName}. Investigate.`;
132872
133962
  }
132873
133963
  const { name = '', version: version1 = '' } = management;
132874
- const extensionVersion = __webpack_require__("./package.json").i8;
132875
- return `${` \u{1F9E9} ${external_pintor_default().blue('Extension.js')} ${external_pintor_default().gray(`${extensionVersion}`)}\n Extension Name ${external_pintor_default().gray(name)}\n Extension Version ${external_pintor_default().gray(version1)}\n Extension ID ${external_pintor_default().gray(id)}`}`;
133964
+ const extensionVersion = messages_require('../../../package.json').version;
133965
+ let effectiveBrowserLine = browserVersionLine && browserVersionLine.trim().length > 0 ? browserVersionLine.trim() : '';
133966
+ if (!effectiveBrowserLine) try {
133967
+ if ('chromium' === browser || 'chromium-based' === browser) {
133968
+ const p = external_chromium_location_default()();
133969
+ if (p && 'string' == typeof p && external_fs_.existsSync(p)) {
133970
+ const v = messages_require('child_process').execFileSync(p, [
133971
+ '--version'
133972
+ ], {
133973
+ encoding: 'utf8'
133974
+ }).trim();
133975
+ effectiveBrowserLine = v || 'Chromium';
133976
+ }
133977
+ } else if ('chrome' === browser) {
133978
+ const p = (0, external_chrome_location2_namespaceObject.locateChromeOrExplain)({
133979
+ allowFallback: true
133980
+ });
133981
+ if (p && external_fs_.existsSync(p)) {
133982
+ const v = messages_require('child_process').execFileSync(p, [
133983
+ '--version'
133984
+ ], {
133985
+ encoding: 'utf8'
133986
+ }).trim();
133987
+ effectiveBrowserLine = v || 'Chrome';
133988
+ }
133989
+ } else if ('edge' === browser) {
133990
+ const p = external_edge_location_default()();
133991
+ if (p && external_fs_.existsSync(p)) {
133992
+ const v = messages_require('child_process').execFileSync(p, [
133993
+ '--version'
133994
+ ], {
133995
+ encoding: 'utf8'
133996
+ }).trim();
133997
+ effectiveBrowserLine = v || 'Microsoft Edge';
133998
+ }
133999
+ } else if ('firefox' === browser) {
134000
+ const p = external_firefox_location2_default()(true);
134001
+ if (p && 'string' == typeof p && external_fs_.existsSync(p)) {
134002
+ const v = messages_require('child_process').execFileSync(p, [
134003
+ '--version'
134004
+ ], {
134005
+ encoding: 'utf8'
134006
+ }).trim();
134007
+ effectiveBrowserLine = v || 'Firefox';
134008
+ }
134009
+ }
134010
+ } catch {}
134011
+ const browserLabel = effectiveBrowserLine && effectiveBrowserLine.trim().length > 0 ? effectiveBrowserLine.trim() : capitalize(String(browser || 'unknown'));
134012
+ const cleanId = String(id || '').trim();
134013
+ const urlScheme = 'firefox' === browser || 'gecko-based' === browser ? 'moz-extension' : 'chrome-extension';
134014
+ cleanId.length;
134015
+ (()=>{
134016
+ if ('firefox' === browser || 'gecko-based' === browser) return 'about:debugging#/runtime/this-firefox';
134017
+ if ('chrome' === browser || 'chromium' === browser || 'chromium-based' === browser || 'edge' === browser) return cleanId.length > 0 ? `chrome://extensions/?id=${cleanId}` : 'chrome://extensions';
134018
+ return cleanId.length > 0 ? `${urlScheme}://${cleanId}` : '(temporary)';
134019
+ })();
134020
+ ('firefox' === browser || 'gecko-based' === browser) && 'true' === process.env.EXTENSION_AUTHOR_MODE && cleanId.length;
134021
+ hostPermissions && hostPermissions.length;
134022
+ permissions && permissions.length;
134023
+ const lines = [];
134024
+ lines.push(` \u{1F9E9} ${external_pintor_default().brightBlue('Extension.js')} ${external_pintor_default().gray(`${extensionVersion}`)}`, ` Browser ${external_pintor_default().gray(browserLabel)}`, ` Extension ${external_pintor_default().gray(version1 ? `${name} ${version1}` : name || manifestName)}`, ` Extension ID ${external_pintor_default().gray(cleanId)}`);
134025
+ return lines.join('\n');
132876
134026
  }
132877
134027
  function emptyLine() {
132878
134028
  return '';
@@ -132881,13 +134031,13 @@ var __webpack_exports__ = {};
132881
134031
  return ''.padEnd(80, '=');
132882
134032
  }
132883
134033
  function devChromiumDebugPort(finalPort, requestedPort) {
132884
- return `${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA")} ${external_pintor_default().brightMagenta('Dev')} Chromium debug port: ${external_pintor_default().gray(finalPort.toString())} (requested ${external_pintor_default().gray(requestedPort.toString())})`;
134034
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Chromium debug port: ${external_pintor_default().gray(finalPort.toString())} (requested ${external_pintor_default().gray(requestedPort.toString())})`;
132885
134035
  }
132886
134036
  function devFirefoxDebugPort(finalPort, requestedPort) {
132887
- return `${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA")} ${external_pintor_default().brightMagenta('Dev')} Firefox debug port: ${external_pintor_default().gray(finalPort.toString())} (requested ${external_pintor_default().gray(requestedPort.toString())})`;
134037
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Firefox debug port: ${external_pintor_default().gray(finalPort.toString())} (requested ${external_pintor_default().gray(requestedPort.toString())})`;
132888
134038
  }
132889
134039
  function devFirefoxProfilePath(profilePath) {
132890
- return `${external_pintor_default().brightMagenta("\u25BA\u25BA\u25BA")} ${external_pintor_default().brightMagenta('Dev')} Firefox profile: ${external_pintor_default().underline(profilePath)}`;
134040
+ return `${browsers_lib_messages_getLoggingPrefix('info')} Firefox profile: ${external_pintor_default().underline(profilePath)}`;
132891
134041
  }
132892
134042
  function devHtmlSampleRetry(sample) {
132893
134043
  return `${external_pintor_default().gray('[Extension.js] HTML sample (retry):')} ${external_pintor_default().gray(sample)}`;
@@ -132906,13 +134056,13 @@ var __webpack_exports__ = {};
132906
134056
  return `[extension-log ${ts}] ${data}`;
132907
134057
  }
132908
134058
  function firefoxInspectSourceNonFatal(message) {
132909
- return `${messages_getLoggingPrefix('warn')} Firefox Inspect non-fatal error: ${external_pintor_default().yellow(message)}`;
134059
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Firefox Inspect non-fatal error: ${external_pintor_default().yellow(message)}`;
132910
134060
  }
132911
134061
  function unsupportedBrowser(browser) {
132912
134062
  const supported = "chrome, edge, firefox";
132913
134063
  const hintFlag = `${external_pintor_default().blue('--browser')} ${external_pintor_default().gray('<chrome|edge|firefox>')}`;
132914
134064
  const docsUrl = external_pintor_default().underline('https://github.com/extension-js/extension.js');
132915
- return `${messages_getLoggingPrefix('error')} Unsupported browser ${external_pintor_default().yellow(`"${browser}"`)}\n\nWe currently support: ${external_pintor_default().green(supported)}.\nTry selecting a supported browser with ${hintFlag}.\n\nNeed another engine? Open a discussion or PR:\n${docsUrl}`;
134065
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Unsupported browser ${external_pintor_default().yellow(`"${browser}"`)}\n\nWe currently support: ${external_pintor_default().green(supported)}.\nTry selecting a supported browser with ${hintFlag}.\n\nNeed another engine? Open a discussion or PR:\n${docsUrl}`;
132916
134066
  }
132917
134067
  function browserRunnerError(body) {
132918
134068
  return `${external_pintor_default().red('ERROR')} ${external_pintor_default().brightBlue('error in browser runner')}\n${body}`;
@@ -132934,12 +134084,12 @@ var __webpack_exports__ = {};
132934
134084
  return browserRunnerError(body);
132935
134085
  }
132936
134086
  function rdpInvalidRequestPayload() {
132937
- return `${messages_getLoggingPrefix('error')} Invalid RDP request payload`;
134087
+ return `${browsers_lib_messages_getLoggingPrefix('error')} Invalid RDP request payload`;
132938
134088
  }
132939
134089
  function chromiumDeveloperModeGuidance(browser) {
132940
134090
  let exts = '';
132941
134091
  exts = 'edge' === browser ? external_pintor_default().underline('edge://extensions') : external_pintor_default().underline('chrome://extensions');
132942
- return `${messages_getLoggingPrefix('warn')} Configuration required\nEnable ${external_pintor_default().yellow('Developer mode')} in ${exts} for reliable reloads.\nWithout it, hard reloads may disable your unpacked extension.`;
134092
+ return `${browsers_lib_messages_getLoggingPrefix('warn')} Configuration required\nEnable ${external_pintor_default().yellow('Developer mode')} in ${exts} for reliable reloads.\nWithout it, hard reloads may disable your unpacked extension.`;
132943
134093
  }
132944
134094
  function createChromiumContext() {
132945
134095
  let controller;
@@ -132986,12 +134136,6 @@ var __webpack_exports__ = {};
132986
134136
  };
132987
134137
  }
132988
134138
  var external_child_process_ = __webpack_require__("child_process");
132989
- var external_chrome_location2_ = __webpack_require__("chrome-location2");
132990
- var external_chrome_location2_default = /*#__PURE__*/ __webpack_require__.n(external_chrome_location2_);
132991
- var external_chromium_location_ = __webpack_require__("chromium-location");
132992
- var external_chromium_location_default = /*#__PURE__*/ __webpack_require__.n(external_chromium_location_);
132993
- var external_edge_location_ = __webpack_require__("edge-location");
132994
- var external_edge_location_default = /*#__PURE__*/ __webpack_require__.n(external_edge_location_);
132995
134139
  const instanceIdToRecord = new Map();
132996
134140
  let lastCDPPort;
132997
134141
  function setInstancePorts(instanceId, ports) {
@@ -133245,6 +134389,93 @@ var __webpack_exports__ = {};
133245
134389
  }
133246
134390
  } catch {}
133247
134391
  }
134392
+ const sharedState = {
134393
+ bannerPrinted: false,
134394
+ pendingCompilationLine: ''
134395
+ };
134396
+ function markBannerPrinted() {
134397
+ sharedState.bannerPrinted = true;
134398
+ if (sharedState.pendingCompilationLine) {
134399
+ console.log(sharedState.pendingCompilationLine);
134400
+ sharedState.pendingCompilationLine = '';
134401
+ }
134402
+ }
134403
+ const printedKeys = new Set();
134404
+ function keyFor(browser, outPath, hp) {
134405
+ const host = ((null == hp ? void 0 : hp.host) || '127.0.0.1').toString();
134406
+ const port = (null == hp ? void 0 : hp.port) == null ? '' : String(hp.port);
134407
+ return `${browser}::${external_path_.resolve(outPath)}::${host}:${port}`;
134408
+ }
134409
+ async function printDevBannerOnce(opts) {
134410
+ var _opts_fallback, _opts_fallback1, _opts_fallback2;
134411
+ const k = keyFor(opts.browser, opts.outPath, opts.hostPort);
134412
+ if (printedKeys.has(k)) return false;
134413
+ const info = await opts.getInfo() || null;
134414
+ const manifestPath = external_path_.join(opts.outPath, 'manifest.json');
134415
+ if (!external_fs_.existsSync(manifestPath)) return false;
134416
+ const manifest = JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8'));
134417
+ const extensionId = (null == info ? void 0 : info.extensionId) || (null == (_opts_fallback = opts.fallback) ? void 0 : _opts_fallback.extensionId) || '(temporary)';
134418
+ const name = (null == info ? void 0 : info.name) || (null == (_opts_fallback1 = opts.fallback) ? void 0 : _opts_fallback1.name) || manifest.name;
134419
+ const version1 = (null == info ? void 0 : info.version) || (null == (_opts_fallback2 = opts.fallback) ? void 0 : _opts_fallback2.version) || manifest.version;
134420
+ const message = {
134421
+ data: {
134422
+ id: extensionId,
134423
+ management: {
134424
+ name,
134425
+ version: version1
134426
+ }
134427
+ }
134428
+ };
134429
+ console.log(emptyLine());
134430
+ console.log(runningInDevelopment(manifest, opts.browser, message, opts.browserVersionLine));
134431
+ console.log(emptyLine());
134432
+ markBannerPrinted();
134433
+ printedKeys.add(k);
134434
+ return true;
134435
+ }
134436
+ async function printProdBannerOnce(opts) {
134437
+ const k = keyFor(opts.browser, opts.outPath);
134438
+ if (printedKeys.has(k)) return false;
134439
+ const browserLabel = opts.browserVersionLine && opts.browserVersionLine.trim().length > 0 ? opts.browserVersionLine.trim() : String(opts.browser || 'unknown');
134440
+ try {
134441
+ const manifestPath = external_path_.join(opts.outPath, 'manifest.json');
134442
+ const manifest = JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8'));
134443
+ if (opts.runtime && opts.runtime.extensionId) {
134444
+ const message = {
134445
+ data: {
134446
+ id: opts.runtime.extensionId,
134447
+ management: {
134448
+ name: opts.runtime.name || manifest.name,
134449
+ version: opts.runtime.version || manifest.version
134450
+ }
134451
+ }
134452
+ };
134453
+ console.log(emptyLine());
134454
+ console.log(runningInDevelopment(manifest, opts.browser, message, browserLabel));
134455
+ console.log(emptyLine());
134456
+ } else {
134457
+ const message = {
134458
+ data: {
134459
+ id: '',
134460
+ management: {
134461
+ name: manifest.name,
134462
+ version: manifest.version
134463
+ }
134464
+ }
134465
+ };
134466
+ console.log(emptyLine());
134467
+ console.log(runningInDevelopment(manifest, opts.browser, message, browserLabel));
134468
+ console.log(emptyLine());
134469
+ }
134470
+ } catch {
134471
+ console.log(emptyLine());
134472
+ console.log(webpack_lib_messages.km(opts.outPath, browserLabel));
134473
+ console.log(emptyLine());
134474
+ }
134475
+ markBannerPrinted();
134476
+ printedKeys.add(k);
134477
+ return true;
134478
+ }
133248
134479
  const external_unique_names_generator_namespaceObject = require("unique-names-generator");
133249
134480
  const DEFAULT_BROWSER_FLAGS = [
133250
134481
  '--no-first-run',
@@ -133407,50 +134638,6 @@ var __webpack_exports__ = {};
133407
134638
  console.log(chromiumDryRunBinary(browserBinaryLocation));
133408
134639
  console.log(chromiumDryRunFlags(chromiumConfig.join(' ')));
133409
134640
  }
133410
- const sharedState = {
133411
- bannerPrinted: false,
133412
- pendingCompilationLine: ''
133413
- };
133414
- function markBannerPrinted() {
133415
- sharedState.bannerPrinted = true;
133416
- if (sharedState.pendingCompilationLine) {
133417
- console.log(sharedState.pendingCompilationLine);
133418
- sharedState.pendingCompilationLine = '';
133419
- }
133420
- }
133421
- const printedKeys = new Set();
133422
- function keyFor(browser, outPath, hp) {
133423
- const host = ((null == hp ? void 0 : hp.host) || '127.0.0.1').toString();
133424
- const port = (null == hp ? void 0 : hp.port) == null ? '' : String(hp.port);
133425
- return `${browser}::${external_path_.resolve(outPath)}::${host}:${port}`;
133426
- }
133427
- async function printDevBannerOnce(opts) {
133428
- var _opts_fallback, _opts_fallback1, _opts_fallback2;
133429
- const k = keyFor(opts.browser, opts.outPath, opts.hostPort);
133430
- if (printedKeys.has(k)) return false;
133431
- const info = await opts.getInfo() || null;
133432
- const manifestPath = external_path_.join(opts.outPath, 'manifest.json');
133433
- if (!external_fs_.existsSync(manifestPath)) return false;
133434
- const manifest = JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8'));
133435
- const extensionId = (null == info ? void 0 : info.extensionId) || (null == (_opts_fallback = opts.fallback) ? void 0 : _opts_fallback.extensionId) || '(temporary)';
133436
- const name = (null == info ? void 0 : info.name) || (null == (_opts_fallback1 = opts.fallback) ? void 0 : _opts_fallback1.name) || manifest.name;
133437
- const version1 = (null == info ? void 0 : info.version) || (null == (_opts_fallback2 = opts.fallback) ? void 0 : _opts_fallback2.version) || manifest.version;
133438
- const message = {
133439
- data: {
133440
- id: extensionId,
133441
- management: {
133442
- name,
133443
- version: version1
133444
- }
133445
- }
133446
- };
133447
- console.log(emptyLine());
133448
- console.log(runningInDevelopment(manifest, opts.browser, message));
133449
- console.log(emptyLine());
133450
- markBannerPrinted();
133451
- printedKeys.add(k);
133452
- return true;
133453
- }
133454
134641
  async function deriveExtensionIdFromTargetsHelper(cdp, outPath, maxRetries = 20, backoffMs = 200) {
133455
134642
  let expectedName;
133456
134643
  try {
@@ -134321,7 +135508,6 @@ var __webpack_exports__ = {};
134321
135508
  return (userCandidates.length ? userCandidates : entries).slice(-1)[0];
134322
135509
  }
134323
135510
  async function setupCdpAfterLaunch(compilation, plugin, chromiumArgs) {
134324
- var _compilation_options;
134325
135511
  const loadExtensionFlag = chromiumArgs.find((flag)=>flag.startsWith('--load-extension='));
134326
135512
  const extensionOutputPath = getExtensionOutputPath(compilation, loadExtensionFlag);
134327
135513
  const remoteDebugPortFlag = chromiumArgs.find((flag)=>flag.startsWith('--remote-debugging-port='));
@@ -134353,27 +135539,51 @@ var __webpack_exports__ = {};
134353
135539
  await retryAsync(()=>cdpExtensionController.connect());
134354
135540
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(cdpClientConnected('127.0.0.1', chromeRemoteDebugPort));
134355
135541
  const extensionControllerInfo = await cdpExtensionController.ensureLoaded();
134356
- if ((null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : _compilation_options.mode) !== 'production') try {
134357
- const bannerPrinted = await printDevBannerOnce({
134358
- outPath: extensionOutputPath,
135542
+ try {
135543
+ var _compilation_options;
135544
+ const mode = (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : _compilation_options.mode) || 'development';
135545
+ if ('development' === mode) {
135546
+ const bannerPrinted = await printDevBannerOnce({
135547
+ outPath: extensionOutputPath,
135548
+ browser: plugin.browser,
135549
+ hostPort: {
135550
+ host: '127.0.0.1',
135551
+ port: chromeRemoteDebugPort
135552
+ },
135553
+ getInfo: async ()=>extensionControllerInfo,
135554
+ browserVersionLine: plugin.browserVersionLine
135555
+ });
135556
+ if (!bannerPrinted) await printDevBannerOnce({
135557
+ outPath: extensionOutputPath,
135558
+ browser: plugin.browser,
135559
+ hostPort: {
135560
+ host: '127.0.0.1',
135561
+ port: chromeRemoteDebugPort
135562
+ },
135563
+ getInfo: async ()=>cdpExtensionController.getInfoBestEffort(),
135564
+ browserVersionLine: plugin.browserVersionLine
135565
+ });
135566
+ } else if ('production' === mode) await printProdBannerOnce({
134359
135567
  browser: plugin.browser,
134360
- hostPort: {
134361
- host: '127.0.0.1',
134362
- port: chromeRemoteDebugPort
134363
- },
134364
- getInfo: async ()=>extensionControllerInfo
134365
- });
134366
- if (!bannerPrinted) await printDevBannerOnce({
134367
135568
  outPath: extensionOutputPath,
134368
- browser: plugin.browser,
134369
- hostPort: {
134370
- host: '127.0.0.1',
134371
- port: chromeRemoteDebugPort
134372
- },
134373
- getInfo: async ()=>cdpExtensionController.getInfoBestEffort()
135569
+ browserVersionLine: plugin.browserVersionLine,
135570
+ runtime: {
135571
+ extensionId: extensionControllerInfo.extensionId,
135572
+ name: extensionControllerInfo.name,
135573
+ version: extensionControllerInfo.version
135574
+ }
134374
135575
  });
134375
135576
  } catch (bannerErr) {
134376
135577
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(bestEffortBannerPrintFailed(String(bannerErr)));
135578
+ try {
135579
+ var _compilation_options1;
135580
+ const mode = (null == compilation ? void 0 : null == (_compilation_options1 = compilation.options) ? void 0 : _compilation_options1.mode) || 'development';
135581
+ if ('production' === mode) await printProdBannerOnce({
135582
+ browser: plugin.browser,
135583
+ outPath: extensionOutputPath,
135584
+ browserVersionLine: plugin.browserVersionLine
135585
+ });
135586
+ } catch {}
134377
135587
  }
134378
135588
  plugin.cdpController = cdpExtensionController;
134379
135589
  }
@@ -134421,51 +135631,25 @@ var __webpack_exports__ = {};
134421
135631
  if (resolved && external_fs_.existsSync(resolved)) browserBinaryLocation = resolved;
134422
135632
  } catch {}
134423
135633
  const skipDetection = Boolean(browserBinaryLocation);
134424
- const getChromeVersionLine = (bin)=>{
135634
+ const getBrowserVersionLine = (bin)=>{
134425
135635
  try {
134426
- const versionLine = (0, external_child_process_.execFileSync)(bin, [
134427
- '--version'
134428
- ], {
134429
- encoding: 'utf8'
134430
- }).trim();
134431
- if (versionLine) return versionLine;
134432
- } catch {}
134433
- if ('win32' === process.platform) try {
134434
- const psPath = bin.replace(/'/g, "''");
134435
- const pv = (0, external_child_process_.execFileSync)('powershell.exe', [
134436
- '-NoProfile',
134437
- '-Command',
134438
- `(Get-Item -LiteralPath '${psPath}').VersionInfo.ProductVersion`
134439
- ], {
134440
- encoding: 'utf8',
134441
- stdio: [
134442
- 'ignore',
134443
- 'pipe',
134444
- 'ignore'
134445
- ]
134446
- }).trim();
134447
- const pn = (0, external_child_process_.execFileSync)('powershell.exe', [
134448
- '-NoProfile',
134449
- '-Command',
134450
- `(Get-Item -LiteralPath '${psPath}').VersionInfo.ProductName`
134451
- ], {
134452
- encoding: 'utf8',
134453
- stdio: [
134454
- 'ignore',
134455
- 'pipe',
134456
- 'ignore'
134457
- ]
134458
- }).trim();
134459
- if (pv) return pn ? `${pn} ${pv}` : pv;
134460
- } catch {}
134461
- return '';
135636
+ if ('edge' === browser) return (0, external_edge_location_namespaceObject.getEdgeVersion)(bin, {
135637
+ allowExec: true
135638
+ }) || '';
135639
+ if ('chromium' === browser || 'chromium-based' === browser) return (0, external_chromium_location_namespaceObject.getChromiumVersion)(bin, {
135640
+ allowExec: true
135641
+ }) || '';
135642
+ return (0, external_chrome_location2_namespaceObject.getChromeVersion)(bin, {
135643
+ allowExec: true
135644
+ }) || '';
135645
+ } catch {
135646
+ return '';
135647
+ }
134462
135648
  };
134463
135649
  const looksOfficialChrome = (line)=>/^Google Chrome\s(?!for Testing)/i.test(line);
134464
135650
  const getInstallGuidanceText = ()=>{
134465
135651
  try {
134466
- const f = null == external_chrome_location2_ ? void 0 : external_chrome_location2_.getInstallGuidance;
134467
- const txt = 'function' == typeof f ? f() : '';
134468
- return txt && 'string' == typeof txt ? txt : 'npx @puppeteer/browsers install chrome@stable';
135652
+ return (0, external_chrome_location2_namespaceObject.getInstallGuidance)();
134469
135653
  } catch {
134470
135654
  return 'npx @puppeteer/browsers install chrome@stable';
134471
135655
  }
@@ -134474,13 +135658,12 @@ var __webpack_exports__ = {};
134474
135658
  case 'chrome':
134475
135659
  console.log(locatingBrowser(browser));
134476
135660
  if (!skipDetection) try {
134477
- const locate = external_chrome_location2_.locateChromeOrExplain;
134478
- if ('function' == typeof locate) try {
134479
- const located = locate({
135661
+ try {
135662
+ const located = (0, external_chrome_location2_namespaceObject.locateChromeOrExplain)({
134480
135663
  allowFallback: true
134481
135664
  });
134482
135665
  if (located && external_fs_.existsSync(located)) {
134483
- const versionLine = getChromeVersionLine(located);
135666
+ const versionLine = getBrowserVersionLine(located);
134484
135667
  if (looksOfficialChrome(versionLine)) {
134485
135668
  this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134486
135669
  printedGuidance = true;
@@ -134488,23 +135671,9 @@ var __webpack_exports__ = {};
134488
135671
  } else browserBinaryLocation = located;
134489
135672
  } else browserBinaryLocation = null;
134490
135673
  } catch (err) {
134491
- var _chromeLocation_default;
134492
- let candidate = (null == (_chromeLocation_default = external_chrome_location2_default()) ? void 0 : _chromeLocation_default.call(external_chrome_location2_, true)) || null;
134493
- if (candidate) {
134494
- const versionLine = getChromeVersionLine(candidate);
134495
- if (looksOfficialChrome(versionLine)) {
134496
- this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134497
- printedGuidance = true;
134498
- candidate = null;
134499
- }
134500
- }
134501
- browserBinaryLocation = candidate;
134502
- if (!browserBinaryLocation) throw err;
134503
- }
134504
- else {
134505
135674
  let candidate = external_chrome_location2_default()(true) || null;
134506
135675
  if (candidate) {
134507
- const versionLine = getChromeVersionLine(candidate);
135676
+ const versionLine = getBrowserVersionLine(candidate);
134508
135677
  if (looksOfficialChrome(versionLine)) {
134509
135678
  this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134510
135679
  printedGuidance = true;
@@ -134512,6 +135681,7 @@ var __webpack_exports__ = {};
134512
135681
  }
134513
135682
  }
134514
135683
  browserBinaryLocation = candidate;
135684
+ if (!browserBinaryLocation) throw err;
134515
135685
  }
134516
135686
  } catch (e) {
134517
135687
  this.printEnhancedPuppeteerInstallHint(compilation, String(e), browser);
@@ -134530,8 +135700,7 @@ var __webpack_exports__ = {};
134530
135700
  }
134531
135701
  }
134532
135702
  if (!browserBinaryLocation && !skipDetection) try {
134533
- const loc = (null === external_chromium_location_default() || void 0 === external_chromium_location_default() ? void 0 : external_chromium_location_default()["default"]) || external_chromium_location_default();
134534
- const p = 'function' == typeof loc ? loc() : null;
135703
+ const p = external_chromium_location_default()();
134535
135704
  if (p && 'string' == typeof p && external_fs_.existsSync(p)) browserBinaryLocation = p;
134536
135705
  } catch {}
134537
135706
  break;
@@ -134546,9 +135715,7 @@ var __webpack_exports__ = {};
134546
135715
  if (!browserBinaryLocation || !external_fs_.existsSync(String(browserBinaryLocation))) {
134547
135716
  const guidance = (()=>{
134548
135717
  try {
134549
- const f = null === external_edge_location_default() || void 0 === external_edge_location_default() ? void 0 : external_edge_location_default().getInstallGuidance;
134550
- const txt = 'function' == typeof f ? f() : '';
134551
- return txt && 'string' == typeof txt ? txt : 'npx playwright install msedge';
135718
+ return (0, external_edge_location_namespaceObject.getInstallGuidance)();
134552
135719
  } catch {
134553
135720
  return 'npx playwright install msedge';
134554
135721
  }
@@ -134563,9 +135730,7 @@ var __webpack_exports__ = {};
134563
135730
  } catch {
134564
135731
  const guidance = (()=>{
134565
135732
  try {
134566
- const f = null === external_edge_location_default() || void 0 === external_edge_location_default() ? void 0 : external_edge_location_default().getInstallGuidance;
134567
- const txt = 'function' == typeof f ? f() : '';
134568
- return txt && 'string' == typeof txt ? txt : 'npx playwright install msedge';
135733
+ return (0, external_edge_location_namespaceObject.getInstallGuidance)();
134569
135734
  } catch {
134570
135735
  return 'npx playwright install msedge';
134571
135736
  }
@@ -134590,20 +135755,18 @@ var __webpack_exports__ = {};
134590
135755
  process.exit(1);
134591
135756
  }
134592
135757
  if (!browserBinaryLocation && !skipDetection) try {
134593
- const loc = (null === external_chromium_location_default() || void 0 === external_chromium_location_default() ? void 0 : external_chromium_location_default()["default"]) || external_chromium_location_default();
134594
- const p = 'function' == typeof loc ? loc() : null;
135758
+ const p = external_chromium_location_default()();
134595
135759
  if (p && 'string' == typeof p && external_fs_.existsSync(p)) browserBinaryLocation = p;
134596
135760
  } catch {}
134597
135761
  break;
134598
135762
  default:
134599
135763
  try {
134600
- const locate = external_chrome_location2_.locateChromeOrExplain;
134601
- if ('function' == typeof locate) try {
134602
- const located = locate({
135764
+ try {
135765
+ const located = (0, external_chrome_location2_namespaceObject.locateChromeOrExplain)({
134603
135766
  allowFallback: true
134604
135767
  });
134605
135768
  if (located && external_fs_.existsSync(located)) {
134606
- const versionLine = getChromeVersionLine(located);
135769
+ const versionLine = getBrowserVersionLine(located);
134607
135770
  if (looksOfficialChrome(versionLine)) {
134608
135771
  this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134609
135772
  printedGuidance = true;
@@ -134611,23 +135774,9 @@ var __webpack_exports__ = {};
134611
135774
  } else browserBinaryLocation = located;
134612
135775
  } else browserBinaryLocation = null;
134613
135776
  } catch (err) {
134614
- var _chromeLocation_default1;
134615
- let candidate = (null == (_chromeLocation_default1 = external_chrome_location2_default()) ? void 0 : _chromeLocation_default1.call(external_chrome_location2_, true)) || null;
134616
- if (candidate) {
134617
- const versionLine = getChromeVersionLine(candidate);
134618
- if (looksOfficialChrome(versionLine)) {
134619
- this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134620
- printedGuidance = true;
134621
- candidate = null;
134622
- }
134623
- }
134624
- browserBinaryLocation = candidate;
134625
- if (!browserBinaryLocation) throw err;
134626
- }
134627
- else {
134628
135777
  let candidate = external_chrome_location2_default()(true) || null;
134629
135778
  if (candidate) {
134630
- const versionLine = getChromeVersionLine(candidate);
135779
+ const versionLine = getBrowserVersionLine(candidate);
134631
135780
  if (looksOfficialChrome(versionLine)) {
134632
135781
  this.printEnhancedPuppeteerInstallHint(compilation, getInstallGuidanceText(), browser);
134633
135782
  printedGuidance = true;
@@ -134635,6 +135784,7 @@ var __webpack_exports__ = {};
134635
135784
  }
134636
135785
  }
134637
135786
  browserBinaryLocation = candidate;
135787
+ if (!browserBinaryLocation) throw err;
134638
135788
  }
134639
135789
  } catch (e) {
134640
135790
  this.printEnhancedPuppeteerInstallHint(compilation, String(e), browser);
@@ -134652,9 +135802,7 @@ var __webpack_exports__ = {};
134652
135802
  if ('chromium' === browser || 'chromium-based' === browser) {
134653
135803
  const chromiumGuidance = (()=>{
134654
135804
  try {
134655
- const f = null === external_chromium_location_default() || void 0 === external_chromium_location_default() ? void 0 : external_chromium_location_default().getInstallGuidance;
134656
- const txt = 'function' == typeof f ? f() : '';
134657
- return txt && 'string' == typeof txt ? txt : 'npx @puppeteer/browsers install chromium';
135805
+ return (0, external_chromium_location_namespaceObject.getInstallGuidance)();
134658
135806
  } catch {
134659
135807
  return 'npx @puppeteer/browsers install chromium';
134660
135808
  }
@@ -134676,7 +135824,10 @@ var __webpack_exports__ = {};
134676
135824
  const last = [
134677
135825
  ...extensionsToLoad
134678
135826
  ].reverse().find((e)=>'string' == typeof e);
134679
- if (last) this.ctx.setExtensionRoot(String(last));
135827
+ if (last) {
135828
+ const root = String(last);
135829
+ this.ctx.setExtensionRoot(root);
135830
+ }
134680
135831
  } catch {}
134681
135832
  let chromiumConfig = browser_config_browserConfig(compilation, {
134682
135833
  ...this.options,
@@ -134696,6 +135847,26 @@ var __webpack_exports__ = {};
134696
135847
  if (this.options.dryRun) return void logChromiumDryRun(browserBinaryLocation, chromiumConfig);
134697
135848
  await this.launchWithDirectSpawn(browserBinaryLocation, chromiumConfig);
134698
135849
  try {
135850
+ let browserVersionLine;
135851
+ try {
135852
+ if (browserBinaryLocation && external_fs_.existsSync(browserBinaryLocation)) {
135853
+ const vLine = getBrowserVersionLine(browserBinaryLocation);
135854
+ if (vLine && vLine.trim().length > 0) browserVersionLine = vLine.trim();
135855
+ }
135856
+ } catch {}
135857
+ try {
135858
+ var _compilation_options;
135859
+ const mode = (null == compilation ? void 0 : null == (_compilation_options = compilation.options) ? void 0 : _compilation_options.mode) || 'development';
135860
+ if ('production' === mode) {
135861
+ const loadExtensionFlag = chromiumConfig.find((flag)=>flag.startsWith('--load-extension='));
135862
+ const extensionOutputPath = getExtensionOutputPath(compilation, loadExtensionFlag);
135863
+ if (extensionOutputPath) await printProdBannerOnce({
135864
+ browser: this.options.browser,
135865
+ outPath: extensionOutputPath,
135866
+ browserVersionLine
135867
+ });
135868
+ }
135869
+ } catch {}
134699
135870
  const cdpConfig = {
134700
135871
  extension: Array.isArray(this.options.extension) ? this.options.extension : [
134701
135872
  this.options.extension
@@ -134721,7 +135892,8 @@ var __webpack_exports__ = {};
134721
135892
  chromiumBinary: this.options.chromiumBinary,
134722
135893
  source: this.options.source,
134723
135894
  watchSource: this.options.watchSource,
134724
- dryRun: this.options.dryRun
135895
+ dryRun: this.options.dryRun,
135896
+ browserVersionLine
134725
135897
  };
134726
135898
  await setupCdpAfterLaunch(compilation, cdpConfig, chromiumConfig);
134727
135899
  if (cdpConfig.cdpController) this.ctx.setController(cdpConfig.cdpController, selectedPort);
@@ -134975,20 +136147,27 @@ var __webpack_exports__ = {};
134975
136147
  return null == (_console = console) ? void 0 : null == (_console_debug = _console.debug) ? void 0 : _console_debug.call(_console, ...a);
134976
136148
  }
134977
136149
  };
134978
- if (null == (_compiler_hooks = compiler.hooks) ? void 0 : null == (_compiler_hooks_watchRun = _compiler_hooks.watchRun) ? void 0 : _compiler_hooks_watchRun.tapAsync) compiler.hooks.watchRun.tapAsync('run-browsers:watch', (compilation, done)=>{
136150
+ if (null == (_compiler_hooks = compiler.hooks) ? void 0 : null == (_compiler_hooks_watchRun = _compiler_hooks.watchRun) ? void 0 : _compiler_hooks_watchRun.tapAsync) compiler.hooks.watchRun.tapAsync('run-browsers:watch', (compilerWithModifiedFiles, done)=>{
134979
136151
  try {
134980
- const files = (null == compilation ? void 0 : compilation.modifiedFiles) || new Set();
134981
- const normalizedFilePaths = Array.from(files).map((filePath)=>filePath.replace(/\\/g, '/'));
134982
- const hitManifest = normalizedFilePaths.some((filePath)=>/(^|\/)manifest\.json$/i.test(filePath));
134983
- const localeChanged = normalizedFilePaths.some((filePath)=>/(^|\/)__?locales\/.+\.json$/i.test(filePath));
136152
+ const modifiedFiles = (null == compilerWithModifiedFiles ? void 0 : compilerWithModifiedFiles.modifiedFiles) || new Set();
136153
+ const normalizedModifiedFilePaths = Array.from(modifiedFiles).map((filePath)=>String(filePath).replace(/\\/g, '/'));
136154
+ const hitManifest = normalizedModifiedFilePaths.some((filePath)=>/(^|\/)manifest\.json$/i.test(filePath));
136155
+ const localeChanged = normalizedModifiedFilePaths.some((filePath)=>/(^|\/)__?locales\/.+\.json$/i.test(filePath));
134984
136156
  let serviceWorkerChanged = false;
134985
- const { absolutePath: serviceWorkerAbsolutePath, relativePath: serviceWorkerRelativePath } = this.ctx.getServiceWorkerPaths() || {};
134986
- if (serviceWorkerAbsolutePath) {
134987
- const normalizedServiceWorkerAbsolutePath = serviceWorkerAbsolutePath.replace(/\\/g, '/');
134988
- serviceWorkerChanged = normalizedFilePaths.some((filePath)=>{
134989
- const normalizedPath = filePath.replace(/\\/g, '/');
134990
- return normalizedPath === normalizedServiceWorkerAbsolutePath || normalizedPath.endsWith(normalizedServiceWorkerAbsolutePath) || (serviceWorkerRelativePath ? normalizedPath === serviceWorkerRelativePath.replace(/\\/g, '/') || normalizedPath.endsWith('/' + serviceWorkerRelativePath.replace(/\\/g, '/')) : false);
134991
- });
136157
+ if (this.serviceWorkerSourceDependencyPaths.size > 0) serviceWorkerChanged = normalizedModifiedFilePaths.some((modifiedFilePath)=>{
136158
+ if (this.serviceWorkerSourceDependencyPaths.has(modifiedFilePath)) return true;
136159
+ for (const serviceWorkerSourceDependencyPath of this.serviceWorkerSourceDependencyPaths)if (modifiedFilePath.endsWith(serviceWorkerSourceDependencyPath)) return true;
136160
+ return false;
136161
+ });
136162
+ else {
136163
+ const { absolutePath: serviceWorkerAbsolutePath, relativePath: serviceWorkerRelativePath } = this.ctx.getServiceWorkerPaths() || {};
136164
+ if (serviceWorkerAbsolutePath) {
136165
+ const normalizedServiceWorkerAbsolutePath = serviceWorkerAbsolutePath.replace(/\\/g, '/');
136166
+ serviceWorkerChanged = normalizedModifiedFilePaths.some((filePath)=>{
136167
+ const normalizedPath = filePath.replace(/\\/g, '/');
136168
+ return normalizedPath === normalizedServiceWorkerAbsolutePath || normalizedPath.endsWith(normalizedServiceWorkerAbsolutePath) || (serviceWorkerRelativePath ? normalizedPath === serviceWorkerRelativePath.replace(/\\/g, '/') || normalizedPath.endsWith('/' + serviceWorkerRelativePath.replace(/\\/g, '/')) : false);
136169
+ });
136170
+ }
134992
136171
  }
134993
136172
  if (hitManifest) this.ctx.setPendingReloadReason('manifest');
134994
136173
  else if (localeChanged) this.ctx.setPendingReloadReason('locales');
@@ -135004,6 +136183,7 @@ var __webpack_exports__ = {};
135004
136183
  const hasErrors = 'function' == typeof (null == stats ? void 0 : stats.hasErrors) ? stats.hasErrors() : !!(null == stats ? void 0 : null == (_stats_compilation = stats.compilation) ? void 0 : null == (_stats_compilation_errors = _stats_compilation.errors) ? void 0 : _stats_compilation_errors.length);
135005
136184
  if (hasErrors) return;
135006
136185
  this.refreshSWFromManifest(stats.compilation);
136186
+ this.refreshServiceWorkerSourceDependencyPaths(stats.compilation);
135007
136187
  const reason = this.ctx.getPendingReloadReason();
135008
136188
  if (!reason) return;
135009
136189
  this.ctx.clearPendingReloadReason();
@@ -135033,13 +136213,42 @@ var __webpack_exports__ = {};
135033
136213
  }
135034
136214
  } catch {}
135035
136215
  }
136216
+ refreshServiceWorkerSourceDependencyPaths(compilation) {
136217
+ try {
136218
+ const serviceWorkerEntrypointName = 'background/service_worker';
136219
+ const discovered = this.collectEntrypointModuleResourcePaths(compilation, serviceWorkerEntrypointName);
136220
+ this.serviceWorkerSourceDependencyPaths = discovered;
136221
+ } catch {}
136222
+ }
136223
+ collectEntrypointModuleResourcePaths(compilation, entrypointName) {
136224
+ var _entrypoints_get;
136225
+ const collectedResourcePaths = new Set();
136226
+ const entrypoints = null == compilation ? void 0 : compilation.entrypoints;
136227
+ const entrypoint = null == entrypoints ? void 0 : null == (_entrypoints_get = entrypoints.get) ? void 0 : _entrypoints_get.call(entrypoints, entrypointName);
136228
+ if (!entrypoint) return collectedResourcePaths;
136229
+ const chunkGraph = null == compilation ? void 0 : compilation.chunkGraph;
136230
+ if (!chunkGraph) return collectedResourcePaths;
136231
+ const entrypointChunks = Array.from((null == entrypoint ? void 0 : entrypoint.chunks) || []);
136232
+ for (const chunk of entrypointChunks){
136233
+ var _chunkGraph_getChunkModulesIterable, _chunkGraph_getChunkModulesIterableBySourceType, _chunkGraph_getChunkModules;
136234
+ const modulesIterable = (null == (_chunkGraph_getChunkModulesIterable = chunkGraph.getChunkModulesIterable) ? void 0 : _chunkGraph_getChunkModulesIterable.call(chunkGraph, chunk)) || (null == (_chunkGraph_getChunkModulesIterableBySourceType = chunkGraph.getChunkModulesIterableBySourceType) ? void 0 : _chunkGraph_getChunkModulesIterableBySourceType.call(chunkGraph, chunk, "javascript")) || (null == (_chunkGraph_getChunkModules = chunkGraph.getChunkModules) ? void 0 : _chunkGraph_getChunkModules.call(chunkGraph, chunk));
136235
+ if (modulesIterable) for (const module of modulesIterable){
136236
+ var _module_rootModule, _module_originalSource, _module_originalSource1;
136237
+ const resourcePath = (null == module ? void 0 : module.resource) || (null == module ? void 0 : null == (_module_rootModule = module.rootModule) ? void 0 : _module_rootModule.resource) || (null == module ? void 0 : null == (_module_originalSource1 = module.originalSource) ? void 0 : null == (_module_originalSource = _module_originalSource1.call(module)) ? void 0 : _module_originalSource.resource);
136238
+ if ('string' == typeof resourcePath && resourcePath.length > 0) collectedResourcePaths.add(resourcePath.replace(/\\/g, '/'));
136239
+ }
136240
+ }
136241
+ return collectedResourcePaths;
136242
+ }
135036
136243
  constructor(options, ctx){
135037
136244
  chromium_hard_reload_define_property(this, "options", void 0);
135038
136245
  chromium_hard_reload_define_property(this, "ctx", void 0);
135039
136246
  chromium_hard_reload_define_property(this, "logger", void 0);
135040
136247
  chromium_hard_reload_define_property(this, "warnedDevMode", void 0);
136248
+ chromium_hard_reload_define_property(this, "serviceWorkerSourceDependencyPaths", void 0);
135041
136249
  this.options = options;
135042
136250
  this.ctx = ctx;
136251
+ this.serviceWorkerSourceDependencyPaths = new Set();
135043
136252
  }
135044
136253
  }
135045
136254
  async function waitForChromeRemoteDebugging(port, instanceId) {
@@ -135528,8 +136737,6 @@ var __webpack_exports__ = {};
135528
136737
  didLaunch: false
135529
136738
  };
135530
136739
  }
135531
- var external_firefox_location2_ = __webpack_require__("firefox-location2");
135532
- var external_firefox_location2_default = /*#__PURE__*/ __webpack_require__.n(external_firefox_location2_);
135533
136740
  function setupFirefoxProcessHandlers(browser, childRef, cleanupInstance) {
135534
136741
  let isCleaningUp = false;
135535
136742
  const attemptCleanup = async ()=>{
@@ -136123,7 +137330,7 @@ var __webpack_exports__ = {};
136123
137330
  if (Array.isArray(codeWanted)) return codeWanted.includes(code);
136124
137331
  return code === codeWanted;
136125
137332
  }
136126
- async function printRunningInDevelopmentSummary(candidateAddonPaths, browser, extensionId) {
137333
+ async function printRunningInDevelopmentSummary(candidateAddonPaths, browser, extensionId, browserVersionLine) {
136127
137334
  try {
136128
137335
  let chosenPath = null;
136129
137336
  for (const p of candidateAddonPaths){
@@ -136152,7 +137359,8 @@ var __webpack_exports__ = {};
136152
137359
  extensionId: extensionId || '(temporary)',
136153
137360
  name: manifest.name,
136154
137361
  version: manifest.version
136155
- })
137362
+ }),
137363
+ browserVersionLine
136156
137364
  });
136157
137365
  }
136158
137366
  }
@@ -136468,7 +137676,7 @@ var __webpack_exports__ = {};
136468
137676
  throw lastError;
136469
137677
  }
136470
137678
  async installAddons(compilation) {
136471
- var _compilation_options_devServer, _compilation_options, _this_options, _compilation_options1;
137679
+ var _compilation_options_devServer, _compilation_options, _this_options;
136472
137680
  const { devtools } = this.options;
136473
137681
  const rawExtensions = (Array.isArray(this.options.extensionsToLoad) && this.options.extensionsToLoad.length ? this.options.extensionsToLoad : void 0) || (Array.isArray(this.options.extension) ? this.options.extension : [
136474
137682
  this.options.extension
@@ -136521,7 +137729,7 @@ var __webpack_exports__ = {};
136521
137729
  if (!this.derivedExtensionId) this.derivedExtensionId = await deriveMozExtensionId(client);
136522
137730
  } catch {}
136523
137731
  this.lastInstalledAddonPath = candidateAddonPaths[0];
136524
- if ((null == compilation ? void 0 : null == (_compilation_options1 = compilation.options) ? void 0 : _compilation_options1.mode) !== 'production') printRunningInDevelopmentSummary(candidateAddonPaths, 'firefox', this.derivedExtensionId);
137732
+ printRunningInDevelopmentSummary(candidateAddonPaths, 'firefox', this.derivedExtensionId, this.options.browserVersionLine);
136525
137733
  }
136526
137734
  markNeedsReinstall() {
136527
137735
  this.needsReinstall = true;
@@ -136703,7 +137911,8 @@ var __webpack_exports__ = {};
136703
137911
  instanceId: plugin.instanceId,
136704
137912
  port: debugPort,
136705
137913
  source: 'string' == typeof plugin.source ? plugin.source : void 0,
136706
- watchSource: plugin.watchSource
137914
+ watchSource: plugin.watchSource,
137915
+ browserVersionLine: plugin.browserVersionLine
136707
137916
  });
136708
137917
  this.debugPort = 'string' == typeof debugPort ? parseInt(debugPort, 10) : debugPort;
136709
137918
  }
@@ -136729,12 +137938,6 @@ var __webpack_exports__ = {};
136729
137938
  await retry(()=>controller.ensureLoaded(compilation));
136730
137939
  plugin.rdpController = controller;
136731
137940
  }
136732
- try {
136733
- const list = Array.isArray(plugin.extensionsToLoad) ? plugin.extensionsToLoad : Array.isArray(plugin.extension) ? plugin.extension : 'string' == typeof plugin.extension ? [
136734
- plugin.extension
136735
- ] : [];
136736
- if (list.length) await printRunningInDevelopmentSummary(list, 'firefox');
136737
- } catch {}
136738
137941
  return controller;
136739
137942
  }
136740
137943
  function logFirefoxDryRun(browserBinaryLocation, firefoxConfig) {
@@ -137003,10 +138206,7 @@ var __webpack_exports__ = {};
137003
138206
  else if (!skipDetection) if (engineBased) {
137004
138207
  console.error(requireGeckoBinaryForGeckoBased());
137005
138208
  process.exit(1);
137006
- } else {
137007
- const locate = external_firefox_location2_default()["default"] || external_firefox_location2_default();
137008
- browserBinaryLocation = 'function' == typeof locate ? locate(true) : null;
137009
- }
138209
+ } else browserBinaryLocation = external_firefox_location2_default()(true);
137010
138210
  } catch (_error) {
137011
138211
  console.error(this.host.geckoBinary ? invalidGeckoBinaryPath(this.host.geckoBinary) : requireGeckoBinaryForGeckoBased());
137012
138212
  process.exit(1);
@@ -137020,9 +138220,7 @@ var __webpack_exports__ = {};
137020
138220
  } else {
137021
138221
  const guidance = (()=>{
137022
138222
  try {
137023
- const f = null === external_firefox_location2_default() || void 0 === external_firefox_location2_default() ? void 0 : external_firefox_location2_default().getInstallGuidance;
137024
- const txt = 'function' == typeof f ? f() : '';
137025
- return txt && 'string' == typeof txt ? txt : 'npx @puppeteer/browsers install firefox';
138223
+ return (0, external_firefox_location2_namespaceObject.getInstallGuidance)();
137026
138224
  } catch {
137027
138225
  return 'npx @puppeteer/browsers install firefox';
137028
138226
  }
@@ -137033,6 +138231,11 @@ var __webpack_exports__ = {};
137033
138231
  }
137034
138232
  }
137035
138233
  const binaryPath = browserBinaryLocation;
138234
+ try {
138235
+ this.host.browserVersionLine = (0, external_firefox_location2_namespaceObject.getFirefoxVersion)(binaryPath, {
138236
+ allowExec: true
138237
+ }) || '';
138238
+ } catch {}
137036
138239
  try {
137037
138240
  await FirefoxBinaryDetector.validateFirefoxBinary(binaryPath);
137038
138241
  } catch {}
@@ -137727,14 +138930,19 @@ var __webpack_exports__ = {};
137727
138930
  const { manifestPath } = projectStructure;
137728
138931
  const { packageJsonDir } = getDirs(projectStructure);
137729
138932
  const manifest = filterKeysForThisBrowser(JSON.parse(external_fs_.readFileSync(manifestPath, 'utf-8')), devOptions.browser);
137730
- const userExtensionOutputPath = asAbsolute(external_path_.isAbsolute(devOptions.output.path) ? devOptions.output.path : external_path_.resolve(packageJsonDir, devOptions.output.path));
137731
- const extensionsToLoad = computeExtensionsToLoad(__dirname, devOptions.mode, devOptions.browser, userExtensionOutputPath);
138933
+ const primaryExtensionOutputDir = asAbsolute(external_path_.isAbsolute(devOptions.output.path) ? devOptions.output.path : external_path_.resolve(packageJsonDir, devOptions.output.path));
138934
+ const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
138935
+ projectRoot: packageJsonDir,
138936
+ config: devOptions.extensions
138937
+ });
138938
+ const unpackedExtensionDirsToLoad = computeExtensionsToLoad(external_path_.resolve(__dirname, '..'), devOptions.mode, devOptions.browser, primaryExtensionOutputDir, companionUnpackedExtensionDirs);
137732
138939
  const debug = 'true' === process.env.EXTENSION_AUTHOR_MODE;
137733
138940
  if (debug) {
137734
138941
  console.log(webpack_lib_messages.Ry(devOptions.browser, devOptions.chromiumBinary, devOptions.geckoBinary));
137735
138942
  console.log(webpack_lib_messages.ZE(packageJsonDir));
137736
- console.log(webpack_lib_messages.$T(userExtensionOutputPath));
137737
- console.log(webpack_lib_messages.KH(extensionsToLoad));
138943
+ console.log(webpack_lib_messages.$T(primaryExtensionOutputDir));
138944
+ console.log(webpack_lib_messages.KH(unpackedExtensionDirsToLoad));
138945
+ if (void 0 !== devOptions.extensions && 0 === companionUnpackedExtensionDirs.length) console.warn(webpack_lib_messages.fH());
137738
138946
  }
137739
138947
  const darkDefaults = withDarkMode({
137740
138948
  browser: devOptions.browser,
@@ -137750,7 +138958,7 @@ var __webpack_exports__ = {};
137750
138958
  devtool: 'production' === (devOptions.mode || 'development') ? false : 3 === manifest.manifest_version ? 'cheap-source-map' : 'eval-cheap-source-map',
137751
138959
  output: {
137752
138960
  clean: devOptions.output.clean,
137753
- path: userExtensionOutputPath,
138961
+ path: primaryExtensionOutputDir,
137754
138962
  publicPath: '/',
137755
138963
  hotUpdateChunkFilename: 'hot/[id].[fullhash].hot-update.js',
137756
138964
  hotUpdateMainFilename: 'hot/[runtime].[fullhash].hot-update.json',
@@ -137837,7 +139045,7 @@ var __webpack_exports__ = {};
137837
139045
  browser: devOptions.browser
137838
139046
  }),
137839
139047
  new BrowsersPlugin({
137840
- extension: extensionsToLoad,
139048
+ extension: unpackedExtensionDirsToLoad,
137841
139049
  browser: devOptions.browser,
137842
139050
  noOpen: devOptions.noOpen,
137843
139051
  startingUrl: devOptions.startingUrl,
@@ -137897,22 +139105,11 @@ var __webpack_exports__ = {};
137897
139105
  runtimeChunk: false,
137898
139106
  moduleIds: 'deterministic',
137899
139107
  chunkIds: 'deterministic'
137900
- },
137901
- experiments: {
137902
- css: true,
137903
- asyncWebAssembly: true
137904
- }
137905
- };
137906
- }
137907
- function getBuildSummary(browser, info) {
137908
- const assets = (null == info ? void 0 : info.assets) || [];
137909
- return {
137910
- browser,
137911
- total_assets: assets.length,
137912
- total_bytes: assets.reduce((n, a)=>n + (a.size || 0), 0),
137913
- largest_asset_bytes: assets.reduce((m, a)=>Math.max(m, a.size || 0), 0),
137914
- warnings_count: ((null == info ? void 0 : info.warnings) || []).length,
137915
- errors_count: ((null == info ? void 0 : info.errors) || []).length
139108
+ },
139109
+ experiments: {
139110
+ css: true,
139111
+ asyncWebAssembly: true
139112
+ }
137916
139113
  };
137917
139114
  }
137918
139115
  async function extensionBuild(pathOrRemoteUrl, buildOptions) {
@@ -137972,26 +139169,7 @@ var __webpack_exports__ = {};
137972
139169
  }
137973
139170
  if (!(null == buildOptions ? void 0 : buildOptions.silent) && stats) console.log(webpack_lib_messages.LO(manifestDir, stats, browser));
137974
139171
  if (null == stats ? void 0 : stats.hasErrors()) {
137975
- try {
137976
- const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
137977
- const str = stats.toString({
137978
- colors: true,
137979
- all: false,
137980
- errors: true,
137981
- warnings: !!verbose
137982
- });
137983
- if (str) console.error(scrubBrand(str));
137984
- } catch {
137985
- try {
137986
- const str = stats.toString({
137987
- colors: true,
137988
- all: false,
137989
- errors: true,
137990
- warnings: true
137991
- });
137992
- if (str) console.error(str);
137993
- } catch {}
137994
- }
139172
+ handleStatsErrors(stats);
137995
139173
  if (!shouldExitOnError) return reject(new Error('Build failed with errors'));
137996
139174
  process.exit(1);
137997
139175
  } else {
@@ -138014,12 +139192,23 @@ var __webpack_exports__ = {};
138014
139192
  }
138015
139193
  }
138016
139194
  const dev_server_namespaceObject = require("@rspack/dev-server");
139195
+ function dev_server_messages_getLoggingPrefix(type) {
139196
+ const isAuthor = 'true' === process.env.EXTENSION_AUTHOR_MODE;
139197
+ if (isAuthor) {
139198
+ const base = 'error' === type ? 'ERROR Author says' : "\u25BA\u25BA\u25BA Author says";
139199
+ return external_pintor_default().brightMagenta(base);
139200
+ }
139201
+ if ('error' === type) return external_pintor_default().red('ERROR');
139202
+ if ('warn' === type) return external_pintor_default().brightYellow("\u25BA\u25BA\u25BA");
139203
+ if ('info' === type) return external_pintor_default().gray("\u25BA\u25BA\u25BA");
139204
+ return external_pintor_default().green("\u25BA\u25BA\u25BA");
139205
+ }
138017
139206
  function messages_ready(mode, browser) {
138018
139207
  const extensionOutput = 'firefox' === browser || 'gecko-based' === browser || 'edge' === browser ? 'Add-on' : 'Extension';
138019
139208
  const b = String(browser || '');
138020
139209
  const cap = b.charAt(0).toUpperCase() + b.slice(1);
138021
139210
  const pretty = external_pintor_default().green('ready for ' + mode);
138022
- return `${external_pintor_default().gray("\u25BA\u25BA\u25BA")} ${cap} ${extensionOutput} ${pretty}.`;
139211
+ return `${dev_server_messages_getLoggingPrefix('info')} ${cap} ${extensionOutput} ${pretty}.`;
138023
139212
  }
138024
139213
  function messages_portInUse(requestedPort, newPort) {
138025
139214
  return `Port: Requested port ${external_pintor_default().brightBlue(requestedPort.toString())} is in use; using ${external_pintor_default().brightBlue(newPort.toString())} instead.`;
@@ -138135,48 +139324,6 @@ var __webpack_exports__ = {};
138135
139324
  this.basePort = basePort;
138136
139325
  }
138137
139326
  }
138138
- function parseMilliseconds(value) {
138139
- if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : null;
138140
- if ('string' == typeof value) {
138141
- const parsed = parseInt(value, 10);
138142
- return !Number.isNaN(parsed) && parsed > 0 ? parsed : null;
138143
- }
138144
- return null;
138145
- }
138146
- function setupAutoExit(autoExitMsRaw, forceKillMsRaw, onCleanup) {
138147
- let autoExitTimer = null;
138148
- let forceKillTimer = null;
138149
- const autoExitMs = parseMilliseconds(autoExitMsRaw);
138150
- if (null === autoExitMs) return ()=>{};
138151
- try {
138152
- console.log(autoExitModeEnabled(autoExitMs));
138153
- } catch {}
138154
- autoExitTimer = setTimeout(async ()=>{
138155
- try {
138156
- console.log(autoExitTriggered(autoExitMs));
138157
- } catch {}
138158
- await onCleanup();
138159
- }, autoExitMs);
138160
- const parsedForceKillMs = parseMilliseconds(forceKillMsRaw);
138161
- const forceKillMs = null !== parsedForceKillMs && parsedForceKillMs > 0 ? parsedForceKillMs : autoExitMs + 4000;
138162
- forceKillTimer = setTimeout(()=>{
138163
- try {
138164
- console.log(autoExitForceKill(forceKillMs));
138165
- } catch {}
138166
- process.exit(0);
138167
- }, forceKillMs);
138168
- function cancelAutoExitTimers() {
138169
- if (null !== autoExitTimer) {
138170
- clearTimeout(autoExitTimer);
138171
- autoExitTimer = null;
138172
- }
138173
- if (null !== forceKillTimer) {
138174
- clearTimeout(forceKillTimer);
138175
- forceKillTimer = null;
138176
- }
138177
- }
138178
- return cancelAutoExitTimers;
138179
- }
138180
139327
  function hasDependency(projectPath, dependency) {
138181
139328
  const findNearestPackageJsonDirectory = (startPath)=>{
138182
139329
  let currentDirectory = startPath;
@@ -138209,48 +139356,10 @@ var __webpack_exports__ = {};
138209
139356
  ];
138210
139357
  return frameworks.some((fw)=>hasDependency(projectPath, fw));
138211
139358
  }
138212
- function closeAll(devServer, portManager) {
138213
- devServer.stop().then(async ()=>{
138214
- await portManager.terminateCurrentInstance();
138215
- setTimeout(()=>process.exit(), 500);
138216
- }).catch(async (error)=>{
138217
- console.log(messages_extensionJsRunnerError(error));
138218
- await portManager.terminateCurrentInstance();
138219
- setTimeout(()=>process.exit(1), 500);
138220
- });
139359
+ function sanitize_sanitize(obj) {
139360
+ return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
138221
139361
  }
138222
- async function dev_server_devServer(projectStructure, devOptions) {
138223
- const { manifestPath, packageJsonPath } = projectStructure;
138224
- const manifestDir = external_path_.dirname(manifestPath);
138225
- const packageJsonDir = external_path_.dirname(packageJsonPath);
138226
- const commandConfig = await loadCommandConfig(packageJsonDir, 'dev');
138227
- const browserConfig = await loadBrowserConfig(packageJsonDir, devOptions.browser);
138228
- const portManager = new PortManager(devOptions.browser, packageJsonDir, 8080);
138229
- const desiredPort = 'string' == typeof devOptions.port ? parseInt(devOptions.port, 10) : devOptions.port;
138230
- const portAllocation = await portManager.allocatePorts(devOptions.browser, packageJsonDir, desiredPort);
138231
- const currentInstance = portManager.getCurrentInstance();
138232
- if (!currentInstance) throw new Error('Failed to create instance');
138233
- const sanitize = (obj)=>Object.fromEntries(Object.entries(obj || {}).filter(([, v])=>void 0 !== v));
138234
- const safeBrowserConfig = sanitize(browserConfig);
138235
- const safeCommandConfig = sanitize(commandConfig);
138236
- const safeDevOptions = sanitize(devOptions);
138237
- const baseConfig = webpackConfig(projectStructure, {
138238
- ...safeBrowserConfig,
138239
- ...safeCommandConfig,
138240
- ...safeDevOptions,
138241
- browser: devOptions.browser,
138242
- mode: 'development',
138243
- instanceId: currentInstance.instanceId,
138244
- port: portAllocation.port,
138245
- output: {
138246
- clean: false,
138247
- path: external_path_.join(packageJsonDir, 'dist', devOptions.browser)
138248
- }
138249
- });
138250
- const customWebpackConfig = await loadCustomWebpackConfig(manifestDir);
138251
- const finalConfig = customWebpackConfig(baseConfig);
138252
- const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(finalConfig, {});
138253
- const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
139362
+ function setupCompilerHooks(compiler, port) {
138254
139363
  const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
138255
139364
  let reportedNoEntries = false;
138256
139365
  compiler.hooks.invalid.tap('extension.js:invalid', ()=>{
@@ -138292,8 +139401,7 @@ var __webpack_exports__ = {};
138292
139401
  const hasEntrypoints = entrypoints && Object.keys(entrypoints).length > 0;
138293
139402
  if (!hasAssets && !hasEntrypoints) {
138294
139403
  reportedNoEntries = true;
138295
- const hookPort = portAllocation.port;
138296
- console.warn(noEntrypointsDetected(hookPort));
139404
+ console.warn(noEntrypointsDetected(port));
138297
139405
  }
138298
139406
  }
138299
139407
  } catch (error) {
@@ -138306,6 +139414,121 @@ var __webpack_exports__ = {};
138306
139414
  if (str) console.error(scrubBrand(str));
138307
139415
  }
138308
139416
  });
139417
+ }
139418
+ function parseMilliseconds(value) {
139419
+ if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : null;
139420
+ if ('string' == typeof value) {
139421
+ const parsed = parseInt(value, 10);
139422
+ return !Number.isNaN(parsed) && parsed > 0 ? parsed : null;
139423
+ }
139424
+ return null;
139425
+ }
139426
+ function setupAutoExit(autoExitMsRaw, forceKillMsRaw, onCleanup) {
139427
+ let autoExitTimer = null;
139428
+ let forceKillTimer = null;
139429
+ const autoExitMs = parseMilliseconds(autoExitMsRaw);
139430
+ if (null === autoExitMs) return ()=>{};
139431
+ try {
139432
+ console.log(autoExitModeEnabled(autoExitMs));
139433
+ } catch {}
139434
+ autoExitTimer = setTimeout(async ()=>{
139435
+ try {
139436
+ console.log(autoExitTriggered(autoExitMs));
139437
+ } catch {}
139438
+ await onCleanup();
139439
+ }, autoExitMs);
139440
+ const parsedForceKillMs = parseMilliseconds(forceKillMsRaw);
139441
+ const forceKillMs = null !== parsedForceKillMs && parsedForceKillMs > 0 ? parsedForceKillMs : autoExitMs + 4000;
139442
+ forceKillTimer = setTimeout(()=>{
139443
+ try {
139444
+ console.log(autoExitForceKill(forceKillMs));
139445
+ } catch {}
139446
+ process.exit(0);
139447
+ }, forceKillMs);
139448
+ function cancelAutoExitTimers() {
139449
+ if (null !== autoExitTimer) {
139450
+ clearTimeout(autoExitTimer);
139451
+ autoExitTimer = null;
139452
+ }
139453
+ if (null !== forceKillTimer) {
139454
+ clearTimeout(forceKillTimer);
139455
+ forceKillTimer = null;
139456
+ }
139457
+ }
139458
+ return cancelAutoExitTimers;
139459
+ }
139460
+ function closeAll(devServer, portManager) {
139461
+ return devServer.stop().then(async ()=>{
139462
+ await portManager.terminateCurrentInstance();
139463
+ setTimeout(()=>process.exit(), 500);
139464
+ }).catch(async (error)=>{
139465
+ console.log(messages_extensionJsRunnerError(error));
139466
+ await portManager.terminateCurrentInstance();
139467
+ setTimeout(()=>process.exit(1), 500);
139468
+ });
139469
+ }
139470
+ function setupCleanupHandlers(devServer, portManager) {
139471
+ const cleanup = async ()=>{
139472
+ try {
139473
+ await closeAll(devServer, portManager);
139474
+ } catch (error) {
139475
+ console.error('[Extension.js Runner] Error during cleanup.', error);
139476
+ process.exit(1);
139477
+ }
139478
+ };
139479
+ process.on('uncaughtException', async (error)=>{
139480
+ console.error('[Extension.js Runner] Uncaught exception.', error);
139481
+ await cleanup();
139482
+ });
139483
+ process.on('unhandledRejection', async (reason, promise)=>{
139484
+ console.error('[Extension.js Runner] Unhandled rejection.', promise, reason);
139485
+ await cleanup();
139486
+ });
139487
+ const cancelAutoExit = setupAutoExit(process.env.EXTENSION_AUTO_EXIT_MS, process.env.EXTENSION_FORCE_KILL_MS, cleanup);
139488
+ const cancelAndCleanup = async ()=>{
139489
+ try {
139490
+ cancelAutoExit();
139491
+ } catch {}
139492
+ await cleanup();
139493
+ };
139494
+ process.on('ERROR', cancelAndCleanup);
139495
+ process.on('SIGINT', cancelAndCleanup);
139496
+ process.on('SIGTERM', cancelAndCleanup);
139497
+ process.on('SIGHUP', cancelAndCleanup);
139498
+ return cancelAutoExit;
139499
+ }
139500
+ async function dev_server_devServer(projectStructure, devOptions) {
139501
+ const { manifestPath, packageJsonPath } = projectStructure;
139502
+ const manifestDir = external_path_.dirname(manifestPath);
139503
+ const packageJsonDir = external_path_.dirname(packageJsonPath);
139504
+ const commandConfig = await loadCommandConfig(packageJsonDir, 'dev');
139505
+ const browserConfig = await loadBrowserConfig(packageJsonDir, devOptions.browser);
139506
+ const portManager = new PortManager(devOptions.browser, packageJsonDir, 8080);
139507
+ const desiredPort = 'string' == typeof devOptions.port ? parseInt(devOptions.port, 10) : devOptions.port;
139508
+ const portAllocation = await portManager.allocatePorts(devOptions.browser, packageJsonDir, desiredPort);
139509
+ const currentInstance = portManager.getCurrentInstance();
139510
+ if (!currentInstance) throw new Error('Failed to create instance');
139511
+ const safeBrowserConfig = sanitize_sanitize(browserConfig);
139512
+ const safeCommandConfig = sanitize_sanitize(commandConfig);
139513
+ const safeDevOptions = sanitize_sanitize(devOptions);
139514
+ const baseConfig = webpackConfig(projectStructure, {
139515
+ ...safeBrowserConfig,
139516
+ ...safeCommandConfig,
139517
+ ...safeDevOptions,
139518
+ browser: devOptions.browser,
139519
+ mode: 'development',
139520
+ instanceId: currentInstance.instanceId,
139521
+ port: portAllocation.port,
139522
+ output: {
139523
+ clean: false,
139524
+ path: external_path_.join(packageJsonDir, 'dist', devOptions.browser)
139525
+ }
139526
+ });
139527
+ const customWebpackConfig = await loadCustomWebpackConfig(manifestDir);
139528
+ const finalConfig = customWebpackConfig(baseConfig);
139529
+ const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(finalConfig, {});
139530
+ const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
139531
+ setupCompilerHooks(compiler, portAllocation.port);
138309
139532
  const port = portAllocation.port;
138310
139533
  if (void 0 !== devOptions.port && devOptions.port !== port) console.log(messages_portInUse(devOptions.port, port));
138311
139534
  const serverConfig = {
@@ -138347,7 +139570,8 @@ var __webpack_exports__ = {};
138347
139570
  'Access-Control-Allow-Origin': '*'
138348
139571
  },
138349
139572
  port,
138350
- hot: true
139573
+ hot: 'only',
139574
+ liveReload: true
138351
139575
  };
138352
139576
  const devServer = new dev_server_namespaceObject.RspackDevServer(serverConfig, compiler);
138353
139577
  const START_TIMEOUT_MS = parseInt(String(process.env.EXTENSION_START_TIMEOUT_MS || '30000'), 10);
@@ -138364,37 +139588,7 @@ var __webpack_exports__ = {};
138364
139588
  console.log(messages_extensionJsRunnerError(error));
138365
139589
  process.exit(1);
138366
139590
  }
138367
- const cleanup = async ()=>{
138368
- try {
138369
- await closeAll(devServer, portManager);
138370
- } catch (error) {
138371
- console.error('[Extension.js Runner] Error during cleanup.', error);
138372
- process.exit(1);
138373
- }
138374
- };
138375
- process.on('ERROR', cleanup);
138376
- process.on('SIGINT', cleanup);
138377
- process.on('SIGTERM', cleanup);
138378
- process.on('SIGHUP', cleanup);
138379
- process.on('uncaughtException', async (error)=>{
138380
- console.error('[Extension.js Runner] Uncaught exception.', error);
138381
- await cleanup();
138382
- });
138383
- process.on('unhandledRejection', async (reason, promise)=>{
138384
- console.error('[Extension.js Runner] Unhandled rejection.', promise, reason);
138385
- await cleanup();
138386
- });
138387
- const cancelAutoExit = setupAutoExit(process.env.EXTENSION_AUTO_EXIT_MS, process.env.EXTENSION_FORCE_KILL_MS, cleanup);
138388
- const cancelAndCleanup = async ()=>{
138389
- try {
138390
- cancelAutoExit();
138391
- } catch {}
138392
- await cleanup();
138393
- };
138394
- process.on('ERROR', cancelAndCleanup);
138395
- process.on('SIGINT', cancelAndCleanup);
138396
- process.on('SIGTERM', cancelAndCleanup);
138397
- process.on('SIGHUP', cancelAndCleanup);
139591
+ setupCleanupHandlers(devServer, portManager);
138398
139592
  }
138399
139593
  const promises_namespaceObject = require("fs/promises");
138400
139594
  async function generateExtensionTypes(manifestDir, packageJsonDir) {
@@ -138456,6 +139650,25 @@ var __webpack_exports__ = {};
138456
139650
  process.exit(1);
138457
139651
  }
138458
139652
  }
139653
+ function createShutdownHandler(compiler) {
139654
+ let isShuttingDown = false;
139655
+ const shutdown = (code = 0)=>{
139656
+ if (isShuttingDown) return;
139657
+ isShuttingDown = true;
139658
+ try {
139659
+ compiler.close(()=>{
139660
+ process.exit(code);
139661
+ });
139662
+ setTimeout(()=>process.exit(code), 2000);
139663
+ } catch {
139664
+ process.exit(code);
139665
+ }
139666
+ };
139667
+ process.on('SIGINT', ()=>shutdown(0));
139668
+ process.on('SIGTERM', ()=>shutdown(0));
139669
+ process.on('SIGHUP', ()=>shutdown(0));
139670
+ return shutdown;
139671
+ }
138459
139672
  async function extensionPreview(pathOrRemoteUrl, previewOptions) {
138460
139673
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
138461
139674
  const debug = 'true' === process.env.EXTENSION_AUTHOR_MODE;
@@ -138474,28 +139687,19 @@ var __webpack_exports__ = {};
138474
139687
  } catch {}
138475
139688
  try {
138476
139689
  var _baseConfig_plugins;
138477
- const commandConfig = await loadCommandConfig(manifestDir, 'preview');
138478
- const browserConfig = await loadBrowserConfig(manifestDir, browser);
139690
+ const commandConfig = await loadCommandConfig(packageJsonDir, 'preview');
139691
+ const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
138479
139692
  console.log(webpack_lib_messages.WW(browser));
139693
+ const safeBrowserConfig = sanitize_sanitize(browserConfig);
139694
+ const safeCommandConfig = sanitize_sanitize(commandConfig);
139695
+ const safePreviewOptions = sanitize_sanitize(previewOptions);
138480
139696
  const baseConfig = webpackConfig(projectStructure, {
138481
- ...browserConfig,
138482
- ...commandConfig,
139697
+ ...safeBrowserConfig,
139698
+ ...safeCommandConfig,
139699
+ ...safePreviewOptions,
138483
139700
  mode: 'production',
138484
- profile: previewOptions.profile,
138485
139701
  browser,
138486
- chromiumBinary: previewOptions.chromiumBinary,
138487
- geckoBinary: previewOptions.geckoBinary || previewOptions.firefoxBinary,
138488
- startingUrl: previewOptions.startingUrl,
138489
- port: previewOptions.port,
138490
- source: previewOptions.source,
138491
- watchSource: previewOptions.watchSource,
138492
- logLevel: previewOptions.logLevel,
138493
- logContexts: previewOptions.logContexts,
138494
- logFormat: previewOptions.logFormat,
138495
- logTimestamps: previewOptions.logTimestamps,
138496
- logColor: previewOptions.logColor,
138497
- logUrl: previewOptions.logUrl,
138498
- logTab: previewOptions.logTab,
139702
+ geckoBinary: safePreviewOptions.geckoBinary || safePreviewOptions.firefoxBinary,
138499
139703
  output: {
138500
139704
  clean: false,
138501
139705
  path: outputPath
@@ -138509,54 +139713,15 @@ var __webpack_exports__ = {};
138509
139713
  });
138510
139714
  const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(userConfig);
138511
139715
  const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
138512
- let isShuttingDown = false;
138513
- const shutdown = (code = 0)=>{
138514
- if (isShuttingDown) return;
138515
- isShuttingDown = true;
138516
- try {
138517
- compiler.close(()=>{
138518
- process.exit(code);
138519
- });
138520
- setTimeout(()=>process.exit(code), 2000);
138521
- } catch {
138522
- process.exit(code);
138523
- }
138524
- };
138525
- process.on('SIGINT', ()=>shutdown(0));
138526
- process.on('SIGTERM', ()=>shutdown(0));
138527
- process.on('SIGHUP', ()=>shutdown(0));
139716
+ const shutdown = createShutdownHandler(compiler);
138528
139717
  compiler.run((err, stats)=>{
138529
139718
  if (err) {
138530
139719
  console.error(err.stack || err);
138531
139720
  shutdown(1);
138532
139721
  }
138533
139722
  if (null == stats ? void 0 : stats.hasErrors()) {
138534
- try {
138535
- var _stats_toString;
138536
- const verbose = '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
138537
- const str = null == stats ? void 0 : null == (_stats_toString = stats.toString) ? void 0 : _stats_toString.call(stats, {
138538
- colors: true,
138539
- all: false,
138540
- errors: true,
138541
- warnings: !!verbose
138542
- });
138543
- if (str) console.error(scrubBrand(str));
138544
- } catch {
138545
- try {
138546
- var _stats_toString1;
138547
- const str = null == stats ? void 0 : null == (_stats_toString1 = stats.toString) ? void 0 : _stats_toString1.call(stats, {
138548
- colors: true,
138549
- all: false,
138550
- errors: true,
138551
- warnings: true
138552
- });
138553
- if (str) console.error(str);
138554
- } catch {}
138555
- }
139723
+ handleStatsErrors(stats);
138556
139724
  shutdown(1);
138557
- } else {
138558
- console.log('');
138559
- console.log(webpack_lib_messages.km(manifestDir));
138560
139725
  }
138561
139726
  });
138562
139727
  } catch (error) {
@@ -138570,8 +139735,8 @@ var __webpack_exports__ = {};
138570
139735
  const debug = 'true' === process.env.EXTENSION_AUTHOR_MODE;
138571
139736
  const browser = normalizeBrowser(startOptions.browser || 'chrome', startOptions.chromiumBinary, startOptions.geckoBinary || startOptions.firefoxBinary);
138572
139737
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
138573
- const commandConfig = await loadCommandConfig(manifestDir, 'start');
138574
- const browserConfig = await loadBrowserConfig(manifestDir, browser);
139738
+ const commandConfig = await loadCommandConfig(packageJsonDir, 'start');
139739
+ const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
138575
139740
  const distPath = getDistPath(packageJsonDir, browser);
138576
139741
  if (debug) {
138577
139742
  console.log(webpack_lib_messages.OF(manifestDir, packageJsonDir));