extension-develop 4.1.39 → 4.1.40-canary.459.2c1ba7b

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 (210) hide show
  1. package/README.md +13 -10
  2. package/dist/{771~0.mjs → 5h~0.mjs} +13 -3
  3. package/dist/{273~0.mjs → 6l~0.mjs} +1 -1
  4. package/dist/{524~0.mjs → 9~0.mjs} +18 -2
  5. package/dist/{640~0.mjs → bh~0.mjs} +6 -1
  6. package/dist/bridge.mjs +14 -8
  7. package/dist/b~0.mjs +8644 -0
  8. package/dist/command-dev.d.ts +2 -0
  9. package/dist/command-preview.d.ts +2 -0
  10. package/dist/contracts.mjs +2 -1
  11. package/dist/{469~0.mjs → cp~0.mjs} +66 -17
  12. package/dist/css-parse-guard-loader.mjs +2 -2
  13. package/dist/c~0.mjs +56 -0
  14. package/dist/dead-css-url-loader.mjs +20 -119
  15. package/dist/dev-server/control-bridge/actions-file.d.ts +7 -0
  16. package/dist/dev-server/control-bridge/broker.d.ts +42 -2
  17. package/dist/dev-server/control-bridge/consumer-client.d.ts +7 -0
  18. package/dist/dev-server/control-bridge/contracts.d.ts +29 -1
  19. package/dist/dev-server/control-bridge/logs-file.d.ts +6 -0
  20. package/dist/dev-server/control-bridge/loopback.d.ts +1 -0
  21. package/dist/dev-server/control-bridge/producer-runtime.d.ts +5 -2
  22. package/dist/dev-server/control-bridge/production-control.d.ts +1 -0
  23. package/dist/dev-server/control-bridge/session-token.d.ts +5 -2
  24. package/dist/dev-server/cors.d.ts +4 -2
  25. package/dist/dev-server/messages.d.ts +6 -0
  26. package/dist/dev-server/session-restart.d.ts +3 -1
  27. package/dist/dev-server~0.mjs +71 -129
  28. package/dist/df~0.mjs +197 -0
  29. package/dist/{846~0.mjs → d~0.mjs} +4 -3
  30. package/dist/ensure-hmr-for-scripts.js +3 -3
  31. package/dist/ensure-hmr-for-scripts.mjs +3 -3
  32. package/dist/extension-js-devtools/build-stamp.json +2 -2
  33. package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
  34. package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
  35. package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
  36. package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
  37. package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
  38. package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
  39. package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
  40. package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
  41. package/dist/extension-js-theme/build-stamp.json +2 -2
  42. package/dist/{143~0.mjs → ey~0.mjs} +2 -2
  43. package/dist/e~0.mjs +33 -0
  44. package/dist/feature-scripts-classic-traced-globals-loader.mjs +7 -2
  45. package/dist/feature-scripts-content-script-wrapper.js +56 -18
  46. package/dist/feature-scripts-content-script-wrapper.mjs +56 -18
  47. package/dist/feature-scripts-native-geturl-import-loader.mjs +1 -1
  48. package/dist/{105~0.mjs → g0~0.mjs} +1 -1
  49. package/dist/{88~0.mjs → j6~0.mjs} +9 -1
  50. package/dist/{731~0.mjs → j~0.mjs} +2 -2
  51. package/dist/{712~0.mjs → ka~0.mjs} +18 -2
  52. package/dist/{852~0.mjs → k~0.mjs} +4 -2
  53. package/dist/late-css-import-loader.mjs +1 -1
  54. package/dist/lib/addon-lint.d.ts +6 -0
  55. package/dist/lib/build-summary.d.ts +6 -0
  56. package/dist/lib/dev-additions.d.ts +12 -0
  57. package/dist/lib/extension-base-from-stack.d.ts +16 -0
  58. package/dist/lib/localized-manifest-name.d.ts +9 -0
  59. package/dist/lib/manifest-types.d.ts +276 -0
  60. package/dist/lib/messages.d.ts +6 -2
  61. package/dist/lib/process-started-at.d.ts +1 -0
  62. package/dist/lib/real-path.d.ts +8 -0
  63. package/dist/lib/resource-path.d.ts +1 -0
  64. package/dist/lib/session-paths.d.ts +2 -0
  65. package/dist/lib/split-chunks.d.ts +2 -1
  66. package/dist/lib/stats-handler.d.ts +1 -0
  67. package/dist/lib/tsconfig-includes-file.d.ts +1 -0
  68. package/dist/l~0.mjs +2290 -0
  69. package/dist/main-world-bridge.js +92 -23
  70. package/dist/main-world-bridge.mjs +92 -23
  71. package/dist/manifest-entry.d.ts +2 -0
  72. package/dist/manifest.mjs +3 -1
  73. package/dist/module.mjs +3 -3
  74. package/dist/{832~0.mjs → m~0.mjs} +2244 -288
  75. package/dist/o~0.mjs +47 -0
  76. package/dist/plugin-browsers/index.d.ts +7 -0
  77. package/dist/plugin-browsers/safari-dev-plugin.d.ts +2 -0
  78. package/dist/plugin-compatibility/compatibility-lib/messages.d.ts +5 -1
  79. package/dist/plugin-compatibility/compatibility-lib/native-browser-namespace.d.ts +5 -0
  80. package/dist/plugin-compatibility/feature-browser-global.d.ts +11 -1
  81. package/dist/plugin-compatibility/index.d.ts +2 -0
  82. package/dist/plugin-compilation/compilation-lib/messages.d.ts +4 -1
  83. package/dist/plugin-compilation/env.d.ts +1 -0
  84. package/dist/plugin-compilation/index.d.ts +2 -0
  85. package/dist/plugin-compilation/node-builtins.d.ts +5 -0
  86. package/dist/plugin-compilation/one-diagnostic-per-location.d.ts +13 -0
  87. package/dist/plugin-compilation/resolve-file-requests.d.ts +16 -0
  88. package/dist/plugin-compilation/warm-ancestor-watchers.d.ts +19 -0
  89. package/dist/plugin-compilation/watch-real-project-path.d.ts +27 -0
  90. package/dist/plugin-compilation/zip.d.ts +2 -0
  91. package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
  92. package/dist/plugin-css/css-lib/build-css-rules.d.ts +3 -0
  93. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +3 -1
  94. package/dist/plugin-css/css-lib/messages.d.ts +4 -0
  95. package/dist/plugin-css/css-lib/sfc-style-block.d.ts +26 -0
  96. package/dist/plugin-css/css-lib/unplaced-style-imports.d.ts +7 -0
  97. package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
  98. package/dist/plugin-css/dead-css-url-loader.d.ts +9 -1
  99. package/dist/plugin-css/index.d.ts +1 -0
  100. package/dist/plugin-css/sfc-style-block-loader.d.ts +18 -0
  101. package/dist/plugin-css/unplaced-style-import-loader.d.ts +16 -0
  102. package/dist/plugin-playwright/index.d.ts +22 -0
  103. package/dist/plugin-reload/classify-reload.d.ts +20 -0
  104. package/dist/plugin-reload/index.d.ts +4 -2
  105. package/dist/plugin-reload/messages.d.ts +1 -0
  106. package/dist/plugin-reload/reload-dispatch.d.ts +21 -2
  107. package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +6 -0
  108. package/dist/plugin-reload/reload-lib/scripts-replay-shim.d.ts +1 -1
  109. package/dist/plugin-reload/steps/inject-bridge-producer.d.ts +6 -0
  110. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/ChunkLoader.d.ts +3 -0
  111. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/AutoPublicPath.d.ts +1 -1
  112. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/BaseUri.d.ts +1 -1
  113. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/LoadScript.d.ts +1 -1
  114. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/PublicPath.d.ts +1 -1
  115. package/dist/plugin-special-folders/get-data.d.ts +2 -0
  116. package/dist/plugin-special-folders/hint-import-only-scripts.d.ts +4 -0
  117. package/dist/plugin-special-folders/include-files.d.ts +2 -0
  118. package/dist/plugin-special-folders/messages.d.ts +1 -0
  119. package/dist/plugin-web-extension/feature-html/html-lib/inject.d.ts +1 -1
  120. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +1 -0
  121. package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
  122. package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +1 -0
  123. package/dist/plugin-web-extension/feature-icons/extract-icon-variants.d.ts +2 -0
  124. package/dist/plugin-web-extension/feature-json/json-validation.d.ts +2 -1
  125. package/dist/plugin-web-extension/feature-json/messages.d.ts +2 -0
  126. package/dist/plugin-web-extension/feature-json/process-assets.d.ts +1 -1
  127. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-gecko.d.ts +21 -0
  128. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -1
  129. package/dist/plugin-web-extension/feature-manifest/manifest-lib/icon-variants-fallback.d.ts +15 -0
  130. package/dist/plugin-web-extension/feature-manifest/manifest-lib/sanitize-fatal-shapes.d.ts +2 -1
  131. package/dist/plugin-web-extension/feature-manifest/manifest-lib/webkit-unsupported-keys.d.ts +15 -0
  132. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/content_scripts.d.ts +1 -1
  133. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/icons.d.ts +3 -2
  134. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/omnibox.d.ts +1 -1
  135. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/page_action.d.ts +2 -1
  136. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/permissions.d.ts +1 -1
  137. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
  138. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/browser_action.d.ts +4 -3
  139. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +3 -2
  140. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +15 -1
  141. package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +2 -0
  142. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-additions.d.ts +8 -0
  143. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-background.d.ts +2 -2
  144. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-externally-connectable.d.ts +1 -1
  145. package/dist/plugin-web-extension/feature-manifest/steps/patch-gecko-background.d.ts +1 -0
  146. package/dist/plugin-web-extension/feature-manifest/steps/warn-content-script-host-access.d.ts +17 -0
  147. package/dist/plugin-web-extension/feature-manifest/steps/warn-description-length.d.ts +26 -0
  148. package/dist/plugin-web-extension/feature-manifest/steps/warn-gecko-unsupported-apis.d.ts +37 -2
  149. package/dist/plugin-web-extension/feature-scripts/contracts.d.ts +3 -0
  150. package/dist/plugin-web-extension/feature-scripts/index.d.ts +1 -0
  151. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +10 -1
  152. package/dist/plugin-web-extension/feature-scripts/scripts-lib/completion-value.d.ts +13 -0
  153. package/dist/plugin-web-extension/feature-scripts/scripts-lib/injected-sheet-urls.d.ts +5 -0
  154. package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-bridge-pairing.d.ts +5 -0
  155. package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-copy-routing.d.ts +2 -0
  156. package/dist/plugin-web-extension/feature-scripts/scripts-lib/registration-worlds.d.ts +10 -0
  157. package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-main-world-scripts.d.ts +25 -2
  158. package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-script-sheet.d.ts +14 -0
  159. package/dist/plugin-web-extension/feature-scripts/scripts-lib/taken-extension-base.d.ts +10 -0
  160. package/dist/plugin-web-extension/feature-scripts/steps/add-base-uri-runtime-module.d.ts +7 -1
  161. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +2 -0
  162. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +2 -0
  163. package/dist/plugin-web-extension/feature-scripts/steps/add-public-path-runtime-module.d.ts +6 -0
  164. package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +1 -0
  165. package/dist/plugin-web-extension/feature-scripts/steps/compile-main-world-scripts.d.ts +4 -0
  166. package/dist/plugin-web-extension/feature-scripts/steps/keep-completion-value.d.ts +6 -0
  167. package/dist/plugin-web-extension/feature-scripts/steps/pair-runtime-main-world-bridges.d.ts +12 -0
  168. package/dist/plugin-web-extension/feature-scripts/steps/place-runtime-script-sheets.d.ts +12 -0
  169. package/dist/plugin-web-extension/feature-scripts/steps/prune-main-world-bridges.d.ts +1 -0
  170. package/dist/plugin-web-extension/feature-scripts/steps/root-injected-sheet-urls.d.ts +9 -0
  171. package/dist/plugin-web-extension/feature-scripts/steps/route-main-world-copies.d.ts +10 -0
  172. package/dist/plugin-web-extension/feature-scripts/steps/source-literals.d.ts +24 -0
  173. package/dist/plugin-web-extension/feature-scripts/steps/take-extension-base.d.ts +11 -0
  174. package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +18 -3
  175. package/dist/plugin-web-extension/feature-scripts/steps/warn-main-world-registration-changed.d.ts +12 -0
  176. package/dist/plugin-web-extension/feature-scripts/steps/warn-moved-page-relative-urls.d.ts +30 -0
  177. package/dist/plugin-web-extension/feature-scripts/steps/warn-page-relative-script-path.d.ts +10 -0
  178. package/dist/plugin-web-extension/feature-scripts/steps/warn-unknown-registration-world.d.ts +10 -0
  179. package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
  180. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +2 -0
  181. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/page-requests.d.ts +5 -0
  182. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +1 -0
  183. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/unreachable-resources.d.ts +1 -0
  184. package/dist/plugin-web-extension/shared/script-graph.d.ts +12 -0
  185. package/dist/preprocessor-passthrough-loader.mjs +1 -1
  186. package/dist/preview.mjs +1 -1
  187. package/dist/public-css-url-loader.mjs +1 -1
  188. package/dist/{331~0.mjs → q~0.mjs} +2 -2
  189. package/dist/rj~0.mjs +125 -0
  190. package/dist/{519~0.mjs → rl~0.mjs} +56 -5
  191. package/dist/rspack-config~0.mjs +3140 -3302
  192. package/dist/{177~0.mjs → r~0.mjs} +2 -2
  193. package/dist/sfc-style-block-loader.mjs +49 -0
  194. package/dist/stats-handler~0.mjs +15 -7
  195. package/dist/tm~0.mjs +71 -0
  196. package/dist/types.d.ts +46 -5
  197. package/dist/{285~0.mjs → t~0.mjs} +41 -26
  198. package/dist/unplaced-style-import-loader.mjs +131 -0
  199. package/dist/x~0.mjs +3 -0
  200. package/dist/y~0.mjs +234 -0
  201. package/dist/zip~0.mjs +5 -4
  202. package/dist/{363~0.mjs → z~0.mjs} +563 -281
  203. package/package.json +6 -6
  204. package/dist/527~0.mjs +0 -3
  205. package/dist/840~0.mjs +0 -5635
  206. /package/dist/{895~0.mjs → 3~0.mjs} +0 -0
  207. /package/dist/{374~0.mjs → 5~0.mjs} +0 -0
  208. /package/dist/{206~0.mjs → 6~0.mjs} +0 -0
  209. /package/dist/{471~0.mjs → g~0.mjs} +0 -0
  210. /package/dist/{117~0.mjs → w~0.mjs} +0 -0
@@ -2,20 +2,231 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
2
2
  import { Compilation, DefinePlugin, ProvidePlugin, WebpackError, sources } from "@rspack/core";
3
3
  import { createRequire } from "node:module";
4
4
  import pintor from "pintor";
5
- import { publicRelativePath, findPublicFile, inspectPublicFolders } from "./105~0.mjs";
6
- import { isChromiumBasedBrowser, CHROMIUM_FAMILY_ALIASES, GECKO_FAMILY_ALIASES, isWebkitBasedBrowser, isGeckoBasedBrowser } from "./331~0.mjs";
7
- import { parseCanonicalContentScriptAsset, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName } from "./640~0.mjs";
8
- import { stripBom, parseJsonSafe } from "./374~0.mjs";
9
- import { debugLine, isDebug, humanLine, prefix as messaging_prefix } from "./852~0.mjs";
10
- import { filterKeysForThisBrowser } from "./143~0.mjs";
11
- import { displayPath } from "./469~0.mjs";
12
- import { getPreloadedEnvKeys } from "./846~0.mjs";
5
+ import { real_path_isOsPathUnder } from "./tm~0.mjs";
6
+ import { publicRelativePath, findPublicFile, inspectPublicFolders } from "./g0~0.mjs";
7
+ import { isChromiumBasedBrowser, CHROMIUM_FAMILY_ALIASES, GECKO_FAMILY_ALIASES, SUPPORTED_BROWSERS, isWebkitBasedBrowser, WEBKIT_BASED_BROWSERS, isGeckoBasedBrowser } from "./q~0.mjs";
8
+ import { parseCanonicalContentScriptAsset, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName } from "./bh~0.mjs";
9
+ import { stripBom, parseJsonSafe } from "./5~0.mjs";
10
+ import { debugLine, isDebug, humanLine, prefix as messaging_prefix } from "./k~0.mjs";
11
+ import { WEBKIT_UNSUPPORTED_TOP_LEVEL_KEYS, WEBKIT_UNSUPPORTED_OPTIONS_UI_KEYS, WEBKIT_UNSUPPORTED_PERMISSIONS } from "./rj~0.mjs";
12
+ import { filterKeysForThisBrowser } from "./ey~0.mjs";
13
+ import { displayPath } from "./cp~0.mjs";
14
+ import { getPreloadedEnvKeys } from "./d~0.mjs";
13
15
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
14
16
  import { dirname as __rspack_dirname } from "node:path";
15
17
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
16
18
  import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
17
19
  import * as __rspack_external_node_path_806ed179 from "node:path";
18
20
  import * as __rspack_external_dotenv from "dotenv";
21
+ const DEV_SESSION_RESTART_DEBOUNCE_MS = 300;
22
+ class DevSessionRestartScheduler {
23
+ debounceMs;
24
+ handler = null;
25
+ timer;
26
+ latest = null;
27
+ inFlight = false;
28
+ constructor(debounceMs = DEV_SESSION_RESTART_DEBOUNCE_MS){
29
+ this.debounceMs = Math.max(0, debounceMs);
30
+ }
31
+ setHandler(handler) {
32
+ this.handler = handler;
33
+ }
34
+ request(request) {
35
+ this.latest = request;
36
+ if (this.inFlight) return;
37
+ this.schedule();
38
+ }
39
+ isPending() {
40
+ return null != this.latest || this.inFlight;
41
+ }
42
+ dispose() {
43
+ if (this.timer) clearTimeout(this.timer);
44
+ this.timer = void 0;
45
+ this.latest = null;
46
+ this.handler = null;
47
+ }
48
+ schedule() {
49
+ if (this.timer) clearTimeout(this.timer);
50
+ if (0 === this.debounceMs) return void this.flush();
51
+ this.timer = setTimeout(()=>{
52
+ this.timer = void 0;
53
+ this.flush();
54
+ }, this.debounceMs);
55
+ this.timer.unref?.();
56
+ }
57
+ async flush() {
58
+ if (this.inFlight) return;
59
+ const request = this.latest;
60
+ const handler = this.handler;
61
+ if (!request || !handler) return;
62
+ this.latest = null;
63
+ this.inFlight = true;
64
+ try {
65
+ await handler(request);
66
+ } catch {} finally{
67
+ this.inFlight = false;
68
+ if (this.latest) this.schedule();
69
+ }
70
+ }
71
+ }
72
+ let boundScheduler = null;
73
+ const restartingCompilers = new WeakSet();
74
+ function bindDevSessionRestart(scheduler) {
75
+ boundScheduler = scheduler;
76
+ }
77
+ function unbindDevSessionRestart() {
78
+ boundScheduler = null;
79
+ }
80
+ function canAutoRestartDevSession() {
81
+ return null != boundScheduler;
82
+ }
83
+ function requestDevSessionRestart(compiler, request) {
84
+ if (!boundScheduler) return false;
85
+ if (compiler) restartingCompilers.add(compiler);
86
+ boundScheduler.request(request);
87
+ return true;
88
+ }
89
+ function isCompilerRestarting(compiler) {
90
+ return null != compiler && restartingCompilers.has(compiler);
91
+ }
92
+ function isFromFilepathList(filePath, filepathList) {
93
+ return Object.values(filepathList || {}).some((value)=>value === filePath);
94
+ }
95
+ function isFolder(filePath) {
96
+ try {
97
+ return __rspack_external_node_fs_1b05aee1.statSync(filePath).isDirectory();
98
+ } catch {
99
+ return false;
100
+ }
101
+ }
102
+ function getFilename(feature, filePath) {
103
+ const entryExt = __rspack_external_node_path_806ed179.extname(filePath);
104
+ let fileOutputpath = feature;
105
+ if ([
106
+ '.js',
107
+ '.jsx',
108
+ '.tsx',
109
+ '.ts',
110
+ '.vue',
111
+ '.svelte'
112
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.js');
113
+ if ([
114
+ '.html',
115
+ '.njk',
116
+ '.nunjucks'
117
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.html');
118
+ if ([
119
+ '.css',
120
+ '.scss',
121
+ '.sass',
122
+ '.less'
123
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.css');
124
+ return unixify(fileOutputpath || '');
125
+ }
126
+ function unixify(filePath) {
127
+ return filePath.replace(/\\/g, '/');
128
+ }
129
+ function resolveRootAbsoluteRef(ref, projectRoot, publicRoot) {
130
+ if (!ref || !ref.startsWith('/')) return;
131
+ if (projectRoot && real_path_isOsPathUnder(projectRoot, ref)) return;
132
+ if (ref.startsWith('//')) return;
133
+ const trimmed = ref.replace(/^\/+/, '');
134
+ if (!trimmed) return;
135
+ if (publicRoot && __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(publicRoot, trimmed))) return;
136
+ const candidate = __rspack_external_node_path_806ed179.resolve(projectRoot, trimmed);
137
+ const rel = __rspack_external_node_path_806ed179.relative(projectRoot, candidate);
138
+ if (rel.startsWith('..') || __rspack_external_node_path_806ed179.isAbsolute(rel)) return;
139
+ if (!__rspack_external_node_fs_1b05aee1.existsSync(candidate) || !__rspack_external_node_fs_1b05aee1.statSync(candidate).isFile()) return;
140
+ return candidate;
141
+ }
142
+ function collectRootAbsoluteRefs(source) {
143
+ const refs = new Set();
144
+ const attrRe = /(?:src|href)\s*=\s*["'](\/[^"'#?]*)["']/gi;
145
+ const urlRe = /url\(\s*["']?(\/[^"')#?]+)["']?\s*\)/gi;
146
+ let m;
147
+ while(m = attrRe.exec(source))refs.add(m[1]);
148
+ while(m = urlRe.exec(source))refs.add(m[1]);
149
+ return refs;
150
+ }
151
+ function isManifestAddress(value) {
152
+ if ('string' != typeof value) return false;
153
+ const trimmed = value.trim();
154
+ return /^[a-z][a-z0-9+.-]+:/i.test(trimmed) || trimmed.startsWith('//');
155
+ }
156
+ function normalizeManifestOutputPath(originalPath) {
157
+ if (!originalPath) return originalPath;
158
+ const unixPath = originalPath.replace(/\\/g, '/');
159
+ if (/^\/public\//i.test(unixPath)) return unixPath.replace(/^\/public\//i, '');
160
+ if (/^(?:\.\/)?public\//i.test(unixPath)) return unixPath.replace(/^(?:\.\/)?public\//i, '');
161
+ if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
162
+ return unixPath;
163
+ }
164
+ function manifestPageOutputTarget(raw, compiledTarget, manifestPath, projectPath) {
165
+ const unixPath = raw.replace(/\\/g, '/');
166
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(unixPath)) return normalizeManifestOutputPath(unixPath);
167
+ if (/^\//.test(unixPath)) {
168
+ const rest = unixPath.replace(/^\/+/, '');
169
+ if (manifestPath && rest) {
170
+ const manifestDir = __rspack_external_node_path_806ed179.dirname(manifestPath);
171
+ const inPublic = Boolean(findPublicFile(manifestPath, projectPath, rest));
172
+ const inRoot = __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(manifestDir, rest));
173
+ if (inRoot && !inPublic) return compiledTarget;
174
+ }
175
+ return normalizeManifestOutputPath(unixPath);
176
+ }
177
+ const rest = unixPath.replace(/^\.\//, '');
178
+ if (!manifestPath || !rest || rest.split('/').includes('..')) return compiledTarget;
179
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(__rspack_external_node_path_806ed179.dirname(manifestPath), rest))) return compiledTarget;
180
+ if (findPublicFile(manifestPath, projectPath, rest)) return rest;
181
+ return compiledTarget;
182
+ }
183
+ function manifestJsonOutputTarget(raw, compiledTarget, manifestPath, projectPath) {
184
+ return manifestPageOutputTarget(raw, compiledTarget, manifestPath, projectPath);
185
+ }
186
+ function pathEscapesExtensionRoot(normalized) {
187
+ return !normalized || normalized.split('/').includes('..') || /^[A-Za-z]:/.test(normalized);
188
+ }
189
+ function externalAssetOutputPath(normalized, root) {
190
+ const unix = normalized.replace(/\\/g, '/');
191
+ const noDrive = unix.replace(/^([A-Za-z]):(?:\/|$)/, '_drive_$1/');
192
+ const safe = noDrive.split('/').map((segment)=>{
193
+ if ('..' === segment) return '_';
194
+ if ('.' === segment || !segment) return '';
195
+ return segment.replace(/[<>:"|?*\x00-\x1F]/g, '_');
196
+ }).filter(Boolean).join('/');
197
+ return safe ? `${root}/${safe}` : `${root}/external`;
198
+ }
199
+ function iconOutputPath(raw) {
200
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
201
+ const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
202
+ if (!pathEscapesExtensionRoot(normalized)) return normalized;
203
+ return externalAssetOutputPath(normalized, 'icons');
204
+ }
205
+ function iconVariantsOf(holder) {
206
+ return holder && 'object' == typeof holder ? holder.icon_variants : void 0;
207
+ }
208
+ function iconVariantsOutput(variants) {
209
+ if (!Array.isArray(variants)) return variants;
210
+ return variants.map((group)=>{
211
+ if (!group || 'object' != typeof group || Array.isArray(group)) return group;
212
+ return Object.fromEntries(Object.entries(group).map(([key, value])=>[
213
+ key,
214
+ 'string' == typeof value && value && 'color_schemes' !== key ? iconOutputPath(value).replace(/\\/g, '/') : value
215
+ ]));
216
+ });
217
+ }
218
+ function themeIconOutputPath(raw, folder) {
219
+ return featureAssetOutputPath(raw, folder);
220
+ }
221
+ function themeImageOutputPath(raw) {
222
+ return featureAssetOutputPath(raw, 'theme/images');
223
+ }
224
+ function featureAssetOutputPath(raw, folder) {
225
+ if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
226
+ const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
227
+ if (!pathEscapesExtensionRoot(normalized)) return `${folder}/${normalized}`;
228
+ return externalAssetOutputPath(normalized, folder);
229
+ }
19
230
  const ACTION_HTML_FEATURE = 'action/index';
20
231
  const BROWSER_ACTION_HTML_FEATURE = 'browser_action/index';
21
232
  const PAGE_ACTION_HTML_FEATURE = 'page_action/index';
@@ -268,70 +479,6 @@ function leavePublicPagesToCopier(html, context, projectPath) {
268
479
  }
269
480
  return html;
270
481
  }
271
- function isFromFilepathList(filePath, filepathList) {
272
- return Object.values(filepathList || {}).some((value)=>value === filePath);
273
- }
274
- function isFolder(filePath) {
275
- try {
276
- return __rspack_external_node_fs_1b05aee1.statSync(filePath).isDirectory();
277
- } catch {
278
- return false;
279
- }
280
- }
281
- function getFilename(feature, filePath) {
282
- const entryExt = __rspack_external_node_path_806ed179.extname(filePath);
283
- let fileOutputpath = feature;
284
- if ([
285
- '.js',
286
- '.jsx',
287
- '.tsx',
288
- '.ts',
289
- '.vue',
290
- '.svelte'
291
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.js');
292
- if ([
293
- '.html',
294
- '.njk',
295
- '.nunjucks'
296
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.html');
297
- if ([
298
- '.css',
299
- '.scss',
300
- '.sass',
301
- '.less'
302
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.css');
303
- return unixify(fileOutputpath || '');
304
- }
305
- function unixify(filePath) {
306
- return filePath.replace(/\\/g, '/');
307
- }
308
- function resolveRootAbsoluteRef(ref, projectRoot, publicRoot) {
309
- if (!ref || !ref.startsWith('/')) return;
310
- if (projectRoot && ref.startsWith(projectRoot)) return;
311
- if (ref.startsWith('//')) return;
312
- const trimmed = ref.replace(/^\/+/, '');
313
- if (!trimmed) return;
314
- if (publicRoot && __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(publicRoot, trimmed))) return;
315
- const candidate = __rspack_external_node_path_806ed179.resolve(projectRoot, trimmed);
316
- const rel = __rspack_external_node_path_806ed179.relative(projectRoot, candidate);
317
- if (rel.startsWith('..') || __rspack_external_node_path_806ed179.isAbsolute(rel)) return;
318
- if (!__rspack_external_node_fs_1b05aee1.existsSync(candidate) || !__rspack_external_node_fs_1b05aee1.statSync(candidate).isFile()) return;
319
- return candidate;
320
- }
321
- function collectRootAbsoluteRefs(source) {
322
- const refs = new Set();
323
- const attrRe = /(?:src|href)\s*=\s*["'](\/[^"'#?]*)["']/gi;
324
- const urlRe = /url\(\s*["']?(\/[^"')#?]+)["']?\s*\)/gi;
325
- let m;
326
- while(m = attrRe.exec(source))refs.add(m[1]);
327
- while(m = urlRe.exec(source))refs.add(m[1]);
328
- return refs;
329
- }
330
- function isManifestAddress(value) {
331
- if ('string' != typeof value) return false;
332
- const trimmed = value.trim();
333
- return /^[a-z][a-z0-9+.-]+:/i.test(trimmed) || trimmed.startsWith('//');
334
- }
335
482
  function backgroundPage(manifest) {
336
483
  return manifest.background?.page && {
337
484
  background: {
@@ -342,67 +489,6 @@ function backgroundPage(manifest) {
342
489
  }
343
490
  };
344
491
  }
345
- function normalizeManifestOutputPath(originalPath) {
346
- if (!originalPath) return originalPath;
347
- const unixPath = originalPath.replace(/\\/g, '/');
348
- if (/^\/public\//i.test(unixPath)) return unixPath.replace(/^\/public\//i, '');
349
- if (/^(?:\.\/)?public\//i.test(unixPath)) return unixPath.replace(/^(?:\.\/)?public\//i, '');
350
- if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
351
- return unixPath;
352
- }
353
- function manifestPageOutputTarget(raw, compiledTarget, manifestPath, projectPath) {
354
- const unixPath = raw.replace(/\\/g, '/');
355
- if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(unixPath)) return normalizeManifestOutputPath(unixPath);
356
- if (/^\//.test(unixPath)) {
357
- const rest = unixPath.replace(/^\/+/, '');
358
- if (manifestPath && rest) {
359
- const manifestDir = __rspack_external_node_path_806ed179.dirname(manifestPath);
360
- const inPublic = Boolean(findPublicFile(manifestPath, projectPath, rest));
361
- const inRoot = __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(manifestDir, rest));
362
- if (inRoot && !inPublic) return compiledTarget;
363
- }
364
- return normalizeManifestOutputPath(unixPath);
365
- }
366
- const rest = unixPath.replace(/^\.\//, '');
367
- if (!manifestPath || !rest || rest.split('/').includes('..')) return compiledTarget;
368
- if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(__rspack_external_node_path_806ed179.dirname(manifestPath), rest))) return compiledTarget;
369
- if (findPublicFile(manifestPath, projectPath, rest)) return rest;
370
- return compiledTarget;
371
- }
372
- function manifestJsonOutputTarget(raw, compiledTarget, manifestPath, projectPath) {
373
- return manifestPageOutputTarget(raw, compiledTarget, manifestPath, projectPath);
374
- }
375
- function pathEscapesExtensionRoot(normalized) {
376
- return !normalized || normalized.split('/').includes('..') || /^[A-Za-z]:/.test(normalized);
377
- }
378
- function externalAssetOutputPath(normalized, root) {
379
- const unix = normalized.replace(/\\/g, '/');
380
- const noDrive = unix.replace(/^([A-Za-z]):(?:\/|$)/, '_drive_$1/');
381
- const safe = noDrive.split('/').map((segment)=>{
382
- if ('..' === segment) return '_';
383
- if ('.' === segment || !segment) return '';
384
- return segment.replace(/[<>:"|?*\x00-\x1F]/g, '_');
385
- }).filter(Boolean).join('/');
386
- return safe ? `${root}/${safe}` : `${root}/external`;
387
- }
388
- function iconOutputPath(raw) {
389
- if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
390
- const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
391
- if (!pathEscapesExtensionRoot(normalized)) return normalized;
392
- return externalAssetOutputPath(normalized, 'icons');
393
- }
394
- function themeIconOutputPath(raw, folder) {
395
- return featureAssetOutputPath(raw, folder);
396
- }
397
- function themeImageOutputPath(raw) {
398
- return featureAssetOutputPath(raw, 'theme/images');
399
- }
400
- function featureAssetOutputPath(raw, folder) {
401
- if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
402
- const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
403
- if (!pathEscapesExtensionRoot(normalized)) return `${folder}/${normalized}`;
404
- return externalAssetOutputPath(normalized, folder);
405
- }
406
492
  function chromeUrlOverrides(manifest, manifestPath, projectPath) {
407
493
  return manifest.chrome_url_overrides && {
408
494
  chrome_url_overrides: {
@@ -519,15 +605,22 @@ function devtoolsPage(manifest, manifestPath, projectPath) {
519
605
  })()
520
606
  };
521
607
  }
522
- function icons(manifest) {
523
- return manifest.icons && {
524
- icons: Object.fromEntries(Object.entries(manifest.icons).map(([size, icon])=>{
525
- const raw = String(icon);
526
- return [
527
- size,
528
- getFilename(iconOutputPath(raw), raw)
529
- ];
530
- }))
608
+ function icons_icons(manifest) {
609
+ const variants = iconVariantsOf(manifest);
610
+ if (!manifest.icons && !variants) return manifest.icons;
611
+ return {
612
+ ...manifest.icons && {
613
+ icons: Object.fromEntries(Object.entries(manifest.icons).map(([size, icon])=>{
614
+ const raw = String(icon);
615
+ return [
616
+ size,
617
+ getFilename(iconOutputPath(raw), raw)
618
+ ];
619
+ }))
620
+ },
621
+ ...Boolean(variants) && {
622
+ icon_variants: iconVariantsOutput(variants)
623
+ }
531
624
  };
532
625
  }
533
626
  function omnibox_omnibox(manifest) {
@@ -565,7 +658,7 @@ function options_ui_optionsUi(manifest, manifestPath, projectPath) {
565
658
  }
566
659
  };
567
660
  }
568
- function permissions(manifest) {
661
+ function permissions_permissions(manifest) {
569
662
  return manifest.permissions && {
570
663
  permissions: manifest.permissions
571
664
  };
@@ -647,9 +740,9 @@ function manifestCommon(manifest, manifestPath, projectPath) {
647
740
  ...chromeUrlOverrides(manifest, manifestPath, projectPath),
648
741
  ...content_scripts_contentScripts(manifest, manifestPath),
649
742
  ...devtoolsPage(manifest, manifestPath, projectPath),
650
- ...icons(manifest),
743
+ ...icons_icons(manifest),
651
744
  ...commands_commands(manifest),
652
- ...permissions(manifest),
745
+ ...permissions_permissions(manifest),
653
746
  ...optionsPage(manifest, manifestPath, projectPath),
654
747
  ...options_ui_optionsUi(manifest, manifestPath, projectPath),
655
748
  ...sandbox(manifest, manifestPath, projectPath),
@@ -668,6 +761,9 @@ function pageAction(manifest, manifestPath, projectPath) {
668
761
  ...manifest.page_action.default_popup && {
669
762
  default_popup: getFilename(manifestPageOutputTarget(String(manifest.page_action.default_popup), pageActionOutputTarget(manifest), manifestPath, projectPath), String(manifest.page_action.default_popup))
670
763
  },
764
+ ...Boolean(iconVariantsOf(manifest.page_action)) && {
765
+ icon_variants: iconVariantsOutput(iconVariantsOf(manifest.page_action))
766
+ },
671
767
  ...manifest.page_action.default_icon && {
672
768
  default_icon: 'string' == typeof manifest.page_action.default_icon ? (()=>{
673
769
  const raw = String(manifest.page_action.default_icon);
@@ -724,6 +820,9 @@ function browser_action_browserAction(manifest, manifestPath, projectPath) {
724
820
  ...manifest.browser_action.default_popup && {
725
821
  default_popup: getFilename(manifestPageOutputTarget(String(manifest.browser_action.default_popup), browserActionOutputTarget(manifest), manifestPath, projectPath), String(manifest.browser_action.default_popup))
726
822
  },
823
+ ...Boolean(iconVariantsOf(manifest.browser_action)) && {
824
+ icon_variants: iconVariantsOutput(iconVariantsOf(manifest.browser_action))
825
+ },
727
826
  ...manifest.browser_action.default_icon && {
728
827
  default_icon: 'string' == typeof manifest.browser_action.default_icon ? (()=>{
729
828
  const raw = String(manifest.browser_action.default_icon);
@@ -858,6 +957,9 @@ function action_action(manifest, manifestPath, projectPath) {
858
957
  ...manifest.action.default_popup && {
859
958
  default_popup: getFilename(manifestPageOutputTarget(String(manifest.action.default_popup), 'action/index.html', manifestPath, projectPath), String(manifest.action.default_popup))
860
959
  },
960
+ ...Boolean(iconVariantsOf(manifest.action)) && {
961
+ icon_variants: iconVariantsOutput(iconVariantsOf(manifest.action))
962
+ },
861
963
  ...manifest.action.default_icon && {
862
964
  default_icon: 'string' == typeof manifest.action.default_icon ? (()=>{
863
965
  const raw = String(manifest.action.default_icon);
@@ -987,9 +1089,9 @@ function legacyManifestPathWarning(field, legacyPath, modernPath) {
987
1089
  lines.push(`Point it at ${pintor.underline(modernPath)}, Extension.js already emits the page there.`);
988
1090
  return lines.join('\n');
989
1091
  }
990
- function fatalManifestShapeFixed(field, detail) {
1092
+ function fatalManifestShapeFixed(field, detail, refusedBy = 'Chrome') {
991
1093
  const lines = [];
992
- lines.push(`${messaging_prefix('warn')} Repaired the ${pintor.blue(field)} field, which Chrome refuses to load the extension over.`);
1094
+ lines.push(`${messaging_prefix('warn')} Repaired the ${pintor.blue(field)} field, which ${refusedBy} refuses to load the extension over.`);
993
1095
  lines.push(`${pintor.gray('REASON')} ${pintor.underline(detail)}`);
994
1096
  lines.push(`Fix the field in your ${pintor.blue('manifest.json')} file.`);
995
1097
  return lines.join('\n');
@@ -1092,18 +1194,25 @@ function sidebarKeyTranslatedForBrowser(browser, from, to) {
1092
1194
  function mv3BackgroundPageUnsupported(browser) {
1093
1195
  return `${messaging_prefix('warn')} ${pintor.blue(browser)} has no ${pintor.yellow('background.page')} in Manifest V3, and the extension installs with no background context at all.\nNothing reports that at load time: the background code, the reload bridge and the control channel all go missing silently. The build kept the page as written, so the rest of the extension still loads. Declare ${pintor.yellow('background.service_worker')} instead, or scope the page with the firefox: prefix for a Manifest V2 build.`;
1094
1196
  }
1197
+ function geckoEmptyBackgroundScriptsDropped(browser, keepsBackground = false) {
1198
+ const outcome = keepsBackground ? `The ${pintor.blue(browser)} build dropped the empty list and kept the background the manifest declares beside it. ` : `The ${pintor.blue(browser)} build dropped the key, so the add-on runs with no background there too. `;
1199
+ return `${messaging_prefix('warn')} ${pintor.yellow("background.scripts")} is an empty list, and Firefox still starts an empty background page for it where Chrome and Safari start none.\n` + outcome + `Remove ${pintor.yellow("background.scripts")} from ${pintor.blue('manifest.json')}, or list a script in it.`;
1200
+ }
1095
1201
  function geckoSidePanelUnsupported(file) {
1096
1202
  const lines = [];
1097
1203
  lines.push(`${messaging_prefix('warn')} ${pintor.underline(file)} uses chrome.sidePanel, which is Chromium only.`);
1098
1204
  lines.push(`Firefox opens a sidebar through the ${pintor.yellow('sidebar_action')} manifest key on every manifest version, and addons-linter flags the call as UNSUPPORTED_API.`);
1099
- lines.push(`Move the call behind a build-time branch on ${pintor.blue('import.meta.env.EXTENSION_PUBLIC_BROWSER')} so the Firefox bundle drops it.`);
1205
+ lines.push(`${runtimeGuardAdvice('sidePanel')} Only the build-time branch drops the call from the Firefox bundle, which is what clears the linter.`);
1100
1206
  return lines.join('\n');
1101
1207
  }
1208
+ function runtimeGuardAdvice(api) {
1209
+ return `Move the call behind a build-time branch on ${pintor.blue('import.meta.env.EXTENSION_PUBLIC_BROWSER')}, guard it with ${pintor.yellow(`chrome.${api}?.`)}, or keep it inside an ${pintor.yellow(`if (chrome.${api})`)} branch.`;
1210
+ }
1102
1211
  function safariUnsupportedApi(file, api, detail) {
1103
1212
  const lines = [];
1104
1213
  lines.push(`${messaging_prefix('warn')} ${pintor.underline(file)} calls chrome.${api}, which Safari does not have.`);
1105
1214
  lines.push(detail);
1106
- lines.push(`Move the call behind a build-time branch on ${pintor.blue('import.meta.env.EXTENSION_PUBLIC_BROWSER')}, guard it with ${pintor.yellow(`chrome.${api}?.`)}, or keep it inside an ${pintor.yellow(`if (chrome.${api})`)} branch.`);
1215
+ lines.push(runtimeGuardAdvice(api));
1107
1216
  return lines.join('\n');
1108
1217
  }
1109
1218
  const safariBackgroundDies = "The call throws when the script runs, Safari drops the background, and nothing reports an error.";
@@ -1174,6 +1283,13 @@ function safariMemberUnsupported(file, api, member, kind) {
1174
1283
  lines.push(`Safari has ${pintor.blue(`chrome.${api}`)} itself, so a guard on the namespace does not help. Move the call behind a build-time branch on ${pintor.blue('import.meta.env.EXTENSION_PUBLIC_BROWSER')}, guard it with ${pintor.yellow(guard)}, or keep it inside an ${pintor.yellow(`if (chrome.${api}.${member})`)} branch.`);
1175
1284
  return lines.join('\n');
1176
1285
  }
1286
+ function geckoCallbackFormUnsupported(file, api, member) {
1287
+ const lines = [];
1288
+ lines.push(`${messaging_prefix('warn')} ${pintor.underline(file)} passes a callback to chrome.${api}.${member}, which Firefox takes in promise form only.`);
1289
+ lines.push(`Firefox throws "Incorrect argument types for ${api}.${member}" on that call, where Chrome runs the callback.`);
1290
+ lines.push(`Drop the callback and await ${pintor.yellow(`browser.${api}.${member}`)}, which returns a promise on Firefox.`);
1291
+ return lines.join('\n');
1292
+ }
1177
1293
  function geckoActionUnsupportedOnMv2(file) {
1178
1294
  const lines = [];
1179
1295
  lines.push(`${messaging_prefix('warn')} ${pintor.underline(file)} uses chrome.action, which Manifest V2 does not have on Firefox.`);
@@ -1190,22 +1306,85 @@ function contentScriptEntryDroppedForBrowser(index, browser, prefixedKeys) {
1190
1306
  function edgeEmbeddedOptionsDialog() {
1191
1307
  return `${messaging_prefix('warn')} Edge shows an embedded settings page in a dialog at most 400px wide (368px for the page), so a wider settings page is clipped on Edge.\nAdd ${pintor.yellow('edge:options_ui')} with ${pintor.yellow('"open_in_tab": true')} to open settings in a tab on Edge only.`;
1192
1308
  }
1309
+ function iconVariantsFallback(reader, verdicts) {
1310
+ const key = pintor.yellow('icon_variants');
1311
+ const reasons = {
1312
+ gecko: `Firefox does not read ${key} yet`,
1313
+ chromium: `Chromium reads ${key} only with its ${pintor.yellow('ExtensionIconVariants')} flag on`,
1314
+ webkit: `Safari's app converter does not read ${key} yet`
1315
+ };
1316
+ const browsers = {
1317
+ gecko: 'Firefox',
1318
+ chromium: 'Chromium',
1319
+ webkit: 'Safari'
1320
+ };
1321
+ const why = reasons[reader];
1322
+ const browser = browsers[reader];
1323
+ const named = (outcome)=>verdicts.filter((verdict)=>verdict.outcome === outcome).map((verdict)=>pintor.yellow(verdict.key)).join(' and ');
1324
+ const kept = named('kept');
1325
+ const added = named('added');
1326
+ const missing = named('missing');
1327
+ const lines = [];
1328
+ if (kept) lines.push(`${browser} shows ${kept} from your manifest instead.`);
1329
+ if (added) lines.push(`The manifest had no ${added}, so the build filled it from the variant that fits every color scheme, or the light one.`);
1330
+ if (missing) lines.push(`No variant can stand in for ${missing}, so ${browser} shows its default icon. Add ${missing} with PNG files to the manifest.`);
1331
+ const level = added || missing ? 'warn' : 'info';
1332
+ return `${messaging_prefix(level)} ${why}.\n${lines.join('\n')}`;
1333
+ }
1193
1334
  function webkitUnsupportedKeysDropped(browser, dropped) {
1335
+ return unsupportedKeysDropped('Safari', 'app', 'safari:', browser, dropped);
1336
+ }
1337
+ function geckoUnsupportedKeysDropped(browser, dropped) {
1338
+ return unsupportedKeysDropped('Firefox', 'extension', 'firefox:', browser, dropped);
1339
+ }
1340
+ function unsupportedKeysDropped(engine, product, vendorPrefix, browser, dropped) {
1194
1341
  const count = dropped.length;
1195
1342
  const target = pintor.blue(browser);
1196
- const replacement = `Declare a Safari-only replacement with the ${pintor.yellow('safari:')} prefix if you have one.`;
1343
+ const replacement = `Declare a ${engine}-only replacement with the ${pintor.yellow(vendorPrefix)} prefix if you have one.`;
1197
1344
  if (1 === count) {
1198
1345
  const [entry] = dropped;
1199
- return `${messaging_prefix('warn')} Safari has no support for ${pintor.yellow(entry.path)} (${entry.reason}), so the ${target} build dropped it, and nothing the app could have run was lost. ${replacement}`;
1346
+ return `${messaging_prefix('warn')} ${engine} has no support for ${pintor.yellow(entry.path)} (${entry.reason}), so the ${target} build dropped it, and nothing the ${product} could have run was lost. ${replacement}`;
1200
1347
  }
1201
1348
  const bar = `${pintor.gray('│')} `;
1202
1349
  const lines = [
1203
- `${messaging_prefix('warn')} Safari has no support for ${String(count)} manifest keys this project declares, so the ${target} build dropped them:`
1350
+ `${messaging_prefix('warn')} ${engine} has no support for ${String(count)} manifest keys this project declares, so the ${target} build dropped them:`
1204
1351
  ];
1205
1352
  for (const entry of dropped)lines.push(`${bar}${pintor.yellow(entry.path)} ${pintor.gray(entry.reason)}`);
1206
- lines.push(`${bar}These ${String(count)} keys are inert on Safari, so the built app lost nothing it could have run. ${replacement}`);
1353
+ lines.push(`${bar}These ${String(count)} keys are inert on ${engine}, so the built ${product} lost nothing it could have run. ${replacement}`);
1207
1354
  return lines.join('\n');
1208
1355
  }
1356
+ function geckoIncognitoSplitNotAllowed(browser) {
1357
+ return `${messaging_prefix('warn')} Firefox has no split mode, so it reads ${pintor.yellow('incognito: "split"')} as ${pintor.yellow('"not_allowed"')} and the ${pintor.blue(browser)} build never runs in private windows. The build kept the value as declared. Set ${pintor.yellow('firefox:incognito')} to ${pintor.yellow('"spanning"')} or ${pintor.yellow('"not_allowed"')} to choose.`;
1358
+ }
1359
+ function manifestDescriptionOverStoreLimit(browser, length, limit, store) {
1360
+ const apple = 112 === limit ? ' (Apple error 90849)' : '';
1361
+ return [
1362
+ `${messaging_prefix('warn')} manifest.json ${pintor.blue("description")} runs ${length} characters, and ${store} refuses a ${browser} build whose description is over ${limit}${apple}.`,
1363
+ `${pintor.gray('LIMIT')} ${limit} characters, ${pintor.gray('GOT')} ${length}`,
1364
+ `Shorten it to ${limit} characters or fewer, the store reads this field from the manifest.`
1365
+ ].join('\n');
1366
+ }
1367
+ const hostGatedOutcomeOnChromium = {
1368
+ scripting: "scripting.executeScript rejects",
1369
+ cookies: 'cookies.getAll comes back empty',
1370
+ webRequest: 'webRequest events never fire'
1371
+ };
1372
+ function contentScriptMatchesGrantNoHostOnChromium(permissions, matches) {
1373
+ const names = permissions.map((permission)=>pintor.yellow(`"${permission}"`)).join(', ');
1374
+ const outcomes = permissions.map((permission)=>hostGatedOutcomeOnChromium[permission]).filter(Boolean).join(', ');
1375
+ return [
1376
+ `${messaging_prefix('warn')} manifest.json declares ${names} and no host permission, and Chromium takes none from ${pintor.blue("content_scripts")} matches.`,
1377
+ `${pintor.gray('MATCHES')} ${matches.join(', ')}`,
1378
+ `The content script still runs on those pages, but on Chrome the permission reaches none of them: ${outcomes}. Firefox reads the same matches as host access, so this works on Firefox and not on Chrome.`,
1379
+ `Add the hosts to ${pintor.blue('host_permissions')}, or to ${pintor.yellow('chromium:host_permissions')} to keep them out of the other builds.`
1380
+ ].join('\n');
1381
+ }
1382
+ function manifestDescriptionMissingForStore(browser, store, limit) {
1383
+ return [
1384
+ `${messaging_prefix('warn')} manifest.json has no ${pintor.blue("description")}, and ${store} refuses a ${browser} build without one (Apple error 90849).`,
1385
+ `Add a description of ${limit} characters or fewer.`
1386
+ ].join('\n');
1387
+ }
1209
1388
  function edgeEmbedsOptionsPage(manifest, browser) {
1210
1389
  if ('edge' !== String(browser)) return false;
1211
1390
  const optionsUi = manifest.options_ui;
@@ -1219,66 +1398,37 @@ function reportEdgeEmbeddedOptions(manifest, browser) {
1219
1398
  reported = true;
1220
1399
  humanLine(edgeEmbeddedOptionsDialog());
1221
1400
  }
1222
- const UNSUPPORTED_TOP_LEVEL_KEYS = {
1223
- side_panel: 'Safari has no side panel surface',
1224
- sidebar_action: 'Safari has no sidebar surface',
1225
- sandbox: 'Safari cannot run sandboxed extension pages',
1226
- user_scripts: 'Safari has no userScripts API',
1227
- omnibox: 'Safari has no omnibox keyword API',
1228
- chrome_settings_overrides: 'Safari lets no extension override these settings',
1229
- tts_engine: 'Safari has no speech engine API',
1230
- file_browser_handlers: 'ChromeOS only',
1231
- input_components: 'ChromeOS only',
1232
- cross_origin_embedder_policy: 'Safari reads no COEP key from a manifest',
1233
- cross_origin_opener_policy: 'Safari reads no COOP key from a manifest',
1234
- requirements: 'Chrome Web Store only',
1235
- oauth2: 'Safari has no identity API to consume it',
1236
- nacl_modules: 'Native Client is Chrome only',
1237
- replacement_web_app: 'Chrome Web Store only',
1238
- offline_enabled: 'Chrome Web Store only',
1239
- differential_fingerprint: 'Chrome Web Store only',
1240
- incognito: 'Safari always runs extensions in spanning mode and ignores the declared value'
1241
- };
1242
- const UNSUPPORTED_PERMISSIONS = new Set([
1401
+ const GECKO_UNSUPPORTED_PERMISSIONS = new Set([
1243
1402
  'accessibilityFeatures.modify',
1244
1403
  'accessibilityFeatures.read',
1245
1404
  'audio',
1246
1405
  'background',
1247
- 'bookmarks',
1248
- 'browsingData',
1249
1406
  'certificateProvider',
1250
- 'clipboardRead',
1251
1407
  'contentSettings',
1252
1408
  'debugger',
1253
1409
  'declarativeContent',
1254
1410
  'desktopCapture',
1255
1411
  'documentScan',
1256
- 'downloads',
1412
+ 'downloads.ui',
1257
1413
  'enterprise.deviceAttributes',
1258
1414
  'enterprise.platformKeys',
1259
1415
  'experimental',
1260
1416
  'favicon',
1417
+ 'fileBrowserHandler',
1261
1418
  'fileSystemProvider',
1262
1419
  'fontSettings',
1263
1420
  'gcm',
1264
- 'geolocation',
1265
- 'history',
1266
- 'identity',
1267
1421
  'identity.email',
1268
- 'idle',
1269
- 'management',
1270
- 'notifications',
1422
+ 'loginState',
1271
1423
  'offscreen',
1272
1424
  'pageCapture',
1273
1425
  'platformKeys',
1274
1426
  'power',
1275
1427
  'printerProvider',
1276
- 'privacy',
1428
+ 'printing',
1429
+ 'printingMetrics',
1277
1430
  'processes',
1278
- 'proxy',
1279
1431
  'readingList',
1280
- 'search',
1281
- 'sessions',
1282
1432
  'sidePanel',
1283
1433
  'system.cpu',
1284
1434
  'system.display',
@@ -1286,26 +1436,77 @@ const UNSUPPORTED_PERMISSIONS = new Set([
1286
1436
  'system.storage',
1287
1437
  'systemLog',
1288
1438
  'tabCapture',
1289
- 'tabGroups',
1290
- 'topSites',
1291
1439
  'tts',
1292
1440
  'ttsEngine',
1293
- 'userScripts',
1294
1441
  'vpnProvider',
1295
1442
  'wallpaper',
1296
- 'webAuthenticationProxy',
1297
- 'webRequestBlocking'
1443
+ 'webAuthenticationProxy'
1298
1444
  ]);
1299
1445
  const PERMISSION_LISTS = [
1300
1446
  'permissions',
1301
1447
  'optional_permissions'
1302
1448
  ];
1449
+ function dropGeckoUnsupportedKeys(manifest, browser) {
1450
+ const dropped = [];
1451
+ const reinterpreted = [];
1452
+ if (!isGeckoBasedBrowser(String(browser))) return {
1453
+ manifest,
1454
+ dropped,
1455
+ reinterpreted
1456
+ };
1457
+ const next = {
1458
+ ...manifest
1459
+ };
1460
+ for (const listName of PERMISSION_LISTS){
1461
+ const list = next[listName];
1462
+ if (!Array.isArray(list)) continue;
1463
+ const kept = list.filter((entry)=>{
1464
+ if ('string' != typeof entry || !GECKO_UNSUPPORTED_PERMISSIONS.has(entry)) return true;
1465
+ dropped.push({
1466
+ path: `${listName}.${entry}`,
1467
+ reason: `Firefox has no ${entry} permission`
1468
+ });
1469
+ return false;
1470
+ });
1471
+ if (kept.length !== list.length) if (0 === kept.length) delete next[listName];
1472
+ else next[listName] = kept;
1473
+ }
1474
+ if ('split' === next.incognito) reinterpreted.push({
1475
+ path: 'incognito',
1476
+ declared: 'split',
1477
+ effective: 'not_allowed'
1478
+ });
1479
+ return {
1480
+ manifest: next,
1481
+ dropped,
1482
+ reinterpreted
1483
+ };
1484
+ }
1485
+ const filter_keys_gecko_reported = new Set();
1486
+ function reportGeckoUnsupportedKeys(found, browser) {
1487
+ const target = String(browser);
1488
+ if (found.dropped.length > 0) {
1489
+ const signature = `${target}\0${found.dropped.map((entry)=>entry.path).join(',')}`;
1490
+ if (!filter_keys_gecko_reported.has(signature)) {
1491
+ filter_keys_gecko_reported.add(signature);
1492
+ humanLine(geckoUnsupportedKeysDropped(target, found.dropped));
1493
+ }
1494
+ }
1495
+ for (const entry of found.reinterpreted){
1496
+ const signature = `${target}\0${entry.path}=${entry.declared}`;
1497
+ if (!filter_keys_gecko_reported.has(signature)) {
1498
+ filter_keys_gecko_reported.add(signature);
1499
+ humanLine(geckoIncognitoSplitNotAllowed(target));
1500
+ }
1501
+ }
1502
+ }
1503
+ const filter_keys_safari_PERMISSION_LISTS = [
1504
+ 'permissions',
1505
+ 'optional_permissions'
1506
+ ];
1303
1507
  function isWebkitUnsupportedPermission(permission, browser) {
1304
- return isWebkitBasedBrowser(String(browser)) && UNSUPPORTED_PERMISSIONS.has(permission);
1508
+ return isWebkitBasedBrowser(String(browser)) && WEBKIT_UNSUPPORTED_PERMISSIONS.has(permission);
1305
1509
  }
1306
- const UNSUPPORTED_OPTIONS_UI_KEYS = {
1307
- open_in_tab: 'Safari always opens the options page in a tab'
1308
- };
1309
1510
  function isPlainObject(value) {
1310
1511
  return !!value && 'object' == typeof value && !Array.isArray(value);
1311
1512
  }
@@ -1318,18 +1519,18 @@ function dropWebkitUnsupportedKeys(manifest, browser) {
1318
1519
  const next = {
1319
1520
  ...manifest
1320
1521
  };
1321
- for (const [key, reason] of Object.entries(UNSUPPORTED_TOP_LEVEL_KEYS))if (key in next) {
1522
+ for (const [key, reason] of Object.entries(WEBKIT_UNSUPPORTED_TOP_LEVEL_KEYS))if (key in next) {
1322
1523
  delete next[key];
1323
1524
  dropped.push({
1324
1525
  path: key,
1325
1526
  reason
1326
1527
  });
1327
1528
  }
1328
- for (const listName of PERMISSION_LISTS){
1529
+ for (const listName of filter_keys_safari_PERMISSION_LISTS){
1329
1530
  const list = next[listName];
1330
1531
  if (!Array.isArray(list)) continue;
1331
1532
  const kept = list.filter((entry)=>{
1332
- if ('string' != typeof entry || !UNSUPPORTED_PERMISSIONS.has(entry)) return true;
1533
+ if ('string' != typeof entry || !WEBKIT_UNSUPPORTED_PERMISSIONS.has(entry)) return true;
1333
1534
  dropped.push({
1334
1535
  path: `${listName}.${entry}`,
1335
1536
  reason: `Safari has no ${entry} API`
@@ -1345,7 +1546,7 @@ function dropWebkitUnsupportedKeys(manifest, browser) {
1345
1546
  ...optionsUi
1346
1547
  };
1347
1548
  let changed = false;
1348
- for (const [key, reason] of Object.entries(UNSUPPORTED_OPTIONS_UI_KEYS))if (key in patched) {
1549
+ for (const [key, reason] of Object.entries(WEBKIT_UNSUPPORTED_OPTIONS_UI_KEYS))if (key in patched) {
1349
1550
  delete patched[key];
1350
1551
  changed = true;
1351
1552
  dropped.push({
@@ -1373,6 +1574,113 @@ function reportWebkitDroppedKeys(dropped, browser) {
1373
1574
  reportedDrops.add(signature);
1374
1575
  humanLine(webkitUnsupportedKeysDropped(String(browser), dropped));
1375
1576
  }
1577
+ function ignoresIconVariants(browser) {
1578
+ const name = String(browser);
1579
+ if (isGeckoBasedBrowser(name)) return 'gecko';
1580
+ if (isChromiumBasedBrowser(name)) return 'chromium';
1581
+ if (isWebkitBasedBrowser(name)) return 'webkit';
1582
+ }
1583
+ function readGroups(variants, allowSvg) {
1584
+ if (!Array.isArray(variants)) return [];
1585
+ const groups = [];
1586
+ for (const raw of variants){
1587
+ if (!raw || 'object' != typeof raw || Array.isArray(raw)) continue;
1588
+ const group = raw;
1589
+ const sized = {};
1590
+ for (const [key, value] of Object.entries(group))if (/^\d+$/.test(key) && 'string' == typeof value && value) {
1591
+ if (!(!allowSvg && /\.svg$/i.test(value))) sized[key] = value;
1592
+ }
1593
+ groups.push({
1594
+ schemes: Array.isArray(group.color_schemes) ? group.color_schemes.map(String) : void 0,
1595
+ sized,
1596
+ any: 'string' == typeof group.any && group.any ? group.any : void 0
1597
+ });
1598
+ }
1599
+ return groups;
1600
+ }
1601
+ function iconsFromVariants(variants, reader) {
1602
+ if ('webkit' === reader) return pickIcons(variants, false) ?? pickIcons(variants, true);
1603
+ return pickIcons(variants, 'gecko' === reader);
1604
+ }
1605
+ function pickIcons(variants, allowSvg) {
1606
+ const groups = readGroups(variants, allowSvg);
1607
+ const ordered = [
1608
+ ...groups.filter((group)=>!group.schemes),
1609
+ ...groups.filter((group)=>group.schemes?.includes('light')),
1610
+ ...groups
1611
+ ];
1612
+ const sized = ordered.find((group)=>Object.keys(group.sized).length > 0);
1613
+ if (sized) return sized.sized;
1614
+ const vector = allowSvg ? ordered.find((group)=>group.any) : void 0;
1615
+ if (vector?.any) return {
1616
+ 48: vector.any,
1617
+ 96: vector.any
1618
+ };
1619
+ }
1620
+ function hasIcons(value) {
1621
+ if ('string' == typeof value) return value.length > 0;
1622
+ return Boolean(value && 'object' == typeof value && Object.keys(value).length > 0);
1623
+ }
1624
+ function applyIconVariantsFallback(manifest, browser) {
1625
+ const reader = ignoresIconVariants(browser);
1626
+ const verdicts = [];
1627
+ if (!reader || !manifest || 'object' != typeof manifest) return {
1628
+ manifest,
1629
+ verdicts
1630
+ };
1631
+ const next = {
1632
+ ...manifest
1633
+ };
1634
+ if (Array.isArray(next.icon_variants)) if (hasIcons(next.icons)) verdicts.push({
1635
+ key: 'icons',
1636
+ outcome: 'kept'
1637
+ });
1638
+ else {
1639
+ const icons = iconsFromVariants(next.icon_variants, reader);
1640
+ if (icons) next.icons = icons;
1641
+ verdicts.push({
1642
+ key: 'icons',
1643
+ outcome: icons ? 'added' : 'missing'
1644
+ });
1645
+ }
1646
+ for (const surfaceKey of [
1647
+ 'action',
1648
+ 'browser_action'
1649
+ ]){
1650
+ const surface = next[surfaceKey];
1651
+ if (!surface || !Array.isArray(surface.icon_variants)) continue;
1652
+ const key = `${surfaceKey}.default_icon`;
1653
+ if (hasIcons(surface.default_icon)) {
1654
+ verdicts.push({
1655
+ key,
1656
+ outcome: 'kept'
1657
+ });
1658
+ continue;
1659
+ }
1660
+ const icons = iconsFromVariants(surface.icon_variants, reader);
1661
+ if (icons) next[surfaceKey] = {
1662
+ ...surface,
1663
+ default_icon: icons
1664
+ };
1665
+ verdicts.push({
1666
+ key,
1667
+ outcome: icons ? 'added' : 'missing'
1668
+ });
1669
+ }
1670
+ return {
1671
+ manifest: next,
1672
+ verdicts
1673
+ };
1674
+ }
1675
+ const icon_variants_fallback_reported = new Set();
1676
+ function reportIconVariantsFallback(verdicts, browser) {
1677
+ const reader = ignoresIconVariants(browser);
1678
+ if (!reader || 0 === verdicts.length) return;
1679
+ const line = iconVariantsFallback(reader, verdicts);
1680
+ if (icon_variants_fallback_reported.has(line)) return;
1681
+ icon_variants_fallback_reported.add(line);
1682
+ humanLine(line);
1683
+ }
1376
1684
  const cjsRequire = createRequire(import.meta.url);
1377
1685
  const manifestSourceStore = new WeakMap();
1378
1686
  function manifestSourceEntry(compilation) {
@@ -1449,8 +1757,12 @@ function buildCanonicalManifestWithOverrides(manifestPath, manifest, browser, pr
1449
1757
  const webkit = dropWebkitUnsupportedKeys(translated, browser);
1450
1758
  reportWebkitDroppedKeys(webkit.dropped, browser);
1451
1759
  reportEdgeEmbeddedOptions(webkit.manifest, browser);
1760
+ const gecko = dropGeckoUnsupportedKeys(webkit.manifest, browser);
1761
+ reportGeckoUnsupportedKeys(gecko, browser);
1762
+ const icons = applyIconVariantsFallback(gecko.manifest, browser);
1763
+ reportIconVariantsFallback(icons.verdicts, browser);
1452
1764
  return {
1453
- manifest: webkit.manifest,
1765
+ manifest: icons.manifest,
1454
1766
  overrides
1455
1767
  };
1456
1768
  }
@@ -1499,76 +1811,23 @@ function envPublicSecretName(names) {
1499
1811
  const one = 1 === names.length;
1500
1812
  return `${names.map((name)=>pintor.yellow(name)).join(', ')} ${one ? 'looks' : 'look'} like ${one ? 'a secret' : 'secrets'}, and every ${pintor.yellow('EXTENSION_PUBLIC_*')} value is written into the built JavaScript that every user and every store review can read.\nKeep the secret on a server the extension calls, under a name without the ${pintor.yellow('EXTENSION_PUBLIC_')} prefix. If the value is public by design, such as a Firebase web API key, this warning does not apply to it.`;
1501
1813
  }
1502
- function envNoMatchingFile(browser, mode, presentFiles, expectedCandidates) {
1503
- return `Found ${presentFiles.map((file)=>pintor.yellow(file)).join(', ')}, but none match browser ${pintor.yellow(browser)} in mode ${pintor.yellow(mode)}.\nEXTENSION_PUBLIC_* variables read from code are ${pintor.yellow('undefined')} in this build.\nRename the file to one of these, in priority order: ${expectedCandidates.map((file)=>pintor.gray(file)).join(', ')}.\nFamily names apply to every family member, so ${pintor.yellow('.env.chrome')} also matches ${pintor.yellow('chromium')} and ${pintor.yellow('edge')} targets.`;
1814
+ function envIgnoredFiles(files, mode) {
1815
+ return `${messaging_prefix('debug')} env ignored=${files.join(',')} mode=${mode}`;
1504
1816
  }
1505
- const DEV_SESSION_RESTART_DEBOUNCE_MS = 300;
1506
- class DevSessionRestartScheduler {
1507
- debounceMs;
1508
- handler = null;
1509
- timer;
1510
- latest = null;
1511
- inFlight = false;
1512
- constructor(debounceMs = DEV_SESSION_RESTART_DEBOUNCE_MS){
1513
- this.debounceMs = Math.max(0, debounceMs);
1514
- }
1515
- setHandler(handler) {
1516
- this.handler = handler;
1517
- }
1518
- request(request) {
1519
- this.latest = request;
1520
- if (this.inFlight) return;
1521
- this.schedule();
1522
- }
1523
- isPending() {
1524
- return null != this.latest || this.inFlight;
1525
- }
1526
- dispose() {
1527
- if (this.timer) clearTimeout(this.timer);
1528
- this.timer = void 0;
1529
- this.latest = null;
1530
- this.handler = null;
1531
- }
1532
- schedule() {
1533
- if (this.timer) clearTimeout(this.timer);
1534
- if (0 === this.debounceMs) return void this.flush();
1535
- this.timer = setTimeout(()=>{
1536
- this.timer = void 0;
1537
- this.flush();
1538
- }, this.debounceMs);
1539
- this.timer.unref?.();
1540
- }
1541
- async flush() {
1542
- if (this.inFlight) return;
1543
- const request = this.latest;
1544
- const handler = this.handler;
1545
- if (!request || !handler) return;
1546
- this.latest = null;
1547
- this.inFlight = true;
1548
- try {
1549
- await handler(request);
1550
- } catch {} finally{
1551
- this.inFlight = false;
1552
- if (this.latest) this.schedule();
1553
- }
1554
- }
1817
+ function envNoMatchingFile(browser, mode, presentFiles, expectedCandidates, publicValuesDefined = false) {
1818
+ const undefinedLine = publicValuesDefined ? '' : `EXTENSION_PUBLIC_* variables read from code are ${pintor.yellow('undefined')} in this build.\n`;
1819
+ return `Found ${presentFiles.map((file)=>pintor.yellow(file)).join(', ')}, but none match browser ${pintor.yellow(browser)} in mode ${pintor.yellow(mode)}.\n` + undefinedLine + "Rename the file to one of these, in priority order: " + `${expectedCandidates.map((file)=>pintor.gray(file)).join(', ')}.\n` + "Family names apply to every family member, so " + `${pintor.yellow('.env.chrome')} also matches ${pintor.yellow('chromium')} and ${pintor.yellow('edge')} targets.`;
1555
1820
  }
1556
- let boundScheduler = null;
1557
- const restartingCompilers = new WeakSet();
1558
- function bindDevSessionRestart(scheduler) {
1559
- boundScheduler = scheduler;
1821
+ function nodeBuiltinStandInHint(builtin) {
1822
+ const root = builtin.split('/')[0];
1823
+ return `In ${pintor.yellow('extension.config.js')}, set ${pintor.yellow('resolve.fallback')} from the ${pintor.yellow('config')} hook: ${pintor.yellow(`{'${root}': false}`)} for an empty module, or the path of a browser polyfill you installed, such as ${pintor.yellow(`require.resolve('${root}/')`)}. ${pintor.yellow(`node:${root}`)} and ${pintor.yellow(root)} read the same key.`;
1560
1824
  }
1561
- function unbindDevSessionRestart() {
1562
- boundScheduler = null;
1563
- }
1564
- function requestDevSessionRestart(compiler, request) {
1565
- if (!boundScheduler) return false;
1566
- if (compiler) restartingCompilers.add(compiler);
1567
- boundScheduler.request(request);
1568
- return true;
1569
- }
1570
- function isCompilerRestarting(compiler) {
1571
- return null != compiler && restartingCompilers.has(compiler);
1825
+ function nodeBuiltinHasNoStandIn(builtin, issuer, stubbed, upstream) {
1826
+ const from = issuer ? ` ${pintor.yellow(displayPath(issuer))} imports it.` : '';
1827
+ const head = `The Node.js built-in ${pintor.yellow(builtin)} does not exist in a browser, and this build has no stand-in for it.${from}`;
1828
+ if (builtin.startsWith('node:')) return `${head}\nIt has no bare name, so ${pintor.yellow('resolve.fallback')} cannot reach it. In ${pintor.yellow('extension.config.js')}, push ${pintor.yellow(`new rspack.NormalModuleReplacementPlugin(/^${builtin}$/, yourModulePath)`)} onto ${pintor.yellow('config.plugins')} from the ${pintor.yellow('config')} hook, where ${pintor.yellow('yourModulePath')} is the absolute path of a module of yours. The hook's second argument carries the class: ${pintor.yellow('config: (config, {rspack}) => config')}.`;
1829
+ const stubs = stubbed.length > 0 ? `Only ${stubbed.map((name)=>pintor.yellow(name)).join(', ')} ${1 === stubbed.length ? 'is' : 'are'} replaced with an empty module. ` : '';
1830
+ return `${head}\n${stubs}${nodeBuiltinStandInHint(builtin)}\n${upstream}`;
1572
1831
  }
1573
1832
  class WatchEnvFilesPlugin {
1574
1833
  static name = 'plugin-compilation:watch-env-files';
@@ -1765,6 +2024,23 @@ function getEnvFileCandidates(browser, mode) {
1765
2024
  '.env'
1766
2025
  ];
1767
2026
  }
2027
+ const KNOWN_ENV_MODES = new Set([
2028
+ 'development',
2029
+ 'production',
2030
+ 'test',
2031
+ 'none'
2032
+ ]);
2033
+ const KNOWN_ENV_BROWSERS = new Set([
2034
+ ...SUPPORTED_BROWSERS,
2035
+ ...CHROMIUM_FAMILY_ALIASES,
2036
+ ...GECKO_FAMILY_ALIASES,
2037
+ ...WEBKIT_BASED_BROWSERS
2038
+ ]);
2039
+ function isEnvFileForAnotherTarget(file) {
2040
+ const parts = file.split('.').slice(2);
2041
+ if (1 === parts.length) return KNOWN_ENV_MODES.has(parts[0]) || KNOWN_ENV_BROWSERS.has(parts[0]);
2042
+ return 2 === parts.length && KNOWN_ENV_BROWSERS.has(parts[0]) && KNOWN_ENV_MODES.has(parts[1]);
2043
+ }
1768
2044
  const SECRET_SEGMENTS = new Set([
1769
2045
  'SECRET',
1770
2046
  'TOKEN',
@@ -1807,17 +2083,6 @@ class EnvPlugin {
1807
2083
  defaultsPath,
1808
2084
  fallbackDefaultsPath
1809
2085
  ]).apply(compiler);
1810
- if (!envPath && projectPath) {
1811
- let unmatchedEnvFiles = [];
1812
- try {
1813
- unmatchedEnvFiles = __rspack_external_node_fs_1b05aee1.readdirSync(projectPath).filter((file)=>file.startsWith('.env') && '.env.defaults' !== file && '.env.example' !== file).sort();
1814
- } catch {}
1815
- if (unmatchedEnvFiles.length > 0) compiler.hooks.thisCompilation.tap('env:warn-unmatched', (compilation)=>{
1816
- const warn = new WebpackError(envNoMatchingFile(String(this.browser), String(mode), unmatchedEnvFiles, envFiles));
1817
- warn.name = 'EnvNoMatchingFile';
1818
- compilation.warnings.push(warn);
1819
- });
1820
- }
1821
2086
  const envVars = envPath ? __rspack_external_dotenv.parse(__rspack_external_node_fs_1b05aee1.readFileSync(envPath)) : {};
1822
2087
  const readDefaults = (filePath)=>filePath && __rspack_external_node_fs_1b05aee1.existsSync(filePath) ? __rspack_external_dotenv.parse(__rspack_external_node_fs_1b05aee1.readFileSync(filePath)) : {};
1823
2088
  const defaultsVars = {
@@ -1831,6 +2096,23 @@ class EnvPlugin {
1831
2096
  ...envVars,
1832
2097
  ...systemEnv
1833
2098
  };
2099
+ if (!envPath && projectPath) {
2100
+ let presentEnvFiles = [];
2101
+ try {
2102
+ presentEnvFiles = __rspack_external_node_fs_1b05aee1.readdirSync(projectPath).filter((file)=>file.startsWith('.env') && '.env.defaults' !== file && '.env.example' !== file).sort();
2103
+ } catch {}
2104
+ const ignoredEnvFiles = presentEnvFiles.filter(isEnvFileForAnotherTarget);
2105
+ const unmatchedEnvFiles = presentEnvFiles.filter((file)=>!isEnvFileForAnotherTarget(file));
2106
+ if (ignoredEnvFiles.length > 0 && isDebug()) debugLine(envIgnoredFiles(ignoredEnvFiles, String(mode)));
2107
+ if (unmatchedEnvFiles.length > 0) {
2108
+ const publicValuesDefined = Object.keys(combinedVars).some((key)=>key.startsWith('EXTENSION_PUBLIC_') && '' !== String(combinedVars[key] ?? ''));
2109
+ compiler.hooks.thisCompilation.tap('env:warn-unmatched', (compilation)=>{
2110
+ const warn = new WebpackError(envNoMatchingFile(String(this.browser), String(mode), unmatchedEnvFiles, envFiles, publicValuesDefined));
2111
+ warn.name = 'EnvNoMatchingFile';
2112
+ compilation.warnings.push(warn);
2113
+ });
2114
+ }
2115
+ }
1834
2116
  if ('production' === mode) {
1835
2117
  const secretLooking = Object.keys(combinedVars).filter((key)=>key.startsWith('EXTENSION_PUBLIC_')).filter((key)=>'' !== String(combinedVars[key] ?? '')).filter(looksLikeSecretName).sort();
1836
2118
  if (secretLooking.length > 0) compiler.hooks.thisCompilation.tap('env:warn-public-secret', (compilation)=>{
@@ -1926,4 +2208,4 @@ function buildTemplateVars(combinedVars, browser, mode) {
1926
2208
  vars.EXTENSION_PUBLIC_MODE = modeValue;
1927
2209
  return vars;
1928
2210
  }
1929
- export { DevSessionRestartScheduler, EnvPlugin, OPTIONS_HTML_FEATURE, applyIndependentHtmlSurfaces, bindDevSessionRestart, boring, buildCanonicalManifestWithOverrides, cleanDistRemovedSummary, cleanDistSkippedNotFound, cleanDistStarting, collectRootAbsoluteRefs, contentScriptEntryDroppedForBrowser, dropWebkitUnsupportedKeys, externalAssetOutputPath, fatalManifestShapeFixed, geckoActionUnsupportedOnMv2, geckoSidePanelUnsupported, getCurrentManifestContent, getManifestContent, getOriginalManifestContent, hasMv2SandboxPolicy, hasMv3StringPolicy, iconOutputPath, importMetaUrlForEmitPath, invalidThemeValue, isCompilerRestarting, isFolder, isFromFilepathList, isHollowContentScript, isManifestAddress, isWebkitUnsupportedPermission, legacyManifestPathWarning, manifestDepsTracked, manifestEmitSuccess, manifestFieldMistyped, manifestFilesInTurnedOffPublic, manifestIncludeSummary, manifestInvalidError, manifestLegacyWarningsSummary, manifestOverridesSummary, manifestVersionLostForBrowser, missingGeckoDataCollectionPermissions, mv2ActionFoldedIntoBrowserAction, mv2SandboxPolicyDropped, mv3BackgroundPageUnsupported, mv3BrowserActionFoldedIntoAction, mv3StringPolicyRewritten, normalizeManifestOutputPath, omitWebkitDroppedEntries, pageActionDropReason, pageActionDroppedForBrowserAction, pageActionNotSupportedByBrowser, projectConfigChangedRestartRequired, requestDevSessionRestart, resolveRootAbsoluteRef, safariBookmarksUnsupported, safariDownloadsUnsupported, safariHistoryUnsupported, safariIdentityUnsupported, safariIdleUnsupported, safariManagementUnsupported, safariMemberUnsupported, safariNotificationsUnsupported, safariOffscreenUnsupported, safariOmniboxUnsupported, safariSidePanelUnsupported, safariTabGroupsUnsupported, safariUserScriptsUnsupported, serverRestartRequiredFromManifestError, setCurrentManifestContent, setOriginalManifestContent, shouldFoldActionIntoBrowserAction, shouldFoldBrowserActionIntoAction, sidebarFoldTarget, sidebarKeyTranslatedForBrowser, themeIconOutputPath, themeImageOutputPath, themeNotSupportedByBrowser, toJsStringLiteral, unbindDevSessionRestart, unixify, vendorPrefixedKeyDropped, zipPackagingSkipped };
2211
+ export { DevSessionRestartScheduler, EnvPlugin, OPTIONS_HTML_FEATURE, applyIndependentHtmlSurfaces, bindDevSessionRestart, boring, buildCanonicalManifestWithOverrides, canAutoRestartDevSession, cleanDistRemovedSummary, cleanDistSkippedNotFound, cleanDistStarting, collectRootAbsoluteRefs, contentScriptEntryDroppedForBrowser, contentScriptMatchesGrantNoHostOnChromium, dropWebkitUnsupportedKeys, externalAssetOutputPath, fatalManifestShapeFixed, geckoActionUnsupportedOnMv2, geckoCallbackFormUnsupported, geckoEmptyBackgroundScriptsDropped, geckoSidePanelUnsupported, getCurrentManifestContent, getManifestContent, getOriginalManifestContent, hasMv2SandboxPolicy, hasMv3StringPolicy, iconOutputPath, importMetaUrlForEmitPath, invalidThemeValue, isCompilerRestarting, isFolder, isFromFilepathList, isHollowContentScript, isManifestAddress, isWebkitUnsupportedPermission, legacyManifestPathWarning, manifestDepsTracked, manifestDescriptionMissingForStore, manifestDescriptionOverStoreLimit, manifestEmitSuccess, manifestFieldMistyped, manifestFilesInTurnedOffPublic, manifestIncludeSummary, manifestInvalidError, manifestLegacyWarningsSummary, manifestOverridesSummary, manifestVersionLostForBrowser, missingGeckoDataCollectionPermissions, mv2ActionFoldedIntoBrowserAction, mv2SandboxPolicyDropped, mv3BackgroundPageUnsupported, mv3BrowserActionFoldedIntoAction, mv3StringPolicyRewritten, nodeBuiltinHasNoStandIn, nodeBuiltinStandInHint, normalizeManifestOutputPath, omitWebkitDroppedEntries, pageActionDropReason, pageActionDroppedForBrowserAction, pageActionNotSupportedByBrowser, projectConfigChangedRestartRequired, requestDevSessionRestart, resolveRootAbsoluteRef, safariBookmarksUnsupported, safariDownloadsUnsupported, safariHistoryUnsupported, safariIdentityUnsupported, safariIdleUnsupported, safariManagementUnsupported, safariMemberUnsupported, safariNotificationsUnsupported, safariOffscreenUnsupported, safariOmniboxUnsupported, safariSidePanelUnsupported, safariTabGroupsUnsupported, safariUserScriptsUnsupported, serverRestartRequiredFromManifestError, setCurrentManifestContent, setOriginalManifestContent, shouldFoldActionIntoBrowserAction, shouldFoldBrowserActionIntoAction, sidebarFoldTarget, sidebarKeyTranslatedForBrowser, themeIconOutputPath, themeImageOutputPath, themeNotSupportedByBrowser, toJsStringLiteral, unbindDevSessionRestart, unixify, vendorPrefixedKeyDropped, zipPackagingSkipped };