@moku-labs/game 0.15.92 → 0.15.94
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/README.md +1 -0
- package/dist/app/page.d.mts +1 -1
- package/dist/app/page.mjs +2 -2
- 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/cli.mjs +317 -45
- package/dist/{commands-DUco80gt.d.mts → commands-B05keaNh.d.mts} +5 -5
- package/dist/{config-BYx_7HL1.mjs → config-DVqciSkP.mjs} +23 -1
- package/dist/control.d.mts +4 -4
- package/dist/{define-C-EbeoLA.d.mts → define-C5oKi9M2.d.mts} +2 -2
- package/dist/{headless-Dasz6dgy.d.mts → headless-rXLWKvZq.d.mts} +1 -1
- package/dist/{index-vPc22SoP.d.mts → index-DuiCPP3n.d.mts} +26 -7
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +6 -6
- package/dist/inspect.mjs +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-CW4HJWqC.d.mts → runtime-DGpGGQAh.d.mts} +1 -1
- package/dist/{sources-kL64Svgl.mjs → sources-DIl02J8z.mjs} +1 -1
- package/dist/{src-BBJh9Uxh.mjs → src-CkBzjWRd.mjs} +112 -25
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-Cc7uKiHX.d.mts → types-BrEqXapX.d.mts} +2 -2
- package/dist/{types-B2Dh7oWu.d.mts → types-CA98KS-U.d.mts} +29 -6
- package/dist/{types-Btqe51cJ.d.mts → types-CSkVNKPZ.d.mts} +2 -2
- package/dist/{types-D1lRinVJ.d.mts → types-D33h-CNj.d.mts} +20 -3
- package/dist/{types-BMUuyOcm.d.mts → types-DhCTe-kr.d.mts} +28 -7
- package/dist/{visual-BMyWTUgm.d.mts → visual-BfN2jgqg.d.mts} +6 -6
- package/dist/{visual-CULAJg6b.mjs → visual-Cl7Q7pO9.mjs} +4 -2
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +6 -5
- package/package.json +4 -4
|
@@ -4894,6 +4894,23 @@ type Answer<Intent extends string = string> = {
|
|
|
4894
4894
|
intent: Intent;
|
|
4895
4895
|
payload?: Json;
|
|
4896
4896
|
};
|
|
4897
|
+
/**
|
|
4898
|
+
* What `await fx(descriptor)` resolves with for a descriptor that takes answers, a `popup` among
|
|
4899
|
+
* them: the gate's answer plus `at`, the moment of the answer in game ms of `clock`. `at` is read
|
|
4900
|
+
* when the answer arrives, in live mode and in a fast walk alike, so a replayed route gives the same
|
|
4901
|
+
* `at` for the same clock position. A payload-less answer stays without a `payload` key.
|
|
4902
|
+
*
|
|
4903
|
+
* @example
|
|
4904
|
+
* ```ts
|
|
4905
|
+
* // The popup opened at 60000; the player taps "again" 5 s later. The node is still at its own
|
|
4906
|
+
* // `now` of 60000, so it times the closing animation from the answer.
|
|
4907
|
+
* const answer = await fx(popup(Retry, {})); // { intent: "again", at: 65000 }
|
|
4908
|
+
* const until = answer.at + 780; // 65780: the close ends 780 ms after the tap
|
|
4909
|
+
* ```
|
|
4910
|
+
*/
|
|
4911
|
+
type Answered<Intent extends string = string> = Answer<Intent> & {
|
|
4912
|
+
at: number;
|
|
4913
|
+
};
|
|
4897
4914
|
/**
|
|
4898
4915
|
* The one answer a `guide` lets through. `payload` is compared by deep equality when present.
|
|
4899
4916
|
*
|
|
@@ -5284,7 +5301,7 @@ type FxApi = {
|
|
|
5284
5301
|
* @example
|
|
5285
5302
|
* ```ts
|
|
5286
5303
|
* // Inside a node body: wait for the player's pick, then sparkle once the edge has committed.
|
|
5287
|
-
* const pick = await fx(popup(Retry, {})); //
|
|
5304
|
+
* const pick = await fx(popup(Retry, {})); // Answered<"again" | "home">: { intent: "again", at: 65000 }
|
|
5288
5305
|
* fx.emit(hint("sparkle", { cell: "c3" }));
|
|
5289
5306
|
* ```
|
|
5290
5307
|
*/
|
|
@@ -6996,7 +7013,7 @@ declare function contribution<S extends SlotNode<OutcomeTags, string>, F extends
|
|
|
6996
7013
|
when?: (snapshot: Snapshot) => boolean;
|
|
6997
7014
|
}): Readonly<Record<S["name"], ContributionSpec>>;
|
|
6998
7015
|
declare namespace types_d_exports$3 {
|
|
6999
|
-
export { Allow, Answer, AnyFlow, AnyNode, AnyNodeContext, Api$2 as Api, Bookmark, BundlesOf, CheckedEdges, Config$3 as Config, Contribution, ContributionSpec, DefineNode, Deps$3 as Deps, Descriptor, Edges, Effect, EffectHandler, EffectOptions, EmitterIdOf, EnterCallback, Events$3 as Events, Exit, FeatureDescription, FeatureEmitter, FeatureFilter, FeaturePlugin, FeatureTextFormats, FeatureTree, FeaturesApi, FlowCtx, FlowDefinition, FlowEntry, FlowGraph, FlowKit, FlowSpec, FlowState, FxApi, FxHandler, GameState, GameTypes, GateApi, GraphError, GraphNode, GuideOptions, Hint, HudKeysOf, InboxApi, JournalEntry, KernelSlice$3 as KernelSlice, LifecycleChanged, Mapped, NodeContext, NodeDefinition, NodeFx, NodeInfo, NodeSpec, NodeTable, OutcomeTags, Position, RecoverContext, RegisteredFeature, Result, RouteStep, RunnerApi, SceneIdOf, SlotNode, Stage, State$3 as State, StringTableLike, Target, TextFormatsOf, TextStylesOf, TypeTag, WorldEvent };
|
|
7016
|
+
export { Allow, Answer, Answered, AnyFlow, AnyNode, AnyNodeContext, Api$2 as Api, Bookmark, BundlesOf, CheckedEdges, Config$3 as Config, Contribution, ContributionSpec, DefineNode, Deps$3 as Deps, Descriptor, Edges, Effect, EffectHandler, EffectOptions, EmitterIdOf, EnterCallback, Events$3 as Events, Exit, FeatureDescription, FeatureEmitter, FeatureFilter, FeaturePlugin, FeatureTextFormats, FeatureTree, FeaturesApi, FlowCtx, FlowDefinition, FlowEntry, FlowGraph, FlowKit, FlowSpec, FlowState, FxApi, FxHandler, GameState, GameTypes, GateApi, GraphError, GraphNode, GuideOptions, Hint, HudKeysOf, InboxApi, JournalEntry, KernelSlice$3 as KernelSlice, LifecycleChanged, Mapped, NodeContext, NodeDefinition, NodeFx, NodeInfo, NodeSpec, NodeTable, OutcomeTags, Position, RecoverContext, RegisteredFeature, Result, RouteStep, RunnerApi, SceneIdOf, SlotNode, Stage, State$3 as State, StringTableLike, Target, TextFormatsOf, TextStylesOf, TypeTag, WorldEvent };
|
|
7000
7017
|
}
|
|
7001
7018
|
/**
|
|
7002
7019
|
* flow plugin events.
|
|
@@ -14573,4 +14590,4 @@ type BundleCompanion = {
|
|
|
14573
14590
|
unload(bundle: string): void;
|
|
14574
14591
|
};
|
|
14575
14592
|
//#endregion
|
|
14576
|
-
export { MonitorConfig as $,
|
|
14593
|
+
export { MonitorConfig as $, Ease as $n, StoreApi as $r, PerfStartupLine as $t, FilterSlotQuad as A, FeaturePlugin as An, Explained as Ar, OverlayWhat as At, Parent as B, SceneIdOf as Bn, Config$6 as Br, PerfCollectorLine as Bt, SceneSpec as C, contribution as Cn, QueryTerm as Cr, FrameReadout as Ct, DebugSwitches as D, to as Dn, TagType as Dr, MONITOR_SECTIONS as Dt, types_d_exports$1 as E, slot as En, SystemFor as Er, LongFrameEntry as Et, HudPartValue as F, FlowGraph as Fn, Config$5 as Fr, PassKind as Ft, SpriteOptions as G, GuideOptions as Gn, types_d_exports$6 as Gr, PerfGapLine as Gt, ShapeValue as H, Descriptor as Hn, Json as Hr, PerfDisplay as Ht, NineSlice$1 as I, FlowState as In, FakeClock as Ir, PassRecord as It, TransformValue as J, Answer as Jn, ProviderCall as Jr, PerfLongFrameLine as Jt, SpriteValue as K, Hint as Kn, Patch as Kr, PerfHeaderLine as Kt, NineSliceValue as L, JournalEntry as Ln, State$5 as Lr, PerfCause as Lt, WhyEntry as M, AnyFlow as Mn, types_d_exports$4 as Mr, PERF_GAP_BUCKETS as Mt, Display as N, Bookmark as Nn, Api$4 as Nr, PERF_LOG_VERSION as Nt, FilterSlot as O, type as On, Api$3 as Or, MonitorSections as Ot, HudPart as P, DefineNode as Pn, ClockSource as Pr, PROBLEM_RULES as Pt, Config$2 as Q, DescriptionNode as Qn, SnapshotOf as Qr, PerfSpikeLine as Qt, Overlay as R, NodeTable as Rn, types_d_exports$5 as Rr, PerfChange as Rt, SceneDefinition as S, types_d_exports$3 as Sn, Narrowed as Sr, FrameReadResult as St, State$1 as T, exit as Tn, SystemDefinition as Tr, FrameRing as Tt, Sprite as U, Effect as Un, Root as Ur, PerfEventLine as Ut, Shape as V, TypeTag as Vn, Events$5 as Vr, PerfCounts as Vt, SpriteBlend as W, EffectOptions as Wn, State$6 as Wr, PerfEventName as Wt, AdaptiveScale as X, AnchorTarget as Xn, SaveUnreadableError as Xr, PerfMeasured as Xt, sprite as Y, Answered as Yn, SaveDoc as Yr, PerfMarkLine as Yt, Api$1 as Z, ChangeHook as Zn, Snapshot as Zr, PerfSampleLine as Zt, AnySceneProjection as _, Events$8 as _i, HudKeysOf as _n, ComponentValue as _r, ViewportSize as _t, Config as a, PauseReason as ai, SHADER_WHATS as an, ProjectionSpec as ar, PixiUniformGroup as at, Events$1 as b, TextFormatsOf as bn, FrameDiff as br, WhyLive as bt, LoadBundles as c, Api$7 as ci, WarmDetail as cn, TrackOptions as cr, Under as ct, Manifest as d, RateChange as di, DEMAND_REASONS as dn, AnyComponent as dr, ShotsConfig as dt, RngApi as ei, PerfTelemetryLine as en, Motion as er, PixiFilter as et, ReadyBundles as f, State$8 as fi, Api$2 as fn, AnyComponentType as fr, Captured as ft, types_d_exports as g, Config$9 as gi, GameTypes as gn, ComponentType as gr, Point as gt, Usage as h, types_d_exports$8 as hi, EmitterIdOf as hn, ComponentSchema as hr, Orientation as ht, BundleSpec as i, Events$6 as ii, ProblemRule as in, ProjectionMotion as ir, PixiTexture as it, SyncApi as j, FeatureTree as jn, State$4 as jr, PERF_CAUSES as jt, FilterSlotInputs as k, FeatureDescription as kn, Config$4 as kr, OverlayEventDetail as kt, LoadReason as l, Config$8 as li, CANVAS_RESTARTS as ln, TrackSegment as lr, types_d_exports$2 as lt, Tier as m, Time as mi, Config$3 as mn, ComponentHandle as mr, RenderStats as mt, AssetsIo as n, Api$6 as ni, PoolTrimDetail as nn, MotionHandle as nr, PixiModule as nt, DefineBundles as o, State$7 as oi, ShaderEventDetail as on, ReducedMotion as or, PoolTrim as ot, State as p, ThermalReading as pi, BundlesOf as pn, AnyComponentValue as pr, MonitorCounts as pt, Transform as q, NodeFx as qn, PlayerStateProvider as qr, PerfLogLine as qt, BundleMap as r, Config$7 as ri, ProblemEventDetail as rn, NumericFields as rr, PixiSprite as rt, Events as s, types_d_exports$7 as si, ShaderWhat as sn, SceneSwitch as sr, State$2 as st, Api as t, RngState as ti, PerfThermalLine as tn, MotionCause as tr, PixiGpuProgram as tt, LoadResult as u, FrameRate as ui, CanvasRestart as un, ViewHandle as ur, ShotsApi as ut, Config$1 as v, Require as vi, Position as vn, Entity as vr, FilterCache as vt, ScenesApi as w, defineFlow as wn, ResourceType as wr, FrameRecord as wt, LayerMap as x, TextStylesOf as xn, Mut as xr, FrameColumns as xt, DefineScene as y, State$3 as yn, EntitySnapshot as yr, RetakeWhy as yt, OverlayValue as z, RouteStep as zn, Api$5 as zr, PerfChangeEntry as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as Ease, Dr as TagType, Hn as Descriptor, Hr as Json, J as TransformValue, Kn as Hint, Nr as Api$5, Or as Api$2, Xn as AnchorTarget, Yn as Answered, Z as Api$3, Zn as ChangeHook, _t as ViewportSize, ci as Api, dr as AnyComponent, er as Motion, fn as Api$1, fr as AnyComponentType, gr as ComponentType, ir as ProjectionMotion, nr as MotionHandle, or as ReducedMotion, pr as AnyComponentValue, rr as NumericFields, s as Events$1, t as Api$4, tr as MotionCause, ur as ViewHandle, vi as Require, vr as Entity } from "./types-D33h-CNj.mjs";
|
|
2
2
|
import { Log } from "@moku-labs/common/browser";
|
|
3
3
|
import { PluginCtx } from "@moku-labs/core";
|
|
4
4
|
import { Node, Yoga } from "yoga-layout/load";
|
|
@@ -1118,18 +1118,27 @@ type State$1 = {
|
|
|
1118
1118
|
*/
|
|
1119
1119
|
type InputApi = {
|
|
1120
1120
|
/**
|
|
1121
|
-
* Reads the `Tappable` of a view and answers its intent.
|
|
1121
|
+
* Reads the `Tappable` of a view and answers its intent. On a view whose `Tappable` has
|
|
1122
|
+
* `point: true`, a given point is added to the payload under `point`, as the finger's press
|
|
1123
|
+
* point would be. It is already in the view's own units, the units of its hit box, and is used
|
|
1124
|
+
* as it is. Without a point, or on a view without the flag, the payload is answered unchanged,
|
|
1125
|
+
* with no `point` key: the keyboard taps of ui (Enter on the focused button, Escape) give none.
|
|
1122
1126
|
*
|
|
1123
1127
|
* @param target - The projection key of a live view, or an entity.
|
|
1128
|
+
* @param point - The press point in the view's own units; read only by a view with `point: true`.
|
|
1124
1129
|
* @returns What `flow.gate.answer` returned: true when the gate took the answer.
|
|
1125
1130
|
* @example
|
|
1126
1131
|
* ```ts
|
|
1127
1132
|
* // A hidden-object test finds one object without touching a pixel.
|
|
1128
1133
|
* app.input.tap({ projection: "scene.objects", key: "lamp" });
|
|
1129
1134
|
* // true: answers { intent: "found", payload: { id: "lamp" } }
|
|
1135
|
+
*
|
|
1136
|
+
* // A headless test taps the gift sphere (Tappable { intent: "kitTap", point: true }) at its left edge.
|
|
1137
|
+
* app.input.tap({ projection: "kit", key: "sphere" }, { x: 10, y: 60 });
|
|
1138
|
+
* // true: answers { intent: "kitTap", payload: { point: { x: 10, y: 60 } } }
|
|
1130
1139
|
* ```
|
|
1131
1140
|
*/
|
|
1132
|
-
tap(target: Target): boolean;
|
|
1141
|
+
tap(target: Target, point?: Point$1): boolean;
|
|
1133
1142
|
/**
|
|
1134
1143
|
* Reads the `Pressable` of a view and answers its intent, the way a long press would.
|
|
1135
1144
|
*
|
|
@@ -2104,6 +2113,8 @@ type ButtonPayload = Json & Brand<"ButtonPayload">;
|
|
|
2104
2113
|
type ButtonLocal = Record<string, unknown> & Brand<"ButtonLocal">;
|
|
2105
2114
|
/** Makes a button the control the Escape key taps while its root is the top one. */
|
|
2106
2115
|
type ButtonEscape = boolean & Brand<"ButtonEscape">;
|
|
2116
|
+
/** Asks a button that answers an intent to add the press point to its payload. */
|
|
2117
|
+
type ButtonPoint = boolean & Brand<"ButtonPoint">;
|
|
2107
2118
|
/** What a text draws: a plain string, or a message of the game's string table. */
|
|
2108
2119
|
type TextContent = (string | Message) & Brand<"TextContent">;
|
|
2109
2120
|
/** The text style key, or a layout style when the built-in `body` is meant. */
|
|
@@ -2235,13 +2246,19 @@ type HostProps = CommonProps & {
|
|
|
2235
2246
|
/**
|
|
2236
2247
|
* What a button takes. `intent` and `local` exclude each other: a button either answers the gate
|
|
2237
2248
|
* or writes local state. `escape` marks the control the Escape key taps: the close button or the
|
|
2238
|
-
* backdrop of a dismissable popup.
|
|
2249
|
+
* backdrop of a dismissable popup. `point`, only beside `intent`, adds the press point of a finger
|
|
2250
|
+
* tap to the payload under `point`, in the button's own layout units: (0, 0) its top-left corner,
|
|
2251
|
+
* (width, height) its bottom-right, whatever its offset, scale or parent. A keyboard tap (Enter on
|
|
2252
|
+
* the focused button, Escape) has no press point and answers the payload as it is.
|
|
2239
2253
|
*
|
|
2240
2254
|
* @example
|
|
2241
2255
|
* ```ts
|
|
2242
2256
|
* const props: ButtonTagProps = { intent: "claim", payload: { orderId: "o1" } };
|
|
2243
2257
|
* // The close button of the settings popup: Escape taps it while the popup is on top.
|
|
2244
2258
|
* const close: ButtonTagProps = { intent: "close", escape: true };
|
|
2259
|
+
* // The gift sphere of 400 x 200, `<button intent="kitTap" point />`: a finger 10 in from its
|
|
2260
|
+
* // left edge and 150 down answers { intent: "kitTap", payload: { point: { x: 10, y: 150 } } }.
|
|
2261
|
+
* const sphere: ButtonTagProps = { intent: "kitTap", point: true };
|
|
2245
2262
|
* ```
|
|
2246
2263
|
*/
|
|
2247
2264
|
type ButtonTagProps = CommonProps & {
|
|
@@ -2249,10 +2266,12 @@ type ButtonTagProps = CommonProps & {
|
|
|
2249
2266
|
} & ({
|
|
2250
2267
|
intent?: ButtonIntent;
|
|
2251
2268
|
payload?: ButtonPayload;
|
|
2269
|
+
point?: ButtonPoint;
|
|
2252
2270
|
local?: never;
|
|
2253
2271
|
} | {
|
|
2254
2272
|
intent?: never;
|
|
2255
2273
|
payload?: never;
|
|
2274
|
+
point?: never;
|
|
2256
2275
|
local?: ButtonLocal;
|
|
2257
2276
|
});
|
|
2258
2277
|
/**
|
|
@@ -2568,7 +2587,8 @@ declare const ScrollState: ComponentType<{
|
|
|
2568
2587
|
declare const DebugTrigger: TagType;
|
|
2569
2588
|
/**
|
|
2570
2589
|
* Builds the effect a node awaits to show a popup. The gate opens for the outcomes of the
|
|
2571
|
-
* component, so the node resolves with the intent one of its buttons answered
|
|
2590
|
+
* component, so the node resolves with the intent one of its buttons answered, its payload, and
|
|
2591
|
+
* `at`: the clock moment the answer arrived, in game ms. `over` names the
|
|
2572
2592
|
* component of a popup that stays mounted beneath this one, drawn covered, until this one is gone.
|
|
2573
2593
|
*
|
|
2574
2594
|
* @param component - A component declared with `outcomes`.
|
|
@@ -2584,7 +2604,8 @@ declare const DebugTrigger: TagType;
|
|
|
2584
2604
|
* });
|
|
2585
2605
|
* popup(Reward, { gold: 5 });
|
|
2586
2606
|
* // { kind: "popup", payload: { component: "Reward", props: { gold: 5 } }, answers: ["claim"] }
|
|
2587
|
-
*
|
|
2607
|
+
* // The player claims 5 s after the popup opened at 60000.
|
|
2608
|
+
* await fx(popup(Reward, { gold: 5 })); // Answered<"claim">: { intent: "claim", at: 65000 }
|
|
2588
2609
|
* ```
|
|
2589
2610
|
* @example
|
|
2590
2611
|
* ```ts
|
|
@@ -2600,7 +2621,7 @@ declare const DebugTrigger: TagType;
|
|
|
2600
2621
|
*/
|
|
2601
2622
|
declare function popup<Properties extends object, Local extends object, Outcomes extends Record<string, unknown>>(component: PopupComponent<Properties, Local, Outcomes>, props: Properties, options?: {
|
|
2602
2623
|
over?: string;
|
|
2603
|
-
}): Descriptor<
|
|
2624
|
+
}): Descriptor<Answered<keyof Outcomes & string>>;
|
|
2604
2625
|
//#endregion
|
|
2605
2626
|
//#region src/plugins/ui/layout/types.d.ts
|
|
2606
2627
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as AnimApi, r as UiApi } from "./types-
|
|
3
|
-
import { L as InputApi } from "./types-
|
|
4
|
-
import { r as Repro } from "./headless-
|
|
5
|
-
import { i as ControlApp, o as InputOf } from "./types-
|
|
6
|
-
import { t as commands } from "./commands-
|
|
1
|
+
import { Nr as Api$4, Or as Api$1, Z as Api, ni as Api$3, zr as Api$2 } from "./types-D33h-CNj.mjs";
|
|
2
|
+
import { P as AnimApi, r as UiApi } from "./types-BrEqXapX.mjs";
|
|
3
|
+
import { L as InputApi } from "./types-DhCTe-kr.mjs";
|
|
4
|
+
import { r as Repro } from "./headless-rXLWKvZq.mjs";
|
|
5
|
+
import { i as ControlApp, o as InputOf } from "./types-CSkVNKPZ.mjs";
|
|
6
|
+
import { t as commands } from "./commands-B05keaNh.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. */
|
|
@@ -1208,7 +1208,8 @@ const UiCounters = /*#__PURE__*/ resource("UiCounters", {
|
|
|
1208
1208
|
});
|
|
1209
1209
|
/**
|
|
1210
1210
|
* Builds the effect a node awaits to show a popup. The gate opens for the outcomes of the
|
|
1211
|
-
* component, so the node resolves with the intent one of its buttons answered
|
|
1211
|
+
* component, so the node resolves with the intent one of its buttons answered, its payload, and
|
|
1212
|
+
* `at`: the clock moment the answer arrived, in game ms. `over` names the
|
|
1212
1213
|
* component of a popup that stays mounted beneath this one, drawn covered, until this one is gone.
|
|
1213
1214
|
*
|
|
1214
1215
|
* @param component - A component declared with `outcomes`.
|
|
@@ -1224,7 +1225,8 @@ const UiCounters = /*#__PURE__*/ resource("UiCounters", {
|
|
|
1224
1225
|
* });
|
|
1225
1226
|
* popup(Reward, { gold: 5 });
|
|
1226
1227
|
* // { kind: "popup", payload: { component: "Reward", props: { gold: 5 } }, answers: ["claim"] }
|
|
1227
|
-
*
|
|
1228
|
+
* // The player claims 5 s after the popup opened at 60000.
|
|
1229
|
+
* await fx(popup(Reward, { gold: 5 })); // Answered<"claim">: { intent: "claim", at: 65000 }
|
|
1228
1230
|
* ```
|
|
1229
1231
|
* @example
|
|
1230
1232
|
* ```ts
|
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-BfN2jgqg.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,5 +1,5 @@
|
|
|
1
1
|
import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
|
|
2
|
-
import { n as read, t as sources } from "./sources-
|
|
2
|
+
import { n as read, t as sources } from "./sources-DIl02J8z.mjs";
|
|
3
3
|
import { n as commands, t as run } from "./run-B5if0jxE.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { createBrandConsole } from "@moku-labs/common/cli";
|
package/llms.txt
CHANGED
|
@@ -44,7 +44,7 @@ Root exports:
|
|
|
44
44
|
- A pure wait ends in two ways. A gate answer whose `intent` is an outcome name: the answer payload becomes the outcome payload. Or a world event whose `type` is listed in the node's `inbox`: the event payload becomes the outcome payload.
|
|
45
45
|
- Transition: rest node to rest node. It is a transaction. On an error the runner discards, rolls back to the last rest point, retries `retries` times, then enters `safeNode`. A failure inside `safeNode` rejects `run()`.
|
|
46
46
|
- Three ways to run an effect in a node. `await fx(descriptor)`: the node waits for it. `fx.start(descriptor)`: it starts now and the node goes on; write it in place of `void fx(...)`. A failure of a started effect is the log entry `flow:fx-start-failed` and never fails the node. A `cosmetic` descriptor (`sfx`, `play`, `haptic`, `music`) that fails, awaited or started, is the warn entry `flow:fx-cosmetic-failed` with `{ kind, message }` and resolves `undefined`; a descriptor with `answers` and a `guide` are refused, they have to be awaited. `fx.emit(hint(...))`: released after the commit of the edge, dropped in fast mode.
|
|
47
|
-
- `await fx(descriptor)` is typed by the descriptor (`Flow.Descriptor<Result>`): `schedule`, `guide`, `music`, `sfx`, `haptic`, `play` resolve `void`; `load` resolves `Assets.LoadResult | undefined` (`undefined` without `assets`, as in `game.headless()`); `ready` resolves `boolean | undefined` (`true` when every bundle is loaded and on the GPU, `undefined` without `assets`, so compare `=== false`); `popup(Component, props)` resolves `Flow.
|
|
47
|
+
- `await fx(descriptor)` is typed by the descriptor (`Flow.Descriptor<Result>`): `schedule`, `guide`, `music`, `sfx`, `haptic`, `play` resolve `void`; `load` resolves `Assets.LoadResult | undefined` (`undefined` without `assets`, as in `game.headless()`); `ready` resolves `boolean | undefined` (`true` when every bundle is loaded and on the GPU, `undefined` without `assets`, so compare `=== false`); `popup(Component, props)` resolves `Flow.Answered<outcome names>`, `{ intent, payload?, at }` with `at` the `clock.now()` moment the answer arrived (live and in a fast walk alike), so comparing it with an intent the component does not declare is a compile error; a descriptor written by hand resolves `unknown`. A game declares its own: `const envRead = defineEffect<{ notice: boolean }, EnvRead>("view-env.read", { fast: "run" })`, then `await fx(envRead({ notice: true }))` is `EnvRead` and `envRead.handle(ctx.require(flowPlugin).fx, payload => ...)` registers the one handler (returns the remover). Only `{ fast: "run" }` without `cosmetic` resolves `Result`; any other declaration resolves `Result | undefined`. `NodeFx` is generic: a hand-written fake is typed `as NodeFx`, or use `fakeFx`.
|
|
48
48
|
- Every failure is written into the log by the engine: an `error` entry `flow:error` with `{ path, rolledBackTo, retry, error: { message, stack } }`. Read it with `app.log.trace()`. A game needs no plugin for it.
|
|
49
49
|
- `recover` on a rest node: `recover: async ({ player, session, rng, fx, signal, now }) => { ... }`. It runs only when the runner gave up on a transition and enters this node as `safeNode`, before the node is entered. The rollback left the state of the failed rest point; `recover` writes the drafts so the safe node can draw itself. What it wrote commits as one edge with `outcome: "recover"` and becomes the rest point. A `recover` that throws rejects `run()`. A retry does not run it. So the safe node stays a pure wait: no `run` body, no extra outcome, no self edge.
|
|
50
50
|
- Entering a rest node calls `model.store.markRest()`: the save provider gets the patches. Leaving a `barrier` node calls `markBarrier(txId)`: a durable write, and rollback cannot cross it.
|
|
@@ -303,7 +303,7 @@ app.model.store.snapshot().session; // { rolls: 2 }
|
|
|
303
303
|
await run.stop();
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios?, dev? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId }
|
|
306
|
+
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios?, dev? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId, apiKeyId?, apiIssuer?, apiKeyPath? }`: an iOS build signs from the command line with an App Store Connect team key, since an Xcode account sign-in is not seen by `xcodebuild` there, which fails with "No Accounts" and no provisioning profiles; the key is `apiKeyId` (the key id), `apiIssuer` (the issuer id) and `apiKeyPath` (the `.p8` file: absolute, `~/...` or relative to the game, kept outside the repo, never the key itself), all three or none (`[game] config.native.signing.apple has apiKeyId but no apiIssuer, apiKeyPath.`); `native build` and `native dev` on iOS put them into the env Tauri reads, `APPLE_API_KEY`, `APPLE_API_ISSUER` and `APPLE_API_KEY_PATH` (absolute), and put the earlier env back after; without them the three env vars a person sets reach Tauri as before, and a config key wins over them; `ios: { minimumVersion?, infoPlist?, privacyManifest? }`, the minimum `"26.0"` by default, `infoPlist` of `PlistValue`: strings, booleans, arrays, dictionaries, a number or `null` refused; the manifest relative to the game; `dev: { identifier, name?, icon? }`, the test app of `--store --dev`, the identifier ending in `.dev` and not `native.identifier`, `name` `"<name> DEV"` and `icon` `native.icon` by default), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
307
307
|
|
|
308
308
|
```ts
|
|
309
309
|
// config.ts of a game in a native shell
|
|
@@ -344,7 +344,7 @@ Commands of the bin `moku-game` (bun). Every command takes `--root <dir>` (defau
|
|
|
344
344
|
- `moku-game build [--out dist/web]`: packs the assets, bundles the page minified with `__MOKU_GAME_DEV__`, `__MOKU_GAME_AGENT__` and `__MOKU_GAME_CONTROL__` defined `false` (no scenario, no agent, no `.dev` module, no `/control`, no engine id), every link `./`, and copies the pack beside it with `manifest.json` next to `index.html`. Every page marks `moku:script` first and `moku:main` first after its imports. A release page whose `.js` carries `"/__editor/hello"` or `"[moku-editor]"` (the editor's agent) fails with `[game] build: the release page carries the editor agent (…)` and its output folder is removed. Runs from any http sub-path and from Tauri, not from `file://`.
|
|
345
345
|
- `moku-game build --debug[=read] [--editor host:port]`: a debug page, never shipped: the release page plus `@moku-labs/editor/agent/page` (resolved from the game, else `[game] build --debug needs @moku-labs/editor in the game.`) and the game's `.dev` modules, started after the app; DEV `false`, AGENT `true`, CONTROL `true` (`--debug`: every command, cheats too; `--debug=full` is an alias that prints one line) or `false` (`--debug=read`, the rare read-only page: read and cosmetic commands); `__MOKU_GAME_BUILD__` `debug-<UTC stamp>` for both, `__MOKU_GAME_ENGINE__` the engine id (`<version>+<dist hash>[.patch.<hash>]`, `+src` from sources), `__MOKU_GAME_EDITOR__` the `--editor` address (default `127.0.0.1:47600`); the title reads `<title> Debug`; no hot swap, no frame recorder, no audio journal, no scenario. It prints one warning naming the profile, the build id, the engine and the editor. `MOKU_NATIVE_PROFILE=store` with `--debug` is refused. `MOKU_NATIVE_PROFILE=dev`, a test app's web build: a run without `--debug` is refused (`[game] build: MOKU_NATIVE_PROFILE is dev: a dev page carries the overlay.`); `--debug` builds `__MOKU_GAME_EDITOR__` exactly `"off"`, so the agent opens no socket, with CONTROL `true` and `__MOKU_GAME_APP__` `native.dev.identifier`; `--editor`, `--debug=read` and an `@moku-labs/editor` below 0.10.19, or of a version that cannot be read, are refused.
|
|
346
346
|
- `moku-game native build <target> [--simulator] [--debug[=full] [--editor host:port]]`, `native dev <target>`, `native doctor [<target>]`, `native clean [<target>]`: one verb of `@moku-labs/native` (a dev dependency, `^0.3.13`) over `config.ts`. App name, identifier and icon from `native`, orientation and background colour from `page`; the web build is `moku-game build`, the dev server `moku-game dev --port 5173`; system rows for `back`, `haptics`, `store`; the Tauri project in `.moku/tauri`, the apps in `dist-native`; an Android app composes native's `shell` system first. `native build android --debug` builds a debug app (`debug: true` to native, which installs it beside the store app; the web build is `moku-game build --debug` with the same profile and `--editor`). `native build ios --debug [--simulator]` is the same app on iOS: the engine names it `<name> (debug)` and `<identifier>.debug`, in `.moku/tauri-debug`, native delivers to `dist-native/ios-debug`. Other verbs and targets refuse `--debug`. `native clean` also cleans `.moku/tauri-dev` and `.moku/tauri-debug` when they exist, one native clean per folder; `doctor` stays on `.moku/tauri`. `[game] config.ts has no native section.` without `native`.
|
|
347
|
-
- `moku-game native build <ios|android> --store --build-number <n>`: a store build, an `.aab` on Android (`aab: true` to native), an `.ipa` with `exportMethod: "app-store-connect"` on iOS. `app.version` from `package.json`, `app.buildNumber` from the flag, an integer from 1 to 2100000000, one number for both stores. Refused before `config.ts` is read: outside `native build`, with `--debug`, `--editor` or `--simulator`, on another target, without a valid number; `--build-number` without `--store`. Then every problem at once, before anything compiles, in one `[game] native --store: …` error, a line per problem: no signing block for the target, on Android a keystore that is not a file or an unset password variable (its name only, never a value), a `package.json` version that is not `x.y.z`, an identifier that ends in `.soak`, `.debug`, `.dev`, `.test` or `.staging`. On iOS it warns, and goes on, without `ios.privacyManifest` or `ITSAppUsesNonExemptEncryption` in `ios.infoPlist`. A build without `--store` runs no store check: `native build ios` is a device build. `--store --dev` builds the test app of `native.dev`: every store check, the identifier row reading `native.dev.identifier`; `dev: true` to native (`aab` on Android as before), the same signing, the web build `moku-game build --debug`, the project `.moku/tauri-dev`, a full Rust build of its own, the apps in `dist-native-dev`; the save stays under `native.identifier`. `--dev` without `--store` is refused before `config.ts` is read, with no `native.dev` right after, and `--store --debug` stays refused. Every build takes a valid `package.json` version (else native's `0.1.0`), `app.keepScreenOn` from `keepAwake` in `system`, and on iOS the minimum `26.0`; a debug app leaves `signing.android` out and keeps the SDK key.
|
|
347
|
+
- `moku-game native build <ios|android> --store --build-number <n>`: a store build, an `.aab` on Android (`aab: true` to native), an `.ipa` with `exportMethod: "app-store-connect"` on iOS. `app.version` from `package.json`, `app.buildNumber` from the flag, an integer from 1 to 2100000000, one number for both stores. Refused before `config.ts` is read: outside `native build`, with `--debug`, `--editor` or `--simulator`, on another target, without a valid number; `--build-number` without `--store`. Then every problem at once, before anything compiles, in one `[game] native --store: …` error, a line per problem: no signing block for the target, on Android a keystore that is not a file or an unset password variable (its name only, never a value), a `package.json` version that is not `x.y.z`, an identifier that ends in `.soak`, `.debug`, `.dev`, `.test` or `.staging`. On iOS it warns, and goes on, without `ios.privacyManifest` or `ITSAppUsesNonExemptEncryption` in `ios.infoPlist`; a `.p8` of `signing.apple.apiKeyPath` that is not a file is a problem line with the resolved path. `--upload` (`native build ios --store [--dev] --build-number <n> --upload`) sends the build to App Store Connect, for TestFlight: refused before `config.ts` is read without `--store` (`[game] native: --upload goes with --store.`) and on another target (`[game] native: --upload goes with ios.`); it needs a key, the one of `config.ts`, else the three env vars, and the store checks name a missing key, and for the env key a `.p8` that is not a file by the variable's name only. After a green build it runs `xcrun altool --upload-app -f <ipa> -t ios --api-key <id> --api-issuer <issuer> --p8-file-path <.p8>` on the newest `.ipa` of `dist-native/ios` (`dist-native-dev/ios` with `--dev`), printing `native: uploading <ipa> to App Store Connect.` and `native: uploaded. TestFlight shows the build after Apple processes it.`, never an id or the key path; no `.ipa` (`[game] native: no .ipa in <folder> to upload.`) or an altool exit other than 0 (`[game] native: the upload failed (altool exit <code>).`) exits 1, and a failed build uploads nothing. A build without `--store` runs no store check: `native build ios` is a device build. `--store --dev` builds the test app of `native.dev`: every store check, the identifier row reading `native.dev.identifier`; `dev: true` to native (`aab` on Android as before), the same signing, the web build `moku-game build --debug`, the project `.moku/tauri-dev`, a full Rust build of its own, the apps in `dist-native-dev`; the save stays under `native.identifier`. `--dev` without `--store` is refused before `config.ts` is read, with no `native.dev` right after, and `--store --debug` stays refused. Every build takes a valid `package.json` version (else native's `0.1.0`), `app.keepScreenOn` from `keepAwake` in `system`, and on iOS the minimum `26.0`; a debug app leaves `signing.android` out and keeps the SDK key.
|
|
348
348
|
- `moku-game keys [--check]`: `generated/assets.ts`, the compiled strings (`strings.ts`, `strings.<locale>.ts` for the top-level features and the layers, and `strings.<feature>.<locale>.ts` for every sub-feature with string files) and the dev manifest `generated/manifest.json` (a sub-feature's bundle carries its `dir` and `parent`); `dev` runs the same scan at start and on save and serves the manifest on `/manifest.json`, `visual` stops without it. `moku-game pack [--no-cache]`: `dist/assets`. Both pass the layers of `config.ts`.
|
|
349
349
|
- `moku-game visual [--update] [--only <name>] [--no-pixels | --pixels] [--webgl] [--dir <path>] [--tests <file>] [--url <url>]`: runs `runVisualTests` with the default export of `tests/visual/index.ts`, `{ app, tests }` (`app` is a `VisualSetup` `{ app, page? }`: `export default { app: { app: fixtureApp }, tests }`), against `tests/visual/baselines/`. The flags go through `parseVisualArgv`. The pixel leg runs on a Mac only unless `--pixels`/`--no-pixels`; without `--url` the command writes its own page into `.moku/visual/` (the page of `dev` and of the editor in `.moku/` stays), runs Bun again under `.moku/visual/bunfig.toml` as `dev` does (hot plugin, `--serve-plugin`, `--preload`), and the child serves the page on a free port, then stops it. No `manifest.json`: `[game] visual: no manifest.json in "<game>".` Exit 0 when the report is ok, else 1. `[game] visual: <file> must export default { app, tests }.` for a missing module or another shape, a bare app factory too.
|
|
350
350
|
- `preparePage(root, { agents?, preload?, servePlugins? })` of `@moku-labs/game/cli` writes the dev page of `moku-game dev` and resolves `{ html, bunfig, engine }` (both paths absolute; `engine` the `EngineFingerprint` whose `id` the page shows in `globalThis.__MOKU_GAME_ENGINE__`), for a server the caller starts: `bun --config=<bunfig>`. With agents the page also imports the game's `**/*.dev.ts` and hands them to the agents. It also writes the first, empty `.moku/assets-stamp.ts` when the game has none. The editor calls it: `await preparePage("games/timber", { agents: ["@moku-labs/editor/agent/page"] })`.
|
|
@@ -575,6 +575,7 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
|
|
|
575
575
|
- `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".
|
|
576
576
|
- `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.
|
|
577
577
|
- `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.
|
|
578
|
+
- `Tappable({ intent, payload, point: true })`: a finger tap answers `{ intent, payload: { ...payload, point: { x, y } } }`, the press-down point in the view's own units (a ui `button` with `point`: (0, 0) its top-left corner); `app.input.tap(target, point?)` hands a point already in those units to a flagged view. No `point` key without the flag, without a point (Enter, Escape, `tap(target)`) or on a long press; `point` absent by default, so a `Tappable` serialises as before. Type: `TapValue` (the component's value, `IntentValue & { point?: true }`).
|
|
578
579
|
- `Draggable({ payload, carry?, aim? })`: `aim: { x, y }`, a point of the view in its own units, moves the hover and the drop lookup from the finger to that point of the view in the hand; `null` (default) is the finger.
|
|
579
580
|
- `pluginConfigs.renderer.onDemand: true` draws a frame only when something visible changed (a written view, a filter value, a resize, a wake, a capture); `app.renderer.stats().drawn` is the frames drawn per second (`fps` without it); a game that writes into its own `Display` object calls `app.renderer.invalidate(entity)` before the write; `renderer.sync.debug.verifyFrames(true)` (dev/debug) checks skipped frames by pixels and logs `renderer:missed-frame`; a dev build warns `renderer:missed-mark` for a write without the call.
|
|
580
581
|
- `app.renderer.stats()` adds `textureMbSplit: { art, targets, kept }` (MiB). `app.renderer.host.resolution()` is the resolution drawn at: `override ?? min(devicePixelRatio, maxResolution)`; `maxResolution` is a number (default 2), a change of `devicePixelRatio` is followed from the next frame, and `app.renderer.monitor.setResolution(n | undefined)` overrides it in every build, the way to apply a player's graphics setting from an effect (0.5 to 4, else a `RangeError`).
|
|
@@ -593,9 +594,9 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
|
|
|
593
594
|
|
|
594
595
|
A screen is a projection whose `view` returns JSX. The game's `tsconfig.json` sets `"jsx": "react-jsx"` and `"jsxImportSource": "@moku-labs/game"`; screens are `.tsx` files. There is no DOM and no React.
|
|
595
596
|
|
|
596
|
-
- Tags: `screen`, `layer`, `row`, `column`, `stack`, `spacer`, `panel` (swallows taps), `image` (`texture`, `fit?: "contain" | "cover" | "fill"`), `icon` (`name`, `fit?`), `text` (`content: string | Message`, or `bind={bind(Counter, "value")}` with `components={[Counter({ value })]}`; formats `int`, `mm:ss`, `h:mm:ss`, `duration`; `Countdown({ until })` with `bind(Countdown, "left", { format: "mm:ss" })` counts down to a `clock` moment; `style` is a text style key), `button` (`intent` + `payload`, or `local`, never both), `scroll` (`axis?: "x" | "y"` (`"y"`), fixed at spawn, another one later warns `ui:scroll-axis-fixed`; children for a short list, laid out as a column on `y` and a row on `x`, or the windowed form `rows`, `rowHeight`, `overscan?` (5), `row: index => node`, on `y` only: `axis: "x"` with `rows` throws `[game] A windowed scroll moves on y only.`; row state belongs in the model, a row that leaves the window loses its local state; `snap?: number[]` stops in offsets, kept inside `0..max`: a release glides to the stop nearest `offset + v × 260` (v in units a ms) on `1 − (1 − p)³` over `min(620, 260 + distance × 1.1)` ms; without `snap` a release flings, `v ×= 0.998` a ms until under 0.02, 0 when the finger rested over 50 ms; `offset?: number` (0) where it stands from the start, drawn there in its first frame, a new value glides there, the same value does nothing; hard edges, nothing passes on to a parent scroll; a press on a child that leaves the tap slop along the scroll's axis goes to the scroll and the child answers nothing, a finger on a moving scroll only stops it; every number in `time.delta` ms, so a time scale applies; the public component `ScrollState { offset, max, moving }` on its entity, whole units `0..max`, written when it changes and once with `moving: false` when it stops, read by a system and by `game.explain`; `app.ui.scroll(key, to)` and the visual step `{ scroll: { key, to } }` set it at once), `input` (a text field; its text lives in the component's `local`, see the ui README), `anchor` (`to: AnchorTarget | AnchorTarget[]`, `AnchorTarget` = `{ projection, key }`, a ui element keyed under its root's projection; `pad?: number` (0) outward in its root's units: its rect is where its targets are drawn, the union of the shown ones, in the frame they are laid out, scrolled or moved, through fits, slots and ancestor motion, rotation left out; children lay out inside it; a `width`/`height`/`position` in its style is ignored (`ui:anchor-style`, dev); with no target shown it is drawn at alpha 0 and takes no tap, stays, and comes back with its target; `ui:anchor-target-missing` `{ key, to }` once (dev) after a key named nothing two frames in a row; a target inside the anchor is refused, `[game] An anchor cannot point at its own child "key".`; its `change.Box` motion plays only when its targets change (a new `to`, a key naming another entity), never on a follow, and a glide that runs is carried so it lands on the moving target; 0 B a frame still or following: `<anchor key="window" to={{ projection: "board.strip", key: "seat0" }} pad={4} motion={glide}>`). Common props: `key`, `style`, `state: { active?, disabled?, selected? }`, `motion`, `components` (extra component values for the element's entity, such as a filter: `components={[Glow({ strength: 2 })]}`, or `DebugTrigger()`: five taps within 3000 ms of wall time on that view call `app.debug.overlay.open()` on a page with the agent flag, nothing elsewhere; put it on a `button` naming nothing); containers take `hosts?: string[]` (projections drawn inside the element: world views hang under it from the slot's first frame; a JSX projection is laid out in the slot's content box). Children draw and are hit in markup order at equal `zIndex`; the roots of a scene draw in the order of its `projections` (the `ui` layer sorts by `Order`; `ui: { sort: "none" }` keeps insertion order). `defineMotion({ when: "change" })` plays its `enter` and `exit` only for a commit or a popup, never when its screen mounts or unmounts; declare a motion at module level (`ui:motion-rebuilt` names a loop rebuilt in a view). `motion.change` plays `Box` (the rects), `Transform` (the rest poses), the visual the element is drawn with (`Shape`, `Sprite`, `NineSlice`, `Text`, when a render or a restyle moves a number of it: `sweep`, `alpha`, `w`; a returned motion brings the numbers home from where they stand and the other fields land at once; the last motion of that name is cancelled first) and each extra of `components`, each as `(view, previous, next, hint)`; a dev build names any other `change` hook once, `ui:change-never-plays` `{ key, name }`. An element a render replaces (a root whose view returns another key or tag, a child of another key or tag) plays its exit with `"change"`, everything under it plays its own, and it leaves `find` at once, so the new element takes the keys they share. Style adds `nineSlice`, `tint`, `offsetX`, `offsetY`, `scale`, `origin`, `fit: "contain"`; state variants `is: { hover, pressed, disabled, active, selected, covered }`. `popup(Component, props, { over })` stacks a popup over a kept one.
|
|
597
|
+
- Tags: `screen`, `layer`, `row`, `column`, `stack`, `spacer`, `panel` (swallows taps), `image` (`texture`, `fit?: "contain" | "cover" | "fill"`), `icon` (`name`, `fit?`), `text` (`content: string | Message`, or `bind={bind(Counter, "value")}` with `components={[Counter({ value })]}`; formats `int`, `mm:ss`, `h:mm:ss`, `duration`; `Countdown({ until })` with `bind(Countdown, "left", { format: "mm:ss" })` counts down to a `clock` moment; `style` is a text style key), `button` (`intent` + `payload`, or `local`, never both; `point` beside `intent` adds `payload.point: { x, y }` of a finger tap, the press-down point in the button's own units, (0, 0) its top-left corner, absent for keyboard taps: `<button intent="kitTap" point />`), `scroll` (`axis?: "x" | "y"` (`"y"`), fixed at spawn, another one later warns `ui:scroll-axis-fixed`; children for a short list, laid out as a column on `y` and a row on `x`, or the windowed form `rows`, `rowHeight`, `overscan?` (5), `row: index => node`, on `y` only: `axis: "x"` with `rows` throws `[game] A windowed scroll moves on y only.`; row state belongs in the model, a row that leaves the window loses its local state; `snap?: number[]` stops in offsets, kept inside `0..max`: a release glides to the stop nearest `offset + v × 260` (v in units a ms) on `1 − (1 − p)³` over `min(620, 260 + distance × 1.1)` ms; without `snap` a release flings, `v ×= 0.998` a ms until under 0.02, 0 when the finger rested over 50 ms; `offset?: number` (0) where it stands from the start, drawn there in its first frame, a new value glides there, the same value does nothing; hard edges, nothing passes on to a parent scroll; a press on a child that leaves the tap slop along the scroll's axis goes to the scroll and the child answers nothing, a finger on a moving scroll only stops it; every number in `time.delta` ms, so a time scale applies; the public component `ScrollState { offset, max, moving }` on its entity, whole units `0..max`, written when it changes and once with `moving: false` when it stops, read by a system and by `game.explain`; `app.ui.scroll(key, to)` and the visual step `{ scroll: { key, to } }` set it at once), `input` (a text field; its text lives in the component's `local`, see the ui README), `anchor` (`to: AnchorTarget | AnchorTarget[]`, `AnchorTarget` = `{ projection, key }`, a ui element keyed under its root's projection; `pad?: number` (0) outward in its root's units: its rect is where its targets are drawn, the union of the shown ones, in the frame they are laid out, scrolled or moved, through fits, slots and ancestor motion, rotation left out; children lay out inside it; a `width`/`height`/`position` in its style is ignored (`ui:anchor-style`, dev); with no target shown it is drawn at alpha 0 and takes no tap, stays, and comes back with its target; `ui:anchor-target-missing` `{ key, to }` once (dev) after a key named nothing two frames in a row; a target inside the anchor is refused, `[game] An anchor cannot point at its own child "key".`; its `change.Box` motion plays only when its targets change (a new `to`, a key naming another entity), never on a follow, and a glide that runs is carried so it lands on the moving target; 0 B a frame still or following: `<anchor key="window" to={{ projection: "board.strip", key: "seat0" }} pad={4} motion={glide}>`). Common props: `key`, `style`, `state: { active?, disabled?, selected? }`, `motion`, `components` (extra component values for the element's entity, such as a filter: `components={[Glow({ strength: 2 })]}`, or `DebugTrigger()`: five taps within 3000 ms of wall time on that view call `app.debug.overlay.open()` on a page with the agent flag, nothing elsewhere; put it on a `button` naming nothing); containers take `hosts?: string[]` (projections drawn inside the element: world views hang under it from the slot's first frame; a JSX projection is laid out in the slot's content box). Children draw and are hit in markup order at equal `zIndex`; the roots of a scene draw in the order of its `projections` (the `ui` layer sorts by `Order`; `ui: { sort: "none" }` keeps insertion order). `defineMotion({ when: "change" })` plays its `enter` and `exit` only for a commit or a popup, never when its screen mounts or unmounts; declare a motion at module level (`ui:motion-rebuilt` names a loop rebuilt in a view). `motion.change` plays `Box` (the rects), `Transform` (the rest poses), the visual the element is drawn with (`Shape`, `Sprite`, `NineSlice`, `Text`, when a render or a restyle moves a number of it: `sweep`, `alpha`, `w`; a returned motion brings the numbers home from where they stand and the other fields land at once; the last motion of that name is cancelled first) and each extra of `components`, each as `(view, previous, next, hint)`; a dev build names any other `change` hook once, `ui:change-never-plays` `{ key, name }`. An element a render replaces (a root whose view returns another key or tag, a child of another key or tag) plays its exit with `"change"`, everything under it plays its own, and it leaves `find` at once, so the new element takes the keys they share. Style adds `nineSlice`, `tint`, `offsetX`, `offsetY`, `scale`, `origin`, `fit: "contain"`; state variants `is: { hover, pressed, disabled, active, selected, covered }`. `popup(Component, props, { over })` stacks a popup over a kept one.
|
|
597
598
|
- Style vocabulary (`defineStyle`, plain data): flow `direction`, `wrap`, `justify`, `align`, `alignSelf`, `gap`, `grow`, `shrink`; box `padding`, `margin`, `width`, `height`, `minWidth`, `minHeight`, `maxWidth`, `maxHeight`, `aspect`, `overflow`; position `position`, `left`, `top`, `right`, `bottom`, `reason`; visual `fill`, `stroke`, `strokeWidth`, `radius`, `alpha`, `shape: "rect" | "triangle" | "arc"` (`"rect"`; a triangle fills the box pointing right; an arc is only a `stroke` of `strokeWidth` on the circle inscribed in the box, `min(width, height) − strokeWidth` across, from 12 o'clock clockwise over `sweep`), `dash` (dash length of the stroke, gaps of half a dash; not on an arc), `sweep` (0..1, default 1, clamped; 0 draws nothing, 1 a closed ring), `cap: "round" | "butt"` (`"round"`; the ends of an open arc); variants `is: { pressed?, disabled?, active?, selected? }` and `when: { portrait?, landscape?, tall?, wide? }`, each a partial style merged in when the flag holds. Lengths are reference units or `"safeArea.top" | "safeArea.right" | "safeArea.bottom" | "safeArea.left"`. No font size here: it comes from the text style.
|
|
598
|
-
- `defineComponent(name, { local?, outcomes?, view(props, local) })`. A component with `outcomes` is a popup: `await fx(popup(Component, props))` opens the gate for its outcomes and resolves with `{ intent, payload }` of the pressed button. A button with `local` writes into the nearest component instance; it never reaches the graph.
|
|
599
|
+
- `defineComponent(name, { local?, outcomes?, view(props, local) })`. A component with `outcomes` is a popup: `await fx(popup(Component, props))` opens the gate for its outcomes and resolves with `{ intent, payload, at }` of the pressed button, `at` the clock moment of the answer. A button with `local` writes into the nearest component instance; it never reaches the graph.
|
|
599
600
|
- `tr(key, params?)` returns a frozen `Message` `{ key, params }`; no locale is read at the call site. Strings live in `strings/<locale>.json` of any feature or sub-feature, as ICU MessageFormat 1 (`{n, plural, one {# order} other {# orders}}`, `select`, `selectordinal`, `number`, `date`, `time`; no skeletons, no `currency`). `bun run assets:keys` compiles them. The keys of the top-level features and the layers go into `generated/strings.<locale>.ts`, which one feature registers; a sub-feature's keys start with `<name>.` (`ep01.title`) and go into `generated/strings.<name>.<locale>.ts`, which the sub-feature registers lazily, `strings: { en: () => import("@generated/strings.ep01.en"), ru: () => import("@generated/strings.ep01.ru") }`. With `assets` composed those modules load and unload with the bundle named like the sub-feature: every way the bundle comes (a node entry, a scene's `bundles`, `load`, a restore, the `safeNode`) brings its strings, a locale switch brings them in the new locale, and while the bundle is not loaded a key of it gives `⟦key⟧` and `has(key)` is false. A compiled module calls the root helpers `messageArgument(value, intl)` (an element stays an element part, a list goes through `Intl.ListFormat`, a number through `Intl.NumberFormat`, else text) and `messageDuration(ms)` (`95_000` gives `{ minutes: 1, seconds: 35 }`). `app.i18n`: `locale()`, `setLocale(locale)` (async, emits `i18n:locale-changed`), `format(message, locale?)` returns `Part[]`, `plain(message)` returns a string, `has(key)`, `isKey(value)`, `locales()`, `replace(locale, messages)` (dev hot swap of a generated strings file). Config: `locale: "en"`, `fallback: "en"`, `locales: {}`.
|
|
600
601
|
- Keys that come from data: `I18n.TextKey<Strings>` is the keys of the generated `Strings` without parameters (nothing new is generated). A data table types its keys `TextKey` or builds them with the kit's `key("board.hint.red")`; the kit's `tr` never takes a plain `string`. A key read back from a save is checked where the app is (an effect handler, app or page code, loading a save) with one `isKey(value)`: `defineGameApp({ ..., strings: type<Strings>() })` types the game's `app.i18n`, so a true `app.i18n.isKey(value)` narrows the value to `TextKey`; `ctx.require(i18nPlugin).isKey(value)` in a plugin narrows to `string`. `app.i18n.isKey(value)` answers true for a key of the loaded tables of the current locale or the fallback, and for the `<feature>.` prefix of a sub-feature whose strings are not loaded yet; a key that takes parameters answers true too.
|
|
601
602
|
- Text: `Text` component, `label({ text, style, at, anchor? })` for board text in a projection view, `defineTextStyles({ "hud.digits": { font, size, fill, bold?, italic?, stroke?, strokeWidth?, letterSpacing?, align?, wrap? (a width, "none" or "box": wrap at the laid-out width of its ui element; lines break between words, after a hyphen inside a word and at a soft hyphen U+00AD, drawn as `-` only where the line breaks), digits?, lineHeight? (the line as a multiple of size above 0, such as 1.28; glyphs sit in the middle of the line; absent: the font's own line) } })` under the feature's `textStyles` key. Tags inside a string: `<b>`, `<i>`, `<color=#rrggbb>`, `<icon=key>`, `\<`, `\n`. Built-in styles `body` and `digits` from config `fonts: { body: "ui.font-body", digits: "ui.font-digits" }`. `app.text.measure(content, style, width?)` gives the same numbers in a browser and in Bun. `app.text.replaceStyles(styles)` is the dev hot swap of a saved `defineTextStyles` value. A game's own number format: `defineTextFormats({ "pill.number": value => ({ content, style }) })` under the feature's `textFormats` key, named by the `bind` of `defineGame` (`GameTypes.textFormats`): `bind(Counter, "value", { format: "pill.number" })`. It takes the whole value, is pure over value and language, is not called while the whole value and the locale stand, and owns `Text.style`; a `Countdown` calls it every frame. `app.text.formatted(name, value)` answers `{ text, style }`, `undefined` for an unknown or built-in name and for a format that threw. A saved module exporting formats reloads the page.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/game",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.94",
|
|
4
4
|
"description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -159,10 +159,10 @@
|
|
|
159
159
|
"@arethetypeswrong/core": "0.18.3",
|
|
160
160
|
"@biomejs/biome": "2.4.16",
|
|
161
161
|
"@formatjs/icu-messageformat-parser": "3.5.20",
|
|
162
|
-
"@moku-labs/ci": "1.5.
|
|
163
|
-
"@moku-labs/common": "0.3.
|
|
162
|
+
"@moku-labs/ci": "1.5.8",
|
|
163
|
+
"@moku-labs/common": "0.3.11",
|
|
164
164
|
"@moku-labs/core": "1.7.6",
|
|
165
|
-
"@moku-labs/native": "0.3.
|
|
165
|
+
"@moku-labs/native": "0.3.15",
|
|
166
166
|
"@moku-labs/system": "0.3.7",
|
|
167
167
|
"@types/bun": "1.4.2",
|
|
168
168
|
"@vitest/coverage-istanbul": "4.0.18",
|