@moku-labs/game 0.7.1 → 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 (40) hide show
  1. package/README.md +12 -8
  2. package/dist/assets.d.mts +97 -33
  3. package/dist/assets.mjs +350 -110
  4. package/dist/{commands-mzE9PX0H.d.mts → commands-DuwCxK5t.d.mts} +5 -4
  5. package/dist/control.d.mts +4 -3
  6. package/dist/control.mjs +2 -2
  7. package/dist/{define-BbgXv4cy.d.mts → define-B6pHpdBi.d.mts} +4 -3
  8. package/dist/headless-BsNdJs9W.mjs +186 -0
  9. package/dist/headless-SCQXJxQf.d.mts +181 -0
  10. package/dist/hot.d.mts +4 -2
  11. package/dist/hot.mjs +8 -6
  12. package/dist/index-BO9kZzY3.d.mts +1611 -0
  13. package/dist/index.d.mts +6 -1596
  14. package/dist/index.mjs +4 -34334
  15. package/dist/{input-CK4nxBO1.mjs → input-z_35Jwfn.mjs} +2 -2
  16. package/dist/inspect.d.mts +7 -6
  17. package/dist/inspect.mjs +2 -2
  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 +57 -41
  23. package/dist/project.mjs +994 -505
  24. package/dist/{run-Bcyg32M5.mjs → run-CofJEdYx.mjs} +4 -187
  25. package/dist/{runtime-HTlmRb81.d.mts → runtime-CdNJ0UBm.d.mts} +1 -1
  26. package/dist/{sources-DVWJ8nfr.mjs → sources-DNnzyCYf.mjs} +2 -2
  27. package/dist/src-536arXjV.mjs +34644 -0
  28. package/dist/testing.d.mts +85 -283
  29. package/dist/testing.mjs +158 -2109
  30. package/dist/{types-BMEn0tSC.d.mts → types-B0v5VVa3.d.mts} +10 -9
  31. package/dist/{types-ClF8say0.d.mts → types-CQueODzo.d.mts} +2 -2
  32. package/dist/{types-CYYKjvLn.d.mts → types-DUMoYPYe.d.mts} +5 -182
  33. package/dist/{types-CXyipKhE.d.mts → types-VZVWwqCg.d.mts} +42 -4
  34. package/dist/{types-BaUUcIaN.d.mts → types-xXfyk56Q.d.mts} +1 -1
  35. package/dist/{visual-DUvvPPCt.mjs → visual-dMW8iqAE.mjs} +8 -4
  36. package/dist/visual.d.mts +330 -0
  37. package/dist/visual.mjs +2142 -0
  38. package/llms.txt +59 -21
  39. package/package.json +7 -8
  40. package/dist/memory-CvgdnsQO.mjs +0 -259
@@ -24,7 +24,7 @@ function checkId(kind, id) {
24
24
  * ```ts
25
25
  * // A game's .dev module: the orders on the board, re-read after every edge.
26
26
  * export const orders = defineSource({
27
- * id: "timber.orders",
27
+ * id: "mini.orders",
28
28
  * title: "Orders",
29
29
  * input: {},
30
30
  * changes: "edge",
@@ -49,7 +49,7 @@ function defineSource(source) {
49
49
  * ```ts
50
50
  * // A game's .dev module: open the shop from anywhere, through the graph.
51
51
  * export const openShop = defineCommand({
52
- * id: "timber.openShop",
52
+ * id: "mini.openShop",
53
53
  * title: "Open the shop",
54
54
  * input: {},
55
55
  * effect: "route",
@@ -1,9 +1,10 @@
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-BMEn0tSC.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-CYYKjvLn.mjs";
3
- import { c as UiNode } from "./types-BaUUcIaN.mjs";
4
- import { a as SoundEntry, t as AudioApi, v as UiApi } from "./types-CXyipKhE.mjs";
5
- import { n as defineSource } from "./define-BbgXv4cy.mjs";
6
- import { n as EffectsApi, r as EffectsStats } from "./types-ClF8say0.mjs";
1
+ import { Gt as Api, H as EntitySnapshot, R as ComponentSchema, U as FrameDiff, f as Usage, gt as Position, j as Explained, jt as JournalEntry, k as Api$1, kt as FlowGraph, m as Api$2, rn as Snapshot, t as Api$3, w as RenderStats, x as Under } from "./types-B0v5VVa3.mjs";
2
+ import { t as HeadlessApp } from "./headless-SCQXJxQf.mjs";
3
+ import { a as InputOf, c as Source, i as InputArguments, l as WatchApp, o as InputSchema, t as CheatEntry, u as WatchInput } from "./types-DUMoYPYe.mjs";
4
+ import { c as UiNode } from "./types-xXfyk56Q.mjs";
5
+ import { a as SoundEntry, t as AudioApi, v as UiApi } from "./types-VZVWwqCg.mjs";
6
+ import { n as defineSource } from "./define-B6pHpdBi.mjs";
7
+ import { n as EffectsApi, r as EffectsStats } from "./types-CQueODzo.mjs";
7
8
 
8
9
  //#region src/plugins/flow/doors/read.d.ts
9
10
  /**
package/dist/inspect.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { c as defineSource } from "./input-CK4nxBO1.mjs";
2
- import { n as read, r as watch, t as sources } from "./sources-DVWJ8nfr.mjs";
1
+ import { c as defineSource } from "./input-z_35Jwfn.mjs";
2
+ import { n as read, r as watch, t as sources } from "./sources-DNnzyCYf.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-HTlmRb81.mjs";
1
+ import { a as jsxs, i as jsxDEV, n as JSX, r as jsx, t as Fragment } from "./runtime-CdNJ0UBm.mjs";
2
2
  export { Fragment, type JSX, jsx, jsxDEV, jsxs };
@@ -1,2 +1,2 @@
1
- import { a as jsxs, n as JSX, r as jsx, t as Fragment } from "./runtime-HTlmRb81.mjs";
1
+ import { a as jsxs, n as JSX, r as jsx, t as Fragment } from "./runtime-CdNJ0UBm.mjs";
2
2
  export { Fragment, type JSX, jsx, jsxs };
package/dist/lint.d.mts CHANGED
@@ -1,9 +1,41 @@
1
1
  //#region src/lint.d.ts
2
- /** The options every rule takes: which files it checks. A key given replaces the rule's default. */
2
+ /**
3
+ * The options every rule takes: which files it checks. A key given replaces the rule's default.
4
+ *
5
+ * @example
6
+ * ```json
7
+ * "moku-game/determinism": ["error", { "files": ["src/logic/**"], "ignores": ["src/logic/*.dev.ts"] }]
8
+ * ```
9
+ */
3
10
  type GameLintOptions = {
4
11
  /** Globs of the files the rule checks, relative to the directory oxlint runs in. */files?: string[]; /** Globs of the files the rule skips, even when `files` matches them. */
5
12
  ignores?: string[];
6
13
  };
14
+ /**
15
+ * The options of the layout rules `layer-imports`, `feature-door` and `rules-siblings`: the files,
16
+ * where the layers sit and which tsconfig names the aliases.
17
+ *
18
+ * @example
19
+ * ```json
20
+ * "moku-game/layer-imports": ["error", { "root": "src", "tsconfig": "tsconfig.game.json" }]
21
+ * ```
22
+ */
23
+ type GameLintLayoutOptions = GameLintOptions & {
24
+ /** The folder of `core/`, `shared/`, `features/`, `plugins/` and `game.ts`, relative to the directory oxlint runs in. Default `.`. */root?: string; /** The tsconfig whose `paths` name the aliases, relative to the directory oxlint runs in. Default `tsconfig.json`. */
25
+ tsconfig?: string;
26
+ };
27
+ /**
28
+ * The options of `test-suffix`: the files, the game root and the suffix of each test kind folder.
29
+ *
30
+ * @example
31
+ * ```json
32
+ * "moku-game/test-suffix": ["error", { "root": "src", "suffixes": { "tests/e2e/": ".spec.ts" } }]
33
+ * ```
34
+ */
35
+ type GameLintSuffixOptions = GameLintOptions & {
36
+ /** The folder whose test files the rule reads, relative to the directory oxlint runs in. Default `.`. */root?: string; /** Kind folder to the suffix of its files, as `{ "tests/e2e/": ".e2e.ts" }`. Replaces the default table. */
37
+ suffixes?: Record<string, string>;
38
+ };
7
39
  /** The part of an ESTree node the rules read. oxlint and ESLint hand over full nodes. */
8
40
  type GameLintNode = {
9
41
  readonly type: string; /** A string on an `Identifier`; the `JSXIdentifier` node on a `JSXAttribute`. */
@@ -67,7 +99,7 @@ type GameLintRule = {
67
99
  };
68
100
  create(context: GameLintContext): GameLintListeners;
69
101
  };
70
- /** The plugin object: `moku-game` and its seven rules. */
102
+ /** The plugin object: `moku-game` and its ten rules. */
71
103
  type GameLintPlugin = {
72
104
  readonly meta: {
73
105
  readonly name: "moku-game";
@@ -75,7 +107,7 @@ type GameLintPlugin = {
75
107
  readonly rules: Readonly<Record<GameLintRuleName, GameLintRule>>;
76
108
  };
77
109
  /** The rule names, without the `moku-game/` prefix. */
78
- type GameLintRuleName = "lazy-imports" | "native-imports" | "dev-imports" | "no-module-state" | "determinism" | "rules-siblings" | "static-keys";
110
+ type GameLintRuleName = "lazy-imports" | "native-imports" | "dev-imports" | "no-module-state" | "determinism" | "rules-siblings" | "static-keys" | "layer-imports" | "feature-door" | "test-suffix";
79
111
  /**
80
112
  * Turn a glob into an anchored regular expression: `**`, `*`, `?` and one level of `{a,b}`.
81
113
  *
@@ -87,6 +119,25 @@ type GameLintRuleName = "lazy-imports" | "native-imports" | "dev-imports" | "no-
87
119
  * ```
88
120
  */
89
121
  declare function globToRegExp(glob: string): RegExp;
122
+ /**
123
+ * The files a module specifier names through the aliases the layout rules read: the nearest
124
+ * `paths` of the tsconfig and the configs it extends by relative path, else the v15 aliases under
125
+ * the game root. A specifier is matched as TypeScript matches it; `@moku-labs/game` is a package
126
+ * even when the paths map it. The project index maps a specifier the same way, and a unit test
127
+ * keeps the two in step.
128
+ *
129
+ * @param tsconfig - The absolute path of the tsconfig.
130
+ * @param root - The absolute folder of the layers; the v15 aliases resolve against it.
131
+ * @param specifier - The module specifier as written.
132
+ * @returns The absolute targets in the order of the tsconfig; `[]` for a relative specifier, the
133
+ * engine and a package.
134
+ * @example
135
+ * ```ts
136
+ * // A game without a tsconfig reads the v15 aliases.
137
+ * aliasTargetsOf("/game/tsconfig.json", "/game", "@features/orders"); // ["/game/features/orders/index.ts"]
138
+ * ```
139
+ */
140
+ declare function aliasTargetsOf(tsconfig: string, root: string, specifier: string): string[];
90
141
  /**
91
142
  * The `moku-game` oxlint plugin. A game loads it by package name and turns its rules on.
92
143
  *
@@ -97,4 +148,4 @@ declare function globToRegExp(glob: string): RegExp;
97
148
  */
98
149
  declare const plugin: GameLintPlugin;
99
150
  //#endregion
100
- export { GameLintContext, GameLintDefinition, GameLintListeners, GameLintNode, GameLintOptions, GameLintPlugin, GameLintRule, GameLintRuleName, GameLintScope, plugin as default, globToRegExp };
151
+ export { GameLintContext, GameLintDefinition, GameLintLayoutOptions, GameLintListeners, GameLintNode, GameLintOptions, GameLintPlugin, GameLintRule, GameLintRuleName, GameLintScope, GameLintSuffixOptions, aliasTargetsOf, plugin as default, globToRegExp };