@caperjs/core 0.3.0 → 0.4.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/build/assetpack.mjs +90 -0
- package/build/index.d.mts +29 -0
- package/build/plugins/pruneFallbacks.mjs +25 -2
- package/lib/{CaptionsPlugin-BLbLl3WB.js → CaptionsPlugin-cSJj-R9M.js} +4 -4
- package/lib/{CaptionsPlugin-BLbLl3WB.js.map → CaptionsPlugin-cSJj-R9M.js.map} +1 -1
- package/lib/{DataAdapter-aHSNM_26.js → DataAdapter-D2tc6hx9.js} +5 -5
- package/lib/{DataAdapter-aHSNM_26.js.map → DataAdapter-D2tc6hx9.js.map} +1 -1
- package/lib/{DebugRenderer-8LjHtBzA.js → DebugRenderer-CGUKy6Fy.js} +2 -2
- package/lib/{DebugRenderer-8LjHtBzA.js.map → DebugRenderer-CGUKy6Fy.js.map} +1 -1
- package/lib/{DevToolsPlugin-Vrk6aOtS.js → DevToolsPlugin-B8GX3H9b.js} +2 -2
- package/lib/{DevToolsPlugin-Vrk6aOtS.js.map → DevToolsPlugin-B8GX3H9b.js.map} +1 -1
- package/lib/{GSAPPlugin-Hm3F4zdg.js → GSAPPlugin-Br9AjuTD.js} +5 -5
- package/lib/{GSAPPlugin-Hm3F4zdg.js.map → GSAPPlugin-Br9AjuTD.js.map} +1 -1
- package/lib/{LayoutPlugin-Dpgeawfw.js → LayoutPlugin-BX3OP7pw.js} +4 -4
- package/lib/{LayoutPlugin-Dpgeawfw.js.map → LayoutPlugin-BX3OP7pw.js.map} +1 -1
- package/lib/{SpinePlugin-B08yAw1S.js → SpinePlugin-C-JDdXpf.js} +2 -2
- package/lib/{SpinePlugin-B08yAw1S.js.map → SpinePlugin-C-JDdXpf.js.map} +1 -1
- package/lib/{StatsPlugin-D2Xa5j97.js → StatsPlugin-yJlJtoQ2.js} +7 -10
- package/lib/{StatsPlugin-D2Xa5j97.js.map → StatsPlugin-yJlJtoQ2.js.map} +1 -1
- package/lib/{VoiceOverPlugin-qtFlqpRn.js → VoiceOverPlugin-DjSZp4Ko.js} +4 -4
- package/lib/{VoiceOverPlugin-qtFlqpRn.js.map → VoiceOverPlugin-DjSZp4Ko.js.map} +1 -1
- package/lib/caper.mjs +156 -1927
- package/lib/caper.mjs.map +1 -1
- package/lib/const-C3sxeYhl.js +1746 -0
- package/lib/const-C3sxeYhl.js.map +1 -0
- package/lib/core/create.d.ts.map +1 -1
- package/lib/padding-1kHDpGlQ.js +41 -0
- package/lib/padding-1kHDpGlQ.js.map +1 -0
- package/lib/plugins/FullScreenPlugin.d.ts +0 -5
- package/lib/plugins/FullScreenPlugin.d.ts.map +1 -1
- package/lib/plugins/KeyboardPlugin.d.ts +0 -1
- package/lib/plugins/KeyboardPlugin.d.ts.map +1 -1
- package/lib/plugins/Plugin.d.ts +101 -2
- package/lib/plugins/Plugin.d.ts.map +1 -1
- package/lib/plugins/SceneManagerPlugin.d.ts +0 -1
- package/lib/plugins/SceneManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/StatsPlugin.d.ts +0 -1
- package/lib/plugins/StatsPlugin.d.ts.map +1 -1
- package/lib/plugins/TimerPlugin.d.ts.map +1 -1
- package/lib/plugins/WebEventsPlugin.d.ts +0 -1
- package/lib/plugins/WebEventsPlugin.d.ts.map +1 -1
- package/lib/plugins/breakpoints/BreakpointPlugin.d.ts.map +1 -1
- package/lib/plugins/gesture/GesturePlugin.d.ts.map +1 -1
- package/lib/plugins/input/AbstractControls.d.ts +46 -7
- package/lib/plugins/input/AbstractControls.d.ts.map +1 -1
- package/lib/plugins/input/InputPlugin.d.ts.map +1 -1
- package/lib/plugins/input/controlsCore.d.ts +58 -0
- package/lib/plugins/input/controlsCore.d.ts.map +1 -0
- package/lib/plugins/input/controlsCore.test.d.ts +2 -0
- package/lib/plugins/input/controlsCore.test.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/KeyboardControls.d.ts +15 -0
- package/lib/plugins/input/keyboard/KeyboardControls.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/index.d.ts +1 -1
- package/lib/plugins/input/keyboard/index.d.ts.map +1 -1
- package/lib/plugins/input/touch/VirtualControls.d.ts +7 -19
- package/lib/plugins/input/touch/VirtualControls.d.ts.map +1 -1
- package/lib/{registries-m2vKTIih.js → registries-BfV-VF7a.js} +565 -552
- package/lib/registries-BfV-VF7a.js.map +1 -0
- package/package.json +2 -1
- package/src/core/create.ts +11 -0
- package/src/plugins/FullScreenPlugin.ts +5 -18
- package/src/plugins/KeyboardPlugin.ts +3 -10
- package/src/plugins/Plugin.test.ts +130 -2
- package/src/plugins/Plugin.ts +159 -3
- package/src/plugins/SceneManagerPlugin.ts +3 -8
- package/src/plugins/StatsPlugin.ts +3 -10
- package/src/plugins/TimerPlugin.ts +1 -2
- package/src/plugins/WebEventsPlugin.ts +9 -18
- package/src/plugins/breakpoints/BreakpointPlugin.ts +1 -2
- package/src/plugins/captions/CaptionsPlugin.ts +1 -1
- package/src/plugins/gesture/GesturePlugin.ts +4 -8
- package/src/plugins/input/AbstractControls.ts +103 -8
- package/src/plugins/input/Controls.test.ts +56 -0
- package/src/plugins/input/InputPlugin.ts +6 -14
- package/src/plugins/input/controlsCore.test.ts +151 -0
- package/src/plugins/input/controlsCore.ts +162 -0
- package/src/plugins/input/keyboard/KeyboardControls.ts +84 -0
- package/src/plugins/input/keyboard/index.ts +1 -1
- package/src/plugins/input/touch/VirtualControls.ts +41 -142
- package/src/version.ts +1 -1
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts +0 -33
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts.map +0 -1
- package/lib/registries-m2vKTIih.js.map +0 -1
- package/src/plugins/input/keyboard/KeyboardContols.ts +0 -206
|
@@ -0,0 +1,1746 @@
|
|
|
1
|
+
import { Dt as e, G as t, J as n, Nt as r, Ut as i, _t as a, b as o, dt as s, f as c, gt as l, m as u, ot as d, p as f, pt as p, r as m, ut as ee, vt as te, yt as ne } from "./registries-BfV-VF7a.js";
|
|
2
|
+
import { t as h } from "./padding-1kHDpGlQ.js";
|
|
3
|
+
import { AnimatedSprite as re, Assets as g, BitmapText as _, Graphics as v, HTMLText as y, ParticleContainer as ie, Sprite as b, Text as x, Texture as ae, TilingSprite as oe } from "pixi.js";
|
|
4
|
+
import { gsap as S } from "gsap";
|
|
5
|
+
//#region src/utils/debug.ts
|
|
6
|
+
var C = {
|
|
7
|
+
bounds: 65535,
|
|
8
|
+
innerBounds: 65280,
|
|
9
|
+
outerBounds: 16711680,
|
|
10
|
+
direction: 16776960,
|
|
11
|
+
gap: 16711935,
|
|
12
|
+
region: 30975
|
|
13
|
+
}, w = {
|
|
14
|
+
stroke: .6,
|
|
15
|
+
fill: .1,
|
|
16
|
+
fillActive: .2,
|
|
17
|
+
crosshair: .5
|
|
18
|
+
};
|
|
19
|
+
function T(e) {
|
|
20
|
+
let t = new v();
|
|
21
|
+
return t.eventMode = "none", t.interactiveChildren = !1, t.layout = !1, t.label = e ?? "DebugGraphics", t;
|
|
22
|
+
}
|
|
23
|
+
function E(e, t = C.bounds) {
|
|
24
|
+
let n = new x({
|
|
25
|
+
text: e,
|
|
26
|
+
style: {
|
|
27
|
+
fontFamily: "monospace",
|
|
28
|
+
fontSize: 10,
|
|
29
|
+
fill: t,
|
|
30
|
+
stroke: {
|
|
31
|
+
color: 0,
|
|
32
|
+
width: 2
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return n.eventMode = "none", n.layout = !1, n.label = "DebugLabel", n;
|
|
37
|
+
}
|
|
38
|
+
var D = /* @__PURE__ */ new Map();
|
|
39
|
+
function O(e, t, n) {
|
|
40
|
+
D.set(e, {
|
|
41
|
+
label: t,
|
|
42
|
+
color: n
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function k(e) {
|
|
46
|
+
D.delete(e);
|
|
47
|
+
}
|
|
48
|
+
function se() {
|
|
49
|
+
return D;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/utils/number.ts
|
|
53
|
+
function A(e, t = 0) {
|
|
54
|
+
return e.toString().padStart(t, "0");
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/display/ParticleContainer.ts
|
|
58
|
+
var j = ["autoUpdate", "priority"], ce = {
|
|
59
|
+
autoUpdate: !0,
|
|
60
|
+
priority: 0
|
|
61
|
+
}, le = class extends ie {
|
|
62
|
+
static {
|
|
63
|
+
this.__caper_method_binding_root = !0;
|
|
64
|
+
}
|
|
65
|
+
constructor(e = {}) {
|
|
66
|
+
super(e), this.onDestroy = new t(), this.__config = {
|
|
67
|
+
...ce,
|
|
68
|
+
...e
|
|
69
|
+
}, r(this), this.on("added", this._added), this.on("removed", this._removed);
|
|
70
|
+
}
|
|
71
|
+
get app() {
|
|
72
|
+
return m.getInstance();
|
|
73
|
+
}
|
|
74
|
+
update(e) {}
|
|
75
|
+
resize(e) {}
|
|
76
|
+
added() {}
|
|
77
|
+
destroy(e) {
|
|
78
|
+
this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.onDestroy.emit(), super.destroy(e);
|
|
79
|
+
}
|
|
80
|
+
removed() {}
|
|
81
|
+
_added() {
|
|
82
|
+
this.__config.autoUpdate && this.app.ticker.add(this.update, this, this.__config.priority), this.added();
|
|
83
|
+
}
|
|
84
|
+
_removed() {
|
|
85
|
+
this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.removed();
|
|
86
|
+
}
|
|
87
|
+
}, ue = class extends v {
|
|
88
|
+
constructor(e) {
|
|
89
|
+
super(typeof e == "string" ? g.get(e) : e);
|
|
90
|
+
let t = this.getLocalBounds();
|
|
91
|
+
this.pivot.set((t.x + t.width) / 2, (t.y + t.height) / 2);
|
|
92
|
+
}
|
|
93
|
+
}, M;
|
|
94
|
+
function N(t, n) {
|
|
95
|
+
for (let r in t) try {
|
|
96
|
+
n[r] = t[r];
|
|
97
|
+
} catch (t) {
|
|
98
|
+
e.warn(`Error setting property ${r}`, t);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function P() {
|
|
102
|
+
if (!M) {
|
|
103
|
+
let e = new v();
|
|
104
|
+
e.rect(0, 0, 100, 100), e.fill({ color: 16711680 }), e.stroke({
|
|
105
|
+
color: 16777215,
|
|
106
|
+
width: 1,
|
|
107
|
+
alignment: 0
|
|
108
|
+
}), e.moveTo(0, 0), e.lineTo(100, 100), e.moveTo(100, 0), e.lineTo(0, 100), e.stroke({
|
|
109
|
+
color: 16777215,
|
|
110
|
+
width: 2,
|
|
111
|
+
alignment: .5
|
|
112
|
+
}), M = m.getInstance().renderer.generateTexture(e), e.destroy();
|
|
113
|
+
}
|
|
114
|
+
return M;
|
|
115
|
+
}
|
|
116
|
+
function F(t) {
|
|
117
|
+
let n, r = t?.asset, i = r, a = t?.sheet;
|
|
118
|
+
if (r instanceof ae) n = r;
|
|
119
|
+
else if (!a || a?.length === 0) g.cache.has(i) ? n = g.get(i) : g.get(i) ? n = g.get(i).texture : (e.error("Asset \"" + r + "\" not loaded into Pixi cache"), n = P());
|
|
120
|
+
else if (g.get(a)) {
|
|
121
|
+
let t = g.get(a), o = t.textures;
|
|
122
|
+
if (o !== void 0) if (o.hasOwnProperty(i)) n = o[i];
|
|
123
|
+
else if (t.linkedSheets !== void 0 && t.linkedSheets.length > 0) {
|
|
124
|
+
for (let e of t.linkedSheets) if (e.textures !== void 0 && e.textures.hasOwnProperty(i)) {
|
|
125
|
+
n = e.textures[i];
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
n === void 0 && (e.error("Asset \"" + r + "\" not found inside spritesheet \"" + r + "' or any of its linked sheets"), n = P());
|
|
129
|
+
} else e.error("Asset \"" + r + "\" not found inside spritesheet \"" + a + "'"), n = P();
|
|
130
|
+
else e.error("Spritesheet \"" + a + "\" loaded but textures arent?!"), n = P();
|
|
131
|
+
} else return e.error("Spritesheet \"" + a + "\" not loaded into Pixi cache"), P();
|
|
132
|
+
return n || new b().texture;
|
|
133
|
+
}
|
|
134
|
+
function I(e, t) {
|
|
135
|
+
let n = d(e.position, !1, e.x, e.y);
|
|
136
|
+
t.x = n.x, t.y = n.y;
|
|
137
|
+
}
|
|
138
|
+
function L(e, t) {
|
|
139
|
+
if (!e) return;
|
|
140
|
+
if (e.scale === void 0) {
|
|
141
|
+
if (e.scaleX === void 0 && e.scaleY === void 0) return;
|
|
142
|
+
e.scaleX === void 0 && (e.scaleX = 1), e.scaleY === void 0 && (e.scaleY = 1);
|
|
143
|
+
}
|
|
144
|
+
let n = d(e.scale, !1, e.scaleX, e.scaleY);
|
|
145
|
+
t.scale.set(n.x, n.y);
|
|
146
|
+
}
|
|
147
|
+
function R(e, t) {
|
|
148
|
+
if (e !== void 0) {
|
|
149
|
+
let n = d(e);
|
|
150
|
+
t.anchor.set(n.x, n.y);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function z(e, t) {
|
|
154
|
+
if (e !== void 0) {
|
|
155
|
+
let n = d(e);
|
|
156
|
+
t.pivot.set(n.x, n.y);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/display/AnimatedSprite.ts
|
|
161
|
+
var B = class e extends re {
|
|
162
|
+
constructor(n) {
|
|
163
|
+
let i = n?.animations ?? {}, a = n?.animation ?? Object.keys(i)[0], o = i[a], s = n?.sheet, c = n?.texturePrefix || "", l = n?.zeroPad, u = n?.startIndex ?? 0;
|
|
164
|
+
super(e.generateTexturesFromProps(a, o, c, s, l, u), n?.autoUpdate !== !1), this.config = n, this.onAnimationChange = new t(), this.onAnimationStart = new t(), this.onAnimationStop = new t(), this.onAnimationLoop = new t(), this.onAnimationComplete = new t(), this.onAnimationFrameChange = new t(), this.defaultTexturePrefix = "", this._paused = !1, this._isReversed = !1, r(this), this.defaultSheet = s, this.defaultTexturePrefix = c, this.defaultZeroPad = l, this._generateAnimations(), this.currentAnimation = this.defaultAnimation = a, this.autoPlay = n?.autoPlay ?? !0, this.loop = n?.loop ?? !0, this.updateAnchor = n?.updateAnchor ?? !1, this.animationSpeed = this.defaultAnimationSpeed = n?.animationSpeed ?? 1, this.on("added", this._added);
|
|
165
|
+
}
|
|
166
|
+
get paused() {
|
|
167
|
+
return this._paused;
|
|
168
|
+
}
|
|
169
|
+
set paused(e) {
|
|
170
|
+
this._paused = e;
|
|
171
|
+
}
|
|
172
|
+
get speed() {
|
|
173
|
+
return this.animationSpeed;
|
|
174
|
+
}
|
|
175
|
+
set speed(e) {
|
|
176
|
+
this.animationSpeed = this.defaultAnimationSpeed = e;
|
|
177
|
+
}
|
|
178
|
+
get isReversed() {
|
|
179
|
+
return this._isReversed;
|
|
180
|
+
}
|
|
181
|
+
static generateTexturesFromProps(e, t, n = "", r = void 0, i, a) {
|
|
182
|
+
let o = [], s = "", c = t?.sheet ?? r;
|
|
183
|
+
if (t?.numFrames > 1) {
|
|
184
|
+
let r = t?.startIndex ?? a ?? 0;
|
|
185
|
+
for (let a = r; a < r + t?.numFrames; a++) s = `${n}${t?.texturePrefix ?? e}${A(a, t?.zeroPad ?? i)}`, o.push(F({
|
|
186
|
+
asset: s,
|
|
187
|
+
sheet: c
|
|
188
|
+
}));
|
|
189
|
+
} else s = `${n}${t?.texturePrefix ?? e}`, o.push(F({
|
|
190
|
+
asset: s,
|
|
191
|
+
sheet: c
|
|
192
|
+
}));
|
|
193
|
+
return o;
|
|
194
|
+
}
|
|
195
|
+
reverse() {
|
|
196
|
+
this._isReversed = !this._isReversed, this._isReversed ? this.setAnimation(`${this.currentAnimation}_reverse`) : this.setAnimation(this.currentAnimation.split("_reverse")[0]);
|
|
197
|
+
}
|
|
198
|
+
setAnimation(e, t = !0) {
|
|
199
|
+
if (!this._animations.has(e)) throw Error(`Animation ${e} does not exist`);
|
|
200
|
+
this.textures = this._animations.get(e), this.currentAnimation = e;
|
|
201
|
+
let n = this.config?.animations?.[e.split("_reverse")[0]]?.animationSpeed;
|
|
202
|
+
n ? this.animationSpeed = n : this.animationSpeed = this.defaultAnimationSpeed, this.onAnimationChange.emit(e), t && this.play();
|
|
203
|
+
}
|
|
204
|
+
play() {
|
|
205
|
+
super.play(), this.onAnimationStart?.emit();
|
|
206
|
+
}
|
|
207
|
+
stop() {
|
|
208
|
+
super.stop(), this.onAnimationStop?.emit();
|
|
209
|
+
}
|
|
210
|
+
nextAnimation() {
|
|
211
|
+
let e = te(this._animations, this.currentAnimation) ?? l(this._animations);
|
|
212
|
+
e && this.setAnimation(e[0]);
|
|
213
|
+
}
|
|
214
|
+
previousAnimation() {
|
|
215
|
+
let e = ne(this._animations, this.currentAnimation) ?? a(this._animations);
|
|
216
|
+
e && this.setAnimation(e[0]);
|
|
217
|
+
}
|
|
218
|
+
update(e) {
|
|
219
|
+
this._paused || super.update(e);
|
|
220
|
+
}
|
|
221
|
+
_generateAnimations() {
|
|
222
|
+
this._animations = /* @__PURE__ */ new Map();
|
|
223
|
+
let t = this.config?.animations ?? {};
|
|
224
|
+
if (t) {
|
|
225
|
+
for (let [n, r] of Object.entries(t)) this._animations.set(n, e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad));
|
|
226
|
+
if (this.config?.reversible) for (let [n, r] of Object.entries(t)) {
|
|
227
|
+
let t = e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad);
|
|
228
|
+
t.reverse(), this._animations.set(`${n}_reverse`, t);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
_added() {
|
|
233
|
+
this.onLoop = () => {
|
|
234
|
+
this.onAnimationLoop.emit();
|
|
235
|
+
}, this.onComplete = () => {
|
|
236
|
+
this.onAnimationComplete.emit();
|
|
237
|
+
}, this.onFrameChange = () => {
|
|
238
|
+
this.onAnimationFrameChange.emit();
|
|
239
|
+
}, this.autoPlay && this.play();
|
|
240
|
+
}
|
|
241
|
+
}, de = o(u()), V = class extends de {
|
|
242
|
+
get app() {
|
|
243
|
+
return m.getInstance();
|
|
244
|
+
}
|
|
245
|
+
get animationNames() {
|
|
246
|
+
return this.spine.state.data.skeletonData.animations.map((e) => e.name);
|
|
247
|
+
}
|
|
248
|
+
get currentEntry() {
|
|
249
|
+
return this.spine.state.getCurrent(0);
|
|
250
|
+
}
|
|
251
|
+
get elapsedAnimationTime() {
|
|
252
|
+
return this.currentEntry ? this.currentEntry.trackTime : -1;
|
|
253
|
+
}
|
|
254
|
+
constructor(e) {
|
|
255
|
+
super(), this.onAnimationComplete = new t(), this.onAnimationStart = new t(), this.onAnimationInterrupt = new t(), this.onAnimationDispose = new t(), this.onAnimationEnd = new t(), this.onAnimationEvent = new t(), this.onPaused = new t(), this.onResumed = new t(), r(this);
|
|
256
|
+
let n = e?.data, i = "";
|
|
257
|
+
if (typeof n == "string") {
|
|
258
|
+
let e = n.slice(-5);
|
|
259
|
+
e !== ".json" && e !== ".skel" ? e = ".json" : n = n.substring(0, n.length - 5), i = {
|
|
260
|
+
skeleton: n + e,
|
|
261
|
+
atlas: n + ".atlas"
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
this.spine = window.Spine.from(i), this.add.existing(this.spine), e && (e.autoUpdate !== void 0 && (this.spine.autoUpdate = e.autoUpdate), e.animationName && this.setAnimation(e.animationName, e.loop, e.trackIndex ?? 0)), this.addSignalConnection(this.app.actions("toggle_pause").connect(this.togglePause)), e?.paused && this.pause(), this._stateListener = {
|
|
265
|
+
start: this._handleAnimationStart,
|
|
266
|
+
interrupt: this._handleAnimationInterrupt,
|
|
267
|
+
dispose: this._handleAnimationDispose,
|
|
268
|
+
end: this._handleAnimationEnd,
|
|
269
|
+
event: this._handleAnimationEvent,
|
|
270
|
+
complete: this._handleAnimationComplete
|
|
271
|
+
}, this.spine.state.addListener(this._stateListener);
|
|
272
|
+
}
|
|
273
|
+
destroy() {
|
|
274
|
+
this.spine.state.removeListener(this._stateListener), super.destroy();
|
|
275
|
+
}
|
|
276
|
+
getCurrentAnimation(e = 0) {
|
|
277
|
+
return this.spine.state.getCurrent(e)?.animation?.name || "";
|
|
278
|
+
}
|
|
279
|
+
setAnimation(e, t = !1, n = 0) {
|
|
280
|
+
this.spine.state.setAnimation(n, e, t);
|
|
281
|
+
}
|
|
282
|
+
pause() {
|
|
283
|
+
this.paused = !0, this.spine.autoUpdate = !1, this.currentEntry && (this.currentEntry.timeScale = 0), this.onPaused.emit(this.currentEntry);
|
|
284
|
+
}
|
|
285
|
+
resume() {
|
|
286
|
+
this.paused = !1, this.spine.autoUpdate = !0, this.currentEntry && (this.currentEntry.timeScale = 1), this.onResumed.emit(this.currentEntry);
|
|
287
|
+
}
|
|
288
|
+
togglePause() {
|
|
289
|
+
this.paused ? this.resume() : this.pause();
|
|
290
|
+
}
|
|
291
|
+
_handleAnimationComplete(e) {
|
|
292
|
+
this.onAnimationComplete.emit(e);
|
|
293
|
+
}
|
|
294
|
+
_handleAnimationStart(e) {
|
|
295
|
+
this.onAnimationStart.emit(e);
|
|
296
|
+
}
|
|
297
|
+
_handleAnimationInterrupt(e) {
|
|
298
|
+
this.onAnimationInterrupt.emit(e);
|
|
299
|
+
}
|
|
300
|
+
_handleAnimationDispose(e) {
|
|
301
|
+
this.onAnimationDispose.emit(e);
|
|
302
|
+
}
|
|
303
|
+
_handleAnimationEnd(e) {
|
|
304
|
+
this.onAnimationEnd.emit(e);
|
|
305
|
+
}
|
|
306
|
+
_handleAnimationEvent(e, t) {
|
|
307
|
+
this.onAnimationEvent.emit(e, t);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/mixins/focus.ts
|
|
312
|
+
function H(e) {
|
|
313
|
+
return class extends e {
|
|
314
|
+
constructor(...e) {
|
|
315
|
+
super(...e), this.isFocused = !1, this.isKeyDown = !1, this.focusEnabled = !0, this.tabIndex = 0, this.accessible = !1, this.accessibleType = "button", this.accessibleTitle = "Focusable", this.accessibleHint = "Press enter to focus", this.accessiblePointerEvents = "auto", this.accessibleChildren = !0, this.onFocus = new t(), this.onFocusIn = new t(), this.onFocusOut = new t(), this.onBlur = new t(), this._eventsDisabled = !1, this.eventMode = "static", this.on("mouseover", this._onMouseOver), this.on("mousedown", this._onMouseDown), this.on("click", this._handleClick), this.on("tap", this._handleClick);
|
|
316
|
+
}
|
|
317
|
+
get app() {
|
|
318
|
+
return m.getInstance();
|
|
319
|
+
}
|
|
320
|
+
destroy(e) {
|
|
321
|
+
this.off("mouseover", this._onMouseOver), this.off("mousedown", this._onMouseDown), this.off("click", this._handleClick), this.off("tap", this._handleClick), super.destroy(e);
|
|
322
|
+
}
|
|
323
|
+
focusIn() {
|
|
324
|
+
this.app.focus.active && this.emit("pointerover", { type: "pointerover" });
|
|
325
|
+
}
|
|
326
|
+
blur() {
|
|
327
|
+
this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this));
|
|
328
|
+
}
|
|
329
|
+
focusOut() {
|
|
330
|
+
this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this)), this.app.focus.active && this.emit("pointerout", { type: "pointerout" });
|
|
331
|
+
}
|
|
332
|
+
click() {}
|
|
333
|
+
getFocusPosition() {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
getFocusArea() {
|
|
337
|
+
return this.getBounds();
|
|
338
|
+
}
|
|
339
|
+
getFocusSize() {
|
|
340
|
+
return [this.getFocusArea().width, this.getFocusArea().height];
|
|
341
|
+
}
|
|
342
|
+
_onMouseOver(e) {
|
|
343
|
+
this.app.focus.setFocus(this);
|
|
344
|
+
}
|
|
345
|
+
_onMouseDown(e) {
|
|
346
|
+
this._maybeEmit("pointerdown", e);
|
|
347
|
+
}
|
|
348
|
+
_handleClick(e) {
|
|
349
|
+
this._maybeEmit("click", e), this.click();
|
|
350
|
+
}
|
|
351
|
+
_handleKeyUp(e) {}
|
|
352
|
+
_maybeEmit(e, t) {
|
|
353
|
+
this._eventsDisabled || t.type || (this._eventsDisabled = !0, this.emit(e, { type: e }), this._eventsDisabled = !1);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
H.INITTED = !1;
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/mixins/interaction.ts
|
|
360
|
+
function U(e) {
|
|
361
|
+
return class extends e {
|
|
362
|
+
constructor(...e) {
|
|
363
|
+
super(...e), this._signals = /* @__PURE__ */ new Map(), this._emitSignal = this._emitSignal.bind(this), this.eventMode = "static";
|
|
364
|
+
}
|
|
365
|
+
onInteraction(e) {
|
|
366
|
+
if (!this._signals.has(e)) {
|
|
367
|
+
let n = new t();
|
|
368
|
+
this._signals.set(e, n), this.on(e, this._emitSignal);
|
|
369
|
+
}
|
|
370
|
+
return this._signals.get(e);
|
|
371
|
+
}
|
|
372
|
+
destroy(e) {
|
|
373
|
+
for (let e of this._signals.keys()) this.off(e, this._emitSignal);
|
|
374
|
+
this._signals.clear(), super.destroy(e);
|
|
375
|
+
}
|
|
376
|
+
_emitSignal(e) {
|
|
377
|
+
let t = e.type, n = this._signals.get(t);
|
|
378
|
+
n && n.emit(e);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/ui/Button.ts
|
|
384
|
+
var W = [
|
|
385
|
+
"textures",
|
|
386
|
+
"sounds",
|
|
387
|
+
"actions",
|
|
388
|
+
"cursor",
|
|
389
|
+
"disabledCursor",
|
|
390
|
+
"sheet",
|
|
391
|
+
"enabled",
|
|
392
|
+
"layout",
|
|
393
|
+
"textLabel"
|
|
394
|
+
], fe = H(U(o(u()))), G = class extends fe {
|
|
395
|
+
get textLabel() {
|
|
396
|
+
return this._textLabel;
|
|
397
|
+
}
|
|
398
|
+
constructor(e) {
|
|
399
|
+
super(), this.onDown = new t(), this.onUp = new t(), this.onUpOutside = new t(), this.onOut = new t(), this.onOver = new t(), this.onClick = new t(), this.onEnabled = new t(), this.onDisabled = new t(), this.onKeyboardEvent = new t(), this.onDestroy = new t(), this._isDownCallbacks = /* @__PURE__ */ new Map(), this._isDownListenerAdded = !1, r(this), this.config = Object.assign({
|
|
400
|
+
id: "button",
|
|
401
|
+
textures: { default: "" },
|
|
402
|
+
sheet: void 0,
|
|
403
|
+
enabled: !0,
|
|
404
|
+
cursor: "default",
|
|
405
|
+
disabledCursor: "not-allowed"
|
|
406
|
+
}, e), this.id = this.config.id, e.layout === void 0 ? this.layout = !1 : this.layout = e.layout, this.view = this.add.sprite({
|
|
407
|
+
asset: this.config.textures.default,
|
|
408
|
+
sheet: this.config.sheet ?? void 0
|
|
409
|
+
}), this.cursor = this.config.cursor, this.enabled = e.enabled !== !1, this.layout?.style.transformOrigin !== "top left" && (this.layout = { transformOrigin: "top left" }, this.app.renderer.layout && this.app.renderer.layout.update(this)), this.config.textLabel && this.addLabel(this.config.textLabel), this.addSignalConnection(this.onInteraction("pointerover").connect(this.handlePointerOver, -1), this.onInteraction("pointerout").connect(this.handlePointerOut, -1), this.onInteraction("pointerup").connect(this.handlePointerUp, -1), this.onInteraction("click").connect(this.handleClick, -1), this.onInteraction("tap").connect(this.handleClick, -1), this.onInteraction("pointerdown").connect(this.handlePointerDown, -1)), this.on("removed", this._resetPressState);
|
|
410
|
+
}
|
|
411
|
+
set enabled(e) {
|
|
412
|
+
this._enabled !== e && (this._enabled = e, this.cursor = this._enabled ? this.config.cursor : this.config.disabledCursor, this.focusEnabled = e, this._enabled ? (this.view.texture = this.make.texture({
|
|
413
|
+
asset: this.config.textures.default,
|
|
414
|
+
sheet: this.config.sheet ?? void 0
|
|
415
|
+
}), this.onEnabled.emit()) : (this._resetPressState(), this.view.texture = this.make.texture({
|
|
416
|
+
asset: this.config.textures.disabled || this.config.textures.default,
|
|
417
|
+
sheet: this.config.sheet ?? void 0
|
|
418
|
+
}), this.onDisabled.emit()));
|
|
419
|
+
}
|
|
420
|
+
_resetPressState() {
|
|
421
|
+
window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), this.isDown = !1, this._pointerId = void 0;
|
|
422
|
+
}
|
|
423
|
+
addLabel(e) {
|
|
424
|
+
if (e instanceof x || e instanceof y || e instanceof _) e.anchor.set(.5, .5), this._textLabel = this.add.existing(e), this._textLabel.layout = !1;
|
|
425
|
+
else switch (e.anchor = .5, e.type) {
|
|
426
|
+
case "bitmap":
|
|
427
|
+
this._textLabel = this.add.bitmapText({
|
|
428
|
+
...e,
|
|
429
|
+
layout: !1
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
case "html":
|
|
433
|
+
this._textLabel = this.add.htmlText({
|
|
434
|
+
...e,
|
|
435
|
+
layout: !1
|
|
436
|
+
});
|
|
437
|
+
break;
|
|
438
|
+
default:
|
|
439
|
+
this._textLabel = this.add.text({
|
|
440
|
+
...e,
|
|
441
|
+
layout: !1
|
|
442
|
+
});
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
return this.positionLabel(), this._textLabel;
|
|
446
|
+
}
|
|
447
|
+
positionLabel() {
|
|
448
|
+
this._textLabel && this._textLabel.position.set(this.view.width * .5, this.view.height * .5);
|
|
449
|
+
}
|
|
450
|
+
get enabled() {
|
|
451
|
+
return this._enabled;
|
|
452
|
+
}
|
|
453
|
+
get app() {
|
|
454
|
+
return m.getInstance();
|
|
455
|
+
}
|
|
456
|
+
destroy(e) {
|
|
457
|
+
this.onDestroy.emit(), this._resetPressState(), this._isDownListenerAdded &&= (this.app.ticker.remove(this._handleIsDownCallbacks), !1), super.destroy(e);
|
|
458
|
+
}
|
|
459
|
+
focusOut() {
|
|
460
|
+
super.focusOut(), this.isDown = !1, this.isOver = !1;
|
|
461
|
+
}
|
|
462
|
+
blur() {
|
|
463
|
+
super.blur(), this.isDown = !1, this.isOver = !1;
|
|
464
|
+
}
|
|
465
|
+
getFocusArea() {
|
|
466
|
+
return this.view.getBounds().clone();
|
|
467
|
+
}
|
|
468
|
+
addIsDownCallback(e, t) {
|
|
469
|
+
this._isDownCallbacks.set(e, t), this._checkIsDownCallbacks();
|
|
470
|
+
}
|
|
471
|
+
removeIsDownCallback(e) {
|
|
472
|
+
this._isDownCallbacks.delete(e), this._checkIsDownCallbacks();
|
|
473
|
+
}
|
|
474
|
+
setTexture(e, t) {
|
|
475
|
+
this.config.textures[e] = t, e === "default" && (this.view.texture = this.make.texture({
|
|
476
|
+
asset: this.config.textures.default,
|
|
477
|
+
sheet: this.config.sheet
|
|
478
|
+
})), this.positionLabel();
|
|
479
|
+
}
|
|
480
|
+
handlePointerOver() {
|
|
481
|
+
this._enabled && (this.isOver ||= !0, !this.isDown && (this.view.texture = this.make.texture({
|
|
482
|
+
asset: this.config.textures.hover || this.config.textures.default,
|
|
483
|
+
sheet: this.config.sheet
|
|
484
|
+
}), this.onOver.emit(), this.config.sounds?.hover && this.app.audio.play(this.config.sounds.hover, "sfx"), this.config.actions?.hover && this._doAction(this.config.actions.hover)));
|
|
485
|
+
}
|
|
486
|
+
handlePointerOut() {
|
|
487
|
+
this.isOver = !1, this._enabled && (this.isDown || (this.view.texture = this.make.texture({
|
|
488
|
+
asset: this.config.textures.default,
|
|
489
|
+
sheet: this.config.sheet
|
|
490
|
+
}), this.config.sounds?.out && this.app.audio.play(this.config.sounds.out, "sfx"), this.onOut.emit()));
|
|
491
|
+
}
|
|
492
|
+
handlePointerDown(e) {
|
|
493
|
+
!this._enabled && !this.isKeyDown || !this.isDown && this._pointerId === void 0 && (this._pointerId = e.pointerId, window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), window.addEventListener("pointerup", this.handlePointerUpOutside), this.on("pointerupoutside", this.handlePointerUpOutside), this.isDown = !0, this.view.texture = this.make.texture({
|
|
494
|
+
asset: this.config.textures.active || this.config.textures.hover || this.config.textures.default,
|
|
495
|
+
sheet: this.config.sheet
|
|
496
|
+
}), this.onDown.emit(), this.config.sounds?.down && this.app.audio.play(this.config.sounds.down, "sfx"), this.config.actions?.down && this._doAction(this.config.actions.down));
|
|
497
|
+
}
|
|
498
|
+
handlePointerUp(e) {
|
|
499
|
+
!this._enabled || !this.isOver || e.pointerId !== this._pointerId || (window.removeEventListener("pointerup", this.handlePointerUpOutside), this.view.texture = this.make.texture({
|
|
500
|
+
asset: this.config.textures.default,
|
|
501
|
+
sheet: this.config.sheet
|
|
502
|
+
}), this.onUp.emit(), this._pointerId = void 0);
|
|
503
|
+
}
|
|
504
|
+
handleClick(e) {
|
|
505
|
+
this._enabled && (e?.pointerId !== void 0 && !this.isDown || e !== void 0 && e === this._lastClickEvent || (this._lastClickEvent = e, this.isDown = !1, this.onClick.emit(), this.config.sounds?.click && this.app.audio.play(this.config.sounds.click, "sfx"), this.config.actions?.click && this._doAction(this.config.actions.click)));
|
|
506
|
+
}
|
|
507
|
+
handlePointerUpOutside(e) {
|
|
508
|
+
if (e.pointerId !== this._pointerId) return;
|
|
509
|
+
let t = this._enabled;
|
|
510
|
+
this._resetPressState(), this.isOver = !1, t && (this.view.texture = this.make.texture({
|
|
511
|
+
asset: this.config.textures.default,
|
|
512
|
+
sheet: this.config.sheet
|
|
513
|
+
}), this.onUpOutside.emit());
|
|
514
|
+
}
|
|
515
|
+
_doAction(e) {
|
|
516
|
+
typeof e == "function" ? e() : (e.data ??= {}, e.data.button || (e.data.button = this), this.app.action(e.id, e.data));
|
|
517
|
+
}
|
|
518
|
+
_checkIsDownCallbacks() {
|
|
519
|
+
!this._isDownListenerAdded && this._isDownCallbacks.size > 0 ? (this._isDownListenerAdded = !0, this.app.ticker.add(this._handleIsDownCallbacks)) : this._isDownListenerAdded && this._isDownCallbacks.size === 0 && (this.app.ticker.remove(this._handleIsDownCallbacks), this._isDownListenerAdded = !1);
|
|
520
|
+
}
|
|
521
|
+
_handleIsDownCallbacks() {
|
|
522
|
+
this.isDown && this._isDownCallbacks.forEach((e) => {
|
|
523
|
+
e();
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}, pe = o(u());
|
|
527
|
+
function me(e) {
|
|
528
|
+
return e instanceof x || e instanceof _;
|
|
529
|
+
}
|
|
530
|
+
var he = [
|
|
531
|
+
"bindTo",
|
|
532
|
+
"bindToAppSize",
|
|
533
|
+
"autoLayoutChildren",
|
|
534
|
+
"debug"
|
|
535
|
+
], K = class extends pe {
|
|
536
|
+
constructor(e = {}) {
|
|
537
|
+
if (super(), this.onLayoutComplete = new t(), this._debugGraphics = null, this._debugLabel = null, !this.app.config.useLayout) throw Error("You must set useLayout to true in your app config to use FlexContainer");
|
|
538
|
+
r(this), this.config = {
|
|
539
|
+
autoLayoutChildren: !0,
|
|
540
|
+
...e
|
|
541
|
+
}, this.layout = this.createLayout(e), this.on("added", this.handleAdded), this.on("childAdded", this.handleChildAdded), this.on("childRemoved", this.handleChildRemoved), this.config.bindToAppSize && this.app.onResize.connect(this.handleResize), this.config.bindTo && "on" in this.config.bindTo && this.config.bindTo.on("layout", this.handleBindToResize);
|
|
542
|
+
}
|
|
543
|
+
createLayout(e) {
|
|
544
|
+
e?.layout === !0 && (e.layout = {});
|
|
545
|
+
let t = { ...e?.layout ?? {} };
|
|
546
|
+
return this.config.bindToAppSize ? (t.width = this.app.size.width, t.height = this.app.size.height) : this.config.bindTo && (t.width = this.config.bindTo.width, t.height = this.config.bindTo.height), t;
|
|
547
|
+
}
|
|
548
|
+
handleAdded() {
|
|
549
|
+
this.updateLayout();
|
|
550
|
+
}
|
|
551
|
+
_updateLayout() {
|
|
552
|
+
this.app.ticker.addOnce(this.updateLayout);
|
|
553
|
+
}
|
|
554
|
+
handleChildAdded(e) {
|
|
555
|
+
this.config.autoLayoutChildren && (e.layout ? me(e) && !e.layout?.style?.isLeaf && (e.layout = { isLeaf: !0 }) : e.layout = { isLeaf: !0 }), c.childAdded(e), e.on("layout", this._updateLayout), this._updateLayout();
|
|
556
|
+
}
|
|
557
|
+
handleChildRemoved(e) {
|
|
558
|
+
e.off("layout", this._updateLayout), c.childRemoved(e), this._updateLayout();
|
|
559
|
+
}
|
|
560
|
+
handleResize() {
|
|
561
|
+
this.config.bindToAppSize && (this.layout = {
|
|
562
|
+
width: this.app.size.width,
|
|
563
|
+
height: this.app.size.height
|
|
564
|
+
}), this._updateLayout();
|
|
565
|
+
}
|
|
566
|
+
handleBindToResize() {
|
|
567
|
+
this.config.bindTo && (this.layout = {
|
|
568
|
+
width: this.config.bindTo.width,
|
|
569
|
+
height: this.config.bindTo.height
|
|
570
|
+
}, this._updateLayout());
|
|
571
|
+
}
|
|
572
|
+
updateLayout() {
|
|
573
|
+
this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this.onLayoutComplete.emit(), this.config.debug && this.drawDebug());
|
|
574
|
+
}
|
|
575
|
+
get app() {
|
|
576
|
+
return m.getInstance();
|
|
577
|
+
}
|
|
578
|
+
configure(e) {
|
|
579
|
+
this.layout = e, this._updateLayout();
|
|
580
|
+
}
|
|
581
|
+
get gap() {
|
|
582
|
+
return this.layout?.style?.gap ?? 0;
|
|
583
|
+
}
|
|
584
|
+
set gap(e) {
|
|
585
|
+
this.layout = { gap: e }, this._updateLayout();
|
|
586
|
+
}
|
|
587
|
+
get flexWrap() {
|
|
588
|
+
return this.layout?.style?.flexWrap;
|
|
589
|
+
}
|
|
590
|
+
set flexWrap(e) {
|
|
591
|
+
this.layout = { flexWrap: e }, this._updateLayout();
|
|
592
|
+
}
|
|
593
|
+
get flexDirection() {
|
|
594
|
+
return this.layout?.style?.flexDirection;
|
|
595
|
+
}
|
|
596
|
+
set flexDirection(e) {
|
|
597
|
+
this.layout = { flexDirection: e }, this._updateLayout();
|
|
598
|
+
}
|
|
599
|
+
get alignItems() {
|
|
600
|
+
return this.layout?.style?.alignItems;
|
|
601
|
+
}
|
|
602
|
+
set alignItems(e) {
|
|
603
|
+
this.layout = { alignItems: e }, this._updateLayout();
|
|
604
|
+
}
|
|
605
|
+
get justifyContent() {
|
|
606
|
+
return this.layout?.style?.justifyContent;
|
|
607
|
+
}
|
|
608
|
+
set justifyContent(e) {
|
|
609
|
+
this.layout = { justifyContent: e }, this._updateLayout();
|
|
610
|
+
}
|
|
611
|
+
get size() {
|
|
612
|
+
return {
|
|
613
|
+
width: this.layout?.style?.width,
|
|
614
|
+
height: this.layout?.style?.height
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
set size(e) {
|
|
618
|
+
Array.isArray(e) && (e = {
|
|
619
|
+
width: e[0],
|
|
620
|
+
height: e[1]
|
|
621
|
+
}), (typeof e == "number" || typeof e == "string") && (e = {
|
|
622
|
+
width: e,
|
|
623
|
+
height: e
|
|
624
|
+
}), this.layout = { ...e }, this._updateLayout();
|
|
625
|
+
}
|
|
626
|
+
get layoutWidth() {
|
|
627
|
+
return this.layout?.style?.width;
|
|
628
|
+
}
|
|
629
|
+
set layoutWidth(e) {
|
|
630
|
+
this.layout = { width: e }, this._updateLayout();
|
|
631
|
+
}
|
|
632
|
+
get layoutHeight() {
|
|
633
|
+
return this.layout?.style?.height;
|
|
634
|
+
}
|
|
635
|
+
set layoutHeight(e) {
|
|
636
|
+
this.layout = { height: e }, this._updateLayout();
|
|
637
|
+
}
|
|
638
|
+
get padding() {
|
|
639
|
+
return this.layout?.style?.padding;
|
|
640
|
+
}
|
|
641
|
+
set padding(e) {
|
|
642
|
+
this.layout = { padding: e }, this._updateLayout();
|
|
643
|
+
}
|
|
644
|
+
get paddingTop() {
|
|
645
|
+
return this.layout?.style?.paddingTop;
|
|
646
|
+
}
|
|
647
|
+
set paddingTop(e) {
|
|
648
|
+
this.layout = { paddingTop: e }, this._updateLayout();
|
|
649
|
+
}
|
|
650
|
+
get paddingRight() {
|
|
651
|
+
return this.layout?.style?.paddingRight;
|
|
652
|
+
}
|
|
653
|
+
set paddingRight(e) {
|
|
654
|
+
this.layout = { paddingRight: e }, this._updateLayout();
|
|
655
|
+
}
|
|
656
|
+
get paddingBottom() {
|
|
657
|
+
return this.layout?.style?.paddingBottom;
|
|
658
|
+
}
|
|
659
|
+
set paddingBottom(e) {
|
|
660
|
+
this.layout = { paddingBottom: e }, this._updateLayout();
|
|
661
|
+
}
|
|
662
|
+
get paddingLeft() {
|
|
663
|
+
return this.layout?.style?.paddingLeft;
|
|
664
|
+
}
|
|
665
|
+
set paddingLeft(e) {
|
|
666
|
+
this.layout = { paddingLeft: e }, this._updateLayout();
|
|
667
|
+
}
|
|
668
|
+
get margin() {
|
|
669
|
+
return this.layout?.style?.margin;
|
|
670
|
+
}
|
|
671
|
+
set margin(e) {
|
|
672
|
+
this.layout = { margin: e }, this._updateLayout();
|
|
673
|
+
}
|
|
674
|
+
get marginTop() {
|
|
675
|
+
return this.layout?.style?.marginTop;
|
|
676
|
+
}
|
|
677
|
+
set marginTop(e) {
|
|
678
|
+
this.layout = { marginTop: e }, this._updateLayout();
|
|
679
|
+
}
|
|
680
|
+
get marginRight() {
|
|
681
|
+
return this.layout?.style?.marginRight;
|
|
682
|
+
}
|
|
683
|
+
set marginRight(e) {
|
|
684
|
+
this.layout = { marginRight: e }, this._updateLayout();
|
|
685
|
+
}
|
|
686
|
+
get marginBottom() {
|
|
687
|
+
return this.layout?.style?.marginBottom;
|
|
688
|
+
}
|
|
689
|
+
set marginBottom(e) {
|
|
690
|
+
this.layout = { marginBottom: e }, this._updateLayout();
|
|
691
|
+
}
|
|
692
|
+
get marginLeft() {
|
|
693
|
+
return this.layout?.style?.marginLeft;
|
|
694
|
+
}
|
|
695
|
+
set marginLeft(e) {
|
|
696
|
+
this.layout = { marginLeft: e }, this._updateLayout();
|
|
697
|
+
}
|
|
698
|
+
get debug() {
|
|
699
|
+
return this.config.debug ?? !1;
|
|
700
|
+
}
|
|
701
|
+
set debug(e) {
|
|
702
|
+
this.config.debug = e, e ? (O(`FlexContainer:${this.uid}`, this.label || "FlexContainer", C.bounds), this.drawDebug()) : (k(`FlexContainer:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1));
|
|
703
|
+
}
|
|
704
|
+
drawDebug() {
|
|
705
|
+
(!this._debugGraphics || this._debugGraphics.parent !== this) && (this._debugGraphics ||= T(`${this.label ?? "FlexContainer"}:debug`), this.addChild(this._debugGraphics), this._debugGraphics.layout = !1), (!this._debugLabel || this._debugLabel.parent !== this) && (this._debugLabel ||= E(this.label || "FlexContainer", C.bounds), this.addChild(this._debugLabel), this._debugLabel.layout = !1), this._debugLabel.text = this.label || "FlexContainer", this._debugLabel.visible = !0, this.setChildIndex(this._debugGraphics, this.children.length - 1), this.setChildIndex(this._debugLabel, this.children.length - 1), this._debugGraphics.clear();
|
|
706
|
+
let e = this.layout?.computedLayout;
|
|
707
|
+
if (!e) return;
|
|
708
|
+
let t = e.width, n = e.height, r = this.layout?.style?.flexDirection ?? "row", i = this.layout?.style?.gap ?? 0;
|
|
709
|
+
this._debugGraphics.rect(0, 0, t, n).stroke({
|
|
710
|
+
width: 1,
|
|
711
|
+
color: C.bounds,
|
|
712
|
+
alpha: w.stroke,
|
|
713
|
+
pixelLine: !0
|
|
714
|
+
});
|
|
715
|
+
let a = this.layout?.style?.paddingTop ?? 0, o = this.layout?.style?.paddingRight ?? 0, s = this.layout?.style?.paddingBottom ?? 0, c = this.layout?.style?.paddingLeft ?? 0;
|
|
716
|
+
a > 0 && this._debugGraphics.rect(0, 0, t, a).fill({
|
|
717
|
+
color: C.outerBounds,
|
|
718
|
+
alpha: w.fill
|
|
719
|
+
}), s > 0 && this._debugGraphics.rect(0, n - s, t, s).fill({
|
|
720
|
+
color: C.outerBounds,
|
|
721
|
+
alpha: w.fill
|
|
722
|
+
}), c > 0 && this._debugGraphics.rect(0, a, c, n - a - s).fill({
|
|
723
|
+
color: C.outerBounds,
|
|
724
|
+
alpha: w.fill
|
|
725
|
+
}), o > 0 && this._debugGraphics.rect(t - o, a, o, n - a - s).fill({
|
|
726
|
+
color: C.outerBounds,
|
|
727
|
+
alpha: w.fill
|
|
728
|
+
});
|
|
729
|
+
let l = Math.min(t, n, 40), u = t / 2, d = n / 2, f = r === "row" || r === "row-reverse";
|
|
730
|
+
if (f) {
|
|
731
|
+
let e = r === "row" ? 1 : -1, t = u - e * l / 2, n = u + e * l / 2;
|
|
732
|
+
this._debugGraphics.moveTo(t, d).lineTo(n, d).moveTo(n, d).lineTo(n - e * 6, d - 4).moveTo(n, d).lineTo(n - e * 6, d + 4).stroke({
|
|
733
|
+
width: 1,
|
|
734
|
+
color: C.direction,
|
|
735
|
+
alpha: .8,
|
|
736
|
+
pixelLine: !0
|
|
737
|
+
});
|
|
738
|
+
} else {
|
|
739
|
+
let e = r === "column" ? 1 : -1, t = d - e * l / 2, n = d + e * l / 2;
|
|
740
|
+
this._debugGraphics.moveTo(u, t).lineTo(u, n).moveTo(u, n).lineTo(u - 4, n - e * 6).moveTo(u, n).lineTo(u + 4, n - e * 6).stroke({
|
|
741
|
+
width: 1,
|
|
742
|
+
color: C.direction,
|
|
743
|
+
alpha: .8,
|
|
744
|
+
pixelLine: !0
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
if (i > 0) for (let e = 0; e < this.children.length - 1; e++) {
|
|
748
|
+
let r = this.children[e];
|
|
749
|
+
if (r === this._debugGraphics || r === this._debugLabel || !r.layout?.computedLayout) continue;
|
|
750
|
+
let a = r.layout.computedLayout;
|
|
751
|
+
if (f) {
|
|
752
|
+
let e = a.left + a.width;
|
|
753
|
+
this._debugGraphics.rect(e, 0, i, n).fill({
|
|
754
|
+
color: C.gap,
|
|
755
|
+
alpha: w.fill
|
|
756
|
+
});
|
|
757
|
+
} else {
|
|
758
|
+
let e = a.top + a.height;
|
|
759
|
+
this._debugGraphics.rect(0, e, t, i).fill({
|
|
760
|
+
color: C.gap,
|
|
761
|
+
alpha: w.fill
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
for (let e of this.children) {
|
|
766
|
+
if (e === this._debugGraphics || e === this._debugLabel || !e.layout?.computedLayout) continue;
|
|
767
|
+
let t = e.layout.computedLayout;
|
|
768
|
+
this._debugGraphics.rect(t.left, t.top, t.width, t.height).stroke({
|
|
769
|
+
width: 1,
|
|
770
|
+
color: C.innerBounds,
|
|
771
|
+
alpha: .4,
|
|
772
|
+
pixelLine: !0
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
this._debugLabel.position.set(2, 2);
|
|
776
|
+
}
|
|
777
|
+
destroy() {
|
|
778
|
+
this.config.debug && k(`FlexContainer:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null), this.off("added", this.handleAdded), this.off("childAdded", this.handleChildAdded), this.off("childRemoved", this.handleChildRemoved), this.config.bindToAppSize && this.app.onResize.disconnect(this.handleResize), this.config.bindTo && "off" in this.config.bindTo && this.config.bindTo.off("layout", this.handleBindToResize), super.destroy();
|
|
779
|
+
}
|
|
780
|
+
}, q = {
|
|
781
|
+
type: "info",
|
|
782
|
+
duration: 3e3,
|
|
783
|
+
width: 300,
|
|
784
|
+
height: 80,
|
|
785
|
+
backgroundColor: 0,
|
|
786
|
+
backgroundAlpha: .8,
|
|
787
|
+
cornerRadius: 0,
|
|
788
|
+
padding: 10,
|
|
789
|
+
autoClose: !0,
|
|
790
|
+
textAlign: "center",
|
|
791
|
+
verticalAlign: "middle",
|
|
792
|
+
colorBarWidth: 6,
|
|
793
|
+
shadow: {
|
|
794
|
+
color: 0,
|
|
795
|
+
alpha: .2,
|
|
796
|
+
offset: {
|
|
797
|
+
x: 1,
|
|
798
|
+
y: 3
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
closeButton: {
|
|
802
|
+
show: !1,
|
|
803
|
+
position: "top right",
|
|
804
|
+
size: 12,
|
|
805
|
+
offset: 4
|
|
806
|
+
},
|
|
807
|
+
style: {
|
|
808
|
+
fill: 16777215,
|
|
809
|
+
fontSize: 16,
|
|
810
|
+
wordWrap: !0
|
|
811
|
+
},
|
|
812
|
+
textColors: {
|
|
813
|
+
info: 3447003,
|
|
814
|
+
success: 3066993,
|
|
815
|
+
warning: 15844367,
|
|
816
|
+
error: 15158332
|
|
817
|
+
}
|
|
818
|
+
}, ge = class extends o(c) {
|
|
819
|
+
set toaster(e) {
|
|
820
|
+
this._toaster = e;
|
|
821
|
+
}
|
|
822
|
+
get toaster() {
|
|
823
|
+
return this._toaster;
|
|
824
|
+
}
|
|
825
|
+
set text(e) {
|
|
826
|
+
this.textDisplay.text = e, this.alignText();
|
|
827
|
+
}
|
|
828
|
+
constructor(e = {}) {
|
|
829
|
+
super(), this.onToastClosed = new t(), this.isHiding = !1, this.config = {
|
|
830
|
+
...q,
|
|
831
|
+
...e
|
|
832
|
+
}, this.initialize();
|
|
833
|
+
}
|
|
834
|
+
initialize() {
|
|
835
|
+
if (this.view = this.add.container(), this.config.shadow && (this.shadow = this.view.add.graphics().roundRect(this.config.shadow.offset?.x ?? 4, this.config.shadow.offset?.y ?? 4, this.config.width, this.config.height, this.config.cornerRadius).fill({
|
|
836
|
+
color: this.config.shadow.color ?? 0,
|
|
837
|
+
alpha: this.config.shadow.alpha ?? .2
|
|
838
|
+
})), this.background = this.view.add.graphics().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({
|
|
839
|
+
color: this.config.backgroundColor,
|
|
840
|
+
alpha: this.config.backgroundAlpha
|
|
841
|
+
}), this.config.type) {
|
|
842
|
+
let e = new v().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({ color: 16777215 }), t = this.view.add.graphics().rect(0, 0, this.config.colorBarWidth, this.config.height).fill({ color: this.config.textColors[this.config.type] });
|
|
843
|
+
t.mask = e, this.view.addChild(e), this.view.addChild(t);
|
|
844
|
+
}
|
|
845
|
+
this.config.closeButton?.show && this.addCloseButton();
|
|
846
|
+
let e = this.config.type ? this.config.colorBarWidth + this.config.padding : this.config.padding, t = this.config.closeButton?.show && this.config.closeButton.position === "top right" ? this.config.closeButton.size + this.config.closeButton.offset * 2 : this.config.padding;
|
|
847
|
+
this.textDisplay = this.view.add.text({
|
|
848
|
+
text: this.config.message,
|
|
849
|
+
style: {
|
|
850
|
+
...q.style,
|
|
851
|
+
...this.config.style,
|
|
852
|
+
wordWrapWidth: this.config.style?.wordWrapWidth ?? this.config.width - e - t
|
|
853
|
+
},
|
|
854
|
+
x: e,
|
|
855
|
+
y: this.config.padding
|
|
856
|
+
}), this.alignText(), this.view.pivot.set(this.config.width * .5, this.config.height * .5), this.view.position.set(this.config.width * .5, this.config.height * .5), this.alpha = 0, this.addChild(this.view);
|
|
857
|
+
}
|
|
858
|
+
addCloseButton() {
|
|
859
|
+
let e = this.config.closeButton?.class || G, t = this.config.closeButton?.size ?? 12, n = this.config.closeButton?.offset ?? 4, r = this.config.closeButton?.position ?? "top right";
|
|
860
|
+
this.closeButton = this.view.add.existing(new e({ cursor: "pointer" }));
|
|
861
|
+
let i = r === "top right" ? this.config.width - t * .5 - n : t * .5 + n, a = t * .5 + n;
|
|
862
|
+
this.closeButton.position.set(i, a), this.closeButton.onClick.connect(() => {
|
|
863
|
+
this.hide();
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
alignText() {
|
|
867
|
+
switch (this.config.textAlign) {
|
|
868
|
+
case "left":
|
|
869
|
+
this.textDisplay.anchor.set(0, .5);
|
|
870
|
+
break;
|
|
871
|
+
case "center":
|
|
872
|
+
this.textDisplay.anchor.set(.5, .5), this.textDisplay.x = this.config.width / 2;
|
|
873
|
+
break;
|
|
874
|
+
case "right":
|
|
875
|
+
this.textDisplay.anchor.set(1, .5);
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
switch (this.config.verticalAlign) {
|
|
879
|
+
case "top":
|
|
880
|
+
this.textDisplay.y = this.config.padding;
|
|
881
|
+
break;
|
|
882
|
+
case "middle":
|
|
883
|
+
this.textDisplay.y = this.config.height * .5;
|
|
884
|
+
break;
|
|
885
|
+
case "bottom":
|
|
886
|
+
this.textDisplay.y = this.config.height - this.textDisplay.height - this.config.padding;
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
getShowAnimation() {
|
|
891
|
+
let e = S.timeline({ paused: !0 });
|
|
892
|
+
return e.to(this, {
|
|
893
|
+
alpha: 1,
|
|
894
|
+
duration: .4,
|
|
895
|
+
ease: "power2.out"
|
|
896
|
+
}), e;
|
|
897
|
+
}
|
|
898
|
+
getHideAnimation() {
|
|
899
|
+
let e = S.timeline({ paused: !0 });
|
|
900
|
+
return e.to(this, {
|
|
901
|
+
alpha: 0,
|
|
902
|
+
duration: .25,
|
|
903
|
+
ease: "power2.in"
|
|
904
|
+
}), e;
|
|
905
|
+
}
|
|
906
|
+
async show() {
|
|
907
|
+
return this.timeline = this.getShowAnimation(), await this.timeline.play(), this.config.autoClose && (this.closeTimeout = setTimeout(() => {
|
|
908
|
+
this.hide();
|
|
909
|
+
}, this.config.duration)), this;
|
|
910
|
+
}
|
|
911
|
+
async hide() {
|
|
912
|
+
if (this.isHiding || this.destroyed) return this;
|
|
913
|
+
this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0);
|
|
914
|
+
try {
|
|
915
|
+
await this.getHideAnimation().play(), this.destroyed || this.onToastClosed.emit();
|
|
916
|
+
} catch (e) {
|
|
917
|
+
console.warn("Toast hide animation error:", e), this.destroyed || this.onToastClosed.emit();
|
|
918
|
+
}
|
|
919
|
+
return this;
|
|
920
|
+
}
|
|
921
|
+
destroy() {
|
|
922
|
+
this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0), S.killTweensOf(this), this.timeline &&= (this.timeline.kill(), void 0), !this.destroyed && !this.isHiding && this.onToastClosed.emit(), super.destroy({ children: !0 });
|
|
923
|
+
}
|
|
924
|
+
}, _e = {
|
|
925
|
+
position: "bottom right",
|
|
926
|
+
maxToasts: 5,
|
|
927
|
+
spacing: 10,
|
|
928
|
+
offset: {
|
|
929
|
+
x: 20,
|
|
930
|
+
y: 20
|
|
931
|
+
},
|
|
932
|
+
stackDirection: "up",
|
|
933
|
+
animationSpeed: 1
|
|
934
|
+
}, ve = class extends o(c) {
|
|
935
|
+
get size() {
|
|
936
|
+
return this.toasts.length;
|
|
937
|
+
}
|
|
938
|
+
get toastPosition() {
|
|
939
|
+
return this.config.position ?? "top right";
|
|
940
|
+
}
|
|
941
|
+
get stackDirection() {
|
|
942
|
+
return this.config.stackDirection ?? "up";
|
|
943
|
+
}
|
|
944
|
+
get spacing() {
|
|
945
|
+
return this.config.spacing ?? 10;
|
|
946
|
+
}
|
|
947
|
+
get offset() {
|
|
948
|
+
return this.config.offset ?? {
|
|
949
|
+
x: 20,
|
|
950
|
+
y: 20
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
get maxToasts() {
|
|
954
|
+
return this.config.maxToasts ?? 5;
|
|
955
|
+
}
|
|
956
|
+
get toastConfig() {
|
|
957
|
+
return this.defaultToastConfig ?? {};
|
|
958
|
+
}
|
|
959
|
+
constructor(e = {}, n = {}) {
|
|
960
|
+
super({ autoResize: !0 }), this.onToastAdded = new t(), this.onToastRemoved = new t(), this.onAllToastsRemoved = new t(), this.toasts = [], this.config = {
|
|
961
|
+
..._e,
|
|
962
|
+
...e
|
|
963
|
+
}, this.defaultToastConfig = { ...n }, this.initialize(), this.resize();
|
|
964
|
+
}
|
|
965
|
+
initialize() {
|
|
966
|
+
this.container = this.add.container();
|
|
967
|
+
}
|
|
968
|
+
async show(e = this.defaultToastConfig, t = !1) {
|
|
969
|
+
if (this.size >= this.config.maxToasts) {
|
|
970
|
+
let e = this.toasts[0];
|
|
971
|
+
await e.hide(), await this.removeToast(e);
|
|
972
|
+
}
|
|
973
|
+
!t && this.defaultToastConfig && (e = {
|
|
974
|
+
...this.defaultToastConfig,
|
|
975
|
+
...e,
|
|
976
|
+
style: this.defaultToastConfig.style || e.style ? {
|
|
977
|
+
...this.defaultToastConfig.style ?? {},
|
|
978
|
+
...e.style ?? {}
|
|
979
|
+
} : this.defaultToastConfig.style,
|
|
980
|
+
textColors: this.defaultToastConfig.textColors || e.textColors ? {
|
|
981
|
+
...this.defaultToastConfig.textColors ?? {},
|
|
982
|
+
...e.textColors ?? {}
|
|
983
|
+
} : q.textColors,
|
|
984
|
+
shadow: this.defaultToastConfig.shadow || e.shadow ? {
|
|
985
|
+
...this.defaultToastConfig.shadow ?? {},
|
|
986
|
+
...e.shadow ?? {}
|
|
987
|
+
} : this.defaultToastConfig.shadow,
|
|
988
|
+
closeButton: this.defaultToastConfig.closeButton || e.closeButton ? {
|
|
989
|
+
...this.defaultToastConfig.closeButton ?? {},
|
|
990
|
+
...e.closeButton ?? {}
|
|
991
|
+
} : q.closeButton
|
|
992
|
+
});
|
|
993
|
+
let n = new (e.class ?? ge)(e);
|
|
994
|
+
return n.toaster = this, this.container.addChild(n), this.toasts.push(n), this.positionToast(n, this.toasts.length - 1, !1), n.onToastClosed.connectOnce(() => this.removeToast(n)), this.positionToasts(), this.onToastAdded.emit(n), n.show();
|
|
995
|
+
}
|
|
996
|
+
async hideAll() {
|
|
997
|
+
let e = [...this.toasts];
|
|
998
|
+
await Promise.all(e.map((e) => e.hide())), this.onAllToastsRemoved.emit();
|
|
999
|
+
}
|
|
1000
|
+
async removeAll() {
|
|
1001
|
+
return this.hideAll();
|
|
1002
|
+
}
|
|
1003
|
+
async removeToast(e) {
|
|
1004
|
+
let t = this.toasts.indexOf(e);
|
|
1005
|
+
t === -1 || e.destroyed || (this.toasts.splice(t, 1), this.positionToasts(), e.destroyed || (this.container.removeChild(e), e.destroy()), this.onToastRemoved.emit(e));
|
|
1006
|
+
}
|
|
1007
|
+
positionToasts(e = !0, t = !1) {
|
|
1008
|
+
this.toasts.filter((e, n) => e && !e.destroyed && (t ? n !== this.toasts.length - 1 : !0)).forEach((t, n) => {
|
|
1009
|
+
this.positionToast(t, n, e);
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
positionToast(e, t, n = !0) {
|
|
1013
|
+
if (!e?.parent || e.destroyed) return;
|
|
1014
|
+
let { position: r, spacing: i, offset: a, stackDirection: o } = this.config, s = typeof a == "number" ? a : a.x, c = typeof a == "number" ? a : a.y, l = this.app.size.width * .5, u = this.app.size.height * .5;
|
|
1015
|
+
switch (r) {
|
|
1016
|
+
case "top right":
|
|
1017
|
+
case "right top":
|
|
1018
|
+
l += this.app.size.width * .5 - e.width - s, u -= this.app.size.height * .5 - c;
|
|
1019
|
+
break;
|
|
1020
|
+
case "top left":
|
|
1021
|
+
case "left top":
|
|
1022
|
+
l -= this.app.size.width * .5 - s, u -= this.app.size.height * .5 - c;
|
|
1023
|
+
break;
|
|
1024
|
+
case "bottom right":
|
|
1025
|
+
case "right bottom":
|
|
1026
|
+
l += this.app.size.width * .5 - e.width - s, u += this.app.size.height * .5 - e.height - c;
|
|
1027
|
+
break;
|
|
1028
|
+
case "bottom left":
|
|
1029
|
+
case "left bottom":
|
|
1030
|
+
l -= this.app.size.width * .5 - s, u += this.app.size.height * .5 - e.height - c;
|
|
1031
|
+
break;
|
|
1032
|
+
case "top":
|
|
1033
|
+
case "top center":
|
|
1034
|
+
l += -e.width * .5, u -= this.app.size.height * .5 - c;
|
|
1035
|
+
break;
|
|
1036
|
+
case "bottom":
|
|
1037
|
+
case "bottom center":
|
|
1038
|
+
l += -e.width * .5, u += this.app.size.height * .5 - e.height - c;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
o === "down" ? u += t * (e.height + i) : u -= t * (e.height + i);
|
|
1042
|
+
try {
|
|
1043
|
+
n ? S.to(e, {
|
|
1044
|
+
x: l,
|
|
1045
|
+
y: u,
|
|
1046
|
+
duration: .3 / this.config.animationSpeed,
|
|
1047
|
+
ease: "power2.out"
|
|
1048
|
+
}) : e.position.set(l, u);
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
console.warn("Error positioning toast:", e);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
resize() {
|
|
1054
|
+
this.position.set(-this.app.size.width * .5, -this.app.size.height * .5), this.positionToasts(!1);
|
|
1055
|
+
}
|
|
1056
|
+
destroy() {
|
|
1057
|
+
this.toasts.forEach((e) => {
|
|
1058
|
+
S.killTweensOf(e);
|
|
1059
|
+
}), this.hideAll(), this.toasts = [], super.destroy({ children: !0 });
|
|
1060
|
+
}
|
|
1061
|
+
}, J = [
|
|
1062
|
+
"debug",
|
|
1063
|
+
"padding",
|
|
1064
|
+
"size",
|
|
1065
|
+
"useAppSize",
|
|
1066
|
+
"useSafeArea",
|
|
1067
|
+
"layout"
|
|
1068
|
+
], ye = {
|
|
1069
|
+
top: 0,
|
|
1070
|
+
right: 0,
|
|
1071
|
+
bottom: 0,
|
|
1072
|
+
left: 0
|
|
1073
|
+
};
|
|
1074
|
+
function be(e, t) {
|
|
1075
|
+
return {
|
|
1076
|
+
top: e.top + t.top,
|
|
1077
|
+
right: e.right + t.right,
|
|
1078
|
+
bottom: e.bottom + t.bottom,
|
|
1079
|
+
left: e.left + t.left
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
var xe = {
|
|
1083
|
+
flexGrow: 0,
|
|
1084
|
+
flexShrink: 0,
|
|
1085
|
+
autoLayoutChildren: !0
|
|
1086
|
+
}, Se = o(u()), Ce = class t extends Se {
|
|
1087
|
+
constructor(e) {
|
|
1088
|
+
if (super(), this.settingsMap = /* @__PURE__ */ new Map(), this._childMap = /* @__PURE__ */ new Map(), this._debugGraphics = null, this._debugLabel = null, this._regionLabels = [], this._disableAddChildError = !1, this._bindings = [], this._canvasChildren = [], this.removeChildren = (e, t) => super.removeChildren(e, t), this.removeChildAt = (e) => super.removeChildAt(e), this.addChildAt = (e, t) => {
|
|
1089
|
+
throw Error("UICanvas: Do not call addChildAt() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
|
|
1090
|
+
}, this.setChildIndex = (e, t) => {
|
|
1091
|
+
throw Error("UICanvas: Do not call setChildIndex() directly. Use reorderElement(child, index), bringToFront(child), or sendToBack(child) instead.\nExample: uiCanvas.reorderElement(myChild, 0)");
|
|
1092
|
+
}, this.getChildIndex = (e) => super.getChildIndex(e), this.getChildAt = (e) => super.getChildAt(e), !this.app.config.useLayout) throw Error("You must set useLayout to true in your app config to use UICanvas");
|
|
1093
|
+
r(this), this._positionContainers = /* @__PURE__ */ new Map(), this.config = {
|
|
1094
|
+
debug: e.debug === !0,
|
|
1095
|
+
padding: h(e?.padding ?? 0),
|
|
1096
|
+
size: e.size === void 0 ? {
|
|
1097
|
+
width: 0,
|
|
1098
|
+
height: 0
|
|
1099
|
+
} : p(e.size),
|
|
1100
|
+
useAppSize: e.useAppSize === !0,
|
|
1101
|
+
useSafeArea: e.useSafeArea ?? !0,
|
|
1102
|
+
autoLayoutChildren: e.autoLayoutChildren ?? !0
|
|
1103
|
+
}, e.layout ? typeof e.layout == "boolean" ? this.config.layout = e.layout : this.config.layout = {
|
|
1104
|
+
...xe,
|
|
1105
|
+
...e.layout
|
|
1106
|
+
} : this.config.layout = { ...xe }, this.config.useAppSize && (this.config.size = this.app.size), this.layout = {
|
|
1107
|
+
width: this.config.size.width,
|
|
1108
|
+
height: this.config.size.height,
|
|
1109
|
+
flexDirection: "column",
|
|
1110
|
+
justifyContent: "space-between",
|
|
1111
|
+
...typeof this.config.layout == "object" ? this.config.layout : {}
|
|
1112
|
+
}, this.on("childRemoved", this._childRemoved), this.once("added", this._added), this.addSignalConnection(this.app.onResize.connect(this.resize)), this._initializeLayout(), this._updateLayout(), this.config.debug && O(`UICanvas:${this.uid}`, this.label || "UICanvas", C.outerBounds);
|
|
1113
|
+
}
|
|
1114
|
+
_updateLayout() {
|
|
1115
|
+
this.app.ticker.addOnce(this.updateLayout);
|
|
1116
|
+
}
|
|
1117
|
+
_initializeLayout() {
|
|
1118
|
+
this._disableAddChildError = !0, this.topRow = this.add.flexContainer({
|
|
1119
|
+
label: "Top",
|
|
1120
|
+
layout: {
|
|
1121
|
+
width: "100%",
|
|
1122
|
+
height: "auto",
|
|
1123
|
+
flexDirection: "row",
|
|
1124
|
+
justifyContent: "space-between",
|
|
1125
|
+
alignItems: "flex-start"
|
|
1126
|
+
}
|
|
1127
|
+
}), this.middleRow = this.add.flexContainer({
|
|
1128
|
+
label: "Middle",
|
|
1129
|
+
layout: {
|
|
1130
|
+
width: "100%",
|
|
1131
|
+
flexDirection: "row",
|
|
1132
|
+
justifyContent: "space-between",
|
|
1133
|
+
alignItems: "center"
|
|
1134
|
+
}
|
|
1135
|
+
}), this.bottomRow = this.add.flexContainer({
|
|
1136
|
+
label: "Bottom",
|
|
1137
|
+
layout: {
|
|
1138
|
+
width: "100%",
|
|
1139
|
+
height: "auto",
|
|
1140
|
+
flexDirection: "row",
|
|
1141
|
+
justifyContent: "space-between",
|
|
1142
|
+
alignItems: "flex-end"
|
|
1143
|
+
}
|
|
1144
|
+
}), this._disableAddChildError = !1;
|
|
1145
|
+
let e = this._createPositionContainer(this.topRow, {
|
|
1146
|
+
justifyContent: "flex-start",
|
|
1147
|
+
alignItems: "flex-start",
|
|
1148
|
+
flexGrow: 0,
|
|
1149
|
+
flexShrink: 0
|
|
1150
|
+
}, "Left"), t = this._createPositionContainer(this.topRow, {
|
|
1151
|
+
justifyContent: "center",
|
|
1152
|
+
alignItems: "flex-start",
|
|
1153
|
+
flexGrow: 1,
|
|
1154
|
+
flexShrink: 0
|
|
1155
|
+
}, "Center"), n = this._createPositionContainer(this.topRow, {
|
|
1156
|
+
justifyContent: "flex-end",
|
|
1157
|
+
alignItems: "flex-start",
|
|
1158
|
+
flexGrow: 0,
|
|
1159
|
+
flexShrink: 0
|
|
1160
|
+
}, "Right"), r = this._createPositionContainer(this.middleRow, {
|
|
1161
|
+
justifyContent: "flex-start",
|
|
1162
|
+
alignItems: "center",
|
|
1163
|
+
flexDirection: "row",
|
|
1164
|
+
flexGrow: 0,
|
|
1165
|
+
flexShrink: 0
|
|
1166
|
+
}, "Left"), i = this._createPositionContainer(this.middleRow, {
|
|
1167
|
+
justifyContent: "center",
|
|
1168
|
+
alignItems: "center",
|
|
1169
|
+
flexDirection: "row",
|
|
1170
|
+
flexGrow: 1,
|
|
1171
|
+
flexShrink: 0
|
|
1172
|
+
}, "Center"), a = this._createPositionContainer(this.middleRow, {
|
|
1173
|
+
justifyContent: "flex-end",
|
|
1174
|
+
alignItems: "center",
|
|
1175
|
+
flexDirection: "row",
|
|
1176
|
+
flexGrow: 0,
|
|
1177
|
+
flexShrink: 0
|
|
1178
|
+
}, "Right"), o = this._createPositionContainer(this.bottomRow, {
|
|
1179
|
+
justifyContent: "flex-start",
|
|
1180
|
+
alignItems: "flex-end",
|
|
1181
|
+
flexDirection: "row",
|
|
1182
|
+
flexGrow: 0,
|
|
1183
|
+
flexShrink: 0
|
|
1184
|
+
}, "Left"), s = this._createPositionContainer(this.bottomRow, {
|
|
1185
|
+
justifyContent: "center",
|
|
1186
|
+
alignItems: "flex-end",
|
|
1187
|
+
flexGrow: 1,
|
|
1188
|
+
flexShrink: 0,
|
|
1189
|
+
flexDirection: "row"
|
|
1190
|
+
}, "Center"), c = this._createPositionContainer(this.bottomRow, {
|
|
1191
|
+
justifyContent: "flex-end",
|
|
1192
|
+
alignItems: "flex-end",
|
|
1193
|
+
flexDirection: "row",
|
|
1194
|
+
flexGrow: 0,
|
|
1195
|
+
flexShrink: 0
|
|
1196
|
+
}, "Right");
|
|
1197
|
+
this._positionContainers.set("top left", e), this._positionContainers.set("left top", e), this._positionContainers.set("top center", t), this._positionContainers.set("top", t), this._positionContainers.set("top right", n), this._positionContainers.set("right top", n), this._positionContainers.set("left center", r), this._positionContainers.set("left", r), this._positionContainers.set("left bottom", o), this._positionContainers.set("center", i), this._positionContainers.set("right center", a), this._positionContainers.set("right", a), this._positionContainers.set("right bottom", c), this._positionContainers.set("bottom left", o), this._positionContainers.set("bottom center", s), this._positionContainers.set("bottom", s), this._positionContainers.set("bottom right", c);
|
|
1198
|
+
}
|
|
1199
|
+
_createPositionContainer(e, t, n) {
|
|
1200
|
+
let r = e.add.container({ layout: {
|
|
1201
|
+
width: "auto",
|
|
1202
|
+
height: "auto",
|
|
1203
|
+
...t
|
|
1204
|
+
} });
|
|
1205
|
+
return r.label = n, r.on("childAdded", this._updateLayout), r.on("childRemoved", this._updateLayout), r.on("layout", this._updateLayout), r;
|
|
1206
|
+
}
|
|
1207
|
+
get canvasChildren() {
|
|
1208
|
+
return this._canvasChildren;
|
|
1209
|
+
}
|
|
1210
|
+
get app() {
|
|
1211
|
+
return m.getInstance();
|
|
1212
|
+
}
|
|
1213
|
+
destroy() {
|
|
1214
|
+
this._disableAddChildError = !0, this.config.debug && k(`UICanvas:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null);
|
|
1215
|
+
for (let e of this._regionLabels) e.destroy();
|
|
1216
|
+
this._regionLabels = [], this.canvasChildren?.forEach((e) => {
|
|
1217
|
+
e.off("layout", this._updateLayout);
|
|
1218
|
+
}), this.children.forEach((e) => {
|
|
1219
|
+
e.off("layout", this._updateLayout);
|
|
1220
|
+
}), this.off("childAdded", this._updateLayout), this.off("childRemoved", this._updateLayout), this._positionContainers.forEach((e) => {
|
|
1221
|
+
e.off("childAdded", this._updateLayout), e.off("childRemoved", this._updateLayout);
|
|
1222
|
+
}), this._bindings = [], super.destroy();
|
|
1223
|
+
}
|
|
1224
|
+
set size(e) {
|
|
1225
|
+
this.config.size = e === void 0 ? {
|
|
1226
|
+
width: 0,
|
|
1227
|
+
height: 0
|
|
1228
|
+
} : p(e), this.layout = {
|
|
1229
|
+
width: this.config.size.width,
|
|
1230
|
+
height: this.config.size.height
|
|
1231
|
+
}, this.updateLayout();
|
|
1232
|
+
}
|
|
1233
|
+
set padding(e) {
|
|
1234
|
+
this.config.padding = h(e), this._applyPadding(), this._updateLayout();
|
|
1235
|
+
}
|
|
1236
|
+
_applyPadding() {
|
|
1237
|
+
let e = be(this.config.padding, this.config.useSafeArea ? this.app.safeArea : ye);
|
|
1238
|
+
this.layout = {
|
|
1239
|
+
paddingLeft: e.left,
|
|
1240
|
+
paddingTop: e.top,
|
|
1241
|
+
paddingRight: e.right,
|
|
1242
|
+
paddingBottom: e.bottom
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
static isFlexContainer(e) {
|
|
1246
|
+
return e instanceof K;
|
|
1247
|
+
}
|
|
1248
|
+
addChild(...e) {
|
|
1249
|
+
if (this._disableAddChildError) return super.addChild(...e);
|
|
1250
|
+
throw Error("UICanvas: Do not call addChild() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
|
|
1251
|
+
}
|
|
1252
|
+
removeChild(...e) {
|
|
1253
|
+
if (this._disableAddChildError) return super.removeChild(...e);
|
|
1254
|
+
throw Error("UICanvas: Do not call removeChild() directly. Use removeElement(child) instead.");
|
|
1255
|
+
}
|
|
1256
|
+
resize() {
|
|
1257
|
+
this._applyPadding(), this.config.useAppSize ? (this.size = {
|
|
1258
|
+
width: this.app.size.width,
|
|
1259
|
+
height: this.app.size.height
|
|
1260
|
+
}, this.position.set(-this.app.size.width * .5, -this.app.size.height * .5)) : this._updateLayout();
|
|
1261
|
+
}
|
|
1262
|
+
updateLayout() {
|
|
1263
|
+
this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this._positionContainers.forEach((e) => {
|
|
1264
|
+
this.app.renderer.layout.update(e);
|
|
1265
|
+
}), this.config.useAppSize && this.position.set(-this.config.size.width * .5, -this.config.size.height * .5), this._updateBindings(), this.config.debug && this.app.ticker.addOnce(this.drawDebug));
|
|
1266
|
+
}
|
|
1267
|
+
bindElement(e, t, n) {
|
|
1268
|
+
e.parent !== this && (this._disableAddChildError = !0, super.addChild(e), this._disableAddChildError = !1), e.layout = !1, this._bindings = this._bindings.filter((t) => t.child !== e), this._bindings.push({
|
|
1269
|
+
child: e,
|
|
1270
|
+
anchor: t,
|
|
1271
|
+
place: n
|
|
1272
|
+
}), this._updateLayout();
|
|
1273
|
+
}
|
|
1274
|
+
unbindElement(e) {
|
|
1275
|
+
let t = this._bindings.some((t) => t.child === e);
|
|
1276
|
+
this._bindings = this._bindings.filter((t) => t.child !== e), t && e.parent === this && (this._disableAddChildError = !0, super.removeChild(e), this._disableAddChildError = !1);
|
|
1277
|
+
}
|
|
1278
|
+
_updateBindings() {
|
|
1279
|
+
for (let { child: e, anchor: t, place: n } of this._bindings) {
|
|
1280
|
+
let r = this._anchorRect(t);
|
|
1281
|
+
r && n(r, e);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
_anchorRect(e) {
|
|
1285
|
+
let t = e.layout?.computedLayout;
|
|
1286
|
+
if (!t) return null;
|
|
1287
|
+
let n = 0, r = 0;
|
|
1288
|
+
for (let t = e; t && t !== this; t = t.parent) {
|
|
1289
|
+
let e = t.layout?.computedLayout;
|
|
1290
|
+
e && (n += e.left, r += e.top);
|
|
1291
|
+
}
|
|
1292
|
+
return {
|
|
1293
|
+
left: n,
|
|
1294
|
+
top: r,
|
|
1295
|
+
width: t.width,
|
|
1296
|
+
height: t.height
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
addElement(n, r) {
|
|
1300
|
+
let i = r?.align ?? "top left", a = this._positionContainers.get(i);
|
|
1301
|
+
return a ? (t.isFlexContainer(n) && this.addSignalConnection(n.onLayoutComplete.connect(this._updateLayout)), this.settingsMap.set(n, {
|
|
1302
|
+
align: i,
|
|
1303
|
+
padding: r?.padding ? h(r.padding) : {
|
|
1304
|
+
top: 0,
|
|
1305
|
+
left: 0,
|
|
1306
|
+
bottom: 0,
|
|
1307
|
+
right: 0
|
|
1308
|
+
}
|
|
1309
|
+
}), this._childMap.set(n, a), this._canvasChildren = Array.from(this._childMap.keys()), a.add.existing(n), this._childAdded(n), n) : (e.error(`UICanvas:: Invalid position "${i}" for element`), n);
|
|
1310
|
+
}
|
|
1311
|
+
removeElement(e) {
|
|
1312
|
+
let t = this._childMap.get(e);
|
|
1313
|
+
if (!t) throw Error(`UICanvas: Cannot remove element — it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
|
|
1314
|
+
return t.removeChild(e), e.off("layout", this._updateLayout), this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), this._updateLayout(), e;
|
|
1315
|
+
}
|
|
1316
|
+
reorderElement(e, t) {
|
|
1317
|
+
let n = this._childMap.get(e);
|
|
1318
|
+
if (!n) throw Error(`UICanvas: Cannot reorder element — it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
|
|
1319
|
+
return n.setChildIndex(e, t), this._updateLayout(), e;
|
|
1320
|
+
}
|
|
1321
|
+
bringToFront(e) {
|
|
1322
|
+
let t = this._childMap.get(e);
|
|
1323
|
+
if (!t) throw Error(`UICanvas: Cannot reorder element — it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
|
|
1324
|
+
return this.reorderElement(e, t.children.length - 1);
|
|
1325
|
+
}
|
|
1326
|
+
sendToBack(e) {
|
|
1327
|
+
return this.reorderElement(e, 0);
|
|
1328
|
+
}
|
|
1329
|
+
_childAdded(e) {
|
|
1330
|
+
this.config.autoLayoutChildren && (e.layout ||= !0, e.layout?.style?.width || (e.layout = { width: "auto" }), e.layout?.style?.height || (e.layout = { height: "auto" })), e.on("layout", this._updateLayout), c.childAdded(e), this._updateLayout();
|
|
1331
|
+
}
|
|
1332
|
+
_childRemoved(e) {
|
|
1333
|
+
this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), c.childRemoved(e);
|
|
1334
|
+
}
|
|
1335
|
+
_added() {
|
|
1336
|
+
this._updateLayout();
|
|
1337
|
+
}
|
|
1338
|
+
get debug() {
|
|
1339
|
+
return this.config.debug;
|
|
1340
|
+
}
|
|
1341
|
+
set debug(e) {
|
|
1342
|
+
if (this.config.debug = e, e) O(`UICanvas:${this.uid}`, this.label || "UICanvas", C.outerBounds), this.drawDebug();
|
|
1343
|
+
else {
|
|
1344
|
+
k(`UICanvas:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1);
|
|
1345
|
+
for (let e of this._regionLabels) e.visible = !1;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
drawDebug() {
|
|
1349
|
+
this._debugGraphics || (this._disableAddChildError = !0, this._debugGraphics = T(`${this.label ?? "UICanvas"}:debug`), super.addChild(this._debugGraphics), this._debugGraphics.layout = !1, this._disableAddChildError = !1), this._debugLabel || (this._disableAddChildError = !0, this._debugLabel = E(this.label || "UICanvas", C.outerBounds), super.addChild(this._debugLabel), this._debugLabel.layout = !1, this._disableAddChildError = !1), this._debugLabel.text = this.label || "UICanvas", this._debugLabel.visible = !0, this._debugLabel.position.set(2, 2), this._debugGraphics.clear();
|
|
1350
|
+
let e = this.config.size.width, t = this.config.size.height, n = this.config.padding;
|
|
1351
|
+
this._debugGraphics.rect(0, 0, e, t).stroke({
|
|
1352
|
+
width: 1,
|
|
1353
|
+
color: C.outerBounds,
|
|
1354
|
+
alpha: w.stroke,
|
|
1355
|
+
pixelLine: !0
|
|
1356
|
+
}), n.top > 0 && this._debugGraphics.rect(0, 0, e, n.top).fill({
|
|
1357
|
+
color: C.outerBounds,
|
|
1358
|
+
alpha: w.fill
|
|
1359
|
+
}), n.bottom > 0 && this._debugGraphics.rect(0, t - n.bottom, e, n.bottom).fill({
|
|
1360
|
+
color: C.outerBounds,
|
|
1361
|
+
alpha: w.fill
|
|
1362
|
+
}), n.left > 0 && this._debugGraphics.rect(0, n.top, n.left, t - n.top - n.bottom).fill({
|
|
1363
|
+
color: C.outerBounds,
|
|
1364
|
+
alpha: w.fill
|
|
1365
|
+
}), n.right > 0 && this._debugGraphics.rect(e - n.right, n.top, n.right, t - n.top - n.bottom).fill({
|
|
1366
|
+
color: C.outerBounds,
|
|
1367
|
+
alpha: w.fill
|
|
1368
|
+
});
|
|
1369
|
+
let r = n.left, i = n.top, a = e - n.left - n.right, o = t - n.top - n.bottom;
|
|
1370
|
+
this._debugGraphics.rect(r, i, a, o).stroke({
|
|
1371
|
+
width: 1,
|
|
1372
|
+
color: C.innerBounds,
|
|
1373
|
+
alpha: w.stroke,
|
|
1374
|
+
pixelLine: !0
|
|
1375
|
+
});
|
|
1376
|
+
let s = /* @__PURE__ */ new Map();
|
|
1377
|
+
this._positionContainers.forEach((e, t) => {
|
|
1378
|
+
(!s.has(e) || t.length < s.get(e).length) && s.set(e, t);
|
|
1379
|
+
});
|
|
1380
|
+
let c = [...new Set(this._positionContainers.values())];
|
|
1381
|
+
for (; this._regionLabels.length < c.length;) {
|
|
1382
|
+
this._disableAddChildError = !0;
|
|
1383
|
+
let e = E("", C.region);
|
|
1384
|
+
super.addChild(e), e.layout = !1, this._regionLabels.push(e), this._disableAddChildError = !1;
|
|
1385
|
+
}
|
|
1386
|
+
c.forEach((e, t) => {
|
|
1387
|
+
if (!e.layout?.computedLayout) return;
|
|
1388
|
+
let n = e.layout.computedLayout, r = e.parent;
|
|
1389
|
+
if (!r?.layout?.computedLayout) return;
|
|
1390
|
+
let i = r.layout.computedLayout, a = i.left + n.left, o = i.top + n.top, c = n.width, l = n.height, u = e.children.length > 0;
|
|
1391
|
+
this._debugGraphics.rect(a, o, c, l).fill({
|
|
1392
|
+
color: C.region,
|
|
1393
|
+
alpha: u ? w.fillActive : w.fill
|
|
1394
|
+
}).stroke({
|
|
1395
|
+
width: 1,
|
|
1396
|
+
color: C.region,
|
|
1397
|
+
alpha: .3,
|
|
1398
|
+
pixelLine: !0
|
|
1399
|
+
});
|
|
1400
|
+
let d = this._regionLabels[t];
|
|
1401
|
+
d.text = s.get(e) ?? "", d.visible = !0, d.position.set(a + 2, o + 2);
|
|
1402
|
+
});
|
|
1403
|
+
for (let e = c.length; e < this._regionLabels.length; e++) this._regionLabels[e].visible = !1;
|
|
1404
|
+
let l = e / 2, u = t / 2;
|
|
1405
|
+
this._debugGraphics.moveTo(l, u - 10).lineTo(l, u + 10).stroke({
|
|
1406
|
+
width: 1,
|
|
1407
|
+
color: C.outerBounds,
|
|
1408
|
+
alpha: w.crosshair,
|
|
1409
|
+
pixelLine: !0
|
|
1410
|
+
}).moveTo(l - 10, u).lineTo(l + 10, u).stroke({
|
|
1411
|
+
width: 1,
|
|
1412
|
+
color: C.outerBounds,
|
|
1413
|
+
alpha: w.crosshair,
|
|
1414
|
+
pixelLine: !0
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
}, Y = null;
|
|
1418
|
+
function we() {
|
|
1419
|
+
if (Y) return Y;
|
|
1420
|
+
Y = /* @__PURE__ */ new Map();
|
|
1421
|
+
let e = globalThis.Caper?.get?.("entityList") ?? [];
|
|
1422
|
+
for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && Y.set(t.id, t.module);
|
|
1423
|
+
return Y;
|
|
1424
|
+
}
|
|
1425
|
+
function Te(e) {
|
|
1426
|
+
return we().get(e);
|
|
1427
|
+
}
|
|
1428
|
+
function Ee() {
|
|
1429
|
+
return [...we().keys()];
|
|
1430
|
+
}
|
|
1431
|
+
//#endregion
|
|
1432
|
+
//#region src/mixins/factory/ui-registry.ts
|
|
1433
|
+
var X = null;
|
|
1434
|
+
function De() {
|
|
1435
|
+
if (X) return X;
|
|
1436
|
+
X = /* @__PURE__ */ new Map();
|
|
1437
|
+
let e = globalThis.Caper?.get?.("uiList") ?? [];
|
|
1438
|
+
for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && X.set(t.id, t.module);
|
|
1439
|
+
return X;
|
|
1440
|
+
}
|
|
1441
|
+
function Oe(e) {
|
|
1442
|
+
return De().get(e);
|
|
1443
|
+
}
|
|
1444
|
+
function ke() {
|
|
1445
|
+
return [...De().keys()];
|
|
1446
|
+
}
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/mixins/factory/schema.ts
|
|
1449
|
+
var Ae = [
|
|
1450
|
+
"position",
|
|
1451
|
+
"scale",
|
|
1452
|
+
"pivot"
|
|
1453
|
+
], je = [
|
|
1454
|
+
"position",
|
|
1455
|
+
"x",
|
|
1456
|
+
"y",
|
|
1457
|
+
"scale",
|
|
1458
|
+
"scaleX",
|
|
1459
|
+
"scaleY",
|
|
1460
|
+
"pivot",
|
|
1461
|
+
"anchor"
|
|
1462
|
+
];
|
|
1463
|
+
function Z(e) {
|
|
1464
|
+
let t = e.applies ?? Ae, n = t.includes("position"), r = t.includes("scale"), i = t.includes("pivot"), a = t.includes("anchor"), o = [...je, ...e.exclude ?? []];
|
|
1465
|
+
return (t) => {
|
|
1466
|
+
let s = e.build(t);
|
|
1467
|
+
if (t == null) return s;
|
|
1468
|
+
let c = t;
|
|
1469
|
+
return n && I({
|
|
1470
|
+
position: c.position,
|
|
1471
|
+
x: c.x,
|
|
1472
|
+
y: c.y
|
|
1473
|
+
}, s), r && L({
|
|
1474
|
+
scale: c.scale,
|
|
1475
|
+
scaleX: c.scaleX,
|
|
1476
|
+
scaleY: c.scaleY
|
|
1477
|
+
}, s), i && z(c.pivot, s), a && R(c.anchor, s), N(ee(o, c), s), s;
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/mixins/factory/const.ts
|
|
1482
|
+
var Me = /* @__PURE__ */ i({ defaultFactoryMethods: () => $ }), Q = [
|
|
1483
|
+
"text",
|
|
1484
|
+
"roundPixels",
|
|
1485
|
+
"resolution",
|
|
1486
|
+
"style",
|
|
1487
|
+
"anchor",
|
|
1488
|
+
"pivot"
|
|
1489
|
+
], $ = {
|
|
1490
|
+
existing: (e, t) => {
|
|
1491
|
+
if (!t) return e;
|
|
1492
|
+
let { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ...l } = t;
|
|
1493
|
+
return I({
|
|
1494
|
+
position: n,
|
|
1495
|
+
x: r,
|
|
1496
|
+
y: i
|
|
1497
|
+
}, e), L({
|
|
1498
|
+
scale: o,
|
|
1499
|
+
scaleX: s,
|
|
1500
|
+
scaleY: c
|
|
1501
|
+
}, e), z(a, e), N(l, e), e;
|
|
1502
|
+
},
|
|
1503
|
+
container: Z({
|
|
1504
|
+
build: (e) => new c(e ? s(e, f) : void 0),
|
|
1505
|
+
applies: [
|
|
1506
|
+
"position",
|
|
1507
|
+
"scale",
|
|
1508
|
+
"pivot"
|
|
1509
|
+
],
|
|
1510
|
+
exclude: f
|
|
1511
|
+
}),
|
|
1512
|
+
particleContainer: Z({
|
|
1513
|
+
build: (e) => new le(e ? s(e, j) : void 0),
|
|
1514
|
+
applies: [
|
|
1515
|
+
"position",
|
|
1516
|
+
"scale",
|
|
1517
|
+
"pivot"
|
|
1518
|
+
],
|
|
1519
|
+
exclude: j
|
|
1520
|
+
}),
|
|
1521
|
+
texture: F,
|
|
1522
|
+
sprite: Z({
|
|
1523
|
+
build: (e) => new b(e ? F(e) : void 0),
|
|
1524
|
+
applies: [
|
|
1525
|
+
"position",
|
|
1526
|
+
"scale",
|
|
1527
|
+
"pivot",
|
|
1528
|
+
"anchor"
|
|
1529
|
+
],
|
|
1530
|
+
exclude: ["asset", "sheet"]
|
|
1531
|
+
}),
|
|
1532
|
+
tilingSprite: Z({
|
|
1533
|
+
build: (e) => new oe(e ? F(e) : void 0),
|
|
1534
|
+
applies: [
|
|
1535
|
+
"position",
|
|
1536
|
+
"scale",
|
|
1537
|
+
"pivot",
|
|
1538
|
+
"anchor"
|
|
1539
|
+
],
|
|
1540
|
+
exclude: ["asset", "sheet"]
|
|
1541
|
+
}),
|
|
1542
|
+
animatedSprite: Z({
|
|
1543
|
+
build: (e) => new B(e),
|
|
1544
|
+
applies: [
|
|
1545
|
+
"position",
|
|
1546
|
+
"scale",
|
|
1547
|
+
"pivot"
|
|
1548
|
+
],
|
|
1549
|
+
exclude: [
|
|
1550
|
+
"sheet",
|
|
1551
|
+
"texturePrefix",
|
|
1552
|
+
"zeroPad",
|
|
1553
|
+
"animations",
|
|
1554
|
+
"autoPlay",
|
|
1555
|
+
"autoUpdate",
|
|
1556
|
+
"defaultAnimation",
|
|
1557
|
+
"reversible",
|
|
1558
|
+
"animationSpeed",
|
|
1559
|
+
"startIndex",
|
|
1560
|
+
"animation"
|
|
1561
|
+
]
|
|
1562
|
+
}),
|
|
1563
|
+
graphics: Z({
|
|
1564
|
+
build: (e) => new v(),
|
|
1565
|
+
applies: [
|
|
1566
|
+
"position",
|
|
1567
|
+
"scale",
|
|
1568
|
+
"pivot"
|
|
1569
|
+
]
|
|
1570
|
+
}),
|
|
1571
|
+
svg(e) {
|
|
1572
|
+
let t = new ue(e.ctx), { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ctx: l, ...u } = e;
|
|
1573
|
+
return I({
|
|
1574
|
+
position: n,
|
|
1575
|
+
x: r,
|
|
1576
|
+
y: i
|
|
1577
|
+
}, t), L({
|
|
1578
|
+
scale: o,
|
|
1579
|
+
scaleX: s,
|
|
1580
|
+
scaleY: c
|
|
1581
|
+
}, t), z(a, t), N(u, t), t;
|
|
1582
|
+
},
|
|
1583
|
+
text: Z({
|
|
1584
|
+
build: (e) => new x(e ? {
|
|
1585
|
+
text: e.text,
|
|
1586
|
+
roundPixels: e.roundPixels,
|
|
1587
|
+
resolution: e.resolution,
|
|
1588
|
+
style: e.style,
|
|
1589
|
+
anchor: e.anchor ? d(e.anchor, !0) : void 0,
|
|
1590
|
+
pivot: e.pivot ? d(e.pivot, !0) : void 0
|
|
1591
|
+
} : {}),
|
|
1592
|
+
applies: [
|
|
1593
|
+
"position",
|
|
1594
|
+
"scale",
|
|
1595
|
+
"pivot"
|
|
1596
|
+
],
|
|
1597
|
+
exclude: [...Q]
|
|
1598
|
+
}),
|
|
1599
|
+
htmlText: Z({
|
|
1600
|
+
build: (e) => new y(e ? {
|
|
1601
|
+
text: e.text,
|
|
1602
|
+
roundPixels: e.roundPixels,
|
|
1603
|
+
resolution: e.resolution,
|
|
1604
|
+
style: e.style,
|
|
1605
|
+
anchor: e.anchor ? d(e.anchor, !0) : void 0,
|
|
1606
|
+
pivot: e.pivot ? d(e.pivot, !0) : void 0
|
|
1607
|
+
} : {}),
|
|
1608
|
+
applies: [
|
|
1609
|
+
"position",
|
|
1610
|
+
"scale",
|
|
1611
|
+
"pivot"
|
|
1612
|
+
],
|
|
1613
|
+
exclude: [...Q]
|
|
1614
|
+
}),
|
|
1615
|
+
bitmapText: Z({
|
|
1616
|
+
build: (e) => new _(e ? {
|
|
1617
|
+
text: e.text,
|
|
1618
|
+
roundPixels: e.roundPixels,
|
|
1619
|
+
style: e.style,
|
|
1620
|
+
anchor: e.anchor ? d(e.anchor, !0) : void 0,
|
|
1621
|
+
pivot: e.pivot ? d(e.pivot, !0) : void 0
|
|
1622
|
+
} : {}),
|
|
1623
|
+
applies: [
|
|
1624
|
+
"position",
|
|
1625
|
+
"scale",
|
|
1626
|
+
"pivot"
|
|
1627
|
+
],
|
|
1628
|
+
exclude: [...Q]
|
|
1629
|
+
}),
|
|
1630
|
+
button: Z({
|
|
1631
|
+
build: (e) => new G(e ? s(e, W) : void 0),
|
|
1632
|
+
applies: [
|
|
1633
|
+
"position",
|
|
1634
|
+
"scale",
|
|
1635
|
+
"pivot"
|
|
1636
|
+
],
|
|
1637
|
+
exclude: W
|
|
1638
|
+
}),
|
|
1639
|
+
flexContainer: Z({
|
|
1640
|
+
build: (e) => new K(e),
|
|
1641
|
+
applies: [
|
|
1642
|
+
"position",
|
|
1643
|
+
"scale",
|
|
1644
|
+
"pivot"
|
|
1645
|
+
],
|
|
1646
|
+
exclude: he
|
|
1647
|
+
}),
|
|
1648
|
+
uiCanvas: Z({
|
|
1649
|
+
build: (e) => new Ce(e ? s(e, J) : {}),
|
|
1650
|
+
applies: [
|
|
1651
|
+
"position",
|
|
1652
|
+
"scale",
|
|
1653
|
+
"pivot"
|
|
1654
|
+
],
|
|
1655
|
+
exclude: J
|
|
1656
|
+
}),
|
|
1657
|
+
spine: Z({
|
|
1658
|
+
build: (e) => {
|
|
1659
|
+
let t = "", n = e?.data;
|
|
1660
|
+
if (typeof n == "string") {
|
|
1661
|
+
let e = n.slice(-5);
|
|
1662
|
+
e !== ".json" && e !== ".skel" ? e = ".json" : t = n.substring(0, n.length - 5), t = {
|
|
1663
|
+
skeleton: n + e,
|
|
1664
|
+
atlas: n + ".atlas"
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
let r = window.Spine.from(t);
|
|
1668
|
+
return e?.autoUpdate !== void 0 && (r.autoUpdate = e.autoUpdate), e?.animationName && r.state.setAnimation(e.trackIndex ?? 0, e.animationName, e.loop), r;
|
|
1669
|
+
},
|
|
1670
|
+
applies: [
|
|
1671
|
+
"position",
|
|
1672
|
+
"scale",
|
|
1673
|
+
"pivot",
|
|
1674
|
+
"anchor"
|
|
1675
|
+
],
|
|
1676
|
+
exclude: [
|
|
1677
|
+
"data",
|
|
1678
|
+
"autoUpdate",
|
|
1679
|
+
"animationName",
|
|
1680
|
+
"trackIndex",
|
|
1681
|
+
"loop"
|
|
1682
|
+
]
|
|
1683
|
+
}),
|
|
1684
|
+
spineAnimation: (e) => {
|
|
1685
|
+
let t = new V(e);
|
|
1686
|
+
if (!e) return t;
|
|
1687
|
+
let { position: n, x: r, y: i, anchor: a, pivot: o, scale: s, scaleX: c, scaleY: l, ...u } = e;
|
|
1688
|
+
return I({
|
|
1689
|
+
position: n,
|
|
1690
|
+
x: r,
|
|
1691
|
+
y: i
|
|
1692
|
+
}, t), L({
|
|
1693
|
+
scale: s,
|
|
1694
|
+
scaleX: c,
|
|
1695
|
+
scaleY: l
|
|
1696
|
+
}, t), R(a, t), z(o, t), N(u, t), t;
|
|
1697
|
+
},
|
|
1698
|
+
toaster: (e, t = {}) => new ve(e, t),
|
|
1699
|
+
entity: (e, t) => {
|
|
1700
|
+
let n = Te(e);
|
|
1701
|
+
if (!n) {
|
|
1702
|
+
let t = Ee();
|
|
1703
|
+
throw Error(`[caper] Unknown entity id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
|
|
1704
|
+
}
|
|
1705
|
+
let r = new n(t);
|
|
1706
|
+
if (t) {
|
|
1707
|
+
let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
|
|
1708
|
+
I({
|
|
1709
|
+
position: e,
|
|
1710
|
+
x: n,
|
|
1711
|
+
y: i
|
|
1712
|
+
}, r), L({
|
|
1713
|
+
scale: o,
|
|
1714
|
+
scaleX: s,
|
|
1715
|
+
scaleY: c
|
|
1716
|
+
}, r), z(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
|
|
1717
|
+
}
|
|
1718
|
+
return r;
|
|
1719
|
+
},
|
|
1720
|
+
ui: (e, t) => {
|
|
1721
|
+
let n = Oe(e);
|
|
1722
|
+
if (!n) {
|
|
1723
|
+
let t = ke();
|
|
1724
|
+
throw Error(`[caper] Unknown ui id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
|
|
1725
|
+
}
|
|
1726
|
+
let r = new n(t);
|
|
1727
|
+
if (t) {
|
|
1728
|
+
let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
|
|
1729
|
+
I({
|
|
1730
|
+
position: e,
|
|
1731
|
+
x: n,
|
|
1732
|
+
y: i
|
|
1733
|
+
}, r), L({
|
|
1734
|
+
scale: o,
|
|
1735
|
+
scaleX: s,
|
|
1736
|
+
scaleY: c
|
|
1737
|
+
}, r), z(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
|
|
1738
|
+
}
|
|
1739
|
+
return r;
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
n($);
|
|
1743
|
+
//#endregion
|
|
1744
|
+
export { A, I as C, ue as D, N as E, se as F, O as I, k as L, C as M, T as N, le as O, E as P, z as S, F as T, H as _, Ce as a, P as b, ve as c, K as d, he as f, U as g, W as h, Ee as i, w as j, j as k, ge as l, G as m, $ as n, J as o, me as p, ke as r, be as s, Me as t, q as u, V as v, L as w, R as x, B as y };
|
|
1745
|
+
|
|
1746
|
+
//# sourceMappingURL=const-C3sxeYhl.js.map
|