@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.
Files changed (42) hide show
  1. package/README.md +8 -5
  2. package/dist/assets.d.mts +97 -33
  3. package/dist/assets.mjs +350 -110
  4. package/dist/{capture-BX5Gfoty.mjs → capture-fpd83Mi5.mjs} +384 -1
  5. package/dist/{commands-C1kIfOG5.d.mts → commands-DuwCxK5t.d.mts} +5 -6
  6. package/dist/control.d.mts +4 -4
  7. package/dist/control.mjs +1 -1
  8. package/dist/{define-BPpZcpxW.d.mts → define-B6pHpdBi.d.mts} +2 -2
  9. package/dist/{headless-CvamCUcR.mjs → headless-BsNdJs9W.mjs} +1 -1
  10. package/dist/{headless-q98SwADR.d.mts → headless-SCQXJxQf.d.mts} +1 -1
  11. package/dist/hot.d.mts +4 -2
  12. package/dist/hot.mjs +8 -6
  13. package/dist/index-BO9kZzY3.d.mts +1611 -0
  14. package/dist/index.d.mts +6 -1597
  15. package/dist/index.mjs +4 -34343
  16. package/dist/inspect.d.mts +7 -8
  17. package/dist/inspect.mjs +1 -1
  18. package/dist/jsx-dev-runtime.d.mts +1 -1
  19. package/dist/jsx-runtime.d.mts +1 -1
  20. package/dist/lint.d.mts +55 -4
  21. package/dist/lint.mjs +993 -40
  22. package/dist/project.d.mts +29 -13
  23. package/dist/project.mjs +986 -497
  24. package/dist/{run-CUPSFM85.mjs → run-CofJEdYx.mjs} +2 -2
  25. package/dist/{runtime-CvDZZg1S.d.mts → runtime-CdNJ0UBm.d.mts} +1 -1
  26. package/dist/{sources-BBUd15vQ.mjs → sources-DNnzyCYf.mjs} +1 -1
  27. package/dist/src-536arXjV.mjs +34644 -0
  28. package/dist/testing.d.mts +130 -3
  29. package/dist/testing.mjs +192 -3
  30. package/dist/{types-BWzCSRM2.d.mts → types-B0v5VVa3.d.mts} +2982 -19
  31. package/dist/{types-DF5kkW-C.d.mts → types-CQueODzo.d.mts} +4 -5
  32. package/dist/{types-CDSKa0vl.d.mts → types-DUMoYPYe.d.mts} +2 -2
  33. package/dist/{types-DlgsfOmW.d.mts → types-VZVWwqCg.d.mts} +49 -12
  34. package/dist/{types-DgdMLZnV.d.mts → types-xXfyk56Q.d.mts} +7 -8
  35. package/dist/{visual-DUvvPPCt.mjs → visual-dMW8iqAE.mjs} +8 -4
  36. package/dist/visual.d.mts +10 -11
  37. package/dist/visual.mjs +2 -2
  38. package/llms.txt +55 -18
  39. package/package.json +1 -1
  40. package/dist/memory-CvgdnsQO.mjs +0 -259
  41. package/dist/registry-DlpRCibU.mjs +0 -384
  42. package/dist/types-ERb2Y9U5.d.mts +0 -2967
@@ -4,8 +4,9 @@
4
4
  * it holds, the anchors of a key, the fresh lines `find` answers and the handle itself. The index
5
5
  * maps every engine id of a game (flows, nodes, features, scenes, projections, emitters, text
6
6
  * styles, styles, components and JSX keys) to anchors: a path plus a binding, a key or a component. It never
7
- * holds a line number; `find` reads the line from the file as it is on disk at the call. No type
8
- * here names a `typescript` type, so the shipped declarations need no TypeScript.
7
+ * holds a line number; `find` reads the line from the file as it is on disk at the call. Names are
8
+ * followed through relative imports and the tsconfig `paths` of the game. No type here names a
9
+ * `typescript` type, so the shipped declarations need no TypeScript.
9
10
  */
10
11
  /**
11
12
  * What `openProject` reads. Paths are root-relative POSIX; the root itself is resolved against the
@@ -15,11 +16,18 @@
15
16
  * ```ts
16
17
  * // The editor opens the mini game with the default manifest and a slower debounce.
17
18
  * const options: ProjectOptions = { root: "tests/fixtures/mini-game", debounceMs: 120 };
19
+ * // A v15 game whose aliases live in a second tsconfig.
20
+ * const game: ProjectOptions = { root: "games/orders", tsconfig: "tsconfig.game.json" };
18
21
  * ```
19
22
  */
20
23
  type ProjectOptions = {
21
24
  /** The folder of the game. A path that is not a directory rejects `openProject`. */root: string; /** The asset manifest, root-relative. Default `manifest.json`, the scanner's default. */
22
- manifest?: string; /** The quiet period, in milliseconds, that closes a batch of file events. Default 75. */
25
+ manifest?: string;
26
+ /**
27
+ * The tsconfig whose `paths` the index follows, root-relative. Default `tsconfig.json`. A path
28
+ * that leaves the root or a file that does not parse rejects `openProject`.
29
+ */
30
+ tsconfig?: string; /** The quiet period, in milliseconds, that closes a batch of file events. Default 75. */
23
31
  debounceMs?: number;
24
32
  };
25
33
  /**
@@ -68,12 +76,15 @@ type Anchor = {
68
76
  * ```ts
69
77
  * index.symbols["flow:infoPopup"]; // { def: [{ path: "flows/info.ts", binding: "infoFlow" }] }
70
78
  * index.files["nodes/count.ts"]?.state; // "ok"
79
+ * // A game whose tsconfig.json holds paths, such as tests/fixtures/layout-game.
80
+ * index.tsconfig; // "tsconfig.json"
71
81
  * ```
72
82
  */
73
83
  type ProjectIndex = {
74
84
  /** The shape of this object. A change of shape bumps it. */schemaVersion: 1; /** sha1 hex over the sorted lines `${path}\0${hash}\n` of every indexed file. */
75
85
  revision: string; /** The asset manifest, root-relative, when that file exists. */
76
- manifest?: string;
86
+ manifest?: string; /** The tsconfig, root-relative, when that file exists and holds `paths` the index follows. */
87
+ tsconfig?: string;
77
88
  /**
78
89
  * Every key: where it is defined (`def`), where its binding is used (`uses`, nodes, styles and
79
90
  * components, one level), and `conflict` when a key other than `jsx:` is defined twice.
@@ -150,12 +161,13 @@ type ProjectApi = {
150
161
  */
151
162
  readonly index: ProjectIndex;
152
163
  /**
153
- * Answers where a key is defined, with lines read from the file on disk now. A file whose bytes
154
- * changed since the index was built is parsed again for the answer; the index itself stays as
155
- * it is until the next watch batch. A JSX key the game reports at run time also finds the
156
- * patterns it was built from: exact keys first, then `{id}` and `{amountKey}` patterns filled
157
- * with a literal prop of the same name on their component (both the pattern and the prop come
158
- * back), then `*` patterns. An unknown key answers `[]`.
164
+ * Answers where a key is defined, with lines read from the file on disk now. A name is followed
165
+ * through relative imports and the tsconfig aliases, so `@features/home` reaches the file that
166
+ * declares the node. A file whose bytes changed since the index was built is parsed again for
167
+ * the answer; the index itself stays as it is until the next watch batch. A JSX key the game
168
+ * reports at run time also finds the patterns it was built from: exact keys first, then `{id}`
169
+ * and `{amountKey}` patterns filled with a literal prop of the same name on their component
170
+ * (both the pattern and the prop come back), then `*` patterns. An unknown key answers `[]`.
159
171
  *
160
172
  * @param key - An engine id: `node:infoPopup/count`, `flow:main`, `textStyle:ui.counter`, `jsx:infoPanelSpark`.
161
173
  * @returns One entry per place, in the order above; `broken` when the file does not parse now.
@@ -190,8 +202,9 @@ type ProjectApi = {
190
202
  watch(onIndex: (index: ProjectIndex, change: ProjectChange) => void): () => void;
191
203
  /**
192
204
  * Re-indexes one root-relative path now, for a caller that watches files itself. A deleted
193
- * file drops its entries; a path that is not a `.ts` or `.tsx` source of the index changes
194
- * nothing. The watch callers are not called.
205
+ * file drops its entries. The tsconfig, or a file it extends, reads the aliases again, and the
206
+ * index is rebuilt when names now follow them elsewhere. Any other path that is not a `.ts` or
207
+ * `.tsx` source of the index changes nothing. The watch callers are not called.
195
208
  *
196
209
  * @param path - The root-relative POSIX path of the file.
197
210
  * @returns The index after the file was read.
@@ -201,6 +214,8 @@ type ProjectApi = {
201
214
  * // The editor saved nodes/count.ts through its own file layer.
202
215
  * const index = await project.changed("nodes/count.ts");
203
216
  * index.files["nodes/count.ts"]?.state; // "ok"
217
+ * // It added a paths block to tsconfig.json: the keys behind the aliases join the index.
218
+ * (await project.changed("tsconfig.json")).tsconfig; // "tsconfig.json"
204
219
  * ```
205
220
  */
206
221
  changed(path: string): Promise<ProjectIndex>;
@@ -260,7 +275,8 @@ declare function runCli(argv: readonly string[], ui?: IndexUi): Promise<number>;
260
275
  * path), loads TypeScript, parses every source file and builds the index. Nothing is written to
261
276
  * disk and nothing is inferred from the working directory but the root itself.
262
277
  *
263
- * @param options - The game root, the manifest path and the quiet period of `watch`.
278
+ * @param options - The game root, the manifest path, the tsconfig whose `paths` the index follows
279
+ * (`tsconfig`, root-relative, `tsconfig.json` by default) and the quiet period of `watch`.
264
280
  * @returns The handle; close it when the game closes.
265
281
  * @throws {Error} When the root is missing or not a directory, or the `typescript` package is not
266
282
  * installed: `[game] The project index needs the "typescript" package.`