execbro 1.11.1 → 2.0.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 +4 -4
- package/build/__tests__/unit/appContext.test.d.ts +2 -0
- package/build/__tests__/unit/appContext.test.d.ts.map +1 -0
- package/build/__tests__/unit/appContext.test.js +70 -0
- package/build/__tests__/unit/appContext.test.js.map +1 -0
- package/build/__tests__/unit/appRequest.test.d.ts +2 -0
- package/build/__tests__/unit/appRequest.test.d.ts.map +1 -0
- package/build/__tests__/unit/appRequest.test.js +179 -0
- package/build/__tests__/unit/appRequest.test.js.map +1 -0
- package/build/__tests__/unit/contextWiring.test.d.ts +2 -0
- package/build/__tests__/unit/contextWiring.test.d.ts.map +1 -0
- package/build/__tests__/unit/contextWiring.test.js +28 -0
- package/build/__tests__/unit/contextWiring.test.js.map +1 -0
- package/build/__tests__/unit/epochRender.test.d.ts +2 -0
- package/build/__tests__/unit/epochRender.test.d.ts.map +1 -0
- package/build/__tests__/unit/epochRender.test.js +60 -0
- package/build/__tests__/unit/epochRender.test.js.map +1 -0
- package/build/__tests__/unit/executeBudget.test.d.ts +2 -0
- package/build/__tests__/unit/executeBudget.test.d.ts.map +1 -0
- package/build/__tests__/unit/executeBudget.test.js +27 -0
- package/build/__tests__/unit/executeBudget.test.js.map +1 -0
- package/build/__tests__/unit/executor.test.js +48 -6
- package/build/__tests__/unit/executor.test.js.map +1 -1
- package/build/__tests__/unit/getLogsEmptyContract.test.js +4 -3
- package/build/__tests__/unit/getLogsEmptyContract.test.js.map +1 -1
- package/build/__tests__/unit/getLogsNativeSource.test.js +7 -8
- package/build/__tests__/unit/getLogsNativeSource.test.js.map +1 -1
- package/build/__tests__/unit/inspectorHarvest.test.js +1 -21
- package/build/__tests__/unit/inspectorHarvest.test.js.map +1 -1
- package/build/__tests__/unit/inspectorSource.test.js +1 -38
- package/build/__tests__/unit/inspectorSource.test.js.map +1 -1
- package/build/__tests__/unit/jsLogEvents.test.js +1 -0
- package/build/__tests__/unit/jsLogEvents.test.js.map +1 -1
- package/build/__tests__/unit/logBufferEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/logBufferEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/logBufferEpoch.test.js +63 -0
- package/build/__tests__/unit/logBufferEpoch.test.js.map +1 -0
- package/build/__tests__/unit/metro.test.js +18 -1
- package/build/__tests__/unit/metro.test.js.map +1 -1
- package/build/__tests__/unit/moduleRegistry.test.d.ts +2 -0
- package/build/__tests__/unit/moduleRegistry.test.d.ts.map +1 -0
- package/build/__tests__/unit/moduleRegistry.test.js +62 -0
- package/build/__tests__/unit/moduleRegistry.test.js.map +1 -0
- package/build/__tests__/unit/navigateVerify.test.d.ts +2 -0
- package/build/__tests__/unit/navigateVerify.test.d.ts.map +1 -0
- package/build/__tests__/unit/navigateVerify.test.js +30 -0
- package/build/__tests__/unit/navigateVerify.test.js.map +1 -0
- package/build/__tests__/unit/navigation.test.d.ts +2 -0
- package/build/__tests__/unit/navigation.test.d.ts.map +1 -0
- package/build/__tests__/unit/navigation.test.js +254 -0
- package/build/__tests__/unit/navigation.test.js.map +1 -0
- package/build/__tests__/unit/network.test.js +1 -0
- package/build/__tests__/unit/network.test.js.map +1 -1
- package/build/__tests__/unit/networkBufferEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/networkBufferEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/networkBufferEpoch.test.js +52 -0
- package/build/__tests__/unit/networkBufferEpoch.test.js.map +1 -0
- package/build/__tests__/unit/networkInterceptor.test.js +7 -7
- package/build/__tests__/unit/networkInterceptor.test.js.map +1 -1
- package/build/__tests__/unit/promiseHandles.test.d.ts +2 -0
- package/build/__tests__/unit/promiseHandles.test.d.ts.map +1 -0
- package/build/__tests__/unit/promiseHandles.test.js +61 -0
- package/build/__tests__/unit/promiseHandles.test.js.map +1 -0
- package/build/__tests__/unit/resolveBufferOffline.test.d.ts +2 -0
- package/build/__tests__/unit/resolveBufferOffline.test.d.ts.map +1 -0
- package/build/__tests__/unit/resolveBufferOffline.test.js +25 -0
- package/build/__tests__/unit/resolveBufferOffline.test.js.map +1 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.d.ts +2 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.d.ts.map +1 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.js +118 -0
- package/build/__tests__/unit/sdkMirrorPoller.test.js.map +1 -0
- package/build/__tests__/unit/sessionEpoch.test.d.ts +2 -0
- package/build/__tests__/unit/sessionEpoch.test.d.ts.map +1 -0
- package/build/__tests__/unit/sessionEpoch.test.js +41 -0
- package/build/__tests__/unit/sessionEpoch.test.js.map +1 -0
- package/build/__tests__/unit/truncate.test.d.ts +2 -0
- package/build/__tests__/unit/truncate.test.d.ts.map +1 -0
- package/build/__tests__/unit/truncate.test.js +58 -0
- package/build/__tests__/unit/truncate.test.js.map +1 -0
- package/build/core/appContext.d.ts +53 -0
- package/build/core/appContext.d.ts.map +1 -0
- package/build/core/appContext.js +172 -0
- package/build/core/appContext.js.map +1 -0
- package/build/core/appRequest.d.ts +21 -0
- package/build/core/appRequest.d.ts.map +1 -0
- package/build/core/appRequest.js +95 -0
- package/build/core/appRequest.js.map +1 -0
- package/build/core/bufferConfig.d.ts +5 -0
- package/build/core/bufferConfig.d.ts.map +1 -0
- package/build/core/bufferConfig.js +20 -0
- package/build/core/bufferConfig.js.map +1 -0
- package/build/core/connection.d.ts.map +1 -1
- package/build/core/connection.js +29 -9
- package/build/core/connection.js.map +1 -1
- package/build/core/debugGlobals.d.ts.map +1 -1
- package/build/core/debugGlobals.js +13 -0
- package/build/core/debugGlobals.js.map +1 -1
- package/build/core/epochRender.d.ts +19 -0
- package/build/core/epochRender.d.ts.map +1 -0
- package/build/core/epochRender.js +38 -0
- package/build/core/epochRender.js.map +1 -0
- package/build/core/guides.d.ts.map +1 -1
- package/build/core/guides.js +36 -91
- package/build/core/guides.js.map +1 -1
- package/build/core/index.d.ts +2 -3
- package/build/core/index.d.ts.map +1 -1
- package/build/core/index.js +4 -4
- package/build/core/index.js.map +1 -1
- package/build/core/inspector.d.ts +0 -39
- package/build/core/inspector.d.ts.map +1 -1
- package/build/core/inspector.js +1 -358
- package/build/core/inspector.js.map +1 -1
- package/build/core/ios.js +2 -2
- package/build/core/ios.js.map +1 -1
- package/build/core/jsExecute.d.ts +15 -0
- package/build/core/jsExecute.d.ts.map +1 -1
- package/build/core/jsExecute.js +136 -29
- package/build/core/jsExecute.js.map +1 -1
- package/build/core/logs.d.ts +12 -3
- package/build/core/logs.d.ts.map +1 -1
- package/build/core/logs.js +28 -5
- package/build/core/logs.js.map +1 -1
- package/build/core/metro.d.ts +2 -0
- package/build/core/metro.d.ts.map +1 -1
- package/build/core/metro.js +16 -8
- package/build/core/metro.js.map +1 -1
- package/build/core/moduleRegistry.d.ts +19 -0
- package/build/core/moduleRegistry.d.ts.map +1 -0
- package/build/core/moduleRegistry.js +67 -0
- package/build/core/moduleRegistry.js.map +1 -0
- package/build/core/nativeOnlyHints.d.ts.map +1 -1
- package/build/core/nativeOnlyHints.js +0 -2
- package/build/core/nativeOnlyHints.js.map +1 -1
- package/build/core/navigate.d.ts +46 -0
- package/build/core/navigate.d.ts.map +1 -0
- package/build/core/navigate.js +119 -0
- package/build/core/navigate.js.map +1 -0
- package/build/core/navigation.d.ts +66 -0
- package/build/core/navigation.d.ts.map +1 -0
- package/build/core/navigation.js +269 -0
- package/build/core/navigation.js.map +1 -0
- package/build/core/network.d.ts +12 -2
- package/build/core/network.d.ts.map +1 -1
- package/build/core/network.js +52 -12
- package/build/core/network.js.map +1 -1
- package/build/core/networkInterceptor.d.ts +1 -1
- package/build/core/networkInterceptor.d.ts.map +1 -1
- package/build/core/networkInterceptor.js +3 -2
- package/build/core/networkInterceptor.js.map +1 -1
- package/build/core/promiseHandles.d.ts +19 -0
- package/build/core/promiseHandles.d.ts.map +1 -0
- package/build/core/promiseHandles.js +58 -0
- package/build/core/promiseHandles.js.map +1 -0
- package/build/core/register.d.ts.map +1 -1
- package/build/core/register.js +1 -4
- package/build/core/register.js.map +1 -1
- package/build/core/sdkMirrorPoller.d.ts +31 -0
- package/build/core/sdkMirrorPoller.d.ts.map +1 -0
- package/build/core/sdkMirrorPoller.js +210 -0
- package/build/core/sdkMirrorPoller.js.map +1 -0
- package/build/core/state.d.ts +14 -0
- package/build/core/state.d.ts.map +1 -1
- package/build/core/state.js +48 -2
- package/build/core/state.js.map +1 -1
- package/build/core/toolHelpers.d.ts.map +1 -1
- package/build/core/toolHelpers.js +42 -10
- package/build/core/toolHelpers.js.map +1 -1
- package/build/core/truncate.d.ts +42 -0
- package/build/core/truncate.d.ts.map +1 -0
- package/build/core/truncate.js +169 -0
- package/build/core/truncate.js.map +1 -0
- package/build/core/types.d.ts +3 -0
- package/build/core/types.d.ts.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/tools/_deviceArg.d.ts +17 -1
- package/build/tools/_deviceArg.d.ts.map +1 -1
- package/build/tools/_deviceArg.js +17 -1
- package/build/tools/_deviceArg.js.map +1 -1
- package/build/tools/bundleTools.d.ts.map +1 -1
- package/build/tools/bundleTools.js +20 -33
- package/build/tools/bundleTools.js.map +1 -1
- package/build/tools/componentTools.d.ts.map +1 -1
- package/build/tools/componentTools.js +41 -219
- package/build/tools/componentTools.js.map +1 -1
- package/build/tools/connectionTools.d.ts.map +1 -1
- package/build/tools/connectionTools.js +17 -22
- package/build/tools/connectionTools.js.map +1 -1
- package/build/tools/deviceTools.d.ts.map +1 -1
- package/build/tools/deviceTools.js +13 -167
- package/build/tools/deviceTools.js.map +1 -1
- package/build/tools/executionTools.d.ts.map +1 -1
- package/build/tools/executionTools.js +63 -18
- package/build/tools/executionTools.js.map +1 -1
- package/build/tools/interactionTools.d.ts.map +1 -1
- package/build/tools/interactionTools.js +13 -45
- package/build/tools/interactionTools.js.map +1 -1
- package/build/tools/logTools.d.ts.map +1 -1
- package/build/tools/logTools.js +61 -80
- package/build/tools/logTools.js.map +1 -1
- package/build/tools/metaTools.js +1 -1
- package/build/tools/metaTools.js.map +1 -1
- package/build/tools/navigationTools.d.ts +3 -0
- package/build/tools/navigationTools.d.ts.map +1 -0
- package/build/tools/navigationTools.js +60 -0
- package/build/tools/navigationTools.js.map +1 -0
- package/build/tools/networkTools.d.ts.map +1 -1
- package/build/tools/networkTools.js +44 -202
- package/build/tools/networkTools.js.map +1 -1
- package/build/tools/reduxTools.d.ts.map +1 -1
- package/build/tools/reduxTools.js +3 -2
- package/build/tools/reduxTools.js.map +1 -1
- package/build/tools/requestTools.d.ts +3 -0
- package/build/tools/requestTools.d.ts.map +1 -0
- package/build/tools/requestTools.js +79 -0
- package/build/tools/requestTools.js.map +1 -0
- package/build/tools/screenshotTools.d.ts.map +1 -1
- package/build/tools/screenshotTools.js +9 -13
- package/build/tools/screenshotTools.js.map +1 -1
- package/package.json +1 -1
- package/tools.json +22 -78
- package/build/__tests__/unit/flowpoints.test.d.ts +0 -2
- package/build/__tests__/unit/flowpoints.test.d.ts.map +0 -1
- package/build/__tests__/unit/flowpoints.test.js +0 -126
- package/build/__tests__/unit/flowpoints.test.js.map +0 -1
- package/build/__tests__/unit/flowpointsQuery.test.d.ts +0 -2
- package/build/__tests__/unit/flowpointsQuery.test.d.ts.map +0 -1
- package/build/__tests__/unit/flowpointsQuery.test.js +0 -91
- package/build/__tests__/unit/flowpointsQuery.test.js.map +0 -1
- package/build/__tests__/unit/selectionPoller.test.d.ts +0 -2
- package/build/__tests__/unit/selectionPoller.test.d.ts.map +0 -1
- package/build/__tests__/unit/selectionPoller.test.js +0 -109
- package/build/__tests__/unit/selectionPoller.test.js.map +0 -1
- package/build/__tests__/unit/verifyFlow.test.d.ts +0 -2
- package/build/__tests__/unit/verifyFlow.test.d.ts.map +0 -1
- package/build/__tests__/unit/verifyFlow.test.js +0 -45
- package/build/__tests__/unit/verifyFlow.test.js.map +0 -1
- package/build/core/selectionPoller.d.ts +0 -13
- package/build/core/selectionPoller.d.ts.map +0 -1
- package/build/core/selectionPoller.js +0 -102
- package/build/core/selectionPoller.js.map +0 -1
- package/build/pro/flowpointTools.d.ts +0 -4
- package/build/pro/flowpointTools.d.ts.map +0 -1
- package/build/pro/flowpointTools.js +0 -266
- package/build/pro/flowpointTools.js.map +0 -1
- package/build/pro/flowpoints.d.ts +0 -86
- package/build/pro/flowpoints.d.ts.map +0 -1
- package/build/pro/flowpoints.js +0 -283
- package/build/pro/flowpoints.js.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jest } from "@jest/globals";
|
|
2
|
+
const executeInApp = jest.fn();
|
|
3
|
+
jest.unstable_mockModule("../../core/executor.js", () => ({ executeInApp }));
|
|
4
|
+
const { mirrorOnce, __resetMirrorState } = await import("../../core/sdkMirrorPoller.js");
|
|
5
|
+
const { getLogBuffer, getNetworkBuffer, resetEpochs, bumpEpoch, getEpoch, connectedApps, logBuffers, networkBuffers } = await import("../../core/state.js");
|
|
6
|
+
const { __resetLogSeq } = await import("../../core/logs.js");
|
|
7
|
+
const payload = (network, console_, runId = "run-1") => ({
|
|
8
|
+
success: true,
|
|
9
|
+
result: JSON.stringify({ runId, network, console: console_ }),
|
|
10
|
+
});
|
|
11
|
+
const netEntry = (id) => ({
|
|
12
|
+
id,
|
|
13
|
+
timestamp: Date.now(),
|
|
14
|
+
method: "GET",
|
|
15
|
+
url: `https://api.test/${id}`,
|
|
16
|
+
status: 200,
|
|
17
|
+
requestHeaders: {},
|
|
18
|
+
responseHeaders: {},
|
|
19
|
+
completed: true,
|
|
20
|
+
});
|
|
21
|
+
const logEntry = (id, message) => ({
|
|
22
|
+
id,
|
|
23
|
+
timestamp: Date.now(),
|
|
24
|
+
level: "log",
|
|
25
|
+
message,
|
|
26
|
+
});
|
|
27
|
+
describe("mirrorOnce", () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
executeInApp.mockReset();
|
|
30
|
+
__resetMirrorState();
|
|
31
|
+
__resetLogSeq();
|
|
32
|
+
resetEpochs();
|
|
33
|
+
getLogBuffer("dev").clear();
|
|
34
|
+
getNetworkBuffer("dev").clear();
|
|
35
|
+
});
|
|
36
|
+
it("copies SDK entries into the server buffers", async () => {
|
|
37
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [logEntry("c1", "hello")]));
|
|
38
|
+
const result = await mirrorOnce("dev");
|
|
39
|
+
expect(result).toEqual({ logs: 1, network: 1 });
|
|
40
|
+
expect(getNetworkBuffer("dev").size).toBe(1);
|
|
41
|
+
expect(getLogBuffer("dev").getAll()[0].message).toBe("hello");
|
|
42
|
+
});
|
|
43
|
+
it("is idempotent across repeated polls", async () => {
|
|
44
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [logEntry("c1", "hello")]));
|
|
45
|
+
await mirrorOnce("dev");
|
|
46
|
+
const second = await mirrorOnce("dev");
|
|
47
|
+
expect(second).toEqual({ logs: 0, network: 0 });
|
|
48
|
+
expect(getLogBuffer("dev").size).toBe(1);
|
|
49
|
+
expect(getNetworkBuffer("dev").size).toBe(1);
|
|
50
|
+
});
|
|
51
|
+
it("re-mirrors the same SDK ids after an epoch bump", async () => {
|
|
52
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [logEntry("c1", "hello")]));
|
|
53
|
+
await mirrorOnce("dev");
|
|
54
|
+
bumpEpoch("dev");
|
|
55
|
+
const afterRestart = await mirrorOnce("dev");
|
|
56
|
+
expect(afterRestart).toEqual({ logs: 1, network: 1 });
|
|
57
|
+
expect(getNetworkBuffer("dev").size).toBe(2);
|
|
58
|
+
});
|
|
59
|
+
it("bumps the epoch when the runtime nonce changes", async () => {
|
|
60
|
+
// The only reliable restart signal: Metro's inspector proxy reuses the
|
|
61
|
+
// CDP target id after a process kill, and a dead runtime emits no
|
|
62
|
+
// executionContextsCleared. A fresh globalThis is direct proof.
|
|
63
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [], "run-1"));
|
|
64
|
+
await mirrorOnce("dev");
|
|
65
|
+
expect(getEpoch("dev")).toBe(1);
|
|
66
|
+
// Same SDK id, new runtime: must land as a distinct entry, not overwrite.
|
|
67
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [], "run-2"));
|
|
68
|
+
const afterRestart = await mirrorOnce("dev");
|
|
69
|
+
expect(getEpoch("dev")).toBe(2);
|
|
70
|
+
expect(afterRestart).toEqual({ logs: 0, network: 1 });
|
|
71
|
+
expect(getNetworkBuffer("dev").size).toBe(2);
|
|
72
|
+
});
|
|
73
|
+
it("does not bump while the runtime nonce is stable", async () => {
|
|
74
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [], "run-1"));
|
|
75
|
+
await mirrorOnce("dev");
|
|
76
|
+
await mirrorOnce("dev");
|
|
77
|
+
await mirrorOnce("dev");
|
|
78
|
+
expect(getEpoch("dev")).toBe(1);
|
|
79
|
+
});
|
|
80
|
+
it("mirrors into the connected device's buffer key, not the caller's substring", async () => {
|
|
81
|
+
// Tools pass a user-facing substring ("iPhone"); the buffer key is the
|
|
82
|
+
// full device name. Using the substring as the key mirrors into a
|
|
83
|
+
// phantom buffer that device-scoped reads never resolve to, so the
|
|
84
|
+
// SDK data silently goes missing for exactly those calls.
|
|
85
|
+
connectedApps.set("8081-abc", {
|
|
86
|
+
ws: {},
|
|
87
|
+
deviceInfo: { deviceName: "iPhone 17 Pro", title: "app", id: "abc" },
|
|
88
|
+
port: 8081,
|
|
89
|
+
platform: "ios",
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
executeInApp.mockResolvedValue(payload([netEntry("n1")], [logEntry("c1", "hi")]));
|
|
93
|
+
await mirrorOnce("iPhone");
|
|
94
|
+
expect(getNetworkBuffer("iPhone 17 Pro").size).toBe(1);
|
|
95
|
+
expect(getLogBuffer("iPhone 17 Pro").size).toBe(1);
|
|
96
|
+
expect(logBuffers.has("iPhone")).toBe(false);
|
|
97
|
+
expect(networkBuffers.has("iPhone")).toBe(false);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
connectedApps.delete("8081-abc");
|
|
101
|
+
getNetworkBuffer("iPhone 17 Pro").clear();
|
|
102
|
+
getLogBuffer("iPhone 17 Pro").clear();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
it("returns zeroes when the eval fails", async () => {
|
|
106
|
+
executeInApp.mockResolvedValue({ success: false, error: "disconnected" });
|
|
107
|
+
expect(await mirrorOnce("dev")).toEqual({ logs: 0, network: 0 });
|
|
108
|
+
});
|
|
109
|
+
it("returns zeroes on malformed JSON", async () => {
|
|
110
|
+
executeInApp.mockResolvedValue({ success: true, result: "not json" });
|
|
111
|
+
expect(await mirrorOnce("dev")).toEqual({ logs: 0, network: 0 });
|
|
112
|
+
});
|
|
113
|
+
it("swallows a thrown eval", async () => {
|
|
114
|
+
executeInApp.mockRejectedValue(new Error("boom"));
|
|
115
|
+
expect(await mirrorOnce("dev")).toEqual({ logs: 0, network: 0 });
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=sdkMirrorPoller.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkMirrorPoller.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/sdkMirrorPoller.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAO,CAAC;AACpC,IAAI,CAAC,mBAAmB,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;AAE7E,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;AACzF,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAA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,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionEpoch.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/sessionEpoch.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getEpoch, bumpEpoch, resetEpochs } from "../../core/state.js";
|
|
2
|
+
import { logBufferSize, networkBufferSize } from "../../core/bufferConfig.js";
|
|
3
|
+
describe("sessionEpoch", () => {
|
|
4
|
+
beforeEach(() => resetEpochs());
|
|
5
|
+
it("starts at 1 for an unseen device", () => {
|
|
6
|
+
expect(getEpoch("iPhone 17 Pro")).toBe(1);
|
|
7
|
+
});
|
|
8
|
+
it("increments on bump and returns the new value", () => {
|
|
9
|
+
expect(bumpEpoch("iPhone 17 Pro")).toBe(2);
|
|
10
|
+
expect(getEpoch("iPhone 17 Pro")).toBe(2);
|
|
11
|
+
});
|
|
12
|
+
it("tracks epochs independently per device", () => {
|
|
13
|
+
bumpEpoch("iPhone 17 Pro");
|
|
14
|
+
bumpEpoch("iPhone 17 Pro");
|
|
15
|
+
expect(getEpoch("iPhone 17 Pro")).toBe(3);
|
|
16
|
+
expect(getEpoch("sdk_gphone64_arm64")).toBe(1);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe("bufferConfig", () => {
|
|
20
|
+
const saved = { ...process.env };
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
process.env = { ...saved };
|
|
23
|
+
});
|
|
24
|
+
it("defaults to 2000 logs and 1000 network entries", () => {
|
|
25
|
+
expect(logBufferSize()).toBe(2000);
|
|
26
|
+
expect(networkBufferSize()).toBe(1000);
|
|
27
|
+
});
|
|
28
|
+
it("honours env overrides", () => {
|
|
29
|
+
process.env.EXECBRO_LOG_BUFFER_SIZE = "50";
|
|
30
|
+
process.env.EXECBRO_NET_BUFFER_SIZE = "25";
|
|
31
|
+
expect(logBufferSize()).toBe(50);
|
|
32
|
+
expect(networkBufferSize()).toBe(25);
|
|
33
|
+
});
|
|
34
|
+
it("ignores non-numeric and non-positive overrides", () => {
|
|
35
|
+
process.env.EXECBRO_LOG_BUFFER_SIZE = "abc";
|
|
36
|
+
expect(logBufferSize()).toBe(2000);
|
|
37
|
+
process.env.EXECBRO_LOG_BUFFER_SIZE = "0";
|
|
38
|
+
expect(logBufferSize()).toBe(2000);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=sessionEpoch.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionEpoch.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/sessionEpoch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE9E,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAEhC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC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AuB,GAAG,KAAK,CAAC;QAC5C,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAC;QAC1C,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/truncate.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, it, expect } from "@jest/globals";
|
|
2
|
+
import { truncateToBudget } from "../../core/truncate.js";
|
|
3
|
+
describe("truncateToBudget", () => {
|
|
4
|
+
it("returns small values byte-identical and reports no truncation", () => {
|
|
5
|
+
const value = { entityDrawerOpen: false };
|
|
6
|
+
const out = truncateToBudget(value, 25000);
|
|
7
|
+
expect(out.truncated).toBe(false);
|
|
8
|
+
expect(out.appliedBudget).toBeNull();
|
|
9
|
+
expect(JSON.stringify(out.value)).toBe(JSON.stringify(value));
|
|
10
|
+
});
|
|
11
|
+
it("bounds a large array and preserves its true length in the marker", () => {
|
|
12
|
+
const value = { data: Array.from({ length: 153 }, (_, i) => ({ id: i, a: 1, b: 2 })) };
|
|
13
|
+
const out = truncateToBudget(value, 300);
|
|
14
|
+
expect(out.truncated).toBe(true);
|
|
15
|
+
expect(out.returnedBytes).toBeLessThanOrEqual(300);
|
|
16
|
+
const rendered = JSON.stringify(out.value);
|
|
17
|
+
expect(rendered).toContain("more");
|
|
18
|
+
expect(rendered).toMatch(/\+1[0-9][0-9] more/);
|
|
19
|
+
});
|
|
20
|
+
it("survives circular references instead of throwing", () => {
|
|
21
|
+
const a = { name: "root" };
|
|
22
|
+
a.self = a;
|
|
23
|
+
const out = truncateToBudget(a, 25000);
|
|
24
|
+
// `truncated` reports "content was elided", and a cycle always is —
|
|
25
|
+
// it cannot be represented in JSON. Sibling keys survive intact.
|
|
26
|
+
expect(out.truncated).toBe(true);
|
|
27
|
+
expect(JSON.stringify(out.value)).toContain("[Circular]");
|
|
28
|
+
expect(out.value.name).toBe("root");
|
|
29
|
+
});
|
|
30
|
+
it("keeps repeated (non-circular) references intact", () => {
|
|
31
|
+
// A shared child appearing twice is not a cycle — marking the second
|
|
32
|
+
// occurrence "[Circular]" would be a false positive, so `seen` must be
|
|
33
|
+
// path-scoped rather than global.
|
|
34
|
+
const shared = { id: 7 };
|
|
35
|
+
const out = truncateToBudget({ first: shared, second: shared }, 25000);
|
|
36
|
+
expect(out.truncated).toBe(false);
|
|
37
|
+
expect(JSON.stringify(out.value)).toBe(JSON.stringify({ first: { id: 7 }, second: { id: 7 } }));
|
|
38
|
+
});
|
|
39
|
+
it("reports original and returned byte counts", () => {
|
|
40
|
+
const value = { s: "x".repeat(5000) };
|
|
41
|
+
const out = truncateToBudget(value, 200);
|
|
42
|
+
expect(out.originalBytes).toBeGreaterThan(5000);
|
|
43
|
+
expect(out.returnedBytes).toBeLessThanOrEqual(200);
|
|
44
|
+
expect(out.appliedBudget).not.toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it("honours an explicit budget over the adaptive ladder", () => {
|
|
47
|
+
const value = { arr: [1, 2, 3, 4, 5, 6, 7, 8] };
|
|
48
|
+
const out = truncateToBudget(value, 25000, { maxArrayItems: 2 });
|
|
49
|
+
expect(JSON.stringify(out.value)).toContain("+6 more");
|
|
50
|
+
});
|
|
51
|
+
it("marks objects and arrays elided by depth with their sizes", () => {
|
|
52
|
+
const value = { a: { b: { c: { d: { e: [1, 2, 3] } } } } };
|
|
53
|
+
const out = truncateToBudget(value, 25000, { maxDepth: 2 });
|
|
54
|
+
const rendered = JSON.stringify(out.value);
|
|
55
|
+
expect(rendered).toContain("{Object(");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=truncate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E,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;QAC3D,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RESOLUTION ORDER — read this before adding a new handle to the context.
|
|
3
|
+
*
|
|
4
|
+
* When you need something the app holds privately, try the sources that are
|
|
5
|
+
* *records the runtime already keeps* before reaching into live internals.
|
|
6
|
+
* Records are stable and enumerable; internals are closures we usually cannot
|
|
7
|
+
* open, and the introspection that does work tends to be the first thing to
|
|
8
|
+
* break on a library upgrade.
|
|
9
|
+
*
|
|
10
|
+
* 1. Metro module registry (`__r.getModules()`) — anything a module exported.
|
|
11
|
+
* Resolved expo-router's imperative API when no global existed.
|
|
12
|
+
* 2. SDK network buffer (`__RN_AI_DEVTOOLS__.getNetworkEntries()`) — anything
|
|
13
|
+
* that went over the wire: headers, endpoints, credentials.
|
|
14
|
+
* Resolved the bearer token for Apollo apps that keep none in redux.
|
|
15
|
+
* 3. Fiber tree — anything passed as props or context. Resolves the redux
|
|
16
|
+
* store and React Navigation refs.
|
|
17
|
+
* 4. Known globals and the SDK registry — cheap, but app-specific and often
|
|
18
|
+
* absent or, worse, a bespoke wrapper (Boardwise's `__EXPO_ROUTER__` is
|
|
19
|
+
* not the library's `router`).
|
|
20
|
+
* 5. Introspection of live internals — last resort. Apollo's auth link is a
|
|
21
|
+
* closure over an async getter; Zustand stores are module-scoped hooks and
|
|
22
|
+
* never appear in the fiber tree at all.
|
|
23
|
+
*
|
|
24
|
+
* Two facts that motivate the ordering: single-strategy fiber resolution
|
|
25
|
+
* accounted for 33 of 103 redux-tool failures (32%), and the two hardest
|
|
26
|
+
* handles here — expo-router and the Apollo token — were both solved by
|
|
27
|
+
* records (1 and 2), not by introspection.
|
|
28
|
+
*
|
|
29
|
+
* Rationale and evidence: docs/devtools-core/specs/2026-07-31-bounded-state-reads-design.md §4.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CONTEXT_BINDINGS: readonly ["require", "store", "state", "apollo", "cache", "deref", "router", "summary", "__eb_require"];
|
|
32
|
+
/**
|
|
33
|
+
* Injected preamble exposing resolved app handles to every evaluated
|
|
34
|
+
* expression.
|
|
35
|
+
*
|
|
36
|
+
* Motivated by telemetry, not ergonomics: store resolution is the single
|
|
37
|
+
* largest failure cause for the redux tools (33 of 103 failures), because no
|
|
38
|
+
* one strategy works across apps — `__REDUX_STORE__` exists in Boardwise and
|
|
39
|
+
* astro but not gifted, while gifted has the SDK registry. Agents work around
|
|
40
|
+
* it by hand-writing `__REDUX_STORE__ || __RN_AI_DEVTOOLS__.stores.redux`
|
|
41
|
+
* fallback chains, and one recorded call was spent entirely on
|
|
42
|
+
* `Object.keys(globalThis).filter(k => k.includes('REDUX'))`.
|
|
43
|
+
*
|
|
44
|
+
* Cost discipline: this runs on every call. The fiber walk is ~1 ms and is
|
|
45
|
+
* done eagerly; `cache()` and `__eb_require` are deferred because
|
|
46
|
+
* `cache.extract()` costs 17 ms and can materialise 1.6 MB, and indexing
|
|
47
|
+
* ~4,000 modules is not free either.
|
|
48
|
+
*
|
|
49
|
+
* Every binding degrades to null rather than throwing. ES5 only — Hermes
|
|
50
|
+
* compiles this string.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildContextPreamble(): string;
|
|
53
|
+
//# sourceMappingURL=appContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appContext.d.ts","sourceRoot":"","sources":["../../src/core/appContext.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,eAAO,MAAM,gBAAgB,yGAUnB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA4G7C"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { buildRequireSource } from "./moduleRegistry.js";
|
|
2
|
+
/**
|
|
3
|
+
* RESOLUTION ORDER — read this before adding a new handle to the context.
|
|
4
|
+
*
|
|
5
|
+
* When you need something the app holds privately, try the sources that are
|
|
6
|
+
* *records the runtime already keeps* before reaching into live internals.
|
|
7
|
+
* Records are stable and enumerable; internals are closures we usually cannot
|
|
8
|
+
* open, and the introspection that does work tends to be the first thing to
|
|
9
|
+
* break on a library upgrade.
|
|
10
|
+
*
|
|
11
|
+
* 1. Metro module registry (`__r.getModules()`) — anything a module exported.
|
|
12
|
+
* Resolved expo-router's imperative API when no global existed.
|
|
13
|
+
* 2. SDK network buffer (`__RN_AI_DEVTOOLS__.getNetworkEntries()`) — anything
|
|
14
|
+
* that went over the wire: headers, endpoints, credentials.
|
|
15
|
+
* Resolved the bearer token for Apollo apps that keep none in redux.
|
|
16
|
+
* 3. Fiber tree — anything passed as props or context. Resolves the redux
|
|
17
|
+
* store and React Navigation refs.
|
|
18
|
+
* 4. Known globals and the SDK registry — cheap, but app-specific and often
|
|
19
|
+
* absent or, worse, a bespoke wrapper (Boardwise's `__EXPO_ROUTER__` is
|
|
20
|
+
* not the library's `router`).
|
|
21
|
+
* 5. Introspection of live internals — last resort. Apollo's auth link is a
|
|
22
|
+
* closure over an async getter; Zustand stores are module-scoped hooks and
|
|
23
|
+
* never appear in the fiber tree at all.
|
|
24
|
+
*
|
|
25
|
+
* Two facts that motivate the ordering: single-strategy fiber resolution
|
|
26
|
+
* accounted for 33 of 103 redux-tool failures (32%), and the two hardest
|
|
27
|
+
* handles here — expo-router and the Apollo token — were both solved by
|
|
28
|
+
* records (1 and 2), not by introspection.
|
|
29
|
+
*
|
|
30
|
+
* Rationale and evidence: docs/devtools-core/specs/2026-07-31-bounded-state-reads-design.md §4.
|
|
31
|
+
*/
|
|
32
|
+
export const CONTEXT_BINDINGS = [
|
|
33
|
+
"require",
|
|
34
|
+
"store",
|
|
35
|
+
"state",
|
|
36
|
+
"apollo",
|
|
37
|
+
"cache",
|
|
38
|
+
"deref",
|
|
39
|
+
"router",
|
|
40
|
+
"summary",
|
|
41
|
+
"__eb_require"
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Injected preamble exposing resolved app handles to every evaluated
|
|
45
|
+
* expression.
|
|
46
|
+
*
|
|
47
|
+
* Motivated by telemetry, not ergonomics: store resolution is the single
|
|
48
|
+
* largest failure cause for the redux tools (33 of 103 failures), because no
|
|
49
|
+
* one strategy works across apps — `__REDUX_STORE__` exists in Boardwise and
|
|
50
|
+
* astro but not gifted, while gifted has the SDK registry. Agents work around
|
|
51
|
+
* it by hand-writing `__REDUX_STORE__ || __RN_AI_DEVTOOLS__.stores.redux`
|
|
52
|
+
* fallback chains, and one recorded call was spent entirely on
|
|
53
|
+
* `Object.keys(globalThis).filter(k => k.includes('REDUX'))`.
|
|
54
|
+
*
|
|
55
|
+
* Cost discipline: this runs on every call. The fiber walk is ~1 ms and is
|
|
56
|
+
* done eagerly; `cache()` and `__eb_require` are deferred because
|
|
57
|
+
* `cache.extract()` costs 17 ms and can materialise 1.6 MB, and indexing
|
|
58
|
+
* ~4,000 modules is not free either.
|
|
59
|
+
*
|
|
60
|
+
* Every binding degrades to null rather than throwing. ES5 only — Hermes
|
|
61
|
+
* compiles this string.
|
|
62
|
+
*/
|
|
63
|
+
export function buildContextPreamble() {
|
|
64
|
+
return `
|
|
65
|
+
${buildRequireSource()}
|
|
66
|
+
// Expose under the natural name too. Hermes has no require in the evaluate
|
|
67
|
+
// scope, so this shadows nothing, and var keeps it local to the evaluated
|
|
68
|
+
// program rather than mutating globalThis.
|
|
69
|
+
var require = __eb_require;
|
|
70
|
+
var __eb_fiberFind = function (predicate) {
|
|
71
|
+
try {
|
|
72
|
+
var hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
73
|
+
if (!hook || typeof hook.getFiberRoots !== 'function' || !hook.renderers) return null;
|
|
74
|
+
var found = null;
|
|
75
|
+
var ids = [];
|
|
76
|
+
hook.renderers.forEach(function (_, k) { ids.push(k); });
|
|
77
|
+
var walk = function (f, d) {
|
|
78
|
+
if (!f || d > 1600 || found) return;
|
|
79
|
+
var p = f.memoizedProps;
|
|
80
|
+
if (p) {
|
|
81
|
+
var hit = predicate(p, f);
|
|
82
|
+
if (hit) { found = hit; return; }
|
|
83
|
+
}
|
|
84
|
+
if (f.child) walk(f.child, d + 1);
|
|
85
|
+
if (f.sibling) walk(f.sibling, d);
|
|
86
|
+
};
|
|
87
|
+
for (var i = 0; i < ids.length; i++) {
|
|
88
|
+
var roots = hook.getFiberRoots(ids[i]);
|
|
89
|
+
if (!roots) continue;
|
|
90
|
+
roots.forEach(function (r) { walk(r.current, 0); });
|
|
91
|
+
}
|
|
92
|
+
return found;
|
|
93
|
+
} catch (e) { return null; }
|
|
94
|
+
};
|
|
95
|
+
var __eb_isStore = function (v) {
|
|
96
|
+
return !!v && typeof v === 'object' && typeof v.dispatch === 'function' &&
|
|
97
|
+
typeof v.getState === 'function' && typeof v.subscribe === 'function';
|
|
98
|
+
};
|
|
99
|
+
var store = (function () {
|
|
100
|
+
try {
|
|
101
|
+
var viaFiber = __eb_fiberFind(function (p) { return __eb_isStore(p.store) ? p.store : null; });
|
|
102
|
+
if (viaFiber) return viaFiber;
|
|
103
|
+
if (__eb_isStore(globalThis.__REDUX_STORE__)) return globalThis.__REDUX_STORE__;
|
|
104
|
+
var sdk = globalThis.__RN_AI_DEVTOOLS__;
|
|
105
|
+
if (sdk && sdk.stores && __eb_isStore(sdk.stores.redux)) return sdk.stores.redux;
|
|
106
|
+
if (sdk && sdk.custom && sdk.custom.StoreRegister && __eb_isStore(sdk.custom.StoreRegister.store)) {
|
|
107
|
+
return sdk.custom.StoreRegister.store;
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
} catch (e) { return null; }
|
|
111
|
+
})();
|
|
112
|
+
var state = store ? store.getState() : null;
|
|
113
|
+
var apollo = (function () {
|
|
114
|
+
try {
|
|
115
|
+
if (globalThis.__APOLLO_CLIENT__) return globalThis.__APOLLO_CLIENT__;
|
|
116
|
+
return __eb_fiberFind(function (p) {
|
|
117
|
+
return p.client && p.client.cache && typeof p.client.query === 'function' ? p.client : null;
|
|
118
|
+
});
|
|
119
|
+
} catch (e) { return null; }
|
|
120
|
+
})();
|
|
121
|
+
var __eb_cache = null;
|
|
122
|
+
function cache() {
|
|
123
|
+
if (__eb_cache) return __eb_cache;
|
|
124
|
+
if (!apollo || !apollo.cache || typeof apollo.cache.extract !== 'function') return null;
|
|
125
|
+
try { __eb_cache = apollo.cache.extract(); } catch (e) { return null; }
|
|
126
|
+
return __eb_cache;
|
|
127
|
+
}
|
|
128
|
+
var deref = function (value, c) {
|
|
129
|
+
var source = c || __eb_cache;
|
|
130
|
+
if (!value || typeof value !== 'object' || !value.__ref) return value;
|
|
131
|
+
if (!source) return value;
|
|
132
|
+
return source[value.__ref];
|
|
133
|
+
};
|
|
134
|
+
var router = (function () {
|
|
135
|
+
try {
|
|
136
|
+
var m = __eb_require('expo-router/build/imperative-api');
|
|
137
|
+
if (m && m.router && typeof m.router.navigate === 'function') return m.router;
|
|
138
|
+
} catch (e) { /* fall through */ }
|
|
139
|
+
try {
|
|
140
|
+
var viaFiber = __eb_fiberFind(function (p) {
|
|
141
|
+
if (p.value && typeof p.value.navigate === 'function' && typeof p.value.resetRoot === 'function') return p.value;
|
|
142
|
+
if (p.navigation && typeof p.navigation.navigate === 'function' && typeof p.navigation.resetRoot === 'function') return p.navigation;
|
|
143
|
+
return null;
|
|
144
|
+
});
|
|
145
|
+
if (viaFiber) return viaFiber;
|
|
146
|
+
var sdk = globalThis.__RN_AI_DEVTOOLS__;
|
|
147
|
+
if (sdk && sdk.navigation) return sdk.navigation;
|
|
148
|
+
if (globalThis.__EXPO_ROUTER__) return globalThis.__EXPO_ROUTER__;
|
|
149
|
+
return null;
|
|
150
|
+
} catch (e) { return null; }
|
|
151
|
+
})();
|
|
152
|
+
var summary = function (value) {
|
|
153
|
+
if (!value || typeof value !== 'object') return value;
|
|
154
|
+
var keys = Object.keys(value);
|
|
155
|
+
var rows = [];
|
|
156
|
+
for (var i = 0; i < keys.length; i++) {
|
|
157
|
+
var v = value[keys[i]];
|
|
158
|
+
var bytes = -1;
|
|
159
|
+
try { bytes = JSON.stringify(v).length; } catch (e) { bytes = -1; }
|
|
160
|
+
rows.push({
|
|
161
|
+
key: keys[i],
|
|
162
|
+
type: Array.isArray(v) ? 'array' : (v === null ? 'null' : typeof v),
|
|
163
|
+
count: v && typeof v === 'object' ? Object.keys(v).length : undefined,
|
|
164
|
+
bytes: bytes
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
rows.sort(function (a, b) { return b.bytes - a.bytes; });
|
|
168
|
+
return rows;
|
|
169
|
+
};
|
|
170
|
+
`.trim();
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=appContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appContext.js","sourceRoot":"","sources":["../../src/core/appContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,SAAS;IACT,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,cAAc;CACR,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB;IAChC,OAAO;EACT,kBAAkB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyGrB,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface AppRequestOptions {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
body?: unknown;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
auth?: "auto" | "none";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build an in-app fetch as a promise chain.
|
|
10
|
+
*
|
|
11
|
+
* Runs inside the app so it inherits the real network stack, TLS trust and
|
|
12
|
+
* proxy configuration — and so the bearer token is resolved from live state
|
|
13
|
+
* rather than pasted into the expression. The corpus shows 21 instances of this
|
|
14
|
+
* pattern across two apps; Boardwise's 15 embed a full JWT literal, which puts
|
|
15
|
+
* the credential in the transcript.
|
|
16
|
+
*
|
|
17
|
+
* Promise chain, not async/await: async function syntax is engine-dependent and
|
|
18
|
+
* rejected by many Hermes builds.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildRequestExpression(opts: AppRequestOptions): string;
|
|
21
|
+
//# sourceMappingURL=appRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appRequest.d.ts","sourceRoot":"","sources":["../../src/core/appRequest.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAmFtE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build an in-app fetch as a promise chain.
|
|
3
|
+
*
|
|
4
|
+
* Runs inside the app so it inherits the real network stack, TLS trust and
|
|
5
|
+
* proxy configuration — and so the bearer token is resolved from live state
|
|
6
|
+
* rather than pasted into the expression. The corpus shows 21 instances of this
|
|
7
|
+
* pattern across two apps; Boardwise's 15 embed a full JWT literal, which puts
|
|
8
|
+
* the credential in the transcript.
|
|
9
|
+
*
|
|
10
|
+
* Promise chain, not async/await: async function syntax is engine-dependent and
|
|
11
|
+
* rejected by many Hermes builds.
|
|
12
|
+
*/
|
|
13
|
+
export function buildRequestExpression(opts) {
|
|
14
|
+
const method = JSON.stringify(opts.method.toUpperCase());
|
|
15
|
+
const url = JSON.stringify(opts.url);
|
|
16
|
+
const extraHeaders = JSON.stringify(opts.headers ?? {});
|
|
17
|
+
const hasBody = opts.body !== undefined;
|
|
18
|
+
const bodyJson = hasBody ? JSON.stringify(JSON.stringify(opts.body)) : "null";
|
|
19
|
+
const wantsAuth = (opts.auth ?? "auto") === "auto";
|
|
20
|
+
// Token lookup covers the shapes seen in the corpus. `state` comes from the
|
|
21
|
+
// injected context, so this works without the caller knowing where the app
|
|
22
|
+
// keeps its credentials.
|
|
23
|
+
const authBlock = wantsAuth
|
|
24
|
+
? `
|
|
25
|
+
var token = null;
|
|
26
|
+
var authFrom = headers['Authorization'] ? 'explicit' : null;
|
|
27
|
+
try {
|
|
28
|
+
if (typeof state !== 'undefined' && state) {
|
|
29
|
+
token = (state.user && state.user.accessToken) ||
|
|
30
|
+
(state.auth && (state.auth.accessToken || state.auth.token)) || null;
|
|
31
|
+
if (token && !authFrom) authFrom = 'redux';
|
|
32
|
+
}
|
|
33
|
+
} catch (e) { token = null; }
|
|
34
|
+
// Fallback: reuse the Authorization header from the app's most recent real
|
|
35
|
+
// request. Source-agnostic, so it works for apps that keep the token
|
|
36
|
+
// outside redux — Apollo holds it in the link chain, which is not
|
|
37
|
+
// introspectable, and is exactly why those requests used to be hand-written
|
|
38
|
+
// with a pasted JWT. Requires the SDK's network capture.
|
|
39
|
+
if (!token && !headers['Authorization']) {
|
|
40
|
+
try {
|
|
41
|
+
var sdk = globalThis.__RN_AI_DEVTOOLS__;
|
|
42
|
+
var entries = sdk && sdk.getNetworkEntries ? sdk.getNetworkEntries() : null;
|
|
43
|
+
if (entries) {
|
|
44
|
+
for (var ei = entries.length - 1; ei >= 0 && !token; ei--) {
|
|
45
|
+
var rh = entries[ei] && entries[ei].requestHeaders;
|
|
46
|
+
if (!rh) continue;
|
|
47
|
+
var hk = Object.keys(rh);
|
|
48
|
+
for (var hi = 0; hi < hk.length; hi++) {
|
|
49
|
+
if (hk[hi].toLowerCase() === 'authorization' && rh[hk[hi]]) {
|
|
50
|
+
headers['Authorization'] = rh[hk[hi]];
|
|
51
|
+
authFrom = 'captured-request';
|
|
52
|
+
token = true;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (e) { /* leave unauthenticated */ }
|
|
59
|
+
}
|
|
60
|
+
// An explicit header wins: the caller knows where their token lives.
|
|
61
|
+
if (token && authFrom === 'redux' && !headers['Authorization']) {
|
|
62
|
+
headers['Authorization'] = 'Bearer ' + token;
|
|
63
|
+
}`
|
|
64
|
+
: "";
|
|
65
|
+
return `(function(){
|
|
66
|
+
var headers = {};
|
|
67
|
+
var extra = ${extraHeaders};
|
|
68
|
+
for (var k in extra) { if (Object.prototype.hasOwnProperty.call(extra, k)) headers[k] = extra[k]; }
|
|
69
|
+
var bodyText = ${bodyJson};
|
|
70
|
+
if (bodyText !== null && !headers['Content-Type']) headers['Content-Type'] = "application/json";${authBlock}
|
|
71
|
+
var init = { method: ${method}, headers: headers };
|
|
72
|
+
if (bodyText !== null) init.body = bodyText;
|
|
73
|
+
${wantsAuth
|
|
74
|
+
? `var authNote = !headers['Authorization']
|
|
75
|
+
? 'auth="auto" found no token: not in state.user.accessToken / state.auth.accessToken / state.auth.token, and no captured request carried an Authorization header (the SDK network capture may be absent, or the app has not made an authenticated request yet). This request was sent UNAUTHENTICATED - pass headers.Authorization explicitly.'
|
|
76
|
+
: null;
|
|
77
|
+
var authSource = headers['Authorization'] ? authFrom : null;`
|
|
78
|
+
: `var authNote = null;`}
|
|
79
|
+
return fetch(${url}, init).then(function (res) {
|
|
80
|
+
return res.text().then(function (text) {
|
|
81
|
+
var parsed = text;
|
|
82
|
+
try { parsed = JSON.parse(text); } catch (e) { parsed = text; }
|
|
83
|
+
var out = { status: res.status, ok: res.ok, authorized: !!headers['Authorization'], body: parsed };
|
|
84
|
+
if (typeof authSource !== 'undefined' && authSource) out.authSource = authSource;
|
|
85
|
+
if (authNote) out.authNote = authNote;
|
|
86
|
+
return out;
|
|
87
|
+
});
|
|
88
|
+
}, function (err) {
|
|
89
|
+
var out = { status: 0, ok: false, error: String(err && err.message ? err.message : err) };
|
|
90
|
+
if (authNote) out.authNote = authNote;
|
|
91
|
+
return out;
|
|
92
|
+
});
|
|
93
|
+
})()`;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=appRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appRequest.js","sourceRoot":"","sources":["../../src/core/appRequest.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAuB;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9E,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,MAAM,CAAC;IAEnD,4EAA4E;IAC5E,2EAA2E;IAC3E,yBAAyB;IACzB,MAAM,SAAS,GAAG,SAAS;QACvB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuCJ;QACE,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;;kBAEO,YAAY;;qBAET,QAAQ;sGACyE,SAAS;2BACpF,MAAM;;MAE3B,SAAS;QACP,CAAC,CAAC;;;iEAGuD;QACzD,CAAC,CAAC,sBAAsB;mBACb,GAAG;;;;;;;;;;;;;;KAcjB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Per-device console log buffer capacity. Override: EXECBRO_LOG_BUFFER_SIZE. */
|
|
2
|
+
export declare function logBufferSize(): number;
|
|
3
|
+
/** Per-device network request buffer capacity. Override: EXECBRO_NET_BUFFER_SIZE. */
|
|
4
|
+
export declare function networkBufferSize(): number;
|
|
5
|
+
//# sourceMappingURL=bufferConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bufferConfig.d.ts","sourceRoot":"","sources":["../../src/core/bufferConfig.ts"],"names":[],"mappings":"AAWA,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|