@moku-labs/game 0.15.1 → 0.15.3
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/page.d.mts +1 -1
- package/dist/app/system.d.mts +3 -3
- package/dist/app.d.mts +3 -3
- package/dist/app.mjs +1 -1
- package/dist/assets.d.mts +1 -1
- package/dist/{commands-BynjWVVy.d.mts → commands-31d2BEwc.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-Ckj_TMWu.d.mts → define-DYJwRXB_.d.mts} +2 -2
- package/dist/{headless-B0mH9qYg.d.mts → headless-D0U5AXiK.d.mts} +1 -1
- package/dist/{index-CCiTo1_3.d.mts → index-ByvWj9OX.d.mts} +42 -6
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +6 -6
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-BV3xv6gx.d.mts → runtime-biKbodaT.d.mts} +1 -1
- package/dist/{src-CwVzErzN.mjs → src-xChMXzwH.mjs} +4553 -1306
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-D44EL4gT.d.mts → types-B0bmoyRT.d.mts} +2 -2
- package/dist/{types-CpdkyhaC.d.mts → types-BApuIqwq.d.mts} +4 -4
- package/dist/{types-Bw-qLjFZ.d.mts → types-CsMLBPf-.d.mts} +150 -43
- package/dist/{types-E2ykwIUO.d.mts → types-DlC3Ytbj.d.mts} +528 -54
- package/dist/{types-G3ZAAsbd.d.mts → types-yLdzHyTl.d.mts} +26 -11
- package/dist/{visual-DoHwXeQi.d.mts → visual-G6F0Mi9H.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/llms.txt +3 -0
- package/package.json +4 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cn as MotionCause, En as ProjectionMotion, Hr as Api, Jt as TransformValue, Mn as Api$1, Mt as ViewportSize, Qr as Require, Sn as Motion, Sr as Json, T as Api$3, Tn as NumericFields, Zt as Api$2, fr as Answer, in as AnyComponentValue, jn as ViewHandle, ln as Entity, nn as AnyComponent, or as Descriptor, pr as Api$5, rn as AnyComponentType, s as Events$1, sn as ComponentType, t as Api$4, ur as Hint, vn as TagType, wn as MotionHandle, yn as ChangeHook } from "./types-DlC3Ytbj.mjs";
|
|
2
2
|
import { Log } from "@moku-labs/common/browser";
|
|
3
3
|
import { PluginCtx } from "@moku-labs/core";
|
|
4
4
|
|
|
@@ -1630,11 +1630,6 @@ type DrawnLabel = {
|
|
|
1630
1630
|
/**
|
|
1631
1631
|
* A dev warning that is written once per key. Pure modules take it as an argument, so nothing
|
|
1632
1632
|
* below the plugin context reaches the log itself.
|
|
1633
|
-
*
|
|
1634
|
-
* @example
|
|
1635
|
-
* ```ts
|
|
1636
|
-
* const warn: Warn = (key, message) => seen.has(key) || log.warn(message);
|
|
1637
|
-
* ```
|
|
1638
1633
|
*/
|
|
1639
1634
|
type Warn = (key: string, message: string, data?: Record<string, unknown>) => void;
|
|
1640
1635
|
/**
|
|
@@ -1651,18 +1646,21 @@ type LayoutOptions = {
|
|
|
1651
1646
|
/**
|
|
1652
1647
|
* What was resolved for one entity last, so the frame step knows whether anything moved. `unit`
|
|
1653
1648
|
* is what the shown string of a bound label was built from: the rounded value for `"int"`, whole
|
|
1654
|
-
* seconds for a time format.
|
|
1649
|
+
* seconds for a time format. `bindRef` is the bind object `bind` was keyed from, so the key is
|
|
1650
|
+
* built once per attached bind and a frame compares one reference.
|
|
1655
1651
|
*
|
|
1656
1652
|
* @example
|
|
1657
1653
|
* ```ts
|
|
1654
|
+
* const left = bind(Countdown, "left", { format: "mm:ss" });
|
|
1658
1655
|
* const seen: SeenText = {
|
|
1659
|
-
* content: "", style: "digits", bind: "Countdown.left:mm:ss", locale: "ru", unit: 95
|
|
1656
|
+
* content: "", style: "digits", bindRef: left, bind: "Countdown.left:mm:ss", locale: "ru", unit: 95
|
|
1660
1657
|
* };
|
|
1661
1658
|
* ```
|
|
1662
1659
|
*/
|
|
1663
1660
|
type SeenText = {
|
|
1664
1661
|
content: unknown;
|
|
1665
1662
|
style: string;
|
|
1663
|
+
bindRef: TextBind | undefined;
|
|
1666
1664
|
bind: string | undefined;
|
|
1667
1665
|
locale: string;
|
|
1668
1666
|
unit: number | undefined;
|
|
@@ -2483,6 +2481,8 @@ type PopupLink = {
|
|
|
2483
2481
|
* popup (its open is an event), the cause of its projection view otherwise, `"mount"` after a
|
|
2484
2482
|
* restore or a load. `slot` is the host element the root is laid out in (`undefined` for the
|
|
2485
2483
|
* viewport), `slotRect` the content box it was last solved in, in the host's own units.
|
|
2484
|
+
* `pending` is true while the solve running now still waits to lay the root out; `mountRoot`
|
|
2485
|
+
* creates it `false`.
|
|
2486
2486
|
*/
|
|
2487
2487
|
type Root = {
|
|
2488
2488
|
entity: Entity;
|
|
@@ -2503,6 +2503,13 @@ type Root = {
|
|
|
2503
2503
|
w: number;
|
|
2504
2504
|
h: number;
|
|
2505
2505
|
} | undefined;
|
|
2506
|
+
pending?: boolean;
|
|
2507
|
+
/**
|
|
2508
|
+
* The release of the hold on the feature the root shows (`world.ecs.hold`): the feature of a
|
|
2509
|
+
* popup's component, or of a JSX projection. Called when the sweep drops the root. Optional
|
|
2510
|
+
* like `pending`: `mountRoot` always writes it.
|
|
2511
|
+
*/
|
|
2512
|
+
held?: (() => void) | undefined;
|
|
2506
2513
|
};
|
|
2507
2514
|
/**
|
|
2508
2515
|
* Where the focus ring was last drawn: the layer and order of its root, the rect grown by the
|
|
@@ -2632,7 +2639,10 @@ type TextState = {
|
|
|
2632
2639
|
* the element that hosts it; `fields` holds the text fields by entity. `hints` buffers the hints
|
|
2633
2640
|
* released since the last frame step; `scrolls` holds the scroll containers; `windowRenders`
|
|
2634
2641
|
* counts the re-renders of a windowed list its range made. `styled` and `written` count the style
|
|
2635
|
-
* passes and the write passes of the reconcile, for `UiCounters`.
|
|
2642
|
+
* passes and the write passes of the reconcile, for `UiCounters`. `hostsVersion` moves on when a
|
|
2643
|
+
* host came, went, became live or was patched, and when a view lost its `Parent` or its `Held`;
|
|
2644
|
+
* `hostsSeen` and `membershipSeen` are that version and the world's membership version at the
|
|
2645
|
+
* last full hosting step, which runs again only when one of them moved.
|
|
2636
2646
|
*/
|
|
2637
2647
|
type JsxState = {
|
|
2638
2648
|
components: Map<string, AnyComponentDefinition>;
|
|
@@ -2644,7 +2654,10 @@ type JsxState = {
|
|
|
2644
2654
|
exiting: Set<Entity>;
|
|
2645
2655
|
removing: Set<Entity>;
|
|
2646
2656
|
hosts: Set<Entity>;
|
|
2647
|
-
hosted: Map<Entity, Entity>;
|
|
2657
|
+
hosted: Map<Entity, Entity>;
|
|
2658
|
+
hostsVersion: number;
|
|
2659
|
+
hostsSeen: number;
|
|
2660
|
+
membershipSeen: number; /** The host elements that became live in this solve: the solve hosts their views in the same frame (spec 16 U2). */
|
|
2648
2661
|
risen: Set<Entity>; /** The views the full hosting step of this frame took back from their host; their removal lands at the flush. */
|
|
2649
2662
|
released: Set<Entity>; /** The cause the elements entered by the diff running now take: the root's for its first build, else `"change"`. */
|
|
2650
2663
|
building: MotionCause | undefined;
|
|
@@ -2667,7 +2680,9 @@ type JsxState = {
|
|
|
2667
2680
|
written: number; /** The wall times of the last taps on a `DebugTrigger` view, five at the most. */
|
|
2668
2681
|
debugTaps: number[]; /** Whether `ui:debug-trigger-no-agent` was logged: once per app. */
|
|
2669
2682
|
debugWarned: boolean; /** Elements that carry `Overlay`, from their enter to their despawn (spec 22 O4.5). */
|
|
2670
|
-
overlays: Set<Entity>;
|
|
2683
|
+
overlays: Set<Entity>; /** Component name to the feature whose `ui` key lists it: the feature a popup root holds. */
|
|
2684
|
+
featureOfComponent: Map<string, string>; /** Projection name to the feature that registered it: the feature a JSX root holds. */
|
|
2685
|
+
featureOfProjection: Map<string, string>;
|
|
2671
2686
|
};
|
|
2672
2687
|
/**
|
|
2673
2688
|
* One node of the snapshot `tree()` answers with. `rect` is natural: under a `fit` ancestor it
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as AnimApi, r as UiApi } from "./types-
|
|
3
|
-
import { j as InputApi } from "./types-
|
|
4
|
-
import { r as Repro } from "./headless-
|
|
5
|
-
import { a as InputOf, r as ControlApp } from "./types-
|
|
6
|
-
import { t as commands } from "./commands-
|
|
1
|
+
import { Ir as Api$3, T as Api, Zt as Api$1, yr as Api$2 } from "./types-DlC3Ytbj.mjs";
|
|
2
|
+
import { P as AnimApi, r as UiApi } from "./types-CsMLBPf-.mjs";
|
|
3
|
+
import { j as InputApi } from "./types-yLdzHyTl.mjs";
|
|
4
|
+
import { r as Repro } from "./headless-D0U5AXiK.mjs";
|
|
5
|
+
import { a as InputOf, r as ControlApp } from "./types-B0bmoyRT.mjs";
|
|
6
|
+
import { t as commands } from "./commands-31d2BEwc.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-
|
|
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-G6F0Mi9H.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/llms.txt
CHANGED
|
@@ -101,6 +101,8 @@ function defineFeature(name: string, description: FeatureDescription): FeaturePl
|
|
|
101
101
|
// contribute?: Record<string, { flow: AnyFlow; order: number; when?: (snapshot: Snapshot) => boolean }>;
|
|
102
102
|
// features?: readonly FeaturePlugin[]; // sub-features, composed right after this one
|
|
103
103
|
// projections?, systems?, components?, scenes?, assets?; // V2 keys, read by world, scenes and assets
|
|
104
|
+
// systemsRun?: "always" | "active"; // read by world. "always" (default) or "active":
|
|
105
|
+
// // the feature's systems run only while a node, scene, view or ui root of it is there
|
|
104
106
|
// animations?: readonly AnimationDefinition[]; // V3, read by anim
|
|
105
107
|
// ui?: readonly ComponentDefinition[]; // V3, read by ui (defineComponent results)
|
|
106
108
|
// strings?: Record<locale, CompiledMessages | (() => Promise<unknown>)>; // V3, read by i18n
|
|
@@ -527,6 +529,7 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
|
|
|
527
529
|
- `app.assets`: `load(bundle)`, `unload(bundle)`, `isLoaded(bundle)`, `has(bundle)` (the manifest carries it, loaded or not), `texture(key)`, `font(key)`, `audio(key)`, `usage()`. Per bundle in a feature's `assets.ts`: `defineBundles({ ep01: { tier: "feature", release: "leave", mipmaps: ["items/**"] } })`. `release: "leave"` also unloads the bundle, with reason `"leave"`, at the next rest once nothing holds it: not pinned by the node entered, not named by the mounted scene, no node of its feature on the stack; a bundle the outgoing scene named leaves one rest later. The default `"budget"` leaves only under the texture budget. `mipmaps` (`true` or globs relative to `assets/`) uploads the textures with their full chain; such a texture stays loose in a pack. A sub-feature with resources gets its own bundles, named like its folder, with `dir` and `parent` in the manifest; a code-only one has none. `companions.add({ load(bundle), unload(bundle) })` adds what loads and unloads with every bundle; `i18n` adds the strings of a sub-feature that way, only when `assets` is composed. Events `assets:bundle-loaded`, `assets:bundle-progress`, `assets:bundle-unloaded` (`reason: "budget" | "request" | "leave"`), `assets:replaced` (dev). Config: `manifest`, `textureBudgetMb: 192`, `preloadDepth: 2`, `baseUrl`, `io`.
|
|
528
530
|
- `resource(name, defaults)` clones plain JSON defaults into every world. `resource(name, () => value)` calls the factory once per world on first read, so the value may hold a `Map` or a function: `const Looks = resource("boardLooks", () => ({ shown: new Map<World.Entity, { look: string }>() }))`. A system keeps its own state there; `snapshot()` leaves a value that is not JSON out.
|
|
529
531
|
- `Now` is the engine resource of the frame's moment: `world` writes `clock.now()` into it at start and first thing in every frame, headless too, so every system of a frame reads one moment: `const { now } = res(Now)`; a fake clock makes it exact. A system that shows time writes its component only when its picture changes. `snapshot().resources` holds `Now: { now }`. Reserved resource names: `Now`, `Pointer`, `AnimPlayer`, `UiCounters`; a game resource of one of them throws `[game] world: the resource name "Now" is the engine's (the frame's moment).`
|
|
532
|
+
- Systems that run where their feature is: `defineFeature("board", { systems, systemsRun: "active" })` runs the feature's systems only while it is active: a node of it on the flow stack (outer frames of sub-flows included), a scene it declares mounted (`scenes` holds it), a view of a projection it registered, leaving included, or a popup or JSX root of it that `ui` holds until its exit ended. `"always"` (default) and the systems the engine's plugins or `ecs.system` register run every frame. A skipped system keeps its slot, walks no query, marks nothing and allocates nothing; `ctx.resumed` is true on its first run after a skip (a cache it drew is rebuilt then). `app.world.ecs.isActive(feature)` answers for any feature; `ecs.hold(feature)` returns a release (`scenes` and `ui` call it). The active set is read at the start of each phase that runs systems. Dev warnings `world:feature-never-active`, `world:hold-unknown-feature`, `world:bad-feature-entry` with `key: "systemsRun"`.
|
|
530
533
|
- Motion hooks are told why they play: `enter(view, item, hint, cause)` and `exit(view, item, hint, cause)` get `World.MotionCause`, `"mount"` (the view comes or goes with its screen: a mount, an unmount, a load, a restore, a paused or fast world) or `"change"` (a commit). A world projection plays them only for `"change"`; `ui` plays them for both. `app.world.projection.causeOf(entity)` answers how a view came or how it is leaving, also in a removal hook of its despawn, until the next frame.
|
|
531
534
|
- `app.world.projection.replace(spec)` swaps the spec of a registered projection; a mounted one runs its new `view` on the next frame. An unknown name throws. The caller is the dev hot swap.
|
|
532
535
|
- `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.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -102,10 +102,12 @@
|
|
|
102
102
|
"lint:fix": "biome check --write . && eslint --fix .",
|
|
103
103
|
"format": "biome format --write .",
|
|
104
104
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tests/fixtures/episodes-game",
|
|
105
|
-
"test": "bun --bun vitest run",
|
|
105
|
+
"test": "bun --bun vitest run --project unit --project integration",
|
|
106
106
|
"test:unit": "bun --bun vitest run --project unit",
|
|
107
107
|
"test:integration": "bun --bun vitest run --project integration",
|
|
108
108
|
"test:coverage": "bun --bun vitest run --project unit --project integration --coverage",
|
|
109
|
+
"test:perf": "node ./node_modules/vitest/vitest.mjs run --project perf",
|
|
110
|
+
"bench:perf": "node ./node_modules/vitest/vitest.mjs bench --run --project perf",
|
|
109
111
|
"build": "tsdown",
|
|
110
112
|
"mini:pack": "bun tests/fixtures/moku-game.ts pack --root tests/fixtures/mini-game",
|
|
111
113
|
"mini:dev": "bun tests/fixtures/moku-game.ts dev --root tests/fixtures/mini-game",
|