@moku-labs/game 0.0.2 → 0.1.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 +107 -31
- package/dist/assets.d.mts +58 -6
- package/dist/assets.mjs +1630 -234
- package/dist/commands-C0BljsM5.d.mts +99 -0
- package/dist/control.d.mts +3 -92
- package/dist/control.mjs +3 -757
- package/dist/define-CjP_4H0G.d.mts +51 -0
- package/dist/{registry-DlpRCibU.mjs → dev-CcwFrwok.mjs} +30 -1
- package/dist/index.d.mts +362 -303
- package/dist/index.mjs +12717 -6654
- package/dist/inspect.d.mts +10 -8
- package/dist/inspect.mjs +2 -518
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
- package/dist/run-tlcn1w7y.mjs +944 -0
- package/dist/{runtime-DiOTkDZz.d.mts → runtime-Bn5TXNxP.d.mts} +1 -1
- package/dist/sources-BooL2MsX.mjs +545 -0
- package/dist/testing.d.mts +328 -3
- package/dist/testing.mjs +2126 -2
- package/dist/types-BZ1OLf24.d.mts +5999 -0
- package/dist/{types-DWILGrPn.d.mts → types-C47fKNcn.d.mts} +93 -20
- package/dist/types-CqkrEY06.d.mts +1734 -0
- package/dist/types-CxZy7Pi4.d.mts +1210 -0
- package/dist/{define-sFoO3y6X.d.mts → types-DmhTHRVW.d.mts} +180 -51
- package/dist/{types-yg_ywtT-.d.mts → types-X9jXjka3.d.mts} +230 -31
- package/dist/{visual-BDUHSRvf.mjs → visual-NPrDkvUk.mjs} +19 -13
- package/package.json +22 -2
- package/dist/headless-CvamCUcR.mjs +0 -186
- package/dist/headless-KaSWcd0s.d.mts +0 -181
- package/dist/types-BxkNNYul.d.mts +0 -2840
- package/dist/types-CTPS9GBu.d.mts +0 -742
- package/dist/types-DD-QrG_z.d.mts +0 -588
- package/dist/types-DYLnSgMI.d.mts +0 -570
- package/dist/types-JNc_UQBo.d.mts +0 -2896
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { c as Source, d as HeadlessApp, n as Command, o as InputSchema } from "./types-DmhTHRVW.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/flow/doors/define.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Declares a source: a read-only view the editor lists, reads and watches. The types flow from
|
|
6
|
+
* the object: the input from `input`, the app from the `read` parameter, the output from its
|
|
7
|
+
* result.
|
|
8
|
+
*
|
|
9
|
+
* @param source - The descriptor.
|
|
10
|
+
* @returns The same descriptor, frozen.
|
|
11
|
+
* @throws {Error} When the id is not a dotted name such as `"game.position"`.
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // A game's .dev module: the orders on the board, re-read after every edge.
|
|
15
|
+
* export const orders = defineSource({
|
|
16
|
+
* id: "timber.orders",
|
|
17
|
+
* title: "Orders",
|
|
18
|
+
* input: {},
|
|
19
|
+
* changes: "edge",
|
|
20
|
+
* read: app => app.flow.state().path
|
|
21
|
+
* });
|
|
22
|
+
* read(app, orders); // "board/awaitIntent"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function defineSource<S extends InputSchema, O, App = HeadlessApp>(source: Source<S, O, App>): Source<S, O, App>;
|
|
26
|
+
/**
|
|
27
|
+
* Declares a command: a dev-only action the editor lists and runs. Its body starts with the
|
|
28
|
+
* inline dev guard, so a production build drops it.
|
|
29
|
+
*
|
|
30
|
+
* @param command - The descriptor.
|
|
31
|
+
* @returns The same descriptor, frozen.
|
|
32
|
+
* @throws {Error} When the id is not a dotted name such as `"game.answer"`.
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // A game's .dev module: open the shop from anywhere, through the graph.
|
|
36
|
+
* export const openShop = defineCommand({
|
|
37
|
+
* id: "timber.openShop",
|
|
38
|
+
* title: "Open the shop",
|
|
39
|
+
* input: {},
|
|
40
|
+
* effect: "route",
|
|
41
|
+
* run: app => {
|
|
42
|
+
* if (typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) throw controlRefused();
|
|
43
|
+
* return app.flow.walk([{ at: "home", intent: "shop" }]);
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* (await run(app, openShop)).state.path; // "shop"
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function defineCommand<S extends InputSchema, O, App = HeadlessApp>(command: Command<S, O, App>): Command<S, O, App>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { defineSource as n, defineCommand as t };
|
|
@@ -381,4 +381,33 @@ function graphHash(graph) {
|
|
|
381
381
|
return hashText(stableJson(graph));
|
|
382
382
|
}
|
|
383
383
|
//#endregion
|
|
384
|
-
|
|
384
|
+
//#region src/plugins/flow/doors/dev.ts
|
|
385
|
+
/**
|
|
386
|
+
* Reads the dev flag at call time. Undefined means off: production is the default.
|
|
387
|
+
*
|
|
388
|
+
* @returns True only when `__MOKU_GAME_DEV__` is exactly `true`.
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts
|
|
391
|
+
* // The dev page set the flag in web/dev.ts before the engine started.
|
|
392
|
+
* globalThis.__MOKU_GAME_DEV__ = true;
|
|
393
|
+
* isDev(); // true
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
function isDev() {
|
|
397
|
+
return typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__ === true;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Builds the error a control command throws outside a dev build.
|
|
401
|
+
*
|
|
402
|
+
* @returns The error, ready to throw.
|
|
403
|
+
* @example
|
|
404
|
+
* ```ts
|
|
405
|
+
* // A production build called a /control command.
|
|
406
|
+
* controlRefused().message; // "[game] Control commands run in dev builds only.\n Define __MOKU_GAME_DEV__ as true in the dev build."
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
function controlRefused() {
|
|
410
|
+
return /* @__PURE__ */ new Error("[game] Control commands run in dev builds only.\n Define __MOKU_GAME_DEV__ as true in the dev build.");
|
|
411
|
+
}
|
|
412
|
+
//#endregion
|
|
413
|
+
export { findNode as a, slotNames as c, describeGraph as i, compact as l, isDev as n, framePath as o, collectFlows as r, graphHash as s, controlRefused as t, pushEntry as u };
|