@moku-labs/game 0.15.145 → 0.15.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Gt as audioPlugin, Pt as effectsPlugin, Q as platformPlugin, i as screen, t as createApp, w as flattenFeatures } from "./src-BR2Uw9Xz.mjs";
1
+ import { Gt as audioPlugin, Pt as effectsPlugin, Q as platformPlugin, i as screen, t as createApp, w as flattenFeatures } from "./src-DRt212D0.mjs";
2
2
  import { t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock, r as isFakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  //#region src/app/define.ts
@@ -1391,4 +1391,95 @@ async function captureFrame(mctx, options) {
1391
1391
  return shot === void 0 ? void 0 : answerOf(mctx, shot, options.against);
1392
1392
  }
1393
1393
  //#endregion
1394
- export { slotNames as _, sheetAlone as a, pageNow as c, describedNode as d, findNode as f, restlessCapOf as g, isRestCheckpoint as h, servePaused as i, collectFlows as l, graphHash as m, captureFrame as n, afterTask as o, framePath as p, serveCaptures as r, epochOf as s, cancelCaptures as t, describeGraph as u, compact as v, pushEntry as y };
1394
+ //#region src/plugins/scenes/bundles.ts
1395
+ /**
1396
+ * Tells whether what a scene's `bundles` returned is a list of bundle names.
1397
+ *
1398
+ * @param value - The return value of `bundles(state)`.
1399
+ * @returns True for an array whose every entry is a string.
1400
+ * @example
1401
+ * ```ts
1402
+ * isNameList(["ep01", 3]); // false
1403
+ * ```
1404
+ */
1405
+ function isNameList(value) {
1406
+ return Array.isArray(value) && value.every((name) => typeof name === "string");
1407
+ }
1408
+ /**
1409
+ * Lists the bundles a scene names for a committed state: its `bundle` first, then what its
1410
+ * `bundles(state)` returns, in order, each name once. An error the game's `bundles` throws
1411
+ * propagates unchanged. With a memo, a scene is asked once per committed state: while `player`
1412
+ * and `session` are the trees it last answered for, the same frozen list comes back and `bundles`
1413
+ * is not called (F194: the look-ahead asked every scene of the neighbourhood at every rest).
1414
+ *
1415
+ * @param scene - The scene declaration.
1416
+ * @param state - The committed player and session, frozen.
1417
+ * @param memo - The last answer of each scene, kept by the plugin that asks; none to ask every time.
1418
+ * @returns The bundle names, the scene bundle first; frozen when they come from the memo.
1419
+ * @throws {Error} When `bundles` returns something that is not a list of names.
1420
+ * @example
1421
+ * ```ts
1422
+ * // assets pins what the scene of the node being entered names, read from the committed state.
1423
+ * const { player, session } = model.store.snapshot();
1424
+ * namedBundles(wardScene, { player, session }); // ["location", "ep01"] while session.episode is "ep01"
1425
+ * ```
1426
+ */
1427
+ function namedBundles(scene, state, memo) {
1428
+ const known = memo?.get(scene);
1429
+ if (known !== void 0 && known.player === state.player && known.session === state.session) return known.names;
1430
+ const names = Object.freeze(readNames(scene, state));
1431
+ memo?.set(scene, {
1432
+ player: state.player,
1433
+ session: state.session,
1434
+ names
1435
+ });
1436
+ return names;
1437
+ }
1438
+ /**
1439
+ * Asks a scene for its bundles: its `bundle`, then what `bundles(state)` returns, each name once.
1440
+ *
1441
+ * @param scene - The scene declaration.
1442
+ * @param state - The committed player and session, frozen.
1443
+ * @returns A new list of names, the scene bundle first.
1444
+ * @throws {Error} When `bundles` returns something that is not a list of names.
1445
+ */
1446
+ function readNames(scene, state) {
1447
+ const names = [scene.bundle];
1448
+ if (scene.bundles === void 0) return names;
1449
+ const listed = scene.bundles(state);
1450
+ if (!isNameList(listed)) throw new Error(`[game] Scene "${scene.id}": bundles() must return a list of bundle names.\n Return the bundle keys the scene needs, such as ["ep01"].`);
1451
+ for (const name of listed) if (!names.includes(name)) names.push(name);
1452
+ return names;
1453
+ }
1454
+ /**
1455
+ * Tells whether the `bundles` slot of an entry can be called: absent, `undefined` or a function.
1456
+ *
1457
+ * @param entry - One entry of a feature's `scenes` list.
1458
+ * @returns True when the switch can call what the slot holds, or there is nothing to call.
1459
+ * @example
1460
+ * ```ts
1461
+ * hasCallableBundles({ bundles: 3 }); // false
1462
+ * ```
1463
+ */
1464
+ function hasCallableBundles(entry) {
1465
+ if (!("bundles" in entry)) return true;
1466
+ return entry.bundles === void 0 || typeof entry.bundles === "function";
1467
+ }
1468
+ /**
1469
+ * Tells whether one entry of a feature's `scenes` list is a scene declaration. The key carries
1470
+ * whatever the game put there, so an entry that is not one is skipped instead of crashing.
1471
+ *
1472
+ * @param entry - One entry of the list.
1473
+ * @returns True when the entry can be read as a scene.
1474
+ * @example
1475
+ * ```ts
1476
+ * isSceneDefinition({ id: "board", bundle: "board", layers: [], projections: [] }); // true
1477
+ * isSceneDefinition("board"); // false: a scene is an object
1478
+ * isSceneDefinition({ id: "ward", bundle: "location", layers: [], projections: [], bundles: 3 }); // false
1479
+ * ```
1480
+ */
1481
+ function isSceneDefinition(entry) {
1482
+ return typeof entry === "object" && entry !== null && "id" in entry && typeof entry.id === "string" && "bundle" in entry && typeof entry.bundle === "string" && "layers" in entry && Array.isArray(entry.layers) && "projections" in entry && Array.isArray(entry.projections) && hasCallableBundles(entry);
1483
+ }
1484
+ //#endregion
1485
+ export { isRestCheckpoint as _, serveCaptures as a, compact as b, afterTask as c, collectFlows as d, describeGraph as f, graphHash as g, framePath as h, captureFrame as i, epochOf as l, findNode as m, namedBundles as n, servePaused as o, describedNode as p, cancelCaptures as r, sheetAlone as s, isSceneDefinition as t, pageNow as u, restlessCapOf as v, pushEntry as x, slotNames as y };
@@ -1,4 +1,4 @@
1
- import { $r as Snapshot, Ar as Api$3, Fn as Bookmark, Fr as Api, O as DebugSwitches, Q as Api$2, Rn as FlowState, fi as FrameRate, gi as Time, ii as Api$1, mt as Captured, ti as StoreApi, w as ScenesApi } from "./types-NOciAl87.mjs";
1
+ import { $r as Snapshot, Ar as Api$4, Fn as Bookmark, Fr as Api$1, O as DebugSwitches, Q as Api$3, Rn as FlowState, fi as FrameRate, gi as Time, ii as Api$2, mt as Captured, t as Api, ti as StoreApi, w as ScenesApi } from "./types-NOciAl87.mjs";
2
2
  import { W as AnimApi, a as AudioApi, h as EffectsApi, r as UiApi } from "./types-BDCkyWXq.mjs";
3
3
  import { R as InputApi } from "./types-rsz4pIqe.mjs";
4
4
  import { t as HeadlessApp } from "./headless-BcgzSec_.mjs";
@@ -54,6 +54,7 @@ declare const commands: Readonly<{
54
54
  readonly log: import("@moku-labs/common/browser").LogApi;
55
55
  } & {
56
56
  readonly scenes?: ScenesApi;
57
+ readonly assets?: Pick<Api, "load" | "sceneComing">;
57
58
  }>;
58
59
  restore: Command<{
59
60
  readonly bookmark: "json?";
@@ -62,11 +63,13 @@ declare const commands: Readonly<{
62
63
  readonly log: import("@moku-labs/common/browser").LogApi;
63
64
  } & {
64
65
  readonly scenes?: ScenesApi;
66
+ readonly assets?: Pick<Api, "load" | "sceneComing">;
65
67
  }>;
66
68
  saveExport: Command<{}, Snapshot, HeadlessApp & {
67
69
  readonly log: import("@moku-labs/common/browser").LogApi;
68
70
  } & {
69
71
  readonly scenes?: ScenesApi;
72
+ readonly assets?: Pick<Api, "load" | "sceneComing">;
70
73
  } & {
71
74
  readonly model: {
72
75
  readonly store: Pick<StoreApi, "snapshot" | "flush">;
@@ -80,6 +83,7 @@ declare const commands: Readonly<{
80
83
  readonly log: import("@moku-labs/common/browser").LogApi;
81
84
  } & {
82
85
  readonly scenes?: ScenesApi;
86
+ readonly assets?: Pick<Api, "load" | "sceneComing">;
83
87
  } & {
84
88
  readonly model: {
85
89
  readonly store: Pick<StoreApi, "snapshot" | "flush">;
@@ -91,8 +95,8 @@ declare const commands: Readonly<{
91
95
  }, Readonly<Time>, HeadlessApp & {
92
96
  readonly log: import("@moku-labs/common/browser").LogApi;
93
97
  } & {
94
- readonly clock?: Api;
95
- readonly lifecycle?: Api$1;
98
+ readonly clock?: Api$1;
99
+ readonly lifecycle?: Api$2;
96
100
  }>;
97
101
  clock: Command<{
98
102
  readonly advanceMs: "number";
@@ -101,17 +105,17 @@ declare const commands: Readonly<{
101
105
  }, HeadlessApp & {
102
106
  readonly log: import("@moku-labs/common/browser").LogApi;
103
107
  } & {
104
- readonly clock?: Api;
108
+ readonly clock?: Api$1;
105
109
  }>;
106
110
  pause: Command<{}, boolean, HeadlessApp & {
107
111
  readonly log: import("@moku-labs/common/browser").LogApi;
108
112
  } & {
109
- readonly lifecycle: Api$1;
113
+ readonly lifecycle: Api$2;
110
114
  }>;
111
115
  resume: Command<{}, boolean, HeadlessApp & {
112
116
  readonly log: import("@moku-labs/common/browser").LogApi;
113
117
  } & {
114
- readonly lifecycle: Api$1;
118
+ readonly lifecycle: Api$2;
115
119
  }>;
116
120
  capture: Command<{
117
121
  readonly legend: "boolean?";
@@ -121,9 +125,9 @@ declare const commands: Readonly<{
121
125
  }, Captured | undefined, HeadlessApp & {
122
126
  readonly log: import("@moku-labs/common/browser").LogApi;
123
127
  } & {
124
- readonly renderer: Api$2;
128
+ readonly renderer: Api$3;
125
129
  } & {
126
- readonly world: Api$3;
130
+ readonly world: Api$4;
127
131
  }>;
128
132
  debug: Command<{
129
133
  readonly nineSlice: "boolean?";
@@ -133,7 +137,7 @@ declare const commands: Readonly<{
133
137
  }, DebugSwitches, HeadlessApp & {
134
138
  readonly log: import("@moku-labs/common/browser").LogApi;
135
139
  } & {
136
- readonly renderer: Api$2;
140
+ readonly renderer: Api$3;
137
141
  }>;
138
142
  reducedMotion: Command<{
139
143
  readonly on: "boolean";
@@ -1,6 +1,6 @@
1
1
  import { t as HeadlessApp } from "./headless-BcgzSec_.mjs";
2
2
  import { a as InputArguments, c as Ran, n as ChoiceInput, r as Command, s as InputSchema, u as ToggleInput } from "./types-C2hkiREP.mjs";
3
- import { t as commands } from "./commands-7RWSJMv7.mjs";
3
+ import { t as commands } from "./commands-DjcKboFw.mjs";
4
4
  import { t as defineCommand } from "./define-DK_J6R4D.mjs";
5
5
 
6
6
  //#region src/plugins/flow/doors/dev.d.ts
package/dist/control.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { n as controlRefused, t as controlReadOnly } from "./dev-BNndV-hU.mjs";
2
2
  import { c as defineCommand } from "./session-ClUqpGId.mjs";
3
- import { n as commands, t as run } from "./run-1i_SfbM4.mjs";
3
+ import { n as commands, t as run } from "./run-BVW1feQ2.mjs";
4
4
  export { commands, controlReadOnly, controlRefused, defineCommand, run };
@@ -1,4 +1,4 @@
1
- import { d as describedNode, m as graphHash } from "./capture-BuVczpxc.mjs";
1
+ import { g as graphHash, p as describedNode } from "./bundles-YzDqsUJn.mjs";
2
2
  //#region src/plugins/flow/headless.ts
3
3
  const noPayload = null;
4
4
  /** Seed of a repro that pins no rng state, the seed `saveOf` writes. */
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as HAPTIC_KINDS, $t as PASS_KINDS, A as types_exports$17, At as Traced, B as types_exports$7, Bt as Glow, C as defineFeature, Ct as PointerOver, D as defineBundles, Dt as Tappable, E as music, Et as Swipeable, F as types_exports$12, Ft as Emitter, G as types_exports$2, Gt as audioPlugin, H as types_exports$5, Ht as Outline, I as types_exports$11, It as Alpha, J as uiPlugin, Jt as animPlugin, K as types_exports$1, Kt as scenesPlugin, L as types_exports$10, Lt as Blur, M as types_exports$15, Mt as messageArgument, N as types_exports$14, Nt as messageDuration, O as load, Ot as Touchable, P as types_exports$13, Pt as effectsPlugin, Q as platformPlugin, Qt as rendererPlugin, R as types_exports$9, Rt as ColorMatrix, S as tr, St as Pointer, T as defineEmitter, Tt as Pressed, U as types_exports$4, Ut as defineFilter, V as types_exports$6, Vt as Noise, W as types_exports$3, Wt as debugPlugin, X as defineMotion, Xt as Animation, Y as resolve, Yt as AnimPlayer, Z as textPlugin, Zt as Frames, _ as guide, _n as modelPlugin, _t as inputPlugin, a as Vignette, an as PROBLEM_RULES, at as parallel, b as projection, bn as lifecyclePlugin, bt as Held, c as RevealLine, cn as DEMAND_REASONS, ct as set, d as Flash, dt as spawned, en as frameAt, et as defineAnimation, f as Dissolve, fn as contribution, ft as stagger, g as defineEffect, gn as type, gt as wait, h as cubicBezier, hn as to, ht as use, i as screen, in as PERF_LOG_VERSION, it as mark, j as types_exports$16, jt as i18nPlugin, k as ready, kt as Traceable, l as Grade, ln as worldPlugin, lt as sfx, m as Aura, mn as slot, mt as tween, n as createPlugin, nn as PERF_CAUSES, nt as frames, o as Shine, on as SHADER_WHATS, ot as play, p as Bloom, pn as exit, pt as stopSfx, q as types_exports, qt as assetsPlugin, r as defineGame, rn as PERF_GAP_BUCKETS, rt as haptic, s as RevealRound, sn as CANVAS_RESTARTS, st as sequence, t as createApp, tn as MONITOR_SECTIONS, tt as external, u as Fold, un as flowPlugin, ut as spawn, v as hint, vn as SaveUnreadableError, vt as Draggable, w as flattenFeatures, wt as Pressable, x as defineScene, xn as timePlugin, xt as Hovered, y as schedule, yn as clockPlugin, yt as DropTarget, z as types_exports$8, zt as Displacement } from "./src-BR2Uw9Xz.mjs";
1
+ import { $ as HAPTIC_KINDS, $t as PASS_KINDS, A as types_exports$17, At as Traced, B as types_exports$7, Bt as Glow, C as defineFeature, Ct as PointerOver, D as defineBundles, Dt as Tappable, E as music, Et as Swipeable, F as types_exports$12, Ft as Emitter, G as types_exports$2, Gt as audioPlugin, H as types_exports$5, Ht as Outline, I as types_exports$11, It as Alpha, J as uiPlugin, Jt as animPlugin, K as types_exports$1, Kt as scenesPlugin, L as types_exports$10, Lt as Blur, M as types_exports$15, Mt as messageArgument, N as types_exports$14, Nt as messageDuration, O as load, Ot as Touchable, P as types_exports$13, Pt as effectsPlugin, Q as platformPlugin, Qt as rendererPlugin, R as types_exports$9, Rt as ColorMatrix, S as tr, St as Pointer, T as defineEmitter, Tt as Pressed, U as types_exports$4, Ut as defineFilter, V as types_exports$6, Vt as Noise, W as types_exports$3, Wt as debugPlugin, X as defineMotion, Xt as Animation, Y as resolve, Yt as AnimPlayer, Z as textPlugin, Zt as Frames, _ as guide, _n as modelPlugin, _t as inputPlugin, a as Vignette, an as PROBLEM_RULES, at as parallel, b as projection, bn as lifecyclePlugin, bt as Held, c as RevealLine, cn as DEMAND_REASONS, ct as set, d as Flash, dt as spawned, en as frameAt, et as defineAnimation, f as Dissolve, fn as contribution, ft as stagger, g as defineEffect, gn as type, gt as wait, h as cubicBezier, hn as to, ht as use, i as screen, in as PERF_LOG_VERSION, it as mark, j as types_exports$16, jt as i18nPlugin, k as ready, kt as Traceable, l as Grade, ln as worldPlugin, lt as sfx, m as Aura, mn as slot, mt as tween, n as createPlugin, nn as PERF_CAUSES, nt as frames, o as Shine, on as SHADER_WHATS, ot as play, p as Bloom, pn as exit, pt as stopSfx, q as types_exports, qt as assetsPlugin, r as defineGame, rn as PERF_GAP_BUCKETS, rt as haptic, s as RevealRound, sn as CANVAS_RESTARTS, st as sequence, t as createApp, tn as MONITOR_SECTIONS, tt as external, u as Fold, un as flowPlugin, ut as spawn, v as hint, vn as SaveUnreadableError, vt as Draggable, w as flattenFeatures, wt as Pressable, x as defineScene, xn as timePlugin, xt as Hovered, y as schedule, yn as clockPlugin, yt as DropTarget, z as types_exports$8, zt as Displacement } from "./src-DRt212D0.mjs";
2
2
  import { $ as Overlay, D as defineStyle, E as defineTokens, L as defineTextFormats, M as Countdown, N as Text, P as bind, Q as NineSlice, R as defineTextStyles, X as Display, Z as HudPart, _ as DebugTrigger, ct as Exiting, dt as Order, ft as Tree, gt as system, h as Box, ht as resource, it as Transform, lt as Layer, mt as mut, nt as Shape, pt as component, rt as Sprite, st as sprite, tt as Parent, ut as Now, vt as tag, w as popup, x as ScrollState, y as LocalWrite, z as label } from "./visual-x0TPowBE.mjs";
3
3
  import { t as defineComponent } from "./component-DGg5DqKK.mjs";
4
4
  export { Alpha, types_exports as Anim, AnimPlayer, Animation, types_exports$1 as Assets, types_exports$2 as Audio, Aura, Bloom, Blur, Box, CANVAS_RESTARTS, types_exports$3 as Clock, ColorMatrix, Countdown, DEMAND_REASONS, types_exports$4 as Debug, DebugTrigger, Displacement, Display, Dissolve, Draggable, DropTarget, types_exports$5 as Effects, Emitter, Exiting, Flash, types_exports$6 as Flow, Fold, Frames, Glow, Grade, HAPTIC_KINDS, Held, Hovered, HudPart, types_exports$7 as I18n, types_exports$8 as Input, Layer, types_exports$9 as Lifecycle, LocalWrite, MONITOR_SECTIONS, types_exports$10 as Model, NineSlice, Noise, Now, Order, Outline, Overlay, PASS_KINDS, PERF_CAUSES, PERF_GAP_BUCKETS, PERF_LOG_VERSION, PROBLEM_RULES, Parent, types_exports$11 as Platform, Pointer, PointerOver, Pressable, Pressed, types_exports$12 as Renderer, RevealLine, RevealRound, SHADER_WHATS, SaveUnreadableError, types_exports$13 as Scenes, ScrollState, Shape, Shine, Sprite, Swipeable, Tappable, Text, types_exports$14 as TextTypes, types_exports$15 as Time, Touchable, Traceable, Traced, Transform, Tree, types_exports$16 as Ui, Vignette, types_exports$17 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, contribution, createApp, createPlugin, cubicBezier, debugPlugin, defineAnimation, defineBundles, defineComponent, defineEffect, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextFormats, defineTextStyles, defineTokens, effectsPlugin, exit, external, flattenFeatures, flowPlugin, frameAt, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, messageArgument, messageDuration, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, ready, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, stopSfx, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
@@ -1,6 +1,6 @@
1
- import { a as sheetAlone, m as graphHash } from "./capture-BuVczpxc.mjs";
1
+ import { g as graphHash, n as namedBundles, s as sheetAlone, t as isSceneDefinition } from "./bundles-YzDqsUJn.mjs";
2
2
  import { a as isDev, i as isControl, n as controlRefused, o as notInstalled, r as isAgent, t as controlReadOnly } from "./dev-BNndV-hU.mjs";
3
- import { n as reproBookmark } from "./headless-BuXptVI_.mjs";
3
+ import { n as reproBookmark } from "./headless-yi2XmYWC.mjs";
4
4
  import { a as readTarget, c as defineCommand, i as isProjectionTarget, n as isTainted, o as checkInput, r as recordCheat, s as inputOrEmpty, u as inputSchema } from "./session-ClUqpGId.mjs";
5
5
  //#region src/plugins/anim/control.ts
6
6
  /**
@@ -1120,6 +1120,68 @@ const scrollCommand = defineCommand({
1120
1120
  //#region src/plugins/flow/control.ts
1121
1121
  const noPayload = null;
1122
1122
  /**
1123
+ * Asks a scene what it names for a state. A scene whose `bundles` throws for that state names only
1124
+ * its own bundle here: the `scene` stage of the restored node meets the throw itself.
1125
+ *
1126
+ * @param scene - The scene declaration.
1127
+ * @param state - The player and session of the bookmark, frozen.
1128
+ * @returns The bundle names, the scene bundle first.
1129
+ */
1130
+ function namedOrOwn(scene, state) {
1131
+ try {
1132
+ return namedBundles(scene, state);
1133
+ } catch {
1134
+ return [scene.bundle];
1135
+ }
1136
+ }
1137
+ /**
1138
+ * Lists the bundles the mounted scene and the bookmark's scene name for the bookmark's state.
1139
+ *
1140
+ * @param app - The app with the screen plugins.
1141
+ * @param bookmark - The bookmark about to be entered.
1142
+ * @returns The bundle names, each once.
1143
+ */
1144
+ function bundlesFor(app, bookmark) {
1145
+ const wanted = /* @__PURE__ */ new Set([app.scenes?.current(), bookmark.scene]);
1146
+ const state = Object.freeze({
1147
+ player: bookmark.player,
1148
+ session: bookmark.session
1149
+ });
1150
+ const names = /* @__PURE__ */ new Set();
1151
+ for (const feature of app.flow.features.all()) {
1152
+ const list = feature.description.scenes;
1153
+ const scenes = Array.isArray(list) ? list.filter((entry) => isSceneDefinition(entry)) : [];
1154
+ for (const scene of scenes) if (wanted.has(scene.id)) for (const name of namedOrOwn(scene, state)) names.add(name);
1155
+ }
1156
+ return [...names];
1157
+ }
1158
+ /**
1159
+ * Loads what the mounted scene and the bookmark's scene name for the bookmark's state, before the
1160
+ * state lands (F199). The mounted scene stays on screen through a restore, and its views read the
1161
+ * committed state at once: a state that landed first would be drawn from bundles nobody loaded.
1162
+ * The names are held as a coming scene's while they load, so no release at the next rest lets
1163
+ * them go before the restored node's `scene` stage names them; the next list of a mounted scene
1164
+ * ends that hold.
1165
+ *
1166
+ * @param app - The app; without `assets` or a mounted scene, nothing is loaded.
1167
+ * @param bookmark - The bookmark about to be entered.
1168
+ * @returns A promise that resolves once every named bundle is in.
1169
+ * @throws {Error} What a load rejected with: the restore is refused before the state changes.
1170
+ */
1171
+ async function loadBundlesFor(app, bookmark) {
1172
+ const assets = app.assets;
1173
+ if (assets === void 0 || app.scenes === void 0) return;
1174
+ const names = bundlesFor(app, bookmark);
1175
+ if (names.length === 0) return;
1176
+ assets.sceneComing(names);
1177
+ try {
1178
+ for (const name of names) await assets.load(name);
1179
+ } catch (error) {
1180
+ assets.sceneComing([]);
1181
+ throw error;
1182
+ }
1183
+ }
1184
+ /**
1123
1185
  * Restores a bookmark with its `scene` expected first, so the node the restore enters mounts it.
1124
1186
  * A refused restore puts the record back to the mounted scene, when one is mounted: no later
1125
1187
  * node switches to the scene of a bookmark that was never entered. With nothing mounted the
@@ -1131,6 +1193,7 @@ const noPayload = null;
1131
1193
  */
1132
1194
  async function restoreWithScene(app, bookmark) {
1133
1195
  const mounted = app.scenes?.current();
1196
+ await loadBundlesFor(app, bookmark);
1134
1197
  if (bookmark.scene !== void 0) app.scenes?.expect(bookmark.scene);
1135
1198
  try {
1136
1199
  await app.flow.restore(bookmark);
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
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
- import { _ as slotNames, c as pageNow$1, f as findNode, g as restlessCapOf, h as isRestCheckpoint, i as servePaused, l as collectFlows, m as graphHash, n as captureFrame, o as afterTask, p as framePath, r as serveCaptures, s as epochOf, t as cancelCaptures, u as describeGraph, v as compact, y as pushEntry } from "./capture-BuVczpxc.mjs";
4
+ import { _ as isRestCheckpoint, a as serveCaptures, b as compact, c as afterTask, d as collectFlows, f as describeGraph, g as graphHash, h as framePath, i as captureFrame, l as epochOf, m as findNode, n as namedBundles, o as servePaused, r as cancelCaptures, t as isSceneDefinition, u as pageNow$1, v as restlessCapOf, x as pushEntry, y as slotNames } from "./bundles-YzDqsUJn.mjs";
5
5
  import { $ as Overlay, A as unitOf, B as readStyle, C as UiCounters, F as boldLookOf, G as parentOf$1, H as applyPose, I as builtInStyles, J as rootPoseInto, K as poseUnder, M as Countdown, N as Text, O as formatBound, Q as NineSlice, S as UI_OWNER, T as uiFor, U as isLeaving, V as textFor, W as localPoseOf, X as Display, Y as rootPoseOf, Z as HudPart, _ as DebugTrigger, _t as systemsFor, a as fieldsLeftAlone, at as arcDefaults, b as Scroll, c as namedKeyOf, ct as Exiting, d as samePose, dt as Order, et as OverlayLevel, f as visualOf$1, ft as Tree, g as Covered, gt as system, h as Box, ht as resource, i as drawnRect, it as Transform, j as wholeValue, k as isTextFormat, l as namesFormat, lt as Layer, m as writtenKeyOf, n as CONTENT$1, nt as Shape, o as fitScaleOf, ot as componentsFor, p as visualRectOf, pt as component, q as rootPointOf, r as bindOf, rt as Sprite, s as livePatch, tt as Parent, u as restValueOf, ut as Now, v as Escapable, vt as tag, x as ScrollState, y as LocalWrite, yt as neutralOf } from "./visual-x0TPowBE.mjs";
6
6
  import { a as isDev$1 } from "./dev-BNndV-hU.mjs";
7
7
  import { n as isComponentDefinition } from "./component-DGg5DqKK.mjs";
@@ -44066,97 +44066,6 @@ function unloadIfLeft(ctx, name, onStack) {
44066
44066
  unloadBundle(ctx, name, "leave");
44067
44067
  }
44068
44068
  //#endregion
44069
- //#region src/plugins/scenes/bundles.ts
44070
- /**
44071
- * Tells whether what a scene's `bundles` returned is a list of bundle names.
44072
- *
44073
- * @param value - The return value of `bundles(state)`.
44074
- * @returns True for an array whose every entry is a string.
44075
- * @example
44076
- * ```ts
44077
- * isNameList(["ep01", 3]); // false
44078
- * ```
44079
- */
44080
- function isNameList$1(value) {
44081
- return Array.isArray(value) && value.every((name) => typeof name === "string");
44082
- }
44083
- /**
44084
- * Lists the bundles a scene names for a committed state: its `bundle` first, then what its
44085
- * `bundles(state)` returns, in order, each name once. An error the game's `bundles` throws
44086
- * propagates unchanged. With a memo, a scene is asked once per committed state: while `player`
44087
- * and `session` are the trees it last answered for, the same frozen list comes back and `bundles`
44088
- * is not called (F194: the look-ahead asked every scene of the neighbourhood at every rest).
44089
- *
44090
- * @param scene - The scene declaration.
44091
- * @param state - The committed player and session, frozen.
44092
- * @param memo - The last answer of each scene, kept by the plugin that asks; none to ask every time.
44093
- * @returns The bundle names, the scene bundle first; frozen when they come from the memo.
44094
- * @throws {Error} When `bundles` returns something that is not a list of names.
44095
- * @example
44096
- * ```ts
44097
- * // assets pins what the scene of the node being entered names, read from the committed state.
44098
- * const { player, session } = model.store.snapshot();
44099
- * namedBundles(wardScene, { player, session }); // ["location", "ep01"] while session.episode is "ep01"
44100
- * ```
44101
- */
44102
- function namedBundles(scene, state, memo) {
44103
- const known = memo?.get(scene);
44104
- if (known !== void 0 && known.player === state.player && known.session === state.session) return known.names;
44105
- const names = Object.freeze(readNames(scene, state));
44106
- memo?.set(scene, {
44107
- player: state.player,
44108
- session: state.session,
44109
- names
44110
- });
44111
- return names;
44112
- }
44113
- /**
44114
- * Asks a scene for its bundles: its `bundle`, then what `bundles(state)` returns, each name once.
44115
- *
44116
- * @param scene - The scene declaration.
44117
- * @param state - The committed player and session, frozen.
44118
- * @returns A new list of names, the scene bundle first.
44119
- * @throws {Error} When `bundles` returns something that is not a list of names.
44120
- */
44121
- function readNames(scene, state) {
44122
- const names = [scene.bundle];
44123
- if (scene.bundles === void 0) return names;
44124
- const listed = scene.bundles(state);
44125
- if (!isNameList$1(listed)) throw new Error(`[game] Scene "${scene.id}": bundles() must return a list of bundle names.\n Return the bundle keys the scene needs, such as ["ep01"].`);
44126
- for (const name of listed) if (!names.includes(name)) names.push(name);
44127
- return names;
44128
- }
44129
- /**
44130
- * Tells whether the `bundles` slot of an entry can be called: absent, `undefined` or a function.
44131
- *
44132
- * @param entry - One entry of a feature's `scenes` list.
44133
- * @returns True when the switch can call what the slot holds, or there is nothing to call.
44134
- * @example
44135
- * ```ts
44136
- * hasCallableBundles({ bundles: 3 }); // false
44137
- * ```
44138
- */
44139
- function hasCallableBundles(entry) {
44140
- if (!("bundles" in entry)) return true;
44141
- return entry.bundles === void 0 || typeof entry.bundles === "function";
44142
- }
44143
- /**
44144
- * Tells whether one entry of a feature's `scenes` list is a scene declaration. The key carries
44145
- * whatever the game put there, so an entry that is not one is skipped instead of crashing.
44146
- *
44147
- * @param entry - One entry of the list.
44148
- * @returns True when the entry can be read as a scene.
44149
- * @example
44150
- * ```ts
44151
- * isSceneDefinition({ id: "board", bundle: "board", layers: [], projections: [] }); // true
44152
- * isSceneDefinition("board"); // false: a scene is an object
44153
- * isSceneDefinition({ id: "ward", bundle: "location", layers: [], projections: [], bundles: 3 }); // false
44154
- * ```
44155
- */
44156
- function isSceneDefinition(entry) {
44157
- return typeof entry === "object" && entry !== null && "id" in entry && typeof entry.id === "string" && "bundle" in entry && typeof entry.bundle === "string" && "layers" in entry && Array.isArray(entry.layers) && "projections" in entry && Array.isArray(entry.projections) && hasCallableBundles(entry);
44158
- }
44159
- //#endregion
44160
44069
  //#region src/plugins/assets/browser.ts
44161
44070
  /**
44162
44071
  * Fetches one URL with the global `fetch`.
package/dist/testing.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-BR2Uw9Xz.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-DRt212D0.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
4
- import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-BuXptVI_.mjs";
4
+ import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-yi2XmYWC.mjs";
5
5
  //#region src/testing/fake-fx.ts
6
6
  /** The node path a refused `fx.start` names when the test gives none. */
7
7
  const defaultPath = "test";
@@ -3,7 +3,7 @@ import { W as AnimApi, r as UiApi } from "./types-BDCkyWXq.mjs";
3
3
  import { R as InputApi } from "./types-rsz4pIqe.mjs";
4
4
  import { r as Repro } from "./headless-BcgzSec_.mjs";
5
5
  import { i as ControlApp, o as InputOf } from "./types-C2hkiREP.mjs";
6
- import { t as commands } from "./commands-7RWSJMv7.mjs";
6
+ import { t as commands } from "./commands-DjcKboFw.mjs";
7
7
 
8
8
  //#region src/visual/types.d.ts
9
9
  /** The base commands of the `/control` door, keyed by their short names. */
package/dist/visual.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-xIubQ2dq.mjs";
1
+ import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-BotWUgoW.mjs";
2
2
  export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
package/dist/visual.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
2
2
  import { n as read, t as sources } from "./sources-D9Fk3Z4d.mjs";
3
- import { n as commands, t as run } from "./run-1i_SfbM4.mjs";
3
+ import { n as commands, t as run } from "./run-BVW1feQ2.mjs";
4
4
  import path from "node:path";
5
5
  import { createBrandConsole } from "@moku-labs/common/cli";
6
6
  import { mkdir, readFile, writeFile } from "node:fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.145",
3
+ "version": "0.15.146",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [