@moku-labs/game 0.15.164 → 0.15.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/page.d.mts +1 -1
- package/dist/app/system.d.mts +2 -2
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +1 -1
- package/dist/{commands-D5MG6t52.d.mts → commands-CxBsMGeq.d.mts} +2 -2
- package/dist/control.d.mts +1 -1
- package/dist/{index-HsOHfkao.d.mts → index-ytikCrJO.d.mts} +15 -7
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/inspect.d.mts +2 -2
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-JG7kE0RP.d.mts → runtime-DUjK2y1r.d.mts} +1 -1
- package/dist/{src-CUi3Ytta.mjs → src-BaG4Sw8I.mjs} +416 -217
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +1 -1
- package/dist/{types-Cs3a-2Km.d.mts → types-C7D1V3iQ.d.mts} +21 -8
- package/dist/{types-CZguGD6b.d.mts → types-CVyUyLXa.d.mts} +3 -3
- package/dist/{types-VZL87Yhu.d.mts → types-SFW8MKyb.d.mts} +69 -15
- package/dist/{visual-BrvFv5pU.d.mts → visual-BMKoT_48.d.mts} +2 -2
- package/dist/visual.d.mts +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bn as NodeTable, Ir as ClockSource, Jn as Hint, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Wn as Descriptor, Wr as Json, Yn as NodeFx } from "./types-B93wB7Sh.mjs";
|
|
2
|
-
import { t as createApp } from "./index-
|
|
3
|
-
import { b as memory, x as saveOf, y as WithGameState } from "./types-
|
|
2
|
+
import { t as createApp } from "./index-ytikCrJO.mjs";
|
|
3
|
+
import { b as memory, x as saveOf, y as WithGameState } from "./types-CVyUyLXa.mjs";
|
|
4
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-8XrFW9w1.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
package/dist/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gn as refuseStart, k as flattenFeatures, t as createApp, vn as exit, xn as type } from "./src-
|
|
1
|
+
import { gn as refuseStart, k as flattenFeatures, t as createApp, vn as exit, xn as type } from "./src-BaG4Sw8I.mjs";
|
|
2
2
|
import { n as saveOf, t as memory } from "./memory-DeD9wis6.mjs";
|
|
3
3
|
import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
|
|
4
4
|
import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-yi2XmYWC.mjs";
|
|
@@ -414,23 +414,34 @@ declare function spawned(id: string): {
|
|
|
414
414
|
* A sound. `anim` owns the descriptor because it sits below `audio`; `audio` owns the handler,
|
|
415
415
|
* and a game without `audio` plays nothing and hears no error. A sound with an `id` is named:
|
|
416
416
|
* one sound plays per id, a new one with the same id fades the old one out over `fadeMs`, and
|
|
417
|
-
* `stopSfx(id)` stops it.
|
|
418
|
-
*
|
|
417
|
+
* `stopSfx(id)` stops it. With `loop: true` the sound loops until `stopSfx(id)` or until its scene
|
|
418
|
+
* leaves, so a loop needs an `id`: a loop without one does not compile. The payload carries `id`,
|
|
419
|
+
* `fadeMs` and `loop` only when they are given, so a sound without them stays `{ key, bus }`.
|
|
419
420
|
*
|
|
420
421
|
* @param key - Asset key of the sound.
|
|
421
|
-
* @param options - The bus, the name and the
|
|
422
|
+
* @param options - The bus, the name, the fade and the loop.
|
|
422
423
|
* @param options.bus - `"sfx"` when omitted.
|
|
423
424
|
* @param options.id - Name of the sound; one sound per id plays.
|
|
424
|
-
* @param options.fadeMs - Fade of the sound with the same id this one replaces
|
|
425
|
-
* `sfxFadeMs` when omitted.
|
|
425
|
+
* @param options.fadeMs - Fade of the sound with the same id this one replaces, and the fade-in
|
|
426
|
+
* of a loop; `audio`'s `sfxFadeMs` when omitted.
|
|
427
|
+
* @param options.loop - `true` to loop the sound until `stopSfx(id)` or until its scene leaves;
|
|
428
|
+
* needs an `id`.
|
|
426
429
|
* @returns The descriptor, usable as a timeline step and as `fx(...)` in a node.
|
|
427
430
|
* @example
|
|
428
431
|
* ```ts
|
|
429
432
|
* sfx("board.merge"); // { kind: "sfx", payload: { key: "board.merge", bus: "sfx" }, cosmetic: true }
|
|
430
433
|
* sfx("voice.hello", { id: "voice", fadeMs: 200 });
|
|
431
434
|
* // { kind: "sfx", payload: { key: "voice.hello", bus: "sfx", id: "voice", fadeMs: 200 }, cosmetic: true }
|
|
435
|
+
* sfx("rain.room", { id: "rain", loop: true });
|
|
436
|
+
* // { kind: "sfx", payload: { key: "rain.room", bus: "sfx", id: "rain", loop: true }, cosmetic: true }
|
|
432
437
|
* ```
|
|
433
438
|
*/
|
|
439
|
+
declare function sfx(key: string, options: {
|
|
440
|
+
bus?: string;
|
|
441
|
+
id: string;
|
|
442
|
+
fadeMs?: number;
|
|
443
|
+
loop: true;
|
|
444
|
+
}): SfxDescriptor;
|
|
434
445
|
declare function sfx(key: string, options?: {
|
|
435
446
|
bus?: string;
|
|
436
447
|
id?: string;
|
|
@@ -546,12 +557,13 @@ type ErasedFields = AnyComponent extends ComponentType<infer Value> ? Value : ne
|
|
|
546
557
|
* A sound, owned by `anim` and handled by `audio`. It is a `flow` descriptor and a timeline step
|
|
547
558
|
* at once: `fx(sfx("board.merge"))` in a node, or `sfx("board.merge")` inside a `sequence`. A
|
|
548
559
|
* sound with an `id` is named: a second one with the same id fades the first out over `fadeMs`,
|
|
549
|
-
* and `stopSfx(id)` stops it. The payload carries `id` and `
|
|
560
|
+
* and `stopSfx(id)` stops it. The payload carries `id`, `fadeMs` and `loop` only when they were
|
|
561
|
+
* given.
|
|
550
562
|
*
|
|
551
563
|
* @example
|
|
552
564
|
* ```ts
|
|
553
565
|
* const descriptor: SfxDescriptor = {
|
|
554
|
-
* kind: "sfx", payload: { key: "
|
|
566
|
+
* kind: "sfx", payload: { key: "rain.room", bus: "sfx", id: "rain", loop: true }, cosmetic: true
|
|
555
567
|
* };
|
|
556
568
|
* ```
|
|
557
569
|
*/
|
|
@@ -561,7 +573,8 @@ type SfxDescriptor = {
|
|
|
561
573
|
readonly key: string;
|
|
562
574
|
readonly bus: string; /** Name of the sound: one sound per id plays, and `stopSfx(id)` stops it. */
|
|
563
575
|
readonly id?: string; /** Fade of the sound with the same id this one replaces; `audio`'s `sfxFadeMs` when absent. */
|
|
564
|
-
readonly fadeMs?: number;
|
|
576
|
+
readonly fadeMs?: number; /** The sound loops until `stopSfx(id)` or until its scene leaves; set only with an `id`. */
|
|
577
|
+
readonly loop?: true;
|
|
565
578
|
};
|
|
566
579
|
readonly cosmetic: true; /** Never set: `await fx(sfx(...))` resolves nothing. */
|
|
567
580
|
readonly $result?: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as Config$2, Hr as Config, Ir as ClockSource, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Un as TypeTag, Wr as Json, Xr as ProviderCall, Yr as PlayerStateProvider, Zr as SaveDoc, _t as Orientation, a as Config$3, d as Manifest, ei as SnapshotOf, gn as Config$1, it as PixiModule, n as AssetsIo } from "./types-B93wB7Sh.mjs";
|
|
2
|
-
import { H as I18nApi, J as TextKey, q as StringTable } from "./types-
|
|
3
|
-
import { n as AudioContextLike, r as Config$4 } from "./types-
|
|
4
|
-
import { Rt as effectsPlugin, Vt as audioPlugin, i as screen, jt as PlatformProvider, kt as platformPlugin, t as createApp } from "./index-
|
|
2
|
+
import { H as I18nApi, J as TextKey, q as StringTable } from "./types-C7D1V3iQ.mjs";
|
|
3
|
+
import { n as AudioContextLike, r as Config$4 } from "./types-SFW8MKyb.mjs";
|
|
4
|
+
import { Rt as effectsPlugin, Vt as audioPlugin, i as screen, jt as PlatformProvider, kt as platformPlugin, t as createApp } from "./index-ytikCrJO.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 FilterSlotInputs, Ar as Api$1, Q as Api$2, Ur as Events$2, Vr as Api$4, Wn as Descriptor, Wr as Json, at as PixiSprite, b as Events$3, bi as Require, br as Entity, bt as FilterCache, gr as ComponentHandle, it as PixiModule, j as FilterSlotQuad, k as FilterSlot, mn as Api, nt as PixiFilter, oi as Events$4, ot as PixiTexture, rt as PixiGpuProgram, s as Events, st as PixiUniformGroup, t as Api$3, ui as Api$5, vr as ComponentType, vt as Point, yi as Events$1 } from "./types-B93wB7Sh.mjs";
|
|
2
|
-
import { nt as AnimApi } from "./types-
|
|
2
|
+
import { nt as AnimApi } from "./types-C7D1V3iQ.mjs";
|
|
3
3
|
import { Log } from "@moku-labs/common/browser";
|
|
4
4
|
import { PluginCtx } from "@moku-labs/core";
|
|
5
5
|
|
|
@@ -1369,7 +1369,7 @@ type AssetsReplaced$1 = Events["assets:replaced"];
|
|
|
1369
1369
|
*/
|
|
1370
1370
|
type HotSwap = Events$1["ui:hot-swap"];
|
|
1371
1371
|
declare namespace types_d_exports {
|
|
1372
|
-
export { AssetsReplaced, AudioApi, AudioContextLike, AudioCtx, AudioSessionLike, AudioSessionType, BundleUnloaded, Bus, BusState, Config, Deps, KernelSlice, LifecycleChanged, ModelCommitted, MusicDescriptor, MusicMode, MusicOptions, MusicRequest, MusicSwitch, MusicTrack, NamedSound, RetiringTrack, SceneChanged, SfxRequest, SoundEntry, State, StreamTrack, Volumes, VolumesFor };
|
|
1372
|
+
export { AssetsReplaced, AudioApi, AudioContextLike, AudioCtx, AudioSessionLike, AudioSessionType, BundleUnloaded, Bus, BusState, Config, Deps, KernelSlice, LeavingScene, LifecycleChanged, LoopSound, ModelCommitted, MusicDescriptor, MusicMode, MusicOptions, MusicRequest, MusicSwitch, MusicTrack, NamedSound, RetiringTrack, SceneChanged, SfxRequest, SoundEntry, State, StreamTrack, Volumes, VolumesFor };
|
|
1373
1373
|
}
|
|
1374
1374
|
/**
|
|
1375
1375
|
* The three volume buses. `master` carries the whole game, `music` the scene track, `sfx` every
|
|
@@ -1506,7 +1506,9 @@ type RetiringTrack = {
|
|
|
1506
1506
|
timer: ReturnType<typeof setTimeout>;
|
|
1507
1507
|
};
|
|
1508
1508
|
/**
|
|
1509
|
-
* audio plugin
|
|
1509
|
+
* What a game can set on the audio plugin: the start gain of each bus, the fades of music and named
|
|
1510
|
+
* sounds, the volumes reader, the context factory, the journal size, the music mode and the iOS
|
|
1511
|
+
* session. A game sets it through `pluginConfigs.audio`.
|
|
1510
1512
|
*
|
|
1511
1513
|
* @example
|
|
1512
1514
|
* ```ts
|
|
@@ -1544,12 +1546,14 @@ type Config = {
|
|
|
1544
1546
|
/**
|
|
1545
1547
|
* One sound that started: a play of an `sfx` or a music track that began. `at` is the elapsed
|
|
1546
1548
|
* game time in milliseconds, `app.time.snapshot().elapsed` at the start. `id` is there only for
|
|
1547
|
-
* an `sfx` started with one
|
|
1549
|
+
* an `sfx` started with one, and `loop: true` only for an `sfx` started with `{ id, loop: true }`:
|
|
1550
|
+
* a loop has one entry, at its first start, and none when the iOS renewal starts it again.
|
|
1548
1551
|
*
|
|
1549
1552
|
* @example
|
|
1550
1553
|
* ```ts
|
|
1551
1554
|
* const entry: SoundEntry = { key: "ui.click", bus: "sfx", kind: "sfx", at: 1600 };
|
|
1552
1555
|
* const line: SoundEntry = { key: "story.line1", bus: "sfx", kind: "sfx", id: "voice", at: 2400 };
|
|
1556
|
+
* const bed: SoundEntry = { key: "room-rain", bus: "sfx", kind: "sfx", id: "rain", loop: true, at: 0 };
|
|
1553
1557
|
* ```
|
|
1554
1558
|
*/
|
|
1555
1559
|
type SoundEntry = {
|
|
@@ -1557,6 +1561,7 @@ type SoundEntry = {
|
|
|
1557
1561
|
readonly bus: Bus;
|
|
1558
1562
|
readonly kind: "sfx" | "music";
|
|
1559
1563
|
readonly id?: string;
|
|
1564
|
+
readonly loop?: true;
|
|
1560
1565
|
readonly at: number;
|
|
1561
1566
|
};
|
|
1562
1567
|
/**
|
|
@@ -1611,7 +1616,32 @@ type NamedSound = {
|
|
|
1611
1616
|
source: AudioBufferSourceNode | undefined;
|
|
1612
1617
|
};
|
|
1613
1618
|
/**
|
|
1614
|
-
*
|
|
1619
|
+
* One loop a game asked for with `sfx(key, { id, loop: true })`, kept under its id until a stop,
|
|
1620
|
+
* a sound that takes the id, the leave of its scene or `onStop`. It outlives the sound itself: a
|
|
1621
|
+
* locked context and an iOS renewal start it again from here, as the remembered music.
|
|
1622
|
+
* `fadeMs` is its fade-in and the fade of the sound it replaced; `scene` is the scene mounted
|
|
1623
|
+
* when it was asked for (`undefined`: before any scene, so only a stop ends it); `started` is set
|
|
1624
|
+
* at its first real start, so a start again after a renewal writes no journal entry.
|
|
1625
|
+
*/
|
|
1626
|
+
type LoopSound = {
|
|
1627
|
+
key: string;
|
|
1628
|
+
bus: Bus;
|
|
1629
|
+
fadeMs: number;
|
|
1630
|
+
scene: string | undefined;
|
|
1631
|
+
started: boolean;
|
|
1632
|
+
};
|
|
1633
|
+
/**
|
|
1634
|
+
* What the walk of a scene leave reads for each loop: the scene that leaves and the fade, in real
|
|
1635
|
+
* milliseconds, of the loops that belong to it.
|
|
1636
|
+
*/
|
|
1637
|
+
type LeavingScene = {
|
|
1638
|
+
scene: string;
|
|
1639
|
+
fadeMs: number;
|
|
1640
|
+
};
|
|
1641
|
+
/**
|
|
1642
|
+
* What the audio plugin keeps between calls: the context and its graph, the buses, the pause and
|
|
1643
|
+
* unlock flags, the named sounds and the remembered loops, the decoded buffers, the music track
|
|
1644
|
+
* and the journal. Owned and written only by the audio plugin.
|
|
1615
1645
|
*/
|
|
1616
1646
|
type State = {
|
|
1617
1647
|
/** `undefined` means headless: no graph, no sound, every member still keeps its value. */context: AudioContextLike | undefined;
|
|
@@ -1624,7 +1654,18 @@ type State = {
|
|
|
1624
1654
|
* without an id. Played when the context runs, dropped when it does not.
|
|
1625
1655
|
*/
|
|
1626
1656
|
pendingSfx: Map<string, SfxRequest>; /** The sound that plays, or decodes, under each id; an entry leaves when its sound ends or stops. */
|
|
1627
|
-
named: Map<string, NamedSound>;
|
|
1657
|
+
named: Map<string, NamedSound>;
|
|
1658
|
+
/**
|
|
1659
|
+
* The loops the game asked for, by id: kept across a locked context and an iOS renewal, which
|
|
1660
|
+
* `stopAllNamed` survives, and cleared by `onStop` only.
|
|
1661
|
+
*/
|
|
1662
|
+
loops: Map<string, LoopSound>; /** The mounted scene, as the last `scenes:changed` named it; `undefined` before the first. */
|
|
1663
|
+
scene: string | undefined;
|
|
1664
|
+
/**
|
|
1665
|
+
* The scene that leaves and the fade, written by `stopSceneLoops` before its walk of `loops`:
|
|
1666
|
+
* one object for the whole run, so the walk makes nothing.
|
|
1667
|
+
*/
|
|
1668
|
+
leaving: LeavingScene; /** Per key, evicted per key on `assets:bundle-unloaded` and `assets:replaced`, and when a music track stops being the one that plays. */
|
|
1628
1669
|
decoded: Map<string, Promise<AudioBuffer>>; /** Asset keys that already got their one warning. */
|
|
1629
1670
|
warned: Set<string>; /** `config.volumes` threw once and was reported; it is not reported again this run. */
|
|
1630
1671
|
warnedVolumes: boolean;
|
|
@@ -1737,9 +1778,11 @@ type AudioApi = {
|
|
|
1737
1778
|
unlocked(): boolean;
|
|
1738
1779
|
/**
|
|
1739
1780
|
* The sounds that started, oldest first: every play of an `sfx` and every music track that
|
|
1740
|
-
* began, at most `config.journal` of them. A
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1781
|
+
* began, at most `config.journal` of them. A loop is in it once, with `loop: true`, at its first
|
|
1782
|
+
* start: a request for the loop that already plays under its id and the start again after an iOS
|
|
1783
|
+
* renewal add nothing. A sound dropped before the unlock, a missing file and a music switch to
|
|
1784
|
+
* the track that already plays are not in it. Empty while `config.journal` is 0, the default,
|
|
1785
|
+
* and after the app stopped.
|
|
1743
1786
|
*
|
|
1744
1787
|
* No copy and no live view: the list and its entries are never written. Every new sound replaces the plugin's list
|
|
1745
1788
|
* with a new frozen one, so a list read earlier keeps what it held, and a caller cannot change the journal through it.
|
|
@@ -1752,14 +1795,18 @@ type AudioApi = {
|
|
|
1752
1795
|
* app.audio.journal();
|
|
1753
1796
|
* // [{ key: "board.theme", bus: "music", kind: "music", at: 0 },
|
|
1754
1797
|
* // { key: "orders.complete", bus: "sfx", kind: "sfx", at: 1600 }]
|
|
1798
|
+
*
|
|
1799
|
+
* // The ward's node fired `sfx("room-rain", { id: "rain", loop: true })` at 2400.
|
|
1800
|
+
* app.audio.journal().at(-1); // { key: "room-rain", bus: "sfx", kind: "sfx", id: "rain", loop: true, at: 2400 }
|
|
1755
1801
|
* ```
|
|
1756
1802
|
*/
|
|
1757
1803
|
journal(): readonly SoundEntry[];
|
|
1758
1804
|
/**
|
|
1759
|
-
* Fades out and ends the sound that plays under one id, an `sfx` started with `{ id }
|
|
1760
|
-
* same stop as the effect kind `stopSfx`: a sound with that id
|
|
1761
|
-
* waiting for the unlock is dropped
|
|
1762
|
-
*
|
|
1805
|
+
* Fades out and ends the sound that plays under one id, an `sfx` started with `{ id }`, a loop
|
|
1806
|
+
* of `{ id, loop: true }` too. The same stop as the effect kind `stopSfx`: a sound with that id
|
|
1807
|
+
* still decoding never starts, one waiting for the unlock is dropped (a loop remembered while
|
|
1808
|
+
* the context is locked as well), and an id nothing plays under changes nothing. A stopped loop
|
|
1809
|
+
* is not started again by an iOS renewal. Headless it does nothing.
|
|
1763
1810
|
*
|
|
1764
1811
|
* @param id - The id the sound was started with, `"voice"` for `sfx(key, { id: "voice" })`.
|
|
1765
1812
|
* @param options - How the sound ends.
|
|
@@ -1769,6 +1816,9 @@ type AudioApi = {
|
|
|
1769
1816
|
* // A test composed with `journal: 200` cuts the narrator's line before it checks the next screen.
|
|
1770
1817
|
* app.audio.journal().at(-1); // { key: "story.line1", bus: "sfx", kind: "sfx", id: "voice", at: 0 }
|
|
1771
1818
|
* app.audio.stop("voice", { fadeMs: 0 }); // the line ends now and stays in the journal
|
|
1819
|
+
*
|
|
1820
|
+
* // The rain of the ward loops until the test ends it.
|
|
1821
|
+
* app.audio.stop("rain", { fadeMs: 0 }); // the loop ends now; nothing starts it again
|
|
1772
1822
|
* ```
|
|
1773
1823
|
*/
|
|
1774
1824
|
stop(id: string, options?: {
|
|
@@ -1776,7 +1826,8 @@ type AudioApi = {
|
|
|
1776
1826
|
}): void;
|
|
1777
1827
|
};
|
|
1778
1828
|
/**
|
|
1779
|
-
*
|
|
1829
|
+
* The four plugin APIs audio resolves once through `ctx.require`: `flow` for the effect handlers,
|
|
1830
|
+
* `assets` for the bytes, `model` for the committed player volumes and `time` for the journal clock.
|
|
1780
1831
|
*/
|
|
1781
1832
|
type Deps = {
|
|
1782
1833
|
flow: Api;
|
|
@@ -1822,13 +1873,16 @@ type BundleUnloaded = Events["assets:bundle-unloaded"];
|
|
|
1822
1873
|
type AssetsReplaced = Events["assets:replaced"];
|
|
1823
1874
|
/**
|
|
1824
1875
|
* What one play of a sound asks for: the key, the bus the sound goes to, the id it plays under
|
|
1825
|
-
* (`undefined`: none),
|
|
1876
|
+
* (`undefined`: none), the fade in milliseconds of the sound with that id it replaces, and
|
|
1877
|
+
* whether the payload asked for a loop with `loop: true`. Only a loop with an id loops: one with
|
|
1878
|
+
* none could never be stopped, so it plays once.
|
|
1826
1879
|
*/
|
|
1827
1880
|
type SfxRequest = {
|
|
1828
1881
|
key: string;
|
|
1829
1882
|
bus: string;
|
|
1830
1883
|
id: string | undefined;
|
|
1831
1884
|
fadeMs: number;
|
|
1885
|
+
loop: boolean;
|
|
1832
1886
|
};
|
|
1833
1887
|
/**
|
|
1834
1888
|
* What one music switch asks for: the key, or `null` to fade the current track out.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-B93wB7Sh.mjs";
|
|
2
|
-
import { L as InputApi, nt as AnimApi, s as UiApi } from "./types-
|
|
2
|
+
import { L as InputApi, nt as AnimApi, s as UiApi } from "./types-C7D1V3iQ.mjs";
|
|
3
3
|
import { r as Repro } from "./headless-8XrFW9w1.mjs";
|
|
4
4
|
import { i as ControlApp, o as InputOf } from "./types-BEEPI3F3.mjs";
|
|
5
|
-
import { t as commands } from "./commands-
|
|
5
|
+
import { t as commands } from "./commands-CxBsMGeq.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/visual/types.d.ts
|
|
8
8
|
/** The base commands of the `/control` door, keyed by their short names. */
|
package/dist/visual.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-
|
|
1
|
+
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-BMKoT_48.mjs";
|
|
2
2
|
export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
|
package/llms.txt
CHANGED
|
@@ -605,9 +605,9 @@ A screen is a projection whose `view` returns JSX. The game's `tsconfig.json` se
|
|
|
605
605
|
- `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: {}`.
|
|
606
606
|
- 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.
|
|
607
607
|
- Text: `Text` component, `label({ text, style, at, anchor? })` for board text in a projection view, `defineTextStyles({ "hud.digits": { font, size, fill, bold?, italic?, stroke?, strokeWidth?, letterSpacing?, align?, wrap? (a width, "none" or "box": wrap at the laid-out width of its ui element; lines break between words, after a hyphen inside a word and at a soft hyphen U+00AD, drawn as `-` only where the line breaks), digits?, lineHeight? (the line as a multiple of size above 0, such as 1.28; glyphs sit in the middle of the line; absent: the font's own line), balance? (true evens a wrapped block of 2–6 lines at the narrowest width that keeps its number of lines, like CSS `text-wrap: balance`; never wider than the wrap; one line, more than 6 or a word wider than the wrap stay greedy), boldStyle? (a `TextRunStyle` of `font`, `size`, `fill`, `letterSpacing`, `stroke`, `strokeWidth`, `shadow`: the look of the `<b>` runs of the style, laid over it; `font` wins over `bold`), textIndent? (the indent of the first line in reference px, ≥ 0, like CSS `text-indent`; a line after `\n` starts at the edge; counted in the width) } })` under the feature's `textStyles` key. Tags inside a string: `<b>`, `<i>`, `<color=#rrggbb>`, `<span style=KEY>` (the glyph look of the style `KEY`: font, size, fill, spacing, outline, shadow, line; unquoted key; an unknown key draws in the text's own look and warns once), `<icon=key>`, `\<`, `\n`. Every piece of a line stands on one baseline, and a larger piece makes its line taller. Built-in styles `body` and `digits` from config `fonts: { body: "ui.font-body", digits: "ui.font-digits" }`. `app.text.measure(content, style, width?)` gives the same numbers in a browser and in Bun. `app.text.replaceStyles(styles)` is the dev hot swap of a saved `defineTextStyles` value. A game's own number format: `defineTextFormats({ "pill.number": value => ({ content, style }) })` under the feature's `textFormats` key, named by the `bind` of `defineGame` (`GameTypes.textFormats`): `bind(Counter, "value", { format: "pill.number" })`. It takes the whole value, is pure over value and language, is not called while the whole value and the locale stand, and owns `Text.style`; a `Countdown` calls it every frame. `app.text.formatted(name, value)` answers `{ text, style }`, `undefined` for an unknown or built-in name and for a format that threw. A saved module exporting formats reloads the page.
|
|
608
|
-
- Animation is data: `defineAnimation(id, { slots: { name: type<Anim.Target>() }, build: (slots, { at, reducedMotion }) => Step })`; `reducedMotion` is the reduced-motion switch read once when the play starts (absent reads as `false`; `use` carries it only with the outer tools), so `build` can return a designed variant whose tweens are marked `reduced: "keep"`. Steps: `sequence(...)`, `parallel(...)`, `stagger(items, ms, item => Step)`, `tween(target, Component, to, { ms, ease?, delayMs?, additive?, space?, reduced? })`, `set(target, Component, patch)`, `wait(ms)`, `mark(name)`, `frames(target, { keys, fps, loop? })`, `sfx(key, { bus? })
|
|
608
|
+
- Animation is data: `defineAnimation(id, { slots: { name: type<Anim.Target>() }, build: (slots, { at, reducedMotion }) => Step })`; `reducedMotion` is the reduced-motion switch read once when the play starts (absent reads as `false`; `use` carries it only with the outer tools), so `build` can return a designed variant whose tweens are marked `reduced: "keep"`. Steps: `sequence(...)`, `parallel(...)`, `stagger(items, ms, item => Step)`, `tween(target, Component, to, { ms, ease?, delayMs?, additive?, space?, reduced? })`, `set(target, Component, patch)`, `wait(ms)`, `mark(name)`, `frames(target, { keys, fps, loop? })`, `sfx(key, { bus?, id?, fadeMs?, loop? })` (`loop: true` needs `id`), `haptic(kind)`, `use(animation, slots, tools?)`, `spawn` (a temporary entity, flying coins, that the timeline despawns when it ends; see the anim README). `Frames({ keys, fps, loop, playing })` is a component that walks a sprite through its textures for the entity's whole life. A target is `{ projection, key }` or an entity. A timeline resolves each `{ projection, key }` target once, when it starts: every step writes the view that held the key then, also after a commit removed it and while its exit plays, until it despawns; a view spawned again under the same key is not followed, and a key nothing held at the start is looked up at its step. `reduced: "keep"` (on a `tween` step, `transition` and `loop` of `defineMotion`, `TweenOptions`, `RestOptions`) plays a track as written under reduced motion, a fade for one; the default `"cut"` lands it at once or holds a loop on its first key. A node plays it with `await fx(play(animation, slots))`; in fast mode it finishes at once. `defineMotion({ states, transition?, on: { enter?, exit?, change? }, when? })` builds the enter, exit and change hooks for a projection or the `motion` prop of a tag; `when: "change"` plays enter and exit only for a commit, so an element that comes or goes with its screen stands at rest and leaves without a motion (default `"always"`). Events `anim:mark` `{ animation, mark }`, `anim:started` `{ animation, timeline }`, `anim:cancelled` `{ animation, timeline }` and `anim:finished` `{ animation, timeline, reason }` (`reason` is `"ended"` when the tree ran through, `"finished"` for `finish()`, `finishAll()` and the abort of the node that played it; the timeline number is shared with tracks, so it is not consecutive). `app.anim.timelines()` answers `{ running, ended }`: every running timeline with its `timeline`, `animation`, `startFrame`, `slots`, `entities` and `marks`, and the last 16 ended ones with `startFrame`, `endFrame` and `reason` (`"ended"`, `"finished"` or `"cancelled"`), oldest first; `game.timelines` is the same as an inspect source. `defineMotion({ id: "hud.card", … })` labels every track it starts `hud.card.enter`, `.exit`, `.loop` or `.change`, shown by `world.projection.motionIdsOf(entity)` and `game.explain` as `motionIds`; an equal loop built again under another id keeps its running track and its old label. `app.anim.replace(definition)` is the dev hot swap: the next `play` builds the new tree. A system cannot `require` a plugin, so it plays through the resource `AnimPlayer`: `res(AnimPlayer).play(animation, slots)` returns the same handle as `app.anim.play`, and the registered animation of `animation.id` wins, so a hot swap reaches the system. Play on a change, never every frame; from phase `input` the tree moves in `animate` of the same frame. Before `anim` starts it throws `[game] AnimPlayer is not ready: anim has not started.` Config `maxTracks: 2000`.
|
|
609
609
|
- A `tween` step takes `segments` and `repeat` as `ViewHandle.tween` does: `tween(chest, Transform, { y: 0, scale: 0 }, { ms: 2400, additive: true, repeat: "forever", segments: [{ at: 0.08, ease: "out", to: { y: -14, scale: 0.06 } }, { at: 1, to: { y: 0, scale: 0 } }] })`. Segments walk over `ms` on one clock, `to` is where the last one ends, an additive walk names offsets; a number counts the extra runs. A definition error throws for empty segments, an `at` outside 0..1 or out of order, a last segment before 1, a bad repeat, and a `sequence` step after one that never ends. A forever step ends only by cancel or finish (a finish and a fast world land it on its start pose), does not play under reduced motion `"cut"`, writes nothing while its view is unseen, and lets the clock idle; a system plays it once through `AnimPlayer` and keeps the handle.
|
|
610
|
-
- Audio is opt-in: `plugins: [...screen, audioPlugin]`. `fx(sfx("orders.complete"))` resolves when the sound started. `await fx(music("board.theme"))` cross-fades; `music(null)` fades out; a scene's `music` key switches the track on `scenes:changed`. Buses `master`, `music`, `sfx`. Volumes come from the committed player: config `volumes: player => (player as Player).settings.audio`, applied on every `model:committed`. `app.audio`: `setVolume(bus, value)`, `volume(bus)`, `mute(bus, on)`, `muted(bus)`, `unlocked()`, `journal()` (the last started sounds, empty unless config `journal` is above 0). Config: `buses: { master: 1, music: 0.6, sfx: 1 }`, `musicFadeMs: 600`, `volumes`, `context`, `journal: 0`, `music: "decode" | "stream"` default `"decode"` (gapless buffer; `"stream"` is an `<audio>` element, less memory, a gap at every loop), `session: "ambient" | "playback" | "auto"` default `"ambient"` (iOS only: ambient mixes with other apps and obeys the silent switch). The context is asked to run at start: where the shell lets audio play (a native webview with the gesture requirement off) `unlocked()` is true with no touch; a browser that wants a gesture unlocks on the first `pointerdown` or `touchend`. iOS: after a pause the touch unlock stays armed until the context really runs (WebKit holds `resume()` pending after a screenshot or Control Center); on a return from the background (WebKit with `navigator.audioSession`, a touch screen, `session` not `"playback"`) the plugin renews its context one second later or at the first touch: session `"auto"`, old context closed, `session` again, a new context from `config.context` (called again, so return a new context each call) at the same volumes, decoded buffers kept, the scene's music restarted, sounds in flight dropped. Without `audio` every `sfx` and `music` effect resolves `undefined` at once, so the same node runs in a game with no sound. Named sounds: `sfx(key, { bus?, id?, fadeMs? })` with an `id` plays through its own gain, and the next sound with the same `id` fades the old one out over `fadeMs`, else config `sfxFadeMs` (default `120`, real milliseconds); `fx.start(stopSfx(id, { fadeMs? }))` and `app.audio.stop(id, { fadeMs? })` fade it out and end it (`fadeMs: 0` cuts it); an `id` nothing plays under changes nothing, and a sound of that `id` still decoding never starts. Without `id` an `sfx` plays to its end as before.
|
|
610
|
+
- Audio is opt-in: `plugins: [...screen, audioPlugin]`. `fx(sfx("orders.complete"))` resolves when the sound started. `await fx(music("board.theme"))` cross-fades; `music(null)` fades out; a scene's `music` key switches the track on `scenes:changed`. Buses `master`, `music`, `sfx`. Volumes come from the committed player: config `volumes: player => (player as Player).settings.audio`, applied on every `model:committed`. `app.audio`: `setVolume(bus, value)`, `volume(bus)`, `mute(bus, on)`, `muted(bus)`, `unlocked()`, `journal()` (the last started sounds, empty unless config `journal` is above 0). Config: `buses: { master: 1, music: 0.6, sfx: 1 }`, `musicFadeMs: 600`, `volumes`, `context`, `journal: 0`, `music: "decode" | "stream"` default `"decode"` (gapless buffer; `"stream"` is an `<audio>` element, less memory, a gap at every loop), `session: "ambient" | "playback" | "auto"` default `"ambient"` (iOS only: ambient mixes with other apps and obeys the silent switch). The context is asked to run at start: where the shell lets audio play (a native webview with the gesture requirement off) `unlocked()` is true with no touch; a browser that wants a gesture unlocks on the first `pointerdown` or `touchend`. iOS: after a pause the touch unlock stays armed until the context really runs (WebKit holds `resume()` pending after a screenshot or Control Center); on a return from the background (WebKit with `navigator.audioSession`, a touch screen, `session` not `"playback"`) the plugin renews its context one second later or at the first touch: session `"auto"`, old context closed, `session` again, a new context from `config.context` (called again, so return a new context each call) at the same volumes, decoded buffers kept, the scene's music restarted, sounds in flight dropped. Without `audio` every `sfx` and `music` effect resolves `undefined` at once, so the same node runs in a game with no sound. Named sounds: `sfx(key, { bus?, id?, fadeMs?, loop? })` with an `id` plays through its own gain, and the next sound with the same `id` fades the old one out over `fadeMs`, else config `sfxFadeMs` (default `120`, real milliseconds); `fx.start(stopSfx(id, { fadeMs? }))` and `app.audio.stop(id, { fadeMs? })` fade it out and end it (`fadeMs: 0` cuts it); an `id` nothing plays under changes nothing, and a sound of that `id` still decoding never starts. Without `id` an `sfx` plays to its end as before. Loops: `sfx("room-rain", { id: "rain", loop: true, fadeMs: 800 })` is an ambient bed that loops gapless (`loop` without `id` does not compile; a hand-written payload with `loop` and no `id` plays once). It fades in from 0 over `fadeMs`, else `sfxFadeMs`, while the sound it replaces under the `id` fades out over the same time. The same key again under its `id` changes nothing (no restart, no journal entry); another key cross-fades, and a one-shot under the `id` replaces it. It ends at `stopSfx(id)`, `app.audio.stop(id)`, `onStop`, or the `scenes:changed` that leaves the scene mounted when it was asked for, fading over `musicFadeMs`; one fired by a scene's first node belongs to that scene, one asked for before any scene only stops on a stop. Asked for while the context is locked, or during an iOS renewal, it is remembered and starts at the unlock; the renewal starts every loop again at its bus. `bus: "music"` puts it under the music slider; a pause holds it silent; a fast walk starts none; it always decodes, also at `music: "stream"`. The journal has one entry per loop with `loop: true`. An 8 s stereo 48 kHz bed is about 3 MB decoded (a calculation).
|
|
611
611
|
- `app.ui`: `tree()` the live screen as plain data (a text node carries `content`, the words it draws after `tr()` and `bind`; a text field carries `value`), `find(key)` the entity of a keyed element, `fill(key, value)` types into the text field with that `key`, `scroll(key, to)` puts the `scroll` with that `key` at `to` from its start at once, inside `0..max`, its fling or glide stopped (`false` and `ui:scroll-without-scroll` for no live `scroll`, `false` and `ui:scroll-before-solve` for a `scroll` its first solve has not placed yet), `rectOf(target)` where an `AnchorTarget` (or the shown ones of a list) is drawn, in screen reference units, the rect an `<anchor>` sits on, a target of no area shown at its point (`{ x, y, w: 0, h: 0 }`; an `<anchor>` on it stands there at size 0, takes no tap, its children lay out and hit as usual; an inward `pad` past half the target leaves it at size 0 on the centre), `undefined` when none is shown (an `image` whose style states a size, `width`/`height` or both edges of an absolute one, laid out at 0 draws nothing and counts as not shown; one whose style states no size keeps its alpha and draws as its `Sprite` says, ui never writing the size a game's system gives it), any build, a new object per call (`app.ui.rectOf({ projection: "board.strip", key: "seat0" })` → `{ x: 40, y: 1500, w: 116, h: 120 }`), `lint()` tap targets under `tapTargetPt` (default `44`), text that overflows in some locale, absolute elements without `reason`. Config: `tapTargetPt: 44`, `breakpoints: { tall: 2, wide: 1.5 }`. `ui` emits only the dev global event `ui:hot-swap`, see "Hot swap".
|
|
612
612
|
|
|
613
613
|
```tsx
|