extension-develop 4.1.34 → 4.1.35

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 (78) hide show
  1. package/dist/206~0.mjs +33 -0
  2. package/dist/363~0.mjs +1 -1
  3. package/dist/469~0.mjs +98 -16
  4. package/dist/519~0.mjs +12 -1
  5. package/dist/771~0.mjs +49 -8
  6. package/dist/832~0.mjs +127 -25
  7. package/dist/840~0.mjs +215 -54
  8. package/dist/846~0.mjs +16 -14
  9. package/dist/852~0.mjs +2 -0
  10. package/dist/88~0.mjs +10 -1
  11. package/dist/command-preview.d.ts +2 -0
  12. package/dist/contract/codes.json +9 -0
  13. package/dist/contracts-entry.d.ts +1 -1
  14. package/dist/contracts.mjs +109 -1
  15. package/dist/css-parse-guard-loader.mjs +7 -2
  16. package/dist/dev-server/control-bridge/log-rule.d.ts +38 -0
  17. package/dist/dev-server/control-bridge/logs-query.d.ts +2 -55
  18. package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
  19. package/dist/dev-server/html-refresh.d.ts +10 -0
  20. package/dist/dev-server/port-manager.d.ts +14 -0
  21. package/dist/dev-server/reserved-listen.d.ts +9 -0
  22. package/dist/dev-server/session-restart.d.ts +1 -1
  23. package/dist/dev-server~0.mjs +155 -30
  24. package/dist/extension-js-devtools/build-stamp.json +2 -2
  25. package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
  26. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  27. package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
  28. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  29. package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
  30. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  31. package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
  32. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  33. package/dist/extension-js-theme/build-stamp.json +2 -2
  34. package/dist/feature-scripts-classic-concat-loader.js +45 -2
  35. package/dist/feature-scripts-classic-concat-loader.mjs +45 -2
  36. package/dist/feature-scripts-classic-traced-globals-loader.mjs +111 -0
  37. package/dist/feature-scripts-content-script-wrapper.js +10 -6
  38. package/dist/feature-scripts-content-script-wrapper.mjs +10 -6
  39. package/dist/lib/config-loader.d.ts +1 -0
  40. package/dist/lib/css-minimizer-options.d.ts +8 -0
  41. package/dist/lib/develop-context.d.ts +1 -1
  42. package/dist/lib/live-dev-session.d.ts +5 -0
  43. package/dist/lib/messages.d.ts +9 -1
  44. package/dist/lib/messaging.d.ts +2 -0
  45. package/dist/lib/package-manager.d.ts +7 -1
  46. package/dist/lib/paths.d.ts +1 -0
  47. package/dist/lib/project.d.ts +10 -2
  48. package/dist/lib/remote-archive.d.ts +11 -0
  49. package/dist/lib/rename-with-retry.d.ts +6 -0
  50. package/dist/lib/session-paths.d.ts +1 -0
  51. package/dist/lib/zip.d.ts +5 -1
  52. package/dist/plugin-browsers/index.d.ts +2 -0
  53. package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
  54. package/dist/plugin-css/css-in-html-loader.d.ts +1 -1
  55. package/dist/plugin-css/css-lib/build-css-rules.d.ts +2 -1
  56. package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
  57. package/dist/plugin-js-frameworks/js-tools/typescript.d.ts +1 -0
  58. package/dist/plugin-playwright/index.d.ts +3 -0
  59. package/dist/plugin-special-folders/messages.d.ts +1 -0
  60. package/dist/plugin-special-folders/warn-upon-folder-changes.d.ts +1 -1
  61. package/dist/plugin-web-extension/feature-html/html-lib/options-dialog-floor.d.ts +7 -0
  62. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +3 -1
  63. package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
  64. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-injected-hosts.d.ts +4 -1
  65. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +1 -0
  66. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/classic-concat-loader.d.ts +1 -0
  67. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +1 -0
  68. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +1 -0
  69. package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +7 -0
  70. package/dist/plugin-web-extension/feature-scripts/steps/warn-unshipped-runtime-assets.d.ts +32 -0
  71. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +1 -0
  72. package/dist/plugin-web-extension/shared/discover-runtime-surfaces.d.ts +2 -0
  73. package/dist/plugin-web-extension/shared/script-graph.d.ts +4 -0
  74. package/dist/rspack-config~0.mjs +799 -196
  75. package/dist/types.d.ts +7 -1
  76. package/dist/zip~0.mjs +14 -7
  77. package/package.json +3 -3
  78. package/dist/plugin-css/css-lib/is-content-script.d.ts +0 -2
@@ -19,6 +19,9 @@ const schema = {
19
19
  mode: {
20
20
  type: 'string'
21
21
  },
22
+ devSession: {
23
+ type: 'boolean'
24
+ },
22
25
  browser: {
23
26
  type: 'string'
24
27
  },
@@ -142,8 +145,9 @@ function contentScriptWrapper(source, inputSourceMap) {
142
145
  const packageJsonDir = canonicalizeDir(packageJsonPath ? node_path.dirname(packageJsonPath) : manifestDir);
143
146
  const browser = options.browser || 'chrome';
144
147
  const manifest = readManifestCached(manifestPath, browser);
145
- const isProd = 'production' === String(options?.mode || '').toLowerCase();
146
- const devOnly = (code)=>isProd ? '' : code;
148
+ const devSession = 'boolean' == typeof options?.devSession ? options.devSession : 'production' !== String(options?.mode || '').toLowerCase();
149
+ const isShippedBundle = !devSession;
150
+ const devOnly = (code)=>isShippedBundle ? '' : code;
147
151
  const rewrittenSource = String(source);
148
152
  const declaredContentJsAbsEntries = [];
149
153
  const contentScripts = Array.isArray(manifest.content_scripts) ? manifest.content_scripts : [];
@@ -190,8 +194,8 @@ function contentScriptWrapper(source, inputSourceMap) {
190
194
  const runAt = declaredEntry?.runAt || 'document_idle';
191
195
  const isRuntimeMainWorld = (options.mainWorldScripts || []).some((candidate)=>resourceAbsPath === canonicalizeResourcePath(candidate));
192
196
  const isMainWorld = declaredEntry?.world === 'MAIN' || isRuntimeMainWorld;
193
- const hostInstrumentationEnabled = !isProd && !isMainWorld;
194
- const takesBridgeBase = isProd && declaredEntry?.world === 'MAIN';
197
+ const hostInstrumentationEnabled = !isShippedBundle && !isMainWorld;
198
+ const takesBridgeBase = isShippedBundle && declaredEntry?.world === 'MAIN';
195
199
  const takenBridgeBase = takesBridgeBase ? '__EXTENSIONJS_BRIDGE_BASE || ' : '';
196
200
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
197
201
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
@@ -199,14 +203,14 @@ function contentScriptWrapper(source, inputSourceMap) {
199
203
  const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
200
204
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
201
205
  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`;
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";
206
+ 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') + (isShippedBundle ? " 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' + (isShippedBundle ? ' if (wanted && !cssPromise) readCss();\n' : ' if (!cssPromise) readCss();\n') + " setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n";
203
207
  const hasModuleGraph = cssAssetSpecifiers.length > 0 || hasModuleDependency(rewrittenSource);
204
208
  const bundleCssHydrationEnabled = bundleKey.startsWith(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX) && hasModuleGraph;
205
209
  const bundleCssHydrationInline = bundleCssHydrationEnabled ? bundleCssHydrationBody : 'function __EXTENSIONJS_scheduleBundleCssHydration(){}\n';
206
210
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
207
211
  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' : '';
208
212
  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';
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' : '');
213
+ 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(!isShippedBundle)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isShippedBundle || 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') + (!isShippedBundle || 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' : '');
210
214
  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";
211
215
  if (!hasDefaultExport(rewrittenSource, this.resourcePath, compilation)) {
212
216
  const prefix = `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}`;
@@ -19,6 +19,9 @@ const schema = {
19
19
  mode: {
20
20
  type: 'string'
21
21
  },
22
+ devSession: {
23
+ type: 'boolean'
24
+ },
22
25
  browser: {
23
26
  type: 'string'
24
27
  },
@@ -142,8 +145,9 @@ function contentScriptWrapper(source, inputSourceMap) {
142
145
  const packageJsonDir = canonicalizeDir(packageJsonPath ? node_path.dirname(packageJsonPath) : manifestDir);
143
146
  const browser = options.browser || 'chrome';
144
147
  const manifest = readManifestCached(manifestPath, browser);
145
- const isProd = 'production' === String(options?.mode || '').toLowerCase();
146
- const devOnly = (code)=>isProd ? '' : code;
148
+ const devSession = 'boolean' == typeof options?.devSession ? options.devSession : 'production' !== String(options?.mode || '').toLowerCase();
149
+ const isShippedBundle = !devSession;
150
+ const devOnly = (code)=>isShippedBundle ? '' : code;
147
151
  const rewrittenSource = String(source);
148
152
  const declaredContentJsAbsEntries = [];
149
153
  const contentScripts = Array.isArray(manifest.content_scripts) ? manifest.content_scripts : [];
@@ -190,8 +194,8 @@ function contentScriptWrapper(source, inputSourceMap) {
190
194
  const runAt = declaredEntry?.runAt || 'document_idle';
191
195
  const isRuntimeMainWorld = (options.mainWorldScripts || []).some((candidate)=>resourceAbsPath === canonicalizeResourcePath(candidate));
192
196
  const isMainWorld = declaredEntry?.world === 'MAIN' || isRuntimeMainWorld;
193
- const hostInstrumentationEnabled = !isProd && !isMainWorld;
194
- const takesBridgeBase = isProd && declaredEntry?.world === 'MAIN';
197
+ const hostInstrumentationEnabled = !isShippedBundle && !isMainWorld;
198
+ const takesBridgeBase = isShippedBundle && declaredEntry?.world === 'MAIN';
195
199
  const takenBridgeBase = takesBridgeBase ? '__EXTENSIONJS_BRIDGE_BASE || ' : '';
196
200
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
197
201
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
@@ -199,14 +203,14 @@ function contentScriptWrapper(source, inputSourceMap) {
199
203
  const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
200
204
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
201
205
  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`;
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";
206
+ 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') + (isShippedBundle ? " 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' + (isShippedBundle ? ' if (wanted && !cssPromise) readCss();\n' : ' if (!cssPromise) readCss();\n') + " setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n";
203
207
  const hasModuleGraph = cssAssetSpecifiers.length > 0 || hasModuleDependency(rewrittenSource);
204
208
  const bundleCssHydrationEnabled = bundleKey.startsWith(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX) && hasModuleGraph;
205
209
  const bundleCssHydrationInline = bundleCssHydrationEnabled ? bundleCssHydrationBody : 'function __EXTENSIONJS_scheduleBundleCssHydration(){}\n';
206
210
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
207
211
  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' : '';
208
212
  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';
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' : '');
213
+ 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(!isShippedBundle)};\nvar __EXTENSIONJS_HOST_INSTRUMENTATION_ENABLED=${JSON.stringify(hostInstrumentationEnabled)};\n`) + (!isShippedBundle || 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') + (!isShippedBundle || 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' : '');
210
214
  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";
211
215
  if (!hasDefaultExport(rewrittenSource, this.resourcePath, compilation)) {
212
216
  const prefix = `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}`;
@@ -1,6 +1,7 @@
1
1
  import type { Configuration } from '@rspack/core';
2
2
  import type { BrowserConfig, ConfigHookContext, DevOptions, FileConfig } from '../types.js';
3
3
  export declare function getPreloadedEnvKeys(): ReadonlySet<string>;
4
+ export declare function requireCommonJsCopyBesideSource(absolutePath: string): any;
4
5
  export declare function findConfigFile(projectPath: string): string | undefined;
5
6
  export declare function projectConfigCandidatePaths(projectPath: string): string[];
6
7
  export declare function reportConfigLoadingErrorOnce(configPath: string, error: unknown): void;
@@ -0,0 +1,8 @@
1
+ import type { DevOptions } from '../types.js';
2
+ export declare function cssMinimizerOptions(rawManifest: unknown, browser: DevOptions['browser'] | string | undefined): {
3
+ targets: string[];
4
+ exclude: {
5
+ dirSelector: boolean;
6
+ langSelectorList: boolean;
7
+ };
8
+ };
@@ -1,3 +1,3 @@
1
- export declare function findExtensionDevelopRoot(): string | null;
1
+ export declare function findExtensionDevelopRoot(startDir?: string): string | null;
2
2
  export declare function resolveDevelopInstallRoot(): string | undefined;
3
3
  export declare function resolveDevelopDistFile(stem: string): string;
@@ -0,0 +1,5 @@
1
+ export interface LiveDevSession {
2
+ distPath: string;
3
+ pid: number;
4
+ }
5
+ export declare function findLiveDevSession(projectPath: string, browser: string): LiveDevSession | null;
@@ -19,10 +19,13 @@ export declare function extensionLoadRecovered(): string;
19
19
  export declare function extensionLoadStillRefused(reason: string): string;
20
20
  export declare function browserLaunchFailed(browser: DevOptions['browser'], reason: string): string;
21
21
  export declare function authorInstallNotice(target: string): string;
22
- export declare function projectInstallInWorkspaceRoot(workspaceRoot: string): string;
22
+ export declare function projectInstallInWorkspaceRoot(workspaceRoot: string, managerName?: string): string;
23
23
  export declare function projectInstallFallbackToNpm(pmName: string): string;
24
24
  export declare function projectInstallScriptsDisabled(pmName: string): string;
25
25
  export declare function anotherDevSessionActive(browser: string, pid: number, runId: string): string;
26
+ export declare function buildOutDirInvalid(value: string): string;
27
+ export declare function buildSharesDevDist(browser: string, distDisplay: string, pid: number): string;
28
+ export declare function buildSharesDevDistText(distDisplay: string, pid: number): string;
26
29
  export declare function anotherDevSessionRefused(browser: string, pid: number, port: number | null): string;
27
30
  export declare function buildAssetsTree(stats: Stats | undefined, outputFiles?: OutputFile[]): string;
28
31
  export declare function buildComplete(browser: DevOptions['browser'], distDisplayPath: string, totalBytes?: number, mode?: 'development' | 'production' | 'none'): string;
@@ -70,6 +73,11 @@ export declare function downloadingText(url: string): string;
70
73
  export declare function unpackagingExtension(zipFilePath: string): string;
71
74
  export declare function unpackagedSuccessfully(): string;
72
75
  export declare function failedToDownloadOrWriteZIPFileError(error: unknown): string;
76
+ export declare function remoteZipAccessRefused(url: string, status: number, expiry?: {
77
+ at: Date;
78
+ expired: boolean;
79
+ }): string;
80
+ export declare function removedWhitespaceFromUrl(url: string): string;
73
81
  export declare function failedToWriteZIPFileError(error: unknown): string;
74
82
  export declare function invalidRemoteZip(url: string, contentType: string): string;
75
83
  export declare function notAZipArchive(source: string, contentType?: string): string;
@@ -112,6 +112,7 @@ export declare const CODES: {
112
112
  readonly E_POLYFILL_NOT_FOUND: 'E_POLYFILL_NOT_FOUND';
113
113
  readonly E_LOCALES_LAYOUT: 'E_LOCALES_LAYOUT';
114
114
  readonly E_WAR_INVALID: 'E_WAR_INVALID';
115
+ readonly E_DEV_SESSION_DIST_SHARED: 'E_DEV_SESSION_DIST_SHARED';
115
116
  readonly E_BACKGROUND_REQUIRED: 'E_BACKGROUND_REQUIRED';
116
117
  readonly E_CONTENT_SCRIPT_SYNTAX: 'E_CONTENT_SCRIPT_SYNTAX';
117
118
  readonly E_NO_ENTRYPOINTS: 'E_NO_ENTRYPOINTS';
@@ -121,6 +122,7 @@ export declare const CODES: {
121
122
  readonly E_ENV_NO_MATCH: 'E_ENV_NO_MATCH';
122
123
  readonly E_REMOTE_FETCH_TIMEOUT: 'E_REMOTE_FETCH_TIMEOUT';
123
124
  readonly E_REMOTE_DOWNLOAD: 'E_REMOTE_DOWNLOAD';
125
+ readonly E_REMOTE_ACCESS_DENIED: 'E_REMOTE_ACCESS_DENIED';
124
126
  readonly E_REMOTE_ZIP_INVALID: 'E_REMOTE_ZIP_INVALID';
125
127
  readonly E_LOCAL_ZIP_NOT_FOUND: 'E_LOCAL_ZIP_NOT_FOUND';
126
128
  readonly E_PROJECT_DOWNLOAD_EMPTY: 'E_PROJECT_DOWNLOAD_EMPTY';
@@ -26,11 +26,17 @@ export declare function findPnpmWorkspaceRoot(startDir: string): string | undefi
26
26
  export declare function readPnpmWorkspacePackages(workspaceRoot: string): string[];
27
27
  export declare function isPnpmWorkspaceMemberDir(patterns: string[], relativeDir: string): boolean;
28
28
  export declare function findPnpmWorkspaceMember(projectDir: string): PnpmWorkspaceMember | undefined;
29
+ export type WorkspaceMember = PnpmWorkspaceMember & {
30
+ manager: PackageManagerName;
31
+ };
32
+ export declare function findPackageJsonWorkspaceRoot(startDir: string): string | undefined;
33
+ export declare function findWorkspaceMember(projectDir: string): WorkspaceMember | undefined;
34
+ export declare function workspaceManagerOverride(member: WorkspaceMember): PackageManagerResolution | undefined;
29
35
  export type ProjectInstallTarget = {
30
36
  cwd: string;
31
37
  args: string[];
32
38
  };
33
- export declare function projectInstallTarget(pm: PackageManagerResolution, projectDir: string, member: PnpmWorkspaceMember | undefined): ProjectInstallTarget;
39
+ export declare function projectInstallTarget(pm: PackageManagerResolution, projectDir: string, member: PnpmWorkspaceMember | WorkspaceMember | undefined): ProjectInstallTarget;
34
40
  export declare function installScriptSuppression(pm: PackageManagerResolution): {
35
41
  args: string[];
36
42
  env: Record<string, string>;
@@ -19,6 +19,7 @@ export declare function isKnownBrowserName(name: unknown): boolean;
19
19
  export declare function configBrowserOrThrow(configBrowser: unknown, command: string): BrowserInput | undefined;
20
20
  export declare function normalizeBrowser(browser: BrowserInput, chromiumBinary?: string, geckoBinary?: string, safariBinary?: string): NormalizedBrowser;
21
21
  export declare function getDistPath(packageJsonDir: AbsolutePath, browser: string): AbsolutePath;
22
+ export declare function getBuildDistPath(packageJsonDir: AbsolutePath, browser: string, outDir?: string): AbsolutePath;
22
23
  export declare function computePreviewOutputPath(struct: ProjectStructure, browser: string, explicitOutputPath?: string): AbsolutePath;
23
24
  export declare function ensureDirSync(dir: AbsolutePath): void;
24
25
  export declare function devtoolsEngineFor(browser: unknown): 'chrome' | 'edge' | 'chromium' | 'firefox' | 'safari';
@@ -9,8 +9,16 @@ export declare function githubZipCandidates(pathOrRemoteUrl: string): Array<{
9
9
  ref: string;
10
10
  subdir: string;
11
11
  }>;
12
- export declare function getProjectPath(pathOrRemoteUrl: string | undefined): Promise<string>;
13
- export declare function getProjectStructure(pathOrRemoteUrl: string | undefined): Promise<ProjectStructure>;
12
+ export type RemoteArchiveTarget = {
13
+ cacheRoot: string;
14
+ } | {
15
+ destination: string;
16
+ };
17
+ export interface ProjectPathOptions {
18
+ remoteArchive?: RemoteArchiveTarget;
19
+ }
20
+ export declare function getProjectPath(pathOrRemoteUrl: string | undefined, options?: ProjectPathOptions): Promise<string>;
21
+ export declare function getProjectStructure(pathOrRemoteUrl: string | undefined, options?: ProjectPathOptions): Promise<ProjectStructure>;
14
22
  export declare function resolveProjectStructureSync(projectPath: string, options?: {
15
23
  quiet?: boolean;
16
24
  }): ProjectStructure;
@@ -0,0 +1,11 @@
1
+ export interface TokenExpiry {
2
+ at: Date;
3
+ expired: boolean;
4
+ }
5
+ export declare function repairPastedUrl(url: string): {
6
+ url: string;
7
+ repaired: boolean;
8
+ };
9
+ export declare function tokenExpiry(url: string, now?: number): TokenExpiry | undefined;
10
+ export declare function remoteArchiveCacheRoot(env?: Record<string, string | undefined>, platform?: NodeJS.Platform): string;
11
+ export declare function remoteArchiveCacheKey(url: string): string;
@@ -0,0 +1,6 @@
1
+ export interface RenameRetryOptions {
2
+ platform?: NodeJS.Platform;
3
+ rename?: (from: string, to: string) => void;
4
+ sleep?: (ms: number) => void;
5
+ }
6
+ export declare function renameSyncWithRetry(from: string, to: string, options?: RenameRetryOptions): void;
@@ -10,6 +10,7 @@ export declare function sessionArtifactsIgnoreFilePath(projectPath: string): str
10
10
  export declare const SESSION_ARTIFACTS_README_CONTENT: string;
11
11
  export declare function sessionArtifactsReadmePath(projectPath: string): string;
12
12
  export declare function ensureSessionArtifactsIgnoreFile(projectPath: string): void;
13
+ export declare function checkIgnoreSource(stdout: string): string | undefined;
13
14
  export declare function ensureSessionStateInProjectGitignore(projectPath: string): void;
14
15
  export declare function browserArtifactsDir(projectPath: string, browser: string): string;
15
16
  export declare function browserProfileRootDir(projectPath: string, browser: string): string;
package/dist/lib/zip.d.ts CHANGED
@@ -4,5 +4,9 @@ export declare function readRemoteSource(directory: string): string | undefined;
4
4
  export declare function writeRemoteSource(directory: string, source: string): void;
5
5
  export declare function remoteZipDestination(url: string, targetPath: string): string;
6
6
  export declare function assertDestinationIsOurs(destinationPath: string, source: string): void;
7
- export declare function downloadAndExtractZip(url: string, targetPath: string): Promise<string>;
7
+ export interface RemoteArchiveOptions {
8
+ destination?: string;
9
+ reuse?: boolean;
10
+ }
11
+ export declare function downloadAndExtractZip(url: string, targetPath: string, options?: RemoteArchiveOptions): Promise<string>;
8
12
  export declare function extractLocalZip(zipFilePath: string, targetPath: string): Promise<string>;
@@ -123,6 +123,7 @@ export declare class BrowsersPlugin implements RunnerPlugin {
123
123
  private reloadBroker;
124
124
  private logSink;
125
125
  private emulatorViewerUrl;
126
+ private instanceId;
126
127
  private lastReportedRefusal;
127
128
  private loadedContentScriptFiles;
128
129
  constructor(options: BrowsersPluginOptions);
@@ -134,6 +135,7 @@ export declare class BrowsersPlugin implements RunnerPlugin {
134
135
  setReloadBroker(broker: ReloadBroker): void;
135
136
  setLogSink(sink: BrowserLogSink): void;
136
137
  setEmulatorViewerUrl(url: string): void;
138
+ setInstanceId(instanceId: string): void;
137
139
  wakeBackground(): Promise<boolean>;
138
140
  private retryRefusedExtensionLoad;
139
141
  apply(compiler: Compiler): void;
@@ -1,4 +1,4 @@
1
1
  import type { RuleSetRule } from '@rspack/core';
2
2
  import type { DevOptions } from '../types.js';
3
3
  import { type PreprocessorUsage } from './css-lib/build-css-rules.js';
4
- export declare function cssInContentScriptLoader(projectPath: string, manifestPath: string, mode: DevOptions['mode'], usage?: PreprocessorUsage, browser?: DevOptions['browser']): Promise<RuleSetRule[]>;
4
+ export declare function cssInContentScriptLoader(projectPath: string, manifestPath: string, mode: DevOptions['mode'], usage?: PreprocessorUsage): Promise<RuleSetRule[]>;
@@ -1,4 +1,4 @@
1
1
  import type { RuleSetRule } from '@rspack/core';
2
2
  import type { DevOptions } from '../types.js';
3
3
  import { type PreprocessorUsage } from './css-lib/build-css-rules.js';
4
- export declare function cssInHtmlLoader(projectPath: string, mode: DevOptions['mode'], manifestPath: string, usage?: PreprocessorUsage, browser?: DevOptions['browser']): Promise<RuleSetRule[]>;
4
+ export declare function cssInHtmlLoader(projectPath: string, mode: DevOptions['mode'], manifestPath: string, usage?: PreprocessorUsage): Promise<RuleSetRule[]>;
@@ -6,7 +6,8 @@ export interface PreprocessorUsage {
6
6
  }
7
7
  interface BuildCssRulesOptions {
8
8
  nonModuleType: 'asset/inline' | 'css';
9
- issuer: (issuer: string) => boolean;
9
+ issuer?: RuleSetRule['issuer'];
10
+ issuerLayer?: RuleSetRule['issuerLayer'];
10
11
  manifestPath?: string;
11
12
  }
12
13
  export declare function buildCssRules(projectPath: string, mode: DevOptions['mode'], usage: PreprocessorUsage, opts: BuildCssRulesOptions): Promise<RuleSetRule[]>;
@@ -2,6 +2,7 @@ import type { Compilation } from '@rspack/core';
2
2
  export declare const VERBATIM_CSS_MARKER: RegExp;
3
3
  export declare function registerVerbatimCss(raw: string, resourcePath?: string): string;
4
4
  export declare function verbatimCssPlaceholder(id: string): string;
5
+ export declare function verbatimCssModulePlaceholder(id: string, raw: string): string;
5
6
  export declare function takeVerbatimCss(id: string): string | undefined;
6
7
  export declare function cssRelativeRefs(text: string): string[];
7
8
  export declare function restoreVerbatimCssAssets(compilation: Pick<Compilation, 'getAssets' | 'updateAsset'> & Partial<Pick<Compilation, 'emitAsset' | 'getAsset'>>): string[];
@@ -36,6 +36,7 @@ export declare function defaultTypeScriptConfig(projectPath: string, _opts?: unk
36
36
  exclude: string[];
37
37
  };
38
38
  export declare function getUserTypeScriptConfigFile(projectPath: string): string | undefined;
39
+ export declare function getUserJsConfigFile(projectPath: string): string | undefined;
39
40
  export declare function getTypeScriptConfigOverrides(opts: {
40
41
  mode: DevOptions['mode'];
41
42
  }): {