@threenative/playtest 0.3.2 → 0.3.4

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,5 +1,5 @@
1
+ import { u as IPlaytestPerformanceAssertion, c as IPlaytestReport, w as IPlaytestProtocolDiagnostic, p as IPlaytestDiagnosticsPolicy, d as IPlaytestAssertionResult } from './diagnostics-BXhYI2sc.js';
1
2
  import { IPlaytestObservationSnapshot } from './protocol.js';
2
- import { c as IPlaytestReport, w as IPlaytestProtocolDiagnostic, p as IPlaytestDiagnosticsPolicy, d as IPlaytestAssertionResult } from './diagnostics-f8464bJw.js';
3
3
 
4
4
  interface IPlaytestServerConfig {
5
5
  command: string;
@@ -23,7 +23,18 @@ interface IStandalonePlaytestConfig {
23
23
  adbPath?: string;
24
24
  /** @see IAndroidDriverOptions.touchRotation */
25
25
  touchRotation?: number;
26
+ /**
27
+ * The built artifact this run is about to exercise, for `--build-report` to hash. Set by
28
+ * `--artifact`; desktop and iOS already name theirs, so the flag is refused there.
29
+ */
30
+ artifactPath?: string;
26
31
  artifactDirectory: string;
32
+ /**
33
+ * The `<artifact>.build-report.json` a `threenative build` published beside the artifact, carrying
34
+ * the profile's `performanceBudget`. Resolved and proved against the artifact under test before
35
+ * anything launches; its budget is merged into every scenario's `assert.performance`.
36
+ */
37
+ buildReportPath?: string;
27
38
  /**
28
39
  * Capture the run's `before.png`/`after.png` artifact frames. Default true. A scenario that
29
40
  * asserts on a frame still captures one — this only drops the convenience captures every run
@@ -31,6 +42,8 @@ interface IStandalonePlaytestConfig {
31
42
  */
32
43
  captureArtifactScreenshots?: boolean;
33
44
  browserArgs?: readonly string[];
45
+ /** Write a Chrome DevTools `.cpuprofile` for this run (browser and desktop targets). */
46
+ cpuProfilePath?: string;
34
47
  device?: string;
35
48
  desktop?: {
36
49
  executable: string;
@@ -43,7 +56,13 @@ interface IStandalonePlaytestConfig {
43
56
  bundleId: string;
44
57
  transport: "device" | "simulator";
45
58
  };
59
+ judgeMarkerUrl?: string;
46
60
  mailboxRoot?: string;
61
+ /**
62
+ * The performance ceilings the build report declared, already proved against the artifact under
63
+ * test. Merged into each scenario's `assert.performance`; absent when no report was passed.
64
+ */
65
+ performanceBudget?: IPlaytestPerformanceAssertion;
47
66
  port?: number;
48
67
  projectPath: string;
49
68
  scenarioPath: string;
@@ -93,11 +112,21 @@ declare const PLAYTEST_FLAGS: {
93
112
  readonly summary: "built iOS .app bundle";
94
113
  readonly takesValue: true;
95
114
  };
115
+ readonly "--artifact": {
116
+ readonly default: "none (browser and android: with --build-report)";
117
+ readonly summary: "the built artifact this run exercises, hashed to prove the build report describes it";
118
+ readonly takesValue: true;
119
+ };
96
120
  readonly "--artifacts": {
97
121
  readonly default: "artifacts/playtest";
98
122
  readonly summary: "artifact output directory";
99
123
  readonly takesValue: true;
100
124
  };
125
+ readonly "--build-report": {
126
+ readonly default: "none";
127
+ readonly summary: "the <artifact>.build-report.json threenative build published; its performanceBudget bounds every scenario, and a stale or foreign report refuses the run";
128
+ readonly takesValue: true;
129
+ };
101
130
  readonly "--no-screenshots": {
102
131
  readonly default: "false";
103
132
  readonly summary: "skip the before/after artifact frames; scenarios that assert on a frame still capture one";
@@ -115,6 +144,11 @@ declare const PLAYTEST_FLAGS: {
115
144
  readonly summary: "named browser recipe (webgpu)";
116
145
  readonly takesValue: true;
117
146
  };
147
+ readonly "--cpu-prof": {
148
+ readonly default: "none";
149
+ readonly summary: "write a Chrome DevTools .cpuprofile for this run (browser and desktop targets)";
150
+ readonly takesValue: true;
151
+ };
118
152
  readonly "--bundle-id": {
119
153
  readonly default: "dev.threenative.runtime";
120
154
  readonly summary: "iOS application bundle identifier";
@@ -140,7 +174,13 @@ declare const PLAYTEST_FLAGS: {
140
174
  readonly summary: "show the browser window";
141
175
  readonly takesValue: false;
142
176
  };
177
+ readonly "--judge-marker-url": {
178
+ readonly default: "none";
179
+ readonly summary: "judge-owned loopback marker URL whose POST failures are not network errors";
180
+ readonly takesValue: true;
181
+ };
143
182
  readonly "--host-arg": {
183
+ readonly allowDashValue: true;
144
184
  readonly default: "none";
145
185
  readonly repeatable: true;
146
186
  readonly summary: "argument passed to the native desktop host, repeatable";
@@ -244,10 +284,11 @@ interface IStandalonePlaytestReport extends IPlaytestReport {
244
284
  /**
245
285
  * What the run waited for before it observed anything, and what it settled on.
246
286
  *
247
- * `rule: "compile-settled"` means the sustained in-budget frame window was not required,
248
- * because the operator declared a software adapter. A pass from such a run is not a smoothness
249
- * measurement and must not be read as one, so the report says which rule applied rather than
250
- * leaving a reader to assume the stricter one.
287
+ * `rule: "compile-settled"` means the sustained in-budget frame window was not required,
288
+ * because the operator declared a software adapter: the wait still ran to full readiness, but
289
+ * a CPU rasteriser reaches it on the bounded window rather than on five sustained frames. A
290
+ * pass from such a run is not a smoothness measurement and must not be read as one, so the
291
+ * report says which rule applied rather than leaving a reader to assume the stricter one.
251
292
  */
252
293
  startup?: {
253
294
  compileSettled?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { Camera, Scene, Object3D, Vector2 } from 'three';
2
- import { IPlaytestSampleRequest, IPlaytestObservationSnapshot, IPlaytestBridgeV1, JsonValue, IPlaytestGameplayObservation, IPlaytestRuntimeDiagnosticsSample, IPlaytestRenderChainObservation, IPlaytestStartupObservation, IPlaytestSceneObservation } from '../protocol.js';
2
+ import { IPlaytestSampleRequest, IPlaytestObservationSnapshot, IPlaytestBridgeV1, PlaytestClockMode, JsonValue, IPlaytestGameplayObservation, IPlaytestRuntimeDiagnosticsSample, IPlaytestRenderChainObservation, IPlaytestStartupObservation, IPlaytestSceneObservation } from '../protocol.js';
3
3
 
4
4
  type RenderAdvisorOwner = "framework" | "generated-src";
5
5
  type RenderAdvisorSeverity = "info" | "warning";
@@ -149,6 +149,15 @@ interface IThreePlaytestResources {
149
149
  }
150
150
  interface IThreePlaytestBridgeOptions {
151
151
  camera: Camera;
152
+ /**
153
+ * The clock this producer is actually running on, reported verbatim in every observation.
154
+ *
155
+ * `wall-clock` is a producer that lets its own frame pump move the simulation, which is the only
156
+ * way to observe a game *playing*: on that clock `advance` delivers the span of wall time the tick
157
+ * count names and reports the ticks that clock really ran, instead of stepping the loop itself.
158
+ * A production profile asks for it; a deterministic scenario never does.
159
+ */
160
+ clockMode?: PlaytestClockMode;
152
161
  components?: () => Record<string, Record<string, JsonValue>>;
153
162
  /**
154
163
  * Runtime diagnostics for the current frame.
@@ -10,7 +10,7 @@ var SPRITE_FLOOR = 32;
10
10
  var POINT_OBJECT_FLOOR = 16;
11
11
  var VERIFIED_EXAMPLE_PATHS = {
12
12
  gpuParticles: "examples/abyss-framework/src/scenes/Abyss.ts",
13
- hudInstancing: "packages/create-threenative/templates/minimal/src/render/hud.ts",
13
+ hudInstancing: "packages/create-threenative/templates/rts/src/render/army.ts",
14
14
  materialSharing: "packages/create-threenative/templates/starter/src/render/materials.ts",
15
15
  staticMerge: "examples/native-cpu-load-test/src/main.ts"
16
16
  };
@@ -824,14 +824,21 @@ function sampleThreeObservations(input, request) {
824
824
  return {
825
825
  clock: {
826
826
  mode: input.clockMode,
827
- ...input.tick === void 0 ? { timeMs: performance.now() } : { tick: input.tick }
827
+ ...input.tick === void 0 ? { timeMs: performance.now() } : { tick: input.tick },
828
+ // A live run is measured in seconds: the runner reads `timeMs` for any mode that is not
829
+ // fixed-step, so a wall-clock producer that reported only a tick would leave every
830
+ // seconds-based rate unmeasured rather than measured.
831
+ ...input.clockMode === "wall-clock" ? { timeMs: performance.now() } : {}
828
832
  },
829
833
  ...input.diagnostics === void 0 ? {} : { diagnostics: input.diagnostics() },
830
834
  entities,
831
835
  ...input.gameplay === void 0 ? {} : { gameplay: input.gameplay() },
832
836
  ...renderPerformance === void 0 ? {} : { performance: renderPerformance },
833
837
  ...renderChain === void 0 ? {} : { renderChain },
834
- ...input.runtimeDiagnosticsSeries === void 0 ? {} : { runtimeDiagnosticsSeries: input.runtimeDiagnosticsSeries().map((sample) => ({ ...sample })) },
838
+ // The series is a window of up to a thousand samples, so an unconditional copy made every
839
+ // device sample payload grow past the protocol's byte ceiling once a paced run actually
840
+ // rendered that many frames. Answer it only when the request asks, like every other field.
841
+ ...input.runtimeDiagnosticsSeries === void 0 || request.include?.includes("runtimeDiagnosticsSeries") !== true ? {} : { runtimeDiagnosticsSeries: input.runtimeDiagnosticsSeries().map((sample) => ({ ...sample })) },
835
842
  ...input.resources === void 0 ? {} : { resources: input.resources() },
836
843
  scene: observeSceneResources(input.scene, input.camera),
837
844
  // Only walked when a scenario asks. The node walk reads geometry, materials and world
@@ -1216,6 +1223,7 @@ function installThreePlaytestBridge(options) {
1216
1223
  if (options.physics !== void 0 && options.tick === void 0)
1217
1224
  throw new Error("A physics provider requires the authoritative tick provider, and therefore fixedStep.");
1218
1225
  const recorder = options.physics === void 0 ? void 0 : new ThreePlaytestPhysicsRecorder(options.physics);
1226
+ const clockMode = () => options.clockMode ?? (options.fixedStep === void 0 ? "render-frame" : "fixed-step");
1219
1227
  const host = globalThis;
1220
1228
  const previous = host[PLAYTEST_BRIDGE_GLOBAL];
1221
1229
  const registry = new ThreePlaytestEntityRegistry();
@@ -1250,9 +1258,9 @@ function installThreePlaytestBridge(options) {
1250
1258
  await options.fixedStep(ticks);
1251
1259
  const tick = options.tick();
1252
1260
  const advanced = tick - startTick;
1253
- if (advanced !== ticks)
1254
- throw new Error(`fixedStep advanced ${advanced} actual ticks; expected ${ticks}.`);
1255
- return { clock: { mode: "fixed-step", tick }, ticks: advanced };
1261
+ if (clockMode() === "wall-clock" ? advanced < 1 : advanced !== ticks)
1262
+ throw new Error(clockMode() === "wall-clock" ? `wall-clock advance moved no tick in ${ticks} step(s) of wall time; the host presented no frame.` : `fixedStep advanced ${advanced} actual ticks; expected ${ticks}.`);
1263
+ return { clock: { mode: clockMode(), tick }, ticks: advanced };
1256
1264
  }
1257
1265
  },
1258
1266
  applySetup: async (request) => {
@@ -1283,7 +1291,7 @@ function installThreePlaytestBridge(options) {
1283
1291
  syncEntities(registry, options.entities);
1284
1292
  const snapshot = sampleThreeObservations({
1285
1293
  camera: options.camera,
1286
- clockMode: options.fixedStep === void 0 ? "render-frame" : "fixed-step",
1294
+ clockMode: clockMode(),
1287
1295
  diagnostics: options.diagnostics,
1288
1296
  gameplay: options.gameplay,
1289
1297
  runtimeDiagnosticsSeries: options.runtimeDiagnosticsSeries,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threenative/playtest",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "license": "MIT",
5
5
  "description": "Scenario-driven playtest harness for Three.js games. Runs on plain Three.js with zero ThreeNative dependencies.",
6
6
  "keywords": [