@ait-co/devtools 0.1.108 → 0.1.109

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 (33) hide show
  1. package/dist/bundle-KFs4t-wc.d.ts +96 -0
  2. package/dist/bundle-KFs4t-wc.d.ts.map +1 -0
  3. package/dist/mcp/cli.js +186 -40
  4. package/dist/mcp/cli.js.map +1 -1
  5. package/dist/mcp/server.js +3 -3
  6. package/dist/mcp/server.js.map +1 -1
  7. package/dist/panel/index.js +1 -1
  8. package/dist/{pool-Dkp7I9Bf.d.ts → pool-CuVMzWGB.d.ts} +5 -5
  9. package/dist/{pool-Dkp7I9Bf.d.ts.map → pool-CuVMzWGB.d.ts.map} +1 -1
  10. package/dist/{relay-worker-BzFQ3fv9.d.ts → relay-worker-xxanNQGs.d.ts} +3 -3
  11. package/dist/relay-worker-xxanNQGs.d.ts.map +1 -0
  12. package/dist/{runtime-ORdrpizY.d.ts → runtime-Wi5d6Ywz.d.ts} +3 -3
  13. package/dist/{runtime-ORdrpizY.d.ts.map → runtime-Wi5d6Ywz.d.ts.map} +1 -1
  14. package/dist/test-runner/bundle.d.ts +1 -1
  15. package/dist/test-runner/bundle.js +148 -11
  16. package/dist/test-runner/bundle.js.map +1 -1
  17. package/dist/test-runner/cli.d.ts +59 -14
  18. package/dist/test-runner/cli.d.ts.map +1 -1
  19. package/dist/test-runner/cli.js +171 -32
  20. package/dist/test-runner/cli.js.map +1 -1
  21. package/dist/test-runner/config.d.ts +1 -1
  22. package/dist/test-runner/pool.d.ts +1 -1
  23. package/dist/test-runner/relay-worker.d.ts +1 -1
  24. package/dist/test-runner/relay-worker.js.map +1 -1
  25. package/dist/test-runner/rpc.d.ts +1 -1
  26. package/dist/test-runner/rpc.d.ts.map +1 -1
  27. package/dist/test-runner/rpc.js +1 -1
  28. package/dist/test-runner/rpc.js.map +1 -1
  29. package/dist/test-runner/task-graph.d.ts +1 -1
  30. package/package.json +1 -1
  31. package/dist/bundle-BJm5jk56.d.ts +0 -49
  32. package/dist/bundle-BJm5jk56.d.ts.map +0 -1
  33. package/dist/relay-worker-BzFQ3fv9.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
- import { t as BundleOptions } from "./bundle-BJm5jk56.js";
1
+ import { t as BundleOptions } from "./bundle-KFs4t-wc.js";
2
2
  import { t as CdpConnection } from "./cdp-connection-C0AP0tH2.js";
3
- import { n as TestResult, t as RunReport } from "./runtime-ORdrpizY.js";
3
+ import { n as TestResult, t as RunReport } from "./runtime-Wi5d6Ywz.js";
4
4
 
5
5
  //#region src/test-runner/relay-worker.d.ts
6
6
  /** Per-file result in the aggregate `RunReport`. */
@@ -71,4 +71,4 @@ declare function flattenResults(report: RelayRunReport): Array<TestResult & {
71
71
  }>;
72
72
  //#endregion
73
73
  export { runTestFilesOverRelay as a, flattenResults as i, RelayRunOptions as n, RelayRunReport as r, FileResult as t };
74
- //# sourceMappingURL=relay-worker-BzFQ3fv9.d.ts.map
74
+ //# sourceMappingURL=relay-worker-xxanNQGs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-worker-xxanNQGs.d.ts","names":[],"sources":["../src/test-runner/relay-worker.ts"],"mappings":";;;;;;UAuBiB,UAAA;EAcf;EAZA,IAAA;EAcA;EAZA,MAAA,EAAQ,SAAA;IAAc,KAAA;EAAA;AAAA;;UAIP,cAAA;EAiBA;EAff,SAAA;;EAEA,QAAA;EAiBA;EAfA,KAAA,EAAO,UAAA;EAoBP;EAlBA,MAAA;IACE,MAAA;IACA,MAAA;IACA,OAAA;IACA,KAAA;EAAA;AAAA;;UAKa,eAAA;EAqCP;;;EAjCR,aAAA,GAAgB,aAAA;EA+BhB;;;;EA1BA,SAAA;AAAA;;AAoFF;;;;;;;;;;;;;;;;;;;;iBA5DsB,qBAAA,CACpB,UAAA,EAAY,aAAA,EACZ,KAAA,YACA,IAAA,GAAO,eAAA,GACN,OAAA,CAAQ,cAAA;;;;;iBAwDK,cAAA,CAAe,MAAA,EAAQ,cAAA,GAAiB,KAAA,CAAM,UAAA;EAAe,IAAA;AAAA"}
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * @vitest/runner and @vitest/expect are listed as dependencies so that the
15
15
  * package's type contracts are available and so the browser-compatible subsets
16
- * can be referenced. Full pool integration (PoolRunnerInitializer) is tracked
17
- * in issue #645.
16
+ * can be referenced. The Vitest custom pool that drives this runtime through
17
+ * Vitest's `PoolRunnerInitializer` lives in `pool.ts`.
18
18
  *
19
19
  * NOTE: this file is imported by type from Node-side code (rpc.ts / relay-worker.ts)
20
20
  * for the RunReport / TestResult type shapes. The runtime ITSELF is not imported
@@ -47,4 +47,4 @@ interface RunReport {
47
47
  }
48
48
  //#endregion
49
49
  export { TestResult as n, RunReport as t };
50
- //# sourceMappingURL=runtime-ORdrpizY.d.ts.map
50
+ //# sourceMappingURL=runtime-Wi5d6Ywz.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-ORdrpizY.d.ts","names":[],"sources":["../src/test-runner/runtime.ts"],"mappings":";;AA8BA;;;;;;;;;;AAYA;;;;;;;;;;;;;;UAZiB,UAAA;;EAEf,IAAA;;EAEA,MAAA;;EAEA,QAAA;;EAEA,KAAA;AAAA;;UAIe,SAAA;;EAEf,SAAA;;EAEA,QAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;EACA,KAAA,EAAO,UAAA;AAAA"}
1
+ {"version":3,"file":"runtime-Wi5d6Ywz.d.ts","names":[],"sources":["../src/test-runner/runtime.ts"],"mappings":";;AA8BA;;;;;;;;;;AAYA;;;;;;;;;;;;;;UAZiB,UAAA;;EAEf,IAAA;;EAEA,MAAA;;EAEA,QAAA;;EAEA,KAAA;AAAA;;UAIe,SAAA;;EAEf,SAAA;;EAEA,QAAA;EACA,MAAA;EACA,MAAA;EACA,OAAA;EACA,KAAA,EAAO,UAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { n as BundleResult, r as bundleTestFile, t as BundleOptions } from "../bundle-BJm5jk56.js";
1
+ import { n as BundleResult, r as bundleTestFile, t as BundleOptions } from "../bundle-KFs4t-wc.js";
2
2
  export { BundleOptions, BundleResult, bundleTestFile };
@@ -1,14 +1,59 @@
1
+ import { accessSync } from "node:fs";
2
+ import * as fs from "node:fs/promises";
1
3
  import * as path from "node:path";
4
+ import { fileURLToPath } from "node:url";
2
5
  //#region src/test-runner/bundle.ts
3
6
  /**
4
7
  * esbuild-based bundler for user test files.
5
8
  *
6
9
  * Bundles a single test file into a self-contained IIFE string that can be
7
- * injected into a WebView via `Runtime.evaluate`. The user's SDK imports
8
- * (`@apps-in-toss/web-framework` and sub-paths) are intercepted via an
9
- * esbuild plugin that redirects them to `window.__sdk`, which the in-app
10
- * debug gate (`src/in-app/auto.ts`) installs as a namespace mirror of the
11
- * SDK exports (works for both 2.x and 3.x SDK).
10
+ * injected into a WebView via `Runtime.evaluate`. The bundle includes the
11
+ * test runtime (`runtime.ts`), which provides `describe/it/test/expect` and
12
+ * the `runTestModule(factory)` entry point.
13
+ *
14
+ * ## How the wiring works
15
+ *
16
+ * The bundle exposes two exports on `globalThis.__testBundle`:
17
+ * - `runTestModule` — the runtime's entry function.
18
+ * - `__userFactory` — an async function whose body is the user's top-level
19
+ * test registration code (describe/it/test calls).
20
+ *
21
+ * The Node-side RPC (`rpc.ts`) calls:
22
+ * `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`
23
+ *
24
+ * `runTestModule` then installs `describe/it/test/expect` as globals, invokes
25
+ * the factory (which registers all tests), runs them, and returns a `RunReport`.
26
+ *
27
+ * ## Why a factory wrapper is needed
28
+ *
29
+ * Naively adding the runtime to `entryPoints` and bundling the user file would
30
+ * fail for two reasons:
31
+ * 1. `describe/it/test/expect` from the runtime are module-local in the IIFE
32
+ * scope. The user's top-level `describe(...)` calls expect them as globals —
33
+ * they are not globals until `runTestModule` installs them.
34
+ * 2. Even with globals pre-installed, the user file runs at IIFE-evaluation
35
+ * time, before the RPC layer calls `runTestModule` to reset state and start
36
+ * the test clock.
37
+ *
38
+ * The factory approach solves both: the user's registration code is deferred
39
+ * into a function that `runTestModule` calls AFTER installing the globals.
40
+ *
41
+ * ## Factory extraction algorithm
42
+ *
43
+ * The `userFactoryPlugin` reads the user file and splits lines into:
44
+ * - **top-level**: `import …` and re-export lines — kept at module scope
45
+ * (the only valid position for static `import` in ESM).
46
+ * - **body**: all other statements — moved into the body of the exported
47
+ * `__userFactory` async function.
48
+ *
49
+ * esbuild processes the re-generated module, following each static import
50
+ * through the normal dependency graph (including the SDK-redirect plugin).
51
+ *
52
+ * ## SDK redirect
53
+ *
54
+ * Imports of `@apps-in-toss/web-framework` (and sub-paths) are intercepted via
55
+ * the `sdkRedirectPlugin` and replaced with a virtual `window.__sdk` proxy that
56
+ * `src/in-app/auto.ts` installs at runtime. This works for both 2.x and 3.x SDK.
12
57
  *
13
58
  * SECRET-HANDLING: the returned bundle code is caller-managed; never log it.
14
59
  */
@@ -58,10 +103,90 @@ module.exports = __proxy;
58
103
  };
59
104
  }
60
105
  /**
106
+ * esbuild plugin that transforms the user test file into a module that exports
107
+ * an async `__userFactory` function. The factory defers the user's top-level
108
+ * test registration code (describe/it/test calls) so it only runs when
109
+ * `runTestModule(__userFactory)` explicitly invokes it — AFTER the runtime has
110
+ * installed describe/it/test/expect as globals.
111
+ *
112
+ * Algorithm:
113
+ * - Lines matching import declarations or re-export statements are kept at
114
+ * module top-level (the only valid ESM position for static `import`).
115
+ * - All other lines (describe/it/test calls, local declarations, etc.) are
116
+ * moved into the body of the exported async factory function.
117
+ *
118
+ * This preserves SDK import resolution (the sdk-redirect plugin processes
119
+ * top-level imports normally) while deferring test registration to the factory.
120
+ */
121
+ function userFactoryPlugin(absPath) {
122
+ const NAMESPACE = "user-test-factory";
123
+ return {
124
+ name: "user-test-factory",
125
+ setup(build) {
126
+ build.onResolve({ filter: /^user-test-factory$/ }, () => ({
127
+ path: absPath,
128
+ namespace: NAMESPACE
129
+ }));
130
+ build.onLoad({
131
+ filter: /.*/,
132
+ namespace: NAMESPACE
133
+ }, async (args) => {
134
+ const lines = (await fs.readFile(args.path, "utf8")).split("\n");
135
+ const topLevelLines = [];
136
+ const bodyLines = [];
137
+ const EXPORT_DECLARATION_RE = /^(export\s+)(default\s+|async\s+function\s+|function\s+|class\s+|const\s+|let\s+|var\s+)/;
138
+ for (const line of lines) {
139
+ const trimmed = line.trimStart();
140
+ const indent = line.slice(0, line.length - trimmed.length);
141
+ if (trimmed.startsWith("import ") || trimmed.startsWith("import{") || trimmed.startsWith("import'") || trimmed.startsWith("import\"")) topLevelLines.push(line);
142
+ else if (trimmed.startsWith("export ")) if (trimmed.match(EXPORT_DECLARATION_RE)) bodyLines.push(indent + trimmed.slice(7));
143
+ else topLevelLines.push(line);
144
+ else bodyLines.push(line);
145
+ }
146
+ return {
147
+ contents: [
148
+ ...topLevelLines,
149
+ "",
150
+ "// biome-ignore lint: generated factory wrapper",
151
+ "export default async function __userFactory(): Promise<void> {",
152
+ ...bodyLines.map((l) => ` ${l}`),
153
+ "}"
154
+ ].join("\n"),
155
+ loader: "ts",
156
+ resolveDir: path.dirname(absPath)
157
+ };
158
+ });
159
+ }
160
+ };
161
+ }
162
+ /**
163
+ * Returns the absolute path to the co-located runtime module.
164
+ *
165
+ * In the source tree (running via tsx / ts-node) the file is `runtime.ts`.
166
+ * After `tsdown` compiles to `dist/test-runner/`, it becomes `runtime.js`.
167
+ * We try both extensions to support both environments.
168
+ */
169
+ function getRuntimePath() {
170
+ const dir = path.dirname(fileURLToPath(import.meta.url));
171
+ for (const ext of [".ts", ".js"]) {
172
+ const candidate = path.join(dir, `runtime${ext}`);
173
+ try {
174
+ accessSync(candidate);
175
+ return candidate;
176
+ } catch {}
177
+ }
178
+ return path.join(dir, "runtime.js");
179
+ }
180
+ /**
61
181
  * Bundles `absPath` into a single IIFE string suitable for `Runtime.evaluate`.
62
182
  *
63
- * The IIFE installs `window.__testBundle` (or the custom `globalName`) with
64
- * `runTestModule` as the callable entry point.
183
+ * The IIFE installs `window.__testBundle` (or the custom `globalName`) with:
184
+ * - `runTestModule` the runtime entry (from `runtime.ts`).
185
+ * - `__userFactory` — an async function wrapping the user's test registration
186
+ * code so it runs AFTER `runTestModule` installs the globals.
187
+ *
188
+ * Callers (rpc.ts) invoke:
189
+ * `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`
65
190
  *
66
191
  * @param absPath - Absolute path to the user test file.
67
192
  * @param opts - Optional bundling overrides.
@@ -69,17 +194,29 @@ module.exports = __proxy;
69
194
  async function bundleTestFile(absPath, opts) {
70
195
  const globalName = opts?.globalName ?? "__testBundle";
71
196
  const extraExternals = opts?.extraExternals ?? [];
72
- const result = await (await import("esbuild")).build({
73
- entryPoints: [absPath],
197
+ const esbuild = await import("esbuild");
198
+ const runtimePath = getRuntimePath();
199
+ const wrapperContent = [
200
+ `import { runTestModule } from ${JSON.stringify(runtimePath)};`,
201
+ `import __userFactory from "user-test-factory";`,
202
+ `export { runTestModule, __userFactory };`
203
+ ].join("\n");
204
+ const result = await esbuild.build({
205
+ stdin: {
206
+ contents: wrapperContent,
207
+ loader: "ts",
208
+ resolveDir: path.dirname(absPath)
209
+ },
74
210
  bundle: true,
75
211
  format: "iife",
76
212
  globalName,
77
213
  platform: "browser",
78
214
  target: "es2022",
79
215
  write: false,
80
- plugins: [sdkRedirectPlugin()],
216
+ plugins: [userFactoryPlugin(absPath), sdkRedirectPlugin()],
81
217
  external: extraExternals,
82
- treeShaking: true
218
+ treeShaking: true,
219
+ footer: { js: `globalThis[${JSON.stringify(globalName)}] = ${globalName};` }
83
220
  });
84
221
  const warnings = result.warnings.map((w) => `${path.relative(process.cwd(), w.location?.file ?? "")}:${w.location?.line ?? "?"}: ${w.text}`);
85
222
  const outputFile = result.outputFiles?.[0];
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","names":[],"sources":["../../src/test-runner/bundle.ts"],"sourcesContent":["/**\n * esbuild-based bundler for user test files.\n *\n * Bundles a single test file into a self-contained IIFE string that can be\n * injected into a WebView via `Runtime.evaluate`. The user's SDK imports\n * (`@apps-in-toss/web-framework` and sub-paths) are intercepted via an\n * esbuild plugin that redirects them to `window.__sdk`, which the in-app\n * debug gate (`src/in-app/auto.ts`) installs as a namespace mirror of the\n * SDK exports (works for both 2.x and 3.x SDK).\n *\n * SECRET-HANDLING: the returned bundle code is caller-managed; never log it.\n */\n\nimport * as path from 'node:path';\n// esbuild is imported for TYPES only at module scope; the runtime module is\n// loaded lazily inside `bundleTestFile` via dynamic import. esbuild runs a\n// startup invariant check (`TextEncoder().encode('') instanceof Uint8Array`)\n// that fails in a jsdom realm — a static import would break every MCP/test\n// module that merely *imports* this file's transitive graph (e.g. debug-server →\n// run_tests). Lazy load keeps esbuild off the import graph until a bundle is\n// actually built, and mirrors the cloudflared/chii dynamic-import precedent.\nimport type * as esbuild from 'esbuild';\n\n/** Options accepted by `bundleTestFile`. */\nexport interface BundleOptions {\n /**\n * Additional esbuild `external` patterns. The SDK package\n * (`@apps-in-toss/web-framework` and `@apps-in-toss/web-framework/*`) is\n * always handled by the SDK redirect plugin — callers may add more patterns\n * to be left as globals.\n */\n extraExternals?: string[];\n /**\n * Global name for the IIFE output object. Defaults to `__testBundle`.\n * The runtime entry uses this to call `__testBundle.runTestModule()`.\n */\n globalName?: string;\n}\n\n/**\n * The result of bundling a test file.\n * `code` is a self-contained IIFE string ready for `Runtime.evaluate`.\n */\nexport interface BundleResult {\n code: string;\n warnings: string[];\n}\n\n/** The SDK package name that mini-app test code imports from. */\nconst SDK_PACKAGE = '@apps-in-toss/web-framework';\n\n/**\n * Matches the bare SDK package and any sub-path import\n * (`@apps-in-toss/web-framework`, `@apps-in-toss/web-framework/foo`).\n * Built from {@link SDK_PACKAGE} so the package name has a single source.\n */\nconst SDK_IMPORT_FILTER = new RegExp(`^${SDK_PACKAGE.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}`);\n\n/**\n * esbuild plugin that intercepts SDK imports and redirects them to the\n * `window.__sdk` proxy that `src/in-app/auto.ts` installs at runtime.\n *\n * Strategy: for every import of `@apps-in-toss/web-framework` (or sub-paths),\n * esbuild resolves it to a virtual module that re-exports all named exports\n * via `window.__sdk[name]`. This avoids bundling the real SDK (which may not\n * be available in the test environment) while still making named imports work.\n *\n * If `window.__sdk` is absent (non-dog-food build), every access throws a\n * descriptive error rather than returning `undefined` silently.\n */\nfunction sdkRedirectPlugin(): esbuild.Plugin {\n return {\n name: 'sdk-redirect',\n setup(build) {\n // Match the bare package and any sub-path imports\n build.onResolve({ filter: SDK_IMPORT_FILTER }, (args) => ({\n path: args.path,\n namespace: 'sdk-redirect',\n }));\n\n build.onLoad({ filter: /.*/, namespace: 'sdk-redirect' }, () => ({\n // Generate a virtual CommonJS-style module so that esbuild does NOT perform\n // strict named-export matching. When `format:'iife'` bundles a CJS module,\n // it wraps it with its own __toCommonJS helper and satisfies named imports\n // via property access on the module.exports object — which is our Proxy.\n // This means `import { getPlatformOS } from '...'` becomes\n // `__proxy.getPlatformOS` at runtime, which correctly reads from window.__sdk.\n contents: `\nvar __proxy = (typeof window !== 'undefined' && window.__sdk)\n ? window.__sdk\n : new Proxy({}, {\n get: function(_t, p) {\n throw new Error('window.__sdk is not installed — run in a dog-food build. Missing: ' + String(p));\n }\n });\nmodule.exports = __proxy;\n`,\n loader: 'js',\n }));\n },\n };\n}\n\n/**\n * Bundles `absPath` into a single IIFE string suitable for `Runtime.evaluate`.\n *\n * The IIFE installs `window.__testBundle` (or the custom `globalName`) with\n * `runTestModule` as the callable entry point.\n *\n * @param absPath - Absolute path to the user test file.\n * @param opts - Optional bundling overrides.\n */\nexport async function bundleTestFile(absPath: string, opts?: BundleOptions): Promise<BundleResult> {\n const globalName = opts?.globalName ?? '__testBundle';\n const extraExternals = opts?.extraExternals ?? [];\n\n // Lazy load esbuild at call time (see the module-scope import note).\n const esbuild = await import('esbuild');\n\n const result = await esbuild.build({\n entryPoints: [absPath],\n bundle: true,\n format: 'iife',\n globalName,\n platform: 'browser',\n target: 'es2022',\n write: false,\n plugins: [sdkRedirectPlugin()],\n // Extra externals are left as global references (caller's responsibility\n // to ensure they exist in the WebView context).\n external: extraExternals,\n // Keep bundle self-contained; no dynamic require/import at runtime.\n treeShaking: true,\n });\n\n const warnings = result.warnings.map(\n (w) =>\n `${path.relative(process.cwd(), w.location?.file ?? '')}:${w.location?.line ?? '?'}: ${w.text}`,\n );\n\n const outputFile = result.outputFiles?.[0];\n if (!outputFile) {\n throw new Error('bundleTestFile: esbuild produced no output — check entryPoints');\n }\n\n return { code: outputFile.text, warnings };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAM,oBAAoB,IAAI,OAAO,IAPjB,8BAOiC,QAAQ,uBAAuB,OAAO,GAAG;;;;;;;;;;;;;AAc9F,SAAS,oBAAoC;AAC3C,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AAEX,SAAM,UAAU,EAAE,QAAQ,mBAAmB,GAAG,UAAU;IACxD,MAAM,KAAK;IACX,WAAW;IACZ,EAAE;AAEH,SAAM,OAAO;IAAE,QAAQ;IAAM,WAAW;IAAgB,SAAS;IAO/D,UAAU;;;;;;;;;;IAUV,QAAQ;IACT,EAAE;;EAEN;;;;;;;;;;;AAYH,eAAsB,eAAe,SAAiB,MAA6C;CACjG,MAAM,aAAa,MAAM,cAAc;CACvC,MAAM,iBAAiB,MAAM,kBAAkB,EAAE;CAKjD,MAAM,SAAS,OAFC,MAAM,OAAO,YAEA,MAAM;EACjC,aAAa,CAAC,QAAQ;EACtB,QAAQ;EACR,QAAQ;EACR;EACA,UAAU;EACV,QAAQ;EACR,OAAO;EACP,SAAS,CAAC,mBAAmB,CAAC;EAG9B,UAAU;EAEV,aAAa;EACd,CAAC;CAEF,MAAM,WAAW,OAAO,SAAS,KAC9B,MACC,GAAG,KAAK,SAAS,QAAQ,KAAK,EAAE,EAAE,UAAU,QAAQ,GAAG,CAAC,GAAG,EAAE,UAAU,QAAQ,IAAI,IAAI,EAAE,OAC5F;CAED,MAAM,aAAa,OAAO,cAAc;AACxC,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,iEAAiE;AAGnF,QAAO;EAAE,MAAM,WAAW;EAAM;EAAU"}
1
+ {"version":3,"file":"bundle.js","names":[],"sources":["../../src/test-runner/bundle.ts"],"sourcesContent":["/**\n * esbuild-based bundler for user test files.\n *\n * Bundles a single test file into a self-contained IIFE string that can be\n * injected into a WebView via `Runtime.evaluate`. The bundle includes the\n * test runtime (`runtime.ts`), which provides `describe/it/test/expect` and\n * the `runTestModule(factory)` entry point.\n *\n * ## How the wiring works\n *\n * The bundle exposes two exports on `globalThis.__testBundle`:\n * - `runTestModule` — the runtime's entry function.\n * - `__userFactory` — an async function whose body is the user's top-level\n * test registration code (describe/it/test calls).\n *\n * The Node-side RPC (`rpc.ts`) calls:\n * `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`\n *\n * `runTestModule` then installs `describe/it/test/expect` as globals, invokes\n * the factory (which registers all tests), runs them, and returns a `RunReport`.\n *\n * ## Why a factory wrapper is needed\n *\n * Naively adding the runtime to `entryPoints` and bundling the user file would\n * fail for two reasons:\n * 1. `describe/it/test/expect` from the runtime are module-local in the IIFE\n * scope. The user's top-level `describe(...)` calls expect them as globals —\n * they are not globals until `runTestModule` installs them.\n * 2. Even with globals pre-installed, the user file runs at IIFE-evaluation\n * time, before the RPC layer calls `runTestModule` to reset state and start\n * the test clock.\n *\n * The factory approach solves both: the user's registration code is deferred\n * into a function that `runTestModule` calls AFTER installing the globals.\n *\n * ## Factory extraction algorithm\n *\n * The `userFactoryPlugin` reads the user file and splits lines into:\n * - **top-level**: `import …` and re-export lines — kept at module scope\n * (the only valid position for static `import` in ESM).\n * - **body**: all other statements — moved into the body of the exported\n * `__userFactory` async function.\n *\n * esbuild processes the re-generated module, following each static import\n * through the normal dependency graph (including the SDK-redirect plugin).\n *\n * ## SDK redirect\n *\n * Imports of `@apps-in-toss/web-framework` (and sub-paths) are intercepted via\n * the `sdkRedirectPlugin` and replaced with a virtual `window.__sdk` proxy that\n * `src/in-app/auto.ts` installs at runtime. This works for both 2.x and 3.x SDK.\n *\n * SECRET-HANDLING: the returned bundle code is caller-managed; never log it.\n */\n\nimport { accessSync } from 'node:fs';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n// esbuild is imported for TYPES only at module scope; the runtime module is\n// loaded lazily inside `bundleTestFile` via dynamic import. esbuild runs a\n// startup invariant check (`TextEncoder().encode('') instanceof Uint8Array`)\n// that fails in a jsdom realm — a static import would break every MCP/test\n// module that merely *imports* this file's transitive graph (e.g. debug-server →\n// run_tests). Lazy load keeps esbuild off the import graph until a bundle is\n// actually built, and mirrors the cloudflared/chii dynamic-import precedent.\nimport type * as esbuild from 'esbuild';\n\n/** Options accepted by `bundleTestFile`. */\nexport interface BundleOptions {\n /**\n * Additional esbuild `external` patterns. The SDK package\n * (`@apps-in-toss/web-framework` and `@apps-in-toss/web-framework/*`) is\n * always handled by the SDK redirect plugin — callers may add more patterns\n * to be left as globals.\n */\n extraExternals?: string[];\n /**\n * Global name for the IIFE output object. Defaults to `__testBundle`.\n * The runtime entry uses this to call `__testBundle.runTestModule(__userFactory)`.\n */\n globalName?: string;\n}\n\n/**\n * The result of bundling a test file.\n * `code` is a self-contained IIFE string ready for `Runtime.evaluate`.\n */\nexport interface BundleResult {\n code: string;\n warnings: string[];\n}\n\n/** The SDK package name that mini-app test code imports from. */\nconst SDK_PACKAGE = '@apps-in-toss/web-framework';\n\n/**\n * Matches the bare SDK package and any sub-path import\n * (`@apps-in-toss/web-framework`, `@apps-in-toss/web-framework/foo`).\n * Built from {@link SDK_PACKAGE} so the package name has a single source.\n */\nconst SDK_IMPORT_FILTER = new RegExp(`^${SDK_PACKAGE.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}`);\n\n/**\n * esbuild plugin that intercepts SDK imports and redirects them to the\n * `window.__sdk` proxy that `src/in-app/auto.ts` installs at runtime.\n *\n * Strategy: for every import of `@apps-in-toss/web-framework` (or sub-paths),\n * esbuild resolves it to a virtual module that re-exports all named exports\n * via `window.__sdk[name]`. This avoids bundling the real SDK (which may not\n * be available in the test environment) while still making named imports work.\n *\n * If `window.__sdk` is absent (non-dog-food build), every access throws a\n * descriptive error rather than returning `undefined` silently.\n */\nfunction sdkRedirectPlugin(): esbuild.Plugin {\n return {\n name: 'sdk-redirect',\n setup(build) {\n // Match the bare package and any sub-path imports\n build.onResolve({ filter: SDK_IMPORT_FILTER }, (args) => ({\n path: args.path,\n namespace: 'sdk-redirect',\n }));\n\n build.onLoad({ filter: /.*/, namespace: 'sdk-redirect' }, () => ({\n // Generate a virtual CommonJS-style module so that esbuild does NOT perform\n // strict named-export matching. When `format:'iife'` bundles a CJS module,\n // it wraps it with its own __toCommonJS helper and satisfies named imports\n // via property access on the module.exports object — which is our Proxy.\n // This means `import { getPlatformOS } from '...'` becomes\n // `__proxy.getPlatformOS` at runtime, which correctly reads from window.__sdk.\n contents: `\nvar __proxy = (typeof window !== 'undefined' && window.__sdk)\n ? window.__sdk\n : new Proxy({}, {\n get: function(_t, p) {\n throw new Error('window.__sdk is not installed — run in a dog-food build. Missing: ' + String(p));\n }\n });\nmodule.exports = __proxy;\n`,\n loader: 'js',\n }));\n },\n };\n}\n\n/**\n * esbuild plugin that transforms the user test file into a module that exports\n * an async `__userFactory` function. The factory defers the user's top-level\n * test registration code (describe/it/test calls) so it only runs when\n * `runTestModule(__userFactory)` explicitly invokes it — AFTER the runtime has\n * installed describe/it/test/expect as globals.\n *\n * Algorithm:\n * - Lines matching import declarations or re-export statements are kept at\n * module top-level (the only valid ESM position for static `import`).\n * - All other lines (describe/it/test calls, local declarations, etc.) are\n * moved into the body of the exported async factory function.\n *\n * This preserves SDK import resolution (the sdk-redirect plugin processes\n * top-level imports normally) while deferring test registration to the factory.\n */\nfunction userFactoryPlugin(absPath: string): esbuild.Plugin {\n const NAMESPACE = 'user-test-factory';\n return {\n name: 'user-test-factory',\n setup(build) {\n // Resolve the virtual \"user-test-factory\" specifier to our namespace.\n build.onResolve({ filter: /^user-test-factory$/ }, () => ({\n path: absPath,\n namespace: NAMESPACE,\n }));\n\n // Load the user file, split imports from body, wrap body in the factory.\n build.onLoad({ filter: /.*/, namespace: NAMESPACE }, async (args) => {\n const source = await fs.readFile(args.path, 'utf8');\n const lines = source.split('\\n');\n\n const topLevelLines: string[] = [];\n const bodyLines: string[] = [];\n\n // Matches `export` value declarations that cannot appear inside a\n // function body. We strip the `export` keyword so they become plain\n // declarations inside the factory.\n const EXPORT_DECLARATION_RE =\n /^(export\\s+)(default\\s+|async\\s+function\\s+|function\\s+|class\\s+|const\\s+|let\\s+|var\\s+)/;\n\n for (const line of lines) {\n const trimmed = line.trimStart();\n const indent = line.slice(0, line.length - trimmed.length);\n\n // Static import declarations must stay at module top level\n // (the ESM spec forbids `import` inside a function body).\n if (\n trimmed.startsWith('import ') ||\n trimmed.startsWith('import{') ||\n trimmed.startsWith(\"import'\") ||\n trimmed.startsWith('import\"')\n ) {\n topLevelLines.push(line);\n } else if (trimmed.startsWith('export ')) {\n // Determine whether this is a re-export (stays top-level) or a value\n // declaration (goes into the factory, export keyword stripped).\n const m = trimmed.match(EXPORT_DECLARATION_RE);\n if (m) {\n // Value declaration — strip `export ` and move into factory body.\n // e.g. `export function hello()` → `function hello()`\n // `export const x = 1` → `const x = 1`\n bodyLines.push(indent + trimmed.slice('export '.length));\n } else {\n // Re-export or `export type { … }` — stays at top level.\n topLevelLines.push(line);\n }\n } else {\n bodyLines.push(line);\n }\n }\n\n const factoryContent = [\n ...topLevelLines,\n '',\n '// biome-ignore lint: generated factory wrapper',\n 'export default async function __userFactory(): Promise<void> {',\n ...bodyLines.map((l) => ` ${l}`),\n '}',\n ].join('\\n');\n\n return {\n contents: factoryContent,\n loader: 'ts',\n resolveDir: path.dirname(absPath),\n };\n });\n },\n };\n}\n\n/**\n * Returns the absolute path to the co-located runtime module.\n *\n * In the source tree (running via tsx / ts-node) the file is `runtime.ts`.\n * After `tsdown` compiles to `dist/test-runner/`, it becomes `runtime.js`.\n * We try both extensions to support both environments.\n */\nfunction getRuntimePath(): string {\n const dir = path.dirname(fileURLToPath(import.meta.url));\n for (const ext of ['.ts', '.js']) {\n const candidate = path.join(dir, `runtime${ext}`);\n try {\n accessSync(candidate);\n return candidate;\n } catch {\n // try next extension\n }\n }\n // Let esbuild produce a \"file not found\" error with a clear path.\n return path.join(dir, 'runtime.js');\n}\n\n/**\n * Bundles `absPath` into a single IIFE string suitable for `Runtime.evaluate`.\n *\n * The IIFE installs `window.__testBundle` (or the custom `globalName`) with:\n * - `runTestModule` — the runtime entry (from `runtime.ts`).\n * - `__userFactory` — an async function wrapping the user's test registration\n * code so it runs AFTER `runTestModule` installs the globals.\n *\n * Callers (rpc.ts) invoke:\n * `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`\n *\n * @param absPath - Absolute path to the user test file.\n * @param opts - Optional bundling overrides.\n */\nexport async function bundleTestFile(absPath: string, opts?: BundleOptions): Promise<BundleResult> {\n const globalName = opts?.globalName ?? '__testBundle';\n const extraExternals = opts?.extraExternals ?? [];\n\n // Lazy load esbuild at call time (see the module-scope import note).\n const esbuild = await import('esbuild');\n const runtimePath = getRuntimePath();\n\n // Stdin wrapper: import the runtime and the user factory, re-export both.\n // esbuild follows the static imports to include runtime.ts and the user file\n // (via the userFactoryPlugin) in the single IIFE output.\n const wrapperContent = [\n `import { runTestModule } from ${JSON.stringify(runtimePath)};`,\n `import __userFactory from \"user-test-factory\";`,\n `export { runTestModule, __userFactory };`,\n ].join('\\n');\n\n const result = await esbuild.build({\n stdin: {\n contents: wrapperContent,\n loader: 'ts',\n // resolveDir is used for relative imports from the wrapper. Since the\n // wrapper only imports absolute paths (runtimePath) and the virtual\n // \"user-test-factory\" specifier (resolved by plugin), the directory\n // doesn't matter — but we still provide a sensible default.\n resolveDir: path.dirname(absPath),\n },\n bundle: true,\n format: 'iife',\n globalName,\n platform: 'browser',\n target: 'es2022',\n write: false,\n plugins: [userFactoryPlugin(absPath), sdkRedirectPlugin()],\n external: extraExternals,\n treeShaking: true,\n // Ensure the IIFE result is always reachable via globalThis regardless of\n // the evaluation context. esbuild's `globalName` emits:\n // var __testBundle = (() => { ... })();\n // When `Runtime.evaluate` runs this bundle code inside an outer wrapper\n // (rpc.ts's async IIFE), `var` creates a local variable — NOT a global\n // property — so `globalThis.__testBundle` stays `undefined`. The footer\n // explicitly assigns the local variable to `globalThis` to close that gap.\n footer: {\n js: `globalThis[${JSON.stringify(globalName)}] = ${globalName};`,\n },\n });\n\n const warnings = result.warnings.map(\n (w) =>\n `${path.relative(process.cwd(), w.location?.file ?? '')}:${w.location?.line ?? '?'}: ${w.text}`,\n );\n\n const outputFile = result.outputFiles?.[0];\n if (!outputFile) {\n throw new Error('bundleTestFile: esbuild produced no output — check entryPoints');\n }\n\n return { code: outputFile.text, warnings };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAM,oBAAoB,IAAI,OAAO,IAPjB,8BAOiC,QAAQ,uBAAuB,OAAO,GAAG;;;;;;;;;;;;;AAc9F,SAAS,oBAAoC;AAC3C,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AAEX,SAAM,UAAU,EAAE,QAAQ,mBAAmB,GAAG,UAAU;IACxD,MAAM,KAAK;IACX,WAAW;IACZ,EAAE;AAEH,SAAM,OAAO;IAAE,QAAQ;IAAM,WAAW;IAAgB,SAAS;IAO/D,UAAU;;;;;;;;;;IAUV,QAAQ;IACT,EAAE;;EAEN;;;;;;;;;;;;;;;;;;AAmBH,SAAS,kBAAkB,SAAiC;CAC1D,MAAM,YAAY;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AAEX,SAAM,UAAU,EAAE,QAAQ,uBAAuB,SAAS;IACxD,MAAM;IACN,WAAW;IACZ,EAAE;AAGH,SAAM,OAAO;IAAE,QAAQ;IAAM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gB;CAKpC,MAAM,iBAAiB;EACrB,iCAAiC,KAAK,UAAU,YAAY,CAAC;EAC7D;EACA;EACD,CAAC,KAAK,KAAK;CAEZ,MAAM,SAAS,MAAM,QAAQ,MAAM;EACjC,OAAO;GACL,UAAU;GACV,QAAQ;GAKR,YAAY,KAAK,QAAQ,QAAQ;GAClC;EACD,QAAQ;EACR,QAAQ;EACR;EACA,UAAU;EACV,QAAQ;EACR,OAAO;EACP,SAAS,CAAC,kBAAkB,QAAQ,EAAE,mBAAmB,CAAC;EAC1D,UAAU;EACV,aAAa;EAQb,QAAQ,EACN,IAAI,cAAc,KAAK,UAAU,WAAW,CAAC,MAAM,WAAW,IAC/D;EACF,CAAC;CAEF,MAAM,WAAW,OAAO,SAAS,KAC9B,MACC,GAAG,KAAK,SAAS,QAAQ,KAAK,EAAE,EAAE,UAAU,QAAQ,GAAG,CAAC,GAAG,EAAE,UAAU,QAAQ,IAAI,IAAI,EAAE,OAC5F;CAED,MAAM,aAAa,OAAO,cAAc;AACxC,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,iEAAiE;AAGnF,QAAO;EAAE,MAAM,WAAW;EAAM;EAAU"}
@@ -279,11 +279,53 @@ interface CdpConnection {
279
279
  * esbuild-based bundler for user test files.
280
280
  *
281
281
  * Bundles a single test file into a self-contained IIFE string that can be
282
- * injected into a WebView via `Runtime.evaluate`. The user's SDK imports
283
- * (`@apps-in-toss/web-framework` and sub-paths) are intercepted via an
284
- * esbuild plugin that redirects them to `window.__sdk`, which the in-app
285
- * debug gate (`src/in-app/auto.ts`) installs as a namespace mirror of the
286
- * SDK exports (works for both 2.x and 3.x SDK).
282
+ * injected into a WebView via `Runtime.evaluate`. The bundle includes the
283
+ * test runtime (`runtime.ts`), which provides `describe/it/test/expect` and
284
+ * the `runTestModule(factory)` entry point.
285
+ *
286
+ * ## How the wiring works
287
+ *
288
+ * The bundle exposes two exports on `globalThis.__testBundle`:
289
+ * - `runTestModule` — the runtime's entry function.
290
+ * - `__userFactory` — an async function whose body is the user's top-level
291
+ * test registration code (describe/it/test calls).
292
+ *
293
+ * The Node-side RPC (`rpc.ts`) calls:
294
+ * `globalThis.__testBundle.runTestModule(globalThis.__testBundle.__userFactory)`
295
+ *
296
+ * `runTestModule` then installs `describe/it/test/expect` as globals, invokes
297
+ * the factory (which registers all tests), runs them, and returns a `RunReport`.
298
+ *
299
+ * ## Why a factory wrapper is needed
300
+ *
301
+ * Naively adding the runtime to `entryPoints` and bundling the user file would
302
+ * fail for two reasons:
303
+ * 1. `describe/it/test/expect` from the runtime are module-local in the IIFE
304
+ * scope. The user's top-level `describe(...)` calls expect them as globals —
305
+ * they are not globals until `runTestModule` installs them.
306
+ * 2. Even with globals pre-installed, the user file runs at IIFE-evaluation
307
+ * time, before the RPC layer calls `runTestModule` to reset state and start
308
+ * the test clock.
309
+ *
310
+ * The factory approach solves both: the user's registration code is deferred
311
+ * into a function that `runTestModule` calls AFTER installing the globals.
312
+ *
313
+ * ## Factory extraction algorithm
314
+ *
315
+ * The `userFactoryPlugin` reads the user file and splits lines into:
316
+ * - **top-level**: `import …` and re-export lines — kept at module scope
317
+ * (the only valid position for static `import` in ESM).
318
+ * - **body**: all other statements — moved into the body of the exported
319
+ * `__userFactory` async function.
320
+ *
321
+ * esbuild processes the re-generated module, following each static import
322
+ * through the normal dependency graph (including the SDK-redirect plugin).
323
+ *
324
+ * ## SDK redirect
325
+ *
326
+ * Imports of `@apps-in-toss/web-framework` (and sub-paths) are intercepted via
327
+ * the `sdkRedirectPlugin` and replaced with a virtual `window.__sdk` proxy that
328
+ * `src/in-app/auto.ts` installs at runtime. This works for both 2.x and 3.x SDK.
287
329
  *
288
330
  * SECRET-HANDLING: the returned bundle code is caller-managed; never log it.
289
331
  */
@@ -298,7 +340,7 @@ interface BundleOptions {
298
340
  extraExternals?: string[];
299
341
  /**
300
342
  * Global name for the IIFE output object. Defaults to `__testBundle`.
301
- * The runtime entry uses this to call `__testBundle.runTestModule()`.
343
+ * The runtime entry uses this to call `__testBundle.runTestModule(__userFactory)`.
302
344
  */
303
345
  globalName?: string;
304
346
  }
@@ -318,8 +360,8 @@ interface BundleOptions {
318
360
  *
319
361
  * @vitest/runner and @vitest/expect are listed as dependencies so that the
320
362
  * package's type contracts are available and so the browser-compatible subsets
321
- * can be referenced. Full pool integration (PoolRunnerInitializer) is tracked
322
- * in issue #645.
363
+ * can be referenced. The Vitest custom pool that drives this runtime through
364
+ * Vitest's `PoolRunnerInitializer` lives in `pool.ts`.
323
365
  *
324
366
  * NOTE: this file is imported by type from Node-side code (rpc.ts / relay-worker.ts)
325
367
  * for the RunReport / TestResult type shapes. The runtime ITSELF is not imported
@@ -398,18 +440,21 @@ interface RunWithConnectionOptions extends RelayRunOptions {
398
440
  }
399
441
  /**
400
442
  * Runs `files` over `connection` and returns the aggregate report.
401
- * This pure function is the testable core of the CLI; it is separate from
402
- * `main()` so tests can call it without spawning a subprocess.
443
+ * This pure function is the testable core of the CLI (and is what the
444
+ * `run_tests` MCP tool calls against the daemon's attached connection); it is
445
+ * separate from `main()` so tests can call it without spawning a subprocess.
403
446
  *
404
- * TODO (#645): add real relay attach/detach lifecycle here (connect via
405
- * Chii relay URL, call enableDomains, run, then close).
447
+ * A standalone CLI relay attach/detach lifecycle (connect via Chii relay URL,
448
+ * `enableDomains`, run, then close) is not wired into `main()` yet.
406
449
  */
407
450
  declare function runWithConnection(connection: CdpConnection, files: string[], opts?: RunWithConnectionOptions): Promise<RelayRunReport>;
408
451
  /**
409
452
  * CLI entry point.
410
453
  *
411
- * MVP: prints usage and a "relay attach required" notice. Real relay wiring
412
- * (resolve CDP URL, attach, run, close) is tracked in issues #645 / #646.
454
+ * Resolves the matched test files and prints a "relay attach required" notice:
455
+ * the CLI's own standalone relay attach (resolve CDP URL, attach, run, close) is
456
+ * not wired yet, so today these files run via the `run_tests` MCP tool against
457
+ * the daemon's attached page.
413
458
  */
414
459
  declare function main(argv?: string[]): Promise<void>;
415
460
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/mcp/cdp-connection.ts","../../src/test-runner/bundle.ts","../../src/test-runner/runtime.ts","../../src/test-runner/relay-worker.ts","../../src/test-runner/cli.ts"],"mappings":";;;AAwBA;;;;;;;;;AAUA;;;;;;;;;;;AASA;;UAnBiB,SAAA;EA2BI;EAzBnB,EAAA;EAoBA;EAlBA,KAAA;EAoBA;EAlBA,GAAA;AAAA;;UAIe,eAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA;EACA,WAAA;EACA,SAAA;AAAA;AAsBF;AAAA,UAlBiB,qBAAA;;EAEf,IAAA;EACA,IAAA,EAAM,eAAA;EAiBN;EAfA,SAAA;EACA,kBAAA;EACA,UAAA;IACE,UAAA,EAAY,KAAA;MACV,YAAA;MACA,GAAA;MACA,UAAA;MACA,YAAA;IAAA;EAAA;AAAA;;UAMW,6BAAA;EACf,SAAA;EACA,OAAA;IACE,GAAA;IACA,MAAA;IACA,OAAA,GAAU,MAAA;EAAA;EAkBZ;EAfA,SAAA;EAgBI;EAdJ,QAAA;EACA,IAAA;AAAA;;UAIe,4BAAA;EACf,SAAA;EACA,QAAA;IACE,GAAA;IACA,MAAA;IACA,UAAA;IACA,QAAA;EAAA;EAEF,SAAA;EACA,IAAA;AAAA;;;;;UAOe,YAAA;EACf,YAAA;EACA,QAAA;EACA,GAAA;EACA,UAAA;EACA,YAAA;AAAA;;UAIe,2BAAA;EAcD;EAZd,SAAA;EACA,gBAAA;IACE,WAAA;IACA,IAAA;IACA,UAAA;IACA,YAAA;IACA,QAAA;IACA,GAAA;IACA,UAAA;MACE,UAAA,EAAY,YAAA;IAAA,GAShB;IANE,SAAA,GAAY,eAAA;EAAA;AAAA;;UAKC,WAAA;EACf,0BAAA,EAA4B,qBAAA;EAC5B,2BAAA,EAA6B,6BAAA;EAC7B,0BAAA,EAA4B,4BAAA;EAC5B,yBAAA,EAA2B,2BAAA;AAAA;AAAA,KAGjB,YAAA,SAAqB,WAAA;;UAOhB,U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1
+ {"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/mcp/cdp-connection.ts","../../src/test-runner/bundle.ts","../../src/test-runner/runtime.ts","../../src/test-runner/relay-worker.ts","../../src/test-runner/cli.ts"],"mappings":";;;AAwBA;;;;;;;;;AAUA;;;;;;;;;;;AASA;;UAnBiB,SAAA;EA2BI;EAzBnB,EAAA;EAoBA;EAlBA,KAAA;EAoBA;EAlBA,GAAA;AAAA;;UAIe,eAAA;EACf,IAAA;EACA,OAAA;EACA,KAAA;EACA,WAAA;EACA,SAAA;AAAA;AAsBF;AAAA,UAlBiB,qBAAA;;EAEf,IAAA;EACA,IAAA,EAAM,eAAA;EAiBN;EAfA,SAAA;EACA,kBAAA;EACA,UAAA;IACE,UAAA,EAAY,KAAA;MACV,YAAA;MACA,GAAA;MACA,UAAA;MACA,YAAA;IAAA;EAAA;AAAA;;UAMW,6BAAA;EACf,SAAA;EACA,OAAA;IACE,GAAA;IACA,MAAA;IACA,OAAA,GAAU,MAAA;EAAA;EAkBZ;EAfA,SAAA;EAgBI;EAdJ,QAAA;EACA,IAAA;AAAA;;UAIe,4BAAA;EACf,SAAA;EACA,QAAA;IACE,GAAA;IACA,MAAA;IACA,UAAA;IACA,QAAA;EAAA;EAEF,SAAA;EACA,IAAA;AAAA;;;;;UAOe,YAAA;EACf,YAAA;EACA,QAAA;EACA,GAAA;EACA,UAAA;EACA,YAAA;AAAA;;UAIe,2BAAA;EAcD;EAZd,SAAA;EACA,gBAAA;IACE,WAAA;IACA,IAAA;IACA,UAAA;IACA,YAAA;IACA,QAAA;IACA,GAAA;IACA,UAAA;MACE,UAAA,EAAY,YAAA;IAAA,GAShB;IANE,SAAA,GAAY,eAAA;EAAA;AAAA;;UAKC,WAAA;EACf,0BAAA,EAA4B,qBAAA;EAC5B,2BAAA,EAA6B,6BAAA;EAC7B,0BAAA,EAA4B,4BAAA;EAC5B,yBAAA,EAA2B,2BAAA;AAAA;AAAA,KAGjB,YAAA,SAAqB,WAAA;;UAO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