@moku-labs/game 0.15.87 → 0.15.88

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.
Files changed (33) hide show
  1. package/dist/app/page.d.mts +1 -1
  2. package/dist/app/page.mjs +1 -1
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +1 -1
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/{commands-DxUF13zr.d.mts → commands-C6RMqrY8.d.mts} +5 -5
  8. package/dist/control.d.mts +4 -4
  9. package/dist/{define-CMl6NcM4.d.mts → define-DE1XcBwC.d.mts} +2 -2
  10. package/dist/{headless-DtDdn5gg.d.mts → headless-CtRq6Uij.d.mts} +1 -1
  11. package/dist/{index-Bn0pFiae.d.mts → index-nK7iVsWx.d.mts} +30 -7
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +3 -3
  14. package/dist/inspect.d.mts +6 -6
  15. package/dist/inspect.mjs +1 -1
  16. package/dist/jsx-dev-runtime.d.mts +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/{runtime-DOvgFNLH.d.mts → runtime-CmRqaHmz.d.mts} +1 -1
  19. package/dist/{sources-CyltHb9o.mjs → sources-kL64Svgl.mjs} +1 -1
  20. package/dist/{src-BFa-zMmW.mjs → src-BTPWdbHH.mjs} +268 -158
  21. package/dist/testing.d.mts +4 -4
  22. package/dist/testing.mjs +1 -1
  23. package/dist/{types-OBpR0u05.d.mts → types-BbLjYfGR.d.mts} +113 -16
  24. package/dist/{types-OKAnpylW.d.mts → types-BlXL-VC3.d.mts} +4 -4
  25. package/dist/{types-C5gLBKbm.d.mts → types-CJYudpme.d.mts} +2 -2
  26. package/dist/{types-BpipkaVe.d.mts → types-ehmvA6yu.d.mts} +2 -2
  27. package/dist/{types-CbVXXqPs.d.mts → types-w5_A5TPL.d.mts} +35 -4
  28. package/dist/{visual-B7TxMv1J.mjs → visual-CULAJg6b.mjs} +161 -10
  29. package/dist/{visual-CMnWgCkh.d.mts → visual-DvhjRhgP.d.mts} +6 -6
  30. package/dist/visual.d.mts +1 -1
  31. package/dist/visual.mjs +1 -1
  32. package/llms.txt +4 -3
  33. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { Ar as ClockSource, Dn as FeaturePlugin, Fn as NodeTable, Mr as FakeClock, Rr as Json, Un as Hint, Wn as NodeFx, kn as AnyFlow, zn as Descriptor } from "./types-CbVXXqPs.mjs";
2
- import { t as createApp } from "./index-Bn0pFiae.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-OKAnpylW.mjs";
4
- import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
1
+ import { An as AnyFlow, Bn as Descriptor, Gn as NodeFx, In as NodeTable, Nr as FakeClock, On as FeaturePlugin, Wn as Hint, jr as ClockSource, zr as Json } from "./types-w5_A5TPL.mjs";
2
+ import { t as createApp } from "./index-nK7iVsWx.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-BlXL-VC3.mjs";
4
+ import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-CtRq6Uij.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/clock/fake.d.ts
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-BFa-zMmW.mjs";
1
+ import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-BTPWdbHH.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-CWlqhS7l.mjs";
3
3
  import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";
@@ -1,4 +1,4 @@
1
- import { $n as NumericFields, Cr as TagType, Gn as Answer, J as TransformValue, Kn as AnchorTarget, Qn as MotionHandle, Rr as Json, Un as Hint, Xn as Motion, Yn as Ease, Z as Api$3, Zn as MotionCause, cr as AnyComponentType, er as ProjectionMotion, fr as ComponentType, ht as ViewportSize, ii as Api, kr as Api$5, lr as AnyComponentValue, mi as Require, mr as Entity, nr as ReducedMotion, or as ViewHandle, qn as ChangeHook, s as Events$1, sr as AnyComponent, t as Api$4, un as Api$1, wr as Api$2, zn as Descriptor } from "./types-CbVXXqPs.mjs";
1
+ import { $n as MotionHandle, Ar as Api$5, Bn as Descriptor, J as TransformValue, Jn as ChangeHook, Kn as Answer, Qn as MotionCause, Tr as Api$2, Wn as Hint, Xn as Ease, Z as Api$3, Zn as Motion, ai as Api, cr as AnyComponent, er as NumericFields, hi as Require, hr as Entity, ht as ViewportSize, lr as AnyComponentType, pr as ComponentType, qn as AnchorTarget, rr as ReducedMotion, s as Events$1, sr as ViewHandle, t as Api$4, tr as ProjectionMotion, un as Api$1, ur as AnyComponentValue, wr as TagType, zr as Json } from "./types-w5_A5TPL.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";
@@ -1419,7 +1419,7 @@ declare function defineComponent<Properties extends object, Local extends object
1419
1419
  */
1420
1420
  declare function defineComponent<Properties extends object, Local extends object>(name: string, spec: ComponentSpec<Properties, Local, never>): ComponentDefinition<Properties, Local, undefined>;
1421
1421
  declare namespace types_d_exports {
1422
- export { AdvanceTable, AssetsReplaced, BindField, BindOptions, BundleLoaded, BundleUnloaded, Config, CountdownValue, Deps, DrawnLabel, IconRun, KernelSlice, LayoutOptions, Line, LocaleChanged, Point, Run, SeenText, Size, State, TextAlign, TextApi, TextBind, TextCtx, TextFormat, TextLayout, TextRun, TextShadow, TextStyle, TextStyleInput, TextStyles, TextValue, TextWrap, Warn };
1422
+ export { AdvanceTable, AssetsReplaced, BindField, BindOptions, BundleLoaded, BundleUnloaded, Config, CountdownValue, Deps, DrawnLabel, FormattedNumber, IconRun, KernelSlice, LayoutOptions, Line, LocaleChanged, Point, Run, SeenText, Size, State, TextAlign, TextApi, TextBind, TextCtx, TextFormat, TextFormatAnswer, TextFormatFunction, TextFormats, TextLayout, TextRun, TextShadow, TextStyle, TextStyleInput, TextStyles, TextValue, TextWrap, Warn };
1423
1423
  }
1424
1424
  /**
1425
1425
  * A point in reference units: where a label sits, and which point of the block sits there.
@@ -1460,7 +1460,8 @@ declare const textBind: unique symbol;
1460
1460
  /**
1461
1461
  * Which numeric component field a label shows, and how. Plain data in the component, so a
1462
1462
  * snapshot lists it; nominal, so only `bind()` makes one and a hand-written literal does not
1463
- * compile.
1463
+ * compile. `format` is one of the four of `TextFormat`, or a name a feature registered under its
1464
+ * `textFormats` key: the function itself never sits here, so a bind stays data.
1464
1465
  *
1465
1466
  * @example
1466
1467
  * ```ts
@@ -1472,7 +1473,7 @@ declare const textBind: unique symbol;
1472
1473
  type TextBind = {
1473
1474
  readonly component: string;
1474
1475
  readonly field: string;
1475
- readonly format: TextFormat;
1476
+ readonly format: string;
1476
1477
  } & {
1477
1478
  readonly [textBind]: true;
1478
1479
  };
@@ -1486,15 +1487,86 @@ type TextBind = {
1486
1487
  */
1487
1488
  type BindField<Value extends object> = keyof NumericFields<Value> & string;
1488
1489
  /**
1489
- * What `bind()` takes after the field. The format is `"int"` when left out.
1490
+ * What `bind()` takes after the field. The format is `"int"` when left out. `FormatKey` is the
1491
+ * format names of a game: the root `bind` has none and takes the four of `TextFormat`, the `bind`
1492
+ * of `defineGame` takes the names the game passed as `textFormats` too.
1490
1493
  *
1491
1494
  * @example
1492
1495
  * ```ts
1493
- * const options: BindOptions = { format: "mm:ss" };
1496
+ * const timer: BindOptions = { format: "mm:ss" };
1497
+ * const pill: BindOptions<"pill.number"> = { format: "pill.number" };
1494
1498
  * ```
1495
1499
  */
1496
- type BindOptions = {
1497
- format?: TextFormat;
1500
+ type BindOptions<FormatKey extends string = never> = {
1501
+ format?: TextFormat | FormatKey;
1502
+ };
1503
+ /**
1504
+ * What a named format answers for a whole number: what the label shows and the text style it is
1505
+ * drawn in. `style` is required: a format owns the style of its label.
1506
+ *
1507
+ * @example
1508
+ * ```ts
1509
+ * const small: TextFormatAnswer = { content: "950", style: "digits.17" };
1510
+ * // A sentence of the string table works too: it is formatted in the current locale.
1511
+ * const big: TextFormatAnswer = { content: tr("ui.number.thousand", { n: "1.5" }), style: "digits.14.5" };
1512
+ * ```
1513
+ */
1514
+ type TextFormatAnswer<StyleKey extends string = string> = {
1515
+ content: string | Message;
1516
+ style: StyleKey;
1517
+ };
1518
+ /**
1519
+ * A number format of a game: takes the whole value of a bound field, rounded as `"int"` rounds it,
1520
+ * and answers the content and the style. It must be pure over the value and the language: it is
1521
+ * asked when the whole value or the locale moves, never on a frame where they stand, and `ui` may
1522
+ * ask it again for the first solve of a label. A label bound to `Countdown.left` takes
1523
+ * milliseconds, so its format is called every frame the countdown runs: keep such a format cheap.
1524
+ *
1525
+ * @example
1526
+ * ```ts
1527
+ * // Pure over the value and the language. On a `Countdown` it is called every frame.
1528
+ * const pill: TextFormatFunction = value =>
1529
+ * value < 1000
1530
+ * ? { content: String(value), style: "digits.17" }
1531
+ * : { content: `${value / 1000}K`, style: "digits.14.5" };
1532
+ *
1533
+ * pill(950); // { content: "950", style: "digits.17" }
1534
+ * pill(1500); // { content: "1.5K", style: "digits.14.5" }
1535
+ * ```
1536
+ */
1537
+ type TextFormatFunction<StyleKey extends string = string> = (value: number) => TextFormatAnswer<StyleKey>;
1538
+ /**
1539
+ * What `defineTextFormats` returns and a feature registers under its `textFormats` key.
1540
+ *
1541
+ * @example
1542
+ * ```ts
1543
+ * const formats: TextFormats = defineTextFormats({
1544
+ * "pill.number": value => ({ content: String(value), style: "digits.17" })
1545
+ * });
1546
+ *
1547
+ * formats.kind; // "textFormats"
1548
+ * defineFeature("shared", { textStyles, textFormats: formats });
1549
+ * ```
1550
+ */
1551
+ type TextFormats = {
1552
+ readonly kind: "textFormats";
1553
+ readonly map: Readonly<Record<string, TextFormatFunction>>;
1554
+ };
1555
+ /**
1556
+ * What `app.text.formatted` answers: the finished string, tags and all, and the style a named
1557
+ * format picked for the number.
1558
+ *
1559
+ * @example
1560
+ * ```ts
1561
+ * // "pill.number" shows a thousand and more as "1.5K" in a smaller style.
1562
+ * const answer: FormattedNumber | undefined = app.text.formatted("pill.number", 1500);
1563
+ *
1564
+ * answer; // { text: "1.5K", style: "digits.14.5" }
1565
+ * ```
1566
+ */
1567
+ type FormattedNumber = {
1568
+ text: string;
1569
+ style: string;
1498
1570
  };
1499
1571
  /**
1500
1572
  * A moment to count down to, and how much is left. A game writes `until`, a moment of `clock` in
@@ -1779,9 +1851,10 @@ type LayoutOptions = {
1779
1851
  warn: Warn;
1780
1852
  };
1781
1853
  /**
1782
- * What was resolved for one entity last, so the frame step knows whether anything moved. `unit`
1783
- * is what the shown string of a bound label was built from: the rounded value for `"int"`, whole
1784
- * seconds for a time format. `bindRef` is the bind object `bind` was keyed from, so the key is
1854
+ * What was resolved for one entity last, so the frame step knows whether anything moved. `style`
1855
+ * is the style the label shows: for a named format the one its answer picked. `unit` is what the
1856
+ * shown string of a bound label was built from: the rounded value for `"int"` and for a named
1857
+ * format, whole seconds for a time format. `bindRef` is the bind object `bind` was keyed from, so the key is
1785
1858
  * built once per attached bind and a frame compares one reference. `box` is the `Text.box` the
1786
1859
  * label was laid out at: a label of a `"box"` style is laid out again when it moves.
1787
1860
  *
@@ -1822,7 +1895,9 @@ type Config = {
1822
1895
  */
1823
1896
  type State = {
1824
1897
  /** Built-in styles first, then the styles of every feature in feature order. */styles: Map<string, TextStyle>; /** Style name to the feature that brought it, for the duplicate error. */
1825
- styleOwner: Map<string, string>; /** The config fonts plus every `font`, `bold` and `italic` of every style. */
1898
+ styleOwner: Map<string, string>; /** The number formats of every feature by name, in feature order. */
1899
+ formats: Map<string, TextFormatFunction>; /** Format name to the feature that brought it, for the duplicate error. */
1900
+ formatOwner: Map<string, string>; /** The config fonts plus every `font`, `bold` and `italic` of every style. */
1826
1901
  fontKeys: Set<string>; /** The parsed advance table per font key, filled when `assets` has the font. */
1827
1902
  tables: Map<string, AdvanceTable>; /** The font keys handed to `renderer.sync.fonts.install`. */
1828
1903
  installed: Set<string>; /** What was resolved for an entity last. */
@@ -1853,9 +1928,9 @@ type State = {
1853
1928
  removers: Array<() => void>;
1854
1929
  };
1855
1930
  /**
1856
- * text plugin API, `app.text`. Two questions: how big a piece of text is, and which styles the
1857
- * game registered; and one order, the dev hot swap of a styles file. Everything else happens in
1858
- * the frame.
1931
+ * text plugin API, `app.text`. Three questions: how big a piece of text is, which styles the game
1932
+ * registered, and what a game's number format answers; and one order, the dev hot swap of a styles
1933
+ * file. Everything else happens in the frame.
1859
1934
  *
1860
1935
  * @example
1861
1936
  * ```ts
@@ -1908,6 +1983,28 @@ type TextApi = {
1908
1983
  * ```
1909
1984
  */
1910
1985
  hasGlyph(char: string, style: string): boolean;
1986
+ /**
1987
+ * What a format a feature registered answers for a number, before a label shows it: `ui` asks
1988
+ * here in the first solve of a label, when there is no `Text` to read yet. The value is rounded
1989
+ * as the `"int"` format rounds it (0 for one that is not finite), and a `Message` answer is
1990
+ * formatted in the current locale. The format is called on every ask: it must be pure over the
1991
+ * value and the language. A label bound to `Countdown.left` takes milliseconds, so its format is
1992
+ * called every frame the countdown runs.
1993
+ *
1994
+ * @param name - A name a feature registered under its `textFormats` key.
1995
+ * @param value - The number to show.
1996
+ * @returns The string and the style; `undefined` for a name no feature registered, one of the
1997
+ * four built-in formats included, and for a format that threw (reported once per name).
1998
+ * @example
1999
+ * ```ts
2000
+ * // "pill.number" is pure over the value and the language; on a `Countdown` it runs every frame.
2001
+ * // Below a thousand it answers the digits in "digits.17", from there "1.5K" in "digits.14.5".
2002
+ * app.text.formatted("pill.number", 949.6); // { text: "950", style: "digits.17" }
2003
+ * app.text.formatted("pill.number", 1500); // { text: "1.5K", style: "digits.14.5" }
2004
+ * app.text.formatted("mm:ss", 95_000); // undefined: a built-in format has no answer here
2005
+ * ```
2006
+ */
2007
+ formatted(name: string, value: number): FormattedNumber | undefined;
1911
2008
  /**
1912
2009
  * The registered style names: the two built-ins first, then the styles of every feature in
1913
2010
  * feature order.
@@ -3359,4 +3456,4 @@ type CommonProps = {
3359
3456
  components?: ElementComponents;
3360
3457
  };
3361
3458
  //#endregion
3362
- export { types_d_exports as A, Message as B, State as C, TextStyleInput as D, TextFormat as E, types_d_exports$1 as F, TypedTr as G, State$2 as H, Argument as I, ResolvedStyle as J, types_d_exports$2 as K, Config$2 as L, Config$1 as M, InputApi as N, TextStyles as O, State$1 as P, I18nApi as R, Point as S, TextBind as T, StringTable as U, Part as V, TextKey as W, StylesState as X, Style as Y, WhenFlags as Z, UiIntrinsicElements as _, JsxChild as a, Config as b, UiNode as c, DebugTrigger as d, LocalWrite as f, IntrinsicElementsFor as g, defineTokens as h, Finding as i, defineComponent as j, TextValue as k, LayoutState as l, popup as m, ElementChange as n, JsxState as o, ScrollState as p, IsFlags as q, ElementMotion as r, PopupComponent as s, DescriptionNode as t, Box as u, BindField as v, TextApi as w, CountdownValue as x, BindOptions as y, IntlKit as z };
3459
+ export { Style as $, TextFormats as A, Argument as B, Point as C, TextFormat as D, TextBind as E, defineComponent as F, Part as G, I18nApi as H, Config$1 as I, TextKey as J, State$2 as K, InputApi as L, TextStyles as M, TextValue as N, TextFormatAnswer as O, types_d_exports as P, ResolvedStyle as Q, State$1 as R, FormattedNumber as S, TextApi as T, IntlKit as U, Config$2 as V, Message as W, types_d_exports$2 as X, TypedTr as Y, IsFlags as Z, UiIntrinsicElements as _, JsxChild as a, Config as b, UiNode as c, DebugTrigger as d, StylesState as et, LocalWrite as f, IntrinsicElementsFor as g, defineTokens as h, Finding as i, TextStyleInput as j, TextFormatFunction as k, LayoutState as l, popup as m, ElementChange as n, JsxState as o, ScrollState as p, StringTable as q, ElementMotion as r, PopupComponent as s, DescriptionNode as t, WhenFlags as tt, Box as u, BindField as v, State as w, CountdownValue as x, BindOptions as y, types_d_exports$1 as z };
@@ -1,7 +1,7 @@
1
- import { Ar as ClockSource, Dn as FeaturePlugin, Gr as SaveDoc, Ir as Config, Jr as SnapshotOf, Mr as FakeClock, Q as Config$2, Rn as TypeTag, Rr as Json, Ur as PlayerStateProvider, Wr as ProviderCall, a as Config$3, d as Manifest, fn as Config$1, kn as AnyFlow, n as AssetsIo, nt as PixiModule, pt as Orientation } from "./types-CbVXXqPs.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-C5gLBKbm.mjs";
3
- import { R as I18nApi, U as StringTable, W as TextKey } from "./types-OBpR0u05.mjs";
4
- import { St as effectsPlugin, Tt as audioPlugin, ht as PlatformProvider, i as screen, pt as platformPlugin, t as createApp } from "./index-Bn0pFiae.mjs";
1
+ import { An as AnyFlow, Gr as ProviderCall, Kr as SaveDoc, Lr as Config, Nr as FakeClock, On as FeaturePlugin, Q as Config$2, Wr as PlayerStateProvider, Yr as SnapshotOf, a as Config$3, d as Manifest, fn as Config$1, jr as ClockSource, n as AssetsIo, nt as PixiModule, pt as Orientation, zn as TypeTag, zr as Json } from "./types-w5_A5TPL.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-CJYudpme.mjs";
3
+ import { H as I18nApi, J as TextKey, q as StringTable } from "./types-BbLjYfGR.mjs";
4
+ import { St as effectsPlugin, Tt as audioPlugin, ht as PlatformProvider, i as screen, pt as platformPlugin, t as createApp } from "./index-nK7iVsWx.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
- import { $n as NumericFields, A as FilterSlotQuad, Fr as Api$6, Kn as AnchorTarget, Lr as Events$3, O as FilterSlot, Qn as MotionHandle, Rn as TypeTag, Rr as Json, Yn as Ease, Z as Api$4, ar as TrackSegment, at as PixiUniformGroup, b as Events$4, ei as Events$5, et as PixiFilter, fr as ComponentType, gt as FilterCache, ii as Api$1, ir as TrackOptions, it as PixiTexture, j as SyncApi, k as FilterSlotInputs, lr as AnyComponentValue, mi as Require, mr as Entity, mt as Point, nr as ReducedMotion, nt as PixiModule, pi as Events$2, rt as PixiSprite, s as Events$1, sr as AnyComponent, t as Api$5, tt as PixiGpuProgram, un as Api$2, ur as ComponentHandle, wr as Api$3, zn as Descriptor } from "./types-CbVXXqPs.mjs";
2
- import { N as InputApi, R as I18nApi, X as StylesState, c as UiNode, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion, w as TextApi } from "./types-OBpR0u05.mjs";
1
+ import { $n as MotionHandle, A as FilterSlotQuad, Bn as Descriptor, Ir as Api$6, O as FilterSlot, Rr as Events$3, Tr as Api$3, Xn as Ease, Z as Api$4, ai as Api$1, ar as TrackOptions, at as PixiUniformGroup, b as Events$4, cr as AnyComponent, dr as ComponentHandle, er as NumericFields, et as PixiFilter, gt as FilterCache, hi as Require, hr as Entity, it as PixiTexture, j as SyncApi, k as FilterSlotInputs, mi as Events$2, mt as Point, nt as PixiModule, or as TrackSegment, pr as ComponentType, qn as AnchorTarget, rr as ReducedMotion, rt as PixiSprite, s as Events$1, t as Api$5, ti as Events$5, tt as PixiGpuProgram, un as Api$2, ur as AnyComponentValue, zn as TypeTag, zr as Json } from "./types-w5_A5TPL.mjs";
2
+ import { H as I18nApi, L as InputApi, T as TextApi, c as UiNode, et as StylesState, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion } from "./types-BbLjYfGR.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5
 
@@ -1,5 +1,5 @@
1
- import { Rr as Json, qr as Snapshot } from "./types-CbVXXqPs.mjs";
2
- import { t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
1
+ import { Jr as Snapshot, zr as Json } from "./types-w5_A5TPL.mjs";
2
+ import { t as HeadlessApp } from "./headless-CtRq6Uij.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
 
5
5
  //#region src/plugins/flow/doors/types.d.ts
@@ -6678,6 +6678,22 @@ type FeatureTextStyles = {
6678
6678
  readonly kind: "textStyles";
6679
6679
  readonly map: Record<string, object>;
6680
6680
  };
6681
+ /**
6682
+ * The number formats of a feature, as `defineTextFormats` returns them. Structural on purpose:
6683
+ * `text` reads and checks each format, `flow` only carries the map.
6684
+ *
6685
+ * @example
6686
+ * ```ts
6687
+ * const formats: FeatureTextFormats = {
6688
+ * kind: "textFormats",
6689
+ * map: { "pill.number": (value: number) => ({ content: String(value), style: "digits.17" }) }
6690
+ * };
6691
+ * ```
6692
+ */
6693
+ type FeatureTextFormats = {
6694
+ readonly kind: "textFormats";
6695
+ readonly map: Readonly<Record<string, object>>;
6696
+ };
6681
6697
  /**
6682
6698
  * What a feature brings to the game. The logic keys are typed here; the keys of later milestones
6683
6699
  * pass through the index signature until their plugin types them. `flow` stores them untouched,
@@ -6718,7 +6734,8 @@ type FeatureDescription = {
6718
6734
  animations?: readonly FeatureAnimation[]; /** Interface components the feature owns, read by `ui`. `components` stays the ECS key. */
6719
6735
  ui?: readonly FeatureComponent[]; /** Compiled messages per locale, ready or lazy, read by `i18n`. */
6720
6736
  strings?: Record<string, CompiledMessagesLike | (() => Promise<unknown>)>; /** Text styles the feature owns, read by `text`. */
6721
- textStyles?: FeatureTextStyles; /** Particle emitters the feature owns, read by `effects`. */
6737
+ textStyles?: FeatureTextStyles; /** Number formats the feature owns, named by a `bind` and read by `text`. */
6738
+ textFormats?: FeatureTextFormats; /** Particle emitters the feature owns, read by `effects`. */
6722
6739
  emitters?: readonly FeatureEmitter[]; /** Filters the feature puts on its interface components, read by `effects`. */
6723
6740
  filters?: readonly FeatureFilter[];
6724
6741
  /**
@@ -6979,7 +6996,7 @@ declare function contribution<S extends SlotNode<OutcomeTags, string>, F extends
6979
6996
  when?: (snapshot: Snapshot) => boolean;
6980
6997
  }): Readonly<Record<S["name"], ContributionSpec>>;
6981
6998
  declare namespace types_d_exports$3 {
6982
- 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, 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, TextStylesOf, TypeTag, WorldEvent };
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 };
6983
7000
  }
6984
7001
  /**
6985
7002
  * flow plugin events.
@@ -7147,7 +7164,8 @@ type GameTypes = {
7147
7164
  bundles?: string;
7148
7165
  scenes?: string;
7149
7166
  strings: StringTableLike;
7150
- textStyles?: string;
7167
+ textStyles?: string; /** The names of the game's number formats: what `format` of the `bind` of `defineGame` takes next to the four built-in ones. */
7168
+ textFormats?: string;
7151
7169
  emitters?: string; /** The keys of the game's HUD parts: what `HudPart({ key })` and the `hud` list of `Overlay` take. */
7152
7170
  hud?: string;
7153
7171
  };
@@ -7174,6 +7192,19 @@ type HudKeysOf<Types extends GameTypes> = Types extends {
7174
7192
  type TextStylesOf<Types extends GameTypes> = Types extends {
7175
7193
  textStyles: infer Keys extends string;
7176
7194
  } ? Keys : string;
7195
+ /**
7196
+ * The number format name union of a game, `never` when the game passed none: then its `bind` takes
7197
+ * the four built-in formats only, and a name that was never declared does not compile.
7198
+ *
7199
+ * @example
7200
+ * ```ts
7201
+ * type Keys = TextFormatsOf<{ player: {}; session: {}; assets: string; strings: {}; textFormats: "pill.number" }>; // "pill.number"
7202
+ * type None = TextFormatsOf<{ player: {}; session: {}; assets: string; strings: {} }>; // never
7203
+ * ```
7204
+ */
7205
+ type TextFormatsOf<Types extends GameTypes> = Types extends {
7206
+ textFormats: infer Keys extends string;
7207
+ } ? Keys : never;
7177
7208
  /**
7178
7209
  * The emitter id union of a game, `string` when the game passed none. `defineGame` types
7179
7210
  * `Emitter({ effect })` with it.
@@ -14364,4 +14395,4 @@ type BundleCompanion = {
14364
14395
  unload(bundle: string): void;
14365
14396
  };
14366
14397
  //#endregion
14367
- export { MonitorConfig as $, NumericFields as $n, Config$7 as $r, PerfThermalLine as $t, FilterSlotQuad as A, Bookmark as An, ClockSource as Ar, PERF_GAP_BUCKETS as At, Parent as B, Effect as Bn, State$6 as Br, PerfDisplay as Bt, SceneSpec as C, slot as Cn, TagType as Cr, FrameRing as Ct, DebugSwitches as D, FeaturePlugin as Dn, State$4 as Dr, OverlayEventDetail as Dt, types_d_exports$1 as E, FeatureDescription as En, Explained as Er, MonitorSections as Et, HudPartValue as F, NodeTable as Fn, Api$5 as Fr, PerfCause as Ft, SpriteOptions as G, Answer as Gn, SaveDoc as Gr, PerfLogLine as Gt, ShapeValue as H, GuideOptions as Hn, Patch as Hr, PerfEventName as Ht, NineSlice$1 as I, RouteStep as In, Config$6 as Ir, PerfChange as It, TransformValue as J, DescriptionNode as Jn, SnapshotOf as Jr, PerfMeasured as Jt, SpriteValue as K, AnchorTarget as Kn, SaveUnreadableError as Kr, PerfLongFrameLine as Kt, NineSliceValue as L, SceneIdOf as Ln, Events$5 as Lr, PerfChangeEntry as Lt, WhyEntry as M, FlowGraph as Mn, FakeClock as Mr, PROBLEM_RULES as Mt, Display as N, FlowState as Nn, State$5 as Nr, PassKind as Nt, FilterSlot as O, FeatureTree as On, types_d_exports$4 as Or, OverlayWhat as Ot, HudPart as P, JournalEntry as Pn, types_d_exports$5 as Pr, PassRecord as Pt, Config$2 as Q, MotionHandle as Qn, Api$6 as Qr, PerfTelemetryLine as Qt, Overlay as R, TypeTag as Rn, Json as Rr, PerfCollectorLine as Rt, SceneDefinition as S, exit as Sn, SystemFor as Sr, FrameRecord as St, State$1 as T, type as Tn, Config$4 as Tr, MONITOR_SECTIONS as Tt, Sprite as U, Hint as Un, PlayerStateProvider as Ur, PerfGapLine as Ut, Shape as V, EffectOptions as Vn, types_d_exports$6 as Vr, PerfEventLine as Vt, SpriteBlend as W, NodeFx as Wn, ProviderCall as Wr, PerfHeaderLine as Wt, AdaptiveScale as X, Motion as Xn, RngApi as Xr, PerfSpikeLine as Xt, sprite as Y, Ease as Yn, StoreApi as Yr, PerfSampleLine as Yt, Api$1 as Z, MotionCause as Zn, RngState as Zr, PerfStartupLine as Zt, AnySceneProjection as _, State$3 as _n, Mut as _r, RetakeWhy as _t, Config as a, Config$8 as ai, ShaderWhat as an, TrackSegment as ar, PixiUniformGroup as at, Events$1 as b, contribution as bn, ResourceType as br, FrameReadResult as bt, LoadBundles as c, State$8 as ci, CanvasRestart as cn, AnyComponentType as cr, Under as ct, Manifest as d, types_d_exports$8 as di, BundlesOf as dn, ComponentSchema as dr, MonitorCounts as dt, Events$6 as ei, PoolTrimDetail as en, ProjectionMotion as er, PixiFilter as et, ReadyBundles as f, Config$9 as fi, Config$3 as fn, ComponentType as fr, RenderStats as ft, types_d_exports as g, Position as gn, FrameDiff as gr, FilterCache as gt, Usage as h, HudKeysOf as hn, EntitySnapshot as hr, ViewportSize as ht, BundleSpec as i, Api$7 as ii, ShaderEventDetail as in, TrackOptions as ir, PixiTexture as it, SyncApi as j, DefineNode as jn, Config$5 as jr, PERF_LOG_VERSION as jt, FilterSlotInputs as k, AnyFlow as kn, Api$4 as kr, PERF_CAUSES as kt, LoadReason as l, ThermalReading as li, DEMAND_REASONS as ln, AnyComponentValue as lr, types_d_exports$2 as lt, Tier as m, Require as mi, GameTypes as mn, Entity as mr, Point as mt, AssetsIo as n, State$7 as ni, ProblemRule as nn, ReducedMotion as nr, PixiModule as nt, DefineBundles as o, FrameRate as oi, WarmDetail as on, ViewHandle as or, PoolTrim as ot, State as p, Events$8 as pi, EmitterIdOf as pn, ComponentValue as pr, Orientation as pt, Transform as q, ChangeHook as qn, Snapshot as qr, PerfMarkLine as qt, BundleMap as r, types_d_exports$7 as ri, SHADER_WHATS as rn, SceneSwitch as rr, PixiSprite as rt, Events as s, RateChange as si, CANVAS_RESTARTS as sn, AnyComponent as sr, State$2 as st, Api as t, PauseReason as ti, ProblemEventDetail as tn, ProjectionSpec as tr, PixiGpuProgram as tt, LoadResult as u, Time as ui, Api$2 as un, ComponentHandle as ur, Captured as ut, Config$1 as v, TextStylesOf as vn, Narrowed as vr, WhyLive as vt, ScenesApi as w, to as wn, Api$3 as wr, LongFrameEntry as wt, LayerMap as x, defineFlow as xn, SystemDefinition as xr, FrameReadout as xt, DefineScene as y, types_d_exports$3 as yn, QueryTerm as yr, FrameColumns as yt, OverlayValue as z, Descriptor as zn, Root as zr, PerfCounts as zt };
14398
+ export { MonitorConfig as $, MotionHandle as $n, Api$6 as $r, PerfThermalLine as $t, FilterSlotQuad as A, AnyFlow as An, Api$4 as Ar, PERF_GAP_BUCKETS as At, Parent as B, Descriptor as Bn, Root as Br, PerfDisplay as Bt, SceneSpec as C, exit as Cn, SystemFor as Cr, FrameRing as Ct, DebugSwitches as D, FeatureDescription as Dn, Explained as Dr, OverlayEventDetail as Dt, types_d_exports$1 as E, type as En, Config$4 as Er, MonitorSections as Et, HudPartValue as F, JournalEntry as Fn, types_d_exports$5 as Fr, PerfCause as Ft, SpriteOptions as G, NodeFx as Gn, ProviderCall as Gr, PerfLogLine as Gt, ShapeValue as H, EffectOptions as Hn, types_d_exports$6 as Hr, PerfEventName as Ht, NineSlice$1 as I, NodeTable as In, Api$5 as Ir, PerfChange as It, TransformValue as J, ChangeHook as Jn, Snapshot as Jr, PerfMeasured as Jt, SpriteValue as K, Answer as Kn, SaveDoc as Kr, PerfLongFrameLine as Kt, NineSliceValue as L, RouteStep as Ln, Config$6 as Lr, PerfChangeEntry as Lt, WhyEntry as M, DefineNode as Mn, Config$5 as Mr, PROBLEM_RULES as Mt, Display as N, FlowGraph as Nn, FakeClock as Nr, PassKind as Nt, FilterSlot as O, FeaturePlugin as On, State$4 as Or, OverlayWhat as Ot, HudPart as P, FlowState as Pn, State$5 as Pr, PassRecord as Pt, Config$2 as Q, MotionCause as Qn, RngState as Qr, PerfTelemetryLine as Qt, Overlay as R, SceneIdOf as Rn, Events$5 as Rr, PerfCollectorLine as Rt, SceneDefinition as S, defineFlow as Sn, SystemDefinition as Sr, FrameRecord as St, State$1 as T, to as Tn, Api$3 as Tr, MONITOR_SECTIONS as Tt, Sprite as U, GuideOptions as Un, Patch as Ur, PerfGapLine as Ut, Shape as V, Effect as Vn, State$6 as Vr, PerfEventLine as Vt, SpriteBlend as W, Hint as Wn, PlayerStateProvider as Wr, PerfHeaderLine as Wt, AdaptiveScale as X, Ease as Xn, StoreApi as Xr, PerfSpikeLine as Xt, sprite as Y, DescriptionNode as Yn, SnapshotOf as Yr, PerfSampleLine as Yt, Api$1 as Z, Motion as Zn, RngApi as Zr, PerfStartupLine as Zt, AnySceneProjection as _, State$3 as _n, FrameDiff as _r, RetakeWhy as _t, Config as a, Api$7 as ai, ShaderWhat as an, TrackOptions as ar, PixiUniformGroup as at, Events$1 as b, types_d_exports$3 as bn, QueryTerm as br, FrameReadResult as bt, LoadBundles as c, RateChange as ci, CanvasRestart as cn, AnyComponent as cr, Under as ct, Manifest as d, Time as di, BundlesOf as dn, ComponentHandle as dr, MonitorCounts as dt, Config$7 as ei, PoolTrimDetail as en, NumericFields as er, PixiFilter as et, ReadyBundles as f, types_d_exports$8 as fi, Config$3 as fn, ComponentSchema as fr, RenderStats as ft, types_d_exports as g, Position as gn, EntitySnapshot as gr, FilterCache as gt, Usage as h, Require as hi, HudKeysOf as hn, Entity as hr, ViewportSize as ht, BundleSpec as i, types_d_exports$7 as ii, ShaderEventDetail as in, SceneSwitch as ir, PixiTexture as it, SyncApi as j, Bookmark as jn, ClockSource as jr, PERF_LOG_VERSION as jt, FilterSlotInputs as k, FeatureTree as kn, types_d_exports$4 as kr, PERF_CAUSES as kt, LoadReason as l, State$8 as li, DEMAND_REASONS as ln, AnyComponentType as lr, types_d_exports$2 as lt, Tier as m, Events$8 as mi, GameTypes as mn, ComponentValue as mr, Point as mt, AssetsIo as n, PauseReason as ni, ProblemRule as nn, ProjectionSpec as nr, PixiModule as nt, DefineBundles as o, Config$8 as oi, WarmDetail as on, TrackSegment as or, PoolTrim as ot, State as p, Config$9 as pi, EmitterIdOf as pn, ComponentType as pr, Orientation as pt, Transform as q, AnchorTarget as qn, SaveUnreadableError as qr, PerfMarkLine as qt, BundleMap as r, State$7 as ri, SHADER_WHATS as rn, ReducedMotion as rr, PixiSprite as rt, Events as s, FrameRate as si, CANVAS_RESTARTS as sn, ViewHandle as sr, State$2 as st, Api as t, Events$6 as ti, ProblemEventDetail as tn, ProjectionMotion as tr, PixiGpuProgram as tt, LoadResult as u, ThermalReading as ui, Api$2 as un, AnyComponentValue as ur, Captured as ut, Config$1 as v, TextFormatsOf as vn, Mut as vr, WhyLive as vt, ScenesApi as w, slot as wn, TagType as wr, LongFrameEntry as wt, LayerMap as x, contribution as xn, ResourceType as xr, FrameReadout as xt, DefineScene as y, TextStylesOf as yn, Narrowed as yr, FrameColumns as yt, OverlayValue as z, TypeTag as zn, Json as zr, PerfCounts as zt };
@@ -642,8 +642,9 @@ const countdownDefaults = {
642
642
  /**
643
643
  * Shows a numeric component field of the label's own entity: read every frame, written to
644
644
  * `Text.resolved` only when the shown string changes. The field must hold a number; the format
645
- * is `"int"` (rounded) unless named. Reads the component's own name, so a renamed component
646
- * cannot drift from its label.
645
+ * is `"int"` (rounded) unless named. This root `bind` takes the four built-in formats; the `bind`
646
+ * of `defineGame` is this function and takes the names of the game's `defineTextFormats` too. Reads
647
+ * the component's own name, so a renamed component cannot drift from its label.
647
648
  *
648
649
  * @param component - The component whose field the label shows.
649
650
  * @param field - A numeric field of that component.
@@ -813,6 +814,29 @@ function defineTextStyles(map) {
813
814
  };
814
815
  }
815
816
  /**
817
+ * Declares the number formats of a feature. The result goes under the `textFormats` key of the
818
+ * feature description, and `text` reads it in `onStart`; a label names a format in its `bind`. A
819
+ * format takes the whole value and answers what the label shows and its style.
820
+ *
821
+ * @param map - Format name to its function. The four built-in names are refused at start.
822
+ * @returns The registration a feature carries.
823
+ * @example
824
+ * ```ts
825
+ * const formats = defineTextFormats({
826
+ * "pill.number": value => ({ content: String(value), style: "digits.17" })
827
+ * });
828
+ *
829
+ * formats.kind; // "textFormats"
830
+ * formats.map["pill.number"]?.(950); // { content: "950", style: "digits.17" }
831
+ * ```
832
+ */
833
+ function defineTextFormats(map) {
834
+ return {
835
+ kind: "textFormats",
836
+ map
837
+ };
838
+ }
839
+ /**
816
840
  * Tells whether a value is a plain record, so its fields can be read one by one.
817
841
  *
818
842
  * @param value - What a feature put in its description.
@@ -933,10 +957,10 @@ function builtInStyles(fonts) {
933
957
  };
934
958
  }
935
959
  /**
936
- * Binds `label` and `defineTextStyles` to one game's style names and font keys. Type-only: the
937
- * same two functions.
960
+ * Binds `label`, `bind`, `defineTextStyles` and `defineTextFormats` to one game's style names, font
961
+ * keys and format names. Type-only: the same four functions.
938
962
  *
939
- * @returns The two helpers, with the style and font arguments narrowed.
963
+ * @returns The four helpers, with the style, font and format arguments narrowed.
940
964
  * @example
941
965
  * ```ts
942
966
  * const { label } = textFor<"body", "ui.font-body">();
@@ -946,10 +970,112 @@ function builtInStyles(fonts) {
946
970
  function textFor() {
947
971
  return {
948
972
  label,
949
- defineTextStyles
973
+ bind,
974
+ defineTextStyles,
975
+ defineTextFormats
950
976
  };
951
977
  }
952
978
  //#endregion
979
+ //#region src/plugins/text/format.ts
980
+ /** Milliseconds in one second. */
981
+ const SECOND_MS = 1e3;
982
+ /** Seconds in one minute. */
983
+ const SECONDS_PER_MINUTE = 60;
984
+ /** Seconds in one hour. */
985
+ const SECONDS_PER_HOUR = 3600;
986
+ /**
987
+ * Tells whether a string is one of the four built-in formats. Any other string a bind carries is a
988
+ * name a feature registered, or a bind that slipped past the type.
989
+ *
990
+ * @param format - What a bind carries.
991
+ * @returns True for `"int"`, `"mm:ss"`, `"h:mm:ss"` and `"duration"`.
992
+ * @example
993
+ * ```ts
994
+ * isTextFormat("ss"); // false
995
+ * ```
996
+ */
997
+ function isTextFormat(format) {
998
+ return format === "int" || format === "mm:ss" || format === "h:mm:ss" || format === "duration";
999
+ }
1000
+ /**
1001
+ * Pads a number to two digits. A longer number stays as it is.
1002
+ *
1003
+ * @param value - A whole number, 0 or more.
1004
+ * @returns The number with a leading zero below 10.
1005
+ * @example
1006
+ * ```ts
1007
+ * pad2(5); // "05"
1008
+ * ```
1009
+ */
1010
+ function pad2(value) {
1011
+ return String(value).padStart(2, "0");
1012
+ }
1013
+ /**
1014
+ * Whole seconds of a time in milliseconds, rounded up, never below zero. A value that is not
1015
+ * finite counts as zero.
1016
+ *
1017
+ * @param ms - The time in milliseconds.
1018
+ * @returns The whole seconds a timer shows.
1019
+ * @example
1020
+ * ```ts
1021
+ * wholeSeconds(94_001); // 95
1022
+ * ```
1023
+ */
1024
+ function wholeSeconds(ms) {
1025
+ return Number.isFinite(ms) ? Math.max(0, Math.ceil(ms / SECOND_MS)) : 0;
1026
+ }
1027
+ /**
1028
+ * What the shown string of a bound value is built from: the rounded value for `"int"`, whole
1029
+ * seconds for a time format. Two values with the same unit show the same string.
1030
+ *
1031
+ * @param value - The bound number.
1032
+ * @param format - How it is shown.
1033
+ * @returns The unit of the shown string.
1034
+ * @example
1035
+ * ```ts
1036
+ * unitOf(94_500, "mm:ss"); // 95
1037
+ * ```
1038
+ */
1039
+ function unitOf(value, format) {
1040
+ if (format !== "int") return wholeSeconds(value);
1041
+ return Number.isFinite(value) ? Math.round(value) : 0;
1042
+ }
1043
+ /**
1044
+ * The whole number a format a game registered takes: rounded as `"int"` rounds, 0 for a value that
1045
+ * is not finite, and never `-0`, which a format could tell from 0.
1046
+ *
1047
+ * @param value - The bound number.
1048
+ * @returns The whole value.
1049
+ * @example
1050
+ * ```ts
1051
+ * wholeValue(999.6); // 1000
1052
+ * ```
1053
+ */
1054
+ function wholeValue(value) {
1055
+ return Number.isFinite(value) ? Math.round(value) || 0 : 0;
1056
+ }
1057
+ /**
1058
+ * Shows a bound number in one of the four formats. A value that is not finite shows as zero.
1059
+ *
1060
+ * @param value - The number; milliseconds for the time formats.
1061
+ * @param format - How it is shown.
1062
+ * @param duration - Formats milliseconds as words in the current locale.
1063
+ * @returns The string a label shows.
1064
+ * @example
1065
+ * ```ts
1066
+ * formatBound(95_000, "mm:ss", () => ""); // "01:35"
1067
+ * ```
1068
+ */
1069
+ function formatBound(value, format, duration) {
1070
+ const unit = unitOf(value, format);
1071
+ switch (format) {
1072
+ case "int": return String(unit);
1073
+ case "mm:ss": return `${pad2(Math.floor(unit / SECONDS_PER_MINUTE))}:${pad2(unit % SECONDS_PER_MINUTE)}`;
1074
+ case "h:mm:ss": return `${Math.floor(unit / SECONDS_PER_HOUR)}:${pad2(Math.floor(unit / SECONDS_PER_MINUTE) % SECONDS_PER_MINUTE)}:${pad2(unit % SECONDS_PER_MINUTE)}`;
1075
+ case "duration": return duration(unit * SECOND_MS);
1076
+ }
1077
+ }
1078
+ //#endregion
953
1079
  //#region src/plugins/ui/styles/define.ts
954
1080
  /**
955
1081
  * Declares one style. The work is the type: a field outside the vocabulary, or a value outside
@@ -1224,6 +1350,28 @@ function contentOf(props) {
1224
1350
  return props.content ?? "";
1225
1351
  }
1226
1352
  /**
1353
+ * The bind of a text, when the markup gave it one.
1354
+ *
1355
+ * @param element - The element to ask about.
1356
+ * @returns What `bind()` built, or `undefined` for any other element.
1357
+ */
1358
+ function bindOf(element) {
1359
+ const { bind } = element.node.props;
1360
+ return element.type === "text" && typeof bind === "object" && bind !== null ? bind : void 0;
1361
+ }
1362
+ /**
1363
+ * Tells whether an element is a text whose bind names a format of the game, not one of the four
1364
+ * built-in ones: such a format answers the style of the label too, so `Text.style` is what the
1365
+ * label shows and its `style` prop is only where it starts.
1366
+ *
1367
+ * @param element - The element to ask about.
1368
+ * @returns True for a text whose bind names a format.
1369
+ */
1370
+ function namesFormat(element) {
1371
+ const bind = bindOf(element);
1372
+ return bind !== void 0 && !isTextFormat(bind.format);
1373
+ }
1374
+ /**
1227
1375
  * Whether a nine-slice draws its rim alone: `true` while its style says so, `false` once it did and
1228
1376
  * no longer does, and no field on a panel that was never hollow, so a game's describe and saved
1229
1377
  * values stay as they were without it.
@@ -1367,9 +1515,11 @@ function leftSizes(width, height) {
1367
1515
  }
1368
1516
  /**
1369
1517
  * The fields of a value ui does not write onto a live element, or record as its rest: those its component type gives
1370
- * to a plugin and, for the `Sprite` of an image or an icon, the size on an axis its style does not state and the layout
1371
- * left at 0. A game's own system sizes such a sprite; written again by ui (a new viewport, a covered root, a restore)
1372
- * it went back to 0 by 0, drawn at its texture's size (F111). On a first add the size is 0 anyway, the texture's.
1518
+ * to a plugin; for the `Sprite` of an image or an icon, the size on an axis its style does not state and the layout
1519
+ * left at 0; and for the `Text` of a label whose bind names a format, the style its format answered (F135). A game's own
1520
+ * system sizes such a sprite; written again by ui (a new viewport, a covered root, a restore) it went back to 0 by 0,
1521
+ * drawn at its texture's size (F111). On a first add the size is 0 anyway, the texture's. `element.node` is the node of
1522
+ * this render, so a bind that went back to a built-in format or left has its prop written as usual.
1373
1523
  *
1374
1524
  * @param element - The element.
1375
1525
  * @param type - The component type of the value.
@@ -1377,6 +1527,7 @@ function leftSizes(width, height) {
1377
1527
  * @returns The fields left alone.
1378
1528
  */
1379
1529
  function fieldsLeftAlone(element, type, owned) {
1530
+ if (type === Text) return namesFormat(element) ? [...owned, "style"] : owned;
1380
1531
  const { style, rect } = element;
1381
1532
  if (!(element.type === "image" || element.type === "icon") || type !== Sprite) return owned;
1382
1533
  const sizes = leftSizes(rect.w <= 0 && !statesWidth(style), rect.h <= 0 && !statesHeight(style));
@@ -1575,4 +1726,4 @@ function drawnRect(pose, local) {
1575
1726
  };
1576
1727
  }
1577
1728
  //#endregion
1578
- export { Layer as $, readStyle as A, Display as B, defineStyle as C, builtInStyles as D, bind as E, parentOf as F, Parent as G, NineSlice as H, poseUnder as I, Transform as J, Shape as K, rootPointOf as L, applyPose as M, isLeaving as N, defineTextStyles as O, localPoseOf as P, Exiting as Q, rootPoseInto as R, defineTokens as S, Text as T, Overlay as U, HudPart as V, OverlayLevel as W, componentsFor as X, arcDefaults as Y, sprite as Z, ScrollState as _, fitScaleOf as a, resource as at, popup as b, samePose as c, tag as ct, Box as d, Now as et, Covered as f, Scroll as g, LocalWrite as h, fieldsLeftAlone as i, mut as it, textFor as j, label as k, visualOf as l, Escapable as m, CONTENT as n, Tree as nt, livePatch as o, system as ot, DebugTrigger as p, Sprite as q, drawnRect as r, component as rt, restValueOf as s, systemsFor as st, ANCHOR as t, Order as tt, visualRectOf as u, UI_OWNER as v, Countdown as w, uiFor as x, UiCounters as y, rootPoseOf as z };
1729
+ export { Shape as $, Countdown as A, isLeaving as B, uiFor as C, isTextFormat as D, formatBound as E, defineTextStyles as F, rootPoseInto as G, parentOf as H, label as I, HudPart as J, rootPoseOf as K, readStyle as L, bind as M, builtInStyles as N, unitOf as O, defineTextFormats as P, Parent as Q, textFor as R, popup as S, defineStyle as T, poseUnder as U, localPoseOf as V, rootPointOf as W, Overlay as X, NineSlice as Y, OverlayLevel as Z, LocalWrite as _, fieldsLeftAlone as a, Exiting as at, UI_OWNER as b, namesFormat as c, Order as ct, visualOf as d, mut as dt, Sprite as et, visualRectOf as f, resource as ft, Escapable as g, DebugTrigger as h, tag as ht, drawnRect as i, sprite as it, Text as j, wholeValue as k, restValueOf as l, Tree as lt, Covered as m, systemsFor as mt, CONTENT as n, arcDefaults as nt, fitScaleOf as o, Layer as ot, Box as p, system as pt, Display as q, bindOf as r, componentsFor as rt, livePatch as s, Now as st, ANCHOR as t, Transform as tt, samePose as u, component as ut, Scroll as v, defineTokens as w, UiCounters as x, ScrollState as y, applyPose as z };
@@ -1,9 +1,9 @@
1
- import { Fr as Api$2, Qr as Api$3, Z as Api, kr as Api$4, wr as Api$1 } from "./types-CbVXXqPs.mjs";
2
- import { P as AnimApi, r as UiApi } from "./types-C5gLBKbm.mjs";
3
- import { N as InputApi } from "./types-OBpR0u05.mjs";
4
- import { r as Repro } from "./headless-DtDdn5gg.mjs";
5
- import { i as ControlApp, o as InputOf } from "./types-BpipkaVe.mjs";
6
- import { t as commands } from "./commands-DxUF13zr.mjs";
1
+ import { $r as Api$3, Ar as Api$4, Ir as Api$2, Tr as Api$1, Z as Api } from "./types-w5_A5TPL.mjs";
2
+ import { P as AnimApi, r as UiApi } from "./types-CJYudpme.mjs";
3
+ import { L as InputApi } from "./types-BbLjYfGR.mjs";
4
+ import { r as Repro } from "./headless-CtRq6Uij.mjs";
5
+ import { i as ControlApp, o as InputOf } from "./types-ehmvA6yu.mjs";
6
+ import { t as commands } from "./commands-C6RMqrY8.mjs";
7
7
 
8
8
  //#region src/visual/types.d.ts
9
9
  /** The base commands of the `/control` door, keyed by their short names. */
package/dist/visual.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-CMnWgCkh.mjs";
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-DvhjRhgP.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-CyltHb9o.mjs";
2
+ import { n as read, t as sources } from "./sources-kL64Svgl.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";