@phaserjs/phaser-editor-layout 1.0.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/README.md +304 -0
- package/dist/LayoutPlugin.d.ts +147 -0
- package/dist/LayoutPlugin.d.ts.map +1 -0
- package/dist/LayoutPlugin.js +354 -0
- package/dist/LayoutPlugin.js.map +1 -0
- package/dist/LayoutZone.d.ts +56 -0
- package/dist/LayoutZone.d.ts.map +1 -0
- package/dist/LayoutZone.js +54 -0
- package/dist/LayoutZone.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/phaser-editor-layout.js +424 -0
- package/dist/phaser-editor-layout.js.map +7 -0
- package/dist/phaser-editor-layout.min.js +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/global/phaser-editor-layout.global.d.ts +81 -0
- package/package.json +54 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Editor-facing global type declarations for @phaserjs/phaser-editor-layout.
|
|
2
|
+
//
|
|
3
|
+
// The library ships as a browser global (the IIFE build, dist/phaser-editor-layout.js)
|
|
4
|
+
// exposing `PhaserEditorLayout`, exactly like Phaser ships as the `Phaser` global. This
|
|
5
|
+
// file types that global for hosts that consume the lib as a plain <script> instead of
|
|
6
|
+
// an ESM import (the Phaser Editor workbench).
|
|
7
|
+
//
|
|
8
|
+
// It is the hand-authored counterpart of the lib's generated ESM `.d.ts`; keep it in
|
|
9
|
+
// sync with the public API in ../src. The workbench copies this file into the scene
|
|
10
|
+
// plugin as a `.ts` (see workbench/scripts/get-latest-layout.sh) so that, under the
|
|
11
|
+
// plugin's `outFile` build, the namespace is re-emitted and visible to other plugins.
|
|
12
|
+
|
|
13
|
+
declare namespace PhaserEditorLayout {
|
|
14
|
+
|
|
15
|
+
type HAnchor = "left" | "center" | "right" | "none";
|
|
16
|
+
|
|
17
|
+
type VAnchor = "top" | "center" | "bottom" | "none";
|
|
18
|
+
|
|
19
|
+
type TargetType = "screen" | "safeArea" | "parent" | "custom";
|
|
20
|
+
|
|
21
|
+
type VariantName = "base" | "portrait" | "landscape";
|
|
22
|
+
|
|
23
|
+
interface AnchorProps {
|
|
24
|
+
targetType?: TargetType;
|
|
25
|
+
targetZone?: LayoutZone;
|
|
26
|
+
horizontalAnchor?: HAnchor;
|
|
27
|
+
horizontalOffset?: number;
|
|
28
|
+
verticalAnchor?: VAnchor;
|
|
29
|
+
verticalOffset?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface AnchorLayoutData {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
base: AnchorProps;
|
|
35
|
+
portrait: AnchorProps;
|
|
36
|
+
landscape: AnchorProps;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ZoneMargins {
|
|
40
|
+
marginTop: number;
|
|
41
|
+
marginRight: number;
|
|
42
|
+
marginBottom: number;
|
|
43
|
+
marginLeft: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface VariantProvider {
|
|
47
|
+
readonly variant: VariantName;
|
|
48
|
+
readonly designSize: { width: number; height: number } | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class LayoutZone {
|
|
52
|
+
base: ZoneMargins;
|
|
53
|
+
portrait: Partial<ZoneMargins>;
|
|
54
|
+
landscape: Partial<ZoneMargins>;
|
|
55
|
+
constructor(scene: Phaser.Scene, provider: VariantProvider, marginTop?: number, marginRight?: number, marginBottom?: number, marginLeft?: number);
|
|
56
|
+
getRect(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const LAYOUT_UPDATE_EVENT: string;
|
|
60
|
+
|
|
61
|
+
class LayoutPlugin extends Phaser.Plugins.ScenePlugin {
|
|
62
|
+
readonly safeArea: LayoutZone;
|
|
63
|
+
readonly screen: LayoutZone;
|
|
64
|
+
readonly events: Phaser.Events.EventEmitter;
|
|
65
|
+
variant: VariantName;
|
|
66
|
+
get designSize(): { width: number; height: number } | null;
|
|
67
|
+
setDesignSize(width: number, height: number): void;
|
|
68
|
+
clearDesignSize(): void;
|
|
69
|
+
get orientation(): "portrait" | "landscape";
|
|
70
|
+
setVariant(variant: VariantName): void;
|
|
71
|
+
autoVariant(enabled?: boolean): void;
|
|
72
|
+
add<T extends Phaser.GameObjects.GameObject>(obj: T): AnchorLayoutData;
|
|
73
|
+
remove(obj: Phaser.GameObjects.GameObject): void;
|
|
74
|
+
createZone(marginTop?: number, marginRight?: number, marginBottom?: number, marginLeft?: number): LayoutZone;
|
|
75
|
+
refresh(): void;
|
|
76
|
+
resolveList(objects: Phaser.GameObjects.GameObject[]): void;
|
|
77
|
+
on(event: string, fn: Function, context?: any): this;
|
|
78
|
+
once(event: string, fn: Function, context?: any): this;
|
|
79
|
+
off(event: string, fn?: Function, context?: any): this;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@phaserjs/phaser-editor-layout",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Responsive layout runtime for Phaser 3 — anchors, zones and safe areas. The runtime counterpart to Phaser Editor's responsive layout system.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./global": "./dist/phaser-editor-layout.js"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"global",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "npm run clean && npm run build:types && npm run build:global",
|
|
26
|
+
"build:types": "tsc -p tsconfig.json",
|
|
27
|
+
"build:global": "node scripts/build-global.mjs",
|
|
28
|
+
"watch": "tsc -p tsconfig.json -w",
|
|
29
|
+
"clean": "rimraf dist",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"phaser",
|
|
34
|
+
"phaser3",
|
|
35
|
+
"layout",
|
|
36
|
+
"responsive",
|
|
37
|
+
"anchor",
|
|
38
|
+
"constraint",
|
|
39
|
+
"safe-area",
|
|
40
|
+
"scale",
|
|
41
|
+
"ui"
|
|
42
|
+
],
|
|
43
|
+
"author": "Phaser Studio (https://phaser.io/)",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"phaser": "^3.60.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"esbuild": "^0.28.1",
|
|
50
|
+
"phaser": "^3.90.0",
|
|
51
|
+
"rimraf": "^5.0.5",
|
|
52
|
+
"typescript": "^5.4.5"
|
|
53
|
+
}
|
|
54
|
+
}
|