@datamoc/mw_games 0.10.0 → 0.12.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 +83 -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/audio/Playable.d.ts +2 -0
- package/dist/audio/Playable.d.ts.map +1 -1
- package/dist/audio/Playable.js.map +1 -1
- package/dist/audio/Sound.d.ts +7 -1
- package/dist/audio/Sound.d.ts.map +1 -1
- package/dist/audio/Sound.js +8 -1
- package/dist/audio/Sound.js.map +1 -1
- package/dist/mw_games.global.js +56 -56
- package/dist/rpg/EventRunner.d.ts +4 -0
- package/dist/rpg/EventRunner.d.ts.map +1 -1
- package/dist/rpg/EventRunner.js +4 -4
- package/dist/rpg/EventRunner.js.map +1 -1
- package/dist/rpg/GridMover.d.ts +6 -0
- package/dist/rpg/GridMover.d.ts.map +1 -1
- package/dist/rpg/GridMover.js +17 -0
- package/dist/rpg/GridMover.js.map +1 -1
- package/dist/rpg/MoveRoute.d.ts +87 -0
- package/dist/rpg/MoveRoute.d.ts.map +1 -0
- package/dist/rpg/MoveRoute.js +110 -0
- package/dist/rpg/MoveRoute.js.map +1 -0
- package/dist/rpg/index.d.ts +2 -0
- package/dist/rpg/index.d.ts.map +1 -1
- package/dist/rpg/index.js +1 -0
- package/dist/rpg/index.js.map +1 -1
- package/dist/two-d/ui/EventDialogue.d.ts.map +1 -1
- package/dist/two-d/ui/EventDialogue.js +7 -1
- package/dist/two-d/ui/EventDialogue.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
- 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,89 @@ the public API may still change between minor versions.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.12.0] - 2026-09-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `rpg.EventRunner`'s `DialogueRequest` (and `EventCommand`'s `say`/`ask`) gained an optional
|
|
15
|
+
`portrait` field, threaded through to `two-d/ui.messageBoxPresenter` and `MessageBox`'s own
|
|
16
|
+
pre-existing `portrait` support - a portrait-bearing line no longer has to bypass `present`
|
|
17
|
+
and build its own `MessageBox` directly (item 352).
|
|
18
|
+
- `rpg.GridMover.jumpBy` - an instant reposition with no tween and no walk animation, for a
|
|
19
|
+
"jump" move-route step over terrain `moveBy`'s glide has no way to skip.
|
|
20
|
+
- `rpg.MoveRouteRunner`/`MoveRoute`/`MoveRouteStep`/`MoveRouteOptions` - drives any `GridMover`
|
|
21
|
+
through a scripted route (fixed/random/toward/away steps, turn, jump, wait) with `repeat` and
|
|
22
|
+
`skippable` policies, built entirely on `GridMover`'s existing primitives (item 353).
|
|
23
|
+
- `audio.Sound.play(gain, pitch)` - an optional pitch parameter as `HTMLAudioElement.
|
|
24
|
+
playbackRate`. No matching `pan`: a plain `<audio>` element has none to set, the same reason
|
|
25
|
+
`Positional.audioPan` only ever reported a number rather than owning a panner node (item 354).
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- `mobile:build` (and everything built on it: `cap:sync`, `cap:add:android`, `desktop:build`,
|
|
30
|
+
`desktop:run`) now passes `--no-compress` to `emit-page.mjs`. Item 349/350's `.gz`/`.br`
|
|
31
|
+
sidecar files, written by default into every build since those items shipped, broke the
|
|
32
|
+
Android/Capacitor asset merge (`Duplicate resources` from AAPT, which treats `game.js` and
|
|
33
|
+
`game.js.gz` as colliding) the first time the full pipeline was actually built and run
|
|
34
|
+
end to end (item 351) - those sidecars were always dead weight for a packaged native app
|
|
35
|
+
with no server to negotiate `Content-Encoding` for, so this drops them at the source rather
|
|
36
|
+
than special-casing the generated `android/` project.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- `android/` is no longer `.gitignore`d (item 110's original choice, kept since). The
|
|
41
|
+
Capacitor-scaffolded project's own generated `.gitignore` already excludes build output,
|
|
42
|
+
`local.properties`, and the copied web assets/config that `cap sync` regenerates every
|
|
43
|
+
build - the 53 files it leaves are ordinary scaffold source (manifest, Java, gradle files,
|
|
44
|
+
launcher/splash resources), the same kind of thing worth tracking as any other native
|
|
45
|
+
wrapper customization: this session's own `ignoreAssetsPattern` fix (above) would otherwise
|
|
46
|
+
have been silently lost the next time someone ran `cap add android` fresh.
|
|
47
|
+
- `webpage/assets/0c_framework_architecture.svg` regenerated - it had gone stale since the
|
|
48
|
+
`ai` and `mwl` modules were added to `src/`, so the "generated, never hand-drawn" diagram
|
|
49
|
+
was quietly wrong about the current module list until `npm run webpage:diagrams` was
|
|
50
|
+
actually re-run (item 351's Android/Windows verification pass turned this up while
|
|
51
|
+
double-checking related documentation).
|
|
52
|
+
- `webpage/design/architecture-explorer.html`, the interactive module-graph explorer, was
|
|
53
|
+
regenerated via the archify skill for the same reason: authored once at release 0.4.3, it
|
|
54
|
+
had never been updated and was missing `ai`/`mwl` entirely despite linking to itself as
|
|
55
|
+
"generated straight from src/'s own import graph". Rebuilt with real, verified import-graph
|
|
56
|
+
data for all 15 current modules and a fourth guided view ("mwl as data-authoring backbone").
|
|
57
|
+
- `desktop/README.md` documented only the older, unwired `desktop/webview2` host and never
|
|
58
|
+
mentioned `desktop/MwgDesktopHost` - the one `desktop:build`/`desktop:run` actually build -
|
|
59
|
+
or its `SetVirtualHostNameToFolderMapping` capability. Rewritten to cover both hosts and
|
|
60
|
+
which job each is for.
|
|
61
|
+
|
|
62
|
+
## [0.11.0] - 2026-09-14
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- `tools/webp-convert.mjs` (`toWebp`) and `compileResources`'s `toWebp`/`webpLossless`/
|
|
67
|
+
`webpQuality` options - convert `.png`/`.jpg`/`.jpeg` build assets to WebP before embedding,
|
|
68
|
+
lossless by default (verified pixel-for-pixel identical to the source) and only kept when
|
|
69
|
+
actually smaller, under the asset's unchanged key so `load('sprite.png')` keeps working the
|
|
70
|
+
same in dev and built modes. Needs the optional `sharp` devDependency, dynamically imported
|
|
71
|
+
only when `toWebp` is used, so a build that never asks for it never needs it installed
|
|
72
|
+
(item 350).
|
|
73
|
+
- `single-file.mjs`'s `algorithm: 'gzip' | 'brotli'` option (`--brotli[=quality]` on the CLI,
|
|
74
|
+
`--single-file-brotli[=quality]` on `emit-page`) - brotli compression for the single-file
|
|
75
|
+
build alongside the existing gzip path. gzip stays the broadly-supported default: a real
|
|
76
|
+
Chrome (153) tested directly during this feature's own verification throws for
|
|
77
|
+
`DecompressionStream('br')`, so brotli is documented as an advanced, narrower-reach option
|
|
78
|
+
rather than an assumed-safe default (item 350).
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- `single-file.mjs`'s generated bootstrap: `new DecompressionStream(format)` throws
|
|
83
|
+
synchronously for an unsupported format rather than rejecting a promise, which escaped the
|
|
84
|
+
bootstrap's own error handling entirely and left the splash screen stuck forever instead of
|
|
85
|
+
failing visibly - found live in the browser while verifying item 350's brotli option, fixed
|
|
86
|
+
for both gzip and brotli by converting the throw into a rejection.
|
|
87
|
+
- `assets.load`'s `data:` URI format hint now comes from the URI's own MIME type first, falling
|
|
88
|
+
back to the asset path's extension only when that is unavailable. Found while reviewing
|
|
89
|
+
item 350's WebP conversion: `toWebp` can compile a `sprite.png` path into `image/webp` bytes
|
|
90
|
+
(keeping the `.png` key so dev and built modes keep agreeing), and the old, path-only hint
|
|
91
|
+
would have told Pixi's resolver to run the PNG parser over WebP data.
|
|
92
|
+
|
|
10
93
|
## [0.10.0] - 2026-09-14
|
|
11
94
|
|
|
12
95
|
### 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,EAA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
10
|
currentTime: number;
|
|
11
11
|
volume: number;
|
|
12
12
|
loop: boolean;
|
|
13
|
+
/** speed and pitch together, matching `HTMLAudioElement.playbackRate`; 1 is unchanged */
|
|
14
|
+
playbackRate?: number;
|
|
13
15
|
/** Optional completion hook, matching HTMLAudioElement.onended. Backends without an
|
|
14
16
|
* end event can omit it; single-track Music remains fully usable there. */
|
|
15
17
|
onended?: ((event: Event) => unknown) | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playable.d.ts","sourceRoot":"","sources":["../../src/audio/Playable.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACxB,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd;+EAC2E;IAC3E,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAElD"}
|
|
1
|
+
{"version":3,"file":"Playable.d.ts","sourceRoot":"","sources":["../../src/audio/Playable.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACxB,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;+EAC2E;IAC3E,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playable.js","sourceRoot":"","sources":["../../src/audio/Playable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Playable.js","sourceRoot":"","sources":["../../src/audio/Playable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAqBhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/audio/Sound.d.ts
CHANGED
|
@@ -33,8 +33,14 @@ export declare class Sound {
|
|
|
33
33
|
*
|
|
34
34
|
* @param gain multiplied into the sound's own volume, for a distance-attenuated one-shot
|
|
35
35
|
* (`Positional.SoundSource.playFor`); 1 leaves it at `volume`.
|
|
36
|
+
* @param pitch played back at this rate, matching `HTMLAudioElement.playbackRate` (1 is
|
|
37
|
+
* unchanged, above 1 higher and faster, below 1 lower and slower) - a footstep or a hit
|
|
38
|
+
* that always sounds identical reads as a loop faster than one with a little variance.
|
|
39
|
+
* There is no matching `pan` parameter: a plain `<audio>` element has no pan of its own to
|
|
40
|
+
* set, and `Positional.audioPan` already made the deliberate call to report a number rather
|
|
41
|
+
* than own a panner node a game does not necessarily want - the same reasoning applies here.
|
|
36
42
|
*/
|
|
37
|
-
play(gain?: number): void;
|
|
43
|
+
play(gain?: number, pitch?: number): void;
|
|
38
44
|
stopAll(): void;
|
|
39
45
|
}
|
|
40
46
|
//# sourceMappingURL=Sound.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sound.d.ts","sourceRoot":"","sources":["../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IACH,IAAI,CAAC,IAAI,SAAI,EAAE,KAAK,SAAI,GAAG,IAAI,CAa9B;IAED,OAAO,IAAI,IAAI,CAKd;CACD"}
|
package/dist/audio/Sound.js
CHANGED
|
@@ -28,11 +28,18 @@ export class Sound {
|
|
|
28
28
|
*
|
|
29
29
|
* @param gain multiplied into the sound's own volume, for a distance-attenuated one-shot
|
|
30
30
|
* (`Positional.SoundSource.playFor`); 1 leaves it at `volume`.
|
|
31
|
+
* @param pitch played back at this rate, matching `HTMLAudioElement.playbackRate` (1 is
|
|
32
|
+
* unchanged, above 1 higher and faster, below 1 lower and slower) - a footstep or a hit
|
|
33
|
+
* that always sounds identical reads as a loop faster than one with a little variance.
|
|
34
|
+
* There is no matching `pan` parameter: a plain `<audio>` element has no pan of its own to
|
|
35
|
+
* set, and `Positional.audioPan` already made the deliberate call to report a number rather
|
|
36
|
+
* than own a panner node a game does not necessarily want - the same reasoning applies here.
|
|
31
37
|
*/
|
|
32
|
-
play(gain = 1) {
|
|
38
|
+
play(gain = 1, pitch = 1) {
|
|
33
39
|
const audio = this.pool[this.next];
|
|
34
40
|
this.next = (this.next + 1) % this.pool.length;
|
|
35
41
|
audio.volume = this.volume * gain;
|
|
42
|
+
audio.playbackRate = pitch;
|
|
36
43
|
audio.currentTime = 0;
|
|
37
44
|
// play() can return a Promise that rejects if this reuse interrupts its own prior,
|
|
38
45
|
// still-loading play() (a real browser, not the fakes tests supply) - swallow it the
|
package/dist/audio/Sound.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAc1C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,KAAK;IAMjB,YAAY,IAAY,EAAE,OAAO,GAAiB,EAAE;QAJ5C,SAAI,GAAG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