extension-develop 4.1.34 → 4.1.35

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 (78) hide show
  1. package/dist/206~0.mjs +33 -0
  2. package/dist/363~0.mjs +1 -1
  3. package/dist/469~0.mjs +98 -16
  4. package/dist/519~0.mjs +12 -1
  5. package/dist/771~0.mjs +49 -8
  6. package/dist/832~0.mjs +127 -25
  7. package/dist/840~0.mjs +215 -54
  8. package/dist/846~0.mjs +16 -14
  9. package/dist/852~0.mjs +2 -0
  10. package/dist/88~0.mjs +10 -1
  11. package/dist/command-preview.d.ts +2 -0
  12. package/dist/contract/codes.json +9 -0
  13. package/dist/contracts-entry.d.ts +1 -1
  14. package/dist/contracts.mjs +109 -1
  15. package/dist/css-parse-guard-loader.mjs +7 -2
  16. package/dist/dev-server/control-bridge/log-rule.d.ts +38 -0
  17. package/dist/dev-server/control-bridge/logs-query.d.ts +2 -55
  18. package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
  19. package/dist/dev-server/html-refresh.d.ts +10 -0
  20. package/dist/dev-server/port-manager.d.ts +14 -0
  21. package/dist/dev-server/reserved-listen.d.ts +9 -0
  22. package/dist/dev-server/session-restart.d.ts +1 -1
  23. package/dist/dev-server~0.mjs +155 -30
  24. package/dist/extension-js-devtools/build-stamp.json +2 -2
  25. package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
  26. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  27. package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
  28. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  29. package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
  30. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  31. package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
  32. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  33. package/dist/extension-js-theme/build-stamp.json +2 -2
  34. package/dist/feature-scripts-classic-concat-loader.js +45 -2
  35. package/dist/feature-scripts-classic-concat-loader.mjs +45 -2
  36. package/dist/feature-scripts-classic-traced-globals-loader.mjs +111 -0
  37. package/dist/feature-scripts-content-script-wrapper.js +10 -6
  38. package/dist/feature-scripts-content-script-wrapper.mjs +10 -6
  39. package/dist/lib/config-loader.d.ts +1 -0
  40. package/dist/lib/css-minimizer-options.d.ts +8 -0
  41. package/dist/lib/develop-context.d.ts +1 -1
  42. package/dist/lib/live-dev-session.d.ts +5 -0
  43. package/dist/lib/messages.d.ts +9 -1
  44. package/dist/lib/messaging.d.ts +2 -0
  45. package/dist/lib/package-manager.d.ts +7 -1
  46. package/dist/lib/paths.d.ts +1 -0
  47. package/dist/lib/project.d.ts +10 -2
  48. package/dist/lib/remote-archive.d.ts +11 -0
  49. package/dist/lib/rename-with-retry.d.ts +6 -0
  50. package/dist/lib/session-paths.d.ts +1 -0
  51. package/dist/lib/zip.d.ts +5 -1
  52. package/dist/plugin-browsers/index.d.ts +2 -0
  53. package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
  54. package/dist/plugin-css/css-in-html-loader.d.ts +1 -1
  55. package/dist/plugin-css/css-lib/build-css-rules.d.ts +2 -1
  56. package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
  57. package/dist/plugin-js-frameworks/js-tools/typescript.d.ts +1 -0
  58. package/dist/plugin-playwright/index.d.ts +3 -0
  59. package/dist/plugin-special-folders/messages.d.ts +1 -0
  60. package/dist/plugin-special-folders/warn-upon-folder-changes.d.ts +1 -1
  61. package/dist/plugin-web-extension/feature-html/html-lib/options-dialog-floor.d.ts +7 -0
  62. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +3 -1
  63. package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
  64. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-injected-hosts.d.ts +4 -1
  65. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +1 -0
  66. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/classic-concat-loader.d.ts +1 -0
  67. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +1 -0
  68. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +1 -0
  69. package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +7 -0
  70. package/dist/plugin-web-extension/feature-scripts/steps/warn-unshipped-runtime-assets.d.ts +32 -0
  71. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +1 -0
  72. package/dist/plugin-web-extension/shared/discover-runtime-surfaces.d.ts +2 -0
  73. package/dist/plugin-web-extension/shared/script-graph.d.ts +4 -0
  74. package/dist/rspack-config~0.mjs +799 -196
  75. package/dist/types.d.ts +7 -1
  76. package/dist/zip~0.mjs +14 -7
  77. package/package.json +3 -3
  78. package/dist/plugin-css/css-lib/is-content-script.d.ts +0 -2
package/dist/840~0.mjs CHANGED
@@ -12,11 +12,12 @@ import { EventEmitter } from "node:events";
12
12
  import { browserRowValue, CODES, ENVELOPE, prefix as messaging_prefix, humanLine, card, debugLine, isDebug, claimCardKey, isMachineOutput } from "./852~0.mjs";
13
13
  import { package_namespaceObject, DEV_COMMAND_DEFAULTS, stampReadyDistExtensionId, takeCodedWarnings, mergeOptionLayers, shouldWarnPortConflict, stampReadyKnownExtensionId, assertNoManagedDependencyConflicts, recordCodedWarning, falseProfileSource, START_BUILD_DEFAULTS, resolveCompanionExtensionsConfig, BUILD_COMMAND_DEFAULTS, getSpecialFoldersDataForProjectRoot, withDarkMode } from "./832~0.mjs";
14
14
  import { stripBom, parseJsonSafe, isGeckoBasedBrowser } from "./937~0.mjs";
15
- import { buildWarningsDetails, buildFailed, getDirs, listOutputFiles, zipArtifactReady, projectInstallFallbackToNpm, debugDirs, zipArtifactNotCreated, addonLintDependencyAttribution, browserLaunchFailed, collapseHomeDir, addonLintMore, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, operaBuildUnminified, buildAssetsTree, addonLintFailed, addonLintFailedDebug, safariBuildOutputNotFound, projectInstallScriptsDisabled, addonLintFinding, authorInstallNotice, addonLintSummary, codedError, configResolvedChangeIgnored, projectInstallInWorkspaceRoot, addonLintNotInstalled, writingTypeDefinitions, buildComplete, buildCommandFailed, needsInstall, relativeToDir, displayPath, updatingTypeDefinitions, runtimeChunkKeptInline, debugBrowser, normalizeBrowser, configBrowserOrThrow, debugOutputPath, safariInvalidBundleId, devCommandFailed, buildShareHint, getDistPath, getProjectStructure, debugSplitChunksNarrowed } from "./469~0.mjs";
15
+ import { buildWarningsDetails, buildOutDirInvalid, buildFailed, getBuildDistPath, getDirs, listOutputFiles, zipArtifactReady, projectInstallFallbackToNpm, debugDirs, zipArtifactNotCreated, buildSharesDevDistText, addonLintDependencyAttribution, browserLaunchFailed, collapseHomeDir, addonLintMore, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, operaBuildUnminified, buildAssetsTree, addonLintFailed, addonLintFailedDebug, safariBuildOutputNotFound, projectInstallScriptsDisabled, addonLintFinding, buildSharesDevDist, authorInstallNotice, codedError, configResolvedChangeIgnored, projectInstallInWorkspaceRoot, addonLintNotInstalled, addonLintSummary, writingTypeDefinitions, buildComplete, buildCommandFailed, needsInstall, relativeToDir, updatingTypeDefinitions, runtimeChunkKeptInline, debugBrowser, normalizeBrowser, displayPath, debugOutputPath, safariInvalidBundleId, configBrowserOrThrow, devCommandFailed, buildShareHint, getProjectStructure, debugSplitChunksNarrowed } from "./469~0.mjs";
16
16
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./731~0.mjs";
17
+ import { renameSyncWithRetry } from "./206~0.mjs";
17
18
  import { loadCommandConfig, loadDefineTypes, loadBrowserConfig, loadProjectConfigDefaults, loadConfigResolvedHook, loadCustomConfig } from "./846~0.mjs";
19
+ import { ensureSessionStateInProjectGitignore, browserDistDir, readyContractPath, buildSummaryPath, ensureSessionArtifactsIgnoreFile } from "./771~0.mjs";
18
20
  import { isResourceUnderDirs, canonicalizeDir } from "./712~0.mjs";
19
- import { buildSummaryPath, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore } from "./771~0.mjs";
20
21
  import { getCanonicalContentScriptEntryName, parseCanonicalContentScriptAsset } from "./640~0.mjs";
21
22
  import { publicRootsFor } from "./105~0.mjs";
22
23
  import { rememberSpecialFoldersConfig } from "./471~0.mjs";
@@ -574,29 +575,17 @@ function findDevelopRootFrom(startDir) {
574
575
  currentDir = parent;
575
576
  }
576
577
  }
577
- function findExtensionDevelopRoot() {
578
- const libDir = __rspack_import_meta_dirname__;
579
- const buildDir = __rspack_external_node_path_806ed179.resolve(libDir, '..');
580
- const packageRoot = __rspack_external_node_path_806ed179.resolve(buildDir, '..');
581
- const packageJsonPath = __rspack_external_node_path_806ed179.join(packageRoot, 'package.json');
582
- if (__rspack_external_node_fs_1b05aee1.existsSync(packageJsonPath)) try {
583
- const pkg = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(packageJsonPath, 'utf-8'));
584
- if ('extension-develop' === pkg.name) return packageRoot;
585
- } catch {}
586
- return null;
587
- }
588
- function resolveDevelopInstallRoot() {
578
+ function findExtensionDevelopRoot(startDir = __rspack_import_meta_dirname__) {
589
579
  const envRoot = process.env.EXTENSION_DEVELOP_ROOT;
590
580
  if (envRoot) {
591
581
  const resolvedEnvRoot = resolveDevelopRootFromDir(__rspack_external_node_path_806ed179.resolve(envRoot));
592
582
  if (resolvedEnvRoot) return resolvedEnvRoot;
593
583
  }
584
+ return findDevelopRootFrom(startDir) || null;
585
+ }
586
+ function resolveDevelopInstallRoot() {
594
587
  const directRoot = findExtensionDevelopRoot();
595
588
  if (directRoot) return directRoot;
596
- try {
597
- const candidateRoot = findDevelopRootFrom(__rspack_import_meta_dirname__);
598
- if (candidateRoot) return candidateRoot;
599
- } catch {}
600
589
  try {
601
590
  const pkgPath = cjsRequire.resolve('extension-develop/package.json', {
602
591
  paths: [
@@ -1171,14 +1160,79 @@ function findPnpmWorkspaceMember(projectDir) {
1171
1160
  relativeDir
1172
1161
  };
1173
1162
  }
1163
+ function readPackageJsonWorkspaces(dir) {
1164
+ try {
1165
+ const pkg = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(dir, 'package.json'), 'utf8'));
1166
+ const field = pkg?.workspaces;
1167
+ const list = Array.isArray(field) ? field : field?.packages;
1168
+ if (!Array.isArray(list)) return;
1169
+ return list.filter((item)=>'string' == typeof item);
1170
+ } catch {
1171
+ return;
1172
+ }
1173
+ }
1174
+ function findPackageJsonWorkspaceRoot(startDir) {
1175
+ let current = __rspack_external_node_path_806ed179.resolve(startDir);
1176
+ while(true){
1177
+ if (readPackageJsonWorkspaces(current)) return current;
1178
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(current, '.git'))) return;
1179
+ const parent = __rspack_external_node_path_806ed179.dirname(current);
1180
+ if (parent === current) return;
1181
+ current = parent;
1182
+ }
1183
+ }
1184
+ function packageJsonWorkspaceManager(root) {
1185
+ const lockPm = detectPackageManagerFromLockfile(root);
1186
+ if ('pnpm' === lockPm) return;
1187
+ if (lockPm) return lockPm;
1188
+ try {
1189
+ const pkg = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(root, 'package.json'), 'utf8'));
1190
+ const pinned = /^(npm|yarn|bun)@/.exec(String(pkg?.packageManager || ''));
1191
+ if (pinned) return pinned[1];
1192
+ } catch {}
1193
+ return 'npm';
1194
+ }
1195
+ function findWorkspaceMember(projectDir) {
1196
+ const pnpmMember = findPnpmWorkspaceMember(projectDir);
1197
+ if (pnpmMember) return {
1198
+ ...pnpmMember,
1199
+ manager: 'pnpm'
1200
+ };
1201
+ const root = findPackageJsonWorkspaceRoot(projectDir);
1202
+ if (!root) return;
1203
+ const resolvedProject = __rspack_external_node_path_806ed179.resolve(projectDir);
1204
+ if (root === resolvedProject) return;
1205
+ const relativeDir = __rspack_external_node_path_806ed179.relative(root, resolvedProject).split(__rspack_external_node_path_806ed179.sep).join('/');
1206
+ const patterns = readPackageJsonWorkspaces(root) || [];
1207
+ if (!isPnpmWorkspaceMemberDir(patterns, relativeDir)) return;
1208
+ const manager = packageJsonWorkspaceManager(root);
1209
+ if (!manager) return;
1210
+ return {
1211
+ root,
1212
+ relativeDir,
1213
+ manager
1214
+ };
1215
+ }
1216
+ function workspaceManagerOverride(member) {
1217
+ if ('pnpm' === member.manager) return;
1218
+ if (detectPackageManagerFromLockfile(member.root)) return;
1219
+ return hydrateResolvedPackageManager(member.manager) || {
1220
+ name: member.manager
1221
+ };
1222
+ }
1174
1223
  function projectInstallTarget(pm, projectDir, member) {
1175
- if ('pnpm' === pm.name && member) return {
1224
+ const memberManager = member ? 'manager' in member ? member.manager : 'pnpm' : void 0;
1225
+ if (member && 'pnpm' === pm.name && 'pnpm' === memberManager) return {
1176
1226
  cwd: member.root,
1177
1227
  args: [
1178
1228
  '--filter',
1179
1229
  `{${member.relativeDir}}...`
1180
1230
  ]
1181
1231
  };
1232
+ if (member && memberManager && 'pnpm' !== memberManager) return {
1233
+ cwd: member.root,
1234
+ args: []
1235
+ };
1182
1236
  return {
1183
1237
  cwd: projectDir,
1184
1238
  args: projectInstallArgs(pm, projectDir)
@@ -1910,14 +1964,14 @@ function promoteStagingDist(stagingPath, distPath) {
1910
1964
  const retiredPath = `${stagingPath}-retired`;
1911
1965
  let retired = false;
1912
1966
  if (__rspack_external_node_fs_1b05aee1.existsSync(distPath)) {
1913
- __rspack_external_node_fs_1b05aee1.renameSync(distPath, retiredPath);
1967
+ renameSyncWithRetry(distPath, retiredPath);
1914
1968
  retired = true;
1915
1969
  }
1916
1970
  try {
1917
- __rspack_external_node_fs_1b05aee1.renameSync(stagingPath, distPath);
1971
+ renameSyncWithRetry(stagingPath, distPath);
1918
1972
  } catch (error) {
1919
1973
  if (retired) try {
1920
- __rspack_external_node_fs_1b05aee1.renameSync(retiredPath, distPath);
1974
+ renameSyncWithRetry(retiredPath, distPath);
1921
1975
  } catch {}
1922
1976
  throw error;
1923
1977
  }
@@ -2188,9 +2242,9 @@ function projectInstallStdio() {
2188
2242
  ] : 'inherit';
2189
2243
  }
2190
2244
  async function ensureUserProjectDependencies(packageJsonDir) {
2191
- const member = findPnpmWorkspaceMember(packageJsonDir);
2245
+ const member = findWorkspaceMember(packageJsonDir);
2192
2246
  if (!needsInstall(packageJsonDir, member?.root)) return;
2193
- const pm = resolvePackageManager({
2247
+ const pm = member && workspaceManagerOverride(member) || resolvePackageManager({
2194
2248
  cwd: member?.root ?? packageJsonDir
2195
2249
  });
2196
2250
  const suppression = installScriptSuppression(pm);
@@ -2201,7 +2255,7 @@ async function ensureUserProjectDependencies(packageJsonDir) {
2201
2255
  ...target.args
2202
2256
  ]);
2203
2257
  if (suppression.args.length || Object.keys(suppression.env).length) console.warn(projectInstallScriptsDisabled(pm.name));
2204
- if (target.cwd !== packageJsonDir) console.warn(projectInstallInWorkspaceRoot(target.cwd));
2258
+ if (target.cwd !== packageJsonDir) console.warn(projectInstallInWorkspaceRoot(target.cwd, pm.name));
2205
2259
  try {
2206
2260
  await execInstallCommand(cmd.command, cmd.args, {
2207
2261
  cwd: target.cwd,
@@ -2386,6 +2440,33 @@ async function generateExtensionTypes(manifestDir, packageJsonDir) {
2386
2440
  }
2387
2441
  }
2388
2442
  }
2443
+ function live_dev_session_isProcessAlive(pid) {
2444
+ try {
2445
+ process.kill(pid, 0);
2446
+ return true;
2447
+ } catch (error) {
2448
+ return error?.code === 'EPERM';
2449
+ }
2450
+ }
2451
+ function findLiveDevSession(projectPath, browser) {
2452
+ let contract;
2453
+ try {
2454
+ contract = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(readyContractPath(projectPath, browser), 'utf-8'));
2455
+ } catch {
2456
+ return null;
2457
+ }
2458
+ if (!contract || 'object' != typeof contract) return null;
2459
+ if ('dev' !== contract.command) return null;
2460
+ if ('starting' !== contract.status && 'ready' !== contract.status) return null;
2461
+ const pid = Number(contract.pid);
2462
+ if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return null;
2463
+ if (!live_dev_session_isProcessAlive(pid)) return null;
2464
+ const distPath = 'string' == typeof contract.distPath && contract.distPath ? __rspack_external_node_path_806ed179.resolve(contract.distPath) : '';
2465
+ return {
2466
+ distPath,
2467
+ pid
2468
+ };
2469
+ }
2389
2470
  const BACKGROUND_PAGE_ENTRY = 'background/index';
2390
2471
  function classifyEntrySurface(entryName) {
2391
2472
  if (entryName === BACKGROUND_PAGE_ENTRY) return 'page';
@@ -3232,6 +3313,7 @@ function hasTypeScriptSourceFiles(projectPath, depth = 0) {
3232
3313
  if (entry.isDirectory()) {
3233
3314
  if (entry.name.startsWith('.') || NON_SOURCE_DIRS.has(entry.name)) return false;
3234
3315
  const sub = __rspack_external_node_path_806ed179.join(projectPath, entry.name);
3316
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(sub, 'package.json'))) return false;
3235
3317
  return hasTypeScriptSourceFiles(sub, depth + 1);
3236
3318
  }
3237
3319
  return false;
@@ -3307,6 +3389,17 @@ function getUserTypeScriptConfigFile(projectPath) {
3307
3389
  if (__rspack_external_node_fs_1b05aee1.existsSync(tsconfigPath)) return tsconfigPath;
3308
3390
  }
3309
3391
  }
3392
+ function getUserJsConfigFile(projectPath) {
3393
+ const searchDirs = [
3394
+ findNearestPackageJsonDirectory(projectPath),
3395
+ projectPath
3396
+ ];
3397
+ for (const dir of searchDirs){
3398
+ if (!dir) continue;
3399
+ const jsconfigPath = __rspack_external_node_path_806ed179.join(dir, 'jsconfig.json');
3400
+ if (__rspack_external_node_fs_1b05aee1.existsSync(jsconfigPath)) return jsconfigPath;
3401
+ }
3402
+ }
3310
3403
  function writeTsConfig(projectPath) {
3311
3404
  const targetDir = findNearestPackageJsonDirectory(projectPath) || projectPath;
3312
3405
  __rspack_external_node_fs_1b05aee1.writeFileSync(__rspack_external_node_path_806ed179.join(targetDir, 'tsconfig.json'), JSON.stringify(defaultTypeScriptConfig(projectPath, {
@@ -3348,6 +3441,13 @@ function printBuildCard(manifestPath, browser, distPath) {
3348
3441
  humanLine(' ');
3349
3442
  process.env.EXTENSION_CLI_BANNER_PRINTED = 'true';
3350
3443
  }
3444
+ function resolveOutDir(raw, packageJsonDir) {
3445
+ if (null == raw) return;
3446
+ if ('string' != typeof raw || !raw.trim()) throw new Error(buildOutDirInvalid(String(raw)));
3447
+ const resolved = __rspack_external_node_path_806ed179.resolve(packageJsonDir, raw.trim());
3448
+ if (resolved === __rspack_external_node_path_806ed179.resolve(packageJsonDir)) throw new Error(buildOutDirInvalid(raw));
3449
+ return raw.trim();
3450
+ }
3351
3451
  async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3352
3452
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
3353
3453
  const isVitest = 'true' === process.env.VITEST;
@@ -3356,8 +3456,8 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3356
3456
  const commandKey = buildOptions?.metadataCommand === 'start' ? 'start' : 'build';
3357
3457
  const configBrowser = buildOptions?.browser ? void 0 : configBrowserOrThrow((await loadCommandConfig(packageJsonDir, commandKey)).browser, commandKey);
3358
3458
  const browser = normalizeBrowser(buildOptions?.browser || configBrowser || 'chrome', buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary, buildOptions?.safariBinary);
3359
- const distPath = getDistPath(packageJsonDir, browser);
3360
- const stagingDistPath = stagingDistPathFor(distPath);
3459
+ let distPath = '';
3460
+ let stagingDistPath = '';
3361
3461
  const isAuthor = isDebug();
3362
3462
  try {
3363
3463
  takeCodedWarnings();
@@ -3376,6 +3476,15 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3376
3476
  if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, packageJsonDir);
3377
3477
  const projectConfig = await loadProjectConfigDefaults(packageJsonDir);
3378
3478
  const commandConfig = await loadCommandConfig(packageJsonDir, commandKey);
3479
+ const outDir = resolveOutDir(buildOptions?.outDir ?? commandConfig.outDir, packageJsonDir);
3480
+ distPath = getBuildDistPath(packageJsonDir, browser, outDir);
3481
+ stagingDistPath = stagingDistPathFor(distPath);
3482
+ const liveDevSession = findLiveDevSession(packageJsonDir, browser);
3483
+ if (liveDevSession && __rspack_external_node_path_806ed179.resolve(liveDevSession.distPath || browserDistDir(packageJsonDir, browser)) === __rspack_external_node_path_806ed179.resolve(distPath)) {
3484
+ const distDisplay = displayPath(distPath);
3485
+ recordCodedWarning(CODES.E_DEV_SESSION_DIST_SHARED, buildSharesDevDistText(distDisplay, liveDevSession.pid));
3486
+ console.warn(buildSharesDevDist(browser, distDisplay, liveDevSession.pid));
3487
+ }
3379
3488
  const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
3380
3489
  const foldersConfig = commandConfig.folders ?? browserConfig.folders ?? projectConfig.folders;
3381
3490
  rememberSpecialFoldersConfig(packageJsonDir, foldersConfig);
@@ -3411,7 +3520,11 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3411
3520
  finalPath: distPath
3412
3521
  }
3413
3522
  });
3414
- const allPluginsButBrowserRunners = baseConfig.plugins?.filter((plugin)=>plugin?.constructor.name !== 'plugin-browsers');
3523
+ const allPluginsButBrowserRunners = baseConfig.plugins?.filter((plugin)=>{
3524
+ const name = plugin?.constructor.name;
3525
+ if ('plugin-browsers' === name) return false;
3526
+ return !(liveDevSession && 'plugin-playwright' === name);
3527
+ });
3415
3528
  const hookContext = {
3416
3529
  browser,
3417
3530
  mode: resolvedMode,
@@ -3499,7 +3612,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3499
3612
  removeStagingDir(stagingDistPath);
3500
3613
  return reject(promoteError);
3501
3614
  }
3502
- stampReadyDistExtensionId(packageJsonDir, browser, distPath);
3615
+ if (!liveDevSession) stampReadyDistExtensionId(packageJsonDir, browser, distPath);
3503
3616
  }
3504
3617
  const info = stats?.toJson({
3505
3618
  all: false,
@@ -3613,12 +3726,12 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
3613
3726
  try {
3614
3727
  __rspack_external_node_fs_1b05aee1.writeFileSync(buildSummaryPath(packageJsonDir, browser), JSON.stringify(summary));
3615
3728
  } catch {}
3616
- if (safari.bundleId) stampReadyKnownExtensionId(packageJsonDir, browser, `${safari.bundleId}.Extension`);
3729
+ if (safari.bundleId && !liveDevSession) stampReadyKnownExtensionId(packageJsonDir, browser, `${safari.bundleId}.Extension`);
3617
3730
  }
3618
3731
  }
3619
3732
  return summary;
3620
3733
  } catch (error) {
3621
- removeStagingDir(stagingDistPath);
3734
+ if (stagingDistPath) removeStagingDir(stagingDistPath);
3622
3735
  const alreadyReported = error instanceof Error && reportedBuildFailures.has(error);
3623
3736
  if (!alreadyReported) {
3624
3737
  if (isDebug()) console.error(error);
@@ -4072,16 +4185,51 @@ const DEV_CONTENT_SCRIPTS_RUNTIME_SOURCE = `;(function () {
4072
4185
  } catch (x) { collect({}); }
4073
4186
  }
4074
4187
 
4188
+ // The boot read can fail or land on a registry mid-write, and the file on
4189
+ // disk can name an entry the loaded one does not. One re-read per need,
4190
+ // shared by the callers waiting on it, and no re-sync of an unchanged file.
4191
+ var refreshing = [];
4192
+ function refresh(cb) {
4193
+ refreshing.push(cb);
4194
+ if (refreshing.length > 1) return;
4195
+ var finish = function () {
4196
+ var fns = refreshing;
4197
+ refreshing = [];
4198
+ for (var i = 0; i < fns.length; i++) call(fns[i]);
4199
+ };
4200
+ load(function (reg) {
4201
+ if (!reg) return finish();
4202
+ var same = false;
4203
+ try { same = !!registry && JSON.stringify(reg) === JSON.stringify(registry); } catch (e) {
4204
+ // Ignore
4205
+ }
4206
+ registry = reg;
4207
+ if (same) return finish();
4208
+ sync(reg, finish);
4209
+ });
4210
+ }
4211
+
4212
+ function entriesFor(name) {
4213
+ var out = [];
4214
+ if (!registry) return out;
4215
+ for (var i = 0; i < registry.entries.length; i++) {
4216
+ var e = registry.entries[i];
4217
+ if (e && !e.static && e.entry === name) out.push(e);
4218
+ }
4219
+ return out;
4220
+ }
4221
+
4075
4222
  function onStub(msg, sender) {
4076
4223
  if (!msg || !isString(msg.entry) || !sender || !sender.tab || sender.tab.id == null) return;
4077
4224
  var tabId = sender.tab.id;
4078
4225
  var frameId = typeof sender.frameId === "number" ? sender.frameId : 0;
4079
4226
  onReady(function () {
4080
- if (!registry) return;
4081
- for (var i = 0; i < registry.entries.length; i++) {
4082
- var e = registry.entries[i];
4083
- if (e && !e.static && e.entry === msg.entry) inject(e, {tabId: tabId, frameIds: [frameId]}, false);
4084
- }
4227
+ var serve = function () {
4228
+ var entries = entriesFor(msg.entry);
4229
+ for (var i = 0; i < entries.length; i++) inject(entries[i], {tabId: tabId, frameIds: [frameId]}, false);
4230
+ };
4231
+ if (entriesFor(msg.entry).length) return serve();
4232
+ refresh(serve);
4085
4233
  });
4086
4234
  }
4087
4235
 
@@ -4089,26 +4237,31 @@ const DEV_CONTENT_SCRIPTS_RUNTIME_SOURCE = `;(function () {
4089
4237
  // and Chromium never injects into a tab that finished loading before it.
4090
4238
  function heal(done) {
4091
4239
  onReady(function () {
4092
- if (!registry) return call(done);
4093
- var pending = 1;
4094
- var step = function () { pending--; if (pending <= 0) call(done); };
4095
- for (var i = 0; i < registry.entries.length; i++) {
4096
- (function (e) {
4097
- if (!e || e.stubOnly || e.static) return;
4098
- pending++;
4099
- tabsFor(e, true, function (tabs) {
4100
- var left = tabs.length;
4101
- if (!left) return step();
4102
- for (var t = 0; t < tabs.length; t++) {
4103
- inject(e, {tabId: tabs[t].id, allFrames: !!e.allFrames}, true, function () { if (--left === 0) step(); });
4104
- }
4105
- });
4106
- })(registry.entries[i]);
4107
- }
4108
- step();
4240
+ if (registry) return healEntries(done);
4241
+ refresh(function () { healEntries(done); });
4109
4242
  });
4110
4243
  }
4111
4244
 
4245
+ function healEntries(done) {
4246
+ if (!registry) return call(done);
4247
+ var pending = 1;
4248
+ var step = function () { pending--; if (pending <= 0) call(done); };
4249
+ for (var i = 0; i < registry.entries.length; i++) {
4250
+ (function (e) {
4251
+ if (!e || e.stubOnly || e.static) return;
4252
+ pending++;
4253
+ tabsFor(e, true, function (tabs) {
4254
+ var left = tabs.length;
4255
+ if (!left) return step();
4256
+ for (var t = 0; t < tabs.length; t++) {
4257
+ inject(e, {tabId: tabs[t].id, allFrames: !!e.allFrames}, true, function () { if (--left === 0) step(); });
4258
+ }
4259
+ });
4260
+ })(registry.entries[i]);
4261
+ }
4262
+ step();
4263
+ }
4264
+
4112
4265
  // Reload every tab the given entries match, each once.
4113
4266
  function reloadTabs(entries, done) {
4114
4267
  var seen = {};
@@ -4585,6 +4738,7 @@ class BrowsersPlugin {
4585
4738
  reloadBroker;
4586
4739
  logSink;
4587
4740
  emulatorViewerUrl;
4741
+ instanceId;
4588
4742
  lastReportedRefusal;
4589
4743
  loadedContentScriptFiles = [];
4590
4744
  constructor(options){
@@ -4599,6 +4753,9 @@ class BrowsersPlugin {
4599
4753
  setEmulatorViewerUrl(url) {
4600
4754
  this.emulatorViewerUrl = url;
4601
4755
  }
4756
+ setInstanceId(instanceId) {
4757
+ this.instanceId = instanceId;
4758
+ }
4602
4759
  async wakeBackground() {
4603
4760
  try {
4604
4761
  return await this.controller?.wakeBackground?.() === true;
@@ -4659,6 +4816,9 @@ class BrowsersPlugin {
4659
4816
  contextDir,
4660
4817
  extensionsToLoad: this.extensionsToLoad,
4661
4818
  logSink: this.logSink,
4819
+ ...this.options.browserOptions.instanceId || !this.instanceId ? {} : {
4820
+ instanceId: this.instanceId
4821
+ },
4662
4822
  ...this.emulatorViewerUrl ? {
4663
4823
  emulatorViewerUrl: this.emulatorViewerUrl
4664
4824
  } : {}
@@ -4674,6 +4834,7 @@ class BrowsersPlugin {
4674
4834
  tabFilter: this.options.browserOptions.logTab
4675
4835
  });
4676
4836
  } catch (error) {
4837
+ if (!this.controller) this.isFirstCompile = true;
4677
4838
  const reason = error instanceof Error ? error.message : String(error);
4678
4839
  console.error(browserLaunchFailed(this.options.browserOptions.browser, reason));
4679
4840
  this.emitter.emit('error', {
@@ -4921,4 +5082,4 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
4921
5082
  process.exit(1);
4922
5083
  }
4923
5084
  }
4924
- export { BuildEmitter, ConfigResolvedPlugin, DEV_CONTENT_SCRIPTS_RUNTIME_SOURCE, DEV_CONTENT_SCRIPT_REGISTRY_ASSET, NOT_RAW_RESOURCE_QUERY, RAW_RESOURCE_QUERY, applySplitChunksGuard, attachLifecycleStream, backgroundIsRequiredMessageOnly, buildDevContentScriptMarkerPrelude, buildSourceFeatureIndex, classifyEntrySurface, classifyReloadFromSources, contentScriptEntryForAsset, createChangedSourcesTracker, createLifecycleStream, createNodeModulesExclude, defaultSplitChunks, dispatchReload, ensureOptionalContractPackageResolved, ensureTypeScriptConfig, extensionBuild, extensionDev, getJsxImportSource, getUserTypeScriptConfigFile, hasDependency, isDevContentScriptStandInAsset, isUsingIntegration, isUsingJsxFramework, isUsingReact, isUsingTypeScript, isUsingVue, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadLoaderOptions, maybeUsePreact, maybeUseReact, maybeUseSolid, maybeUseVue, mergeLoaderOptions, planDevContentScripts, readContentScriptCount, recordZipArtifact, recordZipFailure, resolveDevelopDistFile, resolveDevelopInstallRoot, resolveReactRefreshEntry, resolveTranspilePackageDirs, svelteCompilerRuntimeMismatch, swcParserForFile };
5085
+ export { BuildEmitter, ConfigResolvedPlugin, DEV_CONTENT_SCRIPTS_RUNTIME_SOURCE, DEV_CONTENT_SCRIPT_REGISTRY_ASSET, NOT_RAW_RESOURCE_QUERY, RAW_RESOURCE_QUERY, applySplitChunksGuard, attachLifecycleStream, backgroundIsRequiredMessageOnly, buildDevContentScriptMarkerPrelude, buildSourceFeatureIndex, classifyEntrySurface, classifyReloadFromSources, contentScriptEntryForAsset, createChangedSourcesTracker, createLifecycleStream, createNodeModulesExclude, defaultSplitChunks, dispatchReload, ensureOptionalContractPackageResolved, ensureTypeScriptConfig, extensionBuild, extensionDev, getJsxImportSource, getUserJsConfigFile, getUserTypeScriptConfigFile, hasDependency, isDevContentScriptStandInAsset, isUsingIntegration, isUsingJsxFramework, isUsingReact, isUsingTypeScript, isUsingVue, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadLoaderOptions, maybeUsePreact, maybeUseReact, maybeUseSolid, maybeUseVue, mergeLoaderOptions, planDevContentScripts, readContentScriptCount, recordZipArtifact, recordZipFailure, resolveDevelopDistFile, resolveDevelopInstallRoot, resolveReactRefreshEntry, resolveTranspilePackageDirs, svelteCompilerRuntimeMismatch, swcParserForFile };
package/dist/846~0.mjs CHANGED
@@ -6,7 +6,6 @@ import { isUsingExperimentalConfig as messages_isUsingExperimentalConfig, config
6
6
  import { debugLine, isDebug, CODES } from "./852~0.mjs";
7
7
  import { isWebkitBasedBrowser } from "./937~0.mjs";
8
8
  import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
9
- import * as __rspack_external_node_os_4f3c9d58 from "node:os";
10
9
  import * as __rspack_external_node_path_806ed179 from "node:path";
11
10
  import * as __rspack_external_node_vm_ef240610 from "node:vm";
12
11
  const preloadedEnvKeys = new Set();
@@ -45,6 +44,21 @@ function loadCommonJsConfigWithStableDirname(absolutePath) {
45
44
  fn(exports, requireFn, module, absolutePath, dirname);
46
45
  return unwrapDefaultExport(module.exports);
47
46
  }
47
+ function requireCommonJsCopyBesideSource(absolutePath) {
48
+ const requireFn = createRequire(absolutePath);
49
+ const siblingCjsPath = __rspack_external_node_path_806ed179.join(__rspack_external_node_path_806ed179.dirname(absolutePath), `.${__rspack_external_node_path_806ed179.basename(absolutePath, __rspack_external_node_path_806ed179.extname(absolutePath))}.${process.pid}-${Date.now()}.cjs`);
50
+ try {
51
+ __rspack_external_node_fs_1b05aee1.copyFileSync(absolutePath, siblingCjsPath);
52
+ return requireFn(siblingCjsPath);
53
+ } finally{
54
+ delete requireFn.cache[siblingCjsPath];
55
+ try {
56
+ __rspack_external_node_fs_1b05aee1.rmSync(siblingCjsPath, {
57
+ force: true
58
+ });
59
+ } catch {}
60
+ }
61
+ }
48
62
  function findNearestWorkspaceRoot(startDir) {
49
63
  let current = __rspack_external_node_path_806ed179.resolve(startDir);
50
64
  while(true){
@@ -253,19 +267,7 @@ async function loadConfigFileUncached(absolutePath) {
253
267
  if (looksLikeCommonJsInEsm) try {
254
268
  required = loadCommonJsConfigWithStableDirname(absolutePath);
255
269
  } catch {
256
- const tmpDir = __rspack_external_node_fs_1b05aee1.mkdtempSync(__rspack_external_node_path_806ed179.join(__rspack_external_node_os_4f3c9d58.tmpdir(), 'extension-config-'));
257
- try {
258
- const tmpCjsPath = __rspack_external_node_path_806ed179.join(tmpDir, __rspack_external_node_path_806ed179.basename(absolutePath, __rspack_external_node_path_806ed179.extname(absolutePath)) + '.cjs');
259
- __rspack_external_node_fs_1b05aee1.copyFileSync(absolutePath, tmpCjsPath);
260
- required = requireFn(tmpCjsPath);
261
- } finally{
262
- try {
263
- __rspack_external_node_fs_1b05aee1.rmSync(tmpDir, {
264
- recursive: true,
265
- force: true
266
- });
267
- } catch {}
268
- }
270
+ required = requireCommonJsCopyBesideSource(absolutePath);
269
271
  }
270
272
  else throw requireErr;
271
273
  }
package/dist/852~0.mjs CHANGED
@@ -213,6 +213,7 @@ const CODES = {
213
213
  E_POLYFILL_NOT_FOUND: 'E_POLYFILL_NOT_FOUND',
214
214
  E_LOCALES_LAYOUT: 'E_LOCALES_LAYOUT',
215
215
  E_WAR_INVALID: 'E_WAR_INVALID',
216
+ E_DEV_SESSION_DIST_SHARED: 'E_DEV_SESSION_DIST_SHARED',
216
217
  E_BACKGROUND_REQUIRED: 'E_BACKGROUND_REQUIRED',
217
218
  E_CONTENT_SCRIPT_SYNTAX: 'E_CONTENT_SCRIPT_SYNTAX',
218
219
  E_NO_ENTRYPOINTS: 'E_NO_ENTRYPOINTS',
@@ -222,6 +223,7 @@ const CODES = {
222
223
  E_ENV_NO_MATCH: 'E_ENV_NO_MATCH',
223
224
  E_REMOTE_FETCH_TIMEOUT: 'E_REMOTE_FETCH_TIMEOUT',
224
225
  E_REMOTE_DOWNLOAD: 'E_REMOTE_DOWNLOAD',
226
+ E_REMOTE_ACCESS_DENIED: 'E_REMOTE_ACCESS_DENIED',
225
227
  E_REMOTE_ZIP_INVALID: 'E_REMOTE_ZIP_INVALID',
226
228
  E_LOCAL_ZIP_NOT_FOUND: 'E_LOCAL_ZIP_NOT_FOUND',
227
229
  E_PROJECT_DOWNLOAD_EMPTY: 'E_PROJECT_DOWNLOAD_EMPTY',
package/dist/88~0.mjs CHANGED
@@ -20,6 +20,15 @@ function registerVerbatimCss(raw, resourcePath) {
20
20
  function verbatimCssPlaceholder(id) {
21
21
  return `.__extjs_verbatim_${id}__{--extjs-verbatim:1}\n`;
22
22
  }
23
+ function verbatimCssModulePlaceholder(id, raw) {
24
+ const scrubbed = raw.replace(/\/\*[\s\S]*?\*\//g, ' ');
25
+ const names = new Set();
26
+ for (const match of scrubbed.matchAll(/\.(-?[_a-zA-Z][\w-]*)/g))names.add(match[1]);
27
+ const exported = [
28
+ ...names
29
+ ].map((name)=>`${name}:${name}`).join(';');
30
+ return `:global(.__extjs_verbatim_${id}__){--extjs-verbatim:1}\n` + (exported ? `:export{${exported}}\n` : '');
31
+ }
23
32
  function cssRelativeRefs(text) {
24
33
  const scrubbed = text.replace(/\/\*[\s\S]*?\*\//g, ' ');
25
34
  const refs = new Set();
@@ -86,4 +95,4 @@ function minifierDroppedTokens(before, after) {
86
95
  ...cssSelectorTokens(before)
87
96
  ].filter((token)=>!kept.has(token));
88
97
  }
89
- export { minifierDroppedTokens, registerVerbatimCss, restoreVerbatimCssAssets, verbatimCssPlaceholder };
98
+ export { minifierDroppedTokens, registerVerbatimCss, restoreVerbatimCssAssets, verbatimCssModulePlaceholder, verbatimCssPlaceholder };
@@ -1,3 +1,4 @@
1
+ import { type RemoteArchiveTarget } from './lib/project.js';
1
2
  import type { PreviewOptions } from './types.js';
2
3
  /**
3
4
  * Resolved browser launch options returned by extensionPreview.
@@ -43,6 +44,7 @@ export interface PreviewBrowserSession {
43
44
  }
44
45
  export type PreviewLauncherFn = (opts: ResolvedPreviewOptions) => Promise<PreviewBrowserSession> | Promise<void>;
45
46
  export declare function explicitUnpackedDir(pathOrRemoteUrl: string | undefined, packageJsonDir: string, manifestDir?: string): string | undefined;
47
+ export declare function previewArchiveTarget(metadataCommand: 'start' | 'preview', outputPath?: string): RemoteArchiveTarget | undefined;
46
48
  export declare function extensionPreview(pathOrRemoteUrl: string | undefined, previewOptions: PreviewOptions, browserLauncher?: PreviewLauncherFn): Promise<{
47
49
  warnings: string[];
48
50
  }>;
@@ -168,6 +168,11 @@
168
168
  "area": "compile",
169
169
  "summary": "web_accessible_resources shape or match pattern rejected."
170
170
  },
171
+ "E_DEV_SESSION_DIST_SHARED": {
172
+ "area": "compile",
173
+ "summary": "A build writes the dist folder a running dev session serves.",
174
+ "warn": true
175
+ },
171
176
  "E_BACKGROUND_REQUIRED": {
172
177
  "area": "compile",
173
178
  "summary": "The reload runtime needs a background chunk that is absent."
@@ -209,6 +214,10 @@
209
214
  "area": "remote",
210
215
  "summary": "A remote extension could not be downloaded or written to disk."
211
216
  },
217
+ "E_REMOTE_ACCESS_DENIED": {
218
+ "area": "remote",
219
+ "summary": "The server refused access to the remote URL with a 401 or 403, so its access token has expired, was revoked, or was changed while copying."
220
+ },
212
221
  "E_REMOTE_ZIP_INVALID": {
213
222
  "area": "remote",
214
223
  "summary": "The remote URL did not return a ZIP, returned a damaged one that will not unpack, or one with an entry outside its folder."
@@ -1,2 +1,2 @@
1
1
  export * from './dev-server/control-bridge/contracts.js';
2
- export type { LogLevelFilter, LogQuery } from './dev-server/control-bridge/logs-query.js';
2
+ export * from './dev-server/control-bridge/log-rule.js';