@threenative/playtest 0.3.0 → 0.3.2

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.
@@ -1,8 +1,8 @@
1
1
  import { IPlaytestObservationSnapshot, IPlaytestSetupRequest, JsonValue, IPlaytestBridgeDescription, IPlaytestBridgeReady, IPlaytestSampleRequest } from '../protocol.js';
2
- import { b as IPlaytestScenario, s as IPlaytestObservations, r as IPlaytestFramebufferCoverageObservation, j as IPlaytestCaptureProvenance, y as IPlaytestSetupApplication, l as IPlaytestDeviceMetricsObservation, e as IPlaytestDiagnostic, w as IPlaytestProtocolDiagnostic, i as IPlaytestArtifactRequest, v as IPlaytestPointer } from '../diagnostics-D89qJhf0.js';
2
+ import { b as IPlaytestScenario, s as IPlaytestObservations, r as IPlaytestFramebufferCoverageObservation, j as IPlaytestCaptureProvenance, z as IPlaytestSetupApplication, l as IPlaytestDeviceMetricsObservation, e as IPlaytestDiagnostic, w as IPlaytestProtocolDiagnostic, i as IPlaytestArtifactRequest, v as IPlaytestPointer } from '../diagnostics-f8464bJw.js';
3
3
  import { Page } from 'playwright';
4
- import { I as IStandalonePlaytestConfig, b as IRunnerConsoleEntry, c as ILabeledPlaytestSample, d as IMovementSampleInterval, a as IStandalonePlaytestReport } from '../shared-Ax3-pneQ.js';
5
- export { e as IPlaytestFlagHelp, f as IPlaytestServerConfig, g as IRunStepSamples, M as ManagedServerError, P as PLAYTEST_FLAGS, h as PlaytestCliUsageError, i as failedDiagnosticsAssertion, j as formatUsage, p as parseStandalonePlaytestArgs } from '../shared-Ax3-pneQ.js';
4
+ import { I as IStandalonePlaytestConfig, b as IRunnerConsoleEntry, c as ILabeledPlaytestSample, d as IMovementSampleInterval, a as IStandalonePlaytestReport } from '../shared-BGwYk5HG.js';
5
+ export { e as IPlaytestFlagHelp, f as IPlaytestServerConfig, g as IRunStepSamples, M as ManagedServerError, P as PLAYTEST_FLAGS, h as PlaytestCliUsageError, i as failedDiagnosticsAssertion, j as formatUsage, p as parseStandalonePlaytestArgs } from '../shared-BGwYk5HG.js';
6
6
  import { ChildProcess } from 'node:child_process';
7
7
 
8
8
  declare function preflightDisplay(config: Pick<IStandalonePlaytestConfig, "headless">, scenario: Pick<IPlaytestScenario, "artifacts" | "assert" | "steps">, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): IPlaytestDiagnostic | undefined;
@@ -44,6 +44,8 @@ interface IPlaytestBridgeClient {
44
44
  close(): Promise<void>;
45
45
  drainEvents(limit?: number): Promise<JsonValue[]>;
46
46
  description: IPlaytestBridgeDescription;
47
+ /** Setup applied before the handshake released a held game, when the scenario declared setup. */
48
+ setupApplication?: IPlaytestSetupApplication;
47
49
  /** Re-reads the bridge's readiness, including startup progress when it reports any. */
48
50
  readiness(): Promise<IPlaytestBridgeReady>;
49
51
  sample(request: IPlaytestSampleRequest): Promise<IPlaytestObservationSnapshot>;
@@ -72,7 +74,7 @@ declare function connectPlaytestBridge(page: Page, scenario: IPlaytestScenario,
72
74
  * installs no bridge still fails with the same diagnostic, just later.
73
75
  */
74
76
  declare function bridgeWaitTimeoutMs(operationMs?: number): number;
75
- declare function connectPlaytestBridgeTransport(transport: IBridgeTransport, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
77
+ declare function connectPlaytestBridgeTransport(transport: IBridgeTransport, scenario: IPlaytestScenario, timeoutMs?: number, target?: string): Promise<IPlaytestBridgeClient | undefined>;
76
78
 
77
79
  /** Capture the largest rendered canvas without composited DOM overlays. */
78
80
  declare function captureVisualSurface(page: Page, artifactPath?: string): Promise<Buffer | undefined>;
@@ -138,7 +140,7 @@ declare function pageLifecycleDiagnostic(error: unknown, lifecycle: IPageLifecyc
138
140
  */
139
141
  declare function openPageAndConnectBridge(page: Page, config: IStandalonePlaytestConfig, scenario: IPlaytestScenario): Promise<IPlaytestBridgeClient | undefined>;
140
142
 
141
- declare const STANDALONE_PLAYTEST_OBSERVATION_FIELDS: readonly ["components", "componentSeries", "console", "effectLogBefore", "framebufferCoverage", "hud", "network", "physicsDebugSeries", "performanceSeries", "renderChain", "physicsDebugBefore", "resources", "resourceSeries", "runtimeDiagnostics", "runtimeDiagnosticsBefore", "runtimeObservations", "signals", "signalSeries", "visual"];
143
+ declare const STANDALONE_PLAYTEST_OBSERVATION_FIELDS: readonly ["components", "componentSeries", "console", "effectLogBefore", "framebufferCoverage", "hud", "network", "physicsDebugSeries", "performanceSeries", "pipelineCensus", "renderChain", "physicsDebugBefore", "resources", "resourceSeries", "runtimeDiagnostics", "runtimeDiagnosticsBefore", "runtimeObservations", "scene", "sceneNodes", "signals", "signalSeries", "startup", "visual"];
142
144
 
143
145
  declare function handlePlaytestSignal(teardown: (stopManagedServer: boolean) => Promise<void>, setExitCode?: (code: number) => void, exit?: (code: number) => void, target?: string, writeMessage?: (message: string) => void): Promise<void>;
144
146
  declare function writeCaptureProvenance(artifactDirectory: string, provenance: IPlaytestCaptureProvenance): Promise<void>;
@@ -189,6 +191,8 @@ interface IAndroidDriverOptions {
189
191
  adbPath?: string;
190
192
  packageName: string;
191
193
  serial?: string;
194
+ /** Android user id to target; when omitted, the device's current foreground user is detected. */
195
+ user?: string;
192
196
  /**
193
197
  * The rotation between the touchscreen's raw axes and the frame the app draws in, when the
194
198
  * device cannot be asked.
@@ -244,6 +248,25 @@ interface IAndroidPointerInjection {
244
248
  rotation: number;
245
249
  trackingIds: number[];
246
250
  }
251
+ interface IAndroidTouchViewport {
252
+ device: {
253
+ height: number;
254
+ width: number;
255
+ };
256
+ logical: {
257
+ bottom: number;
258
+ left: number;
259
+ right: number;
260
+ top: number;
261
+ };
262
+ orientation: number | undefined;
263
+ physical: {
264
+ bottom: number;
265
+ left: number;
266
+ right: number;
267
+ top: number;
268
+ };
269
+ }
247
270
  declare class AdbAndroidDriver implements IAndroidDriver {
248
271
  private readonly options;
249
272
  private static readonly COVERAGE_VIDEO_PATH;
@@ -253,12 +276,16 @@ declare class AdbAndroidDriver implements IAndroidDriver {
253
276
  private readonly touchSlots;
254
277
  private nextTrackingId;
255
278
  private rotation?;
279
+ private touchViewport?;
280
+ private readonly user?;
281
+ private activeUser?;
256
282
  private viewportPresented;
257
283
  constructor(options: IAndroidDriverOptions);
258
284
  prepare(endpoint: string, mailboxRoot?: string, viewport?: {
259
285
  height: number;
260
286
  width: number;
261
287
  }): Promise<void>;
288
+ private resolveUser;
262
289
  /**
263
290
  * Put the device into the scenario's viewport, and fail closed if it did not take.
264
291
  *
@@ -311,6 +338,9 @@ declare function parseAndroidConsole(output: string): Array<{
311
338
  text: string;
312
339
  type: string;
313
340
  }>;
341
+ declare function parseAndroidTouchViewport(output: string): IAndroidTouchViewport;
342
+ /** Map a normalized logical-display point to the raw touchscreen axes. */
343
+ declare function touchPositionForViewport(x: number, y: number, viewport: IAndroidTouchViewport, rotationOverride?: number): [number, number];
314
344
  /**
315
345
  * Splits slot identity from coordinates into separate synced `adb emu event send` batches.
316
346
  *
@@ -322,6 +352,17 @@ declare function parseAndroidConsole(output: string): Array<{
322
352
  * google_apis image. Identity goes first so a slot exists before it is positioned.
323
353
  */
324
354
  declare function androidTouchBatches(identity: readonly string[], positions: readonly string[]): string[][];
355
+ /**
356
+ * Confirm that Android reported the requested viewport, including the physical-size omission.
357
+ *
358
+ * @situation verify that an Android device presented the requested viewport
359
+ * @situation accept the physical panel size when `wm size` omits its override line
360
+ * @example viewportPresentationObserved(undefined, "1080x2400", { width: 1080, height: 2400 });
361
+ */
362
+ declare function viewportPresentationObserved(override: string | undefined, expected: string | undefined, physical: {
363
+ height: number;
364
+ width: number;
365
+ }): boolean;
325
366
  /**
326
367
  * The touch rotation for the window `dumpsys window` just described, or `undefined`.
327
368
  *
@@ -390,8 +431,16 @@ interface IDeviceMailboxPaths {
390
431
  request: string;
391
432
  response: string;
392
433
  }
434
+ /** The raw response and request position captured before a mailbox file is consumed. */
435
+ interface IDeviceResponseObservation {
436
+ body: string;
437
+ method: string;
438
+ order: number;
439
+ requestId: string;
440
+ }
393
441
  interface IDevicePlaytestTransport extends IBridgeTransport {
394
442
  start(): Promise<void>;
443
+ setResponseObserver?(observer: (observation: IDeviceResponseObservation) => void): void;
395
444
  }
396
445
  declare class DeviceBridgeTransport implements IDevicePlaytestTransport {
397
446
  readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
@@ -418,9 +467,12 @@ declare class DeviceMailboxTransport implements IDevicePlaytestTransport {
418
467
  private connected;
419
468
  private closed;
420
469
  private nextId;
470
+ private nextOrder;
471
+ private responseObserver?;
421
472
  constructor(mailbox: IDeviceMailbox, paths: IDeviceMailboxPaths, operationTimeoutMs?: number);
473
+ setResponseObserver(observer: (observation: IDeviceResponseObservation) => void): void;
422
474
  start(): Promise<void>;
423
- call<T>(method: string, argument?: unknown): Promise<T>;
475
+ call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
424
476
  close(): Promise<void>;
425
477
  waitForBridge(timeoutMs: number): Promise<boolean>;
426
478
  private waitForResponse;
@@ -518,6 +570,8 @@ declare class DesktopPlaytestDriver implements IDevicePlaytestDriver {
518
570
 
519
571
  interface IDesktopPlaytestDependencies {
520
572
  driver?: IDevicePlaytestDriver;
573
+ /** Builds the driver when one is not injected, so a test can watch what it is given. */
574
+ driverFactory?: (options: IDesktopPlaytestDriverOptions) => IDevicePlaytestDriver;
521
575
  mailboxRoot?: string;
522
576
  transport?: IDevicePlaytestTransport;
523
577
  }
@@ -578,4 +632,154 @@ declare function runIosPlaytest(config: IStandalonePlaytestConfig, dependencies?
578
632
  declare function requireAssertions(value: IPlaytestScenario["assert"], scenarioPath: string): NonNullable<IPlaytestScenario["assert"]>;
579
633
  declare function recordToScenario(value: unknown, scenarioPath?: string, oracleValue?: unknown): IPlaytestScenario;
580
634
 
581
- export { ANDROID_TRANSPORT_CAPABILITIES, AdbAndroidDriver, DesktopPlaytestDriver, DeviceBridgeTransport, DeviceMailboxTransport, type IAndroidDriver, type IAndroidDriverOptions, type IAndroidPlaytestDependencies, type IAndroidPointer, type IAndroidPointerInjection, type IBridgeTransport, type IBrowserPointerChange, type IDesktopPlaytestDependencies, type IDesktopPlaytestDriverOptions, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IDevicePlaytestTransport, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, ILabeledPlaytestSample, IMovementSampleInterval, type IPlaytestBridgeClient, type IRunIosCommand, IRunnerConsoleEntry, IStandalonePlaytestConfig, IStandalonePlaytestReport, type IStandalonePlaytestRunOptions, type IosTransportKind, LocalDeviceMailbox, PERFORMANCE_BROWSER_ARGS, PlaytestBridgeError, PlaywrightTransport, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, WEBGPU_BROWSER_ARGS, XcrunIosDriver, advanceFixedStep, advanceTimeoutMs, androidMailboxPaths, androidTouchBatches, batchArtifactDirectory, boundedTeardownStep, bridgeWaitTimeoutMs, buildReport, captureVisualSurface, connectPlaytestBridge, connectPlaytestBridgeTransport, deviceMailboxPaths, deviceTimeoutDiagnostic, discoverAdb, handlePlaytestSignal, initStandalonePlaytest, isRuntimeReadout, keyboardIsShown, openPageAndConnectBridge, pageLifecycleDiagnostic, parseAndroidConsole, parseLaunchedPid, playtestStepDrivesMovement, preflightDisplay, reconcileBrowserPointers, recordToScenario, requireAssertions, resolveBrowserArguments, resolveManagedServerCommand, resolveManagedServerConfig, rotatedTouchPosition, runAndroidPlaytest, runDesktopPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, runStandalonePlaytests, softwareAdapterName, substituteManagedPort, tapCommand, touchRotationFromWindowDump, validateDeviceEndpoint, viewportPresentationCommands, viewportRestoreCommands, writeCaptureProvenance, writeObservationArtifacts };
635
+ /** Shared parser and aggregation for browser pipeline censuses and native pipeline markers. */
636
+ declare const PIPELINE_CAPTURE_VERSION: 1;
637
+ declare const PIPELINE_EVENT_MARKER = "TN_PIPELINE_EVENT:";
638
+ type PipelineCaptureSource = "browser" | "native";
639
+ type PipelineCaptureKind = "compute" | "render";
640
+ type PipelineCaptureMode = "sync" | "async";
641
+ type PipelineCaptureStatus = "created" | "failed" | "pending";
642
+ interface IPipelineCaptureShader {
643
+ readonly bytes: number;
644
+ readonly hash: string;
645
+ }
646
+ interface IPipelineCaptureProvenance {
647
+ readonly material?: {
648
+ readonly id?: number;
649
+ readonly name?: string;
650
+ readonly type?: string;
651
+ };
652
+ readonly object?: {
653
+ readonly id?: number;
654
+ readonly name?: string;
655
+ readonly uuid?: string;
656
+ };
657
+ readonly unknown: boolean;
658
+ }
659
+ interface IPipelineCaptureEvent {
660
+ readonly sequence: number;
661
+ readonly programIdentity: string;
662
+ readonly pipelineIdentity: string;
663
+ readonly kind: PipelineCaptureKind;
664
+ readonly pass: string;
665
+ readonly mode: PipelineCaptureMode;
666
+ readonly status: PipelineCaptureStatus;
667
+ readonly vertex?: IPipelineCaptureShader;
668
+ readonly fragment?: IPipelineCaptureShader;
669
+ readonly compute?: IPipelineCaptureShader;
670
+ readonly provenance: IPipelineCaptureProvenance;
671
+ readonly reasons: readonly string[];
672
+ readonly startedMs: number;
673
+ readonly settledMs?: number;
674
+ readonly serviceMs?: number;
675
+ readonly promiseMs?: number;
676
+ readonly queueMs?: number;
677
+ readonly wallMs?: number;
678
+ readonly label?: string;
679
+ readonly error?: string;
680
+ readonly beforeFirstPresent?: boolean;
681
+ }
682
+ interface IPipelineCaptureCounts {
683
+ readonly lookups: number;
684
+ readonly creations: number;
685
+ readonly failures: number;
686
+ readonly pending: number;
687
+ readonly uniquePrograms: number;
688
+ readonly uniquePipelines: number;
689
+ readonly recordedEvents: number;
690
+ readonly droppedEvents: number;
691
+ }
692
+ /**
693
+ * What ended the capture, and therefore what "complete" is allowed to mean.
694
+ *
695
+ * `finalized` is a process that exited: the host drained its compile pool and printed a final
696
+ * count. `checkpoint` is a live snapshot from a present, which is all a run ended by
697
+ * `am force-stop` can produce — every event up to that present is accounted for and nothing was
698
+ * still compiling, and the capture claims nothing about the run after it.
699
+ */
700
+ interface IPipelineCaptureBoundary {
701
+ readonly kind: "checkpoint" | "finalized";
702
+ readonly events: number;
703
+ readonly outstanding?: number;
704
+ readonly present?: number;
705
+ }
706
+ interface IPipelineCapture {
707
+ readonly version: number;
708
+ readonly source: PipelineCaptureSource;
709
+ readonly boundary?: IPipelineCaptureBoundary;
710
+ readonly complete: boolean;
711
+ readonly overflowed: boolean;
712
+ readonly backend?: Readonly<Record<string, unknown>>;
713
+ readonly clock?: Readonly<Record<string, unknown>>;
714
+ readonly build?: Readonly<Record<string, unknown>>;
715
+ readonly adapter?: Readonly<Record<string, unknown>>;
716
+ readonly firstPresent?: {
717
+ readonly boundaryMs: number;
718
+ readonly eventsSettled: number;
719
+ };
720
+ readonly counts: IPipelineCaptureCounts;
721
+ readonly events: readonly IPipelineCaptureEvent[];
722
+ readonly incompleteReasons: readonly string[];
723
+ }
724
+ interface IPipelinePassSummary {
725
+ readonly creations: number;
726
+ readonly failures: number;
727
+ readonly beforeFirstPresent: number;
728
+ /** Sum of observed device-call service durations; absent when the driver did not expose them. */
729
+ readonly serviceMs?: number;
730
+ readonly serviceSamples: number;
731
+ readonly pass: string;
732
+ }
733
+ interface IPipelineContributorSummary {
734
+ readonly creations: number;
735
+ readonly failures: number;
736
+ readonly label: string;
737
+ readonly sampleCount: number;
738
+ /** Sum of observed device-call service durations; absent when the driver did not expose them. */
739
+ readonly serviceMs?: number;
740
+ }
741
+ interface IPipelineProgramReasonSummary {
742
+ readonly creations: number;
743
+ readonly programIdentity: string;
744
+ readonly reasons: readonly string[];
745
+ }
746
+ interface IPipelineSizeTimePassSummary {
747
+ readonly meanBytes: number;
748
+ readonly meanServiceMs: number;
749
+ readonly pass: string;
750
+ readonly samples: number;
751
+ }
752
+ interface IPipelineSizeTimeSummary {
753
+ readonly byPass: readonly IPipelineSizeTimePassSummary[];
754
+ readonly samples: number;
755
+ readonly statement: string;
756
+ }
757
+ interface IPipelineWarmupSummary {
758
+ readonly afterFirstPresent: number;
759
+ readonly beforeFirstPresent: number;
760
+ readonly eventsSettledAtFirstPresent?: number;
761
+ readonly total: number;
762
+ readonly unreported: number;
763
+ }
764
+ interface IPipelineSummary {
765
+ readonly adapter?: Readonly<Record<string, unknown>>;
766
+ readonly boundary?: IPipelineCaptureBoundary;
767
+ readonly build?: Readonly<Record<string, unknown>>;
768
+ readonly complete: boolean;
769
+ readonly counts: IPipelineCaptureCounts;
770
+ readonly contributors: readonly IPipelineContributorSummary[];
771
+ readonly incompleteReasons: readonly string[];
772
+ readonly passTotals: readonly IPipelinePassSummary[];
773
+ readonly programReasons: readonly IPipelineProgramReasonSummary[];
774
+ readonly sizeTime: IPipelineSizeTimeSummary;
775
+ readonly source: PipelineCaptureSource;
776
+ readonly warmup: IPipelineWarmupSummary;
777
+ }
778
+ /** Parse a capture file, either as a JSON browser census or a native log containing markers. */
779
+ declare function parsePipelineCapture(input: string | unknown): IPipelineCapture;
780
+ /** Parse only native marker lines, preserving the same malformed-input contract as perf. */
781
+ declare function parsePipelineEventMarkers(text: string): IPipelineCaptureEvent[];
782
+ declare function summarizePipelineCapture(capture: IPipelineCapture): IPipelineSummary;
783
+ declare function formatPipelineSummary(summary: IPipelineSummary): string;
784
+
785
+ export { ANDROID_TRANSPORT_CAPABILITIES, AdbAndroidDriver, DesktopPlaytestDriver, DeviceBridgeTransport, DeviceMailboxTransport, type IAndroidDriver, type IAndroidDriverOptions, type IAndroidPlaytestDependencies, type IAndroidPointer, type IAndroidPointerInjection, type IAndroidTouchViewport, type IBridgeTransport, type IBrowserPointerChange, type IDesktopPlaytestDependencies, type IDesktopPlaytestDriverOptions, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IDevicePlaytestTransport, type IDeviceResponseObservation, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, ILabeledPlaytestSample, IMovementSampleInterval, type IPipelineCapture, type IPipelineCaptureBoundary, type IPipelineCaptureCounts, type IPipelineCaptureEvent, type IPipelineCaptureProvenance, type IPipelineCaptureShader, type IPipelineContributorSummary, type IPipelinePassSummary, type IPipelineProgramReasonSummary, type IPipelineSizeTimePassSummary, type IPipelineSizeTimeSummary, type IPipelineSummary, type IPipelineWarmupSummary, type IPlaytestBridgeClient, type IRunIosCommand, IRunnerConsoleEntry, IStandalonePlaytestConfig, IStandalonePlaytestReport, type IStandalonePlaytestRunOptions, type IosTransportKind, LocalDeviceMailbox, PERFORMANCE_BROWSER_ARGS, PIPELINE_CAPTURE_VERSION, PIPELINE_EVENT_MARKER, type PipelineCaptureKind, type PipelineCaptureMode, type PipelineCaptureSource, type PipelineCaptureStatus, PlaytestBridgeError, PlaywrightTransport, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, WEBGPU_BROWSER_ARGS, XcrunIosDriver, advanceFixedStep, advanceTimeoutMs, androidMailboxPaths, androidTouchBatches, batchArtifactDirectory, boundedTeardownStep, bridgeWaitTimeoutMs, buildReport, captureVisualSurface, connectPlaytestBridge, connectPlaytestBridgeTransport, deviceMailboxPaths, deviceTimeoutDiagnostic, discoverAdb, formatPipelineSummary, handlePlaytestSignal, initStandalonePlaytest, isRuntimeReadout, keyboardIsShown, openPageAndConnectBridge, pageLifecycleDiagnostic, parseAndroidConsole, parseAndroidTouchViewport, parseLaunchedPid, parsePipelineCapture, parsePipelineEventMarkers, playtestStepDrivesMovement, preflightDisplay, reconcileBrowserPointers, recordToScenario, requireAssertions, resolveBrowserArguments, resolveManagedServerCommand, resolveManagedServerConfig, rotatedTouchPosition, runAndroidPlaytest, runDesktopPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, runStandalonePlaytests, softwareAdapterName, substituteManagedPort, summarizePipelineCapture, tapCommand, touchPositionForViewport, touchRotationFromWindowDump, validateDeviceEndpoint, viewportPresentationCommands, viewportPresentationObserved, viewportRestoreCommands, writeCaptureProvenance, writeObservationArtifacts };