@moku-labs/game 0.15.117 → 0.15.119
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/page.mjs +1 -1
- package/dist/app/system.d.mts +2 -2
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +1 -1
- package/dist/{commands-DYw6k-2W.d.mts → commands-CzT9eYnf.d.mts} +2 -2
- package/dist/control.d.mts +1 -1
- package/dist/{index-Cdl7-lTx.d.mts → index-CKF3qS2-.d.mts} +8 -6
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +2 -2
- 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-B4jwb6Rd.d.mts → runtime-BbZtyfgH.d.mts} +1 -1
- package/dist/{sources-WiVMRhXq.mjs → sources-CdWn7B5r.mjs} +1 -1
- package/dist/{src-spqsx3lB.mjs → src-_nn6V6aX.mjs} +201 -75
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +1 -1
- package/dist/{types-MOasDgxY.d.mts → types-BHEOjYV3.d.mts} +95 -14
- package/dist/{types-DGBAOEkO.d.mts → types-XygtsVg3.d.mts} +3 -3
- package/dist/{types-CFV-839_.d.mts → types-cEAJaK0D.d.mts} +1 -1
- package/dist/{visual-CcsSoV27.d.mts → visual-CVHirfkU.d.mts} +3 -3
- package/dist/{visual-CvFDvkA_.mjs → visual-CYq-xUqz.mjs} +45 -16
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -289,13 +289,36 @@ type Style<Asset extends string = string> = BaseStyle<Asset> & {
|
|
|
289
289
|
is?: IsVariants<Asset>;
|
|
290
290
|
when?: WhenVariants<Asset>;
|
|
291
291
|
};
|
|
292
|
+
/**
|
|
293
|
+
* The style object of a `text` tag: a layout style whose base and `when` variants may name the
|
|
294
|
+
* text style key it draws and measures with, so one text takes the letters of the frame. The `is`
|
|
295
|
+
* variants carry no key: a press must not move the layout. A named format of a bound text still
|
|
296
|
+
* picks its own style; a style without `text` draws in `body`. `Key` is the game's text style key
|
|
297
|
+
* union: `uiFor` narrows `text` to it.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```tsx
|
|
301
|
+
* // The shop title: 19 on a 16:9 phone, 20.5 on a 20:9 one, one text node on both.
|
|
302
|
+
* <text key="title" content="Vitrine" style={{ text: "title.19", when: { tall: { text: "title.20.5" } } }} />;
|
|
303
|
+
* const title = app.ui.find("title");
|
|
304
|
+
* if (title !== undefined) app.world.ecs.get(title, Text)?.style; // "title.19" on 1080 x 1920, "title.20.5" on 1080 x 2400
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
type TextTagStyle<Asset extends string = string, Key extends string = string> = Omit<Style<Asset>, "when"> & {
|
|
308
|
+
text?: Key;
|
|
309
|
+
when?: { [Name in keyof WhenVariants<Asset>]?: BaseStyle<Asset> & {
|
|
310
|
+
text?: Key;
|
|
311
|
+
} };
|
|
312
|
+
};
|
|
292
313
|
/**
|
|
293
314
|
* What `resolve` answers with: the base vocabulary with every safe-area token replaced by a
|
|
294
|
-
* number and every variant already merged in
|
|
315
|
+
* number and every variant already merged in, and the text style key a text's style named.
|
|
316
|
+
* Frozen.
|
|
295
317
|
*
|
|
296
318
|
* @example
|
|
297
319
|
* ```ts
|
|
298
320
|
* const resolved: ResolvedStyle = { direction: "row", gap: 12, padding: 24 };
|
|
321
|
+
* const title: ResolvedStyle = { text: "title.20.5", width: 600 };
|
|
299
322
|
* ```
|
|
300
323
|
*/
|
|
301
324
|
type ResolvedStyle = Omit<BaseStyle, "padding" | "margin" | "left" | "top" | "right" | "bottom"> & {
|
|
@@ -314,7 +337,8 @@ type ResolvedStyle = Omit<BaseStyle, "padding" | "margin" | "left" | "top" | "ri
|
|
|
314
337
|
left?: number;
|
|
315
338
|
top?: number;
|
|
316
339
|
right?: number;
|
|
317
|
-
bottom?: number;
|
|
340
|
+
bottom?: number; /** The text style key of a text, when its style object names one. */
|
|
341
|
+
text?: string;
|
|
318
342
|
};
|
|
319
343
|
/**
|
|
320
344
|
* The viewport flags of a style: which `when` variants apply this frame.
|
|
@@ -1058,7 +1082,8 @@ type State$1 = {
|
|
|
1058
1082
|
moved: boolean;
|
|
1059
1083
|
/**
|
|
1060
1084
|
* The press belongs to a scroll: it landed on a moving one and stopped it, or it was handed to
|
|
1061
|
-
* one past the tap slop
|
|
1085
|
+
* one past the tap slop, or a locked one dropped it (F177), which leaves no pressed entity. Its
|
|
1086
|
+
* release answers nothing and runs no `onTap` listener.
|
|
1062
1087
|
*/
|
|
1063
1088
|
caught: boolean; /** The pressed or held entity. */
|
|
1064
1089
|
entity: Entity | undefined; /** The projection key of `entity`, read once at press time. */
|
|
@@ -2298,8 +2323,11 @@ type ButtonEscape = boolean & Brand<"ButtonEscape">;
|
|
|
2298
2323
|
type ButtonPoint = boolean & Brand<"ButtonPoint">;
|
|
2299
2324
|
/** What a text draws: a plain string, or a message of the game's string table. */
|
|
2300
2325
|
type TextContent = (string | Message) & Brand<"TextContent">;
|
|
2301
|
-
/**
|
|
2302
|
-
|
|
2326
|
+
/**
|
|
2327
|
+
* The text style key, or a layout style that may name the key in its base and its `when`
|
|
2328
|
+
* variants; one that names none draws in the built-in `body`.
|
|
2329
|
+
*/
|
|
2330
|
+
type TextStyleProp = (string | TextTagStyle) & Brand<"TextStyleProp">;
|
|
2303
2331
|
/** The asset key of an image. */
|
|
2304
2332
|
type ImageTexture = string & Brand<"ImageTexture">;
|
|
2305
2333
|
/** The asset key of an icon. */
|
|
@@ -2415,6 +2443,35 @@ type ScrollGlideMs = number & Brand<"ScrollGlideMs">;
|
|
|
2415
2443
|
* ```
|
|
2416
2444
|
*/
|
|
2417
2445
|
type ScrollAim = (string | number) & Brand<"ScrollAim">;
|
|
2446
|
+
/**
|
|
2447
|
+
* Keeps the finger from moving the scroll while it is `true` (F177); any other value leaves it
|
|
2448
|
+
* unlocked. A drag on it or on a view inside it moves nothing, its release neither flings nor
|
|
2449
|
+
* snaps, and a finger that lands while it glides or flings does not stop it. The views inside keep
|
|
2450
|
+
* their taps: a press that drifts past the tap slop answers none. A finger that holds the scroll
|
|
2451
|
+
* when the lock comes is let go with no velocity: with `snap` it glides to the stop nearest to
|
|
2452
|
+
* where it stands, and the finger takes it again only after a new press. `offset`, `aim`, `jump`
|
|
2453
|
+
* and `glideMs` move it as before. A scroll of the same axis around it does not take the pan.
|
|
2454
|
+
*
|
|
2455
|
+
* @example
|
|
2456
|
+
* ```tsx
|
|
2457
|
+
* // A delivery plays on the order strip, which stands on 318: the game moves it to the delivered
|
|
2458
|
+
* // order in 150 ms, and the player can tap the cards but not scroll them.
|
|
2459
|
+
* <scroll
|
|
2460
|
+
* key="strip"
|
|
2461
|
+
* axis="x"
|
|
2462
|
+
* snap={[0, 318, 390]}
|
|
2463
|
+
* offset={390}
|
|
2464
|
+
* glideMs={150}
|
|
2465
|
+
* locked
|
|
2466
|
+
* style={{ width: 306, height: 120 }}
|
|
2467
|
+
* >
|
|
2468
|
+
* <row key="track" style={{ width: 696, height: 120 }} />
|
|
2469
|
+
* </scroll>;
|
|
2470
|
+
* // 150 ms in: ScrollState { offset: 390, max: 390, moving: false }
|
|
2471
|
+
* // a drag on the strip after that: the same ScrollState in every frame, and no tap
|
|
2472
|
+
* ```
|
|
2473
|
+
*/
|
|
2474
|
+
type ScrollLocked = boolean & Brand<"ScrollLocked">;
|
|
2418
2475
|
/** How many rows a windowed scroll has. */
|
|
2419
2476
|
type ScrollRows = number & Brand<"ScrollRows">;
|
|
2420
2477
|
/** The height of every row, in reference units; above 0. */
|
|
@@ -2527,6 +2584,8 @@ type ButtonTagProps = CommonProps & {
|
|
|
2527
2584
|
* @example
|
|
2528
2585
|
* ```ts
|
|
2529
2586
|
* const props: TextTagProps = { content: "120", style: "digits" };
|
|
2587
|
+
* // The shop title: "title.19" on a short phone, "title.20.5" on a tall one.
|
|
2588
|
+
* const title: TextTagProps = { content: "Vitrine", style: { text: "title.19", when: { tall: { text: "title.20.5" } } } };
|
|
2530
2589
|
* // The coin counter: Counter is an extra component, the text shows Math.round of its value.
|
|
2531
2590
|
* const coins: TextTagProps = { bind: bind(Counter, "value"), components: [Counter({ value: 25 })] };
|
|
2532
2591
|
* ```
|
|
@@ -2594,7 +2653,8 @@ type ScrollWindowForm = {
|
|
|
2594
2653
|
* What a scroll container takes: children for a short list, or `rows`, `rowHeight` and `row` for
|
|
2595
2654
|
* a long one, whose rows exist only in the window; the `axis` it moves on, the `snap` stops a
|
|
2596
2655
|
* release glides to, the `offset` it stands at, how long a glide to it lasts (`glideMs`), what it
|
|
2597
|
-
* aims at (`aim`),
|
|
2656
|
+
* aims at (`aim`), whether a new `offset` stands there at once (`jump`), and whether the finger
|
|
2657
|
+
* is kept from moving it (`locked`).
|
|
2598
2658
|
*
|
|
2599
2659
|
* @example
|
|
2600
2660
|
* ```ts
|
|
@@ -2607,6 +2667,8 @@ type ScrollWindowForm = {
|
|
|
2607
2667
|
* const quick: ScrollProps = { axis: "x", offset: 390, glideMs: 150 };
|
|
2608
2668
|
* // The next order is at 0 too: a strip the player dragged to 390 glides back to 0.
|
|
2609
2669
|
* const next: ScrollProps = { axis: "x", offset: 0, aim: "order-7" };
|
|
2670
|
+
* // A delivery plays: the strip stands on 390 and no finger moves it.
|
|
2671
|
+
* const delivering: ScrollProps = { axis: "x", offset: 390, locked: true };
|
|
2610
2672
|
* // 1000 orders of 120 u in a 1600 u list: rows 0 to 18 exist at offset 0.
|
|
2611
2673
|
* const orders: ScrollProps = {
|
|
2612
2674
|
* style: { height: 1600 },
|
|
@@ -2623,6 +2685,7 @@ type ScrollProps = CommonProps & {
|
|
|
2623
2685
|
glideMs?: ScrollGlideMs;
|
|
2624
2686
|
aim?: ScrollAim;
|
|
2625
2687
|
jump?: ScrollJump;
|
|
2688
|
+
locked?: ScrollLocked;
|
|
2626
2689
|
} & (ScrollChildForm | ScrollWindowForm);
|
|
2627
2690
|
/**
|
|
2628
2691
|
* What a text field takes. `local` is required: every keystroke writes that field of the local
|
|
@@ -2717,8 +2780,8 @@ type Restyled<Properties, Asset extends string> = Properties extends unknown ? O
|
|
|
2717
2780
|
/**
|
|
2718
2781
|
* The same tags with the asset keys, text style keys and message keys of one game. `uiFor`
|
|
2719
2782
|
* carries it, so a game can name the type of its own intrinsics. The asset keys narrow `texture`,
|
|
2720
|
-
* `name` and the `nineSlice` of every style; the text style keys narrow the `style` of a text
|
|
2721
|
-
* and the `textStyle` of a field; the message keys narrow `content` and `placeholder`.
|
|
2783
|
+
* `name` and the `nineSlice` of every style; the text style keys narrow the `style` of a text,
|
|
2784
|
+
* the `text` of its style object and of each `when` variant, and the `textStyle` of a field; the message keys narrow `content` and `placeholder`.
|
|
2722
2785
|
*
|
|
2723
2786
|
* @example
|
|
2724
2787
|
* ```ts
|
|
@@ -2741,7 +2804,7 @@ type IntrinsicElementsFor<Asset extends string, TextStyleKey extends string, Str
|
|
|
2741
2804
|
text: Omit<CommonProps, "style"> & {
|
|
2742
2805
|
content?: string | Message<StringKey>;
|
|
2743
2806
|
bind?: TextBind;
|
|
2744
|
-
style?: TextStyleKey |
|
|
2807
|
+
style?: TextStyleKey | TextTagStyle<Asset, TextStyleKey>;
|
|
2745
2808
|
};
|
|
2746
2809
|
};
|
|
2747
2810
|
//#endregion
|
|
@@ -2895,7 +2958,9 @@ type Rect = {
|
|
|
2895
2958
|
};
|
|
2896
2959
|
/**
|
|
2897
2960
|
* The patches the scroll step writes with, one object each, filled in place: a frame builds none.
|
|
2898
|
-
* Every number in them is a whole reference unit.
|
|
2961
|
+
* Every number in them is a whole reference unit. `Scrollable` has two: `scrollable` when only
|
|
2962
|
+
* `moving` changed, `scrollLock` when `locked` did, so a scroll never locked keeps a `Scrollable`
|
|
2963
|
+
* with no `locked` field.
|
|
2899
2964
|
*/
|
|
2900
2965
|
type ScrollPatches = {
|
|
2901
2966
|
scroll: {
|
|
@@ -2910,6 +2975,10 @@ type ScrollPatches = {
|
|
|
2910
2975
|
scrollable: {
|
|
2911
2976
|
moving: boolean;
|
|
2912
2977
|
};
|
|
2978
|
+
scrollLock: {
|
|
2979
|
+
moving: boolean;
|
|
2980
|
+
locked: boolean;
|
|
2981
|
+
};
|
|
2913
2982
|
x: {
|
|
2914
2983
|
x: number;
|
|
2915
2984
|
};
|
|
@@ -3152,7 +3221,9 @@ type ScrollWindow = {
|
|
|
3152
3221
|
* new range re-aims takes it. `atProp` is true while the scroll follows that prop: it stands at it
|
|
3153
3222
|
* or glides to it, so a new range puts it at the prop again. The first place and a glide to a new
|
|
3154
3223
|
* prop set it; a press and `app.ui.scroll` clear it, and a fling or a snap glide only comes after a
|
|
3155
|
-
* press.
|
|
3224
|
+
* press. `locked` is the `locked` prop of the last place or settle, true only for the value `true`
|
|
3225
|
+
* (F177): the finger neither moves nor stops the scroll, the program still does. Plain values
|
|
3226
|
+
* written in place: a frame allocates nothing.
|
|
3156
3227
|
*/
|
|
3157
3228
|
type ScrollMotion = {
|
|
3158
3229
|
axis: "x" | "y";
|
|
@@ -3169,6 +3240,7 @@ type ScrollMotion = {
|
|
|
3169
3240
|
seen: number;
|
|
3170
3241
|
aim: string | number | undefined;
|
|
3171
3242
|
glideMs: number;
|
|
3243
|
+
locked: boolean;
|
|
3172
3244
|
placed: boolean;
|
|
3173
3245
|
atProp: boolean;
|
|
3174
3246
|
};
|
|
@@ -3676,8 +3748,10 @@ type UiNode = {
|
|
|
3676
3748
|
*/
|
|
3677
3749
|
content?: string;
|
|
3678
3750
|
/**
|
|
3679
|
-
* The text style key a `text`
|
|
3680
|
-
*
|
|
3751
|
+
* The text style key a `text` draws with: the key its style object took for this frame (the base
|
|
3752
|
+
* `text` or one a `when` variant set), else its `style` prop while that is a key; for a text bound
|
|
3753
|
+
* to a named format, the style that format answered. Absent on any other tag and on a text whose
|
|
3754
|
+
* style names none.
|
|
3681
3755
|
*
|
|
3682
3756
|
* @example
|
|
3683
3757
|
* ```ts
|
|
@@ -3685,6 +3759,13 @@ type UiNode = {
|
|
|
3685
3759
|
* const label = app.ui.tree().children.find(node => node.key === "homePlayLabel");
|
|
3686
3760
|
* label?.textStyle; // "ui.button"
|
|
3687
3761
|
* ```
|
|
3762
|
+
* @example
|
|
3763
|
+
* ```ts
|
|
3764
|
+
* // `<text key="title" style={{ text: "title.19", when: { tall: { text: "title.20.5" } } }} />`
|
|
3765
|
+
* // on a tall viewport (1080 x 2400), under the root row.
|
|
3766
|
+
* const title = app.ui.tree().children.find(node => node.key === "title");
|
|
3767
|
+
* title?.textStyle; // "title.20.5"
|
|
3768
|
+
* ```
|
|
3688
3769
|
*/
|
|
3689
3770
|
textStyle?: string;
|
|
3690
3771
|
value?: string;
|
|
@@ -3738,4 +3819,4 @@ type CommonProps = {
|
|
|
3738
3819
|
components?: ElementComponents;
|
|
3739
3820
|
};
|
|
3740
3821
|
//#endregion
|
|
3741
|
-
export { ResolvedStyle as $, TextFormats as A, types_d_exports$1 as B, Point as C, TextFormat as D, TextBind as E, types_d_exports as F, Message as G, Config$2 as H, defineComponent as I, StringTable as J, Part as K, Config$1 as L, TextStyleInput as M, TextStyles as N, TextFormatAnswer as O, TextValue as P, IsFlags as Q, InputApi as R, FormattedNumber as S, TextApi as T, I18nApi as U, Argument as V, IntlKit as W, TypedTr as X, TextKey as Y, types_d_exports$2 as Z, UiIntrinsicElements as _, JsxChild as a, Config as b, UiNode as c, DebugTrigger as d, Style as et, LocalWrite as f, IntrinsicElementsFor as g, defineTokens as h, Finding as i, TextRunStyle as j, TextFormatFunction as k, LayoutState as l, popup as m, ElementChange as n,
|
|
3822
|
+
export { ResolvedStyle as $, TextFormats as A, types_d_exports$1 as B, Point as C, TextFormat as D, TextBind as E, types_d_exports as F, Message as G, Config$2 as H, defineComponent as I, StringTable as J, Part as K, Config$1 as L, TextStyleInput as M, TextStyles as N, TextFormatAnswer as O, TextValue as P, IsFlags as Q, InputApi as R, FormattedNumber as S, TextApi as T, I18nApi as U, Argument as V, IntlKit as W, TypedTr as X, TextKey as Y, types_d_exports$2 as Z, UiIntrinsicElements as _, JsxChild as a, Config as b, UiNode as c, DebugTrigger as d, Style as et, LocalWrite as f, IntrinsicElementsFor as g, defineTokens as h, Finding as i, TextRunStyle as j, TextFormatFunction as k, LayoutState as l, popup as m, ElementChange as n, TextTagStyle as nt, JsxState as o, ScrollState as p, State$2 as q, ElementMotion as r, WhenFlags as rt, PopupComponent as s, DescriptionNode as t, StylesState as tt, Box as u, BindField as v, State as w, CountdownValue as x, BindOptions as y, State$1 as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $r as SnapshotOf, Fr as ClockSource, Hn as TypeTag, Jr as PlayerStateProvider, Lr as FakeClock, Nn as AnyFlow, Q as Config$2, Ur as Json, Vr as Config, Xr as SaveDoc, Yr as ProviderCall, a as Config$3, d as Manifest, gt as Orientation, hn as Config$1, jn as FeaturePlugin, n as AssetsIo, rt as PixiModule } from "./types-BUR4LWSa.mjs";
|
|
2
|
-
import { o as AudioContextLike, s as Config$4 } from "./types-
|
|
3
|
-
import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-
|
|
4
|
-
import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-
|
|
2
|
+
import { o as AudioContextLike, s as Config$4 } from "./types-cEAJaK0D.mjs";
|
|
3
|
+
import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-BHEOjYV3.mjs";
|
|
4
|
+
import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-CKF3qS2-.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
|
7
7
|
//#region src/plugins/model/store/providers/memory.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as FilterSlotQuad, Br as Api$6, Hn as TypeTag, Hr as Events$3, O as FilterSlot, Un as Descriptor, Ur as Json, Z as Api$4, Zn as AnchorTarget, _r as ComponentType, _t as Point, ai as Events$5, at as PixiTexture, b as Events$4, er as Ease, fr as AnyComponent, hr as ComponentHandle, ir as NumericFields, it as PixiSprite, j as SyncApi, k as FilterSlotInputs, kr as Api$3, li as Api$1, lr as TrackOptions, mr as AnyComponentValue, nt as PixiGpuProgram, ot as PixiUniformGroup, pn as Api$2, rr as MotionHandle, rt as PixiModule, s as Events$1, sr as ReducedMotion, t as Api$5, tt as PixiFilter, ur as TrackSegment, vi as Events$2, yi as Require, yr as Entity, yt as FilterCache } from "./types-BUR4LWSa.mjs";
|
|
2
|
-
import { R as InputApi, T as TextApi, U as I18nApi, c as UiNode, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion, tt as StylesState } from "./types-
|
|
2
|
+
import { R as InputApi, T as TextApi, U as I18nApi, c as UiNode, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion, tt as StylesState } from "./types-BHEOjYV3.mjs";
|
|
3
3
|
import { Log } from "@moku-labs/common/browser";
|
|
4
4
|
import { PluginCtx } from "@moku-labs/core";
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Br as Api$2, Pr as Api$4, Z as Api, kr as Api$1, ri as Api$3 } from "./types-BUR4LWSa.mjs";
|
|
2
|
-
import { W as AnimApi, r as UiApi } from "./types-
|
|
3
|
-
import { R as InputApi } from "./types-
|
|
2
|
+
import { W as AnimApi, r as UiApi } from "./types-cEAJaK0D.mjs";
|
|
3
|
+
import { R as InputApi } from "./types-BHEOjYV3.mjs";
|
|
4
4
|
import { r as Repro } from "./headless-C5kxf9oU.mjs";
|
|
5
5
|
import { i as ControlApp, o as InputOf } from "./types-CATC2vK8.mjs";
|
|
6
|
-
import { t as commands } from "./commands-
|
|
6
|
+
import { t as commands } from "./commands-CzT9eYnf.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. */
|
|
@@ -1253,11 +1253,13 @@ function formatBound(value, format, duration) {
|
|
|
1253
1253
|
* Declares one style. The work is the type: a field outside the vocabulary, or a value outside
|
|
1254
1254
|
* its union, is an error where the style is written, not where it is used.
|
|
1255
1255
|
*
|
|
1256
|
-
* @param style - The style, with its `is` and `when` variants
|
|
1256
|
+
* @param style - The style, with its `is` and `when` variants; the style of a text may name its
|
|
1257
|
+
* text style key, in its base and in its `when` variants.
|
|
1257
1258
|
* @returns The same object, frozen.
|
|
1258
1259
|
* @example
|
|
1259
1260
|
* ```ts
|
|
1260
1261
|
* defineStyle({ direction: "row", gap: 12 }).gap; // 12
|
|
1262
|
+
* defineStyle({ text: "title.19", when: { tall: { text: "title.20.5" } } }).when.tall.text; // "title.20.5"
|
|
1261
1263
|
* ```
|
|
1262
1264
|
*/
|
|
1263
1265
|
function defineStyle(style) {
|
|
@@ -1465,6 +1467,36 @@ const FITS = [
|
|
|
1465
1467
|
"cover",
|
|
1466
1468
|
"fill"
|
|
1467
1469
|
];
|
|
1470
|
+
/** What a text is drawn in when its markup names no text style key. */
|
|
1471
|
+
const DEFAULT_TEXT_STYLE = "body";
|
|
1472
|
+
/**
|
|
1473
|
+
* The text style key the markup of a text names (F182): the key its resolved style took from its
|
|
1474
|
+
* base or from a `when` variant of this frame, else its `style` prop while that is a key. A
|
|
1475
|
+
* property read and a type check: nothing is built.
|
|
1476
|
+
*
|
|
1477
|
+
* @param style - The resolved style of the text.
|
|
1478
|
+
* @param property - Its `style` prop.
|
|
1479
|
+
* @returns The key, or `undefined` when the markup names none.
|
|
1480
|
+
* @example
|
|
1481
|
+
* ```ts
|
|
1482
|
+
* namedKeyOf({ text: "title.20.5" }, "title.19"); // "title.20.5"
|
|
1483
|
+
* ```
|
|
1484
|
+
*/
|
|
1485
|
+
function namedKeyOf(style, property) {
|
|
1486
|
+
if (typeof style.text === "string") return style.text;
|
|
1487
|
+
return typeof property === "string" ? property : void 0;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* The text style key a text's markup writes into `Text.style` and is measured with until the
|
|
1491
|
+
* entity carries its `Text`: the key it names, else `body`. One reader for the measure, the
|
|
1492
|
+
* `Text` write and `lint()`; a format of a game still answers its own style where it does.
|
|
1493
|
+
*
|
|
1494
|
+
* @param element - The text, its style of this frame resolved.
|
|
1495
|
+
* @returns The key.
|
|
1496
|
+
*/
|
|
1497
|
+
function writtenKeyOf(element) {
|
|
1498
|
+
return namedKeyOf(element.style, element.node.props.style) ?? DEFAULT_TEXT_STYLE;
|
|
1499
|
+
}
|
|
1468
1500
|
/**
|
|
1469
1501
|
* Tells whether a tag draws nothing of its own, so its `Shape` is invisible unless its style fills.
|
|
1470
1502
|
*
|
|
@@ -1711,7 +1743,7 @@ function fieldsLeftAlone(element, type, owned) {
|
|
|
1711
1743
|
/**
|
|
1712
1744
|
* The visual component of an element: a sprite for an image or an icon (at alpha 0 while its style
|
|
1713
1745
|
* states a size the layout makes 0: the renderer draws a sprite of width 0 at its texture's size,
|
|
1714
|
-
* so the size alone cannot say "nothing"), the text for a text (with
|
|
1746
|
+
* so the size alone cannot say "nothing"), the text for a text (in the key of `writtenKeyOf`, with
|
|
1715
1747
|
* its laid-out width as the box a `"box"` style wraps at), the nine-slice of its style (outlined
|
|
1716
1748
|
* when the style sets `debug`, its rim alone when it sets `hollow`; the sprite and the nine-slice
|
|
1717
1749
|
* blended by the style's `blend`), or a rounded rectangle, a triangle with `shape: "triangle"`, its
|
|
@@ -1747,19 +1779,16 @@ function visualOf(element) {
|
|
|
1747
1779
|
...blendOf(element, style.blend)
|
|
1748
1780
|
})];
|
|
1749
1781
|
}
|
|
1750
|
-
if (type === "text") {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
...boxOf(element)
|
|
1761
|
-
})];
|
|
1762
|
-
}
|
|
1782
|
+
if (type === "text") return [Text({
|
|
1783
|
+
content: contentOf(node.props),
|
|
1784
|
+
style: writtenKeyOf(element),
|
|
1785
|
+
bind: node.props.bind,
|
|
1786
|
+
anchor: {
|
|
1787
|
+
x: 0,
|
|
1788
|
+
y: 0
|
|
1789
|
+
},
|
|
1790
|
+
...boxOf(element)
|
|
1791
|
+
})];
|
|
1763
1792
|
const clip = type === "scroll" || style.overflow === "hidden";
|
|
1764
1793
|
if (style.nineSlice !== void 0 && !clip) return [NineSlice({
|
|
1765
1794
|
texture: style.nineSlice,
|
|
@@ -1900,4 +1929,4 @@ function drawnRect(pose, local) {
|
|
|
1900
1929
|
};
|
|
1901
1930
|
}
|
|
1902
1931
|
//#endregion
|
|
1903
|
-
export {
|
|
1932
|
+
export { Overlay as $, unitOf as A, readStyle as B, UiCounters as C, defineStyle as D, defineTokens as E, boldLookOf as F, parentOf as G, applyPose as H, builtInStyles as I, rootPoseInto as J, poseUnder as K, defineTextFormats as L, Countdown as M, Text as N, formatBound as O, bind as P, NineSlice as Q, defineTextStyles as R, UI_OWNER as S, uiFor as T, isLeaving as U, textFor as V, localPoseOf as W, Display as X, rootPoseOf as Y, HudPart as Z, DebugTrigger as _, systemsFor as _t, fieldsLeftAlone as a, arcDefaults as at, Scroll as b, namedKeyOf as c, Exiting as ct, samePose as d, Order as dt, OverlayLevel as et, visualOf as f, Tree as ft, Covered as g, system as gt, Box as h, resource as ht, drawnRect as i, Transform as it, wholeValue as j, isTextFormat as k, namesFormat as l, Layer as lt, writtenKeyOf as m, mut as mt, CONTENT as n, Shape as nt, fitScaleOf as o, componentsFor as ot, visualRectOf as p, component as pt, rootPointOf as q, bindOf as r, Sprite as rt, livePatch as s, sprite as st, ANCHOR as t, Parent as tt, restValueOf as u, Now as ut, Escapable as v, tag as vt, popup as w, ScrollState as x, LocalWrite as y, label as z };
|
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-CVHirfkU.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-CdWn7B5r.mjs";
|
|
3
3
|
import { n as commands, t as run } from "./run-CeZj5UAg.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { createBrandConsole } from "@moku-labs/common/cli";
|
package/llms.txt
CHANGED
|
@@ -27,7 +27,7 @@ Root exports:
|
|
|
27
27
|
- Class: `SaveUnreadableError`.
|
|
28
28
|
- Plugin instances: `timePlugin`, `lifecyclePlugin`, `modelPlugin`, `clockPlugin`, `flowPlugin`, `worldPlugin`, `rendererPlugin`, `inputPlugin`, `assetsPlugin`, `scenesPlugin`, `animPlugin`, `i18nPlugin`, `textPlugin`, `uiPlugin`, `audioPlugin`, `effectsPlugin`, `platformPlugin`; the list `screen` = `world`, `renderer`, `input`, `assets`, `scenes`, `anim`, `i18n`, `text`, `ui`. `effects`, `audio` and `platform` are opt-in: `plugins: [...screen, effectsPlugin, audioPlugin, platformPlugin]`, `platform` last.
|
|
29
29
|
- Screen helpers from the root: `component`, `tag`, `resource`, `mut`, `system`, `projection`, `Layer`, `Order`, `Exiting`, `Tree`, `Now`, `Transform`, `Sprite`, `NineSlice`, `Shape`, `Parent`, `Display`, `Overlay`, `HudPart`, `sprite`, `Tappable`, `Pressable`, `Draggable`, `DropTarget`, `Swipeable`, `Traceable`, `Touchable`, `Held`, `Hovered`, `PointerOver`, `Pressed`, `Pointer`, `Traced`, `defineBundles`, `load`, `defineScene`.
|
|
30
|
-
- Interface helpers from the root (V3): `defineAnimation`, `sequence`, `parallel`, `stagger`, `tween`, `set`, `wait`, `mark`, `frames`, `sfx`, `haptic`, `use`, `spawn`, `spawned`, `play`, `external`, `defineMotion`, `Animation`, `Frames`, the resource `AnimPlayer`; `tr`, `messageArgument`, `messageDuration`; `Text`, `label`, `defineTextStyles`, `defineTextFormats`, `bind`, `Countdown` and the types `BindOptions`, `CountdownValue`, `TextFormat`, `TextFormats`, `TextFormatAnswer`, `TextFormatFunction`, `FormattedNumber`; `defineComponent`, `popup`, `defineStyle`, `defineTokens`, `resolve`, `Box`, `LocalWrite`, `DebugTrigger`, `ScrollState`; `music`. Also `stopSfx(id, { fadeMs? })` (ends a named sound, see audio) and `cubicBezier(x1, y1, x2, y2)` (a CSS-style easing curve for `tween`'s `ease`).
|
|
30
|
+
- Interface helpers from the root (V3): `defineAnimation`, `sequence`, `parallel`, `stagger`, `tween`, `set`, `wait`, `mark`, `frames`, `sfx`, `haptic`, `use`, `spawn`, `spawned`, `play`, `external`, `defineMotion`, `Animation`, `Frames`, the resource `AnimPlayer`; `tr`, `messageArgument`, `messageDuration`; `Text`, `label`, `defineTextStyles`, `defineTextFormats`, `bind`, `Countdown` and the types `BindOptions`, `CountdownValue`, `TextFormat`, `TextFormats`, `TextFormatAnswer`, `TextFormatFunction`, `FormattedNumber`; `defineComponent`, `popup`, `defineStyle` and the type `TextTagStyle`, `defineTokens`, `resolve`, `Box`, `LocalWrite`, `DebugTrigger`, `ScrollState`; `music`. Also `stopSfx(id, { fadeMs? })` (ends a named sound, see audio) and `cubicBezier(x1, y1, x2, y2)` (a CSS-style easing curve for `tween`'s `ease`).
|
|
31
31
|
- Effects helpers from the root (V5): `defineEmitter`, `Emitter`, `defineFilter`, `Glow`, `Outline`, `Blur`, `ColorMatrix`, `Noise`, `Displacement`, `Alpha`; the effect set `Flash`, `Grade`, `Vignette`, `RevealLine`, `RevealRound`, `Dissolve`, `Shine`, `Aura`, `Fold`, `Bloom` and their value types `FlashValue`, `GradeValue`, `VignetteValue`, `RevealLineValue`, `RevealRoundValue`, `DissolveValue`, `ShineValue`, `AuraValue`, `FoldValue`, `BloomValue`.
|
|
32
32
|
- Platform from the root (V6): the types `PlatformProvider`, `BackResult`, `HapticKind` and the frozen list `HAPTIC_KINDS`.
|
|
33
33
|
- `defineGame<Types>()` returns, typed by the game's `player`, `session`, `assets`, `bundles`, `scenes`, `strings`, `textStyles` and `textFormats`: `defineNode`, `defineFlow`, `defineFeature`, `projection`, `sprite`, `Sprite`, `NineSlice`, `defineBundles`, `load`, `defineScene`, `defineAnimation`, `frames`, `sfx`, `play`, `tr`, `label`, `bind`, `defineTextStyles`, `defineTextFormats`, `defineComponent`, `defineStyle`, `defineTokens`, `popup`, `music`, `Frames`, `defineEmitter`, `Emitter`, `Displacement`, and `system` (its `ctx.snapshot` typed by `player` and `session`), `volumes` (the `audio` config's reader of the typed player), `key` (string keys from data, below). `Types` is `{ player; session; assets: string; bundles?: string; scenes?: string; strings: Record<string, unknown>; textStyles?: string; textFormats?: string; emitters?: string }`.
|
|
@@ -595,7 +595,7 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
|
|
|
595
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.
|
|
596
596
|
|
|
597
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; `jump?: boolean` makes a new `offset` value of that render stand there at once, in the same solve as the content's new rects (track and offset shifted 82 together keep the cards in place), its fling or glide stopped, `moving: false`; a held scroll only remembers it; left out, a new value glides; 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.
|
|
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
|
+
- 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. A `<text>` style object (type `TextTagStyle`) also takes `text: "<text style key>"`, in its base and in `when` (not `is`): `style={{ text: "title.19", when: { tall: { text: "title.20.5" } } }}` draws one text with the key of the frame (F182).
|
|
599
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.
|
|
600
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: {}`.
|
|
601
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.
|