@caperjs/core 0.2.4 → 0.4.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/build/assetpack.mjs +90 -0
- package/build/index.mjs +3 -1
- package/build/internal/discovery.mjs +1 -1
- package/build/internal/manifest.mjs +8 -3
- package/build/internal/validate.mjs +3 -1
- package/build/plugins/assetTypes.mjs +4 -4
- package/build/plugins/caperConfig.mjs +12 -5
- package/build/plugins/lists.mjs +29 -9
- package/build/plugins/pruneFallbacks.mjs +25 -2
- package/cli/create.mjs +57 -6
- package/cli/create.test.mjs +36 -0
- package/cli/update.mjs +1 -1
- package/lib/{CaptionsPlugin-WPAcfAkx.js → CaptionsPlugin-cSJj-R9M.js} +5 -5
- package/lib/{CaptionsPlugin-WPAcfAkx.js.map → CaptionsPlugin-cSJj-R9M.js.map} +1 -1
- package/lib/{DataAdapter-DS-twowe.js → DataAdapter-D2tc6hx9.js} +15 -10
- package/lib/DataAdapter-D2tc6hx9.js.map +1 -0
- package/lib/{DebugRenderer-D1ryrRYx.js → DebugRenderer-CGUKy6Fy.js} +2 -2
- package/lib/{DebugRenderer-D1ryrRYx.js.map → DebugRenderer-CGUKy6Fy.js.map} +1 -1
- package/lib/{DevToolsPlugin-DH7zX7HU.js → DevToolsPlugin-B8GX3H9b.js} +2 -2
- package/lib/{DevToolsPlugin-DH7zX7HU.js.map → DevToolsPlugin-B8GX3H9b.js.map} +1 -1
- package/lib/{GSAPPlugin-BBtRjUqe.js → GSAPPlugin-Br9AjuTD.js} +6 -6
- package/lib/{GSAPPlugin-BBtRjUqe.js.map → GSAPPlugin-Br9AjuTD.js.map} +1 -1
- package/lib/{LayoutPlugin-Co6vcoV4.js → LayoutPlugin-BX3OP7pw.js} +4 -4
- package/lib/{LayoutPlugin-Co6vcoV4.js.map → LayoutPlugin-BX3OP7pw.js.map} +1 -1
- package/lib/{SpinePlugin-uN641Hmk.js → SpinePlugin-C-JDdXpf.js} +690 -793
- package/lib/SpinePlugin-C-JDdXpf.js.map +1 -0
- package/lib/{StatsPlugin-vZQRm6wh.js → StatsPlugin-yJlJtoQ2.js} +7 -7
- package/lib/StatsPlugin-yJlJtoQ2.js.map +1 -0
- package/lib/{VoiceOverPlugin-KlZdGj1G.js → VoiceOverPlugin-DjSZp4Ko.js} +7 -6
- package/lib/VoiceOverPlugin-DjSZp4Ko.js.map +1 -0
- package/lib/caper.mjs +159 -1917
- 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/Application.d.ts +8 -3
- package/lib/core/Application.d.ts.map +1 -1
- package/lib/core/Application.test.d.ts +2 -0
- package/lib/core/Application.test.d.ts.map +1 -0
- package/lib/core/config.d.ts +6 -1
- package/lib/core/config.d.ts.map +1 -1
- package/lib/core/config.test.d.ts +2 -0
- package/lib/core/config.test.d.ts.map +1 -0
- package/lib/core/create.d.ts.map +1 -1
- package/lib/core/interfaces/IApplication.d.ts +6 -6
- package/lib/core/interfaces/IApplication.d.ts.map +1 -1
- package/lib/core/interfaces/ICoreSignals.d.ts +2 -1
- package/lib/core/interfaces/ICoreSignals.d.ts.map +1 -1
- package/lib/display/Camera.test.d.ts +2 -0
- package/lib/display/Camera.test.d.ts.map +1 -0
- package/lib/display/Entity.d.ts +2 -2
- package/lib/display/SceneTransition.test.d.ts +1 -0
- package/lib/display/SceneTransition.test.d.ts.map +1 -0
- package/lib/display/SpineAnimation.d.ts +3 -3
- package/lib/mixins/factory/methods.d.ts.map +1 -1
- package/lib/padding-1kHDpGlQ.js +41 -0
- package/lib/padding-1kHDpGlQ.js.map +1 -0
- package/lib/plugins/AssetsPlugin.d.ts.map +1 -1
- package/lib/plugins/AssetsPlugin.test.d.ts +2 -0
- package/lib/plugins/AssetsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/DataAdapter.d.ts.map +1 -1
- package/lib/plugins/DataAdapter.test.d.ts +2 -0
- package/lib/plugins/DataAdapter.test.d.ts.map +1 -0
- package/lib/plugins/FullScreenPlugin.d.ts +0 -5
- package/lib/plugins/FullScreenPlugin.d.ts.map +1 -1
- package/lib/plugins/FullScreenPlugin.test.d.ts +2 -0
- package/lib/plugins/FullScreenPlugin.test.d.ts.map +1 -0
- package/lib/plugins/GSAPPlugin.d.ts +0 -2
- package/lib/plugins/GSAPPlugin.d.ts.map +1 -1
- package/lib/plugins/GSAPPlugin.test.d.ts +2 -0
- package/lib/plugins/GSAPPlugin.test.d.ts.map +1 -0
- package/lib/plugins/KeyboardPlugin.d.ts +0 -1
- package/lib/plugins/KeyboardPlugin.d.ts.map +1 -1
- package/lib/plugins/LookupPlugin.d.ts +6 -1
- package/lib/plugins/LookupPlugin.d.ts.map +1 -1
- package/lib/plugins/LookupPlugin.test.d.ts +2 -0
- package/lib/plugins/LookupPlugin.test.d.ts.map +1 -0
- package/lib/plugins/Plugin.d.ts +101 -2
- package/lib/plugins/Plugin.d.ts.map +1 -1
- package/lib/plugins/PopupManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/PopupManagerPlugin.test.d.ts +1 -0
- package/lib/plugins/PopupManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/SceneManagerPlugin.d.ts +1 -1
- package/lib/plugins/SceneManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/SceneManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/SceneManagerPlugin.test.d.ts.map +1 -0
- 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/actions/ActionsPlugin.test.d.ts +2 -0
- package/lib/plugins/actions/ActionsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/audio/AudioChannel.d.ts.map +1 -1
- package/lib/plugins/audio/AudioManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/audio/AudioManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/audio/AudioManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/audio/VoiceOverPlugin.d.ts.map +1 -1
- package/lib/plugins/breakpoints/BreakpointPlugin.d.ts.map +1 -1
- package/lib/plugins/captions/CaptionsPlugin.test.d.ts +2 -0
- package/lib/plugins/captions/CaptionsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/focus/FocusManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/focus/FocusManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/focus/FocusManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/gesture/GesturePlugin.d.ts.map +1 -1
- package/lib/plugins/input/AbstractControls.d.ts +47 -3
- package/lib/plugins/input/AbstractControls.d.ts.map +1 -1
- package/lib/plugins/input/Controls.test.d.ts +2 -0
- package/lib/plugins/input/Controls.test.d.ts.map +1 -0
- 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 +8 -14
- package/lib/plugins/input/touch/VirtualControls.d.ts.map +1 -1
- package/lib/plugins/input/touch/VirtualControls.test.d.ts +2 -0
- package/lib/plugins/input/touch/VirtualControls.test.d.ts.map +1 -0
- package/lib/{registries-BLrxALZ0.js → registries-BfV-VF7a.js} +665 -597
- package/lib/registries-BfV-VF7a.js.map +1 -0
- package/lib/store/Store.d.ts.map +1 -1
- package/lib/ui/Button.d.ts.map +1 -1
- package/lib/ui/UICanvas.d.ts +10 -1
- package/lib/ui/UICanvas.d.ts.map +1 -1
- package/lib/ui/UICanvas.test.d.ts +0 -1
- package/lib/ui/UICanvas.test.d.ts.map +1 -1
- package/lib/utils/color.d.ts.map +1 -1
- package/lib/utils/color.test.d.ts +2 -0
- package/lib/utils/color.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/core/Application.test.ts +168 -0
- package/src/core/Application.ts +37 -27
- package/src/core/config.test.ts +79 -0
- package/src/core/config.ts +28 -6
- package/src/core/create.ts +11 -0
- package/src/core/interfaces/IApplication.ts +6 -6
- package/src/core/interfaces/ICoreSignals.ts +2 -0
- package/src/display/Camera.test.ts +40 -0
- package/src/display/Camera.ts +3 -3
- package/src/display/Entity.ts +2 -2
- package/src/display/SceneTransition.test.ts +58 -0
- package/src/display/SceneTransition.ts +1 -1
- package/src/display/SpineAnimation.ts +4 -4
- package/src/mixins/factory/methods.ts +0 -1
- package/src/plugins/AssetsPlugin.test.ts +48 -0
- package/src/plugins/AssetsPlugin.ts +3 -1
- package/src/plugins/DataAdapter.test.ts +32 -0
- package/src/plugins/DataAdapter.ts +5 -1
- package/src/plugins/FullScreenPlugin.test.ts +48 -0
- package/src/plugins/FullScreenPlugin.ts +9 -18
- package/src/plugins/GSAPPlugin.test.ts +31 -0
- package/src/plugins/GSAPPlugin.ts +1 -4
- package/src/plugins/KeyboardPlugin.ts +3 -10
- package/src/plugins/LookupPlugin.test.ts +42 -0
- package/src/plugins/LookupPlugin.ts +15 -3
- package/src/plugins/Plugin.test.ts +130 -2
- package/src/plugins/Plugin.ts +159 -3
- package/src/plugins/PopupManagerPlugin.test.ts +53 -0
- package/src/plugins/PopupManagerPlugin.ts +5 -3
- package/src/plugins/SceneManagerPlugin.test.ts +76 -0
- package/src/plugins/SceneManagerPlugin.ts +18 -13
- package/src/plugins/StatsPlugin.ts +3 -2
- package/src/plugins/TimerPlugin.ts +1 -2
- package/src/plugins/WebEventsPlugin.test.ts +32 -0
- package/src/plugins/WebEventsPlugin.ts +9 -16
- package/src/plugins/actions/ActionsPlugin.test.ts +68 -0
- package/src/plugins/actions/ActionsPlugin.ts +5 -5
- package/src/plugins/audio/AudioChannel.test.ts +19 -0
- package/src/plugins/audio/AudioChannel.ts +8 -1
- package/src/plugins/audio/AudioManagerPlugin.test.ts +41 -0
- package/src/plugins/audio/AudioManagerPlugin.ts +3 -2
- package/src/plugins/audio/VoiceOverPlugin.ts +1 -0
- package/src/plugins/breakpoints/BreakpointPlugin.ts +1 -2
- package/src/plugins/captions/CaptionsPlugin.test.ts +40 -0
- package/src/plugins/captions/CaptionsPlugin.ts +2 -2
- package/src/plugins/focus/FocusManagerPlugin.test.ts +71 -0
- package/src/plugins/focus/FocusManagerPlugin.ts +7 -0
- package/src/plugins/gesture/GesturePlugin.ts +4 -8
- package/src/plugins/input/AbstractControls.ts +104 -3
- package/src/plugins/input/Controls.test.ts +205 -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.test.ts +38 -0
- package/src/plugins/input/touch/VirtualControls.ts +53 -120
- package/src/plugins/spine/SpinePlugin.ts +2 -2
- package/src/store/Store.test.ts +15 -0
- package/src/store/Store.ts +4 -1
- package/src/ui/Button.test.ts +12 -0
- package/src/ui/Button.ts +1 -0
- package/src/ui/UICanvas.test.ts +109 -6
- package/src/ui/UICanvas.ts +41 -3
- package/src/utils/color.test.ts +16 -0
- package/src/utils/color.ts +2 -1
- package/src/utils/platform.ts +1 -1
- package/src/version.ts +1 -1
- package/lib/DataAdapter-DS-twowe.js.map +0 -1
- package/lib/SpinePlugin-uN641Hmk.js.map +0 -1
- package/lib/StatsPlugin-vZQRm6wh.js.map +0 -1
- package/lib/VoiceOverPlugin-KlZdGj1G.js.map +0 -1
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts +0 -28
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts.map +0 -1
- package/lib/registries-BLrxALZ0.js.map +0 -1
- package/src/plugins/input/keyboard/KeyboardContols.ts +0 -182
package/lib/caper.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, H as ee, I as m, It as te, J as ne, K as h, L as g, Lt as re, M as ie, Mt as ae, N as _, Nt as v, O as oe, Ot as se, P as ce, Pt as le, Q as ue, R as de, Rt as fe, S as pe, St as me, T as he, Tt as ge, U as _e, V as ve, Vt as ye, W as be, X as xe, Y as Se, Z as Ce, _ as we, _t as Te, a as Ee, at as De, b as y, bt as Oe, c as ke, ct as Ae, d as je, dt as Me, et as Ne, f as b, ft as Pe, g as Fe, gt as Ie, h as Le, ht as Re, i as ze, it as Be, j as Ve, jt as He, k as Ue, kt as We, l as Ge, lt as Ke, m as qe, mt as Je, n as Ye, nt as Xe, o as Ze, ot as x, p as Qe, pt as $e, q as et, r as S, rt as tt, s as nt, st as rt, t as it, tt as at, u as ot, ut as st, v as C, vt as ct, w as lt, wt as ut, x as dt, xt as ft, y as pt, yt as mt, z as ht, zt as w } from "./registries-BfV-VF7a.js";
|
|
2
|
+
import { A as gt, C as _t, D as vt, E as yt, F as bt, I as xt, L as St, M as Ct, N as wt, O as Tt, P as Et, S as Dt, T as Ot, _ as T, a as kt, b as At, c as jt, d as Mt, f as Nt, g as E, h as Pt, i as Ft, j as It, k as Lt, l as Rt, m as zt, n as Bt, o as Vt, p as Ht, r as Ut, s as Wt, u as Gt, v as Kt, w as qt, x as Jt, y as Yt } from "./const-C3sxeYhl.js";
|
|
3
|
+
import { n as Xt, t as D } from "./padding-1kHDpGlQ.js";
|
|
4
|
+
import { r as Zt, t as Qt } from "./DataAdapter-D2tc6hx9.js";
|
|
5
|
+
import { CanvasTextMetrics as O, Container as $t, Graphics as k, Point as A, Polygon as en, Rectangle as tn, Sprite as nn, Texture as j, isMobile as M } from "pixi.js";
|
|
6
|
+
import { gsap as N } from "gsap";
|
|
5
7
|
//#region src/utils/array.ts
|
|
6
|
-
function
|
|
8
|
+
function rn(e) {
|
|
7
9
|
let t, n;
|
|
8
|
-
for (let r = 0; r < e.length; ++r) n =
|
|
10
|
+
for (let r = 0; r < e.length; ++r) n = w(0, e.length), t = e[r], e[r] = e[n], e[n] = t;
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
return e[
|
|
12
|
+
function an(e) {
|
|
13
|
+
return e[w(0, e.length)];
|
|
12
14
|
}
|
|
13
15
|
//#endregion
|
|
14
16
|
//#region src/utils/canvas.ts
|
|
15
|
-
function
|
|
17
|
+
function on(e) {
|
|
16
18
|
let t = e.getContext("webgl");
|
|
17
19
|
if (t) {
|
|
18
20
|
let e = t.getExtension("WEBGL_lose_context");
|
|
@@ -23,13 +25,13 @@ function jt(e) {
|
|
|
23
25
|
}
|
|
24
26
|
//#endregion
|
|
25
27
|
//#region src/utils/color.ts
|
|
26
|
-
function
|
|
28
|
+
function sn(e) {
|
|
27
29
|
return `#${e.toString(16)}`;
|
|
28
30
|
}
|
|
29
|
-
function
|
|
31
|
+
function cn(e) {
|
|
30
32
|
return parseInt(e.replace(/^#/, ""), 16);
|
|
31
33
|
}
|
|
32
|
-
var
|
|
34
|
+
var ln = class e {
|
|
33
35
|
static {
|
|
34
36
|
this.WHITE = new e(255, 255, 255);
|
|
35
37
|
}
|
|
@@ -67,7 +69,7 @@ var Pt = class e {
|
|
|
67
69
|
return e << 16 | t << 8 | n;
|
|
68
70
|
}
|
|
69
71
|
static rgbToHexString(e) {
|
|
70
|
-
let t = Number(e).toString(16);
|
|
72
|
+
let t = Math.max(0, Math.min(255, Math.round(Number(e)))).toString(16);
|
|
71
73
|
return t.length < 2 && (t = "0" + t), t;
|
|
72
74
|
}
|
|
73
75
|
static rgbToFullHexString(t, n, r) {
|
|
@@ -94,193 +96,106 @@ var Pt = class e {
|
|
|
94
96
|
this.b / 255
|
|
95
97
|
];
|
|
96
98
|
}
|
|
97
|
-
}, j = {
|
|
98
|
-
bounds: 65535,
|
|
99
|
-
innerBounds: 65280,
|
|
100
|
-
outerBounds: 16711680,
|
|
101
|
-
direction: 16776960,
|
|
102
|
-
gap: 16711935,
|
|
103
|
-
region: 30975
|
|
104
|
-
}, M = {
|
|
105
|
-
stroke: .6,
|
|
106
|
-
fill: .1,
|
|
107
|
-
fillActive: .2,
|
|
108
|
-
crosshair: .5
|
|
109
99
|
};
|
|
110
|
-
function Ft(e) {
|
|
111
|
-
let t = new E();
|
|
112
|
-
return t.eventMode = "none", t.interactiveChildren = !1, t.layout = !1, t.label = e ?? "DebugGraphics", t;
|
|
113
|
-
}
|
|
114
|
-
function N(e, t = j.bounds) {
|
|
115
|
-
let n = new O({
|
|
116
|
-
text: e,
|
|
117
|
-
style: {
|
|
118
|
-
fontFamily: "monospace",
|
|
119
|
-
fontSize: 10,
|
|
120
|
-
fill: t,
|
|
121
|
-
stroke: {
|
|
122
|
-
color: 0,
|
|
123
|
-
width: 2
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return n.eventMode = "none", n.layout = !1, n.label = "DebugLabel", n;
|
|
128
|
-
}
|
|
129
|
-
var It = /* @__PURE__ */ new Map();
|
|
130
|
-
function P(e, t, n) {
|
|
131
|
-
It.set(e, {
|
|
132
|
-
label: t,
|
|
133
|
-
color: n
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function F(e) {
|
|
137
|
-
It.delete(e);
|
|
138
|
-
}
|
|
139
|
-
function Lt() {
|
|
140
|
-
return It;
|
|
141
|
-
}
|
|
142
100
|
//#endregion
|
|
143
101
|
//#region src/utils/define.ts
|
|
144
|
-
function
|
|
102
|
+
function un(e) {
|
|
145
103
|
return e;
|
|
146
104
|
}
|
|
147
|
-
function
|
|
105
|
+
function dn(e) {
|
|
148
106
|
return e;
|
|
149
107
|
}
|
|
150
|
-
function
|
|
108
|
+
function fn(e) {
|
|
151
109
|
return e;
|
|
152
110
|
}
|
|
153
|
-
function
|
|
111
|
+
function pn(e) {
|
|
154
112
|
return e;
|
|
155
113
|
}
|
|
156
|
-
function
|
|
114
|
+
function mn(e) {
|
|
157
115
|
return e;
|
|
158
116
|
}
|
|
159
117
|
//#endregion
|
|
160
|
-
//#region src/utils/number.ts
|
|
161
|
-
function Ut(e, t = 0) {
|
|
162
|
-
return e.toString().padStart(t, "0");
|
|
163
|
-
}
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/utils/padding.ts
|
|
166
|
-
function Wt(e, t) {
|
|
167
|
-
return e >= 0 && e <= 1 ? e * t : e;
|
|
168
|
-
}
|
|
169
|
-
function I(e) {
|
|
170
|
-
if (Array.isArray(e)) return {
|
|
171
|
-
top: e[0],
|
|
172
|
-
right: e?.[1] ?? e[0],
|
|
173
|
-
bottom: e?.[2] ?? e[0],
|
|
174
|
-
left: e?.[3] ?? e?.[1] ?? e[0] ?? 0
|
|
175
|
-
};
|
|
176
|
-
if (typeof e == "number") return {
|
|
177
|
-
top: e,
|
|
178
|
-
right: e,
|
|
179
|
-
bottom: e,
|
|
180
|
-
left: e
|
|
181
|
-
};
|
|
182
|
-
if (typeof e == "object") {
|
|
183
|
-
let t = e;
|
|
184
|
-
return t.x !== void 0 && t.y !== void 0 ? {
|
|
185
|
-
top: t.y,
|
|
186
|
-
right: t.x,
|
|
187
|
-
bottom: t.y,
|
|
188
|
-
left: t.x
|
|
189
|
-
} : {
|
|
190
|
-
top: e.top ?? 0,
|
|
191
|
-
right: e.right ?? 0,
|
|
192
|
-
bottom: e.bottom ?? 0,
|
|
193
|
-
left: e.left ?? 0
|
|
194
|
-
};
|
|
195
|
-
} else return {
|
|
196
|
-
top: 0,
|
|
197
|
-
right: 0,
|
|
198
|
-
bottom: 0,
|
|
199
|
-
left: 0
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
118
|
//#region src/utils/pixi.ts
|
|
204
|
-
function
|
|
119
|
+
function hn(e, t) {
|
|
205
120
|
e.parent && e.parent.worldTransform.apply(e.position, e.position), t.worldTransform.applyInverse(e.position, e.position), e.parent?.removeChild(e), t.addChild(e);
|
|
206
121
|
}
|
|
207
|
-
function
|
|
122
|
+
function gn(e) {
|
|
208
123
|
return Math.sqrt(e.width * e.width + e.height * e.height);
|
|
209
124
|
}
|
|
210
|
-
function
|
|
125
|
+
function _n(e) {
|
|
211
126
|
let t = e.parent;
|
|
212
127
|
t && (t.removeChild(e), t.addChild(e));
|
|
213
128
|
}
|
|
214
|
-
function
|
|
129
|
+
function vn(e) {
|
|
215
130
|
let t = e.parent;
|
|
216
131
|
t && (t.removeChild(e), t.addChildAt(e, 0));
|
|
217
132
|
}
|
|
218
|
-
function
|
|
219
|
-
if (e instanceof
|
|
133
|
+
function yn(e, t) {
|
|
134
|
+
if (e instanceof en) {
|
|
220
135
|
for (let n = 0; n < e.points.length; n += 2) e.points[n] += t.x, e.points[n + 1] += t.y;
|
|
221
136
|
return e;
|
|
222
137
|
} else return e.x += t.x, e.y += t.y, e;
|
|
223
138
|
}
|
|
224
|
-
function
|
|
139
|
+
function bn(e, t) {
|
|
225
140
|
return e.x += t.x, e.y += t.y, e;
|
|
226
141
|
}
|
|
227
|
-
function
|
|
142
|
+
function P(e, t, n = "width") {
|
|
228
143
|
let r = n === "width" ? "y" : "x", i = n === "width" ? "x" : "y";
|
|
229
144
|
e[n] = t, e.scale[r] = e.scale[i];
|
|
230
145
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
146
|
+
function F(e, t) {
|
|
147
|
+
P(e, t, "width");
|
|
233
148
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
149
|
+
function I(e, t) {
|
|
150
|
+
P(e, t, "height");
|
|
236
151
|
}
|
|
237
|
-
function
|
|
152
|
+
function xn(e, t, n = "width") {
|
|
238
153
|
let r;
|
|
239
154
|
r = t?.width && t?.height ? {
|
|
240
155
|
x: t.width,
|
|
241
156
|
y: t.height
|
|
242
|
-
} :
|
|
157
|
+
} : x(t), n === "width" ? (F(e, r.x), e.height < r.y && I(e, r.y)) : (I(e, r.y), e.width < r.x && F(e, r.x));
|
|
243
158
|
}
|
|
244
159
|
//#endregion
|
|
245
160
|
//#region src/utils/platform.ts
|
|
246
|
-
var
|
|
161
|
+
var Sn = typeof window < "u" ? window.devicePixelRatio > 1 || window.matchMedia && window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)").matches : !1, L = typeof window < "u" ? "ontouchstart" in window || navigator.maxTouchPoints > 0 : !1, R = M.any, z = M.android.device, Cn = M.apple.device;
|
|
247
162
|
//#endregion
|
|
248
163
|
//#region src/utils/rect.ts
|
|
249
|
-
function
|
|
164
|
+
function wn(e, t) {
|
|
250
165
|
return e.x += t.x, e.y += t.y, e;
|
|
251
166
|
}
|
|
252
|
-
function
|
|
253
|
-
return t === void 0 && (t = new
|
|
167
|
+
function Tn(e, t) {
|
|
168
|
+
return t === void 0 && (t = new A()), t.set(e.x + e.width * .5, e.y + e.height * .5), t;
|
|
254
169
|
}
|
|
255
|
-
function
|
|
170
|
+
function En(e, t) {
|
|
256
171
|
return e.x *= t, e.y *= t, e.width *= t, e.height *= t, e;
|
|
257
172
|
}
|
|
258
|
-
function
|
|
259
|
-
return t === void 0 && (t = new
|
|
173
|
+
function Dn(e, t) {
|
|
174
|
+
return t === void 0 && (t = new A()), t.set(e.width, e.height), t;
|
|
260
175
|
}
|
|
261
176
|
//#endregion
|
|
262
177
|
//#region src/utils/set.ts
|
|
263
|
-
function
|
|
178
|
+
function On(e, t) {
|
|
264
179
|
let n = /* @__PURE__ */ new Set();
|
|
265
180
|
for (let r of e) t(r) && n.add(r);
|
|
266
181
|
return n;
|
|
267
182
|
}
|
|
268
|
-
function
|
|
183
|
+
function kn(e) {
|
|
269
184
|
return e?.values().next().value;
|
|
270
185
|
}
|
|
271
|
-
function
|
|
186
|
+
function An(e) {
|
|
272
187
|
let t;
|
|
273
188
|
for (let n of e) t = n;
|
|
274
189
|
return t;
|
|
275
190
|
}
|
|
276
191
|
//#endregion
|
|
277
192
|
//#region src/utils/text.ts
|
|
278
|
-
function
|
|
279
|
-
let n =
|
|
193
|
+
function B(e, t) {
|
|
194
|
+
let n = O.measureText(e.text, e.style), r = n.lines, i = n.lineHeight, a = e.toLocal(new A(t.pageX, t.pageY)), o = 0, s = Infinity, c = 0;
|
|
280
195
|
for (let t = 0; t < r.length; t++) {
|
|
281
196
|
let n = r[t];
|
|
282
197
|
for (let r = 0; r <= n.length; r++) {
|
|
283
|
-
let l = n.substring(0, r), u =
|
|
198
|
+
let l = n.substring(0, r), u = O.measureText(l, e.style).width, d = t * i, f = Math.hypot(u - a.x, d - a.y);
|
|
284
199
|
f < s && (s = f, o = c + r);
|
|
285
200
|
}
|
|
286
201
|
c += n.length;
|
|
@@ -289,35 +204,35 @@ function un(e, t) {
|
|
|
289
204
|
}
|
|
290
205
|
//#endregion
|
|
291
206
|
//#region src/version.ts
|
|
292
|
-
var
|
|
293
|
-
function
|
|
294
|
-
let e = `\n${
|
|
207
|
+
var V = "0.4.0", H = "8.19.0", jn = " ........ ..... ............ ............. ........... \n ............. ....... ................ ............. .............. \n .............. ......... ............... ............. .............. \n ..... ........... .............. ............ .............. \n ..... ...... ...... .............. ............. ............. \n .............. ...... ..... ............ ............. ..... ...... \n ................... ..... ..... ............. ..... ....... \n ................ .......... ............. ..... ..... ";
|
|
208
|
+
function U() {
|
|
209
|
+
let e = `\n${jn}\n\n v${V} | %cPixi.js v${H} %c| %chttps://github.com/anthonysapp/caper\n\n`;
|
|
295
210
|
console.log(e, "color: #E91E63; font-weight: 600;", "color: inherit;", "color: #00BCD4; text-decoration: underline;");
|
|
296
211
|
}
|
|
297
212
|
//#endregion
|
|
298
213
|
//#region src/webgl-check.ts
|
|
299
|
-
function
|
|
214
|
+
function Mn() {
|
|
300
215
|
if (typeof document > "u") return;
|
|
301
216
|
let e = document.createElement("canvas");
|
|
302
217
|
e.getContext("webgl") || e.getContext("experimental-webgl") || console.error("Your browser does not support WebGL.");
|
|
303
218
|
}
|
|
304
219
|
//#endregion
|
|
305
220
|
//#region src/plugins/actions/methods.ts
|
|
306
|
-
function
|
|
307
|
-
return e ??
|
|
221
|
+
function Nn(e) {
|
|
222
|
+
return e ?? _;
|
|
308
223
|
}
|
|
309
|
-
function
|
|
224
|
+
function Pn(e, t, n = !0) {
|
|
310
225
|
return n && (t = {
|
|
311
|
-
...
|
|
226
|
+
...m,
|
|
312
227
|
...t
|
|
313
228
|
}), t;
|
|
314
229
|
}
|
|
315
|
-
function
|
|
230
|
+
function Fn(e) {
|
|
316
231
|
return e || [];
|
|
317
232
|
}
|
|
318
233
|
//#endregion
|
|
319
234
|
//#region src/plugins/breakpoints/methods.ts
|
|
320
|
-
function
|
|
235
|
+
function In(e) {
|
|
321
236
|
return {
|
|
322
237
|
tiers: e.tiers,
|
|
323
238
|
modes: e.modes ?? {}
|
|
@@ -325,43 +240,43 @@ function yn(e) {
|
|
|
325
240
|
}
|
|
326
241
|
//#endregion
|
|
327
242
|
//#region src/plugins/input/touch/constants.ts
|
|
328
|
-
var
|
|
243
|
+
var W = /* @__PURE__ */ function(e) {
|
|
329
244
|
return e.None = "none", e.Left = "left", e.Top = "top", e.Bottom = "bottom", e.Right = "right", e.TopLeft = "top_left", e.TopRight = "top_right", e.BottomLeft = "bottom_left", e.BottomRight = "bottom_right", e;
|
|
330
|
-
}({}),
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
245
|
+
}({}), Ln = [
|
|
246
|
+
W.None,
|
|
247
|
+
W.Left,
|
|
248
|
+
W.Top,
|
|
249
|
+
W.Bottom,
|
|
250
|
+
W.Right,
|
|
251
|
+
W.TopLeft,
|
|
252
|
+
W.TopRight,
|
|
253
|
+
W.BottomLeft,
|
|
254
|
+
W.BottomRight
|
|
340
255
|
];
|
|
341
256
|
//#endregion
|
|
342
257
|
//#region src/plugins/input/methods.ts
|
|
343
|
-
function
|
|
258
|
+
function Rn(e, t, n) {
|
|
344
259
|
return n || [];
|
|
345
260
|
}
|
|
346
261
|
//#endregion
|
|
347
262
|
//#region src/core/globals.ts
|
|
348
|
-
var
|
|
349
|
-
function
|
|
263
|
+
var G = 200, zn = "CaperApplication";
|
|
264
|
+
function Bn() {
|
|
350
265
|
try {
|
|
351
266
|
return globalThis.Caper?.__dev === !0;
|
|
352
267
|
} catch {
|
|
353
268
|
return !1;
|
|
354
269
|
}
|
|
355
270
|
}
|
|
356
|
-
function
|
|
271
|
+
function Vn() {
|
|
357
272
|
try {
|
|
358
273
|
return !1;
|
|
359
274
|
} catch {
|
|
360
275
|
return !1;
|
|
361
276
|
}
|
|
362
277
|
}
|
|
363
|
-
var
|
|
364
|
-
function
|
|
278
|
+
var K = "__first__";
|
|
279
|
+
function q() {
|
|
365
280
|
let e = globalThis, t = e.Caper ||= {};
|
|
366
281
|
return t.apps instanceof Map || (t.apps = /* @__PURE__ */ new Map()), (typeof t.automation != "object" || t.automation === null) && (t.automation = {}), t.__readyResolvers instanceof Map || (t.__readyResolvers = /* @__PURE__ */ new Map()), t.__readyApps instanceof Set || (t.__readyApps = /* @__PURE__ */ new Set()), typeof t.ready != "function" && (t.ready = (e) => {
|
|
367
282
|
let n = t.__readyResolvers, r = t.__readyApps;
|
|
@@ -370,7 +285,7 @@ function Dn() {
|
|
|
370
285
|
let e = r.values().next().value;
|
|
371
286
|
return Promise.resolve(t.apps.get(e));
|
|
372
287
|
}
|
|
373
|
-
let i = e ??
|
|
288
|
+
let i = e ?? K, a = n.get(i);
|
|
374
289
|
if (!a) {
|
|
375
290
|
let e, t = new Promise((t) => {
|
|
376
291
|
e = t;
|
|
@@ -383,15 +298,15 @@ function Dn() {
|
|
|
383
298
|
return a.promise;
|
|
384
299
|
}), t;
|
|
385
300
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
301
|
+
function Hn() {
|
|
302
|
+
q();
|
|
388
303
|
}
|
|
389
|
-
function
|
|
390
|
-
return e.config?.id ||
|
|
304
|
+
function J(e) {
|
|
305
|
+
return e.config?.id || zn;
|
|
391
306
|
}
|
|
392
|
-
function
|
|
393
|
-
let t =
|
|
394
|
-
n.push(e), n.length >
|
|
307
|
+
function Un(e) {
|
|
308
|
+
let t = J(e), n = [], r, i = [], a = (e) => {
|
|
309
|
+
n.push(e), n.length > G && n.splice(0, n.length - G);
|
|
395
310
|
}, o = () => r ? r() : void 0, s = (e) => {
|
|
396
311
|
if (i.length !== 0) for (let t = i.length - 1; t >= 0; t--) {
|
|
397
312
|
let n = !1;
|
|
@@ -461,88 +376,60 @@ function An(e) {
|
|
|
461
376
|
});
|
|
462
377
|
})), c;
|
|
463
378
|
}
|
|
464
|
-
function
|
|
465
|
-
let t =
|
|
466
|
-
if (t.apps.set(n, e), t.app = e,
|
|
467
|
-
let r =
|
|
379
|
+
function Y(e) {
|
|
380
|
+
let t = q(), n = J(e);
|
|
381
|
+
if (t.apps.set(n, e), t.app = e, Bn() || e.config?.automation === !0 || Vn()) {
|
|
382
|
+
let r = Un(e);
|
|
468
383
|
t.automation[n] = r, e.automation = r;
|
|
469
384
|
}
|
|
470
385
|
}
|
|
471
|
-
function
|
|
472
|
-
let t =
|
|
386
|
+
function X(e) {
|
|
387
|
+
let t = q(), n = J(e);
|
|
473
388
|
t.__readyApps.add(n);
|
|
474
389
|
let r = t.__readyResolvers, i = r.get(n);
|
|
475
390
|
i && (i.resolve(e), r.delete(n));
|
|
476
|
-
let a = r.get(
|
|
477
|
-
a && (a.resolve(e), r.delete(
|
|
391
|
+
let a = r.get(K);
|
|
392
|
+
a && (a.resolve(e), r.delete(K));
|
|
478
393
|
}
|
|
479
394
|
//#endregion
|
|
480
395
|
//#region src/core/create.ts
|
|
481
|
-
var
|
|
482
|
-
function
|
|
396
|
+
var Wn = "caper-game-container";
|
|
397
|
+
function Z(e) {
|
|
483
398
|
let t = document.createElement("div");
|
|
484
399
|
return t.setAttribute("id", e), document.body.appendChild(t), t;
|
|
485
400
|
}
|
|
486
|
-
async function
|
|
401
|
+
async function Gn() {
|
|
487
402
|
return new Promise((e) => {
|
|
488
403
|
document.readyState === "complete" || document.readyState === "interactive" ? e(!0) : document.addEventListener("DOMContentLoaded", () => {
|
|
489
404
|
e(!0);
|
|
490
405
|
});
|
|
491
406
|
});
|
|
492
407
|
}
|
|
493
|
-
async function
|
|
494
|
-
await
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
408
|
+
async function Kn(e = { id: "CaperApplication" }, t = Wn, n = !0) {
|
|
409
|
+
let { defaultFactoryMethods: r } = await import("./const-C3sxeYhl.js").then((e) => e.t);
|
|
410
|
+
ne(r), await Gn(), Mn(), n && U();
|
|
411
|
+
let i = null;
|
|
412
|
+
if (typeof t == "string" ? (i = document.getElementById(t), i ||= Z(t)) : t instanceof HTMLElement ? i = t : t === window && (i = document.body), !i) throw Error("You passed in a DOM Element, but none was found. If you instead pass in a string, a container will be created for you, using the string for its id.");
|
|
413
|
+
e.resizeToContainer && (e.resizeTo = i), e.useLayout && (e.layout = {
|
|
498
414
|
autoUpdate: !1,
|
|
499
415
|
enableDebug: !1,
|
|
500
416
|
debugModificationCount: 0,
|
|
501
417
|
throttle: 100
|
|
502
|
-
}), e.container =
|
|
503
|
-
let
|
|
504
|
-
return await
|
|
418
|
+
}), e.container = i;
|
|
419
|
+
let a = new (e.application || S)();
|
|
420
|
+
return await a.initialize(e, i), e.useLayout && (a.stage.layout = {
|
|
505
421
|
position: "absolute",
|
|
506
422
|
width: "100%",
|
|
507
423
|
height: "100%"
|
|
508
|
-
}), await
|
|
424
|
+
}), await a._postInitialize(), Y(a), globalThis.Caper?.__runtimeManaged || X(a), a;
|
|
509
425
|
}
|
|
510
426
|
//#endregion
|
|
511
427
|
//#region src/display/Entity.ts
|
|
512
|
-
var
|
|
428
|
+
var qn = class extends b {
|
|
513
429
|
constructor(e) {
|
|
514
430
|
super(), this.props = e ?? {};
|
|
515
431
|
}
|
|
516
|
-
},
|
|
517
|
-
autoUpdate: !0,
|
|
518
|
-
priority: 0
|
|
519
|
-
}, Bn = class extends Ct {
|
|
520
|
-
static {
|
|
521
|
-
this.__caper_method_binding_root = !0;
|
|
522
|
-
}
|
|
523
|
-
constructor(e = {}) {
|
|
524
|
-
super(e), this.onDestroy = new p(), this.__config = {
|
|
525
|
-
...zn,
|
|
526
|
-
...e
|
|
527
|
-
}, m(this), this.on("added", this._added), this.on("removed", this._removed);
|
|
528
|
-
}
|
|
529
|
-
get app() {
|
|
530
|
-
return S.getInstance();
|
|
531
|
-
}
|
|
532
|
-
update(e) {}
|
|
533
|
-
resize(e) {}
|
|
534
|
-
added() {}
|
|
535
|
-
destroy(e) {
|
|
536
|
-
this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.onDestroy.emit(), super.destroy(e);
|
|
537
|
-
}
|
|
538
|
-
removed() {}
|
|
539
|
-
_added() {
|
|
540
|
-
this.__config.autoUpdate && this.app.ticker.add(this.update, this, this.__config.priority), this.added();
|
|
541
|
-
}
|
|
542
|
-
_removed() {
|
|
543
|
-
this.__config.autoUpdate && this.app.ticker.remove(this.update, this), this.removed();
|
|
544
|
-
}
|
|
545
|
-
}, Vn = class extends _ {
|
|
432
|
+
}, Jn = class extends b {
|
|
546
433
|
get animationContext() {
|
|
547
434
|
return this._animationContext ?? `__scene_${this.id}`;
|
|
548
435
|
}
|
|
@@ -577,7 +464,7 @@ var Ln = class extends _ {
|
|
|
577
464
|
}
|
|
578
465
|
onPause(e) {}
|
|
579
466
|
onResume(e) {}
|
|
580
|
-
},
|
|
467
|
+
}, Yn = class extends b {
|
|
581
468
|
get active() {
|
|
582
469
|
return this._active;
|
|
583
470
|
}
|
|
@@ -595,7 +482,7 @@ var Ln = class extends _ {
|
|
|
595
482
|
autoResize: !0,
|
|
596
483
|
autoUpdate: !1,
|
|
597
484
|
priority: -9999
|
|
598
|
-
}), this.initialized = !1, this._active = !1, e && this.app.ticker.add(this._update), this.addSignalConnection(this.app.assets.onLoadStart.connect(this.handleLoadStart), this.app.assets.onLoadProgress.connect(this.handleLoadProgress), this.app.assets.
|
|
485
|
+
}), this.initialized = !1, this._active = !1, e && this.app.ticker.add(this._update), this.addSignalConnection(this.app.assets.onLoadStart.connect(this.handleLoadStart), this.app.assets.onLoadProgress.connect(this.handleLoadProgress), this.app.assets.onLoadComplete.connect(this.handleLoadComplete));
|
|
599
486
|
}
|
|
600
487
|
async initialize() {
|
|
601
488
|
return Promise.resolve();
|
|
@@ -618,163 +505,9 @@ var Ln = class extends _ {
|
|
|
618
505
|
_update(e) {
|
|
619
506
|
this.active && this.initialized && this.update(e);
|
|
620
507
|
}
|
|
621
|
-
},
|
|
508
|
+
}, Xn = class extends $t {
|
|
622
509
|
constructor(e) {
|
|
623
|
-
super(
|
|
624
|
-
let t = this.getLocalBounds();
|
|
625
|
-
this.pivot.set((t.x + t.width) / 2, (t.y + t.height) / 2);
|
|
626
|
-
}
|
|
627
|
-
}, Wn;
|
|
628
|
-
function H(e, t) {
|
|
629
|
-
for (let n in e) try {
|
|
630
|
-
t[n] = e[n];
|
|
631
|
-
} catch (e) {
|
|
632
|
-
c.warn(`Error setting property ${n}`, e);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
function U() {
|
|
636
|
-
if (!Wn) {
|
|
637
|
-
let e = new E();
|
|
638
|
-
e.rect(0, 0, 100, 100), e.fill({ color: 16711680 }), e.stroke({
|
|
639
|
-
color: 16777215,
|
|
640
|
-
width: 1,
|
|
641
|
-
alignment: 0
|
|
642
|
-
}), e.moveTo(0, 0), e.lineTo(100, 100), e.moveTo(100, 0), e.lineTo(0, 100), e.stroke({
|
|
643
|
-
color: 16777215,
|
|
644
|
-
width: 2,
|
|
645
|
-
alignment: .5
|
|
646
|
-
}), Wn = S.getInstance().renderer.generateTexture(e), e.destroy();
|
|
647
|
-
}
|
|
648
|
-
return Wn;
|
|
649
|
-
}
|
|
650
|
-
function W(e) {
|
|
651
|
-
let t, n = e?.asset, r = n, i = e?.sheet;
|
|
652
|
-
if (n instanceof k) t = n;
|
|
653
|
-
else if (!i || i?.length === 0) C.cache.has(r) ? t = C.get(r) : C.get(r) ? t = C.get(r).texture : (c.error("Asset \"" + n + "\" not loaded into Pixi cache"), t = U());
|
|
654
|
-
else if (C.get(i)) {
|
|
655
|
-
let e = C.get(i), a = e.textures;
|
|
656
|
-
if (a !== void 0) if (a.hasOwnProperty(r)) t = a[r];
|
|
657
|
-
else if (e.linkedSheets !== void 0 && e.linkedSheets.length > 0) {
|
|
658
|
-
for (let n of e.linkedSheets) if (n.textures !== void 0 && n.textures.hasOwnProperty(r)) {
|
|
659
|
-
t = n.textures[r];
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
t === void 0 && (c.error("Asset \"" + n + "\" not found inside spritesheet \"" + n + "' or any of its linked sheets"), t = U());
|
|
663
|
-
} else c.error("Asset \"" + n + "\" not found inside spritesheet \"" + i + "'"), t = U();
|
|
664
|
-
else c.error("Spritesheet \"" + i + "\" loaded but textures arent?!"), t = U();
|
|
665
|
-
} else return c.error("Spritesheet \"" + i + "\" not loaded into Pixi cache"), U();
|
|
666
|
-
return t || new Et().texture;
|
|
667
|
-
}
|
|
668
|
-
function G(e, t) {
|
|
669
|
-
let n = y(e.position, !1, e.x, e.y);
|
|
670
|
-
t.x = n.x, t.y = n.y;
|
|
671
|
-
}
|
|
672
|
-
function K(e, t) {
|
|
673
|
-
if (!e) return;
|
|
674
|
-
if (e.scale === void 0) {
|
|
675
|
-
if (e.scaleX === void 0 && e.scaleY === void 0) return;
|
|
676
|
-
e.scaleX === void 0 && (e.scaleX = 1), e.scaleY === void 0 && (e.scaleY = 1);
|
|
677
|
-
}
|
|
678
|
-
let n = y(e.scale, !1, e.scaleX, e.scaleY);
|
|
679
|
-
t.scale.set(n.x, n.y);
|
|
680
|
-
}
|
|
681
|
-
function Gn(e, t) {
|
|
682
|
-
if (e !== void 0) {
|
|
683
|
-
let n = y(e);
|
|
684
|
-
t.anchor.set(n.x, n.y);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
function q(e, t) {
|
|
688
|
-
if (e !== void 0) {
|
|
689
|
-
let n = y(e);
|
|
690
|
-
t.pivot.set(n.x, n.y);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
//#endregion
|
|
694
|
-
//#region src/display/AnimatedSprite.ts
|
|
695
|
-
var Kn = class e extends bt {
|
|
696
|
-
constructor(t) {
|
|
697
|
-
let n = t?.animations ?? {}, r = t?.animation ?? Object.keys(n)[0], i = n[r], a = t?.sheet, o = t?.texturePrefix || "", s = t?.zeroPad, c = t?.startIndex ?? 0;
|
|
698
|
-
super(e.generateTexturesFromProps(r, i, o, a, s, c), t?.autoUpdate !== !1), this.config = t, this.onAnimationChange = new p(), this.onAnimationStart = new p(), this.onAnimationStop = new p(), this.onAnimationLoop = new p(), this.onAnimationComplete = new p(), this.onAnimationFrameChange = new p(), this.defaultTexturePrefix = "", this._paused = !1, this._isReversed = !1, m(this), this.defaultSheet = a, this.defaultTexturePrefix = o, this.defaultZeroPad = s, this._generateAnimations(), this.currentAnimation = this.defaultAnimation = r, this.autoPlay = t?.autoPlay ?? !0, this.loop = t?.loop ?? !0, this.updateAnchor = t?.updateAnchor ?? !1, this.animationSpeed = this.defaultAnimationSpeed = t?.animationSpeed ?? 1, this.on("added", this._added);
|
|
699
|
-
}
|
|
700
|
-
get paused() {
|
|
701
|
-
return this._paused;
|
|
702
|
-
}
|
|
703
|
-
set paused(e) {
|
|
704
|
-
this._paused = e;
|
|
705
|
-
}
|
|
706
|
-
get speed() {
|
|
707
|
-
return this.animationSpeed;
|
|
708
|
-
}
|
|
709
|
-
set speed(e) {
|
|
710
|
-
this.animationSpeed = this.defaultAnimationSpeed = e;
|
|
711
|
-
}
|
|
712
|
-
get isReversed() {
|
|
713
|
-
return this._isReversed;
|
|
714
|
-
}
|
|
715
|
-
static generateTexturesFromProps(e, t, n = "", r = void 0, i, a) {
|
|
716
|
-
let o = [], s = "", c = t?.sheet ?? r;
|
|
717
|
-
if (t?.numFrames > 1) {
|
|
718
|
-
let r = t?.startIndex ?? a ?? 0;
|
|
719
|
-
for (let a = r; a < r + t?.numFrames; a++) s = `${n}${t?.texturePrefix ?? e}${Ut(a, t?.zeroPad ?? i)}`, o.push(W({
|
|
720
|
-
asset: s,
|
|
721
|
-
sheet: c
|
|
722
|
-
}));
|
|
723
|
-
} else s = `${n}${t?.texturePrefix ?? e}`, o.push(W({
|
|
724
|
-
asset: s,
|
|
725
|
-
sheet: c
|
|
726
|
-
}));
|
|
727
|
-
return o;
|
|
728
|
-
}
|
|
729
|
-
reverse() {
|
|
730
|
-
this._isReversed = !this._isReversed, this._isReversed ? this.setAnimation(`${this.currentAnimation}_reverse`) : this.setAnimation(this.currentAnimation.split("_reverse")[0]);
|
|
731
|
-
}
|
|
732
|
-
setAnimation(e, t = !0) {
|
|
733
|
-
if (!this._animations.has(e)) throw Error(`Animation ${e} does not exist`);
|
|
734
|
-
this.textures = this._animations.get(e), this.currentAnimation = e;
|
|
735
|
-
let n = this.config?.animations?.[e.split("_reverse")[0]]?.animationSpeed;
|
|
736
|
-
n ? this.animationSpeed = n : this.animationSpeed = this.defaultAnimationSpeed, this.onAnimationChange.emit(e), t && this.play();
|
|
737
|
-
}
|
|
738
|
-
play() {
|
|
739
|
-
super.play(), this.onAnimationStart?.emit();
|
|
740
|
-
}
|
|
741
|
-
stop() {
|
|
742
|
-
super.stop(), this.onAnimationStop?.emit();
|
|
743
|
-
}
|
|
744
|
-
nextAnimation() {
|
|
745
|
-
let e = lt(this._animations, this.currentAnimation) ?? ze(this._animations);
|
|
746
|
-
e && this.setAnimation(e[0]);
|
|
747
|
-
}
|
|
748
|
-
previousAnimation() {
|
|
749
|
-
let e = ht(this._animations, this.currentAnimation) ?? ke(this._animations);
|
|
750
|
-
e && this.setAnimation(e[0]);
|
|
751
|
-
}
|
|
752
|
-
update(e) {
|
|
753
|
-
this._paused || super.update(e);
|
|
754
|
-
}
|
|
755
|
-
_generateAnimations() {
|
|
756
|
-
this._animations = /* @__PURE__ */ new Map();
|
|
757
|
-
let t = this.config?.animations ?? {};
|
|
758
|
-
if (t) {
|
|
759
|
-
for (let [n, r] of Object.entries(t)) this._animations.set(n, e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad));
|
|
760
|
-
if (this.config?.reversible) for (let [n, r] of Object.entries(t)) {
|
|
761
|
-
let t = e.generateTexturesFromProps(n, r, this.defaultTexturePrefix, this.defaultSheet, this.defaultZeroPad);
|
|
762
|
-
t.reverse(), this._animations.set(`${n}_reverse`, t);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
_added() {
|
|
767
|
-
this.onLoop = () => {
|
|
768
|
-
this.onAnimationLoop.emit();
|
|
769
|
-
}, this.onComplete = () => {
|
|
770
|
-
this.onAnimationComplete.emit();
|
|
771
|
-
}, this.onFrameChange = () => {
|
|
772
|
-
this.onAnimationFrameChange.emit();
|
|
773
|
-
}, this.autoPlay && this.play();
|
|
774
|
-
}
|
|
775
|
-
}, qn = class extends xt {
|
|
776
|
-
constructor(e) {
|
|
777
|
-
return super({ isRenderGroup: !0 }), this.config = e, this.onZoom = new p(), this.onZoomComplete = new p(), this.minX = 0, this.minY = 0, this._zooming = !1, this._zoomLerp = .1, this._targetPivot = new D(0, 0), this._targetScale = new D(1, 1), this._lerp = 0, this._target = null, this._followOffset = new D(0, 0), m(this), e && (this.container = e.container, this.addChild(this.container), e.minX && (this.minX = e.minX), e.maxX && (this.maxX = e.maxX), e.minY && (this.minY = e.minY), this.viewportWidth = e.viewportWidth ?? this.app.size.width, this.viewportHeight = e.viewportHeight ?? this.app.size.width, this.worldWidth = e.worldWidth ?? this.viewportWidth, this.worldHeight = e.worldHeight ?? this.viewportHeight, this.maxX = e.maxX ?? this.worldWidth - this.viewportWidth, this.maxY = e.maxY ?? this.worldHeight - this.viewportHeight), this._targetPivot.set(this.viewportWidth * .5, this.viewportHeight * .5), e.target && (this.target = e.target), this._lerp = 1, this.update(), e.lerp && (this.lerp = e.lerp), this;
|
|
510
|
+
return super({ isRenderGroup: !0 }), this.config = e, this.onZoom = new p(), this.onZoomComplete = new p(), this.minX = 0, this.minY = 0, this._zooming = !1, this._zoomLerp = .1, this._targetPivot = new A(0, 0), this._targetScale = new A(1, 1), this._lerp = 0, this._target = null, this._followOffset = new A(0, 0), v(this), e && (this.container = e.container, this.addChild(this.container), e.minX && (this.minX = e.minX), e.maxX && (this.maxX = e.maxX), e.minY && (this.minY = e.minY), this.viewportWidth = e.viewportWidth ?? this.app.size.width, this.viewportHeight = e.viewportHeight ?? this.app.size.height, this.worldWidth = e.worldWidth ?? this.viewportWidth, this.worldHeight = e.worldHeight ?? this.viewportHeight, this.maxX = e.maxX ?? this.worldWidth - this.viewportWidth, this.maxY = e.maxY ?? this.worldHeight - this.viewportHeight), this._targetPivot.set(this.viewportWidth * .5, this.viewportHeight * .5), e.target && (this.target = e.target), this._lerp = 1, this.update(), e.lerp && (this.lerp = e.lerp), this;
|
|
778
511
|
}
|
|
779
512
|
get zooming() {
|
|
780
513
|
return this._zooming;
|
|
@@ -786,7 +519,7 @@ var Kn = class e extends bt {
|
|
|
786
519
|
return this._targetPivot;
|
|
787
520
|
}
|
|
788
521
|
get targetScale() {
|
|
789
|
-
return this.
|
|
522
|
+
return this._targetScale;
|
|
790
523
|
}
|
|
791
524
|
get lerp() {
|
|
792
525
|
return this._lerp;
|
|
@@ -805,7 +538,7 @@ var Kn = class e extends bt {
|
|
|
805
538
|
return this._followOffset;
|
|
806
539
|
}
|
|
807
540
|
set followOffset(e) {
|
|
808
|
-
this._followOffset =
|
|
541
|
+
this._followOffset = x(e, !0);
|
|
809
542
|
}
|
|
810
543
|
get app() {
|
|
811
544
|
return S.getInstance();
|
|
@@ -845,9 +578,9 @@ var Kn = class e extends bt {
|
|
|
845
578
|
} else this.pivot.set(this._targetPivot.x, this._targetPivot.y);
|
|
846
579
|
this.position.set(this.viewportWidth / 2, this.viewportHeight / 2);
|
|
847
580
|
}
|
|
848
|
-
},
|
|
581
|
+
}, Zn = class {
|
|
849
582
|
constructor(e, t) {
|
|
850
|
-
this.camera = e, this.interactiveArea = t, this.dragging = !1, this.previousPointerPosition = null,
|
|
583
|
+
this.camera = e, this.interactiveArea = t, this.dragging = !1, this.previousPointerPosition = null, v(this), this.camera = e, this.interactiveArea = t, this.app.keyboard.onKeyDown().connect(this.handleKeyDown), this.interactiveArea.on("pointerdown", this.onPointerDown.bind(this)), this.interactiveArea.on("pointermove", this.onPointerMove.bind(this)), this.app.stage.on("pointerup", this.onPointerUp.bind(this)), this.app.stage.on("pointerupoutside", this.onPointerUp.bind(this)), this.interactiveArea.on("touchstart", this.onPointerDown.bind(this)), this.interactiveArea.on("touchmove", this.onPointerMove.bind(this)), this.interactiveArea.on("touchend", this.onPointerUp.bind(this));
|
|
851
584
|
}
|
|
852
585
|
get app() {
|
|
853
586
|
return S.getInstance();
|
|
@@ -890,1506 +623,15 @@ var Kn = class e extends bt {
|
|
|
890
623
|
this.dragging = !1, this.previousPointerPosition = null;
|
|
891
624
|
}
|
|
892
625
|
getEventPosition(e) {
|
|
893
|
-
return e instanceof TouchEvent ? new
|
|
894
|
-
}
|
|
895
|
-
}, Yn = h(v()), Xn = class extends Yn {
|
|
896
|
-
get app() {
|
|
897
|
-
return S.getInstance();
|
|
898
|
-
}
|
|
899
|
-
get animationNames() {
|
|
900
|
-
return this.spine.state.data.skeletonData.animations.map((e) => e.name);
|
|
901
|
-
}
|
|
902
|
-
get currentEntry() {
|
|
903
|
-
return this.spine.state.getCurrent(0);
|
|
904
|
-
}
|
|
905
|
-
get elapsedAnimationTime() {
|
|
906
|
-
return this.currentEntry ? this.currentEntry.trackTime : -1;
|
|
907
|
-
}
|
|
908
|
-
constructor(e) {
|
|
909
|
-
super(), this.onAnimationComplete = new p(), this.onAnimationStart = new p(), this.onAnimationInterrupt = new p(), this.onAnimationDispose = new p(), this.onAnimationEnd = new p(), this.onAnimationEvent = new p(), this.onPaused = new p(), this.onResumed = new p(), m(this);
|
|
910
|
-
let t = e?.data, n = "";
|
|
911
|
-
if (typeof t == "string") {
|
|
912
|
-
let e = t.slice(-5);
|
|
913
|
-
e !== ".json" && e !== ".skel" ? e = ".json" : t = t.substring(0, t.length - 5), n = {
|
|
914
|
-
skeleton: t + e,
|
|
915
|
-
atlas: t + ".atlas"
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
this.spine = window.Spine.from(n), 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 = {
|
|
919
|
-
start: this._handleAnimationStart,
|
|
920
|
-
interrupt: this._handleAnimationInterrupt,
|
|
921
|
-
dispose: this._handleAnimationDispose,
|
|
922
|
-
end: this._handleAnimationEnd,
|
|
923
|
-
event: this._handleAnimationEvent,
|
|
924
|
-
complete: this._handleAnimationComplete
|
|
925
|
-
}, this.spine.state.addListener(this._stateListener);
|
|
926
|
-
}
|
|
927
|
-
destroy() {
|
|
928
|
-
this.spine.state.removeListener(this._stateListener), super.destroy();
|
|
929
|
-
}
|
|
930
|
-
getCurrentAnimation(e = 0) {
|
|
931
|
-
return this.spine.state.getCurrent(e)?.animation?.name || "";
|
|
932
|
-
}
|
|
933
|
-
setAnimation(e, t = !1, n = 0) {
|
|
934
|
-
this.spine.state.setAnimation(n, e, t);
|
|
935
|
-
}
|
|
936
|
-
pause() {
|
|
937
|
-
this.paused = !0, this.spine.autoUpdate = !1, this.currentEntry && (this.currentEntry.timeScale = 0), this.onPaused.emit(this.currentEntry);
|
|
938
|
-
}
|
|
939
|
-
resume() {
|
|
940
|
-
this.paused = !1, this.spine.autoUpdate = !0, this.currentEntry && (this.currentEntry.timeScale = 1), this.onResumed.emit(this.currentEntry);
|
|
941
|
-
}
|
|
942
|
-
togglePause() {
|
|
943
|
-
this.paused ? this.resume() : this.pause();
|
|
944
|
-
}
|
|
945
|
-
_handleAnimationComplete(e) {
|
|
946
|
-
this.onAnimationComplete.emit(e);
|
|
947
|
-
}
|
|
948
|
-
_handleAnimationStart(e) {
|
|
949
|
-
this.onAnimationStart.emit(e);
|
|
950
|
-
}
|
|
951
|
-
_handleAnimationInterrupt(e) {
|
|
952
|
-
this.onAnimationInterrupt.emit(e);
|
|
953
|
-
}
|
|
954
|
-
_handleAnimationDispose(e) {
|
|
955
|
-
this.onAnimationDispose.emit(e);
|
|
956
|
-
}
|
|
957
|
-
_handleAnimationEnd(e) {
|
|
958
|
-
this.onAnimationEnd.emit(e);
|
|
959
|
-
}
|
|
960
|
-
_handleAnimationEvent(e, t) {
|
|
961
|
-
this.onAnimationEvent.emit(e, t);
|
|
962
|
-
}
|
|
963
|
-
};
|
|
964
|
-
//#endregion
|
|
965
|
-
//#region src/mixins/focus.ts
|
|
966
|
-
function J(e) {
|
|
967
|
-
return class extends e {
|
|
968
|
-
constructor(...e) {
|
|
969
|
-
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 p(), this.onFocusIn = new p(), this.onFocusOut = new p(), this.onBlur = new p(), 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);
|
|
970
|
-
}
|
|
971
|
-
get app() {
|
|
972
|
-
return S.getInstance();
|
|
973
|
-
}
|
|
974
|
-
destroy(e) {
|
|
975
|
-
this.off("mouseover", this._onMouseOver), this.off("mousedown", this._onMouseDown), this.off("click", this._handleClick), this.off("tap", this._handleClick), super.destroy(e);
|
|
976
|
-
}
|
|
977
|
-
focusIn() {
|
|
978
|
-
this.app.focus.active && this.emit("pointerover", { type: "pointerover" });
|
|
979
|
-
}
|
|
980
|
-
blur() {
|
|
981
|
-
this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this));
|
|
982
|
-
}
|
|
983
|
-
focusOut() {
|
|
984
|
-
this.isKeyDown || window.removeEventListener("keyup", this._handleKeyUp.bind(this)), this.app.focus.active && this.emit("pointerout", { type: "pointerout" });
|
|
985
|
-
}
|
|
986
|
-
click() {}
|
|
987
|
-
getFocusPosition() {
|
|
988
|
-
return null;
|
|
989
|
-
}
|
|
990
|
-
getFocusArea() {
|
|
991
|
-
return this.getBounds();
|
|
992
|
-
}
|
|
993
|
-
getFocusSize() {
|
|
994
|
-
return [this.getFocusArea().width, this.getFocusArea().height];
|
|
995
|
-
}
|
|
996
|
-
_onMouseOver(e) {
|
|
997
|
-
this.app.focus.setFocus(this);
|
|
998
|
-
}
|
|
999
|
-
_onMouseDown(e) {
|
|
1000
|
-
this._maybeEmit("pointerdown", e);
|
|
1001
|
-
}
|
|
1002
|
-
_handleClick(e) {
|
|
1003
|
-
this._maybeEmit("click", e), this.click();
|
|
1004
|
-
}
|
|
1005
|
-
_handleKeyUp(e) {}
|
|
1006
|
-
_maybeEmit(e, t) {
|
|
1007
|
-
this._eventsDisabled || t.type || (this._eventsDisabled = !0, this.emit(e, { type: e }), this._eventsDisabled = !1);
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
J.INITTED = !1;
|
|
1012
|
-
//#endregion
|
|
1013
|
-
//#region src/mixins/interaction.ts
|
|
1014
|
-
function Zn(e) {
|
|
1015
|
-
return class extends e {
|
|
1016
|
-
constructor(...e) {
|
|
1017
|
-
super(...e), this._signals = /* @__PURE__ */ new Map(), this._emitSignal = this._emitSignal.bind(this), this.eventMode = "static";
|
|
1018
|
-
}
|
|
1019
|
-
onInteraction(e) {
|
|
1020
|
-
if (!this._signals.has(e)) {
|
|
1021
|
-
let t = new p();
|
|
1022
|
-
this._signals.set(e, t), this.on(e, this._emitSignal);
|
|
1023
|
-
}
|
|
1024
|
-
return this._signals.get(e);
|
|
1025
|
-
}
|
|
1026
|
-
destroy(e) {
|
|
1027
|
-
for (let e of this._signals.keys()) this.off(e, this._emitSignal);
|
|
1028
|
-
this._signals.clear(), super.destroy(e);
|
|
1029
|
-
}
|
|
1030
|
-
_emitSignal(e) {
|
|
1031
|
-
let t = e.type, n = this._signals.get(t);
|
|
1032
|
-
n && n.emit(e);
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
}
|
|
1036
|
-
//#endregion
|
|
1037
|
-
//#region src/ui/Button.ts
|
|
1038
|
-
var Qn = [
|
|
1039
|
-
"textures",
|
|
1040
|
-
"sounds",
|
|
1041
|
-
"actions",
|
|
1042
|
-
"cursor",
|
|
1043
|
-
"disabledCursor",
|
|
1044
|
-
"sheet",
|
|
1045
|
-
"enabled",
|
|
1046
|
-
"layout",
|
|
1047
|
-
"textLabel"
|
|
1048
|
-
], $n = J(Zn(h(v()))), er = class extends $n {
|
|
1049
|
-
get textLabel() {
|
|
1050
|
-
return this._textLabel;
|
|
1051
|
-
}
|
|
1052
|
-
constructor(e) {
|
|
1053
|
-
super(), this.onDown = new p(), this.onUp = new p(), this.onUpOutside = new p(), this.onOut = new p(), this.onOver = new p(), this.onClick = new p(), this.onEnabled = new p(), this.onDisabled = new p(), this.onKeyboardEvent = new p(), this.onDestroy = new p(), this._isDownCallbacks = /* @__PURE__ */ new Map(), this._isDownListenerAdded = !1, m(this), this.config = Object.assign({
|
|
1054
|
-
id: "button",
|
|
1055
|
-
textures: { default: "" },
|
|
1056
|
-
sheet: void 0,
|
|
1057
|
-
enabled: !0,
|
|
1058
|
-
cursor: "default",
|
|
1059
|
-
disabledCursor: "not-allowed"
|
|
1060
|
-
}, e), this.id = this.config.id, e.layout === void 0 ? this.layout = !1 : this.layout = e.layout, this.view = this.add.sprite({
|
|
1061
|
-
asset: this.config.textures.default,
|
|
1062
|
-
sheet: this.config.sheet ?? void 0
|
|
1063
|
-
}), 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);
|
|
1064
|
-
}
|
|
1065
|
-
set enabled(e) {
|
|
1066
|
-
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({
|
|
1067
|
-
asset: this.config.textures.default,
|
|
1068
|
-
sheet: this.config.sheet ?? void 0
|
|
1069
|
-
}), this.onEnabled.emit()) : (this._resetPressState(), this.view.texture = this.make.texture({
|
|
1070
|
-
asset: this.config.textures.disabled || this.config.textures.default,
|
|
1071
|
-
sheet: this.config.sheet ?? void 0
|
|
1072
|
-
}), this.onDisabled.emit()));
|
|
1073
|
-
}
|
|
1074
|
-
_resetPressState() {
|
|
1075
|
-
window.removeEventListener("pointerup", this.handlePointerUpOutside), this.off("pointerupoutside", this.handlePointerUpOutside), this.isDown = !1, this._pointerId = void 0;
|
|
1076
|
-
}
|
|
1077
|
-
addLabel(e) {
|
|
1078
|
-
if (e instanceof O || e instanceof St || e instanceof w) e.anchor.set(.5, .5), this._textLabel = this.add.existing(e), this._textLabel.layout = !1;
|
|
1079
|
-
else switch (e.anchor = .5, e.type) {
|
|
1080
|
-
case "bitmap":
|
|
1081
|
-
this._textLabel = this.add.bitmapText({
|
|
1082
|
-
...e,
|
|
1083
|
-
layout: !1
|
|
1084
|
-
});
|
|
1085
|
-
break;
|
|
1086
|
-
case "html":
|
|
1087
|
-
this._textLabel = this.add.htmlText({
|
|
1088
|
-
...e,
|
|
1089
|
-
layout: !1
|
|
1090
|
-
});
|
|
1091
|
-
break;
|
|
1092
|
-
default:
|
|
1093
|
-
this._textLabel = this.add.text({
|
|
1094
|
-
...e,
|
|
1095
|
-
layout: !1
|
|
1096
|
-
});
|
|
1097
|
-
break;
|
|
1098
|
-
}
|
|
1099
|
-
return this.positionLabel(), this._textLabel;
|
|
1100
|
-
}
|
|
1101
|
-
positionLabel() {
|
|
1102
|
-
this._textLabel && this._textLabel.position.set(this.view.width * .5, this.view.height * .5);
|
|
1103
|
-
}
|
|
1104
|
-
get enabled() {
|
|
1105
|
-
return this._enabled;
|
|
1106
|
-
}
|
|
1107
|
-
get app() {
|
|
1108
|
-
return S.getInstance();
|
|
1109
|
-
}
|
|
1110
|
-
destroy(e) {
|
|
1111
|
-
this.onDestroy.emit(), this._resetPressState(), this._isDownListenerAdded &&= (this.app.ticker.remove(this._handleIsDownCallbacks), !1), super.destroy(e);
|
|
1112
|
-
}
|
|
1113
|
-
focusOut() {
|
|
1114
|
-
super.focusOut(), this.isDown = !1, this.isOver = !1;
|
|
1115
|
-
}
|
|
1116
|
-
blur() {
|
|
1117
|
-
super.blur(), this.isDown = !1, this.isOver = !1;
|
|
1118
|
-
}
|
|
1119
|
-
getFocusArea() {
|
|
1120
|
-
return this.view.getBounds().clone();
|
|
1121
|
-
}
|
|
1122
|
-
addIsDownCallback(e, t) {
|
|
1123
|
-
this._isDownCallbacks.set(e, t), this._checkIsDownCallbacks();
|
|
1124
|
-
}
|
|
1125
|
-
removeIsDownCallback(e) {
|
|
1126
|
-
this._isDownCallbacks.delete(e), this._checkIsDownCallbacks();
|
|
1127
|
-
}
|
|
1128
|
-
setTexture(e, t) {
|
|
1129
|
-
this.config.textures[e] = t, e === "default" && (this.view.texture = this.make.texture({
|
|
1130
|
-
asset: this.config.textures.default,
|
|
1131
|
-
sheet: this.config.sheet
|
|
1132
|
-
})), this.positionLabel();
|
|
1133
|
-
}
|
|
1134
|
-
handlePointerOver() {
|
|
1135
|
-
this._enabled && (this.isOver ||= !0, !this.isDown && (this.view.texture = this.make.texture({
|
|
1136
|
-
asset: this.config.textures.hover || this.config.textures.default,
|
|
1137
|
-
sheet: this.config.sheet
|
|
1138
|
-
}), 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)));
|
|
1139
|
-
}
|
|
1140
|
-
handlePointerOut() {
|
|
1141
|
-
this.isOver = !1, this._enabled && (this.isDown || (this.view.texture = this.make.texture({
|
|
1142
|
-
asset: this.config.textures.default,
|
|
1143
|
-
sheet: this.config.sheet
|
|
1144
|
-
}), this.config.sounds?.out && this.app.audio.play(this.config.sounds.out, "sfx"), this.onOut.emit()));
|
|
1145
|
-
}
|
|
1146
|
-
handlePointerDown(e) {
|
|
1147
|
-
!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({
|
|
1148
|
-
asset: this.config.textures.active || this.config.textures.hover || this.config.textures.default,
|
|
1149
|
-
sheet: this.config.sheet
|
|
1150
|
-
}), 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));
|
|
1151
|
-
}
|
|
1152
|
-
handlePointerUp(e) {
|
|
1153
|
-
!this._enabled || !this.isOver || e.pointerId !== this._pointerId || (window.removeEventListener("pointerup", this.handlePointerUpOutside), this.view.texture = this.make.texture({
|
|
1154
|
-
asset: this.config.textures.default,
|
|
1155
|
-
sheet: this.config.sheet
|
|
1156
|
-
}), this.onUp.emit(), this._pointerId = void 0);
|
|
1157
|
-
}
|
|
1158
|
-
handleClick(e) {
|
|
1159
|
-
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)));
|
|
1160
|
-
}
|
|
1161
|
-
handlePointerUpOutside(e) {
|
|
1162
|
-
if (e.pointerId !== this._pointerId) return;
|
|
1163
|
-
let t = this._enabled;
|
|
1164
|
-
this._resetPressState(), this.isOver = !1, t && (this.view.texture = this.make.texture({
|
|
1165
|
-
asset: this.config.textures.default,
|
|
1166
|
-
sheet: this.config.sheet
|
|
1167
|
-
}), this.onUpOutside.emit());
|
|
1168
|
-
}
|
|
1169
|
-
_doAction(e) {
|
|
1170
|
-
typeof e == "function" ? e() : (e.data.button || (e.data.button = this), this.app.action(e.id, e.data));
|
|
1171
|
-
}
|
|
1172
|
-
_checkIsDownCallbacks() {
|
|
1173
|
-
!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);
|
|
1174
|
-
}
|
|
1175
|
-
_handleIsDownCallbacks() {
|
|
1176
|
-
this.isDown && this._isDownCallbacks.forEach((e) => {
|
|
1177
|
-
e();
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
}, tr = h(v());
|
|
1181
|
-
function nr(e) {
|
|
1182
|
-
return e instanceof O || e instanceof w;
|
|
1183
|
-
}
|
|
1184
|
-
var rr = [
|
|
1185
|
-
"bindTo",
|
|
1186
|
-
"bindToAppSize",
|
|
1187
|
-
"autoLayoutChildren",
|
|
1188
|
-
"debug"
|
|
1189
|
-
], ir = class extends tr {
|
|
1190
|
-
constructor(e = {}) {
|
|
1191
|
-
if (super(), this.onLayoutComplete = new p(), 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");
|
|
1192
|
-
m(this), this.config = {
|
|
1193
|
-
autoLayoutChildren: !0,
|
|
1194
|
-
...e
|
|
1195
|
-
}, 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);
|
|
1196
|
-
}
|
|
1197
|
-
createLayout(e) {
|
|
1198
|
-
e?.layout === !0 && (e.layout = {});
|
|
1199
|
-
let t = { ...e?.layout ?? {} };
|
|
1200
|
-
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;
|
|
1201
|
-
}
|
|
1202
|
-
handleAdded() {
|
|
1203
|
-
this.updateLayout();
|
|
1204
|
-
}
|
|
1205
|
-
_updateLayout() {
|
|
1206
|
-
this.app.ticker.addOnce(this.updateLayout);
|
|
1207
|
-
}
|
|
1208
|
-
handleChildAdded(e) {
|
|
1209
|
-
this.config.autoLayoutChildren && (e.layout ? nr(e) && !e.layout?.style?.isLeaf && (e.layout = { isLeaf: !0 }) : e.layout = { isLeaf: !0 }), _.childAdded(e), e.on("layout", this._updateLayout), this._updateLayout();
|
|
1210
|
-
}
|
|
1211
|
-
handleChildRemoved(e) {
|
|
1212
|
-
e.off("layout", this._updateLayout), _.childRemoved(e), this._updateLayout();
|
|
1213
|
-
}
|
|
1214
|
-
handleResize() {
|
|
1215
|
-
this.config.bindToAppSize && (this.layout = {
|
|
1216
|
-
width: this.app.size.width,
|
|
1217
|
-
height: this.app.size.height
|
|
1218
|
-
}), this._updateLayout();
|
|
1219
|
-
}
|
|
1220
|
-
handleBindToResize() {
|
|
1221
|
-
this.config.bindTo && (this.layout = {
|
|
1222
|
-
width: this.config.bindTo.width,
|
|
1223
|
-
height: this.config.bindTo.height
|
|
1224
|
-
}, this._updateLayout());
|
|
1225
|
-
}
|
|
1226
|
-
updateLayout() {
|
|
1227
|
-
this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this.onLayoutComplete.emit(), this.config.debug && this.drawDebug());
|
|
1228
|
-
}
|
|
1229
|
-
get app() {
|
|
1230
|
-
return S.getInstance();
|
|
1231
|
-
}
|
|
1232
|
-
configure(e) {
|
|
1233
|
-
this.layout = e, this._updateLayout();
|
|
1234
|
-
}
|
|
1235
|
-
get gap() {
|
|
1236
|
-
return this.layout?.style?.gap ?? 0;
|
|
1237
|
-
}
|
|
1238
|
-
set gap(e) {
|
|
1239
|
-
this.layout = { gap: e }, this._updateLayout();
|
|
1240
|
-
}
|
|
1241
|
-
get flexWrap() {
|
|
1242
|
-
return this.layout?.style?.flexWrap;
|
|
1243
|
-
}
|
|
1244
|
-
set flexWrap(e) {
|
|
1245
|
-
this.layout = { flexWrap: e }, this._updateLayout();
|
|
1246
|
-
}
|
|
1247
|
-
get flexDirection() {
|
|
1248
|
-
return this.layout?.style?.flexDirection;
|
|
1249
|
-
}
|
|
1250
|
-
set flexDirection(e) {
|
|
1251
|
-
this.layout = { flexDirection: e }, this._updateLayout();
|
|
1252
|
-
}
|
|
1253
|
-
get alignItems() {
|
|
1254
|
-
return this.layout?.style?.alignItems;
|
|
1255
|
-
}
|
|
1256
|
-
set alignItems(e) {
|
|
1257
|
-
this.layout = { alignItems: e }, this._updateLayout();
|
|
1258
|
-
}
|
|
1259
|
-
get justifyContent() {
|
|
1260
|
-
return this.layout?.style?.justifyContent;
|
|
1261
|
-
}
|
|
1262
|
-
set justifyContent(e) {
|
|
1263
|
-
this.layout = { justifyContent: e }, this._updateLayout();
|
|
1264
|
-
}
|
|
1265
|
-
get size() {
|
|
1266
|
-
return {
|
|
1267
|
-
width: this.layout?.style?.width,
|
|
1268
|
-
height: this.layout?.style?.height
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
set size(e) {
|
|
1272
|
-
Array.isArray(e) && (e = {
|
|
1273
|
-
width: e[0],
|
|
1274
|
-
height: e[1]
|
|
1275
|
-
}), (typeof e == "number" || typeof e == "string") && (e = {
|
|
1276
|
-
width: e,
|
|
1277
|
-
height: e
|
|
1278
|
-
}), this.layout = { ...e }, this._updateLayout();
|
|
1279
|
-
}
|
|
1280
|
-
get layoutWidth() {
|
|
1281
|
-
return this.layout?.style?.width;
|
|
1282
|
-
}
|
|
1283
|
-
set layoutWidth(e) {
|
|
1284
|
-
this.layout = { width: e }, this._updateLayout();
|
|
1285
|
-
}
|
|
1286
|
-
get layoutHeight() {
|
|
1287
|
-
return this.layout?.style?.height;
|
|
1288
|
-
}
|
|
1289
|
-
set layoutHeight(e) {
|
|
1290
|
-
this.layout = { height: e }, this._updateLayout();
|
|
1291
|
-
}
|
|
1292
|
-
get padding() {
|
|
1293
|
-
return this.layout?.style?.padding;
|
|
1294
|
-
}
|
|
1295
|
-
set padding(e) {
|
|
1296
|
-
this.layout = { padding: e }, this._updateLayout();
|
|
1297
|
-
}
|
|
1298
|
-
get paddingTop() {
|
|
1299
|
-
return this.layout?.style?.paddingTop;
|
|
1300
|
-
}
|
|
1301
|
-
set paddingTop(e) {
|
|
1302
|
-
this.layout = { paddingTop: e }, this._updateLayout();
|
|
1303
|
-
}
|
|
1304
|
-
get paddingRight() {
|
|
1305
|
-
return this.layout?.style?.paddingRight;
|
|
1306
|
-
}
|
|
1307
|
-
set paddingRight(e) {
|
|
1308
|
-
this.layout = { paddingRight: e }, this._updateLayout();
|
|
1309
|
-
}
|
|
1310
|
-
get paddingBottom() {
|
|
1311
|
-
return this.layout?.style?.paddingBottom;
|
|
1312
|
-
}
|
|
1313
|
-
set paddingBottom(e) {
|
|
1314
|
-
this.layout = { paddingBottom: e }, this._updateLayout();
|
|
626
|
+
return e instanceof TouchEvent ? new A(e.touches[0].clientX, e.touches[0].clientY) : new A(e.clientX, e.clientY);
|
|
1315
627
|
}
|
|
1316
|
-
|
|
1317
|
-
return this.layout?.style?.paddingLeft;
|
|
1318
|
-
}
|
|
1319
|
-
set paddingLeft(e) {
|
|
1320
|
-
this.layout = { paddingLeft: e }, this._updateLayout();
|
|
1321
|
-
}
|
|
1322
|
-
get margin() {
|
|
1323
|
-
return this.layout?.style?.margin;
|
|
1324
|
-
}
|
|
1325
|
-
set margin(e) {
|
|
1326
|
-
this.layout = { margin: e }, this._updateLayout();
|
|
1327
|
-
}
|
|
1328
|
-
get marginTop() {
|
|
1329
|
-
return this.layout?.style?.marginTop;
|
|
1330
|
-
}
|
|
1331
|
-
set marginTop(e) {
|
|
1332
|
-
this.layout = { marginTop: e }, this._updateLayout();
|
|
1333
|
-
}
|
|
1334
|
-
get marginRight() {
|
|
1335
|
-
return this.layout?.style?.marginRight;
|
|
1336
|
-
}
|
|
1337
|
-
set marginRight(e) {
|
|
1338
|
-
this.layout = { marginRight: e }, this._updateLayout();
|
|
1339
|
-
}
|
|
1340
|
-
get marginBottom() {
|
|
1341
|
-
return this.layout?.style?.marginBottom;
|
|
1342
|
-
}
|
|
1343
|
-
set marginBottom(e) {
|
|
1344
|
-
this.layout = { marginBottom: e }, this._updateLayout();
|
|
1345
|
-
}
|
|
1346
|
-
get marginLeft() {
|
|
1347
|
-
return this.layout?.style?.marginLeft;
|
|
1348
|
-
}
|
|
1349
|
-
set marginLeft(e) {
|
|
1350
|
-
this.layout = { marginLeft: e }, this._updateLayout();
|
|
1351
|
-
}
|
|
1352
|
-
get debug() {
|
|
1353
|
-
return this.config.debug ?? !1;
|
|
1354
|
-
}
|
|
1355
|
-
set debug(e) {
|
|
1356
|
-
this.config.debug = e, e ? (P(`FlexContainer:${this.uid}`, this.label || "FlexContainer", j.bounds), this.drawDebug()) : (F(`FlexContainer:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1));
|
|
1357
|
-
}
|
|
1358
|
-
drawDebug() {
|
|
1359
|
-
(!this._debugGraphics || this._debugGraphics.parent !== this) && (this._debugGraphics ||= Ft(`${this.label ?? "FlexContainer"}:debug`), this.addChild(this._debugGraphics), this._debugGraphics.layout = !1), (!this._debugLabel || this._debugLabel.parent !== this) && (this._debugLabel ||= N(this.label || "FlexContainer", j.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();
|
|
1360
|
-
let e = this.layout?.computedLayout;
|
|
1361
|
-
if (!e) return;
|
|
1362
|
-
let t = e.width, n = e.height, r = this.layout?.style?.flexDirection ?? "row", i = this.layout?.style?.gap ?? 0;
|
|
1363
|
-
this._debugGraphics.rect(0, 0, t, n).stroke({
|
|
1364
|
-
width: 1,
|
|
1365
|
-
color: j.bounds,
|
|
1366
|
-
alpha: M.stroke,
|
|
1367
|
-
pixelLine: !0
|
|
1368
|
-
});
|
|
1369
|
-
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;
|
|
1370
|
-
a > 0 && this._debugGraphics.rect(0, 0, t, a).fill({
|
|
1371
|
-
color: j.outerBounds,
|
|
1372
|
-
alpha: M.fill
|
|
1373
|
-
}), s > 0 && this._debugGraphics.rect(0, n - s, t, s).fill({
|
|
1374
|
-
color: j.outerBounds,
|
|
1375
|
-
alpha: M.fill
|
|
1376
|
-
}), c > 0 && this._debugGraphics.rect(0, a, c, n - a - s).fill({
|
|
1377
|
-
color: j.outerBounds,
|
|
1378
|
-
alpha: M.fill
|
|
1379
|
-
}), o > 0 && this._debugGraphics.rect(t - o, a, o, n - a - s).fill({
|
|
1380
|
-
color: j.outerBounds,
|
|
1381
|
-
alpha: M.fill
|
|
1382
|
-
});
|
|
1383
|
-
let l = Math.min(t, n, 40), u = t / 2, d = n / 2, f = r === "row" || r === "row-reverse";
|
|
1384
|
-
if (f) {
|
|
1385
|
-
let e = r === "row" ? 1 : -1, t = u - e * l / 2, n = u + e * l / 2;
|
|
1386
|
-
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({
|
|
1387
|
-
width: 1,
|
|
1388
|
-
color: j.direction,
|
|
1389
|
-
alpha: .8,
|
|
1390
|
-
pixelLine: !0
|
|
1391
|
-
});
|
|
1392
|
-
} else {
|
|
1393
|
-
let e = r === "column" ? 1 : -1, t = d - e * l / 2, n = d + e * l / 2;
|
|
1394
|
-
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({
|
|
1395
|
-
width: 1,
|
|
1396
|
-
color: j.direction,
|
|
1397
|
-
alpha: .8,
|
|
1398
|
-
pixelLine: !0
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
if (i > 0) for (let e = 0; e < this.children.length - 1; e++) {
|
|
1402
|
-
let r = this.children[e];
|
|
1403
|
-
if (r === this._debugGraphics || r === this._debugLabel || !r.layout?.computedLayout) continue;
|
|
1404
|
-
let a = r.layout.computedLayout;
|
|
1405
|
-
if (f) {
|
|
1406
|
-
let e = a.left + a.width;
|
|
1407
|
-
this._debugGraphics.rect(e, 0, i, n).fill({
|
|
1408
|
-
color: j.gap,
|
|
1409
|
-
alpha: M.fill
|
|
1410
|
-
});
|
|
1411
|
-
} else {
|
|
1412
|
-
let e = a.top + a.height;
|
|
1413
|
-
this._debugGraphics.rect(0, e, t, i).fill({
|
|
1414
|
-
color: j.gap,
|
|
1415
|
-
alpha: M.fill
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
for (let e of this.children) {
|
|
1420
|
-
if (e === this._debugGraphics || e === this._debugLabel || !e.layout?.computedLayout) continue;
|
|
1421
|
-
let t = e.layout.computedLayout;
|
|
1422
|
-
this._debugGraphics.rect(t.left, t.top, t.width, t.height).stroke({
|
|
1423
|
-
width: 1,
|
|
1424
|
-
color: j.innerBounds,
|
|
1425
|
-
alpha: .4,
|
|
1426
|
-
pixelLine: !0
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
this._debugLabel.position.set(2, 2);
|
|
1430
|
-
}
|
|
1431
|
-
destroy() {
|
|
1432
|
-
this.config.debug && F(`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();
|
|
1433
|
-
}
|
|
1434
|
-
}, Y = {
|
|
1435
|
-
type: "info",
|
|
1436
|
-
duration: 3e3,
|
|
1437
|
-
width: 300,
|
|
1438
|
-
height: 80,
|
|
1439
|
-
backgroundColor: 0,
|
|
1440
|
-
backgroundAlpha: .8,
|
|
1441
|
-
cornerRadius: 0,
|
|
1442
|
-
padding: 10,
|
|
1443
|
-
autoClose: !0,
|
|
1444
|
-
textAlign: "center",
|
|
1445
|
-
verticalAlign: "middle",
|
|
1446
|
-
colorBarWidth: 6,
|
|
1447
|
-
shadow: {
|
|
1448
|
-
color: 0,
|
|
1449
|
-
alpha: .2,
|
|
1450
|
-
offset: {
|
|
1451
|
-
x: 1,
|
|
1452
|
-
y: 3
|
|
1453
|
-
}
|
|
1454
|
-
},
|
|
1455
|
-
closeButton: {
|
|
1456
|
-
show: !1,
|
|
1457
|
-
position: "top right",
|
|
1458
|
-
size: 12,
|
|
1459
|
-
offset: 4
|
|
1460
|
-
},
|
|
1461
|
-
style: {
|
|
1462
|
-
fill: 16777215,
|
|
1463
|
-
fontSize: 16,
|
|
1464
|
-
wordWrap: !0
|
|
1465
|
-
},
|
|
1466
|
-
textColors: {
|
|
1467
|
-
info: 3447003,
|
|
1468
|
-
success: 3066993,
|
|
1469
|
-
warning: 15844367,
|
|
1470
|
-
error: 15158332
|
|
1471
|
-
}
|
|
1472
|
-
}, ar = class extends h(_) {
|
|
1473
|
-
set toaster(e) {
|
|
1474
|
-
this._toaster = e;
|
|
1475
|
-
}
|
|
1476
|
-
get toaster() {
|
|
1477
|
-
return this._toaster;
|
|
1478
|
-
}
|
|
1479
|
-
set text(e) {
|
|
1480
|
-
this.textDisplay.text = e, this.alignText();
|
|
1481
|
-
}
|
|
1482
|
-
constructor(e = {}) {
|
|
1483
|
-
super(), this.onToastClosed = new p(), this.isHiding = !1, this.config = {
|
|
1484
|
-
...Y,
|
|
1485
|
-
...e
|
|
1486
|
-
}, this.initialize();
|
|
1487
|
-
}
|
|
1488
|
-
initialize() {
|
|
1489
|
-
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({
|
|
1490
|
-
color: this.config.shadow.color ?? 0,
|
|
1491
|
-
alpha: this.config.shadow.alpha ?? .2
|
|
1492
|
-
})), this.background = this.view.add.graphics().roundRect(0, 0, this.config.width, this.config.height, this.config.cornerRadius).fill({
|
|
1493
|
-
color: this.config.backgroundColor,
|
|
1494
|
-
alpha: this.config.backgroundAlpha
|
|
1495
|
-
}), this.config.type) {
|
|
1496
|
-
let e = new E().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] });
|
|
1497
|
-
t.mask = e, this.view.addChild(e), this.view.addChild(t);
|
|
1498
|
-
}
|
|
1499
|
-
this.config.closeButton?.show && this.addCloseButton();
|
|
1500
|
-
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;
|
|
1501
|
-
this.textDisplay = this.view.add.text({
|
|
1502
|
-
text: this.config.message,
|
|
1503
|
-
style: {
|
|
1504
|
-
...Y.style,
|
|
1505
|
-
...this.config.style,
|
|
1506
|
-
wordWrapWidth: this.config.style?.wordWrapWidth ?? this.config.width - e - t
|
|
1507
|
-
},
|
|
1508
|
-
x: e,
|
|
1509
|
-
y: this.config.padding
|
|
1510
|
-
}), 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);
|
|
1511
|
-
}
|
|
1512
|
-
addCloseButton() {
|
|
1513
|
-
let e = this.config.closeButton?.class || er, t = this.config.closeButton?.size ?? 12, n = this.config.closeButton?.offset ?? 4, r = this.config.closeButton?.position ?? "top right";
|
|
1514
|
-
this.closeButton = this.view.add.existing(new e({ cursor: "pointer" }));
|
|
1515
|
-
let i = r === "top right" ? this.config.width - t * .5 - n : t * .5 + n, a = t * .5 + n;
|
|
1516
|
-
this.closeButton.position.set(i, a), this.closeButton.onClick.connect(() => {
|
|
1517
|
-
this.hide();
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
alignText() {
|
|
1521
|
-
switch (this.config.textAlign) {
|
|
1522
|
-
case "left":
|
|
1523
|
-
this.textDisplay.anchor.set(0, .5);
|
|
1524
|
-
break;
|
|
1525
|
-
case "center":
|
|
1526
|
-
this.textDisplay.anchor.set(.5, .5), this.textDisplay.x = this.config.width / 2;
|
|
1527
|
-
break;
|
|
1528
|
-
case "right":
|
|
1529
|
-
this.textDisplay.anchor.set(1, .5);
|
|
1530
|
-
break;
|
|
1531
|
-
}
|
|
1532
|
-
switch (this.config.verticalAlign) {
|
|
1533
|
-
case "top":
|
|
1534
|
-
this.textDisplay.y = this.config.padding;
|
|
1535
|
-
break;
|
|
1536
|
-
case "middle":
|
|
1537
|
-
this.textDisplay.y = this.config.height * .5;
|
|
1538
|
-
break;
|
|
1539
|
-
case "bottom":
|
|
1540
|
-
this.textDisplay.y = this.config.height - this.textDisplay.height - this.config.padding;
|
|
1541
|
-
break;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
getShowAnimation() {
|
|
1545
|
-
let e = A.timeline({ paused: !0 });
|
|
1546
|
-
return e.to(this, {
|
|
1547
|
-
alpha: 1,
|
|
1548
|
-
duration: .4,
|
|
1549
|
-
ease: "power2.out"
|
|
1550
|
-
}), e;
|
|
1551
|
-
}
|
|
1552
|
-
getHideAnimation() {
|
|
1553
|
-
let e = A.timeline({ paused: !0 });
|
|
1554
|
-
return e.to(this, {
|
|
1555
|
-
alpha: 0,
|
|
1556
|
-
duration: .25,
|
|
1557
|
-
ease: "power2.in"
|
|
1558
|
-
}), e;
|
|
1559
|
-
}
|
|
1560
|
-
async show() {
|
|
1561
|
-
return this.timeline = this.getShowAnimation(), await this.timeline.play(), this.config.autoClose && (this.closeTimeout = setTimeout(() => {
|
|
1562
|
-
this.hide();
|
|
1563
|
-
}, this.config.duration)), this;
|
|
1564
|
-
}
|
|
1565
|
-
async hide() {
|
|
1566
|
-
if (this.isHiding || this.destroyed) return this;
|
|
1567
|
-
this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0);
|
|
1568
|
-
try {
|
|
1569
|
-
await this.getHideAnimation().play(), this.destroyed || this.onToastClosed.emit();
|
|
1570
|
-
} catch (e) {
|
|
1571
|
-
console.warn("Toast hide animation error:", e), this.destroyed || this.onToastClosed.emit();
|
|
1572
|
-
}
|
|
1573
|
-
return this;
|
|
1574
|
-
}
|
|
1575
|
-
destroy() {
|
|
1576
|
-
this.isHiding = !0, this.closeTimeout &&= (clearTimeout(this.closeTimeout), void 0), A.killTweensOf(this), this.timeline &&= (this.timeline.kill(), void 0), !this.destroyed && !this.isHiding && this.onToastClosed.emit(), super.destroy({ children: !0 });
|
|
1577
|
-
}
|
|
1578
|
-
}, or = {
|
|
1579
|
-
position: "bottom right",
|
|
1580
|
-
maxToasts: 5,
|
|
1581
|
-
spacing: 10,
|
|
1582
|
-
offset: {
|
|
1583
|
-
x: 20,
|
|
1584
|
-
y: 20
|
|
1585
|
-
},
|
|
1586
|
-
stackDirection: "up",
|
|
1587
|
-
animationSpeed: 1
|
|
1588
|
-
}, sr = class extends h(_) {
|
|
1589
|
-
get size() {
|
|
1590
|
-
return this.toasts.length;
|
|
1591
|
-
}
|
|
1592
|
-
get toastPosition() {
|
|
1593
|
-
return this.config.position ?? "top right";
|
|
1594
|
-
}
|
|
1595
|
-
get stackDirection() {
|
|
1596
|
-
return this.config.stackDirection ?? "up";
|
|
1597
|
-
}
|
|
1598
|
-
get spacing() {
|
|
1599
|
-
return this.config.spacing ?? 10;
|
|
1600
|
-
}
|
|
1601
|
-
get offset() {
|
|
1602
|
-
return this.config.offset ?? {
|
|
1603
|
-
x: 20,
|
|
1604
|
-
y: 20
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
get maxToasts() {
|
|
1608
|
-
return this.config.maxToasts ?? 5;
|
|
1609
|
-
}
|
|
1610
|
-
get toastConfig() {
|
|
1611
|
-
return this.defaultToastConfig ?? {};
|
|
1612
|
-
}
|
|
1613
|
-
constructor(e = {}, t = {}) {
|
|
1614
|
-
super({ autoResize: !0 }), this.onToastAdded = new p(), this.onToastRemoved = new p(), this.onAllToastsRemoved = new p(), this.toasts = [], this.config = {
|
|
1615
|
-
...or,
|
|
1616
|
-
...e
|
|
1617
|
-
}, this.defaultToastConfig = { ...t }, this.initialize(), this.resize();
|
|
1618
|
-
}
|
|
1619
|
-
initialize() {
|
|
1620
|
-
this.container = this.add.container();
|
|
1621
|
-
}
|
|
1622
|
-
async show(e = this.defaultToastConfig, t = !1) {
|
|
1623
|
-
if (this.size >= this.config.maxToasts) {
|
|
1624
|
-
let e = this.toasts[0];
|
|
1625
|
-
await e.hide(), await this.removeToast(e);
|
|
1626
|
-
}
|
|
1627
|
-
!t && this.defaultToastConfig && (e = {
|
|
1628
|
-
...this.defaultToastConfig,
|
|
1629
|
-
...e,
|
|
1630
|
-
style: this.defaultToastConfig.style || e.style ? {
|
|
1631
|
-
...this.defaultToastConfig.style ?? {},
|
|
1632
|
-
...e.style ?? {}
|
|
1633
|
-
} : this.defaultToastConfig.style,
|
|
1634
|
-
textColors: this.defaultToastConfig.textColors || e.textColors ? {
|
|
1635
|
-
...this.defaultToastConfig.textColors ?? {},
|
|
1636
|
-
...e.textColors ?? {}
|
|
1637
|
-
} : Y.textColors,
|
|
1638
|
-
shadow: this.defaultToastConfig.shadow || e.shadow ? {
|
|
1639
|
-
...this.defaultToastConfig.shadow ?? {},
|
|
1640
|
-
...e.shadow ?? {}
|
|
1641
|
-
} : this.defaultToastConfig.shadow,
|
|
1642
|
-
closeButton: this.defaultToastConfig.closeButton || e.closeButton ? {
|
|
1643
|
-
...this.defaultToastConfig.closeButton ?? {},
|
|
1644
|
-
...e.closeButton ?? {}
|
|
1645
|
-
} : Y.closeButton
|
|
1646
|
-
});
|
|
1647
|
-
let n = new (e.class ?? ar)(e);
|
|
1648
|
-
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();
|
|
1649
|
-
}
|
|
1650
|
-
async hideAll() {
|
|
1651
|
-
let e = [...this.toasts];
|
|
1652
|
-
await Promise.all(e.map((e) => e.hide())), this.onAllToastsRemoved.emit();
|
|
1653
|
-
}
|
|
1654
|
-
async removeAll() {
|
|
1655
|
-
return this.hideAll();
|
|
1656
|
-
}
|
|
1657
|
-
async removeToast(e) {
|
|
1658
|
-
let t = this.toasts.indexOf(e);
|
|
1659
|
-
t === -1 || e.destroyed || (this.toasts.splice(t, 1), this.positionToasts(), e.destroyed || (this.container.removeChild(e), e.destroy()), this.onToastRemoved.emit(e));
|
|
1660
|
-
}
|
|
1661
|
-
positionToasts(e = !0, t = !1) {
|
|
1662
|
-
this.toasts.filter((e, n) => e && !e.destroyed && (t ? n !== this.toasts.length - 1 : !0)).forEach((t, n) => {
|
|
1663
|
-
this.positionToast(t, n, e);
|
|
1664
|
-
});
|
|
1665
|
-
}
|
|
1666
|
-
positionToast(e, t, n = !0) {
|
|
1667
|
-
if (!e?.parent || e.destroyed) return;
|
|
1668
|
-
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;
|
|
1669
|
-
switch (r) {
|
|
1670
|
-
case "top right":
|
|
1671
|
-
case "right top":
|
|
1672
|
-
l += this.app.size.width * .5 - e.width - s, u -= this.app.size.height * .5 - c;
|
|
1673
|
-
break;
|
|
1674
|
-
case "top left":
|
|
1675
|
-
case "left top":
|
|
1676
|
-
l -= this.app.size.width * .5 - s, u -= this.app.size.height * .5 - c;
|
|
1677
|
-
break;
|
|
1678
|
-
case "bottom right":
|
|
1679
|
-
case "right bottom":
|
|
1680
|
-
l += this.app.size.width * .5 - e.width - s, u += this.app.size.height * .5 - e.height - c;
|
|
1681
|
-
break;
|
|
1682
|
-
case "bottom left":
|
|
1683
|
-
case "left bottom":
|
|
1684
|
-
l -= this.app.size.width * .5 - s, u += this.app.size.height * .5 - e.height - c;
|
|
1685
|
-
break;
|
|
1686
|
-
case "top":
|
|
1687
|
-
case "top center":
|
|
1688
|
-
l += -e.width * .5, u -= this.app.size.height * .5 - c;
|
|
1689
|
-
break;
|
|
1690
|
-
case "bottom":
|
|
1691
|
-
case "bottom center":
|
|
1692
|
-
l += -e.width * .5, u += this.app.size.height * .5 - e.height - c;
|
|
1693
|
-
break;
|
|
1694
|
-
}
|
|
1695
|
-
o === "down" ? u += t * (e.height + i) : u -= t * (e.height + i);
|
|
1696
|
-
try {
|
|
1697
|
-
n ? A.to(e, {
|
|
1698
|
-
x: l,
|
|
1699
|
-
y: u,
|
|
1700
|
-
duration: .3 / this.config.animationSpeed,
|
|
1701
|
-
ease: "power2.out"
|
|
1702
|
-
}) : e.position.set(l, u);
|
|
1703
|
-
} catch (e) {
|
|
1704
|
-
console.warn("Error positioning toast:", e);
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
resize() {
|
|
1708
|
-
this.position.set(-this.app.size.width * .5, -this.app.size.height * .5), this.positionToasts(!1);
|
|
1709
|
-
}
|
|
1710
|
-
destroy() {
|
|
1711
|
-
this.toasts.forEach((e) => {
|
|
1712
|
-
A.killTweensOf(e);
|
|
1713
|
-
}), this.hideAll(), this.toasts = [], super.destroy({ children: !0 });
|
|
1714
|
-
}
|
|
1715
|
-
}, cr = [
|
|
1716
|
-
"debug",
|
|
1717
|
-
"padding",
|
|
1718
|
-
"size",
|
|
1719
|
-
"useAppSize",
|
|
1720
|
-
"useSafeArea",
|
|
1721
|
-
"layout"
|
|
1722
|
-
], lr = {
|
|
1723
|
-
top: 0,
|
|
1724
|
-
right: 0,
|
|
1725
|
-
bottom: 0,
|
|
1726
|
-
left: 0
|
|
1727
|
-
};
|
|
1728
|
-
function ur(e, t) {
|
|
1729
|
-
return {
|
|
1730
|
-
top: e.top + t.top,
|
|
1731
|
-
right: e.right + t.right,
|
|
1732
|
-
bottom: e.bottom + t.bottom,
|
|
1733
|
-
left: e.left + t.left
|
|
1734
|
-
};
|
|
1735
|
-
}
|
|
1736
|
-
var dr = {
|
|
1737
|
-
flexGrow: 0,
|
|
1738
|
-
flexShrink: 0,
|
|
1739
|
-
autoLayoutChildren: !0
|
|
1740
|
-
}, fr = h(v()), pr = class e extends fr {
|
|
1741
|
-
constructor(e) {
|
|
1742
|
-
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) => {
|
|
1743
|
-
throw Error("UICanvas: Do not call addChildAt() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
|
|
1744
|
-
}, this.setChildIndex = (e, t) => {
|
|
1745
|
-
super.setChildIndex(e, t), this._updateLayout();
|
|
1746
|
-
}, 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");
|
|
1747
|
-
m(this), this._positionContainers = /* @__PURE__ */ new Map(), this.config = {
|
|
1748
|
-
debug: e.debug === !0,
|
|
1749
|
-
padding: I(e?.padding ?? 0),
|
|
1750
|
-
size: e.size === void 0 ? {
|
|
1751
|
-
width: 0,
|
|
1752
|
-
height: 0
|
|
1753
|
-
} : et(e.size),
|
|
1754
|
-
useAppSize: e.useAppSize === !0,
|
|
1755
|
-
useSafeArea: e.useSafeArea ?? !0,
|
|
1756
|
-
autoLayoutChildren: e.autoLayoutChildren ?? !0
|
|
1757
|
-
}, e.layout ? typeof e.layout == "boolean" ? this.config.layout = e.layout : this.config.layout = {
|
|
1758
|
-
...dr,
|
|
1759
|
-
...e.layout
|
|
1760
|
-
} : this.config.layout = { ...dr }, this.config.useAppSize && (this.config.size = this.app.size), this.layout = {
|
|
1761
|
-
width: this.config.size.width,
|
|
1762
|
-
height: this.config.size.height,
|
|
1763
|
-
flexDirection: "column",
|
|
1764
|
-
justifyContent: "space-between",
|
|
1765
|
-
...typeof this.config.layout == "object" ? this.config.layout : {}
|
|
1766
|
-
}, 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 && P(`UICanvas:${this.uid}`, this.label || "UICanvas", j.outerBounds);
|
|
1767
|
-
}
|
|
1768
|
-
_updateLayout() {
|
|
1769
|
-
this.app.ticker.addOnce(this.updateLayout);
|
|
1770
|
-
}
|
|
1771
|
-
_initializeLayout() {
|
|
1772
|
-
this._disableAddChildError = !0, this.topRow = this.add.flexContainer({
|
|
1773
|
-
label: "Top",
|
|
1774
|
-
layout: {
|
|
1775
|
-
width: "100%",
|
|
1776
|
-
height: "auto",
|
|
1777
|
-
flexDirection: "row",
|
|
1778
|
-
justifyContent: "space-between",
|
|
1779
|
-
alignItems: "flex-start"
|
|
1780
|
-
}
|
|
1781
|
-
}), this.middleRow = this.add.flexContainer({
|
|
1782
|
-
label: "Middle",
|
|
1783
|
-
layout: {
|
|
1784
|
-
width: "100%",
|
|
1785
|
-
flexDirection: "row",
|
|
1786
|
-
justifyContent: "space-between",
|
|
1787
|
-
alignItems: "center"
|
|
1788
|
-
}
|
|
1789
|
-
}), this.bottomRow = this.add.flexContainer({
|
|
1790
|
-
label: "Bottom",
|
|
1791
|
-
layout: {
|
|
1792
|
-
width: "100%",
|
|
1793
|
-
height: "auto",
|
|
1794
|
-
flexDirection: "row",
|
|
1795
|
-
justifyContent: "space-between",
|
|
1796
|
-
alignItems: "flex-end"
|
|
1797
|
-
}
|
|
1798
|
-
}), this._disableAddChildError = !1;
|
|
1799
|
-
let e = this._createPositionContainer(this.topRow, {
|
|
1800
|
-
justifyContent: "flex-start",
|
|
1801
|
-
alignItems: "flex-start",
|
|
1802
|
-
flexGrow: 0,
|
|
1803
|
-
flexShrink: 0
|
|
1804
|
-
}, "Left"), t = this._createPositionContainer(this.topRow, {
|
|
1805
|
-
justifyContent: "center",
|
|
1806
|
-
alignItems: "flex-start",
|
|
1807
|
-
flexGrow: 1,
|
|
1808
|
-
flexShrink: 0
|
|
1809
|
-
}, "Center"), n = this._createPositionContainer(this.topRow, {
|
|
1810
|
-
justifyContent: "flex-end",
|
|
1811
|
-
alignItems: "flex-start",
|
|
1812
|
-
flexGrow: 0,
|
|
1813
|
-
flexShrink: 0
|
|
1814
|
-
}, "Right"), r = this._createPositionContainer(this.middleRow, {
|
|
1815
|
-
justifyContent: "flex-start",
|
|
1816
|
-
alignItems: "center",
|
|
1817
|
-
flexDirection: "row",
|
|
1818
|
-
flexGrow: 0,
|
|
1819
|
-
flexShrink: 0
|
|
1820
|
-
}, "Left"), i = this._createPositionContainer(this.middleRow, {
|
|
1821
|
-
justifyContent: "center",
|
|
1822
|
-
alignItems: "center",
|
|
1823
|
-
flexDirection: "row",
|
|
1824
|
-
flexGrow: 1,
|
|
1825
|
-
flexShrink: 0
|
|
1826
|
-
}, "Center"), a = this._createPositionContainer(this.middleRow, {
|
|
1827
|
-
justifyContent: "flex-end",
|
|
1828
|
-
alignItems: "center",
|
|
1829
|
-
flexDirection: "row",
|
|
1830
|
-
flexGrow: 0,
|
|
1831
|
-
flexShrink: 0
|
|
1832
|
-
}, "Right"), o = this._createPositionContainer(this.bottomRow, {
|
|
1833
|
-
justifyContent: "flex-start",
|
|
1834
|
-
alignItems: "flex-end",
|
|
1835
|
-
flexDirection: "row",
|
|
1836
|
-
flexGrow: 0,
|
|
1837
|
-
flexShrink: 0
|
|
1838
|
-
}, "Left"), s = this._createPositionContainer(this.bottomRow, {
|
|
1839
|
-
justifyContent: "center",
|
|
1840
|
-
alignItems: "flex-end",
|
|
1841
|
-
flexGrow: 1,
|
|
1842
|
-
flexShrink: 0,
|
|
1843
|
-
flexDirection: "row"
|
|
1844
|
-
}, "Center"), c = this._createPositionContainer(this.bottomRow, {
|
|
1845
|
-
justifyContent: "flex-end",
|
|
1846
|
-
alignItems: "flex-end",
|
|
1847
|
-
flexDirection: "row",
|
|
1848
|
-
flexGrow: 0,
|
|
1849
|
-
flexShrink: 0
|
|
1850
|
-
}, "Right");
|
|
1851
|
-
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);
|
|
1852
|
-
}
|
|
1853
|
-
_createPositionContainer(e, t, n) {
|
|
1854
|
-
let r = e.add.container({ layout: {
|
|
1855
|
-
width: "auto",
|
|
1856
|
-
height: "auto",
|
|
1857
|
-
...t
|
|
1858
|
-
} });
|
|
1859
|
-
return r.label = n, r.on("childAdded", this._updateLayout), r.on("childRemoved", this._updateLayout), r.on("layout", this._updateLayout), r;
|
|
1860
|
-
}
|
|
1861
|
-
get canvasChildren() {
|
|
1862
|
-
return this._canvasChildren;
|
|
1863
|
-
}
|
|
1864
|
-
get app() {
|
|
1865
|
-
return S.getInstance();
|
|
1866
|
-
}
|
|
1867
|
-
destroy() {
|
|
1868
|
-
this._disableAddChildError = !0, this.config.debug && F(`UICanvas:${this.uid}`), this._debugGraphics &&= (this._debugGraphics.destroy(), null), this._debugLabel &&= (this._debugLabel.destroy(), null);
|
|
1869
|
-
for (let e of this._regionLabels) e.destroy();
|
|
1870
|
-
this._regionLabels = [], this.canvasChildren?.forEach((e) => {
|
|
1871
|
-
e.off("layout", this._updateLayout);
|
|
1872
|
-
}), this.children.forEach((e) => {
|
|
1873
|
-
e.off("layout", this._updateLayout);
|
|
1874
|
-
}), this.off("childAdded", this._updateLayout), this.off("childRemoved", this._updateLayout), this._positionContainers.forEach((e) => {
|
|
1875
|
-
e.off("childAdded", this._updateLayout), e.off("childRemoved", this._updateLayout);
|
|
1876
|
-
}), this._bindings = [], super.destroy();
|
|
1877
|
-
}
|
|
1878
|
-
set size(e) {
|
|
1879
|
-
this.config.size = e === void 0 ? {
|
|
1880
|
-
width: 0,
|
|
1881
|
-
height: 0
|
|
1882
|
-
} : et(e), this.layout = {
|
|
1883
|
-
width: this.config.size.width,
|
|
1884
|
-
height: this.config.size.height
|
|
1885
|
-
}, this.updateLayout();
|
|
1886
|
-
}
|
|
1887
|
-
set padding(e) {
|
|
1888
|
-
this.config.padding = I(e), this._applyPadding(), this._updateLayout();
|
|
1889
|
-
}
|
|
1890
|
-
_applyPadding() {
|
|
1891
|
-
let e = ur(this.config.padding, this.config.useSafeArea ? this.app.safeArea : lr);
|
|
1892
|
-
this.layout = {
|
|
1893
|
-
paddingLeft: e.left,
|
|
1894
|
-
paddingTop: e.top,
|
|
1895
|
-
paddingRight: e.right,
|
|
1896
|
-
paddingBottom: e.bottom
|
|
1897
|
-
};
|
|
1898
|
-
}
|
|
1899
|
-
static isFlexContainer(e) {
|
|
1900
|
-
return e instanceof ir;
|
|
1901
|
-
}
|
|
1902
|
-
addChild(...e) {
|
|
1903
|
-
if (this._disableAddChildError) return super.addChild(...e);
|
|
1904
|
-
throw Error("UICanvas: Do not call addChild() directly. Use addElement(child, { align }) instead.\nExample: uiCanvas.addElement(myChild, { align: 'top right' })");
|
|
1905
|
-
}
|
|
1906
|
-
removeChild(...e) {
|
|
1907
|
-
if (this._disableAddChildError) return super.removeChild(...e);
|
|
1908
|
-
throw Error("UICanvas: Do not call removeChild() directly. Use removeElement(child) instead.");
|
|
1909
|
-
}
|
|
1910
|
-
resize() {
|
|
1911
|
-
this._applyPadding(), this.config.useAppSize ? (this.size = {
|
|
1912
|
-
width: this.app.size.width,
|
|
1913
|
-
height: this.app.size.height
|
|
1914
|
-
}, this.position.set(-this.app.size.width * .5, -this.app.size.height * .5)) : this._updateLayout();
|
|
1915
|
-
}
|
|
1916
|
-
updateLayout() {
|
|
1917
|
-
this.destroyed || !this.layout || !this.app?.renderer.layout || (this.app.renderer.layout.update(this), this._positionContainers.forEach((e) => {
|
|
1918
|
-
this.app.renderer.layout.update(e);
|
|
1919
|
-
}), 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));
|
|
1920
|
-
}
|
|
1921
|
-
bindElement(e, t, n) {
|
|
1922
|
-
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({
|
|
1923
|
-
child: e,
|
|
1924
|
-
anchor: t,
|
|
1925
|
-
place: n
|
|
1926
|
-
}), this._updateLayout();
|
|
1927
|
-
}
|
|
1928
|
-
unbindElement(e) {
|
|
1929
|
-
let t = this._bindings.some((t) => t.child === e);
|
|
1930
|
-
this._bindings = this._bindings.filter((t) => t.child !== e), t && e.parent === this && (this._disableAddChildError = !0, super.removeChild(e), this._disableAddChildError = !1);
|
|
1931
|
-
}
|
|
1932
|
-
_updateBindings() {
|
|
1933
|
-
for (let { child: e, anchor: t, place: n } of this._bindings) {
|
|
1934
|
-
let r = this._anchorRect(t);
|
|
1935
|
-
r && n(r, e);
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
_anchorRect(e) {
|
|
1939
|
-
let t = e.layout?.computedLayout;
|
|
1940
|
-
if (!t) return null;
|
|
1941
|
-
let n = 0, r = 0;
|
|
1942
|
-
for (let t = e; t && t !== this; t = t.parent) {
|
|
1943
|
-
let e = t.layout?.computedLayout;
|
|
1944
|
-
e && (n += e.left, r += e.top);
|
|
1945
|
-
}
|
|
1946
|
-
return {
|
|
1947
|
-
left: n,
|
|
1948
|
-
top: r,
|
|
1949
|
-
width: t.width,
|
|
1950
|
-
height: t.height
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
addElement(t, n) {
|
|
1954
|
-
let r = n?.align ?? "top left", i = this._positionContainers.get(r);
|
|
1955
|
-
return i ? (e.isFlexContainer(t) && this.addSignalConnection(t.onLayoutComplete.connect(this._updateLayout)), this.settingsMap.set(t, {
|
|
1956
|
-
align: r,
|
|
1957
|
-
padding: n?.padding ? I(n.padding) : {
|
|
1958
|
-
top: 0,
|
|
1959
|
-
left: 0,
|
|
1960
|
-
bottom: 0,
|
|
1961
|
-
right: 0
|
|
1962
|
-
}
|
|
1963
|
-
}), this._childMap.set(t, i), this._canvasChildren = Array.from(this._childMap.keys()), i.add.existing(t), this._childAdded(t), t) : (c.error(`UICanvas:: Invalid position "${r}" for element`), t);
|
|
1964
|
-
}
|
|
1965
|
-
removeElement(e) {
|
|
1966
|
-
let t = this._childMap.get(e);
|
|
1967
|
-
if (!t) throw Error(`UICanvas: Cannot remove element — it was not added via addElement().\nChild label: "${e.label ?? "(unlabeled)"}"`);
|
|
1968
|
-
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;
|
|
1969
|
-
}
|
|
1970
|
-
_childAdded(e) {
|
|
1971
|
-
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), _.childAdded(e), this._updateLayout();
|
|
1972
|
-
}
|
|
1973
|
-
_childRemoved(e) {
|
|
1974
|
-
this.settingsMap.delete(e), this._childMap.delete(e), this._canvasChildren = Array.from(this._childMap.keys()), _.childRemoved(e);
|
|
1975
|
-
}
|
|
1976
|
-
_added() {
|
|
1977
|
-
this._updateLayout();
|
|
1978
|
-
}
|
|
1979
|
-
get debug() {
|
|
1980
|
-
return this.config.debug;
|
|
1981
|
-
}
|
|
1982
|
-
set debug(e) {
|
|
1983
|
-
if (this.config.debug = e, e) P(`UICanvas:${this.uid}`, this.label || "UICanvas", j.outerBounds), this.drawDebug();
|
|
1984
|
-
else {
|
|
1985
|
-
F(`UICanvas:${this.uid}`), this._debugGraphics && this._debugGraphics.clear(), this._debugLabel && (this._debugLabel.visible = !1);
|
|
1986
|
-
for (let e of this._regionLabels) e.visible = !1;
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
drawDebug() {
|
|
1990
|
-
this._debugGraphics || (this._disableAddChildError = !0, this._debugGraphics = Ft(`${this.label ?? "UICanvas"}:debug`), super.addChild(this._debugGraphics), this._debugGraphics.layout = !1, this._disableAddChildError = !1), this._debugLabel || (this._disableAddChildError = !0, this._debugLabel = N(this.label || "UICanvas", j.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();
|
|
1991
|
-
let e = this.config.size.width, t = this.config.size.height, n = this.config.padding;
|
|
1992
|
-
this._debugGraphics.rect(0, 0, e, t).stroke({
|
|
1993
|
-
width: 1,
|
|
1994
|
-
color: j.outerBounds,
|
|
1995
|
-
alpha: M.stroke,
|
|
1996
|
-
pixelLine: !0
|
|
1997
|
-
}), n.top > 0 && this._debugGraphics.rect(0, 0, e, n.top).fill({
|
|
1998
|
-
color: j.outerBounds,
|
|
1999
|
-
alpha: M.fill
|
|
2000
|
-
}), n.bottom > 0 && this._debugGraphics.rect(0, t - n.bottom, e, n.bottom).fill({
|
|
2001
|
-
color: j.outerBounds,
|
|
2002
|
-
alpha: M.fill
|
|
2003
|
-
}), n.left > 0 && this._debugGraphics.rect(0, n.top, n.left, t - n.top - n.bottom).fill({
|
|
2004
|
-
color: j.outerBounds,
|
|
2005
|
-
alpha: M.fill
|
|
2006
|
-
}), n.right > 0 && this._debugGraphics.rect(e - n.right, n.top, n.right, t - n.top - n.bottom).fill({
|
|
2007
|
-
color: j.outerBounds,
|
|
2008
|
-
alpha: M.fill
|
|
2009
|
-
});
|
|
2010
|
-
let r = n.left, i = n.top, a = e - n.left - n.right, o = t - n.top - n.bottom;
|
|
2011
|
-
this._debugGraphics.rect(r, i, a, o).stroke({
|
|
2012
|
-
width: 1,
|
|
2013
|
-
color: j.innerBounds,
|
|
2014
|
-
alpha: M.stroke,
|
|
2015
|
-
pixelLine: !0
|
|
2016
|
-
});
|
|
2017
|
-
let s = /* @__PURE__ */ new Map();
|
|
2018
|
-
this._positionContainers.forEach((e, t) => {
|
|
2019
|
-
(!s.has(e) || t.length < s.get(e).length) && s.set(e, t);
|
|
2020
|
-
});
|
|
2021
|
-
let c = [...new Set(this._positionContainers.values())];
|
|
2022
|
-
for (; this._regionLabels.length < c.length;) {
|
|
2023
|
-
this._disableAddChildError = !0;
|
|
2024
|
-
let e = N("", j.region);
|
|
2025
|
-
super.addChild(e), e.layout = !1, this._regionLabels.push(e), this._disableAddChildError = !1;
|
|
2026
|
-
}
|
|
2027
|
-
c.forEach((e, t) => {
|
|
2028
|
-
if (!e.layout?.computedLayout) return;
|
|
2029
|
-
let n = e.layout.computedLayout, r = e.parent;
|
|
2030
|
-
if (!r?.layout?.computedLayout) return;
|
|
2031
|
-
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;
|
|
2032
|
-
this._debugGraphics.rect(a, o, c, l).fill({
|
|
2033
|
-
color: j.region,
|
|
2034
|
-
alpha: u ? M.fillActive : M.fill
|
|
2035
|
-
}).stroke({
|
|
2036
|
-
width: 1,
|
|
2037
|
-
color: j.region,
|
|
2038
|
-
alpha: .3,
|
|
2039
|
-
pixelLine: !0
|
|
2040
|
-
});
|
|
2041
|
-
let d = this._regionLabels[t];
|
|
2042
|
-
d.text = s.get(e) ?? "", d.visible = !0, d.position.set(a + 2, o + 2);
|
|
2043
|
-
});
|
|
2044
|
-
for (let e = c.length; e < this._regionLabels.length; e++) this._regionLabels[e].visible = !1;
|
|
2045
|
-
let l = e / 2, u = t / 2;
|
|
2046
|
-
this._debugGraphics.moveTo(l, u - 10).lineTo(l, u + 10).stroke({
|
|
2047
|
-
width: 1,
|
|
2048
|
-
color: j.outerBounds,
|
|
2049
|
-
alpha: M.crosshair,
|
|
2050
|
-
pixelLine: !0
|
|
2051
|
-
}).moveTo(l - 10, u).lineTo(l + 10, u).stroke({
|
|
2052
|
-
width: 1,
|
|
2053
|
-
color: j.outerBounds,
|
|
2054
|
-
alpha: M.crosshair,
|
|
2055
|
-
pixelLine: !0
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
}, X = null;
|
|
2059
|
-
function mr() {
|
|
2060
|
-
if (X) return X;
|
|
2061
|
-
X = /* @__PURE__ */ new Map();
|
|
2062
|
-
let e = globalThis.Caper?.get?.("entityList") ?? [];
|
|
2063
|
-
for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && X.set(t.id, t.module);
|
|
2064
|
-
return X;
|
|
2065
|
-
}
|
|
2066
|
-
function hr(e) {
|
|
2067
|
-
return mr().get(e);
|
|
2068
|
-
}
|
|
2069
|
-
function gr() {
|
|
2070
|
-
return [...mr().keys()];
|
|
2071
|
-
}
|
|
2072
|
-
//#endregion
|
|
2073
|
-
//#region src/mixins/factory/ui-registry.ts
|
|
2074
|
-
var Z = null;
|
|
2075
|
-
function _r() {
|
|
2076
|
-
if (Z) return Z;
|
|
2077
|
-
Z = /* @__PURE__ */ new Map();
|
|
2078
|
-
let e = globalThis.Caper?.get?.("uiList") ?? [];
|
|
2079
|
-
for (let t of e) t.active !== !1 && typeof t.module == "function" && t.module.prototype && Z.set(t.id, t.module);
|
|
2080
|
-
return Z;
|
|
2081
|
-
}
|
|
2082
|
-
function vr(e) {
|
|
2083
|
-
return _r().get(e);
|
|
2084
|
-
}
|
|
2085
|
-
function yr() {
|
|
2086
|
-
return [..._r().keys()];
|
|
2087
|
-
}
|
|
2088
|
-
//#endregion
|
|
2089
|
-
//#region src/mixins/factory/schema.ts
|
|
2090
|
-
var br = [
|
|
2091
|
-
"position",
|
|
2092
|
-
"scale",
|
|
2093
|
-
"pivot"
|
|
2094
|
-
], xr = [
|
|
2095
|
-
"position",
|
|
2096
|
-
"x",
|
|
2097
|
-
"y",
|
|
2098
|
-
"scale",
|
|
2099
|
-
"scaleX",
|
|
2100
|
-
"scaleY",
|
|
2101
|
-
"pivot",
|
|
2102
|
-
"anchor"
|
|
2103
|
-
];
|
|
2104
|
-
function Q(e) {
|
|
2105
|
-
let t = e.applies ?? br, n = t.includes("position"), r = t.includes("scale"), i = t.includes("pivot"), a = t.includes("anchor"), o = [...xr, ...e.exclude ?? []];
|
|
2106
|
-
return (t) => {
|
|
2107
|
-
let s = e.build(t);
|
|
2108
|
-
if (t == null) return s;
|
|
2109
|
-
let c = t;
|
|
2110
|
-
return n && G({
|
|
2111
|
-
position: c.position,
|
|
2112
|
-
x: c.x,
|
|
2113
|
-
y: c.y
|
|
2114
|
-
}, s), r && K({
|
|
2115
|
-
scale: c.scale,
|
|
2116
|
-
scaleX: c.scaleX,
|
|
2117
|
-
scaleY: c.scaleY
|
|
2118
|
-
}, s), i && q(c.pivot, s), a && Gn(c.anchor, s), H(st(o, c), s), s;
|
|
2119
|
-
};
|
|
2120
|
-
}
|
|
2121
|
-
//#endregion
|
|
2122
|
-
//#region src/mixins/factory/const.ts
|
|
2123
|
-
var Sr = [
|
|
2124
|
-
"text",
|
|
2125
|
-
"roundPixels",
|
|
2126
|
-
"resolution",
|
|
2127
|
-
"style",
|
|
2128
|
-
"anchor",
|
|
2129
|
-
"pivot"
|
|
2130
|
-
], Cr = {
|
|
2131
|
-
existing: (e, t) => {
|
|
2132
|
-
if (!t) return e;
|
|
2133
|
-
let { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ...l } = t;
|
|
2134
|
-
return G({
|
|
2135
|
-
position: n,
|
|
2136
|
-
x: r,
|
|
2137
|
-
y: i
|
|
2138
|
-
}, e), K({
|
|
2139
|
-
scale: o,
|
|
2140
|
-
scaleX: s,
|
|
2141
|
-
scaleY: c
|
|
2142
|
-
}, e), q(a, e), H(l, e), e;
|
|
2143
|
-
},
|
|
2144
|
-
container: Q({
|
|
2145
|
-
build: (e) => new _(e ? g(e, b) : void 0),
|
|
2146
|
-
applies: [
|
|
2147
|
-
"position",
|
|
2148
|
-
"scale",
|
|
2149
|
-
"pivot"
|
|
2150
|
-
],
|
|
2151
|
-
exclude: b
|
|
2152
|
-
}),
|
|
2153
|
-
particleContainer: Q({
|
|
2154
|
-
build: (e) => new Bn(e ? g(e, Rn) : void 0),
|
|
2155
|
-
applies: [
|
|
2156
|
-
"position",
|
|
2157
|
-
"scale",
|
|
2158
|
-
"pivot"
|
|
2159
|
-
],
|
|
2160
|
-
exclude: Rn
|
|
2161
|
-
}),
|
|
2162
|
-
texture: W,
|
|
2163
|
-
sprite: Q({
|
|
2164
|
-
build: (e) => new Et(e ? W(e) : void 0),
|
|
2165
|
-
applies: [
|
|
2166
|
-
"position",
|
|
2167
|
-
"scale",
|
|
2168
|
-
"pivot",
|
|
2169
|
-
"anchor"
|
|
2170
|
-
],
|
|
2171
|
-
exclude: ["asset", "sheet"]
|
|
2172
|
-
}),
|
|
2173
|
-
tilingSprite: Q({
|
|
2174
|
-
build: (e) => new Dt(e ? W(e) : void 0),
|
|
2175
|
-
applies: [
|
|
2176
|
-
"position",
|
|
2177
|
-
"scale",
|
|
2178
|
-
"pivot",
|
|
2179
|
-
"anchor"
|
|
2180
|
-
],
|
|
2181
|
-
exclude: ["asset", "sheet"]
|
|
2182
|
-
}),
|
|
2183
|
-
animatedSprite: Q({
|
|
2184
|
-
build: (e) => new Kn(e),
|
|
2185
|
-
applies: [
|
|
2186
|
-
"position",
|
|
2187
|
-
"scale",
|
|
2188
|
-
"pivot"
|
|
2189
|
-
],
|
|
2190
|
-
exclude: [
|
|
2191
|
-
"sheet",
|
|
2192
|
-
"texturePrefix",
|
|
2193
|
-
"zeroPad",
|
|
2194
|
-
"animations",
|
|
2195
|
-
"autoPlay",
|
|
2196
|
-
"autoUpdate",
|
|
2197
|
-
"defaultAnimation",
|
|
2198
|
-
"reversible",
|
|
2199
|
-
"animationSpeed",
|
|
2200
|
-
"startIndex",
|
|
2201
|
-
"animation"
|
|
2202
|
-
]
|
|
2203
|
-
}),
|
|
2204
|
-
graphics: Q({
|
|
2205
|
-
build: (e) => new E(),
|
|
2206
|
-
applies: [
|
|
2207
|
-
"position",
|
|
2208
|
-
"scale",
|
|
2209
|
-
"pivot"
|
|
2210
|
-
]
|
|
2211
|
-
}),
|
|
2212
|
-
svg(e) {
|
|
2213
|
-
let t = new Un(e.ctx), { position: n, x: r, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, ctx: l, ...u } = e;
|
|
2214
|
-
return G({
|
|
2215
|
-
position: n,
|
|
2216
|
-
x: r,
|
|
2217
|
-
y: i
|
|
2218
|
-
}, t), K({
|
|
2219
|
-
scale: o,
|
|
2220
|
-
scaleX: s,
|
|
2221
|
-
scaleY: c
|
|
2222
|
-
}, t), q(a, t), H(u, t), t;
|
|
2223
|
-
},
|
|
2224
|
-
text: Q({
|
|
2225
|
-
build: (e) => new O(e ? {
|
|
2226
|
-
text: e.text,
|
|
2227
|
-
roundPixels: e.roundPixels,
|
|
2228
|
-
resolution: e.resolution,
|
|
2229
|
-
style: e.style,
|
|
2230
|
-
anchor: e.anchor ? y(e.anchor, !0) : void 0,
|
|
2231
|
-
pivot: e.pivot ? y(e.pivot, !0) : void 0
|
|
2232
|
-
} : {}),
|
|
2233
|
-
applies: [
|
|
2234
|
-
"position",
|
|
2235
|
-
"scale",
|
|
2236
|
-
"pivot"
|
|
2237
|
-
],
|
|
2238
|
-
exclude: [...Sr]
|
|
2239
|
-
}),
|
|
2240
|
-
htmlText: Q({
|
|
2241
|
-
build: (e) => new St(e ? {
|
|
2242
|
-
text: e.text,
|
|
2243
|
-
roundPixels: e.roundPixels,
|
|
2244
|
-
resolution: e.resolution,
|
|
2245
|
-
style: e.style,
|
|
2246
|
-
anchor: e.anchor ? y(e.anchor, !0) : void 0,
|
|
2247
|
-
pivot: e.pivot ? y(e.pivot, !0) : void 0
|
|
2248
|
-
} : {}),
|
|
2249
|
-
applies: [
|
|
2250
|
-
"position",
|
|
2251
|
-
"scale",
|
|
2252
|
-
"pivot"
|
|
2253
|
-
],
|
|
2254
|
-
exclude: [...Sr]
|
|
2255
|
-
}),
|
|
2256
|
-
bitmapText: Q({
|
|
2257
|
-
build: (e) => new w(e ? {
|
|
2258
|
-
text: e.text,
|
|
2259
|
-
roundPixels: e.roundPixels,
|
|
2260
|
-
style: e.style,
|
|
2261
|
-
anchor: e.anchor ? y(e.anchor, !0) : void 0,
|
|
2262
|
-
pivot: e.pivot ? y(e.pivot, !0) : void 0
|
|
2263
|
-
} : {}),
|
|
2264
|
-
applies: [
|
|
2265
|
-
"position",
|
|
2266
|
-
"scale",
|
|
2267
|
-
"pivot"
|
|
2268
|
-
],
|
|
2269
|
-
exclude: [...Sr]
|
|
2270
|
-
}),
|
|
2271
|
-
button: Q({
|
|
2272
|
-
build: (e) => new er(e ? g(e, Qn) : void 0),
|
|
2273
|
-
applies: [
|
|
2274
|
-
"position",
|
|
2275
|
-
"scale",
|
|
2276
|
-
"pivot"
|
|
2277
|
-
],
|
|
2278
|
-
exclude: Qn
|
|
2279
|
-
}),
|
|
2280
|
-
flexContainer: Q({
|
|
2281
|
-
build: (e) => new ir(e),
|
|
2282
|
-
applies: [
|
|
2283
|
-
"position",
|
|
2284
|
-
"scale",
|
|
2285
|
-
"pivot"
|
|
2286
|
-
],
|
|
2287
|
-
exclude: rr
|
|
2288
|
-
}),
|
|
2289
|
-
uiCanvas: Q({
|
|
2290
|
-
build: (e) => new pr(e ? g(e, cr) : {}),
|
|
2291
|
-
applies: [
|
|
2292
|
-
"position",
|
|
2293
|
-
"scale",
|
|
2294
|
-
"pivot"
|
|
2295
|
-
],
|
|
2296
|
-
exclude: cr
|
|
2297
|
-
}),
|
|
2298
|
-
spine: Q({
|
|
2299
|
-
build: (e) => {
|
|
2300
|
-
let t = "", n = e?.data;
|
|
2301
|
-
if (typeof n == "string") {
|
|
2302
|
-
let e = n.slice(-5);
|
|
2303
|
-
e !== ".json" && e !== ".skel" ? e = ".json" : t = n.substring(0, n.length - 5), t = {
|
|
2304
|
-
skeleton: n + e,
|
|
2305
|
-
atlas: n + ".atlas"
|
|
2306
|
-
};
|
|
2307
|
-
}
|
|
2308
|
-
let r = window.Spine.from(t);
|
|
2309
|
-
return e?.autoUpdate !== void 0 && (r.autoUpdate = e.autoUpdate), e?.animationName && r.state.setAnimation(e.trackIndex ?? 0, e.animationName, e.loop), r;
|
|
2310
|
-
},
|
|
2311
|
-
applies: [
|
|
2312
|
-
"position",
|
|
2313
|
-
"scale",
|
|
2314
|
-
"pivot",
|
|
2315
|
-
"anchor"
|
|
2316
|
-
],
|
|
2317
|
-
exclude: [
|
|
2318
|
-
"data",
|
|
2319
|
-
"autoUpdate",
|
|
2320
|
-
"animationName",
|
|
2321
|
-
"trackIndex",
|
|
2322
|
-
"loop"
|
|
2323
|
-
]
|
|
2324
|
-
}),
|
|
2325
|
-
spineAnimation: (e) => {
|
|
2326
|
-
let t = new Xn(e);
|
|
2327
|
-
if (!e) return t;
|
|
2328
|
-
let { position: n, x: r, y: i, anchor: a, pivot: o, scale: s, scaleX: c, scaleY: l, ...u } = e;
|
|
2329
|
-
return G({
|
|
2330
|
-
position: n,
|
|
2331
|
-
x: r,
|
|
2332
|
-
y: i
|
|
2333
|
-
}, t), K({
|
|
2334
|
-
scale: s,
|
|
2335
|
-
scaleX: c,
|
|
2336
|
-
scaleY: l
|
|
2337
|
-
}, t), Gn(a, t), q(o, t), H(u, t), t;
|
|
2338
|
-
},
|
|
2339
|
-
toaster: (e, t = {}) => new sr(e, t),
|
|
2340
|
-
entity: (e, t) => {
|
|
2341
|
-
let n = hr(e);
|
|
2342
|
-
if (!n) {
|
|
2343
|
-
let t = gr();
|
|
2344
|
-
throw Error(`[caper] Unknown entity id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
|
|
2345
|
-
}
|
|
2346
|
-
let r = new n(t);
|
|
2347
|
-
if (t) {
|
|
2348
|
-
let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
|
|
2349
|
-
G({
|
|
2350
|
-
position: e,
|
|
2351
|
-
x: n,
|
|
2352
|
-
y: i
|
|
2353
|
-
}, r), K({
|
|
2354
|
-
scale: o,
|
|
2355
|
-
scaleX: s,
|
|
2356
|
-
scaleY: c
|
|
2357
|
-
}, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
|
|
2358
|
-
}
|
|
2359
|
-
return r;
|
|
2360
|
-
},
|
|
2361
|
-
ui: (e, t) => {
|
|
2362
|
-
let n = vr(e);
|
|
2363
|
-
if (!n) {
|
|
2364
|
-
let t = yr();
|
|
2365
|
-
throw Error(`[caper] Unknown ui id '${String(e)}'. Known: ${t.length > 0 ? t.map((e) => `'${e}'`).join(", ") : "(none — discovery may have failed)"}`);
|
|
2366
|
-
}
|
|
2367
|
-
let r = new n(t);
|
|
2368
|
-
if (t) {
|
|
2369
|
-
let { position: e, x: n, y: i, pivot: a, scale: o, scaleX: s, scaleY: c, alpha: l, visible: u } = t;
|
|
2370
|
-
G({
|
|
2371
|
-
position: e,
|
|
2372
|
-
x: n,
|
|
2373
|
-
y: i
|
|
2374
|
-
}, r), K({
|
|
2375
|
-
scale: o,
|
|
2376
|
-
scaleX: s,
|
|
2377
|
-
scaleY: c
|
|
2378
|
-
}, r), q(a, r), l !== void 0 && (r.alpha = l), u !== void 0 && (r.visible = u);
|
|
2379
|
-
}
|
|
2380
|
-
return r;
|
|
2381
|
-
}
|
|
2382
|
-
};
|
|
2383
|
-
we(Cr);
|
|
2384
|
-
//#endregion
|
|
2385
|
-
//#region src/mixins/factory/props.ts
|
|
2386
|
-
var wr = [
|
|
628
|
+
}, Qn = [
|
|
2387
629
|
"text",
|
|
2388
630
|
"anchor",
|
|
2389
631
|
"roundPixels",
|
|
2390
632
|
"style",
|
|
2391
633
|
"pivot"
|
|
2392
|
-
],
|
|
634
|
+
], Q = {
|
|
2393
635
|
value: "",
|
|
2394
636
|
type: "text",
|
|
2395
637
|
fixed: !0,
|
|
@@ -2428,32 +670,32 @@ var wr = [
|
|
|
2428
670
|
scale: 1,
|
|
2429
671
|
marginTop: 60
|
|
2430
672
|
}
|
|
2431
|
-
},
|
|
673
|
+
}, $n = [
|
|
2432
674
|
"text",
|
|
2433
675
|
"password",
|
|
2434
676
|
"number",
|
|
2435
677
|
"email",
|
|
2436
678
|
"tel",
|
|
2437
679
|
"url"
|
|
2438
|
-
],
|
|
680
|
+
], er = class e extends T(E(y(b))) {
|
|
2439
681
|
constructor(e, t = !1, n = null) {
|
|
2440
682
|
if (super({
|
|
2441
683
|
autoUpdate: !0,
|
|
2442
684
|
autoResize: !t
|
|
2443
685
|
}), this.isClone = t, this.clone = n, this.onEnter = new p(), this.onChange = new p(), this.onError = new p(), this._lastWidth = 0, this._lastHeight = 0, this._placeholderPositioned = !1, this._placeholderAnimating = !1, this._caretPosition = -1, this._value = "", this.options = {
|
|
2444
|
-
|
|
686
|
+
...Q,
|
|
2445
687
|
...e,
|
|
2446
688
|
style: {
|
|
2447
|
-
|
|
689
|
+
...Q.style,
|
|
2448
690
|
...e?.style ?? {}
|
|
2449
691
|
},
|
|
2450
|
-
padding:
|
|
692
|
+
padding: D(e.padding ?? Q.padding),
|
|
2451
693
|
bg: {
|
|
2452
|
-
|
|
694
|
+
...Q.bg,
|
|
2453
695
|
...e.bg ?? {}
|
|
2454
696
|
},
|
|
2455
697
|
focusOverlay: {
|
|
2456
|
-
|
|
698
|
+
...Q.focusOverlay,
|
|
2457
699
|
...e.focusOverlay ?? {}
|
|
2458
700
|
}
|
|
2459
701
|
}, this.options.layout && typeof this.options.layout == "object" ? this.layout = { ...this.options.layout } : this.layout = { transformOrigin: "top left" }, this.options.placeholder || (this.options.placeholder = { color: Number(this.options.style?.fill) ?? 6710886 }), this._inner = this.add.container({ layout: {
|
|
@@ -2480,7 +722,7 @@ var wr = [
|
|
|
2480
722
|
width: "100%",
|
|
2481
723
|
height: "100%"
|
|
2482
724
|
}
|
|
2483
|
-
}), this._placeholderContainer.eventMode = "none", this.addSelection(), this.addCaret(), this.addInput(), this.addPlaceholder(), this.placeholder.text = this.options.placeholder.text || `Enter ${this.options.type}`, this.input.eventMode = this.placeholder.eventMode = "none",
|
|
725
|
+
}), this._placeholderContainer.eventMode = "none", this.addSelection(), this.addCaret(), this.addInput(), this.addPlaceholder(), this.placeholder.text = this.options.placeholder.text || `Enter ${this.options.type}`, this.input.eventMode = this.placeholder.eventMode = "none", L && this.addSignalConnection(this.onInteraction("pointertap").connect(this.handleClick, -1)), this.addSignalConnection(this.onInteraction("click").connect(this.handleClick, -1)), this.options.fixed) {
|
|
2484
726
|
let e = this.isClone ? this.clone?.options?.focusOverlay?.scale ?? 1 : 1;
|
|
2485
727
|
this._mask = this._inner.add.graphics().rect(0, 0, this.bg.width * e - this.options.padding.left - this.options.padding.right, this.bg.height * e - this.options.padding.top - this.options.padding.bottom).fill({ color: 0 }), this._inputContainer.mask = this._mask;
|
|
2486
728
|
}
|
|
@@ -2528,7 +770,7 @@ var wr = [
|
|
|
2528
770
|
handleClick(e) {
|
|
2529
771
|
if (e?.originalEvent?.key) return;
|
|
2530
772
|
clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer);
|
|
2531
|
-
let t = e ?
|
|
773
|
+
let t = e ? B(this.input, e) : this.input.text?.length ?? 0;
|
|
2532
774
|
this.createDomElement(t);
|
|
2533
775
|
}
|
|
2534
776
|
focusIn() {
|
|
@@ -2582,7 +824,7 @@ var wr = [
|
|
|
2582
824
|
if (this.placeholder.visible = !0, !this.isClone && this._placeholderPositioned && !this._placeholderAnimating) {
|
|
2583
825
|
this._placeholderAnimating = !0;
|
|
2584
826
|
let e = this.input.x, t = this.input.y;
|
|
2585
|
-
this.options.placeholder.animationOnType ? this.addAnimation([
|
|
827
|
+
this.options.placeholder.animationOnType ? this.addAnimation([N.to(this.placeholder, {
|
|
2586
828
|
x: e,
|
|
2587
829
|
y: t,
|
|
2588
830
|
tint: 16777215,
|
|
@@ -2593,7 +835,7 @@ var wr = [
|
|
|
2593
835
|
onComplete: () => {
|
|
2594
836
|
this._placeholderPositioned = !1, this._placeholderAnimating = !1;
|
|
2595
837
|
}
|
|
2596
|
-
}),
|
|
838
|
+
}), N.to(this.placeholder.scale, {
|
|
2597
839
|
x: 1,
|
|
2598
840
|
y: 1,
|
|
2599
841
|
duration: this.options.placeholder.animationOnType.duration || .4,
|
|
@@ -2614,11 +856,11 @@ var wr = [
|
|
|
2614
856
|
break;
|
|
2615
857
|
}
|
|
2616
858
|
if (this.options.placeholder.offsetOnType) {
|
|
2617
|
-
let n =
|
|
859
|
+
let n = x(this.options.placeholder.offsetOnType);
|
|
2618
860
|
e += n.x, t += n.y;
|
|
2619
861
|
}
|
|
2620
862
|
if (this.options.placeholder.animationOnType) {
|
|
2621
|
-
if (this.addAnimation(
|
|
863
|
+
if (this.addAnimation(N.to(this.placeholder, {
|
|
2622
864
|
x: e,
|
|
2623
865
|
y: t,
|
|
2624
866
|
duration: this.options.placeholder.animationOnType.duration || .4,
|
|
@@ -2627,8 +869,8 @@ var wr = [
|
|
|
2627
869
|
alpha: this.options.placeholder.animationOnType.alpha ?? this.options.placeholder.alpha ?? 1,
|
|
2628
870
|
overwrite: !0
|
|
2629
871
|
})), this.options.placeholder.scaleOnType) {
|
|
2630
|
-
let e =
|
|
2631
|
-
this.addAnimation(
|
|
872
|
+
let e = x(this.options.placeholder.scaleOnType);
|
|
873
|
+
this.addAnimation(N.to(this.placeholder.scale, {
|
|
2632
874
|
x: e.x,
|
|
2633
875
|
y: e.y,
|
|
2634
876
|
duration: this.options.placeholder.animationOnType.duration || .4,
|
|
@@ -2674,7 +916,7 @@ var wr = [
|
|
|
2674
916
|
}
|
|
2675
917
|
addCaret() {
|
|
2676
918
|
this.caret = this._inputContainer.add.sprite({
|
|
2677
|
-
asset:
|
|
919
|
+
asset: j.WHITE,
|
|
2678
920
|
width: 3,
|
|
2679
921
|
height: 10,
|
|
2680
922
|
tint: this.options.caret.color ?? 0,
|
|
@@ -2715,9 +957,9 @@ var wr = [
|
|
|
2715
957
|
this.domElement = this.clone.domElement, this._addDomElementListeners();
|
|
2716
958
|
return;
|
|
2717
959
|
}
|
|
2718
|
-
clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer), this.domElement = document.createElement("input"), this.domElement.type = "text", this.options.type &&
|
|
960
|
+
clearTimeout(this._focusTimer), clearTimeout(this._pointerDownTimer), this.domElement = document.createElement("input"), this.domElement.type = "text", this.options.type && $n.includes(this.options.type) && (this.domElement.type = this.options.type), this.options.pattern && (this.domElement.pattern = this.options.pattern), this.options.regex && (this._regex = this.options.regex);
|
|
2719
961
|
let t = this.getGlobalPosition(), n = this.getBounds();
|
|
2720
|
-
n.x = t.x, n.y = t.y, n.width = this.width - this.options.padding.left, this.domElement.style.position = "fixed", this.domElement.style.border = "none", this.domElement.style.outline = "none", this.domElement.style.left =
|
|
962
|
+
n.x = t.x, n.y = t.y, n.width = this.width - this.options.padding.left, this.domElement.style.position = "fixed", this.domElement.style.border = "none", this.domElement.style.outline = "none", this.domElement.style.left = z ? "0" : `${n.left}px`, this.domElement.style.top = z ? "0" : `${n.top}px`, this.domElement.style.width = `${n.width}px`, this.domElement.style.height = `${n.height}px`, this.domElement.style.padding = "0", this.options.debug ? this.domElement.style.opacity = "0.8" : this.domElement.style.opacity = "0.0000001", this.app.canvas.parentElement?.appendChild(this.domElement), this.domElement.value = this.value, this.domElement.setAttribute("placeholder", this.options?.placeholder?.text ?? ""), this.options?.maxLength && this.domElement.setAttribute("maxLength", this.options.maxLength.toString()), this._addDomElementListeners(), this._focusDomElement(e);
|
|
2721
963
|
}
|
|
2722
964
|
destroyDomElement() {
|
|
2723
965
|
this.isClone || (this.domElement &&= (this._removeDomElementListeners(), this.domElement.remove(), this.domElement.parentNode && this.domElement.parentNode.removeChild(this.domElement), null));
|
|
@@ -2729,7 +971,7 @@ var wr = [
|
|
|
2729
971
|
this.cursorAnimation?.kill(), this.caret.visible = !1;
|
|
2730
972
|
}
|
|
2731
973
|
blinkCaret() {
|
|
2732
|
-
this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation =
|
|
974
|
+
this.cursorAnimation && this.cursorAnimation.kill(), this.cursorAnimation = N.fromTo(this.caret, { alpha: 0 }, {
|
|
2733
975
|
duration: .5,
|
|
2734
976
|
alpha: 1,
|
|
2735
977
|
yoyo: !0,
|
|
@@ -2762,15 +1004,15 @@ var wr = [
|
|
|
2762
1004
|
let n = Array.isArray(this.options.focusOverlay.activeFilter), r = !1;
|
|
2763
1005
|
if (n) {
|
|
2764
1006
|
let e = this.options.focusOverlay.activeFilter;
|
|
2765
|
-
(
|
|
1007
|
+
(R && e.includes("mobile") || L && e.includes("touch") || !R && !L && e.includes("desktop")) && (r = !0);
|
|
2766
1008
|
} else r = typeof this.options.focusOverlay.activeFilter == "function" ? this.options.focusOverlay.activeFilter() : t;
|
|
2767
1009
|
if (r) {
|
|
2768
1010
|
let t = structuredClone(this.options), n = this.options.focusOverlay?.scale || 1;
|
|
2769
1011
|
t.focusOverlay = { activeFilter: !1 };
|
|
2770
|
-
let r = Number(t.style?.fontSize ||
|
|
1012
|
+
let r = Number(t.style?.fontSize || Q.style?.fontSize || 20) * n;
|
|
2771
1013
|
if (t.style ||= {}, t.style.fontSize = r, t.padding && (t.padding.left *= n, t.padding.top *= n, t.padding.right *= n, t.padding.bottom *= n), t.bg?.radius && (t.bg.radius *= n), t.bg?.stroke?.width && (t.bg.stroke.width *= n), t.minWidth && (t.minWidth *= n, t.minWidth > this.app.size.width && (t.minWidth = this.app.size.width - (t.bg?.stroke?.width ? t.bg.stroke.width * 2 + 20 : 20))), this.options.focusOverlay?.backing?.active) {
|
|
2772
1014
|
let e = this.make.sprite({
|
|
2773
|
-
asset:
|
|
1015
|
+
asset: j.WHITE,
|
|
2774
1016
|
tint: this.options.focusOverlay.backing.options?.color ?? 0,
|
|
2775
1017
|
alpha: this.options.focusOverlay.backing.options?.alpha ?? .8,
|
|
2776
1018
|
width: this.app.size.width,
|
|
@@ -2785,12 +1027,12 @@ var wr = [
|
|
|
2785
1027
|
}
|
|
2786
1028
|
}
|
|
2787
1029
|
_showCloneOverlay() {
|
|
2788
|
-
this.cloneOverlay.pivot.y = -20, this.addAnimation(
|
|
1030
|
+
this.cloneOverlay.pivot.y = -20, this.addAnimation(N.to(this.cloneOverlay, {
|
|
2789
1031
|
duration: .5,
|
|
2790
1032
|
alpha: .8,
|
|
2791
1033
|
ease: "sine.out",
|
|
2792
1034
|
delay: .1
|
|
2793
|
-
})), this.addAnimation(
|
|
1035
|
+
})), this.addAnimation(N.to(this.cloneOverlay.pivot, {
|
|
2794
1036
|
duration: .5,
|
|
2795
1037
|
y: 0,
|
|
2796
1038
|
ease: "sine.out",
|
|
@@ -2827,11 +1069,11 @@ var wr = [
|
|
|
2827
1069
|
return;
|
|
2828
1070
|
}
|
|
2829
1071
|
let e = this.domElement.selectionStart || 0, t = this.domElement.selectionEnd || -1, n = this.domElement.selectionDirection, r = "", i = this.options.type === "password" ? this.input.text : this._value;
|
|
2830
|
-
if (t === void 0) r = i.substring(0, e), this._caretPosition =
|
|
1072
|
+
if (t === void 0) r = i.substring(0, e), this._caretPosition = O.measureText(r, this.input.style).width, this._selectionRect = null;
|
|
2831
1073
|
else {
|
|
2832
1074
|
r = i.substring(e > t ? t : e, e > t ? e : t);
|
|
2833
|
-
let a = i.substring(0, e > t ? t : e), o =
|
|
2834
|
-
this._selectionRect = new
|
|
1075
|
+
let a = i.substring(0, e > t ? t : e), o = O.measureText(a, this.input.style), s = O.measureText(r, this.input.style);
|
|
1076
|
+
this._selectionRect = new tn(o.width, 0, s.width, this.input.height), this._caretPosition = n === "backward" ? this._selectionRect.left : this._selectionRect.left + this._selectionRect.width;
|
|
2835
1077
|
}
|
|
2836
1078
|
}
|
|
2837
1079
|
_handleDomElementChange(e) {
|
|
@@ -2850,17 +1092,17 @@ var wr = [
|
|
|
2850
1092
|
let e = this._inputContainer.getBounds();
|
|
2851
1093
|
return e.width = this._lastWidth, e.height = this._lastHeight, e;
|
|
2852
1094
|
}
|
|
2853
|
-
},
|
|
1095
|
+
}, tr = class extends b {
|
|
2854
1096
|
constructor(e) {
|
|
2855
|
-
if (super(), this.onChange = new p(), this.onStart = new p(), this.onEnd = new p(), this.onDestroy = new p(), this.outerRadius = 0, this.innerRadius = 0, this.innerAlphaStandby = .5, this.dragging = !1, this.pointData = new
|
|
1097
|
+
if (super(), this.onChange = new p(), this.onStart = new p(), this.onEnd = new p(), this.onDestroy = new p(), this.outerRadius = 0, this.innerRadius = 0, this.innerAlphaStandby = .5, this.dragging = !1, this.pointData = new A(), this.direction = W.None, this.settings = Object.assign({
|
|
2856
1098
|
outerScale: 1,
|
|
2857
1099
|
innerScale: 1
|
|
2858
1100
|
}, e), !this.settings.outer) {
|
|
2859
|
-
let e = new
|
|
1101
|
+
let e = new k();
|
|
2860
1102
|
e.circle(0, 0, 60).fill({ color: 0 }), e.alpha = .5, this.settings.outer = e;
|
|
2861
1103
|
}
|
|
2862
1104
|
if (!this.settings.inner) {
|
|
2863
|
-
let e = new
|
|
1105
|
+
let e = new k();
|
|
2864
1106
|
e.circle(0, 0, 35).fill({ color: 0 }), e.alpha = this.innerAlphaStandby, this.settings.inner = e;
|
|
2865
1107
|
}
|
|
2866
1108
|
this.threshold = this.settings.threshold ?? .01, this.initialize();
|
|
@@ -2870,12 +1112,12 @@ var wr = [
|
|
|
2870
1112
|
}
|
|
2871
1113
|
handleDragMove(e) {
|
|
2872
1114
|
if (!this.dragging || e.pointerId !== this._pointerId) return;
|
|
2873
|
-
let t = this.toLocal(e.global), n = t.x - this.startPosition.x, r = t.y - this.startPosition.y, i = new
|
|
1115
|
+
let t = this.toLocal(e.global), n = t.x - this.startPosition.x, r = t.y - this.startPosition.y, i = new A(0, 0), a = 0, o = W.None;
|
|
2874
1116
|
if (n == 0 && r == 0) {
|
|
2875
1117
|
this.direction = o;
|
|
2876
1118
|
return;
|
|
2877
1119
|
}
|
|
2878
|
-
if (n === 0 && (r > 0 ? (i.set(0, r > this.outerRadius ? this.outerRadius : r), a = 270, o =
|
|
1120
|
+
if (n === 0 && (r > 0 ? (i.set(0, r > this.outerRadius ? this.outerRadius : r), a = 270, o = W.Bottom) : (i.set(0, -(Math.abs(r) > this.outerRadius ? this.outerRadius : Math.abs(r))), a = 90, o = W.Top), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
|
|
2879
1121
|
this.direction = o, this.onChange.emit({
|
|
2880
1122
|
angle: a,
|
|
2881
1123
|
direction: o,
|
|
@@ -2883,7 +1125,7 @@ var wr = [
|
|
|
2883
1125
|
});
|
|
2884
1126
|
return;
|
|
2885
1127
|
}
|
|
2886
|
-
if (r === 0 && (n > 0 ? (i.set(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n), 0), a = 0, o =
|
|
1128
|
+
if (r === 0 && (n > 0 ? (i.set(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n), 0), a = 0, o = W.Right) : (i.set(-(Math.abs(n) > this.outerRadius ? this.outerRadius : Math.abs(n)), 0), a = 180, o = W.Left), this.inner.position.set(i.x, i.y), this.power = this.getPower(i), this.power >= this.threshold)) {
|
|
2887
1129
|
this.direction = o, this.onChange.emit({
|
|
2888
1130
|
angle: a,
|
|
2889
1131
|
direction: o,
|
|
@@ -2907,7 +1149,7 @@ var wr = [
|
|
|
2907
1149
|
this._pointerId === void 0 && (this._pointerId = e.pointerId, this.startPosition = this.toLocal(e.global), this.dragging = !0, this.inner.alpha = 1, this.onStart.emit());
|
|
2908
1150
|
}
|
|
2909
1151
|
handleDragEnd(e) {
|
|
2910
|
-
this._pointerId === e.pointerId && (this.direction =
|
|
1152
|
+
this._pointerId === e.pointerId && (this.direction = W.None, this.inner.position.set(0, 0), this.dragging = !1, this.inner.alpha = this.innerAlphaStandby, this.onEnd.emit(), this._pointerId = void 0);
|
|
2911
1153
|
}
|
|
2912
1154
|
bindEvents() {
|
|
2913
1155
|
this.eventMode = "static", this.on("pointerdown", this.handleDragStart).on("pointerup", this.handleDragEnd).on("pointerupoutside", this.handleDragEnd).on("pointermove", this.handleDragMove), window.addEventListener("pointerup", this.handleDragEnd);
|
|
@@ -2918,24 +1160,24 @@ var wr = [
|
|
|
2918
1160
|
}
|
|
2919
1161
|
getDirection(e) {
|
|
2920
1162
|
let t = Math.atan2(e.y, e.x);
|
|
2921
|
-
return t >= -Math.PI / 8 && t < 0 || t >= 0 && t < Math.PI / 8 ?
|
|
1163
|
+
return t >= -Math.PI / 8 && t < 0 || t >= 0 && t < Math.PI / 8 ? W.Right : t >= Math.PI / 8 && t < 3 * Math.PI / 8 ? W.BottomRight : t >= 3 * Math.PI / 8 && t < 5 * Math.PI / 8 ? W.Bottom : t >= 5 * Math.PI / 8 && t < 7 * Math.PI / 8 ? W.BottomLeft : t >= 7 * Math.PI / 8 && t < Math.PI || t >= -Math.PI && t < -7 * Math.PI / 8 ? W.Left : t >= -7 * Math.PI / 8 && t < -5 * Math.PI / 8 ? W.TopLeft : t >= -5 * Math.PI / 8 && t < -3 * Math.PI / 8 ? W.Top : W.TopRight;
|
|
2922
1164
|
}
|
|
2923
|
-
},
|
|
1165
|
+
}, nr = {
|
|
2924
1166
|
color: 0,
|
|
2925
1167
|
alpha: .75
|
|
2926
|
-
},
|
|
1168
|
+
}, $ = {
|
|
2927
1169
|
backing: !0,
|
|
2928
1170
|
closeOnEscape: !0,
|
|
2929
1171
|
closeOnPointerDownOutside: !0,
|
|
2930
1172
|
actionContext: "popup"
|
|
2931
|
-
},
|
|
1173
|
+
}, rr = class e extends b {
|
|
2932
1174
|
get actionContext() {
|
|
2933
1175
|
return this.config.actionContext;
|
|
2934
1176
|
}
|
|
2935
1177
|
constructor(e, t = {}) {
|
|
2936
1178
|
super(), this.id = e, this.isShowing = !1, this._storedActionContext = void 0, this.config = Object.assign({
|
|
2937
1179
|
id: e,
|
|
2938
|
-
|
|
1180
|
+
...$
|
|
2939
1181
|
}, t), this._initialize();
|
|
2940
1182
|
}
|
|
2941
1183
|
get data() {
|
|
@@ -2944,7 +1186,7 @@ var wr = [
|
|
|
2944
1186
|
static makeBacking(e, t) {
|
|
2945
1187
|
let n = {};
|
|
2946
1188
|
typeof e == "object" && (n = e);
|
|
2947
|
-
let r = Object.assign({ ...
|
|
1189
|
+
let r = Object.assign({ ...nr }, n), i = new nn(j.WHITE);
|
|
2948
1190
|
return i.anchor.set(.5), i.alpha = r.alpha, i.tint = r.color, i.width = t.width, i.height = t.height, i;
|
|
2949
1191
|
}
|
|
2950
1192
|
initialize() {}
|
|
@@ -2986,7 +1228,7 @@ var wr = [
|
|
|
2986
1228
|
restoreActionContext() {
|
|
2987
1229
|
this._storedActionContext && (c.log("Popup", "Restoring action context", this._storedActionContext), this.app.actionContext = this._storedActionContext), this._storedActionContext = void 0;
|
|
2988
1230
|
}
|
|
2989
|
-
},
|
|
2990
|
-
export {
|
|
1231
|
+
}, ir = h.Collector, ar = h.CollectorArray, or = h.CollectorLast, sr = h.CollectorUntil0, cr = h.CollectorWhile0, lr = h.SignalConnections;
|
|
1232
|
+
export { g as ActionsPlugin, Le as Animated, Yt as AnimatedSprite, S as Application, ve as AssetsPlugin, Ue as AudioChannel, oe as AudioInstance, s as AudioManagerPlugin, t as BreakpointPlugin, zt as Button, Pt as ButtonConfigKeys, Xn as Camera, Zn as CameraController, u as CaperEvent, ir as Collector, ar as CollectorArray, or as CollectorLast, sr as CollectorUntil0, cr as CollectorWhile0, ln as Color, b as Container, Qe as ContainerConfigKeys, we as Controls, Qt as DataAdapter, It as DebugAlpha, Ct as DebugColors, ie as DefaultActionContexts, _ as DefaultActionContextsArray, ce as DefaultActions, d as DefaultButtonIds, qn as Entity, qe as Factory, Mt as FlexContainer, Nt as FlexContainerConfigKeys, he as FocusManagerPlugin, l as FocusOutliner, T as Focusable, r as FullScreenPlugin, a as GesturePlugin, er as Input, dt as InputControllerTypes, Fe as InputPlugin, E as Interactive, Ln as JOYSTICK_DIRECTIONS, tr as Joystick, W as JoystickDirection, pt as KeyboardControls, de as KeyboardPlugin, c as Logger, ze as LookupPlugin, Tt as ParticleContainer, Lt as ParticleContainerConfigKeys, ee as Plugin, rr as Popup, je as PopupManagerPlugin, ft as Queue, ot as ResizerPlugin, Jn as Scene, Ge as SceneManagerPlugin, Yn as SceneTransition, p as Signal, lr as SignalConnections, Kt as SpineAnimation, be as Store, vt as Svg, Qn as TextPropsKeys, Ze as Timer, nt as TimerPlugin, Rt as Toast, jt as Toaster, C as TouchControls, C as VirtualControls, kt as UICanvas, Vt as UICanvasConfigKeys, Ee as WebEventsPlugin, y as WithSignals, e as add, Ne as addToPoint, v as bindAllMethods, le as bindMethods, te as bool, se as capitalize, We as capitalizeWords, Tn as center, f as checkAndInvokeMethod, Je as clamp, Wt as computeEffectivePadding, it as coreFunctionRegistry, Ye as coreSignalRegistry, Kn as create, Z as createContainer, wt as createDebugGraphics, Et as createDebugLabel, _e as createFactoryMethods, me as createQueue, Pe as debounce, Ke as deepMerge, m as defaultActionsList, Ve as defaultBreakpoints, Bt as defaultFactoryMethods, lt as defaultGestureOptions, Gt as defaultToastConfig, Pn as defineActions, In as defineBreakpoints, Fn as defineButtons, Se as defineConfig, Nn as defineContexts, Rn as defineControls, Zt as defineData, pn as defineEntity, dn as definePlugin, fn as definePopup, un as defineScene, mn as defineUI, o as delay, on as destroyCanvas, at as distance, Xe as distanceSq, D as ensurePadding, n as env, On as filterSet, kn as firstFromSet, re as floatBetween, fe as floatBetweenPoint, ke as formatTime, xe as generatePluginList, bt as getDebugRegistry, Oe as getDynamicModuleFromImportListItem, At as getErrorTexture, Ie as getFirstMapEntry, Te as getLastMapEntry, B as getNearestCharacterIndex, ct as getNextMapEntry, ue as getOrientation, mt as getPreviousMapEntry, an as getRandomElement, Ft as getRegisteredEntityIds, Ut as getRegisteredUIIds, gt as getZeroPaddedNumber, pe as i18nPlugin, Hn as installCaperGlobal, w as intBetween, i as intBetweenPoint, z as isAndroid, He as isDev, Cn as isIos, R as isMobile, ae as isProduction, ut as isPromise, Sn as isRetina, et as isStorageCapable, Ht as isText, L as isTouch, An as lastFromSet, Re as lerp, tt as lerpPoint, Be as magnitude, De as multiply, ht as normalizeKey, gn as objectDiagonal, wn as offset, yn as offsetShape, bn as offsetSimpleShape, st as omitKeys, H as pixiVersion, Me as pluck, ye as randomUUID, hn as reParent, Y as registerCaperApp, xt as registerDebug, Jt as resolveAnchor, Xt as resolvePadding, Dt as resolvePivot, x as resolvePointLike, _t as resolvePosition, qt as resolveScale, $e as resolveSizeLike, Ot as resolveTexture, yt as resolveUnknownKeys, U as sayHello, En as scale, I as scaleToHeight, xn as scaleToSize, F as scaleToWidth, P as scaleUniform, vn as sendToBack, _n as sendToFront, rn as shuffle, X as signalCaperReady, Dn as size, Ce as sortPluginsByRequires, rt as subtract, Ae as subtractFromPoint, sn as toHex, cn as toRgb, St as unregisterDebug, V as version, ge as wait };
|
|
2991
1233
|
|
|
2992
1234
|
//# sourceMappingURL=caper.mjs.map
|