@moku-labs/game 0.9.0 → 0.10.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 (53) hide show
  1. package/README.md +81 -22
  2. package/bin/moku-game.mjs +4 -0
  3. package/dist/app/page.d.mts +41 -0
  4. package/dist/app/page.mjs +376 -0
  5. package/dist/app/system.d.mts +129 -0
  6. package/dist/app/system.mjs +307 -0
  7. package/dist/app.d.mts +37 -0
  8. package/dist/app.mjs +235 -0
  9. package/dist/assets-BHwTLVta.mjs +7391 -0
  10. package/dist/assets.d.mts +1 -1
  11. package/dist/assets.mjs +1 -7390
  12. package/dist/cli.d.mts +70 -0
  13. package/dist/cli.mjs +1650 -0
  14. package/dist/{commands-DuwCxK5t.d.mts → commands-C4QlqijJ.d.mts} +5 -5
  15. package/dist/config-CdARrrhU.mjs +81 -0
  16. package/dist/control.d.mts +11 -10
  17. package/dist/control.mjs +3 -3
  18. package/dist/{define-B6pHpdBi.d.mts → define-CCc0ozKe.d.mts} +2 -2
  19. package/dist/{dev-wKLgOw7c.mjs → dev-Cc50Dk7H.mjs} +1 -1
  20. package/dist/drafts-BawpSaVp.mjs +156 -0
  21. package/dist/fake-MpzwZhIZ.mjs +87 -0
  22. package/dist/{headless-SCQXJxQf.d.mts → headless-G4nuZ-xz.d.mts} +1 -1
  23. package/dist/hot.d.mts +4 -6
  24. package/dist/hot.mjs +8 -9
  25. package/dist/{index-BO9kZzY3.d.mts → index-xxSxKJJW.d.mts} +17 -17
  26. package/dist/index.d.mts +5 -5
  27. package/dist/index.mjs +1 -1
  28. package/dist/inspect-la_KkjCS.mjs +1 -0
  29. package/dist/inspect.d.mts +7 -7
  30. package/dist/inspect.mjs +3 -2
  31. package/dist/jsx-dev-runtime.d.mts +1 -1
  32. package/dist/jsx-runtime.d.mts +1 -1
  33. package/dist/lint.mjs +10 -6
  34. package/dist/memory-CWlqhS7l.mjs +136 -0
  35. package/dist/memory-DwDhfFWK.d.mts +50 -0
  36. package/dist/project.mjs +3 -3
  37. package/dist/{run-CofJEdYx.mjs → run-wYty_Lwo.mjs} +2 -2
  38. package/dist/{runtime-CdNJ0UBm.d.mts → runtime-DOBYM6g4.d.mts} +1 -1
  39. package/dist/{input-z_35Jwfn.mjs → session-DgukhR_7.mjs} +20 -20
  40. package/dist/{sources-DNnzyCYf.mjs → sources-Duzj6lhV.mjs} +2 -2
  41. package/dist/{src-536arXjV.mjs → src-DSl1eNB1.mjs} +14 -292
  42. package/dist/testing.d.mts +4 -50
  43. package/dist/testing.mjs +3 -87
  44. package/dist/{types-VZVWwqCg.d.mts → types-BM4shh8K.d.mts} +259 -259
  45. package/dist/{types-xXfyk56Q.d.mts → types-BUwDHKXm.d.mts} +1377 -1377
  46. package/dist/{types-CQueODzo.d.mts → types-CefgYzFt.d.mts} +2 -2
  47. package/dist/{types-DUMoYPYe.d.mts → types-DAdwEJMp.d.mts} +2 -2
  48. package/dist/{types-B0v5VVa3.d.mts → types-ZQLYXo5X.d.mts} +304 -304
  49. package/dist/types-hQgI_wrq.d.mts +544 -0
  50. package/dist/visual.d.mts +6 -6
  51. package/dist/visual.mjs +5 -5
  52. package/llms.txt +119 -43
  53. package/package.json +30 -2
package/dist/cli.d.mts ADDED
@@ -0,0 +1,70 @@
1
+ //#region src/cli.d.ts
2
+ /**
3
+ * What the dev page of `preparePage` is written with besides the game.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * // The editor against an engine working tree: its agent on the page, the tree's recipe in Bun.
8
+ * const options: PreparePageOptions = {
9
+ * agents: ["@moku-labs/editor/agent/page"],
10
+ * preload: ["../engine/scripts/tree/preload.ts"],
11
+ * servePlugins: ["../engine/scripts/tree/bundle.ts"]
12
+ * };
13
+ * ```
14
+ */
15
+ type PreparePageOptions = {
16
+ /** Agent modules the dev page passes to startPage, in order. Each default-exports a PageAgent. Bare specifiers or absolute paths. */agents?: readonly string[]; /** Files Bun preloads in the serving process. Relative paths resolve against the cwd. */
17
+ preload?: readonly string[]; /** Bun plugins the dev page bundles with, after the hot plugin. Relative paths resolve against the cwd. */
18
+ servePlugins?: readonly string[];
19
+ };
20
+ /**
21
+ * The written dev page: what a Bun server imports, and the config it runs under.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // The editor re-runs itself under the page's bunfig, in the game folder.
26
+ * const { html, bunfig } = await preparePage("games/timber");
27
+ * Bun.spawn([process.execPath, `--config=${bunfig}`, Bun.main, html, "--root", "games/timber"], { cwd: "games/timber" });
28
+ * ```
29
+ */
30
+ type PreparedPage = {
31
+ /** Absolute path of `<root>/.moku/index.html`: the HTML a Bun server imports. */html: string; /** Absolute path of `<root>/.moku/bunfig.toml`: pass it as `bun --config=<bunfig>`. */
32
+ bunfig: string;
33
+ };
34
+ /**
35
+ * Runs one `moku-game` command line in this process: `dev`, `build`, `native <verb>`, `keys`,
36
+ * `pack` or `help`, with `--root`, `--preload` and `--serve-plugin` before or after the command
37
+ * word. Every line goes through the branded console; nothing exits the process.
38
+ *
39
+ * @param argv - The arguments after the bin.
40
+ * @returns The exit code.
41
+ * @example
42
+ * ```ts
43
+ * // bin/moku-game.mjs in a game folder:
44
+ * await runCli(["dev", "--port", "0"]); // 0 after Ctrl+C; stdout had "http://localhost:<port>/"
45
+ * await runCli(["help"]); // 0
46
+ * ```
47
+ */
48
+ declare function runCli(argv: readonly string[]): Promise<number>;
49
+ /**
50
+ * Writes a game's dev page into `<root>/.moku/` for a server the caller starts: `index.html`,
51
+ * `dev.ts`, `main.ts` with the scenarios of `tests/scenarios/` (and, with agents, the agents and
52
+ * the game's `.dev` modules), and `bunfig.toml` with the engine's hot plugin. It starts no server
53
+ * and no watcher, and throws the `[game]` errors of `moku-game dev`.
54
+ *
55
+ * @param root - The game folder, relative to the cwd or absolute.
56
+ * @param options - The agents, the preloads and the extra bundler plugins.
57
+ * @returns The absolute paths of the HTML and the bunfig.
58
+ * @throws {Error} When the game has no `config.ts` or `index.ts`, a config value is refused, the
59
+ * game does not resolve `@moku-labs/game/hot`, or a preload or plugin is not a file.
60
+ * @example
61
+ * ```ts
62
+ * // The editor bin, started with --root games/timber:
63
+ * const { preparePage } = await import(Bun.resolveSync("@moku-labs/game/cli", root));
64
+ * await preparePage("games/timber", { agents: ["@moku-labs/editor/agent/page"] });
65
+ * // { html: "<cwd>/games/timber/.moku/index.html", bunfig: "<cwd>/games/timber/.moku/bunfig.toml" }
66
+ * ```
67
+ */
68
+ declare function preparePage(root: string, options?: PreparePageOptions): Promise<PreparedPage>;
69
+ //#endregion
70
+ export { PreparePageOptions, PreparedPage, preparePage, runCli };