@phaserjs/phaser-editor-layout 1.1.0 → 1.1.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 +5 -4
- package/dist/LayoutPlugin.d.ts +7 -4
- package/dist/LayoutPlugin.d.ts.map +1 -1
- package/dist/LayoutPlugin.js +11 -4
- package/dist/LayoutPlugin.js.map +1 -1
- package/dist/LayoutZone.d.ts +5 -2
- package/dist/LayoutZone.d.ts.map +1 -1
- package/dist/LayoutZone.js +5 -2
- package/dist/LayoutZone.js.map +1 -1
- package/dist/phaser-editor-layout.js +16 -6
- package/dist/phaser-editor-layout.js.map +2 -2
- package/dist/phaser-editor-layout.min.js +1 -1
- package/global/phaser-editor-layout.global.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ already has.
|
|
|
33
33
|
- **Zones.** A zone is a screen-relative rectangle defined by margins from each screen
|
|
34
34
|
edge (also split into `base` / `portrait` / `landscape`). The built-ins are `screen`
|
|
35
35
|
(full bounds) and `safeArea` (insets supplied by the host). Make your own with
|
|
36
|
-
`createZone(
|
|
36
|
+
`createZone({ base, portrait?, landscape? })`.
|
|
37
37
|
- **Anchors.** Per axis you pick an edge (`left`/`center`/`right`, `top`/`center`/
|
|
38
38
|
`bottom`, or `none`) plus a pixel offset. The object's matching edge/center is aligned
|
|
39
39
|
to the target's, then nudged by the offset.
|
|
@@ -75,8 +75,8 @@ export class MainScene extends Phaser.Scene {
|
|
|
75
75
|
|
|
76
76
|
create() {
|
|
77
77
|
// Built-in zones are always available: this.layout.screen and this.layout.safeArea.
|
|
78
|
-
// Make a custom zone
|
|
79
|
-
const reelsZone = this.layout.createZone(360, 90, 470, 90);
|
|
78
|
+
// Make a custom zone with per-variant margins (top/right/bottom/left insets).
|
|
79
|
+
const reelsZone = this.layout.createZone({ base: { marginTop: 360, marginRight: 90, marginBottom: 470, marginLeft: 90 } });
|
|
80
80
|
|
|
81
81
|
// Top-centered logo, anchored to the safe area. Configure the `base` variant.
|
|
82
82
|
const logo = this.add.image(0, 0, "logo");
|
|
@@ -226,7 +226,7 @@ this.layout.on(LAYOUT_UPDATE_EVENT, () => {
|
|
|
226
226
|
| `variant: VariantName` | The active variant (`"base" \| "portrait" \| "landscape"`). Defaults to `"base"`. |
|
|
227
227
|
| `add(obj): AnchorLayoutData` | Enable layout for `obj`: attaches a default `obj.layoutData`, registers it, and returns the data to configure. |
|
|
228
228
|
| `remove(obj): void` | Stop laying out `obj` and clear its `layoutData`. |
|
|
229
|
-
| `createZone(
|
|
229
|
+
| `createZone(variants?): LayoutZone` | Create a custom screen-relative zone, optionally setting per-variant margins (`{ base?, portrait?, landscape? }`, each a partial of the four `margin*` sides). Assign it to `data.<variant>.targetZone` with `targetType: "custom"`. |
|
|
230
230
|
| `setVariant(variant): void` | Manually set the active variant (turns off auto) and re-resolve. |
|
|
231
231
|
| `autoVariant(enabled?): void` | Follow the screen orientation on every resize (`portrait` / `landscape`); disabling resets to `"base"`. |
|
|
232
232
|
| `get orientation()` | The screen's current orientation (`"portrait"` if `height > width`, else `"landscape"`). |
|
|
@@ -266,6 +266,7 @@ All fields optional; on `portrait` / `landscape` an unset field inherits from `b
|
|
|
266
266
|
| --- | --- |
|
|
267
267
|
| `base: { marginTop, marginRight, marginBottom, marginLeft }` | Baseline insets from each screen edge, in pixels. |
|
|
268
268
|
| `portrait / landscape` | Partial margin overrides for those variants; unset sides inherit `base`. |
|
|
269
|
+
| `setMargins({ base?, portrait?, landscape? }): this` | Set margins for one or more variants in a single call, merging into what's there (only supplied sides change). Returns the zone for chaining. Handy for the built-in `safeArea` / `screen`. |
|
|
269
270
|
| `getRect(out?): Phaser.Geom.Rectangle` | The effective rect at the current screen size and active variant. Pass `out` to avoid allocations. |
|
|
270
271
|
|
|
271
272
|
## Resolution semantics
|
package/dist/LayoutPlugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Phaser from "phaser";
|
|
2
|
-
import { LayoutZone } from "./LayoutZone";
|
|
2
|
+
import { LayoutZone, ZoneVariantMargins } from "./LayoutZone";
|
|
3
3
|
import type { AnchorLayoutData, VariantName } from "./types";
|
|
4
4
|
/** Event fired by the plugin after each resolution pass. */
|
|
5
5
|
export declare const LAYOUT_UPDATE_EVENT = "layoutupdate";
|
|
@@ -94,10 +94,13 @@ export declare class LayoutPlugin extends Phaser.Plugins.ScenePlugin {
|
|
|
94
94
|
remove(obj: Phaser.GameObjects.GameObject): void;
|
|
95
95
|
private _onObjectDestroy;
|
|
96
96
|
/**
|
|
97
|
-
* Create a screen-relative zone
|
|
98
|
-
*
|
|
97
|
+
* Create a screen-relative zone, optionally setting its per-variant margins in the
|
|
98
|
+
* same call, e.g. `createZone({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
99
|
+
*
|
|
100
|
+
* A factory only — the returned zone is not stored by the plugin; hold the reference
|
|
101
|
+
* and assign it to `data.targetZone` (with `targetType: "custom"`).
|
|
99
102
|
*/
|
|
100
|
-
createZone(
|
|
103
|
+
createZone(variants?: ZoneVariantMargins): LayoutZone;
|
|
101
104
|
/**
|
|
102
105
|
* Re-resolve every enabled object now. The plugin also runs this automatically on
|
|
103
106
|
* `scale` `resize` and once after the scene is created, so explicit calls are only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutPlugin.d.ts","sourceRoot":"","sources":["../src/LayoutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"LayoutPlugin.d.ts","sourceRoot":"","sources":["../src/LayoutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAgC,WAA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IAAI;IAO/E,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAS/F,QAAQ,IAAI,IAAI;IAYhB,OAAO,IAAI,IAAI;CAQlB"}
|
package/dist/LayoutPlugin.js
CHANGED
|
@@ -150,11 +150,18 @@ export class LayoutPlugin extends Phaser.Plugins.ScenePlugin {
|
|
|
150
150
|
}
|
|
151
151
|
// ----- zones -----
|
|
152
152
|
/**
|
|
153
|
-
* Create a screen-relative zone
|
|
154
|
-
*
|
|
153
|
+
* Create a screen-relative zone, optionally setting its per-variant margins in the
|
|
154
|
+
* same call, e.g. `createZone({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
155
|
+
*
|
|
156
|
+
* A factory only — the returned zone is not stored by the plugin; hold the reference
|
|
157
|
+
* and assign it to `data.targetZone` (with `targetType: "custom"`).
|
|
155
158
|
*/
|
|
156
|
-
createZone(
|
|
157
|
-
|
|
159
|
+
createZone(variants) {
|
|
160
|
+
const zone = new LayoutZone(this._scene, this);
|
|
161
|
+
if (variants) {
|
|
162
|
+
zone.setMargins(variants);
|
|
163
|
+
}
|
|
164
|
+
return zone;
|
|
158
165
|
}
|
|
159
166
|
// ----- resolution -----
|
|
160
167
|
/**
|
package/dist/LayoutPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutPlugin.js","sourceRoot":"","sources":["../src/LayoutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAYlD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM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AC;IAC1B,CAAC;IAED,OAAO;QAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAEtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ"}
|
package/dist/LayoutZone.d.ts
CHANGED
|
@@ -56,8 +56,11 @@ export declare class LayoutZone {
|
|
|
56
56
|
constructor(scene: Phaser.Scene, provider: VariantProvider, marginTop?: number, marginRight?: number, marginBottom?: number, marginLeft?: number);
|
|
57
57
|
/**
|
|
58
58
|
* Sets margins for one or more variants in a single call, merging into whatever is
|
|
59
|
-
* already there (only the supplied sides change). Returns `this` for chaining
|
|
60
|
-
*
|
|
59
|
+
* already there (only the supplied sides change). Returns `this` for chaining.
|
|
60
|
+
*
|
|
61
|
+
* Handy for the built-in zones, e.g.
|
|
62
|
+
* `scene.layout.safeArea.setMargins({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
63
|
+
* Custom zones can pass the same object straight to {@link LayoutPlugin.createZone}.
|
|
61
64
|
*
|
|
62
65
|
* The editor's code generator uses this for zones and the safe area, since (unlike
|
|
63
66
|
* per-object layout data) zone margins have no per-field override semantics.
|
package/dist/LayoutZone.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutZone.d.ts","sourceRoot":"","sources":["../src/LayoutZone.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC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5B,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACpC;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACjE;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAU;IAEnB,yCAAyC;IACzC,IAAI,EAAE,WAAW,CAAC;IAElB,wEAAwE;IACxE,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/B,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAEhC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAGvC,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,eAAe,EACzB,SAAS,SAAI,EACb,WAAW,SAAI,EACf,YAAY,SAAI,EAChB,UAAU,SAAI;IASlB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAoB9C,mEAAmE;IACnE,OAAO,CAAC,OAAO;IAiBf;;;OAGG;IACH,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS;CAkB9D"}
|
package/dist/LayoutZone.js
CHANGED
|
@@ -24,8 +24,11 @@ export class LayoutZone {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Sets margins for one or more variants in a single call, merging into whatever is
|
|
27
|
-
* already there (only the supplied sides change). Returns `this` for chaining
|
|
28
|
-
*
|
|
27
|
+
* already there (only the supplied sides change). Returns `this` for chaining.
|
|
28
|
+
*
|
|
29
|
+
* Handy for the built-in zones, e.g.
|
|
30
|
+
* `scene.layout.safeArea.setMargins({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
31
|
+
* Custom zones can pass the same object straight to {@link LayoutPlugin.createZone}.
|
|
29
32
|
*
|
|
30
33
|
* The editor's code generator uses this for zones and the safe area, since (unlike
|
|
31
34
|
* per-object layout data) zone margins have no per-field override semantics.
|
package/dist/LayoutZone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutZone.js","sourceRoot":"","sources":["../src/LayoutZone.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAiC5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,UAAU;IAcnB,YACI,KAAmB,EACnB,QAAyB,EACzB,SAAS,GAAG,CAAC,EACb,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,CAAC,EAChB,UAAU,GAAG,CAAC;QAEd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACxB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"LayoutZone.js","sourceRoot":"","sources":["../src/LayoutZone.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAiC5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,UAAU;IAcnB,YACI,KAAmB,EACnB,QAAyB,EACzB,SAAS,GAAG,CAAC,EACb,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,CAAC,EAChB,UAAU,GAAG,CAAC;QAEd,IAAI,CAAC,KAAK,GA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I,GAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,UAAU,mCAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;QAEnE,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE9D,IAAI,GAAG,EAAE,CAAC;YAEN,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YAE/B,OAAO,GAAG,CAAC;QACf,CAAC;QAED,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACJ"}
|
|
@@ -65,8 +65,11 @@ var PhaserEditorLayout = (() => {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Sets margins for one or more variants in a single call, merging into whatever is
|
|
68
|
-
* already there (only the supplied sides change). Returns `this` for chaining
|
|
69
|
-
*
|
|
68
|
+
* already there (only the supplied sides change). Returns `this` for chaining.
|
|
69
|
+
*
|
|
70
|
+
* Handy for the built-in zones, e.g.
|
|
71
|
+
* `scene.layout.safeArea.setMargins({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
72
|
+
* Custom zones can pass the same object straight to {@link LayoutPlugin.createZone}.
|
|
70
73
|
*
|
|
71
74
|
* The editor's code generator uses this for zones and the safe area, since (unlike
|
|
72
75
|
* per-object layout data) zone margins have no per-field override semantics.
|
|
@@ -245,11 +248,18 @@ var PhaserEditorLayout = (() => {
|
|
|
245
248
|
}
|
|
246
249
|
// ----- zones -----
|
|
247
250
|
/**
|
|
248
|
-
* Create a screen-relative zone
|
|
249
|
-
*
|
|
251
|
+
* Create a screen-relative zone, optionally setting its per-variant margins in the
|
|
252
|
+
* same call, e.g. `createZone({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.
|
|
253
|
+
*
|
|
254
|
+
* A factory only — the returned zone is not stored by the plugin; hold the reference
|
|
255
|
+
* and assign it to `data.targetZone` (with `targetType: "custom"`).
|
|
250
256
|
*/
|
|
251
|
-
createZone(
|
|
252
|
-
|
|
257
|
+
createZone(variants) {
|
|
258
|
+
const zone = new LayoutZone(this._scene, this);
|
|
259
|
+
if (variants) {
|
|
260
|
+
zone.setMargins(variants);
|
|
261
|
+
}
|
|
262
|
+
return zone;
|
|
253
263
|
}
|
|
254
264
|
// ----- resolution -----
|
|
255
265
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["phaser-global:phaser", "../src/index.ts", "../src/LayoutPlugin.ts", "../src/LayoutZone.ts"],
|
|
4
|
-
"sourcesContent": ["module.exports = globalThis.Phaser;", "export { LayoutPlugin, LAYOUT_UPDATE_EVENT } from \"./LayoutPlugin\";\nexport { LayoutZone } from \"./LayoutZone\";\nexport type { ZoneMargins, VariantProvider } from \"./LayoutZone\";\nexport type { AnchorLayoutData, AnchorProps, HAnchor, VAnchor, TargetType, VariantName } from \"./types\";\n\n// Side-effect import so the `Phaser.Scene.layout` / `GameObject.layoutData` global\n// augmentations are always part of the public type surface.\nimport \"./types\";\n", "import Phaser from \"phaser\";\nimport { LayoutZone } from \"./LayoutZone\";\nimport type { AnchorLayoutData, HAnchor, TargetType, VAnchor, VariantName } from \"./types\";\n\n/** Event fired by the plugin after each resolution pass. */\nexport const LAYOUT_UPDATE_EVENT = \"layoutupdate\";\n\n/** Fully resolved anchor properties for the active variant (base + overrides). */\ninterface ResolvedAnchor {\n targetType: TargetType;\n targetZone?: LayoutZone;\n horizontalAnchor: HAnchor;\n horizontalOffset: number;\n verticalAnchor: VAnchor;\n verticalOffset: number;\n}\n\n/**\n * Scene plugin that resolves responsive anchors and zones at run time.\n *\n * Reached as `this.layout` (like `this.physics`) once registered with\n * `mapping: \"layout\"`. Per-object layout state lives on the object as\n * `obj.layoutData`; the plugin keeps the set of enabled objects so it can\n * re-resolve them when the screen changes.\n *\n * Register it in the game config:\n *\n * ```ts\n * plugins: {\n * scene: [\n * { key: \"LayoutPlugin\", plugin: LayoutPlugin, mapping: \"layout\" }\n * ]\n * }\n * ```\n */\nexport class LayoutPlugin extends Phaser.Plugins.ScenePlugin {\n\n /** Screen inset by the device safe-area insets. The host sets `safeArea.margin*`. */\n readonly safeArea: LayoutZone;\n\n /** The full screen bounds (0,0 .. width,height). */\n readonly screen: LayoutZone;\n\n /**\n * Event emitter that fires {@link LAYOUT_UPDATE_EVENT} after each resolution pass.\n * Use `this.layout.events.on(\"layoutupdate\", ...)` \u2014 or the `on`/`once`/`off`\n * delegates on the plugin itself.\n */\n readonly events: Phaser.Events.EventEmitter;\n\n /**\n * The active layout variant. `\"base\"` applies only the baseline; `\"portrait\"` /\n * `\"landscape\"` apply their overrides on top of base. Defaults to `\"base\"`. Change\n * it with {@link setVariant} (manual) or {@link autoVariant} (orientation-driven).\n */\n variant: VariantName = \"base\";\n\n // Non-null scene reference captured at construction. `ScenePlugin.scene` /\n // `ScenePlugin.systems` are typed as nullable; this avoids guarding every use.\n private readonly _scene: Phaser.Scene;\n\n // When true, the active variant follows the screen orientation on every resize.\n private _auto = false;\n\n // Injected design size, or null to use the live scene size (scale.gameSize).\n private _designSize: { width: number; height: number } | null = null;\n\n private readonly _objects: Set<Phaser.GameObjects.GameObject>;\n\n // Scratch values reused across a pass to avoid allocations.\n private readonly _rect: Phaser.Geom.Rectangle;\n private readonly _mat: Phaser.GameObjects.Components.TransformMatrix;\n private readonly _p1: Phaser.Math.Vector2;\n private readonly _p2: Phaser.Math.Vector2;\n\n constructor(\n scene: Phaser.Scene,\n pluginManager: Phaser.Plugins.PluginManager,\n pluginKey: string\n ) {\n super(scene, pluginManager, pluginKey);\n\n this._scene = scene;\n this._objects = new Set();\n this.events = new Phaser.Events.EventEmitter();\n\n this.safeArea = new LayoutZone(scene, this);\n this.screen = new LayoutZone(scene, this);\n\n this._rect = new Phaser.Geom.Rectangle();\n this._mat = new Phaser.GameObjects.Components.TransformMatrix();\n this._p1 = new Phaser.Math.Vector2();\n this._p2 = new Phaser.Math.Vector2();\n }\n\n boot(): void {\n\n const events = this._scene.sys.events;\n\n events.on(Phaser.Scenes.Events.CREATE, this.refresh, this);\n events.on(Phaser.Scenes.Events.SHUTDOWN, this.shutdown, this);\n events.once(Phaser.Scenes.Events.DESTROY, this.destroy, this);\n\n this._scene.scale.on(Phaser.Scale.Events.RESIZE, this._onResize, this);\n }\n\n // ----- design size -----\n\n /**\n * The injected design size, or `null` when resolution follows the live scene size\n * (`scale.gameSize`). Read by zones (the plugin is their {@link LayoutZone} provider).\n */\n get designSize(): { width: number; height: number } | null {\n\n return this._designSize;\n }\n\n /**\n * Resolve against a fixed design size (e.g. 1080\u00D71920) instead of the live canvas\n * size, then re-resolve. Hosts that author/preview layouts at a target resolution\n * (the editor) use this; games typically leave it unset and follow `scale.gameSize`.\n */\n setDesignSize(width: number, height: number): void {\n\n this._designSize = { width, height };\n this.refresh();\n }\n\n /** Clear the injected design size and fall back to the live scene size, then re-resolve. */\n clearDesignSize(): void {\n\n this._designSize = null;\n this.refresh();\n }\n\n /** The effective size used for resolution: the injected design size, or the live game size. */\n private _size(): { width: number; height: number } {\n\n return this._designSize ?? this._scene.scale.gameSize;\n }\n\n // ----- variants -----\n\n /** The screen's current orientation, derived from the effective design size. */\n get orientation(): \"portrait\" | \"landscape\" {\n\n const size = this._size();\n\n return size.height > size.width ? \"portrait\" : \"landscape\";\n }\n\n /**\n * Manually set the active variant and re-resolve. Turns off orientation\n * auto-detection (see {@link autoVariant}).\n */\n setVariant(variant: VariantName): void {\n\n this._auto = false;\n this.variant = variant;\n this.refresh();\n }\n\n /**\n * Enable (or disable) orientation-driven variant selection. When enabled, the active\n * variant follows {@link orientation} (`\"portrait\"` / `\"landscape\"`) on every resize.\n * Disabling resets the variant to `\"base\"`.\n */\n autoVariant(enabled = true): void {\n\n this._auto = enabled;\n this.variant = enabled ? this.orientation : \"base\";\n this.refresh();\n }\n\n private _onResize(): void {\n\n if (this._auto) {\n\n this.variant = this.orientation;\n }\n\n this.refresh();\n }\n\n // ----- objects -----\n\n /**\n * Enable layout for an object: attaches a default {@link AnchorLayoutData} as\n * `obj.layoutData` (if it does not have one yet), registers the object for\n * re-resolution, and returns the data so it can be configured.\n *\n * The `base` defaults are inert: `targetType: \"screen\"`, both anchors `\"none\"` and\n * zero offsets, so the object does not move until you choose anchors. `portrait` and\n * `landscape` start empty (they inherit `base`).\n */\n add<T extends Phaser.GameObjects.GameObject>(obj: T): AnchorLayoutData {\n\n let data = obj.layoutData;\n\n if (!data) {\n\n data = {\n enabled: true,\n base: {\n targetType: \"screen\",\n horizontalAnchor: \"none\",\n horizontalOffset: 0,\n verticalAnchor: \"none\",\n verticalOffset: 0,\n },\n portrait: {},\n landscape: {},\n };\n\n obj.layoutData = data;\n }\n\n this._objects.add(obj);\n\n obj.once(Phaser.GameObjects.Events.DESTROY, this._onObjectDestroy, this);\n\n return data;\n }\n\n /** Stop laying out an object and remove its `layoutData`. */\n remove(obj: Phaser.GameObjects.GameObject): void {\n\n this._objects.delete(obj);\n\n obj.off(Phaser.GameObjects.Events.DESTROY, this._onObjectDestroy, this);\n\n obj.layoutData = undefined;\n }\n\n private _onObjectDestroy(obj: Phaser.GameObjects.GameObject): void {\n\n this._objects.delete(obj);\n }\n\n // ----- zones -----\n\n /**\n * Create a screen-relative zone. A factory only \u2014 the returned zone is not stored\n * by the plugin; hold the reference and assign it to `data.targetZone`.\n */\n createZone(\n marginTop = 0,\n marginRight = 0,\n marginBottom = 0,\n marginLeft = 0\n ): LayoutZone {\n\n return new LayoutZone(this._scene, this, marginTop, marginRight, marginBottom, marginLeft);\n }\n\n // ----- resolution -----\n\n /**\n * Re-resolve every enabled object now. The plugin also runs this automatically on\n * `scale` `resize` and once after the scene is created, so explicit calls are only\n * needed after mutating layout data (or the `safeArea` margins) at run time.\n *\n * Objects are resolved parent \u2192 child so a child anchored to its parent's bounds\n * sees the parent's already-resolved rect.\n */\n refresh(): void {\n\n const list: Phaser.GameObjects.GameObject[] = [];\n\n for (const obj of this._objects) {\n\n const data = obj.layoutData;\n\n if (data && data.enabled) {\n\n list.push(obj);\n }\n }\n\n list.sort((a, b) => this._depth(a) - this._depth(b));\n\n for (const obj of list) {\n\n this._resolve(obj);\n }\n\n this.events.emit(LAYOUT_UPDATE_EVENT);\n }\n\n /**\n * Resolve a specific list of objects once, against the current variant / design size /\n * zones, **without** registering them for future passes (no {@link add}, no re-resolve\n * on resize). Hosts that drive resolution themselves \u2014 e.g. the editor's live preview \u2014\n * set each object's `layoutData`, call this, then read back the resolved `x`/`y`.\n *\n * Objects are still resolved parent \u2192 child, and any object whose `layoutData` is\n * missing or disabled is skipped.\n */\n resolveList(objects: Phaser.GameObjects.GameObject[]): void {\n\n const list = objects.filter(obj => obj.layoutData && obj.layoutData.enabled);\n\n list.sort((a, b) => this._depth(a) - this._depth(b));\n\n for (const obj of list) {\n\n this._resolve(obj);\n }\n\n this.events.emit(LAYOUT_UPDATE_EVENT);\n }\n\n private _depth(obj: Phaser.GameObjects.GameObject): number {\n\n let depth = 0;\n let parent = obj.parentContainer;\n\n while (parent) {\n\n depth++;\n parent = parent.parentContainer;\n }\n\n return depth;\n }\n\n private _resolve(obj: Phaser.GameObjects.GameObject): void {\n\n // `x`, `y`, `displayWidth`, origin, etc. live on transform/size/origin\n // components, not on the GameObject base type.\n const go = obj as any;\n const data = obj.layoutData as AnchorLayoutData;\n\n const originX = typeof go.originX === \"number\" ? go.originX : 0;\n const originY = typeof go.originY === \"number\" ? go.originY : 0;\n\n const eff = this._effective(data);\n\n if (eff.targetType === \"parent\") {\n\n this._resolveAgainstParent(go, eff, originX, originY);\n\n return;\n }\n\n this._resolveAgainstZone(go, eff, originX, originY);\n }\n\n /** Merge the active variant's overrides over `base` into concrete anchor properties. */\n private _effective(data: AnchorLayoutData): ResolvedAnchor {\n\n const base = data.base;\n const over = this.variant === \"base\" ? undefined : data[this.variant];\n\n return {\n targetType: over?.targetType ?? base.targetType ?? \"screen\",\n targetZone: over?.targetZone ?? base.targetZone,\n horizontalAnchor: over?.horizontalAnchor ?? base.horizontalAnchor ?? \"none\",\n horizontalOffset: over?.horizontalOffset ?? base.horizontalOffset ?? 0,\n verticalAnchor: over?.verticalAnchor ?? base.verticalAnchor ?? \"none\",\n verticalOffset: over?.verticalOffset ?? base.verticalOffset ?? 0,\n };\n }\n\n /** The zone a non-parent target resolves against. */\n private _zoneFor(eff: ResolvedAnchor): LayoutZone {\n\n switch (eff.targetType) {\n\n case \"safeArea\":\n return this.safeArea;\n\n case \"custom\":\n return eff.targetZone ?? this.screen;\n\n default: // \"screen\"\n return this.screen;\n }\n }\n\n /** Resolve against a zone's world rect, converting to parent-local space if nested. */\n private _resolveAgainstZone(\n go: any,\n eff: ResolvedAnchor,\n originX: number,\n originY: number\n ): void {\n\n const zone = this._zoneFor(eff);\n const t = zone.getRect(this._rect);\n\n const w = this._sizeX(go);\n const h = this._sizeY(go);\n\n const parent: Phaser.GameObjects.Container | null = go.parentContainer ?? null;\n\n if (parent) {\n\n // Work in world space, then convert the result into the parent's local space.\n const m = parent.getWorldTransformMatrix(this._mat);\n const cur = m.transformPoint(go.x, go.y, this._p1) as Phaser.Math.Vector2;\n\n const wx = this._axis(eff.horizontalAnchor, cur.x, t.left, t.right, eff.horizontalOffset, w, originX);\n const wy = this._axis(eff.verticalAnchor, cur.y, t.top, t.bottom, eff.verticalOffset, h, originY);\n\n const local = m.applyInverse(wx, wy, this._p2) as Phaser.Math.Vector2;\n\n go.x = local.x;\n go.y = local.y;\n\n return;\n }\n\n go.x = this._axis(eff.horizontalAnchor, go.x, t.left, t.right, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, t.top, t.bottom, eff.verticalOffset, h, originY);\n }\n\n /** Resolve against the object's parent container bounds (local space), or the screen. */\n private _resolveAgainstParent(\n go: any,\n eff: ResolvedAnchor,\n originX: number,\n originY: number\n ): void {\n\n const parent: Phaser.GameObjects.Container | null = go.parentContainer ?? null;\n\n if (parent) {\n\n // Children live in the parent's unscaled local space, with (0,0) at the\n // container origin. Use the container's explicit size as the rect, and the\n // child's local (unscaled-by-parent) size for edge alignment.\n const right = (parent as any).width || 0;\n const bottom = (parent as any).height || 0;\n\n const w = (go.width || 0) * (typeof go.scaleX === \"number\" ? go.scaleX : 1);\n const h = (go.height || 0) * (typeof go.scaleY === \"number\" ? go.scaleY : 1);\n\n go.x = this._axis(eff.horizontalAnchor, go.x, 0, right, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, 0, bottom, eff.verticalOffset, h, originY);\n\n return;\n }\n\n // No parent container: fall back to the screen rect, in world space.\n const size = this._size();\n const w = this._sizeX(go);\n const h = this._sizeY(go);\n\n go.x = this._axis(eff.horizontalAnchor, go.x, 0, size.width, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, 0, size.height, eff.verticalOffset, h, originY);\n }\n\n /**\n * Resolve one axis. Aligns the object's edge/center to the target edge/center,\n * accounting for the object's origin so `\"left\"`/`\"top\"` align the left/top edge,\n * `\"center\"` the center, and `\"right\"`/`\"bottom\"` the right/bottom edge.\n *\n * Reduces to the documented `t.left + offset + size / 2` form for centered-origin\n * objects (`origin = 0.5`).\n */\n private _axis(\n anchor: string,\n current: number,\n min: number,\n max: number,\n offset: number,\n size: number,\n origin: number\n ): number {\n\n switch (anchor) {\n\n case \"left\":\n case \"top\":\n return min + offset + origin * size;\n\n case \"right\":\n case \"bottom\":\n return max + offset - (1 - origin) * size;\n\n case \"center\":\n return (min + max) / 2 + offset + (origin - 0.5) * size;\n\n default: // \"none\"\n return current;\n }\n }\n\n private _sizeX(go: any): number {\n\n if (typeof go.displayWidth === \"number\") {\n\n return go.displayWidth;\n }\n\n return typeof go.width === \"number\" ? go.width : 0;\n }\n\n private _sizeY(go: any): number {\n\n if (typeof go.displayHeight === \"number\") {\n\n return go.displayHeight;\n }\n\n return typeof go.height === \"number\" ? go.height : 0;\n }\n\n // ----- event delegates -----\n\n on(event: string | symbol, fn: (...args: any[]) => void, context?: any): this {\n\n this.events.on(event, fn, context);\n\n return this;\n }\n\n once(event: string | symbol, fn: (...args: any[]) => void, context?: any): this {\n\n this.events.once(event, fn, context);\n\n return this;\n }\n\n off(event: string | symbol, fn?: (...args: any[]) => void, context?: any, once?: boolean): this {\n\n this.events.off(event, fn, context, once);\n\n return this;\n }\n\n // ----- lifecycle -----\n\n shutdown(): void {\n\n const events = this._scene.sys.events;\n\n events.off(Phaser.Scenes.Events.CREATE, this.refresh, this);\n events.off(Phaser.Scenes.Events.SHUTDOWN, this.shutdown, this);\n\n this._scene.scale.off(Phaser.Scale.Events.RESIZE, this._onResize, this);\n\n this._objects.clear();\n }\n\n destroy(): void {\n\n this.shutdown();\n\n this.events.destroy();\n\n super.destroy();\n }\n}\n", "import Phaser from \"phaser\";\nimport type { VariantName } from \"./types\";\n\n/** The four screen-edge insets that define a zone, in scene/world pixels. */\nexport interface ZoneMargins {\n marginTop: number;\n marginRight: number;\n marginBottom: number;\n marginLeft: number;\n}\n\n/**\n * Per-variant margin overrides accepted by {@link LayoutZone.setMargins}. Every side of\n * every variant is optional; only the supplied sides are changed.\n */\nexport interface ZoneVariantMargins {\n base?: Partial<ZoneMargins>;\n portrait?: Partial<ZoneMargins>;\n landscape?: Partial<ZoneMargins>;\n}\n\n/** Minimal view of the plugin that supplies the active variant and design size. */\nexport interface VariantProvider {\n readonly variant: VariantName;\n\n /**\n * The design size the zones inset from, or `null` to use the live scene size\n * (`scene.scale.gameSize`). A host (e.g. the editor) can inject a fixed design size\n * to resolve against a target resolution instead of the current canvas size.\n */\n readonly designSize: { width: number; height: number } | null;\n}\n\n/**\n * A screen-relative rectangle defined by an inset (margin) from each screen edge.\n *\n * Margins are split into variants: `base` is the baseline (all four sides), and\n * `portrait` / `landscape` are partial overrides \u2014 any side left unset inherits from\n * `base`. The active variant follows the plugin (see {@link VariantProvider}), so a\n * zone's rect can differ per orientation.\n *\n * The rect is computed **lazily** via {@link LayoutZone.getRect} from the current screen\n * size and the effective margins, so the plugin never has to store or iterate zones.\n *\n * The built-in `safeArea` zone is just a `LayoutZone` whose margins are the\n * device-provided insets (notch / home indicator); `screen` is a `LayoutZone` with all\n * margins at 0.\n */\nexport class LayoutZone {\n\n /** Baseline margins (all four sides). */\n base: ZoneMargins;\n\n /** Margin overrides applied when the active variant is `\"portrait\"`. */\n portrait: Partial<ZoneMargins>;\n\n /** Margin overrides applied when the active variant is `\"landscape\"`. */\n landscape: Partial<ZoneMargins>;\n\n private readonly scene: Phaser.Scene;\n private readonly provider: VariantProvider;\n\n constructor(\n scene: Phaser.Scene,\n provider: VariantProvider,\n marginTop = 0,\n marginRight = 0,\n marginBottom = 0,\n marginLeft = 0\n ) {\n this.scene = scene;\n this.provider = provider;\n this.base = { marginTop, marginRight, marginBottom, marginLeft };\n this.portrait = {};\n this.landscape = {};\n }\n\n /**\n * Sets margins for one or more variants in a single call, merging into whatever is\n * already there (only the supplied sides change). Returns `this` for chaining, e.g.\n * `scene.layout.createZone().setMargins({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.\n *\n * The editor's code generator uses this for zones and the safe area, since (unlike\n * per-object layout data) zone margins have no per-field override semantics.\n */\n setMargins(variants: ZoneVariantMargins): this {\n\n if (variants.base) {\n\n Object.assign(this.base, variants.base);\n }\n\n if (variants.portrait) {\n\n this.portrait = { ...this.portrait, ...variants.portrait };\n }\n\n if (variants.landscape) {\n\n this.landscape = { ...this.landscape, ...variants.landscape };\n }\n\n return this;\n }\n\n /** Effective value of one margin side under the active variant. */\n private _margin(side: keyof ZoneMargins): number {\n\n const variant = this.provider.variant;\n\n if (variant !== \"base\") {\n\n const override = (this[variant] as Partial<ZoneMargins>)[side];\n\n if (override !== undefined) {\n\n return override;\n }\n }\n\n return this.base[side];\n }\n\n /**\n * The effective rectangle at the current screen size and active variant. Pass an\n * `out` rectangle to avoid allocations.\n */\n getRect(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle {\n\n const size = this.provider.designSize ?? this.scene.scale.gameSize;\n\n const x = this._margin(\"marginLeft\");\n const y = this._margin(\"marginTop\");\n const width = size.width - x - this._margin(\"marginRight\");\n const height = size.height - y - this._margin(\"marginBottom\");\n\n if (out) {\n\n out.setTo(x, y, width, height);\n\n return out;\n }\n\n return new Phaser.Geom.Rectangle(x, y, width, height);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,aAAO,UAAU,WAAW;AAAA;AAAA;;;ACA5B;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,MAAAA,iBAAmB;;;ACAnB,sBAAmB;AAgDZ,MAAM,aAAN,MAAiB;AAAA,IAcpB,YACI,OACA,UACA,YAAY,GACZ,cAAc,GACd,eAAe,GACf,aAAa,GACf;AACE,WAAK,QAAQ;AACb,WAAK,WAAW;AAChB,WAAK,OAAO,EAAE,WAAW,aAAa,cAAc,WAAW;AAC/D,WAAK,WAAW,CAAC;AACjB,WAAK,YAAY,CAAC;AAAA,IACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["module.exports = globalThis.Phaser;", "export { LayoutPlugin, LAYOUT_UPDATE_EVENT } from \"./LayoutPlugin\";\nexport { LayoutZone } from \"./LayoutZone\";\nexport type { ZoneMargins, VariantProvider } from \"./LayoutZone\";\nexport type { AnchorLayoutData, AnchorProps, HAnchor, VAnchor, TargetType, VariantName } from \"./types\";\n\n// Side-effect import so the `Phaser.Scene.layout` / `GameObject.layoutData` global\n// augmentations are always part of the public type surface.\nimport \"./types\";\n", "import Phaser from \"phaser\";\nimport { LayoutZone, ZoneVariantMargins } from \"./LayoutZone\";\nimport type { AnchorLayoutData, HAnchor, TargetType, VAnchor, VariantName } from \"./types\";\n\n/** Event fired by the plugin after each resolution pass. */\nexport const LAYOUT_UPDATE_EVENT = \"layoutupdate\";\n\n/** Fully resolved anchor properties for the active variant (base + overrides). */\ninterface ResolvedAnchor {\n targetType: TargetType;\n targetZone?: LayoutZone;\n horizontalAnchor: HAnchor;\n horizontalOffset: number;\n verticalAnchor: VAnchor;\n verticalOffset: number;\n}\n\n/**\n * Scene plugin that resolves responsive anchors and zones at run time.\n *\n * Reached as `this.layout` (like `this.physics`) once registered with\n * `mapping: \"layout\"`. Per-object layout state lives on the object as\n * `obj.layoutData`; the plugin keeps the set of enabled objects so it can\n * re-resolve them when the screen changes.\n *\n * Register it in the game config:\n *\n * ```ts\n * plugins: {\n * scene: [\n * { key: \"LayoutPlugin\", plugin: LayoutPlugin, mapping: \"layout\" }\n * ]\n * }\n * ```\n */\nexport class LayoutPlugin extends Phaser.Plugins.ScenePlugin {\n\n /** Screen inset by the device safe-area insets. The host sets `safeArea.margin*`. */\n readonly safeArea: LayoutZone;\n\n /** The full screen bounds (0,0 .. width,height). */\n readonly screen: LayoutZone;\n\n /**\n * Event emitter that fires {@link LAYOUT_UPDATE_EVENT} after each resolution pass.\n * Use `this.layout.events.on(\"layoutupdate\", ...)` \u2014 or the `on`/`once`/`off`\n * delegates on the plugin itself.\n */\n readonly events: Phaser.Events.EventEmitter;\n\n /**\n * The active layout variant. `\"base\"` applies only the baseline; `\"portrait\"` /\n * `\"landscape\"` apply their overrides on top of base. Defaults to `\"base\"`. Change\n * it with {@link setVariant} (manual) or {@link autoVariant} (orientation-driven).\n */\n variant: VariantName = \"base\";\n\n // Non-null scene reference captured at construction. `ScenePlugin.scene` /\n // `ScenePlugin.systems` are typed as nullable; this avoids guarding every use.\n private readonly _scene: Phaser.Scene;\n\n // When true, the active variant follows the screen orientation on every resize.\n private _auto = false;\n\n // Injected design size, or null to use the live scene size (scale.gameSize).\n private _designSize: { width: number; height: number } | null = null;\n\n private readonly _objects: Set<Phaser.GameObjects.GameObject>;\n\n // Scratch values reused across a pass to avoid allocations.\n private readonly _rect: Phaser.Geom.Rectangle;\n private readonly _mat: Phaser.GameObjects.Components.TransformMatrix;\n private readonly _p1: Phaser.Math.Vector2;\n private readonly _p2: Phaser.Math.Vector2;\n\n constructor(\n scene: Phaser.Scene,\n pluginManager: Phaser.Plugins.PluginManager,\n pluginKey: string\n ) {\n super(scene, pluginManager, pluginKey);\n\n this._scene = scene;\n this._objects = new Set();\n this.events = new Phaser.Events.EventEmitter();\n\n this.safeArea = new LayoutZone(scene, this);\n this.screen = new LayoutZone(scene, this);\n\n this._rect = new Phaser.Geom.Rectangle();\n this._mat = new Phaser.GameObjects.Components.TransformMatrix();\n this._p1 = new Phaser.Math.Vector2();\n this._p2 = new Phaser.Math.Vector2();\n }\n\n boot(): void {\n\n const events = this._scene.sys.events;\n\n events.on(Phaser.Scenes.Events.CREATE, this.refresh, this);\n events.on(Phaser.Scenes.Events.SHUTDOWN, this.shutdown, this);\n events.once(Phaser.Scenes.Events.DESTROY, this.destroy, this);\n\n this._scene.scale.on(Phaser.Scale.Events.RESIZE, this._onResize, this);\n }\n\n // ----- design size -----\n\n /**\n * The injected design size, or `null` when resolution follows the live scene size\n * (`scale.gameSize`). Read by zones (the plugin is their {@link LayoutZone} provider).\n */\n get designSize(): { width: number; height: number } | null {\n\n return this._designSize;\n }\n\n /**\n * Resolve against a fixed design size (e.g. 1080\u00D71920) instead of the live canvas\n * size, then re-resolve. Hosts that author/preview layouts at a target resolution\n * (the editor) use this; games typically leave it unset and follow `scale.gameSize`.\n */\n setDesignSize(width: number, height: number): void {\n\n this._designSize = { width, height };\n this.refresh();\n }\n\n /** Clear the injected design size and fall back to the live scene size, then re-resolve. */\n clearDesignSize(): void {\n\n this._designSize = null;\n this.refresh();\n }\n\n /** The effective size used for resolution: the injected design size, or the live game size. */\n private _size(): { width: number; height: number } {\n\n return this._designSize ?? this._scene.scale.gameSize;\n }\n\n // ----- variants -----\n\n /** The screen's current orientation, derived from the effective design size. */\n get orientation(): \"portrait\" | \"landscape\" {\n\n const size = this._size();\n\n return size.height > size.width ? \"portrait\" : \"landscape\";\n }\n\n /**\n * Manually set the active variant and re-resolve. Turns off orientation\n * auto-detection (see {@link autoVariant}).\n */\n setVariant(variant: VariantName): void {\n\n this._auto = false;\n this.variant = variant;\n this.refresh();\n }\n\n /**\n * Enable (or disable) orientation-driven variant selection. When enabled, the active\n * variant follows {@link orientation} (`\"portrait\"` / `\"landscape\"`) on every resize.\n * Disabling resets the variant to `\"base\"`.\n */\n autoVariant(enabled = true): void {\n\n this._auto = enabled;\n this.variant = enabled ? this.orientation : \"base\";\n this.refresh();\n }\n\n private _onResize(): void {\n\n if (this._auto) {\n\n this.variant = this.orientation;\n }\n\n this.refresh();\n }\n\n // ----- objects -----\n\n /**\n * Enable layout for an object: attaches a default {@link AnchorLayoutData} as\n * `obj.layoutData` (if it does not have one yet), registers the object for\n * re-resolution, and returns the data so it can be configured.\n *\n * The `base` defaults are inert: `targetType: \"screen\"`, both anchors `\"none\"` and\n * zero offsets, so the object does not move until you choose anchors. `portrait` and\n * `landscape` start empty (they inherit `base`).\n */\n add<T extends Phaser.GameObjects.GameObject>(obj: T): AnchorLayoutData {\n\n let data = obj.layoutData;\n\n if (!data) {\n\n data = {\n enabled: true,\n base: {\n targetType: \"screen\",\n horizontalAnchor: \"none\",\n horizontalOffset: 0,\n verticalAnchor: \"none\",\n verticalOffset: 0,\n },\n portrait: {},\n landscape: {},\n };\n\n obj.layoutData = data;\n }\n\n this._objects.add(obj);\n\n obj.once(Phaser.GameObjects.Events.DESTROY, this._onObjectDestroy, this);\n\n return data;\n }\n\n /** Stop laying out an object and remove its `layoutData`. */\n remove(obj: Phaser.GameObjects.GameObject): void {\n\n this._objects.delete(obj);\n\n obj.off(Phaser.GameObjects.Events.DESTROY, this._onObjectDestroy, this);\n\n obj.layoutData = undefined;\n }\n\n private _onObjectDestroy(obj: Phaser.GameObjects.GameObject): void {\n\n this._objects.delete(obj);\n }\n\n // ----- zones -----\n\n /**\n * Create a screen-relative zone, optionally setting its per-variant margins in the\n * same call, e.g. `createZone({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.\n *\n * A factory only \u2014 the returned zone is not stored by the plugin; hold the reference\n * and assign it to `data.targetZone` (with `targetType: \"custom\"`).\n */\n createZone(variants?: ZoneVariantMargins): LayoutZone {\n\n const zone = new LayoutZone(this._scene, this);\n\n if (variants) {\n\n zone.setMargins(variants);\n }\n\n return zone;\n }\n\n // ----- resolution -----\n\n /**\n * Re-resolve every enabled object now. The plugin also runs this automatically on\n * `scale` `resize` and once after the scene is created, so explicit calls are only\n * needed after mutating layout data (or the `safeArea` margins) at run time.\n *\n * Objects are resolved parent \u2192 child so a child anchored to its parent's bounds\n * sees the parent's already-resolved rect.\n */\n refresh(): void {\n\n const list: Phaser.GameObjects.GameObject[] = [];\n\n for (const obj of this._objects) {\n\n const data = obj.layoutData;\n\n if (data && data.enabled) {\n\n list.push(obj);\n }\n }\n\n list.sort((a, b) => this._depth(a) - this._depth(b));\n\n for (const obj of list) {\n\n this._resolve(obj);\n }\n\n this.events.emit(LAYOUT_UPDATE_EVENT);\n }\n\n /**\n * Resolve a specific list of objects once, against the current variant / design size /\n * zones, **without** registering them for future passes (no {@link add}, no re-resolve\n * on resize). Hosts that drive resolution themselves \u2014 e.g. the editor's live preview \u2014\n * set each object's `layoutData`, call this, then read back the resolved `x`/`y`.\n *\n * Objects are still resolved parent \u2192 child, and any object whose `layoutData` is\n * missing or disabled is skipped.\n */\n resolveList(objects: Phaser.GameObjects.GameObject[]): void {\n\n const list = objects.filter(obj => obj.layoutData && obj.layoutData.enabled);\n\n list.sort((a, b) => this._depth(a) - this._depth(b));\n\n for (const obj of list) {\n\n this._resolve(obj);\n }\n\n this.events.emit(LAYOUT_UPDATE_EVENT);\n }\n\n private _depth(obj: Phaser.GameObjects.GameObject): number {\n\n let depth = 0;\n let parent = obj.parentContainer;\n\n while (parent) {\n\n depth++;\n parent = parent.parentContainer;\n }\n\n return depth;\n }\n\n private _resolve(obj: Phaser.GameObjects.GameObject): void {\n\n // `x`, `y`, `displayWidth`, origin, etc. live on transform/size/origin\n // components, not on the GameObject base type.\n const go = obj as any;\n const data = obj.layoutData as AnchorLayoutData;\n\n const originX = typeof go.originX === \"number\" ? go.originX : 0;\n const originY = typeof go.originY === \"number\" ? go.originY : 0;\n\n const eff = this._effective(data);\n\n if (eff.targetType === \"parent\") {\n\n this._resolveAgainstParent(go, eff, originX, originY);\n\n return;\n }\n\n this._resolveAgainstZone(go, eff, originX, originY);\n }\n\n /** Merge the active variant's overrides over `base` into concrete anchor properties. */\n private _effective(data: AnchorLayoutData): ResolvedAnchor {\n\n const base = data.base;\n const over = this.variant === \"base\" ? undefined : data[this.variant];\n\n return {\n targetType: over?.targetType ?? base.targetType ?? \"screen\",\n targetZone: over?.targetZone ?? base.targetZone,\n horizontalAnchor: over?.horizontalAnchor ?? base.horizontalAnchor ?? \"none\",\n horizontalOffset: over?.horizontalOffset ?? base.horizontalOffset ?? 0,\n verticalAnchor: over?.verticalAnchor ?? base.verticalAnchor ?? \"none\",\n verticalOffset: over?.verticalOffset ?? base.verticalOffset ?? 0,\n };\n }\n\n /** The zone a non-parent target resolves against. */\n private _zoneFor(eff: ResolvedAnchor): LayoutZone {\n\n switch (eff.targetType) {\n\n case \"safeArea\":\n return this.safeArea;\n\n case \"custom\":\n return eff.targetZone ?? this.screen;\n\n default: // \"screen\"\n return this.screen;\n }\n }\n\n /** Resolve against a zone's world rect, converting to parent-local space if nested. */\n private _resolveAgainstZone(\n go: any,\n eff: ResolvedAnchor,\n originX: number,\n originY: number\n ): void {\n\n const zone = this._zoneFor(eff);\n const t = zone.getRect(this._rect);\n\n const w = this._sizeX(go);\n const h = this._sizeY(go);\n\n const parent: Phaser.GameObjects.Container | null = go.parentContainer ?? null;\n\n if (parent) {\n\n // Work in world space, then convert the result into the parent's local space.\n const m = parent.getWorldTransformMatrix(this._mat);\n const cur = m.transformPoint(go.x, go.y, this._p1) as Phaser.Math.Vector2;\n\n const wx = this._axis(eff.horizontalAnchor, cur.x, t.left, t.right, eff.horizontalOffset, w, originX);\n const wy = this._axis(eff.verticalAnchor, cur.y, t.top, t.bottom, eff.verticalOffset, h, originY);\n\n const local = m.applyInverse(wx, wy, this._p2) as Phaser.Math.Vector2;\n\n go.x = local.x;\n go.y = local.y;\n\n return;\n }\n\n go.x = this._axis(eff.horizontalAnchor, go.x, t.left, t.right, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, t.top, t.bottom, eff.verticalOffset, h, originY);\n }\n\n /** Resolve against the object's parent container bounds (local space), or the screen. */\n private _resolveAgainstParent(\n go: any,\n eff: ResolvedAnchor,\n originX: number,\n originY: number\n ): void {\n\n const parent: Phaser.GameObjects.Container | null = go.parentContainer ?? null;\n\n if (parent) {\n\n // Children live in the parent's unscaled local space, with (0,0) at the\n // container origin. Use the container's explicit size as the rect, and the\n // child's local (unscaled-by-parent) size for edge alignment.\n const right = (parent as any).width || 0;\n const bottom = (parent as any).height || 0;\n\n const w = (go.width || 0) * (typeof go.scaleX === \"number\" ? go.scaleX : 1);\n const h = (go.height || 0) * (typeof go.scaleY === \"number\" ? go.scaleY : 1);\n\n go.x = this._axis(eff.horizontalAnchor, go.x, 0, right, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, 0, bottom, eff.verticalOffset, h, originY);\n\n return;\n }\n\n // No parent container: fall back to the screen rect, in world space.\n const size = this._size();\n const w = this._sizeX(go);\n const h = this._sizeY(go);\n\n go.x = this._axis(eff.horizontalAnchor, go.x, 0, size.width, eff.horizontalOffset, w, originX);\n go.y = this._axis(eff.verticalAnchor, go.y, 0, size.height, eff.verticalOffset, h, originY);\n }\n\n /**\n * Resolve one axis. Aligns the object's edge/center to the target edge/center,\n * accounting for the object's origin so `\"left\"`/`\"top\"` align the left/top edge,\n * `\"center\"` the center, and `\"right\"`/`\"bottom\"` the right/bottom edge.\n *\n * Reduces to the documented `t.left + offset + size / 2` form for centered-origin\n * objects (`origin = 0.5`).\n */\n private _axis(\n anchor: string,\n current: number,\n min: number,\n max: number,\n offset: number,\n size: number,\n origin: number\n ): number {\n\n switch (anchor) {\n\n case \"left\":\n case \"top\":\n return min + offset + origin * size;\n\n case \"right\":\n case \"bottom\":\n return max + offset - (1 - origin) * size;\n\n case \"center\":\n return (min + max) / 2 + offset + (origin - 0.5) * size;\n\n default: // \"none\"\n return current;\n }\n }\n\n private _sizeX(go: any): number {\n\n if (typeof go.displayWidth === \"number\") {\n\n return go.displayWidth;\n }\n\n return typeof go.width === \"number\" ? go.width : 0;\n }\n\n private _sizeY(go: any): number {\n\n if (typeof go.displayHeight === \"number\") {\n\n return go.displayHeight;\n }\n\n return typeof go.height === \"number\" ? go.height : 0;\n }\n\n // ----- event delegates -----\n\n on(event: string | symbol, fn: (...args: any[]) => void, context?: any): this {\n\n this.events.on(event, fn, context);\n\n return this;\n }\n\n once(event: string | symbol, fn: (...args: any[]) => void, context?: any): this {\n\n this.events.once(event, fn, context);\n\n return this;\n }\n\n off(event: string | symbol, fn?: (...args: any[]) => void, context?: any, once?: boolean): this {\n\n this.events.off(event, fn, context, once);\n\n return this;\n }\n\n // ----- lifecycle -----\n\n shutdown(): void {\n\n const events = this._scene.sys.events;\n\n events.off(Phaser.Scenes.Events.CREATE, this.refresh, this);\n events.off(Phaser.Scenes.Events.SHUTDOWN, this.shutdown, this);\n\n this._scene.scale.off(Phaser.Scale.Events.RESIZE, this._onResize, this);\n\n this._objects.clear();\n }\n\n destroy(): void {\n\n this.shutdown();\n\n this.events.destroy();\n\n super.destroy();\n }\n}\n", "import Phaser from \"phaser\";\nimport type { VariantName } from \"./types\";\n\n/** The four screen-edge insets that define a zone, in scene/world pixels. */\nexport interface ZoneMargins {\n marginTop: number;\n marginRight: number;\n marginBottom: number;\n marginLeft: number;\n}\n\n/**\n * Per-variant margin overrides accepted by {@link LayoutZone.setMargins}. Every side of\n * every variant is optional; only the supplied sides are changed.\n */\nexport interface ZoneVariantMargins {\n base?: Partial<ZoneMargins>;\n portrait?: Partial<ZoneMargins>;\n landscape?: Partial<ZoneMargins>;\n}\n\n/** Minimal view of the plugin that supplies the active variant and design size. */\nexport interface VariantProvider {\n readonly variant: VariantName;\n\n /**\n * The design size the zones inset from, or `null` to use the live scene size\n * (`scene.scale.gameSize`). A host (e.g. the editor) can inject a fixed design size\n * to resolve against a target resolution instead of the current canvas size.\n */\n readonly designSize: { width: number; height: number } | null;\n}\n\n/**\n * A screen-relative rectangle defined by an inset (margin) from each screen edge.\n *\n * Margins are split into variants: `base` is the baseline (all four sides), and\n * `portrait` / `landscape` are partial overrides \u2014 any side left unset inherits from\n * `base`. The active variant follows the plugin (see {@link VariantProvider}), so a\n * zone's rect can differ per orientation.\n *\n * The rect is computed **lazily** via {@link LayoutZone.getRect} from the current screen\n * size and the effective margins, so the plugin never has to store or iterate zones.\n *\n * The built-in `safeArea` zone is just a `LayoutZone` whose margins are the\n * device-provided insets (notch / home indicator); `screen` is a `LayoutZone` with all\n * margins at 0.\n */\nexport class LayoutZone {\n\n /** Baseline margins (all four sides). */\n base: ZoneMargins;\n\n /** Margin overrides applied when the active variant is `\"portrait\"`. */\n portrait: Partial<ZoneMargins>;\n\n /** Margin overrides applied when the active variant is `\"landscape\"`. */\n landscape: Partial<ZoneMargins>;\n\n private readonly scene: Phaser.Scene;\n private readonly provider: VariantProvider;\n\n constructor(\n scene: Phaser.Scene,\n provider: VariantProvider,\n marginTop = 0,\n marginRight = 0,\n marginBottom = 0,\n marginLeft = 0\n ) {\n this.scene = scene;\n this.provider = provider;\n this.base = { marginTop, marginRight, marginBottom, marginLeft };\n this.portrait = {};\n this.landscape = {};\n }\n\n /**\n * Sets margins for one or more variants in a single call, merging into whatever is\n * already there (only the supplied sides change). Returns `this` for chaining.\n *\n * Handy for the built-in zones, e.g.\n * `scene.layout.safeArea.setMargins({ base: { marginTop: 40 }, portrait: { marginTop: 80 } })`.\n * Custom zones can pass the same object straight to {@link LayoutPlugin.createZone}.\n *\n * The editor's code generator uses this for zones and the safe area, since (unlike\n * per-object layout data) zone margins have no per-field override semantics.\n */\n setMargins(variants: ZoneVariantMargins): this {\n\n if (variants.base) {\n\n Object.assign(this.base, variants.base);\n }\n\n if (variants.portrait) {\n\n this.portrait = { ...this.portrait, ...variants.portrait };\n }\n\n if (variants.landscape) {\n\n this.landscape = { ...this.landscape, ...variants.landscape };\n }\n\n return this;\n }\n\n /** Effective value of one margin side under the active variant. */\n private _margin(side: keyof ZoneMargins): number {\n\n const variant = this.provider.variant;\n\n if (variant !== \"base\") {\n\n const override = (this[variant] as Partial<ZoneMargins>)[side];\n\n if (override !== undefined) {\n\n return override;\n }\n }\n\n return this.base[side];\n }\n\n /**\n * The effective rectangle at the current screen size and active variant. Pass an\n * `out` rectangle to avoid allocations.\n */\n getRect(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle {\n\n const size = this.provider.designSize ?? this.scene.scale.gameSize;\n\n const x = this._margin(\"marginLeft\");\n const y = this._margin(\"marginTop\");\n const width = size.width - x - this._margin(\"marginRight\");\n const height = size.height - y - this._margin(\"marginBottom\");\n\n if (out) {\n\n out.setTo(x, y, width, height);\n\n return out;\n }\n\n return new Phaser.Geom.Rectangle(x, y, width, height);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,aAAO,UAAU,WAAW;AAAA;AAAA;;;ACA5B;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,MAAAA,iBAAmB;;;ACAnB,sBAAmB;AAgDZ,MAAM,aAAN,MAAiB;AAA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eAAO,GAAG;AAAA,MACd;AAEA,aAAO,OAAO,GAAG,WAAW,WAAW,GAAG,SAAS;AAAA,IACvD;AAAA;AAAA,IAIA,GAAG,OAAwB,IAA8B,SAAqB;AAE1E,WAAK,OAAO,GAAG,OAAO,IAAI,OAAO;AAEjC,aAAO;AAAA,IACX;AAAA,IAEA,KAAK,OAAwB,IAA8B,SAAqB;AAE5E,WAAK,OAAO,KAAK,OAAO,IAAI,OAAO;AAEnC,aAAO;AAAA,IACX;AAAA,IAEA,IAAI,OAAwB,IAA+B,SAAe,MAAsB;AAE5F,WAAK,OAAO,IAAI,OAAO,IAAI,SAAS,IAAI;AAExC,aAAO;AAAA,IACX;AAAA;AAAA,IAIA,WAAiB;AAEb,YAAM,SAAS,KAAK,OAAO,IAAI;AAE/B,aAAO,IAAI,eAAAF,QAAO,OAAO,OAAO,QAAQ,KAAK,SAAS,IAAI;AAC1D,aAAO,IAAI,eAAAA,QAAO,OAAO,OAAO,UAAU,KAAK,UAAU,IAAI;AAE7D,WAAK,OAAO,MAAM,IAAI,eAAAA,QAAO,MAAM,OAAO,QAAQ,KAAK,WAAW,IAAI;AAEtE,WAAK,SAAS,MAAM;AAAA,IACxB;AAAA,IAEA,UAAgB;AAEZ,WAAK,SAAS;AAEd,WAAK,OAAO,QAAQ;AAEpB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;",
|
|
6
6
|
"names": ["import_phaser", "Phaser", "Phaser", "w", "h"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var PhaserEditorLayout=(()=>{var w=Object.create;var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var PhaserEditorLayout=(()=>{var w=Object.create;var f=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var G=(o,s)=>()=>{try{return s||o((s={exports:{}}).exports,s),s.exports}catch(e){throw s=0,e}},V=(o,s)=>{for(var e in s)f(o,e,{get:s[e],enumerable:!0})},z=(o,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of E(s))!j.call(o,r)&&r!==e&&f(o,r,{get:()=>s[r],enumerable:!(t=S(s,r))||t.enumerable});return o};var P=(o,s,e)=>(e=o!=null?w(Z(o)):{},z(s||!o||!o.__esModule?f(e,"default",{value:o,enumerable:!0}):e,o)),M=o=>z(f({},"__esModule",{value:!0}),o);var O=G((L,x)=>{x.exports=globalThis.Phaser});var D={};V(D,{LAYOUT_UPDATE_EVENT:()=>_,LayoutPlugin:()=>g,LayoutZone:()=>p});var h=P(O(),1);var T=P(O(),1),p=class{constructor(s,e,t=0,r=0,a=0,i=0){this.scene=s,this.provider=e,this.base={marginTop:t,marginRight:r,marginBottom:a,marginLeft:i},this.portrait={},this.landscape={}}setMargins(s){return s.base&&Object.assign(this.base,s.base),s.portrait&&(this.portrait={...this.portrait,...s.portrait}),s.landscape&&(this.landscape={...this.landscape,...s.landscape}),this}_margin(s){let e=this.provider.variant;if(e!=="base"){let t=this[e][s];if(t!==void 0)return t}return this.base[s]}getRect(s){var n;let e=(n=this.provider.designSize)!=null?n:this.scene.scale.gameSize,t=this._margin("marginLeft"),r=this._margin("marginTop"),a=e.width-t-this._margin("marginRight"),i=e.height-r-this._margin("marginBottom");return s?(s.setTo(t,r,a,i),s):new T.default.Geom.Rectangle(t,r,a,i)}};var _="layoutupdate",g=class extends h.default.Plugins.ScenePlugin{constructor(e,t,r){super(e,t,r);this.variant="base";this._auto=!1;this._designSize=null;this._scene=e,this._objects=new Set,this.events=new h.default.Events.EventEmitter,this.safeArea=new p(e,this),this.screen=new p(e,this),this._rect=new h.default.Geom.Rectangle,this._mat=new h.default.GameObjects.Components.TransformMatrix,this._p1=new h.default.Math.Vector2,this._p2=new h.default.Math.Vector2}boot(){let e=this._scene.sys.events;e.on(h.default.Scenes.Events.CREATE,this.refresh,this),e.on(h.default.Scenes.Events.SHUTDOWN,this.shutdown,this),e.once(h.default.Scenes.Events.DESTROY,this.destroy,this),this._scene.scale.on(h.default.Scale.Events.RESIZE,this._onResize,this)}get designSize(){return this._designSize}setDesignSize(e,t){this._designSize={width:e,height:t},this.refresh()}clearDesignSize(){this._designSize=null,this.refresh()}_size(){var e;return(e=this._designSize)!=null?e:this._scene.scale.gameSize}get orientation(){let e=this._size();return e.height>e.width?"portrait":"landscape"}setVariant(e){this._auto=!1,this.variant=e,this.refresh()}autoVariant(e=!0){this._auto=e,this.variant=e?this.orientation:"base",this.refresh()}_onResize(){this._auto&&(this.variant=this.orientation),this.refresh()}add(e){let t=e.layoutData;return t||(t={enabled:!0,base:{targetType:"screen",horizontalAnchor:"none",horizontalOffset:0,verticalAnchor:"none",verticalOffset:0},portrait:{},landscape:{}},e.layoutData=t),this._objects.add(e),e.once(h.default.GameObjects.Events.DESTROY,this._onObjectDestroy,this),t}remove(e){this._objects.delete(e),e.off(h.default.GameObjects.Events.DESTROY,this._onObjectDestroy,this),e.layoutData=void 0}_onObjectDestroy(e){this._objects.delete(e)}createZone(e){let t=new p(this._scene,this);return e&&t.setMargins(e),t}refresh(){let e=[];for(let t of this._objects){let r=t.layoutData;r&&r.enabled&&e.push(t)}e.sort((t,r)=>this._depth(t)-this._depth(r));for(let t of e)this._resolve(t);this.events.emit(_)}resolveList(e){let t=e.filter(r=>r.layoutData&&r.layoutData.enabled);t.sort((r,a)=>this._depth(r)-this._depth(a));for(let r of t)this._resolve(r);this.events.emit(_)}_depth(e){let t=0,r=e.parentContainer;for(;r;)t++,r=r.parentContainer;return t}_resolve(e){let t=e,r=e.layoutData,a=typeof t.originX=="number"?t.originX:0,i=typeof t.originY=="number"?t.originY:0,n=this._effective(r);if(n.targetType==="parent"){this._resolveAgainstParent(t,n,a,i);return}this._resolveAgainstZone(t,n,a,i)}_effective(e){var a,i,n,c,m,l,u,d,v,y,b;let t=e.base,r=this.variant==="base"?void 0:e[this.variant];return{targetType:(i=(a=r==null?void 0:r.targetType)!=null?a:t.targetType)!=null?i:"screen",targetZone:(n=r==null?void 0:r.targetZone)!=null?n:t.targetZone,horizontalAnchor:(m=(c=r==null?void 0:r.horizontalAnchor)!=null?c:t.horizontalAnchor)!=null?m:"none",horizontalOffset:(u=(l=r==null?void 0:r.horizontalOffset)!=null?l:t.horizontalOffset)!=null?u:0,verticalAnchor:(v=(d=r==null?void 0:r.verticalAnchor)!=null?d:t.verticalAnchor)!=null?v:"none",verticalOffset:(b=(y=r==null?void 0:r.verticalOffset)!=null?y:t.verticalOffset)!=null?b:0}}_zoneFor(e){var t;switch(e.targetType){case"safeArea":return this.safeArea;case"custom":return(t=e.targetZone)!=null?t:this.screen;default:return this.screen}}_resolveAgainstZone(e,t,r,a){var u;let n=this._zoneFor(t).getRect(this._rect),c=this._sizeX(e),m=this._sizeY(e),l=(u=e.parentContainer)!=null?u:null;if(l){let d=l.getWorldTransformMatrix(this._mat),v=d.transformPoint(e.x,e.y,this._p1),y=this._axis(t.horizontalAnchor,v.x,n.left,n.right,t.horizontalOffset,c,r),b=this._axis(t.verticalAnchor,v.y,n.top,n.bottom,t.verticalOffset,m,a),A=d.applyInverse(y,b,this._p2);e.x=A.x,e.y=A.y;return}e.x=this._axis(t.horizontalAnchor,e.x,n.left,n.right,t.horizontalOffset,c,r),e.y=this._axis(t.verticalAnchor,e.y,n.top,n.bottom,t.verticalOffset,m,a)}_resolveAgainstParent(e,t,r,a){var l;let i=(l=e.parentContainer)!=null?l:null;if(i){let u=i.width||0,d=i.height||0,v=(e.width||0)*(typeof e.scaleX=="number"?e.scaleX:1),y=(e.height||0)*(typeof e.scaleY=="number"?e.scaleY:1);e.x=this._axis(t.horizontalAnchor,e.x,0,u,t.horizontalOffset,v,r),e.y=this._axis(t.verticalAnchor,e.y,0,d,t.verticalOffset,y,a);return}let n=this._size(),c=this._sizeX(e),m=this._sizeY(e);e.x=this._axis(t.horizontalAnchor,e.x,0,n.width,t.horizontalOffset,c,r),e.y=this._axis(t.verticalAnchor,e.y,0,n.height,t.verticalOffset,m,a)}_axis(e,t,r,a,i,n,c){switch(e){case"left":case"top":return r+i+c*n;case"right":case"bottom":return a+i-(1-c)*n;case"center":return(r+a)/2+i+(c-.5)*n;default:return t}}_sizeX(e){return typeof e.displayWidth=="number"?e.displayWidth:typeof e.width=="number"?e.width:0}_sizeY(e){return typeof e.displayHeight=="number"?e.displayHeight:typeof e.height=="number"?e.height:0}on(e,t,r){return this.events.on(e,t,r),this}once(e,t,r){return this.events.once(e,t,r),this}off(e,t,r,a){return this.events.off(e,t,r,a),this}shutdown(){let e=this._scene.sys.events;e.off(h.default.Scenes.Events.CREATE,this.refresh,this),e.off(h.default.Scenes.Events.SHUTDOWN,this.shutdown,this),this._scene.scale.off(h.default.Scale.Events.RESIZE,this._onResize,this),this._objects.clear()}destroy(){this.shutdown(),this.events.destroy(),super.destroy()}};return M(D);})();
|
|
@@ -78,7 +78,7 @@ declare namespace PhaserEditorLayout {
|
|
|
78
78
|
autoVariant(enabled?: boolean): void;
|
|
79
79
|
add<T extends Phaser.GameObjects.GameObject>(obj: T): AnchorLayoutData;
|
|
80
80
|
remove(obj: Phaser.GameObjects.GameObject): void;
|
|
81
|
-
createZone(
|
|
81
|
+
createZone(variants?: ZoneVariantMargins): LayoutZone;
|
|
82
82
|
refresh(): void;
|
|
83
83
|
resolveList(objects: Phaser.GameObjects.GameObject[]): void;
|
|
84
84
|
on(event: string, fn: Function, context?: any): this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phaserjs/phaser-editor-layout",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Responsive layout runtime for Phaser 3 — anchors, zones and safe areas. The runtime counterpart to Phaser Editor's responsive layout system.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|