@moku-labs/game 0.15.11 → 0.15.13

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 +2 -2
  4. package/dist/app.d.mts +2 -2
  5. package/dist/app.mjs +1 -1
  6. package/dist/{commands-C3yVtCg1.d.mts → commands-aLTGwuyk.d.mts} +2 -2
  7. package/dist/component-DGg5DqKK.mjs +44 -0
  8. package/dist/control.d.mts +1 -1
  9. package/dist/{flatten-BkXuscAV.mjs → flatten-nUX9PpGo.mjs} +1 -44
  10. package/dist/{index-CsTMiO0x.d.mts → index-YUceiUFm.d.mts} +2 -2
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +3 -3
  13. package/dist/inspect.d.mts +2 -3
  14. package/dist/inspect.mjs +1 -1
  15. package/dist/jsx-dev-runtime.d.mts +1 -1
  16. package/dist/jsx-dev-runtime.mjs +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/jsx-runtime.mjs +1 -1
  19. package/dist/{runtime-Bxy2zoCG.d.mts → runtime-B5OD9JTT.d.mts} +1 -1
  20. package/dist/{runtime-CBZgWgzx.mjs → runtime-DnM9i73o.mjs} +2 -1
  21. package/dist/{sources-CJgUypyC.mjs → sources-Fbq_PFVH.mjs} +82 -35
  22. package/dist/{src-0m2mjRDI.mjs → src-3_HjYegY.mjs} +60 -457
  23. package/dist/testing.d.mts +2 -2
  24. package/dist/testing.mjs +1 -1
  25. package/dist/{types-CpBnGqDU.d.mts → types-3bEK86Z1.d.mts} +1 -1
  26. package/dist/{types-CveBhKTs.d.mts → types-Dm4tM5nH.d.mts} +3 -3
  27. package/dist/{types-D5Pmo8BD.d.mts → types-xmH1X8qd.d.mts} +8 -0
  28. package/dist/{visual-Dwfy9wDb.mjs → visual-CbGKzlj0.mjs} +444 -1
  29. package/dist/{visual-B5Sypqal.d.mts → visual-DExHHx-a.d.mts} +3 -3
  30. package/dist/visual.d.mts +1 -1
  31. package/dist/visual.mjs +1 -1
  32. package/package.json +1 -1
@@ -2,9 +2,10 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { r as systemSource, t as memory } from "./memory-CWlqhS7l.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 { d as graphHash, f as isRestCheckpoint, h as pushEntry, i as servePaused, l as findNode, m as compact, n as captureFrame, o as collectFlows, p as slotNames, r as serveCaptures, s as describeGraph, t as cancelCaptures, u as framePath } from "./capture-D7XvoHdH.mjs";
5
- import { A as Now, C as Sprite, E as componentsFor, F as resource, I as system, L as systemsFor, M as Tree, N as component, O as Exiting, R as tag, S as Shape, T as arcDefaults, _ as HudPart, b as OverlayLevel, c as Countdown, d as builtInStyles, g as Display, h as textFor, i as samePose, j as Order, k as Layer, l as Text, m as readStyle, n as drawnRect, o as visualOf$1, r as fitScaleOf, s as visualRectOf, t as CONTENT$1, v as NineSlice, w as Transform, x as Parent, y as Overlay } from "./visual-Dwfy9wDb.mjs";
5
+ import { $ as component, A as localPoseOf, B as OverlayLevel, C as builtInStyles, D as textFor, E as readStyle, F as rootPoseOf, G as arcDefaults, H as Shape, I as Display, J as Exiting, K as componentsFor, L as HudPart, M as poseUnder, N as rootPointOf, O as applyPose, P as rootPoseInto, Q as Tree, R as NineSlice, U as Sprite, V as Parent, W as Transform, X as Now, Y as Layer, Z as Order, _ as uiFor, a as visualOf$1, b as Countdown, c as Covered, d as LocalWrite, f as Scroll, h as UiCounters, i as samePose, it as tag, j as parentOf$1, k as isLeaving, l as DebugTrigger, m as UI_OWNER, n as drawnRect, nt as system, o as visualRectOf, p as ScrollState, r as fitScaleOf, rt as systemsFor, s as Box, t as CONTENT$1, tt as resource, u as Escapable, x as Text, z as Overlay } from "./visual-CbGKzlj0.mjs";
6
6
  import { a as isDev } from "./dev-BNndV-hU.mjs";
7
- import { i as isComponentDefinition, n as flatten, r as defineComponent } from "./flatten-BkXuscAV.mjs";
7
+ import { n as isComponentDefinition } from "./component-DGg5DqKK.mjs";
8
+ import { n as flatten } from "./flatten-nUX9PpGo.mjs";
8
9
  import { envPlugin, logPlugin } from "@moku-labs/common/browser";
9
10
  import { createCoreConfig } from "@moku-labs/core";
10
11
  /**
@@ -8797,6 +8798,8 @@ function schemaOf(types) {
8797
8798
  //#region src/plugins/world/ecs/systems.ts
8798
8799
  /** The one phase that runs in every mode, because `renderer.sync` lives in it. */
8799
8800
  const ALWAYS = "sync";
8801
+ /** The system that hands the world to Pixi: the last of its phase, so a frame draws what every system wrote. */
8802
+ const DRAWS = "renderer.sync";
8800
8803
  /** Rows a timing table holds before it first grows. */
8801
8804
  const TIMING_ROWS = 16;
8802
8805
  /** The four phases, in frame order. */
@@ -8895,7 +8898,7 @@ function storeSlots(count) {
8895
8898
  return slots;
8896
8899
  }
8897
8900
  /**
8898
- * Registers a system at the end of its phase list and returns the remover. Its query and its
8901
+ * Registers a system at the end of its phase list, before `renderer.sync` in phase `sync`, and returns the remover. Its query and its
8899
8902
  * `scenes` are read here, once: a later change to the definition is not seen. A dev build checks
8900
8903
  * the `scenes` against the scenes the features declare, once the world started.
8901
8904
  *
@@ -8925,7 +8928,9 @@ function registerSystem(ctx, definition) {
8925
8928
  walk: plan.names.length === 0 ? void 0 : new SystemWalk(ctx, plan)
8926
8929
  };
8927
8930
  const list = state.systems[definition.phase];
8928
- list.push(entry);
8931
+ const draws = list.findIndex((known) => known.definition.name === DRAWS);
8932
+ if (draws === -1) list.push(entry);
8933
+ else list.splice(draws, 0, entry);
8929
8934
  if (state.timing !== void 0) giveRow(state, state.timing, definition.name);
8930
8935
  return () => {
8931
8936
  const at = list.indexOf(entry);
@@ -24379,250 +24384,6 @@ function destroyPools(state) {
24379
24384
  state.pooled = 0;
24380
24385
  }
24381
24386
  //#endregion
24382
- //#region src/plugins/renderer/sync/pose.ts
24383
- /**
24384
- * @file renderer/sync — the pose helpers: where an entity really is, in root (reference) space,
24385
- * and the local pose that puts it there under a parent. Pure component math over `world.ecs.get`,
24386
- * the same math the renderer draws with: `position` is where the `pivot` lands, and the pivot is
24387
- * the local point the view turns and scales around.
24388
- *
24389
- * Engine-internal, not a root export. `input`, `anim` and `ui` import `rootPoseOf` and
24390
- * `localPoseOf` from this module path (`../renderer/sync/pose`) and never walk the `Parent` chain
24391
- * themselves; a per-frame reader (`effects`' following emitters) writes the root pose into its own
24392
- * object with `rootPoseInto`, which allocates nothing; `input` places a carried view under the last pose of a despawned held view with
24393
- * `poseUnder`; `sync` places a box with `rootPointOf`. `input` places the drop lookup of an aimed
24394
- * view with `applyPose`.
24395
- */
24396
- /** How deep a parent chain is followed; deeper is treated as a loop. */
24397
- const MAX_DEPTH$6 = 32;
24398
- /**
24399
- * The parent an entity moves with.
24400
- *
24401
- * @param ecs - The world read.
24402
- * @param entity - The entity.
24403
- * @returns The parent entity, or `0` when it has none or names itself.
24404
- */
24405
- function parentOf$1(ecs, entity) {
24406
- const parent = ecs.get(entity, Parent)?.entity ?? 0;
24407
- return parent === entity ? 0 : parent;
24408
- }
24409
- /**
24410
- * Tells whether an entity is on its way out: it or an ancestor of its `Parent` chain carries `Exiting` (a ui element
24411
- * whose exit plays, a world view in its exit queue). Its despawn is coming; nothing else of the teardown is owed.
24412
- *
24413
- * @param ecs - The world read.
24414
- * @param entity - The entity.
24415
- * @returns True while it, or what it hangs under, leaves.
24416
- */
24417
- function isLeaving(ecs, entity) {
24418
- let current = entity;
24419
- for (let depth = 0; depth < MAX_DEPTH$6 && current !== 0; depth += 1) {
24420
- if (ecs.has(current, Exiting)) return true;
24421
- current = parentOf$1(ecs, current);
24422
- }
24423
- return false;
24424
- }
24425
- /**
24426
- * A fresh copy of a pose, so a caller may change what it got without touching the world.
24427
- *
24428
- * @param pose - The pose to copy.
24429
- * @returns The same numbers in new objects.
24430
- * @example
24431
- * ```ts
24432
- * copyPose({ x: 1, y: 2, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }).pivot.x; // 0
24433
- * ```
24434
- */
24435
- function copyPose(pose) {
24436
- return {
24437
- x: pose.x,
24438
- y: pose.y,
24439
- rotation: pose.rotation,
24440
- scale: pose.scale,
24441
- pivot: {
24442
- x: pose.pivot.x,
24443
- y: pose.pivot.y
24444
- }
24445
- };
24446
- }
24447
- /**
24448
- * Moves a point out of the local space of a pose, into the space the pose sits in.
24449
- *
24450
- * @param pose - The pose whose local space the point is in.
24451
- * @param point - The local point.
24452
- * @returns The point one space higher.
24453
- * @example
24454
- * ```ts
24455
- * applyPose({ x: 10, y: 0, rotation: 0, scale: 2, pivot: { x: 5, y: 0 } }, { x: 5, y: 1 });
24456
- * // { x: 10, y: 2 }
24457
- * ```
24458
- */
24459
- function applyPose(pose, point) {
24460
- const cos = Math.cos(pose.rotation);
24461
- const sin = Math.sin(pose.rotation);
24462
- const dx = point.x - pose.pivot.x;
24463
- const dy = point.y - pose.pivot.y;
24464
- return {
24465
- x: pose.x + pose.scale * (dx * cos - dy * sin),
24466
- y: pose.y + pose.scale * (dx * sin + dy * cos)
24467
- };
24468
- }
24469
- /**
24470
- * Places a local pose under a parent pose: the pose in the space the parent sits in. The step
24471
- * `rootPoseOf` takes once per parent: the position through the parent's pivot, rotation, scale
24472
- * and position, the rotations added and the scales multiplied.
24473
- *
24474
- * @param above - The parent pose.
24475
- * @param local - The pose under it.
24476
- * @returns The composed pose; it keeps the local pivot.
24477
- * @example
24478
- * ```ts
24479
- * poseUnder(
24480
- * { x: 400, y: 300, rotation: 0, scale: 2, pivot: { x: 0, y: 0 } },
24481
- * { x: 0, y: 30, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }
24482
- * ); // { x: 400, y: 360, rotation: 0, scale: 2, pivot: { x: 0, y: 0 } }
24483
- * ```
24484
- */
24485
- function poseUnder(above, local) {
24486
- const landed = applyPose(above, local);
24487
- return {
24488
- x: landed.x,
24489
- y: landed.y,
24490
- rotation: local.rotation + above.rotation,
24491
- scale: local.scale * above.scale,
24492
- pivot: {
24493
- x: local.pivot.x,
24494
- y: local.pivot.y
24495
- }
24496
- };
24497
- }
24498
- /**
24499
- * Where an entity really is, written into the caller's pose: its `Transform` composed through the `Parent` chain,
24500
- * every pivot on the way applied, the numbers of `rootPoseOf` (the same steps in the same order). The answer keeps the
24501
- * entity's own pivot. Allocates nothing: a reader that asks every frame passes the same object.
24502
- *
24503
- * @param ecs - The world read, `world.ecs`.
24504
- * @param entity - The entity to place.
24505
- * @param out - The pose to write, its `pivot` object included; it may be `own`.
24506
- * @param own - A pose to use in place of the entity's own `Transform`, such as its rest pose.
24507
- * @returns `out`, in root space. An entity without a `Transform` sits at the identity pose.
24508
- * @example
24509
- * ```ts
24510
- * // `effects` follows a host every frame: the slot sits at (40, 60) scaled 0.5, the host at (100, 200) inside it.
24511
- * const pose = { x: 0, y: 0, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } };
24512
- * rootPoseInto(ctx.require(worldPlugin).ecs, host, pose);
24513
- * // pose is { x: 90, y: 160, rotation: 0, scale: 0.5, pivot: { x: 0, y: 0 } }
24514
- * ```
24515
- */
24516
- function rootPoseInto(ecs, entity, out, own) {
24517
- const start = own ?? ecs.get(entity, Transform) ?? Transform.defaults;
24518
- out.x = start.x;
24519
- out.y = start.y;
24520
- out.rotation = start.rotation;
24521
- out.scale = start.scale;
24522
- out.pivot.x = start.pivot.x;
24523
- out.pivot.y = start.pivot.y;
24524
- let current = entity;
24525
- for (let depth = 0; depth < MAX_DEPTH$6; depth += 1) {
24526
- const parent = parentOf$1(ecs, current);
24527
- if (parent === 0) break;
24528
- const above = ecs.get(parent, Transform) ?? Transform.defaults;
24529
- const cos = Math.cos(above.rotation);
24530
- const sin = Math.sin(above.rotation);
24531
- const dx = out.x - above.pivot.x;
24532
- const dy = out.y - above.pivot.y;
24533
- out.x = above.x + above.scale * (dx * cos - dy * sin);
24534
- out.y = above.y + above.scale * (dx * sin + dy * cos);
24535
- out.rotation = out.rotation + above.rotation;
24536
- out.scale = out.scale * above.scale;
24537
- current = parent;
24538
- }
24539
- return out;
24540
- }
24541
- /**
24542
- * Where an entity really is: its `Transform` composed through the `Parent` chain, every pivot on
24543
- * the way applied. The answer keeps the entity's own pivot, so it can be written straight into the
24544
- * `Transform` of an entity without a parent and the view does not move.
24545
- *
24546
- * @param ecs - The world read, `world.ecs`.
24547
- * @param entity - The entity to place.
24548
- * @param own - A pose to use in place of the entity's own `Transform`, such as its rest pose.
24549
- * @returns The pose in root space, a fresh object. An entity without a `Transform` sits at the identity pose.
24550
- * @example
24551
- * ```ts
24552
- * // `input` lifts a board cell out of its slot: the slot sits at (40, 60) scaled 0.5,
24553
- * // the cell at (100, 200) inside it.
24554
- * rootPoseOf(ctx.require(worldPlugin).ecs, cell);
24555
- * // { x: 90, y: 160, rotation: 0, scale: 0.5, pivot: { x: 0, y: 0 } }
24556
- * ```
24557
- */
24558
- function rootPoseOf(ecs, entity, own) {
24559
- return rootPoseInto(ecs, entity, {
24560
- x: 0,
24561
- y: 0,
24562
- rotation: 0,
24563
- scale: 1,
24564
- pivot: {
24565
- x: 0,
24566
- y: 0
24567
- }
24568
- }, own);
24569
- }
24570
- /**
24571
- * The inverse of `rootPoseOf`: the local pose under `parent` that puts an entity at a root pose.
24572
- * The pivot is kept, as it is a local point of the entity itself.
24573
- *
24574
- * @param ecs - The world read, `world.ecs`.
24575
- * @param parent - The entity to hang under; `0` for none, which answers the root pose itself.
24576
- * @param root - The pose in root space.
24577
- * @returns The local pose. A parent collapsed to scale 0 counts as scale 1, so the answer stays
24578
- * finite.
24579
- * @example
24580
- * ```ts
24581
- * // `input` drops the cell back into the slot at (40, 60) scaled 0.5, where the finger left it.
24582
- * localPoseOf(ctx.require(worldPlugin).ecs, slot, {
24583
- * x: 90, y: 160, rotation: 0, scale: 0.5, pivot: { x: 0, y: 0 }
24584
- * });
24585
- * // { x: 100, y: 200, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }
24586
- * ```
24587
- */
24588
- function localPoseOf(ecs, parent, root) {
24589
- if (parent === 0) return copyPose(root);
24590
- const above = rootPoseOf(ecs, parent);
24591
- const scale = above.scale === 0 ? 1 : above.scale;
24592
- const cos = Math.cos(-above.rotation);
24593
- const sin = Math.sin(-above.rotation);
24594
- const dx = root.x - above.x;
24595
- const dy = root.y - above.y;
24596
- return {
24597
- x: above.pivot.x + (dx * cos - dy * sin) / scale,
24598
- y: above.pivot.y + (dx * sin + dy * cos) / scale,
24599
- rotation: root.rotation - above.rotation,
24600
- scale: root.scale / scale,
24601
- pivot: {
24602
- x: root.pivot.x,
24603
- y: root.pivot.y
24604
- }
24605
- };
24606
- }
24607
- /**
24608
- * Where a local point of an entity lands in root (reference) space: the point posed through the
24609
- * entity's own `Transform` and its whole `Parent` chain, the forward walk of the hit test's
24610
- * `localPoseOf`. The scale is the real one, so a view collapsed to scale 0 lands on one point.
24611
- *
24612
- * @param ecs - The world read, `world.ecs`.
24613
- * @param entity - The entity whose local space the point is in.
24614
- * @param point - The local point.
24615
- * @returns The point in root space, a fresh object.
24616
- * @example
24617
- * ```ts
24618
- * // The corner of a 64 x 64 cell at (100, 200) inside a slot at (40, 60) scaled 0.5.
24619
- * rootPointOf(ctx.require(worldPlugin).ecs, cell, { x: -32, y: -32 }); // { x: 74, y: 144 }
24620
- * ```
24621
- */
24622
- function rootPointOf(ecs, entity, point) {
24623
- return applyPose(rootPoseOf(ecs, entity), point);
24624
- }
24625
- //#endregion
24626
24387
  //#region src/plugins/renderer/sync/layers.ts
24627
24388
  /**
24628
24389
  * @file renderer/sync — the layers. `scenes` declares them through `world.projection.setLayers`;
@@ -32186,13 +31947,14 @@ function localTargetOf(ecs, entity, component, to) {
32186
31947
  const parent = parentOf$1(ecs, entity);
32187
31948
  if (component !== asComponent(Transform) || parent === 0) return local;
32188
31949
  const now = rootPoseOf(ecs, entity);
32189
- const landed = localPoseOf(ecs, parent, {
31950
+ const root = {
32190
31951
  x: to.x ?? now.x,
32191
31952
  y: to.y ?? now.y,
32192
31953
  rotation: to.rotation ?? now.rotation,
32193
31954
  scale: to.scale ?? now.scale,
32194
31955
  pivot: now.pivot
32195
- });
31956
+ };
31957
+ const landed = localPoseOf(ecs, parent, root);
32196
31958
  for (const field of POSE_FIELDS) if (to[field] !== void 0) local[field] = landed[field];
32197
31959
  return local;
32198
31960
  }
@@ -50454,204 +50216,6 @@ const textPlugin = /*#__PURE__*/ createPlugin$1("text", {
50454
50216
  onStop: ({ state }) => stopText(state)
50455
50217
  });
50456
50218
  //#endregion
50457
- //#region src/plugins/ui/styles/define.ts
50458
- /**
50459
- * Declares one style. The work is the type: a field outside the vocabulary, or a value outside
50460
- * its union, is an error where the style is written, not where it is used.
50461
- *
50462
- * @param style - The style, with its `is` and `when` variants.
50463
- * @returns The same object, frozen.
50464
- * @example
50465
- * ```ts
50466
- * defineStyle({ direction: "row", gap: 12 }).gap; // 12
50467
- * ```
50468
- */
50469
- function defineStyle(style) {
50470
- return Object.freeze(style);
50471
- }
50472
- //#endregion
50473
- //#region src/plugins/ui/styles/tokens.ts
50474
- /**
50475
- * Declares the design tokens of a game: spaces, colours, radii and font keys, flat and plain.
50476
- *
50477
- * @param tokens - The four groups; every key inside them is the game's own.
50478
- * @returns The same object, frozen.
50479
- * @example
50480
- * ```ts
50481
- * defineTokens({ space: { md: 16 } }).space.md; // 16
50482
- * ```
50483
- */
50484
- function defineTokens(tokens) {
50485
- return Object.freeze(tokens);
50486
- }
50487
- //#endregion
50488
- //#region src/plugins/ui/components.ts
50489
- /**
50490
- * Who owns every entity `ui` spawns. The projection module checks it before it hands out a view
50491
- * handle, so only `ui` may move a ui element.
50492
- */
50493
- const UI_OWNER = {
50494
- kind: "plugin",
50495
- name: "ui"
50496
- };
50497
- /** Fresh defaults for the patch, so no two buttons share one object. */
50498
- const localWriteDefaults = { patch: {} };
50499
- /**
50500
- * The rect of a ui element in root coordinates. Written by the solve, read by `tree()`, `lint()`
50501
- * and the hit test of `guide`.
50502
- */
50503
- const Box = /*#__PURE__*/ component("Box", {
50504
- x: 0,
50505
- y: 0,
50506
- w: 0,
50507
- h: 0
50508
- });
50509
- /**
50510
- * On a button that writes local state instead of naming an intent. `input.onTap` reports the tap
50511
- * and `ui` merges the patch into the nearest component instance.
50512
- */
50513
- const LocalWrite = /*#__PURE__*/ component("LocalWrite", localWriteDefaults);
50514
- /**
50515
- * On a scroll container. Internal to `ui`: not exported from the package root.
50516
- */
50517
- const Scroll = /*#__PURE__*/ component("Scroll", {
50518
- axis: "y",
50519
- offset: 0,
50520
- min: 0
50521
- });
50522
- /**
50523
- * On every scroll container: where it stands and whether it moves, for a game system and the
50524
- * read door. `ui` writes it in a frame where the offset or `max` changed, and once more with
50525
- * `moving: false` when it stops; a game reads it and never writes it.
50526
- *
50527
- * @example
50528
- * ```ts
50529
- * // A board system dims the events of the order strip while it rests on the orders.
50530
- * export const stripMist = system({
50531
- * name: "board.stripMist",
50532
- * phase: "animate",
50533
- * query: [ScrollState, OrderStrip],
50534
- * run: entities => {
50535
- * for (const [entity, scroll] of entities) {
50536
- * // scroll: { offset: 318, max: 390, moving: false }
50537
- * }
50538
- * }
50539
- * });
50540
- * ```
50541
- */
50542
- const ScrollState = /*#__PURE__*/ component("ScrollState", {
50543
- offset: 0,
50544
- max: 0,
50545
- moving: false
50546
- });
50547
- /**
50548
- * On the root entity of a popup kept beneath another popup (`popup(..., { over })`). Internal to
50549
- * `ui`: not exported from the package root. Every element of that root resolves `is.covered`.
50550
- */
50551
- const Covered = /*#__PURE__*/ tag("Covered");
50552
- /**
50553
- * On a button with the `escape` prop: the control the Escape key taps while its root is the top
50554
- * one, meant for the close button or the backdrop of a dismissable popup. Internal to `ui`: the
50555
- * game writes the prop, never the tag.
50556
- */
50557
- const Escapable = /*#__PURE__*/ tag("Escapable");
50558
- /**
50559
- * On the view a player taps five times within three seconds to open the editor's overlay on a debug build: the
50560
- * version line of the settings, usually. One helper on top of `app.debug.overlay.open()`; a game that wants another
50561
- * gesture calls that itself. The view must take a press (a `button`, or any element with `Touchable`); a `button`
50562
- * that names no intent is the plain choice. Without the agent flag the tag does nothing.
50563
- *
50564
- * @example
50565
- * ```tsx
50566
- * // The version line of the settings sheet. Five taps open the overlay of `moku-game build --debug` on the phone.
50567
- * <button key="versionLine" style={versionLineStyle} components={[DebugTrigger()]}>
50568
- * <text key="version" style="settings.version" content={tr("settings.version", { version: "1.4.0" })} />
50569
- * </button>
50570
- * ```
50571
- */
50572
- const DebugTrigger = /*#__PURE__*/ tag("DebugTrigger");
50573
- /**
50574
- * The three Yoga counters, the reconcile count of the frame, the range re-renders of the windowed
50575
- * lists, and the style and write passes of the reconcile. Written by the two systems of `ui`, read
50576
- * by the acceptance tests. Not part of `app.ui`.
50577
- */
50578
- const UiCounters = /*#__PURE__*/ resource("UiCounters", {
50579
- solves: 0,
50580
- nodes: 0,
50581
- measured: 0,
50582
- reconciles: 0,
50583
- windowRenders: 0,
50584
- styled: 0,
50585
- written: 0
50586
- });
50587
- /**
50588
- * Builds the effect a node awaits to show a popup. The gate opens for the outcomes of the
50589
- * component, so the node resolves with the intent one of its buttons answered. `over` names the
50590
- * component of a popup that stays mounted beneath this one, drawn covered, until this one is gone.
50591
- *
50592
- * @param component - A component declared with `outcomes`.
50593
- * @param props - What its view is called with.
50594
- * @param options - How the popup stands to the others.
50595
- * @param options.over - The component name of the popup kept beneath this one.
50596
- * @returns The descriptor `fx()` takes.
50597
- * @example
50598
- * ```ts
50599
- * const Reward = defineComponent("Reward", {
50600
- * outcomes: { claim: {} },
50601
- * view: () => ({ type: "panel", props: {}, children: [] })
50602
- * });
50603
- * popup(Reward, { gold: 5 });
50604
- * // { kind: "popup", payload: { component: "Reward", props: { gold: 5 } }, answers: ["claim"] }
50605
- * await fx(popup(Reward, { gold: 5 })); // Answer<"claim">: { intent: "claim" }
50606
- * ```
50607
- * @example
50608
- * ```ts
50609
- * // The settings node asks before a reset; the settings stay beneath, covered.
50610
- * const Confirm = defineComponent("Confirm", {
50611
- * outcomes: { reset: {}, cancel: {} },
50612
- * view: () => ({ type: "panel", props: {}, children: [] })
50613
- * });
50614
- * popup(Confirm, {}, { over: "Settings" });
50615
- * // { kind: "popup", payload: { component: "Confirm", props: {}, over: "Settings" },
50616
- * // answers: ["reset", "cancel"] }
50617
- * ```
50618
- */
50619
- function popup(component, props, options) {
50620
- const over = options?.over;
50621
- return {
50622
- kind: "popup",
50623
- payload: over === void 0 ? {
50624
- component: component.name,
50625
- props
50626
- } : {
50627
- component: component.name,
50628
- props,
50629
- over
50630
- },
50631
- answers: Object.keys(component.outcomes)
50632
- };
50633
- }
50634
- /**
50635
- * Binds the four ui helpers to one game. Type-only: the same four functions, plus the intrinsic
50636
- * table this game's tags are checked against.
50637
- *
50638
- * @returns The helpers and the intrinsic type carrier.
50639
- * @example
50640
- * ```ts
50641
- * const { defineStyle } = uiFor<"ui.coin", "digits", "hud.coins">();
50642
- * defineStyle({ gap: 8 }).gap; // 8
50643
- * ```
50644
- */
50645
- function uiFor() {
50646
- return {
50647
- defineComponent,
50648
- defineStyle,
50649
- defineTokens,
50650
- popup,
50651
- intrinsics: {}
50652
- };
50653
- }
50654
- //#endregion
50655
50219
  //#region src/plugins/ui/jsx/field-layout.ts
50656
50220
  /**
50657
50221
  * The four edges of a resolved padding.
@@ -56155,10 +55719,35 @@ function createReconciler(ctx, modules, fields) {
56155
55719
  ctx.log.error("ui:slot-cycle", { projection: root.name });
56156
55720
  }
56157
55721
  /**
56158
- * Plays the enter hook of an element whose spawn has just been applied. The world calls it from
56159
- * the `Box` hook, at the flush of phase `layout`, so the entity carries every component and the
56160
- * first `sync` has not run: the element is never drawn at its rest pose by mistake. A row a
56161
- * range change scrolled in is not new: it plays no `enter` hook, only its loop starts.
55722
+ * Keeps an element whose spawn has just been applied: the world calls it from the `Box` hook, at
55723
+ * the flush of phase `layout`. Its enter hook waits for `playEntered`, so the game's systems see
55724
+ * the entity first (F48).
55725
+ *
55726
+ * @param entity - The entity the `Box` was attached to.
55727
+ */
55728
+ function queueEnter(entity) {
55729
+ const entering = state.entering;
55730
+ if (entering.count < entering.list.length) entering.list[entering.count] = entity;
55731
+ else entering.list.push(entity);
55732
+ entering.count += 1;
55733
+ }
55734
+ /**
55735
+ * Plays the enter hooks queued since the last call, in the order the elements came. The `ui.enter`
55736
+ * system calls it in phase `sync`: after the game's systems, which may have written what a hook
55737
+ * reads (a list's scroll), and before `renderer.sync`, so an element is never drawn at its rest
55738
+ * pose by mistake. An element despawned in between plays nothing.
55739
+ */
55740
+ function playEntered() {
55741
+ const entering = state.entering;
55742
+ for (let index = 0; index < entering.count; index += 1) {
55743
+ const entity = entering.list[index];
55744
+ if (entity !== void 0) playEnter(entity);
55745
+ }
55746
+ entering.count = 0;
55747
+ }
55748
+ /**
55749
+ * Plays the enter hook of an element whose spawn has been applied, once. A row a range change
55750
+ * scrolled in is not new: it plays no `enter` hook, only its loop starts.
56162
55751
  *
56163
55752
  * @param entity - The entity the `Box` was attached to.
56164
55753
  */
@@ -56483,7 +56072,8 @@ function createReconciler(ctx, modules, fields) {
56483
56072
  mountRoot,
56484
56073
  unmountRoot,
56485
56074
  markPointer,
56486
- playEnter,
56075
+ queueEnter,
56076
+ playEntered,
56487
56077
  sweep,
56488
56078
  converged
56489
56079
  };
@@ -56638,7 +56228,8 @@ function createJsxApi(ctx, modules) {
56638
56228
  releaseHosted: () => releaseHosted(ctx, state),
56639
56229
  applyTap: (entity) => applyTap(ctx, entity),
56640
56230
  markPointer: frame.markPointer,
56641
- playEnter: frame.playEnter,
56231
+ queueEnter: frame.queueEnter,
56232
+ playEntered: frame.playEntered,
56642
56233
  converged: frame.converged,
56643
56234
  key: (input) => focus.key(input),
56644
56235
  blur: focus.blur
@@ -59177,7 +58768,8 @@ function registerComponents(ctx, jsx) {
59177
58768
  for (const feature of ctx.deps.flow.features.all()) for (const entry of feature.description.ui ?? []) if (isComponent(entry)) jsx.register(entry);
59178
58769
  }
59179
58770
  /**
59180
- * Opens the two systems of phase `layout`, the seven world hooks of `Tree`, `Box`, `Pressed` and
58771
+ * Opens the two systems of phase `layout`, the `ui.enter` system of phase `sync`, which plays the
58772
+ * enter hooks after the game's systems (F48), the seven world hooks of `Tree`, `Box`, `Pressed` and
59181
58773
  * `PointerOver`, the two that tell the hosting step a view lost its `Parent` or its `Held` (a
59182
58774
  * view freed so may hang under its host again), the listener that asks for every root to be built again after a restore or a
59183
58775
  * load, the two effect handlers, the hint listener that buffers every released hint for
@@ -59206,10 +58798,15 @@ function openRegistrations(ctx, jsx, layout) {
59206
58798
  phase: "layout",
59207
58799
  query: [],
59208
58800
  run: (_rows, frame) => jsx.solve(frame.time)
58801
+ })), ecs.system(system({
58802
+ name: "ui.enter",
58803
+ phase: "sync",
58804
+ query: [],
58805
+ run: () => jsx.playEntered()
59209
58806
  })), ecs.onAdded(Tree, (entity) => {
59210
58807
  const place = projection.keyOf(entity);
59211
58808
  jsx.mountRoot(entity, place?.projection ?? "ui", ecs.get(entity, Layer)?.name ?? "ui");
59212
- }), ecs.onRemoved(Tree, (entity) => jsx.unmountRoot(entity)), ecs.onAdded(Box, (entity) => jsx.playEnter(entity)), projection.onConverged(jsx.converged), ecs.onAdded(Pressed, (entity) => jsx.markPointer(entity, "pressed", true)), ecs.onRemoved(Pressed, (entity) => jsx.markPointer(entity, "pressed", false)), ecs.onAdded(PointerOver, (entity) => jsx.markPointer(entity, "hover", true)), ecs.onRemoved(PointerOver, (entity) => jsx.markPointer(entity, "hover", false)), ecs.onRemoved(Parent, () => hostsMoved(ctx.state.jsx)), ecs.onRemoved(Held, () => hostsMoved(ctx.state.jsx)), ctx.deps.flow.fx.handle("popup", layout.popupHandler(jsx)), ctx.deps.flow.fx.handle("guide", layout.guideHandler()), ctx.deps.flow.fx.onHint((hint) => {
58809
+ }), ecs.onRemoved(Tree, (entity) => jsx.unmountRoot(entity)), ecs.onAdded(Box, (entity) => jsx.queueEnter(entity)), projection.onConverged(jsx.converged), ecs.onAdded(Pressed, (entity) => jsx.markPointer(entity, "pressed", true)), ecs.onRemoved(Pressed, (entity) => jsx.markPointer(entity, "pressed", false)), ecs.onAdded(PointerOver, (entity) => jsx.markPointer(entity, "hover", true)), ecs.onRemoved(PointerOver, (entity) => jsx.markPointer(entity, "hover", false)), ecs.onRemoved(Parent, () => hostsMoved(ctx.state.jsx)), ecs.onRemoved(Held, () => hostsMoved(ctx.state.jsx)), ctx.deps.flow.fx.handle("popup", layout.popupHandler(jsx)), ctx.deps.flow.fx.handle("guide", layout.guideHandler()), ctx.deps.flow.fx.onHint((hint) => {
59213
58810
  ctx.state.jsx.hints.push(hint);
59214
58811
  }), ctx.deps.input.onTap(jsx.applyTap), ctx.deps.input.onTap(() => jsx.blur()), ctx.deps.input.onTap(jsx.tapped), ctx.deps.input.onPointer(jsx.pointer), ctx.deps.input.onKey(jsx.key), ctx.deps.input.controls.add(LocalWrite), () => jsx.releaseHosted(), () => ecs.despawnOwnedBy(UI_OWNER));
59215
58812
  if (typeof __MOKU_GAME_AGENT__ !== "undefined" && __MOKU_GAME_AGENT__) ctx.state.layout.cleanups.push(ctx.deps.input.onTap((entity) => debugTap(ctx, entity)), ecs.onAdded(DebugTrigger, (entity) => checkTrigger(ctx, entity)));
@@ -59269,6 +58866,8 @@ function stopUi(state) {
59269
58866
  state.jsx.scrolls.clear();
59270
58867
  state.jsx.remount = false;
59271
58868
  state.jsx.hints.length = 0;
58869
+ state.jsx.entering.list.length = 0;
58870
+ state.jsx.entering.count = 0;
59272
58871
  state.jsx.debugTaps.length = 0;
59273
58872
  state.jsx.debugWarned = false;
59274
58873
  state.jsx.focus.entity = void 0;
@@ -59643,6 +59242,10 @@ function createJsxState() {
59643
59242
  fields: emptyMap$1(),
59644
59243
  text: createTextState(),
59645
59244
  hints: [],
59245
+ entering: {
59246
+ list: [],
59247
+ count: 0
59248
+ },
59646
59249
  scrolls: emptySet(),
59647
59250
  windowRenders: 0,
59648
59251
  remount: false,
@@ -61349,4 +60952,4 @@ const screen = [
61349
60952
  uiPlugin
61350
60953
  ];
61351
60954
  //#endregion
61352
- export { haptic as $, PERF_LOG_VERSION as $t, types_exports$11 as A, Emitter as At, Box as B, audioPlugin as Bt, types_exports$4 as C, Touchable as Ct, types_exports$8 as D, messageArgument as Dt, types_exports$7 as E, i18nPlugin as Et, types_exports$16 as F, Glow as Ft, defineTokens as G, Animation as Gt, LocalWrite as H, assetsPlugin as Ht, types_exports$17 as I, Noise as It, platformPlugin as J, PASS_KINDS as Jt, defineStyle as K, Frames as Kt, uiPlugin as L, Outline as Lt, types_exports$13 as M, Blur as Mt, types_exports$14 as N, ColorMatrix as Nt, types_exports$9 as O, messageDuration as Ot, types_exports$15 as P, Displacement as Pt, frames as Q, PERF_GAP_BUCKETS as Qt, resolve as R, defineFilter as Rt, types_exports$3 as S, Tappable as St, types_exports$6 as T, Traced as Tt, ScrollState as U, animPlugin as Ut, DebugTrigger as V, scenesPlugin as Vt, popup as W, AnimPlayer as Wt, defineAnimation as X, MONITOR_SECTIONS as Xt, HAPTIC_KINDS as Y, frameAt as Yt, external as Z, PERF_CAUSES as Zt, defineBundles as _, Pointer as _t, cubicBezier as a, refuseStart as an, sfx as at, types_exports$1 as b, Pressed as bt, hint as c, to as cn, stagger as ct, defineScene as d, SaveUnreadableError as dn, wait as dt, PROBLEM_RULES as en, mark as et, tr as f, lifecyclePlugin as fn, inputPlugin as ft, music as g, Hovered as gt, defineEmitter as h, Held as ht, screen as i, flowPlugin as in, set as it, types_exports$12 as j, Alpha as jt, types_exports$10 as k, effectsPlugin as kt, schedule as l, type as ln, tween as lt, flattenFeatures as m, clockPlugin as mn, DropTarget as mt, createPlugin as n, DEMAND_REASONS as nn, play$1 as nt, defineEffect as o, exit as on, spawn as ot, defineFeature as p, timePlugin as pn, Draggable as pt, textPlugin as q, rendererPlugin as qt, defineGame as r, worldPlugin as rn, sequence as rt, guide as s, slot as sn, spawned as st, createApp as t, SHADER_WHATS as tn, parallel as tt, projection as u, modelPlugin as un, use as ut, load as v, PointerOver as vt, types_exports$5 as w, Traceable as wt, types_exports$2 as x, Swipeable as xt, types_exports as y, Pressable as yt, defineMotion as z, debugPlugin as zt };
60955
+ export { spawn as $, exit as $t, types_exports$11 as A, Outline as At, textPlugin as B, rendererPlugin as Bt, types_exports$4 as C, Emitter as Ct, types_exports$8 as D, Displacement as Dt, types_exports$7 as E, ColorMatrix as Et, types_exports$16 as F, assetsPlugin as Ft, frames as G, PERF_GAP_BUCKETS as Gt, HAPTIC_KINDS as H, frameAt as Ht, types_exports$17 as I, animPlugin as It, parallel as J, SHADER_WHATS as Jt, haptic as K, PERF_LOG_VERSION as Kt, uiPlugin as L, AnimPlayer as Lt, types_exports$13 as M, debugPlugin as Mt, types_exports$14 as N, audioPlugin as Nt, types_exports$9 as O, Glow as Ot, types_exports$15 as P, scenesPlugin as Pt, sfx as Q, refuseStart as Qt, resolve as R, Animation as Rt, types_exports$3 as S, effectsPlugin as St, types_exports$6 as T, Blur as Tt, defineAnimation as U, MONITOR_SECTIONS as Ut, platformPlugin as V, PASS_KINDS as Vt, external as W, PERF_CAUSES as Wt, sequence as X, worldPlugin as Xt, play$1 as Y, DEMAND_REASONS as Yt, set as Z, flowPlugin as Zt, defineBundles as _, Traceable as _t, cubicBezier as a, lifecyclePlugin as an, inputPlugin as at, types_exports$1 as b, messageArgument as bt, hint as c, Held as ct, defineScene as d, PointerOver as dt, slot as en, spawned as et, tr as f, Pressable as ft, music as g, Touchable as gt, defineEmitter as h, Tappable as ht, screen as i, SaveUnreadableError as in, wait as it, types_exports$12 as j, defineFilter as jt, types_exports$10 as k, Noise as kt, schedule as l, Hovered as lt, flattenFeatures as m, Swipeable as mt, createPlugin as n, type as nn, tween as nt, defineEffect as o, timePlugin as on, Draggable as ot, defineFeature as p, Pressed as pt, mark as q, PROBLEM_RULES as qt, defineGame as r, modelPlugin as rn, use as rt, guide as s, clockPlugin as sn, DropTarget as st, createApp as t, to as tn, stagger as tt, projection as u, Pointer as ut, load as v, Traced as vt, types_exports$5 as w, Alpha as wt, types_exports$2 as x, messageDuration as xt, types_exports as y, i18nPlugin as yt, defineMotion as z, Frames as zt };
@@ -1,6 +1,6 @@
1
1
  import { Qn as AnyFlow, Xn as FeaturePlugin, cr as Descriptor, fr as Hint, gr as ClockSource, ir as NodeTable, pr as NodeFx, vr as FakeClock, wr as Json } from "./types-CuEK0Vam.mjs";
2
- import { t as createApp } from "./index-CsTMiO0x.mjs";
3
- import { b as saveOf, v as WithGameState, y as memory } from "./types-CveBhKTs.mjs";
2
+ import { t as createApp } from "./index-YUceiUFm.mjs";
3
+ import { b as saveOf, v as WithGameState, y as memory } from "./types-Dm4tM5nH.mjs";
4
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-DHtavbqk.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { an as refuseStart, ln as type, m as flattenFeatures, on as exit, t as createApp } from "./src-0m2mjRDI.mjs";
1
+ import { $t as exit, Qt as refuseStart, m as flattenFeatures, nn as type, t as createApp } from "./src-3_HjYegY.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-CWlqhS7l.mjs";
3
3
  import { t as fakeClock } from "./fake-6mazmHK3.mjs";
4
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-BA6ffzqD.mjs";
@@ -1,5 +1,5 @@
1
1
  import { $r as Events$2, $t as Api$3, An as ReducedMotion, Br as Events$5, Cn as Ease, Cr as Events$3, D as FilterSlotInputs, Dn as NumericFields, E as FilterSlot, En as MotionHandle, K as Api$4, Mn as TrackSegment, O as SyncApi, Pn as Api$2, Q as PixiTexture, Wr as Api$1, X as PixiModule, Y as PixiFilter, Z as PixiSprite, cr as Descriptor, dn as Entity, ei as Require, in as AnyComponent, jn as TrackOptions, ln as ComponentType, lt as FilterCache, on as AnyComponentValue, s as Events$1, sn as ComponentHandle, sr as TypeTag, st as Point, t as Api$5, v as Events$4, wr as Json, xr as Api$6 } from "./types-CuEK0Vam.mjs";
2
- import { C as TextApi, L as I18nApi, M as InputApi, Y as StylesState, c as UiNode, i as Finding, n as ElementChange, o as JsxState, r as ElementMotion } from "./types-D5Pmo8BD.mjs";
2
+ import { C as TextApi, L as I18nApi, M as InputApi, Y as StylesState, c as UiNode, i as Finding, n as ElementChange, o as JsxState, r as ElementMotion } from "./types-xmH1X8qd.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5
  import { Node, Yoga } from "yoga-layout/load";
@@ -1,7 +1,7 @@
1
1
  import { Ar as ProviderCall, In as Config$1, Pr as SnapshotOf, Qn as AnyFlow, Sr as Config, X as PixiModule, Xn as FeaturePlugin, a as Config$3, d as Manifest, gr as ClockSource, jr as SaveDoc, kr as PlayerStateProvider, n as AssetsIo, ot as Orientation, q as Config$2, sr as TypeTag, vr as FakeClock, wr as Json } from "./types-CuEK0Vam.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-CpBnGqDU.mjs";
3
- import { H as StringTable, L as I18nApi, U as TextKey } from "./types-D5Pmo8BD.mjs";
4
- import { ft as platformPlugin, i as screen, mt as PlatformProvider, t as createApp, wt as audioPlugin, xt as effectsPlugin } from "./index-CsTMiO0x.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-3bEK86Z1.mjs";
3
+ import { H as StringTable, L as I18nApi, U as TextKey } from "./types-xmH1X8qd.mjs";
4
+ import { ft as platformPlugin, i as screen, mt as PlatformProvider, t as createApp, wt as audioPlugin, xt as effectsPlugin } from "./index-YUceiUFm.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/model/store/providers/memory.d.ts