@moku-labs/game 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/assets.d.mts +1 -1
- package/dist/{commands-C83eQ5B9.d.mts → commands-mzE9PX0H.d.mts} +14 -6
- package/dist/control.d.mts +3 -3
- package/dist/control.mjs +1 -1
- package/dist/{define-BKWjWgyQ.d.mts → define-BbgXv4cy.d.mts} +1 -1
- package/dist/hot.d.mts +85 -0
- package/dist/hot.mjs +108 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +624 -71
- package/dist/inspect.d.mts +6 -6
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/lint.d.mts +79 -0
- package/dist/lint.mjs +360 -0
- package/dist/{run-D_R0oJ6g.mjs → run-Bcyg32M5.mjs} +40 -11
- package/dist/{runtime-Bhu442L8.d.mts → runtime-HTlmRb81.d.mts} +1 -1
- package/dist/testing.d.mts +5 -5
- package/dist/testing.mjs +19 -4
- package/dist/{types-Dy1xB68L.d.mts → types-BMEn0tSC.d.mts} +39 -4
- package/dist/{types-VErbiEXy.d.mts → types-BaUUcIaN.d.mts} +59 -6
- package/dist/{types-C-4f2jD_.d.mts → types-CXyipKhE.d.mts} +291 -249
- package/dist/{types-DtmFVCHf.d.mts → types-CYYKjvLn.d.mts} +1 -1
- package/dist/{types-w646dMeA.d.mts → types-ClF8say0.d.mts} +7 -3
- package/llms.txt +52 -6
- package/package.json +10 -1
|
@@ -27,9 +27,21 @@ type Config$8 = {
|
|
|
27
27
|
referenceLong: number;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Global events.
|
|
30
|
+
* Global events: the few that cross plugins with no `depends` edge. Every other event belongs to a
|
|
31
|
+
* plugin.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // ui, after a dev save of features/board/effects.ts; effects hooks it with no depends on ui.
|
|
36
|
+
* ctx.emit("ui:hot-swap", { file: "features/board/effects.ts", module: { starsBurst } });
|
|
37
|
+
* ```
|
|
31
38
|
*/
|
|
32
|
-
type Events$6 =
|
|
39
|
+
type Events$6 = {
|
|
40
|
+
/** A dev hot swap was applied: the saved module's new exports. `ui` emits it, `effects` replaces its emitters on it. */"ui:hot-swap": {
|
|
41
|
+
file: string;
|
|
42
|
+
module: Readonly<Record<string, unknown>>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
33
45
|
/**
|
|
34
46
|
* Public API type of a plugin instance, read from its phantom carrier.
|
|
35
47
|
* Mirrors the kernel's non-exported `ExtractPluginApi`.
|
|
@@ -2141,6 +2153,11 @@ type Bookmark = {
|
|
|
2141
2153
|
session: Json;
|
|
2142
2154
|
rng: RngState;
|
|
2143
2155
|
graph: string;
|
|
2156
|
+
/**
|
|
2157
|
+
* The scene mounted when the bookmark was taken. Written by the `game.bookmark` door, read by
|
|
2158
|
+
* `game.restore`; `flow.restore` ignores it.
|
|
2159
|
+
*/
|
|
2160
|
+
scene?: string;
|
|
2144
2161
|
};
|
|
2145
2162
|
/**
|
|
2146
2163
|
* What `onEnter` callbacks learn about the node being entered.
|
|
@@ -3432,6 +3449,23 @@ type ProjectionApi = {
|
|
|
3432
3449
|
* ```
|
|
3433
3450
|
*/
|
|
3434
3451
|
register(spec: AnyProjectionSpec): void;
|
|
3452
|
+
/**
|
|
3453
|
+
* Swaps the stored spec of a registered projection. A mounted one has its layers checked against
|
|
3454
|
+
* the current scene and runs the new `view` for every item on the next frame, directly. An
|
|
3455
|
+
* unmounted one is only stored; its next `mount` uses it. Nothing changes when the call throws.
|
|
3456
|
+
*
|
|
3457
|
+
* @param spec - The new projection, under the name it was registered with.
|
|
3458
|
+
* @throws {Error} When no projection of that name is registered, or when a mounted one names a
|
|
3459
|
+
* `layer` or `lift` the scene does not declare.
|
|
3460
|
+
* @example
|
|
3461
|
+
* ```ts
|
|
3462
|
+
* // The dev hot swap in `ui`: the saved `view.ts` exports a new `boardItems`.
|
|
3463
|
+
* const world = ctx.require(worldPlugin);
|
|
3464
|
+
* world.projection.replace(boardItems); // the next frame draws every item with the new view
|
|
3465
|
+
* world.projection.replace(shopItems); // throws: Projection "shop.items" is not registered
|
|
3466
|
+
* ```
|
|
3467
|
+
*/
|
|
3468
|
+
replace(spec: AnyProjectionSpec): void;
|
|
3435
3469
|
/**
|
|
3436
3470
|
* Stores the layer list of the scene. The order of the list is draw order; every call stores a
|
|
3437
3471
|
* new frozen array.
|
|
@@ -3696,9 +3730,10 @@ type ProjectionApi = {
|
|
|
3696
3730
|
*
|
|
3697
3731
|
* @example
|
|
3698
3732
|
* ```ts
|
|
3699
|
-
* //
|
|
3733
|
+
* // The ui hot swap replaced the saved `hud` projection: every mounted view runs `view` again.
|
|
3700
3734
|
* const world = ctx.require(worldPlugin);
|
|
3701
|
-
* world.projection.
|
|
3735
|
+
* world.projection.replace(hud);
|
|
3736
|
+
* world.projection.rerunAll(); // the next frame draws the new view, with no motion
|
|
3702
3737
|
* ```
|
|
3703
3738
|
*/
|
|
3704
3739
|
rerunAll(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as ComponentValue, D as Point$2, F as AnyComponentType, I as AnyComponentValue, It as Hint, Kt as Json, O as ViewportSize, P as AnyComponent, Pt as Descriptor, Rt as Api, V as Entity, Z as ChangeHook, at as ProjectionMotion, dn as Api$5, it as NumericFields, k as Api$2, lt as ViewHandle, m as Api$3, nt as Motion, o as Events$1, rt as MotionHandle, t as Api$4, ut as Api$1, vn as Require, z as ComponentType } from "./types-
|
|
1
|
+
import { B as ComponentValue, D as Point$2, F as AnyComponentType, I as AnyComponentValue, It as Hint, Kt as Json, O as ViewportSize, P as AnyComponent, Pt as Descriptor, Rt as Api, V as Entity, Z as ChangeHook, at as ProjectionMotion, dn as Api$5, it as NumericFields, k as Api$2, lt as ViewHandle, m as Api$3, nt as Motion, o as Events$1, rt as MotionHandle, t as Api$4, ut as Api$1, vn as Require, z as ComponentType } from "./types-BMEn0tSC.mjs";
|
|
2
2
|
import { Log } from "@moku-labs/common/browser";
|
|
3
3
|
import { PluginCtx } from "@moku-labs/core";
|
|
4
4
|
|
|
@@ -834,7 +834,7 @@ type State$1 = {
|
|
|
834
834
|
* i18n plugin events.
|
|
835
835
|
*/
|
|
836
836
|
type Events = {
|
|
837
|
-
/** The current locale changed
|
|
837
|
+
/** The current locale changed, or its messages were replaced. */"i18n:locale-changed": {
|
|
838
838
|
locale: string;
|
|
839
839
|
};
|
|
840
840
|
};
|
|
@@ -960,6 +960,24 @@ type I18nApi = {
|
|
|
960
960
|
* ```
|
|
961
961
|
*/
|
|
962
962
|
locales(): readonly string[];
|
|
963
|
+
/**
|
|
964
|
+
* Swaps the compiled module of one feature in a loaded locale, for the dev hot swap. The one
|
|
965
|
+
* registered module whose keys overlap `messages` takes them, the locale is merged again and
|
|
966
|
+
* every key may warn once more. When the locale is the current one or the fallback,
|
|
967
|
+
* `i18n:locale-changed` is emitted with the current locale, so `text` re-resolves every label.
|
|
968
|
+
* A locale not loaded yet is left alone: its loader imports the new module later.
|
|
969
|
+
*
|
|
970
|
+
* @param locale - The locale of the saved `generated/strings.<locale>.ts`.
|
|
971
|
+
* @param messages - The `default` export of the new module.
|
|
972
|
+
* @throws {Error} When no registered module, or more than one, shares a key with `messages`.
|
|
973
|
+
* @example
|
|
974
|
+
* ```ts
|
|
975
|
+
* // ui's hot swap: generated/strings.ru.ts was written again with "hud.orders" as "3 заказа!".
|
|
976
|
+
* ctx.require(i18nPlugin).replace("ru", next.default); // emits i18n:locale-changed
|
|
977
|
+
* app.i18n.plain(tr("hud.orders", { n: 3 })); // "3 заказа!": text redraws the label
|
|
978
|
+
* ```
|
|
979
|
+
*/
|
|
980
|
+
replace(locale: string, messages: CompiledMessages): void;
|
|
963
981
|
};
|
|
964
982
|
/**
|
|
965
983
|
* What the kernel context offers this plugin.
|
|
@@ -1407,7 +1425,8 @@ type State = {
|
|
|
1407
1425
|
};
|
|
1408
1426
|
/**
|
|
1409
1427
|
* text plugin API, `app.text`. Two questions: how big a piece of text is, and which styles the
|
|
1410
|
-
* game registered. Everything else happens in
|
|
1428
|
+
* game registered; and one order, the dev hot swap of a styles file. Everything else happens in
|
|
1429
|
+
* the frame.
|
|
1411
1430
|
*
|
|
1412
1431
|
* @example
|
|
1413
1432
|
* ```ts
|
|
@@ -1464,6 +1483,26 @@ type TextApi = {
|
|
|
1464
1483
|
* ```
|
|
1465
1484
|
*/
|
|
1466
1485
|
styles(): readonly string[];
|
|
1486
|
+
/**
|
|
1487
|
+
* The dev hot swap of a styles file: writes every style of the map over the table. A known
|
|
1488
|
+
* name keeps the feature that owns it, a new name is added and usable at once. The fonts the
|
|
1489
|
+
* styles name are read, the measured layouts are dropped, and every label is laid out again
|
|
1490
|
+
* on the next frame and redrawn with the new style, even when its text and its style name did
|
|
1491
|
+
* not change. The game loop is woken for that frame.
|
|
1492
|
+
*
|
|
1493
|
+
* @param styles - What `defineTextStyles` returned in the saved module.
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```ts
|
|
1496
|
+
* // `ui` hot swaps a saved `hud/styles.ts`: the "hud.title" labels redraw at 64 px.
|
|
1497
|
+
* const uiStyles = defineTextStyles({
|
|
1498
|
+
* "hud.title": { font: "ui.font-body", size: 64, fill: 0xff0000 }
|
|
1499
|
+
* });
|
|
1500
|
+
*
|
|
1501
|
+
* ctx.require(textPlugin).replaceStyles(uiStyles);
|
|
1502
|
+
* ctx.require(textPlugin).measure("12", "hud.title").height; // 76.8 on the 0.6 em fallback
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
replaceStyles(styles: TextStyles): void;
|
|
1467
1506
|
};
|
|
1468
1507
|
/**
|
|
1469
1508
|
* Resolved dependency APIs.
|
|
@@ -2646,9 +2685,10 @@ type JsxState = {
|
|
|
2646
2685
|
/**
|
|
2647
2686
|
* One node of the snapshot `tree()` answers with. `rect` is natural: under a `fit` ancestor it
|
|
2648
2687
|
* is the rect before that ancestor's scale. An element with `fit: "contain"` adds `fitScale`,
|
|
2649
|
-
* the scale it is drawn at.
|
|
2650
|
-
* else the local field it writes. A windowed `scroll`
|
|
2651
|
-
* are the children of its content, and how many the
|
|
2688
|
+
* the scale it is drawn at. A `text` adds `content`: the words it draws. An `input` adds `value`:
|
|
2689
|
+
* the text being typed while it is edited, else the local field it writes. A windowed `scroll`
|
|
2690
|
+
* adds `window`: the rows that exist, which are the children of its content, and how many the
|
|
2691
|
+
* list has.
|
|
2652
2692
|
*
|
|
2653
2693
|
* @example
|
|
2654
2694
|
* ```ts
|
|
@@ -2673,6 +2713,19 @@ type UiNode = {
|
|
|
2673
2713
|
state: IsFlags;
|
|
2674
2714
|
local?: Record<string, unknown>;
|
|
2675
2715
|
fitScale?: number;
|
|
2716
|
+
/**
|
|
2717
|
+
* The words a `text` draws, as one plain string: the string `text` resolved after `tr()` and
|
|
2718
|
+
* `bind`, its tags and icons left out, else its `content` prop while that is a plain string.
|
|
2719
|
+
* Absent on any other tag and on a text that draws nothing.
|
|
2720
|
+
*
|
|
2721
|
+
* @example
|
|
2722
|
+
* ```ts
|
|
2723
|
+
* // Home in Russian: `<text key="title" content={tr("home.title")} />` under the root row.
|
|
2724
|
+
* const title = app.ui.tree().children.find(node => node.key === "title");
|
|
2725
|
+
* title?.content; // "Лесной городок"
|
|
2726
|
+
* ```
|
|
2727
|
+
*/
|
|
2728
|
+
content?: string;
|
|
2676
2729
|
value?: string;
|
|
2677
2730
|
/**
|
|
2678
2731
|
* The rows of a windowed scroll that exist and how many the list has.
|