@datamoc/mw_games 0.6.0 → 0.7.1
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 +66 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mw_games.global.js +22 -19
- package/dist/mwl/actors.d.ts +16 -0
- package/dist/mwl/actors.d.ts.map +1 -0
- package/dist/mwl/actors.js +33 -0
- package/dist/mwl/actors.js.map +1 -0
- package/dist/mwl/catalog.d.ts +13 -0
- package/dist/mwl/catalog.d.ts.map +1 -0
- package/dist/mwl/catalog.js +67 -0
- package/dist/mwl/catalog.js.map +1 -0
- package/dist/mwl/compiler.d.ts +51 -0
- package/dist/mwl/compiler.d.ts.map +1 -0
- package/dist/mwl/compiler.js +119 -0
- package/dist/mwl/compiler.js.map +1 -0
- package/dist/mwl/content.d.ts +90 -0
- package/dist/mwl/content.d.ts.map +1 -0
- package/dist/mwl/content.js +146 -0
- package/dist/mwl/content.js.map +1 -0
- package/dist/mwl/expression.d.ts +21 -0
- package/dist/mwl/expression.d.ts.map +1 -0
- package/dist/mwl/expression.js +110 -0
- package/dist/mwl/expression.js.map +1 -0
- package/dist/mwl/grammar.d.ts +39 -0
- package/dist/mwl/grammar.d.ts.map +1 -0
- package/dist/mwl/grammar.js +204 -0
- package/dist/mwl/grammar.js.map +1 -0
- package/dist/mwl/hooks.d.ts +81 -0
- package/dist/mwl/hooks.d.ts.map +1 -0
- package/dist/mwl/hooks.js +78 -0
- package/dist/mwl/hooks.js.map +1 -0
- package/dist/mwl/index.d.ts +21 -0
- package/dist/mwl/index.d.ts.map +1 -0
- package/dist/mwl/index.js +11 -0
- package/dist/mwl/index.js.map +1 -0
- package/dist/mwl/persistence.d.ts +15 -0
- package/dist/mwl/persistence.d.ts.map +1 -0
- package/dist/mwl/persistence.js +41 -0
- package/dist/mwl/persistence.js.map +1 -0
- package/dist/mwl/runtime.d.ts +196 -0
- package/dist/mwl/runtime.d.ts.map +1 -0
- package/dist/mwl/runtime.js +587 -0
- package/dist/mwl/runtime.js.map +1 -0
- package/dist/mwl/schema.d.ts +20 -0
- package/dist/mwl/schema.d.ts.map +1 -0
- package/dist/mwl/schema.js +379 -0
- package/dist/mwl/schema.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -4
- package/tools/extract-html.d.mts +18 -0
- package/tools/extract-html.mjs +235 -0
- package/tools/mwl.mjs +197 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ of their own; improvements to `mwg`'s own files are shared back.
|
|
|
11
11
|
**[Live examples and API docs](https://datamoc.github.io/mwg/)**: every example below,
|
|
12
12
|
playable in the browser with no download, plus the generated API reference.
|
|
13
13
|
|
|
14
|
-
> **Status: pre-alpha (v0.
|
|
14
|
+
> **Status: pre-alpha (v0.7.1).** Every module in the shared floor below, plus optional
|
|
15
15
|
> 3D, mobile (Capacitor) and desktop (WebView2) packaging, is built and tested - see
|
|
16
16
|
> [ROADMAP.md](ROADMAP.md) for the full, numbered history.
|
|
17
17
|
>
|
|
@@ -373,6 +373,71 @@ with `advanceToInput`.
|
|
|
373
373
|
See [ROADMAP.md](ROADMAP.md) for the full, numbered build order and implementation notes.
|
|
374
374
|
The optional 3D group is now implemented without changing the existing 2D entry point.
|
|
375
375
|
|
|
376
|
+
## MWL
|
|
377
|
+
|
|
378
|
+
MWL is the framework's declarative, WML-inspired authoring layer. It describes
|
|
379
|
+
game data and commands while `mwg` remains responsible for execution, rendering,
|
|
380
|
+
input, audio, and saves. MWL is a new language, not a WML compatibility layer.
|
|
381
|
+
The Wesnoth port can nevertheless use its native `.cfg` files as build inputs:
|
|
382
|
+
the port-owned WML front end parses them, the adapter converts the supported
|
|
383
|
+
nodes to MWL, and the normal MWL compiler emits the runtime module.
|
|
384
|
+
|
|
385
|
+
The framework exposes the parser, validator, compiler, runtime, i18n extraction,
|
|
386
|
+
and the hook contract through `@datamoc/mw_games/mwl`. Compile source at build
|
|
387
|
+
time with:
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
npm run mwl -- validate game.mwl
|
|
391
|
+
npm run mwl -- build game.mwl -o generated/
|
|
392
|
+
npm run mwl -- compile game.mwl -o generated/game-data.ts
|
|
393
|
+
npm run mwl -- extract-i18n game.mwl -o generated/i18n.json
|
|
394
|
+
npm run mwl -- hooks game.mwl --manifest hooks.json -o generated/hooks.mjs
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
The input may also be a content directory. `mwl build content/ -o generated/`
|
|
398
|
+
reads every `.mwl` file recursively in stable path order and emits one merged,
|
|
399
|
+
validated catalog. Diagnostics retain each source file and line, so a game can
|
|
400
|
+
organize assets, units, items, scenarios, dialogue, and AI data as separate files.
|
|
401
|
+
|
|
402
|
+
`mwl build` is the normal game command: it produces `game-data.ts`, `i18n.json`,
|
|
403
|
+
and `assets.json` in one build-time step. The game imports the generated module;
|
|
404
|
+
it never calls `Mwl.compile()` at runtime. MWG also provides generic helpers for
|
|
405
|
+
turning item effects into `actors` modifiers and for versioned, migratable MWL
|
|
406
|
+
saves. Asset attributes such as `image`, `image_icon`, `profile`, `icon`, `file`,
|
|
407
|
+
`sound`, and `*_sound` are collected into the manifest, including comma-separated
|
|
408
|
+
sound lists, Wesnoth sound ranges such as `human-hit-[1~5].ogg`, and image
|
|
409
|
+
modifiers. Nested transform arguments are not mistaken for separate assets.
|
|
410
|
+
Item slots, formulas, hooks, and business rules remain defined by the game.
|
|
411
|
+
|
|
412
|
+
For a large self-contained HTML page, `npm run extract:html -- page.html -o extracted/`
|
|
413
|
+
writes a rewritten `index.html`, an `assets/` directory, and a deterministic
|
|
414
|
+
`manifest.json`. Inline scripts, styles, and supported `data:` URLs are extracted in
|
|
415
|
+
source order. The original page is never overwritten, and unsupported data forms are
|
|
416
|
+
reported as warnings. The output directory is safe to regenerate: its extracted
|
|
417
|
+
`assets/` directory is replaced, while unrelated files are kept.
|
|
418
|
+
CSS `url(data:...)` values and HTML `srcset` candidates are handled too, including
|
|
419
|
+
their density descriptors.
|
|
420
|
+
|
|
421
|
+
Translation messages are the values marked `_ "..."` in the source; the
|
|
422
|
+
extracted catalog matches `@datamoc/mw_games/i18n`. Hooks are referenced as
|
|
423
|
+
`type:name`, declared in a manifest, and bundled with esbuild, which a game
|
|
424
|
+
project installs itself (`npm install --save-dev esbuild`). The framework does
|
|
425
|
+
not depend on esbuild, so a game without hooks pays nothing for the feature.
|
|
426
|
+
|
|
427
|
+
`MwlRuntime` runs compiled content: it loads the map, sides, units, and leaders
|
|
428
|
+
(leaders spawn on their keep with stats from `[unit_type]`), runs `on=` events
|
|
429
|
+
with filters and conditions, tracks movement points, advances the `[schedule]`
|
|
430
|
+
on `[end_turn]`, evaluates `[objectives]`, hosts command and predicate hooks,
|
|
431
|
+
and saves and restores the world. Pathfinding and combat formulas stay in a
|
|
432
|
+
game's engine adapter, because they need that game's real data. A command hook
|
|
433
|
+
receives the `[hook]` attributes as its context; a `condition=hook` objective
|
|
434
|
+
receives its other attributes, so content can parameterize an engine predicate
|
|
435
|
+
(`value` is the generic integer parameter).
|
|
436
|
+
|
|
437
|
+
The generated data is plain TypeScript and works with the same local-file build
|
|
438
|
+
pipeline as the rest of the framework. Wesnoth-specific MWL source belongs in
|
|
439
|
+
the Wesnoth port, not in this framework package.
|
|
440
|
+
|
|
376
441
|
## Licence and provenance
|
|
377
442
|
|
|
378
443
|
`mwg` is MPL-2.0. Its dependencies are permissive and compatible: PixiJS and Babylon.js are
|
package/dist/index.d.ts
CHANGED
|
@@ -20,4 +20,5 @@ export * as Battle from './battle/index.ts';
|
|
|
20
20
|
export * as Board from './board/index.ts';
|
|
21
21
|
export * as Audio from './audio/index.ts';
|
|
22
22
|
export * as Simulation from './simulation/index.ts';
|
|
23
|
+
export * as Mwl from './mwl/index.ts';
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,4 +20,5 @@ export * as Battle from './battle/index.js';
|
|
|
20
20
|
export * as Board from './board/index.js';
|
|
21
21
|
export * as Audio from './audio/index.js';
|
|
22
22
|
export * as Simulation from './simulation/index.js';
|
|
23
|
+
export * as Mwl from './mwl/index.js';
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC"}
|