@moku-labs/game 0.2.0 → 0.3.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 +2 -0
- package/dist/assets.d.mts +181 -22
- package/dist/assets.mjs +1186 -160
- package/dist/{commands-C0BljsM5.d.mts → commands-DYO22lzi.d.mts} +22 -5
- package/dist/control.d.mts +3 -3
- package/dist/control.mjs +3 -3
- package/dist/{define-CjP_4H0G.d.mts → define-BKWjWgyQ.d.mts} +1 -1
- package/dist/dev-CQYJPmcD.mjs +1183 -0
- package/dist/flatten-BkXuscAV.mjs +100 -0
- package/dist/index.d.mts +85 -31
- package/dist/index.mjs +3208 -490
- package/dist/{session-DmAxY6Ll.mjs → input-CK4nxBO1.mjs} +41 -12
- package/dist/inspect.d.mts +32 -9
- package/dist/inspect.mjs +2 -2
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-dev-runtime.mjs +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{run-tlcn1w7y.mjs → run-BfuMLahc.mjs} +489 -213
- package/dist/{runtime-Bn5TXNxP.d.mts → runtime-Bhu442L8.d.mts} +1 -1
- package/dist/{runtime-DRlwxkIv.mjs → runtime-CBZgWgzx.mjs} +1 -57
- package/dist/{sources-BooL2MsX.mjs → sources-C1uGjz4l.mjs} +198 -21
- package/dist/testing.d.mts +5 -5
- package/dist/testing.mjs +5 -4
- package/dist/{types-CxZy7Pi4.d.mts → types-BnWH-75b.d.mts} +95 -21
- package/dist/{types-CqkrEY06.d.mts → types-CVUHPvMB.d.mts} +5 -434
- package/dist/{types-DmhTHRVW.d.mts → types-DtmFVCHf.d.mts} +1 -1
- package/dist/{types-BZ1OLf24.d.mts → types-Dy1xB68L.d.mts} +2318 -1169
- package/dist/{types-X9jXjka3.d.mts → types-VErbiEXy.d.mts} +867 -198
- package/dist/{visual-NPrDkvUk.mjs → visual-DUvvPPCt.mjs} +51 -1
- package/llms.txt +5 -5
- package/package.json +5 -5
- package/dist/component-DGg5DqKK.mjs +0 -44
- package/dist/dev-CcwFrwok.mjs +0 -413
- package/dist/types-C47fKNcn.d.mts +0 -695
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ You write small nodes and edge tables. The engine runs them, saves on the edges
|
|
|
42
42
|
| V5 | Particles, WGSL filters, sprite frames, the production asset pack, a text field, visual tests. |
|
|
43
43
|
| V6 | `platform`: Back button, haptics, keep-awake. Filters on WebGL. The game as a Tauri app on iOS and Android. |
|
|
44
44
|
|
|
45
|
+
Strings are ICU messages with durations, translator notes, a pseudo-locale, and export and import for translators.
|
|
46
|
+
|
|
45
47
|
Rendering is WebGPU first, with Pixi's WebGL fallback. A device with neither gets an honest "unsupported device" screen.
|
|
46
48
|
|
|
47
49
|
## Install
|
package/dist/assets.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as Manifest } from "./types-
|
|
1
|
+
import { l as Manifest } from "./types-Dy1xB68L.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugins/assets/scan/cli.d.ts
|
|
4
4
|
/**
|
|
@@ -18,40 +18,103 @@ type StringsReport = {
|
|
|
18
18
|
notes: readonly string[];
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Compiles the feature strings of a root into a folder, or checks them in a check run
|
|
22
|
-
* `compileStrings` of i18n fits it, and a test
|
|
21
|
+
* Compiles the feature strings of a root into a folder, or checks them in a check run; with
|
|
22
|
+
* `pseudo` it writes the pseudo-locale `en-XA` too. `compileStrings` of i18n fits it, and a test
|
|
23
|
+
* passes a stub instead.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // A test of a wrapper script: a game with one English key.
|
|
28
|
+
* const compile: StringsCompiler = async () => ({ changed: false, locales: ["en"], keys: ["hud.title"], notes: [] });
|
|
29
|
+
* ```
|
|
23
30
|
*/
|
|
24
31
|
type StringsCompiler = (root: string, out: string, options: {
|
|
25
32
|
check: boolean;
|
|
33
|
+
pseudo: boolean;
|
|
26
34
|
}) => Promise<StringsReport>;
|
|
35
|
+
/**
|
|
36
|
+
* Writes one exchange file per locale for the translators into a folder, and reports how many
|
|
37
|
+
* keys each locale lacks. `exportStrings` of i18n fits it, and a test passes a stub instead.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // A test of a wrapper script: two locales, Russian three keys short.
|
|
42
|
+
* const exportStub: StringsExporter = async () => ({ locales: ["en", "ru"], missing: { en: 0, ru: 3 } });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
type StringsExporter = (root: string, dir: string, options: {
|
|
46
|
+
source: string;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
locales: readonly string[];
|
|
49
|
+
missing: Readonly<Record<string, number>>;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Takes the translated exchange files of a folder back into the string files of the features,
|
|
53
|
+
* then compiles into `out`. It reports the totals of the run: the locales read, the keys written
|
|
54
|
+
* and the feature files rewritten. `importStrings` of i18n fits it, and a test passes a stub.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* // A test of a wrapper script: the Russian file brought two hud texts.
|
|
59
|
+
* const importStub: StringsImporter = async () => ({ locales: ["ru"], keys: 2, files: ["features/hud/strings/ru.json"] });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
type StringsImporter = (root: string, dir: string, options: {
|
|
63
|
+
source: string;
|
|
64
|
+
pseudo: boolean;
|
|
65
|
+
out: string;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
locales: readonly string[];
|
|
68
|
+
keys: number;
|
|
69
|
+
files: readonly string[];
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* The string tools of i18n the command line runs: the compile of every dev and pack run, the
|
|
73
|
+
* export of `--export` and the import of `--import`. The door `src/assets.ts` passes the real
|
|
74
|
+
* three.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* // src/assets.ts hands the i18n tools to the command line.
|
|
79
|
+
* const strings: StringsTools = { compile: compileStrings, exportStrings, importStrings };
|
|
80
|
+
* await runCli(["--root", "src", "--export", "translations"], strings); // 0
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
type StringsTools = {
|
|
84
|
+
compile: StringsCompiler;
|
|
85
|
+
exportStrings: StringsExporter;
|
|
86
|
+
importStrings: StringsImporter;
|
|
87
|
+
};
|
|
27
88
|
/**
|
|
28
89
|
* Runs the asset key scanner: walk the features, write the manifest and the key module, then
|
|
29
90
|
* compile the feature strings next to the key module, or check that all of it is current. With
|
|
30
|
-
* `--pack <dir>` it packs the art for production on the same scan (`--no-cache` for a cold run)
|
|
31
|
-
*
|
|
91
|
+
* `--pack <dir>` it packs the art for production on the same scan (`--no-cache` for a cold run);
|
|
92
|
+
* `--pseudo` adds the pseudo-locale to a dev run. `--export <dir>` and `--import <dir>` exchange
|
|
93
|
+
* the strings with translators and run alone, from the locale of `--source`. Nothing here calls
|
|
94
|
+
* `process.exit`; the caller does.
|
|
32
95
|
*
|
|
33
96
|
* @param argv - The arguments after the script name.
|
|
34
|
-
* @param
|
|
97
|
+
* @param strings - The string tools of i18n: compile, export and import.
|
|
35
98
|
* @param ui - Where the lines go. The branded console by default.
|
|
36
|
-
* @returns The exit code: `1` when the scan, the compile
|
|
37
|
-
* difference, else `0`.
|
|
99
|
+
* @returns The exit code: `1` when the flags, the scan, the compile, the pack, the export or the
|
|
100
|
+
* import failed or `--check` found a difference, else `0`.
|
|
38
101
|
* @example
|
|
39
102
|
* ```ts
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* await runCli(["--root", "src", "--keys", "src/generated/assets.ts", "--pack", "dist/assets"], compileStrings);
|
|
103
|
+
* const strings = { compile: compileStrings, exportStrings, importStrings };
|
|
104
|
+
* await runCli(["--root", "src", "--keys", "src/generated/assets.ts", "--pack", "dist/assets"], strings);
|
|
44
105
|
* // 0, and dist/assets holds the pages, the loose files and the packed manifest.json
|
|
106
|
+
* await runCli(["--root", "src", "--export", "translations"], strings);
|
|
107
|
+
* // 0, and translations/ holds one <locale>.json per locale for the translators
|
|
45
108
|
* ```
|
|
46
109
|
*/
|
|
47
|
-
declare function runCli(argv: string[],
|
|
110
|
+
declare function runCli(argv: string[], strings: StringsTools, ui?: ScanUi): Promise<number>;
|
|
48
111
|
//#endregion
|
|
49
112
|
//#region src/plugins/i18n/compile/compile.d.ts
|
|
50
113
|
/**
|
|
51
114
|
* What one compile produced.
|
|
52
115
|
*/
|
|
53
116
|
type CompileReport = {
|
|
54
|
-
/** True when an output on disk differs from what the compile produced. */changed: boolean; /** Every locale a feature brought a file for, sorted. */
|
|
117
|
+
/** True when an output on disk differs from what the compile produced. */changed: boolean; /** Every locale a feature brought a file for, and `en-XA` with `pseudo`, sorted. */
|
|
55
118
|
locales: readonly string[]; /** Every message key, sorted. */
|
|
56
119
|
keys: readonly string[]; /** One line per key a locale lacks. Nothing here stops a build. */
|
|
57
120
|
notes: readonly string[];
|
|
@@ -61,22 +124,27 @@ type CompileReport = {
|
|
|
61
124
|
*/
|
|
62
125
|
type CompileOptions = {
|
|
63
126
|
/** True for a check run: nothing is written. */check?: boolean; /** Name of the folder that holds the features. Default `"features"`. */
|
|
64
|
-
features?: string;
|
|
127
|
+
features?: string; /** True to also write `strings.en-XA.ts`, the pseudo-locale, from the `"en"` messages. */
|
|
128
|
+
pseudo?: boolean;
|
|
65
129
|
};
|
|
66
130
|
/**
|
|
67
131
|
* Walks `features/*/strings/<locale>.json` of a game, compiles every message and writes the
|
|
68
|
-
* generated modules: the types module `strings.ts` and one `strings.<locale>.ts` per locale
|
|
69
|
-
* check run writes nothing and only reports whether something
|
|
132
|
+
* generated modules: the types module `strings.ts` and one `strings.<locale>.ts` per locale, plus
|
|
133
|
+
* `strings.en-XA.ts` with `pseudo`. A check run writes nothing and only reports whether something
|
|
134
|
+
* would change; it checks `strings.en-XA.ts` only with `pseudo`.
|
|
70
135
|
*
|
|
71
136
|
* @param root - Game source root, the folder that holds the features.
|
|
72
137
|
* @param out - The generated directory the modules are written into.
|
|
73
|
-
* @param options - Whether this is a check run,
|
|
138
|
+
* @param options - Whether this is a check run, what the features folder is called, and whether
|
|
139
|
+
* the pseudo-locale is written.
|
|
74
140
|
* @returns Whether an output differed, the locales, the keys and the notes.
|
|
75
|
-
* @throws {Error} One error that lists every problem the compile found
|
|
141
|
+
* @throws {Error} One error that lists every problem the compile found, or the pseudo error when
|
|
142
|
+
* no feature brings an `en` string file.
|
|
76
143
|
* @example
|
|
77
144
|
* ```ts
|
|
78
|
-
*
|
|
79
|
-
*
|
|
145
|
+
* // A dev build also writes the pseudo-locale, derived from the English messages.
|
|
146
|
+
* const report = await compileStrings("src", "src/generated", { pseudo: true });
|
|
147
|
+
* // report.locales: ["en", "en-XA", "ru"], report.changed: true on the first run
|
|
80
148
|
* ```
|
|
81
149
|
*/
|
|
82
150
|
declare function compileStrings(root: string, out: string, options?: CompileOptions): Promise<CompileReport>;
|
|
@@ -95,6 +163,97 @@ declare function compileStrings(root: string, out: string, options?: CompileOpti
|
|
|
95
163
|
*/
|
|
96
164
|
declare function checkStrings(root: string, out: string): Promise<boolean>;
|
|
97
165
|
//#endregion
|
|
166
|
+
//#region src/plugins/i18n/compile/exchange.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* What an export and an import are told beyond their two paths.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* const options: ExchangeOptions = { source: "ru" }; // the translators read the Russian text
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
type ExchangeOptions = {
|
|
176
|
+
/** The locale translators read from, written as `source` beside each text. Default `"en"`. */source?: string; /** Name of the folder that holds the features. Default `"features"`. */
|
|
177
|
+
features?: string;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* What an import is told: the exchange options and the compile that runs after the files are
|
|
181
|
+
* written.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const options: ImportOptions = { out: "src/generated", pseudo: true };
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
type ImportOptions = ExchangeOptions & {
|
|
189
|
+
/** Where the compile after the import writes. Default `<root>/generated`. */out?: string; /** True to write the pseudo-locale `strings.en-XA.ts` in that compile too. */
|
|
190
|
+
pseudo?: boolean;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* What an export wrote: the locales, one file each, and how many keys each one lacks.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const report: ExportReport = { locales: ["en", "ru"], missing: { en: 0, ru: 3 } };
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
type ExportReport = {
|
|
201
|
+
/** Every locale a file was written for, sorted. The source is one of them. */locales: readonly string[]; /** Per exported locale, how many keys had no text there. */
|
|
202
|
+
missing: Readonly<Record<string, number>>;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* What an import wrote into the game.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const report: ImportReport = { locales: ["ru"], keys: 3, files: ["features/hud/strings/ru.json"] };
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
type ImportReport = {
|
|
213
|
+
/** Every locale an exchange file was read for, sorted. */locales: readonly string[]; /** How many keys were written. */
|
|
214
|
+
keys: number; /** The string files of the features that were rewritten, relative to the root, sorted. */
|
|
215
|
+
files: readonly string[];
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Writes the files translators work in: one `<dir>/<locale>.json` per locale the features bring,
|
|
219
|
+
* the source locale included, so a new language starts as a copy of `en.json`. Every key of the
|
|
220
|
+
* game is in every file, sorted: `{ text, source, note? }`, with `text: ""` where the locale has no
|
|
221
|
+
* message yet. The game tree is not touched, and a second run writes the same bytes.
|
|
222
|
+
*
|
|
223
|
+
* @param root - Game source root, the folder that holds the features.
|
|
224
|
+
* @param dir - The folder the exchange files are written into; created when missing.
|
|
225
|
+
* @param options - The source locale and the name of the features folder.
|
|
226
|
+
* @returns The exported locales and how many keys each one lacks.
|
|
227
|
+
* @throws {Error} When the game's strings do not compile, or no feature brings the source locale.
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* // Before a release, the game hands its strings to the translators.
|
|
231
|
+
* await exportStrings("src", "translations"); // { locales: ["en", "ru"], missing: { en: 0, ru: 3 } }
|
|
232
|
+
* // translations/ru.json: { "hud.bonus": { "text": "", "source": "Bonus" }, … }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function exportStrings(root: string, dir: string, options?: ExchangeOptions): Promise<ExportReport>;
|
|
236
|
+
/**
|
|
237
|
+
* Takes translated exchange files back into the game: every `<dir>/<locale>.json` is checked
|
|
238
|
+
* against the game first, then each new text is written into the string file of the feature that
|
|
239
|
+
* owns its key, and the strings are compiled into `out` as a dev run does. An empty text and a
|
|
240
|
+
* text equal to the current message are skipped. With any problem nothing is written.
|
|
241
|
+
*
|
|
242
|
+
* @param root - Game source root, the folder that holds the features.
|
|
243
|
+
* @param dir - The folder the translators handed back.
|
|
244
|
+
* @param options - The features folder, where the compile writes, and whether it writes `en-XA`.
|
|
245
|
+
* @returns The locales read, how many keys were written and the files rewritten.
|
|
246
|
+
* @throws {Error} One error that lists every problem of the exchange files, or the compile's own
|
|
247
|
+
* error after the files are written (a parameter kind that differs across locales).
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* // The translators handed back translations/ru.json with two hud texts filled in.
|
|
251
|
+
* await importStrings("src", "translations", { out: "src/generated" });
|
|
252
|
+
* // { locales: ["ru"], keys: 2, files: ["features/hud/strings/ru.json"] }
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
declare function importStrings(root: string, dir: string, options?: ImportOptions): Promise<ImportReport>;
|
|
256
|
+
//#endregion
|
|
98
257
|
//#region src/plugins/assets/scan/emit.d.ts
|
|
99
258
|
/**
|
|
100
259
|
* Writes `manifest.json`: two-space JSON with a trailing newline, bundles sorted by name, pages
|
|
@@ -210,4 +369,4 @@ type ScanResult = {
|
|
|
210
369
|
*/
|
|
211
370
|
declare function scanAssets(options: ScanOptions): Promise<ScanResult>;
|
|
212
371
|
//#endregion
|
|
213
|
-
export { type CompileOptions, type CompileReport, type PackOptions, type PackResult, type ScanOptions, type ScanResult, type ScanUi, type StringsCompiler, type StringsReport, checkStrings, compileStrings, emitKeys, emitManifest, packAssets, runCli, scanAssets };
|
|
372
|
+
export { type CompileOptions, type CompileReport, type ExchangeOptions, type ExportReport, type ImportOptions, type ImportReport, type PackOptions, type PackResult, type ScanOptions, type ScanResult, type ScanUi, type StringsCompiler, type StringsExporter, type StringsImporter, type StringsReport, type StringsTools, checkStrings, compileStrings, emitKeys, emitManifest, exportStrings, importStrings, packAssets, runCli, scanAssets };
|