@datamoc/mw_games 0.40.0 → 0.42.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 (119) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/REFERENCE.md +2128 -0
  3. package/api-surface.json +72 -0
  4. package/data/microgm-opt.PROVENANCE.md +3 -0
  5. package/data/soundfont-catalog.json +183 -0
  6. package/dist/ai/index.d.ts +10 -0
  7. package/dist/ai/index.d.ts.map +1 -1
  8. package/dist/ai/index.js.map +1 -1
  9. package/dist/ai/lua.d.ts +6 -0
  10. package/dist/ai/lua.d.ts.map +1 -1
  11. package/dist/ai/lua.js.map +1 -1
  12. package/dist/audio/MidiRender.d.ts +3 -1
  13. package/dist/audio/MidiRender.d.ts.map +1 -1
  14. package/dist/audio/MidiRender.js +3 -1
  15. package/dist/audio/MidiRender.js.map +1 -1
  16. package/dist/audio/SampleDecoder.d.ts +41 -0
  17. package/dist/audio/SampleDecoder.d.ts.map +1 -0
  18. package/dist/audio/SampleDecoder.js +70 -0
  19. package/dist/audio/SampleDecoder.js.map +1 -0
  20. package/dist/audio/SoundFont.d.ts +93 -1
  21. package/dist/audio/SoundFont.d.ts.map +1 -1
  22. package/dist/audio/SoundFont.js +290 -8
  23. package/dist/audio/SoundFont.js.map +1 -1
  24. package/dist/audio/index.d.ts +4 -2
  25. package/dist/audio/index.d.ts.map +1 -1
  26. package/dist/audio/index.js +2 -1
  27. package/dist/audio/index.js.map +1 -1
  28. package/dist/core/DialogueText.d.ts +25 -0
  29. package/dist/core/DialogueText.d.ts.map +1 -1
  30. package/dist/core/DialogueText.js +25 -0
  31. package/dist/core/DialogueText.js.map +1 -1
  32. package/dist/core/Motion.d.ts +20 -0
  33. package/dist/core/Motion.d.ts.map +1 -1
  34. package/dist/core/Motion.js +20 -0
  35. package/dist/core/Motion.js.map +1 -1
  36. package/dist/core/Save.d.ts +31 -0
  37. package/dist/core/Save.d.ts.map +1 -1
  38. package/dist/core/Save.js +31 -0
  39. package/dist/core/Save.js.map +1 -1
  40. package/dist/core/Twee.d.ts +34 -0
  41. package/dist/core/Twee.d.ts.map +1 -1
  42. package/dist/core/Twee.js +34 -0
  43. package/dist/core/Twee.js.map +1 -1
  44. package/dist/mw_games.global.js +11 -11
  45. package/dist/mwl/presentation.d.ts +16 -0
  46. package/dist/mwl/presentation.d.ts.map +1 -1
  47. package/dist/mwl/presentation.js.map +1 -1
  48. package/dist/mwl/pyroeis-runtime.d.ts +7 -0
  49. package/dist/mwl/pyroeis-runtime.d.ts.map +1 -1
  50. package/dist/mwl/pyroeis-runtime.js.map +1 -1
  51. package/dist/mwl/pyroeis.d.ts +3 -0
  52. package/dist/mwl/pyroeis.d.ts.map +1 -1
  53. package/dist/mwl/pyroeis.js.map +1 -1
  54. package/dist/physics/PhysicsWorld.d.ts +3 -0
  55. package/dist/physics/PhysicsWorld.d.ts.map +1 -1
  56. package/dist/physics/PhysicsWorld.js.map +1 -1
  57. package/dist/physics/XpbdWorld.d.ts +56 -0
  58. package/dist/physics/XpbdWorld.d.ts.map +1 -1
  59. package/dist/physics/XpbdWorld.js +45 -0
  60. package/dist/physics/XpbdWorld.js.map +1 -1
  61. package/dist/physics/cloth/index.d.ts +20 -19
  62. package/dist/physics/cloth/index.d.ts.map +1 -1
  63. package/dist/physics/cloth/index.js +19 -0
  64. package/dist/physics/cloth/index.js.map +1 -1
  65. package/dist/physics/spring/index.d.ts +19 -18
  66. package/dist/physics/spring/index.d.ts.map +1 -1
  67. package/dist/physics/spring/index.js +23 -0
  68. package/dist/physics/spring/index.js.map +1 -1
  69. package/dist/three-d/Character3D.d.ts +8 -7
  70. package/dist/three-d/Character3D.d.ts.map +1 -1
  71. package/dist/three-d/Character3D.js +7 -0
  72. package/dist/three-d/Character3D.js.map +1 -1
  73. package/dist/three-d/Collision3D.d.ts +4 -0
  74. package/dist/three-d/Collision3D.d.ts.map +1 -1
  75. package/dist/three-d/Collision3D.js.map +1 -1
  76. package/dist/three-d/Engine3D.d.ts +2 -0
  77. package/dist/three-d/Engine3D.d.ts.map +1 -1
  78. package/dist/three-d/Engine3D.js.map +1 -1
  79. package/dist/three-d/Grid.d.ts +5 -0
  80. package/dist/three-d/Grid.d.ts.map +1 -1
  81. package/dist/three-d/Grid.js.map +1 -1
  82. package/dist/three-d/Heightmap.d.ts +3 -0
  83. package/dist/three-d/Heightmap.d.ts.map +1 -1
  84. package/dist/three-d/Heightmap.js.map +1 -1
  85. package/dist/three-d/TileGrid3D.d.ts +6 -0
  86. package/dist/three-d/TileGrid3D.d.ts.map +1 -1
  87. package/dist/three-d/TileGrid3D.js.map +1 -1
  88. package/dist/three-d/Vox.d.ts +7 -0
  89. package/dist/three-d/Vox.d.ts.map +1 -1
  90. package/dist/three-d/Vox.js.map +1 -1
  91. package/dist/two-d/presentation/MwlPresentation.d.ts +7 -0
  92. package/dist/two-d/presentation/MwlPresentation.d.ts.map +1 -1
  93. package/dist/two-d/presentation/MwlPresentation.js.map +1 -1
  94. package/dist/two-d/ui/theme.d.ts +18 -0
  95. package/dist/two-d/ui/theme.d.ts.map +1 -1
  96. package/dist/two-d/ui/theme.js.map +1 -1
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.js +1 -1
  99. package/package.json +23 -1
  100. package/sbom.cdx.json +599 -139
  101. package/tools/benchmark-browser.mjs +6 -0
  102. package/tools/bundle-size.mjs +4 -0
  103. package/tools/compile-resources.d.mts +6 -0
  104. package/tools/compile-resources.mjs +53 -16
  105. package/tools/emit-page.d.mts +3 -0
  106. package/tools/emit-page.mjs +15 -2
  107. package/tools/init.mjs +3 -1
  108. package/tools/make-example-assets.mjs +4 -0
  109. package/tools/multiplayer-server.mjs +4 -0
  110. package/tools/mwl.mjs +7 -0
  111. package/tools/play-uci.mjs +4 -0
  112. package/tools/sbom.mjs +4 -0
  113. package/tools/soundfonts.d.mts +79 -0
  114. package/tools/soundfonts.mjs +301 -0
  115. package/tools/svg-optimise.d.mts +8 -0
  116. package/tools/svg-optimise.mjs +45 -0
  117. package/tools/verify-scenarios.mjs +6 -2
  118. package/tools/vite.mjs +2 -1
  119. package/tools.md +218 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,121 @@ the public API may still change between minor versions.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.42.0] - 2026-10-16
11
+
12
+ The documentation and asset follow-ups to 0.41.0: SVG minification, a policy for the instruments a
13
+ SoundFont lacks, a playable bridge game with its tutorial, an examples index, and function-level
14
+ examples. One behaviour changes: a drum kit a font lacks now falls back to the standard kit instead of
15
+ a melodic preset.
16
+
17
+ ### Added
18
+
19
+ - Function-level `@example`s where the examples used to sit on a file or an interface, so an
20
+ editor's hover shows them: `SaveSystem` (with a migration), `parseDialogueLines`,
21
+ `parseTwee` (walking a story), `motionDuration` (reduced motion on a slide and on a
22
+ meaningful bar) and `Theme` (a custom theme, `themeChanged`, the high-contrast swap).
23
+ - `XpbdWorld` documents a bridge: a Warren truss with beams, a `tensionOnly` cable note and a
24
+ breaking load, tested to hold a light cart, break under a heavy one and repeat exactly.
25
+ - `REFERENCE.md` records what subsetting the bundled bank costs (piano and drums 264 KB,
26
+ eight essential programs 421 KB, sixteen 585 KB) and what plays for a program the font lacks.
27
+ - `svgo: true` on `compileResources`, `emitPage` and `mwgPage` (and `--svgo` on `mwg-emit`) minifies
28
+ embedded `.svg` assets through the optional `svgo` package, version 4 or newer, imported only when
29
+ used. Ids and the `viewBox` are left alone, a file is embedded optimised only when that is smaller,
30
+ and one svgo cannot parse fails the build by name. On the repository's own 30 SVGs: 13.6%
31
+ smaller, worst rendered pixel difference 1 in 255. `@datamoc/mw_games/tools/svg-optimise` is the
32
+ standalone half.
33
+ - `missingProgram: 'piano' | 'synth'` on `parseSoundFont`, `loadSoundFont` and
34
+ `renderMidiToBufferAsync`: what plays for a program the font lacks, the font's own piano as
35
+ before or the built-in synthesizer, so a game with a trimmed bank hears the synthesizer's timbre
36
+ for an instrument it did not ship instead of a piano line.
37
+ - `missingSoundFontPrograms` (`audio`) lists the programs a MIDI usage asks for that a SoundFont 2 or
38
+ 3 does not carry. The asset compiler runs it: each embedded font's result has a `missing` list and
39
+ `mwg-emit` and `compile-resources` warn about them.
40
+ - `examples/bridge` and the "Build a bridge game" tutorial (`webpage/tutorials/bridge`): a playable
41
+ truss builder on `XpbdWorld` (three levels, a budget, cables, beams coloured by load, breaking),
42
+ a deterministic replay of the player's build through `Recorder`/`Player`, best results through
43
+ `SaveSystem`, reduced motion and the high-contrast theme. The simulation is renderer-free and
44
+ tested, every tutorial snippet is checked to appear verbatim in the example, and the interface
45
+ step points at `examples/mwl-presentation` for HUD and windows described as MWL content.
46
+ - An examples index (`tools/build-example-index.mjs`, written by `npm run webpage:docs` to
47
+ `documentation/examples.html`): for each public module every exported symbol with an `@example`,
48
+ its first lines and a link to its API page, plus the runnable examples that import the module.
49
+
50
+ ### Fixed
51
+
52
+ - A request for a drum kit the font lacks falls back to the standard kit, never to a melodic
53
+ preset: it used to take the same program number from bank 0, so a font with a piano and no drums
54
+ played the piano where the kick should be.
55
+
56
+ ## [0.41.0] - 2026-10-16
57
+
58
+ `microgm-opt` stays the default SoundFont, and a game that wants another one can now pick it:
59
+ a licence-classified catalogue of a per-instrument collection, a tool that fetches only the
60
+ instruments the game plays, and SoundFont 3 support from the build to the browser, so the
61
+ font reaches the page compressed and is decoded at load.
62
+
63
+ ### Added
64
+
65
+ - `mwg-soundfonts` (`list`, `fetch`, `convert`, and `@datamoc/mw_games/tools/soundfonts`):
66
+ `data/soundfont-catalog.json` lists the bundled bank and 18 fonts of the marmooo
67
+ free-soundfonts collection with each licence classified (public domain, permissive and
68
+ attribution fetch freely; share-alike, copyleft and unclear ones need `--accept-licence`;
69
+ TimGM6mb is listed as GPL-2.0 where the collection says public domain). `fetch` takes the
70
+ instruments named by `--midi` files or `--programs` and merges them into one SoundFont 3 with
71
+ a `.credits.txt` beside it: nothing is decoded, so no `ffmpeg`. `--sf2` and `convert` decode
72
+ to a plain SoundFont 2 instead (Ogg Vorbis through `ffmpeg`, a developer-machine tool), about
73
+ eight times larger.
74
+ - `loadSoundFont`, `decodeSoundFont` and `webAudioSampleDecoder` (`audio`): a game reads the
75
+ SoundFont 2 or 3 it ships with `loadSoundFont`, a SoundFont 3 decoded once at load through
76
+ `decodeAudioData` (each sample in a context at its own rate, so no resampling), or through a
77
+ decoder the caller passes. Checked in Chrome against `ffmpeg`: the same frames, rates and
78
+ loop points, and the same render. `decodeSoundFont` returns the SoundFont 2 bytes for
79
+ anything that takes them.
80
+ - `compileResources`, `emitPage` and `mwgPage` embed `.sf3` assets and subset them to the
81
+ programs the game's MIDI files use, the Ogg bytes copied untouched.
82
+ - `mergeSoundFonts` (`audio`): joins SoundFont 2 files, or SoundFont 3 files with their Ogg
83
+ bytes untouched, into one, the first font winning a shared (bank, program).
84
+
85
+ ### Fixed
86
+
87
+ - `parseSoundFont` refuses a SoundFont 3 by name (pointing at `loadSoundFont`) instead of
88
+ reading its Ogg bytes as PCM and playing noise.
89
+ - A SoundFont whose sample offsets point outside its sample data is refused when read, rather
90
+ than read beyond it.
91
+ - Decoding a SoundFont 3 bounds what the file can make it allocate: a sample rate outside 400 to
92
+ 200000 Hz is refused, a decoded sample is capped at sixteen million frames and a whole font at
93
+ 134 million (256 MB of audio), in both `decodeSoundFont` and the WebAudio decoder.
94
+ - `mwg-soundfonts` treats the font as untrusted input: a sample whose offsets point outside the
95
+ sample data is refused instead of copied from beyond it, and `ffmpeg` only ever receives bytes
96
+ that start with the Ogg magic, with the demuxer forced to Ogg and only the `pipe` protocol
97
+ allowed, so a crafted "sample" cannot be probed as a playlist that names local files.
98
+
99
+ ## [0.40.1] - 2026-10-15
100
+
101
+ The published package now carries its documentation the way npm expects to find it: a
102
+ homepage that opens the documentation site, the reference and the tools guide inside the
103
+ tarball, declared Node support, and a `--help` on every command line tool.
104
+
105
+ ### Added
106
+
107
+ - `package.json` declares `homepage` (the documentation site, so `npm docs` opens it
108
+ instead of the GitHub README), `bugs` and `engines` (`node >=20.19.0`), and exports
109
+ `./package.json` so a tool can read an installed module's metadata. `@datamoc/mwg`
110
+ inherits all of them, plus the keywords it lacked.
111
+ - `REFERENCE.md` and `tools.md` ship in the tarball, so the README's relative links
112
+ resolve offline from `node_modules`.
113
+ - `REFERENCE.md` sections for `skeleton`, `physics` and `mwl/pyroeis`.
114
+ - JSDoc on the exported symbols of the least documented entry points
115
+ (`mwl/presentation`, `ai/lua`, `physics/xpbd`, `two-d/presentation`, `3d`, `mwl/pyroeis`,
116
+ `physics`).
117
+
118
+ ### Fixed
119
+
120
+ - `mwg-bench`, `mwg-size`, `mwg-sbom`, `mwg-lockstep-server`, `mwg-mwl`, `mwg-uci` now print
121
+ their usage for `--help` instead of running. `mwg-init --help` no longer creates a folder
122
+ named `--help`, `mwg-scenarios --help` no longer hangs, and `mwg-placeholder-assets --help`
123
+ no longer rewrites the assets.
124
+
10
125
  ## [0.40.0] - 2026-10-15
11
126
 
12
127
  A game that plays sampled MIDI no longer ships a whole SoundFont: the asset