@moku-labs/game 0.15.131 → 0.15.133

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-BM3N5FXk.mjs";
1
+ import { Gt as audioPlugin, Pt as effectsPlugin, Q as platformPlugin, i as screen, t as createApp, w as flattenFeatures } from "./src-C6CJ7f20.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
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-BM3N5FXk.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-C6CJ7f20.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 };
@@ -17985,18 +17985,152 @@ function storeMatrix(cells, at, matrix) {
17985
17985
  //#endregion
17986
17986
  //#region src/plugins/renderer/sources.ts
17987
17987
  /**
17988
- * Destroys a texture with its source, after the `change` listeners of the source and of its style
17989
- * are removed: Pixi 8.22 caches batch and filter bind groups forever, and each one warns
17990
- * `[BindGroup] ... destroyed while still bound to a shader` when a source it holds goes. For every
17991
- * texture the renderer owns whole: loaded files, kept pictures, the warm-up target.
17988
+ * Destroys a texture with its source, after every bind group that binds the source let go of it. Pixi 8.22 caches
17989
+ * the bind group of every batch it drew, forever, and each listens to `change` on the source and on its style: left
17990
+ * alone, a group warns `[BindGroup] ... destroyed while still bound to a shader` when the source goes, keeps the
17991
+ * destroyed source, and keeps its listeners on `Texture.EMPTY`, which pads every group (F194). For every texture the
17992
+ * renderer owns whole: loaded files, kept pictures, the warm-up target.
17992
17993
  *
17993
17994
  * @param texture - The texture, its source its own.
17994
17995
  */
17995
17996
  function destroyWhole(texture) {
17996
- texture.source.style.removeAllListeners("change");
17997
- texture.source.removeAllListeners("change");
17997
+ const source = texture.source;
17998
+ const style = source.style;
17999
+ const owned = ownsStyle(source);
18000
+ const empty = emptyOf(texture);
18001
+ if (empty !== void 0) releaseBindGroups(source, empty);
18002
+ if (owned) style.removeAllListeners("change");
18003
+ else dropListeners(style, source);
18004
+ source.removeAllListeners("change");
17998
18005
  texture.destroy(true);
17999
18006
  }
18007
+ /**
18008
+ * Makes every Pixi bind group that binds a source let go of it, before the source is destroyed. The group's slots of
18009
+ * the source, and of its style when the source owns it, take `Texture.EMPTY`'s, with no listener: EMPTY never
18010
+ * changes. A group left with no texture source but EMPTY can never be drawn again (Pixi keys the cache by texture
18011
+ * uids, never reused), so its listeners on EMPTY and on any shared style are dropped and its style slots take EMPTY's
18012
+ * too: only the group object stays in Pixi's cache. A group that still binds a live texture keeps every listener.
18013
+ * Allocates nothing.
18014
+ *
18015
+ * @param source - The source about to be destroyed.
18016
+ * @param empty - The source of `Texture.EMPTY`.
18017
+ */
18018
+ function releaseBindGroups(source, empty) {
18019
+ const listeners = source._events?.change;
18020
+ if (listeners === void 0) return;
18021
+ if (!Array.isArray(listeners)) {
18022
+ releaseListener(listeners, source, empty);
18023
+ return;
18024
+ }
18025
+ for (const listener of listeners) releaseListener(listener, source, empty);
18026
+ }
18027
+ /**
18028
+ * Releases the source from one listener's group, when the listener is a bind group's.
18029
+ *
18030
+ * @param listener - A `change` listener of the source.
18031
+ * @param source - The source about to be destroyed.
18032
+ * @param empty - The source of `Texture.EMPTY`.
18033
+ */
18034
+ function releaseListener(listener, source, empty) {
18035
+ const group = listener.context;
18036
+ if (group === null || typeof group !== "object" || listener.fn !== group.onResourceChange) return;
18037
+ if (group.resources === null) return;
18038
+ if (!releaseSlots(group, source, empty)) return;
18039
+ dropDead(group, empty);
18040
+ }
18041
+ /**
18042
+ * Swaps the group's slots of the source, and of its owned style, for EMPTY's, and says whether the group is dead.
18043
+ *
18044
+ * @param group - The bind group.
18045
+ * @param source - The source about to be destroyed.
18046
+ * @param empty - The source of `Texture.EMPTY`.
18047
+ * @returns True when no slot binds a texture source other than EMPTY, nor anything but a style.
18048
+ */
18049
+ function releaseSlots(group, source, empty) {
18050
+ const owned = ownsStyle(source);
18051
+ const style = source.style;
18052
+ const resources = group.resources;
18053
+ const keys = group._resourceKeys;
18054
+ let dead = true;
18055
+ for (const key of keys) {
18056
+ const resource = resources[key];
18057
+ if (resource === source) resources[key] = empty;
18058
+ else if (owned && resource === style) resources[key] = empty.style;
18059
+ else if (bindsMore(resource, empty)) dead = false;
18060
+ }
18061
+ group._dirty = true;
18062
+ return dead;
18063
+ }
18064
+ /**
18065
+ * Whether a slot keeps its group alive: a texture source other than EMPTY, or a resource that is not a style.
18066
+ *
18067
+ * @param resource - The slot's resource.
18068
+ * @param empty - The source of `Texture.EMPTY`.
18069
+ * @returns True when the group may still be drawn with it.
18070
+ */
18071
+ function bindsMore(resource, empty) {
18072
+ if (resource === null || resource === void 0) return false;
18073
+ if (resource === empty) return false;
18074
+ return resource._resourceType !== "textureSampler";
18075
+ }
18076
+ /**
18077
+ * Drops a dead group's listeners from EMPTY's source and style and from any shared style it still binds, whose
18078
+ * slots take EMPTY's style.
18079
+ *
18080
+ * @param group - The dead bind group.
18081
+ * @param empty - The source of `Texture.EMPTY`.
18082
+ */
18083
+ function dropDead(group, empty) {
18084
+ const resources = group.resources;
18085
+ const keys = group._resourceKeys;
18086
+ const emptyStyle = empty.style;
18087
+ for (const key of keys) {
18088
+ const resource = resources[key];
18089
+ if (resource === null || resource === void 0 || resource === emptyStyle) continue;
18090
+ if (resource === empty) continue;
18091
+ dropListeners(resource, group);
18092
+ resources[key] = emptyStyle;
18093
+ }
18094
+ dropListeners(empty, group);
18095
+ dropListeners(empty.style, group);
18096
+ }
18097
+ /**
18098
+ * Removes every `change` listener of one context from an emitter. A list is compacted in place: eventemitter3's own
18099
+ * `off` copies the whole list per call, and EMPTY's lists hold one listener per padding slot of every live group.
18100
+ *
18101
+ * @param emitter - The emitter.
18102
+ * @param context - The context whose listeners go.
18103
+ */
18104
+ function dropListeners(emitter, context) {
18105
+ const listeners = emitter._events?.change;
18106
+ if (listeners === void 0) return;
18107
+ if (!Array.isArray(listeners)) {
18108
+ if (listeners.context === context) emitter.off("change", listeners.fn, context);
18109
+ return;
18110
+ }
18111
+ let kept = 0;
18112
+ for (const listener of listeners) if (listener.context !== context) listeners[kept++] = listener;
18113
+ listeners.length = kept;
18114
+ }
18115
+ /**
18116
+ * The source of `Texture.EMPTY`, read from the texture's own class: every texture class of Pixi inherits the static
18117
+ * `EMPTY` of `Texture`, and the renderer's modules hold no Pixi module here.
18118
+ *
18119
+ * @param texture - Any Pixi texture.
18120
+ * @returns The source of `Texture.EMPTY`; undefined for a texture of no Pixi class, which no bind group binds.
18121
+ */
18122
+ function emptyOf(texture) {
18123
+ return texture.constructor.EMPTY?.source;
18124
+ }
18125
+ /**
18126
+ * Whether a source owns its style: Pixi marks a style handed in from outside as shared (`_ownsStyle` false).
18127
+ *
18128
+ * @param source - The source.
18129
+ * @returns False only for a shared style.
18130
+ */
18131
+ function ownsStyle(source) {
18132
+ return source._ownsStyle !== false;
18133
+ }
18000
18134
  //#endregion
18001
18135
  //#region src/plugins/renderer/kept/render.ts
18002
18136
  /**
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-BM3N5FXk.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-C6CJ7f20.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
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-BuXptVI_.mjs";
package/dist/visual.mjs CHANGED
@@ -1176,7 +1176,7 @@ function pageOracle(event) {
1176
1176
  }
1177
1177
  /**
1178
1178
  * Turns on the pixel check of the frames the renderer skips, through the door `game.debug`, and
1179
- * starts reading the log of the page from its end: from here on, `pageMissed` fails a step on the
1179
+ * starts reading the log of the page after its last line: from here on, `pageMissed` fails a step on the
1180
1180
  * first line of the frame oracles or of `pageBroke`. A `pageBroke` line the page logged while it
1181
1181
  * loaded, before the check, fails the start.
1182
1182
  *
@@ -1188,7 +1188,7 @@ async function pageVerify(_argument) {
1188
1188
  const { game, doors } = pageHandles();
1189
1189
  await doors.run(game, doors.commands.debug, { verifyFrames: true });
1190
1190
  const entries = game.log.trace();
1191
- Reflect.set(globalThis, "__mokuVisualTrace", entries.length);
1191
+ Reflect.set(globalThis, "__mokuVisualTrace", { last: entries.at(-1) });
1192
1192
  for (const entry of entries) if (pageBroke(entry.event)) return {
1193
1193
  ok: false,
1194
1194
  reason: `${entry.event} ${JSON.stringify(entry.data)}`
@@ -1212,10 +1212,12 @@ async function pageVerify(_argument) {
1212
1212
  * @returns The line, as its event and its data, or `undefined` when none was logged.
1213
1213
  */
1214
1214
  function pageMissed(handles) {
1215
- const from = Reflect.get(globalThis, "__mokuVisualTrace");
1216
- if (typeof from !== "number") return void 0;
1215
+ const mark = Reflect.get(globalThis, "__mokuVisualTrace");
1216
+ if (typeof mark !== "object" || mark === null) return void 0;
1217
+ const read = mark;
1217
1218
  const entries = handles.game.log.trace();
1218
- Reflect.set(globalThis, "__mokuVisualTrace", entries.length);
1219
+ const from = entries.lastIndexOf(read.last) + 1;
1220
+ read.last = entries.at(-1);
1219
1221
  for (let at = from; at < entries.length; at += 1) {
1220
1222
  const entry = entries[at];
1221
1223
  if (entry !== void 0 && (pageOracle(entry.event) || pageBroke(entry.event))) return `${entry.event} ${JSON.stringify(entry.data)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.131",
3
+ "version": "0.15.133",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -125,7 +125,7 @@
125
125
  "yoga-layout": "3.2.1"
126
126
  },
127
127
  "peerDependencies": {
128
- "@moku-labs/common": "^0.3.4",
128
+ "@moku-labs/common": "^0.3.12",
129
129
  "@moku-labs/core": "^1.7.1",
130
130
  "@moku-labs/native": "^0.3.13",
131
131
  "@moku-labs/system": "^0.3.1",
@@ -160,7 +160,7 @@
160
160
  "@biomejs/biome": "2.4.16",
161
161
  "@formatjs/icu-messageformat-parser": "3.5.20",
162
162
  "@moku-labs/ci": "1.5.8",
163
- "@moku-labs/common": "0.3.11",
163
+ "@moku-labs/common": "0.3.12",
164
164
  "@moku-labs/core": "1.7.6",
165
165
  "@moku-labs/native": "0.3.15",
166
166
  "@moku-labs/system": "0.3.8",