@moku-labs/game 0.8.0 → 0.9.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 +8 -5
- package/dist/assets.d.mts +97 -33
- package/dist/assets.mjs +350 -110
- package/dist/{capture-BX5Gfoty.mjs → capture-fpd83Mi5.mjs} +384 -1
- package/dist/{commands-C1kIfOG5.d.mts → commands-DuwCxK5t.d.mts} +5 -6
- package/dist/control.d.mts +4 -4
- package/dist/control.mjs +1 -1
- package/dist/{define-BPpZcpxW.d.mts → define-B6pHpdBi.d.mts} +2 -2
- package/dist/{headless-CvamCUcR.mjs → headless-BsNdJs9W.mjs} +1 -1
- package/dist/{headless-q98SwADR.d.mts → headless-SCQXJxQf.d.mts} +1 -1
- package/dist/hot.d.mts +4 -2
- package/dist/hot.mjs +8 -6
- package/dist/index-BO9kZzY3.d.mts +1611 -0
- package/dist/index.d.mts +6 -1597
- package/dist/index.mjs +4 -34343
- package/dist/inspect.d.mts +7 -8
- package/dist/inspect.mjs +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/lint.d.mts +55 -4
- package/dist/lint.mjs +993 -40
- package/dist/project.d.mts +29 -13
- package/dist/project.mjs +986 -497
- package/dist/{run-CUPSFM85.mjs → run-CofJEdYx.mjs} +2 -2
- package/dist/{runtime-CvDZZg1S.d.mts → runtime-CdNJ0UBm.d.mts} +1 -1
- package/dist/{sources-BBUd15vQ.mjs → sources-DNnzyCYf.mjs} +1 -1
- package/dist/src-536arXjV.mjs +34644 -0
- package/dist/testing.d.mts +130 -3
- package/dist/testing.mjs +192 -3
- package/dist/{types-BWzCSRM2.d.mts → types-B0v5VVa3.d.mts} +2982 -19
- package/dist/{types-DF5kkW-C.d.mts → types-CQueODzo.d.mts} +4 -5
- package/dist/{types-CDSKa0vl.d.mts → types-DUMoYPYe.d.mts} +2 -2
- package/dist/{types-DlgsfOmW.d.mts → types-VZVWwqCg.d.mts} +49 -12
- package/dist/{types-DgdMLZnV.d.mts → types-xXfyk56Q.d.mts} +7 -8
- package/dist/{visual-DUvvPPCt.mjs → visual-dMW8iqAE.mjs} +8 -4
- package/dist/visual.d.mts +10 -11
- package/dist/visual.mjs +2 -2
- package/llms.txt +55 -18
- package/package.json +1 -1
- package/dist/memory-CvgdnsQO.mjs +0 -259
- package/dist/registry-DlpRCibU.mjs +0 -384
- package/dist/types-ERb2Y9U5.d.mts +0 -2967
package/dist/index.d.mts
CHANGED
|
@@ -1,1597 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { _ as
|
|
6
|
-
|
|
7
|
-
import { PluginCtx } from "@moku-labs/core";
|
|
8
|
-
|
|
9
|
-
//#region src/plugins/text/components.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Words on the screen: a string or a message, the style it is drawn in, and the string `text`
|
|
12
|
-
* resolved out of it. A game writes `content`, `style`, `bind`, `anchor` and `alpha`; `resolved`
|
|
13
|
-
* is engine-owned and `ui` and the tests read it. `alpha` (1 by default) fades the whole block and
|
|
14
|
-
* is patched in place, so a tween on it rebuilds nothing.
|
|
15
|
-
*/
|
|
16
|
-
declare const Text: ComponentType<TextValue>;
|
|
17
|
-
/**
|
|
18
|
-
* Shows a numeric component field of the label's own entity: read every frame, written to
|
|
19
|
-
* `Text.resolved` only when the shown string changes. The field must hold a number; the format
|
|
20
|
-
* is `"int"` (rounded) unless named. Reads the component's own name, so a renamed component
|
|
21
|
-
* cannot drift from its label.
|
|
22
|
-
*
|
|
23
|
-
* @param component - The component whose field the label shows.
|
|
24
|
-
* @param field - A numeric field of that component.
|
|
25
|
-
* @param options - How the number is shown.
|
|
26
|
-
* @returns The bind a `Text` carries.
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const Counter = component("Counter", { value: 0 });
|
|
30
|
-
*
|
|
31
|
-
* bind(Counter, "value"); // { component: "Counter", field: "value", format: "int" }
|
|
32
|
-
*
|
|
33
|
-
* // The chest timer: the time left, as minutes and seconds.
|
|
34
|
-
* Text({ style: "digits", bind: bind(Countdown, "left", { format: "mm:ss" }) });
|
|
35
|
-
* // bind is { component: "Countdown", field: "left", format: "mm:ss" }; 95 s left shows "01:35"
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare function bind<Value extends object>(component: ComponentHandle<Value>, field: BindField<Value>, options?: BindOptions): TextBind;
|
|
39
|
-
/**
|
|
40
|
-
* A moment to count down to. A game writes `until`, a moment of `clock` in epoch milliseconds;
|
|
41
|
-
* `text` keeps `left` at the time that is left, computed from one `clock.now()` per frame on the
|
|
42
|
-
* render side, and writes it only when the label bound to it changes. At zero both stay at zero.
|
|
43
|
-
* Nothing of it reaches the save.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* // The chest of the board opens at a moment of the save; clock.now() is 1_790_000_000_000.
|
|
48
|
-
* view: chest => [
|
|
49
|
-
* Countdown({ until: chest.opensAt }), // opensAt: 1_790_000_095_000
|
|
50
|
-
* Text({ style: "digits", bind: bind(Countdown, "left", { format: "mm:ss" }) })
|
|
51
|
-
* ]
|
|
52
|
-
* // after the frame that spawns it: Text.resolved is "01:35", Countdown.left is 95000
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
declare const Countdown: ComponentType<CountdownValue>;
|
|
56
|
-
/**
|
|
57
|
-
* What `label` takes: the two things every label needs, and the anchor that has a default.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* const options: LabelOptions = { text: "+5", style: "board.float", at: { x: 90, y: 180 } };
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
type LabelOptions = {
|
|
65
|
-
text: string | Message;
|
|
66
|
-
style: string;
|
|
67
|
-
at: Point;
|
|
68
|
-
anchor?: Point;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Bundles the two components a label needs, so a projection `view` reads as one line. The anchor
|
|
72
|
-
* is the point of the block that sits on the transform.
|
|
73
|
-
*
|
|
74
|
-
* @param options - The text, its style, where it sits, and which point of it sits there.
|
|
75
|
-
* @returns The `Text` and the `Transform` value, in that order.
|
|
76
|
-
* @example
|
|
77
|
-
* ```ts
|
|
78
|
-
* label({ text: "+5", style: "board.float", at: { x: 90, y: 180 } });
|
|
79
|
-
* // [Text({ content: "+5", style: "board.float", bind: undefined,
|
|
80
|
-
* // anchor: { x: 0.5, y: 0.5 }, alpha: 1, resolved: "" }),
|
|
81
|
-
* // Transform({ x: 90, y: 180, rotation: 0, scale: 1 })]
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare function label(options: LabelOptions): [ComponentValue<TextValue>, ComponentValue<TransformValue>];
|
|
85
|
-
/**
|
|
86
|
-
* Declares the text styles of a feature. The result goes under the `textStyles` key of the
|
|
87
|
-
* feature description, and `text` reads it in `onStart`.
|
|
88
|
-
*
|
|
89
|
-
* @param map - Style name to what that style looks like.
|
|
90
|
-
* @returns The registration a feature carries.
|
|
91
|
-
* @throws {Error} When a style names a wrap that is not a width and not `"none"`.
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* defineTextStyles({ "hud.digits": { font: "ui.font-digits", size: 40, fill: 0xffe082 } });
|
|
95
|
-
* // { kind: "textStyles", map: { "hud.digits": { font: "ui.font-digits", bold: undefined,
|
|
96
|
-
* // italic: undefined, size: 40, fill: 0xffe082, stroke: 0x000000, strokeWidth: 0,
|
|
97
|
-
* // letterSpacing: 0, align: "left", wrap: "none", digits: false, shadow: undefined } } }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
declare function defineTextStyles(map: Record<string, TextStyleInput>): TextStyles;
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/plugins/world/projection/define.d.ts
|
|
103
|
-
/**
|
|
104
|
-
* Types a projection: keyed items of the model turned into entities. `Item` is inferred from the
|
|
105
|
-
* return of `from` and reaches `key`, `view` and every motion hook; `layer` and `lift` stay
|
|
106
|
-
* literal, so `defineScene` can check them against the layers of the scene.
|
|
107
|
-
*
|
|
108
|
-
* @param spec - Name, layer, optional lift layer, `from`, `key`, `view` and the motion hooks.
|
|
109
|
-
* @returns The same spec, typed.
|
|
110
|
-
* @example
|
|
111
|
-
* ```ts
|
|
112
|
-
* const boardItems = projection({
|
|
113
|
-
* name: "board.items",
|
|
114
|
-
* layer: "items",
|
|
115
|
-
* from: (player: { items: { id: string }[] }) => player.items,
|
|
116
|
-
* key: item => item.id,
|
|
117
|
-
* view: () => []
|
|
118
|
-
* });
|
|
119
|
-
* boardItems.layer; // "items", the literal type, not string
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
declare function projection<const LayerName extends string, const LiftName extends string, Item, Player = Json, Session = Json>(spec: ProjectionSpec<Item, LayerName, LiftName, Player, Session>): ProjectionSpec<Item, LayerName, LiftName, Player, Session>;
|
|
123
|
-
/**
|
|
124
|
-
* The projection helper bound to one game's `player` and `session`.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```ts
|
|
128
|
-
* const bound: ProjectionFor<{ coins: number }, {}> = projection;
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
type ProjectionFor<Player, Session> = <const LayerName extends string, const LiftName extends string, Item>(spec: ProjectionSpec<Item, LayerName, LiftName, Player, Session>) => ProjectionSpec<Item, LayerName, LiftName, Player, Session>;
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/plugins/anim/index.d.ts
|
|
134
|
-
/**
|
|
135
|
-
* Anim plugin: `app.anim.play(animation, slots)`, `app.anim.finishAll()`,
|
|
136
|
-
* `app.anim.setReducedMotion(on)`.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* // Animation is text: a module next to the feature, played by a node or by a test.
|
|
141
|
-
* const coinsFly = defineAnimation("hud.coinsFly", {
|
|
142
|
-
* slots: { from: type<Target>(), to: type<Target>() },
|
|
143
|
-
* build: ({ from, to }, { at }) =>
|
|
144
|
-
* sequence(
|
|
145
|
-
* tween(from, Transform, { x: at(to).x, y: at(to).y }, { ms: 600, ease: "inCubic" }),
|
|
146
|
-
* mark("landed")
|
|
147
|
-
* )
|
|
148
|
-
* });
|
|
149
|
-
*
|
|
150
|
-
* const app = createApp({ plugins: [...screen, animPlugin, hudFeature] });
|
|
151
|
-
*
|
|
152
|
-
* app.anim.play(coinsFly, { from: purse, to: counter }).marks(); // []: the first frame is next
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
declare const animPlugin: import("@moku-labs/core").PluginInstance<"anim", Config$13, State$12, AnimApi, {
|
|
156
|
-
"anim:mark": {
|
|
157
|
-
animation: string;
|
|
158
|
-
mark: string;
|
|
159
|
-
};
|
|
160
|
-
"anim:finished": {
|
|
161
|
-
animation: string;
|
|
162
|
-
};
|
|
163
|
-
}> & Record<never, never>;
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/plugins/assets/index.d.ts
|
|
166
|
-
/**
|
|
167
|
-
* Assets plugin: `app.assets.load(bundle)`, `app.assets.texture(key)`, `app.assets.usage()`.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```ts
|
|
171
|
-
* // A game names its manifest; the graph decides from there what is loaded and when.
|
|
172
|
-
* const app = createApp({
|
|
173
|
-
* plugins: [...screen, boardFeature],
|
|
174
|
-
* pluginConfigs: { assets: { manifest: "/assets/manifest.json", textureBudgetMb: 192 } }
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* await app.start();
|
|
178
|
-
* app.assets.usage().textureMb; // 0.188, the boot tier
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
declare const assetsPlugin: import("@moku-labs/core").PluginInstance<"assets", Config$7, State$6, Api$4, {
|
|
182
|
-
"assets:bundle-loaded": {
|
|
183
|
-
bundle: string;
|
|
184
|
-
tier: Tier;
|
|
185
|
-
mb: number;
|
|
186
|
-
reason: LoadReason;
|
|
187
|
-
};
|
|
188
|
-
"assets:bundle-progress": {
|
|
189
|
-
bundle: string;
|
|
190
|
-
loaded: number;
|
|
191
|
-
total: number;
|
|
192
|
-
};
|
|
193
|
-
"assets:bundle-unloaded": {
|
|
194
|
-
bundle: string;
|
|
195
|
-
tier: Tier;
|
|
196
|
-
mb: number;
|
|
197
|
-
reason: "budget" | "request";
|
|
198
|
-
keys: readonly string[];
|
|
199
|
-
};
|
|
200
|
-
}> & Record<never, never>;
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/plugins/audio/index.d.ts
|
|
203
|
-
/**
|
|
204
|
-
* Audio plugin: `app.audio`, the handlers of the effect kinds `sfx` and `music`, and the three
|
|
205
|
-
* buses a game drives from its player state.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* // A game composes it next to the screen set and points it at the player's settings.
|
|
210
|
-
* createApp({
|
|
211
|
-
* plugins: [...screen, audioPlugin, settingsFeature],
|
|
212
|
-
* pluginConfigs: { audio: { volumes: player => player.settings.audio } }
|
|
213
|
-
* });
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
declare const audioPlugin: import("@moku-labs/core").PluginInstance<"audio", Config$14, State$13, AudioApi, {}> & Record<never, never>;
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/plugins/clock/index.d.ts
|
|
219
|
-
/**
|
|
220
|
-
* Clock plugin: `app.clock.now()`, `app.clock.scheduleAt(moment)`, `app.clock.onElapsed(fn)`.
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```ts
|
|
224
|
-
* // A game plugin that needs trusted time declares the dependency and asks for the API.
|
|
225
|
-
* const energyPlugin = createPlugin("energy", {
|
|
226
|
-
* depends: [clockPlugin],
|
|
227
|
-
* api: ctx => ({ fullAt: (missing: number) => ctx.require(clockPlugin).now() + missing * 60_000 })
|
|
228
|
-
* });
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
declare const clockPlugin: import("@moku-labs/core").PluginInstance<"clock", Config$1, State$1, Api, {}> & Record<never, never>;
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region src/plugins/effects/index.d.ts
|
|
234
|
-
/**
|
|
235
|
-
* Effects plugin: `app.effects.stats()`; the `Emitter` component and every filter component do
|
|
236
|
-
* the rest as data on entities.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```ts
|
|
240
|
-
* // A game composes it next to the screen set; its features bring the emitters and filters.
|
|
241
|
-
* const app = createApp({
|
|
242
|
-
* plugins: [...screen, effectsPlugin, boardFeature],
|
|
243
|
-
* pluginConfigs: { renderer: { mount: "#game" }, effects: { maxPasses: 16 } }
|
|
244
|
-
* });
|
|
245
|
-
* app.effects.stats(); // { particles: 0, emitters: 0, filters: 0, renderPasses: 0 }: nothing runs before start
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
declare const effectsPlugin: import("@moku-labs/core").PluginInstance<"effects", Config$16, State$16, EffectsApi, {}> & Record<never, never>;
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/plugins/flow/index.d.ts
|
|
251
|
-
/**
|
|
252
|
-
* Flow plugin: `app.flow.run()`, `app.flow.gate.answer(...)`, `app.flow.fx.handle(...)`.
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* // The game starts the graph itself: an awaited loop in onStart would never let start() resolve.
|
|
257
|
-
* createApp({
|
|
258
|
-
* pluginConfigs: { flow: { mainFlow, safeNode: "home" } },
|
|
259
|
-
* onStart: ctx => {
|
|
260
|
-
* ctx.flow.run().catch(showFatal);
|
|
261
|
-
* }
|
|
262
|
-
* });
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
declare const flowPlugin: import("@moku-labs/core").PluginInstance<"flow", Config$2, State$2, Api$1, {
|
|
266
|
-
"flow:edge": {
|
|
267
|
-
flow: string;
|
|
268
|
-
node: string;
|
|
269
|
-
outcome: string;
|
|
270
|
-
payload: Json;
|
|
271
|
-
next: string;
|
|
272
|
-
patches: {
|
|
273
|
-
doc: Patch[];
|
|
274
|
-
session: Patch[];
|
|
275
|
-
};
|
|
276
|
-
index: number;
|
|
277
|
-
now: number;
|
|
278
|
-
};
|
|
279
|
-
"flow:rest": {
|
|
280
|
-
path: string;
|
|
281
|
-
checkpoint: boolean;
|
|
282
|
-
};
|
|
283
|
-
"flow:error": {
|
|
284
|
-
path: string;
|
|
285
|
-
error: unknown;
|
|
286
|
-
rolledBackTo: string;
|
|
287
|
-
retry: boolean;
|
|
288
|
-
};
|
|
289
|
-
}> & Record<never, never>;
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/plugins/i18n/index.d.ts
|
|
292
|
-
/**
|
|
293
|
-
* I18n plugin: `app.i18n.format(tr("hud.orders", { n: 3 }))`, and `tr` for the game.
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* ```ts
|
|
297
|
-
* // A feature ships its compiled modules; the settings screen switches between them.
|
|
298
|
-
* export const hudFeature = defineFeature("hud", {
|
|
299
|
-
* projections: [hud],
|
|
300
|
-
* strings: { ru: ruStrings, en: () => import("./generated/strings.en") }
|
|
301
|
-
* });
|
|
302
|
-
*
|
|
303
|
-
* await app.i18n.setLocale("en"); // text re-resolves every message on i18n:locale-changed
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
declare const i18nPlugin: import("@moku-labs/core").PluginInstance<"i18n", Config$10, State$9, I18nApi, {
|
|
307
|
-
"i18n:locale-changed": {
|
|
308
|
-
locale: string;
|
|
309
|
-
};
|
|
310
|
-
}> & Record<never, never>;
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/plugins/input/index.d.ts
|
|
313
|
-
/**
|
|
314
|
-
* Input plugin: `app.input.tap(target)`, `app.input.drag(from, to)`.
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```ts
|
|
318
|
-
* // A view declares its behaviour; the engine owns the drag and the way home.
|
|
319
|
-
* const boardItems = projection({
|
|
320
|
-
* name: "board.items",
|
|
321
|
-
* layer: "items",
|
|
322
|
-
* from: (player: Player) => player.items,
|
|
323
|
-
* key: (item: Item) => item.id,
|
|
324
|
-
* view: (item: Item) => [
|
|
325
|
-
* Draggable({ payload: { from: item.cell } }),
|
|
326
|
-
* DropTarget({ intent: "merge", payload: { to: item.cell } })
|
|
327
|
-
* ]
|
|
328
|
-
* });
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
declare const inputPlugin: import("@moku-labs/core").PluginInstance<"input", Config$11, State$10, InputApi, {}> & Record<never, never>;
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/plugins/lifecycle/index.d.ts
|
|
334
|
-
/**
|
|
335
|
-
* Lifecycle plugin: `app.lifecycle.push(reason)`, `app.lifecycle.pop(reason)`.
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* ```ts
|
|
339
|
-
* // A game plugin that reacts to the pause declares the dependency and hooks the event.
|
|
340
|
-
* const musicPlugin = createPlugin("music", {
|
|
341
|
-
* depends: [lifecyclePlugin],
|
|
342
|
-
* hooks: () => ({ "lifecycle:changed": ({ paused }) => music.setMuted(paused) })
|
|
343
|
-
* });
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
346
|
-
declare const lifecyclePlugin: import("@moku-labs/core").PluginInstance<"lifecycle", Config$3, State$3, Api$2, {
|
|
347
|
-
"lifecycle:changed": {
|
|
348
|
-
reason: PauseReason;
|
|
349
|
-
action: "push" | "pop";
|
|
350
|
-
reasons: readonly PauseReason[];
|
|
351
|
-
paused: boolean;
|
|
352
|
-
resumed: boolean;
|
|
353
|
-
};
|
|
354
|
-
}> & Record<never, never>;
|
|
355
|
-
//#endregion
|
|
356
|
-
//#region src/plugins/model/index.d.ts
|
|
357
|
-
/**
|
|
358
|
-
* Model plugin: `app.model.store`, `app.model.rng`.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```ts
|
|
362
|
-
* // A game plugin that draws from committed state declares the dependency and reads the snapshot.
|
|
363
|
-
* const hudPlugin = createPlugin("hud", {
|
|
364
|
-
* depends: [modelPlugin],
|
|
365
|
-
* hooks: ctx => ({
|
|
366
|
-
* "model:committed": () => drawCoins(ctx.require(modelPlugin).store.snapshot().player)
|
|
367
|
-
* })
|
|
368
|
-
* });
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
declare const modelPlugin: import("@moku-labs/core").PluginInstance<"model", Config$4, State$4, {
|
|
372
|
-
store: StoreApi;
|
|
373
|
-
rng: RngApi;
|
|
374
|
-
}, {
|
|
375
|
-
"model:committed": {
|
|
376
|
-
roots: readonly Root[];
|
|
377
|
-
cause: "edge" | "rollback" | "restore" | "load";
|
|
378
|
-
};
|
|
379
|
-
}> & Record<never, never>;
|
|
380
|
-
declare namespace types_d_exports$10 {
|
|
381
|
-
export { BackResult, Config, HapticKind, KernelSlice, LifecycleChanged, PlatformApi, PlatformProvider, ProviderMethod, State };
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* The seam a game fills, usually from `@moku-labs/system` in its own bridge. The engine never
|
|
385
|
-
* imports a native package: the provider is built in the application layer. Every `on*` returns
|
|
386
|
-
* its remover, which the plugin calls on stop.
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* ```ts
|
|
390
|
-
* // A headless test drives the plugin with a fake of six functions.
|
|
391
|
-
* const ticks: string[] = [];
|
|
392
|
-
* const provider: PlatformProvider = {
|
|
393
|
-
* onPause: () => () => undefined,
|
|
394
|
-
* onResume: () => () => undefined,
|
|
395
|
-
* onBack: () => () => undefined,
|
|
396
|
-
* haptic: kind => ticks.push(kind),
|
|
397
|
-
* keepAwake: () => undefined,
|
|
398
|
-
* exit: () => undefined
|
|
399
|
-
* };
|
|
400
|
-
* createApp({ plugins: [...screen, platformPlugin], pluginConfigs: { platform: { provider } } });
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
type PlatformProvider = {
|
|
404
|
-
/** Calls `fn` when the app goes to the background. Returns the remover. */onPause(fn: () => void): () => void; /** Calls `fn` when the app comes back to the foreground. Returns the remover. */
|
|
405
|
-
onResume(fn: () => void): () => void;
|
|
406
|
-
/**
|
|
407
|
-
* Calls `fn` on every press of the system Back button. `fn` returns whether the engine took the
|
|
408
|
-
* press; `false` lets the provider do its default, which on Android leaves the app.
|
|
409
|
-
*/
|
|
410
|
-
onBack(fn: () => boolean): () => void; /** Plays one haptic tick. */
|
|
411
|
-
haptic(kind: HapticKind): void; /** Keeps the screen on while `on` is true. */
|
|
412
|
-
keepAwake(on: boolean): void; /** Leaves the app. */
|
|
413
|
-
exit(): void;
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* What took one Back press: the Escape button of the top popup, the intent `back` of the resting
|
|
417
|
-
* node, the provider leaving the app, or nothing at all because the app has no provider.
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* ```ts
|
|
421
|
-
* // Home rests and does not list "back": the provider leaves the app.
|
|
422
|
-
* const result: BackResult = app.platform.back(); // "exit"
|
|
423
|
-
* ```
|
|
424
|
-
*/
|
|
425
|
-
type BackResult = "popup" | "intent" | "exit" | "none";
|
|
426
|
-
/**
|
|
427
|
-
* What a game sets on `pluginConfigs.platform`: the provider seam its application layer fills
|
|
428
|
-
* from the native shell, and whether the screen stays on while the game runs.
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* ```ts
|
|
432
|
-
* // app.ts of a game in the native shell; `provider` is the game's own bridge to the shell.
|
|
433
|
-
* const config: Platform.Config = { provider, keepAwake: true };
|
|
434
|
-
* config.keepAwake; // true
|
|
435
|
-
* ```
|
|
436
|
-
*/
|
|
437
|
-
type Config = {
|
|
438
|
-
/** The provider. `undefined`, the default: the plugin is inert, as on the web without a bridge and in headless tests. */provider: PlatformProvider | undefined; /** Keep the screen on while the game runs. Default `false`. */
|
|
439
|
-
keepAwake: boolean;
|
|
440
|
-
};
|
|
441
|
-
/**
|
|
442
|
-
* platform plugin state.
|
|
443
|
-
*/
|
|
444
|
-
type State = {
|
|
445
|
-
/** Whether `provider.keepAwake(true)` is in force. */awake: boolean; /** Removers of the provider subscriptions and of the haptic handler, called on stop. */
|
|
446
|
-
offs: Array<() => void>; /** Haptic kinds already warned about in a dev build, so each warns once. */
|
|
447
|
-
warned: Set<string>;
|
|
448
|
-
};
|
|
449
|
-
/**
|
|
450
|
-
* platform plugin API, `app.platform`. The rest of the plugin runs on its own: the provider's
|
|
451
|
-
* pause, resume and Back press, the `haptic` effect and keep-awake need no call.
|
|
452
|
-
*
|
|
453
|
-
* @example
|
|
454
|
-
* ```ts
|
|
455
|
-
* // An e2e test plays the Android Back button on Home, which rests without "back".
|
|
456
|
-
* app.platform.back(); // "exit": the provider leaves the app
|
|
457
|
-
* ```
|
|
458
|
-
*/
|
|
459
|
-
type PlatformApi = {
|
|
460
|
-
/**
|
|
461
|
-
* Runs the Back chain once, exactly as a press of the system Back button does. The first step
|
|
462
|
-
* that takes the press wins: Escape taps the `escape` button of the top ui root (`"popup"`),
|
|
463
|
-
* then the intent `back` is answered to the resting node (`"intent"`), and otherwise the
|
|
464
|
-
* provider leaves the app (`"exit"`). While the graph moves between nodes the gate is closed and
|
|
465
|
-
* holds the answer for one frame, so the press answers `"intent"` and never leaves the app.
|
|
466
|
-
* Escape also ends the editing of a ui text field, so a
|
|
467
|
-
* press while a field is edited ends the edit and answers `"popup"`. Without a provider nothing
|
|
468
|
-
* is pressed and the answer is `"none"`.
|
|
469
|
-
*
|
|
470
|
-
* @returns What took the press.
|
|
471
|
-
* @example
|
|
472
|
-
* ```ts
|
|
473
|
-
* // An e2e test plays the Android Back button over the settings popup, then on Home.
|
|
474
|
-
* app.platform.back(); // "popup": the settings popup was open and closed like Escape
|
|
475
|
-
* // ...the runner settles on Home, which does not list "back"...
|
|
476
|
-
* app.platform.back(); // "exit": the provider leaves the app
|
|
477
|
-
* ```
|
|
478
|
-
*/
|
|
479
|
-
back(): BackResult;
|
|
480
|
-
};
|
|
481
|
-
/**
|
|
482
|
-
* What the kernel context offers the files of the plugin.
|
|
483
|
-
*
|
|
484
|
-
* `platform` owns no event, so `emit` is the kernel's and never called here.
|
|
485
|
-
*/
|
|
486
|
-
type KernelSlice = PluginCtx<Config, State> & {
|
|
487
|
-
readonly global: object;
|
|
488
|
-
readonly log: Log.LogApi;
|
|
489
|
-
readonly require: Require;
|
|
490
|
-
};
|
|
491
|
-
/**
|
|
492
|
-
* Payload of the `lifecycle:changed` hook: the pause that releases keep-awake.
|
|
493
|
-
*/
|
|
494
|
-
type LifecycleChanged = Events["lifecycle:changed"];
|
|
495
|
-
/**
|
|
496
|
-
* A method of the provider, named in the log when it throws.
|
|
497
|
-
*/
|
|
498
|
-
type ProviderMethod = keyof PlatformProvider;
|
|
499
|
-
//#endregion
|
|
500
|
-
//#region src/plugins/platform/index.d.ts
|
|
501
|
-
/**
|
|
502
|
-
* Platform plugin: `app.platform`, the handler of the effect kind `haptic`, and the provider's
|
|
503
|
-
* pause, resume and Back press. Inert without a provider.
|
|
504
|
-
*
|
|
505
|
-
* @example
|
|
506
|
-
* ```ts
|
|
507
|
-
* // A game in the native shell composes it last and hands it the bridge it built.
|
|
508
|
-
* createApp({
|
|
509
|
-
* plugins: [...screen, effectsPlugin, audioPlugin, platformPlugin, ...features],
|
|
510
|
-
* pluginConfigs: { platform: { provider: fromSystem(system), keepAwake: true } }
|
|
511
|
-
* });
|
|
512
|
-
* ```
|
|
513
|
-
*/
|
|
514
|
-
declare const platformPlugin: import("@moku-labs/core").PluginInstance<"platform", Config, State, PlatformApi, {}> & Record<never, never>;
|
|
515
|
-
//#endregion
|
|
516
|
-
//#region src/plugins/renderer/index.d.ts
|
|
517
|
-
/**
|
|
518
|
-
* Renderer plugin: `app.renderer.host.ready()`, `app.renderer.viewport.size()`,
|
|
519
|
-
* `app.renderer.sync.hitTest(...)`.
|
|
520
|
-
*
|
|
521
|
-
* @example
|
|
522
|
-
* ```ts
|
|
523
|
-
* // A game with a screen names the element the canvas goes into. Nothing else is configured.
|
|
524
|
-
* const app = createApp({
|
|
525
|
-
* plugins: [...screen, boardFeature],
|
|
526
|
-
* pluginConfigs: { renderer: { mount: "#game" } }
|
|
527
|
-
* });
|
|
528
|
-
*
|
|
529
|
-
* await app.start();
|
|
530
|
-
* app.renderer.host.kind(); // "webgpu" in Chrome, "webgl" on an older device
|
|
531
|
-
* ```
|
|
532
|
-
*/
|
|
533
|
-
declare const rendererPlugin: import("@moku-labs/core").PluginInstance<"renderer", Config$8, State$7, Api$5, {
|
|
534
|
-
"renderer:device-lost": {
|
|
535
|
-
kind: "webgpu" | "webgl";
|
|
536
|
-
reason: string;
|
|
537
|
-
};
|
|
538
|
-
}> & Record<never, never>;
|
|
539
|
-
//#endregion
|
|
540
|
-
//#region src/plugins/scenes/index.d.ts
|
|
541
|
-
/**
|
|
542
|
-
* Scenes plugin: `app.scenes.current()`, and `defineScene` for the game.
|
|
543
|
-
*
|
|
544
|
-
* @example
|
|
545
|
-
* ```ts
|
|
546
|
-
* // features/board/view/scene.ts, and the node that shows it.
|
|
547
|
-
* export const boardScene = defineScene("board", {
|
|
548
|
-
* bundle: "board",
|
|
549
|
-
* layers: { cells: {}, items: { sort: "y" }, lifted: {} },
|
|
550
|
-
* projections: [boardCells, boardItems]
|
|
551
|
-
* });
|
|
552
|
-
*
|
|
553
|
-
* export const awaitIntent = defineNode({ scene: "board", rest: true, outcomes: { merge: type() } });
|
|
554
|
-
* ```
|
|
555
|
-
*/
|
|
556
|
-
declare const scenesPlugin: import("@moku-labs/core").PluginInstance<"scenes", Record<string, never>, State$14, ScenesApi, {
|
|
557
|
-
"scenes:changed": {
|
|
558
|
-
from: string | undefined;
|
|
559
|
-
to: string;
|
|
560
|
-
music: string | undefined;
|
|
561
|
-
};
|
|
562
|
-
}> & Record<never, never>;
|
|
563
|
-
//#endregion
|
|
564
|
-
//#region src/plugins/text/index.d.ts
|
|
565
|
-
/**
|
|
566
|
-
* Text plugin: `app.text.measure(...)`, the `Text` component and the helpers `label` and
|
|
567
|
-
* `defineTextStyles` a game writes.
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* ```ts
|
|
571
|
-
* // A feature brings its styles; a projection puts a label over an item.
|
|
572
|
-
* export const hudStyles = defineTextStyles({
|
|
573
|
-
* "hud.digits": { font: "ui.font-digits", size: 40, fill: 0xffe082, digits: true }
|
|
574
|
-
* });
|
|
575
|
-
*
|
|
576
|
-
* const app = createApp({ plugins: [...screen, hudFeature] });
|
|
577
|
-
*
|
|
578
|
-
* app.text.styles(); // ["body", "digits", "hud.digits"]
|
|
579
|
-
* ```
|
|
580
|
-
*/
|
|
581
|
-
declare const textPlugin: import("@moku-labs/core").PluginInstance<"text", Config$12, State$11, TextApi, {}> & Record<never, never>;
|
|
582
|
-
//#endregion
|
|
583
|
-
//#region src/plugins/time/index.d.ts
|
|
584
|
-
/**
|
|
585
|
-
* Time plugin: `app.time.onFrame(phase, fn)`, `app.time.step(dt)`.
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* ```ts
|
|
589
|
-
* // A game plugin with frame work declares the dependency and registers a callback on start.
|
|
590
|
-
* const sparklePlugin = createPlugin("sparkle", {
|
|
591
|
-
* depends: [timePlugin],
|
|
592
|
-
* onStart: ctx => void ctx.require(timePlugin).onFrame("animate", time => advance(time.delta))
|
|
593
|
-
* });
|
|
594
|
-
* ```
|
|
595
|
-
*/
|
|
596
|
-
declare const timePlugin: import("@moku-labs/core").PluginInstance<"time", Config$5, State$5, Api$3, {}> & Record<never, never>;
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region src/plugins/ui/index.d.ts
|
|
599
|
-
/**
|
|
600
|
-
* Ui plugin: `app.ui.tree()`, `app.ui.find(...)`, `app.ui.lint()`, `app.ui.fill(...)`, the
|
|
601
|
-
* text field `<input local>`, the components `Box` and
|
|
602
|
-
* `LocalWrite`, and the helpers `defineComponent`, `defineStyle`, `defineTokens` and `popup`.
|
|
603
|
-
*
|
|
604
|
-
* @example
|
|
605
|
-
* ```ts
|
|
606
|
-
* // A headless test reads the HUD and taps the button the popup opened.
|
|
607
|
-
* const app = createApp({ plugins: [...screen, uiPlugin, hudFeature] });
|
|
608
|
-
*
|
|
609
|
-
* app.ui.tree().type; // "row"
|
|
610
|
-
* app.input.tap(app.ui.find("claim") ?? 0);
|
|
611
|
-
* ```
|
|
612
|
-
*/
|
|
613
|
-
declare const uiPlugin: import("@moku-labs/core").PluginInstance<"ui", Config$15, State$15, UiApi, {}> & Record<never, never>;
|
|
614
|
-
//#endregion
|
|
615
|
-
//#region src/plugins/world/index.d.ts
|
|
616
|
-
/**
|
|
617
|
-
* World plugin: `app.world.ecs.query(...)`, `app.world.projection.mount(...)`.
|
|
618
|
-
*
|
|
619
|
-
* @example
|
|
620
|
-
* ```ts
|
|
621
|
-
* // A test drives the screen without a browser: mount, commit, step frames.
|
|
622
|
-
* const app = createApp({ plugins: [worldPlugin, boardFeature] });
|
|
623
|
-
*
|
|
624
|
-
* app.world.projection.setLayers([{ name: "items", sort: "y" }]);
|
|
625
|
-
* app.world.projection.mount(["board.items"], { kind: "plugin", name: "test" });
|
|
626
|
-
* app.world.projection.entityOf("board.items", "i7"); // 1048576
|
|
627
|
-
* ```
|
|
628
|
-
*/
|
|
629
|
-
declare const worldPlugin: import("@moku-labs/core").PluginInstance<"world", Config$9, State$8, Api$6, {
|
|
630
|
-
"world:reconciled": {
|
|
631
|
-
mode: "play" | "direct";
|
|
632
|
-
projections: number;
|
|
633
|
-
entered: number;
|
|
634
|
-
changed: number;
|
|
635
|
-
exited: number;
|
|
636
|
-
revived: number;
|
|
637
|
-
queued: number;
|
|
638
|
-
hintsRouted: number;
|
|
639
|
-
hintsDropped: number;
|
|
640
|
-
};
|
|
641
|
-
}> & Record<never, never>;
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region src/plugins/flow/feature.d.ts
|
|
644
|
-
/**
|
|
645
|
-
* Turns a feature description into a plugin that registers it with `flow.features` in `onInit`.
|
|
646
|
-
* Throws for a name that is reserved or already a plugin. The plugin carries `logicOnly`: the
|
|
647
|
-
* same plugin built from the V1 keys of the description, for headless tests.
|
|
648
|
-
*
|
|
649
|
-
* @param name - Feature name. Shares the namespace with plugin names.
|
|
650
|
-
* @param description - What the feature brings: nodes, flows, slot contributions.
|
|
651
|
-
* @returns The feature plugin, with its `logicOnly` twin.
|
|
652
|
-
* @throws {Error} When the name is reserved or belongs to an engine plugin.
|
|
653
|
-
* @example
|
|
654
|
-
* ```ts
|
|
655
|
-
* // The reward popup is a feature: the main flow only declares slot("afterOrder").
|
|
656
|
-
* export const rewardFeature = defineFeature("reward", {
|
|
657
|
-
* flows: [rewardFlow],
|
|
658
|
-
* contribute: { afterOrder: { flow: rewardFlow, order: 10 } }
|
|
659
|
-
* });
|
|
660
|
-
* createApp({ plugins: [rewardFeature] }); // a headless test passes rewardFeature.logicOnly
|
|
661
|
-
* ```
|
|
662
|
-
*/
|
|
663
|
-
declare function defineFeature(name: string, description: FeatureDescription): FeaturePlugin;
|
|
664
|
-
//#endregion
|
|
665
|
-
//#region src/plugins/flow/fx/descriptors.d.ts
|
|
666
|
-
/**
|
|
667
|
-
* Creates a fire-and-forget cosmetic descriptor for `fx.emit`. It is dispatched only after the
|
|
668
|
-
* commit of its transaction and dropped in fast mode.
|
|
669
|
-
*
|
|
670
|
-
* @param kind - Effect kind a handler is registered for.
|
|
671
|
-
* @param payload - Plain JSON for the handler.
|
|
672
|
-
* @returns The hint as plain data.
|
|
673
|
-
* @example
|
|
674
|
-
* ```ts
|
|
675
|
-
* // Inside a node body: sparkle on the merged cell, shown once the edge has committed.
|
|
676
|
-
* fx.emit(hint("sparkle", { cell: "c3" }));
|
|
677
|
-
* // hint("sparkle", { cell: "c3" }) is { kind: "sparkle", payload: { cell: "c3" }, hint: true }
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
declare function hint(kind: string, payload?: Json): Hint;
|
|
681
|
-
/**
|
|
682
|
-
* Creates the awaited effect that asks the clock for one `elapsed` at this moment. `undefined`
|
|
683
|
-
* means nothing is due and leaves the `moment` key out, so the descriptor stays plain JSON. Its
|
|
684
|
-
* handler runs in fast mode too.
|
|
685
|
-
*
|
|
686
|
-
* @param moment - Epoch milliseconds of the next due timer, or `undefined`.
|
|
687
|
-
* @returns The descriptor a node awaits.
|
|
688
|
-
* @example
|
|
689
|
-
* ```ts
|
|
690
|
-
* // Inside a node body, after the rules changed a timer: ask for the next `elapsed`.
|
|
691
|
-
* await fx(schedule(1_790_000_060_000)); // payload: { moment: 1790000060000 }
|
|
692
|
-
* await fx(schedule(undefined)); // payload: {}, the pending timer is cancelled
|
|
693
|
-
* ```
|
|
694
|
-
*/
|
|
695
|
-
declare function schedule(moment: number | undefined): Descriptor;
|
|
696
|
-
/**
|
|
697
|
-
* Creates the tutorial descriptor: it narrows the gate to one answer until the node exits. Its
|
|
698
|
-
* visual part (`target`, highlight, hand, text) is drawn by `ui`, which dims the screen and cuts
|
|
699
|
-
* a hole over the target element. The highlight list and the target are copied, so a later change
|
|
700
|
-
* of the caller's objects cannot reach the descriptor.
|
|
701
|
-
*
|
|
702
|
-
* @param options - The allowed answer and the visual hints.
|
|
703
|
-
* @returns The descriptor a node awaits.
|
|
704
|
-
* @example
|
|
705
|
-
* ```ts
|
|
706
|
-
* // A tutorial node: the popup lists two intents, the guide lets only "ok" through.
|
|
707
|
-
* await fx(guide({ allow: { intent: "ok" }, target: { projection: "hud", key: "play" } }));
|
|
708
|
-
* await fx({ kind: "popup", answers: ["ok", "cancel"] });
|
|
709
|
-
* // app.flow.gate.answer({ intent: "cancel" }) is false until the node exits
|
|
710
|
-
* ```
|
|
711
|
-
*/
|
|
712
|
-
declare function guide(options: GuideOptions): Descriptor;
|
|
713
|
-
//#endregion
|
|
714
|
-
//#region src/plugins/world/ecs/define.d.ts
|
|
715
|
-
/**
|
|
716
|
-
* Declares a component type. The defaults give the TypeScript type, the JSON shape and the
|
|
717
|
-
* inspector schema; the name is the storage key and the key of `motion.change`.
|
|
718
|
-
*
|
|
719
|
-
* @param name - Storage name, unique per world.
|
|
720
|
-
* @param defaults - Every field with its default value. Plain JSON only.
|
|
721
|
-
* @param options - The fields a plugin owns: a projection view neither writes nor corrects them.
|
|
722
|
-
* @param options.owned - Names of the owned fields.
|
|
723
|
-
* @returns A callable component type.
|
|
724
|
-
* @example
|
|
725
|
-
* ```ts
|
|
726
|
-
* const Item = component("Item", { kind: "", level: 1 });
|
|
727
|
-
* Item({ level: 2 }); // { type: Item, value: { kind: "", level: 2 } }
|
|
728
|
-
* Item({ level: 2 }).type.componentName; // "Item", the storage key
|
|
729
|
-
*
|
|
730
|
-
* // A caption whose drawn string is written by the plugin that draws it.
|
|
731
|
-
* const Caption = component("Caption", { text: "", shown: "" }, { owned: ["shown"] });
|
|
732
|
-
* Caption.owned; // ["shown"]
|
|
733
|
-
* ```
|
|
734
|
-
*/
|
|
735
|
-
declare function component<Value extends object>(name: string, defaults: Value, options?: {
|
|
736
|
-
owned?: ReadonlyArray<keyof Value & string>;
|
|
737
|
-
}): ComponentType<Value>;
|
|
738
|
-
/**
|
|
739
|
-
* Declares a tag: a component with no data, stored as `true`.
|
|
740
|
-
*
|
|
741
|
-
* @param name - Storage name, unique per world.
|
|
742
|
-
* @returns A callable tag type.
|
|
743
|
-
* @example
|
|
744
|
-
* ```ts
|
|
745
|
-
* const Held = tag("Held");
|
|
746
|
-
* Held(); // { type: Held, value: true }
|
|
747
|
-
* Held().type.componentName; // "Held"
|
|
748
|
-
* ```
|
|
749
|
-
*/
|
|
750
|
-
declare function tag(name: string): TagType;
|
|
751
|
-
/**
|
|
752
|
-
* Declares a resource: one mutable object per world, created from a deep clone of the defaults
|
|
753
|
-
* on first read.
|
|
754
|
-
*
|
|
755
|
-
* @param name - Storage name, unique per world.
|
|
756
|
-
* @param defaults - The value a fresh world starts with.
|
|
757
|
-
* @returns The resource type.
|
|
758
|
-
* @example
|
|
759
|
-
* ```ts
|
|
760
|
-
* const Pointer = resource("Pointer", { x: 0, y: 0, down: false });
|
|
761
|
-
* Pointer.defaults; // { x: 0, y: 0, down: false }
|
|
762
|
-
* ```
|
|
763
|
-
*/
|
|
764
|
-
declare function resource<Value extends object>(name: string, defaults: Value): ResourceType<Value>;
|
|
765
|
-
/**
|
|
766
|
-
* Marks a query term as written. The only effect is change detection: every entity the query
|
|
767
|
-
* yields is marked changed for this component.
|
|
768
|
-
*
|
|
769
|
-
* @param componentType - The component the system writes.
|
|
770
|
-
* @returns The marked term.
|
|
771
|
-
* @example
|
|
772
|
-
* ```ts
|
|
773
|
-
* const Transform = component("Transform", { x: 0, y: 0 });
|
|
774
|
-
* mut(Transform).kind; // "mut"
|
|
775
|
-
* ```
|
|
776
|
-
*/
|
|
777
|
-
declare function mut<Value extends object>(componentType: ComponentHandle<Value>): Mut<Value>;
|
|
778
|
-
/**
|
|
779
|
-
* Types a system definition. It returns the same plain object; the work is the type, which reads
|
|
780
|
-
* the query tuple and types the first argument of `run`.
|
|
781
|
-
*
|
|
782
|
-
* @param definition - Name, phase, query and the run function.
|
|
783
|
-
* @returns The same definition, typed.
|
|
784
|
-
* @example
|
|
785
|
-
* ```ts
|
|
786
|
-
* const Transform = component("Transform", { x: 0, y: 0 });
|
|
787
|
-
* const drift = system({
|
|
788
|
-
* name: "drift",
|
|
789
|
-
* phase: "animate",
|
|
790
|
-
* query: [mut(Transform)],
|
|
791
|
-
* run: entities => {
|
|
792
|
-
* for (const [, transform] of entities) transform.x += 1;
|
|
793
|
-
* }
|
|
794
|
-
* });
|
|
795
|
-
* drift.phase; // "animate"
|
|
796
|
-
* ```
|
|
797
|
-
*/
|
|
798
|
-
declare function system<const Terms extends readonly QueryTerm[]>(definition: SystemDefinition<Terms>): SystemDefinition<Terms>;
|
|
799
|
-
/**
|
|
800
|
-
* The layer a view is drawn in. Written only by the projection; a `view` that returns it is
|
|
801
|
-
* logged and the value ignored.
|
|
802
|
-
*/
|
|
803
|
-
declare const Layer: ComponentType<{
|
|
804
|
-
name: string;
|
|
805
|
-
}>;
|
|
806
|
-
/**
|
|
807
|
-
* Explicit draw order inside a layer sorted by `"order"`.
|
|
808
|
-
*/
|
|
809
|
-
declare const Order: ComponentType<{
|
|
810
|
-
value: number;
|
|
811
|
-
}>;
|
|
812
|
-
/**
|
|
813
|
-
* The view is in the despawn queue: still drawn, never hit-tested.
|
|
814
|
-
*/
|
|
815
|
-
declare const Exiting: TagType;
|
|
816
|
-
/**
|
|
817
|
-
* The element description of a screen: a projection whose `view` returns one node gets it wrapped
|
|
818
|
-
* as this component, and `ui` reconciles the node into child entities. The node is a foreign
|
|
819
|
-
* object, so the world diffs it by identity and `snapshot()` leaves it out.
|
|
820
|
-
*/
|
|
821
|
-
declare const Tree: ComponentType<{
|
|
822
|
-
node: DescriptionNode;
|
|
823
|
-
}>;
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region src/plugins/input/components.d.ts
|
|
826
|
-
/**
|
|
827
|
-
* A gesture that names an intent. `payload` is a plain JSON object of model keys, never an
|
|
828
|
-
* entity id: the flow graph reads it as the payload of the answer.
|
|
829
|
-
*
|
|
830
|
-
* @example
|
|
831
|
-
* ```ts
|
|
832
|
-
* const value: IntentValue = { intent: "merge", payload: { to: "c3" } };
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
835
|
-
type IntentValue = {
|
|
836
|
-
intent: string;
|
|
837
|
-
payload: Json;
|
|
838
|
-
};
|
|
839
|
-
/**
|
|
840
|
-
* A view that can be carried. It names no intent: the drop target does. `carry` lists the
|
|
841
|
-
* projection keys of views of the same projection that ride along on top of it, such as the cards
|
|
842
|
-
* that lie on a solitaire card.
|
|
843
|
-
*
|
|
844
|
-
* @example
|
|
845
|
-
* ```ts
|
|
846
|
-
* const value: CarryValue = { payload: { from: "c7" }, carry: ["c8", "c9"] };
|
|
847
|
-
* ```
|
|
848
|
-
*/
|
|
849
|
-
type CarryValue = {
|
|
850
|
-
payload: Json;
|
|
851
|
-
carry: readonly string[];
|
|
852
|
-
};
|
|
853
|
-
/**
|
|
854
|
-
* Where the one pointer is, in reference units. `justPressed` and `justReleased` are true for
|
|
855
|
-
* exactly one frame.
|
|
856
|
-
*
|
|
857
|
-
* @example
|
|
858
|
-
* ```ts
|
|
859
|
-
* const value: PointerValue = {
|
|
860
|
-
* x: 540, y: 960, down: true, justPressed: false, justReleased: false
|
|
861
|
-
* };
|
|
862
|
-
* ```
|
|
863
|
-
*/
|
|
864
|
-
type PointerValue = {
|
|
865
|
-
x: number;
|
|
866
|
-
y: number;
|
|
867
|
-
down: boolean;
|
|
868
|
-
justPressed: boolean;
|
|
869
|
-
justReleased: boolean;
|
|
870
|
-
};
|
|
871
|
-
/**
|
|
872
|
-
* A tap on this view answers `{ intent, payload }`.
|
|
873
|
-
*/
|
|
874
|
-
declare const Tappable: ComponentType<IntentValue>;
|
|
875
|
-
/**
|
|
876
|
-
* A long press on this view answers `{ intent, payload }`.
|
|
877
|
-
*/
|
|
878
|
-
declare const Pressable: ComponentType<IntentValue>;
|
|
879
|
-
/**
|
|
880
|
-
* This view can be carried by the finger. It names no intent; the drop target does. The views
|
|
881
|
-
* whose keys `carry` lists hang under it from the grab to the release and fly home with it.
|
|
882
|
-
*/
|
|
883
|
-
declare const Draggable: ComponentType<CarryValue>;
|
|
884
|
-
/**
|
|
885
|
-
* A drop on this view answers THIS intent, with the carried payload merged under it.
|
|
886
|
-
*/
|
|
887
|
-
declare const DropTarget: ComponentType<IntentValue>;
|
|
888
|
-
/**
|
|
889
|
-
* A swipe on this view answers `{ intent, payload: { ...payload, direction } }`.
|
|
890
|
-
*/
|
|
891
|
-
declare const Swipeable: ComponentType<IntentValue>;
|
|
892
|
-
/**
|
|
893
|
-
* A finger drawn through views that carry this answers once, on the release:
|
|
894
|
-
* `{ intent, payload: { path } }`, the payloads of the cells in the order the finger went through
|
|
895
|
-
* them. Going back to the cell before the last takes the last one off. It wins over every other
|
|
896
|
-
* gesture component on the same view.
|
|
897
|
-
*/
|
|
898
|
-
declare const Traceable: ComponentType<IntentValue>;
|
|
899
|
-
/**
|
|
900
|
-
* Takes a press without naming a gesture: the hit test accepts a view that carries only this tag,
|
|
901
|
-
* and a tap on it runs the `onTap` listeners and answers nothing. `ui` tags the buttons that
|
|
902
|
-
* write local state and name no intent.
|
|
903
|
-
*/
|
|
904
|
-
declare const Touchable: TagType;
|
|
905
|
-
/**
|
|
906
|
-
* On the carried view, from grab to release.
|
|
907
|
-
*/
|
|
908
|
-
declare const Held: TagType;
|
|
909
|
-
/**
|
|
910
|
-
* On the topmost drop target under the finger during a drag. At most one, never the held view.
|
|
911
|
-
*/
|
|
912
|
-
declare const Hovered: TagType;
|
|
913
|
-
/**
|
|
914
|
-
* On every view of the trace in progress, from the moment the finger reaches it until it backs
|
|
915
|
-
* off it or the trace ends. A game system draws the line through them.
|
|
916
|
-
*/
|
|
917
|
-
declare const Traced: TagType;
|
|
918
|
-
/**
|
|
919
|
-
* On the pressed view, from pointer down until a tap, a long press, a grab, a swipe or a cancel.
|
|
920
|
-
*/
|
|
921
|
-
declare const Pressed: TagType;
|
|
922
|
-
/**
|
|
923
|
-
* On the topmost view a press would take, while a mouse or a pen moves over it with no press. At
|
|
924
|
-
* most one view carries it, and a touch never hovers. A touch sample, a pointer cancel, the pointer
|
|
925
|
-
* leaving the canvas and a paused world take it away. `ui` reads it as `is.hover`. It is not
|
|
926
|
-
* `Hovered`, which marks the drop target under a drag.
|
|
927
|
-
*/
|
|
928
|
-
declare const PointerOver: TagType;
|
|
929
|
-
/**
|
|
930
|
-
* Where the one pointer is, in reference units. Written once per frame by the frame step.
|
|
931
|
-
*/
|
|
932
|
-
declare const Pointer: ResourceType<PointerValue>;
|
|
933
|
-
//#endregion
|
|
934
|
-
//#region src/plugins/assets/bundles.d.ts
|
|
935
|
-
/**
|
|
936
|
-
* Declares the bundles of one feature. The map is copied, so a later change of the caller's
|
|
937
|
-
* object cannot reach the scanner or the plugin. `defineGame` returns this helper typed by the
|
|
938
|
-
* game's `BundleKey`, so a name the scanner never saw does not compile.
|
|
939
|
-
*
|
|
940
|
-
* @param map - Bundle name to its tier and, when it is a split bundle, its globs.
|
|
941
|
-
* @returns The bundle map as plain data.
|
|
942
|
-
* @example
|
|
943
|
-
* ```ts
|
|
944
|
-
* // features/board/assets.ts of a game: the board is a scene bundle, the chains load on demand.
|
|
945
|
-
* export const boardAssets = defineBundles({
|
|
946
|
-
* board: { tier: "scene" },
|
|
947
|
-
* "board.chains": { tier: "lazy", files: ["chains/*.png"] }
|
|
948
|
-
* });
|
|
949
|
-
* ```
|
|
950
|
-
*/
|
|
951
|
-
declare function defineBundles<Key extends string>(map: Partial<Record<Key, BundleSpec>>): BundleMap<Key>;
|
|
952
|
-
/**
|
|
953
|
-
* Creates the awaited effect that loads one or more bundles. The handler of the kind `"load"` is
|
|
954
|
-
* registered by this plugin and runs in fast mode too, so a fast walk really loads.
|
|
955
|
-
*
|
|
956
|
-
* @param bundle - One bundle name, or a list of them in load order.
|
|
957
|
-
* @returns The descriptor a loading node awaits.
|
|
958
|
-
* @example
|
|
959
|
-
* ```ts
|
|
960
|
-
* // A loading node of a game: one bundle per turn, so the screen can draw progress.
|
|
961
|
-
* await fx(load("board.chains")); // { loaded: ["board.chains"], mb: 1.25 }
|
|
962
|
-
* await fx(load(["board", "ui"])); // both, in that order
|
|
963
|
-
* ```
|
|
964
|
-
*/
|
|
965
|
-
declare function load(bundle: string | readonly string[]): Descriptor;
|
|
966
|
-
//#endregion
|
|
967
|
-
//#region src/plugins/scenes/define.d.ts
|
|
968
|
-
/**
|
|
969
|
-
* Declares a scene: a bundle, named layers in draw order, the projections it mounts and optional
|
|
970
|
-
* music. A layer `ui` is appended for the HUD and the popups unless the scene declares one. The
|
|
971
|
-
* layer names come from the keys of `layers` and that `ui`, so a projection whose `layer` or
|
|
972
|
-
* `lift` is not among them does not compile — and throws here for a caller without types.
|
|
973
|
-
*
|
|
974
|
-
* @param id - Id of the scene. A node names it with `defineNode({ scene: id })`.
|
|
975
|
-
* @param scene - The bundle, the layers, the projections and the optional music key.
|
|
976
|
-
* @returns The scene as frozen data, ready for the `scenes` key of a feature.
|
|
977
|
-
* @throws {Error} For an integer-like layer name, and for a `layer` or `lift` that is not declared.
|
|
978
|
-
* @example
|
|
979
|
-
* ```ts
|
|
980
|
-
* // features/board/view/scene.ts of a game.
|
|
981
|
-
* export const boardScene = defineScene("board", {
|
|
982
|
-
* bundle: "board",
|
|
983
|
-
* layers: { background: {}, cells: {}, items: { sort: "y" }, lifted: {} },
|
|
984
|
-
* projections: [boardCells, boardItems]
|
|
985
|
-
* });
|
|
986
|
-
*
|
|
987
|
-
* boardScene.layers[2]; // { name: "items", sort: "y" }
|
|
988
|
-
* boardScene.layers[4]; // { name: "ui", sort: "none" }, appended for the HUD
|
|
989
|
-
* ```
|
|
990
|
-
*/
|
|
991
|
-
declare function defineScene<Layers extends LayerMap, const Projections extends readonly AnySceneProjection[]>(id: string, scene: SceneSpec<Layers, Projections, string, string>): SceneDefinition;
|
|
992
|
-
//#endregion
|
|
993
|
-
//#region src/plugins/anim/components.d.ts
|
|
994
|
-
/**
|
|
995
|
-
* How many tracks and running timelines name this entity. Written by `anim` while something
|
|
996
|
-
* moves and removed at zero; the inspector and `ui.lint` read it, `anim` itself never does.
|
|
997
|
-
*/
|
|
998
|
-
declare const Animation: ComponentType<{
|
|
999
|
-
playing: number;
|
|
1000
|
-
}>;
|
|
1001
|
-
/**
|
|
1002
|
-
* A frame loop on an entity, for as long as the entity carries it: every `1000 / fps` ms
|
|
1003
|
-
* `Sprite.texture` becomes the next key of `keys`, after the last key it wraps to the first. No
|
|
1004
|
-
* timeline around it, not counted by `Animation` or `app.anim.active()`. A running `frames` step on
|
|
1005
|
-
* the same entity owns the sprite until it ends; the loop goes on from where its clock stands.
|
|
1006
|
-
* Paused and fast world modes and reduced motion stop the clock on the frame it shows.
|
|
1007
|
-
*
|
|
1008
|
-
* @example
|
|
1009
|
-
* ```ts
|
|
1010
|
-
* // A coin spins on the board for its whole life: a projection view returns both components.
|
|
1011
|
-
* const coinSpin = ["items.coin-0", "items.coin-1", "items.coin-2", "items.coin-3"] as const;
|
|
1012
|
-
* const coin = [Sprite({ texture: "items.coin-0" }), Frames({ keys: coinSpin, fps: 12 })];
|
|
1013
|
-
* Frames({ keys: coinSpin, fps: 12 }).value.loop; // true: the default
|
|
1014
|
-
* ```
|
|
1015
|
-
*/
|
|
1016
|
-
declare const Frames: ComponentType<FramesValue>;
|
|
1017
|
-
//#endregion
|
|
1018
|
-
//#region src/plugins/anim/motion.d.ts
|
|
1019
|
-
/**
|
|
1020
|
-
* The display components a pure `defineMotion` can name. A hook has no context, so it can only
|
|
1021
|
-
* reach the components `anim` itself imports: the four of `renderer` that carry numeric fields.
|
|
1022
|
-
*
|
|
1023
|
-
* @example
|
|
1024
|
-
* ```ts
|
|
1025
|
-
* type Fields = MotionComponents["Transform"]; // { x: number; y: number; rotation: number; scale: number }
|
|
1026
|
-
* ```
|
|
1027
|
-
*/
|
|
1028
|
-
type MotionComponents = {
|
|
1029
|
-
Transform: TransformValue;
|
|
1030
|
-
Sprite: SpriteValue;
|
|
1031
|
-
NineSlice: NineSliceValue;
|
|
1032
|
-
Shape: ShapeValue;
|
|
1033
|
-
};
|
|
1034
|
-
/**
|
|
1035
|
-
* One named pose: the numeric fields it gives each component it names.
|
|
1036
|
-
*
|
|
1037
|
-
* @example
|
|
1038
|
-
* ```ts
|
|
1039
|
-
* const hidden: MotionState = { Transform: { scale: 0.8 }, Shape: { alpha: 0 } };
|
|
1040
|
-
* ```
|
|
1041
|
-
*/
|
|
1042
|
-
type MotionState = { readonly [Name in keyof MotionComponents]?: Readonly<Partial<NumericFields<MotionComponents[Name]>>> };
|
|
1043
|
-
/**
|
|
1044
|
-
* What `defineMotion` is given: the named poses, the keyframe tracks, how long the way takes, and
|
|
1045
|
-
* which hooks to build. `on.enter` and `on.exit` name a state or a track. For a track,
|
|
1046
|
-
* `transition.ms` is the whole walk and each segment eases by its key, not by `transition.ease`.
|
|
1047
|
-
*
|
|
1048
|
-
* `loop.track` names a keyframe track that plays from the moment the element enters, forever,
|
|
1049
|
-
* added over whatever else moves it: one cycle is `loop.ms` (default `transition.ms`), every
|
|
1050
|
-
* Transform key is an offset from rest, and the last key repeats the first one. It is not part of
|
|
1051
|
-
* the motion `enter` returns.
|
|
1052
|
-
*
|
|
1053
|
-
* @example
|
|
1054
|
-
* ```ts
|
|
1055
|
-
* const spec: MotionSpec = {
|
|
1056
|
-
* states: { hidden: { Transform: { scale: 0.8 } } },
|
|
1057
|
-
* keyframes: { dropIn: [{ at: 0, Transform: { dy: -780, scale: 0.8 } }, { at: 0.42, Transform: { dy: 14 } }] },
|
|
1058
|
-
* transition: { ms: 1000 },
|
|
1059
|
-
* on: { enter: "dropIn", exit: "hidden", change: ["Transform"] }
|
|
1060
|
-
* };
|
|
1061
|
-
* // An order card pops in over 250 ms and sways on its pin, one swing every 2400 ms.
|
|
1062
|
-
* const orderCard: MotionSpec = {
|
|
1063
|
-
* states: { small: { Transform: { scale: 0.8 } } },
|
|
1064
|
-
* keyframes: { sway: [{ at: 0, Transform: { rotation: 0 } }, { at: 0.5, Transform: { rotation: 0.03 } }, { at: 1, Transform: { rotation: 0 } }] },
|
|
1065
|
-
* transition: { ms: 250 },
|
|
1066
|
-
* loop: { track: "sway", ms: 2400 },
|
|
1067
|
-
* on: { enter: "small" }
|
|
1068
|
-
* };
|
|
1069
|
-
* ```
|
|
1070
|
-
*/
|
|
1071
|
-
type MotionSpec = {
|
|
1072
|
-
readonly states?: Readonly<Record<string, MotionState>>;
|
|
1073
|
-
readonly keyframes?: Readonly<Record<string, readonly MotionKeyframe[]>>;
|
|
1074
|
-
readonly transition?: {
|
|
1075
|
-
readonly ms?: number;
|
|
1076
|
-
readonly ease?: Ease;
|
|
1077
|
-
};
|
|
1078
|
-
readonly loop?: {
|
|
1079
|
-
readonly track: string;
|
|
1080
|
-
readonly ms?: number;
|
|
1081
|
-
};
|
|
1082
|
-
readonly on: {
|
|
1083
|
-
readonly enter?: string;
|
|
1084
|
-
readonly exit?: string;
|
|
1085
|
-
readonly change?: readonly (keyof MotionComponents & string)[];
|
|
1086
|
-
};
|
|
1087
|
-
};
|
|
1088
|
-
/**
|
|
1089
|
-
* Builds the projection motion hooks of an element from named poses and keyframe tracks. The
|
|
1090
|
-
* transition is resolved and every name is checked here, at definition time, so every track it
|
|
1091
|
-
* starts carries a concrete duration and a wrong name fails where it is written. A `loop` builds
|
|
1092
|
-
* the `loop` hook: `world` and `ui` play it wherever they play `enter`, so a projection view loops
|
|
1093
|
-
* once it entered with motion, never after a direct reconcile, and `ui` swaps it when the motion
|
|
1094
|
-
* prop of an element changes. One cycle of the loop is `loop.ms`, or `transition.ms` when it is
|
|
1095
|
-
* left out.
|
|
1096
|
-
*
|
|
1097
|
-
* @param spec - The named poses, the keyframe tracks, the transition, the loop and the hooks to
|
|
1098
|
-
* build.
|
|
1099
|
-
* @returns The `enter`, `loop`, `exit` and `change` hooks. `settle` is left out: the default of
|
|
1100
|
-
* `world` applies.
|
|
1101
|
-
* @throws {Error} When a track is invalid, a name is both a state and a track, `on` names
|
|
1102
|
-
* neither, `loop.track` names no track, `loop.ms` is not a finite number above 0, or the loop
|
|
1103
|
-
* ends somewhere else than it starts.
|
|
1104
|
-
* @example
|
|
1105
|
-
* ```ts
|
|
1106
|
-
* const buttonMotion = defineMotion({
|
|
1107
|
-
* states: { hidden: { Transform: { scale: 0.8 }, Shape: { alpha: 0 } } },
|
|
1108
|
-
* transition: { ms: 150, ease: "out" },
|
|
1109
|
-
* on: { enter: "hidden", exit: "hidden", change: ["Transform"] }
|
|
1110
|
-
* });
|
|
1111
|
-
* buttonMotion.settle; // undefined
|
|
1112
|
-
* ```
|
|
1113
|
-
*/
|
|
1114
|
-
declare function defineMotion(spec: MotionSpec): ProjectionMotion<unknown>;
|
|
1115
|
-
//#endregion
|
|
1116
|
-
//#region src/plugins/i18n/tr.d.ts
|
|
1117
|
-
/**
|
|
1118
|
-
* Builds a message. The result is frozen and the parameters are copied, so the caller's object
|
|
1119
|
-
* stays its own and nothing downstream can rewrite a label in place.
|
|
1120
|
-
*
|
|
1121
|
-
* @param key - The message key, one of the keys `compileStrings` generated.
|
|
1122
|
-
* @param params - The parameters the message declares. An element parameter is kept as it is.
|
|
1123
|
-
* @returns The message, frozen.
|
|
1124
|
-
* @example
|
|
1125
|
-
* ```ts
|
|
1126
|
-
* tr("hud.orders", { n: 3 }); // { key: "hud.orders", params: { n: 3 } }
|
|
1127
|
-
* tr("orders.complete"); // { key: "orders.complete" }
|
|
1128
|
-
* ```
|
|
1129
|
-
*/
|
|
1130
|
-
declare function tr(key: string, params?: Record<string, Argument>): Message;
|
|
1131
|
-
//#endregion
|
|
1132
|
-
//#region src/plugins/ui/styles/define.d.ts
|
|
1133
|
-
/**
|
|
1134
|
-
* Declares one style. The work is the type: a field outside the vocabulary, or a value outside
|
|
1135
|
-
* its union, is an error where the style is written, not where it is used.
|
|
1136
|
-
*
|
|
1137
|
-
* @param style - The style, with its `is` and `when` variants.
|
|
1138
|
-
* @returns The same object, frozen.
|
|
1139
|
-
* @example
|
|
1140
|
-
* ```ts
|
|
1141
|
-
* defineStyle({ direction: "row", gap: 12 }).gap; // 12
|
|
1142
|
-
* ```
|
|
1143
|
-
*/
|
|
1144
|
-
declare function defineStyle<const Given extends Style>(style: Given): Readonly<Given>;
|
|
1145
|
-
//#endregion
|
|
1146
|
-
//#region src/plugins/ui/styles/resolve.d.ts
|
|
1147
|
-
/**
|
|
1148
|
-
* The flags one element is resolved against: the viewport flags of the frame plus its own state.
|
|
1149
|
-
*
|
|
1150
|
-
* @example
|
|
1151
|
-
* ```ts
|
|
1152
|
-
* const flags: StyleFlags = {
|
|
1153
|
-
* portrait: true, landscape: false, tall: false, wide: false,
|
|
1154
|
-
* pressed: false, hover: false, focus: false, disabled: false, active: true, selected: false,
|
|
1155
|
-
* covered: false
|
|
1156
|
-
* };
|
|
1157
|
-
* ```
|
|
1158
|
-
*/
|
|
1159
|
-
type StyleFlags = WhenFlags & IsFlags;
|
|
1160
|
-
/**
|
|
1161
|
-
* Resolves one style against the flags of the frame and the viewport.
|
|
1162
|
-
*
|
|
1163
|
-
* @param style - The style a game wrote, or nothing.
|
|
1164
|
-
* @param flags - The four viewport flags and the seven state flags. While `disabled` is true the
|
|
1165
|
-
* `hover` and `pressed` variants are skipped.
|
|
1166
|
-
* @param viewport - What `renderer.viewport.size()` answered, for the safe-area tokens.
|
|
1167
|
-
* @returns The frozen style the layout and the visual are written from.
|
|
1168
|
-
* @example
|
|
1169
|
-
* ```ts
|
|
1170
|
-
* resolve(
|
|
1171
|
-
* { gap: 8, is: { pressed: { gap: 4 } } },
|
|
1172
|
-
* { portrait: true, landscape: false, tall: false, wide: false,
|
|
1173
|
-
* pressed: true, hover: false, focus: false, disabled: false, active: false, selected: false,
|
|
1174
|
-
* covered: false },
|
|
1175
|
-
* { width: 1080, height: 1920, scale: 1, orientation: "portrait",
|
|
1176
|
-
* safeArea: { top: 0, right: 0, bottom: 0, left: 0 } }
|
|
1177
|
-
* ).gap; // 4
|
|
1178
|
-
* ```
|
|
1179
|
-
*/
|
|
1180
|
-
declare function resolve(style: Style | undefined, flags: StyleFlags, viewport: ViewportSize): ResolvedStyle;
|
|
1181
|
-
//#endregion
|
|
1182
|
-
//#region src/plugins/audio/descriptors.d.ts
|
|
1183
|
-
/**
|
|
1184
|
-
* Creates the awaited effect that switches the music track. The same key as the one playing does
|
|
1185
|
-
* nothing, and `null` fades the current track out. An absent `fadeMs` leaves the key out of the
|
|
1186
|
-
* payload, so the descriptor stays plain JSON and the plugin's `musicFadeMs` decides at play time.
|
|
1187
|
-
*
|
|
1188
|
-
* @param key - Asset key of an `.mp3`, or `null` to stop the music.
|
|
1189
|
-
* @param options - `fadeMs` overrides the configured cross-fade for this switch.
|
|
1190
|
-
* @returns The descriptor a node awaits, frozen.
|
|
1191
|
-
* @example
|
|
1192
|
-
* ```ts
|
|
1193
|
-
* // A node of a game: the menu goes quiet before the ending cinematic starts.
|
|
1194
|
-
* await fx(music(null, { fadeMs: 1500 }));
|
|
1195
|
-
* // music("board.theme") is { kind: "music", payload: { key: "board.theme" }, cosmetic: true }
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
declare function music(key: string | null, options?: MusicOptions): Descriptor;
|
|
1199
|
-
//#endregion
|
|
1200
|
-
//#region src/plugins/effects/filters/builtins.d.ts
|
|
1201
|
-
/**
|
|
1202
|
-
* A soft halo of `color` around the opaque pixels of a view and its subtree, `distance` pixels
|
|
1203
|
-
* wide, that follows the shape: rounded corners stay rounded. Its alpha is
|
|
1204
|
-
* `strength × alpha ×` the share of the disc of radius `distance` around the pixel the view
|
|
1205
|
-
* covers, so `strength: 2` is full next to a straight edge and fades to nothing at `distance`.
|
|
1206
|
-
* It takes 64 to 256 probes, by radius in physical pixels: about 3.5 physical pixels apart up to
|
|
1207
|
-
* a radius of 32 physical pixels. The view is padded by its live `distance`. One render pass per
|
|
1208
|
-
* apply.
|
|
1209
|
-
*
|
|
1210
|
-
* @example
|
|
1211
|
-
* ```ts
|
|
1212
|
-
* // A merged item glows, and a motion hook tweens the glow away.
|
|
1213
|
-
* Glow({ strength: 4 }).value; // { strength: 4, distance: 10, color: 0xffffff, alpha: 1, enabled: true, order: 0 }
|
|
1214
|
-
* view.tween(Glow, { strength: 0 }, { ms: 200 });
|
|
1215
|
-
* ```
|
|
1216
|
-
*/
|
|
1217
|
-
declare const Glow: FilterComponent<GlowValue>;
|
|
1218
|
-
/**
|
|
1219
|
-
* A ring of `thickness` pixels in `color` around the opaque pixels of a view and its subtree; the
|
|
1220
|
-
* view is padded by its live `thickness`. One render pass per apply.
|
|
1221
|
-
*
|
|
1222
|
-
* @example
|
|
1223
|
-
* ```ts
|
|
1224
|
-
* // The selected card is outlined in honey.
|
|
1225
|
-
* Outline({ thickness: 4, color: 0xffc233 }).value; // { thickness: 4, color: 0xffc233, alpha: 1, enabled: true, order: 0 }
|
|
1226
|
-
* ```
|
|
1227
|
-
*/
|
|
1228
|
-
declare const Outline: FilterComponent<OutlineValue>;
|
|
1229
|
-
/**
|
|
1230
|
-
* Pixi's blur over a view and its subtree. `quality: 0` means `config.blur.quality`;
|
|
1231
|
-
* `resolution: 0` means `config.blur.phoneResolution` on a phone, otherwise 1. `repeatEdgePixels`
|
|
1232
|
-
* keeps the padding at 0. Costs `2 × quality` render passes per apply.
|
|
1233
|
-
*
|
|
1234
|
-
* @example
|
|
1235
|
-
* ```ts
|
|
1236
|
-
* // The board behind a popup: the filter sits on the ui slot that hosts the board.
|
|
1237
|
-
* Blur({ strength: 6 }).value; // { strength: 6, quality: 0, resolution: 0, repeatEdgePixels: true, enabled: true, order: 0 }
|
|
1238
|
-
* ```
|
|
1239
|
-
*/
|
|
1240
|
-
declare const Blur: ComponentType<BlurValue>;
|
|
1241
|
-
/**
|
|
1242
|
-
* Pixi's colour matrix: brightness, saturation, contrast, hue in degrees and grayscale, composed
|
|
1243
|
-
* in that order from the identity on every change. Every default is the identity.
|
|
1244
|
-
*
|
|
1245
|
-
* @example
|
|
1246
|
-
* ```ts
|
|
1247
|
-
* // A locked card goes gray.
|
|
1248
|
-
* ColorMatrix({ grayscale: 1 }).value.grayscale; // 1
|
|
1249
|
-
* ```
|
|
1250
|
-
*/
|
|
1251
|
-
declare const ColorMatrix: ComponentType<ColorMatrixValue>;
|
|
1252
|
-
/**
|
|
1253
|
-
* Pixi's noise. The seed is always given, never Pixi's random default, so two runs draw the same
|
|
1254
|
-
* grain.
|
|
1255
|
-
*
|
|
1256
|
-
* @example
|
|
1257
|
-
* ```ts
|
|
1258
|
-
* Noise({ amount: 0.2, seed: 7 }).value; // { amount: 0.2, seed: 7, enabled: true, order: 0 }
|
|
1259
|
-
* ```
|
|
1260
|
-
*/
|
|
1261
|
-
declare const Noise: ComponentType<NoiseValue>;
|
|
1262
|
-
/**
|
|
1263
|
-
* Pixi's displacement over the texture of the asset key `map`. Nothing is drawn while the map is
|
|
1264
|
-
* not loaded; a missing key warns once.
|
|
1265
|
-
*
|
|
1266
|
-
* @example
|
|
1267
|
-
* ```ts
|
|
1268
|
-
* // Heat haze over the furnace.
|
|
1269
|
-
* Displacement({ map: "fx.ripple", scaleX: 8, scaleY: 8 }).value.map; // "fx.ripple"
|
|
1270
|
-
* ```
|
|
1271
|
-
*/
|
|
1272
|
-
declare const Displacement: ComponentType<DisplacementValue>;
|
|
1273
|
-
/**
|
|
1274
|
-
* Pixi's alpha over a view and its subtree as one layer, so overlapping children do not show
|
|
1275
|
-
* through each other.
|
|
1276
|
-
*
|
|
1277
|
-
* @example
|
|
1278
|
-
* ```ts
|
|
1279
|
-
* Alpha({ alpha: 0.5 }).value; // { alpha: 0.5, enabled: true, order: 0 }
|
|
1280
|
-
* ```
|
|
1281
|
-
*/
|
|
1282
|
-
declare const Alpha: ComponentType<AlphaValue>;
|
|
1283
|
-
//#endregion
|
|
1284
|
-
//#region src/plugins/effects/filters/define.d.ts
|
|
1285
|
-
/**
|
|
1286
|
-
* Turns a WGSL fragment body and its GLSL ES 3.0 twin into a filter component type; Pixi draws
|
|
1287
|
-
* the one of the running backend. To the WGSL the engine prepends the vertex stage, the input
|
|
1288
|
-
* bindings and a `FilterUniforms` struct in declaration order, bound as `fu`. To the GLSL it
|
|
1289
|
-
* prepends `#version 300 es`, `vTextureCoord`, `finalColor`, `uTexture`, the global filter
|
|
1290
|
-
* uniforms as `vec4` and one `uniform` per declared uniform under its bare name. Every number
|
|
1291
|
-
* uniform is a number field, so the existing `tween` drives it; a colour is one hex field sent as
|
|
1292
|
-
* a `vec3`; a tuple is an array field and not tweenable. Every filter component also carries
|
|
1293
|
-
* `enabled: true` and `order: 0`. Register it through the `filters` key of a feature.
|
|
1294
|
-
*
|
|
1295
|
-
* @param id - The filter id, also the component name; unique, and not one of the built-ins.
|
|
1296
|
-
* @param spec - Both bodies, the uniforms, the passes one apply costs and the padding.
|
|
1297
|
-
* @returns The component type, with the frozen `filter` definition attached.
|
|
1298
|
-
* @throws {Error} When the id is empty, the WGSL has no `mainFragment`, the GLSL no `void main(`,
|
|
1299
|
-
* a uniform is reserved, badly named or of no known form, or the passes or the padding break
|
|
1300
|
-
* their rules.
|
|
1301
|
-
* @example
|
|
1302
|
-
* ```ts
|
|
1303
|
-
* // features/board/effects.ts: a gold tint a motion hook tweens on a merge, on WebGPU and WebGL.
|
|
1304
|
-
* const Tint = defineFilter("fx.tint", { wgsl: tintWgsl, glsl: tintGlsl, uniforms: { amount: 0, color: { color: 0xffd700 } } });
|
|
1305
|
-
* Tint({ amount: 1 }).value; // { amount: 1, color: 0xffd700, enabled: true, order: 0 }
|
|
1306
|
-
* Tint.filter.glsl.includes("uniform vec3 color;"); // true
|
|
1307
|
-
* ```
|
|
1308
|
-
*/
|
|
1309
|
-
declare function defineFilter<Uniforms extends Record<string, UniformDeclaration> = Record<never, never>>(id: string, spec: FilterSpec<Uniforms>): FilterComponent<FilterValueOf<Uniforms>>;
|
|
1310
|
-
//#endregion
|
|
1311
|
-
//#region src/plugins/effects/particles/component.d.ts
|
|
1312
|
-
/**
|
|
1313
|
-
* A particle effect on an entity. A `burst` effect emits when the component appears or its
|
|
1314
|
-
* `effect` changes; a `rate` effect emits while `active` is true and the entity lives. An effect in
|
|
1315
|
-
* `"world"` space outlives the entity, one in `"local"` space moves and dies with it. `""` draws
|
|
1316
|
-
* nothing. Plain JSON: it shows in `snapshot()`.
|
|
1317
|
-
*
|
|
1318
|
-
* @example
|
|
1319
|
-
* ```ts
|
|
1320
|
-
* // A merged item bursts stars from its enter hook; the generator steams for its whole life.
|
|
1321
|
-
* view.set(Emitter, { effect: "fx.starsBurst" });
|
|
1322
|
-
* Emitter({ effect: "fx.steam" }).value; // { effect: "fx.steam", active: true }
|
|
1323
|
-
* ```
|
|
1324
|
-
*/
|
|
1325
|
-
declare const Emitter: ComponentType<EmitterValue>;
|
|
1326
|
-
//#endregion
|
|
1327
|
-
//#region src/plugins/effects/particles/define.d.ts
|
|
1328
|
-
/**
|
|
1329
|
-
* Describes a particle effect. Every field is optional except `textures` and exactly one of
|
|
1330
|
-
* `burst` and `rate`; the definition is frozen, registered through the `emitters` key of a feature
|
|
1331
|
-
* and started by an `Emitter` component naming its id.
|
|
1332
|
-
*
|
|
1333
|
-
* @param id - The effect id, unique across the features of the game.
|
|
1334
|
-
* @param config - The effect as data.
|
|
1335
|
-
* @returns The frozen definition `{ id, config }`, the config with every default filled in.
|
|
1336
|
-
* @throws {Error} When the id is empty or a field breaks its rule.
|
|
1337
|
-
* @example
|
|
1338
|
-
* ```ts
|
|
1339
|
-
* // features/board/effects.ts: the steam over the generator.
|
|
1340
|
-
* const steam = defineEmitter("fx.steam", { textures: ["fx.puff"], rate: 12, space: "local" });
|
|
1341
|
-
* steam.config.rate; // 12
|
|
1342
|
-
* steam.config.lifeMs; // [600, 1000], the default
|
|
1343
|
-
* ```
|
|
1344
|
-
*/
|
|
1345
|
-
declare function defineEmitter(id: string, config: EmitterConfig): EmitterDefinition;
|
|
1346
|
-
//#endregion
|
|
1347
|
-
//#region src/index.d.ts
|
|
1348
|
-
/**
|
|
1349
|
-
* Creates a game application.
|
|
1350
|
-
*
|
|
1351
|
-
* @example
|
|
1352
|
-
* ```ts
|
|
1353
|
-
* // The entry point of a game. The graph is started by the game, never by the plugin.
|
|
1354
|
-
* const app = createApp({
|
|
1355
|
-
* pluginConfigs: { flow: { mainFlow, safeNode: "home" } },
|
|
1356
|
-
* onStart: ctx => void ctx.flow.run().catch(error => ctx.log.error("game: failed", { error }))
|
|
1357
|
-
* });
|
|
1358
|
-
* ```
|
|
1359
|
-
*/
|
|
1360
|
-
declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs/core").AnyPluginInstance[] = readonly []>(options?: import("@moku-labs/core").CreateAppOptions<Config$6, Events$1, (import("@moku-labs/core").PluginInstance<"time", Config$5, State$5, Api$3, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"lifecycle", Config$3, State$3, Api$2, {
|
|
1361
|
-
"lifecycle:changed": {
|
|
1362
|
-
reason: PauseReason;
|
|
1363
|
-
action: "push" | "pop";
|
|
1364
|
-
reasons: readonly PauseReason[];
|
|
1365
|
-
paused: boolean;
|
|
1366
|
-
resumed: boolean;
|
|
1367
|
-
};
|
|
1368
|
-
}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"model", Config$4, State$4, {
|
|
1369
|
-
store: StoreApi;
|
|
1370
|
-
rng: RngApi;
|
|
1371
|
-
}, {
|
|
1372
|
-
"model:committed": {
|
|
1373
|
-
roots: readonly Root[];
|
|
1374
|
-
cause: "edge" | "rollback" | "restore" | "load";
|
|
1375
|
-
};
|
|
1376
|
-
}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"clock", Config$1, State$1, Api, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"flow", Config$2, State$2, Api$1, {
|
|
1377
|
-
"flow:edge": {
|
|
1378
|
-
flow: string;
|
|
1379
|
-
node: string;
|
|
1380
|
-
outcome: string;
|
|
1381
|
-
payload: Json;
|
|
1382
|
-
next: string;
|
|
1383
|
-
patches: {
|
|
1384
|
-
doc: Patch[];
|
|
1385
|
-
session: Patch[];
|
|
1386
|
-
};
|
|
1387
|
-
index: number;
|
|
1388
|
-
now: number;
|
|
1389
|
-
};
|
|
1390
|
-
"flow:rest": {
|
|
1391
|
-
path: string;
|
|
1392
|
-
checkpoint: boolean;
|
|
1393
|
-
};
|
|
1394
|
-
"flow:error": {
|
|
1395
|
-
path: string;
|
|
1396
|
-
error: unknown;
|
|
1397
|
-
rolledBackTo: string;
|
|
1398
|
-
retry: boolean;
|
|
1399
|
-
};
|
|
1400
|
-
}> & Record<never, never>) | ExtraPlugins[number], [...ExtraPlugins], import("@moku-labs/core").CoreApisFromTuple<[import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common/browser").LogConfig, import("@moku-labs/common/browser").LogState, import("@moku-labs/common/browser").LogApi>, import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common/browser").EnvConfig, import("@moku-labs/common/browser").EnvState, import("@moku-labs/common/browser").EnvApi>]>, import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common/browser").LogConfig, import("@moku-labs/common/browser").LogState, import("@moku-labs/common/browser").LogApi> | import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common/browser").EnvConfig, import("@moku-labs/common/browser").EnvState, import("@moku-labs/common/browser").EnvApi>> | undefined) => import("@moku-labs/core").App<Config$6, Events$1, (import("@moku-labs/core").PluginInstance<"time", Config$5, State$5, Api$3, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"lifecycle", Config$3, State$3, Api$2, {
|
|
1401
|
-
"lifecycle:changed": {
|
|
1402
|
-
reason: PauseReason;
|
|
1403
|
-
action: "push" | "pop";
|
|
1404
|
-
reasons: readonly PauseReason[];
|
|
1405
|
-
paused: boolean;
|
|
1406
|
-
resumed: boolean;
|
|
1407
|
-
};
|
|
1408
|
-
}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"model", Config$4, State$4, {
|
|
1409
|
-
store: StoreApi;
|
|
1410
|
-
rng: RngApi;
|
|
1411
|
-
}, {
|
|
1412
|
-
"model:committed": {
|
|
1413
|
-
roots: readonly Root[];
|
|
1414
|
-
cause: "edge" | "rollback" | "restore" | "load";
|
|
1415
|
-
};
|
|
1416
|
-
}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"clock", Config$1, State$1, Api, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"flow", Config$2, State$2, Api$1, {
|
|
1417
|
-
"flow:edge": {
|
|
1418
|
-
flow: string;
|
|
1419
|
-
node: string;
|
|
1420
|
-
outcome: string;
|
|
1421
|
-
payload: Json;
|
|
1422
|
-
next: string;
|
|
1423
|
-
patches: {
|
|
1424
|
-
doc: Patch[];
|
|
1425
|
-
session: Patch[];
|
|
1426
|
-
};
|
|
1427
|
-
index: number;
|
|
1428
|
-
now: number;
|
|
1429
|
-
};
|
|
1430
|
-
"flow:rest": {
|
|
1431
|
-
path: string;
|
|
1432
|
-
checkpoint: boolean;
|
|
1433
|
-
};
|
|
1434
|
-
"flow:error": {
|
|
1435
|
-
path: string;
|
|
1436
|
-
error: unknown;
|
|
1437
|
-
rolledBackTo: string;
|
|
1438
|
-
retry: boolean;
|
|
1439
|
-
};
|
|
1440
|
-
}> & Record<never, never>) | ExtraPlugins[number], import("@moku-labs/core").CoreApisFromTuple<[import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common/browser").LogConfig, import("@moku-labs/common/browser").LogState, import("@moku-labs/common/browser").LogApi>, import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common/browser").EnvConfig, import("@moku-labs/common/browser").EnvState, import("@moku-labs/common/browser").EnvApi>]>>;
|
|
1441
|
-
/**
|
|
1442
|
-
* Creates a game plugin.
|
|
1443
|
-
*
|
|
1444
|
-
* @example
|
|
1445
|
-
* ```ts
|
|
1446
|
-
* // A game plugin that writes every edge of the graph to the log.
|
|
1447
|
-
* export const edgeLog = createPlugin("edgeLog", {
|
|
1448
|
-
* depends: [flowPlugin],
|
|
1449
|
-
* hooks: ctx => ({ "flow:edge": ({ node, outcome }) => ctx.log.info("edge", { node, outcome }) })
|
|
1450
|
-
* });
|
|
1451
|
-
* ```
|
|
1452
|
-
*/
|
|
1453
|
-
declare const createPlugin: import("@moku-labs/core").BoundCreatePluginFunction<Config$6, Events$1, import("@moku-labs/core").CoreApisFromTuple<[import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common/browser").LogConfig, import("@moku-labs/common/browser").LogState, import("@moku-labs/common/browser").LogApi>, import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common/browser").EnvConfig, import("@moku-labs/common/browser").EnvState, import("@moku-labs/common/browser").EnvApi>]>>;
|
|
1454
|
-
/**
|
|
1455
|
-
* Binds the authoring helpers to the types of one game: "createApp for a game". Each plugin binds
|
|
1456
|
-
* its own helpers (`flowFor`, `projectionFor`, `componentsFor`, `bundlesFor`, `scenesFor`); this
|
|
1457
|
-
* only spreads them, so the kit's type is inferred and never written by hand. At run time these
|
|
1458
|
-
* are the same functions and component objects the plugins export.
|
|
1459
|
-
*
|
|
1460
|
-
* @returns The helpers typed with the game's `player`, `session`, `assets`, `bundles`, `strings`
|
|
1461
|
-
* and `emitters`.
|
|
1462
|
-
* @example
|
|
1463
|
-
* ```ts
|
|
1464
|
-
* // kit.ts of a game: bound once, imported by every node, flow and view file.
|
|
1465
|
-
* export const { defineNode, defineFlow, defineFeature, projection, sprite, Sprite, defineBundles, load, defineScene } =
|
|
1466
|
-
* defineGame<{ player: Player; session: Session; assets: AssetKey; bundles: BundleKey; strings: StringTable }>();
|
|
1467
|
-
* ```
|
|
1468
|
-
*/
|
|
1469
|
-
declare function defineGame<Types extends GameTypes>(): {
|
|
1470
|
-
defineEmitter: (id: EmitterIdOf<Types>, config: Omit<EmitterConfig, "textures"> & {
|
|
1471
|
-
readonly textures: readonly Types["assets"][];
|
|
1472
|
-
}) => EmitterDefinition;
|
|
1473
|
-
Emitter: Narrowed<EmitterValue, {
|
|
1474
|
-
effect?: EmitterIdOf<Types>;
|
|
1475
|
-
active?: boolean;
|
|
1476
|
-
}>;
|
|
1477
|
-
Displacement: Narrowed<DisplacementValue, Partial<Omit<DisplacementValue, "map">> & {
|
|
1478
|
-
map?: Types["assets"];
|
|
1479
|
-
}>;
|
|
1480
|
-
music: MusicDescriptor<Types["assets"]>;
|
|
1481
|
-
defineComponent: typeof defineComponent;
|
|
1482
|
-
defineStyle: <const Given extends Style<Types["assets"]>>(style: Given) => Readonly<Given>;
|
|
1483
|
-
defineTokens: typeof defineTokens;
|
|
1484
|
-
popup: <Properties extends object, Local extends object>(component: PopupComponent<Properties, Local>, props: Properties, options?: {
|
|
1485
|
-
over?: string;
|
|
1486
|
-
}) => Descriptor;
|
|
1487
|
-
intrinsics: IntrinsicElementsFor<Types["assets"], TextStylesOf<Types>, Extract<keyof Types["strings"], string>>;
|
|
1488
|
-
label: (options: Omit<LabelOptions, "style"> & {
|
|
1489
|
-
style: TextStylesOf<Types>;
|
|
1490
|
-
}) => ReturnType<typeof label>;
|
|
1491
|
-
defineTextStyles: (map: Record<string, Omit<TextStyleInput, "bold" | "font" | "italic"> & {
|
|
1492
|
-
font: Types["assets"];
|
|
1493
|
-
} & {
|
|
1494
|
-
bold?: Types["assets"];
|
|
1495
|
-
italic?: Types["assets"];
|
|
1496
|
-
}>) => TextStyles;
|
|
1497
|
-
tr: TypedTr<Types["strings"]>;
|
|
1498
|
-
defineAnimation: typeof defineAnimation;
|
|
1499
|
-
frames: (target: Target, options: {
|
|
1500
|
-
keys: readonly Types["assets"][];
|
|
1501
|
-
fps: number;
|
|
1502
|
-
loop?: boolean;
|
|
1503
|
-
}) => Step;
|
|
1504
|
-
sfx: (key: Types["assets"], options?: {
|
|
1505
|
-
bus?: string;
|
|
1506
|
-
}) => SfxDescriptor;
|
|
1507
|
-
play: typeof play;
|
|
1508
|
-
Frames: Narrowed<FramesValue, Partial<Omit<FramesValue, "keys">> & {
|
|
1509
|
-
keys?: readonly Types["assets"][];
|
|
1510
|
-
}>;
|
|
1511
|
-
defineScene: DefineScene<Types["assets"], BundlesOf<Types>>;
|
|
1512
|
-
defineBundles: DefineBundles<BundlesOf<Types>>;
|
|
1513
|
-
load: LoadBundles<BundlesOf<Types>>;
|
|
1514
|
-
sprite: (options: Omit<SpriteOptions, "texture"> & {
|
|
1515
|
-
texture: Types["assets"];
|
|
1516
|
-
}) => ReturnType<typeof sprite>;
|
|
1517
|
-
Sprite: Narrowed<SpriteValue, Partial<Omit<SpriteValue, "texture">> & {
|
|
1518
|
-
texture?: Types["assets"];
|
|
1519
|
-
}>;
|
|
1520
|
-
NineSlice: Narrowed<NineSliceValue, Partial<Omit<NineSliceValue, "texture">> & {
|
|
1521
|
-
texture?: Types["assets"];
|
|
1522
|
-
}>;
|
|
1523
|
-
projection: ProjectionFor<Types["player"], Types["session"]>;
|
|
1524
|
-
defineNode: DefineNode<{
|
|
1525
|
-
player: Types["player"];
|
|
1526
|
-
session: Types["session"];
|
|
1527
|
-
scenes: SceneIdOf<Types>;
|
|
1528
|
-
}>;
|
|
1529
|
-
defineFlow: typeof defineFlow;
|
|
1530
|
-
defineFeature: (name: string, description: FeatureDescription) => FeaturePlugin;
|
|
1531
|
-
};
|
|
1532
|
-
/**
|
|
1533
|
-
* The screen plugins, in dependency order. A game with a screen spreads them into `plugins`;
|
|
1534
|
-
* a headless test leaves them out. V2: `world`, `renderer`, `input`, `assets`, `scenes`. V3 appends `anim`, `i18n`, `text`, `ui`; `audio`, `effects` and `platform` stay opt-in: `[...screen, effectsPlugin, audioPlugin, platformPlugin]`.
|
|
1535
|
-
*
|
|
1536
|
-
* @example
|
|
1537
|
-
* ```ts
|
|
1538
|
-
* createApp({ plugins: [...screen, boardFeature], pluginConfigs: { renderer: { mount: "#game" } } });
|
|
1539
|
-
* ```
|
|
1540
|
-
*/
|
|
1541
|
-
declare const screen: readonly [import("@moku-labs/core").PluginInstance<"world", Config$9, State$8, Api$6, {
|
|
1542
|
-
"world:reconciled": {
|
|
1543
|
-
mode: "play" | "direct";
|
|
1544
|
-
projections: number;
|
|
1545
|
-
entered: number;
|
|
1546
|
-
changed: number;
|
|
1547
|
-
exited: number;
|
|
1548
|
-
revived: number;
|
|
1549
|
-
queued: number;
|
|
1550
|
-
hintsRouted: number;
|
|
1551
|
-
hintsDropped: number;
|
|
1552
|
-
};
|
|
1553
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"renderer", Config$8, State$7, Api$5, {
|
|
1554
|
-
"renderer:device-lost": {
|
|
1555
|
-
kind: "webgpu" | "webgl";
|
|
1556
|
-
reason: string;
|
|
1557
|
-
};
|
|
1558
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"input", Config$11, State$10, InputApi, {}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"assets", Config$7, State$6, Api$4, {
|
|
1559
|
-
"assets:bundle-loaded": {
|
|
1560
|
-
bundle: string;
|
|
1561
|
-
tier: Tier;
|
|
1562
|
-
mb: number;
|
|
1563
|
-
reason: LoadReason;
|
|
1564
|
-
};
|
|
1565
|
-
"assets:bundle-progress": {
|
|
1566
|
-
bundle: string;
|
|
1567
|
-
loaded: number;
|
|
1568
|
-
total: number;
|
|
1569
|
-
};
|
|
1570
|
-
"assets:bundle-unloaded": {
|
|
1571
|
-
bundle: string;
|
|
1572
|
-
tier: Tier;
|
|
1573
|
-
mb: number;
|
|
1574
|
-
reason: "budget" | "request";
|
|
1575
|
-
keys: readonly string[];
|
|
1576
|
-
};
|
|
1577
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"scenes", Record<string, never>, State$14, ScenesApi, {
|
|
1578
|
-
"scenes:changed": {
|
|
1579
|
-
from: string | undefined;
|
|
1580
|
-
to: string;
|
|
1581
|
-
music: string | undefined;
|
|
1582
|
-
};
|
|
1583
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"anim", Config$13, State$12, AnimApi, {
|
|
1584
|
-
"anim:mark": {
|
|
1585
|
-
animation: string;
|
|
1586
|
-
mark: string;
|
|
1587
|
-
};
|
|
1588
|
-
"anim:finished": {
|
|
1589
|
-
animation: string;
|
|
1590
|
-
};
|
|
1591
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"i18n", Config$10, State$9, I18nApi, {
|
|
1592
|
-
"i18n:locale-changed": {
|
|
1593
|
-
locale: string;
|
|
1594
|
-
};
|
|
1595
|
-
}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"text", Config$12, State$11, TextApi, {}> & Record<never, never>, import("@moku-labs/core").PluginInstance<"ui", Config$15, State$15, UiApi, {}> & Record<never, never>];
|
|
1596
|
-
//#endregion
|
|
1597
|
-
export { Alpha, types_d_exports as Anim, Animation, types_d_exports$1 as Assets, types_d_exports$2 as Audio, type BackResult, type BindOptions, Blur, Box, types_d_exports$3 as Clock, ColorMatrix, Countdown, type CountdownValue, type DescriptionNode, Displacement, Display, Draggable, DropTarget, types_d_exports$4 as Effects, Emitter, Exiting, types_d_exports$5 as Flow, Frames, Glow, HAPTIC_KINDS, type HapticKind, Held, Hovered, types_d_exports$6 as I18n, types_d_exports$7 as Input, Layer, types_d_exports$8 as Lifecycle, LocalWrite, types_d_exports$9 as Model, NineSlice, Noise, Order, Outline, Parent, types_d_exports$10 as Platform, type PlatformProvider, Pointer, PointerOver, Pressable, Pressed, types_d_exports$11 as Renderer, SaveUnreadableError, types_d_exports$12 as Scenes, Shape, Sprite, Swipeable, Tappable, Text, type TextFormat, types_d_exports$13 as TextTypes, types_d_exports$14 as Time, Touchable, Traceable, Traced, Transform, Tree, types_d_exports$15 as Ui, types_d_exports$16 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, createApp, createPlugin, defineAnimation, defineBundles, defineComponent, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextStyles, defineTokens, effectsPlugin, exit, external, flowPlugin, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
|
|
1
|
+
import { Ct as to, N as types_d_exports$16, Q as DescriptionNode, S as types_d_exports$11, St as slot, Wt as types_d_exports$14, Zt as types_d_exports$9, fn as types_d_exports$8, nn as SaveUnreadableError, p as types_d_exports$1, vn as types_d_exports$3, wt as type, xt as exit, yt as types_d_exports$5 } from "./types-B0v5VVa3.mjs";
|
|
2
|
+
import { B as types_d_exports$6, G as Display, J as Parent, K as NineSlice, N as types_d_exports$13, S as BindOptions, W as types_d_exports$7, Y as Shape, Z as Sprite, b as defineComponent, d as popup, et as Transform, f as defineTokens, k as TextFormat, l as Box, nt as sprite, u as LocalWrite, w as CountdownValue } from "./types-xXfyk56Q.mjs";
|
|
3
|
+
import { B as set, D as types_d_exports, F as haptic, G as tween, H as spawn, I as mark, K as use, L as parallel, M as defineAnimation, N as external, O as HapticKind, P as frames, R as play, U as spawned, V as sfx, W as stagger, h as types_d_exports$12, j as HAPTIC_KINDS, q as wait, s as types_d_exports$2, y as types_d_exports$15, z as sequence } from "./types-VZVWwqCg.mjs";
|
|
4
|
+
import { a as types_d_exports$4 } from "./types-CQueODzo.mjs";
|
|
5
|
+
import { $ as uiPlugin, A as Pointer, B as Layer, C as defineScene, Ct as label, D as DropTarget, E as Draggable, F as Tappable, G as resource, H as Tree, I as Touchable, J as guide, K as system, L as Traceable, M as Pressable, N as Pressed, O as Held, P as Swipeable, Q as worldPlugin, R as Traced, S as Frames, St as defineTextStyles, T as load, U as component, V as Order, W as mut, X as schedule, Y as hint, Z as defineFeature, _ as defineStyle, _t as animPlugin, a as defineEmitter, at as BackResult, b as AnimPlayer, bt as Text, c as Alpha, ct as modelPlugin, d as Displacement, dt as i18nPlugin, et as timePlugin, f as Glow, ft as flowPlugin, g as resolve, gt as assetsPlugin, h as music, ht as audioPlugin, i as screen, it as platformPlugin, j as PointerOver, k as Hovered, l as Blur, lt as lifecyclePlugin, m as Outline, mt as clockPlugin, n as createPlugin, nt as scenesPlugin, o as Emitter, ot as PlatformProvider, p as Noise, pt as effectsPlugin, q as tag, r as defineGame, rt as rendererPlugin, s as defineFilter, st as types_d_exports$10, t as createApp, tt as textPlugin, u as ColorMatrix, ut as inputPlugin, v as tr, vt as projection, w as defineBundles, x as Animation, xt as bind, y as defineMotion, yt as Countdown, z as Exiting } from "./index-BO9kZzY3.mjs";
|
|
6
|
+
export { Alpha, types_d_exports as Anim, AnimPlayer, Animation, types_d_exports$1 as Assets, types_d_exports$2 as Audio, type BackResult, type BindOptions, Blur, Box, types_d_exports$3 as Clock, ColorMatrix, Countdown, type CountdownValue, type DescriptionNode, Displacement, Display, Draggable, DropTarget, types_d_exports$4 as Effects, Emitter, Exiting, types_d_exports$5 as Flow, Frames, Glow, HAPTIC_KINDS, type HapticKind, Held, Hovered, types_d_exports$6 as I18n, types_d_exports$7 as Input, Layer, types_d_exports$8 as Lifecycle, LocalWrite, types_d_exports$9 as Model, NineSlice, Noise, Order, Outline, Parent, types_d_exports$10 as Platform, type PlatformProvider, Pointer, PointerOver, Pressable, Pressed, types_d_exports$11 as Renderer, SaveUnreadableError, types_d_exports$12 as Scenes, Shape, Sprite, Swipeable, Tappable, Text, type TextFormat, types_d_exports$13 as TextTypes, types_d_exports$14 as Time, Touchable, Traceable, Traced, Transform, Tree, types_d_exports$15 as Ui, types_d_exports$16 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, createApp, createPlugin, defineAnimation, defineBundles, defineComponent, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextStyles, defineTokens, effectsPlugin, exit, external, flowPlugin, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
|