extension-develop 4.0.30 → 4.0.33

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.
package/dist/839.mjs CHANGED
@@ -5,7 +5,7 @@ import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
5
5
  import "pintor";
6
6
  import { EventEmitter } from "node:events";
7
7
  import { browserRowValue, ENVELOPE, CODES, prefix as messaging_prefix, card, isDebug, claimCardKey, isMachineOutput } from "./349.mjs";
8
- import { package_namespaceObject, buildWarningsDetails, DEV_COMMAND_DEFAULTS, buildFailed, getDirs, stampReadyDistExtensionId, zipArtifactReady, stampReadyKnownExtensionId, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, START_BUILD_DEFAULTS, extensionLoadRecovered, extensionLoadStillRefused, writingTypeDefinitionsError, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildAssetsTree, loadCommandConfig, needsInstall, mergeOptionLayers, buildCommandFailed, writingTypeDefinitions, buildComplete, normalizeBrowser, debugBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, buildShareHint, loadBrowserConfig, BUILD_COMMAND_DEFAULTS } from "./101.mjs";
8
+ import { package_namespaceObject, buildWarningsDetails, DEV_COMMAND_DEFAULTS, buildFailed, getDirs, stampReadyDistExtensionId, zipArtifactReady, stampReadyKnownExtensionId, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, START_BUILD_DEFAULTS, extensionLoadRecovered, extensionLoadStillRefused, writingTypeDefinitionsError, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildAssetsTree, loadCommandConfig, needsInstall, mergeOptionLayers, buildCommandFailed, writingTypeDefinitions, buildComplete, normalizeBrowser, debugBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, buildShareHint, loadBrowserConfig, BUILD_COMMAND_DEFAULTS, withDarkMode } from "./101.mjs";
9
9
  import { stripBom, parseJsonSafe } from "./23.mjs";
10
10
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
11
11
  import { buildSummaryPath, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore } from "./494.mjs";
@@ -890,7 +890,14 @@ let hasShownUserMessage = false;
890
890
  function findNearestPackageJsonDirectory(startPath) {
891
891
  return findNearestProjectManifestDirSync(startPath, 6);
892
892
  }
893
- function hasTypeScriptSourceFiles(projectPath) {
893
+ const NON_SOURCE_DIRS = new Set([
894
+ 'node_modules',
895
+ 'dist',
896
+ 'public'
897
+ ]);
898
+ const MAX_SOURCE_SCAN_DEPTH = 4;
899
+ function hasTypeScriptSourceFiles(projectPath, depth = 0) {
900
+ if (depth > MAX_SOURCE_SCAN_DEPTH) return false;
894
901
  try {
895
902
  const entries = __rspack_external_node_fs_5ea92f0c.readdirSync(projectPath, {
896
903
  withFileTypes: true
@@ -904,14 +911,9 @@ function hasTypeScriptSourceFiles(projectPath) {
904
911
  return true;
905
912
  }
906
913
  if (entry.isDirectory()) {
907
- if (![
908
- 'src',
909
- 'content',
910
- 'sidebar',
911
- 'background'
912
- ].includes(entry.name)) return false;
914
+ if (entry.name.startsWith('.') || NON_SOURCE_DIRS.has(entry.name)) return false;
913
915
  const sub = __rspack_external_node_path_c5b9b54f.join(projectPath, entry.name);
914
- return hasTypeScriptSourceFiles(sub);
916
+ return hasTypeScriptSourceFiles(sub, depth + 1);
915
917
  }
916
918
  return false;
917
919
  });
@@ -930,18 +932,18 @@ function isUsingTypeScript(projectPath) {
930
932
  return hasTypeScriptDependency(projectPath) || hasTypeScriptSourceFiles(projectPath);
931
933
  }
932
934
  function ensureTypeScriptConfig(projectPath) {
933
- if (hasShownUserMessage) return;
934
935
  const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
935
936
  const hasDep = hasTypeScriptDependency(projectPath);
936
937
  const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
937
- if (hasDep || hasTsFiles) if (tsConfigFilePath) {
938
- if (isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('TypeScript')}`);
939
- } else if (hasTsFiles) throw new Error('[Extension.js] Missing tsconfig.json next to package.json. Create one to use TypeScript.');
940
- else {
941
- console.log(creatingTSConfig());
942
- writeTsConfig(projectPath);
938
+ if (hasDep || hasTsFiles) {
939
+ if (tsConfigFilePath) {
940
+ if (!hasShownUserMessage && isDebug()) console.log(`${messaging_prefix('debug')} ${isUsingIntegration('TypeScript')}`);
941
+ } else {
942
+ if (!hasShownUserMessage) console.log(creatingTSConfig());
943
+ writeTsConfig(projectPath);
944
+ }
945
+ hasShownUserMessage = true;
943
946
  }
944
- hasShownUserMessage = true;
945
947
  }
946
948
  function defaultTypeScriptConfig(projectPath, _opts) {
947
949
  return {
@@ -978,7 +980,8 @@ function getUserTypeScriptConfigFile(projectPath) {
978
980
  }
979
981
  }
980
982
  function writeTsConfig(projectPath) {
981
- __rspack_external_node_fs_5ea92f0c.writeFileSync(__rspack_external_node_path_c5b9b54f.join(projectPath, 'tsconfig.json'), JSON.stringify(defaultTypeScriptConfig(projectPath, {
983
+ const targetDir = findNearestPackageJsonDirectory(projectPath) || projectPath;
984
+ __rspack_external_node_fs_5ea92f0c.writeFileSync(__rspack_external_node_path_c5b9b54f.join(targetDir, 'tsconfig.json'), JSON.stringify(defaultTypeScriptConfig(projectPath, {
982
985
  mode: 'development'
983
986
  }), null, 2));
984
987
  }
@@ -1055,8 +1058,9 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1055
1058
  if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, manifestDir);
1056
1059
  const commandKey = buildOptions?.metadataCommand === 'start' ? 'start' : 'build';
1057
1060
  const commandConfig = await loadCommandConfig(packageJsonDir, commandKey);
1061
+ const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
1058
1062
  const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
1059
- const mergedBuildOptions = mergeOptionLayers('start' === commandKey ? START_BUILD_DEFAULTS : BUILD_COMMAND_DEFAULTS, commandConfig, buildOptions);
1063
+ const mergedBuildOptions = mergeOptionLayers('start' === commandKey ? START_BUILD_DEFAULTS : BUILD_COMMAND_DEFAULTS, browserConfig, commandConfig, buildOptions);
1060
1064
  const silent = Boolean(mergedBuildOptions.silent);
1061
1065
  removeStaleStagingDirs(distPath);
1062
1066
  if (debug) {
@@ -1064,7 +1068,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1064
1068
  console.log(debugBrowser(browser, buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary));
1065
1069
  console.log(debugOutputPath(distPath));
1066
1070
  }
1067
- const mergedExtensionsConfig = buildOptions?.extensions ?? commandConfig.extensions ?? specialFoldersData.extensions;
1071
+ const mergedExtensionsConfig = buildOptions?.extensions ?? commandConfig.extensions ?? browserConfig.extensions ?? specialFoldersData.extensions;
1068
1072
  const resolvedExtensionsConfig = await resolveCompanionExtensionsConfig({
1069
1073
  projectRoot: packageJsonDir,
1070
1074
  browser,
@@ -1678,7 +1682,10 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1678
1682
  }
1679
1683
  const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
1680
1684
  const commandConfig = await loadCommandConfig(packageJsonDir, 'dev');
1681
- const merged = mergeOptionLayers(DEV_COMMAND_DEFAULTS, browserConfig, commandConfig, devOptions);
1685
+ const merged = withDarkMode({
1686
+ ...mergeOptionLayers(DEV_COMMAND_DEFAULTS, browserConfig, commandConfig, devOptions),
1687
+ browser
1688
+ });
1682
1689
  if (('safari' === browser || 'webkit-based' === browser) && !devOptions.noBrowser && devOptions.safariPackager) {
1683
1690
  const safariPackager = devOptions.safariPackager;
1684
1691
  const safariOverrides = {
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "E_BROWSER_NOT_INSTALLABLE": {
42
42
  "area": "usage",
43
- "summary": "The browser ships with the OS and cannot be installed by the CLI."
43
+ "summary": "The browser is a known target but has no managed download; the CLI cannot fetch it."
44
44
  },
45
45
  "E_PARENT_GONE": {
46
46
  "area": "usage",
@@ -18,6 +18,7 @@ export interface StatsToStringLike {
18
18
  export declare function isEmitTimeWarning(warning: {
19
19
  code?: unknown;
20
20
  } | string | null | undefined): boolean;
21
+ export declare function humanizeCaseMismatchBlocks(raw: string, showStack?: boolean): string;
21
22
  export declare function wrapStatsBlocks(raw: string): string;
22
23
  export declare function renderStatsBlocks(stats: StatsToStringLike, opts: {
23
24
  errors: boolean;
@@ -7,3 +7,9 @@ export declare class EnvPlugin {
7
7
  constructor(options: Partial<PluginInterface>);
8
8
  apply(compiler: Compiler): void;
9
9
  }
10
+ /**
11
+ * Env values available to `$EXTENSION_*` placeholders in emitted .json/.html.
12
+ * Mirrors DefinePlugin: dotenv/process values plus the per-build-target
13
+ * browser and mode synthetics JS already reads via import.meta.env.
14
+ */
15
+ export declare function buildTemplateVars(combinedVars: Record<string, unknown>, browser: DevOptions['browser'], mode: string): Record<string, string>;
@@ -1,3 +1,3 @@
1
- export type AssetCategory = 'content-script' | 'service-worker' | 'page' | 'ignored';
1
+ export type AssetCategory = 'content-script' | 'service-worker' | 'page' | 'runtime' | 'ignored';
2
2
  export declare function categorizeAsset(rawName: string): AssetCategory;
3
3
  export declare const BUDGET_BYTES: Record<AssetCategory, number>;
@@ -14,6 +14,7 @@ interface PerfBudgetsPluginOptions {
14
14
  * content_scripts/* → 512 KiB (injected on every navigation)
15
15
  * background / SW → 512 KiB (wakes from cold each session)
16
16
  * pages / sidebar / … → 1 MiB (opened on demand)
17
+ * runtime / wasm cores → 1 MiB (hashed payloads at the output root)
17
18
  * images, fonts, etc. → silenced (not a code-splitting concern)
18
19
  *
19
20
  * Numbers are sized to clear realistic framework templates (React/Vue/
@@ -7,6 +7,7 @@ export declare class WasmPlugin {
7
7
  constructor(options: PluginInterface & {
8
8
  mode: DevOptions['mode'];
9
9
  });
10
+ private collectSearchRoots;
10
11
  private resolveAssetPath;
11
12
  private buildAssetAliases;
12
13
  private ensureWasmResolution;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Old Extension.js scaffold layout → current standardized HTML destinations.
3
+ * Detection is field-scoped on purpose: a string that merely looks like an old
4
+ * path in description, web_accessible_resources, or any other field is not a hit.
5
+ */
6
+ export interface LegacyManifestPathRule {
7
+ /** Dot-path into the author manifest (e.g. `options_ui.page`). */
8
+ field: string;
9
+ /** Exact path the old scaffold wrote into that field. */
10
+ legacyPath: string;
11
+ /** Canonical emit destination Extension.js rewrites the field to. */
12
+ modernPath: string;
13
+ }
14
+ export interface LegacyManifestPathHit {
15
+ field: string;
16
+ legacyPath: string;
17
+ modernPath: string;
18
+ }
19
+ export declare const LEGACY_MANIFEST_PATH_RULES: readonly LegacyManifestPathRule[];
20
+ /** Collapse author path noise so `./x` and `/x` match the scaffold form. */
21
+ export declare function normalizeLegacyPathRef(raw: string): string;
22
+ /**
23
+ * Field-by-field scan of the *author* manifest for old scaffold HTML paths.
24
+ * Call this on the pre-rewrite source; the emitted asset already has modern paths.
25
+ */
26
+ export declare function findLegacyManifestPathHits(manifest: unknown): LegacyManifestPathHit[];
@@ -1,5 +1,5 @@
1
1
  export declare function serverRestartRequiredFromManifestError(fileAdded: string, fileRemoved: string): string;
2
- export declare function legacyManifestPathWarning(legacyPath: string): string;
2
+ export declare function legacyManifestPathWarning(field: string, legacyPath: string, modernPath: string): string;
3
3
  export declare function fatalManifestShapeFixed(field: string, detail: string): string;
4
4
  export declare function invalidThemeValue(field: string, detail: string, value: string): string;
5
5
  export declare function themeNotSupportedByBrowser(browser: string): string;
@@ -1,5 +1,6 @@
1
1
  import { type Compiler } from '@rspack/core';
2
2
  export declare class ManifestLegacyWarnings {
3
3
  static readonly name: string;
4
+ private reportedHits;
4
5
  apply(compiler: Compiler): void;
5
6
  }
@@ -3,6 +3,7 @@ import type { DevOptions, PluginInterface } from '../../../types';
3
3
  export declare class UpdateManifest {
4
4
  readonly manifestPath: string;
5
5
  readonly browser: DevOptions['browser'];
6
+ private reportedFatalFixes;
6
7
  constructor(options: PluginInterface);
7
8
  private applyDevOverrides;
8
9
  apply(compiler: Compiler): void;
@@ -1,4 +1,6 @@
1
1
  import type { Compilation } from '@rspack/core';
2
2
  import type { FilepathList } from '../../types';
3
3
  export declare const EMITTED_ASSET_REF_PATTERN: RegExp;
4
+ export declare function listEmittedAssetNames(compilation: Compilation): string[];
5
+ export declare function collectReferencedRuntimePayloads(source: string, emittedAssetNames: string[]): string[];
4
6
  export declare function collectContentScriptEntryImports(compilation: Compilation, includeList?: FilepathList): Record<string, string[]>;
@@ -0,0 +1,8 @@
1
+ import type { FilepathList } from '../../types';
2
+ /**
3
+ * Statically discovers HTML pages referenced only through
4
+ * chrome.devtools.panels.create in the devtools page's scripts, and returns
5
+ * them as extra HTML entries keyed by their extension-root-relative path so
6
+ * the emitted dist serves the exact URL Chrome will request.
7
+ */
8
+ export declare function discoverDevtoolsPanelPages(manifestPath: string): FilepathList;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.0.30",
46
+ "version": "4.0.33",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",
@@ -99,13 +99,13 @@
99
99
  "@rspack/plugin-react-refresh": "2.0.2",
100
100
  "@vue/compiler-sfc": "3.5.26",
101
101
  "acorn": "^8.16.0",
102
- "adm-zip": "^0.6.0",
103
102
  "browser-extension-manifest-fields": "^2.2.9",
104
103
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
105
104
  "content-security-policy-parser": "^0.6.0",
106
105
  "dotenv": "^17.2.3",
107
106
  "es-module-lexer": "^2.1.0",
108
- "extension-from-store": "^0.1.1",
107
+ "extension-from-store": "^0.2.5",
108
+ "fflate": "^0.8.3",
109
109
  "go-git-it": "^5.1.5",
110
110
  "ignore": "^7.0.5",
111
111
  "less": "4.6.7",
@@ -133,7 +133,6 @@
133
133
  "devDependencies": {
134
134
  "@prefresh/webpack": "4.0.6",
135
135
  "@rslib/core": "^0.23.1",
136
- "@types/adm-zip": "^0.5.7",
137
136
  "@types/case-sensitive-paths-webpack-plugin": "^2.1.9",
138
137
  "@types/chrome": "^0.1.33",
139
138
  "@types/cross-spawn": "^6.0.6",