extension-develop 4.1.9 → 4.1.11

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 (58) hide show
  1. package/dist/0~rspack-config.mjs +212 -102
  2. package/dist/101.mjs +1 -1
  3. package/dist/291.mjs +8 -1
  4. package/dist/839.mjs +65 -13
  5. package/dist/extension-js-devtools/chrome/background/service_worker.js +1 -1
  6. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  7. package/dist/extension-js-devtools/chrome/manifest.json +4 -0
  8. package/dist/extension-js-devtools/chrome/options/index.css +2 -0
  9. package/dist/extension-js-devtools/chrome/options/index.html +11 -0
  10. package/dist/extension-js-devtools/chrome/options/index.js +1 -0
  11. package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
  12. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  13. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
  14. package/dist/extension-js-devtools/chromium/background/service_worker.js +1 -1
  15. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  16. package/dist/extension-js-devtools/chromium/manifest.json +4 -0
  17. package/dist/extension-js-devtools/chromium/options/index.css +2 -0
  18. package/dist/extension-js-devtools/chromium/options/index.html +11 -0
  19. package/dist/extension-js-devtools/chromium/options/index.js +1 -0
  20. package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
  21. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  22. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
  23. package/dist/extension-js-devtools/edge/background/service_worker.js +1 -1
  24. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  25. package/dist/extension-js-devtools/edge/manifest.json +4 -0
  26. package/dist/extension-js-devtools/edge/options/index.css +2 -0
  27. package/dist/extension-js-devtools/edge/options/index.html +11 -0
  28. package/dist/extension-js-devtools/edge/options/index.js +1 -0
  29. package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
  30. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  31. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
  32. package/dist/extension-js-devtools/firefox/background/scripts.js +1 -1
  33. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  34. package/dist/extension-js-devtools/firefox/manifest.json +4 -0
  35. package/dist/extension-js-devtools/firefox/options/index.css +2 -0
  36. package/dist/extension-js-devtools/firefox/options/index.html +11 -0
  37. package/dist/extension-js-devtools/firefox/options/index.js +1 -0
  38. package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
  39. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  40. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
  41. package/dist/feature-scripts-content-script-wrapper.js +3 -2
  42. package/dist/feature-scripts-content-script-wrapper.mjs +3 -2
  43. package/dist/feature-scripts-native-geturl-import-loader.mjs +73 -9
  44. package/dist/minimum-script-file.js +4 -4
  45. package/dist/minimum-script-file.mjs +4 -4
  46. package/dist/plugin-reload/reload-dispatch.d.ts +1 -1
  47. package/dist/plugin-reload/steps/setup-reload-strategy/index.d.ts +6 -8
  48. package/dist/plugin-web-extension/feature-html/html-lib/assets.d.ts +3 -2
  49. package/dist/plugin-web-extension/feature-html/html-lib/parse-html.d.ts +2 -0
  50. package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +6 -0
  51. package/dist/plugin-web-extension/feature-json/resolve-json-resource.d.ts +6 -0
  52. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/storage.d.ts +1 -1
  53. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/declarative_net_request.d.ts +1 -1
  54. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/index.d.ts +1 -1
  55. package/dist/plugin-web-extension/feature-scripts/contracts.d.ts +3 -0
  56. package/dist/plugin-web-extension/feature-scripts/scripts-lib/utils.d.ts +9 -0
  57. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +2 -1
  58. package/package.json +2 -2
@@ -7,7 +7,7 @@ import { reservedScriptsFolder } from "./266.mjs";
7
7
  import { stripBom } from "./23.mjs";
8
8
  import { canonicalizeDir, canonicalizeResourcePath } from "./93.mjs";
9
9
  import { findNearestProjectManifestSync } from "./80.mjs";
10
- import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX } from "./291.mjs";
10
+ import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX, getContentScriptCssProbeMarker } from "./291.mjs";
11
11
  initSync();
12
12
  const schema = {
13
13
  type: 'object',
@@ -172,9 +172,10 @@ function contentScriptWrapper(source, inputSourceMap) {
172
172
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
173
173
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
174
174
  const buildToken = createBuildToken(rewrittenSource);
175
+ const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
175
176
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
176
177
  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`;
177
- const bundleCssHydrationInline = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\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_runtimeGetURL(__EXTENSIONJS_BUNDLE_KEY + ".css")]).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n 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 var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n`;
178
+ const bundleCssHydrationInline = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n 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 var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n`;
178
179
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
179
180
  const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\nvar __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\nvar __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\nfunction __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}\nvar __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __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${cssAssetUrlsInline}var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\nvar __EXTENSIONJS_REGISTERED_CLEANUPS=[];\nfunction __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}\nfunction __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}\nfunction __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_debugObserveOwnedRootRemoval(){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_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_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}\nfunction __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 try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n };\n}\nfunction __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}\nfunction __EXTENSIONJS_patchDomRemovalApis(){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_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}\ntry {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n globalThis.registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n// Dev-only DOM instrumentation. Gated so production content scripts never\n// install a whole-document MutationObserver, monkey-patch Node.prototype\n// removal APIs, or write data-extjs-debug-* attributes onto the host page.\nif (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_debugObserveOwnedRootRemoval(); } catch (error) {}\n try { __EXTENSIONJS_patchDomRemovalApis(); } catch (error) {}\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) {}\nfunction __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n`;
180
181
  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 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 __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1;\n try { cleanup.__extjsGeneration = __EXTENSIONJS_REINJECT_GENERATION; cleanup.__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] content script default export failed to run", error); } catch (ignored) {}\n 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`;
@@ -7,7 +7,7 @@ import { reservedScriptsFolder } from "./266.mjs";
7
7
  import { stripBom } from "./23.mjs";
8
8
  import { canonicalizeDir, canonicalizeResourcePath } from "./93.mjs";
9
9
  import { findNearestProjectManifestSync } from "./80.mjs";
10
- import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX } from "./291.mjs";
10
+ import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX, getContentScriptCssProbeMarker } from "./291.mjs";
11
11
  initSync();
12
12
  const schema = {
13
13
  type: 'object',
@@ -172,9 +172,10 @@ function contentScriptWrapper(source, inputSourceMap) {
172
172
  const bundleKey = declaredEntry ? getCanonicalContentScriptEntryName(declaredEntry.index) : `scripts/${String(relToScripts || '').replace(/\\/g, '/')}`;
173
173
  const reinjectKey = declaredEntry ? `${bundleKey}::script-${declaredEntry.scriptIndex}` : bundleKey;
174
174
  const buildToken = createBuildToken(rewrittenSource);
175
+ const cssProbeMarker = getContentScriptCssProbeMarker(bundleKey);
175
176
  const cssAssetSpecifiers = collectStyleAssetSpecifiers(rewrittenSource);
176
177
  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`;
177
- const bundleCssHydrationInline = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\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_runtimeGetURL(__EXTENSIONJS_BUNDLE_KEY + ".css")]).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n 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 var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n`;
178
+ const bundleCssHydrationInline = `function __EXTENSIONJS_runtimeGetURL(path){\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") return globalThis.browser.runtime.getURL(path);\n if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") return globalThis.chrome.runtime.getURL(path);\n } catch (error) {}\n try {\n var base = (typeof globalThis === "object" && globalThis && globalThis.__EXTJS_EXTENSION_BASE__) ? String(globalThis.__EXTJS_EXTENSION_BASE__) : "";\n if (!base && typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n if (!base) return "";\n return base.replace(/\\/+\$/, "/") + String(path || "").replace(/^\\/+/, "");\n } catch (error) {}\n return "";\n}\nvar __EXTENSIONJS_BUNDLE_CSS_PROBE=${JSON.stringify(cssProbeMarker)};\nfunction __EXTENSIONJS_bundleCssProbeUrls(){\n try {\n var probe = String(__EXTENSIONJS_BUNDLE_CSS_PROBE || "");\n if (!probe.length) return [];\n if (probe.lastIndexOf("__EXTENSIONJS_CSS_PROBE", 0) === 0) return [];\n var url = __EXTENSIONJS_runtimeGetURL(probe);\n if (typeof url !== "string" || !url.length) return [];\n if (url.charAt(url.length - 1) === "/") return [];\n return [url];\n } catch (error) { return []; }\n}\nfunction __EXTENSIONJS_scheduleBundleCssHydration(){\n try {\n if (String(__EXTENSIONJS_BUNDLE_KEY || "").indexOf(${JSON.stringify(CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX)}) !== 0) return;\n if (typeof document === "undefined" || typeof fetch !== "function") return;\n var cssUrls = Array.from(new Set((Array.isArray(__EXTENSIONJS_BUNDLE_CSS_URLS) ? __EXTENSIONJS_BUNDLE_CSS_URLS : []).concat(__EXTENSIONJS_bundleCssProbeUrls()).filter(function(value){ return typeof value === "string" && value.trim().length > 0; })));\n if (!cssUrls.length) return;\n var cssText = "";\n var cssPromise = null;\n var readCss = function(){\n if (cssPromise) return cssPromise;\n cssPromise = (function fetchCandidate(index){\n if (index >= cssUrls.length) return Promise.resolve("");\n return fetch(cssUrls[index]).then(function(response){\n if (!response || !response.ok) return "";\n return response.text();\n }).catch(function(){\n return "";\n }).then(function(text){\n if (typeof text === "string" && text.trim().length > 0) return text;\n return fetchCandidate(index + 1);\n });\n })(0).then(function(text){\n cssText = typeof text === "string" ? text : "";\n try { setTimeout(tick, 0); } catch (error) {}\n return cssText;\n }).catch(function(){ return ""; });\n return cssPromise;\n };\n var tries = 0;\n var tick = function(){\n try {\n var __extjsToken = __EXTENSIONJS_ownerToken();\n var hosts = Array.from(document.querySelectorAll("#extension-root,[data-extension-root]:not([data-extension-root=\\"extension-js-devtools\\"])"));\n for (var i = 0; i < hosts.length; i++) {\n var host = hosts[i];\n if (!host || !host.shadowRoot || typeof host.getAttribute !== "function") continue;\n 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 var sr = host.shadowRoot;\n var styles = Array.from(sr.querySelectorAll("style"));\n var hasUserStyle = styles.some(function(styleEl){\n return styleEl && styleEl.getAttribute("data-extjs-bundle-css") !== "true" && String(styleEl.textContent || "").trim().length > 0;\n });\n var injected = null;\n for (var s = 0; s < styles.length; s++) {\n if (!styles[s] || styles[s].getAttribute("data-extjs-bundle-css") !== "true") continue;\n var styleOwner = String(styles[s].getAttribute("data-extjs-style-owner") || "");\n if (!styleOwner || styleOwner === __extjsToken) { injected = styles[s]; break; }\n }\n if (hasUserStyle) {\n if (injected && injected.parentNode) injected.parentNode.removeChild(injected);\n return;\n }\n if (typeof cssText === "string" && cssText.trim()) {\n if (!injected) {\n injected = document.createElement("style");\n injected.setAttribute("data-extjs-bundle-css", "true");\n injected.setAttribute("data-extjs-reinject-key", String(__EXTENSIONJS_REINJECT_KEY || ""));\n sr.insertBefore(injected, sr.firstChild || null);\n }\n injected.setAttribute("data-extjs-style-owner", __extjsToken);\n if (String(injected.textContent || "") !== cssText) injected.textContent = cssText;\n return;\n }\n }\n } catch (error) {}\n if (tries++ < 20) {\n if (!cssPromise) readCss();\n setTimeout(tick, 250);\n }\n };\n tick();\n } catch (error) {}\n}\n`;
178
179
  const isBuiltInCompanion = /extension-js-(?:devtools|theme)/.test(String(packageJsonDir || ''));
179
180
  const bootstrap = `var __EXTENSIONJS_BUNDLE_KEY=${JSON.stringify(bundleKey)};\nvar __EXTENSIONJS_REINJECT_KEY=${JSON.stringify(reinjectKey)};\nvar __EXTENSIONJS_REINJECT_BUILD_TOKEN=${JSON.stringify(buildToken)};\nvar __EXTENSIONJS_NO_FOREIGN_ADOPT=${JSON.stringify(isBuiltInCompanion)};\nfunction __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}\nvar __EXTENSIONJS_DEV_MARKERS_ENABLED=${JSON.stringify(!isProd)};\nvar __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${cssAssetUrlsInline}var __EXTENSIONJS_REINJECT_REGISTRY=(typeof globalThis==="object" && globalThis ? (globalThis.__EXTENSIONJS_DEV_REINJECT__ || (globalThis.__EXTENSIONJS_DEV_REINJECT__={})) : {});\nvar __EXTENSIONJS_REGISTERED_CLEANUPS=[];\nfunction __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}\nfunction __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}\nfunction __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_debugObserveOwnedRootRemoval(){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_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_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}\nfunction __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 try { __EXTENSIONJS_cleanupKnownRoots(); } catch (error) {}\n try { __EXTENSIONJS_setReinjectMarker(__EXTENSIONJS_REINJECT_KEY, Number(__EXTENSIONJS_REINJECT_GENERATION) || 0, "cleaned"); } catch (error) {}\n };\n}\nfunction __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}\nfunction __EXTENSIONJS_patchDomRemovalApis(){\n try {\n if (!__EXTENSIONJS_DEV_MARKERS_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}\ntry {\n if (typeof globalThis === "object" && globalThis) {\n globalThis.__EXTENSIONJS_registerCleanup = __EXTENSIONJS_registerCleanup;\n globalThis.registerCleanup = __EXTENSIONJS_registerCleanup;\n }\n} catch (error) {}\n// Dev-only DOM instrumentation. Gated so production content scripts never\n// install a whole-document MutationObserver, monkey-patch Node.prototype\n// removal APIs, or write data-extjs-debug-* attributes onto the host page.\nif (__EXTENSIONJS_DEV_MARKERS_ENABLED) {\n try { __EXTENSIONJS_debugObserveOwnedRootRemoval(); } catch (error) {}\n try { __EXTENSIONJS_patchDomRemovalApis(); } catch (error) {}\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) {}\nfunction __EXTENSIONJS_syncAssetBase(){\n try {\n var base = "";\n try {\n if (typeof globalThis === "object" && globalThis && globalThis.browser && globalThis.browser.runtime && typeof globalThis.browser.runtime.getURL === "function") base = String(globalThis.browser.runtime.getURL("/"));\n else if (typeof globalThis === "object" && globalThis && globalThis.chrome && globalThis.chrome.runtime && typeof globalThis.chrome.runtime.getURL === "function") base = String(globalThis.chrome.runtime.getURL("/"));\n } catch (error) {}\n if (!base) {\n try {\n if (typeof document === "object" && document && document.documentElement) base = String(document.documentElement.getAttribute("data-extjs-extension-base") || "");\n } catch (error) {}\n }\n if (!base) return false;\n if (base.charAt(base.length - 1) !== "/") base += "/";\n if (typeof __webpack_require__ === "function" || typeof __webpack_require__ === "object") {\n try { __webpack_require__.p = base; } catch (error) {}\n try { __webpack_require__.b = base; } catch (error) {}\n }\n return true;\n } catch (error) {}\n return false;\n}\ntry {\n if (!__EXTENSIONJS_syncAssetBase()) {\n var __EXTENSIONJS_assetBaseRetries = 0;\n var __EXTENSIONJS_retryAssetBase = function(){\n try {\n if (__EXTENSIONJS_syncAssetBase()) return;\n } catch (error) {}\n if (__EXTENSIONJS_assetBaseRetries++ < 50) setTimeout(__EXTENSIONJS_retryAssetBase, 100);\n };\n __EXTENSIONJS_retryAssetBase();\n }\n} catch (error) {}\n`;
180
181
  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 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 __EXTENSIONJS_REINJECT_GENERATION = (Number(__EXTENSIONJS_REINJECT_GENERATION) || 0) + 1;\n try { cleanup.__extjsGeneration = __EXTENSIONJS_REINJECT_GENERATION; cleanup.__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] content script default export failed to run", error); } catch (ignored) {}\n 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`;
@@ -1,17 +1,79 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  const GETURL_ARG = /\bruntime\s*\.\s*getURL\s*\(/;
3
3
  const BARE_IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
4
- function identifierBoundToGetURL(source, name) {
5
- const id = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
- const rhs = '[^;\\n]*\\bruntime\\s*\\.\\s*getURL\\s*\\(';
7
- const declared = new RegExp('\\b(?:const|let|var)\\s+' + id + '\\s*=' + rhs);
8
- const assigned = new RegExp('(?:^|[^\\w$.])' + id + '\\s*=(?!=)' + rhs);
9
- return declared.test(source) || assigned.test(source);
4
+ const MEMBER_PATH = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)+$/;
5
+ const escapeId = (name)=>name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
+ function codeOnly(source) {
7
+ let out = '';
8
+ const n = source.length;
9
+ let i = 0;
10
+ let prevSignificant = '';
11
+ while(i < n){
12
+ const char = source[i];
13
+ const next = source[i + 1];
14
+ if ('/' === char && '/' === next) {
15
+ while(i < n && '\n' !== source[i])i++;
16
+ continue;
17
+ }
18
+ if ('/' === char && '*' === next) {
19
+ const end = source.indexOf('*/', i + 2);
20
+ i = -1 === end ? n : end + 2;
21
+ continue;
22
+ }
23
+ if ('"' === char || "'" === char || '`' === char) {
24
+ const close = skipString(source, i, n);
25
+ out += source.slice(i, close + 1);
26
+ i = close + 1;
27
+ prevSignificant = char;
28
+ continue;
29
+ }
30
+ if ('/' === char && regexCanStart(prevSignificant)) {
31
+ i = skipRegex(source, i, n) + 1;
32
+ prevSignificant = '/';
33
+ continue;
34
+ }
35
+ out += char;
36
+ if (!/\s/.test(char)) prevSignificant = char;
37
+ i++;
38
+ }
39
+ return out;
40
+ }
41
+ const RHS = '[\\s\\S]{0,400}?\\bruntime\\s*\\.\\s*getURL\\s*\\(';
42
+ const TYPE_ANNOTATION = '(?:\\s*:[^=;\\n]{0,120})?';
43
+ function identifierBoundToGetURL(code, name) {
44
+ const id = escapeId(name);
45
+ const declared = new RegExp('\\b(?:const|let|var)\\s+' + id + TYPE_ANNOTATION + '\\s*=' + RHS);
46
+ const assigned = new RegExp('(?:^|[^\\w$.])' + id + '\\s*=(?!=)' + RHS);
47
+ return declared.test(code) || assigned.test(code);
48
+ }
49
+ function memberBoundToGetURL(code, path) {
50
+ const parts = path.split('.').map((p)=>p.trim());
51
+ const leaf = escapeId(parts[parts.length - 1]);
52
+ const root = escapeId(parts[0]);
53
+ const property = new RegExp('\\b(?:const|let|var)\\s+' + root + TYPE_ANNOTATION + '\\s*=[\\s\\S]{0,400}?\\b' + leaf + '\\s*:[^,}]{0,200}?\\bruntime\\s*\\.\\s*getURL\\s*\\(');
54
+ const assigned = new RegExp('(?:^|[^\\w$])' + escapeId(path.replace(/\s+/g, '')) + '\\s*=(?!=)' + RHS);
55
+ return property.test(code) || assigned.test(code.replace(/\s*\.\s*/g, '.'));
56
+ }
57
+ function firstArgument(args) {
58
+ let depth = 0;
59
+ for(let i = 0; i < args.length; i++){
60
+ const char = args[i];
61
+ if ('"' === char || "'" === char || '`' === char) {
62
+ i = skipString(args, i, args.length);
63
+ continue;
64
+ }
65
+ if ('(' === char || '[' === char || '{' === char) depth++;
66
+ else if (')' === char || ']' === char || '}' === char) depth--;
67
+ else if (',' === char && 0 === depth) return args.slice(0, i);
68
+ }
69
+ return args;
10
70
  }
11
71
  function annotateGetURLDynamicImports(source) {
12
72
  const insertions = [];
13
73
  const n = source.length;
14
74
  let i = 0;
75
+ let cachedCode = null;
76
+ const bindingSource = ()=>cachedCode ??= codeOnly(source);
15
77
  let prevSignificant = '';
16
78
  while(i < n){
17
79
  const char = source[i];
@@ -41,9 +103,11 @@ function annotateGetURLDynamicImports(source) {
41
103
  if ('(' === source[j]) {
42
104
  const args = readBalancedArgs(source, j);
43
105
  if (null != args && !args.includes('webpackIgnore')) {
44
- const direct = GETURL_ARG.test(args);
45
- const name = args.trim();
46
- if (direct || BARE_IDENTIFIER.test(name) && identifierBoundToGetURL(source, name)) insertions.push(j + 1);
106
+ const specifier = firstArgument(args);
107
+ const direct = GETURL_ARG.test(specifier);
108
+ const name = specifier.trim();
109
+ const code = bindingSource();
110
+ if (direct || BARE_IDENTIFIER.test(name) && identifierBoundToGetURL(code, name) || MEMBER_PATH.test(name) && memberBoundToGetURL(code, name)) insertions.push(j + 1);
47
111
  }
48
112
  }
49
113
  prevSignificant = 't';
@@ -3,11 +3,11 @@ const safeHistory = "u" > typeof globalThis ? globalThis.history : void 0;
3
3
  try {
4
4
  if ('object' == typeof safeLocation && safeLocation && String(safeLocation.protocol || '').includes('-extension:')) {
5
5
  const q = String(safeLocation.search || '').toLowerCase();
6
- const alreadySet = q.includes('rspack-dev-server-hot=false') && q.includes('webpack-dev-server-hot=false');
7
- if (!alreadySet && 'function' == typeof URL && 'object' == typeof safeHistory && safeHistory && 'function' == typeof safeHistory.replaceState) {
6
+ const hasStaleGuards = q.includes('rspack-dev-server-hot=false') || q.includes('webpack-dev-server-hot=false');
7
+ if (hasStaleGuards && 'function' == typeof URL && 'object' == typeof safeHistory && safeHistory && 'function' == typeof safeHistory.replaceState) {
8
8
  const u = new URL(String(safeLocation.href));
9
- u.searchParams.set('rspack-dev-server-hot', 'false');
10
- u.searchParams.set('webpack-dev-server-hot', 'false');
9
+ u.searchParams.delete('rspack-dev-server-hot');
10
+ u.searchParams.delete('webpack-dev-server-hot');
11
11
  safeHistory.replaceState(null, '', u.toString());
12
12
  }
13
13
  }
@@ -3,11 +3,11 @@ const safeHistory = "u" > typeof globalThis ? globalThis.history : void 0;
3
3
  try {
4
4
  if ('object' == typeof safeLocation && safeLocation && String(safeLocation.protocol || '').includes('-extension:')) {
5
5
  const q = String(safeLocation.search || '').toLowerCase();
6
- const alreadySet = q.includes('rspack-dev-server-hot=false') && q.includes('webpack-dev-server-hot=false');
7
- if (!alreadySet && 'function' == typeof URL && 'object' == typeof safeHistory && safeHistory && 'function' == typeof safeHistory.replaceState) {
6
+ const hasStaleGuards = q.includes('rspack-dev-server-hot=false') || q.includes('webpack-dev-server-hot=false');
7
+ if (hasStaleGuards && 'function' == typeof URL && 'object' == typeof safeHistory && safeHistory && 'function' == typeof safeHistory.replaceState) {
8
8
  const u = new URL(String(safeLocation.href));
9
- u.searchParams.set('rspack-dev-server-hot', 'false');
10
- u.searchParams.set('webpack-dev-server-hot', 'false');
9
+ u.searchParams.delete('rspack-dev-server-hot');
10
+ u.searchParams.delete('webpack-dev-server-hot');
11
11
  safeHistory.replaceState(null, '', u.toString());
12
12
  }
13
13
  }
@@ -17,7 +17,7 @@ export declare function dispatchReload(instruction: ReloadInstruction | undefine
17
17
  export interface ChangedSourcesSnapshot {
18
18
  /** A manifest.json / _locales change, forces a full reload regardless of which other files changed. */
19
19
  forcedFull: boolean;
20
- /** Project-relative, forward-slashed paths of every file changed since the last compile. */
20
+ /** Project-relative, forward-slashed paths of every file changed since the last successful compile. */
21
21
  changedSources: string[];
22
22
  }
23
23
  export interface ChangedSourcesTracker {
@@ -1,13 +1,11 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  import type { DevOptions, Manifest, PluginInterface } from '../../../types';
3
- export declare function getBackgroundEntryName(manifest: Manifest, browser: DevOptions['browser']): {
4
- pageEntry: string;
5
- tryCatchWrapper: boolean;
6
- eagerChunkLoading: boolean;
7
- serviceWorkerEntry?: undefined;
8
- } | {
9
- pageEntry?: undefined;
10
- serviceWorkerEntry: string;
3
+ export declare function getBackgroundEntryName(manifest: Manifest, browser: DevOptions['browser'], context: {
4
+ manifestDir: string;
5
+ projectPath?: string;
6
+ }): {
7
+ pageEntry?: string;
8
+ serviceWorkerEntry?: string;
11
9
  tryCatchWrapper: boolean;
12
10
  eagerChunkLoading: boolean;
13
11
  };
@@ -1,3 +1,4 @@
1
- import * as parse5utilities from 'parse5-utilities';
1
+ import type * as parse5utilities from 'parse5-utilities';
2
2
  import type { FilepathList } from '../../../types';
3
- export declare function handleStaticAsset(compilation: unknown, htmlEntry: string, htmlDir: string, absolutePath: string, assetType: 'staticSrc' | 'staticHref', cleanPath: string, search: string | undefined, hash: string | undefined, baseHref: string | undefined, includeList: FilepathList, extname: string, childNode: parse5utilities.ParsedNode): parse5utilities.ParsedNode;
3
+ import type { HtmlStaticAttribute } from './parse-html';
4
+ export declare function handleStaticAsset(compilation: unknown, htmlEntry: string, htmlDir: string, absolutePath: string, assetType: 'staticSrc' | 'staticHref', cleanPath: string, search: string | undefined, hash: string | undefined, baseHref: string | undefined, includeList: FilepathList, extname: string, childNode: parse5utilities.ParsedNode, attributeName?: HtmlStaticAttribute): parse5utilities.ParsedNode;
@@ -1,8 +1,10 @@
1
1
  import type * as parse5utilities from 'parse5-utilities';
2
+ export type HtmlStaticAttribute = 'src' | 'href' | 'poster' | 'srcset' | 'imagesrcset';
2
3
  interface OnResourceFoundOptions {
3
4
  filePath: string;
4
5
  childNode: ReturnType<typeof parse5utilities.createNode>;
5
6
  assetType: 'script' | 'css' | 'staticSrc' | 'staticHref';
7
+ attributeName?: HtmlStaticAttribute;
6
8
  }
7
9
  export declare function parseHtml(node: ReturnType<typeof parse5utilities.createNode>, onResourceFound: (options: OnResourceFoundOptions) => void): void;
8
10
  export {};
@@ -1,4 +1,6 @@
1
+ import * as parse5utilities from 'parse5-utilities';
1
2
  import type { FilepathList } from '../../../types';
3
+ import { type HtmlStaticAttribute } from './parse-html';
2
4
  export interface ParsedHtmlAsset {
3
5
  css?: string[];
4
6
  js?: string[];
@@ -12,6 +14,10 @@ export declare function getExtname(filePath: string): string;
12
14
  export declare function getFilePath(filePath: string, extension: string, isPublic: boolean): string;
13
15
  export declare function isFromIncludeList(filePath: string, includeList?: FilepathList): boolean;
14
16
  export declare function isUrl(src: string): boolean;
17
+ export type { HtmlStaticAttribute };
18
+ export declare function resolveStaticAttributeName(assetType: 'staticSrc' | 'staticHref', attributeName?: HtmlStaticAttribute): HtmlStaticAttribute;
19
+ export declare function rewriteSrcsetCandidate(srcset: string, fromCleanPath: string, toUrl: string): string;
20
+ export declare function applyRewrittenStaticUrl(node: parse5utilities.ParsedNode, attributeName: HtmlStaticAttribute, cleanPath: string, value: string): parse5utilities.ParsedNode;
15
21
  export declare function cleanAssetUrl(url: string): {
16
22
  cleanPath: string;
17
23
  hash: string;
@@ -0,0 +1,6 @@
1
+ export interface ResolvedJsonResource {
2
+ abs: string;
3
+ isUnderPublic: boolean;
4
+ isPublicRoot: boolean;
5
+ }
6
+ export declare function resolveJsonResource(thisResource: string, manifestDir: string, projectPath: string): ResolvedJsonResource;
@@ -1,5 +1,5 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function storage(manifest: Manifest): {
2
+ export declare function storage(manifest: Manifest, manifestPath?: string): {
3
3
  storage: {
4
4
  managed_schema?: string | undefined;
5
5
  };
@@ -1,2 +1,2 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function declarativeNetRequest(manifest: Manifest): any;
2
+ export declare function declarativeNetRequest(manifest: Manifest, manifestPath?: string): any;
@@ -1,2 +1,2 @@
1
1
  import type { Manifest } from '../../../../types';
2
- export declare function manifestV3(manifest: Manifest): any;
2
+ export declare function manifestV3(manifest: Manifest, manifestPath?: string): any;
@@ -10,3 +10,6 @@ export declare function parseCanonicalContentScriptAsset(assetName: string): {
10
10
  extension: 'js' | 'css';
11
11
  } | undefined;
12
12
  export declare function isCanonicalContentScriptAsset(assetName: string): boolean;
13
+ export declare const CONTENT_SCRIPT_CSS_PROBE_MARKER_PREFIX = "__EXTENSIONJS_CSS_PROBE__";
14
+ export declare function getContentScriptCssProbeMarker(entryName: string): string;
15
+ export declare function createContentScriptCssProbeMarkerPattern(): RegExp;
@@ -1,2 +1,11 @@
1
+ import type { DevOptions, Manifest } from '../../../types';
2
+ export declare const isRemoteUrl: (entry: string) => boolean;
3
+ export declare function resolveScriptEntryPath(entry: string, manifestDir: string, projectPath: string): string;
4
+ export declare function getBackgroundWorkerEntryName(options: {
5
+ manifest: Manifest;
6
+ browser: DevOptions['browser'];
7
+ manifestDir: string;
8
+ projectPath?: string;
9
+ }): 'background/service_worker' | 'background/scripts' | undefined;
1
10
  export declare function getScriptEntries(scriptPath: string | string[] | undefined): string[];
2
11
  export declare function getCssEntries(scriptPath: string | string[] | undefined): string[];
@@ -1,5 +1,6 @@
1
- import type { Compiler } from '@rspack/core';
1
+ import { type Compiler } from '@rspack/core';
2
2
  import type { DevOptions, FilepathList, PluginInterface } from '../../../../types';
3
+ export declare function resolveBundleCssProbeMarker(cssPath: string, hasAsset: (name: string) => boolean, assetNames: () => string[]): string;
3
4
  export declare class AddContentScriptWrapper {
4
5
  static getBridgeScripts(manifestPath: string, browser?: DevOptions['browser']): FilepathList;
5
6
  private readonly manifestPath;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.1.9",
46
+ "version": "4.1.11",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",
@@ -99,7 +99,7 @@
99
99
  "@rspack/plugin-react-refresh": "2.0.2",
100
100
  "@vue/compiler-sfc": "3.5.26",
101
101
  "acorn": "^8.16.0",
102
- "browser-extension-manifest-fields": "^2.3.0",
102
+ "browser-extension-manifest-fields": "^2.3.1",
103
103
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
104
104
  "content-security-policy-parser": "^0.6.0",
105
105
  "dotenv": "^17.2.3",