extension 4.2.0 → 4.2.1-canary.472.df3e2e9

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 (44) hide show
  1. package/dist/browsers.cjs +505 -543
  2. package/dist/cli.cjs +3194 -993
  3. package/dist/extension/browsers/browsers-lib/first-run-install.d.ts +1 -1
  4. package/dist/extension/browsers/browsers-lib/output-binaries-resolver.d.ts +1 -1
  5. package/dist/extension/browsers/browsers-lib/process-teardown.d.ts +12 -2
  6. package/dist/extension/browsers/browsers-lib/ready-stamp.d.ts +3 -1
  7. package/dist/extension/browsers/browsers-lib/resolve-live-pid.d.ts +14 -2
  8. package/dist/extension/browsers/browsers-types.d.ts +4 -0
  9. package/dist/extension/browsers/run-chromium/chromium-launch/index.d.ts +9 -0
  10. package/dist/extension/browsers/run-chromium/chromium-launch/launch-dependencies.d.ts +0 -1
  11. package/dist/extension/browsers/run-firefox/firefox-launch/browser-config.d.ts +2 -2
  12. package/dist/extension/browsers/run-firefox/firefox-launch/index.d.ts +5 -2
  13. package/dist/extension/browsers/run-firefox/firefox-launch/launch-dependencies.d.ts +1 -0
  14. package/dist/extension/browsers/run-firefox/firefox-launch/managed-update-policy.d.ts +1 -1
  15. package/dist/extension/browsers/run-firefox/firefox-launch/process-handlers.d.ts +1 -0
  16. package/dist/extension/browsers/run-only.d.ts +3 -0
  17. package/dist/extension/browsers/run-safari/safari-launch/container-app.d.ts +1 -1
  18. package/dist/extension/browsers/run-safari/safari-types.d.ts +1 -0
  19. package/dist/extension/commands/create.d.ts +4 -9
  20. package/dist/extension/commands/dev-wait.d.ts +9 -1
  21. package/dist/extension/commands/doctor.d.ts +2 -1
  22. package/dist/extension/commands/preview.d.ts +1 -0
  23. package/dist/extension/config-types.d.ts +3 -3
  24. package/dist/extension/helpers/check-updates.d.ts +11 -1
  25. package/dist/extension/helpers/choice-flags.d.ts +6 -0
  26. package/dist/extension/helpers/cli-argv.d.ts +4 -1
  27. package/dist/extension/helpers/config-browser.d.ts +1 -1
  28. package/dist/extension/helpers/early-interrupt-arm.d.ts +1 -0
  29. package/dist/extension/helpers/early-interrupt.d.ts +35 -0
  30. package/dist/extension/helpers/extension-develop-runtime.d.ts +2 -1
  31. package/dist/extension/helpers/messages.d.ts +5 -0
  32. package/dist/extension/helpers/messaging.d.ts +12 -0
  33. package/dist/extension/helpers/no-browser.d.ts +1 -1
  34. package/dist/extension/helpers/project-name-prompt.d.ts +2 -3
  35. package/dist/extension/helpers/ready-contract-codes.d.ts +1 -0
  36. package/dist/extension/helpers/session-interrupt-frame.d.ts +8 -0
  37. package/dist/extension/helpers/session-liveness.d.ts +3 -2
  38. package/dist/extension/helpers/vendors.d.ts +0 -1
  39. package/dist/extension/index.d.ts +1 -0
  40. package/dist/extension/run.d.ts +1 -0
  41. package/dist/{6.cjs → n.cjs} +80 -5
  42. package/package.json +6 -7
  43. package/dist/extension/browsers/browsers-lib/rename-with-retry.d.ts +0 -6
  44. package/dist/extension/browsers/browsers-lib/write-json-atomic.d.ts +0 -2
package/dist/browsers.cjs CHANGED
@@ -3,6 +3,121 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
3
  return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
4
  }();
5
5
  var __webpack_modules__ = {
6
+ "../develop/lib/ready-contract-writer.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
+ var node_fs__rspack_import_0 = __webpack_require__("node:fs");
8
+ var _rename_with_retry__rspack_import_1 = __webpack_require__("../develop/lib/rename-with-retry.ts");
9
+ function tryReadReadyRecord(readyPath) {
10
+ try {
11
+ if (!node_fs__rspack_import_0.existsSync(readyPath)) return {};
12
+ const value = JSON.parse(node_fs__rspack_import_0.readFileSync(readyPath, 'utf-8'));
13
+ return value && 'object' == typeof value ? {
14
+ record: value
15
+ } : {};
16
+ } catch (error) {
17
+ return {
18
+ error: error instanceof Error ? error : new Error(String(error))
19
+ };
20
+ }
21
+ }
22
+ function readReadyRecord(readyPath) {
23
+ return tryReadReadyRecord(readyPath).record;
24
+ }
25
+ function writeReadyRecord(readyPath, record, renameRetry) {
26
+ const tmpPath = `${readyPath}.tmp-${process.pid}`;
27
+ try {
28
+ node_fs__rspack_import_0.writeFileSync(tmpPath, `${JSON.stringify(record, null, 2)}\n`, 'utf-8');
29
+ (0, _rename_with_retry__rspack_import_1.O)(tmpPath, readyPath, renameRetry);
30
+ return;
31
+ } catch (error) {
32
+ try {
33
+ node_fs__rspack_import_0.rmSync(tmpPath, {
34
+ force: true
35
+ });
36
+ } catch {}
37
+ return error instanceof Error ? error : new Error(String(error));
38
+ }
39
+ }
40
+ function patchReadyRecord(readyPath, patch, renameRetry) {
41
+ const ready = readReadyRecord(readyPath);
42
+ if (!ready) return {
43
+ written: false
44
+ };
45
+ if (false === patch(ready)) return {
46
+ written: false
47
+ };
48
+ const error = writeReadyRecord(readyPath, ready, renameRetry);
49
+ return error ? {
50
+ written: false,
51
+ error
52
+ } : {
53
+ written: true
54
+ };
55
+ }
56
+ const LAUNCHED_PROCESS_FIELDS = {
57
+ browser: {
58
+ pid: 'browserPid',
59
+ startedAt: 'browserStartedAt',
60
+ startId: 'browserStartId'
61
+ },
62
+ launcher: {
63
+ pid: 'launcherPid',
64
+ startedAt: 'launcherStartedAt',
65
+ startId: 'launcherStartId'
66
+ }
67
+ };
68
+ function stampLaunchedProcess(ready, which, pid, probes) {
69
+ const fields = LAUNCHED_PROCESS_FIELDS[which];
70
+ if (ready[fields.pid] === pid) return;
71
+ ready[fields.pid] = pid;
72
+ const startedAt = probes.startedAt(pid);
73
+ if (startedAt) ready[fields.startedAt] = startedAt;
74
+ else delete ready[fields.startedAt];
75
+ const startId = probes.startId(pid);
76
+ if (startId) ready[fields.startId] = startId;
77
+ else delete ready[fields.startId];
78
+ }
79
+ __webpack_require__.d(__webpack_exports__, {}, {
80
+ VN: stampLaunchedProcess,
81
+ lu: readReadyRecord,
82
+ vF: patchReadyRecord
83
+ });
84
+ },
85
+ "../develop/lib/rename-with-retry.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
86
+ var node_fs__rspack_import_0 = __webpack_require__("node:fs");
87
+ const RETRYABLE_RENAME_CODES = new Set([
88
+ 'EPERM',
89
+ 'EACCES',
90
+ 'EBUSY'
91
+ ]);
92
+ const RENAME_RETRY_DELAYS_MS = [
93
+ 10,
94
+ 20,
95
+ 40,
96
+ 80,
97
+ 160,
98
+ 320
99
+ ];
100
+ function sleepSync(ms) {
101
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
102
+ }
103
+ function renameSyncWithRetry(from, to, options = {}) {
104
+ const platform = options.platform ?? process.platform;
105
+ const rename = options.rename ?? node_fs__rspack_import_0.renameSync;
106
+ const sleep = options.sleep ?? sleepSync;
107
+ for(let attempt = 0;; attempt++)try {
108
+ rename(from, to);
109
+ return;
110
+ } catch (error) {
111
+ const code = error?.code;
112
+ const delay = RENAME_RETRY_DELAYS_MS[attempt];
113
+ if ('win32' !== platform || !code || !RETRYABLE_RENAME_CODES.has(code) || void 0 === delay) throw error;
114
+ sleep(delay);
115
+ }
116
+ }
117
+ __webpack_require__.d(__webpack_exports__, {}, {
118
+ O: renameSyncWithRetry
119
+ });
120
+ },
6
121
  "../develop/lib/session-contract.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
122
  var node_path__rspack_import_0 = __webpack_require__("node:path");
8
123
  function sessionArtifactsRootDirBesideBuild(buildPath) {
@@ -48,6 +163,7 @@ var __webpack_modules__ = {
48
163
  var external_node_crypto_ = __webpack_require__("node:crypto");
49
164
  var external_node_fs_ = __webpack_require__("node:fs");
50
165
  var external_node_path_ = __webpack_require__("node:path");
166
+ var ready_contract_writer = __webpack_require__("../develop/lib/ready-contract-writer.ts");
51
167
  const MSG_NAME = /^__MSG_([A-Za-z0-9_@]+)__$/;
52
168
  function toLocaleFolder(locale) {
53
169
  const [language = '', ...rest] = String(locale ?? '').trim().split(/[-_]/);
@@ -106,11 +222,7 @@ var __webpack_modules__ = {
106
222
  }
107
223
  function readReadyMetadata(readyPath) {
108
224
  if (!readyPath) return null;
109
- try {
110
- return JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
111
- } catch {
112
- return null;
113
- }
225
+ return (0, ready_contract_writer.lu)(readyPath) ?? null;
114
226
  }
115
227
  function resolveRunLabel(ready) {
116
228
  const runId = toNormalizedId(ready?.runId);
@@ -2556,28 +2668,31 @@ var __webpack_modules__ = {
2556
2668
  var node_path__rspack_import_1 = __webpack_require__("node:path");
2557
2669
  var _locator_env__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/locator-env.ts");
2558
2670
  var _ready_stamp__rspack_import_2 = __webpack_require__("./browsers/browsers-lib/ready-stamp.ts");
2559
- function computeSharedCacheRoot() {
2560
- const explicit = String(process.env.EXT_BROWSERS_CACHE_DIR || '').trim();
2561
- if (explicit) return node_path__rspack_import_1.resolve(explicit);
2562
- const isWin = 'win32' === process.platform;
2563
- const isMac = 'darwin' === process.platform;
2564
- if (isWin) {
2565
- const local = String(process.env.LOCALAPPDATA || '').trim();
2566
- if (local) return node_path__rspack_import_1.join(local, 'extension.js', 'browsers');
2567
- const userProfile = String(process.env.USERPROFILE || '').trim();
2568
- if (userProfile) return node_path__rspack_import_1.join(userProfile, 'AppData', 'Local', 'extension.js', 'browsers');
2569
- return node_path__rspack_import_1.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
2570
- }
2571
- if (isMac) {
2572
- const home = String(process.env.HOME || '').trim();
2573
- if (home) return node_path__rspack_import_1.join(home, 'Library', 'Caches', 'extension.js', 'browsers');
2574
- return node_path__rspack_import_1.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
2575
- }
2576
- const xdg = String(process.env.XDG_CACHE_HOME || '').trim();
2577
- if (xdg) return node_path__rspack_import_1.join(xdg, 'extension.js', 'browsers');
2578
- const home = String(process.env.HOME || '').trim();
2579
- if (home) return node_path__rspack_import_1.join(home, '.cache', 'extension.js', 'browsers');
2580
- return node_path__rspack_import_1.resolve(process.cwd(), '.cache', 'extension.js', 'browsers');
2671
+ function computeSharedCacheRoot(env = process.env, platform = process.platform, cwd) {
2672
+ const p = 'win32' === platform ? node_path__rspack_import_1.win32 : node_path__rspack_import_1.posix;
2673
+ const explicit = String(env.EXT_BROWSERS_CACHE_DIR || '').trim();
2674
+ if (explicit) {
2675
+ if (node_path__rspack_import_1.isAbsolute(explicit) || p.isAbsolute(explicit)) return explicit;
2676
+ return void 0 === cwd ? node_path__rspack_import_1.resolve(explicit) : p.resolve(cwd, explicit);
2677
+ }
2678
+ const inWorkingDir = ()=>void 0 === cwd ? node_path__rspack_import_1.resolve(process.cwd(), '.cache', 'extension.js', 'browsers') : p.resolve(cwd, '.cache', 'extension.js', 'browsers');
2679
+ if ('win32' === platform) {
2680
+ const local = String(env.LOCALAPPDATA || '').trim();
2681
+ if (local) return p.join(local, 'extension.js', 'browsers');
2682
+ const userProfile = String(env.USERPROFILE || '').trim();
2683
+ if (userProfile) return p.join(userProfile, 'AppData', 'Local', 'extension.js', 'browsers');
2684
+ return inWorkingDir();
2685
+ }
2686
+ if ('darwin' === platform) {
2687
+ const home = String(env.HOME || '').trim();
2688
+ if (home) return p.join(home, 'Library', 'Caches', 'extension.js', 'browsers');
2689
+ return inWorkingDir();
2690
+ }
2691
+ const xdg = String(env.XDG_CACHE_HOME || '').trim();
2692
+ if (xdg) return p.join(xdg, 'extension.js', 'browsers');
2693
+ const home = String(env.HOME || '').trim();
2694
+ if (home) return p.join(home, '.cache', 'extension.js', 'browsers');
2695
+ return inWorkingDir();
2581
2696
  }
2582
2697
  function sharedManagedCacheEnv(browser) {
2583
2698
  return (0, _locator_env__rspack_import_3.is)(process.env, managedBrowserCacheEnv(computeSharedCacheRoot(), browser));
@@ -2893,10 +3008,12 @@ var __webpack_modules__ = {
2893
3008
  },
2894
3009
  "./browsers/browsers-lib/process-teardown.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2895
3010
  var node_child_process__rspack_import_0 = __webpack_require__("node:child_process");
2896
- var _helpers_messaging__rspack_import_1 = __webpack_require__("./helpers/messaging.ts");
2897
- var _messages__rspack_import_2 = __webpack_require__("./browsers/browsers-lib/messages.ts");
2898
- var _resolve_live_pid__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/resolve-live-pid.ts");
3011
+ var node_path__rspack_import_1 = __webpack_require__("node:path");
3012
+ var _helpers_messaging__rspack_import_2 = __webpack_require__("./helpers/messaging.ts");
3013
+ var _messages__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/messages.ts");
3014
+ var _resolve_live_pid__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/resolve-live-pid.ts");
2899
3015
  const FORCE_KILL_GRACE_MS = 5000;
3016
+ const EXIT_PROBE_TIMEOUT_MS = 1500;
2900
3017
  const terminatedByUs = new WeakSet();
2901
3018
  const terminatedPids = new Set();
2902
3019
  function wasTerminatedByUs(child) {
@@ -2906,27 +3023,52 @@ var __webpack_modules__ = {
2906
3023
  return 'number' == typeof pid && terminatedPids.has(pid);
2907
3024
  }
2908
3025
  function authorLog(line) {
2909
- if (line && (0, _helpers_messaging__rspack_import_1._o)()) (0, _helpers_messaging__rspack_import_1._w)(line);
3026
+ if (line && (0, _helpers_messaging__rspack_import_2._o)()) (0, _helpers_messaging__rspack_import_2._w)(line);
2910
3027
  }
2911
- function killWindowsTree(pid, sync) {
2912
- if ('win32' !== process.platform || !pid) return;
3028
+ function windowsTaskkillPath(env = process.env) {
3029
+ const root = env.SystemRoot || env.windir || 'C:\\Windows';
3030
+ return node_path__rspack_import_1.win32.join(root, 'System32', 'taskkill.exe');
3031
+ }
3032
+ function runTaskkill(pid, options) {
3033
+ if ((options.platform ?? process.platform) !== 'win32' || !pid) return;
2913
3034
  const args = [
2914
3035
  '/PID',
2915
3036
  String(pid),
2916
3037
  '/T',
2917
- '/F'
3038
+ ...options.force ? [
3039
+ '/F'
3040
+ ] : []
2918
3041
  ];
3042
+ const bin = windowsTaskkillPath();
2919
3043
  try {
2920
- if (sync) (0, node_child_process__rspack_import_0.spawnSync)('taskkill', args, {
3044
+ if (options.sync) (0, node_child_process__rspack_import_0.spawnSync)(bin, args, {
2921
3045
  stdio: 'ignore',
2922
3046
  windowsHide: true
2923
3047
  });
2924
- else (0, node_child_process__rspack_import_0.spawn)('taskkill', args, {
3048
+ else (0, node_child_process__rspack_import_0.spawn)(bin, args, {
2925
3049
  stdio: 'ignore',
2926
3050
  windowsHide: true
2927
3051
  }).on('error', ()=>{});
2928
3052
  } catch {}
2929
3053
  }
3054
+ function killWindowsTree(pid, sync) {
3055
+ runTaskkill(pid, {
3056
+ sync,
3057
+ force: true
3058
+ });
3059
+ }
3060
+ function killProcessTree(pid, options = {}) {
3061
+ const platform = options.platform ?? process.platform;
3062
+ if (!pid) return;
3063
+ if ('win32' === platform) return void runTaskkill(pid, {
3064
+ sync: true === options.sync,
3065
+ force: true,
3066
+ platform
3067
+ });
3068
+ try {
3069
+ process.kill(-pid, 'SIGKILL');
3070
+ } catch {}
3071
+ }
2930
3072
  function signalPid(pid, signal) {
2931
3073
  try {
2932
3074
  process.kill(pid, signal);
@@ -2938,20 +3080,27 @@ var __webpack_modules__ = {
2938
3080
  const teardownDefaults = {
2939
3081
  platform: process.platform,
2940
3082
  now: ()=>Date.now(),
2941
- isAlive: (pid)=>(0, _resolve_live_pid__rspack_import_3.by)(pid),
2942
- startedAt: (pid)=>(0, _resolve_live_pid__rspack_import_3.AW)(pid),
3083
+ isAlive: (pid)=>(0, _resolve_live_pid__rspack_import_4.by)(pid),
3084
+ startedAt: (pid)=>(0, _resolve_live_pid__rspack_import_4.AW)(pid),
3085
+ startedAtOnExit: (pid)=>(0, _resolve_live_pid__rspack_import_4.AW)(pid, process.platform, EXIT_PROBE_TIMEOUT_MS),
3086
+ startId: (pid)=>(0, _resolve_live_pid__rspack_import_4.Fj)(pid),
2943
3087
  mark: (pid)=>markDescendants(pid),
2944
3088
  sweep: (marks)=>forceKillMarkedOnExit(marks),
2945
3089
  kill: signalPid,
2946
3090
  killTree: (pid)=>killWindowsTree(pid, false),
2947
- print: (line)=>(0, _helpers_messaging__rspack_import_1._w)(line)
3091
+ killTreeOnExit: (pid)=>killWindowsTree(pid, true),
3092
+ askTree: (pid)=>runTaskkill(pid, {
3093
+ sync: false,
3094
+ force: false
3095
+ }),
3096
+ print: (line)=>(0, _helpers_messaging__rspack_import_2._w)(line)
2948
3097
  };
2949
3098
  function startedBy(pid, askedAt, deps) {
2950
3099
  const started = deps.startedAt(pid);
2951
3100
  return null !== started && started <= askedAt;
2952
3101
  }
2953
3102
  function forceKill(pid, browser, helpers, deps, sigkill) {
2954
- authorLog(_messages__rspack_import_2.AGJ(browser));
3103
+ authorLog(_messages__rspack_import_3.AGJ(browser));
2955
3104
  if ('win32' === deps.platform) return void deps.killTree(pid);
2956
3105
  sigkill();
2957
3106
  deps.sweep(helpers);
@@ -2959,46 +3108,57 @@ var __webpack_modules__ = {
2959
3108
  function gracefulTerminatePid(pid, browser, deps = teardownDefaults) {
2960
3109
  if (!pid || terminatedPids.has(pid)) return;
2961
3110
  terminatedPids.add(pid);
2962
- killWindowsTree(pid, false);
2963
- authorLog(_messages__rspack_import_2.XHr(browser));
3111
+ authorLog(_messages__rspack_import_3.XHr(browser));
2964
3112
  const askedAt = 1000 * Math.floor(deps.now() / 1000) - 1;
2965
- deps.kill(pid, 'SIGTERM');
3113
+ const idAtAsk = deps.startId(pid);
3114
+ askToStop(pid, deps, ()=>deps.kill(pid, 'SIGTERM'));
2966
3115
  const killTimer = setTimeout(()=>{
2967
3116
  if (!deps.isAlive(pid)) return;
2968
- if (!startedBy(pid, askedAt, deps)) return void deps.print(_messages__rspack_import_2.JQd(browser, pid, deps.platform));
3117
+ const same = (0, _resolve_live_pid__rspack_import_4.cJ)(idAtAsk, pid, deps.startId);
3118
+ if (false === same || void 0 === same && !startedBy(pid, askedAt, deps)) return void deps.print(_messages__rspack_import_3.JQd(browser, pid, deps.platform));
2969
3119
  forceKill(pid, browser, [], deps, ()=>deps.kill(pid, 'SIGKILL'));
2970
3120
  }, FORCE_KILL_GRACE_MS);
2971
3121
  killTimer.unref?.();
2972
3122
  }
2973
- function forceKillPidOnExit(pid, browser, adoptedAt, deps = teardownDefaults) {
2974
- if (!pid || !startedBy(pid, adoptedAt, deps)) return;
3123
+ function forceKillPidOnExit(pid, browser, adoptedAt, deps = teardownDefaults, adoptedStartId) {
3124
+ if (!pid) return;
3125
+ const same = (0, _resolve_live_pid__rspack_import_4.cJ)(adoptedStartId, pid, deps.startId);
3126
+ const started = void 0 === same ? deps.startedAtOnExit(pid) : null;
3127
+ const reused = void 0 === same ? null === started || started > adoptedAt : !same;
3128
+ if (reused) {
3129
+ if (deps.isAlive(pid)) deps.print(_messages__rspack_import_3.JQd(browser, pid, deps.platform));
3130
+ return;
3131
+ }
2975
3132
  terminatedPids.add(pid);
2976
- killWindowsTree(pid, true);
2977
- authorLog(_messages__rspack_import_2.AGJ(browser));
3133
+ if ('win32' === deps.platform) deps.killTreeOnExit(pid);
3134
+ authorLog(_messages__rspack_import_3.AGJ(browser));
2978
3135
  deps.kill(pid, 'SIGKILL');
2979
3136
  }
3137
+ function askToStop(pid, deps, sigterm) {
3138
+ if ('win32' !== deps.platform) return void sigterm();
3139
+ if (pid) deps.askTree(pid);
3140
+ }
2980
3141
  function gracefulTerminateChild(child, browser, helpers, deps = teardownDefaults) {
2981
- if (!child || child.killed) return;
3142
+ if (!child || child.killed || terminatedByUs.has(child)) return;
2982
3143
  terminatedByUs.add(child);
2983
- killWindowsTree(child.pid, false);
2984
- authorLog(_messages__rspack_import_2.XHr(browser));
3144
+ authorLog(_messages__rspack_import_3.XHr(browser));
2985
3145
  const marks = helpers ?? deps.mark(child.pid);
2986
3146
  const askedAt = deps.now();
2987
- child.kill('SIGTERM');
3147
+ askToStop(child.pid, deps, ()=>child.kill('SIGTERM'));
2988
3148
  const killTimer = setTimeout(()=>{
2989
3149
  const pid = child.pid;
2990
3150
  if (!pid || null !== child.exitCode || null !== child.signalCode) return;
2991
- if (!startedBy(pid, askedAt, deps)) return void deps.print(_messages__rspack_import_2.JQd(browser, pid, deps.platform));
3151
+ if (!startedBy(pid, askedAt, deps)) return void deps.print(_messages__rspack_import_3.JQd(browser, pid, deps.platform));
2992
3152
  forceKill(pid, browser, marks, deps, ()=>child.kill('SIGKILL'));
2993
3153
  }, FORCE_KILL_GRACE_MS);
2994
3154
  killTimer.unref?.();
2995
3155
  }
2996
- function forceKillChildOnExit(child, browser) {
3156
+ function forceKillChildOnExit(child, browser, deps = teardownDefaults) {
2997
3157
  if (!child) return;
2998
3158
  terminatedByUs.add(child);
2999
- killWindowsTree(child.pid, true);
3159
+ if ('win32' === deps.platform && child.pid) deps.killTreeOnExit(child.pid);
3000
3160
  try {
3001
- authorLog(_messages__rspack_import_2.AGJ(browser));
3161
+ authorLog(_messages__rspack_import_3.AGJ(browser));
3002
3162
  child.kill('SIGKILL');
3003
3163
  } catch {}
3004
3164
  }
@@ -3089,7 +3249,8 @@ var __webpack_modules__ = {
3089
3249
  Qx: forceKillPidOnExit,
3090
3250
  SG: markDescendants,
3091
3251
  V8: forceKillMarkedOnExit,
3092
- _T: gracefulTerminatePid
3252
+ _T: gracefulTerminatePid,
3253
+ g8: killProcessTree
3093
3254
  });
3094
3255
  },
3095
3256
  "./browsers/browsers-lib/ready-message.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
@@ -3107,83 +3268,35 @@ var __webpack_modules__ = {
3107
3268
  });
3108
3269
  },
3109
3270
  "./browsers/browsers-lib/ready-stamp.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3110
- __webpack_require__.d(__webpack_exports__, {
3111
- Jk: ()=>claimReadyPath,
3112
- $V: ()=>clearReadyCdpPort,
3113
- dT: ()=>describeLaunchFailure,
3114
- Du: ()=>earlierManagedProfileBaseDir,
3115
- NE: ()=>launchFailureCode,
3116
- fB: ()=>managedProfileBaseDir,
3117
- sJ: ()=>readReadyDevAdditions,
3118
- Lb: ()=>readReadyExecutorAttached,
3119
- Uf: ()=>readReadyRunId,
3120
- O3: ()=>readyPathFor,
3121
- S9: ()=>sessionRootFor,
3122
- Wi: ()=>stampReadyBrowserExited,
3123
- M: ()=>stampReadyBrowserLaunch,
3124
- dz: ()=>stampReadyBrowserLaunchFailed,
3125
- xG: ()=>stampReadyBrowserUpNotAttached,
3126
- QP: ()=>stampReadyCdpFault,
3127
- HI: ()=>stampReadyCdpPort,
3128
- s5: ()=>stampReadyDevBrowserFlag,
3129
- td: ()=>stampReadyDevBrowserPreference,
3130
- wy: ()=>stampReadyExtensionBaseUrl,
3131
- hg: ()=>stampReadyExtensionId,
3132
- sf: ()=>stampReadyExtensionLoadRefused,
3133
- iD: ()=>stampReadyProfileLocked,
3134
- __: ()=>stampReadyRdpPort,
3135
- uz: ()=>stampReadyRdpPortError,
3136
- eW: ()=>stampReadySafariEnable,
3137
- kf: ()=>stampReadyStartingUrl,
3138
- ZC: ()=>stampReadyWebDriver
3139
- });
3140
- var external_node_fs_ = __webpack_require__("node:fs");
3141
- var external_node_path_ = __webpack_require__("node:path");
3142
- var session_contract = __webpack_require__("../develop/lib/session-contract.ts");
3143
- var messaging = __webpack_require__("./helpers/messaging.ts");
3144
- var resolve_live_pid = __webpack_require__("./browsers/browsers-lib/resolve-live-pid.ts");
3145
- var rename_with_retry = __webpack_require__("./browsers/browsers-lib/rename-with-retry.ts");
3146
- function writeJsonAtomic(filePath, value, retry = {}) {
3147
- const tmpPath = `${filePath}.tmp-${process.pid}`;
3148
- try {
3149
- external_node_fs_.writeFileSync(tmpPath, JSON.stringify(value, null, 2), 'utf-8');
3150
- (0, rename_with_retry.O)(tmpPath, filePath, retry);
3151
- return true;
3152
- } catch {
3153
- try {
3154
- external_node_fs_.rmSync(tmpPath, {
3155
- force: true
3156
- });
3157
- } catch {}
3158
- return false;
3159
- }
3160
- }
3271
+ var node_path__rspack_import_0 = __webpack_require__("node:path");
3272
+ var _develop_lib_ready_contract_writer__rspack_import_4 = __webpack_require__("../develop/lib/ready-contract-writer.ts");
3273
+ var _develop_lib_session_contract__rspack_import_3 = __webpack_require__("../develop/lib/session-contract.ts");
3274
+ var _helpers_messaging__rspack_import_1 = __webpack_require__("./helpers/messaging.ts");
3275
+ var _resolve_live_pid__rspack_import_2 = __webpack_require__("./browsers/browsers-lib/resolve-live-pid.ts");
3161
3276
  const ownedReadyPaths = new Map();
3162
3277
  function claimReadyPath(extensionOutputPath, readyPath) {
3163
3278
  if (!extensionOutputPath || !readyPath) return;
3164
- ownedReadyPaths.set(external_node_path_.resolve(extensionOutputPath), readyPath);
3279
+ ownedReadyPaths.set(node_path__rspack_import_0.resolve(extensionOutputPath), readyPath);
3165
3280
  }
3166
3281
  function sessionRootFor(extensionOutputPath) {
3167
- const owned = ownedReadyPaths.get(external_node_path_.resolve(extensionOutputPath));
3168
- return owned ? external_node_path_.dirname(external_node_path_.dirname(owned)) : (0, session_contract.bv)(extensionOutputPath);
3282
+ const owned = ownedReadyPaths.get(node_path__rspack_import_0.resolve(extensionOutputPath));
3283
+ return owned ? node_path__rspack_import_0.dirname(node_path__rspack_import_0.dirname(owned)) : (0, _develop_lib_session_contract__rspack_import_3.bv)(extensionOutputPath);
3169
3284
  }
3170
3285
  function managedProfileBaseDir(extensionOutputPath, browser) {
3171
- return external_node_path_.resolve(sessionRootFor(extensionOutputPath), 'profiles', `${browser}-profile`);
3286
+ return node_path__rspack_import_0.resolve(sessionRootFor(extensionOutputPath), 'profiles', `${browser}-profile`);
3172
3287
  }
3173
3288
  function earlierManagedProfileBaseDir(extensionOutputPath, browser) {
3174
- const earlier = external_node_path_.resolve((0, session_contract.bv)(extensionOutputPath), 'profiles', `${browser}-profile`);
3289
+ const earlier = node_path__rspack_import_0.resolve((0, _develop_lib_session_contract__rspack_import_3.bv)(extensionOutputPath), 'profiles', `${browser}-profile`);
3175
3290
  return earlier === managedProfileBaseDir(extensionOutputPath, browser) ? void 0 : earlier;
3176
3291
  }
3177
3292
  function readyPathFor(extensionOutputPath) {
3178
- return ownedReadyPaths.get(external_node_path_.resolve(extensionOutputPath)) ?? (0, session_contract.zJ)(extensionOutputPath);
3293
+ return ownedReadyPaths.get(node_path__rspack_import_0.resolve(extensionOutputPath)) ?? (0, _develop_lib_session_contract__rspack_import_3.zJ)(extensionOutputPath);
3179
3294
  }
3180
3295
  const ANOTHER_PROCESS_RUN = 'run-of-another-process';
3181
3296
  function readReadyRunId(extensionOutputPath) {
3182
3297
  try {
3183
3298
  if (!extensionOutputPath) return;
3184
- const readyPath = readyPathFor(extensionOutputPath);
3185
- if (!external_node_fs_.existsSync(readyPath)) return;
3186
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3299
+ const ready = (0, _develop_lib_ready_contract_writer__rspack_import_4.lu)(readyPathFor(extensionOutputPath));
3187
3300
  const runId = ready?.runId;
3188
3301
  if ('number' == typeof ready?.pid && ready.pid !== process.pid) return ANOTHER_PROCESS_RUN;
3189
3302
  return 'string' == typeof runId && runId ? runId : void 0;
@@ -3199,72 +3312,52 @@ var __webpack_modules__ = {
3199
3312
  function dateStatus(ready) {
3200
3313
  ready.ts = new Date().toISOString();
3201
3314
  }
3202
- function stampReadyRdpPort(extensionOutputPath, rdpPort, runId) {
3315
+ function patchReady(extensionOutputPath, runId, patch) {
3203
3316
  try {
3204
- if (!extensionOutputPath || !Number.isFinite(rdpPort)) return;
3205
- const readyPath = readyPathFor(extensionOutputPath);
3206
- if (!external_node_fs_.existsSync(readyPath)) return;
3207
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3208
- if (isForeignRun(ready, runId)) return;
3209
- const held = (0, session_contract.K0)(ready);
3210
- if (ready.rdpPort === rdpPort && !ready.rdpPortError && !held) return;
3317
+ if (!extensionOutputPath) return;
3318
+ (0, _develop_lib_ready_contract_writer__rspack_import_4.vF)(readyPathFor(extensionOutputPath), (ready)=>isForeignRun(ready, runId) ? false : patch(ready));
3319
+ } catch {}
3320
+ }
3321
+ function stampReadyRdpPort(extensionOutputPath, rdpPort, runId) {
3322
+ if (!Number.isFinite(rdpPort)) return;
3323
+ patchReady(extensionOutputPath, runId, (ready)=>{
3324
+ const held = (0, _develop_lib_session_contract__rspack_import_3.K0)(ready);
3325
+ if (ready.rdpPort === rdpPort && !ready.rdpPortError && !held) return false;
3211
3326
  ready.rdpPort = rdpPort;
3212
3327
  delete ready.rdpPortError;
3213
- if ((0, session_contract.uG)(ready, {
3328
+ if ((0, _develop_lib_session_contract__rspack_import_3.uG)(ready, {
3214
3329
  rdpPort: true
3215
3330
  })) dateStatus(ready);
3216
- writeJsonAtomic(readyPath, ready);
3217
- } catch {}
3331
+ });
3218
3332
  }
3219
3333
  function stampReadyRdpPortError(extensionOutputPath, reason, runId) {
3220
- try {
3221
- if (!extensionOutputPath) return;
3222
- const readyPath = readyPathFor(extensionOutputPath);
3223
- if (!external_node_fs_.existsSync(readyPath)) return;
3224
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3225
- if (isForeignRun(ready, runId)) return;
3334
+ patchReady(extensionOutputPath, runId, (ready)=>{
3226
3335
  delete ready.rdpPort;
3227
3336
  ready.rdpPortError = String(reason || '').trim() || 'Firefox did not open its remote debugging port';
3228
- if ((0, session_contract.uG)(ready, {
3337
+ if ((0, _develop_lib_session_contract__rspack_import_3.uG)(ready, {
3229
3338
  rdpPort: true
3230
3339
  })) dateStatus(ready);
3231
- writeJsonAtomic(readyPath, ready);
3232
- } catch {}
3340
+ });
3233
3341
  }
3234
3342
  function stampReadyCdpPort(extensionOutputPath, cdpPort, runId) {
3235
- try {
3236
- if (!extensionOutputPath || !Number.isFinite(cdpPort)) return;
3237
- const readyPath = readyPathFor(extensionOutputPath);
3238
- if (!external_node_fs_.existsSync(readyPath)) return;
3239
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3240
- if (isForeignRun(ready, runId)) return;
3241
- const held = (0, session_contract.K0)(ready);
3242
- if (ready.cdpPort === cdpPort && !held) return;
3343
+ if (!Number.isFinite(cdpPort)) return;
3344
+ patchReady(extensionOutputPath, runId, (ready)=>{
3345
+ const held = (0, _develop_lib_session_contract__rspack_import_3.K0)(ready);
3346
+ if (ready.cdpPort === cdpPort && !held) return false;
3243
3347
  ready.cdpPort = cdpPort;
3244
- if ((0, session_contract.uG)(ready, {
3348
+ if ((0, _develop_lib_session_contract__rspack_import_3.uG)(ready, {
3245
3349
  cdpPort: true
3246
3350
  })) dateStatus(ready);
3247
- writeJsonAtomic(readyPath, ready);
3248
- } catch {}
3351
+ });
3249
3352
  }
3250
3353
  function clearReadyCdpPort(extensionOutputPath, runId) {
3251
- try {
3252
- if (!extensionOutputPath) return;
3253
- const readyPath = readyPathFor(extensionOutputPath);
3254
- if (!external_node_fs_.existsSync(readyPath)) return;
3255
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3256
- if (isForeignRun(ready, runId) || !('cdpPort' in ready)) return;
3354
+ patchReady(extensionOutputPath, runId, (ready)=>{
3355
+ if (!('cdpPort' in ready)) return false;
3257
3356
  delete ready.cdpPort;
3258
- writeJsonAtomic(readyPath, ready);
3259
- } catch {}
3357
+ });
3260
3358
  }
3261
3359
  function stampReadyWebDriver(extensionOutputPath, details, runId) {
3262
- try {
3263
- if (!extensionOutputPath) return;
3264
- const readyPath = readyPathFor(extensionOutputPath);
3265
- if (!external_node_fs_.existsSync(readyPath)) return;
3266
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3267
- if (isForeignRun(ready, runId)) return;
3360
+ patchReady(extensionOutputPath, runId, (ready)=>{
3268
3361
  const sessionId = String(details?.sessionId || '').trim();
3269
3362
  const port = details?.port;
3270
3363
  const requestPath = String(details?.requestPath || '').trim();
@@ -3275,24 +3368,15 @@ var __webpack_modules__ = {
3275
3368
  delete ready.webdriverUnavailableReason;
3276
3369
  } else {
3277
3370
  const reason = String(details?.unavailableReason || '').trim();
3278
- if (!reason) {
3279
- if (requestPath) writeJsonAtomic(readyPath, ready);
3280
- return;
3281
- }
3371
+ if (!reason) return Boolean(requestPath);
3282
3372
  delete ready.webdriverPort;
3283
3373
  delete ready.webdriverSessionId;
3284
3374
  ready.webdriverUnavailableReason = reason;
3285
3375
  }
3286
- writeJsonAtomic(readyPath, ready);
3287
- } catch {}
3376
+ });
3288
3377
  }
3289
3378
  function stampReadySafariEnable(extensionOutputPath, details, runId) {
3290
- try {
3291
- if (!extensionOutputPath) return;
3292
- const readyPath = readyPathFor(extensionOutputPath);
3293
- if (!external_node_fs_.existsSync(readyPath)) return;
3294
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3295
- if (isForeignRun(ready, runId)) return;
3379
+ patchReady(extensionOutputPath, runId, (ready)=>{
3296
3380
  const safari = {
3297
3381
  bundleId: details.bundleId,
3298
3382
  extensionId: details.extensionId,
@@ -3310,42 +3394,27 @@ var __webpack_modules__ = {
3310
3394
  ...details.earlierExtensionIds
3311
3395
  ];
3312
3396
  ready.safari = safari;
3313
- writeJsonAtomic(readyPath, ready);
3314
- } catch {}
3397
+ });
3315
3398
  }
3316
3399
  function stampReadyStartingUrl(extensionOutputPath, details, runId) {
3317
- try {
3318
- if (!extensionOutputPath) return;
3319
- const readyPath = readyPathFor(extensionOutputPath);
3320
- if (!external_node_fs_.existsSync(readyPath)) return;
3321
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3322
- if (isForeignRun(ready, runId)) return;
3400
+ patchReady(extensionOutputPath, runId, (ready)=>{
3323
3401
  ready.startingUrl = details.url;
3324
3402
  ready.startingUrlOpened = details.opened;
3325
3403
  if (details.opened) delete ready.startingUrlUnopenedReason;
3326
3404
  else ready.startingUrlUnopenedReason = String(details.reason || '').trim();
3327
- writeJsonAtomic(readyPath, ready);
3328
- } catch {}
3329
- }
3330
- function stampPidWithStart(ready, pidKey, startKey, pid) {
3331
- if (ready[pidKey] === pid) return;
3332
- ready[pidKey] = pid;
3333
- const startedAt = (0, resolve_live_pid.V5)(pid);
3334
- if (startedAt) ready[startKey] = startedAt;
3335
- else delete ready[startKey];
3405
+ });
3336
3406
  }
3337
- function stampReadyBrowserLaunch(extensionOutputPath, details, runId) {
3338
- try {
3339
- if (!extensionOutputPath) return;
3340
- const readyPath = readyPathFor(extensionOutputPath);
3341
- if (!external_node_fs_.existsSync(readyPath)) return;
3342
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3343
- if (isForeignRun(ready, runId)) return;
3407
+ const pidStartProbes = {
3408
+ startedAt: (pid)=>(0, _resolve_live_pid__rspack_import_2.V5)(pid),
3409
+ startId: (pid)=>(0, _resolve_live_pid__rspack_import_2.Fj)(pid)
3410
+ };
3411
+ function stampReadyBrowserLaunch(extensionOutputPath, details, runId, probes = pidStartProbes) {
3412
+ patchReady(extensionOutputPath, runId, (ready)=>{
3344
3413
  const profilePath = String(details?.profilePath || '').trim();
3345
3414
  if (profilePath) ready.profilePath = profilePath;
3346
3415
  if ('boolean' == typeof details?.profileReused) ready.profileReused = details.profileReused;
3347
- if ('number' == typeof details?.browserPid && Number.isFinite(details.browserPid)) stampPidWithStart(ready, 'browserPid', 'browserStartedAt', details.browserPid);
3348
- if ('number' == typeof details?.launcherPid && Number.isFinite(details.launcherPid)) stampPidWithStart(ready, 'launcherPid', 'launcherStartedAt', details.launcherPid);
3416
+ if ('number' == typeof details?.browserPid && Number.isFinite(details.browserPid)) (0, _develop_lib_ready_contract_writer__rspack_import_4.VN)(ready, 'browser', details.browserPid, probes);
3417
+ if ('number' == typeof details?.launcherPid && Number.isFinite(details.launcherPid)) (0, _develop_lib_ready_contract_writer__rspack_import_4.VN)(ready, 'launcher', details.launcherPid, probes);
3349
3418
  const extensionId = String(details?.extensionId || '').trim();
3350
3419
  if (extensionId && 'browser' !== ready.extensionIdSource) {
3351
3420
  ready.extensionId = extensionId;
@@ -3368,46 +3437,32 @@ var __webpack_modules__ = {
3368
3437
  dateStatus(ready);
3369
3438
  }
3370
3439
  }
3371
- writeJsonAtomic(readyPath, ready);
3372
- } catch {}
3440
+ });
3373
3441
  }
3374
3442
  function readReadyExecutorAttached(extensionOutputPath, runId) {
3375
3443
  try {
3376
3444
  if (!extensionOutputPath) return false;
3377
- const readyPath = readyPathFor(extensionOutputPath);
3378
- if (!external_node_fs_.existsSync(readyPath)) return false;
3379
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3380
- if (isForeignRun(ready, runId)) return false;
3445
+ const ready = (0, _develop_lib_ready_contract_writer__rspack_import_4.lu)(readyPathFor(extensionOutputPath));
3446
+ if (!ready || isForeignRun(ready, runId)) return false;
3381
3447
  return 'string' == typeof ready.executorAttachedAt || 'attached' === ready.runtime;
3382
3448
  } catch {
3383
3449
  return false;
3384
3450
  }
3385
3451
  }
3386
3452
  function stampReadyBrowserUpNotAttached(extensionOutputPath, details, runId) {
3387
- try {
3388
- if (!extensionOutputPath) return;
3389
- const readyPath = readyPathFor(extensionOutputPath);
3390
- if (!external_node_fs_.existsSync(readyPath)) return;
3391
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3392
- if (isForeignRun(ready, runId)) return;
3453
+ patchReady(extensionOutputPath, runId, (ready)=>{
3393
3454
  ready.browserUpNotAttachedAt = new Date().toISOString();
3394
3455
  ready.browserUpNotAttachedWaitMs = details.waitedMs;
3395
3456
  ready.browserUpNotAttachedHint = String(details.hint || '').trim() || 'the browser is up, but the extension has not connected';
3396
- writeJsonAtomic(readyPath, ready);
3397
- } catch {}
3457
+ });
3398
3458
  }
3399
3459
  function describeLaunchFailure(error) {
3400
3460
  const message = error instanceof Error ? error.message : 'string' == typeof error ? error : String(error?.message ?? error ?? '');
3401
- return (0, messaging.UT)(message).replace(/\s+/g, ' ').trim();
3461
+ return (0, _helpers_messaging__rspack_import_1.UT)(message).replace(/\s+/g, ' ').trim();
3402
3462
  }
3403
3463
  function stampReadyBrowserLaunchFailed(extensionOutputPath, reason, runId, errorCode) {
3404
- try {
3405
- if (!extensionOutputPath) return;
3406
- const readyPath = readyPathFor(extensionOutputPath);
3407
- if (!external_node_fs_.existsSync(readyPath)) return;
3408
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3409
- if (isForeignRun(ready, runId)) return;
3410
- if ('error' === ready.status && ready.code && 'browser_launch_failed' !== ready.code) return;
3464
+ patchReady(extensionOutputPath, runId, (ready)=>{
3465
+ if ('error' === ready.status && ready.code && 'browser_launch_failed' !== ready.code) return false;
3411
3466
  const detail = String(reason || '').trim() || 'the browser process could not be started';
3412
3467
  ready.status = 'error';
3413
3468
  ready.code = 'browser_launch_failed';
@@ -3416,8 +3471,7 @@ var __webpack_modules__ = {
3416
3471
  ready.browserLaunchFailedAt = new Date().toISOString();
3417
3472
  ready.browserLaunchFailedReason = detail;
3418
3473
  if (errorCode) ready.browserLaunchFailedCode = errorCode;
3419
- writeJsonAtomic(readyPath, ready);
3420
- } catch {}
3474
+ });
3421
3475
  }
3422
3476
  function launchFailureCode(error) {
3423
3477
  const code = error?.code;
@@ -3430,26 +3484,19 @@ var __webpack_modules__ = {
3430
3484
  function readReadyDevAdditions(extensionOutputPath) {
3431
3485
  try {
3432
3486
  if (!extensionOutputPath) return [];
3433
- const readyPath = readyPathFor(extensionOutputPath);
3434
- if (!external_node_fs_.existsSync(readyPath)) return [];
3435
- return devAdditionEntries(JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'))?.devAdditions);
3487
+ return devAdditionEntries((0, _develop_lib_ready_contract_writer__rspack_import_4.lu)(readyPathFor(extensionOutputPath))?.devAdditions);
3436
3488
  } catch {
3437
3489
  return [];
3438
3490
  }
3439
3491
  }
3440
3492
  function stampReadyLauncherAddition(extensionOutputPath, entry, named, runId) {
3441
- try {
3442
- if (!extensionOutputPath || !entry?.value) return;
3443
- const readyPath = readyPathFor(extensionOutputPath);
3444
- if (!external_node_fs_.existsSync(readyPath)) return;
3445
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3446
- if (isForeignRun(ready, runId)) return;
3493
+ if (!entry?.value) return;
3494
+ patchReady(extensionOutputPath, runId, (ready)=>{
3447
3495
  ready.devAdditions = [
3448
3496
  ...devAdditionEntries(ready.devAdditions).filter((earlier)=>!(earlier.kind === entry.kind && named(earlier.value) === named(entry.value))),
3449
3497
  entry
3450
3498
  ];
3451
- writeJsonAtomic(readyPath, ready);
3452
- } catch {}
3499
+ });
3453
3500
  }
3454
3501
  function stampReadyDevBrowserFlag(extensionOutputPath, flag, runId) {
3455
3502
  stampReadyLauncherAddition(extensionOutputPath, {
@@ -3464,54 +3511,34 @@ var __webpack_modules__ = {
3464
3511
  }, (value)=>value.split('=')[0], runId);
3465
3512
  }
3466
3513
  function stampReadyCdpFault(extensionOutputPath, code, detail, runId) {
3467
- try {
3468
- if (!extensionOutputPath || !code) return;
3469
- const readyPath = readyPathFor(extensionOutputPath);
3470
- if (!external_node_fs_.existsSync(readyPath)) return;
3471
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3472
- if (isForeignRun(ready, runId)) return;
3473
- ready.cdpFaultCode = (0, messaging.F7)(code);
3514
+ if (!code) return;
3515
+ patchReady(extensionOutputPath, runId, (ready)=>{
3516
+ ready.cdpFaultCode = (0, _helpers_messaging__rspack_import_1.F7)(code);
3474
3517
  ready.cdpFaultMessage = String(detail || '').trim() || 'the CDP wire failed after launch';
3475
- if ((0, session_contract.uG)(ready, {
3518
+ if ((0, _develop_lib_session_contract__rspack_import_3.uG)(ready, {
3476
3519
  cdpPort: true
3477
3520
  })) dateStatus(ready);
3478
- writeJsonAtomic(readyPath, ready);
3479
- } catch {}
3521
+ });
3480
3522
  }
3481
3523
  function stampReadyExtensionId(extensionOutputPath, extensionId, runId) {
3482
- try {
3483
- const id = String(extensionId || '').trim();
3484
- if (!extensionOutputPath || !id) return;
3485
- const readyPath = readyPathFor(extensionOutputPath);
3486
- if (!external_node_fs_.existsSync(readyPath)) return;
3487
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3488
- if (isForeignRun(ready, runId)) return;
3489
- if (ready.extensionId === id && 'browser' === ready.extensionIdSource) return;
3524
+ const id = String(extensionId || '').trim();
3525
+ if (!id) return;
3526
+ patchReady(extensionOutputPath, runId, (ready)=>{
3527
+ if (ready.extensionId === id && 'browser' === ready.extensionIdSource) return false;
3490
3528
  ready.extensionId = id;
3491
3529
  ready.extensionIdSource = 'browser';
3492
- writeJsonAtomic(readyPath, ready);
3493
- } catch {}
3530
+ });
3494
3531
  }
3495
3532
  function stampReadyExtensionBaseUrl(extensionOutputPath, extensionBaseUrl, runId) {
3496
- try {
3497
- const base = String(extensionBaseUrl || '').trim();
3498
- if (!extensionOutputPath || !base) return;
3499
- const readyPath = readyPathFor(extensionOutputPath);
3500
- if (!external_node_fs_.existsSync(readyPath)) return;
3501
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3502
- if (isForeignRun(ready, runId)) return;
3503
- if (ready.extensionBaseUrl === base) return;
3533
+ const base = String(extensionBaseUrl || '').trim();
3534
+ if (!base) return;
3535
+ patchReady(extensionOutputPath, runId, (ready)=>{
3536
+ if (ready.extensionBaseUrl === base) return false;
3504
3537
  ready.extensionBaseUrl = base;
3505
- writeJsonAtomic(readyPath, ready);
3506
- } catch {}
3538
+ });
3507
3539
  }
3508
3540
  function stampReadyExtensionLoadRefused(extensionOutputPath, reason, runId, cause) {
3509
- try {
3510
- if (!extensionOutputPath) return;
3511
- const readyPath = readyPathFor(extensionOutputPath);
3512
- if (!external_node_fs_.existsSync(readyPath)) return;
3513
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3514
- if (isForeignRun(ready, runId)) return;
3541
+ patchReady(extensionOutputPath, runId, (ready)=>{
3515
3542
  ready.status = 'error';
3516
3543
  ready.code = 'extension_load_refused';
3517
3544
  dateStatus(ready);
@@ -3525,34 +3552,24 @@ var __webpack_modules__ = {
3525
3552
  delete ready.extensionId;
3526
3553
  delete ready.extensionIdSource;
3527
3554
  }
3528
- writeJsonAtomic(readyPath, ready);
3529
- } catch {}
3555
+ });
3530
3556
  }
3531
3557
  function stampReadyProfileLocked(extensionOutputPath, details, runId) {
3532
- try {
3533
- if (!extensionOutputPath) return;
3534
- const readyPath = readyPathFor(extensionOutputPath);
3535
- if (!external_node_fs_.existsSync(readyPath)) return;
3536
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3537
- if (isForeignRun(ready, runId)) return;
3558
+ patchReady(extensionOutputPath, runId, (ready)=>{
3538
3559
  ready.status = 'error';
3539
3560
  ready.code = 'profile_locked';
3540
3561
  dateStatus(ready);
3541
3562
  ready.message = String(details?.message || '').trim() || 'the browser profile is already in use by another session';
3542
3563
  ready.profileLockedAt = new Date().toISOString();
3543
3564
  if (details?.owner) ready.profileLockOwner = details.owner;
3544
- writeJsonAtomic(readyPath, ready);
3545
- } catch {}
3565
+ });
3546
3566
  }
3547
3567
  function stampReadyBrowserExited(extensionOutputPath, code, signal = null, runId, details = {}) {
3548
- try {
3549
- if (!extensionOutputPath) return;
3550
- const readyPath = readyPathFor(extensionOutputPath);
3551
- if (!external_node_fs_.existsSync(readyPath)) return;
3552
- const ready = JSON.parse(external_node_fs_.readFileSync(readyPath, 'utf-8'));
3553
- if (isForeignRun(ready, runId)) return;
3568
+ patchReady(extensionOutputPath, runId, (ready)=>{
3554
3569
  ready.browserExitedAt = new Date().toISOString();
3555
3570
  ready.browserExitCode = code;
3571
+ delete ready.cdpPort;
3572
+ delete ready.rdpPort;
3556
3573
  ready.browserExitSignal = signal;
3557
3574
  const how = null == code && signal ? `signal ${signal}` : `code ${code ?? 'unknown'}`;
3558
3575
  if ('preview' === ready.command || 'start' === ready.command) {
@@ -3566,9 +3583,38 @@ var __webpack_modules__ = {
3566
3583
  dateStatus(ready);
3567
3584
  ready.message = `the ${ready.browser || 'browser'} process exited (${how}) before the extension loaded, nothing is running`;
3568
3585
  }
3569
- writeJsonAtomic(readyPath, ready);
3570
- } catch {}
3586
+ });
3571
3587
  }
3588
+ __webpack_require__.d(__webpack_exports__, {}, {
3589
+ $V: clearReadyCdpPort,
3590
+ Du: earlierManagedProfileBaseDir,
3591
+ HI: stampReadyCdpPort,
3592
+ Jk: claimReadyPath,
3593
+ Lb: readReadyExecutorAttached,
3594
+ M: stampReadyBrowserLaunch,
3595
+ NE: launchFailureCode,
3596
+ O3: readyPathFor,
3597
+ QP: stampReadyCdpFault,
3598
+ S9: sessionRootFor,
3599
+ Uf: readReadyRunId,
3600
+ Wi: stampReadyBrowserExited,
3601
+ ZC: stampReadyWebDriver,
3602
+ __: stampReadyRdpPort,
3603
+ dT: describeLaunchFailure,
3604
+ dz: stampReadyBrowserLaunchFailed,
3605
+ eW: stampReadySafariEnable,
3606
+ fB: managedProfileBaseDir,
3607
+ hg: stampReadyExtensionId,
3608
+ iD: stampReadyProfileLocked,
3609
+ kf: stampReadyStartingUrl,
3610
+ s5: stampReadyDevBrowserFlag,
3611
+ sJ: readReadyDevAdditions,
3612
+ sf: stampReadyExtensionLoadRefused,
3613
+ td: stampReadyDevBrowserPreference,
3614
+ uz: stampReadyRdpPortError,
3615
+ wy: stampReadyExtensionBaseUrl,
3616
+ xG: stampReadyBrowserUpNotAttached
3617
+ });
3572
3618
  },
3573
3619
  "./browsers/browsers-lib/real-path.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3574
3620
  var node_fs__rspack_import_0 = __webpack_require__("node:fs");
@@ -3635,42 +3681,6 @@ var __webpack_modules__ = {
3635
3681
  kq: isInsidePath
3636
3682
  });
3637
3683
  },
3638
- "./browsers/browsers-lib/rename-with-retry.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3639
- var node_fs__rspack_import_0 = __webpack_require__("node:fs");
3640
- const RETRYABLE_RENAME_CODES = new Set([
3641
- 'EPERM',
3642
- 'EACCES',
3643
- 'EBUSY'
3644
- ]);
3645
- const RENAME_RETRY_DELAYS_MS = [
3646
- 10,
3647
- 20,
3648
- 40,
3649
- 80,
3650
- 160,
3651
- 320
3652
- ];
3653
- function sleepSync(ms) {
3654
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
3655
- }
3656
- function renameSyncWithRetry(from, to, options = {}) {
3657
- const platform = options.platform ?? process.platform;
3658
- const rename = options.rename ?? node_fs__rspack_import_0.renameSync;
3659
- const sleep = options.sleep ?? sleepSync;
3660
- for(let attempt = 0;; attempt++)try {
3661
- rename(from, to);
3662
- return;
3663
- } catch (error) {
3664
- const code = error?.code;
3665
- const delay = RENAME_RETRY_DELAYS_MS[attempt];
3666
- if ('win32' !== platform || !code || !RETRYABLE_RENAME_CODES.has(code) || void 0 === delay) throw error;
3667
- sleep(delay);
3668
- }
3669
- }
3670
- __webpack_require__.d(__webpack_exports__, {}, {
3671
- O: renameSyncWithRetry
3672
- });
3673
- },
3674
3684
  "./browsers/browsers-lib/resolve-live-pid.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3675
3685
  var node_child_process__rspack_import_0 = __webpack_require__("node:child_process");
3676
3686
  var node_fs__rspack_import_1 = __webpack_require__("node:fs");
@@ -3715,10 +3725,14 @@ var __webpack_modules__ = {
3715
3725
  }
3716
3726
  return rows;
3717
3727
  }
3718
- function appendLinuxProfileEnv(rows) {
3728
+ const processTableIo = {
3729
+ run: (bin, args)=>runQuiet(bin, args),
3730
+ readFile: (file)=>node_fs__rspack_import_1.readFileSync(file, 'utf-8')
3731
+ };
3732
+ function appendLinuxProfileEnv(rows, readFile) {
3719
3733
  return rows.map((row)=>{
3720
3734
  try {
3721
- const environ = node_fs__rspack_import_1.readFileSync(`/proc/${row.pid}/environ`, 'utf-8');
3735
+ const environ = readFile(`/proc/${row.pid}/environ`);
3722
3736
  const entry = environ.split('\0').find((pair)=>pair.startsWith('XRE_PROFILE_PATH='));
3723
3737
  return entry ? {
3724
3738
  ...row,
@@ -3729,10 +3743,10 @@ var __webpack_modules__ = {
3729
3743
  }
3730
3744
  });
3731
3745
  }
3732
- function listProcesses(platform = process.platform) {
3746
+ function listProcesses(platform = process.platform, io = processTableIo) {
3733
3747
  if ('win32' === platform) {
3734
3748
  const script = 'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId) $($_.ParentProcessId) $($_.CommandLine)" }';
3735
- const output = runQuiet('powershell.exe', [
3749
+ const output = io.run('powershell.exe', [
3736
3750
  '-NoProfile',
3737
3751
  '-NonInteractive',
3738
3752
  '-Command',
@@ -3741,18 +3755,18 @@ var __webpack_modules__ = {
3741
3755
  return output ? parseProcessRows(output) : [];
3742
3756
  }
3743
3757
  if ('darwin' === platform) {
3744
- const output = runQuiet('ps', [
3758
+ const output = io.run('ps', [
3745
3759
  '-axEo',
3746
3760
  'pid=,ppid=,command='
3747
3761
  ]);
3748
3762
  return output ? parseProcessRows(output) : [];
3749
3763
  }
3750
- const output = runQuiet('ps', [
3764
+ const output = io.run('ps', [
3751
3765
  '-axo',
3752
3766
  'pid=,ppid=,command='
3753
3767
  ]);
3754
3768
  const rows = output ? parseProcessRows(output) : [];
3755
- return 'linux' === platform ? appendLinuxProfileEnv(rows) : rows;
3769
+ return 'linux' === platform ? appendLinuxProfileEnv(rows, io.readFile) : rows;
3756
3770
  }
3757
3771
  function normalizePath(value) {
3758
3772
  return String(value || '').replace(/\\/g, '/').toLowerCase();
@@ -3779,19 +3793,36 @@ var __webpack_modules__ = {
3779
3793
  const cut = trimmed.search(/\s(-|[a-z_][a-z0-9_]*=)/);
3780
3794
  return cut > 0 ? trimmed.slice(0, cut) : trimmed;
3781
3795
  }
3796
+ function generationsBelow(row, ancestorPid, byPid) {
3797
+ let at = row;
3798
+ for(let depth = 1; at && depth <= byPid.size + 1; depth += 1){
3799
+ if (at.ppid === ancestorPid) return depth;
3800
+ at = byPid.get(at.ppid);
3801
+ }
3802
+ return 0;
3803
+ }
3804
+ function isHandoffOf(launcher, row, byPid, platform) {
3805
+ const depth = generationsBelow(row, launcher.pid, byPid);
3806
+ if (depth > 1) return false;
3807
+ return 'win32' === platform || row.command !== launcher.command;
3808
+ }
3782
3809
  function findLiveBrowserPid(input) {
3783
3810
  const profilePath = String(input.profilePath || '').trim();
3784
3811
  const binary = normalizePath(input.binary).trim();
3785
3812
  if (!profilePath || !binary) return null;
3786
3813
  const candidates = input.rows.filter((row)=>executableOf(row.command) === binary && carriesProfile(row.command, profilePath) && !HELPER_PROCESS.test(row.command));
3787
3814
  if (0 === candidates.length) return null;
3815
+ const byPid = new Map(input.rows.map((row)=>[
3816
+ row.pid,
3817
+ row
3818
+ ]));
3788
3819
  const launcher = input.launcherPid ? candidates.find((row)=>row.pid === input.launcherPid) : void 0;
3789
3820
  if (launcher) {
3790
- const twin = candidates.find((row)=>row.pid !== launcher.pid);
3821
+ const platform = input.platform ?? process.platform;
3822
+ const twin = candidates.find((row)=>row.pid !== launcher.pid && isHandoffOf(launcher, row, byPid, platform));
3791
3823
  return twin ? twin.pid : launcher.pid;
3792
3824
  }
3793
- const pids = new Set(candidates.map((row)=>row.pid));
3794
- const roots = candidates.filter((row)=>!pids.has(row.ppid));
3825
+ const roots = candidates.filter((row)=>!candidates.some((other)=>other.pid !== row.pid && generationsBelow(row, other.pid, byPid) > 0));
3795
3826
  return (roots[0] || candidates[0]).pid;
3796
3827
  }
3797
3828
  function isPidAlive(pid) {
@@ -3804,25 +3835,45 @@ var __webpack_modules__ = {
3804
3835
  }
3805
3836
  }
3806
3837
  const PID_START_PROBE_TIMEOUT_MS = 5000;
3807
- function pidStartedAtMs(pid, platform = process.platform) {
3838
+ function pidStartedAtMs(pid, platform = process.platform, timeoutMs = PID_START_PROBE_TIMEOUT_MS) {
3808
3839
  if (!pid || !Number.isInteger(pid) || pid <= 0) return null;
3809
3840
  const output = 'win32' === platform ? runQuiet('powershell.exe', [
3810
3841
  '-NoProfile',
3811
3842
  '-NonInteractive',
3812
3843
  '-Command',
3813
3844
  `[System.Diagnostics.Process]::GetProcessById(${pid}).StartTime.ToUniversalTime().ToString('o')`
3814
- ], PID_START_PROBE_TIMEOUT_MS) : runQuiet('ps', [
3845
+ ], timeoutMs) : runQuiet('ps', [
3815
3846
  '-o',
3816
3847
  'lstart=',
3817
3848
  '-p',
3818
3849
  String(pid)
3819
- ], PID_START_PROBE_TIMEOUT_MS, {
3850
+ ], timeoutMs, {
3820
3851
  ...process.env,
3821
3852
  LC_ALL: 'C'
3822
3853
  });
3823
3854
  const started = Date.parse(String(output || '').trim());
3824
3855
  return Number.isNaN(started) ? null : started;
3825
3856
  }
3857
+ function pidStartId(pid, reader = {}) {
3858
+ if ((reader.platform ?? process.platform) !== 'linux') return;
3859
+ if (!pid || !Number.isInteger(pid) || pid <= 0) return;
3860
+ const readFile = reader.readFile ?? ((file)=>node_fs__rspack_import_1.readFileSync(file, 'utf-8'));
3861
+ try {
3862
+ const stat = readFile(`/proc/${pid}/stat`);
3863
+ const afterName = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
3864
+ const startTicks = afterName[19];
3865
+ const bootId = readFile('/proc/sys/kernel/random/boot_id').trim();
3866
+ if (!/^\d+$/.test(String(startTicks)) || !bootId) return;
3867
+ return `${bootId}:${startTicks}`;
3868
+ } catch {
3869
+ return;
3870
+ }
3871
+ }
3872
+ function sameStartId(stamped, pid, startIdOf = pidStartId) {
3873
+ if ('string' != typeof stamped || !stamped || !pid) return;
3874
+ const current = startIdOf(pid);
3875
+ return current ? current === stamped : void 0;
3876
+ }
3826
3877
  function pidStartedAtIso(pid, platform = process.platform) {
3827
3878
  const started = pidStartedAtMs(pid, platform);
3828
3879
  return null == started ? void 0 : new Date(started).toISOString();
@@ -3840,7 +3891,8 @@ var __webpack_modules__ = {
3840
3891
  profilePath: input.profilePath,
3841
3892
  binary: input.binary,
3842
3893
  launcherPid: input.launcherPid,
3843
- rows: list()
3894
+ rows: list(),
3895
+ platform: input.platform
3844
3896
  });
3845
3897
  if (last && last !== input.launcherPid) break;
3846
3898
  if (attempt < attempts - 1) await sleep(intervalMs);
@@ -3849,10 +3901,12 @@ var __webpack_modules__ = {
3849
3901
  }
3850
3902
  __webpack_require__.d(__webpack_exports__, {}, {
3851
3903
  AW: pidStartedAtMs,
3904
+ Fj: pidStartId,
3852
3905
  O3: listProcesses,
3853
3906
  V5: pidStartedAtIso,
3854
3907
  aA: resolveLiveBrowserPid,
3855
3908
  by: isPidAlive,
3909
+ cJ: sameStartId,
3856
3910
  n7: findLiveBrowserPid
3857
3911
  });
3858
3912
  },
@@ -4443,25 +4497,11 @@ var __webpack_modules__ = {
4443
4497
  var firefox_location2__rspack_import_4 = __webpack_require__("firefox-location2");
4444
4498
  var _helpers_messaging__rspack_import_5 = __webpack_require__("./helpers/messaging.ts");
4445
4499
  var _messages__rspack_import_6 = __webpack_require__("./browsers/browsers-lib/messages.ts");
4500
+ var _process_teardown__rspack_import_7 = __webpack_require__("./browsers/browsers-lib/process-teardown.ts");
4446
4501
  const VERSION_PROBE_TIMEOUT_MS = 10000;
4447
4502
  function normalizeVersion(text) {
4448
4503
  return /(\d+(?:\.\d+){1,3})/.exec(text)?.[1] ?? '';
4449
4504
  }
4450
- function killProbeTree(pid) {
4451
- if (!pid) return;
4452
- try {
4453
- if ('win32' === process.platform) (0, node_child_process__rspack_import_0.spawn)('taskkill', [
4454
- '/PID',
4455
- String(pid),
4456
- '/T',
4457
- '/F'
4458
- ], {
4459
- stdio: 'ignore',
4460
- windowsHide: true
4461
- }).on('error', ()=>{});
4462
- else process.kill(-pid, 'SIGKILL');
4463
- } catch {}
4464
- }
4465
4505
  function readVersionOutput(bin, args, timeoutMs) {
4466
4506
  return new Promise((resolve)=>{
4467
4507
  let output = '';
@@ -4489,7 +4529,7 @@ var __webpack_modules__ = {
4489
4529
  return;
4490
4530
  }
4491
4531
  timer = setTimeout(()=>{
4492
- killProbeTree(child.pid);
4532
+ (0, _process_teardown__rspack_import_7.g8)(child.pid);
4493
4533
  child.stdout?.destroy();
4494
4534
  settle(null);
4495
4535
  }, timeoutMs);
@@ -4906,91 +4946,6 @@ var __webpack_modules__ = {
4906
4946
  K: declaredCode
4907
4947
  });
4908
4948
  },
4909
- "./browsers/run-chromium/cdp/discovery.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4910
- var node_http__rspack_import_0 = __webpack_require__("node:http");
4911
- var node_net__rspack_import_1 = __webpack_require__("node:net");
4912
- var _helpers_messaging__rspack_import_2 = __webpack_require__("./helpers/messaging.ts");
4913
- var _browsers_lib_constants__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/constants.ts");
4914
- var _browsers_lib_messages__rspack_import_4 = __webpack_require__("./browsers/browsers-lib/messages.ts");
4915
- var _coded_error__rspack_import_5 = __webpack_require__("./browsers/run-chromium/cdp/coded-error.ts");
4916
- async function getJson(host, port, path, timeoutMs) {
4917
- return new Promise((resolve, reject)=>{
4918
- const req = node_http__rspack_import_0.request({
4919
- hostname: host,
4920
- port,
4921
- path,
4922
- method: 'GET'
4923
- }, (res)=>{
4924
- if (200 !== res.statusCode) {
4925
- res.resume();
4926
- reject((0, _coded_error__rspack_import_5.A)(_helpers_messaging__rspack_import_2.Lp.E_CDP_NOT_CONNECTED, `CDP endpoint ${path} answered HTTP ${res.statusCode}`));
4927
- return;
4928
- }
4929
- let data = '';
4930
- res.on('data', (chunk)=>data += chunk);
4931
- res.on('end', ()=>{
4932
- try {
4933
- resolve(JSON.parse(data));
4934
- } catch (e) {
4935
- reject(new Error(`Failed to parse ${path}: ${e}`));
4936
- }
4937
- });
4938
- });
4939
- req.on('error', (err)=>reject(err));
4940
- req.setTimeout(timeoutMs, ()=>{
4941
- req.destroy((0, _coded_error__rspack_import_5.A)(_helpers_messaging__rspack_import_2.Lp.E_CDP_TIMEOUT, `CDP endpoint timed out: ${path}`));
4942
- });
4943
- req.end();
4944
- });
4945
- }
4946
- async function discoverWebSocketDebuggerUrl(host, port, isDev, timeoutMs = _browsers_lib_constants__rspack_import_3.C4) {
4947
- try {
4948
- const version = await getJson(host, port, '/json/version', timeoutMs);
4949
- const wsUrl = 'string' == typeof version?.webSocketDebuggerUrl ? version.webSocketDebuggerUrl : void 0;
4950
- if (wsUrl) {
4951
- if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.Ter());
4952
- return wsUrl;
4953
- }
4954
- } catch (error) {
4955
- if (isDev) (0, _helpers_messaging__rspack_import_2.mR)('[CDP] Failed to read /json/version:', String(error?.message || error));
4956
- }
4957
- const targets = await getJson(host, port, '/json', timeoutMs);
4958
- if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.FFz((targets || []).length || 0));
4959
- const pageTarget = (targets || []).find((target)=>{
4960
- const type = String(target?.type || '');
4961
- const ws = 'string' == typeof target?.webSocketDebuggerUrl ? target.webSocketDebuggerUrl : '';
4962
- return 'page' === type && ws;
4963
- });
4964
- const pageWs = 'string' == typeof pageTarget?.webSocketDebuggerUrl ? pageTarget.webSocketDebuggerUrl : '';
4965
- if (pageWs) {
4966
- if (isDev) (0, _helpers_messaging__rspack_import_2._w)(_browsers_lib_messages__rspack_import_4.Ter());
4967
- return pageWs;
4968
- }
4969
- throw (0, _coded_error__rspack_import_5.A)(_helpers_messaging__rspack_import_2.Lp.E_CDP_NOT_CONNECTED, 'No CDP WebSocket URL available');
4970
- }
4971
- async function checkChromeRemoteDebugging(port = 9222, host = '127.0.0.1') {
4972
- return new Promise((resolve)=>{
4973
- const socket = new node_net__rspack_import_1.Socket();
4974
- socket.on('connect', ()=>{
4975
- socket.destroy();
4976
- resolve(true);
4977
- });
4978
- socket.on('error', ()=>{
4979
- resolve(false);
4980
- });
4981
- socket.on('timeout', ()=>{
4982
- socket.destroy();
4983
- resolve(false);
4984
- });
4985
- socket.setTimeout(2000);
4986
- socket.connect(port, host);
4987
- });
4988
- }
4989
- __webpack_require__.d(__webpack_exports__, {}, {
4990
- N: discoverWebSocketDebuggerUrl,
4991
- z: checkChromeRemoteDebugging
4992
- });
4993
- },
4994
4949
  "./browsers/run-chromium/cdp/ensure-developer-mode.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4995
4950
  var node_fs__rspack_import_0 = __webpack_require__("node:fs");
4996
4951
  var node_path__rspack_import_1 = __webpack_require__("node:path");
@@ -5791,7 +5746,6 @@ var __webpack_modules__ = {
5791
5746
  }
5792
5747
  }
5793
5748
  var process_teardown = __webpack_require__("./browsers/browsers-lib/process-teardown.ts");
5794
- var discovery = __webpack_require__("./browsers/run-chromium/cdp/discovery.ts");
5795
5749
  const activeInstances = new Set();
5796
5750
  let globalHandlersInstalled = false;
5797
5751
  function cleanupOne(instance) {
@@ -5940,10 +5894,7 @@ var __webpack_modules__ = {
5940
5894
  detached: false,
5941
5895
  ...isWin ? {
5942
5896
  windowsHide: true
5943
- } : {},
5944
- ...'win32' !== process.platform && {
5945
- group: process.getgid?.()
5946
- }
5897
+ } : {}
5947
5898
  });
5948
5899
  await new Promise((resolve, reject)=>{
5949
5900
  const handleError = (error)=>{
@@ -5999,8 +5950,7 @@ var __webpack_modules__ = {
5999
5950
  claimPort: (startPort)=>(0, debug_port_claim.V)(startPort),
6000
5951
  spawn: spawnChromiumProcess,
6001
5952
  watchSignals: setupProcessSignalHandlers,
6002
- portIsOpen: (port)=>(0, discovery.z)(port),
6003
- loadCdpSetup: ()=>__webpack_require__.e(6).then(__webpack_require__.bind(__webpack_require__, "./browsers/run-chromium/chromium-launch/setup-cdp-after-launch.ts")),
5953
+ loadCdpSetup: ()=>__webpack_require__.e("n").then(__webpack_require__.bind(__webpack_require__, "./browsers/run-chromium/chromium-launch/setup-cdp-after-launch.ts")),
6004
5954
  terminate: process_teardown.Df,
6005
5955
  terminatedByUs: process_teardown.Op,
6006
5956
  sleep: (ms)=>new Promise((resolve)=>setTimeout(resolve, ms)),
@@ -6278,34 +6228,20 @@ var __webpack_modules__ = {
6278
6228
  const isAuthorMode = (0, messaging._o)();
6279
6229
  const resolveChromeLikeBinary = ()=>{
6280
6230
  try {
6281
- try {
6282
- const env = managedEnvFor('chrome');
6283
- const located = (0, locator_env.zJ)(()=>this.deps.locate.chrome(env));
6284
- if (!located) throw new Error(getInstallGuidanceText('chrome'));
6285
- const normalized = normalizePath(located || null);
6286
- if (isUsableBinary(normalized)) {
6287
- if ((0, official_chrome.g)(normalized)) {
6288
- printInstallGuidance(getInstallGuidanceText('chrome'), browser);
6289
- return null;
6290
- }
6291
- return normalized;
6292
- }
6293
- return null;
6294
- } catch (err) {
6295
- const env = managedEnvFor('chrome');
6296
- let candidate = (0, locator_env.zJ)(()=>this.deps.locate.chrome(env));
6297
- const normalized = normalizePath(candidate || null);
6298
- if (normalized) {
6299
- if ((0, official_chrome.g)(normalized)) {
6300
- printInstallGuidance(getInstallGuidanceText('chrome'), browser);
6301
- candidate = null;
6302
- }
6231
+ const env = managedEnvFor('chrome');
6232
+ const located = normalizePath((0, locator_env.zJ)(()=>this.deps.locate.chrome(env)) || null);
6233
+ if (located) {
6234
+ if (!isUsableBinary(located)) return null;
6235
+ if ((0, official_chrome.g)(located)) {
6236
+ printInstallGuidance(getInstallGuidanceText('chrome'), browser);
6237
+ return null;
6303
6238
  }
6304
- const resolved = normalizePath(candidate || null);
6305
- const fallback = resolved || resolveWslFallback();
6306
- if (!fallback) throw err;
6307
- return fallback;
6239
+ return located;
6308
6240
  }
6241
+ const fallback = resolveWslFallback();
6242
+ if (fallback) return fallback;
6243
+ printInstallGuidance(getInstallGuidanceText('chrome'), browser);
6244
+ return null;
6309
6245
  } catch (error) {
6310
6246
  printInstallGuidance(String(error), browser);
6311
6247
  return null;
@@ -6521,8 +6457,7 @@ var __webpack_modules__ = {
6521
6457
  cdpPort: selectedPort
6522
6458
  });
6523
6459
  const enableCdp = opts?.enableCdpPostLaunch !== false;
6524
- const verifyLoadOnly = !enableCdp && chromiumConfig.some((flag)=>flag.startsWith('--remote-debugging-'));
6525
- const usePipe = chromiumConfig.includes('--remote-debugging-pipe');
6460
+ const verifyLoadOnly = !enableCdp;
6526
6461
  const closeHandlerOutputPath = (0, extension_output_path.W)(compilation, chromiumConfig.find((flag)=>flag.startsWith('--load-extension='))) || void 0;
6527
6462
  const launchRunId = (0, ready_stamp.Uf)(closeHandlerOutputPath);
6528
6463
  if (opts?.debugPortClaim && !chromiumConfig.some((flag)=>flag.startsWith('--remote-debugging-port='))) (0, ready_stamp.$V)(closeHandlerOutputPath, launchRunId);
@@ -6547,11 +6482,6 @@ var __webpack_modules__ = {
6547
6482
  portClaim.release();
6548
6483
  return;
6549
6484
  }
6550
- if (!enableCdp && !verifyLoadOnly) heldPredictions.flush();
6551
- if (predictedRefusal && !verifyLoadOnly) {
6552
- portClaim.release();
6553
- this.endRefusedRun(compilation, predictedRefusal.extensionPath);
6554
- }
6555
6485
  this.closeHandlerContext = {
6556
6486
  command: 'development' === compilation.options.mode ? 'dev' : opts?.sessionCommand || 'preview',
6557
6487
  extensionOutputPath: closeHandlerOutputPath,
@@ -6559,7 +6489,7 @@ var __webpack_modules__ = {
6559
6489
  };
6560
6490
  let child;
6561
6491
  try {
6562
- child = await this.launchWithDirectSpawn(browserBinaryLocation, chromiumConfig, usePipe);
6492
+ child = await this.launchWithDirectSpawn(browserBinaryLocation, chromiumConfig);
6563
6493
  } catch (error) {
6564
6494
  portClaim.release();
6565
6495
  throw error;
@@ -6584,21 +6514,12 @@ var __webpack_modules__ = {
6584
6514
  const startupPreference = (0, ensure_startup_new_tab.vh)(chromiumConfig);
6585
6515
  if (startupPreference) (0, ready_stamp.td)(launchOutputPath, startupPreference, this.closeHandlerContext?.runId);
6586
6516
  }
6587
- const pipeStreams = usePipe && child?.stdio?.[3] && child?.stdio?.[4] ? {
6517
+ const pipeStreams = child?.stdio?.[3] && child?.stdio?.[4] ? {
6588
6518
  input: child.stdio[4],
6589
6519
  output: child.stdio[3]
6590
6520
  } : void 0;
6591
6521
  (0, pipe_guard.b)(pipeStreams?.input);
6592
6522
  (0, pipe_guard.b)(pipeStreams?.output);
6593
- if ((enableCdp || verifyLoadOnly) && !pipeStreams) {
6594
- let portReady = false;
6595
- for(let attempt = 0; attempt < 10; attempt++){
6596
- portReady = await this.deps.portIsOpen(selectedPort);
6597
- if (portReady) break;
6598
- await this.deps.sleep(500);
6599
- }
6600
- if (!portReady && (0, messaging._o)()) this.logger.warn?.(`[browser] Debug port ${selectedPort} not bound after spawn. CDP may fail`);
6601
- }
6602
6523
  const reportReady = ()=>{
6603
6524
  if ('development' !== compilation.options.mode) return;
6604
6525
  if (this.didReportReady || this.extensionLoadRefused) return;
@@ -6668,8 +6589,8 @@ var __webpack_modules__ = {
6668
6589
  }
6669
6590
  const message = String(error && error.message);
6670
6591
  const hint = /timed out|did not complete/i.test(message) ? " Chrome likely rejected the extension at launch, open chrome://extensions in the dev browser window for the exact error. Common causes: MV3 content_security_policy with 'unsafe-inline', manifest keys Chrome does not support, or manifest references to missing files. Reload/HMR cannot attach until this is fixed." : '';
6671
- (0, messaging.Gg)(`[browser] ${message}${hint}`);
6672
6592
  await this.waitForBrowserGone(child, 1500);
6593
+ if (!this.browserGone) (0, messaging.Gg)(`[browser] ${message}${hint}`);
6673
6594
  if (this.browserGone) {
6674
6595
  if ('development' === compilation.options.mode) (0, messaging.Gg)(messages.u1t(this.options.browser));
6675
6596
  return;
@@ -6740,19 +6661,15 @@ var __webpack_modules__ = {
6740
6661
  const plan = chromiumLaunchPlan(binary, chromiumConfig, this.options?.startingUrl, this.options?.noOpen);
6741
6662
  logChromiumDryRun(this.options.browser, plan.binary, plan.args, source);
6742
6663
  }
6743
- async launchWithDirectSpawn(binary, chromeFlags, usePipe = false) {
6664
+ async launchWithDirectSpawn(binary, chromeFlags) {
6744
6665
  if ((0, messaging._o)()) this.logger.info(messages.xyq(this.options.browser));
6745
6666
  const { args: launchArgs } = chromiumLaunchPlan(binary, chromeFlags, this.options?.startingUrl, this.options?.noOpen);
6746
- const stdio = usePipe ? [
6667
+ const stdio = [
6747
6668
  'ignore',
6748
6669
  'ignore',
6749
6670
  'pipe',
6750
6671
  'pipe',
6751
6672
  'pipe'
6752
- ] : [
6753
- 'ignore',
6754
- 'ignore',
6755
- 'pipe'
6756
6673
  ];
6757
6674
  const normalizedBinary = (0, wsl_support.f7)(binary);
6758
6675
  try {
@@ -7481,7 +7398,7 @@ var __webpack_modules__ = {
7481
7398
  const child = instance.childRef();
7482
7399
  const live = instance.livePidRef();
7483
7400
  (0, process_teardown.$Y)(child, instance.browser);
7484
- if (live && live.pid !== child?.pid) (0, process_teardown.Qx)(live.pid, instance.browser, live.adoptedAt);
7401
+ if (live && live.pid !== child?.pid) (0, process_teardown.Qx)(live.pid, instance.browser, live.adoptedAt, void 0, live.startId);
7485
7402
  try {
7486
7403
  instance.cleanupOnExit?.();
7487
7404
  } catch {}
@@ -7642,16 +7559,16 @@ var __webpack_modules__ = {
7642
7559
  try {
7643
7560
  let chosenPath = null;
7644
7561
  for (const p of candidateAddonPaths){
7645
- const isManager = /extensions\/[a-z-]+-manager/.test(String(p));
7646
- const isDevtools = /extension-js-devtools/.test(String(p));
7647
- const isThemePath = /extension-js-theme/.test(String(p));
7648
- if (isManager || isDevtools || isThemePath) continue;
7562
+ const segments = external_node_path_.normalize(String(p)).split(/[\\/]+/);
7563
+ const isManager = segments.some((segment, index)=>'extensions' === segment && /^[a-z-]+-manager$/.test(segments[index + 1] ?? ''));
7564
+ const isCompanion = segments.includes('extension-js-devtools') || segments.includes('extension-js-theme');
7565
+ if (isManager || isCompanion) continue;
7649
7566
  const mp = external_node_path_.join(p, 'manifest.json');
7650
7567
  if (external_node_fs_.existsSync(mp)) {
7651
7568
  const mf = JSON.parse(external_node_fs_.readFileSync(mp, 'utf-8'));
7652
7569
  const name = mf?.name || '';
7653
7570
  const isThemeManifest = mf?.theme != null || 'theme' === String(mf?.type || '');
7654
- if ('string' == typeof name && !/Extension\.js DevTools/i.test(name) && !/theme/i.test(name) && !isThemeManifest) {
7571
+ if ('string' == typeof name && !/^Extension\.js (DevTools|Theme)$/i.test(name) && !isThemeManifest) {
7655
7572
  chosenPath = p;
7656
7573
  break;
7657
7574
  }
@@ -8360,6 +8277,7 @@ var __webpack_modules__ = {
8360
8277
  lastError = error;
8361
8278
  if (controller.getAddonInstallRefusalReason()) break;
8362
8279
  if (plugin.isBrowserGone?.()) break;
8280
+ if (i === attempts - 1) break;
8363
8281
  if ((0, messaging._o)()) try {
8364
8282
  const msg = error?.message || String(error);
8365
8283
  (0, messaging.mR)(`[browser] Firefox RDP setup retry ${i + 1}/${attempts}: ${msg}`);
@@ -8375,8 +8293,10 @@ var __webpack_modules__ = {
8375
8293
  return error;
8376
8294
  };
8377
8295
  try {
8378
- if (plugin.rdpController) await retry(()=>plugin.rdpController.ensureLoaded?.(compilation) || Promise.resolve());
8379
- else {
8296
+ if (plugin.rdpController) {
8297
+ const existing = plugin.rdpController;
8298
+ await retry(()=>existing.ensureLoaded(compilation));
8299
+ } else {
8380
8300
  await retry(()=>controller.ensureLoaded(compilation));
8381
8301
  plugin.rdpController = controller;
8382
8302
  }
@@ -8495,6 +8415,7 @@ var __webpack_modules__ = {
8495
8415
  terminatedByUs: process_teardown.Op,
8496
8416
  pidTerminatedByUs: process_teardown.PU,
8497
8417
  isPidAlive: resolve_live_pid.by,
8418
+ pidStartId: (pid)=>(0, resolve_live_pid.Fj)(pid),
8498
8419
  listProcesses: ()=>(0, resolve_live_pid.O3)(),
8499
8420
  resolveLivePid: resolve_live_pid.aA,
8500
8421
  exit: (code)=>process.exit(code)
@@ -8892,7 +8813,8 @@ var __webpack_modules__ = {
8892
8813
  this.pipeChildOutput(child);
8893
8814
  this.disposeProcessHandlers = this.deps.watchSignals(this.host.browser, ()=>this.child, ()=>this.cleanupInstance(), ()=>this.livePid ? {
8894
8815
  pid: this.livePid,
8895
- adoptedAt: this.livePidAdoptedAt
8816
+ adoptedAt: this.livePidAdoptedAt,
8817
+ startId: this.livePidStartId
8896
8818
  } : null, ()=>(0, shared_utils.sW)(this.host.launchProfilePath));
8897
8819
  }
8898
8820
  reportReady(mode) {
@@ -8964,6 +8886,7 @@ var __webpack_modules__ = {
8964
8886
  if (this.livePid === pid) return;
8965
8887
  this.livePid = pid;
8966
8888
  this.livePidAdoptedAt = Date.now();
8889
+ this.livePidStartId = this.deps.pidStartId(pid);
8967
8890
  (0, ready_stamp.M)(this.extensionOutputPath, {
8968
8891
  browserPid: pid,
8969
8892
  launcherPid: this.child?.pid
@@ -9056,6 +8979,7 @@ var __webpack_modules__ = {
9056
8979
  firefox_launch_define_property(this, "launchRunId", void 0);
9057
8980
  firefox_launch_define_property(this, "livePid", null);
9058
8981
  firefox_launch_define_property(this, "livePidAdoptedAt", 0);
8982
+ firefox_launch_define_property(this, "livePidStartId", void 0);
9059
8983
  firefox_launch_define_property(this, "liveExitWatcher", void 0);
9060
8984
  firefox_launch_define_property(this, "browserGone", false);
9061
8985
  firefox_launch_define_property(this, "didReportReady", false);
@@ -9136,8 +9060,8 @@ var __webpack_modules__ = {
9136
9060
  "./browsers/run-firefox/firefox-launch/managed-update-policy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
9137
9061
  var node_fs__rspack_import_0 = __webpack_require__("node:fs");
9138
9062
  var node_path__rspack_import_1 = __webpack_require__("node:path");
9063
+ var _develop_lib_rename_with_retry__rspack_import_3 = __webpack_require__("../develop/lib/rename-with-retry.ts");
9139
9064
  __webpack_require__("./browsers/browsers-lib/output-binaries-resolver.ts");
9140
- var _browsers_lib_rename_with_retry__rspack_import_3 = __webpack_require__("./browsers/browsers-lib/rename-with-retry.ts");
9141
9065
  const MANAGED_GECKO_POLICIES = {
9142
9066
  DisableAppUpdate: true
9143
9067
  };
@@ -9218,7 +9142,7 @@ var __webpack_modules__ = {
9218
9142
  recursive: true
9219
9143
  });
9220
9144
  fs.writeFileSync(tempPath, `${JSON.stringify(next, null, 2)}\n`, 'utf8');
9221
- (0, _browsers_lib_rename_with_retry__rspack_import_3.O)(tempPath, policyPath, {
9145
+ (0, _develop_lib_rename_with_retry__rspack_import_3.O)(tempPath, policyPath, {
9222
9146
  rename: (from, to)=>fs.renameSync(from, to),
9223
9147
  platform,
9224
9148
  ...opts.retry
@@ -9760,8 +9684,8 @@ var __webpack_modules__ = {
9760
9684
  __webpack_require__.d(__webpack_exports__, {
9761
9685
  G: ()=>MessagingClient
9762
9686
  });
9763
- const external_node_events_namespaceObject = require("node:events");
9764
- var external_node_events_default = /*#__PURE__*/ __webpack_require__.n(external_node_events_namespaceObject);
9687
+ var external_node_events_ = __webpack_require__("node:events");
9688
+ var external_node_events_default = /*#__PURE__*/ __webpack_require__.n(external_node_events_);
9765
9689
  var messaging = __webpack_require__("./helpers/messaging.ts");
9766
9690
  var messages = __webpack_require__("./browsers/browsers-lib/messages.ts");
9767
9691
  var evaluate = __webpack_require__("./browsers/run-firefox/rdp/remote-firefox/evaluate.ts");
@@ -10192,6 +10116,8 @@ var __webpack_modules__ = {
10192
10116
  noOpen: opts.noOpen,
10193
10117
  profile: opts.profile,
10194
10118
  persistProfile: opts.persistProfile,
10119
+ keepProfileChanges: opts.keepProfileChanges,
10120
+ copyFromProfile: opts.copyFromProfile,
10195
10121
  preferences: opts.preferences,
10196
10122
  browserFlags: opts.browserFlags,
10197
10123
  excludeBrowserFlags: opts.excludeBrowserFlags,
@@ -10218,6 +10144,8 @@ var __webpack_modules__ = {
10218
10144
  noOpen: pluginOptions.noOpen,
10219
10145
  profile: pluginOptions.profile,
10220
10146
  persistProfile: pluginOptions.persistProfile,
10147
+ keepProfileChanges: pluginOptions.keepProfileChanges,
10148
+ copyFromProfile: pluginOptions.copyFromProfile,
10221
10149
  preferences: pluginOptions.preferences,
10222
10150
  browserFlags: pluginOptions.browserFlags,
10223
10151
  excludeBrowserFlags: pluginOptions.excludeBrowserFlags,
@@ -10243,6 +10171,9 @@ var __webpack_modules__ = {
10243
10171
  browser: pluginOptions.browser,
10244
10172
  profile: pluginOptions.profile,
10245
10173
  profileSource: opts.profileSource,
10174
+ persistProfile: pluginOptions.persistProfile,
10175
+ keepProfileChanges: pluginOptions.keepProfileChanges,
10176
+ copyFromProfile: pluginOptions.copyFromProfile,
10246
10177
  preferences: pluginOptions.preferences,
10247
10178
  browserFlags: pluginOptions.browserFlags,
10248
10179
  startingUrl: pluginOptions.startingUrl,
@@ -10314,6 +10245,19 @@ var __webpack_modules__ = {
10314
10245
  ];
10315
10246
  const EXIT_DEADLINE_MS = 5500;
10316
10247
  const EXIT_POLL_MS = 50;
10248
+ const BROWSER_GONE_POLL_MS = 250;
10249
+ function untilBrowserGone(launcher) {
10250
+ return new Promise((resolve)=>{
10251
+ const isGone = ()=>!launcher.spawnedBrowser || launcher.browserClosed;
10252
+ if (isGone()) return void resolve();
10253
+ const beat = setInterval(()=>{
10254
+ if (!isGone()) return;
10255
+ clearInterval(beat);
10256
+ resolve();
10257
+ }, BROWSER_GONE_POLL_MS);
10258
+ beat.unref?.();
10259
+ });
10260
+ }
10317
10261
  async function runOnlyPreviewBrowser(opts) {
10318
10262
  if (!(0, _browsers_lib_browser_family__rspack_import_3.rG)(opts.browser) && !(0, _browsers_lib_browser_family__rspack_import_3.M_)(opts.browser)) throw Object.assign(new Error((0, _browsers_lib_messages__rspack_import_7.TbS)(String(opts.browser))), {
10319
10263
  code: _helpers_messaging__rspack_import_1.Lp.E_UNSUPPORTED_BROWSER
@@ -10402,7 +10346,9 @@ var __webpack_modules__ = {
10402
10346
  if (!launcher.spawnedBrowser) (0, _browsers_lib_ready_stamp__rspack_import_10.$V)(opts.outPath, runId);
10403
10347
  throw asLaunchFailure(error, opts.browser, launcher.spawnedBrowser);
10404
10348
  }
10405
- return;
10349
+ return {
10350
+ ended: untilBrowserGone(launcher)
10351
+ };
10406
10352
  }
10407
10353
  const ctx = (0, _run_firefox_firefox_context__rspack_import_17.D)();
10408
10354
  const launcher = new _run_firefox_firefox_launch__rspack_import_15.c(buildPreviewFirefoxOptions(opts), ctx);
@@ -10418,6 +10364,7 @@ var __webpack_modules__ = {
10418
10364
  throw asLaunchFailure(error, opts.browser, launcher.spawnedBrowser);
10419
10365
  }
10420
10366
  return {
10367
+ ended: untilBrowserGone(launcher),
10421
10368
  async wakeBackground () {
10422
10369
  const controller = ctx.getController?.();
10423
10370
  if (!controller) return false;
@@ -10573,10 +10520,10 @@ var __webpack_modules__ = {
10573
10520
  process.on('SIGHUP', quitAllOnSignal);
10574
10521
  process.on('exit', quitAllOnExit);
10575
10522
  }
10576
- async function rememberRaisedContainerApp(tools, appPath, before) {
10577
- const deadline = Date.now() + RAISE_WAIT_MS;
10523
+ async function rememberRaisedContainerApp(tools, appPath, before, waitMs = RAISE_WAIT_MS) {
10524
+ const deadline = Date.now() + waitMs;
10578
10525
  let raised = [];
10579
- while(Date.now() < deadline){
10526
+ for(let read = 0; 0 === read || Date.now() < deadline; read += 1){
10580
10527
  raised = (await tools.listAppPids(appPath)).filter((pid)=>!before.has(pid));
10581
10528
  if (raised.length > 0) break;
10582
10529
  await sleep(POLL_MS);
@@ -11851,7 +11798,7 @@ var __webpack_modules__ = {
11851
11798
  const appex = target === appPath ? (0, safari_ui.rB)(appPath) : null;
11852
11799
  if (appex) await tools.pluginkitAdd(appex);
11853
11800
  if (appex && host.announceDevReady && !isSigned) keepRowRegistered(tools, appex, `${config.bundleIdentifier}.Extension`, host.rowWatchMs);
11854
- if (host.announceDevReady && target === appPath) await rememberRaisedContainerApp(tools, appPath, appsBefore);
11801
+ if (host.announceDevReady && target === appPath) await rememberRaisedContainerApp(tools, appPath, appsBefore, host.raiseWaitMs);
11855
11802
  if (config.safariBinary) await tools.openSafari(config.safariBinary);
11856
11803
  const raisedBundleId = config.safariBinary ? 'com.apple.Safari' : config.bundleIdentifier;
11857
11804
  const browserPid = await tools.resolvePid(raisedBundleId);
@@ -13415,26 +13362,9 @@ function describeButton(b) {
13415
13362
  });
13416
13363
  },
13417
13364
  "./helpers/messaging.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
13418
- __webpack_require__.d(__webpack_exports__, {
13419
- Lp: ()=>CODES,
13420
- T_: ()=>artifactNoun,
13421
- QZ: ()=>browserDisplayName,
13422
- A6: ()=>browserRowValue,
13423
- Nr: ()=>card,
13424
- F7: ()=>cdpFaultWarningCode,
13425
- od: ()=>claimCardKey,
13426
- Qi: ()=>hasChannelPrefix,
13427
- Gg: ()=>humanError,
13428
- _w: ()=>humanLine,
13429
- mR: ()=>humanWarn,
13430
- VR: ()=>isCardKeyClaimed,
13431
- _o: ()=>isDebug,
13432
- Pl: ()=>prefix,
13433
- UT: ()=>stripChannelPrefix
13434
- });
13435
- const external_node_util_namespaceObject = require("node:util");
13436
- var external_pintor_ = __webpack_require__("pintor");
13437
- var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_);
13365
+ var node_util__rspack_import_0 = __webpack_require__("node:util");
13366
+ var pintor__rspack_import_1 = __webpack_require__("pintor");
13367
+ var pintor__rspack_import_1_default = /*#__PURE__*/ __webpack_require__.n(pintor__rspack_import_1);
13438
13368
  const GLYPH = '⏵⏵⏵';
13439
13369
  const DEBUG_GLYPH = '···';
13440
13370
  const DEBUG_VALUES = new Set([
@@ -13459,8 +13389,8 @@ function describeButton(b) {
13459
13389
  return new RegExp(`^(?:build )?${word}\\b`, 'i').test(text.replace(ANSI_PATTERN, '').trimStart());
13460
13390
  }
13461
13391
  function prefix(type, text) {
13462
- const paint = 'error' === type ? external_pintor_default().red : 'warn' === type ? external_pintor_default().brightYellow : 'success' === type ? external_pintor_default().green : external_pintor_default().gray;
13463
- if ('debug' === type) return external_pintor_default().dim(external_pintor_default().gray(DEBUG_GLYPH));
13392
+ const paint = 'error' === type ? pintor__rspack_import_1_default().red : 'warn' === type ? pintor__rspack_import_1_default().brightYellow : 'success' === type ? pintor__rspack_import_1_default().green : pintor__rspack_import_1_default().gray;
13393
+ if ('debug' === type) return pintor__rspack_import_1_default().dim(pintor__rspack_import_1_default().gray(DEBUG_GLYPH));
13464
13394
  const glyph = paint(GLYPH);
13465
13395
  const word = SEVERITY_WORDS[type];
13466
13396
  if (!word || glyph !== GLYPH) return glyph;
@@ -13485,7 +13415,7 @@ function describeButton(b) {
13485
13415
  let silentBuilds = 0;
13486
13416
  function humanLine(...parts) {
13487
13417
  if (silentBuilds > 0) return;
13488
- if (isMachineOutput()) return void process.stderr.write(`${(0, external_node_util_namespaceObject.format)(...parts)}\n`);
13418
+ if (isMachineOutput()) return void process.stderr.write(`${(0, node_util__rspack_import_0.format)(...parts)}\n`);
13489
13419
  console.log(...parts);
13490
13420
  }
13491
13421
  function humanWarn(...parts) {
@@ -13500,10 +13430,10 @@ function describeButton(b) {
13500
13430
  function card(input = {}) {
13501
13431
  const version = String(input.version || '').trim();
13502
13432
  const suffix = String(input.suffix || '').trim();
13503
- const head = ` 🧩 Extension.js` + (version ? ` ${external_pintor_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
13433
+ const head = ` 🧩 Extension.js` + (version ? ` ${pintor__rspack_import_1_default().gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
13504
13434
  const body = (input.rows || []).filter((row)=>String(row.value || '').trim().length > 0).slice(0, MAX_CARD_ROWS).map((row)=>{
13505
13435
  const label = row.label.padEnd(CARD_LABEL_WIDTH);
13506
- return ` ${label}${external_pintor_default().gray(String(row.value).trim())}`;
13436
+ return ` ${label}${pintor__rspack_import_1_default().gray(String(row.value).trim())}`;
13507
13437
  });
13508
13438
  return [
13509
13439
  head,
@@ -13564,6 +13494,7 @@ function describeButton(b) {
13564
13494
  E_PROJECT_NOT_FOUND: 'E_PROJECT_NOT_FOUND',
13565
13495
  E_MANIFEST_NOT_FOUND: 'E_MANIFEST_NOT_FOUND',
13566
13496
  E_MANIFEST_INVALID: 'E_MANIFEST_INVALID',
13497
+ E_PACKAGE_JSON_INVALID: 'E_PACKAGE_JSON_INVALID',
13567
13498
  E_FIRST_COMPILE: 'E_FIRST_COMPILE',
13568
13499
  E_COMPILE: 'E_COMPILE',
13569
13500
  E_BROWSER_NOT_FOUND: 'E_BROWSER_NOT_FOUND',
@@ -13623,6 +13554,7 @@ function describeButton(b) {
13623
13554
  E_OPTIONAL_DEP_UNKNOWN: 'E_OPTIONAL_DEP_UNKNOWN',
13624
13555
  E_COMPANION_EXTENSION_PATH: 'E_COMPANION_EXTENSION_PATH',
13625
13556
  E_MANIFEST_IN_PUBLIC: 'E_MANIFEST_IN_PUBLIC',
13557
+ E_FOLDER_UNREADABLE: 'E_FOLDER_UNREADABLE',
13626
13558
  E_RUNTIME_NOT_FOUND: 'E_RUNTIME_NOT_FOUND',
13627
13559
  E_COMPILE_FATAL: 'E_COMPILE_FATAL',
13628
13560
  E_MODULE_NOT_FOUND: 'E_MODULE_NOT_FOUND',
@@ -13675,6 +13607,7 @@ function describeButton(b) {
13675
13607
  E_PROJECT_LAYOUT: 'E_PROJECT_LAYOUT',
13676
13608
  E_ASSET_IMPORT_SHAPE: 'E_ASSET_IMPORT_SHAPE',
13677
13609
  E_ENV_FILE_UNREADABLE: 'E_ENV_FILE_UNREADABLE',
13610
+ E_INLINE_SCRIPT_SYNTAX: 'E_INLINE_SCRIPT_SYNTAX',
13678
13611
  W_MANAGED_DEP_CONFLICT: 'W_MANAGED_DEP_CONFLICT',
13679
13612
  W_TYPES_EMIT: 'W_TYPES_EMIT',
13680
13613
  W_MODULE_NOT_FOUND: 'W_MODULE_NOT_FOUND',
@@ -13718,7 +13651,14 @@ function describeButton(b) {
13718
13651
  W_SCRIPT_WORLD_UNKNOWN: 'W_SCRIPT_WORLD_UNKNOWN',
13719
13652
  W_ENV_NAME_RESERVED: 'W_ENV_NAME_RESERVED',
13720
13653
  W_COMPANION_EXTENSION_PATH: 'W_COMPANION_EXTENSION_PATH',
13721
- W_ENV_DEFINE_WRITTEN: 'W_ENV_DEFINE_WRITTEN'
13654
+ W_ENV_DEFINE_WRITTEN: 'W_ENV_DEFINE_WRITTEN',
13655
+ W_ENV_ASSET_NOT_UTF8: 'W_ENV_ASSET_NOT_UTF8',
13656
+ W_HTML_NOT_UTF8: 'W_HTML_NOT_UTF8',
13657
+ W_RELOAD_NOT_APPLIED: 'W_RELOAD_NOT_APPLIED',
13658
+ W_CONTENT_SCRIPT_NOT_INJECTED: 'W_CONTENT_SCRIPT_NOT_INJECTED',
13659
+ W_CONTENT_SCRIPT_CLEANUP: 'W_CONTENT_SCRIPT_CLEANUP',
13660
+ W_CONTENT_SCRIPT_MOUNT: 'W_CONTENT_SCRIPT_MOUNT',
13661
+ W_DEV_SERVER_SOCKET: 'W_DEV_SERVER_SOCKET'
13722
13662
  };
13723
13663
  const CDP_FAULT_STEMS = [
13724
13664
  'CDP_NOT_CONNECTED',
@@ -13732,6 +13672,23 @@ function describeButton(b) {
13732
13672
  const known = CDP_FAULT_STEMS.find((name)=>name === stem);
13733
13673
  return known ? CODES[`W_${known}`] : CODES.W_CDP_OP_FAILED;
13734
13674
  }
13675
+ __webpack_require__.d(__webpack_exports__, {}, {
13676
+ A6: browserRowValue,
13677
+ F7: cdpFaultWarningCode,
13678
+ Gg: humanError,
13679
+ Lp: CODES,
13680
+ Nr: card,
13681
+ Pl: prefix,
13682
+ QZ: browserDisplayName,
13683
+ Qi: hasChannelPrefix,
13684
+ T_: artifactNoun,
13685
+ UT: stripChannelPrefix,
13686
+ VR: isCardKeyClaimed,
13687
+ _o: isDebug,
13688
+ _w: humanLine,
13689
+ mR: humanWarn,
13690
+ od: claimCardKey
13691
+ });
13735
13692
  },
13736
13693
  "./helpers/vendors.ts" () {
13737
13694
  const EMULATOR_BROWSER_TARGET = 'chromium-emulator';
@@ -13762,7 +13719,6 @@ function describeButton(b) {
13762
13719
  EMULATOR_BROWSER_TARGET
13763
13720
  ];
13764
13721
  SUPPORTED_BROWSER_TARGETS.join(' | ');
13765
- "chrome | chromium | edge | firefox | safari";
13766
13722
  SUPPORTED_BROWSER_TARGETS.filter((target)=>!isSafariVendor(target) && !isEmulatorVendor(target)).join(' | ');
13767
13723
  const MANAGED_INSTALL_TARGETS = [
13768
13724
  'chrome',
@@ -13798,6 +13754,9 @@ function describeButton(b) {
13798
13754
  "node:crypto" (module) {
13799
13755
  module.exports = require("node:crypto");
13800
13756
  },
13757
+ "node:events" (module) {
13758
+ module.exports = require("node:events");
13759
+ },
13801
13760
  "node:fs" (module) {
13802
13761
  module.exports = require("node:fs");
13803
13762
  },
@@ -13819,6 +13778,9 @@ function describeButton(b) {
13819
13778
  "node:readline" (module) {
13820
13779
  module.exports = require("node:readline");
13821
13780
  },
13781
+ "node:util" (module) {
13782
+ module.exports = require("node:util");
13783
+ },
13822
13784
  pintor (module) {
13823
13785
  module.exports = require("pintor");
13824
13786
  },