@threenative/playtest 0.1.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.
@@ -0,0 +1,390 @@
1
+ import { n as IPlaytestSetupRequest, r as JsonValue, b as IPlaytestBridgeDescription, m as IPlaytestSampleRequest, l as IPlaytestObservationSnapshot } from '../protocol-CeC1lz_G.js';
2
+ import { s as IPlaytestProtocolDiagnostic, z as IPlaytestScenario, u as IPlaytestReport, n as IPlaytestObservations, j as IPlaytestDiagnostic } from '../diagnostics-Ckm_5lrw.js';
3
+ import { Page } from 'playwright';
4
+
5
+ /** The only seam between assertion orchestration and an application bridge. */
6
+ interface BridgeTransport {
7
+ readonly capabilities: readonly string[];
8
+ call<T>(method: string, argument?: unknown): Promise<T>;
9
+ close(): Promise<void>;
10
+ waitForBridge(timeoutMs: number): Promise<boolean>;
11
+ }
12
+ declare class PlaytestBridgeError extends Error {
13
+ readonly diagnostic: IPlaytestProtocolDiagnostic;
14
+ constructor(diagnostic: IPlaytestProtocolDiagnostic);
15
+ }
16
+ interface IPlaytestBridgeClient {
17
+ advance(ticks: number): Promise<void>;
18
+ applySetup(request: IPlaytestSetupRequest): Promise<void>;
19
+ close(): Promise<void>;
20
+ drainEvents(limit?: number): Promise<JsonValue[]>;
21
+ description: IPlaytestBridgeDescription;
22
+ sample(request: IPlaytestSampleRequest): Promise<IPlaytestObservationSnapshot>;
23
+ }
24
+ declare class PlaywrightTransport implements BridgeTransport {
25
+ private readonly page;
26
+ readonly capabilities: readonly ["browser.canvas", "browser.console", "browser.dom", "browser.input", "browser.network", "browser.screenshot", "browser.trace", "runtime.ui"];
27
+ constructor(page: Page);
28
+ call<T>(method: string, argument?: unknown): Promise<T>;
29
+ close(): Promise<void>;
30
+ waitForBridge(timeoutMs: number): Promise<boolean>;
31
+ }
32
+ declare function connectPlaytestBridge(page: Page, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
33
+ declare function connectPlaytestBridgeTransport(transport: BridgeTransport, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
34
+
35
+ interface IAndroidDriverOptions {
36
+ activity: string;
37
+ adbPath?: string;
38
+ packageName: string;
39
+ serial?: string;
40
+ }
41
+ interface IAndroidDriver {
42
+ captureConsole(): Promise<Array<{
43
+ text: string;
44
+ type: string;
45
+ }>>;
46
+ isAlive(): Promise<boolean>;
47
+ prepare(endpoint: string, mailboxRoot?: string): Promise<void>;
48
+ readFile?(path: string): Promise<string | undefined>;
49
+ removeFile?(path: string): Promise<void>;
50
+ screenshot(path: string): Promise<void>;
51
+ stop(): Promise<void>;
52
+ writeFile?(path: string, contents: string): Promise<void>;
53
+ }
54
+ declare class AdbAndroidDriver implements IAndroidDriver {
55
+ private readonly options;
56
+ private readonly adbPath;
57
+ constructor(options: IAndroidDriverOptions);
58
+ prepare(endpoint: string, mailboxRoot?: string): Promise<void>;
59
+ captureConsole(): Promise<Array<{
60
+ text: string;
61
+ type: string;
62
+ }>>;
63
+ screenshot(path: string): Promise<void>;
64
+ isAlive(): Promise<boolean>;
65
+ readFile(path: string): Promise<string | undefined>;
66
+ removeFile(path: string): Promise<void>;
67
+ stop(): Promise<void>;
68
+ writeFile(path: string, contents: string): Promise<void>;
69
+ private adb;
70
+ private serialArgs;
71
+ }
72
+ declare function discoverAdb(environment?: NodeJS.ProcessEnv): string;
73
+
74
+ interface IPlaytestServerConfig {
75
+ command: string;
76
+ cwd?: string;
77
+ timeoutMs?: number;
78
+ }
79
+ interface IStandalonePlaytestConfig {
80
+ android?: {
81
+ activity: string;
82
+ packageName: string;
83
+ };
84
+ adbPath?: string;
85
+ artifactDirectory: string;
86
+ browserArgs?: readonly string[];
87
+ device?: string;
88
+ endpoint?: string;
89
+ headless: boolean;
90
+ ios?: {
91
+ appPath?: string;
92
+ bundleId: string;
93
+ transport: "device" | "simulator";
94
+ };
95
+ mailboxRoot?: string;
96
+ projectPath: string;
97
+ scenarioPath: string;
98
+ server?: IPlaytestServerConfig;
99
+ timeoutMs: number;
100
+ target?: "android" | "browser" | "ios";
101
+ trace: boolean;
102
+ url: string;
103
+ xcrunPath?: string;
104
+ }
105
+ interface IPlaytestFlagHelp {
106
+ default: string;
107
+ summary: string;
108
+ takesValue: boolean;
109
+ allowDashValue?: boolean;
110
+ repeatable?: boolean;
111
+ }
112
+ declare const PLAYTEST_FLAGS: {
113
+ readonly "--adb": {
114
+ readonly default: "auto-discover";
115
+ readonly summary: "absolute adb executable path";
116
+ readonly takesValue: true;
117
+ };
118
+ readonly "--activity": {
119
+ readonly default: ".MystralActivity";
120
+ readonly summary: "Android launch activity";
121
+ readonly takesValue: true;
122
+ };
123
+ readonly "--app": {
124
+ readonly default: "required for iOS";
125
+ readonly summary: "built iOS .app bundle";
126
+ readonly takesValue: true;
127
+ };
128
+ readonly "--artifacts": {
129
+ readonly default: "artifacts/playtest";
130
+ readonly summary: "artifact output directory";
131
+ readonly takesValue: true;
132
+ };
133
+ readonly "--browser-arg": {
134
+ readonly allowDashValue: true;
135
+ readonly default: "none (repeatable)";
136
+ readonly repeatable: true;
137
+ readonly summary: "one additional Chromium argument";
138
+ readonly takesValue: true;
139
+ };
140
+ readonly "--browser-recipe": {
141
+ readonly default: "none";
142
+ readonly summary: "named browser recipe (webgpu)";
143
+ readonly takesValue: true;
144
+ };
145
+ readonly "--bundle-id": {
146
+ readonly default: "dev.threenative.runtime";
147
+ readonly summary: "iOS application bundle identifier";
148
+ readonly takesValue: true;
149
+ };
150
+ readonly "--device": {
151
+ readonly default: "platform default";
152
+ readonly summary: "Android serial or iOS device identifier";
153
+ readonly takesValue: true;
154
+ };
155
+ readonly "--endpoint": {
156
+ readonly default: "http://127.0.0.1:41777/playtest";
157
+ readonly summary: "device bridge endpoint";
158
+ readonly takesValue: true;
159
+ };
160
+ readonly "--headed": {
161
+ readonly default: "false";
162
+ readonly summary: "show the browser window";
163
+ readonly takesValue: false;
164
+ };
165
+ readonly "--mailbox-root": {
166
+ readonly default: "Android external files directory";
167
+ readonly summary: "native device mailbox directory";
168
+ readonly takesValue: true;
169
+ };
170
+ readonly "--ios-transport": {
171
+ readonly default: "simulator";
172
+ readonly summary: "iOS transport (simulator or device)";
173
+ readonly takesValue: true;
174
+ };
175
+ readonly "--project": {
176
+ readonly default: ".";
177
+ readonly summary: "project root used to resolve paths";
178
+ readonly takesValue: true;
179
+ };
180
+ readonly "--package": {
181
+ readonly default: "com.mystral.engine";
182
+ readonly summary: "Android application id";
183
+ readonly takesValue: true;
184
+ };
185
+ readonly "--scenario": {
186
+ readonly default: "required (or positional)";
187
+ readonly summary: "scenario JSON path";
188
+ readonly takesValue: true;
189
+ };
190
+ readonly "--server-command": {
191
+ readonly default: "none";
192
+ readonly summary: "command for a managed app server";
193
+ readonly takesValue: true;
194
+ };
195
+ readonly "--server-timeout": {
196
+ readonly default: "15000";
197
+ readonly summary: "managed server readiness timeout in ms";
198
+ readonly takesValue: true;
199
+ };
200
+ readonly "--timeout": {
201
+ readonly default: "15000";
202
+ readonly summary: "page operation timeout in ms";
203
+ readonly takesValue: true;
204
+ };
205
+ readonly "--target": {
206
+ readonly default: "browser";
207
+ readonly summary: "execution target (browser, android, or ios)";
208
+ readonly takesValue: true;
209
+ };
210
+ readonly "--trace": {
211
+ readonly default: "false";
212
+ readonly summary: "write a Playwright trace";
213
+ readonly takesValue: false;
214
+ };
215
+ readonly "--url": {
216
+ readonly default: "http://127.0.0.1:5173";
217
+ readonly summary: "application URL";
218
+ readonly takesValue: true;
219
+ };
220
+ readonly "--xcrun": {
221
+ readonly default: "auto-discover";
222
+ readonly summary: "absolute xcrun executable path";
223
+ readonly takesValue: true;
224
+ };
225
+ };
226
+ declare class PlaytestCliUsageError extends Error {
227
+ constructor(message: string);
228
+ }
229
+ declare function formatUsage(): string;
230
+ declare function parseStandalonePlaytestArgs(argv: readonly string[], cwd?: string): IStandalonePlaytestConfig;
231
+
232
+ declare const ANDROID_TRANSPORT_CAPABILITIES: readonly ["browser.console", "browser.input", "browser.screenshot"];
233
+ interface IDeviceMailbox {
234
+ read(path: string): Promise<string | undefined>;
235
+ remove(path: string): Promise<void>;
236
+ write(path: string, contents: string): Promise<void>;
237
+ }
238
+ interface IDeviceMailboxPaths {
239
+ request: string;
240
+ response: string;
241
+ }
242
+ interface DevicePlaytestTransport extends BridgeTransport {
243
+ start(): Promise<void>;
244
+ }
245
+ declare class DeviceBridgeTransport implements DevicePlaytestTransport {
246
+ readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot"];
247
+ readonly endpoint: URL;
248
+ private connected;
249
+ private nextId;
250
+ private readonly pending;
251
+ private readonly queue;
252
+ private server?;
253
+ private waiters;
254
+ constructor(endpoint: string);
255
+ start(): Promise<void>;
256
+ call<T>(method: string, argument?: unknown): Promise<T>;
257
+ close(): Promise<void>;
258
+ waitForBridge(timeoutMs: number): Promise<boolean>;
259
+ private handle;
260
+ private markConnected;
261
+ }
262
+ declare class DeviceMailboxTransport implements DevicePlaytestTransport {
263
+ private readonly mailbox;
264
+ private readonly paths;
265
+ readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot"];
266
+ private connected;
267
+ private closed;
268
+ private nextId;
269
+ constructor(mailbox: IDeviceMailbox, paths: IDeviceMailboxPaths);
270
+ start(): Promise<void>;
271
+ call<T>(method: string, argument?: unknown): Promise<T>;
272
+ close(): Promise<void>;
273
+ waitForBridge(timeoutMs: number): Promise<boolean>;
274
+ private waitForResponse;
275
+ private readResponse;
276
+ }
277
+ declare function androidMailboxPaths(packageName: string, root?: string): IDeviceMailboxPaths;
278
+ declare function deviceMailboxPaths(root: string): IDeviceMailboxPaths;
279
+ declare function validateDeviceEndpoint(value: string): URL;
280
+
281
+ declare const STANDALONE_PLAYTEST_OBSERVATION_FIELDS: readonly ["components", "componentSeries", "console", "hud", "network", "resources", "resourceSeries", "runtimeDiagnostics", "runtimeObservations", "signals", "signalSeries", "visual"];
282
+
283
+ interface IStandalonePlaytestReport extends IPlaytestReport {
284
+ artifactDirectory: string;
285
+ pass: boolean;
286
+ runtime: "native" | "web";
287
+ scenario: string;
288
+ target: string;
289
+ url: string;
290
+ }
291
+ interface LabeledPlaytestSample {
292
+ label: string;
293
+ signals: unknown[];
294
+ snapshot: IPlaytestObservationSnapshot;
295
+ }
296
+ declare function runStandalonePlaytest(config: IStandalonePlaytestConfig): Promise<IStandalonePlaytestReport>;
297
+ declare function preflightDisplay(config: Pick<IStandalonePlaytestConfig, "headless">, scenario: Pick<IPlaytestScenario, "artifacts" | "assert" | "steps">, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): IPlaytestDiagnostic | undefined;
298
+ declare function buildReport(config: IStandalonePlaytestConfig, scenario: IPlaytestScenario, beforeSnapshot: IPlaytestObservationSnapshot | undefined, afterSnapshot: IPlaytestObservationSnapshot | undefined, consoleEntries: Array<{
299
+ text: string;
300
+ type: string;
301
+ }>, networkEntries: Array<{
302
+ method: string;
303
+ url: string;
304
+ }>, pathLength?: number | undefined, hud?: Record<string, {
305
+ after?: unknown;
306
+ before?: unknown;
307
+ }>, runtimeReady?: boolean, visual?: IPlaytestObservations["visual"], labeledSamples?: readonly LabeledPlaytestSample[]): IStandalonePlaytestReport;
308
+
309
+ interface IAndroidPlaytestDependencies {
310
+ driver?: IAndroidDriver;
311
+ transport?: DevicePlaytestTransport;
312
+ }
313
+ interface IDevicePlaytestDriver {
314
+ captureConsole(): Promise<Array<{
315
+ text: string;
316
+ type: string;
317
+ }>>;
318
+ isAlive(): Promise<boolean>;
319
+ prepare(endpoint: string, mailboxRoot?: string): Promise<void>;
320
+ readFile?(path: string): Promise<string | undefined>;
321
+ removeFile?(path: string): Promise<void>;
322
+ screenshot(path: string): Promise<void>;
323
+ stop(): Promise<void>;
324
+ writeFile?(path: string, contents: string): Promise<void>;
325
+ }
326
+ interface IDevicePlaytestTarget {
327
+ driver: IDevicePlaytestDriver;
328
+ mailboxPaths: ReturnType<typeof androidMailboxPaths>;
329
+ name: "android" | "ios";
330
+ processName: string;
331
+ transport?: DevicePlaytestTransport;
332
+ }
333
+ declare function runAndroidPlaytest(config: IStandalonePlaytestConfig, dependencies?: IAndroidPlaytestDependencies): Promise<IStandalonePlaytestReport>;
334
+ declare function runDevicePlaytest(config: IStandalonePlaytestConfig, target: IDevicePlaytestTarget): Promise<IStandalonePlaytestReport>;
335
+
336
+ declare function initStandalonePlaytest(projectPath?: string): Promise<{
337
+ created: string[];
338
+ }>;
339
+
340
+ type IosTransportKind = "device" | "simulator";
341
+ interface IIosDriverOptions {
342
+ appPath: string;
343
+ bundleId: string;
344
+ device?: string;
345
+ transport: IosTransportKind;
346
+ xcrunPath?: string;
347
+ }
348
+ interface IIosCommandOptions {
349
+ env?: NodeJS.ProcessEnv;
350
+ }
351
+ type IRunIosCommand = (args: readonly string[], options?: IIosCommandOptions) => Promise<string>;
352
+ declare class XcrunIosDriver implements IDevicePlaytestDriver {
353
+ private readonly options;
354
+ private readonly run;
355
+ private mailboxRoot?;
356
+ private pid?;
357
+ private suppressedResponse?;
358
+ constructor(options: IIosDriverOptions, run?: IRunIosCommand);
359
+ prepare(endpoint: string, mailboxRoot?: string): Promise<void>;
360
+ captureConsole(): Promise<Array<{
361
+ text: string;
362
+ type: string;
363
+ }>>;
364
+ isAlive(): Promise<boolean>;
365
+ screenshot(path: string): Promise<void>;
366
+ readFile(path: string): Promise<string | undefined>;
367
+ removeFile(path: string): Promise<void>;
368
+ stop(): Promise<void>;
369
+ writeFile(path: string, contents: string): Promise<void>;
370
+ getMailboxRoot(): string;
371
+ private prepareSimulator;
372
+ private prepareDevice;
373
+ private device;
374
+ private processName;
375
+ private mailboxPath;
376
+ }
377
+ declare function parseLaunchedPid(output: string): string;
378
+
379
+ interface IIosPlaytestDependencies {
380
+ driver?: IDevicePlaytestDriver & {
381
+ getMailboxRoot?(): string;
382
+ };
383
+ transport?: DevicePlaytestTransport;
384
+ }
385
+ declare function runIosPlaytest(config: IStandalonePlaytestConfig, dependencies?: IIosPlaytestDependencies): Promise<IStandalonePlaytestReport>;
386
+
387
+ declare function requireAssertions(value: IPlaytestScenario["assert"], scenarioPath: string): NonNullable<IPlaytestScenario["assert"]>;
388
+ declare function recordToScenario(value: unknown, scenarioPath?: string, oracleValue?: unknown): IPlaytestScenario;
389
+
390
+ export { ANDROID_TRANSPORT_CAPABILITIES, AdbAndroidDriver, type BridgeTransport, DeviceBridgeTransport, DeviceMailboxTransport, type DevicePlaytestTransport, type IAndroidDriver, type IAndroidDriverOptions, type IAndroidPlaytestDependencies, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, type IPlaytestBridgeClient, type IPlaytestFlagHelp, type IPlaytestServerConfig, type IRunIosCommand, type IStandalonePlaytestConfig, type IStandalonePlaytestReport, type IosTransportKind, PLAYTEST_FLAGS, PlaytestBridgeError, PlaytestCliUsageError, PlaywrightTransport, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, XcrunIosDriver, androidMailboxPaths, buildReport, connectPlaytestBridge, connectPlaytestBridgeTransport, deviceMailboxPaths, discoverAdb, formatUsage, initStandalonePlaytest, parseLaunchedPid, parseStandalonePlaytestArgs, preflightDisplay, recordToScenario, requireAssertions, runAndroidPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, validateDeviceEndpoint };