@ait-co/devtools 0.1.117 → 0.1.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attach-orchestrator-BEMGBeWm.js +3 -0
- package/dist/attach-orchestrator-BZsqoFjB.js +2797 -0
- package/dist/attach-orchestrator-BZsqoFjB.js.map +1 -0
- package/dist/attach-orchestrator-CFotueL3.js +1749 -0
- package/dist/attach-orchestrator-CFotueL3.js.map +1 -0
- package/dist/attach-orchestrator-DEJfLm7V.js +1749 -0
- package/dist/attach-orchestrator-DEJfLm7V.js.map +1 -0
- package/dist/{cli-CvUNQKqw.js → attach-orchestrator-qFEMBUwb.js} +3 -805
- package/dist/attach-orchestrator-qFEMBUwb.js.map +1 -0
- package/dist/{bundle-KFs4t-wc.d.ts → bundle-CA1TCXED.d.ts} +1 -1
- package/dist/{bundle-KFs4t-wc.d.ts.map → bundle-CA1TCXED.d.ts.map} +1 -1
- package/dist/capture-BmK_cBqQ.d.ts +58 -0
- package/dist/capture-BmK_cBqQ.d.ts.map +1 -0
- package/dist/{cdp-connection-C0AP0tH2.d.ts → cdp-connection-DB2zgthr.d.ts} +1 -1
- package/dist/{cdp-connection-C0AP0tH2.d.ts.map → cdp-connection-DB2zgthr.d.ts.map} +1 -1
- package/dist/cell-BDFMsPXV.js +3 -0
- package/dist/cell-BPWZUm_X.js +85 -0
- package/dist/cell-BPWZUm_X.js.map +1 -0
- package/dist/cell-Cv3e_qwn.js +84 -0
- package/dist/cell-Cv3e_qwn.js.map +1 -0
- package/dist/cell-Dp_pDs_j.js +85 -0
- package/dist/cell-Dp_pDs_j.js.map +1 -0
- package/dist/cell-nrWFeqvG.js +84 -0
- package/dist/cell-nrWFeqvG.js.map +1 -0
- package/dist/cli-BA1ynNNx.js +1039 -0
- package/dist/cli-BA1ynNNx.js.map +1 -0
- package/dist/debug-server-BhHVy3XT.js +1191 -0
- package/dist/debug-server-BhHVy3XT.js.map +1 -0
- package/dist/{debug-server-BvrESnaV.js → debug-server-T8i9_iCc.js} +5 -3
- package/dist/debug-server-T8i9_iCc.js.map +1 -0
- package/dist/debug-server-krAOy6cl.js +1891 -0
- package/dist/debug-server-krAOy6cl.js.map +1 -0
- package/dist/{debug-server-jrI9U_f4.js → debug-server-wo18jR4T.js} +429 -2969
- package/dist/debug-server-wo18jR4T.js.map +1 -0
- package/dist/mcp/cli.js +3 -2
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/{pool-htlVnEFl.d.ts → pool-U9FrxEuR.d.ts} +5 -5
- package/dist/{pool-htlVnEFl.d.ts.map → pool-U9FrxEuR.d.ts.map} +1 -1
- package/dist/relay-factory-DVI7TrX4.js +69 -0
- package/dist/relay-factory-DVI7TrX4.js.map +1 -0
- package/dist/relay-secret-store-BcVrWwTq.js +153 -0
- package/dist/relay-secret-store-BcVrWwTq.js.map +1 -0
- package/dist/{relay-secret-store-BHcOmaNK.js → relay-secret-store-BlFEhqwb.js} +1 -1
- package/dist/{relay-secret-store-CmqchhR5.js → relay-secret-store-CFc9n0OA.js} +1 -1
- package/dist/{relay-secret-store-CmqchhR5.js.map → relay-secret-store-CFc9n0OA.js.map} +1 -1
- package/dist/{relay-secret-store-CkA7KNUb.js → relay-secret-store-CmDDfZMh.js} +2 -2
- package/dist/{relay-secret-store-CkA7KNUb.js.map → relay-secret-store-CmDDfZMh.js.map} +1 -1
- package/dist/relay-secret-store-DNPJKHNs.js +153 -0
- package/dist/relay-secret-store-DNPJKHNs.js.map +1 -0
- package/dist/relay-url-store-CdA58fgw.js +122 -0
- package/dist/relay-url-store-CdA58fgw.js.map +1 -0
- package/dist/{relay-url-store-C0qukm3R.js → relay-url-store-CnL2zwbH.js} +2 -2
- package/dist/{relay-url-store-C0qukm3R.js.map → relay-url-store-CnL2zwbH.js.map} +1 -1
- package/dist/{relay-url-store-NDtEcOE-.js → relay-url-store-DGQ-HPQC.js} +2 -2
- package/dist/{relay-url-store-NDtEcOE-.js.map → relay-url-store-DGQ-HPQC.js.map} +1 -1
- package/dist/relay-url-store-Dv5HSzwb.js +122 -0
- package/dist/relay-url-store-Dv5HSzwb.js.map +1 -0
- package/dist/{relay-worker-DWW4vZxU.d.ts → relay-worker-D-3aAyDO.d.ts} +28 -4
- package/dist/relay-worker-D-3aAyDO.d.ts.map +1 -0
- package/dist/{runtime-BU-iMHz6.d.ts → runtime-D57Rtnsd.d.ts} +1 -1
- package/dist/{runtime-BU-iMHz6.d.ts.map → runtime-D57Rtnsd.d.ts.map} +1 -1
- package/dist/test-runner/bundle.d.ts +1 -1
- package/dist/test-runner/bundle.js +9 -9
- package/dist/test-runner/bundle.js.map +1 -1
- package/dist/test-runner/capture.d.ts +2 -0
- package/dist/test-runner/capture.js +44 -0
- package/dist/test-runner/capture.js.map +1 -0
- package/dist/test-runner/cli.d.ts +85 -12
- package/dist/test-runner/cli.d.ts.map +1 -1
- package/dist/test-runner/cli.js +2 -2
- package/dist/test-runner/config.d.ts +76 -2
- package/dist/test-runner/config.d.ts.map +1 -1
- package/dist/test-runner/config.js +4 -2
- package/dist/test-runner/config.js.map +1 -1
- package/dist/test-runner/pool.d.ts +1 -1
- package/dist/test-runner/relay-factory.d.ts +11136 -0
- package/dist/test-runner/relay-factory.d.ts.map +1 -0
- package/dist/test-runner/relay-factory.js +69 -0
- package/dist/test-runner/relay-factory.js.map +1 -0
- package/dist/test-runner/relay-worker.d.ts +1 -1
- package/dist/test-runner/relay-worker.js +66 -20
- package/dist/test-runner/relay-worker.js.map +1 -1
- package/dist/test-runner/report.d.ts +106 -0
- package/dist/test-runner/report.d.ts.map +1 -0
- package/dist/test-runner/report.js +139 -0
- package/dist/test-runner/report.js.map +1 -0
- package/dist/test-runner/rpc.d.ts +2 -2
- package/dist/test-runner/runtime.d.ts +1 -1
- package/dist/test-runner/task-graph.d.ts +1 -1
- package/dist/{totp-D70zD5tJ.js → totp-0bvlo9Yb.js} +1 -1
- package/dist/{totp-D70zD5tJ.js.map → totp-0bvlo9Yb.js.map} +1 -1
- package/dist/totp-DfekTBk3.js +211 -0
- package/dist/totp-DfekTBk3.js.map +1 -0
- package/dist/totp-zGIlDsZS.js +3 -0
- package/package.json +1 -1
- package/dist/cli-CvUNQKqw.js.map +0 -1
- package/dist/debug-server-BvrESnaV.js.map +0 -1
- package/dist/debug-server-jrI9U_f4.js.map +0 -1
- package/dist/relay-worker-DWW4vZxU.d.ts.map +0 -1
- package/dist/totp-D104cJQN.js +0 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/test-runner/capture.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* `__AIT_CAPTURE__` console-line parser (devtools#696).
|
|
4
|
+
*
|
|
5
|
+
* env3 test runs inject sdk-example's `aitCapture.ts`, which — when running in a
|
|
6
|
+
* WebView (no filesystem) — emits one `console.log` line per category in the
|
|
7
|
+
* stable form:
|
|
8
|
+
*
|
|
9
|
+
* __AIT_CAPTURE__ <category> <json>
|
|
10
|
+
*
|
|
11
|
+
* The relay-worker harvests `Runtime.consoleAPICalled` events as plain text
|
|
12
|
+
* lines (see `relay-worker.ts`) and hands them here. This module's only job is
|
|
13
|
+
* to recognise the allowlisted prefix, split off the category, and keep the
|
|
14
|
+
* remaining JSON string OPAQUE — devtools does NOT own or interpret the
|
|
15
|
+
* `__AIT_CAPTURE__` record shape (that lives in sdk-example). We carry
|
|
16
|
+
* `{ category, json }` through untouched so the 2.x↔3.0 line comparison stays a
|
|
17
|
+
* downstream concern.
|
|
18
|
+
*
|
|
19
|
+
* Why a strict allowlist prefix (SECRET-HANDLING): the raw console stream may
|
|
20
|
+
* also contain wss/scheme/relay noise lines. Only lines that EXACTLY start with
|
|
21
|
+
* `'__AIT_CAPTURE__ '` pass; everything else is discarded, so a stray relay URL
|
|
22
|
+
* can never be serialised into a capture artifact.
|
|
23
|
+
*
|
|
24
|
+
* react-free, dependency-free — safe to import from any test-runner entry
|
|
25
|
+
* without dragging in the chii/cloudflared Node graph.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* One parsed capture line. `json` is the raw JSON string exactly as the page
|
|
29
|
+
* emitted it (an array of sdk-example capture records). devtools treats it as
|
|
30
|
+
* opaque — it is validated as parseable JSON but never inspected.
|
|
31
|
+
*/
|
|
32
|
+
interface AitCaptureLine {
|
|
33
|
+
/** The capture category (first whitespace-delimited token after the prefix). */
|
|
34
|
+
category: string;
|
|
35
|
+
/** The remaining JSON payload, verbatim. Opaque to devtools. */
|
|
36
|
+
json: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses raw console line texts into {@link AitCaptureLine}s.
|
|
40
|
+
*
|
|
41
|
+
* Filtering rules (each independently drops a line — never throws):
|
|
42
|
+
* - the line text must `startsWith(CAPTURE_PREFIX)` exactly (allowlist);
|
|
43
|
+
* - there must be a non-empty category token (up to the next space);
|
|
44
|
+
* - the remaining payload must be valid JSON (`JSON.parse` succeeds).
|
|
45
|
+
*
|
|
46
|
+
* Lines that fail any rule (wss/scheme noise, truncated, broken JSON) are
|
|
47
|
+
* silently discarded — capture harvesting is best-effort and must never fail a
|
|
48
|
+
* run or leak a malformed/secret-bearing line.
|
|
49
|
+
*
|
|
50
|
+
* @param raw - Console line objects (only `.text` is read).
|
|
51
|
+
* @returns The captured lines, in input order.
|
|
52
|
+
*/
|
|
53
|
+
declare function parseCaptureLines(raw: ReadonlyArray<{
|
|
54
|
+
text: string;
|
|
55
|
+
}>): AitCaptureLine[];
|
|
56
|
+
//#endregion
|
|
57
|
+
export { parseCaptureLines as n, AitCaptureLine as t };
|
|
58
|
+
//# sourceMappingURL=capture-BmK_cBqQ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-BmK_cBqQ.d.ts","names":[],"sources":["../src/test-runner/capture.ts"],"mappings":";;AA+BA;;;;;AAyBA;;;;;;;;;;;;;;;;;;;;;;;;UAzBiB,cAAA;;EAEf,QAAA;;EAEA,IAAA;AAAA;;;;;;;;;;;;;;;;iBAqBc,iBAAA,CAAkB,GAAA,EAAK,aAAA;EAAgB,IAAA;AAAA,KAAkB,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdp-connection-
|
|
1
|
+
{"version":3,"file":"cdp-connection-DB2zgthr.d.ts","names":[],"sources":["../src/mcp/cdp-connection.ts"],"mappings":"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"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { buildIndicatorExpression } from "./attach-orchestrator-qFEMBUwb.js";
|
|
3
|
+
//#region src/test-runner/cell.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).
|
|
6
|
+
*
|
|
7
|
+
* Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the
|
|
8
|
+
* first test bundle is injected. The injected values are session-global — one
|
|
9
|
+
* call covers all files in the run.
|
|
10
|
+
*
|
|
11
|
+
* The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so
|
|
12
|
+
* sdk-example's `aitCapture.ts` picks up the correct test-axis values instead
|
|
13
|
+
* of falling back to `'2.x'`/`'mock'`.
|
|
14
|
+
*
|
|
15
|
+
* devtools does NOT know the shape of `__AIT_CELL__` — it only provides the
|
|
16
|
+
* general injection mechanism. The caller (CLI or MCP auto-attach path) is
|
|
17
|
+
* responsible for constructing the cell object.
|
|
18
|
+
*
|
|
19
|
+
* SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be
|
|
20
|
+
* logged at the caller's discretion. This module does NOT log them itself.
|
|
21
|
+
*
|
|
22
|
+
* Node-only. react-free. CdpConnection only.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Injects each key of `globals` into `globalThis` in the page via a single
|
|
26
|
+
* `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`
|
|
27
|
+
* inject — the cell is session-global and applies to all subsequent files.
|
|
28
|
+
*
|
|
29
|
+
* Throws if the CDP evaluate returns an exception.
|
|
30
|
+
*
|
|
31
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
32
|
+
* @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.
|
|
33
|
+
*/
|
|
34
|
+
async function injectGlobals(conn, globals) {
|
|
35
|
+
const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;
|
|
36
|
+
const result = await conn.send("Runtime.evaluate", {
|
|
37
|
+
expression: expr,
|
|
38
|
+
returnByValue: true
|
|
39
|
+
});
|
|
40
|
+
if (result.exceptionDetails) {
|
|
41
|
+
const msg = result.exceptionDetails.exception?.description ?? result.exceptionDetails.text ?? "unknown error";
|
|
42
|
+
throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Injects the "Debugger Connected" on-phone indicator via `Runtime.evaluate`.
|
|
47
|
+
*
|
|
48
|
+
* Uses the same CDP mechanism as {@link injectGlobals} — a single
|
|
49
|
+
* `Runtime.evaluate` round-trip with the expression built by
|
|
50
|
+
* {@link buildIndicatorExpression}. The indicator is a dismissible red badge
|
|
51
|
+
* rendered at the bottom-left of the page (position:fixed, safe-area-aware).
|
|
52
|
+
*
|
|
53
|
+
* **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to
|
|
54
|
+
* its caller. Injection failure (e.g. page detached during inject, CSS not
|
|
55
|
+
* supported) is swallowed and logged as `console.debug` — the badge is
|
|
56
|
+
* informational UI and must never block attach success or test execution.
|
|
57
|
+
* This is the same fire-and-forget spirit as the eruda mount in
|
|
58
|
+
* `src/in-app/attach.ts`.
|
|
59
|
+
*
|
|
60
|
+
* Call this ONLY on the manual debug paths (start_attach MCP, devtools-test
|
|
61
|
+
* CLI). Do NOT call on the `run_tests` auto-attach path — the red badge
|
|
62
|
+
* would contaminate screenshots, measure_safe_area probes, and DOM snapshots
|
|
63
|
+
* taken during automated measurement runs.
|
|
64
|
+
*
|
|
65
|
+
* SECRET-HANDLING: the injected expression contains no secrets, relay URLs,
|
|
66
|
+
* wss addresses, or TOTP codes — it is pure DOM UI text built by
|
|
67
|
+
* {@link buildIndicatorExpression}.
|
|
68
|
+
*
|
|
69
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
70
|
+
* @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.
|
|
71
|
+
*/
|
|
72
|
+
async function injectDebugIndicator(conn, opts) {
|
|
73
|
+
try {
|
|
74
|
+
await conn.send("Runtime.evaluate", {
|
|
75
|
+
expression: buildIndicatorExpression(opts),
|
|
76
|
+
returnByValue: true
|
|
77
|
+
});
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.debug("[@ait-co/devtools] debug indicator inject skipped:", err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { injectDebugIndicator, injectGlobals };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=cell-BPWZUm_X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-BPWZUm_X.js","names":[],"sources":["../src/test-runner/cell.ts"],"sourcesContent":["/**\n * Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).\n *\n * Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the\n * first test bundle is injected. The injected values are session-global — one\n * call covers all files in the run.\n *\n * The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so\n * sdk-example's `aitCapture.ts` picks up the correct test-axis values instead\n * of falling back to `'2.x'`/`'mock'`.\n *\n * devtools does NOT know the shape of `__AIT_CELL__` — it only provides the\n * general injection mechanism. The caller (CLI or MCP auto-attach path) is\n * responsible for constructing the cell object.\n *\n * SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be\n * logged at the caller's discretion. This module does NOT log them itself.\n *\n * Node-only. react-free. CdpConnection only.\n */\n\nimport { buildIndicatorExpression } from '../mcp/attach-orchestrator.js';\nimport type { CdpConnection } from '../mcp/cdp-connection.js';\n\n/**\n * Injects each key of `globals` into `globalThis` in the page via a single\n * `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`\n * inject — the cell is session-global and applies to all subsequent files.\n *\n * Throws if the CDP evaluate returns an exception.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.\n */\nexport async function injectGlobals(\n conn: CdpConnection,\n globals: Record<string, unknown>,\n): Promise<void> {\n // JSON.stringify is safe here: globals values are plain data (sdkLine/platform\n // strings or simple objects). If a value is not JSON-serialisable this throws\n // at call time, which surfaces the error early and clearly.\n const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;\n const result = await conn.send('Runtime.evaluate', { expression: expr, returnByValue: true });\n if (result.exceptionDetails) {\n const msg =\n result.exceptionDetails.exception?.description ??\n result.exceptionDetails.text ??\n 'unknown error';\n throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);\n }\n}\n\n/**\n * Injects the \"Debugger Connected\" on-phone indicator via `Runtime.evaluate`.\n *\n * Uses the same CDP mechanism as {@link injectGlobals} — a single\n * `Runtime.evaluate` round-trip with the expression built by\n * {@link buildIndicatorExpression}. The indicator is a dismissible red badge\n * rendered at the bottom-left of the page (position:fixed, safe-area-aware).\n *\n * **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to\n * its caller. Injection failure (e.g. page detached during inject, CSS not\n * supported) is swallowed and logged as `console.debug` — the badge is\n * informational UI and must never block attach success or test execution.\n * This is the same fire-and-forget spirit as the eruda mount in\n * `src/in-app/attach.ts`.\n *\n * Call this ONLY on the manual debug paths (start_attach MCP, devtools-test\n * CLI). Do NOT call on the `run_tests` auto-attach path — the red badge\n * would contaminate screenshots, measure_safe_area probes, and DOM snapshots\n * taken during automated measurement runs.\n *\n * SECRET-HANDLING: the injected expression contains no secrets, relay URLs,\n * wss addresses, or TOTP codes — it is pure DOM UI text built by\n * {@link buildIndicatorExpression}.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.\n */\nexport async function injectDebugIndicator(\n conn: CdpConnection,\n opts?: { label?: string },\n): Promise<void> {\n try {\n await conn.send('Runtime.evaluate', {\n expression: buildIndicatorExpression(opts),\n returnByValue: true,\n });\n } catch (err) {\n // Badge injection is informational UI — swallow and log; never propagate.\n console.debug('[@ait-co/devtools] debug indicator inject skipped:', err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAsB,cACpB,MACA,SACe;CAIf,MAAM,OAAO,sCAAsC,KAAK,UAAU,QAAQ,CAAC;CAC3E,MAAM,SAAS,MAAM,KAAK,KAAK,oBAAoB;EAAE,YAAY;EAAM,eAAe;EAAM,CAAC;AAC7F,KAAI,OAAO,kBAAkB;EAC3B,MAAM,MACJ,OAAO,iBAAiB,WAAW,eACnC,OAAO,iBAAiB,QACxB;AACF,QAAM,IAAI,MAAM,0CAA0C,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BpE,eAAsB,qBACpB,MACA,MACe;AACf,KAAI;AACF,QAAM,KAAK,KAAK,oBAAoB;GAClC,YAAY,yBAAyB,KAAK;GAC1C,eAAe;GAChB,CAAC;UACK,KAAK;AAEZ,UAAQ,MAAM,sDAAsD,IAAI"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { buildIndicatorExpression } from "./attach-orchestrator-DEJfLm7V.js";
|
|
2
|
+
//#region src/test-runner/cell.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).
|
|
5
|
+
*
|
|
6
|
+
* Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the
|
|
7
|
+
* first test bundle is injected. The injected values are session-global — one
|
|
8
|
+
* call covers all files in the run.
|
|
9
|
+
*
|
|
10
|
+
* The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so
|
|
11
|
+
* sdk-example's `aitCapture.ts` picks up the correct test-axis values instead
|
|
12
|
+
* of falling back to `'2.x'`/`'mock'`.
|
|
13
|
+
*
|
|
14
|
+
* devtools does NOT know the shape of `__AIT_CELL__` — it only provides the
|
|
15
|
+
* general injection mechanism. The caller (CLI or MCP auto-attach path) is
|
|
16
|
+
* responsible for constructing the cell object.
|
|
17
|
+
*
|
|
18
|
+
* SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be
|
|
19
|
+
* logged at the caller's discretion. This module does NOT log them itself.
|
|
20
|
+
*
|
|
21
|
+
* Node-only. react-free. CdpConnection only.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Injects each key of `globals` into `globalThis` in the page via a single
|
|
25
|
+
* `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`
|
|
26
|
+
* inject — the cell is session-global and applies to all subsequent files.
|
|
27
|
+
*
|
|
28
|
+
* Throws if the CDP evaluate returns an exception.
|
|
29
|
+
*
|
|
30
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
31
|
+
* @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.
|
|
32
|
+
*/
|
|
33
|
+
async function injectGlobals(conn, globals) {
|
|
34
|
+
const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;
|
|
35
|
+
const result = await conn.send("Runtime.evaluate", {
|
|
36
|
+
expression: expr,
|
|
37
|
+
returnByValue: true
|
|
38
|
+
});
|
|
39
|
+
if (result.exceptionDetails) {
|
|
40
|
+
const msg = result.exceptionDetails.exception?.description ?? result.exceptionDetails.text ?? "unknown error";
|
|
41
|
+
throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Injects the "Debugger Connected" on-phone indicator via `Runtime.evaluate`.
|
|
46
|
+
*
|
|
47
|
+
* Uses the same CDP mechanism as {@link injectGlobals} — a single
|
|
48
|
+
* `Runtime.evaluate` round-trip with the expression built by
|
|
49
|
+
* {@link buildIndicatorExpression}. The indicator is a dismissible red badge
|
|
50
|
+
* rendered at the bottom-left of the page (position:fixed, safe-area-aware).
|
|
51
|
+
*
|
|
52
|
+
* **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to
|
|
53
|
+
* its caller. Injection failure (e.g. page detached during inject, CSS not
|
|
54
|
+
* supported) is swallowed and logged as `console.debug` — the badge is
|
|
55
|
+
* informational UI and must never block attach success or test execution.
|
|
56
|
+
* This is the same fire-and-forget spirit as the eruda mount in
|
|
57
|
+
* `src/in-app/attach.ts`.
|
|
58
|
+
*
|
|
59
|
+
* Call this ONLY on the manual debug paths (start_attach MCP, devtools-test
|
|
60
|
+
* CLI). Do NOT call on the `run_tests` auto-attach path — the red badge
|
|
61
|
+
* would contaminate screenshots, measure_safe_area probes, and DOM snapshots
|
|
62
|
+
* taken during automated measurement runs.
|
|
63
|
+
*
|
|
64
|
+
* SECRET-HANDLING: the injected expression contains no secrets, relay URLs,
|
|
65
|
+
* wss addresses, or TOTP codes — it is pure DOM UI text built by
|
|
66
|
+
* {@link buildIndicatorExpression}.
|
|
67
|
+
*
|
|
68
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
69
|
+
* @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.
|
|
70
|
+
*/
|
|
71
|
+
async function injectDebugIndicator(conn, opts) {
|
|
72
|
+
try {
|
|
73
|
+
await conn.send("Runtime.evaluate", {
|
|
74
|
+
expression: buildIndicatorExpression(opts),
|
|
75
|
+
returnByValue: true
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.debug("[@ait-co/devtools] debug indicator inject skipped:", err);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { injectDebugIndicator, injectGlobals };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=cell-Cv3e_qwn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-Cv3e_qwn.js","names":[],"sources":["../src/test-runner/cell.ts"],"sourcesContent":["/**\n * Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).\n *\n * Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the\n * first test bundle is injected. The injected values are session-global — one\n * call covers all files in the run.\n *\n * The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so\n * sdk-example's `aitCapture.ts` picks up the correct test-axis values instead\n * of falling back to `'2.x'`/`'mock'`.\n *\n * devtools does NOT know the shape of `__AIT_CELL__` — it only provides the\n * general injection mechanism. The caller (CLI or MCP auto-attach path) is\n * responsible for constructing the cell object.\n *\n * SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be\n * logged at the caller's discretion. This module does NOT log them itself.\n *\n * Node-only. react-free. CdpConnection only.\n */\n\nimport { buildIndicatorExpression } from '../mcp/attach-orchestrator.js';\nimport type { CdpConnection } from '../mcp/cdp-connection.js';\n\n/**\n * Injects each key of `globals` into `globalThis` in the page via a single\n * `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`\n * inject — the cell is session-global and applies to all subsequent files.\n *\n * Throws if the CDP evaluate returns an exception.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.\n */\nexport async function injectGlobals(\n conn: CdpConnection,\n globals: Record<string, unknown>,\n): Promise<void> {\n // JSON.stringify is safe here: globals values are plain data (sdkLine/platform\n // strings or simple objects). If a value is not JSON-serialisable this throws\n // at call time, which surfaces the error early and clearly.\n const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;\n const result = await conn.send('Runtime.evaluate', { expression: expr, returnByValue: true });\n if (result.exceptionDetails) {\n const msg =\n result.exceptionDetails.exception?.description ??\n result.exceptionDetails.text ??\n 'unknown error';\n throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);\n }\n}\n\n/**\n * Injects the \"Debugger Connected\" on-phone indicator via `Runtime.evaluate`.\n *\n * Uses the same CDP mechanism as {@link injectGlobals} — a single\n * `Runtime.evaluate` round-trip with the expression built by\n * {@link buildIndicatorExpression}. The indicator is a dismissible red badge\n * rendered at the bottom-left of the page (position:fixed, safe-area-aware).\n *\n * **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to\n * its caller. Injection failure (e.g. page detached during inject, CSS not\n * supported) is swallowed and logged as `console.debug` — the badge is\n * informational UI and must never block attach success or test execution.\n * This is the same fire-and-forget spirit as the eruda mount in\n * `src/in-app/attach.ts`.\n *\n * Call this ONLY on the manual debug paths (start_attach MCP, devtools-test\n * CLI). Do NOT call on the `run_tests` auto-attach path — the red badge\n * would contaminate screenshots, measure_safe_area probes, and DOM snapshots\n * taken during automated measurement runs.\n *\n * SECRET-HANDLING: the injected expression contains no secrets, relay URLs,\n * wss addresses, or TOTP codes — it is pure DOM UI text built by\n * {@link buildIndicatorExpression}.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.\n */\nexport async function injectDebugIndicator(\n conn: CdpConnection,\n opts?: { label?: string },\n): Promise<void> {\n try {\n await conn.send('Runtime.evaluate', {\n expression: buildIndicatorExpression(opts),\n returnByValue: true,\n });\n } catch (err) {\n // Badge injection is informational UI — swallow and log; never propagate.\n console.debug('[@ait-co/devtools] debug indicator inject skipped:', err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAsB,cACpB,MACA,SACe;CAIf,MAAM,OAAO,sCAAsC,KAAK,UAAU,QAAQ,CAAC;CAC3E,MAAM,SAAS,MAAM,KAAK,KAAK,oBAAoB;EAAE,YAAY;EAAM,eAAe;EAAM,CAAC;AAC7F,KAAI,OAAO,kBAAkB;EAC3B,MAAM,MACJ,OAAO,iBAAiB,WAAW,eACnC,OAAO,iBAAiB,QACxB;AACF,QAAM,IAAI,MAAM,0CAA0C,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BpE,eAAsB,qBACpB,MACA,MACe;AACf,KAAI;AACF,QAAM,KAAK,KAAK,oBAAoB;GAClC,YAAY,yBAAyB,KAAK;GAC1C,eAAe;GAChB,CAAC;UACK,KAAK;AAEZ,UAAQ,MAAM,sDAAsD,IAAI"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as buildIndicatorExpression } from "./attach-orchestrator-BZsqoFjB.js";
|
|
3
|
+
//#region src/test-runner/cell.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).
|
|
6
|
+
*
|
|
7
|
+
* Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the
|
|
8
|
+
* first test bundle is injected. The injected values are session-global — one
|
|
9
|
+
* call covers all files in the run.
|
|
10
|
+
*
|
|
11
|
+
* The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so
|
|
12
|
+
* sdk-example's `aitCapture.ts` picks up the correct test-axis values instead
|
|
13
|
+
* of falling back to `'2.x'`/`'mock'`.
|
|
14
|
+
*
|
|
15
|
+
* devtools does NOT know the shape of `__AIT_CELL__` — it only provides the
|
|
16
|
+
* general injection mechanism. The caller (CLI or MCP auto-attach path) is
|
|
17
|
+
* responsible for constructing the cell object.
|
|
18
|
+
*
|
|
19
|
+
* SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be
|
|
20
|
+
* logged at the caller's discretion. This module does NOT log them itself.
|
|
21
|
+
*
|
|
22
|
+
* Node-only. react-free. CdpConnection only.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Injects each key of `globals` into `globalThis` in the page via a single
|
|
26
|
+
* `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`
|
|
27
|
+
* inject — the cell is session-global and applies to all subsequent files.
|
|
28
|
+
*
|
|
29
|
+
* Throws if the CDP evaluate returns an exception.
|
|
30
|
+
*
|
|
31
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
32
|
+
* @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.
|
|
33
|
+
*/
|
|
34
|
+
async function injectGlobals(conn, globals) {
|
|
35
|
+
const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;
|
|
36
|
+
const result = await conn.send("Runtime.evaluate", {
|
|
37
|
+
expression: expr,
|
|
38
|
+
returnByValue: true
|
|
39
|
+
});
|
|
40
|
+
if (result.exceptionDetails) {
|
|
41
|
+
const msg = result.exceptionDetails.exception?.description ?? result.exceptionDetails.text ?? "unknown error";
|
|
42
|
+
throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Injects the "Debugger Connected" on-phone indicator via `Runtime.evaluate`.
|
|
47
|
+
*
|
|
48
|
+
* Uses the same CDP mechanism as {@link injectGlobals} — a single
|
|
49
|
+
* `Runtime.evaluate` round-trip with the expression built by
|
|
50
|
+
* {@link buildIndicatorExpression}. The indicator is a dismissible red badge
|
|
51
|
+
* rendered at the bottom-left of the page (position:fixed, safe-area-aware).
|
|
52
|
+
*
|
|
53
|
+
* **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to
|
|
54
|
+
* its caller. Injection failure (e.g. page detached during inject, CSS not
|
|
55
|
+
* supported) is swallowed and logged as `console.debug` — the badge is
|
|
56
|
+
* informational UI and must never block attach success or test execution.
|
|
57
|
+
* This is the same fire-and-forget spirit as the eruda mount in
|
|
58
|
+
* `src/in-app/attach.ts`.
|
|
59
|
+
*
|
|
60
|
+
* Call this ONLY on the manual debug paths (start_attach MCP, devtools-test
|
|
61
|
+
* CLI). Do NOT call on the `run_tests` auto-attach path — the red badge
|
|
62
|
+
* would contaminate screenshots, measure_safe_area probes, and DOM snapshots
|
|
63
|
+
* taken during automated measurement runs.
|
|
64
|
+
*
|
|
65
|
+
* SECRET-HANDLING: the injected expression contains no secrets, relay URLs,
|
|
66
|
+
* wss addresses, or TOTP codes — it is pure DOM UI text built by
|
|
67
|
+
* {@link buildIndicatorExpression}.
|
|
68
|
+
*
|
|
69
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
70
|
+
* @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.
|
|
71
|
+
*/
|
|
72
|
+
async function injectDebugIndicator(conn, opts) {
|
|
73
|
+
try {
|
|
74
|
+
await conn.send("Runtime.evaluate", {
|
|
75
|
+
expression: buildIndicatorExpression(opts),
|
|
76
|
+
returnByValue: true
|
|
77
|
+
});
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.debug("[@ait-co/devtools] debug indicator inject skipped:", err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { injectGlobals as n, injectDebugIndicator as t };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=cell-Dp_pDs_j.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-Dp_pDs_j.js","names":[],"sources":["../src/test-runner/cell.ts"],"sourcesContent":["/**\n * Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).\n *\n * Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the\n * first test bundle is injected. The injected values are session-global — one\n * call covers all files in the run.\n *\n * The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so\n * sdk-example's `aitCapture.ts` picks up the correct test-axis values instead\n * of falling back to `'2.x'`/`'mock'`.\n *\n * devtools does NOT know the shape of `__AIT_CELL__` — it only provides the\n * general injection mechanism. The caller (CLI or MCP auto-attach path) is\n * responsible for constructing the cell object.\n *\n * SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be\n * logged at the caller's discretion. This module does NOT log them itself.\n *\n * Node-only. react-free. CdpConnection only.\n */\n\nimport { buildIndicatorExpression } from '../mcp/attach-orchestrator.js';\nimport type { CdpConnection } from '../mcp/cdp-connection.js';\n\n/**\n * Injects each key of `globals` into `globalThis` in the page via a single\n * `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`\n * inject — the cell is session-global and applies to all subsequent files.\n *\n * Throws if the CDP evaluate returns an exception.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.\n */\nexport async function injectGlobals(\n conn: CdpConnection,\n globals: Record<string, unknown>,\n): Promise<void> {\n // JSON.stringify is safe here: globals values are plain data (sdkLine/platform\n // strings or simple objects). If a value is not JSON-serialisable this throws\n // at call time, which surfaces the error early and clearly.\n const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;\n const result = await conn.send('Runtime.evaluate', { expression: expr, returnByValue: true });\n if (result.exceptionDetails) {\n const msg =\n result.exceptionDetails.exception?.description ??\n result.exceptionDetails.text ??\n 'unknown error';\n throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);\n }\n}\n\n/**\n * Injects the \"Debugger Connected\" on-phone indicator via `Runtime.evaluate`.\n *\n * Uses the same CDP mechanism as {@link injectGlobals} — a single\n * `Runtime.evaluate` round-trip with the expression built by\n * {@link buildIndicatorExpression}. The indicator is a dismissible red badge\n * rendered at the bottom-left of the page (position:fixed, safe-area-aware).\n *\n * **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to\n * its caller. Injection failure (e.g. page detached during inject, CSS not\n * supported) is swallowed and logged as `console.debug` — the badge is\n * informational UI and must never block attach success or test execution.\n * This is the same fire-and-forget spirit as the eruda mount in\n * `src/in-app/attach.ts`.\n *\n * Call this ONLY on the manual debug paths (start_attach MCP, devtools-test\n * CLI). Do NOT call on the `run_tests` auto-attach path — the red badge\n * would contaminate screenshots, measure_safe_area probes, and DOM snapshots\n * taken during automated measurement runs.\n *\n * SECRET-HANDLING: the injected expression contains no secrets, relay URLs,\n * wss addresses, or TOTP codes — it is pure DOM UI text built by\n * {@link buildIndicatorExpression}.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.\n */\nexport async function injectDebugIndicator(\n conn: CdpConnection,\n opts?: { label?: string },\n): Promise<void> {\n try {\n await conn.send('Runtime.evaluate', {\n expression: buildIndicatorExpression(opts),\n returnByValue: true,\n });\n } catch (err) {\n // Badge injection is informational UI — swallow and log; never propagate.\n console.debug('[@ait-co/devtools] debug indicator inject skipped:', err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAsB,cACpB,MACA,SACe;CAIf,MAAM,OAAO,sCAAsC,KAAK,UAAU,QAAQ,CAAC;CAC3E,MAAM,SAAS,MAAM,KAAK,KAAK,oBAAoB;EAAE,YAAY;EAAM,eAAe;EAAM,CAAC;AAC7F,KAAI,OAAO,kBAAkB;EAC3B,MAAM,MACJ,OAAO,iBAAiB,WAAW,eACnC,OAAO,iBAAiB,QACxB;AACF,QAAM,IAAI,MAAM,0CAA0C,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BpE,eAAsB,qBACpB,MACA,MACe;AACf,KAAI;AACF,QAAM,KAAK,KAAK,oBAAoB;GAClC,YAAY,yBAAyB,KAAK;GAC1C,eAAe;GAChB,CAAC;UACK,KAAK;AAEZ,UAAQ,MAAM,sDAAsD,IAAI"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { buildIndicatorExpression } from "./attach-orchestrator-CFotueL3.js";
|
|
2
|
+
//#region src/test-runner/cell.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).
|
|
5
|
+
*
|
|
6
|
+
* Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the
|
|
7
|
+
* first test bundle is injected. The injected values are session-global — one
|
|
8
|
+
* call covers all files in the run.
|
|
9
|
+
*
|
|
10
|
+
* The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so
|
|
11
|
+
* sdk-example's `aitCapture.ts` picks up the correct test-axis values instead
|
|
12
|
+
* of falling back to `'2.x'`/`'mock'`.
|
|
13
|
+
*
|
|
14
|
+
* devtools does NOT know the shape of `__AIT_CELL__` — it only provides the
|
|
15
|
+
* general injection mechanism. The caller (CLI or MCP auto-attach path) is
|
|
16
|
+
* responsible for constructing the cell object.
|
|
17
|
+
*
|
|
18
|
+
* SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be
|
|
19
|
+
* logged at the caller's discretion. This module does NOT log them itself.
|
|
20
|
+
*
|
|
21
|
+
* Node-only. react-free. CdpConnection only.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Injects each key of `globals` into `globalThis` in the page via a single
|
|
25
|
+
* `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`
|
|
26
|
+
* inject — the cell is session-global and applies to all subsequent files.
|
|
27
|
+
*
|
|
28
|
+
* Throws if the CDP evaluate returns an exception.
|
|
29
|
+
*
|
|
30
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
31
|
+
* @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.
|
|
32
|
+
*/
|
|
33
|
+
async function injectGlobals(conn, globals) {
|
|
34
|
+
const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;
|
|
35
|
+
const result = await conn.send("Runtime.evaluate", {
|
|
36
|
+
expression: expr,
|
|
37
|
+
returnByValue: true
|
|
38
|
+
});
|
|
39
|
+
if (result.exceptionDetails) {
|
|
40
|
+
const msg = result.exceptionDetails.exception?.description ?? result.exceptionDetails.text ?? "unknown error";
|
|
41
|
+
throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Injects the "Debugger Connected" on-phone indicator via `Runtime.evaluate`.
|
|
46
|
+
*
|
|
47
|
+
* Uses the same CDP mechanism as {@link injectGlobals} — a single
|
|
48
|
+
* `Runtime.evaluate` round-trip with the expression built by
|
|
49
|
+
* {@link buildIndicatorExpression}. The indicator is a dismissible red badge
|
|
50
|
+
* rendered at the bottom-left of the page (position:fixed, safe-area-aware).
|
|
51
|
+
*
|
|
52
|
+
* **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to
|
|
53
|
+
* its caller. Injection failure (e.g. page detached during inject, CSS not
|
|
54
|
+
* supported) is swallowed and logged as `console.debug` — the badge is
|
|
55
|
+
* informational UI and must never block attach success or test execution.
|
|
56
|
+
* This is the same fire-and-forget spirit as the eruda mount in
|
|
57
|
+
* `src/in-app/attach.ts`.
|
|
58
|
+
*
|
|
59
|
+
* Call this ONLY on the manual debug paths (start_attach MCP, devtools-test
|
|
60
|
+
* CLI). Do NOT call on the `run_tests` auto-attach path — the red badge
|
|
61
|
+
* would contaminate screenshots, measure_safe_area probes, and DOM snapshots
|
|
62
|
+
* taken during automated measurement runs.
|
|
63
|
+
*
|
|
64
|
+
* SECRET-HANDLING: the injected expression contains no secrets, relay URLs,
|
|
65
|
+
* wss addresses, or TOTP codes — it is pure DOM UI text built by
|
|
66
|
+
* {@link buildIndicatorExpression}.
|
|
67
|
+
*
|
|
68
|
+
* @param conn - The live CDP connection (relay-attached page).
|
|
69
|
+
* @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.
|
|
70
|
+
*/
|
|
71
|
+
async function injectDebugIndicator(conn, opts) {
|
|
72
|
+
try {
|
|
73
|
+
await conn.send("Runtime.evaluate", {
|
|
74
|
+
expression: buildIndicatorExpression(opts),
|
|
75
|
+
returnByValue: true
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.debug("[@ait-co/devtools] debug indicator inject skipped:", err);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { injectDebugIndicator, injectGlobals };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=cell-nrWFeqvG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-nrWFeqvG.js","names":[],"sources":["../src/test-runner/cell.ts"],"sourcesContent":["/**\n * Cell injection utility for the `devtools-test` CLI (issue #684 §4.1).\n *\n * Injects arbitrary globals into the page via `Runtime.evaluate` BEFORE the\n * first test bundle is injected. The injected values are session-global — one\n * call covers all files in the run.\n *\n * The primary use-case is injecting `__AIT_CELL__` (sdkLine/platform) so\n * sdk-example's `aitCapture.ts` picks up the correct test-axis values instead\n * of falling back to `'2.x'`/`'mock'`.\n *\n * devtools does NOT know the shape of `__AIT_CELL__` — it only provides the\n * general injection mechanism. The caller (CLI or MCP auto-attach path) is\n * responsible for constructing the cell object.\n *\n * SECRET-HANDLING: cell values (sdkLine/platform) are not secrets and may be\n * logged at the caller's discretion. This module does NOT log them itself.\n *\n * Node-only. react-free. CdpConnection only.\n */\n\nimport { buildIndicatorExpression } from '../mcp/attach-orchestrator.js';\nimport type { CdpConnection } from '../mcp/cdp-connection.js';\n\n/**\n * Injects each key of `globals` into `globalThis` in the page via a single\n * `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`\n * inject — the cell is session-global and applies to all subsequent files.\n *\n * Throws if the CDP evaluate returns an exception.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param globals - Plain-JSON-serialisable key→value map to assign onto `globalThis`.\n */\nexport async function injectGlobals(\n conn: CdpConnection,\n globals: Record<string, unknown>,\n): Promise<void> {\n // JSON.stringify is safe here: globals values are plain data (sdkLine/platform\n // strings or simple objects). If a value is not JSON-serialisable this throws\n // at call time, which surfaces the error early and clearly.\n const expr = `(() => { Object.assign(globalThis, ${JSON.stringify(globals)}); return true; })()`;\n const result = await conn.send('Runtime.evaluate', { expression: expr, returnByValue: true });\n if (result.exceptionDetails) {\n const msg =\n result.exceptionDetails.exception?.description ??\n result.exceptionDetails.text ??\n 'unknown error';\n throw new Error(`injectGlobals: Runtime.evaluate threw: ${msg}`);\n }\n}\n\n/**\n * Injects the \"Debugger Connected\" on-phone indicator via `Runtime.evaluate`.\n *\n * Uses the same CDP mechanism as {@link injectGlobals} — a single\n * `Runtime.evaluate` round-trip with the expression built by\n * {@link buildIndicatorExpression}. The indicator is a dismissible red badge\n * rendered at the bottom-left of the page (position:fixed, safe-area-aware).\n *\n * **Isolation**: unlike {@link injectGlobals}, this function NEVER throws to\n * its caller. Injection failure (e.g. page detached during inject, CSS not\n * supported) is swallowed and logged as `console.debug` — the badge is\n * informational UI and must never block attach success or test execution.\n * This is the same fire-and-forget spirit as the eruda mount in\n * `src/in-app/attach.ts`.\n *\n * Call this ONLY on the manual debug paths (start_attach MCP, devtools-test\n * CLI). Do NOT call on the `run_tests` auto-attach path — the red badge\n * would contaminate screenshots, measure_safe_area probes, and DOM snapshots\n * taken during automated measurement runs.\n *\n * SECRET-HANDLING: the injected expression contains no secrets, relay URLs,\n * wss addresses, or TOTP codes — it is pure DOM UI text built by\n * {@link buildIndicatorExpression}.\n *\n * @param conn - The live CDP connection (relay-attached page).\n * @param opts - Optional overrides forwarded to {@link buildIndicatorExpression}.\n */\nexport async function injectDebugIndicator(\n conn: CdpConnection,\n opts?: { label?: string },\n): Promise<void> {\n try {\n await conn.send('Runtime.evaluate', {\n expression: buildIndicatorExpression(opts),\n returnByValue: true,\n });\n } catch (err) {\n // Badge injection is informational UI — swallow and log; never propagate.\n console.debug('[@ait-co/devtools] debug indicator inject skipped:', err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAsB,cACpB,MACA,SACe;CAIf,MAAM,OAAO,sCAAsC,KAAK,UAAU,QAAQ,CAAC;CAC3E,MAAM,SAAS,MAAM,KAAK,KAAK,oBAAoB;EAAE,YAAY;EAAM,eAAe;EAAM,CAAC;AAC7F,KAAI,OAAO,kBAAkB;EAC3B,MAAM,MACJ,OAAO,iBAAiB,WAAW,eACnC,OAAO,iBAAiB,QACxB;AACF,QAAM,IAAI,MAAM,0CAA0C,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BpE,eAAsB,qBACpB,MACA,MACe;AACf,KAAI;AACF,QAAM,KAAK,KAAK,oBAAoB;GAClC,YAAY,yBAAyB,KAAK;GAC1C,eAAe;GAChB,CAAC;UACK,KAAK;AAEZ,UAAQ,MAAM,sDAAsD,IAAI"}
|