extension-develop 4.1.14 → 4.1.16

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 (57) hide show
  1. package/dist/0~dev-server.mjs +2 -2
  2. package/dist/0~rspack-config.mjs +216 -100
  3. package/dist/101.mjs +1 -1
  4. package/dist/266.mjs +40 -1
  5. package/dist/372.mjs +2 -1
  6. package/dist/77.mjs +4 -1
  7. package/dist/{518.mjs → 834.mjs} +1 -42
  8. package/dist/839.mjs +106 -3
  9. package/dist/86.mjs +45 -0
  10. package/dist/dead-css-url-loader.mjs +1 -1
  11. package/dist/extension-js-devtools/chrome/options/index.html +1 -1
  12. package/dist/extension-js-devtools/chrome/options/index.js +1 -1
  13. package/dist/extension-js-devtools/chrome/pages/centralized-logger.html +1 -1
  14. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -4
  15. package/dist/extension-js-devtools/chrome/pages/welcome.html +1 -1
  16. package/dist/extension-js-devtools/chrome/pages/welcome.js +4 -4
  17. package/dist/extension-js-devtools/chrome/shared/commons.js +1 -0
  18. package/dist/extension-js-devtools/chrome/shared/framework.js +1 -0
  19. package/dist/extension-js-devtools/chromium/options/index.html +1 -1
  20. package/dist/extension-js-devtools/chromium/options/index.js +1 -1
  21. package/dist/extension-js-devtools/chromium/pages/centralized-logger.html +1 -1
  22. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -4
  23. package/dist/extension-js-devtools/chromium/pages/welcome.html +1 -1
  24. package/dist/extension-js-devtools/chromium/pages/welcome.js +4 -4
  25. package/dist/extension-js-devtools/chromium/shared/commons.js +1 -0
  26. package/dist/extension-js-devtools/chromium/shared/framework.js +1 -0
  27. package/dist/extension-js-devtools/edge/options/index.html +1 -1
  28. package/dist/extension-js-devtools/edge/options/index.js +1 -1
  29. package/dist/extension-js-devtools/edge/pages/centralized-logger.html +1 -1
  30. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -4
  31. package/dist/extension-js-devtools/edge/pages/welcome.html +1 -1
  32. package/dist/extension-js-devtools/edge/pages/welcome.js +4 -4
  33. package/dist/extension-js-devtools/edge/shared/commons.js +1 -0
  34. package/dist/extension-js-devtools/edge/shared/framework.js +1 -0
  35. package/dist/extension-js-devtools/firefox/options/index.html +1 -1
  36. package/dist/extension-js-devtools/firefox/options/index.js +1 -1
  37. package/dist/extension-js-devtools/firefox/pages/centralized-logger.html +1 -1
  38. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -4
  39. package/dist/extension-js-devtools/firefox/pages/welcome.html +1 -1
  40. package/dist/extension-js-devtools/firefox/pages/welcome.js +4 -4
  41. package/dist/extension-js-devtools/firefox/shared/commons.js +1 -0
  42. package/dist/extension-js-devtools/firefox/shared/framework.js +1 -0
  43. package/dist/lib/messages.d.ts +1 -0
  44. package/dist/lib/normalize-split-chunks.d.ts +7 -0
  45. package/dist/lib/split-chunks.d.ts +13 -0
  46. package/dist/plugin-css/index.d.ts +1 -0
  47. package/dist/plugin-css/public-css-url-loader.d.ts +13 -0
  48. package/dist/plugin-web-extension/feature-html/html-lib/inject.d.ts +12 -1
  49. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +1 -1
  50. package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +2 -1
  51. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-injected-permissions.d.ts +2 -0
  52. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +21 -0
  53. package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +2 -0
  54. package/dist/plugin-web-extension/feature-scripts/steps/warn-split-initial-chunks.d.ts +7 -0
  55. package/dist/plugin-web-extension/shared/initial-files.d.ts +11 -0
  56. package/dist/public-css-url-loader.mjs +37 -0
  57. package/package.json +1 -1
@@ -390,45 +390,4 @@ function getBaseNode(htmlDocument) {
390
390
  }
391
391
  }
392
392
  }
393
- const ASSET_EXT = /\.(png|jpe?g|gif|webp|svg|avif|ico|bmp|cur|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav)$/i;
394
- const URL_REF = /url\(\s*(?:"([^"\n]*)"|'([^'\n]*)'|([^)'"\s]*))\s*\)/g;
395
- function toPosixPath(value) {
396
- return String(value).split(__rspack_external_node_path_c5b9b54f.sep).join('/');
397
- }
398
- function isDeadCssUrlRef(rawRequest, { issuerDir, roots }) {
399
- const req = String(rawRequest).split('?')[0].split('#')[0];
400
- if (!req || req.startsWith('//') || /^[a-z][a-z0-9+.-]*:/i.test(req)) return false;
401
- if (req.startsWith('~') || req.startsWith('@')) return false;
402
- const isRootRef = req.startsWith('/');
403
- const isRelativeRef = req.startsWith('./') || req.startsWith('../');
404
- const isBareAssetRef = !isRootRef && !isRelativeRef && ASSET_EXT.test(req);
405
- if (!isRootRef && !isRelativeRef && !isBareAssetRef) return false;
406
- const candidates = isRootRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req.slice(1))) : [
407
- __rspack_external_node_path_c5b9b54f.resolve(issuerDir, req),
408
- ...isBareAssetRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req)) : []
409
- ];
410
- return !candidates.some((candidate)=>__rspack_external_node_fs_5ea92f0c.existsSync(candidate));
411
- }
412
- function replaceCssUrlRefs(source, replacer) {
413
- return source.replace(URL_REF, (whole, dq, sq, bare)=>{
414
- const request = dq ?? sq ?? bare ?? '';
415
- if (!request) return whole;
416
- const next = replacer(request);
417
- if (void 0 === next) return whole;
418
- return `url("${next.replace(/["\\]/g, '\\$&')}")`;
419
- });
420
- }
421
- function extractCssUrlRefs(source) {
422
- const found = [];
423
- const seen = new Set();
424
- URL_REF.lastIndex = 0;
425
- let match;
426
- while(null !== (match = URL_REF.exec(source))){
427
- const request = match[1] ?? match[2] ?? match[3] ?? '';
428
- if (!request || seen.has(request)) continue;
429
- seen.add(request);
430
- found.push(request);
431
- }
432
- return found;
433
- }
434
- export { applyRewrittenStaticUrl, cleanAssetUrl, cleanLeading, extractCssUrlRefs, getAssetsFromHtml, getBaseHref, getBaseNode, getExtname, getFilePath, getHtmlPageDeclaredAssetPath, htmlStaticAssetOutputName, iconOutputPath, isDeadCssUrlRef, isFromIncludeList, isHttpLike, isSpecialScheme, manifestJsonOutputTarget, manifestPageOutputTarget, normalizeManifestOutputPath, parseHtml, replaceCssUrlRefs, resolveAbsoluteFsPath, resolveHtmlRefPath, resolveStaticAttributeName, themeIconOutputPath, themeImageOutputPath, toPosixPath, utils_isUrl };
393
+ export { applyRewrittenStaticUrl, cleanAssetUrl, cleanLeading, getAssetsFromHtml, getBaseHref, getBaseNode, getExtname, getFilePath, getHtmlPageDeclaredAssetPath, htmlStaticAssetOutputName, iconOutputPath, isFromIncludeList, isHttpLike, isSpecialScheme, manifestJsonOutputTarget, manifestPageOutputTarget, normalizeManifestOutputPath, parseHtml, resolveAbsoluteFsPath, resolveHtmlRefPath, resolveStaticAttributeName, themeIconOutputPath, themeImageOutputPath, utils_isUrl };
package/dist/839.mjs CHANGED
@@ -7,7 +7,7 @@ import { EventEmitter } from "node:events";
7
7
  import { browserRowValue, ENVELOPE, CODES, prefix as messaging_prefix, card, isDebug, claimCardKey, isMachineOutput } from "./349.mjs";
8
8
  import { package_namespaceObject, loadCommandConfig, DEV_COMMAND_DEFAULTS, stampReadyDistExtensionId, loadProjectConfigDefaults, mergeOptionLayers, stampReadyKnownExtensionId, assertNoManagedDependencyConflicts, loadCustomConfig, START_BUILD_DEFAULTS, loadBrowserConfig, resolveCompanionExtensionsConfig, BUILD_COMMAND_DEFAULTS, getSpecialFoldersDataForProjectRoot, withDarkMode } from "./101.mjs";
9
9
  import { stripBom, parseJsonSafe } from "./23.mjs";
10
- import { buildAssetsTree, buildWarningsDetails, getProjectStructure, buildFailed, needsInstall, getDirs, buildCommandFailed, writingTypeDefinitions, buildComplete, zipArtifactReady, ensureSessionStateInProjectGitignore, projectInstallFallbackToNpm, ensureSessionArtifactsIgnoreFile, normalizeBrowser, debugDirs, debugBrowser, debugOutputPath, browserLaunchFailed, buildSummaryPath, extensionLoadRecovered, extensionLoadStillRefused, getDistPath, buildShareHint, writingTypeDefinitionsError, devCommandFailed, projectInstallScriptsDisabled, authorInstallNotice, configBrowserOrThrow } from "./77.mjs";
10
+ import { buildWarningsDetails, buildFailed, getDirs, zipArtifactReady, projectInstallFallbackToNpm, debugDirs, browserLaunchFailed, buildSummaryPath, extensionLoadRecovered, extensionLoadStillRefused, writingTypeDefinitionsError, buildAssetsTree, authorInstallNotice, projectInstallScriptsDisabled, configBrowserOrThrow, needsInstall, buildCommandFailed, writingTypeDefinitions, buildComplete, ensureSessionStateInProjectGitignore, ensureSessionArtifactsIgnoreFile, normalizeBrowser, debugBrowser, debugOutputPath, devCommandFailed, getProjectStructure, getDistPath, buildShareHint, debugSplitChunksNarrowed } from "./77.mjs";
11
11
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
12
12
  import { publicRootsFor } from "./278.mjs";
13
13
  import { getCanonicalContentScriptEntryName } from "./291.mjs";
@@ -904,6 +904,109 @@ async function generateExtensionTypes(manifestDir, packageJsonDir) {
904
904
  }
905
905
  }
906
906
  }
907
+ function classifyEntrySurface(entryName) {
908
+ if (entryName.startsWith('background')) return 'background';
909
+ if (entryName.startsWith("content_scripts/")) return "content_script";
910
+ if (entryName.startsWith("scripts/")) return "script";
911
+ return 'page';
912
+ }
913
+ function isPageChunkName(name) {
914
+ return 'string' == typeof name && name.length > 0 && 'page' === classifyEntrySurface(name);
915
+ }
916
+ function isSurfaceLockedChunkName(name) {
917
+ return 'string' == typeof name && 'page' !== classifyEntrySurface(name);
918
+ }
919
+ function canBeInitial(chunk) {
920
+ return 'function' == typeof chunk.canBeInitial ? chunk.canBeInitial() : true;
921
+ }
922
+ function pageInitialChunks(chunk) {
923
+ return canBeInitial(chunk) && isPageChunkName(chunk.name);
924
+ }
925
+ const FRAMEWORK_PACKAGE_PATTERN = /[\\/]node_modules[\\/](react|react-dom|scheduler|preact|vue|@vue|svelte|solid-js|lit|lit-html|lit-element|@lit)[\\/]/;
926
+ const SCRIPT_MODULE_TYPE = /^javascript\//;
927
+ function defaultSplitChunks() {
928
+ return {
929
+ chunks: pageInitialChunks,
930
+ cacheGroups: {
931
+ default: false,
932
+ defaultVendors: false,
933
+ framework: {
934
+ name: 'shared/framework',
935
+ filename: 'shared/framework.js',
936
+ test: FRAMEWORK_PACKAGE_PATTERN,
937
+ type: SCRIPT_MODULE_TYPE,
938
+ priority: 40,
939
+ enforce: true,
940
+ reuseExistingChunk: true
941
+ },
942
+ commons: {
943
+ name: 'shared/commons',
944
+ filename: 'shared/commons.js',
945
+ type: SCRIPT_MODULE_TYPE,
946
+ minChunks: 2,
947
+ minSize: 0,
948
+ priority: 20,
949
+ reuseExistingChunk: true
950
+ }
951
+ }
952
+ };
953
+ }
954
+ function narrowedSelector(option) {
955
+ if ('all' === option) return (chunk)=>!isSurfaceLockedChunkName(chunk.name);
956
+ return (chunk)=>('function' == typeof chunk.canBeInitial ? chunk.canBeInitial() : true) && !isSurfaceLockedChunkName(chunk.name);
957
+ }
958
+ function narrowChunks(chunks) {
959
+ if ('all' === chunks || 'initial' === chunks) return narrowedSelector(chunks);
960
+ }
961
+ function normalizeSplitChunks(config) {
962
+ const splitChunks = config.optimization?.splitChunks;
963
+ if (!splitChunks || 'object' != typeof splitChunks) return {
964
+ config,
965
+ narrowed: []
966
+ };
967
+ const narrowed = [];
968
+ const next = {
969
+ ...splitChunks
970
+ };
971
+ const topLevel = narrowChunks(splitChunks.chunks);
972
+ if (topLevel) {
973
+ next.chunks = topLevel;
974
+ narrowed.push('splitChunks.chunks');
975
+ }
976
+ if (splitChunks.cacheGroups && 'object' == typeof splitChunks.cacheGroups) {
977
+ const cacheGroups = {};
978
+ for (const [key, group] of Object.entries(splitChunks.cacheGroups)){
979
+ const groupSelector = group && 'object' == typeof group ? narrowChunks(group.chunks) : void 0;
980
+ if (groupSelector && group && 'object' == typeof group) {
981
+ cacheGroups[key] = {
982
+ ...group,
983
+ chunks: groupSelector
984
+ };
985
+ narrowed.push(`splitChunks.cacheGroups.${key}.chunks`);
986
+ } else cacheGroups[key] = group;
987
+ }
988
+ next.cacheGroups = cacheGroups;
989
+ }
990
+ if (0 === narrowed.length) return {
991
+ config,
992
+ narrowed
993
+ };
994
+ return {
995
+ config: {
996
+ ...config,
997
+ optimization: {
998
+ ...config.optimization,
999
+ splitChunks: next
1000
+ }
1001
+ },
1002
+ narrowed
1003
+ };
1004
+ }
1005
+ function applySplitChunksGuard(config) {
1006
+ const { config: next, narrowed } = normalizeSplitChunks(config);
1007
+ if (narrowed.length > 0 && isDebug()) console.log(debugSplitChunksNarrowed(narrowed));
1008
+ return next;
1009
+ }
907
1010
  const ARTIFACTS_KEY = '__extensionJsZipArtifacts';
908
1011
  function recordZipArtifact(carrier, artifact) {
909
1012
  if (!carrier || 'object' != typeof carrier) return;
@@ -1166,7 +1269,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1166
1269
  ...baseConfig,
1167
1270
  plugins: allPluginsButBrowserRunners
1168
1271
  });
1169
- const compilerConfig = merge(userConfig);
1272
+ const compilerConfig = applySplitChunksGuard(merge(userConfig));
1170
1273
  compilerConfig.stats = false;
1171
1274
  const compileContext = 'string' == typeof compilerConfig.context && compilerConfig.context ? __rspack_external_node_path_c5b9b54f.resolve(compilerConfig.context) : packageJsonDir;
1172
1275
  const mergedOutputPath = 'string' == typeof compilerConfig.output?.path ? __rspack_external_node_path_c5b9b54f.resolve(compileContext, compilerConfig.output.path) : '';
@@ -1941,4 +2044,4 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1941
2044
  process.exit(1);
1942
2045
  }
1943
2046
  }
1944
- export { BuildEmitter, attachLifecycleStream, buildSourceFeatureIndex, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, humanLine, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, readContentScriptCount, recordZipArtifact, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager };
2047
+ export { BuildEmitter, applySplitChunksGuard, attachLifecycleStream, buildSourceFeatureIndex, classifyEntrySurface, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, defaultSplitChunks, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, humanLine, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, readContentScriptCount, recordZipArtifact, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager };
package/dist/86.mjs ADDED
@@ -0,0 +1,45 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
4
+ const ASSET_EXT = /\.(png|jpe?g|gif|webp|svg|avif|ico|bmp|cur|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav)$/i;
5
+ const URL_REF = /url\(\s*(?:"([^"\n]*)"|'([^'\n]*)'|([^)'"\s]*))\s*\)/g;
6
+ function toPosixPath(value) {
7
+ return String(value).split(__rspack_external_node_path_c5b9b54f.sep).join('/');
8
+ }
9
+ function isDeadCssUrlRef(rawRequest, { issuerDir, roots }) {
10
+ const req = String(rawRequest).split('?')[0].split('#')[0];
11
+ if (!req || req.startsWith('//') || /^[a-z][a-z0-9+.-]*:/i.test(req)) return false;
12
+ if (req.startsWith('~') || req.startsWith('@')) return false;
13
+ const isRootRef = req.startsWith('/');
14
+ const isRelativeRef = req.startsWith('./') || req.startsWith('../');
15
+ const isBareAssetRef = !isRootRef && !isRelativeRef && ASSET_EXT.test(req);
16
+ if (!isRootRef && !isRelativeRef && !isBareAssetRef) return false;
17
+ const candidates = isRootRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req.slice(1))) : [
18
+ __rspack_external_node_path_c5b9b54f.resolve(issuerDir, req),
19
+ ...isBareAssetRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req)) : []
20
+ ];
21
+ return !candidates.some((candidate)=>__rspack_external_node_fs_5ea92f0c.existsSync(candidate));
22
+ }
23
+ function replaceCssUrlRefs(source, replacer) {
24
+ return source.replace(URL_REF, (whole, dq, sq, bare)=>{
25
+ const request = dq ?? sq ?? bare ?? '';
26
+ if (!request) return whole;
27
+ const next = replacer(request);
28
+ if (void 0 === next) return whole;
29
+ return `url("${next.replace(/["\\]/g, '\\$&')}")`;
30
+ });
31
+ }
32
+ function extractCssUrlRefs(source) {
33
+ const found = [];
34
+ const seen = new Set();
35
+ URL_REF.lastIndex = 0;
36
+ let match;
37
+ while(null !== (match = URL_REF.exec(source))){
38
+ const request = match[1] ?? match[2] ?? match[3] ?? '';
39
+ if (!request || seen.has(request)) continue;
40
+ seen.add(request);
41
+ found.push(request);
42
+ }
43
+ return found;
44
+ }
45
+ export { extractCssUrlRefs, isDeadCssUrlRef, replaceCssUrlRefs, toPosixPath };
@@ -2,7 +2,7 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
2
2
  import { WebpackError } from "@rspack/core";
3
3
  import { publicFolderOrDefault } from "./278.mjs";
4
4
  import { canonicalizeDir, canonicalizeResourcePath } from "./93.mjs";
5
- import { isDeadCssUrlRef, extractCssUrlRefs, toPosixPath } from "./518.mjs";
5
+ import { isDeadCssUrlRef, extractCssUrlRefs, toPosixPath } from "./86.mjs";
6
6
  import { deadCssUrlRef } from "./845.mjs";
7
7
  import { toRuntimeStylesheetModule, rewriteInlinedCssUrls } from "./372.mjs";
8
8
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
@@ -5,7 +5,7 @@
5
5
  <link rel="stylesheet" href="/options/index.css"></head>
6
6
  <body>
7
7
  <div id="root"></div>
8
- <script src="/options/index.js" type="module"></script>
8
+ <script src="/shared/framework.js" type="module"></script><script src="/shared/commons.js" type="module"></script><script src="/options/index.js" type="module"></script>
9
9
 
10
10
 
11
11
  </body></html>