@datamoc/mw_games 0.10.0 → 0.11.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 +31 -0
- package/dist/assets/loader.d.ts.map +1 -1
- package/dist/assets/loader.js +22 -2
- package/dist/assets/loader.js.map +1 -1
- package/dist/mw_games.global.js +20 -20
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
- package/tools/compile-resources.d.mts +29 -0
- package/tools/compile-resources.mjs +61 -7
- package/tools/single-file.d.mts +1 -0
- package/tools/single-file.mjs +72 -28
- package/tools/webp-convert.d.mts +8 -0
- package/tools/webp-convert.mjs +90 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,37 @@ the public API may still change between minor versions.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.11.0] - 2026-09-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `tools/webp-convert.mjs` (`toWebp`) and `compileResources`'s `toWebp`/`webpLossless`/
|
|
15
|
+
`webpQuality` options - convert `.png`/`.jpg`/`.jpeg` build assets to WebP before embedding,
|
|
16
|
+
lossless by default (verified pixel-for-pixel identical to the source) and only kept when
|
|
17
|
+
actually smaller, under the asset's unchanged key so `load('sprite.png')` keeps working the
|
|
18
|
+
same in dev and built modes. Needs the optional `sharp` devDependency, dynamically imported
|
|
19
|
+
only when `toWebp` is used, so a build that never asks for it never needs it installed
|
|
20
|
+
(item 350).
|
|
21
|
+
- `single-file.mjs`'s `algorithm: 'gzip' | 'brotli'` option (`--brotli[=quality]` on the CLI,
|
|
22
|
+
`--single-file-brotli[=quality]` on `emit-page`) - brotli compression for the single-file
|
|
23
|
+
build alongside the existing gzip path. gzip stays the broadly-supported default: a real
|
|
24
|
+
Chrome (153) tested directly during this feature's own verification throws for
|
|
25
|
+
`DecompressionStream('br')`, so brotli is documented as an advanced, narrower-reach option
|
|
26
|
+
rather than an assumed-safe default (item 350).
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- `single-file.mjs`'s generated bootstrap: `new DecompressionStream(format)` throws
|
|
31
|
+
synchronously for an unsupported format rather than rejecting a promise, which escaped the
|
|
32
|
+
bootstrap's own error handling entirely and left the splash screen stuck forever instead of
|
|
33
|
+
failing visibly - found live in the browser while verifying item 350's brotli option, fixed
|
|
34
|
+
for both gzip and brotli by converting the throw into a rejection.
|
|
35
|
+
- `assets.load`'s `data:` URI format hint now comes from the URI's own MIME type first, falling
|
|
36
|
+
back to the asset path's extension only when that is unavailable. Found while reviewing
|
|
37
|
+
item 350's WebP conversion: `toWebp` can compile a `sprite.png` path into `image/webp` bytes
|
|
38
|
+
(keeping the `.png` key so dev and built modes keep agreeing), and the old, path-only hint
|
|
39
|
+
would have told Pixi's resolver to run the PNG parser over WebP data.
|
|
40
|
+
|
|
10
41
|
## [0.10.0] - 2026-09-14
|
|
11
42
|
|
|
12
43
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,iBAAiB;IACjC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,iBAAiB;IACjC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7B,6FAA6F;IAC7F,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AA0BD;;;;;;GAMG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAa,GAAG,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD1G;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAMjE;AAED,wGAAwG;AACxG,wBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAMpD;AAED,uFAAuF;AACvF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAI5D"}
|
package/dist/assets/loader.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { Assets, Texture } from 'pixi.js';
|
|
2
2
|
import { resolve } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* `data:` URI MIME type to the format token Pixi's resolver expects - the authoritative source
|
|
5
|
+
* when it is available, since a compiled asset's embedded bytes can differ from what its path's
|
|
6
|
+
* extension suggests (`tools/compile-resources.mjs`'s `toWebp` option, item 350, compiles a
|
|
7
|
+
* `sprite.png` path into `image/webp` bytes when that is smaller, keeping the `.png` key so
|
|
8
|
+
* `load('sprite.png')` still works the same in dev and built modes).
|
|
9
|
+
*/
|
|
10
|
+
const MIME_TO_FORMAT = {
|
|
11
|
+
'image/png': 'png',
|
|
12
|
+
'image/jpeg': 'jpg',
|
|
13
|
+
'image/webp': 'webp',
|
|
14
|
+
'image/gif': 'gif',
|
|
15
|
+
'image/svg+xml': 'svg',
|
|
16
|
+
};
|
|
3
17
|
/**
|
|
4
18
|
* Loads assets by path, giving each one an alias equal to its path.
|
|
5
19
|
*
|
|
@@ -22,9 +36,15 @@ export async function load(paths, options = {}) {
|
|
|
22
36
|
descriptor.data = { resolution };
|
|
23
37
|
//a compiled build's `src` is a `data:` URI, which carries no extension for Pixi's
|
|
24
38
|
//resolver to pick a parser from - `path` still does, so it is supplied explicitly
|
|
25
|
-
//instead of a game having to pass its own {src, parser} descriptor to Assets directly
|
|
39
|
+
//instead of a game having to pass its own {src, parser} descriptor to Assets directly.
|
|
40
|
+
//The URI's own MIME type is tried first, not just `path`'s extension: `toWebp` (item
|
|
41
|
+
//350) can compile a `sprite.png` path into `data:image/webp;...` bytes when that is
|
|
42
|
+
//smaller, and the *key* deliberately stays "sprite.png" so dev and built modes agree -
|
|
43
|
+
//trusting only the stale `.png` extension here would tell Pixi's resolver to run the
|
|
44
|
+
//PNG parser over WebP bytes.
|
|
26
45
|
if (src.startsWith('data:')) {
|
|
27
|
-
const
|
|
46
|
+
const mime = /^data:([^;,]+)/.exec(src)?.[1];
|
|
47
|
+
const extension = (mime && MIME_TO_FORMAT[mime]) ?? /\.([a-z0-9]+)$/i.exec(path)?.[1];
|
|
28
48
|
if (extension)
|
|
29
49
|
descriptor.format = extension;
|
|
30
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAsB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/assets/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAsB,MAAM,YAAY,CAAC;AA+CzD;;;;;;GAMG;AACH,MAAM,cAAc,GAA2B;IAC9C,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,KAAK;CACtB,CAAC;AAWF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,KAAe,EAAE,OAAO,GAAsC,EAAE;IAC1F,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GACpD,OAAO,OAAO,KAAK,UAAU;QAC5B,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE;QAC3F,CAAC,CAAC,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAA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