@moku-labs/game 0.2.0 → 0.4.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.
Files changed (35) hide show
  1. package/README.md +2 -0
  2. package/dist/assets.d.mts +181 -22
  3. package/dist/assets.mjs +1186 -160
  4. package/dist/{commands-C0BljsM5.d.mts → commands-DYO22lzi.d.mts} +22 -5
  5. package/dist/control.d.mts +3 -3
  6. package/dist/control.mjs +3 -3
  7. package/dist/{define-CjP_4H0G.d.mts → define-BKWjWgyQ.d.mts} +1 -1
  8. package/dist/dev-CQYJPmcD.mjs +1183 -0
  9. package/dist/flatten-BkXuscAV.mjs +100 -0
  10. package/dist/index.d.mts +85 -31
  11. package/dist/index.mjs +3208 -490
  12. package/dist/{session-DmAxY6Ll.mjs → input-CK4nxBO1.mjs} +41 -12
  13. package/dist/inspect.d.mts +32 -9
  14. package/dist/inspect.mjs +2 -2
  15. package/dist/jsx-dev-runtime.d.mts +1 -1
  16. package/dist/jsx-dev-runtime.mjs +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/jsx-runtime.mjs +1 -1
  19. package/dist/{run-tlcn1w7y.mjs → run-BfuMLahc.mjs} +489 -213
  20. package/dist/{runtime-Bn5TXNxP.d.mts → runtime-Bhu442L8.d.mts} +1 -1
  21. package/dist/{runtime-DRlwxkIv.mjs → runtime-CBZgWgzx.mjs} +1 -57
  22. package/dist/{sources-BooL2MsX.mjs → sources-C1uGjz4l.mjs} +198 -21
  23. package/dist/testing.d.mts +5 -5
  24. package/dist/testing.mjs +5 -4
  25. package/dist/{types-CxZy7Pi4.d.mts → types-BnWH-75b.d.mts} +95 -21
  26. package/dist/{types-CqkrEY06.d.mts → types-CVUHPvMB.d.mts} +5 -434
  27. package/dist/{types-DmhTHRVW.d.mts → types-DtmFVCHf.d.mts} +1 -1
  28. package/dist/{types-BZ1OLf24.d.mts → types-Dy1xB68L.d.mts} +2318 -1169
  29. package/dist/{types-X9jXjka3.d.mts → types-VErbiEXy.d.mts} +867 -198
  30. package/dist/{visual-NPrDkvUk.mjs → visual-DUvvPPCt.mjs} +51 -1
  31. package/llms.txt +5 -5
  32. package/package.json +5 -5
  33. package/dist/component-DGg5DqKK.mjs +0 -44
  34. package/dist/dev-CcwFrwok.mjs +0 -413
  35. package/dist/types-C47fKNcn.d.mts +0 -695
@@ -67,23 +67,33 @@ function defineCommand(command) {
67
67
  return Object.freeze(command);
68
68
  }
69
69
  //#endregion
70
- //#region src/plugins/flow/doors/input.ts
71
- /** The input of a call that passed none. */
72
- const noInput = Object.freeze({});
70
+ //#region src/plugins/input/target.ts
73
71
  /**
74
- * Hands the given input on, or an empty one. `InputArguments` and `WatchInput` let a call leave
75
- * the input out only when every field of the schema is optional, so `{}` is an input of that
76
- * schema.
72
+ * Tells whether the JSON a command got names a view by its projection key.
77
73
  *
78
- * @param input - The input of the call, if any.
79
- * @returns The input to pass to the descriptor.
74
+ * @param value - The JSON.
75
+ * @returns True for an object with a string `projection` and a string `key`.
80
76
  * @example
81
77
  * ```ts
82
- * inputOrEmpty<{ last: "number?" }>(undefined); // {}
78
+ * isProjectionTarget({ projection: "board.items", key: "i5" }); // true
83
79
  * ```
84
80
  */
85
- function inputOrEmpty(input) {
86
- return input ?? noInput;
81
+ function isProjectionTarget(value) {
82
+ return typeof value === "object" && value !== null && !Array.isArray(value) && typeof value.projection === "string" && typeof value.key === "string";
83
+ }
84
+ /**
85
+ * Reads the projection key of a view out of the JSON a command got.
86
+ *
87
+ * @param value - The JSON: `{ projection, key }`.
88
+ * @returns The target, a fresh object.
89
+ * @throws {Error} When the JSON is not an object with a string `projection` and a string `key`.
90
+ */
91
+ function readTarget(value) {
92
+ if (isProjectionTarget(value)) return {
93
+ projection: value.projection,
94
+ key: value.key
95
+ };
96
+ throw new Error("[game] The target is not a projection key.\n Pass a view like { projection: \"board.items\", key: \"i5\" }.");
87
97
  }
88
98
  //#endregion
89
99
  //#region src/plugins/flow/doors/session.ts
@@ -142,4 +152,23 @@ function recordCheat(app, id, input, frame) {
142
152
  sessions.set(app, session);
143
153
  }
144
154
  //#endregion
145
- export { defineCommand as a, inputOrEmpty as i, isTainted as n, defineSource as o, recordCheat as r, cheatsOf as t };
155
+ //#region src/plugins/flow/doors/input.ts
156
+ /** The input of a call that passed none. */
157
+ const noInput = Object.freeze({});
158
+ /**
159
+ * Hands the given input on, or an empty one. `InputArguments` and `WatchInput` let a call leave
160
+ * the input out only when every field of the schema is optional, so `{}` is an input of that
161
+ * schema.
162
+ *
163
+ * @param input - The input of the call, if any.
164
+ * @returns The input to pass to the descriptor.
165
+ * @example
166
+ * ```ts
167
+ * inputOrEmpty<{ last: "number?" }>(undefined); // {}
168
+ * ```
169
+ */
170
+ function inputOrEmpty(input) {
171
+ return input ?? noInput;
172
+ }
173
+ //#endregion
174
+ export { isProjectionTarget as a, defineSource as c, recordCheat as i, cheatsOf as n, readTarget as o, isTainted as r, defineCommand as s, inputOrEmpty as t };
@@ -1,10 +1,9 @@
1
- import { $ as Position, Dt as Api, dt as FlowGraph, h as Api$1, l as RenderStats, pt as JournalEntry, t as Api$2, z as EntitySnapshot, zt as Snapshot } from "./types-BZ1OLf24.mjs";
2
- import { f as Usage, t as Api$3 } from "./types-C47fKNcn.mjs";
3
- import { a as InputOf, c as Source, d as HeadlessApp, i as InputArguments, l as WatchApp, o as InputSchema, t as CheatEntry, u as WatchInput } from "./types-DmhTHRVW.mjs";
4
- import { c as UiNode } from "./types-X9jXjka3.mjs";
5
- import { A as UiApi } from "./types-CqkrEY06.mjs";
6
- import { n as defineSource } from "./define-CjP_4H0G.mjs";
7
- import { _ as EffectsApi, a as SoundEntry, t as AudioApi, v as EffectsStats } from "./types-CxZy7Pi4.mjs";
1
+ import { At as JournalEntry, H as EntitySnapshot, Ot as FlowGraph, R as ComponentSchema, U as FrameDiff, Ut as Api, f as Usage, gt as Position, j as Explained, k as Api$1, m as Api$2, t as Api$3, tn as Snapshot, w as RenderStats, x as Under } from "./types-Dy1xB68L.mjs";
2
+ import { a as InputOf, c as Source, d as HeadlessApp, i as InputArguments, l as WatchApp, o as InputSchema, t as CheatEntry, u as WatchInput } from "./types-DtmFVCHf.mjs";
3
+ import { c as UiNode } from "./types-VErbiEXy.mjs";
4
+ import { A as UiApi } from "./types-CVUHPvMB.mjs";
5
+ import { n as defineSource } from "./define-BKWjWgyQ.mjs";
6
+ import { _ as EffectsApi, a as SoundEntry, t as AudioApi, v as EffectsStats } from "./types-BnWH-75b.mjs";
8
7
 
9
8
  //#region src/plugins/flow/doors/read.d.ts
10
9
  /**
@@ -76,8 +75,9 @@ declare const sources: Readonly<{
76
75
  ui: Source<{}, UiNode, HeadlessApp & {
77
76
  readonly ui: UiApi;
78
77
  }>;
79
- rect: Source<{
80
- key: "string";
78
+ locate: Source<{
79
+ key: "string?";
80
+ target: "json?";
81
81
  }, {
82
82
  x: number;
83
83
  y: number;
@@ -86,6 +86,8 @@ declare const sources: Readonly<{
86
86
  } | undefined, HeadlessApp & {
87
87
  readonly ui: UiApi;
88
88
  readonly renderer: Api$2;
89
+ } & {
90
+ readonly world: Api$1;
89
91
  }>;
90
92
  render: Source<{}, RenderStats, HeadlessApp & {
91
93
  readonly renderer: Api$2;
@@ -106,6 +108,27 @@ declare const sources: Readonly<{
106
108
  }, readonly import("@moku-labs/common/browser").LogEntry[], HeadlessApp & {
107
109
  readonly log: import("@moku-labs/common/browser").LogApi;
108
110
  }>;
111
+ explain: Source<{
112
+ entity: "number";
113
+ }, Explained | undefined, HeadlessApp & {
114
+ readonly world: Api$1;
115
+ }>;
116
+ diff: Source<{
117
+ from: "number";
118
+ to: "number";
119
+ }, FrameDiff, HeadlessApp & {
120
+ readonly world: Api$1;
121
+ }>;
122
+ schema: Source<{}, readonly ComponentSchema[], HeadlessApp & {
123
+ readonly world: Api$1;
124
+ }>;
125
+ at: Source<{
126
+ x: "number";
127
+ y: "number";
128
+ }, readonly Under[], HeadlessApp & {
129
+ readonly renderer: Api$2;
130
+ readonly world: Api$1;
131
+ }>;
109
132
  }>;
110
133
  //#endregion
111
134
  export { type InputOf, type InputSchema, type Source, defineSource, read, sources, watch };
package/dist/inspect.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { o as defineSource } from "./session-DmAxY6Ll.mjs";
2
- import { n as read, r as watch, t as sources } from "./sources-BooL2MsX.mjs";
1
+ import { c as defineSource } from "./input-CK4nxBO1.mjs";
2
+ import { n as read, r as watch, t as sources } from "./sources-C1uGjz4l.mjs";
3
3
  export { defineSource, read, sources, watch };
@@ -1,2 +1,2 @@
1
- import { a as jsxs, i as jsxDEV, n as JSX, r as jsx, t as Fragment } from "./runtime-Bn5TXNxP.mjs";
1
+ import { a as jsxs, i as jsxDEV, n as JSX, r as jsx, t as Fragment } from "./runtime-Bhu442L8.mjs";
2
2
  export { Fragment, type JSX, jsx, jsxDEV, jsxs };
@@ -1,2 +1,2 @@
1
- import { i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./runtime-DRlwxkIv.mjs";
1
+ import { i as jsxs, n as jsx, r as jsxDEV, t as Fragment } from "./runtime-CBZgWgzx.mjs";
2
2
  export { Fragment, jsx, jsxDEV, jsxs };
@@ -1,2 +1,2 @@
1
- import { a as jsxs, n as JSX, r as jsx, t as Fragment } from "./runtime-Bn5TXNxP.mjs";
1
+ import { a as jsxs, n as JSX, r as jsx, t as Fragment } from "./runtime-Bhu442L8.mjs";
2
2
  export { Fragment, type JSX, jsx, jsxs };
@@ -1,2 +1,2 @@
1
- import { i as jsxs, n as jsx, t as Fragment } from "./runtime-DRlwxkIv.mjs";
1
+ import { i as jsxs, n as jsx, t as Fragment } from "./runtime-CBZgWgzx.mjs";
2
2
  export { Fragment, jsx, jsxs };