extension-develop 4.1.31 → 4.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +2 -0
  2. package/dist/105~0.mjs +1 -1
  3. package/dist/177~0.mjs +87 -19
  4. package/dist/273~0.mjs +13 -3
  5. package/dist/363~0.mjs +1874 -0
  6. package/dist/{896~0.mjs → 469~0.mjs} +116 -586
  7. package/dist/519~0.mjs +21 -8
  8. package/dist/616~0.mjs +1 -1
  9. package/dist/771~0.mjs +103 -0
  10. package/dist/832~0.mjs +229 -463
  11. package/dist/840~0.mjs +1189 -54
  12. package/dist/846~0.mjs +453 -0
  13. package/dist/852~0.mjs +8 -6
  14. package/dist/bridge.mjs +3 -2
  15. package/dist/command-preview.d.ts +1 -0
  16. package/dist/contract/codes.json +39 -29
  17. package/dist/contract/envelope.schema.json +16 -0
  18. package/dist/contract/golden.build.compile.json +20 -3
  19. package/dist/contract/golden.eval.csp-blocks-eval.page.json +15 -0
  20. package/dist/css-parse-guard-loader.mjs +3 -1
  21. package/dist/dead-css-url-loader.mjs +129 -13
  22. package/dist/dev-server/cleanup.d.ts +1 -1
  23. package/dist/dev-server/lifecycle-stream.d.ts +14 -3
  24. package/dist/dev-server/session-start-prune.d.ts +13 -0
  25. package/dist/dev-server~0.mjs +91 -14
  26. package/dist/ensure-hmr-for-scripts.js +4 -8
  27. package/dist/ensure-hmr-for-scripts.mjs +4 -8
  28. package/dist/extension-js-devtools/build-stamp.json +2 -2
  29. package/dist/extension-js-theme/build-stamp.json +2 -2
  30. package/dist/feature-scripts-content-script-wrapper.js +7 -4
  31. package/dist/feature-scripts-content-script-wrapper.mjs +7 -4
  32. package/dist/lib/build-summary.d.ts +4 -1
  33. package/dist/lib/coded-warnings.d.ts +3 -0
  34. package/dist/lib/compilation-diagnostics.d.ts +23 -0
  35. package/dist/lib/config-loader.d.ts +2 -2
  36. package/dist/lib/config-resolved-plugin.d.ts +3 -2
  37. package/dist/lib/corepack-registry.d.ts +3 -0
  38. package/dist/lib/diagnostic-code.d.ts +6 -0
  39. package/dist/lib/merge-options.d.ts +1 -0
  40. package/dist/lib/messages.d.ts +4 -1
  41. package/dist/lib/messaging.d.ts +12 -4
  42. package/dist/lib/output-files.d.ts +11 -0
  43. package/dist/lib/package-manager.d.ts +2 -2
  44. package/dist/module.mjs +2 -1
  45. package/dist/plugin-browsers/index.d.ts +1 -0
  46. package/dist/plugin-compatibility/compatibility-lib/free-browser-references.d.ts +9 -0
  47. package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -1
  48. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +4 -2
  49. package/dist/plugin-css/css-lib/line-rewrite-source-map.d.ts +8 -0
  50. package/dist/plugin-css/dead-css-url-loader.d.ts +0 -2
  51. package/dist/plugin-css/public-css-url-loader.d.ts +8 -3
  52. package/dist/plugin-playwright/index.d.ts +9 -4
  53. package/dist/plugin-reload/classify-reload.d.ts +2 -0
  54. package/dist/plugin-reload/messages.d.ts +1 -0
  55. package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +4 -0
  56. package/dist/plugin-reload/steps/prune-unreachable-chunks.d.ts +5 -0
  57. package/dist/plugin-special-folders/messages.d.ts +1 -1
  58. package/dist/plugin-special-folders/prune-removed-public-files.d.ts +7 -0
  59. package/dist/plugin-static-assets/check-namespace-imports.d.ts +4 -0
  60. package/dist/plugin-static-assets/static-assets-lib/asset-output-name.d.ts +8 -0
  61. package/dist/plugin-static-assets/static-assets-lib/messages.d.ts +1 -0
  62. package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +2 -1
  63. package/dist/plugin-web-extension/feature-icons/messages.d.ts +1 -4
  64. package/dist/plugin-web-extension/feature-locales/get-locales.d.ts +2 -0
  65. package/dist/plugin-web-extension/feature-locales/messages.d.ts +3 -1
  66. package/dist/plugin-web-extension/feature-locales/validation.d.ts +1 -0
  67. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -0
  68. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/content_scripts.d.ts +1 -0
  69. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +1 -0
  70. package/dist/plugin-web-extension/feature-scripts/index.d.ts +2 -0
  71. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +4 -3
  72. package/dist/plugin-web-extension/feature-scripts/scripts-lib/load-time-constants.d.ts +11 -0
  73. package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +4 -0
  74. package/dist/plugin-web-extension/feature-scripts/steps/warn-missing-build-constants.d.ts +24 -0
  75. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/declared-pages.d.ts +2 -0
  76. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +5 -0
  77. package/dist/plugin-web-extension/index.d.ts +1 -0
  78. package/dist/plugin-web-extension/shared/classic-concat.d.ts +1 -0
  79. package/dist/plugin-web-extension/shared/compilation-issues.d.ts +1 -1
  80. package/dist/preprocessor-passthrough-loader.mjs +3 -1
  81. package/dist/public-css-url-loader.mjs +1 -1
  82. package/dist/rspack-config~0.mjs +4925 -5885
  83. package/dist/stats-handler~0.mjs +12 -4
  84. package/dist/types.d.ts +19 -2
  85. package/dist/zip~0.mjs +20 -2
  86. package/package.json +4 -4
  87. package/dist/300~0.mjs +0 -394
  88. package/dist/747~0.mjs +0 -90
package/README.md CHANGED
@@ -292,6 +292,8 @@ dist/
292
292
  - Built on the Rspack stack; user config is loaded when an `extension.config.*` is present.
293
293
  - Only `EXTENSION_PUBLIC_*` variables are injected into client code; avoid secrets in templated `.json`/`.html`.
294
294
 
295
+ - A `dev` session started within the watcher's accuracy margin of the last source write (up to 2 s, usually 10 to 100 ms, for example `create` followed at once by `dev`) compiles twice at startup. The second compile is the watcher reporting files written just before it attached, not a change in the project, and the session is unaffected.
296
+
295
297
  ## Plugins
296
298
 
297
299
  | Name | Group | Summary |
package/dist/105~0.mjs CHANGED
@@ -95,4 +95,4 @@ function publicRootsFor(compiler) {
95
95
  if (!compiler) return [];
96
96
  return publicRootsByCompiler.get(compiler) || [];
97
97
  }
98
- export { findPublicFile, inspectPublicFolders, publicContainmentRoot, publicFolderOrDefault, publicRelativePath, publicResolveRoots, publicRootsFor, rememberPublicRoots, turnedOffPublicFolders };
98
+ export { findPublicFile, inspectPublicFolders, publicContainmentRoot, publicFolderOrDefault, publicRelativePath, publicResolveRoots, publicRootsFor, rememberPublicRoots, resolvePublicFolder, turnedOffPublicFolders };
package/dist/177~0.mjs CHANGED
@@ -1,8 +1,62 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
- import { publicContainmentRoot } from "./105~0.mjs";
3
- import { replaceCssUrlRefs } from "./273~0.mjs";
2
+ import { resolvePublicFolder, publicContainmentRoot } from "./105~0.mjs";
3
+ import { replaceCssUrlRefs, publicOwnedOutputName } from "./273~0.mjs";
4
4
  import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
5
5
  import * as __rspack_external_node_path_806ed179 from "node:path";
6
+ const BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
7
+ function vlq(value) {
8
+ let rest = value < 0 ? -value << 1 | 1 : value << 1;
9
+ let out = '';
10
+ do {
11
+ let digit = 31 & rest;
12
+ rest >>>= 5;
13
+ if (rest > 0) digit |= 32;
14
+ out += BASE64[digit];
15
+ }while (rest > 0);
16
+ return out;
17
+ }
18
+ function commonSuffixLength(a, b, limit) {
19
+ let length = 0;
20
+ while(length < limit && a[a.length - 1 - length] === b[b.length - 1 - length])length++;
21
+ return length;
22
+ }
23
+ function lineRewriteSourceMap(original, rewritten, source) {
24
+ const originalLines = original.split('\n');
25
+ const rewrittenLines = rewritten.split('\n');
26
+ const lines = [];
27
+ let previousLine = 0;
28
+ let previousColumn = 0;
29
+ for(let index = 0; index < rewrittenLines.length; index++){
30
+ const from = originalLines[index] ?? '';
31
+ const to = rewrittenLines[index];
32
+ const segments = [
33
+ `${vlq(0)}${vlq(0)}${vlq(index - previousLine)}${vlq(0 - previousColumn)}`
34
+ ];
35
+ previousLine = index;
36
+ previousColumn = 0;
37
+ if (from !== to) {
38
+ let prefix = 0;
39
+ while(prefix < from.length && prefix < to.length && from[prefix] === to[prefix])prefix++;
40
+ const suffix = commonSuffixLength(from, to, Math.min(from.length, to.length) - prefix);
41
+ const generatedColumn = to.length - suffix;
42
+ const originalColumn = from.length - suffix;
43
+ segments.push(`${vlq(generatedColumn)}${vlq(0)}${vlq(0)}${vlq(originalColumn)}`);
44
+ previousColumn = originalColumn;
45
+ }
46
+ lines.push(segments.join(','));
47
+ }
48
+ return {
49
+ version: 3,
50
+ sources: [
51
+ source
52
+ ],
53
+ sourcesContent: [
54
+ original
55
+ ],
56
+ names: [],
57
+ mappings: lines.join(';')
58
+ };
59
+ }
6
60
  const PUBLIC_ROOT_SCHEME = 'https://extensionjs-public.invalid';
7
61
  function isFile(candidate) {
8
62
  try {
@@ -11,27 +65,41 @@ function isFile(candidate) {
11
65
  return false;
12
66
  }
13
67
  }
14
- function keepPublicRootRefs(source, publicRoot) {
15
- return replaceCssUrlRefs(source, (request)=>{
16
- if (!request.startsWith('/') || request.startsWith('//')) return;
68
+ function publicPathOfRelativeRef(req, { issuerDir, publicDir }) {
69
+ if (!req || /^[a-z][a-z0-9+.-]*:/i.test(req)) return;
70
+ if (req.startsWith('~') || req.startsWith('@')) return;
71
+ const absolutePath = __rspack_external_node_path_806ed179.resolve(issuerDir, req);
72
+ if (!isFile(absolutePath)) return;
73
+ return publicOwnedOutputName(absolutePath, publicDir);
74
+ }
75
+ function keepPublicRootRefs(source, publicRoot, relative) {
76
+ return replaceCssUrlRefs(source, (request, { isImport })=>{
77
+ if (request.startsWith('//')) return;
17
78
  const suffixAt = request.search(/[?#]/);
18
- const rel = (-1 === suffixAt ? request : request.slice(0, suffixAt)).slice(1);
19
- if (!rel || !isFile(__rspack_external_node_path_806ed179.join(publicRoot, rel))) return;
20
- return `${PUBLIC_ROOT_SCHEME}${request}`;
79
+ const req = -1 === suffixAt ? request : request.slice(0, suffixAt);
80
+ if (req.startsWith('/')) {
81
+ const rel = req.slice(1);
82
+ if (!rel || !isFile(__rspack_external_node_path_806ed179.join(publicRoot, rel))) return;
83
+ return `${PUBLIC_ROOT_SCHEME}${request}`;
84
+ }
85
+ if (!relative || isImport) return;
86
+ const publicPath = publicPathOfRelativeRef(req, relative);
87
+ if (!publicPath) return;
88
+ return `${PUBLIC_ROOT_SCHEME}/${publicPath}${request.slice(req.length)}`;
21
89
  });
22
90
  }
23
- function restorePublicRootRefs(source) {
24
- return source.split(PUBLIC_ROOT_SCHEME).join('');
25
- }
26
- function publicCssUrlLoader(source) {
91
+ function publicCssUrlLoader(source, map) {
27
92
  const { manifestPath, projectPath } = this.getOptions() || {};
28
- if (!manifestPath || !projectPath) return source;
29
- try {
93
+ let rewritten = source;
94
+ if (manifestPath && projectPath) try {
30
95
  const publicRoot = publicContainmentRoot(manifestPath, projectPath);
31
- return keepPublicRootRefs(source, publicRoot);
32
- } catch {
33
- return source;
34
- }
96
+ const publicDir = resolvePublicFolder(manifestPath, projectPath);
97
+ rewritten = keepPublicRootRefs(source, publicRoot, publicDir && this.resourcePath ? {
98
+ issuerDir: __rspack_external_node_path_806ed179.dirname(this.resourcePath),
99
+ publicDir
100
+ } : void 0);
101
+ } catch {}
102
+ this.callback(null, rewritten, map ?? (rewritten === source ? void 0 : lineRewriteSourceMap(source, rewritten, this.resourcePath || '')));
35
103
  }
36
104
  export default publicCssUrlLoader;
37
- export { PUBLIC_ROOT_SCHEME, keepPublicRootRefs, restorePublicRootRefs };
105
+ export { PUBLIC_ROOT_SCHEME, keepPublicRootRefs };
package/dist/273~0.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import { canonicalizeDir, canonicalizeResourcePath } from "./712~0.mjs";
2
3
  import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
3
4
  import * as __rspack_external_node_path_806ed179 from "node:path";
4
5
  const ASSET_EXT = /\.(png|jpe?g|gif|webp|svg|avif|ico|bmp|cur|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav)$/i;
@@ -20,11 +21,20 @@ function isDeadCssUrlRef(rawRequest, { issuerDir, roots }) {
20
21
  ];
21
22
  return !candidates.some((candidate)=>__rspack_external_node_fs_1b05aee1.existsSync(candidate));
22
23
  }
24
+ function publicOwnedOutputName(absolutePath, publicDir) {
25
+ if (!publicDir) return;
26
+ const rel = __rspack_external_node_path_806ed179.relative(canonicalizeDir(publicDir), canonicalizeResourcePath(absolutePath));
27
+ if (!rel || __rspack_external_node_path_806ed179.isAbsolute(rel) || '..' === rel.split(__rspack_external_node_path_806ed179.sep)[0]) return;
28
+ return toPosixPath(rel);
29
+ }
23
30
  function replaceCssUrlRefs(source, replacer) {
24
- return source.replace(URL_REF, (whole, dq, sq, bare)=>{
31
+ return source.replace(URL_REF, (whole, dq, sq, bare, offset)=>{
25
32
  const request = dq ?? sq ?? bare ?? '';
26
33
  if (!request) return whole;
27
- const next = replacer(request);
34
+ const before = source.slice(Math.max(0, offset - 32), offset);
35
+ const next = replacer(request, {
36
+ isImport: /@import\s*$/i.test(before)
37
+ });
28
38
  if (void 0 === next) return whole;
29
39
  return `url("${next.replace(/["\\]/g, '\\$&')}")`;
30
40
  });
@@ -42,4 +52,4 @@ function extractCssUrlRefs(source) {
42
52
  }
43
53
  return found;
44
54
  }
45
- export { extractCssUrlRefs, isDeadCssUrlRef, replaceCssUrlRefs, toPosixPath };
55
+ export { extractCssUrlRefs, isDeadCssUrlRef, publicOwnedOutputName, replaceCssUrlRefs, toPosixPath };