@webority/sandbox-gate 0.179.0 → 0.181.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # @webority/sandbox-gate
2
- The gate runner the Webority repos share: sandbox boot, a parallel task runner, gate Chrome ownership, accessibility trees and changed-file helpers.
2
+ The gate runner the Webority repos share: sandbox boot, a parallel task runner, gate Chrome ownership, accessibility trees and changed-file helpers. It also ships a Vite preset for phone browser demos, on its `phone-web` subpath.
3
3
  - `derivePorts(root, count)`: the port block a checkout owns.
4
4
  - `runTasks(tasks, options)`: runs tasks in parallel and buffers each one's output; `options.maxParallel` caps how many run at once, and `options.write` receives the step headers and each task's output (standard output when unset). Every task states `limitMs`. Past it the task is reported SLOW: it keeps running, its result carries `slow`, and the gate result is unchanged. At 3 times the limit (`HUNG_LIMIT_MULTIPLIER`) the runner ends the task's process tree and returns it with `hung` and exit code 124 (`HUNG_EXIT_CODE`). Limits count time the gate ran, not wall time: while a task runs, a 5 s tick watches for gaps over 30 s (the machine slept or the process was stopped), moves every running limit by the gap, and reports it on the task's result as `pausedMs`; `pausedMs()` gives the gate's total. `stopRunning(reason)` ends every running task with exit code `STOPPED_EXIT_CODE` and returns their labels. A script that handles SIGINT or SIGTERM calls it, then ends with `process.exit`.
5
5
  - `bootSandboxes(options)`: starts the sandboxes on the given ports.
6
6
  - `stopAll(options)`: stops the children, frees their ports and reaps gate Chrome. Every port is tried even when one fails; the failures are then thrown together as one `AggregateError`.
7
7
  - `describeSandboxDeath(death, readLog?)`: the message for a sandbox that ended before the run did (from `bootSandboxes(...).deaths()`), with the last lines of its log; `logEvidence(text)` picks those lines.
8
8
  - `accessibilityTree(page, options)`: the flat accessibility tree of an element.
9
- Node only; not for browsers.
9
+ The main entry is Node only; not for browsers. The `phone-web` subpath is a bundler config for the phone browser demos.
10
+
11
+ ## `@webority/sandbox-gate/phone-web`
12
+ The bundler config for the phone sandbox browser demos. `createPhoneWebConfig(options)` returns a config that the demo merges its own keys over. It holds the fixes the phone libraries need to run in a browser, and the three stubs that stand in for their native imports: `empty`, `kvStore` and `nullNativeModule`, in `src/phoneWeb/stubs/`. A demo keeps no copy of them.
13
+
14
+ Options:
15
+ - `root`: the demo folder, which is the bundler root. The bundler plugins resolve from its `package.json`.
16
+ - `repoRoot`: the repo root. The dev server may serve files from it.
17
+ - `phoneLibraries`: where the demo reads the phone libraries from. Its `kind` is one of two:
18
+ - `"source"`, with `packagesDir` (the folder holding `mobile-core/`, `mobile-ui/` and `web-core/`, each read from its `src/`) and `singletonsDir` (the `node_modules` folder holding the one copy of each shared package).
19
+ - `"published"`, for a demo that installs the libraries and reads their `lib/module` output.
20
+
21
+ An unknown kind, a `root` with no `package.json`, or a missing `packagesDir` or `singletonsDir` throws when the config loads. The error names the option and the path.
@@ -0,0 +1 @@
1
+ export declare const manualChunks: (id: string) => string | null;
@@ -0,0 +1,14 @@
1
+ import type { UserConfig } from "vite";
2
+ export type PhoneLibraries = {
3
+ kind: "source";
4
+ packagesDir: string;
5
+ singletonsDir: string;
6
+ } | {
7
+ kind: "published";
8
+ };
9
+ export interface PhoneWebConfigOptions {
10
+ root: string;
11
+ repoRoot: string;
12
+ phoneLibraries: PhoneLibraries;
13
+ }
14
+ export declare function createPhoneWebConfig(options: PhoneWebConfigOptions): Promise<UserConfig>;
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"node:module";import{existsSync as t}from"node:fs";import n from"node:path";import{readFile as r}from"node:fs/promises";import{pathToFileURL as i}from"node:url";var a=/\/node_modules\/(react|react-dom|react-native-web)\//,o=/\/AppIcon\/catalog\/([^/]+)\/([a-z])[^/]*\.g\.(?:ts|js)$/,s=/\/AppIcon\/variants\.g\.(?:ts|js)$/,c=e=>{let t=e.replace(/\?.*$/,``),n=o.exec(t),r=n?.[1],i=n?.[2];return r!==void 0&&i!==void 0?`icons-${r}-${i<=`m`?`a-m`:`n-z`}`:s.test(t)?`icons-variants`:a.test(t)?`vendor`:null},l=`@webority/sandbox-gate/phone-web`,u=e=>n.join(import.meta.dirname,`stubs`,e+n.extname(import.meta.filename)),d=e=>/\/specs\/NativePdfRasterizer(\.js)?$/.test(e),f=(e,t)=>/\/ts-declarations\/global(\.js)?$/.test(e)&&!!t?.includes(`/expo-modules-core/`),p=(e,t)=>e===`../fabric/NativeSvgSoundModule`&&!!t?.includes(`/react-native-svg/`),m=/[\\/]@webority[\\/]mobile-ui[\\/]lib[\\/].*\.js$/,h=e=>typeof e==`function`,g=e=>typeof e==`function`,_=e=>typeof e==`object`&&e&&`default`in e?e.default:void 0,v=(e,t)=>typeof e==`object`&&!!e&&t in e,y=(e,t)=>v(e,t)?e[t]:void 0,b=(t,r)=>{try{return e(n.join(t,`package.json`)).resolve(r)}catch(e){throw Error(`${l}: ${r} is not installed for the phone web demo at ${t}`,{cause:e})}},x=async(e,t)=>{let n=_(await import(i(b(e,t)).href));if(!h(n))throw Error(`${l}: ${t} installed for the phone web demo at ${e} has no default plugin function`);return n},S=async e=>{let t=y(_(await import(i(b(e,`@babel/core`)).href)),`transformAsync`);if(!g(t))throw Error(`${l}: @babel/core installed for the phone web demo at ${e} exports no transformAsync`);return t},C=()=>({name:`webority-native-resolution`,enforce:`pre`,async resolveId(e,t,n){if(d(e))return u(`nullNativeModule`);if(f(e,t))return u(`empty`);if(p(e,t))return u(`nullNativeModule`);let r=await this.resolve(e,t,{...n,skipSelf:!0});return r?.id.includes(`/expo-modules-core/`)?{...r,moduleSideEffects:!0}:r}}),w=e=>({name:`webority-dev-expo-runtime`,resolveId(t,n){return t===`./Expo.fx`&&n?.includes(`/node_modules/expo/src/`)||f(t,n)?u(`empty`):p(t,n)||e!==void 0&&d(t)?u(`nullNativeModule`):null},async load(t){if(e===void 0||!m.test(t))return null;let n=await r(t,`utf8`);if(!n.includes(`useAnimatedStyle`)&&!n.includes(`useDerivedValue`))return null;let i=await e.transformAsync(n,{filename:t,babelrc:!1,configFile:!1,plugins:[e.reanimatedPlugin]});if(!i?.code)throw Error(`${l}: the Reanimated plugin returned no code for ${t}`);return i.code}}),T=[`react-native-safe-area-context`,`react-native-gesture-handler`,`react-native-keyboard-controller`,`react-native-reanimated`,`react-native-worklets`],E=[`.web.tsx`,`.web.ts`,`.web.jsx`,`.web.js`,`.tsx`,`.ts`,`.jsx`,`.js`],D=[`.web.js`,`.web.ts`,`.web.tsx`,`.js`,`.ts`,`.tsx`],O=(e,n)=>{if(!t(e))throw Error(`${l}: ${n} ${e} does not exist`)};async function k(e){let{root:r,repoRoot:i}=e;if(!t(n.join(r,`package.json`)))throw Error(`${l}: root ${r} has no package.json; pass the demo folder`);let a=e.phoneLibraries,o=[`react`,`react-dom`,`react-native-web`,...T],s=[],d=[];if(a.kind===`source`){let{packagesDir:e,singletonsDir:t}=a;O(e,`phoneLibraries.packagesDir`),O(t,`phoneLibraries.singletonsDir`),s=T.map(e=>({find:e,replacement:n.resolve(t,e)})),d=[{find:/^@webority\/mobile-(core|ui)$/,replacement:n.resolve(e,`mobile-$1/src/index.ts`)},{find:/^@webority\/mobile-(core|ui)\/(.+)$/,replacement:n.resolve(e,`mobile-$1/src/$2`)},{find:/^@webority\/web-core\/(.+)$/,replacement:n.resolve(e,`web-core/src/$1`)}]}else if(a.kind===`published`)o.push(`@webority/mobile-ui`,`@webority/mobile-core`);else throw Error(`${l}: phoneLibraries.kind for the demo at ${r} must be "source" or "published", got ${JSON.stringify(a)}`);let f=b(r,`react-native-reanimated/plugin`),p=a.kind===`published`?{transformAsync:await S(r),reanimatedPlugin:f}:void 0,m=await x(r,`@vitejs/plugin-react`),h=await x(r,`@rolldown/plugin-babel`);return{plugins:[C(),m(),h({cwd:i,plugins:[f]})],resolve:{dedupe:o,extensions:E,alias:[{find:`react-native`,replacement:n.resolve(r,`node_modules/react-native-web`)},{find:`react`,replacement:n.resolve(r,`node_modules/react`)},{find:`react-dom`,replacement:n.resolve(r,`node_modules/react-dom`)},...s,{find:/^expo-sqlite\/kv-store$/,replacement:u(`kvStore`)},{find:/^@react-native\/assets-registry\/registry$/,replacement:n.resolve(r,`node_modules/react-native-web/dist/modules/AssetRegistry/index.js`)},...d]},optimizeDeps:{rolldownOptions:{plugins:[w(p)],resolve:{extensions:D}}},define:{__DEV__:JSON.stringify(process.env.NODE_ENV!==`production`),"process.env.EXPO_OS":JSON.stringify(`web`),"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV??`production`),global:`globalThis`},server:{fs:{allow:[i]}},build:{chunkSizeWarningLimit:700,rolldownOptions:{output:{manualChunks:c}}}}}export{k as createPhoneWebConfig};
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "vite";
2
+ export type PluginFactory = (options?: Record<string, unknown>) => Plugin;
3
+ export type Transform = (code: string, options: Record<string, unknown>) => Promise<{
4
+ code?: string | null;
5
+ } | null>;
6
+ export type MobileUiSupport = {
7
+ transformAsync: Transform;
8
+ reanimatedPlugin: string;
9
+ };
10
+ export type StubName = "empty" | "kvStore" | "nullNativeModule";
11
+ export declare const PRESET = "@webority/sandbox-gate/phone-web";
12
+ export declare const stubPath: (name: StubName) => string;
13
+ export declare const isPdfRasterizerSpec: (source: string) => boolean;
14
+ export declare const resolveFromRoot: (root: string, specifier: string) => string;
15
+ export declare const loadPluginFactory: (root: string, specifier: string) => Promise<PluginFactory>;
16
+ export declare const loadTransformAsync: (root: string) => Promise<Transform>;
17
+ export declare const nativeResolutionPlugin: () => Plugin;
18
+ export declare const devRuntimePlugin: (mobileUi: MobileUiSupport | undefined) => Plugin;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,12 @@
1
+ type KvStore = {
2
+ getItem(key: string): Promise<string | null>;
3
+ setItem(key: string, value: string): Promise<void>;
4
+ removeItem(key: string): Promise<void>;
5
+ clear(): Promise<void>;
6
+ getAllKeys(): Promise<string[]>;
7
+ multiGet(keys: string[]): Promise<[string, string | null][]>;
8
+ multiSet(pairs: [string, string][]): Promise<void>;
9
+ multiRemove(keys: string[]): Promise<void>;
10
+ };
11
+ declare const kvStore: KvStore;
12
+ export default kvStore;
@@ -0,0 +1 @@
1
+ var e=/* @__PURE__ */ new Map,t=()=>typeof localStorage>`u`?void 0:localStorage,n=n=>{try{return t()?.getItem(n)??e.get(n)??null}catch(t){if(!(t instanceof DOMException))throw t;return e.get(n)??null}},r=(n,r)=>{e.set(n,r);try{t()?.setItem(n,r)}catch(e){if(!(e instanceof DOMException))throw e}},i=n=>{e.delete(n);try{t()?.removeItem(n)}catch(e){if(!(e instanceof DOMException))throw e}},a={getItem:async e=>n(e),setItem:async(e,t)=>r(e,t),removeItem:async e=>i(e),clear:async()=>{e.clear();try{t()?.clear()}catch(e){if(!(e instanceof DOMException))throw e}},getAllKeys:async()=>[...e.keys()],multiGet:async e=>e.map(e=>[e,n(e)]),multiSet:async e=>{for(let[t,n]of e)r(t,n)},multiRemove:async e=>{for(let t of e)i(t)}};export{a as default};
@@ -0,0 +1,2 @@
1
+ declare const NullNativeModule: null;
2
+ export default NullNativeModule;
@@ -0,0 +1 @@
1
+ var e=null;export{e as default};
package/dist/ports.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { type ForeignListener } from "./process.ts";
1
2
  export declare const SANDBOX_PORT_RANGE: {
2
3
  readonly first: 7000;
3
4
  readonly end: 10000;
4
5
  };
5
6
  export declare const RESERVED_PORTS: readonly number[];
6
- export declare function derivePorts(root: string, count?: number): number[];
7
+ export declare function derivePorts(root: string, count?: number, foreignListeners?: (ports: readonly number[]) => ForeignListener[]): number[];
package/dist/process.d.ts CHANGED
@@ -8,11 +8,44 @@ export declare class GateCommandError extends Error {
8
8
  }
9
9
  /** Run a helper command hidden, to completion; throws GateCommandError when it cannot start, outgrows maxBuffer or exits non-zero. */
10
10
  export declare function runChecked(command: string, args: string[], okStatuses?: number[], maxBuffer?: number): string;
11
- /** Kill `pid` (and on Windows its tree); a kill that fails while the process is still alive throws. */
12
- export declare function killPidHard(pid: string): void;
11
+ /** The account that owns a process: its uid and its name. */
12
+ export interface ProcessOwner {
13
+ uid: number;
14
+ name: string;
15
+ }
16
+ /** The owner of `pid` on Linux and macOS, or null when no process has that pid. */
17
+ export declare function processOwner(pid: string): ProcessOwner | null;
18
+ /** What a kill that exited non-zero means: the process left, it belongs to another account, or one of ours survived. */
19
+ export type KillFailure = "gone" | "foreign" | "survived";
20
+ /** Reads a failed kill. Only another account's live process is foreign; a live process of our own account is a survivor. */
21
+ export declare function readKillFailure({ alive, owner, myUid }: {
22
+ alive: boolean;
23
+ owner: ProcessOwner | null;
24
+ myUid: number;
25
+ }): KillFailure;
26
+ /** The result of killPidHard: the process ended, or it belongs to another account and was left running. */
27
+ export type KillResult = {
28
+ outcome: "ended";
29
+ } | {
30
+ outcome: "foreign";
31
+ owner: ProcessOwner;
32
+ };
33
+ /** Kill `pid` (and on Windows its tree). A process of another account is reported, not killed; one of ours that survives throws. */
34
+ export declare function killPidHard(pid: string): KillResult;
35
+ /** A listener on a gate port that another account owns, so the gate cannot free that port. */
36
+ export interface ForeignListener {
37
+ port: number;
38
+ pid: string;
39
+ owner: string;
40
+ }
41
+ /** The other account's listener killPort found on `port`, when it found one. */
42
+ export declare function foreignListenerOn(port: number): ForeignListener | undefined;
43
+ export declare function describeForeignListener({ port, pid, owner }: ForeignListener): string;
44
+ /** Every listener on `ports` that another account owns, on Linux and macOS; none on Windows. */
45
+ export declare function listenersOfOtherAccounts(ports: readonly number[]): ForeignListener[];
13
46
  export declare const secs: (ms: number) => string;
14
47
  export declare function reachable(url: string): Promise<boolean>;
15
- /** Kill the process listening on a port, and its descendants. */
48
+ /** Kill the process listening on a port, and its descendants. Returns whether a process of this account ended. */
16
49
  export declare function killPort(port: number): boolean;
17
50
  /** Whether killPort ended a listener on `port` at or after `sinceMs` (a performance.now() time). */
18
51
  export declare function portKilledSince(port: number, sinceMs: number): boolean;
@@ -1,19 +1,20 @@
1
- import{spawn as e,spawnSync as t}from"node:child_process";import{closeSync as n,existsSync as r,fstatSync as i,mkdtempSync as a,openSync as o,readFileSync as s,readSync as c,readdirSync as l,rmSync as u}from"node:fs";import{tmpdir as d}from"node:os";import{join as f,resolve as p}from"node:path";import{createHash as m}from"node:crypto";async function h(e,t={}){return g(await e.locator(t.selector??`body`).ariaSnapshot())}function g(e){let t=[];for(let n of e.split(`
2
- `)){let e=n.trimStart();if(!e.startsWith(`- `))continue;let r=(n.length-e.length)/2,i=e.slice(2).trimEnd();if(i.startsWith(`/`))continue;i.endsWith(`:`)&&(i=i.slice(0,-1));let a=[];for(;i.endsWith(`]`);){let e=i.lastIndexOf(` [`);if(e===-1)break;a.unshift(i.slice(e+2,-1)),i=i.slice(0,e)}let o=i,s=``,c=i.indexOf(` `),l=i.indexOf(`:`);l!==-1&&(c===-1||l<c)?(o=i.slice(0,l),s=_(i.slice(l+1).trim())):c!==-1&&(o=i.slice(0,c),s=_(i.slice(c+1).trim())),t.push({depth:r,role:o,name:s,states:a})}return t}function _(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}var v=(e,t=[])=>[e,...t].join(` `);async function y(e){await new Promise(e=>process.stdout.write(``,()=>e())),await new Promise(e=>process.stderr.write(``,()=>e())),process.exit(e)}var b=class extends Error{name=`GateCommandError`;signal;constructor(e,t=null){super(e),this.signal=t}};function x(e,n,r=[0],i=1048576){let a=t(e,n,{encoding:`utf8`,windowsHide:!0,maxBuffer:i});if(a.error)throw new b(`${e} failed to start: ${a.error.message}`);if(a.status===null||!r.includes(a.status))throw new b(`${e} ${n.join(` `)} failed (exit ${a.status??a.signal}): ${a.stderr.trim()}`,a.status===null?a.signal:null);return a.stdout}function S(e){try{return process.kill(Number(e),0),!0}catch(e){let t=e instanceof Error&&`code`in e?e.code:void 0;if(t===`ESRCH`)return!1;if(t===`EPERM`)return!0;throw e}}function C(e){let[n,r]=process.platform===`win32`?[`taskkill`,[`/PID`,e,`/T`,`/F`]]:[`kill`,[`-9`,e]],i=t(n,r,{encoding:`utf8`,windowsHide:!0});if(i.error)throw new b(`${n} failed to start: ${i.error.message}`);if(i.status!==0&&S(e))throw new b(`${n} ${r.join(` `)} failed (exit ${i.status}): ${i.stderr.trim()}`)}var w=e=>`${(e/1e3).toFixed(1)}s`;async function T(e){try{return(await fetch(e)).ok}catch{return!1}}var E=/* @__PURE__ */ new Map;function D(e){if(process.platform===`win32`){let t=x(`netstat`,[`-ano`]),n=new Set(t.split(`
3
- `).filter(e=>e.includes(`LISTENING`)).filter(t=>t.trim().split(/\s+/)[1]?.endsWith(`:${e}`)).map(e=>e.trim().split(/\s+/).pop()).filter(e=>!!e&&e!==`0`));for(let e of n)C(e);return n.size>0&&E.set(e,performance.now()),n.size>0}let t=x(`lsof`,[`-ti`,`tcp:${e}`,`-sTCP:LISTEN`],[0,1]).split(`
4
- `).filter(Boolean);for(let e of t)C(e);return t.length>0&&E.set(e,performance.now()),t.length>0}function ee(e,t){let n=E.get(e);return n!==void 0&&n>=t}function O(){let e=process.platform===`win32`?x(`powershell`,[`-NoProfile`,`-Command`,`Get-CimInstance Win32_Process | ForEach-Object { '{0} {1}' -f $_.ProcessId, $_.ParentProcessId }`]):x(`ps`,[`-A`,`-o`,`pid=,ppid=`]),t=/* @__PURE__ */ new Map;for(let n of e.split(/\r?\n/)){let e=n.trim().match(/^(\d+)\s+(\d+)$/);e&&t.set(Number(e[1]),Number(e[2]))}return t}function k(e,t){let n=[],r=[t];for(;r.length>0;){let i=[];for(let[a,o]of e)r.includes(o)&&a!==t&&!n.includes(a)&&(n.push(a),i.push(a));r=i}return n}var te=2**30;function ne(e){return typeof e==`object`&&!!e&&`ProcessId`in e&&typeof e.ProcessId==`number`&&`ParentProcessId`in e&&typeof e.ParentProcessId==`number`&&`WorkingSetSize`in e&&typeof e.WorkingSetSize==`number`}function re(){let e=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;if(process.platform===`win32`){let r=t(`powershell`,[`-NoProfile`,`-NonInteractive`,`-Command`,`Get-CimInstance Win32_Process | Select ProcessId,ParentProcessId,WorkingSetSize | ConvertTo-Json -Compress`],{encoding:`utf8`,windowsHide:!0});if(r.status!==0)throw new b(`powershell failed (exit ${r.status}): ${r.error?.message??r.stderr}`);let i=JSON.parse(r.stdout),a=Array.isArray(i)?i:[i];for(let t of a){if(!ne(t))throw Error(`powershell returned a process row of an unknown shape: ${JSON.stringify(t)}`);e.set(t.ProcessId,t.ParentProcessId),n.set(t.ProcessId,t.WorkingSetSize)}return{parentOf:e,bytesOf:n}}let r=t(`ps`,[`-A`,`-o`,`pid=,ppid=,rss=`],{encoding:`utf8`,windowsHide:!0});if(r.status!==0)throw new b(`ps failed (exit ${r.status}): ${r.error?.message??r.stderr}`);for(let t of r.stdout.split(/\r?\n/)){if(t.trim()===``)continue;let r=t.trim().match(/^(\d+)\s+(\d+)\s+(\d+)$/);if(!r)throw Error(`ps returned a line of an unknown shape: ${t}`);e.set(Number(r[1]),Number(r[2])),n.set(Number(r[1]),Number(r[3])*1024)}return{parentOf:e,bytesOf:n}}var ie=250,A;function j(e){let t=performance.now();(A===void 0||t-A.atMs>ie)&&(A={atMs:t,table:re()});let{parentOf:n,bytesOf:r}=A.table;if(!r.has(e))return null;let i=0;for(let t of[e,...k(n,e)])i+=r.get(t)??0;return i/te}function M(e=process.pid){let t=0;for(let n=0;n<3;n+=1){let n=k(O(),e);if(n.length===0)return t;for(let e of n.reverse())try{process.kill(e,`SIGKILL`),t+=1}catch(e){if(N(e)!==`ESRCH`)throw e}}return t}function N(e){return e instanceof Error&&`code`in e?e.code:void 0}function P(e){try{process.kill(e,`SIGKILL`)}catch(t){let n=N(t);if(n===`ESRCH`||n===`EPERM`&&e<0)return;throw t}}function F(e){M(e),P(e),process.platform!==`win32`&&P(-e)}var I=`webority-ui-gate-chrome`,L=RegExp(`${I}[=-](\\d+)`);function R(){let e=Number(process.env.WEBORITY_UI_GATE_PID);return Number.isFinite(e)&&e>0?e:process.pid}function ae(){return a(f(d(),`${I}-${R()}-`))}function oe(){return[`--${I}=${R()}`]}function z(e){try{return process.kill(e,0),!0}catch{return!1}}function B(){return process.platform===`win32`?x(`powershell`,[`-NoProfile`,`-Command`,`Get-CimInstance Win32_Process -Filter "Name='chrome.exe'" | ForEach-Object { '{0} {1}' -f $_.ProcessId, $_.CommandLine }`]).split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(` `);return t<0?null:{pid:e.slice(0,t).trim(),commandLine:e.slice(t+1)}}).filter(e=>e!==null):x(`ps`,[`-A`,`-o`,`pid=,args=`],[0],67108864).split(`
5
- `).map(e=>e.trim()).filter(e=>/(?:^|[/\s])(chrome|chromium)(?:\s|$|\.exe)/i.test(e)).map(e=>{let t=e.match(/^(\d+)\s+(.*)$/);if(!t)return null;let[,n,r]=t;return n===void 0||r===void 0?null:{pid:n,commandLine:r}}).filter(e=>e!==null)}function se(){let e=[];for(let{pid:t,commandLine:n}of B()){if(!n?.includes(`webority-ui-gate-chrome`))continue;let r=n.match(L);if(!r)continue;let i=Number(r[1]);!Number.isFinite(i)||i<=0||i!==process.pid&&(z(i)||e.push(t))}for(let t of e)C(t);return ce(),e.length}function V(e=process.pid){let t=[];for(let{pid:n,commandLine:r}of B()){let i=r?.match(L);i&&Number(i[1])===e&&t.push(n)}for(let e of t)C(e);return t.length}function ce(){let e=RegExp(`^${I}-(\\d+)-`),t;try{t=l(d())}catch{return}for(let n of t){let t=n.match(e);if(!t)continue;let r=Number(t[1]);if(!(r===process.pid||z(r)))try{u(f(d(),n),{recursive:!0,force:!0})}catch(e){if((e instanceof Error&&`code`in e?e.code:void 0)!==`ENOENT`)throw e}}}var le=`--blink-settings=preferredColorScheme=1`;function H(e){process.stdout.write(`${e}\n`)}var ue=[`dev`,`preview`],de=[`react`,`razor`,`phoneWeb`];function fe({razorProject:e,origin:t,configuration:n=`Debug`}){return[`run`,`--project`,e,`--no-build`,`-c`,n,`--`,`--urls`,t]}var pe=/Port \d+ is already in use|address already in use|EADDRINUSE/i;function me({log:e,retriesLeft:t,killed:n}){return!n&&t>0&&pe.test(e)}async function he({attempts:e,intervalMs:t,reachable:n,died:r}){for(let i=0;i<e;i+=1){if(r())return!1;let e=await n();if(r())return!1;if(e)return!0;await new Promise(e=>setTimeout(e,t))}return!1}function ge(t){let{which:n,ports:i,origins:a,readyUrls:c={},reactFilter:l=`@webority/react-sandbox`,reactMode:f=`dev`,razorProject:m=`samples/Razor.Sandbox`,phoneWebDir:h=`samples/mobile-sandbox-web`,tag:g,env:_={},configuration:y=`Debug`}=t,b=e=>{let t=i[e];if(t===void 0)throw Error(`bootSandboxes: no port for "${e}"`);return t},x=e=>{let t=a[e];if(t===void 0)throw Error(`bootSandboxes: no origin for "${e}"`);return t};if(!ue.includes(f))throw Error(`bootSandboxes: unknown React mode "${f}"`);for(let e of n){if(!de.includes(e))throw Error(`bootSandboxes: unknown sandbox "${e}"`);b(e),x(e)}let S=e=>{switch(e){case`react`:return f===`preview`?[`corepack`,[`pnpm`,`--filter`,l,`exec`,`vite`,`preview`,`--port`,String(b(`react`)),`--strictPort`]]:[`corepack`,[`pnpm`,`--filter`,l,`dev`,`--port`,String(b(`react`)),`--strictPort`]];case`razor`:return[`dotnet`,fe({razorProject:m,origin:x(`razor`),configuration:y})];case`phoneWeb`:return[`corepack`,[`pnpm`,`--dir`,h,`exec`,`vite`,`--port`,String(b(`phoneWeb`)),`--strictPort`]]}},C=e=>p(d(),`webority-gate-${g?`${e}-${g}`:e}-sandbox-${process.pid}.log`),w={};for(let e of n)w[e]=C(e);let E=[];H(`\nStarting the sandboxes (${n.join(`, `)})... (output: ${n.map(e=>C(e)).join(`, `)})`);let O=[],k=(t,n,i)=>{let[a,c]=S(t),l=C(t);D(b(t));let u=o(l,`w`),d=e(v(a,c),{stdio:[`ignore`,u,u],shell:!0,windowsHide:!0,env:{...process.env,..._,WEBORITY_GATE_SANDBOX:`1`}}),f=performance.now();return d.on(`exit`,(e,a)=>{me({log:r(l)?s(l,`utf8`):``,retriesLeft:i,killed:d.killed})?(H(`\nThe ${t} sandbox's port ${b(t)} was taken; freeing it and starting the sandbox once more.`),O[n]=k(t,n,i-1)):d.killed||E.push({name:t,port:b(t),code:e,signal:a,log:l,stoppedByGate:ee(b(t),f)})}),d};n.forEach((e,t)=>{O[t]=k(e,t,1)});let te=n.map(e=>c[e]??x(e));async function ne(){for(let e of te)if(!await T(e))return!1;return!0}return{children:O,logs:w,deaths:()=>[...E],waitReady({attempts:e=600,intervalMs:t=300}={}){return he({attempts:e,intervalMs:t,reachable:ne,died:()=>E.length>0})},finish(e){if(e===0)for(let e of Object.values(w))e!==void 0&&u(e,{force:!0});else for(let[e,t]of Object.entries(w)){if(t===void 0||!r(t))continue;let n=s(t,`utf8`).trimEnd().split(`
6
- `),i=n.findIndex(e=>/Exception: |^\s*Error: /.test(e));i!==-1&&i<n.length-25&&H(`\n──── ${e} sandbox log, first error (${t}:${i+1}) ────\n${n.slice(i,i+3).join(`
7
- `)}`),H(`\n──── ${e} sandbox log, last 25 lines (${t}) ────\n${n.slice(-25).join(`
8
- `)}`)}}}}function _e({ports:e=[],children:t=[]}={}){let n=[];for(let e of t)e.kill();for(let t of e)try{D(t)}catch(e){if(e instanceof b&&e.signal===`SIGTERM`){H(`stopAll: port ${t} listing was ended by SIGTERM during shutdown; skipped`);continue}n.push(Error(`could not free port ${t}`,{cause:e}))}let r=V();if(n.length>0)throw AggregateError(n,`stopAll: ${n.length} port(s) could not be freed`);return r}var ve=5,ye=65536,U=300,be=/\b([\w.-]*(?:password|passwd|pwd|secret|token|apikey|api_key|accountkey|sharedaccesskey|sig|signature|credential)[\w.-]*)=("[^"]*"|'[^']*'|[^\s;,&]+)/gi;function xe(e){if(!r(e))return null;let t=o(e,`r`);try{let e=i(t).size,n=Math.min(e,ye),r=Buffer.alloc(n);c(t,r,0,n,e-n);let a=r.toString(`utf8`);return n<e?a.slice(a.indexOf(`
9
- `)+1):a}finally{n(t)}}var Se=e=>{let t=e.replace(be,`$1=[redacted]`);return t.length>U?`${t.slice(0,U)}...`:t};function W(e){let t=e.split(`
10
- `).filter(e=>e.trim()!==``),n=t.slice(-5),r=t.findLastIndex(e=>/Exception: |^\s*Error: /.test(e)),i=t[r];return(i!==void 0&&r<t.length-ve?[i,`...`,...n]:n).map(Se)}function Ce({name:e,port:t,code:n,signal:r,log:i,stoppedByGate:a},o=xe){let s=r?`signal ${r}`:`exit ${n}`,c=r===`SIGKILL`||n===137,l=c&&a?`the gate itself ended it when it freed port ${t}, while the sandbox was still in use. This is an infrastructure failure, not a test failure: rerun the gate`:c?`the system killed it, usually for lack of memory. This is an infrastructure failure, not a test failure: rerun the gate`:`it stopped on its own, so a rerun fails the same way: its log below says why`,u=o(i),d=u===null?[]:W(u);return`The ${e} sandbox ended before the run did (${s}): ${l}. Log: ${i}\n${u===null?` (no log was written)`:d.length>0?d.map(e=>` ${e}`).join(`
11
- `):` (the log is empty)`}`}var we=process.env.WUI_REACT_ORIGIN||`http://localhost:5173`,Te=process.env.WUI_RAZOR_ORIGIN||`http://localhost:5299`,Ee=process.env.WUI_PHONE_WEB_ORIGIN||`http://localhost:5174`,De={first:7e3,end:1e4},Oe=[7e3,7474,7687,8e3,8008,8080,8081,8443,8888,9e3,9090,9092,9200,9229,9300],G=12;function ke(e,t=2){if(!Number.isInteger(t)||t<1||t>12)throw RangeError(`derivePorts: count must be 1 to 12, got ${t}`);let{first:n,end:r}=De,i=(r-n)/G,a=m(`sha1`).update(e).digest().readUInt16BE(0)%i;for(let e=0;e<i;e++){let r=n+(a+e)%i*G;if(!Oe.some(e=>e>=r&&e<r+G))return Array.from({length:t},(e,t)=>r+t)}throw Error(`derivePorts: no free port slot`)}var Ae=124,je=143,Me=3,Ne=5e3,Pe=3e4,Fe=5e3,K={now:()=>performance.now(),every:(e,t)=>{let n=setInterval(t,e);return n.unref(),()=>clearInterval(n)},after:(e,t)=>{let n=setTimeout(t,e);return n.unref(),()=>clearTimeout(n)}},Ie=e=>{process.stdout.write(e)},q=/* @__PURE__ */ new Set,Le=!1,J=0,Y=0,X,Z;function Re(){return Math.round(J)}function ze(e,t){if(Z!==void 0&&X!==t)throw Error(`runBuffered: a task started on another clock while tasks on the first are open; one clock drives the gate at a time.`);Z===void 0&&(X=t,Y=t.now(),Z=t.every(e.sampleMs,()=>Ve(e)))}function Be(){Z!==void 0&&(Z(),Z=void 0,X=void 0)}function Ve(e){let t=X?.now();if(t===void 0)return;let n=t-Y;if(Y=t,n>e.gapMs){let t=n-e.sampleMs;J+=t,H(`PAUSED: the gate did not run for ${Math.round(t/1e3)} s; every limit moved by that much`)}for(let e of q)e.check(t)}function He(e){return e instanceof Error&&`code`in e&&(e.code===`ESRCH`||e.code===`EPERM`)}function Ue(e){if(!(Number.isFinite(e.limitMs)&&e.limitMs>0))throw Error(`${e.label}: limitMs must be a positive number of milliseconds, not ${e.limitMs}. Every gate task states its limit.`)}function We(e){let t=[...q];for(let n of t)n.stop(e);return t.map(e=>e.label)}function Q(t,n={},r,i={sampleMs:Ne,gapMs:Pe},a=K){Ue(t);let{command:o,args:s,label:c,limitMs:l}=t;return new Promise(t=>{let u=a.now(),d=J,f=[],p=!1,m=!1,h=!1,g=!1,_,y,b,x,S=e(v(o,s),{shell:!0,env:{...process.env,...n},detached:process.platform!==`win32`,windowsHide:!0});S.pid!==void 0&&!Le&&(Le=!0,process.on(`exit`,()=>{if(process.platform!==`win32`){for(let e of q)if(e.pid!==void 0)try{process.kill(-e.pid,`SIGKILL`)}catch(e){if(!He(e))throw e}}}));let C=e=>e-u-(J-d),T=e=>{if(g)return;g=!0,b?.(),x?.(),q.delete(E),q.size===0&&Be();let n=Math.round(a.now()-u),r=Buffer.concat(f).toString(),i=[];y!==void 0&&i.push(`MEMORY SAMPLE FAILED: ${y}`),p&&i.push(`HUNG: ${c} was still running at ${w(l*3)}, 3 times its limit of ${w(l)}; its process tree was ended.`);let o=i.length===0?r:`${r}${r.endsWith(`
1
+ import{spawn as e,spawnSync as t}from"node:child_process";import{closeSync as n,existsSync as r,fstatSync as i,mkdtempSync as a,openSync as o,readFileSync as s,readSync as c,readdirSync as l,rmSync as u}from"node:fs";import{tmpdir as d,userInfo as f}from"node:os";import{join as p,resolve as m}from"node:path";import{createHash as h}from"node:crypto";async function g(e,t={}){return _(await e.locator(t.selector??`body`).ariaSnapshot())}function _(e){let t=[];for(let n of e.split(`
2
+ `)){let e=n.trimStart();if(!e.startsWith(`- `))continue;let r=(n.length-e.length)/2,i=e.slice(2).trimEnd();if(i.startsWith(`/`))continue;i.endsWith(`:`)&&(i=i.slice(0,-1));let a=[];for(;i.endsWith(`]`);){let e=i.lastIndexOf(` [`);if(e===-1)break;a.unshift(i.slice(e+2,-1)),i=i.slice(0,e)}let o=i,s=``,c=i.indexOf(` `),l=i.indexOf(`:`);l!==-1&&(c===-1||l<c)?(o=i.slice(0,l),s=v(i.slice(l+1).trim())):c!==-1&&(o=i.slice(0,c),s=v(i.slice(c+1).trim())),t.push({depth:r,role:o,name:s,states:a})}return t}function v(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function y(e){process.stdout.write(`${e}\n`)}var b=(e,t=[])=>[e,...t].join(` `);async function x(e){await new Promise(e=>process.stdout.write(``,()=>e())),await new Promise(e=>process.stderr.write(``,()=>e())),process.exit(e)}var S=class extends Error{name=`GateCommandError`;signal;constructor(e,t=null){super(e),this.signal=t}};function C(e,n,r=[0],i=1048576){let a=t(e,n,{encoding:`utf8`,windowsHide:!0,maxBuffer:i});if(a.error)throw new S(`${e} failed to start: ${a.error.message}`);if(a.status===null||!r.includes(a.status))throw new S(`${e} ${n.join(` `)} failed (exit ${a.status??a.signal}): ${a.stderr.trim()}`,a.status===null?a.signal:null);return a.stdout}function w(e){try{return process.kill(Number(e),0),!0}catch(e){let t=e instanceof Error&&`code`in e?e.code:void 0;if(t===`ESRCH`)return!1;if(t===`EPERM`)return!0;throw e}}function T(e){let n=t(`ps`,[`-o`,`uid=,user=`,`-p`,e],{encoding:`utf8`,windowsHide:!0});if(n.error)throw new S(`ps failed to start: ${n.error.message}`);if(n.status===1)return null;if(n.status!==0)throw new S(`ps -o uid=,user= -p ${e} failed (exit ${n.status}): ${n.stderr.trim()}`);let r=n.stdout.trim().match(/^(\d+)\s+(\S+)$/);if(!r)throw new S(`ps -o uid=,user= -p ${e} printed a line of an unknown shape: ${n.stdout.trim()}`);return{uid:Number(r[1]),name:String(r[2])}}function E({alive:e,owner:t,myUid:n}){return!e||t===null?`gone`:t.uid===n?`survived`:`foreign`}function D(e){let[n,r]=process.platform===`win32`?[`taskkill`,[`/PID`,e,`/T`,`/F`]]:[`kill`,[`-9`,e]],i=t(n,r,{encoding:`utf8`,windowsHide:!0});if(i.error)throw new S(`${n} failed to start: ${i.error.message}`);if(i.status===0)return{outcome:`ended`};let a=w(e),o=a&&process.platform!==`win32`?T(e):null,s=process.platform===`win32`?a?`survived`:`gone`:E({alive:a,owner:o,myUid:f().uid});if(s===`gone`)return{outcome:`ended`};if(s===`foreign`&&o!==null)return{outcome:`foreign`,owner:o};throw new S(`${n} ${r.join(` `)} failed (exit ${i.status}): ${i.stderr.trim()}`)}var O=/* @__PURE__ */ new Map;function k({port:e,pid:t,owner:n}){return`Port ${e} is held by pid ${t} of account ${n}, which this account cannot stop; the gate leaves it unused.`}function ee(e){if(process.platform===`win32`||e.length===0)return[];let t=C(`lsof`,[`-nP`,`-iTCP:${Math.min(...e)}-${Math.max(...e)}`,`-sTCP:LISTEN`,`-F`,`pn`],[0,1]),n=f().uid,r=[],i=``;for(let a of t.split(`
3
+ `)){if(a.startsWith(`p`)&&(i=a.slice(1)),!a.startsWith(`n`)||i===``)continue;let t=Number(a.slice(a.lastIndexOf(`:`)+1));if(!e.includes(t)||r.some(e=>e.port===t&&e.pid===i))continue;let o=T(i);o!==null&&o.uid!==n&&r.push({port:t,pid:i,owner:o.name})}return r}function A(e,t){let n=!1;for(let r of t){let t=D(r);if(t.outcome===`ended`){n=!0;continue}let i={port:e,pid:r,owner:t.owner.name};O.has(e)||y(k(i)),O.set(e,i)}return n&&ne.set(e,performance.now()),n}var j=e=>`${(e/1e3).toFixed(1)}s`;async function te(e){try{return(await fetch(e)).ok}catch{return!1}}var ne=/* @__PURE__ */ new Map;function M(e){if(process.platform===`win32`){let t=C(`netstat`,[`-ano`]);return A(e,new Set(t.split(`
4
+ `).filter(e=>e.includes(`LISTENING`)).filter(t=>t.trim().split(/\s+/)[1]?.endsWith(`:${e}`)).map(e=>e.trim().split(/\s+/).pop()).filter(e=>!!e&&e!==`0`)))}return A(e,C(`lsof`,[`-ti`,`tcp:${e}`,`-sTCP:LISTEN`],[0,1]).split(`
5
+ `).filter(Boolean))}function re(e,t){let n=ne.get(e);return n!==void 0&&n>=t}function ie(){let e=process.platform===`win32`?C(`powershell`,[`-NoProfile`,`-Command`,`Get-CimInstance Win32_Process | ForEach-Object { '{0} {1}' -f $_.ProcessId, $_.ParentProcessId }`]):C(`ps`,[`-A`,`-o`,`pid=,ppid=`]),t=/* @__PURE__ */ new Map;for(let n of e.split(/\r?\n/)){let e=n.trim().match(/^(\d+)\s+(\d+)$/);e&&t.set(Number(e[1]),Number(e[2]))}return t}function N(e,t){let n=[],r=[t];for(;r.length>0;){let i=[];for(let[a,o]of e)r.includes(o)&&a!==t&&!n.includes(a)&&(n.push(a),i.push(a));r=i}return n}var ae=2**30;function oe(e){return typeof e==`object`&&!!e&&`ProcessId`in e&&typeof e.ProcessId==`number`&&`ParentProcessId`in e&&typeof e.ParentProcessId==`number`&&`WorkingSetSize`in e&&typeof e.WorkingSetSize==`number`}function se(){let e=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;if(process.platform===`win32`){let r=t(`powershell`,[`-NoProfile`,`-NonInteractive`,`-Command`,`Get-CimInstance Win32_Process | Select ProcessId,ParentProcessId,WorkingSetSize | ConvertTo-Json -Compress`],{encoding:`utf8`,windowsHide:!0});if(r.status!==0)throw new S(`powershell failed (exit ${r.status}): ${r.error?.message??r.stderr}`);let i=JSON.parse(r.stdout),a=Array.isArray(i)?i:[i];for(let t of a){if(!oe(t))throw Error(`powershell returned a process row of an unknown shape: ${JSON.stringify(t)}`);e.set(t.ProcessId,t.ParentProcessId),n.set(t.ProcessId,t.WorkingSetSize)}return{parentOf:e,bytesOf:n}}let r=t(`ps`,[`-A`,`-o`,`pid=,ppid=,rss=`],{encoding:`utf8`,windowsHide:!0});if(r.status!==0)throw new S(`ps failed (exit ${r.status}): ${r.error?.message??r.stderr}`);for(let t of r.stdout.split(/\r?\n/)){if(t.trim()===``)continue;let r=t.trim().match(/^(\d+)\s+(\d+)\s+(\d+)$/);if(!r)throw Error(`ps returned a line of an unknown shape: ${t}`);e.set(Number(r[1]),Number(r[2])),n.set(Number(r[1]),Number(r[3])*1024)}return{parentOf:e,bytesOf:n}}var ce=250,P;function le(e){let t=performance.now();(P===void 0||t-P.atMs>ce)&&(P={atMs:t,table:se()});let{parentOf:n,bytesOf:r}=P.table;if(!r.has(e))return null;let i=0;for(let t of[e,...N(n,e)])i+=r.get(t)??0;return i/ae}function F(e=process.pid){let t=0;for(let n=0;n<3;n+=1){let n=N(ie(),e);if(n.length===0)return t;for(let e of n.reverse())try{process.kill(e,`SIGKILL`),t+=1}catch(e){if(ue(e)!==`ESRCH`)throw e}}return t}function ue(e){return e instanceof Error&&`code`in e?e.code:void 0}function de(e){try{process.kill(e,`SIGKILL`)}catch(t){let n=ue(t);if(n===`ESRCH`||n===`EPERM`&&e<0)return;throw t}}function I(e){F(e),de(e),process.platform!==`win32`&&de(-e)}var L=`webority-ui-gate-chrome`,fe=RegExp(`${L}[=-](\\d+)`);function R(){let e=Number(process.env.WEBORITY_UI_GATE_PID);return Number.isFinite(e)&&e>0?e:process.pid}function pe(){return a(p(d(),`${L}-${R()}-`))}function me(){return[`--${L}=${R()}`]}function z(e){try{return process.kill(e,0),!0}catch{return!1}}function he(){return process.platform===`win32`?C(`powershell`,[`-NoProfile`,`-Command`,`Get-CimInstance Win32_Process -Filter "Name='chrome.exe'" | ForEach-Object { '{0} {1}' -f $_.ProcessId, $_.CommandLine }`]).split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(` `);return t<0?null:{pid:e.slice(0,t).trim(),commandLine:e.slice(t+1)}}).filter(e=>e!==null):C(`ps`,[`-A`,`-o`,`pid=,args=`],[0],67108864).split(`
6
+ `).map(e=>e.trim()).filter(e=>/(?:^|[/\s])(chrome|chromium)(?:\s|$|\.exe)/i.test(e)).map(e=>{let t=e.match(/^(\d+)\s+(.*)$/);if(!t)return null;let[,n,r]=t;return n===void 0||r===void 0?null:{pid:n,commandLine:r}}).filter(e=>e!==null)}function ge(){let e=[];for(let{pid:t,commandLine:n}of he()){if(!n?.includes(`webority-ui-gate-chrome`))continue;let r=n.match(fe);if(!r)continue;let i=Number(r[1]);!Number.isFinite(i)||i<=0||i!==process.pid&&(z(i)||e.push(t))}for(let t of e)D(t);return ve(),e.length}function _e(e=process.pid){let t=[];for(let{pid:n,commandLine:r}of he()){let i=r?.match(fe);i&&Number(i[1])===e&&t.push(n)}for(let e of t)D(e);return t.length}function ve(){let e=RegExp(`^${L}-(\\d+)-`),t;try{t=l(d())}catch{return}for(let n of t){let t=n.match(e);if(!t)continue;let r=Number(t[1]);if(!(r===process.pid||z(r)))try{u(p(d(),n),{recursive:!0,force:!0})}catch(e){if((e instanceof Error&&`code`in e?e.code:void 0)!==`ENOENT`)throw e}}}var ye=`--blink-settings=preferredColorScheme=1`,be=[`dev`,`preview`],xe=[`react`,`razor`,`phoneWeb`];function Se({razorProject:e,origin:t,configuration:n=`Debug`}){return[`run`,`--project`,e,`--no-build`,`-c`,n,`--`,`--urls`,t]}var Ce=/Port \d+ is already in use|address already in use|EADDRINUSE/i;function we({log:e,retriesLeft:t,killed:n}){return!n&&t>0&&Ce.test(e)}async function Te({attempts:e,intervalMs:t,reachable:n,died:r}){for(let i=0;i<e;i+=1){if(r())return!1;let e=await n();if(r())return!1;if(e)return!0;await new Promise(e=>setTimeout(e,t))}return!1}function Ee(t){let{which:n,ports:i,origins:a,readyUrls:c={},reactFilter:l=`@webority/react-sandbox`,reactMode:f=`dev`,razorProject:p=`samples/Razor.Sandbox`,phoneWebDir:h=`samples/mobile-sandbox-web`,tag:g,env:_={},configuration:v=`Debug`}=t,x=e=>{let t=i[e];if(t===void 0)throw Error(`bootSandboxes: no port for "${e}"`);return t},S=e=>{let t=a[e];if(t===void 0)throw Error(`bootSandboxes: no origin for "${e}"`);return t};if(!be.includes(f))throw Error(`bootSandboxes: unknown React mode "${f}"`);for(let e of n){if(!xe.includes(e))throw Error(`bootSandboxes: unknown sandbox "${e}"`);x(e),S(e)}let C=e=>{switch(e){case`react`:return f===`preview`?[`corepack`,[`pnpm`,`--filter`,l,`exec`,`vite`,`preview`,`--port`,String(x(`react`)),`--strictPort`]]:[`corepack`,[`pnpm`,`--filter`,l,`dev`,`--port`,String(x(`react`)),`--strictPort`]];case`razor`:return[`dotnet`,Se({razorProject:p,origin:S(`razor`),configuration:v})];case`phoneWeb`:return[`corepack`,[`pnpm`,`--dir`,h,`exec`,`vite`,`--port`,String(x(`phoneWeb`)),`--strictPort`]]}},w=e=>m(d(),`webority-gate-${g?`${e}-${g}`:e}-sandbox-${process.pid}.log`),T={};for(let e of n)T[e]=w(e);let E=[];y(`\nStarting the sandboxes (${n.join(`, `)})... (output: ${n.map(e=>w(e)).join(`, `)})`);let D=[],O=(t,n,i)=>{let[a,c]=C(t),l=w(t);M(x(t));let u=o(l,`w`),d=e(b(a,c),{stdio:[`ignore`,u,u],shell:!0,windowsHide:!0,env:{...process.env,..._,WEBORITY_GATE_SANDBOX:`1`}}),f=performance.now();return d.on(`exit`,(e,a)=>{we({log:r(l)?s(l,`utf8`):``,retriesLeft:i,killed:d.killed})?(y(`\nThe ${t} sandbox's port ${x(t)} was taken; freeing it and starting the sandbox once more.`),D[n]=O(t,n,i-1)):d.killed||E.push({name:t,port:x(t),code:e,signal:a,log:l,stoppedByGate:re(x(t),f)})}),d};n.forEach((e,t)=>{D[t]=O(e,t,1)});let k=n.map(e=>c[e]??S(e));async function ee(){for(let e of k)if(!await te(e))return!1;return!0}return{children:D,logs:T,deaths:()=>[...E],waitReady({attempts:e=600,intervalMs:t=300}={}){return Te({attempts:e,intervalMs:t,reachable:ee,died:()=>E.length>0})},finish(e){if(e===0)for(let e of Object.values(T))e!==void 0&&u(e,{force:!0});else for(let[e,t]of Object.entries(T)){if(t===void 0||!r(t))continue;let n=s(t,`utf8`).trimEnd().split(`
7
+ `),i=n.findIndex(e=>/Exception: |^\s*Error: /.test(e));i!==-1&&i<n.length-25&&y(`\n──── ${e} sandbox log, first error (${t}:${i+1}) ────\n${n.slice(i,i+3).join(`
8
+ `)}`),y(`\n──── ${e} sandbox log, last 25 lines (${t}) ────\n${n.slice(-25).join(`
9
+ `)}`)}}}}function De({ports:e=[],children:t=[]}={}){let n=[];for(let e of t)e.kill();for(let t of e)try{M(t)}catch(e){if(e instanceof S&&e.signal===`SIGTERM`){y(`stopAll: port ${t} listing was ended by SIGTERM during shutdown; skipped`);continue}n.push(Error(`could not free port ${t}`,{cause:e}))}let r=_e();if(n.length>0)throw AggregateError(n,`stopAll: ${n.length} port(s) could not be freed`);return r}var Oe=5,ke=65536,B=300,Ae=/\b([\w.-]*(?:password|passwd|pwd|secret|token|apikey|api_key|accountkey|sharedaccesskey|sig|signature|credential)[\w.-]*)=("[^"]*"|'[^']*'|[^\s;,&]+)/gi;function je(e){if(!r(e))return null;let t=o(e,`r`);try{let e=i(t).size,n=Math.min(e,ke),r=Buffer.alloc(n);c(t,r,0,n,e-n);let a=r.toString(`utf8`);return n<e?a.slice(a.indexOf(`
10
+ `)+1):a}finally{n(t)}}var Me=e=>{let t=e.replace(Ae,`$1=[redacted]`);return t.length>B?`${t.slice(0,B)}...`:t};function V(e){let t=e.split(`
11
+ `).filter(e=>e.trim()!==``),n=t.slice(-5),r=t.findLastIndex(e=>/Exception: |^\s*Error: /.test(e)),i=t[r];return(i!==void 0&&r<t.length-Oe?[i,`...`,...n]:n).map(Me)}function Ne({name:e,port:t,code:n,signal:r,log:i,stoppedByGate:a},o=je){let s=r?`signal ${r}`:`exit ${n}`,c=r===`SIGKILL`||n===137,l=c&&a?`the gate itself ended it when it freed port ${t}, while the sandbox was still in use. This is an infrastructure failure, not a test failure: rerun the gate`:c?`the system killed it, usually for lack of memory. This is an infrastructure failure, not a test failure: rerun the gate`:`it stopped on its own, so a rerun fails the same way: its log below says why`,u=o(i),d=u===null?[]:V(u);return`The ${e} sandbox ended before the run did (${s}): ${l}. Log: ${i}\n${u===null?` (no log was written)`:d.length>0?d.map(e=>` ${e}`).join(`
12
+ `):` (the log is empty)`}`}var Pe=process.env.WUI_REACT_ORIGIN||`http://localhost:5173`,Fe=process.env.WUI_RAZOR_ORIGIN||`http://localhost:5299`,Ie=process.env.WUI_PHONE_WEB_ORIGIN||`http://localhost:5174`,Le={first:7e3,end:1e4},Re=[7e3,7474,7687,8e3,8008,8080,8081,8443,8888,9e3,9090,9092,9200,9229,9300],H=12;function ze(e,t=2,n=ee){if(!Number.isInteger(t)||t<1||t>12)throw RangeError(`derivePorts: count must be 1 to 12, got ${t}`);let{first:r,end:i}=Le,a=(i-r)/H,o=h(`sha1`).update(e).digest().readUInt16BE(0)%a;for(let e=0;e<a;e++){let i=r+(o+e)%a*H;if(Re.some(e=>e>=i&&e<i+H))continue;let s=Array.from({length:t},(e,t)=>i+t),c=n(s);if(c.length===0)return s;for(let e of c)y(k(e))}throw Error(`derivePorts: no free port slot`)}var Be=124,Ve=143,He=3,U=5e3,W=3e4,G=5e3,K={now:()=>performance.now(),every:(e,t)=>{let n=setInterval(t,e);return n.unref(),()=>clearInterval(n)},after:(e,t)=>{let n=setTimeout(t,e);return n.unref(),()=>clearTimeout(n)}},Ue=e=>{process.stdout.write(e)},q=/* @__PURE__ */ new Set,We=!1,J=0,Y=0,X,Z;function Ge(){return Math.round(J)}function Ke(e,t){if(Z!==void 0&&X!==t)throw Error(`runBuffered: a task started on another clock while tasks on the first are open; one clock drives the gate at a time.`);Z===void 0&&(X=t,Y=t.now(),Z=t.every(e.sampleMs,()=>Je(e)))}function qe(){Z!==void 0&&(Z(),Z=void 0,X=void 0)}function Je(e){let t=X?.now();if(t===void 0)return;let n=t-Y;if(Y=t,n>e.gapMs){let t=n-e.sampleMs;J+=t,y(`PAUSED: the gate did not run for ${Math.round(t/1e3)} s; every limit moved by that much`)}for(let e of q)e.check(t)}function Ye(e){return e instanceof Error&&`code`in e&&(e.code===`ESRCH`||e.code===`EPERM`)}function Xe(e){if(!(Number.isFinite(e.limitMs)&&e.limitMs>0))throw Error(`${e.label}: limitMs must be a positive number of milliseconds, not ${e.limitMs}. Every gate task states its limit.`)}function Ze(e){let t=[...q];for(let n of t)n.stop(e);return t.map(e=>e.label)}function Q(t,n={},r,i={sampleMs:U,gapMs:W},a=K){Xe(t);let{command:o,args:s,label:c,limitMs:l}=t;return new Promise(t=>{let u=a.now(),d=J,f=[],p=!1,m=!1,h=!1,g=!1,_,v,x,S,C=e(b(o,s),{shell:!0,env:{...process.env,...n},detached:process.platform!==`win32`,windowsHide:!0});C.pid!==void 0&&!We&&(We=!0,process.on(`exit`,()=>{if(process.platform!==`win32`){for(let e of q)if(e.pid!==void 0)try{process.kill(-e.pid,`SIGKILL`)}catch(e){if(!Ye(e))throw e}}}));let w=e=>e-u-(J-d),T=e=>{if(g)return;g=!0,x?.(),S?.(),q.delete(E),q.size===0&&qe();let n=Math.round(a.now()-u),r=Buffer.concat(f).toString(),i=[];v!==void 0&&i.push(`MEMORY SAMPLE FAILED: ${v}`),p&&i.push(`HUNG: ${c} was still running at ${j(l*3)}, 3 times its limit of ${j(l)}; its process tree was ended.`);let o=i.length===0?r:`${r}${r.endsWith(`
12
13
  `)?``:`
13
14
  `}${i.join(`
14
- `)}`,s=_===void 0?{}:{peakMemoryGiB:_},v=Math.round(J-d),S=v>0?{pausedMs:v}:{};t(h?{label:c,code:143,stopped:!0,output:o,ms:n,...s,...S}:p?{label:c,code:124,hung:!0,output:o,ms:n,...s,...S}:{label:c,code:e,output:o,ms:n,...m?{slow:!0}:{},...s,...S})},E={label:c,pid:S.pid,check:e=>{let t=C(e);!m&&t>=l&&(m=!0,H(`SLOW: ${c} passed its limit of ${w(l)}; it keeps running and is ended as hung at ${w(l*3)}.`)),!p&&t>=l*3&&(p=!0,S.pid!==void 0&&F(S.pid),b=a.after(Fe,()=>{S.stdout.destroy(),S.stderr.destroy(),T(124)}))},stop:e=>{g||h||(h=!0,H(`STOPPED ${c} after ${Math.round(C(a.now())/1e3)} s (${e})`),H(Buffer.concat(f).toString().split(`
15
+ `)}`,s=_===void 0?{}:{peakMemoryGiB:_},y=Math.round(J-d),b=y>0?{pausedMs:y}:{};t(h?{label:c,code:143,stopped:!0,output:o,ms:n,...s,...b}:p?{label:c,code:124,hung:!0,output:o,ms:n,...s,...b}:{label:c,code:e,output:o,ms:n,...m?{slow:!0}:{},...s,...b})},E={label:c,pid:C.pid,check:e=>{let t=w(e);!m&&t>=l&&(m=!0,y(`SLOW: ${c} passed its limit of ${j(l)}; it keeps running and is ended as hung at ${j(l*3)}.`)),!p&&t>=l*3&&(p=!0,C.pid!==void 0&&I(C.pid),x=a.after(G,()=>{C.stdout.destroy(),C.stderr.destroy(),T(124)}))},stop:e=>{g||h||(h=!0,y(`STOPPED ${c} after ${Math.round(w(a.now())/1e3)} s (${e})`),y(Buffer.concat(f).toString().split(`
15
16
  `).slice(-40).join(`
16
- `)),S.pid!==void 0&&F(S.pid),b?.(),b=a.after(Fe,()=>{S.stdout.destroy(),S.stderr.destroy(),T(143)}))}};S.stdout.on(`data`,e=>f.push(e)),S.stderr.on(`data`,e=>f.push(e)),S.on(`close`,e=>T(e??1));let D=S.pid;r!==void 0&&D!==void 0&&(x=a.every(r.everyMs,()=>{try{let e=r.sample(D);e!==null&&(_===void 0||e>_)&&(_=e)}catch(e){y=e instanceof Error?e.message:String(e),x?.()}})),q.add(E),ze(i,a)})}var Ge=/\[vitest-pool\]: Failed to start \w+ worker|\[vitest-pool-runner\]: Timeout waiting for worker to respond/,Ke=/^\s*(Test Files|Tests)\s.*\b\d+ failed/m;async function qe(e,t,n,r,i,a){let o=await Q(e,t,n,r,a);if(o.hung||o.stopped||o.code===0||!e.retryArgs||!Ge.test(o.output)||Ke.test(o.output))return o;let s=o.pausedMs===void 0?`machine load`:`after a pause of ${Math.round(o.pausedMs/1e3)} s`;i(`\n──── RETRY ${e.label}: the vitest worker pool did not start in time (${s}, ${w(o.ms)}); running it once more with half the workers ────\n`);let c=await Q({...e,args:e.retryArgs},t,n,r,a),l=o.slow||c.slow,u=[o.peakMemoryGiB,c.peakMemoryGiB].filter(e=>e!==void 0),d=(o.pausedMs??0)+(c.pausedMs??0);return{...c,ms:o.ms+c.ms,output:`${o.output}\n──── retry ────\n${c.output}`,...l&&!c.hung?{slow:!0}:{},...u.length>0?{peakMemoryGiB:Math.max(...u)}:{},...d>0?{pausedMs:d}:{}}}async function Je(e,t={}){if(e.length===0)return[];let{env:n={},heartbeatMs:r=6e4,maxParallel:i,admit:a,sampleMemory:o=j,memorySampleMs:s=process.platform===`win32`?5e3:1e3,pauseSampleMs:c=Ne,pauseGapMs:l=Pe,write:u=Ie,clock:d=K,onSettle:f}=t;if(i!==void 0&&!(Number.isInteger(i)&&i>=1))throw Error(`runTasks: maxParallel must be a whole number of at least 1, not ${i}.`);if(!(Number.isFinite(s)&&s>0))throw Error(`runTasks: memorySampleMs must be a positive number of milliseconds, not ${s}.`);if(!(Number.isFinite(c)&&c>0))throw Error(`runTasks: pauseSampleMs must be a positive number of milliseconds, not ${c}.`);if(!(Number.isFinite(l)&&l>0))throw Error(`runTasks: pauseGapMs must be a positive number of milliseconds, not ${l}.`);let p={sample:o,everyMs:s},m={sampleMs:c,gapMs:l};for(let t of e)Ue(t);let h=i??1/0,g=[],_=()=>h>0?(--h,Promise.resolve()):new Promise(e=>g.push(e)),v=()=>{let e=g.shift();e===void 0?h+=1:e()};u(`\n──── running in parallel${i!==void 0&&i<e.length?`, ${i} at a time`:``}: ${e.map(e=>e.label).join(` · `)} ────\n`);let y=d.now(),b=/* @__PURE__ */ new Set,x=0,S=d.every(r,()=>{let t=e.map(e=>e.label).filter(e=>!b.has(e));u(`still running after ${Math.round((d.now()-y)/1e3)} s: ${t.join(`, `)}\n`)}),C=/* @__PURE__ */ new Map,T;try{T=await Promise.all(e.map(e=>{let t=(async()=>{if(await null,e.after&&C.has(e.after)&&await C.get(e.after),await _(),await a?.(e,()=>x)===!1){v();let t={label:e.label,code:143,stopped:!0,ms:0};return f?.(t),t}u(`\n──── start ${e.label} (limit ${w(e.limitMs)}) ────\n`);let t;x+=1;try{t=await qe(e,n,p,m,u,d)}finally{--x,v()}b.add(t.label);let r=t.peakMemoryGiB===void 0?``:`, peak ${t.peakMemoryGiB.toFixed(1)} GiB`,i=t.stopped?`${t.label} → STOPPED (${w(t.ms)}${r})`:t.hung?`${t.label} → HUNG (${w(t.ms)}${r}, limit ${w(e.limitMs)})`:`${t.label} → ${t.code===0?`ok`:`FAIL`}${t.slow?`, SLOW`:``} (${w(t.ms)}${r}${t.slow?`, limit ${w(e.limitMs)}`:``})`;u(`\n──── ${i} ────\n`),u(t.output.endsWith(`
17
- `)?t.output:`${t.output}\n`);let o={label:t.label,code:t.code,ms:t.ms,...t.hung?{hung:!0}:{},...t.slow?{slow:!0}:{},...t.stopped?{stopped:!0}:{},...t.peakMemoryGiB===void 0?{}:{peakMemoryGiB:t.peakMemoryGiB},...t.pausedMs===void 0?{}:{pausedMs:t.pausedMs}};return f?.(o),o})();return C.set(e.label,t),t}))}finally{S()}return u(`──── group wall time: ${w(Math.round(d.now()-y))} ────\n`),T}function $(e,n){let r=t(`git`,n,{cwd:e,encoding:`utf8`,windowsHide:!0});if(r.error)throw new b(`git failed to start: ${r.error.message}`);return r.status===0?r.stdout.split(`
18
- `).filter(Boolean):null}function Ye(e,t=process.env.GATE_BASE||null){let n=t?$(e,[`diff`,`--name-only`,`--no-renames`,t,`HEAD`]):$(e,[`diff`,`--name-only`,`--no-renames`,`origin/development...HEAD`]);if(n===null)return null;let r=$(e,[`diff`,`--name-only`,`--no-renames`,`HEAD`])??[],i=$(e,[`ls-files`,`--others`,`--exclude-standard`])??[];return[.../* @__PURE__ */ new Set([...n,...r,...i])].sort()}function Xe(e,t){return t||$(e,[`merge-base`,`origin/development`,`HEAD`])?.[0]||null}function Ze(e,t){let n=$(e,[`show`,`${t}:version.json`]);if(n===null)return null;try{let e=JSON.parse(n.join(`
19
- `)),t=typeof e==`object`&&e&&`Version`in e?e.Version:void 0;return typeof t==`string`?t:null}catch{return null}}function Qe(e,t,n){let r=Xe(e,n);if(!r)return!1;let i=Ze(e,r),a=Ze(e,`HEAD`);if(i===null||a===null||i===a)return!1;let o=$(e,[`status`,`--porcelain`,`--`,t]);if(o===null||o.length>0)return!1;let s=$(e,[`diff`,`-U0`,`--no-renames`,r,`HEAD`,`--`,t]);if(s===null)return!1;let c=[];for(let e of s){let t=c.at(-1);e.startsWith(`@@`)?c.push({removed:[],added:[]}):t&&e.startsWith(`-`)?t.removed.push(e.slice(1)):t&&e.startsWith(`+`)&&t.added.push(e.slice(1))}return c.length!==0&&c.every(({removed:e,added:t})=>e.length===t.length&&e.every((e,n)=>e.split(i).join(a)===t[n]))}export{I as GATE_CHROME_MARKER,Ae as HUNG_EXIT_CODE,Me as HUNG_LIMIT_MULTIPLIER,le as LIGHT_SCHEME_ARG,Ee as PHONE_WEB_ORIGIN,Te as RAZOR_ORIGIN,we as REACT_ORIGIN,je as STOPPED_EXIT_CODE,h as accessibilityTree,Xe as baseCommitOf,ge as bootSandboxes,Ye as changedFiles,ke as derivePorts,k as descendantsOf,Ce as describeSandboxDeath,M as endDescendants,F as endProcessTree,y as exitAfterOutput,R as gateOwnerPid,$ as gitLines,D as killPort,W as logEvidence,g as parseAriaSnapshot,Re as pausedMs,oe as playwrightGateArgs,ae as profileDir,T as reachable,se as reapOrphanGateChrome,V as reapOwnGateChrome,Q as runBuffered,Je as runTasks,w as secs,v as shellLine,_e as stopAll,We as stopRunning,K as systemClock,j as treeMemoryGiB,Qe as versionStampOnly};
17
+ `)),C.pid!==void 0&&I(C.pid),x?.(),x=a.after(G,()=>{C.stdout.destroy(),C.stderr.destroy(),T(143)}))}};C.stdout.on(`data`,e=>f.push(e)),C.stderr.on(`data`,e=>f.push(e)),C.on(`close`,e=>T(e??1));let D=C.pid;r!==void 0&&D!==void 0&&(S=a.every(r.everyMs,()=>{try{let e=r.sample(D);e!==null&&(_===void 0||e>_)&&(_=e)}catch(e){v=e instanceof Error?e.message:String(e),S?.()}})),q.add(E),Ke(i,a)})}var Qe=/\[vitest-pool\]: Failed to start \w+ worker|\[vitest-pool-runner\]: Timeout waiting for worker to respond/,$e=/^\s*(Test Files|Tests)\s.*\b\d+ failed/m;async function et(e,t,n,r,i,a){let o=await Q(e,t,n,r,a);if(o.hung||o.stopped||o.code===0||!e.retryArgs||!Qe.test(o.output)||$e.test(o.output))return o;let s=o.pausedMs===void 0?`machine load`:`after a pause of ${Math.round(o.pausedMs/1e3)} s`;i(`\n──── RETRY ${e.label}: the vitest worker pool did not start in time (${s}, ${j(o.ms)}); running it once more with half the workers ────\n`);let c=await Q({...e,args:e.retryArgs},t,n,r,a),l=o.slow||c.slow,u=[o.peakMemoryGiB,c.peakMemoryGiB].filter(e=>e!==void 0),d=(o.pausedMs??0)+(c.pausedMs??0);return{...c,ms:o.ms+c.ms,output:`${o.output}\n──── retry ────\n${c.output}`,...l&&!c.hung?{slow:!0}:{},...u.length>0?{peakMemoryGiB:Math.max(...u)}:{},...d>0?{pausedMs:d}:{}}}async function tt(e,t={}){if(e.length===0)return[];let{env:n={},heartbeatMs:r=6e4,maxParallel:i,admit:a,sampleMemory:o=le,memorySampleMs:s=process.platform===`win32`?5e3:1e3,pauseSampleMs:c=U,pauseGapMs:l=W,write:u=Ue,clock:d=K,onSettle:f}=t;if(i!==void 0&&!(Number.isInteger(i)&&i>=1))throw Error(`runTasks: maxParallel must be a whole number of at least 1, not ${i}.`);if(!(Number.isFinite(s)&&s>0))throw Error(`runTasks: memorySampleMs must be a positive number of milliseconds, not ${s}.`);if(!(Number.isFinite(c)&&c>0))throw Error(`runTasks: pauseSampleMs must be a positive number of milliseconds, not ${c}.`);if(!(Number.isFinite(l)&&l>0))throw Error(`runTasks: pauseGapMs must be a positive number of milliseconds, not ${l}.`);let p={sample:o,everyMs:s},m={sampleMs:c,gapMs:l};for(let t of e)Xe(t);let h=i??1/0,g=[],_=()=>h>0?(--h,Promise.resolve()):new Promise(e=>g.push(e)),v=()=>{let e=g.shift();e===void 0?h+=1:e()};u(`\n──── running in parallel${i!==void 0&&i<e.length?`, ${i} at a time`:``}: ${e.map(e=>e.label).join(` · `)} ────\n`);let y=d.now(),b=/* @__PURE__ */ new Set,x=0,S=d.every(r,()=>{let t=e.map(e=>e.label).filter(e=>!b.has(e));u(`still running after ${Math.round((d.now()-y)/1e3)} s: ${t.join(`, `)}\n`)}),C=/* @__PURE__ */ new Map,w;try{w=await Promise.all(e.map(e=>{let t=(async()=>{if(await null,e.after&&C.has(e.after)&&await C.get(e.after),await _(),await a?.(e,()=>x)===!1){v();let t={label:e.label,code:143,stopped:!0,ms:0};return f?.(t),t}u(`\n──── start ${e.label} (limit ${j(e.limitMs)}) ────\n`);let t;x+=1;try{t=await et(e,n,p,m,u,d)}finally{--x,v()}b.add(t.label);let r=t.peakMemoryGiB===void 0?``:`, peak ${t.peakMemoryGiB.toFixed(1)} GiB`,i=t.stopped?`${t.label} → STOPPED (${j(t.ms)}${r})`:t.hung?`${t.label} → HUNG (${j(t.ms)}${r}, limit ${j(e.limitMs)})`:`${t.label} → ${t.code===0?`ok`:`FAIL`}${t.slow?`, SLOW`:``} (${j(t.ms)}${r}${t.slow?`, limit ${j(e.limitMs)}`:``})`;u(`\n──── ${i} ────\n`),u(t.output.endsWith(`
18
+ `)?t.output:`${t.output}\n`);let o={label:t.label,code:t.code,ms:t.ms,...t.hung?{hung:!0}:{},...t.slow?{slow:!0}:{},...t.stopped?{stopped:!0}:{},...t.peakMemoryGiB===void 0?{}:{peakMemoryGiB:t.peakMemoryGiB},...t.pausedMs===void 0?{}:{pausedMs:t.pausedMs}};return f?.(o),o})();return C.set(e.label,t),t}))}finally{S()}return u(`──── group wall time: ${j(Math.round(d.now()-y))} ────\n`),w}function $(e,n){let r=t(`git`,n,{cwd:e,encoding:`utf8`,windowsHide:!0});if(r.error)throw new S(`git failed to start: ${r.error.message}`);return r.status===0?r.stdout.split(`
19
+ `).filter(Boolean):null}function nt(e,t=process.env.GATE_BASE||null){let n=t?$(e,[`diff`,`--name-only`,`--no-renames`,t,`HEAD`]):$(e,[`diff`,`--name-only`,`--no-renames`,`origin/development...HEAD`]);if(n===null)return null;let r=$(e,[`diff`,`--name-only`,`--no-renames`,`HEAD`])??[],i=$(e,[`ls-files`,`--others`,`--exclude-standard`])??[];return[.../* @__PURE__ */ new Set([...n,...r,...i])].sort()}function rt(e,t){return t||$(e,[`merge-base`,`origin/development`,`HEAD`])?.[0]||null}function it(e,t){let n=$(e,[`show`,`${t}:version.json`]);if(n===null)return null;try{let e=JSON.parse(n.join(`
20
+ `)),t=typeof e==`object`&&e&&`Version`in e?e.Version:void 0;return typeof t==`string`?t:null}catch{return null}}function at(e,t,n){let r=rt(e,n);if(!r)return!1;let i=it(e,r),a=it(e,`HEAD`);if(i===null||a===null||i===a)return!1;let o=$(e,[`status`,`--porcelain`,`--`,t]);if(o===null||o.length>0)return!1;let s=$(e,[`diff`,`-U0`,`--no-renames`,r,`HEAD`,`--`,t]);if(s===null)return!1;let c=[];for(let e of s){let t=c.at(-1);e.startsWith(`@@`)?c.push({removed:[],added:[]}):t&&e.startsWith(`-`)?t.removed.push(e.slice(1)):t&&e.startsWith(`+`)&&t.added.push(e.slice(1))}return c.length!==0&&c.every(({removed:e,added:t})=>e.length===t.length&&e.every((e,n)=>e.split(i).join(a)===t[n]))}export{L as GATE_CHROME_MARKER,Be as HUNG_EXIT_CODE,He as HUNG_LIMIT_MULTIPLIER,ye as LIGHT_SCHEME_ARG,Ie as PHONE_WEB_ORIGIN,Fe as RAZOR_ORIGIN,Pe as REACT_ORIGIN,Ve as STOPPED_EXIT_CODE,g as accessibilityTree,rt as baseCommitOf,Ee as bootSandboxes,nt as changedFiles,ze as derivePorts,N as descendantsOf,Ne as describeSandboxDeath,F as endDescendants,I as endProcessTree,x as exitAfterOutput,R as gateOwnerPid,$ as gitLines,M as killPort,V as logEvidence,_ as parseAriaSnapshot,Ge as pausedMs,me as playwrightGateArgs,pe as profileDir,te as reachable,ge as reapOrphanGateChrome,_e as reapOwnGateChrome,Q as runBuffered,tt as runTasks,j as secs,b as shellLine,De as stopAll,Ze as stopRunning,K as systemClock,le as treeMemoryGiB,at as versionStampOnly};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/sandbox-gate",
3
- "version": "0.179.0",
3
+ "version": "0.181.0",
4
4
  "description": "The gate runner Webority repos share: sandbox boot on ports derived from the checkout, a buffered parallel task runner, headless Chrome ownership and orphan reaping, accessibility trees from Playwright, and changed-file helpers for a quick scope. Node only.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -18,14 +18,38 @@
18
18
  "types": "./dist/index.d.ts",
19
19
  "default": "./dist/sandbox-gate.js"
20
20
  },
21
+ "./phone-web": {
22
+ "types": "./dist/phoneWeb/index.d.ts",
23
+ "default": "./dist/phoneWeb/index.js"
24
+ },
21
25
  "./package.json": "./package.json"
22
26
  },
27
+ "peerDependencies": {
28
+ "@babel/core": "^7.29.7",
29
+ "@rolldown/plugin-babel": "^0.1.7",
30
+ "@vitejs/plugin-react": "^6.0.0",
31
+ "vite": "^8.3.6"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "@babel/core": {
35
+ "optional": true
36
+ },
37
+ "@rolldown/plugin-babel": {
38
+ "optional": true
39
+ },
40
+ "@vitejs/plugin-react": {
41
+ "optional": true
42
+ },
43
+ "vite": {
44
+ "optional": true
45
+ }
46
+ },
23
47
  "engines": {
24
48
  "node": ">=24.15 <27"
25
49
  },
26
50
  "devDependencies": {
27
51
  "@types/node": "^24.0.0",
28
- "@webority/biome-config": "0.179.0",
52
+ "@webority/biome-config": "0.181.0",
29
53
  "typescript": "^7.0.2",
30
54
  "vite": "^8.3.6"
31
55
  },