@air-jam/devtools 0.0.0-stage → 0.9.3
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/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/agent.d.ts +15 -0
- package/dist/agent.js +19 -0
- package/dist/agent.js.map +1 -0
- package/dist/chunk-5YAARMW5.js +36 -0
- package/dist/chunk-5YAARMW5.js.map +1 -0
- package/dist/chunk-6WQODT37.js +1019 -0
- package/dist/chunk-6WQODT37.js.map +1 -0
- package/dist/chunk-CKFT2ZJE.js +801 -0
- package/dist/chunk-CKFT2ZJE.js.map +1 -0
- package/dist/chunk-ER3Q2C4G.js +358 -0
- package/dist/chunk-ER3Q2C4G.js.map +1 -0
- package/dist/chunk-GUEZP773.js +851 -0
- package/dist/chunk-GUEZP773.js.map +1 -0
- package/dist/chunk-HIDNI56E.js +33 -0
- package/dist/chunk-HIDNI56E.js.map +1 -0
- package/dist/chunk-QKXS5D35.js +43 -0
- package/dist/chunk-QKXS5D35.js.map +1 -0
- package/dist/chunk-S4LSCEVE.js +261 -0
- package/dist/chunk-S4LSCEVE.js.map +1 -0
- package/dist/chunk-VKMJO6VN.js +360 -0
- package/dist/chunk-VKMJO6VN.js.map +1 -0
- package/dist/chunk-WFUR3MXY.js +67 -0
- package/dist/chunk-WFUR3MXY.js.map +1 -0
- package/dist/chunk-XEMR7KUE.js +361 -0
- package/dist/chunk-XEMR7KUE.js.map +1 -0
- package/dist/chunk-ZLPD7FY5.js +191 -0
- package/dist/chunk-ZLPD7FY5.js.map +1 -0
- package/dist/context.d.ts +13 -0
- package/dist/context.js +9 -0
- package/dist/context.js.map +1 -0
- package/dist/controller.d.ts +41 -0
- package/dist/controller.js +30 -0
- package/dist/controller.js.map +1 -0
- package/dist/dev.d.ts +15 -0
- package/dist/dev.js +20 -0
- package/dist/dev.js.map +1 -0
- package/dist/game-session-broker.d.ts +57 -0
- package/dist/game-session-broker.js +235 -0
- package/dist/game-session-broker.js.map +1 -0
- package/dist/game-session.d.ts +13 -0
- package/dist/game-session.js +24 -0
- package/dist/game-session.js.map +1 -0
- package/dist/games.d.ts +21 -0
- package/dist/games.js +14 -0
- package/dist/games.js.map +1 -0
- package/dist/harness/visual.d.ts +321 -0
- package/dist/harness/visual.js +41 -0
- package/dist/harness/visual.js.map +1 -0
- package/dist/logs.d.ts +9 -0
- package/dist/logs.js +58 -0
- package/dist/logs.js.map +1 -0
- package/dist/mcp-config.d.ts +63 -0
- package/dist/mcp-config.js +190 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/platform-auth.d.ts +112 -0
- package/dist/platform-auth.js +37 -0
- package/dist/platform-auth.js.map +1 -0
- package/dist/platform-game-media.d.ts +309 -0
- package/dist/platform-game-media.js +168 -0
- package/dist/platform-game-media.js.map +1 -0
- package/dist/platform-games.d.ts +65 -0
- package/dist/platform-games.js +251 -0
- package/dist/platform-games.js.map +1 -0
- package/dist/quality.d.ts +10 -0
- package/dist/quality.js +63 -0
- package/dist/quality.js.map +1 -0
- package/dist/release.d.ts +1094 -0
- package/dist/release.js +1347 -0
- package/dist/release.js.map +1 -0
- package/dist/tooling/agent-contract.d.ts +2 -0
- package/dist/tooling/agent-contract.js +193 -0
- package/dist/tooling/agent-contract.js.map +1 -0
- package/dist/tooling/hold-runtime-host.d.ts +2 -0
- package/dist/tooling/hold-runtime-host.js +229 -0
- package/dist/tooling/hold-runtime-host.js.map +1 -0
- package/dist/tooling/inspect-airjam-agent.d.ts +2 -0
- package/dist/tooling/inspect-airjam-agent.js +37 -0
- package/dist/tooling/inspect-airjam-agent.js.map +1 -0
- package/dist/tooling/list-visual-scenarios.d.ts +2 -0
- package/dist/tooling/list-visual-scenarios.js +62 -0
- package/dist/tooling/list-visual-scenarios.js.map +1 -0
- package/dist/tooling/managed-dev-supervisor.d.ts +2 -0
- package/dist/tooling/managed-dev-supervisor.js +51 -0
- package/dist/tooling/managed-dev-supervisor.js.map +1 -0
- package/dist/tooling/run-visual-capture.d.ts +2 -0
- package/dist/tooling/run-visual-capture.js +167 -0
- package/dist/tooling/run-visual-capture.js.map +1 -0
- package/dist/types-C6NrHt88.d.ts +775 -0
- package/dist/visual.d.ts +15 -0
- package/dist/visual.js +263 -0
- package/dist/visual.js.map +1 -0
- package/package.json +113 -3
- package/src/agent.ts +380 -0
- package/src/commands.ts +40 -0
- package/src/context.ts +229 -0
- package/src/controller.ts +1376 -0
- package/src/dev.ts +999 -0
- package/src/fs-utils.ts +93 -0
- package/src/game-action-observation.ts +96 -0
- package/src/game-session-broker.ts +301 -0
- package/src/game-session.ts +459 -0
- package/src/games.ts +266 -0
- package/src/harness/visual/prefab-contract.ts +29 -0
- package/src/harness/visual/prefab-runner.ts +178 -0
- package/src/harness/visual/runner.ts +546 -0
- package/src/harness/visual/scenario-contract.ts +9 -0
- package/src/harness/visual/scenario-helpers.ts +63 -0
- package/src/harness/visual/session.ts +369 -0
- package/src/harness/visual/types.ts +181 -0
- package/src/harness/visual.ts +7 -0
- package/src/helper-scripts.ts +49 -0
- package/src/logs.ts +67 -0
- package/src/mcp-config.ts +262 -0
- package/src/platform-auth.ts +455 -0
- package/src/platform-game-media.ts +209 -0
- package/src/platform-games.ts +315 -0
- package/src/quality.ts +82 -0
- package/src/release.ts +1697 -0
- package/src/runtime-owner-protocol.ts +130 -0
- package/src/tooling/agent-contract.ts +232 -0
- package/src/tooling/agent-declaration.ts +36 -0
- package/src/tooling/airjam-agent-inspection.ts +45 -0
- package/src/tooling/airjam-agent.ts +118 -0
- package/src/tooling/hold-runtime-host.ts +224 -0
- package/src/tooling/inspect-airjam-agent.ts +20 -0
- package/src/tooling/list-visual-scenarios.ts +64 -0
- package/src/tooling/managed-dev-supervisor.ts +71 -0
- package/src/tooling/run-visual-capture.ts +217 -0
- package/src/tooling/runtime-owner-actions.ts +42 -0
- package/src/tooling/visual-pack.ts +46 -0
- package/src/types.ts +951 -0
- package/src/visual.ts +304 -0
- package/src/workspace-contract.ts +32 -0
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
// src/harness/visual/prefab-contract.ts
|
|
2
|
+
var definePrefabCaptureHarness = (harness) => harness;
|
|
3
|
+
|
|
4
|
+
// src/harness/visual/prefab-runner.ts
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { pathToFileURL } from "url";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
// src/harness/visual/session.ts
|
|
11
|
+
import {
|
|
12
|
+
AIR_JAM_RUNTIME_INSPECTION_KEY,
|
|
13
|
+
readRuntimeInspectionContract
|
|
14
|
+
} from "@air-jam/sdk/runtime-inspection";
|
|
15
|
+
import {
|
|
16
|
+
chromium
|
|
17
|
+
} from "playwright-core";
|
|
18
|
+
var DEFAULT_HOST_VIEWPORT = {
|
|
19
|
+
width: 1440,
|
|
20
|
+
height: 1024
|
|
21
|
+
};
|
|
22
|
+
var DEFAULT_CONTROLLER_VIEWPORT = {
|
|
23
|
+
width: 390,
|
|
24
|
+
height: 844
|
|
25
|
+
};
|
|
26
|
+
var isEmbeddedMode = (mode) => mode !== "standalone-dev";
|
|
27
|
+
var dismissHarnessControllerFullscreenPrompt = async (page) => {
|
|
28
|
+
const openPrompt = page.locator(
|
|
29
|
+
'[data-testid="controller-fullscreen-prompt"][data-state="open"]'
|
|
30
|
+
);
|
|
31
|
+
await openPrompt.waitFor({ state: "visible", timeout: 5e3 }).catch(() => null);
|
|
32
|
+
if (!await openPrompt.isVisible().catch(() => false)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
await page.getByTestId("controller-fullscreen-prompt-dismiss").click({ force: true });
|
|
36
|
+
await openPrompt.waitFor({ state: "hidden", timeout: 1e4 });
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
var waitForFrameToLoad = async ({
|
|
40
|
+
page,
|
|
41
|
+
testId,
|
|
42
|
+
timeoutMs = 3e4
|
|
43
|
+
}) => {
|
|
44
|
+
const iframe = page.getByTestId(testId);
|
|
45
|
+
await iframe.waitFor({ state: "visible", timeout: timeoutMs });
|
|
46
|
+
const iframeHandle = await iframe.elementHandle({ timeout: timeoutMs });
|
|
47
|
+
if (!iframeHandle) {
|
|
48
|
+
throw new Error(`Could not resolve iframe handle for "${testId}".`);
|
|
49
|
+
}
|
|
50
|
+
const startedAt = Date.now();
|
|
51
|
+
let resolvedFrame = null;
|
|
52
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
53
|
+
const nextFrame = await iframeHandle.contentFrame();
|
|
54
|
+
const frameUrl = nextFrame?.url() ?? "";
|
|
55
|
+
if (nextFrame && frameUrl.length > 0 && frameUrl !== "about:blank") {
|
|
56
|
+
resolvedFrame = nextFrame;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
await page.waitForTimeout(100);
|
|
60
|
+
}
|
|
61
|
+
if (!resolvedFrame) {
|
|
62
|
+
throw new Error(`Timed out waiting for iframe "${testId}" to resolve.`);
|
|
63
|
+
}
|
|
64
|
+
await resolvedFrame.waitForLoadState("domcontentloaded", {
|
|
65
|
+
timeout: Math.max(1, timeoutMs - (Date.now() - startedAt))
|
|
66
|
+
});
|
|
67
|
+
return page.frameLocator(`iframe[data-testid="${testId}"]`);
|
|
68
|
+
};
|
|
69
|
+
var readRuntimeHref = async ({
|
|
70
|
+
page,
|
|
71
|
+
game,
|
|
72
|
+
embedded
|
|
73
|
+
}) => embedded ? game.locator("body").evaluate(() => window.location.href) : page.evaluate(() => window.location.href);
|
|
74
|
+
var readHostRuntimeInspection = async ({
|
|
75
|
+
page,
|
|
76
|
+
game,
|
|
77
|
+
embedded
|
|
78
|
+
}) => {
|
|
79
|
+
const rawInspection = embedded ? await game.locator("body").evaluate(
|
|
80
|
+
(_, key) => window[key] ?? null,
|
|
81
|
+
AIR_JAM_RUNTIME_INSPECTION_KEY
|
|
82
|
+
) : await page.evaluate(
|
|
83
|
+
(key) => window[key] ?? null,
|
|
84
|
+
AIR_JAM_RUNTIME_INSPECTION_KEY
|
|
85
|
+
);
|
|
86
|
+
const inspection = readRuntimeInspectionContract({
|
|
87
|
+
[AIR_JAM_RUNTIME_INSPECTION_KEY]: rawInspection
|
|
88
|
+
});
|
|
89
|
+
return inspection?.role === "host" ? inspection : null;
|
|
90
|
+
};
|
|
91
|
+
var resolveControllerJoinUrl = async ({
|
|
92
|
+
hostPage,
|
|
93
|
+
hostGame,
|
|
94
|
+
hostEmbedded,
|
|
95
|
+
controllerBaseUrl
|
|
96
|
+
}) => {
|
|
97
|
+
let resolvedJoinUrl = null;
|
|
98
|
+
for (let attempt = 0; attempt < 80; attempt += 1) {
|
|
99
|
+
const inspection = await readHostRuntimeInspection({
|
|
100
|
+
page: hostPage,
|
|
101
|
+
game: hostGame,
|
|
102
|
+
embedded: hostEmbedded
|
|
103
|
+
});
|
|
104
|
+
if (inspection?.joinUrlStatus === "ready" && inspection.joinUrl) {
|
|
105
|
+
resolvedJoinUrl = inspection.joinUrl;
|
|
106
|
+
}
|
|
107
|
+
if (!resolvedJoinUrl) {
|
|
108
|
+
const runtimeUrl = new URL(
|
|
109
|
+
await readRuntimeHref({
|
|
110
|
+
page: hostPage,
|
|
111
|
+
game: hostGame,
|
|
112
|
+
embedded: hostEmbedded
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
resolvedJoinUrl = runtimeUrl.searchParams.get("aj_join_url");
|
|
116
|
+
}
|
|
117
|
+
if (resolvedJoinUrl) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
await hostPage.waitForTimeout(250);
|
|
121
|
+
}
|
|
122
|
+
if (!resolvedJoinUrl) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
"Could not resolve a controller join URL from the host runtime inspection contract or runtime URL."
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const joinUrl = new URL(resolvedJoinUrl);
|
|
128
|
+
const controllerUrl = new URL(controllerBaseUrl);
|
|
129
|
+
joinUrl.protocol = controllerUrl.protocol;
|
|
130
|
+
joinUrl.host = controllerUrl.host;
|
|
131
|
+
return joinUrl.toString();
|
|
132
|
+
};
|
|
133
|
+
var openVisualHarnessHostSession = async ({
|
|
134
|
+
browser,
|
|
135
|
+
urls,
|
|
136
|
+
mode
|
|
137
|
+
}) => {
|
|
138
|
+
const embedded = isEmbeddedMode(mode);
|
|
139
|
+
const hostContext = await browser.newContext({
|
|
140
|
+
viewport: DEFAULT_HOST_VIEWPORT
|
|
141
|
+
});
|
|
142
|
+
try {
|
|
143
|
+
const hostPage = await hostContext.newPage();
|
|
144
|
+
await hostPage.goto(urls.hostUrl, { waitUntil: "domcontentloaded" });
|
|
145
|
+
const hostGame = embedded ? await waitForFrameToLoad({
|
|
146
|
+
page: hostPage,
|
|
147
|
+
testId: "arcade-host-game-frame"
|
|
148
|
+
}) : hostPage;
|
|
149
|
+
return {
|
|
150
|
+
urls: { ...urls, controllerJoinUrl: null },
|
|
151
|
+
host: {
|
|
152
|
+
page: hostPage,
|
|
153
|
+
game: hostGame,
|
|
154
|
+
embedded
|
|
155
|
+
},
|
|
156
|
+
close: () => hostContext.close()
|
|
157
|
+
};
|
|
158
|
+
} catch (error) {
|
|
159
|
+
await hostContext.close().catch(() => null);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var openVisualHarnessControllerSession = async ({
|
|
164
|
+
browser,
|
|
165
|
+
urls,
|
|
166
|
+
host
|
|
167
|
+
}) => {
|
|
168
|
+
const controllerContext = await browser.newContext({
|
|
169
|
+
viewport: DEFAULT_CONTROLLER_VIEWPORT
|
|
170
|
+
});
|
|
171
|
+
try {
|
|
172
|
+
const controllerJoinUrl = await resolveControllerJoinUrl({
|
|
173
|
+
hostPage: host.page,
|
|
174
|
+
hostGame: host.game,
|
|
175
|
+
hostEmbedded: host.embedded,
|
|
176
|
+
controllerBaseUrl: urls.controllerBaseUrl
|
|
177
|
+
});
|
|
178
|
+
const controllerPage = await controllerContext.newPage();
|
|
179
|
+
await controllerPage.goto(controllerJoinUrl, {
|
|
180
|
+
waitUntil: "domcontentloaded"
|
|
181
|
+
});
|
|
182
|
+
const fullscreenPromptDismissed = await dismissHarnessControllerFullscreenPrompt(controllerPage);
|
|
183
|
+
const controllerGame = host.embedded ? await waitForFrameToLoad({
|
|
184
|
+
page: controllerPage,
|
|
185
|
+
testId: "arcade-controller-game-frame"
|
|
186
|
+
}) : controllerPage;
|
|
187
|
+
return {
|
|
188
|
+
urls: { ...urls, controllerJoinUrl },
|
|
189
|
+
controller: {
|
|
190
|
+
page: controllerPage,
|
|
191
|
+
game: controllerGame,
|
|
192
|
+
embedded: host.embedded,
|
|
193
|
+
fullscreenPromptDismissed
|
|
194
|
+
},
|
|
195
|
+
close: () => controllerContext.close()
|
|
196
|
+
};
|
|
197
|
+
} catch (error) {
|
|
198
|
+
await controllerContext.close().catch(() => null);
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
var openVisualHarnessSession = async ({
|
|
203
|
+
browser,
|
|
204
|
+
urls,
|
|
205
|
+
mode
|
|
206
|
+
}) => {
|
|
207
|
+
const hostSession = await openVisualHarnessHostSession({
|
|
208
|
+
browser,
|
|
209
|
+
urls,
|
|
210
|
+
mode
|
|
211
|
+
});
|
|
212
|
+
try {
|
|
213
|
+
const controllerSession = await openVisualHarnessControllerSession({
|
|
214
|
+
browser,
|
|
215
|
+
urls,
|
|
216
|
+
host: hostSession.host
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
urls: controllerSession.urls,
|
|
220
|
+
host: hostSession.host,
|
|
221
|
+
controller: controllerSession.controller,
|
|
222
|
+
close: async () => {
|
|
223
|
+
await Promise.allSettled([
|
|
224
|
+
hostSession.close(),
|
|
225
|
+
controllerSession.close()
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
} catch (error) {
|
|
230
|
+
await hostSession.close().catch(() => null);
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var launchHarnessBrowser = async () => {
|
|
235
|
+
const options = {
|
|
236
|
+
headless: true,
|
|
237
|
+
args: [
|
|
238
|
+
"--enable-webgl",
|
|
239
|
+
"--ignore-gpu-blocklist",
|
|
240
|
+
"--use-angle=swiftshader"
|
|
241
|
+
]
|
|
242
|
+
};
|
|
243
|
+
if (process.env.AIRJAM_BROWSER_EXECUTABLE_PATH) {
|
|
244
|
+
return chromium.launch({
|
|
245
|
+
...options,
|
|
246
|
+
executablePath: process.env.AIRJAM_BROWSER_EXECUTABLE_PATH
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
return await chromium.launch(options);
|
|
251
|
+
} catch (bundledBrowserError) {
|
|
252
|
+
try {
|
|
253
|
+
return await chromium.launch({ ...options, channel: "chrome" });
|
|
254
|
+
} catch (systemBrowserError) {
|
|
255
|
+
throw new Error(
|
|
256
|
+
[
|
|
257
|
+
"Air Jam could not launch a browser runtime for semantic sessions.",
|
|
258
|
+
"Install Playwright Chromium or set AIRJAM_BROWSER_EXECUTABLE_PATH to a Chromium-compatible browser.",
|
|
259
|
+
`Bundled browser: ${bundledBrowserError instanceof Error ? bundledBrowserError.message : String(bundledBrowserError)}`,
|
|
260
|
+
`System Chrome: ${systemBrowserError instanceof Error ? systemBrowserError.message : String(systemBrowserError)}`
|
|
261
|
+
].join("\n\n")
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/harness/visual/prefab-runner.ts
|
|
268
|
+
var prefabHarnessSchema = z.object({
|
|
269
|
+
gameId: z.string(),
|
|
270
|
+
prefabs: z.array(
|
|
271
|
+
z.object({
|
|
272
|
+
id: z.string(),
|
|
273
|
+
prefabId: z.string(),
|
|
274
|
+
description: z.string().optional(),
|
|
275
|
+
viewport: z.object({
|
|
276
|
+
width: z.number().int().positive(),
|
|
277
|
+
height: z.number().int().positive()
|
|
278
|
+
}).optional(),
|
|
279
|
+
waitForTestId: z.string().optional(),
|
|
280
|
+
buildHostUrl: z.custom(
|
|
281
|
+
(value) => typeof value === "function"
|
|
282
|
+
)
|
|
283
|
+
})
|
|
284
|
+
)
|
|
285
|
+
});
|
|
286
|
+
var artifactSegment = (value) => {
|
|
287
|
+
const segment = value.replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
288
|
+
if (!segment || segment === "." || segment === "..") {
|
|
289
|
+
throw new Error(`Invalid prefab artifact segment "${value}".`);
|
|
290
|
+
}
|
|
291
|
+
return segment;
|
|
292
|
+
};
|
|
293
|
+
var loadPrefabCapture = async ({
|
|
294
|
+
gameId,
|
|
295
|
+
gameDirectory,
|
|
296
|
+
prefabId,
|
|
297
|
+
variantPairs = [],
|
|
298
|
+
mode = "standalone-dev",
|
|
299
|
+
secure = false
|
|
300
|
+
}) => {
|
|
301
|
+
if (mode !== "standalone-dev" && mode !== "arcade-built") {
|
|
302
|
+
throw new Error(`Unsupported visual prefab capture mode "${mode}".`);
|
|
303
|
+
}
|
|
304
|
+
if (!gameId || gameId === "." || gameId === "..") {
|
|
305
|
+
throw new Error(`Invalid prefab capture game id "${gameId}".`);
|
|
306
|
+
}
|
|
307
|
+
const modulePath = ["prefabs.ts", "prefabs.mjs"].map((fileName) => path.join(gameDirectory, "visual", fileName)).find((filePath) => fs.existsSync(filePath));
|
|
308
|
+
if (!modulePath) {
|
|
309
|
+
throw new Error(
|
|
310
|
+
`No prefab capture harness found in ${path.join(gameDirectory, "visual")}.`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
const loaded = await import(pathToFileURL(modulePath).href);
|
|
314
|
+
const parsed = prefabHarnessSchema.safeParse(loaded.prefabCaptureHarness);
|
|
315
|
+
if (!parsed.success || parsed.data.gameId !== gameId) {
|
|
316
|
+
throw new Error(
|
|
317
|
+
`Invalid prefab capture harness for "${gameId}" at ${modulePath}.`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
const harness = parsed.data;
|
|
321
|
+
const prefab = harness.prefabs.find(
|
|
322
|
+
(candidate) => candidate.id === prefabId || candidate.prefabId === prefabId
|
|
323
|
+
);
|
|
324
|
+
if (!prefab) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`No prefab capture matched "${prefabId}" for "${gameId}". Available prefab captures: ${harness.prefabs.map((entry) => `${entry.id} -> ${entry.prefabId}`).join(", ")}`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
const variants = Object.fromEntries(
|
|
330
|
+
variantPairs.map((pair) => {
|
|
331
|
+
const separator = pair.indexOf("=");
|
|
332
|
+
const key = pair.slice(0, separator).trim();
|
|
333
|
+
const value = pair.slice(separator + 1).trim();
|
|
334
|
+
if (separator <= 0 || !key || !value) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
`Invalid --variant value "${pair}". Expected key=value.`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
return [key, value];
|
|
340
|
+
})
|
|
341
|
+
);
|
|
342
|
+
const suffix = Object.entries(variants).sort(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${artifactSegment(key)}-${artifactSegment(value)}`).join("__");
|
|
343
|
+
const artifactId = [artifactSegment(prefab.id), suffix].filter(Boolean).join("__");
|
|
344
|
+
return { gameId, prefab, variants, artifactId, mode, secure };
|
|
345
|
+
};
|
|
346
|
+
var capturePrefabAtRuntime = async ({
|
|
347
|
+
capture,
|
|
348
|
+
hostUrl,
|
|
349
|
+
artifactRoot
|
|
350
|
+
}) => {
|
|
351
|
+
const { gameId, prefab, variants, artifactId, mode, secure } = capture;
|
|
352
|
+
const artifactDirectory = path.join(
|
|
353
|
+
artifactRoot,
|
|
354
|
+
encodeURIComponent(gameId),
|
|
355
|
+
"prefabs",
|
|
356
|
+
artifactId
|
|
357
|
+
);
|
|
358
|
+
fs.rmSync(artifactDirectory, { force: true, recursive: true });
|
|
359
|
+
fs.mkdirSync(artifactDirectory, { recursive: true });
|
|
360
|
+
const targetUrl = prefab.buildHostUrl(hostUrl, {
|
|
361
|
+
prefabId: prefab.prefabId,
|
|
362
|
+
variants,
|
|
363
|
+
mode
|
|
364
|
+
});
|
|
365
|
+
const browser = await launchHarnessBrowser();
|
|
366
|
+
try {
|
|
367
|
+
const viewport = prefab.viewport ?? { width: 1024, height: 1024 };
|
|
368
|
+
const context = await browser.newContext({ viewport });
|
|
369
|
+
try {
|
|
370
|
+
const page = await context.newPage();
|
|
371
|
+
let pageError = null;
|
|
372
|
+
page.on("pageerror", (error) => {
|
|
373
|
+
pageError ??= error;
|
|
374
|
+
});
|
|
375
|
+
await page.goto(targetUrl, { waitUntil: "domcontentloaded" });
|
|
376
|
+
const game = mode === "arcade-built" ? page.frameLocator('iframe[data-testid="arcade-host-game-frame"]') : page;
|
|
377
|
+
if (prefab.waitForTestId) {
|
|
378
|
+
await game.getByTestId(prefab.waitForTestId).waitFor({
|
|
379
|
+
state: "visible",
|
|
380
|
+
timeout: 3e4
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
await page.waitForTimeout(900);
|
|
384
|
+
if (pageError) throw pageError;
|
|
385
|
+
const screenshotPath = path.join(artifactDirectory, "prefab.png");
|
|
386
|
+
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
387
|
+
const metadata = {
|
|
388
|
+
gameId,
|
|
389
|
+
captureId: prefab.id,
|
|
390
|
+
prefabId: prefab.prefabId,
|
|
391
|
+
runtimeMode: mode,
|
|
392
|
+
secure,
|
|
393
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
394
|
+
viewport,
|
|
395
|
+
variants,
|
|
396
|
+
url: targetUrl,
|
|
397
|
+
screenshot: {
|
|
398
|
+
fileName: "prefab.png",
|
|
399
|
+
relativePath: path.relative(artifactRoot, screenshotPath)
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const metadataPath = path.join(artifactDirectory, "metadata.json");
|
|
403
|
+
fs.writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}
|
|
404
|
+
`);
|
|
405
|
+
return { artifactDirectory, metadataPath, metadata };
|
|
406
|
+
} finally {
|
|
407
|
+
await context.close();
|
|
408
|
+
}
|
|
409
|
+
} finally {
|
|
410
|
+
await browser.close();
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// src/harness/visual/runner.ts
|
|
415
|
+
import fs2 from "fs";
|
|
416
|
+
import path2 from "path";
|
|
417
|
+
var ensureDir = (dir) => {
|
|
418
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
419
|
+
};
|
|
420
|
+
var writeJson = (filePath, value) => {
|
|
421
|
+
ensureDir(path2.dirname(filePath));
|
|
422
|
+
fs2.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
|
|
423
|
+
`, "utf8");
|
|
424
|
+
};
|
|
425
|
+
var resetDir = (dir) => {
|
|
426
|
+
fs2.rmSync(dir, { force: true, recursive: true });
|
|
427
|
+
ensureDir(dir);
|
|
428
|
+
};
|
|
429
|
+
var appendFailureScreenshot = async ({
|
|
430
|
+
page,
|
|
431
|
+
surface,
|
|
432
|
+
scenarioDir,
|
|
433
|
+
screenshotRecords
|
|
434
|
+
}) => {
|
|
435
|
+
const viewport = page.viewportSize() ?? DEFAULT_HOST_VIEWPORT;
|
|
436
|
+
const fileName = `${surface}-failure.png`;
|
|
437
|
+
const filePath = path2.join(scenarioDir, fileName);
|
|
438
|
+
await page.screenshot({
|
|
439
|
+
path: filePath,
|
|
440
|
+
fullPage: true
|
|
441
|
+
});
|
|
442
|
+
screenshotRecords.push({
|
|
443
|
+
surface,
|
|
444
|
+
viewportName: "failure",
|
|
445
|
+
width: viewport.width,
|
|
446
|
+
height: viewport.height,
|
|
447
|
+
fileName,
|
|
448
|
+
filePath
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
var captureFailureScreenshots = async (runContext) => {
|
|
452
|
+
if (!runContext) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
await Promise.allSettled([
|
|
456
|
+
appendFailureScreenshot({
|
|
457
|
+
page: runContext.host.page,
|
|
458
|
+
surface: "host",
|
|
459
|
+
scenarioDir: runContext.scenarioDir,
|
|
460
|
+
screenshotRecords: runContext.screenshotRecords
|
|
461
|
+
}),
|
|
462
|
+
appendFailureScreenshot({
|
|
463
|
+
page: runContext.controller.page,
|
|
464
|
+
surface: "controller",
|
|
465
|
+
scenarioDir: runContext.scenarioDir,
|
|
466
|
+
screenshotRecords: runContext.screenshotRecords
|
|
467
|
+
})
|
|
468
|
+
]);
|
|
469
|
+
};
|
|
470
|
+
var createUnavailableAgentClient = () => {
|
|
471
|
+
const unavailable = async () => {
|
|
472
|
+
throw new Error(
|
|
473
|
+
"This visual scenario run does not have an agent session attached. Start visual capture through Air Jam devtools so scenarios can invoke canonical agent actions."
|
|
474
|
+
);
|
|
475
|
+
};
|
|
476
|
+
return {
|
|
477
|
+
listActions: async () => [],
|
|
478
|
+
read: unavailable,
|
|
479
|
+
waitFor: unavailable,
|
|
480
|
+
invoke: unavailable,
|
|
481
|
+
close: async () => {
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
var createLazyAgentClient = ({
|
|
486
|
+
createAgentSession
|
|
487
|
+
}) => {
|
|
488
|
+
let sessionPromise = null;
|
|
489
|
+
const getSession = async () => {
|
|
490
|
+
if (!createAgentSession) {
|
|
491
|
+
return createUnavailableAgentClient();
|
|
492
|
+
}
|
|
493
|
+
if (!sessionPromise) {
|
|
494
|
+
sessionPromise = createAgentSession();
|
|
495
|
+
}
|
|
496
|
+
return sessionPromise;
|
|
497
|
+
};
|
|
498
|
+
return {
|
|
499
|
+
listActions: async () => (await getSession()).listActions(),
|
|
500
|
+
read: async () => (await getSession()).read(),
|
|
501
|
+
waitFor: async (predicate, description, timeout) => (await getSession()).waitFor(predicate, description, timeout),
|
|
502
|
+
invoke: async (actionId, payload, options) => (await getSession()).invoke(actionId, payload, options),
|
|
503
|
+
close: async () => {
|
|
504
|
+
if (!sessionPromise) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const session = await sessionPromise.catch(() => null);
|
|
508
|
+
await session?.close().catch(() => null);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
};
|
|
512
|
+
var createScenarioRunContext = async ({
|
|
513
|
+
browser,
|
|
514
|
+
gameId,
|
|
515
|
+
scenario,
|
|
516
|
+
scenarioDir,
|
|
517
|
+
urls,
|
|
518
|
+
mode,
|
|
519
|
+
secure,
|
|
520
|
+
createAgentSession
|
|
521
|
+
}) => {
|
|
522
|
+
const session = await openVisualHarnessSession({
|
|
523
|
+
browser,
|
|
524
|
+
urls,
|
|
525
|
+
mode
|
|
526
|
+
});
|
|
527
|
+
const hostPage = session.host.page;
|
|
528
|
+
const controllerPage = session.controller.page;
|
|
529
|
+
const screenshotRecords = [];
|
|
530
|
+
const notes = [];
|
|
531
|
+
notes.push(`Resolved controller join URL: ${session.urls.controllerJoinUrl}`);
|
|
532
|
+
if (session.controller.fullscreenPromptDismissed) {
|
|
533
|
+
notes.push("Dismissed controller fullscreen prompt before capture.");
|
|
534
|
+
}
|
|
535
|
+
const captureSurface = async ({
|
|
536
|
+
surface,
|
|
537
|
+
viewportName,
|
|
538
|
+
width,
|
|
539
|
+
height,
|
|
540
|
+
fullPage = true
|
|
541
|
+
}) => {
|
|
542
|
+
const targetPage = surface === "host" ? hostPage : controllerPage;
|
|
543
|
+
await targetPage.setViewportSize({ width, height });
|
|
544
|
+
await targetPage.waitForTimeout(300);
|
|
545
|
+
const fileName = `${surface}-${viewportName}.png`;
|
|
546
|
+
const filePath = path2.join(scenarioDir, fileName);
|
|
547
|
+
await targetPage.screenshot({
|
|
548
|
+
path: filePath,
|
|
549
|
+
fullPage
|
|
550
|
+
});
|
|
551
|
+
screenshotRecords.push({
|
|
552
|
+
surface,
|
|
553
|
+
viewportName,
|
|
554
|
+
width,
|
|
555
|
+
height,
|
|
556
|
+
fileName,
|
|
557
|
+
filePath
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
const agent = createLazyAgentClient({
|
|
561
|
+
createAgentSession: createAgentSession ? () => createAgentSession({
|
|
562
|
+
gameId,
|
|
563
|
+
scenarioId: scenario.id,
|
|
564
|
+
urls: session.urls,
|
|
565
|
+
mode,
|
|
566
|
+
secure
|
|
567
|
+
}) : void 0
|
|
568
|
+
});
|
|
569
|
+
return {
|
|
570
|
+
gameId,
|
|
571
|
+
scenario,
|
|
572
|
+
scenarioDir,
|
|
573
|
+
urls: session.urls,
|
|
574
|
+
host: session.host,
|
|
575
|
+
controller: session.controller,
|
|
576
|
+
note: (value) => {
|
|
577
|
+
notes.push(value);
|
|
578
|
+
},
|
|
579
|
+
sleep: (ms) => hostPage.waitForTimeout(ms),
|
|
580
|
+
ensureControllerInteractive: async () => {
|
|
581
|
+
await dismissHarnessControllerFullscreenPrompt(controllerPage);
|
|
582
|
+
},
|
|
583
|
+
agent,
|
|
584
|
+
captureHost: async (viewportName, viewport) => captureSurface({ surface: "host", viewportName, ...viewport }),
|
|
585
|
+
captureController: async (viewportName, viewport) => captureSurface({ surface: "controller", viewportName, ...viewport }),
|
|
586
|
+
screenshotRecords,
|
|
587
|
+
notes,
|
|
588
|
+
close: async () => {
|
|
589
|
+
await Promise.allSettled([agent.close(), session.close()]);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
};
|
|
593
|
+
var buildScenarioMetadata = ({
|
|
594
|
+
artifactRoot,
|
|
595
|
+
gameId,
|
|
596
|
+
scenario,
|
|
597
|
+
mode,
|
|
598
|
+
urls,
|
|
599
|
+
screenshotRecords,
|
|
600
|
+
notes,
|
|
601
|
+
status,
|
|
602
|
+
error
|
|
603
|
+
}) => ({
|
|
604
|
+
gameId,
|
|
605
|
+
scenarioId: scenario.id,
|
|
606
|
+
scenarioDescription: scenario.description ?? null,
|
|
607
|
+
runtimeMode: mode,
|
|
608
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
609
|
+
status,
|
|
610
|
+
urls,
|
|
611
|
+
screenshots: screenshotRecords.map((record) => ({
|
|
612
|
+
surface: record.surface,
|
|
613
|
+
viewportName: record.viewportName,
|
|
614
|
+
width: record.width,
|
|
615
|
+
height: record.height,
|
|
616
|
+
fileName: record.fileName,
|
|
617
|
+
relativePath: path2.relative(artifactRoot, record.filePath)
|
|
618
|
+
})),
|
|
619
|
+
notes,
|
|
620
|
+
error: error instanceof Error ? {
|
|
621
|
+
message: error.message,
|
|
622
|
+
stack: error.stack ?? null
|
|
623
|
+
} : null
|
|
624
|
+
});
|
|
625
|
+
var runScenarioCapture = async ({
|
|
626
|
+
artifactRoot,
|
|
627
|
+
browser,
|
|
628
|
+
gameId,
|
|
629
|
+
scenario,
|
|
630
|
+
urls,
|
|
631
|
+
mode,
|
|
632
|
+
secure,
|
|
633
|
+
createAgentSession
|
|
634
|
+
}) => {
|
|
635
|
+
const scenarioDir = path2.join(artifactRoot, gameId, scenario.id);
|
|
636
|
+
resetDir(scenarioDir);
|
|
637
|
+
let runContext = null;
|
|
638
|
+
let metadata = null;
|
|
639
|
+
let scenarioError = null;
|
|
640
|
+
try {
|
|
641
|
+
runContext = await createScenarioRunContext({
|
|
642
|
+
browser,
|
|
643
|
+
gameId,
|
|
644
|
+
scenario,
|
|
645
|
+
scenarioDir,
|
|
646
|
+
urls,
|
|
647
|
+
mode,
|
|
648
|
+
secure,
|
|
649
|
+
createAgentSession
|
|
650
|
+
});
|
|
651
|
+
await scenario.run(runContext);
|
|
652
|
+
metadata = buildScenarioMetadata({
|
|
653
|
+
artifactRoot,
|
|
654
|
+
gameId,
|
|
655
|
+
scenario,
|
|
656
|
+
mode,
|
|
657
|
+
urls: runContext.urls,
|
|
658
|
+
screenshotRecords: runContext.screenshotRecords,
|
|
659
|
+
notes: runContext.notes,
|
|
660
|
+
status: "captured",
|
|
661
|
+
error: null
|
|
662
|
+
});
|
|
663
|
+
} catch (error) {
|
|
664
|
+
scenarioError = error;
|
|
665
|
+
await captureFailureScreenshots(runContext);
|
|
666
|
+
runContext?.note(
|
|
667
|
+
"Scenario failed; best-effort failure screenshots were captured for the current host and controller state."
|
|
668
|
+
);
|
|
669
|
+
metadata = buildScenarioMetadata({
|
|
670
|
+
artifactRoot,
|
|
671
|
+
gameId,
|
|
672
|
+
scenario,
|
|
673
|
+
mode,
|
|
674
|
+
urls: runContext?.urls ?? urls,
|
|
675
|
+
screenshotRecords: runContext?.screenshotRecords ?? [],
|
|
676
|
+
notes: runContext?.notes ?? [],
|
|
677
|
+
status: "failed",
|
|
678
|
+
error
|
|
679
|
+
});
|
|
680
|
+
throw Object.assign(
|
|
681
|
+
error instanceof Error ? error : new Error(String(error)),
|
|
682
|
+
{
|
|
683
|
+
visualMetadata: metadata
|
|
684
|
+
}
|
|
685
|
+
);
|
|
686
|
+
} finally {
|
|
687
|
+
if (!metadata) {
|
|
688
|
+
metadata = buildScenarioMetadata({
|
|
689
|
+
artifactRoot,
|
|
690
|
+
gameId,
|
|
691
|
+
scenario,
|
|
692
|
+
mode,
|
|
693
|
+
urls,
|
|
694
|
+
screenshotRecords: runContext?.screenshotRecords ?? [],
|
|
695
|
+
notes: runContext?.notes ?? [],
|
|
696
|
+
status: "failed",
|
|
697
|
+
error: scenarioError ?? new Error("Scenario setup failed before capture completed.")
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
writeJson(path2.join(scenarioDir, "metadata.json"), metadata);
|
|
701
|
+
if (runContext) {
|
|
702
|
+
await runContext.close();
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return metadata;
|
|
706
|
+
};
|
|
707
|
+
var listScenarioIds = (scenarioPack) => scenarioPack.scenarios.map((scenario) => scenario.id);
|
|
708
|
+
var runVisualHarness = async ({
|
|
709
|
+
gameId,
|
|
710
|
+
scenarioId = null,
|
|
711
|
+
mode = "standalone-dev",
|
|
712
|
+
secure = false,
|
|
713
|
+
artifactRoot,
|
|
714
|
+
loadScenarioPack,
|
|
715
|
+
startStack,
|
|
716
|
+
createAgentSession,
|
|
717
|
+
onScenarioStart,
|
|
718
|
+
onCaptureStart,
|
|
719
|
+
onComplete
|
|
720
|
+
}) => {
|
|
721
|
+
if (mode !== "arcade-built" && mode !== "standalone-dev") {
|
|
722
|
+
throw new Error(
|
|
723
|
+
`Unsupported visual capture mode "${mode}". Phase 1 currently supports "standalone-dev" and "arcade-built".`
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
const scenarioPack = await loadScenarioPack(gameId);
|
|
727
|
+
const scenarios = scenarioId ? scenarioPack.scenarios.filter((scenario) => scenario.id === scenarioId) : scenarioPack.scenarios;
|
|
728
|
+
if (scenarios.length === 0) {
|
|
729
|
+
throw new Error(
|
|
730
|
+
`No visual capture scenario matched "${scenarioId}" for "${gameId}". Available scenarios: ${listScenarioIds(scenarioPack).join(", ")}`
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
const gameArtifactRoot = path2.join(artifactRoot, gameId);
|
|
734
|
+
if (!scenarioId) {
|
|
735
|
+
resetDir(gameArtifactRoot);
|
|
736
|
+
} else {
|
|
737
|
+
ensureDir(gameArtifactRoot);
|
|
738
|
+
}
|
|
739
|
+
fs2.rmSync(path2.join(gameArtifactRoot, "capture-summary.json"), {
|
|
740
|
+
force: true
|
|
741
|
+
});
|
|
742
|
+
const stack = await startStack({
|
|
743
|
+
gameId,
|
|
744
|
+
mode,
|
|
745
|
+
secure
|
|
746
|
+
});
|
|
747
|
+
const browser = await launchHarnessBrowser();
|
|
748
|
+
const results = [];
|
|
749
|
+
try {
|
|
750
|
+
onCaptureStart?.({
|
|
751
|
+
gameId,
|
|
752
|
+
mode,
|
|
753
|
+
scenarioCount: scenarios.length
|
|
754
|
+
});
|
|
755
|
+
for (const scenario of scenarios) {
|
|
756
|
+
onScenarioStart?.(scenario);
|
|
757
|
+
const metadata = await runScenarioCapture({
|
|
758
|
+
artifactRoot,
|
|
759
|
+
browser,
|
|
760
|
+
gameId,
|
|
761
|
+
scenario,
|
|
762
|
+
urls: stack.urls,
|
|
763
|
+
mode,
|
|
764
|
+
secure,
|
|
765
|
+
createAgentSession
|
|
766
|
+
});
|
|
767
|
+
results.push(metadata);
|
|
768
|
+
}
|
|
769
|
+
} finally {
|
|
770
|
+
await browser.close().catch(() => null);
|
|
771
|
+
await stack.shutdown();
|
|
772
|
+
}
|
|
773
|
+
const summary = {
|
|
774
|
+
gameId,
|
|
775
|
+
mode,
|
|
776
|
+
secure,
|
|
777
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
778
|
+
scenarios: results.map((result) => ({
|
|
779
|
+
scenarioId: result.scenarioId,
|
|
780
|
+
status: result.status,
|
|
781
|
+
screenshotCount: result.screenshots.length,
|
|
782
|
+
relativeDir: path2.relative(
|
|
783
|
+
artifactRoot,
|
|
784
|
+
path2.join(artifactRoot, gameId, result.scenarioId)
|
|
785
|
+
)
|
|
786
|
+
}))
|
|
787
|
+
};
|
|
788
|
+
writeJson(path2.join(gameArtifactRoot, "capture-summary.json"), summary);
|
|
789
|
+
onComplete?.(summary);
|
|
790
|
+
return summary;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// src/harness/visual/scenario-contract.ts
|
|
794
|
+
var defineVisualScenarios = (pack) => pack;
|
|
795
|
+
|
|
796
|
+
// src/harness/visual/scenario-helpers.ts
|
|
797
|
+
var STANDARD_HOST_VIEWPORTS = [
|
|
798
|
+
["mac-desktop", { width: 3016, height: 1504 }],
|
|
799
|
+
["desktop", { width: 1440, height: 1024 }],
|
|
800
|
+
["tablet", { width: 1024, height: 1180 }]
|
|
801
|
+
];
|
|
802
|
+
var STANDARD_CONTROLLER_VIEWPORTS = [
|
|
803
|
+
["mobile", { width: 390, height: 844 }],
|
|
804
|
+
["small-mobile", { width: 360, height: 640 }]
|
|
805
|
+
];
|
|
806
|
+
var STANDARD_CONTROLLER_LANDSCAPE_VIEWPORTS = [
|
|
807
|
+
["mobile", { width: 844, height: 390 }],
|
|
808
|
+
["small-mobile", { width: 640, height: 360 }]
|
|
809
|
+
];
|
|
810
|
+
var captureStandardSurfaces = async (context, options) => {
|
|
811
|
+
for (const [viewportName, viewport] of STANDARD_HOST_VIEWPORTS) {
|
|
812
|
+
await context.captureHost(viewportName, viewport);
|
|
813
|
+
}
|
|
814
|
+
await context.ensureControllerInteractive();
|
|
815
|
+
const controllerOrientation = options?.controllerOrientation ?? "portrait";
|
|
816
|
+
const controllerViewports = controllerOrientation === "landscape" ? STANDARD_CONTROLLER_LANDSCAPE_VIEWPORTS : STANDARD_CONTROLLER_VIEWPORTS;
|
|
817
|
+
context.note(
|
|
818
|
+
`Captured controller surfaces in ${controllerOrientation} orientation.`
|
|
819
|
+
);
|
|
820
|
+
for (const [viewportName, viewport] of controllerViewports) {
|
|
821
|
+
await context.captureController(viewportName, viewport);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
var waitForHostText = async (context, text, timeout = 3e4) => {
|
|
825
|
+
await context.host.game.getByText(text).first().waitFor({ state: "visible", timeout });
|
|
826
|
+
};
|
|
827
|
+
var waitForControllerText = async (context, text, timeout = 3e4) => {
|
|
828
|
+
await context.controller.game.getByText(text).first().waitFor({ state: "visible", timeout });
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
export {
|
|
832
|
+
definePrefabCaptureHarness,
|
|
833
|
+
DEFAULT_HOST_VIEWPORT,
|
|
834
|
+
DEFAULT_CONTROLLER_VIEWPORT,
|
|
835
|
+
dismissHarnessControllerFullscreenPrompt,
|
|
836
|
+
openVisualHarnessHostSession,
|
|
837
|
+
openVisualHarnessControllerSession,
|
|
838
|
+
openVisualHarnessSession,
|
|
839
|
+
launchHarnessBrowser,
|
|
840
|
+
loadPrefabCapture,
|
|
841
|
+
capturePrefabAtRuntime,
|
|
842
|
+
runVisualHarness,
|
|
843
|
+
defineVisualScenarios,
|
|
844
|
+
STANDARD_HOST_VIEWPORTS,
|
|
845
|
+
STANDARD_CONTROLLER_VIEWPORTS,
|
|
846
|
+
STANDARD_CONTROLLER_LANDSCAPE_VIEWPORTS,
|
|
847
|
+
captureStandardSurfaces,
|
|
848
|
+
waitForHostText,
|
|
849
|
+
waitForControllerText
|
|
850
|
+
};
|
|
851
|
+
//# sourceMappingURL=chunk-GUEZP773.js.map
|