@moku-labs/game 0.15.130 → 0.15.132

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 (32) hide show
  1. package/dist/app/page.d.mts +1 -1
  2. package/dist/app/page.mjs +1 -1
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +1 -1
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/{commands-1_sCNm0V.d.mts → commands-CzYKkdEO.d.mts} +5 -5
  8. package/dist/control.d.mts +4 -4
  9. package/dist/{define-C6dchCuE.d.mts → define-DR2SWS9E.d.mts} +2 -2
  10. package/dist/{headless-BL14uZkh.d.mts → headless-ffgavU3Y.d.mts} +1 -1
  11. package/dist/{index-BziePJNn.d.mts → index-C_Ej5JkQ.d.mts} +40 -4
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +1 -1
  14. package/dist/inspect.d.mts +9 -6
  15. package/dist/inspect.mjs +1 -1
  16. package/dist/jsx-dev-runtime.d.mts +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/{runtime-C1IjjE5P.d.mts → runtime-wGL7TbEs.d.mts} +1 -1
  19. package/dist/{sources-CuG-Vma9.mjs → sources-D9Fk3Z4d.mjs} +45 -4
  20. package/dist/{src-D9GlfHtW.mjs → src-BM3N5FXk.mjs} +401 -115
  21. package/dist/testing.d.mts +4 -4
  22. package/dist/testing.mjs +1 -1
  23. package/dist/{types-BJcHeAAr.d.mts → types-Bl-YjAnU.d.mts} +41 -8
  24. package/dist/{types-Cq6sox0B.d.mts → types-CYjnhoB9.d.mts} +2 -2
  25. package/dist/{types-BXZesGEs.d.mts → types-DCtlPrmc.d.mts} +4 -4
  26. package/dist/{types-jZ8fj7kN.d.mts → types-DNmg5EAM.d.mts} +37 -2
  27. package/dist/{types-Bd-uqW1x.d.mts → types-DU-RYYj0.d.mts} +126 -7
  28. package/dist/{visual-BJPPDQfT.d.mts → visual-CLR_C--i.d.mts} +6 -6
  29. package/dist/visual.d.mts +1 -1
  30. package/dist/visual.mjs +8 -6
  31. package/llms.txt +2 -2
  32. package/package.json +3 -3
@@ -790,7 +790,7 @@ function askedOf(rate) {
790
790
  * @param rate - The rate, its mode, its reason, the display and the governor.
791
791
  * @returns A fresh frozen snapshot.
792
792
  */
793
- function snapshotOf(rate) {
793
+ function snapshotOf$1(rate) {
794
794
  const { governor } = rate;
795
795
  const { hz } = rate.display;
796
796
  const asked = askedOf(rate);
@@ -830,7 +830,7 @@ function createRateState(config) {
830
830
  ...parts,
831
831
  drawnNow: false,
832
832
  probedNow: false,
833
- snapshot: snapshotOf(parts),
833
+ snapshot: snapshotOf$1(parts),
834
834
  native: void 0
835
835
  };
836
836
  }
@@ -1021,7 +1021,7 @@ function switchRate(ctx, to, scale, mode, reason, at) {
1021
1021
  rate.scale = scale;
1022
1022
  rate.mode = mode;
1023
1023
  rate.reason = reason;
1024
- rate.snapshot = snapshotOf(rate);
1024
+ rate.snapshot = snapshotOf$1(rate);
1025
1025
  ctx.emit("time:rate", {
1026
1026
  from,
1027
1027
  to,
@@ -1070,7 +1070,7 @@ function applyThermal(ctx, g) {
1070
1070
  function noteThermal(ctx, g, status) {
1071
1071
  if (status === null || status === g.thermal) return;
1072
1072
  g.thermal = status;
1073
- ctx.state.rate.snapshot = snapshotOf(ctx.state.rate);
1073
+ ctx.state.rate.snapshot = snapshotOf$1(ctx.state.rate);
1074
1074
  applyThermal(ctx, g);
1075
1075
  }
1076
1076
  /**
@@ -1100,7 +1100,7 @@ function learnDisplay(ctx, hz, at) {
1100
1100
  const first = display.hz === null;
1101
1101
  display.hz = hz;
1102
1102
  if (g !== void 0) g.ladder = ladderOf(hz, ctx.config.maxFps, g.floor);
1103
- rate.snapshot = snapshotOf(rate);
1103
+ rate.snapshot = snapshotOf$1(rate);
1104
1104
  if (g === void 0 || rate.mode !== "auto") return;
1105
1105
  if (!g.ladder.includes(rate.fps)) switchRate(ctx, g.ladder.find((step) => step <= rate.fps) ?? g.ladder.at(-1) ?? rate.fps, rate.scale, "auto", "display", at);
1106
1106
  if (first) applyThermal(ctx, g);
@@ -1353,7 +1353,7 @@ function allowScale(rate, floor) {
1353
1353
  const lowest = g.scales.at(-1) ?? 1;
1354
1354
  if (rate.scale < lowest) {
1355
1355
  rate.scale = lowest;
1356
- rate.snapshot = snapshotOf(rate);
1356
+ rate.snapshot = snapshotOf$1(rate);
1357
1357
  }
1358
1358
  return rate.snapshot;
1359
1359
  }
@@ -10534,7 +10534,8 @@ function startTrack$2(pctx, entity, component, to, options) {
10534
10534
  component: component.componentName,
10535
10535
  handle,
10536
10536
  additive: options.additive === true,
10537
- forever: options.repeat === "forever"
10537
+ forever: options.repeat === "forever",
10538
+ label: options.label
10538
10539
  });
10539
10540
  return handle;
10540
10541
  }
@@ -10620,6 +10621,23 @@ function runningComponents(tracks, entity) {
10620
10621
  }
10621
10622
  return names;
10622
10623
  }
10624
+ /**
10625
+ * The labels of the running tracks on one entity, in track order, each once. A track without a
10626
+ * label adds none. It only reads: an ended track is skipped, not forgotten.
10627
+ *
10628
+ * @param tracks - The tracks the projection started.
10629
+ * @param entity - The entity to ask about.
10630
+ * @returns A new array of labels.
10631
+ */
10632
+ function runningLabels(tracks, entity) {
10633
+ const labels = [];
10634
+ for (const track of tracks) {
10635
+ if (track.entity !== entity) continue;
10636
+ if (track.label === void 0 || labels.includes(track.label)) continue;
10637
+ if (track.handle.active()) labels.push(track.label);
10638
+ }
10639
+ return labels;
10640
+ }
10623
10641
  //#endregion
10624
10642
  //#region src/plugins/world/projection/diff.ts
10625
10643
  /**
@@ -11010,7 +11028,8 @@ function createViewHandle(pctx, view, peers) {
11010
11028
  additive: options.additive ?? false,
11011
11029
  ...options.segments === void 0 ? {} : { segments: options.segments },
11012
11030
  ...options.repeat === void 0 ? {} : { repeat: options.repeat },
11013
- ...options.reduced === void 0 ? {} : { reduced: options.reduced }
11031
+ ...options.reduced === void 0 ? {} : { reduced: options.reduced },
11032
+ ...options.label === void 0 ? {} : { label: options.label }
11014
11033
  }),
11015
11034
  toRest: (component, options) => {
11016
11035
  const target = view.rest.get(component.componentName);
@@ -11022,7 +11041,8 @@ function createViewHandle(pctx, view, peers) {
11022
11041
  ease: options?.ease ?? "out",
11023
11042
  delayMs: options?.delayMs ?? 0,
11024
11043
  additive: false,
11025
- ...options?.reduced === void 0 ? {} : { reduced: options.reduced }
11044
+ ...options?.reduced === void 0 ? {} : { reduced: options.reduced },
11045
+ ...options?.label === void 0 ? {} : { label: options.label }
11026
11046
  });
11027
11047
  },
11028
11048
  all: (handles) => {
@@ -13964,6 +13984,7 @@ function createProjectionApi(ctx, deps) {
13964
13984
  membershipVersion: () => state.membershipVersion,
13965
13985
  causeOf: (entity) => state.byEntity.get(entity)?.cause ?? state.leaving.get(entity),
13966
13986
  motionsOf: (entity) => runningComponents(state.tracks, entity),
13987
+ motionIdsOf: (entity) => runningLabels(state.tracks, entity),
13967
13988
  entityOf: (projection, key) => {
13968
13989
  const entity = state.mounted.get(projection)?.live.get(key)?.entity ?? state.keys.get(projection)?.get(key);
13969
13990
  return entity === void 0 || state.building?.entities.has(entity) === true || state.warmHeld.has(entity) ? void 0 : entity;
@@ -14227,6 +14248,7 @@ function exposeProjection(projection) {
14227
14248
  membershipVersion: projection.membershipVersion,
14228
14249
  causeOf: projection.causeOf,
14229
14250
  motionsOf: projection.motionsOf,
14251
+ motionIdsOf: projection.motionIdsOf,
14230
14252
  entityOf: projection.entityOf,
14231
14253
  entitiesOf: projection.entitiesOf,
14232
14254
  setDriver: projection.setDriver,
@@ -40245,6 +40267,160 @@ function loopBlocksSequence(step) {
40245
40267
  }
40246
40268
  }
40247
40269
  //#endregion
40270
+ //#region src/plugins/anim/state.ts
40271
+ /**
40272
+ * Creates one empty table. It lives in its own non-exported function because lint rule L5 refuses
40273
+ * a collection built inside an exported declaration.
40274
+ *
40275
+ * @returns An empty map.
40276
+ */
40277
+ function emptyMap$5() {
40278
+ return /* @__PURE__ */ new Map();
40279
+ }
40280
+ /**
40281
+ * Creates the empty listener set of `onMark`, for the same reason as `emptyMap`.
40282
+ *
40283
+ * @returns An empty set.
40284
+ */
40285
+ function emptySet$3() {
40286
+ return /* @__PURE__ */ new Set();
40287
+ }
40288
+ /**
40289
+ * Makes the 16 records of the ring of ended timelines, once, so an end only overwrites them.
40290
+ *
40291
+ * @returns Sixteen blank records.
40292
+ */
40293
+ function blankRing() {
40294
+ const ring = [];
40295
+ for (let index = 0; index < 16; index++) ring.push({
40296
+ timeline: 0,
40297
+ animation: "",
40298
+ startFrame: 0,
40299
+ endFrame: 0,
40300
+ reason: "ended"
40301
+ });
40302
+ return ring;
40303
+ }
40304
+ /**
40305
+ * Creates the initial anim state: an empty track table, the empty field bookkeeping of the
40306
+ * retarget policy and the offsets accumulator, no timeline (and a ring of 16 blank records for the
40307
+ * ended ones), no animation and no frame loop, and reduced motion at its configured start value.
40308
+ *
40309
+ * @param ctx - Minimal context.
40310
+ * @param ctx.config - Resolved plugin config.
40311
+ * @returns The plugin state.
40312
+ */
40313
+ function createAnimState(ctx) {
40314
+ return {
40315
+ tracks: emptyMap$5(),
40316
+ trackList: [],
40317
+ nextId: 1,
40318
+ owner: emptyMap$5(),
40319
+ offsets: emptyMap$5(),
40320
+ bases: emptyMap$5(),
40321
+ additive: emptyMap$5(),
40322
+ timelines: emptyMap$5(),
40323
+ timelineList: [],
40324
+ ended: blankRing(),
40325
+ endedNext: 0,
40326
+ endedCount: 0,
40327
+ registry: emptyMap$5(),
40328
+ markListeners: emptySet$3(),
40329
+ frame: 0,
40330
+ overMaxTracks: false,
40331
+ reducedMotion: ctx.config.reducedMotion,
40332
+ removeDriver: void 0,
40333
+ offFrame: void 0,
40334
+ offPlay: void 0,
40335
+ finishAll: void 0,
40336
+ frameLoops: emptyMap$5(),
40337
+ framesHeld: emptyMap$5(),
40338
+ frameMutes: emptyMap$5(),
40339
+ offFrames: [],
40340
+ loopsHeld: void 0,
40341
+ warnedLoops: emptySet$3()
40342
+ };
40343
+ }
40344
+ //#endregion
40345
+ //#region src/plugins/anim/timeline/ring.ts
40346
+ /**
40347
+ * @file anim/timeline — the ring of the last 16 ended timelines and the snapshot `timelines()`
40348
+ * answers. The ring is written in place at every end, so an end allocates no record; the snapshot
40349
+ * builds new plain objects for a reader and is never on the frame path.
40350
+ */
40351
+ /**
40352
+ * Writes one end into the next slot of the ring, in place, and moves the ring on. The record that
40353
+ * was there is overwritten, so the 17th end evicts the oldest.
40354
+ *
40355
+ * @param state - The anim state that holds the ring.
40356
+ * @param running - The timeline that ended.
40357
+ * @param reason - How it ended.
40358
+ */
40359
+ function recordEnd(state, running, reason) {
40360
+ const record = state.ended[state.endedNext];
40361
+ if (record === void 0) return;
40362
+ record.timeline = running.id;
40363
+ record.animation = running.animation;
40364
+ record.startFrame = running.startFrame;
40365
+ record.endFrame = state.frame;
40366
+ record.reason = reason;
40367
+ state.endedNext = (state.endedNext + 1) % 16;
40368
+ state.endedCount = Math.min(16, state.endedCount + 1);
40369
+ }
40370
+ /**
40371
+ * Resets the ring to empty. The 16 records stay allocated and are reused by the next ends.
40372
+ *
40373
+ * @param state - The anim state that holds the ring.
40374
+ */
40375
+ function resetRing(state) {
40376
+ state.endedNext = 0;
40377
+ state.endedCount = 0;
40378
+ }
40379
+ /**
40380
+ * Describes one running timeline for a reader: new arrays for the entities and the marks, the
40381
+ * slots by reference.
40382
+ *
40383
+ * @param running - The running timeline.
40384
+ * @returns A plain object a caller may keep.
40385
+ */
40386
+ function infoOf(running) {
40387
+ return {
40388
+ timeline: running.id,
40389
+ animation: running.animation,
40390
+ startFrame: running.startFrame,
40391
+ slots: running.slots,
40392
+ entities: [...running.entities],
40393
+ marks: [...running.marks]
40394
+ };
40395
+ }
40396
+ /**
40397
+ * Reads what plays now and the ring of what ended, for `timelines()`.
40398
+ *
40399
+ * @param state - The anim state.
40400
+ * @returns The running timelines in start order and the ended ones, oldest first.
40401
+ */
40402
+ function snapshotOf(state) {
40403
+ const running = [];
40404
+ for (const timeline of state.timelineList) if (!timeline.ended) running.push(infoOf(timeline));
40405
+ const ended = [];
40406
+ const first = (state.endedNext - state.endedCount + 16) % 16;
40407
+ for (let offset = 0; offset < state.endedCount; offset++) {
40408
+ const record = state.ended[(first + offset) % 16];
40409
+ if (record === void 0) continue;
40410
+ ended.push({
40411
+ timeline: record.timeline,
40412
+ animation: record.animation,
40413
+ startFrame: record.startFrame,
40414
+ endFrame: record.endFrame,
40415
+ reason: record.reason
40416
+ });
40417
+ }
40418
+ return {
40419
+ running,
40420
+ ended
40421
+ };
40422
+ }
40423
+ //#endregion
40248
40424
  //#region src/plugins/anim/timeline/play.ts
40249
40425
  /**
40250
40426
  * @file anim/timeline — one running timeline: the bookkeeping around a cursor. It builds the step
@@ -40337,21 +40513,30 @@ function cursorCtxOf(rt, running) {
40337
40513
  }
40338
40514
  /**
40339
40515
  * Ends one timeline exactly once: it leaves the table, `Animation` is counted down on every
40340
- * entity it named, every entity it spawned is despawned, `anim:finished` is emitted unless it was
40341
- * cancelled, and `done` resolves.
40516
+ * entity it named, every entity it spawned is despawned, the end is written into the ring of
40517
+ * `timelines()`, `anim:finished` is emitted (`anim:cancelled` for a cancel), and `done` resolves.
40342
40518
  *
40343
40519
  * @param actx - Domain context of the anim plugin.
40344
40520
  * @param running - The running timeline.
40345
- * @param finished - False when the timeline was cancelled: a cancel announces nothing.
40521
+ * @param reason - How it ends: its tree ran through, `finish()` ended it, or `cancel()` did.
40346
40522
  */
40347
- function endTimeline(actx, running, finished) {
40523
+ function endTimeline(actx, running, reason) {
40348
40524
  if (running.ended) return;
40349
40525
  running.ended = true;
40350
40526
  actx.state.timelines.delete(running.id);
40351
40527
  for (const entity of running.entities) countPlaying(actx.deps.world.ecs, entity, -1);
40352
40528
  for (const entity of running.spawned.values()) actx.deps.world.ecs.despawn(entity);
40353
40529
  running.spawned.clear();
40354
- if (finished) actx.emit("anim:finished", { animation: running.animation });
40530
+ recordEnd(actx.state, running, reason);
40531
+ if (reason === "cancelled") actx.emit("anim:cancelled", {
40532
+ animation: running.animation,
40533
+ timeline: running.id
40534
+ });
40535
+ else actx.emit("anim:finished", {
40536
+ animation: running.animation,
40537
+ timeline: running.id,
40538
+ reason
40539
+ });
40355
40540
  running.resolve();
40356
40541
  }
40357
40542
  /**
@@ -40402,6 +40587,8 @@ function startTimeline(actx, rt, definition, slots) {
40402
40587
  const running = {
40403
40588
  id,
40404
40589
  animation: definition.id,
40590
+ slots,
40591
+ startFrame: actx.state.frame,
40405
40592
  cursor,
40406
40593
  marks,
40407
40594
  entities,
@@ -40420,16 +40607,20 @@ function startTimeline(actx, rt, definition, slots) {
40420
40607
  actx.state.timelines.set(id, running);
40421
40608
  actx.state.timelineList.push(running);
40422
40609
  rt.wake();
40610
+ actx.emit("anim:started", {
40611
+ animation: definition.id,
40612
+ timeline: id
40613
+ });
40423
40614
  return {
40424
40615
  finish: () => {
40425
40616
  if (running.ended) return;
40426
40617
  finishCursor(cursorCtxOf(rt, running), cursor);
40427
- endTimeline(actx, running, true);
40618
+ endTimeline(actx, running, "finished");
40428
40619
  },
40429
40620
  cancel: () => {
40430
40621
  if (running.ended) return;
40431
40622
  cancelCursor(cursorCtxOf(rt, running), cursor);
40432
- endTimeline(actx, running, false);
40623
+ endTimeline(actx, running, "cancelled");
40433
40624
  },
40434
40625
  active: () => !running.ended,
40435
40626
  done,
@@ -40450,7 +40641,7 @@ function advanceTimelines(actx, rt, deltaMs) {
40450
40641
  const running = list[index];
40451
40642
  if (running === void 0 || running.ended) continue;
40452
40643
  advanceCursor(cursorCtxOf(rt, running), running.cursor, deltaMs);
40453
- if (running.cursor.ended) endTimeline(actx, running, true);
40644
+ if (running.cursor.ended) endTimeline(actx, running, "ended");
40454
40645
  }
40455
40646
  dropEnded(list);
40456
40647
  }
@@ -40468,7 +40659,7 @@ function finishAllTimelines(actx, rt) {
40468
40659
  const running = list[index];
40469
40660
  if (running === void 0 || running.ended) continue;
40470
40661
  finishCursor(cursorCtxOf(rt, running), running.cursor);
40471
- endTimeline(actx, running, true);
40662
+ endTimeline(actx, running, "finished");
40472
40663
  }
40473
40664
  dropEnded(list);
40474
40665
  }
@@ -41871,6 +42062,7 @@ function stopAnim(state) {
41871
42062
  state.additive.clear();
41872
42063
  state.timelines.clear();
41873
42064
  state.timelineList.length = 0;
42065
+ resetRing(state);
41874
42066
  state.registry.clear();
41875
42067
  state.markListeners.clear();
41876
42068
  state.overMaxTracks = false;
@@ -41883,7 +42075,7 @@ function stopAnim(state) {
41883
42075
  * from a node are the same timeline.
41884
42076
  */
41885
42077
  /**
41886
- * Creates the anim API: `app.anim.play`, `finishAll`, `active`, `onMark`, `reducedMotion`,
42078
+ * Creates the anim API: `app.anim.play`, `finishAll`, `active`, `timelines`, `onMark`, `reducedMotion`,
41887
42079
  * `setReducedMotion` and `replace`.
41888
42080
  *
41889
42081
  * @param ctx - Kernel context of the anim plugin.
@@ -41896,6 +42088,7 @@ function createAnimApi(ctx) {
41896
42088
  play: (animation, slots) => startTimeline(actx, rt, animation, slots),
41897
42089
  finishAll: () => finishAllAnim(actx, rt),
41898
42090
  active: () => actx.state.tracks.size,
42091
+ timelines: () => snapshotOf(actx.state),
41899
42092
  onMark: (fn) => {
41900
42093
  actx.state.markListeners.add(fn);
41901
42094
  return () => {
@@ -41912,62 +42105,6 @@ function createAnimApi(ctx) {
41912
42105
  }
41913
42106
  };
41914
42107
  }
41915
- //#endregion
41916
- //#region src/plugins/anim/state.ts
41917
- /**
41918
- * Creates one empty table. It lives in its own non-exported function because lint rule L5 refuses
41919
- * a collection built inside an exported declaration.
41920
- *
41921
- * @returns An empty map.
41922
- */
41923
- function emptyMap$5() {
41924
- return /* @__PURE__ */ new Map();
41925
- }
41926
- /**
41927
- * Creates the empty listener set of `onMark`, for the same reason as `emptyMap`.
41928
- *
41929
- * @returns An empty set.
41930
- */
41931
- function emptySet$3() {
41932
- return /* @__PURE__ */ new Set();
41933
- }
41934
- /**
41935
- * Creates the initial anim state: an empty track table, the empty field bookkeeping of the
41936
- * retarget policy and the offsets accumulator, no timeline, no animation and no frame loop, and
41937
- * reduced motion at its configured start value.
41938
- *
41939
- * @param ctx - Minimal context.
41940
- * @param ctx.config - Resolved plugin config.
41941
- * @returns The plugin state.
41942
- */
41943
- function createAnimState(ctx) {
41944
- return {
41945
- tracks: emptyMap$5(),
41946
- trackList: [],
41947
- nextId: 1,
41948
- owner: emptyMap$5(),
41949
- offsets: emptyMap$5(),
41950
- bases: emptyMap$5(),
41951
- additive: emptyMap$5(),
41952
- timelines: emptyMap$5(),
41953
- timelineList: [],
41954
- registry: emptyMap$5(),
41955
- markListeners: emptySet$3(),
41956
- frame: 0,
41957
- overMaxTracks: false,
41958
- reducedMotion: ctx.config.reducedMotion,
41959
- removeDriver: void 0,
41960
- offFrame: void 0,
41961
- offPlay: void 0,
41962
- finishAll: void 0,
41963
- frameLoops: emptyMap$5(),
41964
- framesHeld: emptyMap$5(),
41965
- frameMutes: emptyMap$5(),
41966
- offFrames: [],
41967
- loopsHeld: void 0,
41968
- warnedLoops: emptySet$3()
41969
- };
41970
- }
41971
42108
  /**
41972
42109
  * Anim plugin: `app.anim.play(animation, slots)`, `app.anim.finishAll()`,
41973
42110
  * `app.anim.setReducedMotion(on)`.
@@ -42002,7 +42139,9 @@ const animPlugin = /*#__PURE__*/ createPlugin$1("anim", {
42002
42139
  },
42003
42140
  events: (register) => register.map({
42004
42141
  "anim:mark": "A mark of a timeline was reached",
42005
- "anim:finished": "A timeline ended"
42142
+ "anim:started": "A timeline started",
42143
+ "anim:cancelled": "A timeline was cancelled",
42144
+ "anim:finished": "A timeline ended by itself or was finished early"
42006
42145
  }),
42007
42146
  createState: createAnimState,
42008
42147
  api: createAnimApi,
@@ -65228,9 +65367,47 @@ function textStyleOf(element, shownStyleOf) {
65228
65367
  return namedKeyOf(element.style, element.node.props.style);
65229
65368
  }
65230
65369
  /**
65370
+ * The id of the motion an element was given: the `id` of its `motion` prop when that is an object
65371
+ * with a string `id`, which `defineMotion({ id })` sets.
65372
+ *
65373
+ * @param element - The element to read.
65374
+ * @returns The id, or `undefined` for an element without a motion and for a motion without an id.
65375
+ */
65376
+ function motionIdOf(element) {
65377
+ const motion = element.node.props.motion;
65378
+ if (typeof motion !== "object" || motion === null) return void 0;
65379
+ return "id" in motion && typeof motion.id === "string" ? motion.id : void 0;
65380
+ }
65381
+ /**
65382
+ * Where a scroll stands and how it rests: the values `ScrollState` carries (the offset in whole
65383
+ * units, `max`, whether it moves), all 0 and false until the first solve placed it, with its axis
65384
+ * and the stops of its `snap` prop a release would use.
65385
+ *
65386
+ * @param element - The element to read.
65387
+ * @param stopsOf - Reads the stops of a `snap` prop; none in a read without a layout, which leaves `snap` out.
65388
+ * @returns The scroll record, or `undefined` for an element that is no scroll.
65389
+ */
65390
+ function scrollOf(element, stopsOf) {
65391
+ const motion = element.scroll;
65392
+ if (motion === void 0) return void 0;
65393
+ const max = motion.placed ? motion.max : 0;
65394
+ const shown = {
65395
+ axis: motion.axis,
65396
+ offset: motion.placed ? Math.round(motion.offset) : 0,
65397
+ max,
65398
+ moving: motion.placed && motion.mode !== "still"
65399
+ };
65400
+ const snap = stopsOf?.(element.node.props.snap, max);
65401
+ return snap === void 0 ? shown : {
65402
+ ...shown,
65403
+ snap
65404
+ };
65405
+ }
65406
+ /**
65231
65407
  * Turns one element and its subtree into snapshot nodes. The rect is natural; a fitted element
65232
65408
  * adds the scale it is drawn at; a text adds the words it draws and the style key of a keyed
65233
- * text; a text field adds its value; a windowed scroll adds its window. The spacers of a windowed
65409
+ * text; a text field adds its value; a windowed scroll adds its window; an element with a
65410
+ * motion id adds it, a scroll adds where it stands and its snap stops. The spacers of a windowed
65234
65411
  * scroll are left out: its content lists the live rows. The rects of a root laid out in a slot are
65235
65412
  * in the slot's units: `place` maps them into root coordinates.
65236
65413
  *
@@ -65238,14 +65415,15 @@ function textStyleOf(element, shownStyleOf) {
65238
65415
  * @param element - The element to read.
65239
65416
  * @param resolvedOf - Reads the resolved string of a text entity; none in a read without a world.
65240
65417
  * @param shownStyleOf - Reads `Text.style` of a text entity; none in a read without a world.
65418
+ * @param stopsOf - Reads the stops of a `snap` prop; none in a read without a layout.
65241
65419
  * @param place - Maps a rect of a slotted root into root coordinates; none for a root on the viewport.
65242
65420
  * @returns The node, with its children in child order.
65243
65421
  */
65244
- function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
65422
+ function nodeOf(state, element, resolvedOf, shownStyleOf, stopsOf, place) {
65245
65423
  const children = [];
65246
65424
  for (const child of element.children) {
65247
65425
  const childElement = state.elements.get(child);
65248
- if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, place));
65426
+ if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, stopsOf, place));
65249
65427
  }
65250
65428
  const node = {
65251
65429
  key: element.key,
@@ -65284,10 +65462,20 @@ function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
65284
65462
  }
65285
65463
  };
65286
65464
  const local = element.instance === void 0 ? void 0 : state.instances.get(element.instance)?.local;
65287
- return local === void 0 ? windowed : {
65465
+ const located = local === void 0 ? windowed : {
65288
65466
  ...windowed,
65289
65467
  local: { ...local }
65290
65468
  };
65469
+ const motion = motionIdOf(element);
65470
+ const motioned = motion === void 0 ? located : {
65471
+ ...located,
65472
+ motion
65473
+ };
65474
+ const scroll = scrollOf(element, stopsOf);
65475
+ return scroll === void 0 ? motioned : {
65476
+ ...motioned,
65477
+ scroll
65478
+ };
65291
65479
  }
65292
65480
  /**
65293
65481
  * Every mounted root in the order a reader meets them: the popup roots first, the highest `Order`
@@ -65340,17 +65528,18 @@ function placeOf(root, slotPose) {
65340
65528
  * @param slotPose - The root pose of a slot, `rootPoseOf` of `renderer`; none in a read without a world.
65341
65529
  * @param isAside - Whether an entity belongs to the scene `world` builds aside: such a root is not read.
65342
65530
  * @param shownStyleOf - Reads `Text.style` of an entity; none in a read without a world.
65531
+ * @param stopsOf - `stopsOf` of the layout module, which clamps the `snap` stops of a scroll; none in a read without a layout.
65343
65532
  * @returns One root node, or every root under a `screen` node.
65344
65533
  * @example
65345
65534
  * ```ts
65346
65535
  * readTree({ roots: new Map(), elements: new Map() } as unknown as JsxState).type; // "screen"
65347
65536
  * ```
65348
65537
  */
65349
- function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf) {
65538
+ function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf, stopsOf) {
65350
65539
  const nodes = [];
65351
65540
  for (const root of sortedRoots(state, layers, isAside)) {
65352
65541
  const element = root.element === void 0 ? void 0 : state.elements.get(root.element);
65353
- if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, placeOf(root, slotPose)));
65542
+ if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, stopsOf, placeOf(root, slotPose)));
65354
65543
  }
65355
65544
  const single = nodes.length === 1 ? nodes[0] : void 0;
65356
65545
  if (single !== void 0) return single;
@@ -66077,6 +66266,21 @@ function reducedOption(reduced) {
66077
66266
  return reduced === "keep" ? { reduced } : {};
66078
66267
  }
66079
66268
  /**
66269
+ * The `label` field of the options a motion starts a track with: written only when the motion has
66270
+ * an id, so a motion without one starts its tracks with the options it always had.
66271
+ *
66272
+ * @param label - The label `defineMotion` built from its id, or `undefined`.
66273
+ * @returns `{ label }`, or an empty object.
66274
+ * @example
66275
+ * ```ts
66276
+ * labelOption("hud.card.enter"); // { label: "hud.card.enter" }
66277
+ * labelOption(undefined); // {}
66278
+ * ```
66279
+ */
66280
+ function labelOption(label) {
66281
+ return label === void 0 ? {} : { label };
66282
+ }
66283
+ /**
66080
66284
  * Checks one keyframe track at definition time: it has a key, every `at` lies in 0..1 and each
66081
66285
  * key comes after the one before.
66082
66286
  *
@@ -66269,9 +66473,10 @@ function lastValues(segments) {
66269
66473
  * @param keys - The keys of the track.
66270
66474
  * @param ms - The length of the whole track.
66271
66475
  * @param reduced - What reduced motion does to the walk.
66476
+ * @param label - The label of the track, when the motion has an id.
66272
66477
  * @returns The motion, or `undefined` when no key names the lane.
66273
66478
  */
66274
- function enterLane(view, lane, keys, ms, reduced) {
66479
+ function enterLane(view, lane, keys, ms, reduced, label) {
66275
66480
  const segments = segmentsOf(lane, keys);
66276
66481
  const named = lastValues(segments);
66277
66482
  const rest = {};
@@ -66291,7 +66496,8 @@ function enterLane(view, lane, keys, ms, reduced) {
66291
66496
  ms,
66292
66497
  ease: KEY_EASE,
66293
66498
  segments,
66294
- ...reducedOption(reduced)
66499
+ ...reducedOption(reduced),
66500
+ ...labelOption(label)
66295
66501
  });
66296
66502
  }
66297
66503
  /**
@@ -66303,9 +66509,10 @@ function enterLane(view, lane, keys, ms, reduced) {
66303
66509
  * @param keys - The keys of the track.
66304
66510
  * @param ms - The length of the whole track.
66305
66511
  * @param reduced - What reduced motion does to the walk.
66512
+ * @param label - The label of the track, when the motion has an id.
66306
66513
  * @returns The motion, or `undefined` when no key names the lane.
66307
66514
  */
66308
- function exitLane(view, lane, keys, ms, reduced) {
66515
+ function exitLane(view, lane, keys, ms, reduced, label) {
66309
66516
  const segments = segmentsOf(lane, keys);
66310
66517
  const target = lastValues(segments);
66311
66518
  if (Object.keys(target).length === 0) return void 0;
@@ -66313,7 +66520,8 @@ function exitLane(view, lane, keys, ms, reduced) {
66313
66520
  ms,
66314
66521
  ease: KEY_EASE,
66315
66522
  segments,
66316
- ...reducedOption(reduced)
66523
+ ...reducedOption(reduced),
66524
+ ...labelOption(label)
66317
66525
  });
66318
66526
  }
66319
66527
  /**
@@ -66374,9 +66582,10 @@ function loopLanesOf(view) {
66374
66582
  * @param keys - The checked keys of the loop.
66375
66583
  * @param ms - The length of one cycle.
66376
66584
  * @param reduced - Whether reduced motion holds the loop on its first key or lets it walk.
66585
+ * @param label - The label of the track, when the motion has an id.
66377
66586
  * @returns The handle of the walk, or `undefined` when the lane moves nothing.
66378
66587
  */
66379
- function loopLane(view, lane, keys, ms, reduced) {
66588
+ function loopLane(view, lane, keys, ms, reduced, label) {
66380
66589
  const segments = segmentsOf(lane, keys);
66381
66590
  const target = lastValues(segments);
66382
66591
  const first = segments[0];
@@ -66391,7 +66600,8 @@ function loopLane(view, lane, keys, ms, reduced) {
66391
66600
  additive: true,
66392
66601
  repeat: "forever",
66393
66602
  segments,
66394
- ...reducedOption(reduced)
66603
+ ...reducedOption(reduced),
66604
+ ...labelOption(label)
66395
66605
  });
66396
66606
  }
66397
66607
  /**
@@ -66404,12 +66614,13 @@ function loopLane(view, lane, keys, ms, reduced) {
66404
66614
  * @param ms - The length of one cycle: `loop.ms`, or `transition.ms` when it is left out.
66405
66615
  * @param reduced - `loop.reduced`: `"cut"` holds the loop on its first key under reduced motion,
66406
66616
  * `"keep"` lets it walk.
66617
+ * @param label - The label every walk carries (`<id>.loop`), when the motion has an id.
66407
66618
  * @returns One motion over every walk; it never ends on its own.
66408
66619
  */
66409
- function playLoop(view, keys, ms, reduced) {
66620
+ function playLoop(view, keys, ms, reduced, label) {
66410
66621
  const walks = [];
66411
66622
  for (const lane of loopLanesOf(view)) {
66412
- const walk = loopLane(view, lane, keys, ms, reduced);
66623
+ const walk = loopLane(view, lane, keys, ms, reduced, label);
66413
66624
  if (walk !== void 0) walks.push(walk);
66414
66625
  }
66415
66626
  return view.all(walks);
@@ -66423,11 +66634,12 @@ function playLoop(view, keys, ms, reduced) {
66423
66634
  * @param direction - `"enter"` walks first key → rest, `"exit"` walks rest → last key.
66424
66635
  * @param reduced - `transition.reduced`: `"cut"` lands the walk at once under reduced motion,
66425
66636
  * `"keep"` plays it at its length.
66637
+ * @param label - The label every walk carries (`<id>.enter` or `<id>.exit`), when the motion has an id.
66426
66638
  * @returns One motion over every lane.
66427
66639
  */
66428
- function playKeyframes(view, keys, ms, direction, reduced) {
66640
+ function playKeyframes(view, keys, ms, direction, reduced, label) {
66429
66641
  const walk = direction === "enter" ? enterLane : exitLane;
66430
- return view.all(lanesOf(view).map((lane) => walk(view, lane, keys, ms, reduced)));
66642
+ return view.all(lanesOf(view).map((lane) => walk(view, lane, keys, ms, reduced, label)));
66431
66643
  }
66432
66644
  //#endregion
66433
66645
  //#region src/plugins/anim/motion.ts
@@ -66523,6 +66735,18 @@ function checkChoices(spec) {
66523
66735
  }
66524
66736
  }
66525
66737
  /**
66738
+ * Checks the `id` of a motion: absent, or a string with a character in it. A plain JavaScript
66739
+ * caller can pass any value.
66740
+ *
66741
+ * @param spec - What `defineMotion` was given.
66742
+ * @throws {Error} When `id` is given and is not a non-empty string.
66743
+ */
66744
+ function checkId(spec) {
66745
+ const id = spec.id;
66746
+ if (id === void 0 || typeof id === "string" && id !== "") return;
66747
+ throw new Error("[game] defineMotion: id must be a non-empty string.\n Give the motion an id such as \"hud.card\", or leave it out.");
66748
+ }
66749
+ /**
66526
66750
  * Checks a motion at definition time: every keyframe track, no name that is both a state and a
66527
66751
  * track, an `on.enter` / `on.exit` that names one of them, and the words of `when` and `reduced`.
66528
66752
  *
@@ -66530,6 +66754,7 @@ function checkChoices(spec) {
66530
66754
  * @throws {Error} With the name or the value at fault, in the house format.
66531
66755
  */
66532
66756
  function checkMotion$1(spec) {
66757
+ checkId(spec);
66533
66758
  checkChoices(spec);
66534
66759
  for (const [name, keys] of Object.entries(spec.keyframes ?? {})) {
66535
66760
  checkTrack(name, keys);
@@ -66544,20 +66769,41 @@ function checkMotion$1(spec) {
66544
66769
  }
66545
66770
  }
66546
66771
  /**
66772
+ * Builds the labels of a motion from its id.
66773
+ *
66774
+ * @param id - The id of the motion, if it has one.
66775
+ * @returns The four labels, or `undefined` for a motion without an id.
66776
+ * @example
66777
+ * ```ts
66778
+ * labelsOf("hud.card")?.enter; // "hud.card.enter"
66779
+ * labelsOf(undefined); // undefined
66780
+ * ```
66781
+ */
66782
+ function labelsOf(id) {
66783
+ if (id === void 0) return void 0;
66784
+ return {
66785
+ enter: `${id}.enter`,
66786
+ exit: `${id}.exit`,
66787
+ loop: `${id}.loop`,
66788
+ change: `${id}.change`
66789
+ };
66790
+ }
66791
+ /**
66547
66792
  * What plays the name `on` gave a hook: a state is reached with tweens, a keyframe track is walked.
66548
66793
  *
66549
66794
  * @param spec - What `defineMotion` was given, already checked.
66550
66795
  * @param hook - Which hook to build.
66551
66796
  * @param transition - The resolved transition.
66797
+ * @param label - The label of the hook's tracks, when the motion has an id.
66552
66798
  * @returns The player, or `undefined` when `on` names nothing for it.
66553
66799
  */
66554
- function playerOf(spec, hook, transition) {
66800
+ function playerOf(spec, hook, transition, label) {
66555
66801
  const name = spec.on[hook];
66556
66802
  if (name === void 0) return void 0;
66557
66803
  const state = ownEntry(spec.states, name);
66558
- if (state !== void 0) return hook === "enter" ? (view) => playEnter(view, state, transition) : (view) => playExit(view, state, transition);
66804
+ if (state !== void 0) return hook === "enter" ? (view) => playEnter(view, state, transition, label) : (view) => playExit(view, state, transition, label);
66559
66805
  const keys = ownEntry(spec.keyframes, name);
66560
- return keys === void 0 ? void 0 : (view) => playKeyframes(view, keys, transition.ms, hook, transition.reduced);
66806
+ return keys === void 0 ? void 0 : (view) => playKeyframes(view, keys, transition.ms, hook, transition.reduced, label);
66561
66807
  }
66562
66808
  /**
66563
66809
  * Builds the enter or exit hook for the name `on` gave it. A motion that plays only for changes
@@ -66568,10 +66814,11 @@ function playerOf(spec, hook, transition) {
66568
66814
  * @param hook - Which hook to build.
66569
66815
  * @param transition - The resolved transition.
66570
66816
  * @param when - When the hook plays.
66817
+ * @param label - The label of the hook's tracks, when the motion has an id.
66571
66818
  * @returns The hook, or `undefined` when `on` names nothing for it.
66572
66819
  */
66573
- function hookOf(spec, hook, transition, when) {
66574
- const play = playerOf(spec, hook, transition);
66820
+ function hookOf(spec, hook, transition, when, label) {
66821
+ const play = playerOf(spec, hook, transition, label);
66575
66822
  if (play === void 0) return void 0;
66576
66823
  return (view, _item, _hint, cause) => when === "change" && cause === "mount" ? void 0 : play(view);
66577
66824
  }
@@ -66638,11 +66885,13 @@ function recordJson(record) {
66638
66885
  * `printOf` reads it; a loop whose keys hold a function ease carries none.
66639
66886
  *
66640
66887
  * @param loop - The resolved loop, if any.
66888
+ * @param label - The label of the loop's tracks, when the motion has an id. It is not part of the
66889
+ * fingerprint: two loops of equal data are equal under any id.
66641
66890
  * @returns The hook, or `undefined` when the motion names no loop.
66642
66891
  */
66643
- function loopHook(loop) {
66892
+ function loopHook(loop, label) {
66644
66893
  if (loop === void 0) return void 0;
66645
- const hook = (view) => playLoop(view, loop.keys, loop.ms, loop.reduced);
66894
+ const hook = (view) => playLoop(view, loop.keys, loop.ms, loop.reduced, label);
66646
66895
  const print = stableJson({
66647
66896
  keys: loop.keys,
66648
66897
  ms: loop.ms,
@@ -66677,12 +66926,13 @@ function printOf(hook) {
66677
66926
  * @param view - The view handle the hook was given.
66678
66927
  * @param state - The named pose.
66679
66928
  * @param transition - How long the way home takes.
66929
+ * @param label - The label of the tracks, when the motion has an id.
66680
66930
  * @returns One motion over every component the pose names.
66681
66931
  */
66682
- function playEnter(view, state, transition) {
66932
+ function playEnter(view, state, transition, label) {
66683
66933
  const poses = posesOf(state);
66684
66934
  for (const [component, fields] of poses) view.set(component, fields);
66685
- return view.all(poses.map(([component]) => view.toRest(component, trackOptionsOf(transition))));
66935
+ return view.all(poses.map(([component]) => view.toRest(component, trackOptionsOf(transition, label))));
66686
66936
  }
66687
66937
  /**
66688
66938
  * The exit hook: the element tweens into the named pose and its rest pose is left alone, so the
@@ -66691,28 +66941,32 @@ function playEnter(view, state, transition) {
66691
66941
  * @param view - The view handle the hook was given.
66692
66942
  * @param state - The named pose.
66693
66943
  * @param transition - How long the way out takes.
66944
+ * @param label - The label of the tracks, when the motion has an id.
66694
66945
  * @returns One motion over every component the pose names.
66695
66946
  */
66696
- function playExit(view, state, transition) {
66947
+ function playExit(view, state, transition, label) {
66697
66948
  const poses = posesOf(state);
66698
- return view.all(poses.map(([component, fields]) => view.tween(component, fields, trackOptionsOf(transition))));
66949
+ return view.all(poses.map(([component, fields]) => view.tween(component, fields, trackOptionsOf(transition, label))));
66699
66950
  }
66700
66951
  /**
66701
66952
  * The options a transition starts a track with: its length and curve, and `reduced` only for a
66702
- * kept track, so a cut track starts with the options it always had.
66953
+ * kept track, so a cut track starts with the options it always had, and `label` only for a motion
66954
+ * with an id.
66703
66955
  *
66704
66956
  * @param transition - The resolved transition.
66957
+ * @param label - The label of the track, when the motion has an id.
66705
66958
  * @returns The track options.
66706
66959
  * @example
66707
66960
  * ```ts
66708
- * trackOptionsOf({ ms: 150, ease: "out", reduced: "cut" }); // { ms: 150, ease: "out" }
66961
+ * trackOptionsOf({ ms: 150, ease: "out", reduced: "cut" }, "hud.card.enter"); // { ms: 150, ease: "out", label: "hud.card.enter" }
66709
66962
  * ```
66710
66963
  */
66711
- function trackOptionsOf(transition) {
66964
+ function trackOptionsOf(transition, label) {
66712
66965
  return {
66713
66966
  ms: transition.ms,
66714
66967
  ease: transition.ease,
66715
- ...reducedOption(transition.reduced)
66968
+ ...reducedOption(transition.reduced),
66969
+ ...labelOption(label)
66716
66970
  };
66717
66971
  }
66718
66972
  /**
@@ -66720,14 +66974,15 @@ function trackOptionsOf(transition) {
66720
66974
  *
66721
66975
  * @param names - The component names `on.change` listed.
66722
66976
  * @param transition - How long the way home takes.
66977
+ * @param label - The label of the tracks, when the motion has an id.
66723
66978
  * @returns The change table, keyed by component name.
66724
66979
  */
66725
- function changeHooks(names, transition) {
66980
+ function changeHooks(names, transition, label) {
66726
66981
  const hooks = {};
66727
66982
  for (const name of names) {
66728
66983
  const component = componentByName(name);
66729
66984
  if (component === void 0) continue;
66730
- hooks[name] = (view) => view.toRest(component, trackOptionsOf(transition));
66985
+ hooks[name] = (view) => view.toRest(component, trackOptionsOf(transition, label));
66731
66986
  }
66732
66987
  return hooks;
66733
66988
  }
@@ -66747,7 +67002,8 @@ function changeHooks(names, transition) {
66747
67002
  * `world` applies.
66748
67003
  * @throws {Error} When a track is invalid, a name is both a state and a track, `on` names
66749
67004
  * neither, `loop.track` names no track, `loop.ms` is not a finite number above 0, the loop
66750
- * ends somewhere else than it starts, or `when` or a `reduced` is not one of its words.
67005
+ * ends somewhere else than it starts, `id` is given and is not a non-empty string, or `when` or a
67006
+ * `reduced` is not one of its words.
66751
67007
  * @example
66752
67008
  * ```ts
66753
67009
  * const buttonMotion = defineMotion({
@@ -66764,6 +67020,14 @@ function changeHooks(names, transition) {
66764
67020
  * when: "change"
66765
67021
  * });
66766
67022
  * // a scene mount shows it at rest; a commit that adds it grows it in over 220 ms
67023
+ *
67024
+ * const hudCard = defineMotion({
67025
+ * id: "hud.card",
67026
+ * states: { small: { Transform: { scale: 0.8 } } },
67027
+ * on: { enter: "small", change: ["Transform"] }
67028
+ * });
67029
+ * hudCard.id; // "hud.card"
67030
+ * // its enter track is labelled "hud.card.enter", its change track "hud.card.change"
66767
67031
  * ```
66768
67032
  */
66769
67033
  function defineMotion(spec) {
@@ -66774,15 +67038,17 @@ function defineMotion(spec) {
66774
67038
  reduced: spec.transition?.reduced ?? "cut"
66775
67039
  };
66776
67040
  const when = spec.when ?? "always";
66777
- const enter = hookOf(spec, "enter", transition, when);
66778
- const loop = loopHook(loopOf(spec, transition.ms));
66779
- const exit = hookOf(spec, "exit", transition, when);
67041
+ const labels = labelsOf(spec.id);
67042
+ const enter = hookOf(spec, "enter", transition, when, labels?.enter);
67043
+ const loop = loopHook(loopOf(spec, transition.ms), labels?.loop);
67044
+ const exit = hookOf(spec, "exit", transition, when, labels?.exit);
66780
67045
  const changed = spec.on.change ?? [];
66781
67046
  return {
67047
+ ...spec.id === void 0 ? {} : { id: spec.id },
66782
67048
  ...enter === void 0 ? {} : { enter },
66783
67049
  ...loop === void 0 ? {} : { loop },
66784
67050
  ...exit === void 0 ? {} : { exit },
66785
- ...changed.length === 0 ? {} : { change: changeHooks(changed, transition) }
67051
+ ...changed.length === 0 ? {} : { change: changeHooks(changed, transition, labels?.change) }
66786
67052
  };
66787
67053
  }
66788
67054
  //#endregion
@@ -70640,7 +70906,7 @@ function createJsxApi(ctx, modules) {
70640
70906
  }
70641
70907
  };
70642
70908
  return {
70643
- tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf),
70909
+ tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf, modules.layout.stopsOf),
70644
70910
  find,
70645
70911
  lint: () => runLint(ctx),
70646
70912
  fill: (key, value) => {
@@ -72668,6 +72934,25 @@ function nearestStop(snap, offset, max, fallback) {
72668
72934
  return nearest;
72669
72935
  }
72670
72936
  /**
72937
+ * The stops a scroll's `snap` prop names, as a release uses them: numbers only, each kept inside 0
72938
+ * to `max`, in prop order. A `NaN` and a stop that is no number are left out; `Infinity` is kept
72939
+ * clamped to `max`, so every stop is finite and no `null` reaches a reader's JSON.
72940
+ *
72941
+ * @param snap - The `snap` prop of the scroll, any value.
72942
+ * @param max - The largest offset.
72943
+ * @returns The stops, or `undefined` when the prop is no array or no numeric stop remains.
72944
+ * @example
72945
+ * ```ts
72946
+ * stopsOf([-10, 318, Number.NaN, "end", 500, Infinity], 390); // [0, 318, 390, 390]
72947
+ * ```
72948
+ */
72949
+ function stopsOf(snap, max) {
72950
+ if (!Array.isArray(snap)) return void 0;
72951
+ const stops = [];
72952
+ for (const candidate of snap) if (typeof candidate === "number" && !Number.isNaN(candidate)) stops.push(within(candidate, max));
72953
+ return stops.length === 0 ? void 0 : stops;
72954
+ }
72955
+ /**
72671
72956
  * Stops a scroll where it stands.
72672
72957
  *
72673
72958
  * @param motion - Its motion.
@@ -73478,6 +73763,7 @@ function createLayoutApi(ctx) {
73478
73763
  clampScroll: (container, contentHeight, lookup) => clampScroll(ctx, state, container, contentHeight, lookup),
73479
73764
  scrollTo: (container, to, lookup) => scrollTo(ctx, state, container, to, lookup),
73480
73765
  windowOf,
73766
+ stopsOf,
73481
73767
  popupHandler: (jsx) => createPopupHandler(ctx, state, jsx),
73482
73768
  guideHandler: () => createGuideHandler(ctx),
73483
73769
  counters: () => ({