@threenative/playtest 0.2.0 → 0.3.1
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 +22 -3
- package/dist/capture.d.ts +48 -0
- package/dist/capture.js +87 -0
- package/dist/diagnostics-f8464bJw.d.ts +1106 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +5576 -2345
- package/dist/protocol.d.ts +532 -0
- package/dist/protocol.js +42 -0
- package/dist/runner/cli.d.ts +63 -0
- package/dist/runner/cli.js +16171 -5804
- package/dist/runner/index.d.ts +785 -0
- package/dist/runner/index.js +10866 -3651
- package/dist/shared-BGwYk5HG.d.ts +280 -0
- package/dist/three/index.d.ts +217 -0
- package/dist/three/index.js +511 -74
- package/package.json +32 -4
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
declare const PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
2
|
+
declare const PLAYTEST_PROTOCOL_VERSION: 1;
|
|
3
|
+
/**
|
|
4
|
+
* userData key the setup channel sets on an entity placed with `frozen: true`. Games read
|
|
5
|
+
* this marker and suppress physics motion for the entity — placement stays data the game
|
|
6
|
+
* interprets, never a runner-side per-frame teleport.
|
|
7
|
+
*/
|
|
8
|
+
declare const PLAYTEST_FROZEN_MARKER = "__threenativeFrozen";
|
|
9
|
+
/**
|
|
10
|
+
* How much wall clock one advanced tick may take before the runner calls the page hung.
|
|
11
|
+
*
|
|
12
|
+
* `operationTimeoutMs` bounds a request/response round trip, which is the right shape for every
|
|
13
|
+
* bridge call except one: `advance` is bulk work whose duration scales with the ticks asked for,
|
|
14
|
+
* so a fixed budget is wrong for it by construction. A scenario advancing 600 ticks in a single
|
|
15
|
+
* call exceeded 5 s on a two-core CI runner and was reported as a timed-out operation — the page
|
|
16
|
+
* was not hung, it was doing exactly what it was told, slowly.
|
|
17
|
+
*
|
|
18
|
+
* 250 ms is about 2.5x the ~100 ms per tick measured on the slowest lane this repository runs
|
|
19
|
+
* (SwiftShader on a two-core runner). It is a hang detector, not a schedule: no measurement
|
|
20
|
+
* anywhere reads it, and a run that needs it is already reporting its own tick counts.
|
|
21
|
+
*/
|
|
22
|
+
declare const PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
23
|
+
/**
|
|
24
|
+
* Core's own bound on first-use compilation, restated here because `playtest` must not depend on
|
|
25
|
+
* `core`. Kept equal to `STARTUP_COMPILE_BUDGET_MS` in `packages/core/src/startup-readiness.ts`;
|
|
26
|
+
* an advance that can overlap that work has to allow for it.
|
|
27
|
+
*/
|
|
28
|
+
declare const PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15000;
|
|
29
|
+
declare const PLAYTEST_PROTOCOL_LIMITS: {
|
|
30
|
+
readonly maxEntitiesPerSample: 100;
|
|
31
|
+
readonly maxEventsPerDrain: 1000;
|
|
32
|
+
readonly maxPayloadBytes: 1000000;
|
|
33
|
+
readonly operationTimeoutMs: 5000;
|
|
34
|
+
};
|
|
35
|
+
type JsonPrimitive = boolean | number | string | null;
|
|
36
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
37
|
+
[key: string]: JsonValue;
|
|
38
|
+
};
|
|
39
|
+
type PlaytestClockMode = "fixed-step" | "render-frame" | "wall-clock";
|
|
40
|
+
interface IPlaytestBridgeDescription {
|
|
41
|
+
capabilities: readonly string[];
|
|
42
|
+
limits: typeof PLAYTEST_PROTOCOL_LIMITS;
|
|
43
|
+
name: string;
|
|
44
|
+
protocolVersion: typeof PLAYTEST_PROTOCOL_VERSION;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How far the application is through its own first-use startup work.
|
|
48
|
+
*
|
|
49
|
+
* A fixed-step runner advances ticks as fast as the machine allows, so a scenario can finish
|
|
50
|
+
* before a loading screen has closed — and everything a game gates on startup (compute
|
|
51
|
+
* dispatch, the first world present) then never happens inside the run. Reported so the runner
|
|
52
|
+
* can wait for the world instead of photographing the loader and asserting against a frozen
|
|
53
|
+
* simulation.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* When the application's startup milestones happened, in milliseconds on the host's monotonic
|
|
57
|
+
* clock (since navigation on the web, since process start on native). Absent members have not
|
|
58
|
+
* happened yet.
|
|
59
|
+
*/
|
|
60
|
+
interface IPlaytestStartupTimeline {
|
|
61
|
+
loadStartedMs?: number;
|
|
62
|
+
enteredMs?: number;
|
|
63
|
+
compileSettledMs?: number;
|
|
64
|
+
readyMs?: number;
|
|
65
|
+
}
|
|
66
|
+
interface IPlaytestStartupObservation {
|
|
67
|
+
phase: "observing" | "collapsing" | "ready";
|
|
68
|
+
/** 0 while first-use work is pending, then 1. */
|
|
69
|
+
progress: number;
|
|
70
|
+
/** Candidate and backend observation counts from the most recent engine warm-up. */
|
|
71
|
+
warmup?: {
|
|
72
|
+
attempted?: number;
|
|
73
|
+
candidates?: number;
|
|
74
|
+
observed?: {
|
|
75
|
+
created: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
pending: number;
|
|
78
|
+
status: "complete" | "incomplete" | "unavailable";
|
|
79
|
+
uniquePipelines: number;
|
|
80
|
+
uniquePrograms: number;
|
|
81
|
+
};
|
|
82
|
+
status: "complete" | "incomplete" | "unavailable";
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Whether first-use compilation has settled, which happens strictly before `phase` reaches
|
|
86
|
+
* `"ready"`: readiness additionally requires a sustained in-budget frame window. Reported
|
|
87
|
+
* separately because that window is a player-experience gate, and a lane that has been told
|
|
88
|
+
* the machine has no GPU has already conceded it is not measuring that.
|
|
89
|
+
*/
|
|
90
|
+
compileSettled?: boolean;
|
|
91
|
+
/** Present when the application records its startup milestones. */
|
|
92
|
+
timeline?: IPlaytestStartupTimeline;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* How long a run will wait for an application to finish its own first-use startup work.
|
|
96
|
+
*
|
|
97
|
+
* Derived, not picked. Core bounds its own launch twice — `STARTUP_COMPILE_BUDGET_MS` (15s) for
|
|
98
|
+
* first-use compilation, then `STARTUP_STABLE_WINDOW_MS` (10s) for the sustained-frame window,
|
|
99
|
+
* which resolves anyway — so the readiness gate itself is bounded at 25s. Measured end to end on
|
|
100
|
+
* a real SwiftShader adapter, a starter scenario took ~57s to report ready, because the scene
|
|
101
|
+
* build and first-use work that happen *before* that gate opens are not inside those budgets.
|
|
102
|
+
*
|
|
103
|
+
* This deadline is a backstop for a page that has hung, not a schedule anything should approach,
|
|
104
|
+
* so it is set at roughly 3x that measured software launch and >7x the gate's own bound. A margin
|
|
105
|
+
* of a few seconds over a worst case measured on one machine is a coin flip, not headroom.
|
|
106
|
+
*
|
|
107
|
+
* Pinned against core's constants by packages/core/__tests__/startup-ready-bound.spec.ts, which
|
|
108
|
+
* fails if either budget is raised past it.
|
|
109
|
+
*/
|
|
110
|
+
declare const PLAYTEST_STARTUP_READY_TIMEOUT_MS = 180000;
|
|
111
|
+
interface IPlaytestBridgeReady {
|
|
112
|
+
ready: boolean;
|
|
113
|
+
reason?: string;
|
|
114
|
+
/** Present only when the application advertises `runtime.startup`. */
|
|
115
|
+
startup?: IPlaytestStartupObservation;
|
|
116
|
+
}
|
|
117
|
+
interface IPlaytestEntityTransform {
|
|
118
|
+
position?: [number, number, number];
|
|
119
|
+
rotation?: [number, number, number, number];
|
|
120
|
+
scale?: [number, number, number];
|
|
121
|
+
}
|
|
122
|
+
interface IPlaytestSetupRequest {
|
|
123
|
+
entities?: Array<{
|
|
124
|
+
entity: string;
|
|
125
|
+
/** Marks the placed entity with {@link PLAYTEST_FROZEN_MARKER} for the game to read. */
|
|
126
|
+
frozen?: boolean;
|
|
127
|
+
transform: IPlaytestEntityTransform;
|
|
128
|
+
}>;
|
|
129
|
+
resources?: Array<{
|
|
130
|
+
id: string;
|
|
131
|
+
path?: string;
|
|
132
|
+
value: JsonValue;
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
interface IPlaytestSampleRequest {
|
|
136
|
+
entities?: readonly string[];
|
|
137
|
+
include?: readonly string[];
|
|
138
|
+
/** Scenario-step label for providers that retain labelled observation series. */
|
|
139
|
+
label?: string;
|
|
140
|
+
resources?: readonly string[];
|
|
141
|
+
/** Scene-graph selectors to report, one observation per selector, in request order. */
|
|
142
|
+
sceneNodes?: readonly IPlaytestSceneNodeSelector[];
|
|
143
|
+
}
|
|
144
|
+
interface IPlaytestEntityObservation {
|
|
145
|
+
bounds?: {
|
|
146
|
+
height: number;
|
|
147
|
+
width: number;
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
};
|
|
151
|
+
id: string;
|
|
152
|
+
transform?: IPlaytestEntityTransform;
|
|
153
|
+
visible?: boolean;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* What the feet are doing against what the body is doing, for the clip currently playing.
|
|
157
|
+
*
|
|
158
|
+
* The stride convention is on by default and has a named override, so its measurement has to
|
|
159
|
+
* cross the bridge whether or not it is applied — a game that turned it off otherwise has no way
|
|
160
|
+
* to see what that cost, and a scenario has no way to catch a character skating across the floor.
|
|
161
|
+
* Every member is the producer's own measurement; nothing here is derived by the runner.
|
|
162
|
+
*/
|
|
163
|
+
interface IPlaytestStrideObservation {
|
|
164
|
+
/** Metres of ground the clip carries per clip-second at rate 1. Zero when it travels none. */
|
|
165
|
+
clipGroundSpeed: number;
|
|
166
|
+
/** Metres per second the body actually covered, as the producer smoothed it. */
|
|
167
|
+
groundSpeed: number;
|
|
168
|
+
/** True when a rate was measured and deliberately not applied. */
|
|
169
|
+
overridden: boolean;
|
|
170
|
+
/** The playback rate those two imply, after the producer's own clamping. */
|
|
171
|
+
rate: number;
|
|
172
|
+
/** True when that rate is being applied to the action. */
|
|
173
|
+
synced: boolean;
|
|
174
|
+
}
|
|
175
|
+
interface IPlaytestAnimationObservation {
|
|
176
|
+
advancedFrames: number;
|
|
177
|
+
clip: string;
|
|
178
|
+
finished?: boolean;
|
|
179
|
+
/** Present only when the producer measures stride. Absent is unobserved, never zero. */
|
|
180
|
+
stride?: IPlaytestStrideObservation;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* One light in the scene, as the renderer will read it.
|
|
184
|
+
*
|
|
185
|
+
* Counted rather than judged: a light's colour and intensity decide how the game looks, and this
|
|
186
|
+
* harness never owns the look. It reports what is there so a black frame can be told from a lit
|
|
187
|
+
* one without a human opening the page.
|
|
188
|
+
*/
|
|
189
|
+
interface IPlaytestLightObservation {
|
|
190
|
+
/** `#rrggbb`, or `unobserved` when the light carries no readable colour. */
|
|
191
|
+
color: string;
|
|
192
|
+
/** Absent when the light reports no finite intensity. Never an unmeasured zero. */
|
|
193
|
+
intensity?: number;
|
|
194
|
+
/** The light's constructor name — `DirectionalLight`, `AmbientLight`, and so on. */
|
|
195
|
+
type: string;
|
|
196
|
+
visible: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The scene's distance fade, if it has one. Absent means no fog, never "fog at zero".
|
|
200
|
+
*/
|
|
201
|
+
interface IPlaytestFogObservation {
|
|
202
|
+
color: string;
|
|
203
|
+
/** Present for `FogExp2`. */
|
|
204
|
+
density?: number;
|
|
205
|
+
/** Present for linear `Fog`. */
|
|
206
|
+
far?: number;
|
|
207
|
+
/** Present for linear `Fog`. */
|
|
208
|
+
near?: number;
|
|
209
|
+
type: "exponential" | "linear";
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Where the camera is and what it can see, which is the framing an entity transform cannot say.
|
|
213
|
+
*/
|
|
214
|
+
interface IPlaytestCameraObservation {
|
|
215
|
+
/** Absent on a bare `Camera`, which carries no clip planes. */
|
|
216
|
+
far?: number;
|
|
217
|
+
/** Unit world-space forward vector. */
|
|
218
|
+
forward: [number, number, number];
|
|
219
|
+
/** Vertical field of view in degrees. Absent for an orthographic camera. */
|
|
220
|
+
fov?: number;
|
|
221
|
+
/** Absent on a bare `Camera`, which carries no clip planes. */
|
|
222
|
+
near?: number;
|
|
223
|
+
position: [number, number, number];
|
|
224
|
+
/** The camera's constructor name. */
|
|
225
|
+
type: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The room the game is being played in — lights, materials, fog, background and camera framing.
|
|
229
|
+
*
|
|
230
|
+
* `doctor --url` used to list all of this under "not observed", which meant an agent debugging a
|
|
231
|
+
* washed-out or black frame had no instrument at all and went to screenshots. Round 9's visual
|
|
232
|
+
* column was lost to a fog whose far plane sat in front of the sky dome; nothing in the harness
|
|
233
|
+
* could say so. Counts and names only: every value here is read off the scene, and none of it
|
|
234
|
+
* decides how anything looks.
|
|
235
|
+
*/
|
|
236
|
+
interface IPlaytestSceneObservation {
|
|
237
|
+
/** `none`, `color:#rrggbb`, or the background object's constructor name. */
|
|
238
|
+
background: string;
|
|
239
|
+
camera: IPlaytestCameraObservation;
|
|
240
|
+
fog?: IPlaytestFogObservation;
|
|
241
|
+
lights: IPlaytestLightObservation[];
|
|
242
|
+
/**
|
|
243
|
+
* How many materials of each constructor name are mounted in the scene, counted per distinct
|
|
244
|
+
* material rather than per mesh.
|
|
245
|
+
*/
|
|
246
|
+
materials: Record<string, number>;
|
|
247
|
+
/** Objects the walk visited. */
|
|
248
|
+
objects: number;
|
|
249
|
+
/**
|
|
250
|
+
* True when the walk stopped at its cap, so every count above is a floor rather than a total.
|
|
251
|
+
* Reported instead of silently truncating, because a partial count read as a total is the
|
|
252
|
+
* confident-number-with-nothing-behind-it this harness exists to prevent.
|
|
253
|
+
*/
|
|
254
|
+
truncated: boolean;
|
|
255
|
+
/** World-space extent of everything the walk visited, or absent when the scene is empty. */
|
|
256
|
+
worldExtent?: {
|
|
257
|
+
max: [number, number, number];
|
|
258
|
+
min: [number, number, number];
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* One node of the scene graph, read as numbers instead of looked at.
|
|
263
|
+
*
|
|
264
|
+
* `scene.observe` reports the room as counts — how many lights, how many materials of each
|
|
265
|
+
* constructor. That answers "is anything lit" and cannot answer "is the crate on screen", "did
|
|
266
|
+
* the seal plate load its texture", "is this mesh inside the wall". Those are the questions an
|
|
267
|
+
* agent otherwise takes a screenshot for, and a screenshot cannot say why. Every field here is
|
|
268
|
+
* read off the object the renderer will draw; nothing is inferred and nothing decides how the
|
|
269
|
+
* game looks.
|
|
270
|
+
*/
|
|
271
|
+
interface IPlaytestSceneNodeObservation {
|
|
272
|
+
/** Clips mounted on this node's mixer, and which of them are advancing. */
|
|
273
|
+
animation?: {
|
|
274
|
+
clips: string[];
|
|
275
|
+
playing: string[];
|
|
276
|
+
};
|
|
277
|
+
/** World-space axis-aligned bounds, absent when the node encloses nothing. */
|
|
278
|
+
bounds?: {
|
|
279
|
+
max: [number, number, number];
|
|
280
|
+
min: [number, number, number];
|
|
281
|
+
};
|
|
282
|
+
geometry?: {
|
|
283
|
+
attributes: string[];
|
|
284
|
+
triangles: number;
|
|
285
|
+
vertices: number;
|
|
286
|
+
};
|
|
287
|
+
/** Whether the node's world bounds intersect the active camera's frustum. */
|
|
288
|
+
inFrustum?: boolean;
|
|
289
|
+
/** Instance count for an InstancedMesh or BatchedMesh. */
|
|
290
|
+
instances?: number;
|
|
291
|
+
materials?: IPlaytestSceneNodeMaterial[];
|
|
292
|
+
name: string;
|
|
293
|
+
/** Slash-joined path from the scene root, the same shape `entity.observe` reports. */
|
|
294
|
+
path: string;
|
|
295
|
+
position: [number, number, number];
|
|
296
|
+
scale: [number, number, number];
|
|
297
|
+
skinned?: {
|
|
298
|
+
bones: number;
|
|
299
|
+
};
|
|
300
|
+
type: string;
|
|
301
|
+
/** The node's own visible flag. */
|
|
302
|
+
visible: boolean;
|
|
303
|
+
/** The node's flag and every ancestor's — what the renderer actually acts on. */
|
|
304
|
+
visibleInTree: boolean;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* A material as mounted, including the two facts that make a mesh render black while every
|
|
308
|
+
* count above it reads healthy: a map slot bound to a texture that never loaded, and a lit
|
|
309
|
+
* material in a scene with nothing to light it.
|
|
310
|
+
*/
|
|
311
|
+
interface IPlaytestSceneNodeMaterial {
|
|
312
|
+
color?: string;
|
|
313
|
+
emissive?: string;
|
|
314
|
+
/** True when the material reads scene lighting, so an unlit scene renders it black. */
|
|
315
|
+
lit: boolean;
|
|
316
|
+
/** Map slots bound to a texture, by property name. */
|
|
317
|
+
maps: string[];
|
|
318
|
+
/** Bound slots whose texture carries no image — the black-texture case a count cannot show. */
|
|
319
|
+
mapsUnloaded: string[];
|
|
320
|
+
metalness?: number;
|
|
321
|
+
name: string;
|
|
322
|
+
opacity?: number;
|
|
323
|
+
roughness?: number;
|
|
324
|
+
transparent: boolean;
|
|
325
|
+
type: string;
|
|
326
|
+
visible: boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Which nodes to report. An absent field does not filter; every present field must match.
|
|
330
|
+
* A selector that matches nothing is reported as `matched: 0`, never as an empty success.
|
|
331
|
+
*/
|
|
332
|
+
interface IPlaytestSceneNodeSelector {
|
|
333
|
+
/** Ceiling on reported nodes. The walk still counts every match, so `matched` is a total. */
|
|
334
|
+
limit?: number;
|
|
335
|
+
/** Exact `Object3D.name`. */
|
|
336
|
+
name?: string;
|
|
337
|
+
/** Case-insensitive substring of `Object3D.name`. */
|
|
338
|
+
nameContains?: string;
|
|
339
|
+
/** Case-insensitive substring of the slash-joined path. */
|
|
340
|
+
pathContains?: string;
|
|
341
|
+
/** Exact `Object3D.type` — `Mesh`, `SkinnedMesh`, `PointLight`, `Group`. */
|
|
342
|
+
type?: string;
|
|
343
|
+
}
|
|
344
|
+
interface IPlaytestSceneNodesObservation {
|
|
345
|
+
/** Total nodes the selector matched, before `limit` was applied. */
|
|
346
|
+
matched: number;
|
|
347
|
+
nodes: IPlaytestSceneNodeObservation[];
|
|
348
|
+
selector: IPlaytestSceneNodeSelector;
|
|
349
|
+
/** True when `limit` or the walk cap cut the list, so `nodes` is a sample and not the set. */
|
|
350
|
+
truncated: boolean;
|
|
351
|
+
}
|
|
352
|
+
interface IPlaytestContactObservation {
|
|
353
|
+
entity: string;
|
|
354
|
+
kind: string;
|
|
355
|
+
/**
|
|
356
|
+
* The tick the contact happened on, when the producer drains its contact log per tick. Absent
|
|
357
|
+
* from a producer that drains only at sample time, and an assertion that needs it fails closed
|
|
358
|
+
* rather than falling back to step granularity — the two are not the same measurement.
|
|
359
|
+
*/
|
|
360
|
+
tick?: number;
|
|
361
|
+
with: string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* A published value changing, and the tick it changed on.
|
|
365
|
+
*
|
|
366
|
+
* Without this a run can say *a contact happened* and *the state reads `won`*, and nothing relates
|
|
367
|
+
* them. Comparing at step boundaries cannot separate a win that arrived with the contact from one
|
|
368
|
+
* that arrived 199 ticks later in the same step — which is the signature of a timer or a distance
|
|
369
|
+
* check that happens to land near a contact.
|
|
370
|
+
*/
|
|
371
|
+
interface IPlaytestTransitionObservation {
|
|
372
|
+
from: JsonPrimitive;
|
|
373
|
+
/** `states.<entity>` for a registered entity, or `state.<field>` for a published field. */
|
|
374
|
+
path: string;
|
|
375
|
+
tick: number;
|
|
376
|
+
to: JsonPrimitive;
|
|
377
|
+
}
|
|
378
|
+
interface IPlaytestTagObservation {
|
|
379
|
+
count: number;
|
|
380
|
+
}
|
|
381
|
+
interface IPlaytestPerformanceObservation {
|
|
382
|
+
drawCalls?: number;
|
|
383
|
+
triangles?: number;
|
|
384
|
+
}
|
|
385
|
+
interface IPlaytestRenderChainObservation {
|
|
386
|
+
contributions?: Array<{
|
|
387
|
+
graphOutputChanged: boolean;
|
|
388
|
+
name: string;
|
|
389
|
+
}>;
|
|
390
|
+
dropped: Array<{
|
|
391
|
+
name: string;
|
|
392
|
+
reason: string;
|
|
393
|
+
}>;
|
|
394
|
+
requested: string[];
|
|
395
|
+
source: "pinned" | "auto";
|
|
396
|
+
stages: string[];
|
|
397
|
+
tier: "high" | "medium" | "low" | "off";
|
|
398
|
+
velocity: {
|
|
399
|
+
measurementFrame?: number;
|
|
400
|
+
provisioned: boolean;
|
|
401
|
+
required: boolean;
|
|
402
|
+
rejectionFraction?: number;
|
|
403
|
+
source: "mrt" | "per-object" | null;
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
interface IPlaytestWorldRuntimeObservation {
|
|
407
|
+
agent: string;
|
|
408
|
+
core: string;
|
|
409
|
+
randomState: number;
|
|
410
|
+
rapier: string | null;
|
|
411
|
+
step: number;
|
|
412
|
+
}
|
|
413
|
+
interface IPlaytestWorldObservation {
|
|
414
|
+
runtime?: IPlaytestWorldRuntimeObservation;
|
|
415
|
+
seed: number | null;
|
|
416
|
+
}
|
|
417
|
+
interface IPlaytestGameplayObservation {
|
|
418
|
+
animation: Record<string, IPlaytestAnimationObservation>;
|
|
419
|
+
contacts?: IPlaytestContactObservation[];
|
|
420
|
+
states: Record<string, string>;
|
|
421
|
+
tags?: Record<string, IPlaytestTagObservation>;
|
|
422
|
+
/** Tick-stamped changes to published values. Absent from a run whose loop never ticked. */
|
|
423
|
+
transitions?: IPlaytestTransitionObservation[];
|
|
424
|
+
world?: IPlaytestWorldObservation;
|
|
425
|
+
}
|
|
426
|
+
/** Per-render samples shared by the browser and native playtest bridges. */
|
|
427
|
+
/**
|
|
428
|
+
* The named parts of one presented frame. Closed on purpose: a budget naming anything else is a
|
|
429
|
+
* typo, and a typo that evaluated no bound would report green on a ceiling nobody checked.
|
|
430
|
+
*/
|
|
431
|
+
declare const PLAYTEST_FRAME_BUDGET_PHASES: readonly ["hostGap", "overlay", "render", "residual", "update"];
|
|
432
|
+
type PlaytestFramePhase = (typeof PLAYTEST_FRAME_BUDGET_PHASES)[number];
|
|
433
|
+
/**
|
|
434
|
+
* Where a frame's milliseconds went, by phase. Every phase optional so a producer that measures
|
|
435
|
+
* only some of them is describable; a ceiling on a phase the producer omitted fails naming the
|
|
436
|
+
* missing evidence rather than passing on nothing.
|
|
437
|
+
*/
|
|
438
|
+
type PlaytestFramePhaseSample = Partial<Record<PlaytestFramePhase, number>>;
|
|
439
|
+
interface IPlaytestRuntimeDiagnosticsSample {
|
|
440
|
+
drawCalls?: number;
|
|
441
|
+
frameMs: number;
|
|
442
|
+
/**
|
|
443
|
+
* Supplied by an engine that measures its own frame — `@threenative/core` fills it from the
|
|
444
|
+
* frame budget. Absent for a plain Three.js bridge.
|
|
445
|
+
*/
|
|
446
|
+
phases?: PlaytestFramePhaseSample;
|
|
447
|
+
triangles?: number;
|
|
448
|
+
}
|
|
449
|
+
interface IPlaytestObservationSnapshot {
|
|
450
|
+
clock: {
|
|
451
|
+
mode: PlaytestClockMode;
|
|
452
|
+
tick?: number;
|
|
453
|
+
timeMs?: number;
|
|
454
|
+
};
|
|
455
|
+
diagnostics?: JsonValue[];
|
|
456
|
+
components?: Record<string, Record<string, JsonValue>>;
|
|
457
|
+
entities?: IPlaytestEntityObservation[];
|
|
458
|
+
gameplay?: IPlaytestGameplayObservation;
|
|
459
|
+
physicsDebugSeries?: Array<{
|
|
460
|
+
label: string;
|
|
461
|
+
snapshot: JsonValue;
|
|
462
|
+
tick: number;
|
|
463
|
+
}>;
|
|
464
|
+
performance?: IPlaytestPerformanceObservation;
|
|
465
|
+
/** Bounded shader/pipeline creation capture supplied by the engine when diagnostics are enabled. */
|
|
466
|
+
pipelineCensus?: JsonValue;
|
|
467
|
+
renderChain?: IPlaytestRenderChainObservation;
|
|
468
|
+
runtimeDiagnosticsSeries?: IPlaytestRuntimeDiagnosticsSample[];
|
|
469
|
+
resources?: Record<string, JsonValue>;
|
|
470
|
+
scene?: IPlaytestSceneObservation;
|
|
471
|
+
sceneNodes?: IPlaytestSceneNodesObservation[];
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* What the bridge says it actually applied, as opposed to what the runner asked for.
|
|
475
|
+
*
|
|
476
|
+
* The setup contract used to rest entirely on the bridge throwing: `applied` was assigned the
|
|
477
|
+
* *requested* records, so a bridge that partially applied and resolved reported full application
|
|
478
|
+
* and `applied === requested` always. A bridge that returns this instead lets the report show the
|
|
479
|
+
* difference, and lets the runner fail on a request nobody confirmed.
|
|
480
|
+
*
|
|
481
|
+
* `entities` and `resources` are the ids the bridge applied. Returning nothing at all is still
|
|
482
|
+
* accepted — the runner then records that the evidence is the throw contract and not a read-back,
|
|
483
|
+
* rather than claiming a confirmation it never received.
|
|
484
|
+
*/
|
|
485
|
+
interface IPlaytestSetupConfirmation {
|
|
486
|
+
entities?: readonly string[];
|
|
487
|
+
resources?: readonly string[];
|
|
488
|
+
}
|
|
489
|
+
interface IPlaytestAdvanceResult {
|
|
490
|
+
clock: IPlaytestObservationSnapshot["clock"];
|
|
491
|
+
ticks: number;
|
|
492
|
+
}
|
|
493
|
+
interface IPlaytestBridgeV1 {
|
|
494
|
+
advance?(ticks: number): Promise<IPlaytestAdvanceResult>;
|
|
495
|
+
applySetup?(request: IPlaytestSetupRequest): Promise<IPlaytestSetupConfirmation | void>;
|
|
496
|
+
describe(): IPlaytestBridgeDescription | Promise<IPlaytestBridgeDescription>;
|
|
497
|
+
drainEvents?(limit?: number): Promise<JsonValue[]>;
|
|
498
|
+
focus?(): boolean | Promise<boolean>;
|
|
499
|
+
ready(): IPlaytestBridgeReady | Promise<IPlaytestBridgeReady>;
|
|
500
|
+
sample(request: IPlaytestSampleRequest): IPlaytestObservationSnapshot | Promise<IPlaytestObservationSnapshot>;
|
|
501
|
+
}
|
|
502
|
+
/** Request/response envelope used by the host-neutral device transport. */
|
|
503
|
+
interface IPlaytestDeviceRequest {
|
|
504
|
+
argument?: JsonValue;
|
|
505
|
+
id: string;
|
|
506
|
+
method: string;
|
|
507
|
+
}
|
|
508
|
+
interface IPlaytestDeviceResponse {
|
|
509
|
+
error?: {
|
|
510
|
+
message: string;
|
|
511
|
+
};
|
|
512
|
+
id: string;
|
|
513
|
+
result?: JsonValue;
|
|
514
|
+
}
|
|
515
|
+
interface IPlaytestBridgeHost {
|
|
516
|
+
[PLAYTEST_BRIDGE_GLOBAL]?: IPlaytestBridgeV1;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Measure a payload's wire size in bytes.
|
|
520
|
+
* @situation check a runtime observation against the protocol payload limit before sampling
|
|
521
|
+
* @example const bytes = jsonByteLength(observation);
|
|
522
|
+
*/
|
|
523
|
+
declare function jsonByteLength(value: JsonValue): number;
|
|
524
|
+
/**
|
|
525
|
+
* Reject any value that would not survive JSON serialization.
|
|
526
|
+
* @situation validate entity components and gameplay observations before crossing the bridge
|
|
527
|
+
* @constraint throws instead of silently dropping the offending field
|
|
528
|
+
* @example assertJsonSafe(snapshot, "$.components");
|
|
529
|
+
*/
|
|
530
|
+
declare function assertJsonSafe(value: unknown, path?: string): asserts value is JsonValue;
|
|
531
|
+
|
|
532
|
+
export { type IPlaytestAdvanceResult, type IPlaytestAnimationObservation, type IPlaytestBridgeDescription, type IPlaytestBridgeHost, type IPlaytestBridgeReady, type IPlaytestBridgeV1, type IPlaytestCameraObservation, type IPlaytestContactObservation, type IPlaytestDeviceRequest, type IPlaytestDeviceResponse, type IPlaytestEntityObservation, type IPlaytestEntityTransform, type IPlaytestFogObservation, type IPlaytestGameplayObservation, type IPlaytestLightObservation, type IPlaytestObservationSnapshot, type IPlaytestPerformanceObservation, type IPlaytestRenderChainObservation, type IPlaytestRuntimeDiagnosticsSample, type IPlaytestSampleRequest, type IPlaytestSceneNodeMaterial, type IPlaytestSceneNodeObservation, type IPlaytestSceneNodeSelector, type IPlaytestSceneNodesObservation, type IPlaytestSceneObservation, type IPlaytestSetupConfirmation, type IPlaytestSetupRequest, type IPlaytestStartupObservation, type IPlaytestStartupTimeline, type IPlaytestStrideObservation, type IPlaytestTagObservation, type IPlaytestTransitionObservation, type IPlaytestWorldObservation, type IPlaytestWorldRuntimeObservation, type JsonPrimitive, type JsonValue, PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_FRAME_BUDGET_PHASES, PLAYTEST_FROZEN_MARKER, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, type PlaytestClockMode, type PlaytestFramePhase, type PlaytestFramePhaseSample, assertJsonSafe, jsonByteLength };
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// src/protocol.ts
|
|
3
|
+
var PLAYTEST_BRIDGE_GLOBAL = "__THREENATIVE_PLAYTEST_BRIDGE__";
|
|
4
|
+
var PLAYTEST_PROTOCOL_VERSION = 1;
|
|
5
|
+
var PLAYTEST_FROZEN_MARKER = "__threenativeFrozen";
|
|
6
|
+
var PLAYTEST_ADVANCE_TICK_BUDGET_MS = 250;
|
|
7
|
+
var PLAYTEST_STARTUP_COMPILE_BUDGET_MS = 15e3;
|
|
8
|
+
var PLAYTEST_PROTOCOL_LIMITS = {
|
|
9
|
+
maxEntitiesPerSample: 100,
|
|
10
|
+
maxEventsPerDrain: 1e3,
|
|
11
|
+
maxPayloadBytes: 1e6,
|
|
12
|
+
operationTimeoutMs: 5e3
|
|
13
|
+
};
|
|
14
|
+
var PLAYTEST_STARTUP_READY_TIMEOUT_MS = 18e4;
|
|
15
|
+
var PLAYTEST_FRAME_BUDGET_PHASES = ["hostGap", "overlay", "render", "residual", "update"];
|
|
16
|
+
function jsonByteLength(value) {
|
|
17
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
18
|
+
}
|
|
19
|
+
function assertJsonSafe(value, path = "$") {
|
|
20
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === "number") {
|
|
24
|
+
if (Number.isFinite(value)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
value.forEach((item, index) => assertJsonSafe(item, `${path}[${index}]`));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "object") {
|
|
34
|
+
for (const [key, item] of Object.entries(value)) {
|
|
35
|
+
assertJsonSafe(item, `${path}.${key}`);
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw new TypeError(`${path} must be JSON-safe.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { PLAYTEST_ADVANCE_TICK_BUDGET_MS, PLAYTEST_BRIDGE_GLOBAL, PLAYTEST_FRAME_BUDGET_PHASES, PLAYTEST_FROZEN_MARKER, PLAYTEST_PROTOCOL_LIMITS, PLAYTEST_PROTOCOL_VERSION, PLAYTEST_STARTUP_COMPILE_BUDGET_MS, PLAYTEST_STARTUP_READY_TIMEOUT_MS, assertJsonSafe, jsonByteLength };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { I as IStandalonePlaytestConfig, a as IStandalonePlaytestReport } from '../shared-BGwYk5HG.js';
|
|
2
|
+
import '../protocol.js';
|
|
3
|
+
import '../diagnostics-f8464bJw.js';
|
|
4
|
+
|
|
5
|
+
interface IRunnerDiagnostic {
|
|
6
|
+
code: string;
|
|
7
|
+
fix: {
|
|
8
|
+
instruction: string;
|
|
9
|
+
};
|
|
10
|
+
message: string;
|
|
11
|
+
severity: "error";
|
|
12
|
+
}
|
|
13
|
+
type IConfiguredPlaytestRunner = (config: IStandalonePlaytestConfig) => Promise<IStandalonePlaytestReport>;
|
|
14
|
+
interface IPlaytestTargetRunners {
|
|
15
|
+
android: IConfiguredPlaytestRunner;
|
|
16
|
+
androidBrowser?: IConfiguredPlaytestRunner;
|
|
17
|
+
browser: IConfiguredPlaytestRunner;
|
|
18
|
+
desktop: IConfiguredPlaytestRunner;
|
|
19
|
+
ios: IConfiguredPlaytestRunner;
|
|
20
|
+
}
|
|
21
|
+
declare function runConfiguredPlaytest(config: IStandalonePlaytestConfig, runners?: IPlaytestTargetRunners): Promise<IStandalonePlaytestReport>;
|
|
22
|
+
declare function exitCodeForReport(report: {
|
|
23
|
+
assertionResults?: readonly unknown[];
|
|
24
|
+
diagnostics?: ReadonlyArray<{
|
|
25
|
+
code?: string;
|
|
26
|
+
}>;
|
|
27
|
+
pass: boolean;
|
|
28
|
+
}): 0 | 1 | 2;
|
|
29
|
+
declare function classifyRunnerError(error: unknown, options?: {
|
|
30
|
+
cwd?: string;
|
|
31
|
+
scenarioPath?: string;
|
|
32
|
+
}): IRunnerDiagnostic;
|
|
33
|
+
/**
|
|
34
|
+
* `doctor` answers "can this machine run a playtest", `doctor --url` additionally answers "and
|
|
35
|
+
* what is actually in the game running there" — the question asked while staring at a screenshot
|
|
36
|
+
* that looks wrong — and `doctor --device` answers "is the phone cool enough to measure on",
|
|
37
|
+
* which `observations.deviceMetrics` can only answer once the run is already spent.
|
|
38
|
+
*/
|
|
39
|
+
interface IDoctorArgs {
|
|
40
|
+
readonly browserArgs: readonly string[];
|
|
41
|
+
readonly capture?: string;
|
|
42
|
+
readonly device: string | undefined;
|
|
43
|
+
readonly text: boolean;
|
|
44
|
+
readonly url: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
declare function parseDoctorArgs(argv: readonly string[]): IDoctorArgs;
|
|
47
|
+
/** Extra arguments extend the WebGPU recipe; replacing it would silently reintroduce SwiftShader. */
|
|
48
|
+
declare function doctorBrowserArgs(extra: readonly string[]): string[];
|
|
49
|
+
declare function doctorCommand(argv: readonly string[]): Promise<number>;
|
|
50
|
+
declare function main(argv?: readonly string[]): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Wait for stdout to reach the far end before exiting, bounded.
|
|
53
|
+
*
|
|
54
|
+
* Returns true when the stream drained, false when the deadline passed with bytes still pending —
|
|
55
|
+
* the caller exits either way, because a stalled reader must not outrank the exit.
|
|
56
|
+
*/
|
|
57
|
+
interface IDrainableStream {
|
|
58
|
+
readonly writableLength: number;
|
|
59
|
+
write(chunk: string, callback: () => void): unknown;
|
|
60
|
+
}
|
|
61
|
+
declare function flushStdout(timeoutMs?: number, stream?: IDrainableStream): Promise<boolean>;
|
|
62
|
+
|
|
63
|
+
export { type IConfiguredPlaytestRunner, type IDoctorArgs, type IDrainableStream, type IPlaytestTargetRunners, type IRunnerDiagnostic, classifyRunnerError, doctorBrowserArgs, doctorCommand, exitCodeForReport, flushStdout, main, parseDoctorArgs, runConfiguredPlaytest };
|