@datamoc/mw_games 0.12.0 → 0.14.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/CHANGELOG.md +124 -0
- package/README.md +5 -1
- package/dist/board/Classics.d.ts.map +1 -1
- package/dist/board/Classics.js +3 -2
- package/dist/board/Classics.js.map +1 -1
- package/dist/board/FogOfWar.d.ts.map +1 -1
- package/dist/board/FogOfWar.js +5 -2
- package/dist/board/FogOfWar.js.map +1 -1
- package/dist/board/HexSkirmish.d.ts.map +1 -1
- package/dist/board/HexSkirmish.js +2 -1
- package/dist/board/HexSkirmish.js.map +1 -1
- package/dist/core/DialogueText.d.ts +47 -0
- package/dist/core/DialogueText.d.ts.map +1 -0
- package/dist/core/DialogueText.js +43 -0
- package/dist/core/DialogueText.js.map +1 -0
- package/dist/core/Grid.d.ts +64 -0
- package/dist/core/Grid.d.ts.map +1 -0
- package/dist/core/Grid.js +76 -0
- package/dist/core/Grid.js.map +1 -0
- package/dist/core/Twee.d.ts +67 -0
- package/dist/core/Twee.d.ts.map +1 -0
- package/dist/core/Twee.js +140 -0
- package/dist/core/Twee.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -1
- package/dist/mw_games.global.js +108 -107
- package/dist/roguelike/Level.d.ts.map +1 -1
- package/dist/roguelike/Level.js +5 -4
- package/dist/roguelike/Level.js.map +1 -1
- package/dist/rpg/EventRunner.d.ts +20 -0
- package/dist/rpg/EventRunner.d.ts.map +1 -1
- package/dist/rpg/EventRunner.js +52 -11
- package/dist/rpg/EventRunner.js.map +1 -1
- package/dist/rpg/dialogue-text.d.ts +81 -0
- package/dist/rpg/dialogue-text.d.ts.map +1 -0
- package/dist/rpg/dialogue-text.js +88 -0
- package/dist/rpg/dialogue-text.js.map +1 -0
- package/dist/rpg/index.d.ts +4 -1
- package/dist/rpg/index.d.ts.map +1 -1
- package/dist/rpg/index.js +2 -0
- package/dist/rpg/index.js.map +1 -1
- package/dist/rpg/twee-events.d.ts +48 -0
- package/dist/rpg/twee-events.d.ts.map +1 -0
- package/dist/rpg/twee-events.js +35 -0
- package/dist/rpg/twee-events.js.map +1 -0
- package/dist/two-d/Game.d.ts +24 -0
- package/dist/two-d/Game.d.ts.map +1 -1
- package/dist/two-d/Game.js +42 -1
- package/dist/two-d/Game.js.map +1 -1
- package/dist/two-d/ResolutionFit.d.ts +28 -0
- package/dist/two-d/ResolutionFit.d.ts.map +1 -0
- package/dist/two-d/ResolutionFit.js +39 -0
- package/dist/two-d/ResolutionFit.js.map +1 -0
- package/dist/two-d/stage/dialogue-text.d.ts +81 -0
- package/dist/two-d/stage/dialogue-text.d.ts.map +1 -0
- package/dist/two-d/stage/dialogue-text.js +95 -0
- package/dist/two-d/stage/dialogue-text.js.map +1 -0
- package/dist/two-d/stage/index.d.ts +1 -0
- package/dist/two-d/stage/index.d.ts.map +1 -1
- package/dist/two-d/stage/index.js +1 -0
- package/dist/two-d/stage/index.js.map +1 -1
- package/dist/two-d/stage/twee.d.ts +7 -25
- package/dist/two-d/stage/twee.d.ts.map +1 -1
- package/dist/two-d/stage/twee.js +10 -162
- package/dist/two-d/stage/twee.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -1
- package/tools/classic-html.mjs +1 -1
- package/tools/compress-dist.d.mts +18 -0
- package/tools/compress-dist.mjs +5 -0
- package/tools/single-file.d.mts +16 -0
- package/tools/single-file.mjs +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twee.js","sourceRoot":"","sources":["../../../src/two-d/stage/twee.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"twee.js","sourceRoot":"","sources":["../../../src/two-d/stage/twee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAc/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACxC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACzE,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* this from `package.json` automatically, chosen because this project's own build already
|
|
10
10
|
* has no step before `tsc`/`vite` that this would need to run ahead of.
|
|
11
11
|
*/
|
|
12
|
-
export declare const version = "0.
|
|
12
|
+
export declare const version = "0.14.0";
|
|
13
13
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* this from `package.json` automatically, chosen because this project's own build already
|
|
10
10
|
* has no step before `tsc`/`vite` that this would need to run ahead of.
|
|
11
11
|
*/
|
|
12
|
-
export const version = '0.
|
|
12
|
+
export const version = '0.14.0';
|
|
13
13
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datamoc/mw_games",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A local-file game framework: renderer-free game logic, drawn through PixiJS in 2D or Babylon.js in 3D, with mobile and desktop packaging.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -134,8 +134,11 @@
|
|
|
134
134
|
"types": "./dist/ai/lua.d.ts",
|
|
135
135
|
"import": "./dist/ai/lua.js"
|
|
136
136
|
},
|
|
137
|
+
"./tools/classic-html": "./tools/classic-html.mjs",
|
|
137
138
|
"./tools/compile-resources": "./tools/compile-resources.mjs",
|
|
138
139
|
"./tools/compress-dist": "./tools/compress-dist.mjs",
|
|
140
|
+
"./tools/extract-html": "./tools/extract-html.mjs",
|
|
141
|
+
"./tools/single-file": "./tools/single-file.mjs",
|
|
139
142
|
"./tools/webp-convert": "./tools/webp-convert.mjs",
|
|
140
143
|
"./two-d": {
|
|
141
144
|
"types": "./dist/two-d/index.d.ts",
|
package/tools/classic-html.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
23
23
|
* @example
|
|
24
24
|
* ```js
|
|
25
25
|
* import { readFile, writeFile } from 'node:fs/promises';
|
|
26
|
-
* import { toClassicScript } from '@datamoc/mw_games/tools/classic-html
|
|
26
|
+
* import { toClassicScript } from '@datamoc/mw_games/tools/classic-html';
|
|
27
27
|
*
|
|
28
28
|
* const html = await readFile('dist/index.html', 'utf8');
|
|
29
29
|
* const result = toClassicScript(html);
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
/** Options for {@link compressDist}. */
|
|
1
2
|
export interface CompressOptions {
|
|
3
|
+
/** Write `.gz` siblings (default true). */
|
|
2
4
|
gzip?: boolean;
|
|
5
|
+
/** Write `.br` siblings (default true). */
|
|
3
6
|
brotli?: boolean;
|
|
7
|
+
/** Also write `.xz` siblings where smaller (default false, needs the system `xz`). */
|
|
4
8
|
xz?: boolean;
|
|
5
9
|
}
|
|
6
10
|
|
|
11
|
+
/**
|
|
12
|
+
* One considered file, with the sizes of the siblings actually written for it: `file` is
|
|
13
|
+
* relative to `dir`, and a size is 0 when that sibling was not asked for, was not smaller
|
|
14
|
+
* than the original, or (for `.xz`) needs a system binary that is not there. Files under the
|
|
15
|
+
* size floor, and extensions that are already compressed or not text, never produce a row.
|
|
16
|
+
*/
|
|
7
17
|
export interface CompressRow {
|
|
8
18
|
file: string;
|
|
9
19
|
raw: number;
|
|
@@ -12,5 +22,13 @@ export interface CompressRow {
|
|
|
12
22
|
xz: number;
|
|
13
23
|
}
|
|
14
24
|
|
|
25
|
+
/** True when the system `xz` binary (LZMA2) is available for the opt-in archive pass. */
|
|
15
26
|
export function hasXz(): boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Writes compressed siblings for the large files in `dir`, *into that same folder*: the
|
|
30
|
+
* originals are left untouched, and each `<file>` gains `<file>.gz`, `<file>.br` and, when
|
|
31
|
+
* opted into, `<file>.xz`, beside it. There is no separate output directory, so pass a
|
|
32
|
+
* directory you own or a copy of the build output, not one you are about to publish.
|
|
33
|
+
*/
|
|
16
34
|
export function compressDist(dir: string, options?: CompressOptions): Promise<CompressRow[]>;
|
package/tools/compress-dist.mjs
CHANGED
|
@@ -58,6 +58,11 @@ function compressXz(data) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
+
* Writes sibling files *into the folder it is given*: each `<file>.gz`/`.br`/`.xz` appears
|
|
62
|
+
* beside its original inside `dir`, which is rewritten in place, with no separate output
|
|
63
|
+
* directory. The originals themselves are never modified, so a caller whose `dist` is also
|
|
64
|
+
* what it publishes should still hand this a copy.
|
|
65
|
+
*
|
|
61
66
|
* @param dir folder to compress, normally an example's `dist`
|
|
62
67
|
* @param options.gzip write `.gz` siblings (default true)
|
|
63
68
|
* @param options.brotli write `.br` siblings (default true)
|
package/tools/single-file.d.mts
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
+
/** Options for {@link buildSingleFile}. */
|
|
1
2
|
export interface SingleFileOptions {
|
|
3
|
+
/** Path to the folder `emit-page.mjs` already wrote. */
|
|
2
4
|
dist: string;
|
|
5
|
+
/** Compress each inlined script before embedding it (default false). */
|
|
3
6
|
compress?: boolean;
|
|
7
|
+
/** Algorithm used when `compress` is set (default 'gzip'). */
|
|
4
8
|
algorithm?: 'gzip' | 'brotli';
|
|
9
|
+
/** gzip level 1-9, or brotli quality 0-11 (default 9 for gzip, 11 for brotli). */
|
|
5
10
|
level?: number;
|
|
11
|
+
/** Show a splash screen while the embedded scripts decode (default true). */
|
|
6
12
|
splash?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Output file *name*, written inside `dist` (default `standalone.html`). A name, not a
|
|
15
|
+
* path: one containing a separator is refused with a thrown error rather than joined
|
|
16
|
+
* onto `dist`. Additive, so `dist/index.html` is left as it was.
|
|
17
|
+
*/
|
|
7
18
|
output?: string;
|
|
8
19
|
}
|
|
9
20
|
|
|
21
|
+
/** What {@link buildSingleFile} wrote. */
|
|
10
22
|
export interface SingleFileResult {
|
|
23
|
+
/** Path of the written file: `dist` joined with `output`. */
|
|
11
24
|
path: string;
|
|
25
|
+
/** How many `<script src>` payloads were inlined. */
|
|
12
26
|
scripts: number;
|
|
27
|
+
/** Total size of that script code before compression. */
|
|
13
28
|
rawBytes: number;
|
|
29
|
+
/** Total length of the base64 payloads actually embedded, so after compression. */
|
|
14
30
|
embeddedBytes: number;
|
|
15
31
|
}
|
|
16
32
|
|
package/tools/single-file.mjs
CHANGED
|
@@ -51,7 +51,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
51
51
|
* set (default 9 for gzip, 11 for brotli)
|
|
52
52
|
* @param {boolean} [options.splash] show a splash screen while scripts decode (default true)
|
|
53
53
|
* @param {string} [options.output] output file name, written inside `dist` (default
|
|
54
|
-
* `standalone.html`) -
|
|
54
|
+
* `standalone.html`) - a name, not a path: one containing a separator is refused rather than
|
|
55
|
+
* joined onto `dist`. Additive, so the existing multi-file `index.html` is untouched
|
|
55
56
|
* @returns {Promise<{path: string, scripts: number, rawBytes: number, embeddedBytes: number}>}
|
|
56
57
|
*/
|
|
57
58
|
export async function buildSingleFile({
|
|
@@ -66,6 +67,12 @@ export async function buildSingleFile({
|
|
|
66
67
|
if (algorithm !== 'gzip' && algorithm !== 'brotli') {
|
|
67
68
|
throw new Error(`buildSingleFile: algorithm must be 'gzip' or 'brotli', got ${JSON.stringify(algorithm)}`);
|
|
68
69
|
}
|
|
70
|
+
if (/[\\/]/.test(output)) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
'buildSingleFile: `output` is a file name written inside `dist`, not a path, so it cannot ' +
|
|
73
|
+
`contain a separator - got ${JSON.stringify(output)}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
69
76
|
|
|
70
77
|
const htmlPath = join(dist, 'index.html');
|
|
71
78
|
const html = await readFile(htmlPath, 'utf8');
|