@moku-labs/game 0.15.100 → 0.15.102

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.
Files changed (37) hide show
  1. package/dist/app/page.d.mts +4 -3
  2. package/dist/app/page.mjs +73 -4
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +2 -2
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/cli.mjs +1 -1
  8. package/dist/{commands-Da3AUaKC.d.mts → commands-C2JXDkUV.d.mts} +19 -10
  9. package/dist/control.d.mts +10 -6
  10. package/dist/control.mjs +2 -2
  11. package/dist/{define-hPbGjPAY.d.mts → define-DNF9A0ce.d.mts} +2 -2
  12. package/dist/{headless-Co3SEFi5.d.mts → headless-CEG1oR5D.d.mts} +1 -1
  13. package/dist/{index-D5w2xQz0.d.mts → index-DtbI1op8.d.mts} +3 -3
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.mjs +1 -1
  16. package/dist/inspect.d.mts +6 -6
  17. package/dist/inspect.mjs +2 -2
  18. package/dist/jsx-dev-runtime.d.mts +1 -1
  19. package/dist/jsx-runtime.d.mts +1 -1
  20. package/dist/{memory-CWlqhS7l.mjs → memory-DeD9wis6.mjs} +28 -3
  21. package/dist/{run-B5if0jxE.mjs → run-pCQlIaNP.mjs} +46 -3
  22. package/dist/{runtime-B69fIYx_.d.mts → runtime-CcHPrVBm.d.mts} +1 -1
  23. package/dist/{session-D0AYRm5T.mjs → session-ClUqpGId.mjs} +138 -2
  24. package/dist/{sources-Cqqz-0-b.mjs → sources-BJyIJf_X.mjs} +1 -1
  25. package/dist/{src-tL_KNZE7.mjs → src-CilP057R.mjs} +96 -40
  26. package/dist/testing.d.mts +4 -4
  27. package/dist/testing.mjs +2 -2
  28. package/dist/{types-L3E-YS4N.d.mts → types-C1B7-x7p.d.mts} +1 -1
  29. package/dist/{types-BE6tcAFX.d.mts → types-C612npUH.d.mts} +2 -2
  30. package/dist/{types-BVrpb6HD.d.mts → types-Cdzw3as5.d.mts} +2 -2
  31. package/dist/{types-qCcSw8YI.d.mts → types-Ce5W0gZe.d.mts} +51 -10
  32. package/dist/{types-D0lN1gFj.d.mts → types-IJXSUFJa.d.mts} +4 -4
  33. package/dist/{visual-B10_HmCZ.d.mts → visual-BoSpJLWP.d.mts} +6 -6
  34. package/dist/visual.d.mts +1 -1
  35. package/dist/visual.mjs +2 -2
  36. package/llms.txt +4 -4
  37. package/package.json +1 -1
@@ -166,7 +166,143 @@ const noInput = Object.freeze({});
166
166
  * ```
167
167
  */
168
168
  function inputOrEmpty(input) {
169
- return input ?? noInput;
169
+ return input === void 0 ? noInput : input;
170
+ }
171
+ /**
172
+ * Tells whether a value is of an input kind: a string, a finite number, a boolean, or for `json`
173
+ * anything but `undefined`. Pure.
174
+ *
175
+ * @param kind - The kind, without its `?`.
176
+ * @param value - The value, not `undefined`.
177
+ * @returns True when the value fits the kind.
178
+ * @example
179
+ * ```ts
180
+ * fitsKind("number", Number.NaN); // false
181
+ * ```
182
+ */
183
+ function fitsKind(kind, value) {
184
+ if (kind === "number") return typeof value === "number" && Number.isFinite(value);
185
+ if (kind === "json") return true;
186
+ return typeof value === kind;
187
+ }
188
+ /**
189
+ * Shows a given value in a message: a number as it prints, so `NaN` stays `NaN`, anything else as
190
+ * JSON. Pure.
191
+ *
192
+ * @param value - The value.
193
+ * @returns The value as text.
194
+ * @example
195
+ * ```ts
196
+ * shown(Number.NaN); // "NaN"
197
+ * ```
198
+ */
199
+ function shown(value) {
200
+ return typeof value === "number" ? String(value) : JSON.stringify(value) ?? String(value);
201
+ }
202
+ /**
203
+ * Names a kind in a message. Pure.
204
+ *
205
+ * @param kind - The kind.
206
+ * @returns The kind with its article.
207
+ * @example
208
+ * ```ts
209
+ * kindName("number"); // "a finite number"
210
+ * ```
211
+ */
212
+ function kindName(kind) {
213
+ return kind === "number" ? "a finite number" : `a ${kind}`;
214
+ }
215
+ /**
216
+ * Lists the fields a schema takes, for a message: `key (string), to (number)`. Pure.
217
+ *
218
+ * @param schema - The schema.
219
+ * @returns The fields with their kinds, or `nothing` for an empty schema.
220
+ * @example
221
+ * ```ts
222
+ * fieldList({ key: "string", to: "number" }); // "key (string), to (number)"
223
+ * ```
224
+ */
225
+ function fieldList(schema) {
226
+ const fields = Object.keys(schema).map((name) => `${name} (${schema[name] ?? ""})`);
227
+ return fields.length === 0 ? "nothing" : fields.join(", ");
228
+ }
229
+ /**
230
+ * Builds the error of an input that does not fit the schema of its command.
231
+ *
232
+ * @param id - The id of the command.
233
+ * @param problem - What is wrong, one clause.
234
+ * @param schema - The schema, for the fix.
235
+ * @returns The error, ready to throw.
236
+ */
237
+ function inputError(id, problem, schema) {
238
+ return /* @__PURE__ */ new TypeError(`[game] The command ${id} got ${problem}.\n It takes ${fieldList(schema)}; a field ending in ? may be left out.`);
239
+ }
240
+ /**
241
+ * Splits a declared kind into its kind and whether it is optional. Pure.
242
+ *
243
+ * @param declared - The kind as the schema writes it.
244
+ * @returns The kind without its `?`, and whether it had one.
245
+ * @example
246
+ * ```ts
247
+ * splitKind("number?"); // { kind: "number", optional: true }
248
+ * ```
249
+ */
250
+ function splitKind(declared) {
251
+ const optional = declared.endsWith("?");
252
+ return {
253
+ kind: optional ? declared.slice(0, -1) : declared,
254
+ optional
255
+ };
256
+ }
257
+ /**
258
+ * Checks one field of the schema against its given value.
259
+ *
260
+ * @param id - The id of the command, for the message.
261
+ * @param schema - The schema of the command.
262
+ * @param name - The field.
263
+ * @param value - Its given value, `undefined` when left out.
264
+ * @throws {TypeError} When a field without `?` is left out, or the value is of another kind.
265
+ */
266
+ function checkField(id, schema, name, value) {
267
+ const { kind, optional } = splitKind(schema[name] ?? "json?");
268
+ if (value === void 0 && optional) return;
269
+ if (value === void 0) throw inputError(id, `no "${name}", which it needs`, schema);
270
+ if (!fitsKind(kind, value)) throw inputError(id, `${shown(value)} for "${name}", not ${kindName(kind)}`, schema);
271
+ }
272
+ /**
273
+ * Tells whether a value is an object a call can read field by field: not `null`, not an array. Pure.
274
+ *
275
+ * @param value - The value.
276
+ * @returns True for a plain object.
277
+ * @example
278
+ * ```ts
279
+ * isPlainObject([true]); // false
280
+ * ```
281
+ */
282
+ function isPlainObject(value) {
283
+ return typeof value === "object" && value !== null && !Array.isArray(value);
284
+ }
285
+ /**
286
+ * Checks a given input against the schema of its command before the command runs: an object, no
287
+ * field the schema does not name, every field without `?` given, and every given value of its
288
+ * kind. A field with `?` may be left out or be `undefined`. A door call, never a frame path.
289
+ *
290
+ * @param id - The id of the command, for the message.
291
+ * @param schema - The schema of the command.
292
+ * @param input - The input of the call, as it came: an editor or a visual test sends plain JSON.
293
+ * @throws {TypeError} Naming the first field that does not fit, and the fields the command takes.
294
+ * @example
295
+ * ```ts
296
+ * checkInput("game.scroll", { key: "string", to: "number" }, { key: "strip", to: 318 }); // passes
297
+ * checkInput("game.scroll", { key: "string", to: "number" }, { key: "strip", dy: 10 });
298
+ * // throws '[game] The command game.scroll got the field "dy", which it does not take.\n It takes key (string), to (number); …'
299
+ * ```
300
+ */
301
+ function checkInput(id, schema, input) {
302
+ if (!isPlainObject(input)) throw inputError(id, "an input that is not an object", schema);
303
+ const given = input;
304
+ for (const name of Object.keys(given)) if (!Object.hasOwn(schema, name)) throw inputError(id, `the field "${name}", which it does not take`, schema);
305
+ for (const name of Object.keys(schema)) checkField(id, schema, name, given[name]);
170
306
  }
171
307
  //#endregion
172
308
  //#region src/plugins/input/target.ts
@@ -254,4 +390,4 @@ function recordCheat(app, id, input, frame) {
254
390
  sessions.set(app, session);
255
391
  }
256
392
  //#endregion
257
- export { readTarget as a, defineSource as c, isProjectionTarget as i, inputSchema as l, isTainted as n, inputOrEmpty as o, recordCheat as r, defineCommand as s, cheatsOf as t };
393
+ export { readTarget as a, defineCommand as c, isProjectionTarget as i, defineSource as l, isTainted as n, checkInput as o, recordCheat as r, inputOrEmpty as s, cheatsOf as t, inputSchema as u };
@@ -1,6 +1,6 @@
1
1
  import { $ as Shape, H as parentOf, K as rootPoseOf, Y as NineSlice, i as drawnRect, ot as Layer, p as Box } from "./visual-DhqD6W3v.mjs";
2
2
  import { o as notInstalled } from "./dev-BNndV-hU.mjs";
3
- import { a as readTarget, c as defineSource, l as inputSchema, n as isTainted, o as inputOrEmpty, t as cheatsOf } from "./session-D0AYRm5T.mjs";
3
+ import { a as readTarget, l as defineSource, n as isTainted, s as inputOrEmpty, t as cheatsOf, u as inputSchema } from "./session-ClUqpGId.mjs";
4
4
  //#region src/plugins/flow/doors/read.ts
5
5
  /**
6
6
  * @file flow/doors — `read` and `watch`, the `/inspect` side. Neither changes the game.
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { r as systemSource, t as memory } from "./memory-CWlqhS7l.mjs";
2
+ import { i as systemSource, r as MAX_TIMER_MS, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { a as finishDrafts, i as enableDraftPatches, n as deepFreeze$1, o as openDrafts, r as dropDrafts } from "./drafts-BawpSaVp.mjs";
4
4
  import { _ as compact, c as collectFlows, d as findNode, f as framePath, g as slotNames, h as restlessCapOf, i as servePaused, l as describeGraph, m as isRestCheckpoint, n as captureFrame, o as epochOf, p as graphHash, r as serveCaptures, s as pageNow$1, t as cancelCaptures, v as pushEntry } from "./capture-BtS6_oWr.mjs";
5
5
  import { $ as Shape, A as Countdown, B as isLeaving, C as uiFor, D as isTextFormat, E as formatBound, G as rootPoseInto, H as parentOf$1, J as HudPart, K as rootPoseOf, L as readStyle, N as builtInStyles, O as unitOf, Q as Parent, R as textFor, U as poseUnder, V as localPoseOf, W as rootPointOf, X as Overlay, Y as NineSlice, Z as OverlayLevel, _ as LocalWrite, a as fieldsLeftAlone, at as Exiting, b as UI_OWNER, c as namesFormat, ct as Order, d as visualOf$1, et as Sprite, f as visualRectOf, ft as resource, g as Escapable, h as DebugTrigger, ht as tag, i as drawnRect, j as Text, k as wholeValue, l as restValueOf, lt as Tree, m as Covered, mt as systemsFor, n as CONTENT$1, nt as arcDefaults, o as fitScaleOf, ot as Layer, p as Box, pt as system, q as Display, r as bindOf, rt as componentsFor, s as livePatch, st as Now, tt as Transform, u as samePose, ut as component, v as Scroll, x as UiCounters, y as ScrollState, z as applyPose } from "./visual-DhqD6W3v.mjs";
@@ -30,14 +30,18 @@ const createCore$1 = coreConfig.createCore;
30
30
  //#endregion
31
31
  //#region src/plugins/clock/api.ts
32
32
  /**
33
+ * @file clock plugin — API factory. Holds the monotonic rule, the single pending due moment and
34
+ * the `elapsed` listeners.
35
+ */
36
+ /**
33
37
  * Reads the source and raises the high-water mark. A source that goes back cannot move game time
34
- * back, and a fractional reading is cut to whole milliseconds.
38
+ * back, and a fractional reading is cut to whole milliseconds. The shift of `advance` is added.
35
39
  *
36
40
  * @param state - Clock state.
37
41
  * @returns The highest moment ever returned, in epoch milliseconds.
38
42
  */
39
43
  function readNow(state) {
40
- const moment = Math.trunc(state.source.now());
44
+ const moment = Math.trunc(state.source.now() + state.shift);
41
45
  if (moment > state.last) state.last = moment;
42
46
  return state.last;
43
47
  }
@@ -63,15 +67,17 @@ function deliverElapsed(state) {
63
67
  for (const listener of listeners) listener({ now: moment });
64
68
  }
65
69
  /**
66
- * Arms the single timer for a due moment. The delay is counted from the RAW source reading, not
67
- * from trusted time: the source's timer runs on the device clock, so after the device clock was
68
- * moved back the wait is longer than `moment - now()`.
70
+ * Arms the single timer for a due moment. The delay is counted from the RAW source reading plus
71
+ * the shift of `advance`, not from trusted time: the source's timer runs on the device clock, so after the device clock was
72
+ * moved back the wait is longer than `moment - now()`. A moment further than the longest timer
73
+ * waits in steps: the timer fires early and `fireDue` arms it again.
69
74
  *
70
75
  * @param state - Clock state.
71
76
  * @param moment - Due moment in epoch milliseconds.
72
77
  */
73
78
  function arm(state, moment) {
74
- const delayMs = Math.max(0, moment - Math.trunc(state.source.now()));
79
+ const raw = Math.trunc(state.source.now() + state.shift);
80
+ const delayMs = Math.min(MAX_TIMER_MS, Math.max(0, moment - raw));
75
81
  state.dueAt = moment;
76
82
  state.handle = state.source.setTimer(() => fireDue(state), delayMs);
77
83
  }
@@ -93,6 +99,26 @@ function fireDue(state) {
93
99
  deliverElapsed(state);
94
100
  }
95
101
  /**
102
+ * Moves the clock forward by `ms`: the shift every reading adds grows, and the pending moment is
103
+ * delivered at once when it is due now, or armed again for the rest of its wait.
104
+ *
105
+ * @param state - Clock state.
106
+ * @param ms - Milliseconds forward.
107
+ * @returns The trusted moment after the move.
108
+ * @throws {RangeError} When `ms` is not a finite number above 0.
109
+ */
110
+ function advanceBy$1(state, ms) {
111
+ if (!Number.isFinite(ms) || ms <= 0) throw new RangeError(`[game] clock.advance moves the clock forward, not by ${ms} ms.\n Pass a finite number of milliseconds above 0.`);
112
+ state.shift += ms;
113
+ const moment = state.dueAt;
114
+ const now = readNow(state);
115
+ if (moment === void 0) return now;
116
+ cancelPending(state);
117
+ if (now >= moment) deliverElapsed(state);
118
+ else arm(state, moment);
119
+ return now;
120
+ }
121
+ /**
96
122
  * Removes one listener. A second removal of the same listener does nothing.
97
123
  *
98
124
  * @param state - Clock state.
@@ -125,6 +151,7 @@ function createClockApi(ctx) {
125
151
  poke: () => {
126
152
  deliverElapsed(ctx.state);
127
153
  },
154
+ advance: (ms) => advanceBy$1(ctx.state, ms),
128
155
  dueAt: () => ctx.state.dueAt,
129
156
  pending: () => ctx.state.dueAt === void 0 ? 0 : 1,
130
157
  listeners: () => ctx.state.listeners.length
@@ -136,8 +163,8 @@ function createClockApi(ctx) {
136
163
  * @file clock plugin — state factory.
137
164
  */
138
165
  /**
139
- * Creates the initial clock state: the configured source or the system source, no due moment,
140
- * no timer handle, no listeners.
166
+ * Creates the initial clock state: the configured source or the system source, no shift, no due
167
+ * moment, no timer handle, no listeners.
141
168
  *
142
169
  * @param ctx - Minimal context.
143
170
  * @param ctx.config - Resolved plugin config.
@@ -147,6 +174,7 @@ function createClockState(ctx) {
147
174
  return {
148
175
  source: ctx.config.source ?? systemSource(),
149
176
  last: 0,
177
+ shift: 0,
150
178
  dueAt: void 0,
151
179
  handle: void 0,
152
180
  listeners: []
@@ -9126,6 +9154,7 @@ function collectMatch(_value, entity) {
9126
9154
  */
9127
9155
  var SystemWalk = class {
9128
9156
  ctx;
9157
+ hidesAside;
9129
9158
  /** The step handed back for every row: always the one row array. */
9130
9159
  step;
9131
9160
  /** The one row: the entity, then one stored value per name, sized at registration. */
@@ -9146,14 +9175,19 @@ var SystemWalk = class {
9146
9175
  started = false;
9147
9176
  /** The first store's size at the first step: a dev build compares it; -1 when not watched. */
9148
9177
  size = -1;
9178
+ /** The entities of the running aside build this run passes over, read at the first step; `undefined` for none. */
9179
+ aside = void 0;
9149
9180
  /**
9150
9181
  * Prepares the walk of one system.
9151
9182
  *
9152
9183
  * @param ctx - Domain context of the world plugin.
9153
9184
  * @param plan - The system's resolved query.
9185
+ * @param hidesAside - True for a feature's system: it passes over the entities of a scene built aside until the
9186
+ * commit (F155).
9154
9187
  */
9155
- constructor(ctx, plan) {
9188
+ constructor(ctx, plan, hidesAside = false) {
9156
9189
  this.ctx = ctx;
9190
+ this.hidesAside = hidesAside;
9157
9191
  this.names = plan.names;
9158
9192
  this.written = plan.written;
9159
9193
  this.step = {
@@ -9186,13 +9220,14 @@ var SystemWalk = class {
9186
9220
  return this;
9187
9221
  }
9188
9222
  /**
9189
- * Keeps one key of the first store when the entity carries every other name.
9223
+ * Keeps one key of the first store when the entity carries every other name and is not built aside.
9190
9224
  *
9191
9225
  * @param entity - The key.
9192
9226
  */
9193
9227
  keep(entity) {
9194
9228
  const stores = this.stores;
9195
9229
  const count = stores.length;
9230
+ if (this.aside?.has(entity) === true) return;
9196
9231
  for (let index = 1; index < count; index += 1) if (stores[index]?.has(entity) !== true) return;
9197
9232
  this.entities[this.count] = entity;
9198
9233
  this.count += 1;
@@ -9222,8 +9257,8 @@ var SystemWalk = class {
9222
9257
  }
9223
9258
  /**
9224
9259
  * Reads the stores of this run and collects the entities that carry every name, in the first
9225
- * store's order. Structural changes are queued until the phase ends, so the matches stay true
9226
- * while the rows are consumed.
9260
+ * store's order; a feature's system passes over the entities of a scene built aside. Structural
9261
+ * changes are queued until the phase ends, so the matches stay true while the rows are consumed.
9227
9262
  */
9228
9263
  start() {
9229
9264
  const all = this.ctx.state.ecs.stores;
@@ -9237,6 +9272,7 @@ var SystemWalk = class {
9237
9272
  }
9238
9273
  const first = stores[0];
9239
9274
  if (first === void 0) return;
9275
+ this.aside = this.hidesAside ? this.ctx.state.projection.building?.entities : void 0;
9240
9276
  collecting.walk = this;
9241
9277
  first.forEach(collectMatch);
9242
9278
  collecting.walk = void 0;
@@ -9311,7 +9347,7 @@ function mayMatch(stores, entry) {
9311
9347
  */
9312
9348
  function systemRows(ctx, entry) {
9313
9349
  if (entry.plan.names.length === 0) return NO_ROWS;
9314
- entry.walk ??= new SystemWalk(ctx, entry.plan);
9350
+ entry.walk ??= new SystemWalk(ctx, entry.plan, entry.hidesAside);
9315
9351
  return entry.walk.reset();
9316
9352
  }
9317
9353
  /**
@@ -9689,23 +9725,24 @@ function storeSlots(count) {
9689
9725
  /**
9690
9726
  * Registers a system at the end of its phase list and returns the remover. In phase `sync` it goes
9691
9727
  * before `renderer.sync`, which stays last. Its query and its `scenes` are read here, once: a
9692
- * later change to the definition is not seen. A dev build checks
9693
- * the `scenes` against the scenes the features declare, once the world started.
9728
+ * later change to the definition is not seen. A dev build checks the `scenes` against the scenes
9729
+ * the features declare, once the world started.
9730
+ *
9731
+ * The rows of a feature's system (`hidesAside`) pass over the entities of a scene built aside
9732
+ * until the commit, so it meets the coming scene whole, in one frame (F155); `world.query()`,
9733
+ * `get` and `has` inside its `run` still read them. The engine's own systems lay that scene out
9734
+ * and draw it, and see it.
9694
9735
  *
9695
9736
  * @param ctx - Domain context of the world plugin.
9696
9737
  * @param definition - The system.
9738
+ * @param hidesAside - True for a system a feature brought.
9697
9739
  * @returns The remover; calling it twice is a no-op.
9698
9740
  * @throws {Error} When a system of that name is already registered, and in a dev build for a
9699
9741
  * name in `scenes` that no feature declares.
9700
9742
  */
9701
- function registerSystem(ctx, definition) {
9743
+ function registerSystem(ctx, definition, hidesAside = false) {
9702
9744
  const state = ctx.state.ecs;
9703
- for (const phase of [
9704
- "input",
9705
- "animate",
9706
- "layout",
9707
- "sync"
9708
- ]) if (state.systems[phase].some((entry) => entry.definition.name === definition.name)) throw new Error(`[game] System "${definition.name}" is registered twice.\n Give the second system another name, or remove the first one.`);
9745
+ for (const phase of WORLD_PHASES) if (state.systems[phase].some((entry) => entry.definition.name === definition.name)) throw new Error(`[game] System "${definition.name}" is registered twice.\n Give the second system another name, or remove the first one.`);
9709
9746
  if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__) checkScenes(state.scene, definition);
9710
9747
  const plan = planOf(ctx, definition.query);
9711
9748
  const entry = {
@@ -9715,7 +9752,8 @@ function registerSystem(ctx, definition) {
9715
9752
  stores: storeSlots(plan.names.length),
9716
9753
  scenes: definition.scenes === void 0 ? void 0 : [...definition.scenes],
9717
9754
  skipped: false,
9718
- walk: plan.names.length === 0 ? void 0 : new SystemWalk(ctx, plan)
9755
+ hidesAside,
9756
+ walk: plan.names.length === 0 ? void 0 : new SystemWalk(ctx, plan, hidesAside)
9719
9757
  };
9720
9758
  const list = state.systems[definition.phase];
9721
9759
  const draws = list.findIndex((known) => known.definition.name === DRAWS_SYSTEM);
@@ -9908,6 +9946,7 @@ function createEcsApi(ctx) {
9908
9946
  const state = ctx.state.ecs;
9909
9947
  const api = {
9910
9948
  system: (definition) => registerSystem(ctx, definition),
9949
+ featureSystem: (definition) => registerSystem(ctx, definition, true),
9911
9950
  spawn: (owner, components) => {
9912
9951
  const entity = reserveEntity(state, owner);
9913
9952
  queueOrApply(ctx, {
@@ -10139,7 +10178,7 @@ function registerFeatures(ctx, ecs, projection) {
10139
10178
  declareScenes(ctx.state.ecs.scene, features);
10140
10179
  for (const feature of features) {
10141
10180
  registerEach(ctx, feature, "components", isComponentEntry, (entry) => registerType(ctx, entry));
10142
- registerEach(ctx, feature, "systems", isSystemEntry, (entry) => ecs.system(entry));
10181
+ registerEach(ctx, feature, "systems", isSystemEntry, (entry) => ecs.featureSystem(entry));
10143
10182
  registerEach(ctx, feature, "projections", isProjectionEntry, (entry) => projection.register(entry));
10144
10183
  }
10145
10184
  }
@@ -44519,23 +44558,37 @@ function endBuild(ctx, build, how) {
44519
44558
  build.resolve();
44520
44559
  }
44521
44560
  /**
44522
- * Tells whether the floor on the swap lets a built scene commit: no floor, or the clock passed it and the look was drawn
44523
- * once. The count is the look's, never the build's, so a switch slower than the floor is many frames past it and the
44524
- * floor adds no frame. While it holds, the loop is kept awake: it may stop at `idleFps: 0` during a long floor. No floor
44525
- * is one read; no allocation either way.
44561
+ * Tells whether the floor on the swap lets a built scene commit: no floor, or the clock or the game time passed it and
44562
+ * the look was drawn once. On a device both run together; the stepped frames of a visual test move the game time while
44563
+ * its fake clock stands (F86), so the floor passes there after `holdMs` of frames (F156). The count is the look's, never
44564
+ * the build's, so a switch slower than the floor is many frames past it and the floor adds no frame. While it holds, the
44565
+ * loop is kept awake: it may stop at `idleFps: 0` during a long floor. No floor is one read; no allocation either way.
44526
44566
  *
44527
44567
  * @param ctx - Domain context of the plugin.
44528
44568
  * @param frame - The frame counter now.
44569
+ * @param elapsed - The game time now, in ms.
44529
44570
  * @returns True when the build may commit.
44530
44571
  */
44531
- function holdOver(ctx, frame) {
44572
+ function holdOver(ctx, frame, elapsed) {
44532
44573
  const hold = ctx.state.leaving?.hold;
44533
44574
  if (hold === void 0) return true;
44534
- if (ctx.deps.clock.now() >= hold.until && frame >= hold.frame + HOLD_FRAMES) return true;
44575
+ if ((ctx.deps.clock.now() >= hold.until || elapsed >= hold.elapsedUntil) && frame >= hold.frame + HOLD_FRAMES) return true;
44535
44576
  ctx.deps.time.wake();
44536
44577
  return false;
44537
44578
  }
44538
44579
  /**
44580
+ * Tells whether a running build may commit now: every part of it is done and the floor on the swap
44581
+ * passed. Two calls, no allocation.
44582
+ *
44583
+ * @param ctx - Domain context of the plugin.
44584
+ * @param frame - The frame counter now.
44585
+ * @param elapsed - The game time now, in ms.
44586
+ * @returns True when the build may commit.
44587
+ */
44588
+ function readyToCommit(ctx, frame, elapsed) {
44589
+ return ctx.deps.world.projection.built() && holdOver(ctx, frame, elapsed);
44590
+ }
44591
+ /**
44539
44592
  * The `signals` callback of a running build: counts the frame and commits the build the frame
44540
44593
  * every part of it is done and the floor on the swap passed. A world that stopped running live
44541
44594
  * during the build or its wait (a walk that went fast, as the restore of a repro walks its route,
@@ -44547,15 +44600,15 @@ function holdOver(ctx, frame) {
44547
44600
  * @param ctx - Domain context of the plugin.
44548
44601
  * @param build - The running build.
44549
44602
  * @param frame - The frame counter of this frame.
44603
+ * @param elapsed - The game time of this frame, in ms.
44550
44604
  */
44551
- function stepBuild(ctx, build, frame) {
44605
+ function stepBuild(ctx, build, frame, elapsed) {
44552
44606
  build.frames += 1;
44553
- const world = ctx.deps.world;
44554
- if (world.ecs.mode() !== "live") {
44607
+ if (ctx.deps.world.ecs.mode() !== "live") {
44555
44608
  endBuild(ctx, build, "mount");
44556
44609
  return;
44557
44610
  }
44558
- if (world.projection.built() && holdOver(ctx, frame)) endBuild(ctx, build, "commit");
44611
+ if (readyToCommit(ctx, frame, elapsed)) endBuild(ctx, build, "commit");
44559
44612
  }
44560
44613
  /**
44561
44614
  * Drops the running build on an abort of its node (a restore, the inbox, a stop of the runner):
@@ -44609,7 +44662,7 @@ function startBuildRecord(ctx, scene, named, budgetMs, settle) {
44609
44662
  */
44610
44663
  function watchBuild(ctx, build, signal) {
44611
44664
  const onAbort = () => abortBuild(ctx, build);
44612
- const offFrame = ctx.deps.time.onFrame("signals", (time) => stepBuild(ctx, build, time.frame));
44665
+ const offFrame = ctx.deps.time.onFrame("signals", (time) => stepBuild(ctx, build, time.frame, time.elapsed));
44613
44666
  signal.addEventListener("abort", onAbort, { once: true });
44614
44667
  build.off = () => {
44615
44668
  offFrame();
@@ -44652,7 +44705,8 @@ function buildAside(ctx, scene, named, signal) {
44652
44705
  resolve,
44653
44706
  reject
44654
44707
  });
44655
- if (projection.built() && holdOver(ctx, ctx.deps.time.snapshot().frame)) {
44708
+ const { frame, elapsed } = ctx.deps.time.snapshot();
44709
+ if (readyToCommit(ctx, frame, elapsed)) {
44656
44710
  endBuild(ctx, build, "commit");
44657
44711
  return;
44658
44712
  }
@@ -45185,8 +45239,8 @@ function leftScene(ctx, run) {
45185
45239
  return ctx.state.scenes.get(current);
45186
45240
  }
45187
45241
  /**
45188
- * Stamps the floor of a loader on the look of a switch that starts now: the clock moment the swap may happen at, and the
45189
- * frame counter, read once here (`snapshot()` copies). A loader without one leaves the look as it is.
45242
+ * Stamps the floor of a loader on the look of a switch that starts now: the clock moment and the game time the swap may
45243
+ * happen at, and the frame counter, read once here (`snapshot()` copies). A loader without one leaves the look as it is.
45190
45244
  *
45191
45245
  * @param ctx - Domain context of the plugin.
45192
45246
  * @param leaving - The look of the switch.
@@ -45194,9 +45248,11 @@ function leftScene(ctx, run) {
45194
45248
  */
45195
45249
  function stampHold(ctx, leaving, loader) {
45196
45250
  if (loader.holdMs === void 0) return;
45251
+ const { frame, elapsed } = ctx.deps.time.snapshot();
45197
45252
  leaving.hold = {
45198
45253
  until: ctx.deps.clock.now() + loader.holdMs,
45199
- frame: ctx.deps.time.snapshot().frame
45254
+ elapsedUntil: elapsed + loader.holdMs,
45255
+ frame
45200
45256
  };
45201
45257
  }
45202
45258
  /**
@@ -1,7 +1,7 @@
1
- import { An as FeaturePlugin, Hn as Descriptor, Hr as Json, Ir as FakeClock, Kn as Hint, Mn as AnyFlow, Pr as ClockSource, Rn as NodeTable, qn as NodeFx } from "./types-qCcSw8YI.mjs";
2
- import { t as createApp } from "./index-D5w2xQz0.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-D0lN1gFj.mjs";
4
- import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-Co3SEFi5.mjs";
1
+ import { An as FeaturePlugin, Hn as Descriptor, Hr as Json, Ir as FakeClock, Kn as Hint, Mn as AnyFlow, Pr as ClockSource, Rn as NodeTable, qn as NodeFx } from "./types-Ce5W0gZe.mjs";
2
+ import { t as createApp } from "./index-DtbI1op8.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-IJXSUFJa.mjs";
4
+ import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-CEG1oR5D.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/clock/fake.d.ts
package/dist/testing.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { C as flattenFeatures, fn as exit, hn as type, t as createApp, un as refuseStart } from "./src-tL_KNZE7.mjs";
2
- import { n as saveOf, t as memory } from "./memory-CWlqhS7l.mjs";
1
+ import { C as flattenFeatures, fn as exit, hn as type, t as createApp, un as refuseStart } from "./src-CilP057R.mjs";
2
+ import { n as saveOf, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";
5
5
  //#region src/testing/fake-fx.ts
@@ -1,4 +1,4 @@
1
- import { $n as Ease, Dr as TagType, Hn as Descriptor, Hr as Json, J as TransformValue, Kn as Hint, Nr as Api$5, Or as Api$2, Xn as AnchorTarget, Yn as Answered, Z as Api$3, Zn as ChangeHook, _t as ViewportSize, ci as Api, dr as AnyComponent, er as Motion, fn as Api$1, fr as AnyComponentType, gr as ComponentType, ir as ProjectionMotion, nr as MotionHandle, or as ReducedMotion, pr as AnyComponentValue, rr as NumericFields, s as Events$1, t as Api$4, tr as MotionCause, ur as ViewHandle, vi as Require, vr as Entity } from "./types-qCcSw8YI.mjs";
1
+ import { $n as Ease, Dr as TagType, Hn as Descriptor, Hr as Json, J as TransformValue, Kn as Hint, Nr as Api$5, Or as Api$2, Xn as AnchorTarget, Yn as Answered, Z as Api$3, Zn as ChangeHook, _t as ViewportSize, ci as Api, dr as AnyComponent, er as Motion, fn as Api$1, fr as AnyComponentType, gr as ComponentType, ir as ProjectionMotion, nr as MotionHandle, or as ReducedMotion, pr as AnyComponentValue, rr as NumericFields, s as Events$1, t as Api$4, tr as MotionCause, ur as ViewHandle, vi as Require, vr as Entity } from "./types-Ce5W0gZe.mjs";
2
2
  import { Log } from "@moku-labs/common/browser";
3
3
  import { PluginCtx } from "@moku-labs/core";
4
4
  import { Node, Yoga } from "yoga-layout/load";
@@ -1,5 +1,5 @@
1
- import { Hr as Json, Zr as Snapshot } from "./types-qCcSw8YI.mjs";
2
- import { t as HeadlessApp } from "./headless-Co3SEFi5.mjs";
1
+ import { Hr as Json, Zr as Snapshot } from "./types-Ce5W0gZe.mjs";
2
+ import { t as HeadlessApp } from "./headless-CEG1oR5D.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
 
5
5
  //#region src/plugins/flow/doors/types.d.ts
@@ -1,5 +1,5 @@
1
- import { $n as Ease, A as FilterSlotQuad, Hn as Descriptor, Hr as Json, O as FilterSlot, Or as Api$3, Vn as TypeTag, Vr as Events$3, Xn as AnchorTarget, Z as Api$4, _i as Events$2, at as PixiUniformGroup, b as Events$4, ci as Api$1, cr as TrackOptions, dr as AnyComponent, et as PixiFilter, fn as Api$2, gr as ComponentType, gt as Point, ii as Events$5, it as PixiTexture, j as SyncApi, k as FilterSlotInputs, lr as TrackSegment, mr as ComponentHandle, nr as MotionHandle, nt as PixiModule, or as ReducedMotion, pr as AnyComponentValue, rr as NumericFields, rt as PixiSprite, s as Events$1, t as Api$5, tt as PixiGpuProgram, vi as Require, vr as Entity, vt as FilterCache, zr as Api$6 } from "./types-qCcSw8YI.mjs";
2
- import { H as I18nApi, L as InputApi, T as TextApi, c as UiNode, et as StylesState, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion } from "./types-L3E-YS4N.mjs";
1
+ import { $n as Ease, A as FilterSlotQuad, Hn as Descriptor, Hr as Json, O as FilterSlot, Or as Api$3, Vn as TypeTag, Vr as Events$3, Xn as AnchorTarget, Z as Api$4, _i as Events$2, at as PixiUniformGroup, b as Events$4, ci as Api$1, cr as TrackOptions, dr as AnyComponent, et as PixiFilter, fn as Api$2, gr as ComponentType, gt as Point, ii as Events$5, it as PixiTexture, j as SyncApi, k as FilterSlotInputs, lr as TrackSegment, mr as ComponentHandle, nr as MotionHandle, nt as PixiModule, or as ReducedMotion, pr as AnyComponentValue, rr as NumericFields, rt as PixiSprite, s as Events$1, t as Api$5, tt as PixiGpuProgram, vi as Require, vr as Entity, vt as FilterCache, zr as Api$6 } from "./types-Ce5W0gZe.mjs";
2
+ import { H as I18nApi, L as InputApi, T as TextApi, c as UiNode, et as StylesState, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion } from "./types-C1B7-x7p.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5