extension-develop 4.1.31 → 4.1.32

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 (88) hide show
  1. package/README.md +2 -0
  2. package/dist/105~0.mjs +1 -1
  3. package/dist/177~0.mjs +87 -19
  4. package/dist/273~0.mjs +13 -3
  5. package/dist/363~0.mjs +1874 -0
  6. package/dist/{896~0.mjs → 469~0.mjs} +116 -586
  7. package/dist/519~0.mjs +21 -8
  8. package/dist/616~0.mjs +1 -1
  9. package/dist/771~0.mjs +103 -0
  10. package/dist/832~0.mjs +229 -463
  11. package/dist/840~0.mjs +1189 -54
  12. package/dist/846~0.mjs +453 -0
  13. package/dist/852~0.mjs +8 -6
  14. package/dist/bridge.mjs +3 -2
  15. package/dist/command-preview.d.ts +1 -0
  16. package/dist/contract/codes.json +39 -29
  17. package/dist/contract/envelope.schema.json +16 -0
  18. package/dist/contract/golden.build.compile.json +20 -3
  19. package/dist/contract/golden.eval.csp-blocks-eval.page.json +15 -0
  20. package/dist/css-parse-guard-loader.mjs +3 -1
  21. package/dist/dead-css-url-loader.mjs +129 -13
  22. package/dist/dev-server/cleanup.d.ts +1 -1
  23. package/dist/dev-server/lifecycle-stream.d.ts +14 -3
  24. package/dist/dev-server/session-start-prune.d.ts +13 -0
  25. package/dist/dev-server~0.mjs +91 -14
  26. package/dist/ensure-hmr-for-scripts.js +4 -8
  27. package/dist/ensure-hmr-for-scripts.mjs +4 -8
  28. package/dist/extension-js-devtools/build-stamp.json +2 -2
  29. package/dist/extension-js-theme/build-stamp.json +2 -2
  30. package/dist/feature-scripts-content-script-wrapper.js +7 -4
  31. package/dist/feature-scripts-content-script-wrapper.mjs +7 -4
  32. package/dist/lib/build-summary.d.ts +4 -1
  33. package/dist/lib/coded-warnings.d.ts +3 -0
  34. package/dist/lib/compilation-diagnostics.d.ts +23 -0
  35. package/dist/lib/config-loader.d.ts +2 -2
  36. package/dist/lib/config-resolved-plugin.d.ts +3 -2
  37. package/dist/lib/corepack-registry.d.ts +3 -0
  38. package/dist/lib/diagnostic-code.d.ts +6 -0
  39. package/dist/lib/merge-options.d.ts +1 -0
  40. package/dist/lib/messages.d.ts +4 -1
  41. package/dist/lib/messaging.d.ts +12 -4
  42. package/dist/lib/output-files.d.ts +11 -0
  43. package/dist/lib/package-manager.d.ts +2 -2
  44. package/dist/module.mjs +2 -1
  45. package/dist/plugin-browsers/index.d.ts +1 -0
  46. package/dist/plugin-compatibility/compatibility-lib/free-browser-references.d.ts +9 -0
  47. package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -1
  48. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +4 -2
  49. package/dist/plugin-css/css-lib/line-rewrite-source-map.d.ts +8 -0
  50. package/dist/plugin-css/dead-css-url-loader.d.ts +0 -2
  51. package/dist/plugin-css/public-css-url-loader.d.ts +8 -3
  52. package/dist/plugin-playwright/index.d.ts +9 -4
  53. package/dist/plugin-reload/classify-reload.d.ts +2 -0
  54. package/dist/plugin-reload/messages.d.ts +1 -0
  55. package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +4 -0
  56. package/dist/plugin-reload/steps/prune-unreachable-chunks.d.ts +5 -0
  57. package/dist/plugin-special-folders/messages.d.ts +1 -1
  58. package/dist/plugin-special-folders/prune-removed-public-files.d.ts +7 -0
  59. package/dist/plugin-static-assets/check-namespace-imports.d.ts +4 -0
  60. package/dist/plugin-static-assets/static-assets-lib/asset-output-name.d.ts +8 -0
  61. package/dist/plugin-static-assets/static-assets-lib/messages.d.ts +1 -0
  62. package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +2 -1
  63. package/dist/plugin-web-extension/feature-icons/messages.d.ts +1 -4
  64. package/dist/plugin-web-extension/feature-locales/get-locales.d.ts +2 -0
  65. package/dist/plugin-web-extension/feature-locales/messages.d.ts +3 -1
  66. package/dist/plugin-web-extension/feature-locales/validation.d.ts +1 -0
  67. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -0
  68. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/content_scripts.d.ts +1 -0
  69. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +1 -0
  70. package/dist/plugin-web-extension/feature-scripts/index.d.ts +2 -0
  71. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +4 -3
  72. package/dist/plugin-web-extension/feature-scripts/scripts-lib/load-time-constants.d.ts +11 -0
  73. package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +4 -0
  74. package/dist/plugin-web-extension/feature-scripts/steps/warn-missing-build-constants.d.ts +24 -0
  75. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/declared-pages.d.ts +2 -0
  76. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +5 -0
  77. package/dist/plugin-web-extension/index.d.ts +1 -0
  78. package/dist/plugin-web-extension/shared/classic-concat.d.ts +1 -0
  79. package/dist/plugin-web-extension/shared/compilation-issues.d.ts +1 -1
  80. package/dist/preprocessor-passthrough-loader.mjs +3 -1
  81. package/dist/public-css-url-loader.mjs +1 -1
  82. package/dist/rspack-config~0.mjs +4925 -5885
  83. package/dist/stats-handler~0.mjs +12 -4
  84. package/dist/types.d.ts +19 -2
  85. package/dist/zip~0.mjs +20 -2
  86. package/package.json +4 -4
  87. package/dist/300~0.mjs +0 -394
  88. package/dist/747~0.mjs +0 -90
@@ -6,15 +6,18 @@ import { rspack } from "@rspack/core";
6
6
  import { RspackDevServer } from "@rspack/dev-server";
7
7
  import { merge } from "webpack-merge";
8
8
  import { WebSocket, WebSocketServer } from "ws";
9
- import { runnerCleanupError, autoExitForceKill, attachLifecycleStream, devServerHostRefused, extensionJsRunnerError, portInUse, devServerStartTimeout, autoExitTriggered, codedError, runnerUncaughtException, controlBridgeUnavailable, shouldWarnPortConflict, devServerRestarting, asAbsolute, ensureSessionStateInProjectGitignore, runnerUnhandledRejection, actionsPath, autoExitModeEnabled, emulatorViewerUrl, logsPath, humanLine, controlPortFilePath, legacyControlPortFilePath, ensureSessionArtifactsIgnoreFile, getDistPath, createLifecycleStream } from "./896~0.mjs";
9
+ import { debugLine, isDebug, CODES, humanLine } from "./852~0.mjs";
10
+ import { runnerCleanupError, autoExitForceKill, devServerHostRefused, sanitize, extensionJsRunnerError, portInUse, devServerStartTimeout, autoExitTriggered, DEV_COMMAND_DEFAULTS, runnerUncaughtException, controlBridgeUnavailable, shouldWarnPortConflict, devServerRestarting, mergeOptionLayers, runnerUnhandledRejection, createPlaywrightMetadataWriter, autoExitModeEnabled, emulatorViewerUrl, detectLiveDevSessionOwner, getSessionRunId, resolveCompanionExtensionsConfig, getSpecialFoldersDataForProjectRoot } from "./832~0.mjs";
10
11
  import { CONTROL_WS_PATH, writePersistedControlPort, writeControlToken, clearControlToken, readPersistedControlPort } from "./616~0.mjs";
11
12
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./731~0.mjs";
12
- import { isDebug, CODES } from "./852~0.mjs";
13
- import { createPlaywrightMetadataWriter, loadCommandConfig, getSessionRunId, sanitize, loadProjectConfigDefaults, DEV_COMMAND_DEFAULTS, loadCustomConfig, mergeOptionLayers, loadBrowserConfig, resolveCompanionExtensionsConfig, loadConfigResolvedHook, getSpecialFoldersDataForProjectRoot } from "./832~0.mjs";
13
+ import { getDistPath, codedError, anotherDevSessionRefused, asAbsolute } from "./469~0.mjs";
14
14
  import { publicFolderOrDefault } from "./105~0.mjs";
15
- import { setupNoBrowserBannerOnFirstDone, DevSessionRestartScheduler, resolveConnectableHost, default as webpackConfig, bindDevSessionRestart, unbindDevSessionRestart, setupCompilerLifecycleHooks } from "./rspack-config~0.mjs";
15
+ import { loadCommandConfig, loadBrowserConfig, loadConfigResolvedHook, loadProjectConfigDefaults, loadCustomConfig } from "./846~0.mjs";
16
+ import { ensureSessionStateInProjectGitignore, logsPath, actionsPath, controlPortFilePath, readyContractPath, ensureSessionArtifactsIgnoreFile, legacyControlPortFilePath } from "./771~0.mjs";
17
+ import { setupNoBrowserBannerOnFirstDone, resolveConnectableHost, default as webpackConfig, setupCompilerLifecycleHooks } from "./rspack-config~0.mjs";
16
18
  import { isGeckoBasedBrowser, isEmulatorBrowser, isWebkitBasedBrowser } from "./937~0.mjs";
17
- import { buildSourceFeatureIndex, classifyReloadFromSources, applySplitChunksGuard, ConfigResolvedPlugin, readContentScriptCount, createChangedSourcesTracker, dispatchReload } from "./840~0.mjs";
19
+ import { bindDevSessionRestart, DevSessionRestartScheduler, unbindDevSessionRestart } from "./363~0.mjs";
20
+ import { classifyReloadFromSources, attachLifecycleStream, readContentScriptCount, ConfigResolvedPlugin, createChangedSourcesTracker, buildSourceFeatureIndex, applySplitChunksGuard, createLifecycleStream, dispatchReload } from "./840~0.mjs";
18
21
  import { rememberSpecialFoldersConfig } from "./471~0.mjs";
19
22
  import * as __rspack_external_node_os_4f3c9d58 from "node:os";
20
23
  import * as __rspack_external_node_path_806ed179 from "node:path";
@@ -81,7 +84,7 @@ function closeAll(devServer, portManager) {
81
84
  setTimeout(()=>process.exit(1), 500);
82
85
  });
83
86
  }
84
- function setupCleanupHandlers(devServer, portManager) {
87
+ function setupCleanupHandlers(devServer, portManager, onSignal) {
85
88
  let isShuttingDown = false;
86
89
  const cleanup = async ()=>{
87
90
  if (isShuttingDown) return;
@@ -102,10 +105,11 @@ function setupCleanupHandlers(devServer, portManager) {
102
105
  console.error(runnerUnhandledRejection(reason));
103
106
  });
104
107
  const cancelAutoExit = setupAutoExit(process.env.EXTENSION_AUTO_EXIT_MS, process.env.EXTENSION_FORCE_KILL_MS, cleanup);
105
- const cancelAndCleanup = async ()=>{
108
+ const cancelAndCleanup = async (signal)=>{
106
109
  try {
107
110
  cancelAutoExit();
108
111
  } catch {}
112
+ if (!isShuttingDown) onSignal?.(signal);
109
113
  await cleanup();
110
114
  };
111
115
  process.on('SIGINT', cancelAndCleanup);
@@ -783,7 +787,7 @@ class BridgeBroker {
783
787
  if ('producer' === hello.role) {
784
788
  this.lastStaleHelloAt = this.now();
785
789
  if (this.allowStaleProducerResync()) {
786
- if (this.authorMode) console.log(`[control-bridge] stale producer (instance ${hello.instanceId}) → full-reload resync`);
790
+ if (this.authorMode) debugLine(`[control-bridge] stale producer (instance ${hello.instanceId}) → full-reload resync`);
787
791
  conn.send({
788
792
  type: 'reload',
789
793
  reloadType: 'full',
@@ -1420,6 +1424,60 @@ class PortManager {
1420
1424
  await this.releaseReservedPort();
1421
1425
  }
1422
1426
  }
1427
+ function removeLeftovers(folder, root, emitted) {
1428
+ for (const entry of __rspack_external_node_fs_1b05aee1.readdirSync(folder, {
1429
+ withFileTypes: true
1430
+ })){
1431
+ const absolute = __rspack_external_node_path_806ed179.join(folder, entry.name);
1432
+ if (entry.isDirectory()) {
1433
+ removeLeftovers(absolute, root, emitted);
1434
+ try {
1435
+ if (0 === __rspack_external_node_fs_1b05aee1.readdirSync(absolute).length) __rspack_external_node_fs_1b05aee1.rmdirSync(absolute);
1436
+ } catch {}
1437
+ continue;
1438
+ }
1439
+ const name = __rspack_external_node_path_806ed179.relative(root, absolute).replace(/\\/g, '/');
1440
+ if (!emitted.has(name)) try {
1441
+ __rspack_external_node_fs_1b05aee1.rmSync(absolute, {
1442
+ force: true
1443
+ });
1444
+ } catch {}
1445
+ }
1446
+ }
1447
+ class PruneSessionStartLeftovers {
1448
+ static name = 'dev-server:prune-session-start';
1449
+ distPath;
1450
+ constructor(distPath){
1451
+ this.distPath = distPath;
1452
+ }
1453
+ apply(compiler) {
1454
+ let pruned = false;
1455
+ compiler.hooks.done.tap(PruneSessionStartLeftovers.name, (stats)=>{
1456
+ if (pruned || stats.compilation.errors.length > 0) return;
1457
+ const outputPath = compiler.options.output?.path;
1458
+ if (!outputPath) return;
1459
+ const root = __rspack_external_node_path_806ed179.resolve(String(compiler.options.context || ''), outputPath);
1460
+ if (root !== __rspack_external_node_path_806ed179.resolve(this.distPath)) return;
1461
+ pruned = true;
1462
+ const emitted = new Set();
1463
+ for (const asset of stats.compilation.getAssets())emitted.add(String(asset.name || '').replace(/\\/g, '/'));
1464
+ try {
1465
+ removeLeftovers(root, root, emitted);
1466
+ } catch {}
1467
+ });
1468
+ }
1469
+ }
1470
+ function withSessionStartPrune(config, session) {
1471
+ if (session.isRestart) return config;
1472
+ if (detectLiveDevSessionOwner(session.readyPath)) return config;
1473
+ return {
1474
+ ...config,
1475
+ plugins: [
1476
+ new PruneSessionStartLeftovers(session.distPath),
1477
+ ...config.plugins || []
1478
+ ]
1479
+ };
1480
+ }
1423
1481
  function shouldWriteAssetToDisk(filePath) {
1424
1482
  if (/(?:^|[/\\])\.\.(?:[/\\]|$)/.test(filePath)) return false;
1425
1483
  return !/(?:^|[/\\])manifest\.json$/i.test(filePath);
@@ -1624,6 +1682,11 @@ async function dev_server_devServer(projectStructure, devOptions) {
1624
1682
  const portAllocation = await portManager.allocatePorts(desiredPort, devServerHost);
1625
1683
  const currentInstance = portManager.getCurrentInstance();
1626
1684
  if (!currentInstance) throw new Error('Failed to create instance');
1685
+ const liveOwner = detectLiveDevSessionOwner(readyContractPath(packageJsonDir, String(devOptions.browser || 'chromium')));
1686
+ if (liveOwner) {
1687
+ await portManager.terminateCurrentInstance();
1688
+ throw codedError(CODES.E_SESSION_EXISTS, anotherDevSessionRefused(String(devOptions.browser || 'chromium'), liveOwner.pid, liveOwner.port ?? null));
1689
+ }
1627
1690
  const port = portAllocation.port;
1628
1691
  const connectableHost = resolveConnectableHost(devServerHost, extendedOptions.publicHost);
1629
1692
  const devServerWebSocketURL = {
@@ -1811,8 +1874,10 @@ async function dev_server_devServer(projectStructure, devOptions) {
1811
1874
  browser: browserName,
1812
1875
  distPath: primaryDistPath,
1813
1876
  readyPath: metadata.readyPath,
1814
- eventsPath: metadata.eventsPath
1877
+ eventsPath: metadata.eventsPath,
1878
+ noBrowser: Boolean(devOptions.noBrowser)
1815
1879
  });
1880
+ lifecycle.emitOnExit();
1816
1881
  if (shouldWarnPortConflict(devOptions.port, port)) humanLine(portInUse(Number(devOptions.port), port));
1817
1882
  let activeCompiler = null;
1818
1883
  const publicFolder = publicFolderOrDefault(manifestPath, packageJsonDir);
@@ -1871,19 +1936,29 @@ async function dev_server_devServer(projectStructure, devOptions) {
1871
1936
  },
1872
1937
  port,
1873
1938
  hot: true,
1874
- liveReload: true
1939
+ liveReload: true,
1940
+ setupExitSignals: false
1875
1941
  };
1876
1942
  const START_TIMEOUT_MS = parseInt(String(process.env.EXTENSION_START_TIMEOUT_MS || '30000'), 10);
1877
1943
  async function createCompilerAndServer(opts) {
1878
1944
  const baseConfig = webpackConfig(projectStructure, webpackConfigOptions);
1879
- const customWebpackConfig = await loadCustomConfig(packageJsonDir);
1945
+ const hookContext = {
1946
+ browser: webpackConfigOptions.browser,
1947
+ mode: webpackConfigOptions.mode,
1948
+ command: webpackConfigOptions.metadataCommand
1949
+ };
1950
+ const customWebpackConfig = await loadCustomConfig(packageJsonDir, hookContext);
1880
1951
  const compilerConfig = applySplitChunksGuard(merge(customWebpackConfig(baseConfig), {}));
1881
1952
  const configResolved = await loadConfigResolvedHook(packageJsonDir);
1882
1953
  if (configResolved) compilerConfig.plugins = [
1883
1954
  ...compilerConfig.plugins || [],
1884
- new ConfigResolvedPlugin(configResolved)
1955
+ new ConfigResolvedPlugin(configResolved, hookContext)
1885
1956
  ];
1886
- const compiler = rspack(compilerConfig);
1957
+ const compiler = rspack(withSessionStartPrune(compilerConfig, {
1958
+ isRestart: opts.isRestart,
1959
+ distPath: primaryDistPath,
1960
+ readyPath: metadata.readyPath
1961
+ }));
1887
1962
  activeCompiler = compiler;
1888
1963
  const uninstallManifestGuard = installManifestDiskWriteGuard(manifestOutputPath);
1889
1964
  const releaseOutputFsGuard = suppressManifestOutputWrites(compiler, manifestOutputPath);
@@ -2042,6 +2117,8 @@ async function dev_server_devServer(projectStructure, devOptions) {
2042
2117
  reason: 'string' == typeof ready.browserLaunchFailedReason ? ready.browserLaunchFailedReason : void 0
2043
2118
  });
2044
2119
  });
2045
- setupCleanupHandlers(()=>currentServer, portManager);
2120
+ setupCleanupHandlers(()=>currentServer, portManager, (signal)=>{
2121
+ lifecycle.interrupted(signal);
2122
+ });
2046
2123
  }
2047
2124
  export { dev_server_devServer as devServer };
@@ -3,6 +3,7 @@ import { init, parse } from "es-module-lexer";
3
3
  import { validate } from "schema-utils";
4
4
  import { returnWithMap, adjustLoaderSourceMap, inputOrIdentityMap } from "./895~0.mjs";
5
5
  import { EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./640~0.mjs";
6
+ import { debugLine } from "./852~0.mjs";
6
7
  const schema = {
7
8
  type: 'object',
8
9
  properties: {
@@ -45,19 +46,14 @@ function ensureHMRForScripts(source, inputSourceMap) {
45
46
  throw error;
46
47
  }
47
48
  if (moduleLayer === EXTENSIONJS_CONTENT_SCRIPT_LAYER) {
48
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip layer resource=${resourcePath} layer=${moduleLayer}`);
49
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] skip layer resource=${resourcePath} layer=${moduleLayer}`);
49
50
  return source;
50
51
  }
51
52
  if (options?.frameworkOwnsRefresh === true) {
52
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip framework-refresh resource=${resourcePath}`);
53
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] skip framework-refresh resource=${resourcePath}`);
53
54
  return source;
54
55
  }
55
- const issuer = this?._module?.issuer;
56
- if (issuer) {
57
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip child resource=${resourcePath}`);
58
- return source;
59
- }
60
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] inject resource=${resourcePath} manifest=${String(options?.manifestPath || '')} layer=${moduleLayer || '<none>'}`);
56
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] inject resource=${resourcePath} manifest=${String(options?.manifestPath || '')} layer=${moduleLayer || '<none>'}`);
61
57
  const moduleType = String(this?._module?.type || '');
62
58
  if ("javascript/dynamic" === moduleType) {
63
59
  const prelude = buildReloadCode('module.hot');
@@ -3,6 +3,7 @@ import { init, parse } from "es-module-lexer";
3
3
  import { validate } from "schema-utils";
4
4
  import { returnWithMap, adjustLoaderSourceMap, inputOrIdentityMap } from "./895~0.mjs";
5
5
  import { EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./640~0.mjs";
6
+ import { debugLine } from "./852~0.mjs";
6
7
  const schema = {
7
8
  type: 'object',
8
9
  properties: {
@@ -45,19 +46,14 @@ function ensureHMRForScripts(source, inputSourceMap) {
45
46
  throw error;
46
47
  }
47
48
  if (moduleLayer === EXTENSIONJS_CONTENT_SCRIPT_LAYER) {
48
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip layer resource=${resourcePath} layer=${moduleLayer}`);
49
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] skip layer resource=${resourcePath} layer=${moduleLayer}`);
49
50
  return source;
50
51
  }
51
52
  if (options?.frameworkOwnsRefresh === true) {
52
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip framework-refresh resource=${resourcePath}`);
53
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] skip framework-refresh resource=${resourcePath}`);
53
54
  return source;
54
55
  }
55
- const issuer = this?._module?.issuer;
56
- if (issuer) {
57
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip child resource=${resourcePath}`);
58
- return source;
59
- }
60
- if (debugHtmlHmr) console.log(`[extjs:html-hmr] inject resource=${resourcePath} manifest=${String(options?.manifestPath || '')} layer=${moduleLayer || '<none>'}`);
56
+ if (debugHtmlHmr) debugLine(`[extjs:html-hmr] inject resource=${resourcePath} manifest=${String(options?.manifestPath || '')} layer=${moduleLayer || '<none>'}`);
61
57
  const moduleType = String(this?._module?.type || '');
62
58
  if ("javascript/dynamic" === moduleType) {
63
59
  const prelude = buildReloadCode('module.hot');
@@ -1,4 +1,4 @@
1
1
  {
2
- "pipeline": "88ad967dbcb230e3206628b300f701e637dc4325ced0a451f81c46aa0392b2c2",
3
- "builtAt": "2026-10-04T13:16:25.059Z"
2
+ "pipeline": "e8bd094dd76aae4b9affbf32a7821d42d60d419d59597623b6e37831cc5a451a",
3
+ "builtAt": "2026-10-07T12:29:03.300Z"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "pipeline": "88ad967dbcb230e3206628b300f701e637dc4325ced0a451f81c46aa0392b2c2",
3
- "builtAt": "2026-10-04T13:16:28.524Z"
2
+ "pipeline": "e8bd094dd76aae4b9affbf32a7821d42d60d419d59597623b6e37831cc5a451a",
3
+ "builtAt": "2026-10-07T12:29:06.759Z"
4
4
  }
@@ -9,7 +9,6 @@ import { stripBom } from "./937~0.mjs";
9
9
  import { canonicalizeDir, canonicalizeResourcePath } from "./712~0.mjs";
10
10
  import { findNearestProjectManifestSync } from "./731~0.mjs";
11
11
  import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX, getContentScriptCssProbeMarker } from "./640~0.mjs";
12
- import { EXTENSION_ROOT_PLACEHOLDER } from "./747~0.mjs";
13
12
  import { returnWithMap, adjustLoaderSourceMap, inputOrIdentityMap } from "./895~0.mjs";
14
13
  const schema = {
15
14
  type: 'object',
@@ -173,7 +172,9 @@ function contentScriptWrapper(source, inputSourceMap) {
173
172
  const nodeIndicators = detectNodeJsShapedScript(rewrittenSource);
174
173
  if (nodeIndicators.length > 0) {
175
174
  const relFromProject = node_path.relative(packageJsonDir, resourceAbsPath).split(node_path.sep).join('/');
176
- throw new Error(reservedScriptsFolder(relFromProject, nodeIndicators));
175
+ throw Object.assign(new Error(reservedScriptsFolder(relFromProject, nodeIndicators)), {
176
+ name: 'ReservedScriptsFolder'
177
+ });
177
178
  }
178
179
  }
179
180
  const isVendoredMinifiedScript = /\.min\.[cm]?js$/i.test(resourceAbsPath);
@@ -190,20 +191,22 @@ function contentScriptWrapper(source, inputSourceMap) {
190
191
  const isRuntimeMainWorld = (options.mainWorldScripts || []).some((candidate)=>resourceAbsPath === canonicalizeResourcePath(candidate));
191
192
  const isMainWorld = declaredEntry?.world === 'MAIN' || isRuntimeMainWorld;
192
193
  const hostInstrumentationEnabled = !isProd && !isMainWorld;
194
+ const takesBridgeBase = isProd && declaredEntry?.world === 'MAIN';
195
+ const takenBridgeBase = takesBridgeBase ? '__EXTENSIONJS_BRIDGE_BASE || ' : '';
193
196
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
194
197
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
195
198
  const buildToken = createBuildToken(rewrittenSource);
196
199
  const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
197
200
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
198
201
  const cssAssetUrlsInline = `var __EXTENSIONJS_BUNDLE_CSS_URLS=[${cssAssetSpecifiers.map((specifier)=>`(function(){ try { return String(new URL(${escapeCodeString(JSON.stringify(specifier))}, import.meta.url)); } catch (error) { return ""; } })()`).join(',')}];\n`;
199
- const bundleCssHydrationBody = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text.split(${JSON.stringify(EXTENSION_ROOT_PLACEHOLDER)}).join(__EXTENSIONJS_runtimeGetURL("/")) : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n` + devOnly(' var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n if (!hostOwner && String(host.getAttribute("data-extjs-reinject-key") || "") && String(host.getAttribute("data-extjs-reinject-key") || "") !== String(__EXTENSIONJS_BUNDLE_KEY || "")) continue;\n') + (isProd ? " if (__EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (__EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n" : '') + ' var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n';
202
+ const bundleCssHydrationBody = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = ${takenBridgeBase}((typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "");\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = Promise.all(cssUrls.map(function(url){\n return Promise.resolve().then(function(){ return fetch(url); }).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n });\n })).then(function(texts){\n var seen = [];\n for (var t = 0; t < texts.length; t++) {\n if (typeof texts[t] !== "string" || !texts[t].trim().length || seen.indexOf(texts[t]) !== -1) continue;\n seen.push(texts[t]);\n }\n return seen.join("\\n");\n }).then(function(text){\n cssText = typeof text === "string" ? text : "";\n var root = __EXTENSIONJS_runtimeGetURL("/");\n if (root) cssText = cssText.replace(/url\\(\\s*(["\']?)\\/(?!\\/)/gi, function(match, quote){ return "url(" + quote + root; });\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var wanted = false;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n` + devOnly(' var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n if (!hostOwner && String(host.getAttribute("data-extjs-reinject-key") || "") && String(host.getAttribute("data-extjs-reinject-key") || "") !== String(__EXTENSIONJS_BUNDLE_KEY || "")) continue;\n') + (isProd ? " if (__EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (__EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n" : '') + ' var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n wanted = true;\n }\n } catch (error) {}\n if (tries++ < 20) {\n' + (isProd ? ' if (wanted && !cssPromise) readCss();\n' : ' if (!cssPromise) readCss();\n') + " setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n";
200
203
  const hasModuleGraph = cssAssetSpecifiers.length > 0 || hasModuleDependency(rewrittenSource);
201
204
  const bundleCssHydrationEnabled = bundleKey.startsWith(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX) && hasModuleGraph;
202
205
  const bundleCssHydrationInline = bundleCssHydrationEnabled ? bundleCssHydrationBody : 'function __EXTENSIONJS_scheduleBundleCssHydration(){}\n';
203
206
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
204
207
  const hostInstrumentationInline = hostInstrumentationEnabled ? 'function __EXTENSIONJS_debugObserveOwnedRootRemoval(){\n try {\n if (!__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) return;\n if (typeof globalThis !== "object" || !globalThis || globalThis.__EXTJS_DEBUG_REMOVAL_OBSERVER__) return;\n if (typeof MutationObserver !== "function" || typeof document === "undefined") return;\n var target = document.documentElement || document.body || document;\n if (!target) return;\n var observer = new MutationObserver(function(records){\n try {\n var ownedKey = __EXTENSIONJS_ownerToken();\n var findOwnedRoot = function(node){\n try {\n if (!node || node.nodeType !== 1) return null;\n if (typeof node.getAttribute === "function" && String(node.getAttribute("data-extjs-reinject-owner") || "") === ownedKey) return node;\n if (typeof node.querySelector === "function") {\n return node.querySelector("[data-extjs-reinject-owner=\\"" + ownedKey.replace(/"/g, "\\\\\\"") + "\\"]");\n }\n } catch (error) {}\n return null;\n };\n for (var r = 0; r < records.length; r++) {\n var removedNodes = Array.from(records[r].removedNodes || []);\n for (var n = 0; n < removedNodes.length; n++) {\n var node = removedNodes[n];\n var ownedRoot = findOwnedRoot(node);\n if (!ownedRoot || typeof ownedRoot.getAttribute !== "function") continue;\n var owner = String(ownedRoot.getAttribute("data-extjs-reinject-owner") || "");\n if (!owner || owner !== ownedKey) continue;\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal")) pageRoot.setAttribute("data-extjs-debug-last-removal", "mutation-observer");\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-key")) pageRoot.setAttribute("data-extjs-debug-last-removal-key", owner);\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-source")) pageRoot.setAttribute("data-extjs-debug-last-removal-source", "mutation-observer");\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-tag")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(node.tagName || "").toLowerCase());\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-id")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-id", String(node.id || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-class")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-class", String(node.className || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-direct")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-direct", String(node === ownedRoot));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-ready-state")) pageRoot.setAttribute("data-extjs-debug-last-removal-ready-state", String(document.readyState || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-url")) pageRoot.setAttribute("data-extjs-debug-last-removal-url", String(location.href || ""));\n pageRoot.setAttribute("data-extjs-debug-stage", "root-removed-observed");\n }\n return;\n }\n }\n } catch (error) {}\n });\n observer.observe(target, { childList: true, subtree: true });\n globalThis.__EXTJS_DEBUG_REMOVAL_OBSERVER__ = observer;\n } catch (error) {}\n}\nfunction __EXTENSIONJS_patchDomRemovalApis(){\n try {\n if (!__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) return;\n if (typeof globalThis !== "object" || !globalThis || globalThis.__EXTJS_DEBUG_DOM_APIS_PATCHED__) return;\n var record = function(source, node, parent){\n try {\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.setAttribute !== "function") return;\n var ownedRoot = null;\n if (node && node.nodeType === 1) {\n if (typeof node.getAttribute === "function" && String(node.getAttribute("data-extjs-reinject-owner") || "") === __EXTENSIONJS_ownerToken()) ownedRoot = node;\n else if (typeof node.querySelector === "function") ownedRoot = node.querySelector("[data-extjs-reinject-owner=\\"" + __EXTENSIONJS_ownerToken().replace(/"/g, "\\\\\\"") + "\\"]");\n }\n if (!ownedRoot) return;\n pageRoot.setAttribute("data-extjs-debug-stage", "dom-api-removal");\n pageRoot.setAttribute("data-extjs-debug-last-removal", source);\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", source);\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(node && node.tagName || "").toLowerCase());\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-id", String(node && node.id || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-class", String(node && node.className || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-direct", String(node === ownedRoot));\n pageRoot.setAttribute("data-extjs-debug-last-removal-ready-state", String(document.readyState || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-url", String(location.href || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-parent-tag", String(parent && parent.tagName || "").toLowerCase());\n } catch (error) {}\n };\n try {\n var originalRemoveChild = Node.prototype.removeChild;\n if (typeof originalRemoveChild === "function") {\n Node.prototype.removeChild = function(child){\n record("Node.removeChild", child, this);\n return originalRemoveChild.call(this, child);\n };\n }\n } catch (error) {}\n try {\n var originalReplaceChildren = Element.prototype.replaceChildren;\n if (typeof originalReplaceChildren === "function") {\n Element.prototype.replaceChildren = function(){\n try {\n var existing = Array.from(this.childNodes || []);\n for (var i = 0; i < existing.length; i++) record("Element.replaceChildren", existing[i], this);\n } catch (error) {}\n return originalReplaceChildren.apply(this, arguments);\n };\n }\n } catch (error) {}\n globalThis.__EXTJS_DEBUG_DOM_APIS_PATCHED__ = true;\n } catch (error) {}\n}\nif (__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) {\n try { __EXTENSIONJS_debugObserveOwnedRootRemoval(); } catch (error) {}\n try { __EXTENSIONJS_patchDomRemovalApis(); } catch (error) {}\n}\n' : '';
205
208
  const reinjectMarkerInline = 'function __EXTENSIONJS_setReinjectMarker(key, generation, status){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED || typeof document === "undefined") return;\n var root = document.body || document.documentElement;\n if (!root) return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var marker = null;\n try {\n var markers = Array.from(document.querySelectorAll("[data-extjs-reinject-marker=\\"true\\"]"));\n for (var i = 0; i < markers.length; i++) {\n var current = markers[i];\n if (!current || typeof current.getAttribute !== "function") continue;\n var currentOwner = String(current.getAttribute("data-extjs-marker-owner") || "");\n if (currentOwner === __extjsToken) { marker = current; break; }\n if (!currentOwner && current.getAttribute("data-extjs-reinject-key") === key) { marker = current; break; }\n }\n } catch (error) {}\n if (!marker && typeof document.createElement === "function") {\n marker = document.createElement("div");\n marker.setAttribute("data-extjs-reinject-marker", "true");\n marker.setAttribute("hidden", "");\n marker.setAttribute("aria-hidden", "true");\n try { marker.style.display = "none"; } catch (error) {}\n root.appendChild(marker);\n }\n if (!marker) return;\n marker.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n marker.setAttribute("data-extjs-marker-owner", __extjsToken);\n marker.setAttribute("data-extjs-reinject-generation", String(generation));\n marker.setAttribute("data-extjs-reinject-status", String(status || "mounted"));\n marker.setAttribute("data-extjs-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n try { marker.textContent = String(__EXTENSIONJS_BUNDLE_KEY || key || "") + ":" + String(generation) + ":" + String(status || "mounted"); } catch (error) {}\n try {\n var roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n var ownedRootCount = 0;\n for (var j = 0; j < roots.length; j++) {\n var host = roots[j];\n if (!host || typeof host.setAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n ownedRootCount++;\n host.setAttribute("data-extjs-reinject-owner", __extjsToken);\n host.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n host.setAttribute("data-extjs-reinject-generation", String(generation));\n host.setAttribute("data-extjs-reinject-status", String(status || "mounted"));\n host.setAttribute("data-extjs-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n try {\n if (!host.__extjsDebugRemovePatched) {\n host.__extjsDebugRemovePatched = true;\n var __extjsOriginalRemove = typeof host.remove === "function" ? host.remove.bind(host) : null;\n if (__extjsOriginalRemove) {\n host.remove = function(){\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-debug-stage", "root-remove-called");\n pageRoot.setAttribute("data-extjs-debug-last-removal", "remove()");\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", "patched-host-remove");\n }\n } catch (error) {}\n return __extjsOriginalRemove();\n };\n }\n }\n } catch (error) {}\n }\n try {\n marker.setAttribute("data-extjs-debug-stage", String(status || ""));\n marker.setAttribute("data-extjs-debug-root-count", String(roots.length));\n marker.setAttribute("data-extjs-debug-owned-root-count", String(ownedRootCount));\n marker.setAttribute("data-extjs-debug-marker-count", String(markers.length));\n } catch (error) {}\n } catch (error) {}\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-last-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n pageRoot.setAttribute("data-extjs-last-reinject-generation", String(generation));\n pageRoot.setAttribute("data-extjs-last-reinject-status", String(status || "mounted"));\n pageRoot.setAttribute("data-extjs-last-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n pageRoot.setAttribute("data-extjs-debug-stage", marker.getAttribute("data-extjs-debug-stage") || String(status || ""));\n pageRoot.setAttribute("data-extjs-debug-root-count", marker.getAttribute("data-extjs-debug-root-count") || "0");\n pageRoot.setAttribute("data-extjs-debug-owned-root-count", marker.getAttribute("data-extjs-debug-owned-root-count") || "0");\n pageRoot.setAttribute("data-extjs-debug-marker-count", marker.getAttribute("data-extjs-debug-marker-count") || "0");\n }\n } catch (error) {}\n } catch (error) {}\n}\nfunction __EXTENSIONJS_cleanupKnownRoots(staleEvenIfSameBuild){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < roots.length; i++) {\n var host = roots[i];\n if (!host || typeof host.getAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (!hostOwner || hostOwner !== __extjsToken) continue;\n // Build-aware: only remove hosts owned by us whose build token does NOT\n // match the current bundle. Fresh roots from the current mount carry\n // the active build token and must be preserved; orphans from a prior\n // build (e.g. the old isolated world after `chrome.runtime.reload`)\n // carry stale tokens and should be cleared so we never end up with two\n // hosts owned by the same key.\n // EXCEPT when this bundle starts in a FRESH world (no registry entry,\n // because the old isolated world was destroyed by `chrome.runtime.reload`):\n // a same-build root then predates this execution and is a stale zombie\n // (its scripts died with the world). Unedited sibling scripts in a\n // multi-script entry keep their build token across recompiles, so the\n // token equality alone must not protect them here.\n var hostBuild = String(host.getAttribute("data-extjs-reinject-build") || "");\n var currentBuild = String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || "");\n if (!staleEvenIfSameBuild && hostBuild && currentBuild && hostBuild === currentBuild) continue;\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-debug-stage", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removal", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(host.tagName || "").toLowerCase());\n }\n } catch (error) {}\n try { host.remove(); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_cleanupOrphanRoots(){\n try {\n // At bundle execution start, before this run has mounted anything, any\n // `data-extension-root` host without `data-extjs-reinject-owner` is an\n // orphan from a prior session that died before `setReinjectMarker`\n // could tag it (typically: the previous isolated world was destroyed\n // by a `chrome.runtime.reload` mid-mount, or its `whenReady`-deferred\n // `apply` never fired). We have not created our own root yet, so any\n // untagged host we touch here is by definition not from THIS run, but\n // it may belong to a DIFFERENT extension mid-mount in the same DOM.\n // Companion extensions never sweep, and everyone else sweeps only when\n // a reinject marker proves a prior generation of THIS script ran here.\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n if (__EXTENSIONJS_NO_FOREIGN_ADOPT) return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var sawPriorGeneration = false;\n try {\n var markers = Array.from(document.querySelectorAll("[data-extjs-reinject-marker=\\"true\\"]"));\n for (var m = 0; m < markers.length; m++) {\n if (markers[m] && typeof markers[m].getAttribute === "function" && String(markers[m].getAttribute("data-extjs-marker-owner") || "") === __extjsToken) { sawPriorGeneration = true; break; }\n }\n } catch (error) {}\n if (!sawPriorGeneration) return;\n var roots = Array.from(document.querySelectorAll("[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < roots.length; i++) {\n var host = roots[i];\n if (!host || typeof host.getAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner) continue;\n try { host.remove(); } catch (error) {}\n }\n } catch (error) {}\n}\n';
206
- const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\n` + devOnly(`var __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\n`) + `var __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\n` + 'function __EXTENSIONJS_ownerToken(){\n var extId = "";\n try {\n var rt = (typeof globalThis === "object" && globalThis && ((globalThis.browser && globalThis.browser.runtime) || (globalThis.chrome && globalThis.chrome.runtime))) || null;\n if (rt && rt.id) extId = String(rt.id);\n } catch (error) {}\n return String(__EXTENSIONJS_REINJECT_KEY || "") + (extId ? "@" + extId : "");\n}\n' + devOnly(`var __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isProd || bundleCssHydrationEnabled ? 'var __EXTENSIONJS_PRE_MOUNT_ROOTS = [];\nfunction __EXTENSIONJS_snapshotPreMountRoots(){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n __EXTENSIONJS_PRE_MOUNT_ROOTS = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]"));\n } catch (error) { __EXTENSIONJS_PRE_MOUNT_ROOTS = []; }\n}\n__EXTENSIONJS_snapshotPreMountRoots();\n' : 'function __EXTENSIONJS_snapshotPreMountRoots(){}\n') + `${cssAssetUrlsInline}` + devOnly('var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\n') + 'var __EXTENSIONJS_REGISTERED_CLEANUPS=[];\n' + devOnly('function __EXTENSIONJS_readReinjectGeneration(entry){\n try {\n if (!entry) return 0;\n if (typeof entry === "function" && typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry === "object") {\n if (typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry.generation === "number") return entry.generation;\n if (typeof entry.cleanup === "function" && typeof entry.cleanup.__extjsGeneration === "number") return entry.cleanup.__extjsGeneration;\n }\n } catch (error) {}\n return 0;\n}\n') + 'function __EXTENSIONJS_runCleanups(list){\n try {\n if (!Array.isArray(list)) return;\n for (var i = list.length - 1; i >= 0; i--) {\n try { if (typeof list[i] === "function") list[i](); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_registerCleanup(fn){\n if (typeof fn === "function") __EXTENSIONJS_REGISTERED_CLEANUPS.push(fn);\n return fn;\n}\n' + devOnly(reinjectMarkerInline) + 'function __EXTENSIONJS_composeCleanup(primaryCleanup){\n return function(){\n try { if (typeof primaryCleanup === "function") primaryCleanup(); } catch (error) {}\n try { __EXTENSIONJS_runCleanups(__EXTENSIONJS_REGISTERED_CLEANUPS); } catch (error) {}\n' + devOnly(' try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n') + " };\n}\n" + devOnly('function __EXTENSIONJS_recordExecutionSnapshot(stage){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED) return;\n if (typeof document === "undefined") return;\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.getAttribute !== "function" || typeof pageRoot.setAttribute !== "function") return;\n var currentCount = Number(pageRoot.getAttribute("data-extjs-debug-execution-count") || "0");\n var nextCount = Number.isFinite(currentCount) ? currentCount + 1 : 1;\n var roots = [];\n try { roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])")); } catch (error) {}\n pageRoot.setAttribute("data-extjs-debug-execution-count", String(nextCount));\n pageRoot.setAttribute("data-extjs-debug-last-execution-stage", String(stage || ""));\n pageRoot.setAttribute("data-extjs-debug-last-execution-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-existing-root-count-before-cleanup", String(roots.length));\n } catch (error) {}\n}\n') + 'try {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n' + hostInstrumentationInline + devOnly('if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_recordExecutionSnapshot("bootstrap"); } catch (error) {}\n}\nvar __EXTENSIONJS_previousEntry=__EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY];\nvar __EXTENSIONJS_REINJECT_GENERATION=__EXTENSIONJS_readReinjectGeneration(__EXTENSIONJS_previousEntry);\n// Sweep untagged orphans (prior-session roots that died before tagging)\n// before any further cleanup runs. Safe here because our mount has not\n// produced any roots yet, any untagged host is by definition not ours.\ntry { __EXTENSIONJS_cleanupOrphanRoots(); } catch (error) {}\ntry {\n var __EXTENSIONJS_previousCleanup=typeof __EXTENSIONJS_previousEntry === "function" ? __EXTENSIONJS_previousEntry : (__EXTENSIONJS_previousEntry && typeof __EXTENSIONJS_previousEntry.cleanup === "function" ? __EXTENSIONJS_previousEntry.cleanup : null);\n if (typeof __EXTENSIONJS_previousCleanup === "function") {\n if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try {\n var __extjsPageRoot = document.documentElement;\n if (__extjsPageRoot && typeof __extjsPageRoot.setAttribute === "function") {\n __extjsPageRoot.setAttribute("data-extjs-debug-stage", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-source", "previous-cleanup");\n }\n } catch (error) {}\n }\n __EXTENSIONJS_previousCleanup();\n }\n} catch (error) {}\ntry { __EXTENSIONJS_cleanupKnownRoots(!__EXTENSIONJS_previousEntry); } catch (error) {}\n') + (!isProd || hasModuleGraph ? 'function __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n' : '');
209
+ const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\n` + (takesBridgeBase ? 'var __EXTENSIONJS_BRIDGE_BASE = "";\ntry {\n var __EXTENSIONJS_html = document.documentElement;\n __EXTENSIONJS_BRIDGE_BASE = String(__EXTENSIONJS_html.getAttribute("data-extjs-extension-base") || "");\n if (__EXTENSIONJS_BRIDGE_BASE) {\n __EXTENSIONJS_html.removeAttribute("data-extjs-extension-base");\n if (typeof __webpack_require__ === "function") __webpack_require__.extjsBase = __EXTENSIONJS_BRIDGE_BASE;\n }\n} catch (error) {}\n' : '') + devOnly(`var __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\n`) + `var __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\n` + 'function __EXTENSIONJS_ownerToken(){\n var extId = "";\n try {\n var rt = (typeof globalThis === "object" && globalThis && ((globalThis.browser && globalThis.browser.runtime) || (globalThis.chrome && globalThis.chrome.runtime))) || null;\n if (rt && rt.id) extId = String(rt.id);\n } catch (error) {}\n return String(__EXTENSIONJS_REINJECT_KEY || "") + (extId ? "@" + extId : "");\n}\n' + devOnly(`var __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isProd || bundleCssHydrationEnabled ? 'var __EXTENSIONJS_PRE_MOUNT_ROOTS = [];\nfunction __EXTENSIONJS_snapshotPreMountRoots(){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n __EXTENSIONJS_PRE_MOUNT_ROOTS = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]"));\n } catch (error) { __EXTENSIONJS_PRE_MOUNT_ROOTS = []; }\n}\n__EXTENSIONJS_snapshotPreMountRoots();\n' : 'function __EXTENSIONJS_snapshotPreMountRoots(){}\n') + `${cssAssetUrlsInline}` + devOnly('var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\n') + 'var __EXTENSIONJS_REGISTERED_CLEANUPS=[];\n' + devOnly('function __EXTENSIONJS_readReinjectGeneration(entry){\n try {\n if (!entry) return 0;\n if (typeof entry === "function" && typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry === "object") {\n if (typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry.generation === "number") return entry.generation;\n if (typeof entry.cleanup === "function" && typeof entry.cleanup.__extjsGeneration === "number") return entry.cleanup.__extjsGeneration;\n }\n } catch (error) {}\n return 0;\n}\n') + 'function __EXTENSIONJS_runCleanups(list){\n try {\n if (!Array.isArray(list)) return;\n for (var i = list.length - 1; i >= 0; i--) {\n try { if (typeof list[i] === "function") list[i](); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_registerCleanup(fn){\n if (typeof fn === "function") __EXTENSIONJS_REGISTERED_CLEANUPS.push(fn);\n return fn;\n}\n' + devOnly(reinjectMarkerInline) + 'function __EXTENSIONJS_composeCleanup(primaryCleanup){\n return function(){\n try { if (typeof primaryCleanup === "function") primaryCleanup(); } catch (error) {}\n try { __EXTENSIONJS_runCleanups(__EXTENSIONJS_REGISTERED_CLEANUPS); } catch (error) {}\n' + devOnly(' try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n') + " };\n}\n" + devOnly('function __EXTENSIONJS_recordExecutionSnapshot(stage){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED) return;\n if (typeof document === "undefined") return;\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.getAttribute !== "function" || typeof pageRoot.setAttribute !== "function") return;\n var currentCount = Number(pageRoot.getAttribute("data-extjs-debug-execution-count") || "0");\n var nextCount = Number.isFinite(currentCount) ? currentCount + 1 : 1;\n var roots = [];\n try { roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])")); } catch (error) {}\n pageRoot.setAttribute("data-extjs-debug-execution-count", String(nextCount));\n pageRoot.setAttribute("data-extjs-debug-last-execution-stage", String(stage || ""));\n pageRoot.setAttribute("data-extjs-debug-last-execution-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-existing-root-count-before-cleanup", String(roots.length));\n } catch (error) {}\n}\n') + 'try {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n' + hostInstrumentationInline + devOnly('if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_recordExecutionSnapshot("bootstrap"); } catch (error) {}\n}\nvar __EXTENSIONJS_previousEntry=__EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY];\nvar __EXTENSIONJS_REINJECT_GENERATION=__EXTENSIONJS_readReinjectGeneration(__EXTENSIONJS_previousEntry);\n// Sweep untagged orphans (prior-session roots that died before tagging)\n// before any further cleanup runs. Safe here because our mount has not\n// produced any roots yet, any untagged host is by definition not ours.\ntry { __EXTENSIONJS_cleanupOrphanRoots(); } catch (error) {}\ntry {\n var __EXTENSIONJS_previousCleanup=typeof __EXTENSIONJS_previousEntry === "function" ? __EXTENSIONJS_previousEntry : (__EXTENSIONJS_previousEntry && typeof __EXTENSIONJS_previousEntry.cleanup === "function" ? __EXTENSIONJS_previousEntry.cleanup : null);\n if (typeof __EXTENSIONJS_previousCleanup === "function") {\n if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try {\n var __extjsPageRoot = document.documentElement;\n if (__extjsPageRoot && typeof __extjsPageRoot.setAttribute === "function") {\n __extjsPageRoot.setAttribute("data-extjs-debug-stage", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-source", "previous-cleanup");\n }\n } catch (error) {}\n }\n __EXTENSIONJS_previousCleanup();\n }\n} catch (error) {}\ntry { __EXTENSIONJS_cleanupKnownRoots(!__EXTENSIONJS_previousEntry); } catch (error) {}\n') + (!isProd || hasModuleGraph ? 'function __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n' + (takesBridgeBase ? ' if (!base) base = __EXTENSIONJS_BRIDGE_BASE;\n' : '') + ' if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n' : '');
207
210
  const runtimeInline = `function __EXTENSIONJS_whenReady(runAt, cb){\n try {\n if (typeof document === 'undefined') { cb(); return function(){} }\n if (runAt === 'document_start') { cb(); return function(){} }\n var isDone = false;\n function isReady(){\n if (runAt === 'document_end') return document.readyState === 'interactive' || document.readyState === 'complete';\n if (runAt === 'document_idle') return document.readyState === 'complete';\n return document.readyState === 'complete';\n }\n if (isReady()) { cb(); return function(){} }\n var onReady = function(){\n try {\n if (isDone) return;\n if (isReady()) { isDone = true; document.removeEventListener('readystatechange', onReady); cb(); }\n } catch (error) {}\n };\n document.addEventListener('readystatechange', onReady);\n return function(){ try { if (!isDone) document.removeEventListener('readystatechange', onReady); } catch (error) {} };\n } catch (error) { try { cb(); } catch (ignored) {} return function(){} }\n}\n${bundleCssHydrationInline}function __EXTENSIONJS_mount(mount, runAt){\n var cleanup = function(){};\n var cancelReady = function(){};\n if (typeof mount !== "function") {\n` + devOnly(' try { __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1; } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "executed"); } catch (error) {}\n') + " try { __EXTENSIONJS_scheduleBundleCssHydration(); } catch (error) {}\n return __EXTENSIONJS_composeCleanup(null);\n }\n function apply(){\n try {\n __EXTENSIONJS_snapshotPreMountRoots();\n var nextCleanup = mount();\n cleanup = __EXTENSIONJS_composeCleanup(nextCleanup);\n" + devOnly(' __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1;\n try { unmount.__extjsGeneration = __EXTENSIONJS_REINJECT_GENERATION; unmount.__extjsKey = __EXTENSIONJS_REINJECT_KEY; } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, __EXTENSIONJS_REINJECT_GENERATION, "mounted"); } catch (error) {}\n') + ' try { __EXTENSIONJS_scheduleBundleCssHydration(); } catch (error) {}\n } catch (error) {\n try { console.warn("Extension.js: the content script default export failed to run.", error); } catch (ignored) {}\n' + devOnly(' try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "mount-error"); } catch (ignored) {}\n') + " }\n }\n function unmount(){ try { cancelReady && cancelReady(); } catch (error) {} try { if (typeof cleanup === 'function') cleanup(); } catch (error) {} }\n cancelReady = __EXTENSIONJS_whenReady(runAt, apply);\n return unmount;\n}\n";
208
211
  if (!hasDefaultExport(rewrittenSource, this.resourcePath, compilation)) {
209
212
  const prefix = `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}`;
@@ -9,7 +9,6 @@ import { stripBom } from "./937~0.mjs";
9
9
  import { canonicalizeDir, canonicalizeResourcePath } from "./712~0.mjs";
10
10
  import { findNearestProjectManifestSync } from "./731~0.mjs";
11
11
  import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX, getContentScriptCssProbeMarker } from "./640~0.mjs";
12
- import { EXTENSION_ROOT_PLACEHOLDER } from "./747~0.mjs";
13
12
  import { returnWithMap, adjustLoaderSourceMap, inputOrIdentityMap } from "./895~0.mjs";
14
13
  const schema = {
15
14
  type: 'object',
@@ -173,7 +172,9 @@ function contentScriptWrapper(source, inputSourceMap) {
173
172
  const nodeIndicators = detectNodeJsShapedScript(rewrittenSource);
174
173
  if (nodeIndicators.length > 0) {
175
174
  const relFromProject = node_path.relative(packageJsonDir, resourceAbsPath).split(node_path.sep).join('/');
176
- throw new Error(reservedScriptsFolder(relFromProject, nodeIndicators));
175
+ throw Object.assign(new Error(reservedScriptsFolder(relFromProject, nodeIndicators)), {
176
+ name: 'ReservedScriptsFolder'
177
+ });
177
178
  }
178
179
  }
179
180
  const isVendoredMinifiedScript = /\.min\.[cm]?js$/i.test(resourceAbsPath);
@@ -190,20 +191,22 @@ function contentScriptWrapper(source, inputSourceMap) {
190
191
  const isRuntimeMainWorld = (options.mainWorldScripts || []).some((candidate)=>resourceAbsPath === canonicalizeResourcePath(candidate));
191
192
  const isMainWorld = declaredEntry?.world === 'MAIN' || isRuntimeMainWorld;
192
193
  const hostInstrumentationEnabled = !isProd && !isMainWorld;
194
+ const takesBridgeBase = isProd && declaredEntry?.world === 'MAIN';
195
+ const takenBridgeBase = takesBridgeBase ? '__EXTENSIONJS_BRIDGE_BASE || ' : '';
193
196
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
194
197
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
195
198
  const buildToken = createBuildToken(rewrittenSource);
196
199
  const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
197
200
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
198
201
  const cssAssetUrlsInline = `var __EXTENSIONJS_BUNDLE_CSS_URLS=[${cssAssetSpecifiers.map((specifier)=>`(function(){ try { return String(new URL(${escapeCodeString(JSON.stringify(specifier))}, import.meta.url)); } catch (error) { return ""; } })()`).join(',')}];\n`;
199
- const bundleCssHydrationBody = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text.split(${JSON.stringify(EXTENSION_ROOT_PLACEHOLDER)}).join(__EXTENSIONJS_runtimeGetURL("/")) : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n` + devOnly(' var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n if (!hostOwner && String(host.getAttribute("data-extjs-reinject-key") || "") && String(host.getAttribute("data-extjs-reinject-key") || "") !== String(__EXTENSIONJS_BUNDLE_KEY || "")) continue;\n') + (isProd ? " if (__EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (__EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n" : '') + ' var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n';
202
+ const bundleCssHydrationBody = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = ${takenBridgeBase}((typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "");\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = Promise.all(cssUrls.map(function(url){\n return Promise.resolve().then(function(){ return fetch(url); }).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n });\n })).then(function(texts){\n var seen = [];\n for (var t = 0; t < texts.length; t++) {\n if (typeof texts[t] !== "string" || !texts[t].trim().length || seen.indexOf(texts[t]) !== -1) continue;\n seen.push(texts[t]);\n }\n return seen.join("\\n");\n }).then(function(text){\n cssText = typeof text === "string" ? text : "";\n var root = __EXTENSIONJS_runtimeGetURL("/");\n if (root) cssText = cssText.replace(/url\\(\\s*(["\']?)\\/(?!\\/)/gi, function(match, quote){ return "url(" + quote + root; });\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var wanted = false;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n` + devOnly(' var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n if (!hostOwner && String(host.getAttribute("data-extjs-reinject-key") || "") && String(host.getAttribute("data-extjs-reinject-key") || "") !== String(__EXTENSIONJS_BUNDLE_KEY || "")) continue;\n') + (isProd ? " if (__EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (__EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n" : '') + ' var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n wanted = true;\n }\n } catch (error) {}\n if (tries++ < 20) {\n' + (isProd ? ' if (wanted && !cssPromise) readCss();\n' : ' if (!cssPromise) readCss();\n') + " setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n";
200
203
  const hasModuleGraph = cssAssetSpecifiers.length > 0 || hasModuleDependency(rewrittenSource);
201
204
  const bundleCssHydrationEnabled = bundleKey.startsWith(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX) && hasModuleGraph;
202
205
  const bundleCssHydrationInline = bundleCssHydrationEnabled ? bundleCssHydrationBody : 'function __EXTENSIONJS_scheduleBundleCssHydration(){}\n';
203
206
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
204
207
  const hostInstrumentationInline = hostInstrumentationEnabled ? 'function __EXTENSIONJS_debugObserveOwnedRootRemoval(){\n try {\n if (!__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) return;\n if (typeof globalThis !== "object" || !globalThis || globalThis.__EXTJS_DEBUG_REMOVAL_OBSERVER__) return;\n if (typeof MutationObserver !== "function" || typeof document === "undefined") return;\n var target = document.documentElement || document.body || document;\n if (!target) return;\n var observer = new MutationObserver(function(records){\n try {\n var ownedKey = __EXTENSIONJS_ownerToken();\n var findOwnedRoot = function(node){\n try {\n if (!node || node.nodeType !== 1) return null;\n if (typeof node.getAttribute === "function" && String(node.getAttribute("data-extjs-reinject-owner") || "") === ownedKey) return node;\n if (typeof node.querySelector === "function") {\n return node.querySelector("[data-extjs-reinject-owner=\\"" + ownedKey.replace(/"/g, "\\\\\\"") + "\\"]");\n }\n } catch (error) {}\n return null;\n };\n for (var r = 0; r < records.length; r++) {\n var removedNodes = Array.from(records[r].removedNodes || []);\n for (var n = 0; n < removedNodes.length; n++) {\n var node = removedNodes[n];\n var ownedRoot = findOwnedRoot(node);\n if (!ownedRoot || typeof ownedRoot.getAttribute !== "function") continue;\n var owner = String(ownedRoot.getAttribute("data-extjs-reinject-owner") || "");\n if (!owner || owner !== ownedKey) continue;\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal")) pageRoot.setAttribute("data-extjs-debug-last-removal", "mutation-observer");\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-key")) pageRoot.setAttribute("data-extjs-debug-last-removal-key", owner);\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-source")) pageRoot.setAttribute("data-extjs-debug-last-removal-source", "mutation-observer");\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-tag")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(node.tagName || "").toLowerCase());\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-id")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-id", String(node.id || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-class")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-class", String(node.className || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removed-node-direct")) pageRoot.setAttribute("data-extjs-debug-last-removed-node-direct", String(node === ownedRoot));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-ready-state")) pageRoot.setAttribute("data-extjs-debug-last-removal-ready-state", String(document.readyState || ""));\n if (!pageRoot.getAttribute("data-extjs-debug-last-removal-url")) pageRoot.setAttribute("data-extjs-debug-last-removal-url", String(location.href || ""));\n pageRoot.setAttribute("data-extjs-debug-stage", "root-removed-observed");\n }\n return;\n }\n }\n } catch (error) {}\n });\n observer.observe(target, { childList: true, subtree: true });\n globalThis.__EXTJS_DEBUG_REMOVAL_OBSERVER__ = observer;\n } catch (error) {}\n}\nfunction __EXTENSIONJS_patchDomRemovalApis(){\n try {\n if (!__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) return;\n if (typeof globalThis !== "object" || !globalThis || globalThis.__EXTJS_DEBUG_DOM_APIS_PATCHED__) return;\n var record = function(source, node, parent){\n try {\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.setAttribute !== "function") return;\n var ownedRoot = null;\n if (node && node.nodeType === 1) {\n if (typeof node.getAttribute === "function" && String(node.getAttribute("data-extjs-reinject-owner") || "") === __EXTENSIONJS_ownerToken()) ownedRoot = node;\n else if (typeof node.querySelector === "function") ownedRoot = node.querySelector("[data-extjs-reinject-owner=\\"" + __EXTENSIONJS_ownerToken().replace(/"/g, "\\\\\\"") + "\\"]");\n }\n if (!ownedRoot) return;\n pageRoot.setAttribute("data-extjs-debug-stage", "dom-api-removal");\n pageRoot.setAttribute("data-extjs-debug-last-removal", source);\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", source);\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(node && node.tagName || "").toLowerCase());\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-id", String(node && node.id || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-class", String(node && node.className || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-direct", String(node === ownedRoot));\n pageRoot.setAttribute("data-extjs-debug-last-removal-ready-state", String(document.readyState || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-url", String(location.href || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-parent-tag", String(parent && parent.tagName || "").toLowerCase());\n } catch (error) {}\n };\n try {\n var originalRemoveChild = Node.prototype.removeChild;\n if (typeof originalRemoveChild === "function") {\n Node.prototype.removeChild = function(child){\n record("Node.removeChild", child, this);\n return originalRemoveChild.call(this, child);\n };\n }\n } catch (error) {}\n try {\n var originalReplaceChildren = Element.prototype.replaceChildren;\n if (typeof originalReplaceChildren === "function") {\n Element.prototype.replaceChildren = function(){\n try {\n var existing = Array.from(this.childNodes || []);\n for (var i = 0; i < existing.length; i++) record("Element.replaceChildren", existing[i], this);\n } catch (error) {}\n return originalReplaceChildren.apply(this, arguments);\n };\n }\n } catch (error) {}\n globalThis.__EXTJS_DEBUG_DOM_APIS_PATCHED__ = true;\n } catch (error) {}\n}\nif (__EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED) {\n try { __EXTENSIONJS_debugObserveOwnedRootRemoval(); } catch (error) {}\n try { __EXTENSIONJS_patchDomRemovalApis(); } catch (error) {}\n}\n' : '';
205
208
  const reinjectMarkerInline = 'function __EXTENSIONJS_setReinjectMarker(key, generation, status){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED || typeof document === "undefined") return;\n var root = document.body || document.documentElement;\n if (!root) return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var marker = null;\n try {\n var markers = Array.from(document.querySelectorAll("[data-extjs-reinject-marker=\\"true\\"]"));\n for (var i = 0; i < markers.length; i++) {\n var current = markers[i];\n if (!current || typeof current.getAttribute !== "function") continue;\n var currentOwner = String(current.getAttribute("data-extjs-marker-owner") || "");\n if (currentOwner === __extjsToken) { marker = current; break; }\n if (!currentOwner && current.getAttribute("data-extjs-reinject-key") === key) { marker = current; break; }\n }\n } catch (error) {}\n if (!marker && typeof document.createElement === "function") {\n marker = document.createElement("div");\n marker.setAttribute("data-extjs-reinject-marker", "true");\n marker.setAttribute("hidden", "");\n marker.setAttribute("aria-hidden", "true");\n try { marker.style.display = "none"; } catch (error) {}\n root.appendChild(marker);\n }\n if (!marker) return;\n marker.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n marker.setAttribute("data-extjs-marker-owner", __extjsToken);\n marker.setAttribute("data-extjs-reinject-generation", String(generation));\n marker.setAttribute("data-extjs-reinject-status", String(status || "mounted"));\n marker.setAttribute("data-extjs-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n try { marker.textContent = String(__EXTENSIONJS_BUNDLE_KEY || key || "") + ":" + String(generation) + ":" + String(status || "mounted"); } catch (error) {}\n try {\n var roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n var ownedRootCount = 0;\n for (var j = 0; j < roots.length; j++) {\n var host = roots[j];\n if (!host || typeof host.setAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner && hostOwner !== __extjsToken) continue;\n if (!hostOwner && __EXTENSIONJS_NO_FOREIGN_ADOPT) continue;\n if (!hostOwner && __EXTENSIONJS_PRE_MOUNT_ROOTS.indexOf(host) !== -1) continue;\n ownedRootCount++;\n host.setAttribute("data-extjs-reinject-owner", __extjsToken);\n host.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n host.setAttribute("data-extjs-reinject-generation", String(generation));\n host.setAttribute("data-extjs-reinject-status", String(status || "mounted"));\n host.setAttribute("data-extjs-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n try {\n if (!host.__extjsDebugRemovePatched) {\n host.__extjsDebugRemovePatched = true;\n var __extjsOriginalRemove = typeof host.remove === "function" ? host.remove.bind(host) : null;\n if (__extjsOriginalRemove) {\n host.remove = function(){\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-debug-stage", "root-remove-called");\n pageRoot.setAttribute("data-extjs-debug-last-removal", "remove()");\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", "patched-host-remove");\n }\n } catch (error) {}\n return __extjsOriginalRemove();\n };\n }\n }\n } catch (error) {}\n }\n try {\n marker.setAttribute("data-extjs-debug-stage", String(status || ""));\n marker.setAttribute("data-extjs-debug-root-count", String(roots.length));\n marker.setAttribute("data-extjs-debug-owned-root-count", String(ownedRootCount));\n marker.setAttribute("data-extjs-debug-marker-count", String(markers.length));\n } catch (error) {}\n } catch (error) {}\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-last-reinject-key", String(__EXTENSIONJS_BUNDLE_KEY || key || ""));\n pageRoot.setAttribute("data-extjs-last-reinject-generation", String(generation));\n pageRoot.setAttribute("data-extjs-last-reinject-status", String(status || "mounted"));\n pageRoot.setAttribute("data-extjs-last-reinject-build", String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || ""));\n pageRoot.setAttribute("data-extjs-debug-stage", marker.getAttribute("data-extjs-debug-stage") || String(status || ""));\n pageRoot.setAttribute("data-extjs-debug-root-count", marker.getAttribute("data-extjs-debug-root-count") || "0");\n pageRoot.setAttribute("data-extjs-debug-owned-root-count", marker.getAttribute("data-extjs-debug-owned-root-count") || "0");\n pageRoot.setAttribute("data-extjs-debug-marker-count", marker.getAttribute("data-extjs-debug-marker-count") || "0");\n }\n } catch (error) {}\n } catch (error) {}\n}\nfunction __EXTENSIONJS_cleanupKnownRoots(staleEvenIfSameBuild){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < roots.length; i++) {\n var host = roots[i];\n if (!host || typeof host.getAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (!hostOwner || hostOwner !== __extjsToken) continue;\n // Build-aware: only remove hosts owned by us whose build token does NOT\n // match the current bundle. Fresh roots from the current mount carry\n // the active build token and must be preserved; orphans from a prior\n // build (e.g. the old isolated world after `chrome.runtime.reload`)\n // carry stale tokens and should be cleared so we never end up with two\n // hosts owned by the same key.\n // EXCEPT when this bundle starts in a FRESH world (no registry entry,\n // because the old isolated world was destroyed by `chrome.runtime.reload`):\n // a same-build root then predates this execution and is a stale zombie\n // (its scripts died with the world). Unedited sibling scripts in a\n // multi-script entry keep their build token across recompiles, so the\n // token equality alone must not protect them here.\n var hostBuild = String(host.getAttribute("data-extjs-reinject-build") || "");\n var currentBuild = String(__EXTENSIONJS_REINJECT_BUILD_TOKEN || "");\n if (!staleEvenIfSameBuild && hostBuild && currentBuild && hostBuild === currentBuild) continue;\n try {\n var pageRoot = document.documentElement;\n if (pageRoot && typeof pageRoot.setAttribute === "function") {\n pageRoot.setAttribute("data-extjs-debug-stage", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removal", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-last-removal-source", "cleanup-known-roots");\n pageRoot.setAttribute("data-extjs-debug-last-removed-node-tag", String(host.tagName || "").toLowerCase());\n }\n } catch (error) {}\n try { host.remove(); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_cleanupOrphanRoots(){\n try {\n // At bundle execution start, before this run has mounted anything, any\n // `data-extension-root` host without `data-extjs-reinject-owner` is an\n // orphan from a prior session that died before `setReinjectMarker`\n // could tag it (typically: the previous isolated world was destroyed\n // by a `chrome.runtime.reload` mid-mount, or its `whenReady`-deferred\n // `apply` never fired). We have not created our own root yet, so any\n // untagged host we touch here is by definition not from THIS run, but\n // it may belong to a DIFFERENT extension mid-mount in the same DOM.\n // Companion extensions never sweep, and everyone else sweeps only when\n // a reinject marker proves a prior generation of THIS script ran here.\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n if (__EXTENSIONJS_NO_FOREIGN_ADOPT) return;\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var sawPriorGeneration = false;\n try {\n var markers = Array.from(document.querySelectorAll("[data-extjs-reinject-marker=\\"true\\"]"));\n for (var m = 0; m < markers.length; m++) {\n if (markers[m] && typeof markers[m].getAttribute === "function" && String(markers[m].getAttribute("data-extjs-marker-owner") || "") === __extjsToken) { sawPriorGeneration = true; break; }\n }\n } catch (error) {}\n if (!sawPriorGeneration) return;\n var roots = Array.from(document.querySelectorAll("[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < roots.length; i++) {\n var host = roots[i];\n if (!host || typeof host.getAttribute !== "function") continue;\n var hostOwner = String(host.getAttribute("data-extjs-reinject-owner") || "");\n if (hostOwner) continue;\n try { host.remove(); } catch (error) {}\n }\n } catch (error) {}\n}\n';
206
- const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\n` + devOnly(`var __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\n`) + `var __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\n` + 'function __EXTENSIONJS_ownerToken(){\n var extId = "";\n try {\n var rt = (typeof globalThis === "object" && globalThis && ((globalThis.browser && globalThis.browser.runtime) || (globalThis.chrome && globalThis.chrome.runtime))) || null;\n if (rt && rt.id) extId = String(rt.id);\n } catch (error) {}\n return String(__EXTENSIONJS_REINJECT_KEY || "") + (extId ? "@" + extId : "");\n}\n' + devOnly(`var __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isProd || bundleCssHydrationEnabled ? 'var __EXTENSIONJS_PRE_MOUNT_ROOTS = [];\nfunction __EXTENSIONJS_snapshotPreMountRoots(){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n __EXTENSIONJS_PRE_MOUNT_ROOTS = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]"));\n } catch (error) { __EXTENSIONJS_PRE_MOUNT_ROOTS = []; }\n}\n__EXTENSIONJS_snapshotPreMountRoots();\n' : 'function __EXTENSIONJS_snapshotPreMountRoots(){}\n') + `${cssAssetUrlsInline}` + devOnly('var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\n') + 'var __EXTENSIONJS_REGISTERED_CLEANUPS=[];\n' + devOnly('function __EXTENSIONJS_readReinjectGeneration(entry){\n try {\n if (!entry) return 0;\n if (typeof entry === "function" && typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry === "object") {\n if (typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry.generation === "number") return entry.generation;\n if (typeof entry.cleanup === "function" && typeof entry.cleanup.__extjsGeneration === "number") return entry.cleanup.__extjsGeneration;\n }\n } catch (error) {}\n return 0;\n}\n') + 'function __EXTENSIONJS_runCleanups(list){\n try {\n if (!Array.isArray(list)) return;\n for (var i = list.length - 1; i >= 0; i--) {\n try { if (typeof list[i] === "function") list[i](); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_registerCleanup(fn){\n if (typeof fn === "function") __EXTENSIONJS_REGISTERED_CLEANUPS.push(fn);\n return fn;\n}\n' + devOnly(reinjectMarkerInline) + 'function __EXTENSIONJS_composeCleanup(primaryCleanup){\n return function(){\n try { if (typeof primaryCleanup === "function") primaryCleanup(); } catch (error) {}\n try { __EXTENSIONJS_runCleanups(__EXTENSIONJS_REGISTERED_CLEANUPS); } catch (error) {}\n' + devOnly(' try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n') + " };\n}\n" + devOnly('function __EXTENSIONJS_recordExecutionSnapshot(stage){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED) return;\n if (typeof document === "undefined") return;\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.getAttribute !== "function" || typeof pageRoot.setAttribute !== "function") return;\n var currentCount = Number(pageRoot.getAttribute("data-extjs-debug-execution-count") || "0");\n var nextCount = Number.isFinite(currentCount) ? currentCount + 1 : 1;\n var roots = [];\n try { roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])")); } catch (error) {}\n pageRoot.setAttribute("data-extjs-debug-execution-count", String(nextCount));\n pageRoot.setAttribute("data-extjs-debug-last-execution-stage", String(stage || ""));\n pageRoot.setAttribute("data-extjs-debug-last-execution-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-existing-root-count-before-cleanup", String(roots.length));\n } catch (error) {}\n}\n') + 'try {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n' + hostInstrumentationInline + devOnly('if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_recordExecutionSnapshot("bootstrap"); } catch (error) {}\n}\nvar __EXTENSIONJS_previousEntry=__EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY];\nvar __EXTENSIONJS_REINJECT_GENERATION=__EXTENSIONJS_readReinjectGeneration(__EXTENSIONJS_previousEntry);\n// Sweep untagged orphans (prior-session roots that died before tagging)\n// before any further cleanup runs. Safe here because our mount has not\n// produced any roots yet, any untagged host is by definition not ours.\ntry { __EXTENSIONJS_cleanupOrphanRoots(); } catch (error) {}\ntry {\n var __EXTENSIONJS_previousCleanup=typeof __EXTENSIONJS_previousEntry === "function" ? __EXTENSIONJS_previousEntry : (__EXTENSIONJS_previousEntry && typeof __EXTENSIONJS_previousEntry.cleanup === "function" ? __EXTENSIONJS_previousEntry.cleanup : null);\n if (typeof __EXTENSIONJS_previousCleanup === "function") {\n if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try {\n var __extjsPageRoot = document.documentElement;\n if (__extjsPageRoot && typeof __extjsPageRoot.setAttribute === "function") {\n __extjsPageRoot.setAttribute("data-extjs-debug-stage", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-source", "previous-cleanup");\n }\n } catch (error) {}\n }\n __EXTENSIONJS_previousCleanup();\n }\n} catch (error) {}\ntry { __EXTENSIONJS_cleanupKnownRoots(!__EXTENSIONJS_previousEntry); } catch (error) {}\n') + (!isProd || hasModuleGraph ? 'function __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n' : '');
209
+ const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\n` + (takesBridgeBase ? 'var __EXTENSIONJS_BRIDGE_BASE = "";\ntry {\n var __EXTENSIONJS_html = document.documentElement;\n __EXTENSIONJS_BRIDGE_BASE = String(__EXTENSIONJS_html.getAttribute("data-extjs-extension-base") || "");\n if (__EXTENSIONJS_BRIDGE_BASE) {\n __EXTENSIONJS_html.removeAttribute("data-extjs-extension-base");\n if (typeof __webpack_require__ === "function") __webpack_require__.extjsBase = __EXTENSIONJS_BRIDGE_BASE;\n }\n} catch (error) {}\n' : '') + devOnly(`var __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\n`) + `var __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\n` + 'function __EXTENSIONJS_ownerToken(){\n var extId = "";\n try {\n var rt = (typeof globalThis === "object" && globalThis && ((globalThis.browser && globalThis.browser.runtime) || (globalThis.chrome && globalThis.chrome.runtime))) || null;\n if (rt && rt.id) extId = String(rt.id);\n } catch (error) {}\n return String(__EXTENSIONJS_REINJECT_KEY || "") + (extId ? "@" + extId : "");\n}\n' + devOnly(`var __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isProd || bundleCssHydrationEnabled ? 'var __EXTENSIONJS_PRE_MOUNT_ROOTS = [];\nfunction __EXTENSIONJS_snapshotPreMountRoots(){\n try {\n if (typeof document === "undefined" || typeof document.querySelectorAll !== "function") return;\n __EXTENSIONJS_PRE_MOUNT_ROOTS = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]"));\n } catch (error) { __EXTENSIONJS_PRE_MOUNT_ROOTS = []; }\n}\n__EXTENSIONJS_snapshotPreMountRoots();\n' : 'function __EXTENSIONJS_snapshotPreMountRoots(){}\n') + `${cssAssetUrlsInline}` + devOnly('var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\n') + 'var __EXTENSIONJS_REGISTERED_CLEANUPS=[];\n' + devOnly('function __EXTENSIONJS_readReinjectGeneration(entry){\n try {\n if (!entry) return 0;\n if (typeof entry === "function" && typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry === "object") {\n if (typeof entry.__extjsGeneration === "number") return entry.__extjsGeneration;\n if (typeof entry.generation === "number") return entry.generation;\n if (typeof entry.cleanup === "function" && typeof entry.cleanup.__extjsGeneration === "number") return entry.cleanup.__extjsGeneration;\n }\n } catch (error) {}\n return 0;\n}\n') + 'function __EXTENSIONJS_runCleanups(list){\n try {\n if (!Array.isArray(list)) return;\n for (var i = list.length - 1; i >= 0; i--) {\n try { if (typeof list[i] === "function") list[i](); } catch (error) {}\n }\n } catch (error) {}\n}\nfunction __EXTENSIONJS_registerCleanup(fn){\n if (typeof fn === "function") __EXTENSIONJS_REGISTERED_CLEANUPS.push(fn);\n return fn;\n}\n' + devOnly(reinjectMarkerInline) + 'function __EXTENSIONJS_composeCleanup(primaryCleanup){\n return function(){\n try { if (typeof primaryCleanup === "function") primaryCleanup(); } catch (error) {}\n try { __EXTENSIONJS_runCleanups(__EXTENSIONJS_REGISTERED_CLEANUPS); } catch (error) {}\n' + devOnly(' try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n') + " };\n}\n" + devOnly('function __EXTENSIONJS_recordExecutionSnapshot(stage){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_ENABLED) return;\n if (typeof document === "undefined") return;\n var pageRoot = document.documentElement;\n if (!pageRoot || typeof pageRoot.getAttribute !== "function" || typeof pageRoot.setAttribute !== "function") return;\n var currentCount = Number(pageRoot.getAttribute("data-extjs-debug-execution-count") || "0");\n var nextCount = Number.isFinite(currentCount) ? currentCount + 1 : 1;\n var roots = [];\n try { roots = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])")); } catch (error) {}\n pageRoot.setAttribute("data-extjs-debug-execution-count", String(nextCount));\n pageRoot.setAttribute("data-extjs-debug-last-execution-stage", String(stage || ""));\n pageRoot.setAttribute("data-extjs-debug-last-execution-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n pageRoot.setAttribute("data-extjs-debug-existing-root-count-before-cleanup", String(roots.length));\n } catch (error) {}\n}\n') + 'try {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n' + hostInstrumentationInline + devOnly('if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_recordExecutionSnapshot("bootstrap"); } catch (error) {}\n}\nvar __EXTENSIONJS_previousEntry=__EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY];\nvar __EXTENSIONJS_REINJECT_GENERATION=__EXTENSIONJS_readReinjectGeneration(__EXTENSIONJS_previousEntry);\n// Sweep untagged orphans (prior-session roots that died before tagging)\n// before any further cleanup runs. Safe here because our mount has not\n// produced any roots yet, any untagged host is by definition not ours.\ntry { __EXTENSIONJS_cleanupOrphanRoots(); } catch (error) {}\ntry {\n var __EXTENSIONJS_previousCleanup=typeof __EXTENSIONJS_previousEntry === "function" ? __EXTENSIONJS_previousEntry : (__EXTENSIONJS_previousEntry && typeof __EXTENSIONJS_previousEntry.cleanup === "function" ? __EXTENSIONJS_previousEntry.cleanup : null);\n if (typeof __EXTENSIONJS_previousCleanup === "function") {\n if (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try {\n var __extjsPageRoot = document.documentElement;\n if (__extjsPageRoot && typeof __extjsPageRoot.setAttribute === "function") {\n __extjsPageRoot.setAttribute("data-extjs-debug-stage", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal", "previous-cleanup");\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n __extjsPageRoot.setAttribute("data-extjs-debug-last-removal-source", "previous-cleanup");\n }\n } catch (error) {}\n }\n __EXTENSIONJS_previousCleanup();\n }\n} catch (error) {}\ntry { __EXTENSIONJS_cleanupKnownRoots(!__EXTENSIONJS_previousEntry); } catch (error) {}\n') + (!isProd || hasModuleGraph ? 'function __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n' + (takesBridgeBase ? ' if (!base) base = __EXTENSIONJS_BRIDGE_BASE;\n' : '') + ' if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n' : '');
207
210
  const runtimeInline = `function __EXTENSIONJS_whenReady(runAt, cb){\n try {\n if (typeof document === 'undefined') { cb(); return function(){} }\n if (runAt === 'document_start') { cb(); return function(){} }\n var isDone = false;\n function isReady(){\n if (runAt === 'document_end') return document.readyState === 'interactive' || document.readyState === 'complete';\n if (runAt === 'document_idle') return document.readyState === 'complete';\n return document.readyState === 'complete';\n }\n if (isReady()) { cb(); return function(){} }\n var onReady = function(){\n try {\n if (isDone) return;\n if (isReady()) { isDone = true; document.removeEventListener('readystatechange', onReady); cb(); }\n } catch (error) {}\n };\n document.addEventListener('readystatechange', onReady);\n return function(){ try { if (!isDone) document.removeEventListener('readystatechange', onReady); } catch (error) {} };\n } catch (error) { try { cb(); } catch (ignored) {} return function(){} }\n}\n${bundleCssHydrationInline}function __EXTENSIONJS_mount(mount, runAt){\n var cleanup = function(){};\n var cancelReady = function(){};\n if (typeof mount !== "function") {\n` + devOnly(' try { __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1; } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "executed"); } catch (error) {}\n') + " try { __EXTENSIONJS_scheduleBundleCssHydration(); } catch (error) {}\n return __EXTENSIONJS_composeCleanup(null);\n }\n function apply(){\n try {\n __EXTENSIONJS_snapshotPreMountRoots();\n var nextCleanup = mount();\n cleanup = __EXTENSIONJS_composeCleanup(nextCleanup);\n" + devOnly(' __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1;\n try { unmount.__extjsGeneration = __EXTENSIONJS_REINJECT_GENERATION; unmount.__extjsKey = __EXTENSIONJS_REINJECT_KEY; } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, __EXTENSIONJS_REINJECT_GENERATION, "mounted"); } catch (error) {}\n') + ' try { __EXTENSIONJS_scheduleBundleCssHydration(); } catch (error) {}\n } catch (error) {\n try { console.warn("Extension.js: the content script default export failed to run.", error); } catch (ignored) {}\n' + devOnly(' try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "mount-error"); } catch (ignored) {}\n') + " }\n }\n function unmount(){ try { cancelReady && cancelReady(); } catch (error) {} try { if (typeof cleanup === 'function') cleanup(); } catch (error) {} }\n cancelReady = __EXTENSIONJS_whenReady(runAt, apply);\n return unmount;\n}\n";
208
211
  if (!hasDefaultExport(rewrittenSource, this.resourcePath, compilation)) {
209
212
  const prefix = `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}`;
@@ -49,10 +49,13 @@ export type BuildSummary = {
49
49
  size: number;
50
50
  }>;
51
51
  };
52
+ export declare const MAX_SUMMARY_WARNINGS = 20;
52
53
  export declare function getBuildSummary(browser: string, info: {
53
54
  assets?: Array<{
54
55
  size?: number;
55
56
  }>;
56
57
  warnings?: unknown[];
57
58
  errors?: unknown[];
58
- } | null, outputPath?: string): BuildSummary;
59
+ } | null, outputPath?: string, outputFiles?: Array<{
60
+ size: number;
61
+ }>, codes?: ReadonlyMap<string, string>): BuildSummary;