@moku-labs/game 0.15.158 → 0.15.160

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 { Xt as audioPlugin, i as screen, k as flattenFeatures, rt as platformPlugin, t as createApp, zt as effectsPlugin } from "./src-BCuqGRF9.mjs";
1
+ import { Xt as audioPlugin, i as screen, k as flattenFeatures, rt as platformPlugin, t as createApp, zt as effectsPlugin } from "./src-qeTzNTZA.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 uiPlugin, $t as animPlugin, A as defineEmitter, At as Pressed, B as types_exports$12, Bt as Emitter, C as hint, Cn as SaveUnreadableError, Ct as Draggable, D as tr, Dt as Pointer, E as defineScene, En as timePlugin, Et as Hovered, F as types_exports$17, Ft as Traced, G as types_exports$7, Gt as Glow, H as types_exports$10, Ht as Blur, I as types_exports$16, It as i18nPlugin, J as types_exports$4, Jt as defineFilter, K as types_exports$6, Kt as Noise, L as types_exports$15, Lt as messageArgument, M as defineBundles, Mt as Tappable, N as load, Nt as Touchable, O as defineFeature, Ot as PointerOver, P as ready, Pt as Traceable, Q as types_exports, Qt as assetsPlugin, R as types_exports$14, Rt as messageDuration, S as guide, Sn as modelPlugin, St as inputPlugin, T as projection, Tn as lifecyclePlugin, Tt as Held, U as types_exports$9, Ut as ColorMatrix, V as types_exports$11, Vt as Alpha, W as types_exports$8, Wt as Displacement, X as types_exports$2, Xt as audioPlugin, Y as types_exports$3, Yt as debugPlugin, Z as types_exports$1, Zt as scenesPlugin, _ as Dissolve, _n as contribution, _t as stagger, a as Wave, an as frameAt, at as defineAnimation, b as cubicBezier, bn as to, bt as use, c as Shadow, cn as PERF_GAP_BUCKETS, ct as haptic, d as Pixelate, dn as SHADER_WHATS, dt as play, en as AnimPlayer, et as resolve, f as Mirror, fn as CANVAS_RESTARTS, ft as sequence, g as Flash, gt as spawned, h as Fold, hn as flowPlugin, ht as spawn, i as screen, in as PASS_KINDS, it as HAPTIC_KINDS, j as music, jt as Swipeable, k as flattenFeatures, kt as Pressable, l as RevealRound, ln as PERF_LOG_VERSION, lt as mark, m as Grade, mn as worldPlugin, mt as sfx, n as createPlugin, nn as Frames, nt as textPlugin, o as Vignette, on as MONITOR_SECTIONS, ot as external, p as GradientMap, pn as DEMAND_REASONS, pt as set, q as types_exports$5, qt as Outline, r as defineGame, rn as rendererPlugin, rt as platformPlugin, s as Shine, sn as PERF_CAUSES, st as frames, t as createApp, tn as Animation, tt as defineMotion, u as RevealLine, un as PROBLEM_RULES, ut as parallel, v as Bloom, vn as exit, vt as stopSfx, w as schedule, wn as clockPlugin, wt as DropTarget, x as defineEffect, xn as type, xt as wait, y as Aura, yn as slot, yt as tween, z as types_exports$13, zt as effectsPlugin } from "./src-BCuqGRF9.mjs";
1
+ import { $ as uiPlugin, $t as animPlugin, A as defineEmitter, At as Pressed, B as types_exports$12, Bt as Emitter, C as hint, Cn as SaveUnreadableError, Ct as Draggable, D as tr, Dt as Pointer, E as defineScene, En as timePlugin, Et as Hovered, F as types_exports$17, Ft as Traced, G as types_exports$7, Gt as Glow, H as types_exports$10, Ht as Blur, I as types_exports$16, It as i18nPlugin, J as types_exports$4, Jt as defineFilter, K as types_exports$6, Kt as Noise, L as types_exports$15, Lt as messageArgument, M as defineBundles, Mt as Tappable, N as load, Nt as Touchable, O as defineFeature, Ot as PointerOver, P as ready, Pt as Traceable, Q as types_exports, Qt as assetsPlugin, R as types_exports$14, Rt as messageDuration, S as guide, Sn as modelPlugin, St as inputPlugin, T as projection, Tn as lifecyclePlugin, Tt as Held, U as types_exports$9, Ut as ColorMatrix, V as types_exports$11, Vt as Alpha, W as types_exports$8, Wt as Displacement, X as types_exports$2, Xt as audioPlugin, Y as types_exports$3, Yt as debugPlugin, Z as types_exports$1, Zt as scenesPlugin, _ as Dissolve, _n as contribution, _t as stagger, a as Wave, an as frameAt, at as defineAnimation, b as cubicBezier, bn as to, bt as use, c as Shadow, cn as PERF_GAP_BUCKETS, ct as haptic, d as Pixelate, dn as SHADER_WHATS, dt as play, en as AnimPlayer, et as resolve, f as Mirror, fn as CANVAS_RESTARTS, ft as sequence, g as Flash, gt as spawned, h as Fold, hn as flowPlugin, ht as spawn, i as screen, in as PASS_KINDS, it as HAPTIC_KINDS, j as music, jt as Swipeable, k as flattenFeatures, kt as Pressable, l as RevealRound, ln as PERF_LOG_VERSION, lt as mark, m as Grade, mn as worldPlugin, mt as sfx, n as createPlugin, nn as Frames, nt as textPlugin, o as Vignette, on as MONITOR_SECTIONS, ot as external, p as GradientMap, pn as DEMAND_REASONS, pt as set, q as types_exports$5, qt as Outline, r as defineGame, rn as rendererPlugin, rt as platformPlugin, s as Shine, sn as PERF_CAUSES, st as frames, t as createApp, tn as Animation, tt as defineMotion, u as RevealLine, un as PROBLEM_RULES, ut as parallel, v as Bloom, vn as exit, vt as stopSfx, w as schedule, wn as clockPlugin, wt as DropTarget, x as defineEffect, xn as type, xt as wait, y as Aura, yn as slot, yt as tween, z as types_exports$13, zt as effectsPlugin } from "./src-qeTzNTZA.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, GradientMap, HAPTIC_KINDS, Held, Hovered, HudPart, types_exports$7 as I18n, types_exports$8 as Input, Layer, types_exports$9 as Lifecycle, LocalWrite, MONITOR_SECTIONS, Mirror, types_exports$10 as Model, NineSlice, Noise, Now, Order, Outline, Overlay, PASS_KINDS, PERF_CAUSES, PERF_GAP_BUCKETS, PERF_LOG_VERSION, PROBLEM_RULES, Parent, Pixelate, 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, Shadow, 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, Wave, 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 };
@@ -10888,11 +10888,40 @@ function deepEquals(left, right) {
10888
10888
  if (left === right) return true;
10889
10889
  if (left === null || right === null) return false;
10890
10890
  if (typeof left !== "object" || typeof right !== "object") return false;
10891
- if (Array.isArray(left)) return Array.isArray(right) && left.length === right.length && left.every((entry, index) => deepEquals(entry, right[index]));
10891
+ if (Array.isArray(left)) return Array.isArray(right) && sameEntries(left, right);
10892
10892
  if (Array.isArray(right)) return false;
10893
- const keys = Object.keys(left);
10894
- if (keys.length !== Object.keys(right).length) return false;
10895
- return keys.every((key) => deepEquals(left[key], right[key]));
10893
+ return sameFields$1(left, right);
10894
+ }
10895
+ /**
10896
+ * Compares two arrays entry by entry, with an index loop: no closure and no iterator.
10897
+ *
10898
+ * @param left - First array.
10899
+ * @param right - Second array.
10900
+ * @returns True when both have the same length and equal entries.
10901
+ */
10902
+ function sameEntries(left, right) {
10903
+ if (left.length !== right.length) return false;
10904
+ for (let index = 0; index < left.length; index += 1) if (!deepEquals(left[index], right[index])) return false;
10905
+ return true;
10906
+ }
10907
+ /**
10908
+ * Compares the own fields of two objects: every field of `left` equals the same field of `right`,
10909
+ * and both have as many own fields. A `for…in` with an own check reads the keys without the array
10910
+ * `Object.keys` builds, so a compare allocates nothing; the result is the one `Object.keys` gave.
10911
+ *
10912
+ * @param left - First object.
10913
+ * @param right - Second object.
10914
+ * @returns True when both hold the same data.
10915
+ */
10916
+ function sameFields$1(left, right) {
10917
+ let count = 0;
10918
+ for (const key in left) {
10919
+ if (!Object.hasOwn(left, key)) continue;
10920
+ count += 1;
10921
+ if (!deepEquals(left[key], right[key])) return false;
10922
+ }
10923
+ for (const key in right) if (Object.hasOwn(right, key)) count -= 1;
10924
+ return count === 0;
10896
10925
  }
10897
10926
  /**
10898
10927
  * Reads the node a `Tree` value carries. A tag stores `true` and carries none.
@@ -13533,7 +13562,8 @@ function settleUnchanged(pctx, spec, view, entry) {
13533
13562
  * @param counts - The counters of this reconcile.
13534
13563
  */
13535
13564
  function applyLive(pctx, spec, mounted, live, entry, counts) {
13536
- const same = !entry.force && live.item === entry.item;
13565
+ const same = !entry.force && (live.item === entry.item || !entry.direct && deepEquals(live.item, entry.item));
13566
+ if (same) live.item = entry.item;
13537
13567
  const swap = same ? void 0 : swapFor(pctx, spec, live, entry.item);
13538
13568
  if (swap !== void 0) {
13539
13569
  if (swapEntry(pctx, spec, mounted, live, swap, entry)) counts.entered += 1;
@@ -17657,6 +17687,19 @@ function wantsBackBuffer(features) {
17657
17687
  return false;
17658
17688
  }
17659
17689
  /**
17690
+ * The canvas format the platform composites without a conversion (`rgba8unorm` on Android, `bgra8unorm` on desktop).
17691
+ * A WebGPU canvas in another format makes Chromium hold a converted copy while frames are drawn: on the A26 about
17692
+ * 10 MB of GPU memory more for as long as every frame is drawn (F226). Unknown on a page without WebGPU.
17693
+ * A game with a backdrop filter keeps Pixi's bgra8unorm: Pixi copies the canvas into a pool texture of that format,
17694
+ * and a copy needs both in one format.
17695
+ *
17696
+ * @returns The preferred format, or `undefined` without `navigator.gpu`.
17697
+ */
17698
+ function preferredCanvasFormat() {
17699
+ const gpu = typeof globalThis.navigator === "undefined" ? void 0 : globalThis.navigator.gpu;
17700
+ return typeof gpu?.getPreferredCanvasFormat === "function" ? gpu.getPreferredCanvasFormat() : void 0;
17701
+ }
17702
+ /**
17660
17703
  * Loads Pixi once, creates the application and appends its canvas, at the target resolution of
17661
17704
  * now: a restore after a lost device comes back at it, override included. Pixi picks WebGL by
17662
17705
  * itself when WebGPU is missing, so only a device with neither ends up in the catch of the
@@ -17683,7 +17726,10 @@ async function createApplication(ctx, mount, deps) {
17683
17726
  state.resolution.cap = ctx.config.maxResolution;
17684
17727
  state.resolution.pending = void 0;
17685
17728
  const app = new pixi.Application();
17729
+ const backBuffer = wantsBackBuffer(ctx.deps.flow.features.all());
17730
+ const format = backBuffer ? void 0 : preferredCanvasFormat();
17686
17731
  const options = {
17732
+ ...format === void 0 ? {} : { format },
17687
17733
  preference: ctx.config.preference,
17688
17734
  background: ctx.config.background,
17689
17735
  antialias: ctx.config.antialias,
@@ -17691,7 +17737,7 @@ async function createApplication(ctx, mount, deps) {
17691
17737
  autoDensity: false,
17692
17738
  autoStart: false,
17693
17739
  sharedTicker: false,
17694
- useBackBuffer: wantsBackBuffer(ctx.deps.flow.features.all()),
17740
+ useBackBuffer: backBuffer,
17695
17741
  eventMode: "none",
17696
17742
  eventFeatures: {
17697
17743
  move: false,
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { gn as refuseStart, k as flattenFeatures, t as createApp, vn as exit, xn as type } from "./src-BCuqGRF9.mjs";
1
+ import { gn as refuseStart, k as flattenFeatures, t as createApp, vn as exit, xn as type } from "./src-qeTzNTZA.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-yi2XmYWC.mjs";
package/llms.txt CHANGED
@@ -576,6 +576,7 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
576
576
  - `projection({ …, initialOnly: [[Shape, ["sweep"]]] })`: `view` gives those fields once, at the birth of a view; after that they belong to another writer (a system drawing a timer arc from `Now`), and no changed item, motion, end-of-motion check (`world:view-corrected`), rollback, `settle`, restore or load writes or compares them, as with `mute()` for every view's whole life. Field names are checked per component; a pair with no field throws at register. Absent, every field is the projection's.
577
577
  - `projection({ …, warm: (player, session) => item })`: a warm window, since 0.15.47. `warm` returns one item of the type `from` gives, the window as it opens (its closed or default state); while `from` does not show that key, or shows it with another content (a gated window's dim, below), the world builds its view in idle frames (by root and by part, under two thirds of the frame interval, only in a live world on a drawing renderer, never while an owned motion runs but for a gated window's dim) and keeps it hidden: not drawn, not hit, `entityOf` answers nothing. When `from` shows the key, the open only shows the held view in the next frame: an item equal to the warm one writes nothing, another one writes only the difference; `enter` and `loop` play as for a new view. Example, a settings sheet: `projection({ name: "settings.sheet", layer: "ui", from: (player, session) => session.sheet?.kind === "settings" ? [settingsModel(player, session, tables)] : [], key: sheet => sheet.id, view: settingsView, warm: (player, session) => settingsModel(player, { ...session, sheet: { kind: "settings", page: "main" } }, tables) })`. Cost: the memory of the held view (A Memory Missing's album: about +2 MB of JS heap, textures unchanged); after each close the view goes cold and is built again in idle frames (the album: 41–58 frames of work, about a second, at 6× CPU); a commit that changes the warm item rebuilds it, so it suits windows whose item rarely changes (settings, a shop). A `warm` or a `view` that throws logs `world:projection-failed` and the window opens as before. World README, "Warm windows".
578
578
  - A gated window (F202) keeps one key from its dim into its open (`from` shows the dim item, then the open one, while `ready` loads its pictures). Give it a `warm` that answers the open item while the dim shows (and nothing otherwise): the open view is built aside under the dim, also through the press tween of the tapped button (other warm windows wait for that motion to end), and the commit of the open item swaps the views in one frame: the dim view leaves at once (cause `"discard"`, no exit), the held one is shown with its `enter`, only the difference to the warm item written. A commit of the dim's content as a new object swaps nothing. While the dim shows, `entityOf` answers the dim's elements for keys both views have (the root, the scrim) and the open's after the swap. `ready` waits for the build too: it answers `false` while `world.projection.left()` is finite and posts once the build ended, at most 400 ms (game clock) after its bundles settled. World README, "A gated window".
579
+ - A play reconcile takes an item with the same content as the last one (equal as plain data, also as a new object) as unchanged: `view` does not run, a screen keeps its node and `ui` does not reconcile it (F230: a merge hands ~70 board items out as new objects). `view` is a projection of its item: a value it reads from elsewhere shows with the next changed item, a forced rerun or a locale. World README, "When an item did not change".
579
580
  - `from(player, session, sw)`: the third argument is the switch another plugin last handed the projection with `projection.feed(name, sw)`, a `SceneSwitch` `{ from, to, progress }` (the scene left, the scene entered, `progress` 0 to 1), `undefined` for a projection never fed; a `from` with two parameters reads the state alone, as before. A loader reads it: `from: (_player, _session, sw: SceneSwitch | undefined) => ({ to: sw?.to ?? "", progress: sw?.progress ?? 0 })`. World README, "Feeding a projection".
580
581
  - `app.input.lock.window(rect | null | undefined)`: the input lock `ui` sets for a guide (`Input.LockWindow` = `{ x, y, w, h }` in reference units, kept by reference and written in place); a press outside reaches no view and answers `flow.gate.state().blocked` or nothing, a drop or trace sample outside finds nothing; `null` locks everything, `undefined` lifts it. The doors `tap`, `press`, `drag`, `swipe`, `trace` are never locked.
581
582
  - `input`: one followed pointer. A finger that has not started a gesture (pressed, inside the tap slop, no long press, no trace) gives way to the next finger that goes down, wherever it rests, and its press is cancelled; a finger that started a gesture keeps it. `Pointer.id` is the followed `pointerId` (`-1` at rest): a system that measures the finger's travel starts over when it changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.158",
3
+ "version": "0.15.160",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [