@number10/phaserjsx 0.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/clip/stencil-clip.d.ts +86 -0
- package/dist/clip/stencil-clip.d.ts.map +1 -0
- package/dist/components/appliers/applyGestures.d.ts.map +1 -1
- package/dist/components/creators/createGestures.d.ts.map +1 -1
- package/dist/components/custom/CharText/CharText.d.ts.map +1 -1
- package/dist/components/custom/Dialog.d.ts +1 -1
- package/dist/components/custom/Divider.d.ts +1 -1
- package/dist/components/custom/Graphics.d.ts +1 -1
- package/dist/components/custom/Graphics.d.ts.map +1 -1
- package/dist/components/custom/Icon.d.ts.map +1 -1
- package/dist/components/custom/Image.d.ts.map +1 -1
- package/dist/components/custom/Joystick.d.ts +1 -1
- package/dist/components/custom/NineSlice.d.ts.map +1 -1
- package/dist/components/custom/Particles.d.ts +1 -1
- package/dist/components/custom/Particles.d.ts.map +1 -1
- package/dist/components/custom/Portal.d.ts.map +1 -1
- package/dist/components/custom/RefOriginView.d.ts +1 -1
- package/dist/components/custom/ScrollView.d.ts.map +1 -1
- package/dist/components/custom/Sprite.d.ts +1 -1
- package/dist/components/custom/Sprite.d.ts.map +1 -1
- package/dist/components/custom/Text.d.ts.map +1 -1
- package/dist/components/custom/TileSprite.d.ts +1 -1
- package/dist/components/custom/TileSprite.d.ts.map +1 -1
- package/dist/components/custom/View.d.ts.map +1 -1
- package/dist/components/custom/index.cjs +34 -36
- package/dist/components/custom/index.js +2 -37
- package/dist/components/primitives/graphics.d.ts.map +1 -1
- package/dist/components/primitives/image.d.ts.map +1 -1
- package/dist/components/primitives/nineslice.d.ts.map +1 -1
- package/dist/components/primitives/particles.d.ts.map +1 -1
- package/dist/components/primitives/sprite.d.ts.map +1 -1
- package/dist/components/primitives/text.d.ts.map +1 -1
- package/dist/components/primitives/tilesprite.d.ts.map +1 -1
- package/dist/components/primitives/view.d.ts.map +1 -1
- package/dist/custom-BN31OAJq.cjs +30826 -0
- package/dist/custom-BN31OAJq.cjs.map +1 -0
- package/dist/custom-oy3mBnrW.js +29562 -0
- package/dist/custom-oy3mBnrW.js.map +1 -0
- package/dist/fx/fx-creators/blur.d.ts.map +1 -1
- package/dist/fx/fx-creators/color-matrix.d.ts.map +1 -1
- package/dist/fx/fx-creators/glow.d.ts.map +1 -1
- package/dist/fx/fx-creators/pixelate.d.ts.map +1 -1
- package/dist/fx/fx-creators/shadow.d.ts.map +1 -1
- package/dist/fx/fx-creators/vignette.d.ts.map +1 -1
- package/dist/fx/use-fx.d.ts +3 -3
- package/dist/fx/use-fx.d.ts.map +1 -1
- package/dist/gestures/gesture-manager.d.ts +3 -1
- package/dist/gestures/gesture-manager.d.ts.map +1 -1
- package/dist/gestures/gesture-types.d.ts +1 -1
- package/dist/gestures/gesture-types.d.ts.map +1 -1
- package/dist/index.cjs +1547 -2837
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1356 -2866
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +12 -7
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.js +11 -11
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs +55 -33
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.js +56 -37
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/layout/layout-engine.d.ts.map +1 -1
- package/dist/scripts/generate-icon-loaders.js +146 -143
- package/dist/scripts/generate-icon-types.js +94 -83
- package/dist/scripts/generate-icons.d.ts +1 -2
- package/dist/scripts/generate-icons.d.ts.map +1 -1
- package/dist/scripts/generate-icons.js +381 -399
- package/dist/scripts/icon-generator-config.d.ts +0 -1
- package/dist/scripts/icon-generator-config.js +7 -4
- package/dist/theme-base.d.ts.map +1 -1
- package/dist/utils/svg-texture.d.ts.map +1 -1
- package/dist/vite-plugin-icons.d.ts +1 -2
- package/dist/vite-plugin-icons.js +109 -90
- package/package.json +24 -22
- package/dist/TransformOriginView-DsD_qZno.cjs +0 -17115
- package/dist/TransformOriginView-DsD_qZno.cjs.map +0 -1
- package/dist/TransformOriginView-uYYqbEHW.js +0 -17099
- package/dist/TransformOriginView-uYYqbEHW.js.map +0 -1
- package/dist/components/custom/index.cjs.map +0 -1
- package/dist/components/custom/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2931 +1,1421 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { $ as RadioButton, $n as textCreator, $t as shouldComponentUpdate, A as computed, An as midnightPreset, At as createTheme, B as DOMInputElement, Bn as hexToNumber, Bt as remountAll, C as CharText, Cn as defaultTextStyleTokens, Cr as graphicsCreator, Ct as createWiggleEffect, D as Modal, Dn as generateColorScale, Dr as register, Dt as useGameObjectEffect, E as Dialog, En as forestGreenPreset, Er as nodeRegistry, Et as createZoomOutEffect, F as SpringPhysics, Fn as darken, Ft as getMountStats, G as useSVGTextures, Gn as rgbToHsl, Gt as disposeCtx, H as releaseSVGTexture, Hn as lightenHex, Ht as unmountJSX, I as animatedSignal, In as darkenHex, It as mount, J as Particles, Jn as normalizeCornerRadius, Jt as getLayoutProps, K as svgToTexture, Kn as rgbToNumber, Kt as getBackgroundGraphics, L as isAnimatedSignal, Ln as ensureContrast, Lt as mountJSX, M as useSprings, Mn as presets, Mt as mergeThemes, N as DEFAULT_SPRING_CONFIG, Nn as alpha, Nt as themeRegistry, O as Portal, On as getPreset, Ot as viewCreator, P as SPRING_PRESETS, Pn as createTextStyle, Pt as createElement, Q as RadioGroup, Qn as tileSpritePatcher, Qt as shallowEqual, R as unwrapSignal, Rn as getContrastRatio, Rt as normalizeVNodeLike, S as CharTextInput, Sn as defaultSpacingTokens, Sr as imagePatcher, St as createTadaEffect, T as WrapText, Tn as applyLightMode, Tr as host, Tt as createZoomInEffect, U as releaseSVGTextures, Un as numberToHex, Ut as portalRegistry, V as releaseAllSVGTextures, Vn as lighten, Vt as unmount, W as useSVGTexture, Wn as numberToRgb, Wt as View, X as Text, Xn as normalizeGap, Xt as getLayoutSize, Y as TileSprite, Yn as normalizeEdgeInsets, Yt as getLayoutRect, Z as Sprite, Zn as tileSpriteCreator, Zt as getWorldLayoutRect, _ as Dropdown, _n as createDefaultTheme, _r as buildEmitZone, _t as createShakeEffect, a as Tabs, an as useLayoutRect, ar as spriteCreator, at as resolveEffect, b as calculateSliderSize, bn as defaultRadiusTokens, br as nineSlicePatcher, bt as createSpinEffect, c as Sidebar, cn as useRedraw, cr as particlesPatcher, ct as createFadeEffect, d as NineSlice, dn as useState, dr as applyEmitterConfig, dt as createFlipOutEffect, en as useBackgroundGraphics, er as textPatcher, et as Graphics, f as Joystick, fn as useTheme, fr as getFirstEmitter, ft as createFloatEffect, g as Image, gn as getRenderContext, gr as buildDeathZonesFromLayout, gt as createPulseEffect, h as useIconPreload, hn as withHooks, hr as resolveParticlePreset, ht as createPressEffect, i as TabPanel, in as useLayoutEffect, ir as DevPresets, it as applyEffectByName, j as useSpring, jn as oceanBluePreset, jt as getThemedProps, k as Accordion, kn as getPresetWithMode, kt as viewPatcher, l as RefOriginView, ln as useRef, lr as applyDeathZone, lt as createFlashEffect, m as createIconComponent, mn as useWorldLayoutRect, mr as PARTICLE_PRESET_REGISTRY, mt as createNoneEffect, n as Toggle, nn as useEffect, nr as DebugLogger, nt as DEFAULT_EFFECT, o as RangeSlider, on as useLayoutSize, or as spritePatcher, ot as createBounceEffect, p as Icon, pn as useViewportSize, pr as isParticleEmitter, pt as createJelloEffect, q as registerBuiltins, qn as HexColor, qt as getCurrent, r as Tab, rn as useForceRedraw, rr as DevConfig, rt as EFFECT_REGISTRY, s as Slider, sn as useMemo, sr as particlesCreator, st as createBreatheEffect, t as TransformOriginView, tn as useCallback, tr as viewportRegistry, tt as Button, u as NineSliceButton, un as useScene, ur as applyEmitZone, ut as createFlipInEffect, v as ScrollView, vn as defaultTheme, vr as buildEmitZoneFromLayout, vt as createSlideInEffect, w as AlertDialog, wn as applyDarkMode, wr as graphicsPatcher, wt as createWobbleEffect, x as Divider, xn as defaultSizeTokens, xr as imageCreator, xt as createSwingEffect, y as ScrollSlider, yn as createTextStyleTokens, yr as nineSliceCreator, yt as createSlideOutEffect, z as KeyboardInputManager, zn as hex, zt as patchVNode } from "./custom-oy3mBnrW.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "./jsx-runtime.js";
|
|
3
3
|
import * as Phaser from "phaser";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function applyGraphicsProps(node, _prev, next) {
|
|
13
|
-
const prevDeps = node.__drawDependencies;
|
|
14
|
-
const nextDeps = next.dependencies;
|
|
15
|
-
const depsChanged = !shallowEqual(prevDeps, nextDeps);
|
|
16
|
-
if (depsChanged && next.onDraw) {
|
|
17
|
-
if (next.autoClear !== false) {
|
|
18
|
-
node.clear();
|
|
19
|
-
}
|
|
20
|
-
next.onDraw(node, next);
|
|
21
|
-
node.__drawDependencies = nextDeps;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function applyGraphicsLayout(node, prev, next) {
|
|
25
|
-
node.__layoutProps = next;
|
|
26
|
-
if (prev.width !== next.width || prev.height !== next.height || prev.headless !== next.headless) {
|
|
27
|
-
node.__getLayoutSize = () => {
|
|
28
|
-
if (next.headless ?? true) {
|
|
29
|
-
return { width: 0.01, height: 0.01 };
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
width: typeof next.width === "number" ? next.width : 0,
|
|
33
|
-
height: typeof next.height === "number" ? next.height : 0
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function normalizeVisible$1(visible) {
|
|
39
|
-
if (visible === void 0) return true;
|
|
40
|
-
if (typeof visible === "boolean") return visible;
|
|
41
|
-
if (visible === "visible") return true;
|
|
42
|
-
if (visible === "invisible" || visible === "none") return false;
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
function applyPhaserProps(node, prev, next) {
|
|
46
|
-
if (prev.alpha !== next.alpha && typeof next.alpha === "number") {
|
|
47
|
-
node.setAlpha?.(next.alpha);
|
|
48
|
-
}
|
|
49
|
-
if (prev.depth !== next.depth && typeof next.depth === "number") {
|
|
50
|
-
node.setDepth?.(next.depth);
|
|
51
|
-
}
|
|
52
|
-
if (prev.visible !== next.visible) {
|
|
53
|
-
const visibleValue = normalizeVisible$1(next.visible);
|
|
54
|
-
node.visible = visibleValue;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function applyTransformProps(node, prev, next) {
|
|
58
|
-
if (prev.x !== next.x && typeof next.x === "number") {
|
|
59
|
-
node.x = next.x;
|
|
60
|
-
}
|
|
61
|
-
if (prev.y !== next.y && typeof next.y === "number") {
|
|
62
|
-
node.y = next.y;
|
|
63
|
-
}
|
|
64
|
-
if (prev.rotation !== next.rotation && typeof next.rotation === "number") {
|
|
65
|
-
node.rotation = next.rotation;
|
|
66
|
-
}
|
|
67
|
-
const nextScale = next.scale;
|
|
68
|
-
const nextScaleX = next.scaleX;
|
|
69
|
-
const nextScaleY = next.scaleY;
|
|
70
|
-
const prevScale = prev.scale;
|
|
71
|
-
const prevScaleX = prev.scaleX;
|
|
72
|
-
const prevScaleY = prev.scaleY;
|
|
73
|
-
if (nextScale !== void 0 && nextScale !== prevScale) {
|
|
74
|
-
node.setScale?.(nextScale, nextScale);
|
|
75
|
-
} else if (nextScaleX !== prevScaleX || nextScaleY !== prevScaleY) {
|
|
76
|
-
const currentScaleX = node.scaleX ?? 1;
|
|
77
|
-
const currentScaleY = node.scaleY ?? 1;
|
|
78
|
-
const sx = nextScaleX ?? currentScaleX;
|
|
79
|
-
const sy = nextScaleY ?? currentScaleY;
|
|
80
|
-
node.setScale?.(sx, sy);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function createGraphicsLayout(graphics, props) {
|
|
84
|
-
if (props.headless === false) {
|
|
85
|
-
if (typeof props.width !== "number" || typeof props.height !== "number") {
|
|
86
|
-
throw new Error(
|
|
87
|
-
"Graphics component requires explicit width and height props when headless=false"
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
graphics.__layoutProps = props;
|
|
92
|
-
graphics.__getLayoutSize = () => {
|
|
93
|
-
if (graphics.__layoutProps?.headless ?? true) {
|
|
94
|
-
return { width: 0.01, height: 0.01 };
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
width: props.width ?? 0,
|
|
98
|
-
height: props.height ?? 0
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
graphics.__drawDependencies = props.dependencies;
|
|
102
|
-
}
|
|
103
|
-
function normalizeVisible(visible) {
|
|
104
|
-
if (visible === void 0) return true;
|
|
105
|
-
if (typeof visible === "boolean") return visible;
|
|
106
|
-
if (visible === "visible") return true;
|
|
107
|
-
if (visible === "invisible" || visible === "none") return false;
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
function createPhaser(node, props) {
|
|
111
|
-
if (props.visible !== void 0) {
|
|
112
|
-
node.visible = normalizeVisible(props.visible);
|
|
113
|
-
}
|
|
114
|
-
if (props.depth !== void 0) {
|
|
115
|
-
node.setDepth(props.depth);
|
|
116
|
-
}
|
|
117
|
-
if (props.alpha !== void 0) {
|
|
118
|
-
node.setAlpha(props.alpha);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function createTransform(node, props) {
|
|
122
|
-
if (props.scaleX !== void 0 || props.scaleY !== void 0) {
|
|
123
|
-
node.setScale(
|
|
124
|
-
props.scaleX ?? 1,
|
|
125
|
-
props.scaleY ?? 1
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
if (props.rotation !== void 0) {
|
|
129
|
-
node.setRotation(props.rotation);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const graphicsCreator = (scene, props) => {
|
|
133
|
-
const graphics = scene.add.graphics();
|
|
134
|
-
graphics.setPosition(props.x ?? 0, props.y ?? 0);
|
|
135
|
-
createTransform(graphics, props);
|
|
136
|
-
createPhaser(graphics, props);
|
|
137
|
-
createGraphicsLayout(graphics, props);
|
|
138
|
-
if (props.onDraw) {
|
|
139
|
-
props.onDraw(graphics, props);
|
|
140
|
-
}
|
|
141
|
-
return graphics;
|
|
4
|
+
//#region src/camera/use-camera-fx.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook and creators for Phaser camera effects
|
|
7
|
+
*/
|
|
8
|
+
var createCameraShakeFX = (camera, config) => {
|
|
9
|
+
const duration = config.duration ?? 250;
|
|
10
|
+
const intensity = typeof config.intensity === "object" ? new Phaser.Math.Vector2(config.intensity.x, config.intensity.y) : config.intensity ?? .01;
|
|
11
|
+
camera.shake(duration, intensity, config.force ?? false, config.onComplete);
|
|
142
12
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
13
|
+
var createCameraFlashFX = (camera, config) => {
|
|
14
|
+
const duration = config.duration ?? 200;
|
|
15
|
+
const red = config.red ?? 255;
|
|
16
|
+
const green = config.green ?? 255;
|
|
17
|
+
const blue = config.blue ?? 255;
|
|
18
|
+
camera.flash(duration, red, green, blue, config.force ?? false, config.onComplete);
|
|
148
19
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (fit === "fill") {
|
|
156
|
-
return {
|
|
157
|
-
scaleX: targetWidth / textureWidth,
|
|
158
|
-
scaleY: targetHeight / textureHeight
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
const targetAspect = targetWidth / targetHeight;
|
|
162
|
-
const textureAspect = textureWidth / textureHeight;
|
|
163
|
-
if (fit === "contain") {
|
|
164
|
-
const scale = targetAspect > textureAspect ? targetHeight / textureHeight : targetWidth / textureWidth;
|
|
165
|
-
return { scaleX: scale, scaleY: scale };
|
|
166
|
-
}
|
|
167
|
-
if (fit === "cover") {
|
|
168
|
-
const scale = targetAspect < textureAspect ? targetHeight / textureHeight : targetWidth / textureWidth;
|
|
169
|
-
return { scaleX: scale, scaleY: scale };
|
|
170
|
-
}
|
|
171
|
-
return { scaleX: 1, scaleY: 1 };
|
|
172
|
-
}
|
|
173
|
-
function applyImageProps(image, prev, next) {
|
|
174
|
-
const textureChanged = prev.texture !== next.texture || prev.frame !== next.frame;
|
|
175
|
-
if (textureChanged && next.texture) {
|
|
176
|
-
image.setTexture(next.texture, next.frame);
|
|
177
|
-
}
|
|
178
|
-
if (prev.tint !== next.tint) {
|
|
179
|
-
if (typeof next.tint === "number") {
|
|
180
|
-
image.setTint(next.tint);
|
|
181
|
-
} else {
|
|
182
|
-
image.clearTint();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (prev.originX !== next.originX || prev.originY !== next.originY) {
|
|
186
|
-
const originX = next.originX ?? image.originX;
|
|
187
|
-
const originY = next.originY ?? image.originY;
|
|
188
|
-
image.setOrigin(originX, originY);
|
|
189
|
-
}
|
|
190
|
-
const displayWidthChanged = prev.displayWidth !== next.displayWidth;
|
|
191
|
-
const displayHeightChanged = prev.displayHeight !== next.displayHeight;
|
|
192
|
-
const fitChanged = prev.fit !== next.fit;
|
|
193
|
-
if (displayWidthChanged || displayHeightChanged || fitChanged || textureChanged) {
|
|
194
|
-
if (typeof next.displayWidth === "number" && typeof next.displayHeight === "number") {
|
|
195
|
-
const { scaleX, scaleY } = calculateFitScale$1(
|
|
196
|
-
image,
|
|
197
|
-
next.displayWidth,
|
|
198
|
-
next.displayHeight,
|
|
199
|
-
next.fit
|
|
200
|
-
);
|
|
201
|
-
image.setScale(scaleX, scaleY);
|
|
202
|
-
} else if (typeof next.displayWidth === "number") {
|
|
203
|
-
const scale = next.displayWidth / image.width;
|
|
204
|
-
image.setScale(scale);
|
|
205
|
-
} else if (typeof next.displayHeight === "number") {
|
|
206
|
-
const scale = next.displayHeight / image.height;
|
|
207
|
-
image.setScale(scale, scale);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function applyImageLayout(image, prev, next) {
|
|
212
|
-
image.__layoutProps = next;
|
|
213
|
-
if (prev.headless !== next.headless) {
|
|
214
|
-
image.__getLayoutSize = () => {
|
|
215
|
-
if (image.__layoutProps?.headless) {
|
|
216
|
-
return { width: 0.01, height: 0.01 };
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
width: image.displayWidth,
|
|
220
|
-
height: image.displayHeight
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function createImageLayout(image, props) {
|
|
226
|
-
image.__layoutProps = props;
|
|
227
|
-
image.__getLayoutSize = () => {
|
|
228
|
-
if (image.__layoutProps?.headless) {
|
|
229
|
-
return { width: 0.01, height: 0.01 };
|
|
230
|
-
}
|
|
231
|
-
return {
|
|
232
|
-
width: image.displayWidth,
|
|
233
|
-
height: image.displayHeight
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
const imageCreator = (scene, props) => {
|
|
238
|
-
const image = scene.add.image(props.x ?? 0, props.y ?? 0, props.texture, props.frame);
|
|
239
|
-
if (props.headless) {
|
|
240
|
-
image.setOrigin(0.5, 0.5);
|
|
241
|
-
} else {
|
|
242
|
-
image.setOrigin(0, 0);
|
|
243
|
-
}
|
|
244
|
-
if (props.originX !== void 0 || props.originY !== void 0) {
|
|
245
|
-
image.setOrigin(props.originX ?? image.originX, props.originY ?? image.originY);
|
|
246
|
-
}
|
|
247
|
-
const normalizedProps = { ...props };
|
|
248
|
-
if (props.headless) {
|
|
249
|
-
delete normalizedProps.padding;
|
|
250
|
-
delete normalizedProps.margin;
|
|
251
|
-
delete normalizedProps.gap;
|
|
252
|
-
} else {
|
|
253
|
-
if (normalizedProps.rotation !== void 0) {
|
|
254
|
-
delete normalizedProps.rotation;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
createTransform(image, normalizedProps);
|
|
258
|
-
createPhaser(image, normalizedProps);
|
|
259
|
-
if (props.tint !== void 0) {
|
|
260
|
-
image.setTint(props.tint);
|
|
261
|
-
}
|
|
262
|
-
if (props.displayWidth !== void 0 || props.displayHeight !== void 0) {
|
|
263
|
-
if (props.displayWidth !== void 0 && props.displayHeight !== void 0) {
|
|
264
|
-
const fit = props.fit ?? "fill";
|
|
265
|
-
const textureWidth = image.width;
|
|
266
|
-
const textureHeight = image.height;
|
|
267
|
-
if (textureWidth > 0 && textureHeight > 0) {
|
|
268
|
-
if (fit === "fill") {
|
|
269
|
-
image.setDisplaySize(props.displayWidth, props.displayHeight);
|
|
270
|
-
} else if (fit === "contain") {
|
|
271
|
-
const targetAspect = props.displayWidth / props.displayHeight;
|
|
272
|
-
const textureAspect = textureWidth / textureHeight;
|
|
273
|
-
const scale = targetAspect > textureAspect ? props.displayHeight / textureHeight : props.displayWidth / textureWidth;
|
|
274
|
-
image.setScale(scale);
|
|
275
|
-
} else if (fit === "cover") {
|
|
276
|
-
const targetAspect = props.displayWidth / props.displayHeight;
|
|
277
|
-
const textureAspect = textureWidth / textureHeight;
|
|
278
|
-
const scale = targetAspect < textureAspect ? props.displayHeight / textureHeight : props.displayWidth / textureWidth;
|
|
279
|
-
image.setScale(scale);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
} else if (props.displayWidth !== void 0) {
|
|
283
|
-
const scale = props.displayWidth / image.width;
|
|
284
|
-
image.setScale(scale);
|
|
285
|
-
} else if (props.displayHeight !== void 0) {
|
|
286
|
-
const scale = props.displayHeight / image.height;
|
|
287
|
-
image.setScale(scale);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
createImageLayout(image, normalizedProps);
|
|
291
|
-
if (props.onReady) {
|
|
292
|
-
props.onReady(image);
|
|
293
|
-
}
|
|
294
|
-
return image;
|
|
20
|
+
var createCameraFadeInFX = (camera, config) => {
|
|
21
|
+
const duration = config.duration ?? 300;
|
|
22
|
+
const red = config.red ?? 0;
|
|
23
|
+
const green = config.green ?? 0;
|
|
24
|
+
const blue = config.blue ?? 0;
|
|
25
|
+
camera.fadeIn(duration, red, green, blue, config.onComplete);
|
|
295
26
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
const normalizedPrev = { ...prev };
|
|
305
|
-
const normalizedNext = { ...next };
|
|
306
|
-
if (next.headless) {
|
|
307
|
-
delete normalizedNext.padding;
|
|
308
|
-
delete normalizedNext.margin;
|
|
309
|
-
delete normalizedNext.gap;
|
|
310
|
-
} else {
|
|
311
|
-
if (normalizedNext.rotation !== void 0) {
|
|
312
|
-
delete normalizedNext.rotation;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
if (prev.headless) {
|
|
316
|
-
delete normalizedPrev.padding;
|
|
317
|
-
delete normalizedPrev.margin;
|
|
318
|
-
delete normalizedPrev.gap;
|
|
319
|
-
} else {
|
|
320
|
-
if (normalizedPrev.rotation !== void 0) {
|
|
321
|
-
delete normalizedPrev.rotation;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
applyTransformProps(node, normalizedPrev, normalizedNext);
|
|
325
|
-
applyPhaserProps(node, normalizedPrev, normalizedNext);
|
|
326
|
-
applyImageProps(node, normalizedPrev, normalizedNext);
|
|
327
|
-
applyImageLayout(node, normalizedPrev, normalizedNext);
|
|
27
|
+
var createCameraFadeOutFX = (camera, config) => {
|
|
28
|
+
const duration = config.duration ?? 300;
|
|
29
|
+
const red = config.red ?? 0;
|
|
30
|
+
const green = config.green ?? 0;
|
|
31
|
+
const blue = config.blue ?? 0;
|
|
32
|
+
camera.fadeOut(duration, red, green, blue, config.onComplete);
|
|
328
33
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
const sliceChanged = prev.leftWidth !== next.leftWidth || prev.rightWidth !== next.rightWidth || prev.topHeight !== next.topHeight || prev.bottomHeight !== next.bottomHeight;
|
|
335
|
-
if (sliceChanged) {
|
|
336
|
-
const width = typeof next.width === "number" ? next.width : nineSlice.width;
|
|
337
|
-
const height = typeof next.height === "number" ? next.height : nineSlice.height;
|
|
338
|
-
nineSlice.setSlices(
|
|
339
|
-
width,
|
|
340
|
-
height,
|
|
341
|
-
next.leftWidth ?? prev.leftWidth ?? 0,
|
|
342
|
-
next.rightWidth ?? prev.rightWidth ?? 0,
|
|
343
|
-
next.topHeight ?? prev.topHeight,
|
|
344
|
-
next.bottomHeight ?? prev.bottomHeight
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
const prevWidth = typeof prev.width === "number" ? prev.width : nineSlice.width;
|
|
348
|
-
const nextWidth = typeof next.width === "number" ? next.width : nineSlice.width;
|
|
349
|
-
const prevHeight = typeof prev.height === "number" ? prev.height : nineSlice.height;
|
|
350
|
-
const nextHeight = typeof next.height === "number" ? next.height : nineSlice.height;
|
|
351
|
-
if (prevWidth !== nextWidth || prevHeight !== nextHeight) {
|
|
352
|
-
nineSlice.setSize(nextWidth, nextHeight);
|
|
353
|
-
}
|
|
354
|
-
if (prev.tint !== next.tint) {
|
|
355
|
-
if (next.tint !== void 0) {
|
|
356
|
-
nineSlice.setTint(next.tint);
|
|
357
|
-
} else {
|
|
358
|
-
nineSlice.clearTint();
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function applyNineSliceLayout(nineSlice, prev, next) {
|
|
363
|
-
nineSlice.__layoutProps = next;
|
|
364
|
-
if (prev.width !== next.width || prev.height !== next.height) {
|
|
365
|
-
nineSlice.__getLayoutSize = () => {
|
|
366
|
-
return {
|
|
367
|
-
width: nineSlice.width,
|
|
368
|
-
height: nineSlice.height
|
|
369
|
-
};
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
function createNineSliceLayout(nineSlice, props) {
|
|
374
|
-
nineSlice.__layoutProps = props;
|
|
375
|
-
nineSlice.__getLayoutSize = () => {
|
|
376
|
-
return {
|
|
377
|
-
width: nineSlice.width,
|
|
378
|
-
height: nineSlice.height
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
const nineSliceCreator = (scene, props) => {
|
|
383
|
-
const initialWidth = typeof props.width === "number" ? props.width : 64;
|
|
384
|
-
const initialHeight = typeof props.height === "number" ? props.height : 64;
|
|
385
|
-
const nineSlice = scene.add.nineslice(
|
|
386
|
-
props.x ?? 0,
|
|
387
|
-
props.y ?? 0,
|
|
388
|
-
props.texture,
|
|
389
|
-
props.frame,
|
|
390
|
-
initialWidth,
|
|
391
|
-
initialHeight,
|
|
392
|
-
props.leftWidth,
|
|
393
|
-
props.rightWidth,
|
|
394
|
-
props.topHeight,
|
|
395
|
-
props.bottomHeight
|
|
396
|
-
);
|
|
397
|
-
nineSlice.setOrigin(0, 0);
|
|
398
|
-
if (props.tint !== void 0) {
|
|
399
|
-
nineSlice.setTint(props.tint);
|
|
400
|
-
}
|
|
401
|
-
createTransform(nineSlice, props);
|
|
402
|
-
createPhaser(nineSlice, props);
|
|
403
|
-
createNineSliceLayout(nineSlice, props);
|
|
404
|
-
return nineSlice;
|
|
405
|
-
};
|
|
406
|
-
const nineSlicePatcher = (node, prev, next) => {
|
|
407
|
-
applyTransformProps(node, prev, next);
|
|
408
|
-
applyPhaserProps(node, prev, next);
|
|
409
|
-
applyNineSliceProps(node, prev, next);
|
|
410
|
-
applyNineSliceLayout(node, prev, next);
|
|
411
|
-
};
|
|
412
|
-
function resolveNumericSize(value) {
|
|
413
|
-
return typeof value === "number" ? value : void 0;
|
|
414
|
-
}
|
|
415
|
-
function resolveZoneSize(zone, fallback) {
|
|
416
|
-
const size = {};
|
|
417
|
-
const width = zone.width ?? fallback.width;
|
|
418
|
-
const height = zone.height ?? fallback.height;
|
|
419
|
-
if (width !== void 0) size.width = width;
|
|
420
|
-
if (height !== void 0) size.height = height;
|
|
421
|
-
return size;
|
|
422
|
-
}
|
|
423
|
-
function buildZoneSource(zone, fallbackSize) {
|
|
424
|
-
const baseX = zone.x ?? 0;
|
|
425
|
-
const baseY = zone.y ?? 0;
|
|
426
|
-
const { width, height } = resolveZoneSize(zone, fallbackSize);
|
|
427
|
-
switch (zone.shape) {
|
|
428
|
-
case "rect":
|
|
429
|
-
return new Phaser.Geom.Rectangle(baseX, baseY, width ?? 1, height ?? 1);
|
|
430
|
-
case "circle":
|
|
431
|
-
return new Phaser.Geom.Circle(baseX, baseY, zone.radius ?? 1);
|
|
432
|
-
case "ellipse":
|
|
433
|
-
return new Phaser.Geom.Ellipse(baseX, baseY, width ?? 1, height ?? 1);
|
|
434
|
-
case "line":
|
|
435
|
-
return new Phaser.Geom.Line(
|
|
436
|
-
baseX,
|
|
437
|
-
baseY,
|
|
438
|
-
zone.endX ?? baseX + (width ?? 1),
|
|
439
|
-
zone.endY ?? baseY + (height ?? 1)
|
|
440
|
-
);
|
|
441
|
-
default:
|
|
442
|
-
return void 0;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function buildEmitZone(zone, fallbackSize = {}) {
|
|
446
|
-
const type = zone.type ?? "random";
|
|
447
|
-
const source = buildZoneSource(zone, fallbackSize);
|
|
448
|
-
if (!source) return void 0;
|
|
449
|
-
return { type, source };
|
|
450
|
-
}
|
|
451
|
-
function buildEmitZoneFromLayout(zone, width, height) {
|
|
452
|
-
const fallback = {};
|
|
453
|
-
const resolvedWidth = resolveNumericSize(width);
|
|
454
|
-
const resolvedHeight = resolveNumericSize(height);
|
|
455
|
-
if (resolvedWidth !== void 0) fallback.width = resolvedWidth;
|
|
456
|
-
if (resolvedHeight !== void 0) fallback.height = resolvedHeight;
|
|
457
|
-
return buildEmitZone(zone, fallback);
|
|
458
|
-
}
|
|
459
|
-
function buildDeathZone(zone, fallbackSize = {}) {
|
|
460
|
-
const type = zone.mode ?? "onEnter";
|
|
461
|
-
const source = buildZoneSource(zone, fallbackSize);
|
|
462
|
-
if (!source) return void 0;
|
|
463
|
-
return { type, source };
|
|
464
|
-
}
|
|
465
|
-
function buildDeathZonesFromLayout(zones, width, height) {
|
|
466
|
-
if (!zones) return void 0;
|
|
467
|
-
const list = Array.isArray(zones) ? zones : [zones];
|
|
468
|
-
const fallback = {};
|
|
469
|
-
const resolvedWidth = resolveNumericSize(width);
|
|
470
|
-
const resolvedHeight = resolveNumericSize(height);
|
|
471
|
-
if (resolvedWidth !== void 0) fallback.width = resolvedWidth;
|
|
472
|
-
if (resolvedHeight !== void 0) fallback.height = resolvedHeight;
|
|
473
|
-
const deathZones = list.map((zone) => buildDeathZone(zone, fallback)).filter((zone) => Boolean(zone));
|
|
474
|
-
return deathZones.length > 0 ? deathZones : void 0;
|
|
475
|
-
}
|
|
476
|
-
const PARTICLE_PRESET_REGISTRY = {
|
|
477
|
-
explosion: {
|
|
478
|
-
speed: { min: 120, max: 320 },
|
|
479
|
-
scale: { start: 1, end: 0 },
|
|
480
|
-
alpha: { start: 1, end: 0 },
|
|
481
|
-
lifespan: 600,
|
|
482
|
-
quantity: 24,
|
|
483
|
-
blendMode: "ADD"
|
|
484
|
-
},
|
|
485
|
-
trail: {
|
|
486
|
-
speed: { min: 30, max: 80 },
|
|
487
|
-
scale: { start: 0.6, end: 0 },
|
|
488
|
-
alpha: { start: 0.8, end: 0 },
|
|
489
|
-
lifespan: 700,
|
|
490
|
-
frequency: 40
|
|
491
|
-
},
|
|
492
|
-
rain: {
|
|
493
|
-
speed: { min: 320, max: 520 },
|
|
494
|
-
angle: { min: 80, max: 100 },
|
|
495
|
-
scale: { start: 0.5, end: 0.2 },
|
|
496
|
-
alpha: { start: 0.6, end: 0.1 },
|
|
497
|
-
lifespan: 1e3,
|
|
498
|
-
frequency: 20
|
|
499
|
-
},
|
|
500
|
-
snow: {
|
|
501
|
-
speed: { min: 40, max: 120 },
|
|
502
|
-
angle: { min: 80, max: 100 },
|
|
503
|
-
gravityY: 8,
|
|
504
|
-
scale: { start: 0.6, end: 0.6 },
|
|
505
|
-
alpha: { start: 0.8, end: 0.3 },
|
|
506
|
-
lifespan: 2600,
|
|
507
|
-
frequency: 80
|
|
508
|
-
},
|
|
509
|
-
sparkle: {
|
|
510
|
-
speed: { min: 20, max: 60 },
|
|
511
|
-
scale: { start: 0.4, end: 0 },
|
|
512
|
-
alpha: { start: 1, end: 0 },
|
|
513
|
-
lifespan: 500,
|
|
514
|
-
frequency: 60,
|
|
515
|
-
blendMode: "ADD"
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
function resolveParticlePreset(preset, config = {}) {
|
|
519
|
-
const base = preset ? PARTICLE_PRESET_REGISTRY[preset] : void 0;
|
|
520
|
-
if (preset && !base) {
|
|
521
|
-
console.warn(`[Particles] Preset "${String(preset)}" not found in registry`);
|
|
522
|
-
}
|
|
523
|
-
return {
|
|
524
|
-
...base ?? {},
|
|
525
|
-
...config
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
function isParticleEmitter(target) {
|
|
529
|
-
return !!target && typeof target.explode === "function";
|
|
530
|
-
}
|
|
531
|
-
function getFirstEmitter(manager) {
|
|
532
|
-
if (!manager) return null;
|
|
533
|
-
if (manager.__emitter) return manager.__emitter;
|
|
534
|
-
const emitters = manager.emitters;
|
|
535
|
-
if (Array.isArray(emitters)) {
|
|
536
|
-
return emitters[0] ?? null;
|
|
537
|
-
}
|
|
538
|
-
if (emitters && "list" in emitters && Array.isArray(emitters.list)) {
|
|
539
|
-
return emitters.list[0] ?? null;
|
|
540
|
-
}
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
|
-
function applyEmitterConfig(emitter, config) {
|
|
544
|
-
if (!emitter) return;
|
|
545
|
-
const withConfig = emitter;
|
|
546
|
-
if (withConfig.setConfig) {
|
|
547
|
-
withConfig.setConfig(config);
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
if (withConfig.fromJSON) {
|
|
551
|
-
withConfig.fromJSON(config);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
Object.assign(emitter, config);
|
|
555
|
-
}
|
|
556
|
-
function applyEmitZone(emitter, emitZone) {
|
|
557
|
-
if (!emitter || !emitZone) return;
|
|
558
|
-
const withZone = emitter;
|
|
559
|
-
if (withZone.setEmitZone) {
|
|
560
|
-
withZone.setEmitZone(emitZone);
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function applyDeathZone(emitter, deathZone) {
|
|
565
|
-
if (!emitter) return;
|
|
566
|
-
const withZone = emitter;
|
|
567
|
-
const isDefined = (value) => value !== null && value !== void 0;
|
|
568
|
-
const normalized = Array.isArray(deathZone) ? deathZone.filter(isDefined) : deathZone ? [deathZone] : [];
|
|
569
|
-
const hasZone = normalized.length > 0;
|
|
570
|
-
if (hasZone && withZone.setDeathZone) {
|
|
571
|
-
withZone.setDeathZone(normalized);
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
if (!hasZone) {
|
|
575
|
-
if (withZone.clearDeathZones) {
|
|
576
|
-
withZone.clearDeathZones();
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
if (withZone.deathZones) {
|
|
580
|
-
withZone.deathZones = [];
|
|
581
|
-
}
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
if (withZone.clearDeathZones) {
|
|
585
|
-
withZone.clearDeathZones();
|
|
586
|
-
}
|
|
587
|
-
if (withZone.addDeathZone) {
|
|
588
|
-
withZone.addDeathZone(normalized);
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
if (withZone.deathZones) {
|
|
592
|
-
withZone.deathZones = normalized;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
function mergeDeathZones(base, extra) {
|
|
596
|
-
const baseList = Array.isArray(base) ? base : base ? [base] : [];
|
|
597
|
-
const extraList = extra ?? [];
|
|
598
|
-
const merged = [...baseList, ...extraList];
|
|
599
|
-
return merged.length > 0 ? merged : void 0;
|
|
600
|
-
}
|
|
601
|
-
function applyParticlesProps(manager, prev, next) {
|
|
602
|
-
if (!manager) return;
|
|
603
|
-
const textureChanged = prev.texture !== next.texture || prev.frame !== next.frame;
|
|
604
|
-
if (textureChanged && next.texture && "setTexture" in manager && manager.setTexture) {
|
|
605
|
-
manager.setTexture(next.texture, next.frame);
|
|
606
|
-
}
|
|
607
|
-
const configChanged = prev.preset !== next.preset || prev.config !== next.config || prev.zone !== next.zone || prev.excludeZones !== next.excludeZones || prev.width !== next.width || prev.height !== next.height;
|
|
608
|
-
if (configChanged) {
|
|
609
|
-
const resolvedConfig = resolveParticlePreset(next.preset, next.config);
|
|
610
|
-
let emitter = null;
|
|
611
|
-
if (isParticleEmitter(manager)) {
|
|
612
|
-
emitter = manager;
|
|
613
|
-
} else {
|
|
614
|
-
const managerLike = manager;
|
|
615
|
-
emitter = managerLike.__emitter ?? getFirstEmitter(managerLike);
|
|
616
|
-
if (!emitter && managerLike.createEmitter) {
|
|
617
|
-
const created = managerLike.createEmitter(resolvedConfig);
|
|
618
|
-
emitter = created ?? null;
|
|
619
|
-
}
|
|
620
|
-
managerLike.__emitter = emitter;
|
|
621
|
-
}
|
|
622
|
-
if (!emitter) return;
|
|
623
|
-
applyEmitterConfig(emitter, resolvedConfig);
|
|
624
|
-
if (next.zone) {
|
|
625
|
-
const emitZone = buildEmitZoneFromLayout(next.zone, next.width, next.height);
|
|
626
|
-
if (emitZone) {
|
|
627
|
-
applyEmitZone(emitter, emitZone);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
const deathZones = buildDeathZonesFromLayout(next.excludeZones, next.width, next.height);
|
|
631
|
-
const combined = mergeDeathZones(
|
|
632
|
-
resolvedConfig.deathZone,
|
|
633
|
-
deathZones
|
|
634
|
-
);
|
|
635
|
-
applyDeathZone(emitter, combined);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
function applyParticlesLayout(particles, _prev, next) {
|
|
639
|
-
particles.__layoutProps = next;
|
|
640
|
-
}
|
|
641
|
-
function createParticlesLayout(particles, props) {
|
|
642
|
-
particles.__layoutProps = props;
|
|
643
|
-
particles.__getLayoutSize = () => ({ width: 0.01, height: 0.01 });
|
|
644
|
-
}
|
|
645
|
-
const particlesCreator = (scene, props) => {
|
|
646
|
-
const resolvedConfig = {
|
|
647
|
-
...resolveParticlePreset(props.preset, props.config)
|
|
648
|
-
};
|
|
649
|
-
if (props.zone) {
|
|
650
|
-
const emitZone = buildEmitZoneFromLayout(props.zone, props.width, props.height);
|
|
651
|
-
if (emitZone) {
|
|
652
|
-
const configWithZone = resolvedConfig;
|
|
653
|
-
configWithZone.emitZone = emitZone;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
const particles = scene.add.particles(
|
|
657
|
-
props.x ?? 0,
|
|
658
|
-
props.y ?? 0,
|
|
659
|
-
props.texture,
|
|
660
|
-
resolvedConfig
|
|
661
|
-
);
|
|
662
|
-
if (props.frame !== void 0) {
|
|
663
|
-
const configWithFrame = resolvedConfig;
|
|
664
|
-
configWithFrame.frame = props.frame;
|
|
665
|
-
if ("setTexture" in particles && particles.setTexture) {
|
|
666
|
-
particles.setTexture(props.texture, props.frame);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
const emitter = isParticleEmitter(particles) ? particles : getFirstEmitter(particles);
|
|
670
|
-
if (!isParticleEmitter(particles)) {
|
|
671
|
-
particles.__emitter = emitter;
|
|
672
|
-
}
|
|
673
|
-
if ("setOrigin" in particles && typeof particles.setOrigin === "function") {
|
|
674
|
-
particles.setOrigin(0, 0);
|
|
675
|
-
}
|
|
676
|
-
createTransform(particles, props);
|
|
677
|
-
createPhaser(particles, props);
|
|
678
|
-
createParticlesLayout(particles, props);
|
|
679
|
-
if (props.excludeZones && emitter) {
|
|
680
|
-
const deathZones = buildDeathZonesFromLayout(props.excludeZones, props.width, props.height);
|
|
681
|
-
const combinedDeathZones = mergeDeathZones(
|
|
682
|
-
resolvedConfig.deathZone,
|
|
683
|
-
deathZones
|
|
684
|
-
);
|
|
685
|
-
if (combinedDeathZones) {
|
|
686
|
-
applyDeathZone(emitter, combinedDeathZones);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
if (props.onReady) {
|
|
690
|
-
props.onReady(particles);
|
|
691
|
-
}
|
|
692
|
-
return particles;
|
|
693
|
-
};
|
|
694
|
-
const particlesPatcher = (node, prev, next) => {
|
|
695
|
-
applyTransformProps(node, prev, next);
|
|
696
|
-
applyPhaserProps(node, prev, next);
|
|
697
|
-
applyParticlesProps(node, prev, next);
|
|
698
|
-
applyParticlesLayout(node, prev, next);
|
|
699
|
-
};
|
|
700
|
-
function getOriginalTextureDimensions(sprite) {
|
|
701
|
-
const frame = sprite.frame;
|
|
702
|
-
return {
|
|
703
|
-
width: frame.width,
|
|
704
|
-
height: frame.height
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
function calculateFitScale(sprite, targetWidth, targetHeight, fit = "fill") {
|
|
708
|
-
const { width: textureWidth, height: textureHeight } = getOriginalTextureDimensions(sprite);
|
|
709
|
-
if (textureWidth === 0 || textureHeight === 0) {
|
|
710
|
-
return { scaleX: 1, scaleY: 1 };
|
|
711
|
-
}
|
|
712
|
-
if (fit === "fill") {
|
|
713
|
-
return {
|
|
714
|
-
scaleX: targetWidth / textureWidth,
|
|
715
|
-
scaleY: targetHeight / textureHeight
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
const targetAspect = targetWidth / targetHeight;
|
|
719
|
-
const textureAspect = textureWidth / textureHeight;
|
|
720
|
-
if (fit === "contain") {
|
|
721
|
-
const scale = targetAspect > textureAspect ? targetHeight / textureHeight : targetWidth / textureWidth;
|
|
722
|
-
return { scaleX: scale, scaleY: scale };
|
|
723
|
-
}
|
|
724
|
-
if (fit === "cover") {
|
|
725
|
-
const scale = targetAspect < textureAspect ? targetHeight / textureHeight : targetWidth / textureWidth;
|
|
726
|
-
return { scaleX: scale, scaleY: scale };
|
|
727
|
-
}
|
|
728
|
-
return { scaleX: 1, scaleY: 1 };
|
|
729
|
-
}
|
|
730
|
-
function applySpriteProps(sprite, prev, next) {
|
|
731
|
-
const textureChanged = prev.texture !== next.texture || prev.frame !== next.frame;
|
|
732
|
-
if (textureChanged && next.texture) {
|
|
733
|
-
sprite.setTexture(next.texture, next.frame);
|
|
734
|
-
}
|
|
735
|
-
if (prev.tint !== next.tint) {
|
|
736
|
-
if (typeof next.tint === "number") {
|
|
737
|
-
sprite.setTint(next.tint);
|
|
738
|
-
} else {
|
|
739
|
-
sprite.clearTint();
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
if (prev.originX !== next.originX || prev.originY !== next.originY) {
|
|
743
|
-
const originX = next.originX ?? sprite.originX;
|
|
744
|
-
const originY = next.originY ?? sprite.originY;
|
|
745
|
-
sprite.setOrigin(originX, originY);
|
|
746
|
-
}
|
|
747
|
-
const displayWidthChanged = prev.displayWidth !== next.displayWidth;
|
|
748
|
-
const displayHeightChanged = prev.displayHeight !== next.displayHeight;
|
|
749
|
-
const fitChanged = prev.fit !== next.fit;
|
|
750
|
-
if (displayWidthChanged || displayHeightChanged || fitChanged || textureChanged) {
|
|
751
|
-
if (typeof next.displayWidth === "number" && typeof next.displayHeight === "number") {
|
|
752
|
-
const fit = next.fit ?? "fill";
|
|
753
|
-
if (fit === "fill") {
|
|
754
|
-
sprite.setDisplaySize(next.displayWidth, next.displayHeight);
|
|
755
|
-
} else {
|
|
756
|
-
const { scaleX, scaleY } = calculateFitScale(
|
|
757
|
-
sprite,
|
|
758
|
-
next.displayWidth,
|
|
759
|
-
next.displayHeight,
|
|
760
|
-
fit
|
|
761
|
-
);
|
|
762
|
-
sprite.setScale(scaleX, scaleY);
|
|
763
|
-
}
|
|
764
|
-
} else if (typeof next.displayWidth === "number") {
|
|
765
|
-
const { width: origWidth } = getOriginalTextureDimensions(sprite);
|
|
766
|
-
const scale = next.displayWidth / origWidth;
|
|
767
|
-
sprite.setScale(scale);
|
|
768
|
-
} else if (typeof next.displayHeight === "number") {
|
|
769
|
-
const { height: origHeight } = getOriginalTextureDimensions(sprite);
|
|
770
|
-
const scale = next.displayHeight / origHeight;
|
|
771
|
-
sprite.setScale(scale, scale);
|
|
772
|
-
} else {
|
|
773
|
-
sprite.setScale(1);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
const animationChanged = prev.animationKey !== next.animationKey || prev.loop !== next.loop || prev.repeatDelay !== next.repeatDelay;
|
|
777
|
-
if (animationChanged) {
|
|
778
|
-
if (sprite.anims.isPlaying) {
|
|
779
|
-
sprite.anims.stop();
|
|
780
|
-
}
|
|
781
|
-
if (next.animationKey) {
|
|
782
|
-
sprite.anims.play({
|
|
783
|
-
key: next.animationKey,
|
|
784
|
-
repeat: next.loop ? -1 : 0,
|
|
785
|
-
repeatDelay: next.repeatDelay ?? 0
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
const callbacksChanged = prev.onAnimationStart !== next.onAnimationStart || prev.onAnimationComplete !== next.onAnimationComplete || prev.onAnimationRepeat !== next.onAnimationRepeat || prev.onAnimationUpdate !== next.onAnimationUpdate;
|
|
790
|
-
if (callbacksChanged) {
|
|
791
|
-
sprite.off("animationstart");
|
|
792
|
-
sprite.off("animationcomplete");
|
|
793
|
-
sprite.off("animationrepeat");
|
|
794
|
-
sprite.off("animationupdate");
|
|
795
|
-
if (next.onAnimationStart) {
|
|
796
|
-
sprite.on("animationstart", (anim) => {
|
|
797
|
-
next.onAnimationStart?.(anim.key);
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
if (next.onAnimationComplete) {
|
|
801
|
-
sprite.on("animationcomplete", (anim) => {
|
|
802
|
-
next.onAnimationComplete?.(anim.key);
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
if (next.onAnimationRepeat) {
|
|
806
|
-
sprite.on("animationrepeat", (anim) => {
|
|
807
|
-
next.onAnimationRepeat?.(anim.key);
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
if (next.onAnimationUpdate) {
|
|
811
|
-
sprite.on(
|
|
812
|
-
"animationupdate",
|
|
813
|
-
(anim, frame) => {
|
|
814
|
-
next.onAnimationUpdate?.(anim.key, frame);
|
|
815
|
-
}
|
|
816
|
-
);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
function applySpriteLayout(sprite, _prev, next) {
|
|
821
|
-
sprite.__layoutProps = next;
|
|
822
|
-
}
|
|
823
|
-
function createSpriteLayout(sprite, props) {
|
|
824
|
-
sprite.__layoutProps = props;
|
|
825
|
-
sprite.__getLayoutSize = () => {
|
|
826
|
-
return { width: 0.01, height: 0.01 };
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
const spriteCreator = (scene, props) => {
|
|
830
|
-
const sprite = scene.add.sprite(props.x ?? 0, props.y ?? 0, props.texture, props.frame);
|
|
831
|
-
sprite.setOrigin(0.5, 0.5);
|
|
832
|
-
if (props.originX !== void 0 || props.originY !== void 0) {
|
|
833
|
-
sprite.setOrigin(props.originX ?? sprite.originX, props.originY ?? sprite.originY);
|
|
834
|
-
}
|
|
835
|
-
createTransform(sprite, props);
|
|
836
|
-
createPhaser(sprite, props);
|
|
837
|
-
if (props.tint !== void 0) {
|
|
838
|
-
sprite.setTint(props.tint);
|
|
839
|
-
}
|
|
840
|
-
if (props.displayWidth !== void 0 || props.displayHeight !== void 0) {
|
|
841
|
-
if (props.displayWidth !== void 0 && props.displayHeight !== void 0) {
|
|
842
|
-
const fit = props.fit ?? "fill";
|
|
843
|
-
const textureWidth = sprite.width;
|
|
844
|
-
const textureHeight = sprite.height;
|
|
845
|
-
if (textureWidth > 0 && textureHeight > 0) {
|
|
846
|
-
if (fit === "fill") {
|
|
847
|
-
sprite.setDisplaySize(props.displayWidth, props.displayHeight);
|
|
848
|
-
} else if (fit === "contain") {
|
|
849
|
-
const targetAspect = props.displayWidth / props.displayHeight;
|
|
850
|
-
const textureAspect = textureWidth / textureHeight;
|
|
851
|
-
const scale = targetAspect > textureAspect ? props.displayHeight / textureHeight : props.displayWidth / textureWidth;
|
|
852
|
-
sprite.setScale(scale);
|
|
853
|
-
} else if (fit === "cover") {
|
|
854
|
-
const targetAspect = props.displayWidth / props.displayHeight;
|
|
855
|
-
const textureAspect = textureWidth / textureHeight;
|
|
856
|
-
const scale = targetAspect < textureAspect ? props.displayHeight / textureHeight : props.displayWidth / textureWidth;
|
|
857
|
-
sprite.setScale(scale);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
} else if (props.displayWidth !== void 0) {
|
|
861
|
-
const scale = props.displayWidth / sprite.width;
|
|
862
|
-
sprite.setScale(scale);
|
|
863
|
-
} else if (props.displayHeight !== void 0) {
|
|
864
|
-
const scale = props.displayHeight / sprite.height;
|
|
865
|
-
sprite.setScale(scale);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
if (props.animationKey) {
|
|
869
|
-
if (sprite.scene && sprite.scene.anims.exists(props.animationKey)) {
|
|
870
|
-
sprite.anims.play({
|
|
871
|
-
key: props.animationKey,
|
|
872
|
-
repeat: props.loop ? -1 : 0,
|
|
873
|
-
repeatDelay: props.repeatDelay ?? 0
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
if (props.onAnimationStart) {
|
|
878
|
-
sprite.on("animationstart", (anim) => {
|
|
879
|
-
props.onAnimationStart?.(anim.key);
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
if (props.onAnimationComplete) {
|
|
883
|
-
sprite.on("animationcomplete", (anim) => {
|
|
884
|
-
props.onAnimationComplete?.(anim.key);
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
if (props.onAnimationRepeat) {
|
|
888
|
-
sprite.on("animationrepeat", (anim) => {
|
|
889
|
-
props.onAnimationRepeat?.(anim.key);
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
if (props.onAnimationUpdate) {
|
|
893
|
-
sprite.on(
|
|
894
|
-
"animationupdate",
|
|
895
|
-
(anim, frame) => {
|
|
896
|
-
props.onAnimationUpdate?.(anim.key, frame);
|
|
897
|
-
}
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
createSpriteLayout(sprite, props);
|
|
901
|
-
if (props.onReady) {
|
|
902
|
-
props.onReady(sprite);
|
|
903
|
-
}
|
|
904
|
-
return sprite;
|
|
905
|
-
};
|
|
906
|
-
const spritePatcher = (node, prev, next) => {
|
|
907
|
-
applyTransformProps(node, prev, next);
|
|
908
|
-
applyPhaserProps(node, prev, next);
|
|
909
|
-
applySpriteProps(node, prev, next);
|
|
910
|
-
applySpriteLayout(node, prev, next);
|
|
911
|
-
};
|
|
912
|
-
function applyTextProps(node, prev, next) {
|
|
913
|
-
if (node.active === false || node.scene && !node.scene.sys.game) {
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
let needsUpdate = false;
|
|
917
|
-
if (prev.text !== next.text && typeof next.text === "string") {
|
|
918
|
-
node.setText(next.text);
|
|
919
|
-
needsUpdate = true;
|
|
920
|
-
}
|
|
921
|
-
if (next.style !== void 0 && !equal(next.style, prev.style || {})) {
|
|
922
|
-
try {
|
|
923
|
-
node.setStyle(next.style);
|
|
924
|
-
needsUpdate = true;
|
|
925
|
-
} catch (error) {
|
|
926
|
-
console.warn("Failed to apply text style (scene may be transitioning):", error);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
if (next.maxWidth !== prev.maxWidth && next.maxWidth !== void 0) {
|
|
930
|
-
const viewport = viewportRegistry.getViewport();
|
|
931
|
-
const parsedMaxWidth = parseSize(next.maxWidth);
|
|
932
|
-
const resolvedMaxWidth = resolveSize(parsedMaxWidth, viewport?.width, void 0, void 0);
|
|
933
|
-
node.setWordWrapWidth(resolvedMaxWidth, true);
|
|
934
|
-
needsUpdate = true;
|
|
935
|
-
}
|
|
936
|
-
if (prev.style !== next.style && next.style !== void 0) {
|
|
937
|
-
try {
|
|
938
|
-
node.setStyle(next.style);
|
|
939
|
-
needsUpdate = true;
|
|
940
|
-
} catch (error) {
|
|
941
|
-
console.warn("Failed to apply text style (scene may be transitioning):", error);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (needsUpdate && node.updateText) {
|
|
945
|
-
node.updateText();
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
function applyTextLayout(text, _prev, next) {
|
|
949
|
-
text.__layoutProps = next;
|
|
950
|
-
text.__getLayoutSize = () => {
|
|
951
|
-
if (text.__layoutProps?.headless) {
|
|
952
|
-
return { width: 0.01, height: 0.01 };
|
|
953
|
-
}
|
|
954
|
-
return {
|
|
955
|
-
width: text.width,
|
|
956
|
-
height: text.height
|
|
957
|
-
};
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function createTextLayout(text, props) {
|
|
961
|
-
text.__layoutProps = props;
|
|
962
|
-
text.__getLayoutSize = () => {
|
|
963
|
-
if (text.__layoutProps?.headless) {
|
|
964
|
-
return { width: 0.01, height: 0.01 };
|
|
965
|
-
}
|
|
966
|
-
return {
|
|
967
|
-
width: text.width,
|
|
968
|
-
height: text.height
|
|
969
|
-
};
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
const textCreator = (scene, props) => {
|
|
973
|
-
const text = scene.add.text(props.x ?? 0, props.y ?? 0, props.text ?? "", props.style);
|
|
974
|
-
if (props.headless) {
|
|
975
|
-
text.setOrigin(0.5, 0.5);
|
|
976
|
-
} else {
|
|
977
|
-
text.setOrigin(0, 0);
|
|
978
|
-
}
|
|
979
|
-
const normalizedProps = { ...props };
|
|
980
|
-
if (props.headless) {
|
|
981
|
-
delete normalizedProps.padding;
|
|
982
|
-
delete normalizedProps.margin;
|
|
983
|
-
delete normalizedProps.gap;
|
|
984
|
-
} else {
|
|
985
|
-
if (normalizedProps.rotation !== void 0) {
|
|
986
|
-
delete normalizedProps.rotation;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
createTransform(text, normalizedProps);
|
|
990
|
-
createPhaser(text, normalizedProps);
|
|
991
|
-
createTextLayout(text, normalizedProps);
|
|
992
|
-
return text;
|
|
993
|
-
};
|
|
994
|
-
const textPatcher = (node, prev, next) => {
|
|
995
|
-
if (prev.headless !== next.headless) {
|
|
996
|
-
if (next.headless) {
|
|
997
|
-
node.setOrigin(0.5, 0.5);
|
|
998
|
-
} else {
|
|
999
|
-
node.setOrigin(0, 0);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
const normalizedPrev = { ...prev };
|
|
1003
|
-
const normalizedNext = { ...next };
|
|
1004
|
-
if (next.headless) {
|
|
1005
|
-
delete normalizedNext.padding;
|
|
1006
|
-
delete normalizedNext.margin;
|
|
1007
|
-
delete normalizedNext.gap;
|
|
1008
|
-
} else {
|
|
1009
|
-
if (normalizedNext.rotation !== void 0) {
|
|
1010
|
-
delete normalizedNext.rotation;
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
if (prev.headless) {
|
|
1014
|
-
delete normalizedPrev.padding;
|
|
1015
|
-
delete normalizedPrev.margin;
|
|
1016
|
-
delete normalizedPrev.gap;
|
|
1017
|
-
} else {
|
|
1018
|
-
if (normalizedPrev.rotation !== void 0) {
|
|
1019
|
-
delete normalizedPrev.rotation;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
applyTransformProps(node, normalizedPrev, normalizedNext);
|
|
1023
|
-
applyPhaserProps(node, normalizedPrev, normalizedNext);
|
|
1024
|
-
applyTextProps(node, normalizedPrev, normalizedNext);
|
|
1025
|
-
applyTextLayout(node, normalizedPrev, normalizedNext);
|
|
1026
|
-
};
|
|
1027
|
-
const tileSpriteCreator = (_scene, _props) => {
|
|
1028
|
-
throw new Error(
|
|
1029
|
-
"TileSprite component not implemented yet. This is a placeholder for architecture planning."
|
|
1030
|
-
);
|
|
1031
|
-
};
|
|
1032
|
-
const tileSpritePatcher = (_node, _prev, _next) => {
|
|
1033
|
-
throw new Error(
|
|
1034
|
-
"TileSprite component not implemented yet. This is a placeholder for architecture planning."
|
|
1035
|
-
);
|
|
1036
|
-
};
|
|
1037
|
-
function applyBackgroundProps(container, prev, next) {
|
|
1038
|
-
const prevBgColor = prev.backgroundColor;
|
|
1039
|
-
const nextBgColor = next.backgroundColor;
|
|
1040
|
-
const prevBgAlpha = prev.backgroundAlpha ?? 1;
|
|
1041
|
-
const nextBgAlpha = next.backgroundAlpha ?? 1;
|
|
1042
|
-
let prevWidth = typeof prev.width === "number" ? prev.width : 100;
|
|
1043
|
-
let prevHeight = typeof prev.height === "number" ? prev.height : 100;
|
|
1044
|
-
let nextWidth = typeof next.width === "number" ? next.width : 100;
|
|
1045
|
-
let nextHeight = typeof next.height === "number" ? next.height : 100;
|
|
1046
|
-
if (container.__getLayoutSize) {
|
|
1047
|
-
const layoutSize = container.__getLayoutSize();
|
|
1048
|
-
prevWidth = layoutSize.width;
|
|
1049
|
-
prevHeight = layoutSize.height;
|
|
1050
|
-
nextWidth = layoutSize.width;
|
|
1051
|
-
nextHeight = layoutSize.height;
|
|
1052
|
-
}
|
|
1053
|
-
const prevCornerRadius = prev.cornerRadius ?? 0;
|
|
1054
|
-
const nextCornerRadius = next.cornerRadius ?? 0;
|
|
1055
|
-
const prevBorderColor = prev.borderColor;
|
|
1056
|
-
const nextBorderColor = next.borderColor;
|
|
1057
|
-
const prevBorderWidth = prev.borderWidth ?? 0;
|
|
1058
|
-
const nextBorderWidth = next.borderWidth ?? 0;
|
|
1059
|
-
const prevBorderAlpha = prev.borderAlpha ?? 1;
|
|
1060
|
-
const nextBorderAlpha = next.borderAlpha ?? 1;
|
|
1061
|
-
const prevHasBorder = prevBorderWidth > 0 && prevBorderColor !== void 0;
|
|
1062
|
-
const nextHasBorder = nextBorderWidth > 0 && nextBorderColor !== void 0;
|
|
1063
|
-
const prevHasGraphics = prevBgColor !== void 0 || prevHasBorder;
|
|
1064
|
-
const nextHasGraphics = nextBgColor !== void 0 || nextHasBorder;
|
|
1065
|
-
if (prevHasGraphics && !nextHasGraphics) {
|
|
1066
|
-
if (container.__background) {
|
|
1067
|
-
container.__background.destroy();
|
|
1068
|
-
delete container.__background;
|
|
1069
|
-
}
|
|
1070
|
-
} else if (!prevHasGraphics && nextHasGraphics) {
|
|
1071
|
-
if (container.scene) {
|
|
1072
|
-
const background = container.scene.add.graphics();
|
|
1073
|
-
if (nextBgColor !== void 0) {
|
|
1074
|
-
background.fillStyle(nextBgColor, nextBgAlpha);
|
|
1075
|
-
}
|
|
1076
|
-
if (nextHasBorder) {
|
|
1077
|
-
background.lineStyle(nextBorderWidth, nextBorderColor, nextBorderAlpha);
|
|
1078
|
-
}
|
|
1079
|
-
if (nextCornerRadius !== 0) {
|
|
1080
|
-
if (nextBgColor !== void 0) {
|
|
1081
|
-
background.fillRoundedRect(0, 0, nextWidth, nextHeight, nextCornerRadius);
|
|
1082
|
-
}
|
|
1083
|
-
if (nextHasBorder) {
|
|
1084
|
-
background.strokeRoundedRect(0, 0, nextWidth, nextHeight, nextCornerRadius);
|
|
1085
|
-
}
|
|
1086
|
-
} else {
|
|
1087
|
-
if (nextBgColor !== void 0) {
|
|
1088
|
-
background.fillRect(0, 0, nextWidth, nextHeight);
|
|
1089
|
-
}
|
|
1090
|
-
if (nextHasBorder) {
|
|
1091
|
-
background.strokeRect(0, 0, nextWidth, nextHeight);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
container.addAt(background, 0);
|
|
1095
|
-
container.__background = background;
|
|
1096
|
-
background.__isBackground = true;
|
|
1097
|
-
}
|
|
1098
|
-
} else if (container.__background && nextHasGraphics) {
|
|
1099
|
-
const needsRedraw = prevBgColor !== nextBgColor || prevBgAlpha !== nextBgAlpha || prevWidth !== nextWidth || prevHeight !== nextHeight || prevCornerRadius !== nextCornerRadius || prevBorderWidth !== nextBorderWidth || prevBorderColor !== nextBorderColor || prevBorderAlpha !== nextBorderAlpha;
|
|
1100
|
-
if (needsRedraw) {
|
|
1101
|
-
container.__background.clear();
|
|
1102
|
-
if (nextBgColor !== void 0) {
|
|
1103
|
-
container.__background.fillStyle(nextBgColor, nextBgAlpha);
|
|
1104
|
-
}
|
|
1105
|
-
if (nextHasBorder) {
|
|
1106
|
-
container.__background.lineStyle(nextBorderWidth, nextBorderColor, nextBorderAlpha);
|
|
1107
|
-
}
|
|
1108
|
-
if (nextCornerRadius !== 0) {
|
|
1109
|
-
if (nextBgColor !== void 0) {
|
|
1110
|
-
container.__background.fillRoundedRect(0, 0, nextWidth, nextHeight, nextCornerRadius);
|
|
1111
|
-
}
|
|
1112
|
-
if (nextHasBorder) {
|
|
1113
|
-
container.__background.strokeRoundedRect(0, 0, nextWidth, nextHeight, nextCornerRadius);
|
|
1114
|
-
}
|
|
1115
|
-
} else {
|
|
1116
|
-
if (nextBgColor !== void 0) {
|
|
1117
|
-
container.__background.fillRect(0, 0, nextWidth, nextHeight);
|
|
1118
|
-
}
|
|
1119
|
-
if (nextHasBorder) {
|
|
1120
|
-
container.__background.strokeRect(0, 0, nextWidth, nextHeight);
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
function applyGesturesProps(scene, container, prev, next) {
|
|
1127
|
-
if (!scene || !scene.sys || !scene.data) {
|
|
1128
|
-
console.warn("applyGesturesProps: Invalid scene or scene not initialized");
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
if (scene.sys.game === null) {
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
const hasAnyGesture = !!(next.onTouch || next.onTouchOutside || next.onTouchMove || next.onDoubleTap || next.onLongPress || next.onHoverStart || next.onHoverEnd || next.onWheel);
|
|
1135
|
-
const hadAnyGesture = !!(prev.onTouch || prev.onTouchOutside || prev.onTouchMove || prev.onDoubleTap || prev.onLongPress || prev.onHoverStart || prev.onHoverEnd || prev.onWheel);
|
|
1136
|
-
const prevEnabled = hadAnyGesture && prev.enableGestures !== false;
|
|
1137
|
-
const nextEnabled = hasAnyGesture && next.enableGestures !== false;
|
|
1138
|
-
const manager = getGestureManager(scene);
|
|
1139
|
-
if (!prevEnabled && nextEnabled && hasAnyGesture) {
|
|
1140
|
-
const containerWithLayout = container;
|
|
1141
|
-
let width = 100;
|
|
1142
|
-
let height = 100;
|
|
1143
|
-
if (containerWithLayout.__getLayoutSize) {
|
|
1144
|
-
const size = containerWithLayout.__getLayoutSize();
|
|
1145
|
-
width = size.width;
|
|
1146
|
-
height = size.height;
|
|
1147
|
-
} else {
|
|
1148
|
-
const bounds = container.getBounds();
|
|
1149
|
-
width = bounds.width || 100;
|
|
1150
|
-
height = bounds.height || 100;
|
|
1151
|
-
}
|
|
1152
|
-
const hitArea = new Phaser.Geom.Rectangle(0, 0, width, height);
|
|
1153
|
-
const callbacks = {};
|
|
1154
|
-
if (next.onTouch) callbacks.onTouch = next.onTouch;
|
|
1155
|
-
if (next.onTouchOutside) callbacks.onTouchOutside = next.onTouchOutside;
|
|
1156
|
-
if (next.onTouchMove) callbacks.onTouchMove = next.onTouchMove;
|
|
1157
|
-
if (next.onDoubleTap) callbacks.onDoubleTap = next.onDoubleTap;
|
|
1158
|
-
if (next.onLongPress) callbacks.onLongPress = next.onLongPress;
|
|
1159
|
-
if (next.onHoverStart) callbacks.onHoverStart = next.onHoverStart;
|
|
1160
|
-
if (next.onHoverEnd) callbacks.onHoverEnd = next.onHoverEnd;
|
|
1161
|
-
if (next.onWheel) callbacks.onWheel = next.onWheel;
|
|
1162
|
-
const config = {};
|
|
1163
|
-
if (next.longPressDuration !== void 0) config.longPressDuration = next.longPressDuration;
|
|
1164
|
-
if (next.doubleTapDelay !== void 0) config.doubleTapDelay = next.doubleTapDelay;
|
|
1165
|
-
manager.registerContainer(container, callbacks, hitArea, config);
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
if (prevEnabled && (!nextEnabled || !hasAnyGesture)) {
|
|
1169
|
-
manager.unregisterContainer(container);
|
|
1170
|
-
return;
|
|
1171
|
-
}
|
|
1172
|
-
if (nextEnabled && hasAnyGesture) {
|
|
1173
|
-
const callbacksChanged = prev.onTouch !== next.onTouch || prev.onTouchOutside !== next.onTouchOutside || prev.onTouchMove !== next.onTouchMove || prev.onDoubleTap !== next.onDoubleTap || prev.onLongPress !== next.onLongPress || prev.onHoverStart !== next.onHoverStart || prev.onHoverEnd !== next.onHoverEnd || prev.onWheel !== next.onWheel;
|
|
1174
|
-
if (callbacksChanged) {
|
|
1175
|
-
const callbacks = {};
|
|
1176
|
-
if (next.onTouch) callbacks.onTouch = next.onTouch;
|
|
1177
|
-
if (next.onTouchOutside) callbacks.onTouchOutside = next.onTouchOutside;
|
|
1178
|
-
if (next.onTouchMove) callbacks.onTouchMove = next.onTouchMove;
|
|
1179
|
-
if (next.onDoubleTap) callbacks.onDoubleTap = next.onDoubleTap;
|
|
1180
|
-
if (next.onLongPress) callbacks.onLongPress = next.onLongPress;
|
|
1181
|
-
if (next.onHoverStart) callbacks.onHoverStart = next.onHoverStart;
|
|
1182
|
-
if (next.onHoverEnd) callbacks.onHoverEnd = next.onHoverEnd;
|
|
1183
|
-
if (next.onWheel) callbacks.onWheel = next.onWheel;
|
|
1184
|
-
manager.updateCallbacks(container, callbacks);
|
|
1185
|
-
}
|
|
1186
|
-
const containerWithLayout = container;
|
|
1187
|
-
let width = 100;
|
|
1188
|
-
let height = 100;
|
|
1189
|
-
if (containerWithLayout.__getLayoutSize) {
|
|
1190
|
-
const size = containerWithLayout.__getLayoutSize();
|
|
1191
|
-
width = size.width;
|
|
1192
|
-
height = size.height;
|
|
1193
|
-
} else {
|
|
1194
|
-
const bounds = container.getBounds();
|
|
1195
|
-
width = bounds.width || 100;
|
|
1196
|
-
height = bounds.height || 100;
|
|
1197
|
-
}
|
|
1198
|
-
const hitArea = new Phaser.Geom.Rectangle(0, 0, width, height);
|
|
1199
|
-
manager.updateHitArea(container, hitArea);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
function updateGestureHitAreaIfNeeded(node) {
|
|
1203
|
-
const containerWithLayout = node;
|
|
1204
|
-
if (!containerWithLayout.__getLayoutSize) return;
|
|
1205
|
-
try {
|
|
1206
|
-
const manager = getGestureManager(containerWithLayout.scene);
|
|
1207
|
-
const size = containerWithLayout.__getLayoutSize();
|
|
1208
|
-
const hitArea = new Phaser.Geom.Rectangle(0, 0, size.width, size.height);
|
|
1209
|
-
manager.updateHitArea(node, hitArea);
|
|
1210
|
-
} catch {
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
const LAYOUT_RELEVANT_PROPS = [
|
|
1214
|
-
"width",
|
|
1215
|
-
"height",
|
|
1216
|
-
"minWidth",
|
|
1217
|
-
"maxWidth",
|
|
1218
|
-
"minHeight",
|
|
1219
|
-
"maxHeight",
|
|
1220
|
-
"flex",
|
|
1221
|
-
"margin",
|
|
1222
|
-
"padding",
|
|
1223
|
-
"gap",
|
|
1224
|
-
"direction",
|
|
1225
|
-
"justifyContent",
|
|
1226
|
-
"alignItems",
|
|
1227
|
-
"overflow"
|
|
1228
|
-
];
|
|
1229
|
-
const DEEP_COMPARE_PROPS = /* @__PURE__ */ new Set(["margin", "padding"]);
|
|
1230
|
-
function hasLayoutPropsChanged(prev, next) {
|
|
1231
|
-
for (const prop of LAYOUT_RELEVANT_PROPS) {
|
|
1232
|
-
const oldVal = prev[prop];
|
|
1233
|
-
const newVal = next[prop];
|
|
1234
|
-
if (DEEP_COMPARE_PROPS.has(prop)) {
|
|
1235
|
-
if (!equal(oldVal, newVal)) {
|
|
1236
|
-
return true;
|
|
1237
|
-
}
|
|
1238
|
-
} else {
|
|
1239
|
-
if (oldVal !== newVal) {
|
|
1240
|
-
return true;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
return false;
|
|
1245
|
-
}
|
|
1246
|
-
function getParentLayoutContext(node) {
|
|
1247
|
-
const parent = node.parentContainer;
|
|
1248
|
-
if (parent && parent.__layoutProps && parent.__getLayoutSize) {
|
|
1249
|
-
const parentSize = parent.__getLayoutSize();
|
|
1250
|
-
const padding = parent.__layoutProps.padding ?? 0;
|
|
1251
|
-
const normPadding = typeof padding === "number" ? { left: padding, right: padding, top: padding, bottom: padding } : {
|
|
1252
|
-
left: padding.left ?? 0,
|
|
1253
|
-
right: padding.right ?? 0,
|
|
1254
|
-
top: padding.top ?? 0,
|
|
1255
|
-
bottom: padding.bottom ?? 0
|
|
1256
|
-
};
|
|
1257
|
-
return {
|
|
1258
|
-
parentSize: {
|
|
1259
|
-
width: parentSize.width - normPadding.left - normPadding.right,
|
|
1260
|
-
height: parentSize.height - normPadding.top - normPadding.bottom
|
|
1261
|
-
}
|
|
1262
|
-
// Parent already provides content-area, no padding offset needed
|
|
1263
|
-
};
|
|
1264
|
-
}
|
|
1265
|
-
if (node.scene) {
|
|
1266
|
-
return {
|
|
1267
|
-
parentSize: {
|
|
1268
|
-
width: node.scene.scale.width,
|
|
1269
|
-
height: node.scene.scale.height
|
|
1270
|
-
}
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
return {};
|
|
1274
|
-
}
|
|
1275
|
-
function applyLayoutProps(node, prev, next) {
|
|
1276
|
-
node.__layoutProps = next;
|
|
1277
|
-
if (hasLayoutPropsChanged(prev, next)) {
|
|
1278
|
-
const { parentSize, parentPadding } = getParentLayoutContext(node);
|
|
1279
|
-
calculateLayout(node, next, parentSize, parentPadding);
|
|
1280
|
-
updateGestureHitAreaIfNeeded(node);
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
const tooltipStates = /* @__PURE__ */ new Map();
|
|
1284
|
-
function calculateTooltipPosition(targetBounds, position, offset, tooltipWidth, tooltipHeight) {
|
|
1285
|
-
const viewport = {
|
|
1286
|
-
width: window.innerWidth,
|
|
1287
|
-
height: window.innerHeight
|
|
1288
|
-
};
|
|
1289
|
-
let x = 0;
|
|
1290
|
-
let y = 0;
|
|
1291
|
-
switch (position) {
|
|
1292
|
-
case "top":
|
|
1293
|
-
x = targetBounds.centerX - tooltipWidth / 2;
|
|
1294
|
-
y = targetBounds.top - tooltipHeight - offset;
|
|
1295
|
-
break;
|
|
1296
|
-
case "bottom":
|
|
1297
|
-
x = targetBounds.centerX - tooltipWidth / 2;
|
|
1298
|
-
y = targetBounds.bottom + offset;
|
|
1299
|
-
break;
|
|
1300
|
-
case "left":
|
|
1301
|
-
x = targetBounds.left - tooltipWidth - offset;
|
|
1302
|
-
y = targetBounds.centerY - tooltipHeight / 2;
|
|
1303
|
-
break;
|
|
1304
|
-
case "right":
|
|
1305
|
-
x = targetBounds.right + offset;
|
|
1306
|
-
y = targetBounds.centerY - tooltipHeight / 2;
|
|
1307
|
-
break;
|
|
1308
|
-
}
|
|
1309
|
-
x = Math.max(8, Math.min(x, viewport.width - tooltipWidth - 8));
|
|
1310
|
-
y = Math.max(8, Math.min(y, viewport.height - tooltipHeight - 8));
|
|
1311
|
-
return { x, y };
|
|
1312
|
-
}
|
|
1313
|
-
function showTooltip(scene, container, config) {
|
|
1314
|
-
const state = tooltipStates.get(container);
|
|
1315
|
-
if (!state || state.isVisible) return;
|
|
1316
|
-
state.isVisible = true;
|
|
1317
|
-
state.currentConfig = config;
|
|
1318
|
-
const theme = themeRegistry.getGlobalTheme();
|
|
1319
|
-
const tooltipTheme = theme.Tooltip || {};
|
|
1320
|
-
const position = config.position ?? tooltipTheme.position ?? "top";
|
|
1321
|
-
const offset = config.offset ?? tooltipTheme.offset ?? 8;
|
|
1322
|
-
const content = config.content;
|
|
1323
|
-
const targetBounds = container.getBounds();
|
|
1324
|
-
const textStyle = tooltipTheme.textStyle ?? {
|
|
1325
|
-
fontSize: "14px",
|
|
1326
|
-
fontFamily: "Arial",
|
|
1327
|
-
color: "#ffffff",
|
|
1328
|
-
padding: { x: 8, y: 4 }
|
|
1329
|
-
};
|
|
1330
|
-
const { backgroundColor: bgColor, ...styleWithoutBg } = textStyle;
|
|
1331
|
-
const text = scene.add.text(0, 0, content, styleWithoutBg);
|
|
1332
|
-
text.setOrigin(0.5);
|
|
1333
|
-
const padding = textStyle.padding ?? { x: 8, y: 4 };
|
|
1334
|
-
const paddingX = typeof padding === "number" ? padding : padding.x ?? 8;
|
|
1335
|
-
const paddingY = typeof padding === "number" ? padding : padding.y ?? 4;
|
|
1336
|
-
const textWidth = text.width;
|
|
1337
|
-
const textHeight = text.height;
|
|
1338
|
-
const bgWidth = textWidth + paddingX * 2;
|
|
1339
|
-
const bgHeight = textHeight + paddingY * 2;
|
|
1340
|
-
const cornerRadius = tooltipTheme.cornerRadius ?? 6;
|
|
1341
|
-
const graphics = scene.add.graphics();
|
|
1342
|
-
const bg2 = bgColor ?? "#000000dd";
|
|
1343
|
-
let fillColor = 0;
|
|
1344
|
-
let fillAlpha = 0.87;
|
|
1345
|
-
if (typeof bg2 === "string") {
|
|
1346
|
-
if (bg2.startsWith("#")) {
|
|
1347
|
-
const hex = bg2.slice(1);
|
|
1348
|
-
if (hex.length === 8) {
|
|
1349
|
-
fillColor = parseInt(hex.slice(0, 6), 16);
|
|
1350
|
-
fillAlpha = parseInt(hex.slice(6, 8), 16) / 255;
|
|
1351
|
-
} else if (hex.length === 6) {
|
|
1352
|
-
fillColor = parseInt(hex, 16);
|
|
1353
|
-
fillAlpha = 1;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
graphics.fillStyle(fillColor, fillAlpha);
|
|
1358
|
-
graphics.fillRoundedRect(-bgWidth / 2, -bgHeight / 2, bgWidth, bgHeight, cornerRadius);
|
|
1359
|
-
const tooltipContainer = scene.add.container(0, 0, [graphics, text]);
|
|
1360
|
-
tooltipContainer.setDepth(1e4);
|
|
1361
|
-
const textBounds = tooltipContainer.getBounds();
|
|
1362
|
-
const pos = calculateTooltipPosition(
|
|
1363
|
-
targetBounds,
|
|
1364
|
-
position,
|
|
1365
|
-
offset,
|
|
1366
|
-
textBounds.width,
|
|
1367
|
-
textBounds.height
|
|
1368
|
-
);
|
|
1369
|
-
const themeAnim = tooltipTheme.animation || {};
|
|
1370
|
-
const anim = config.animation || {};
|
|
1371
|
-
const fadeInDuration = anim.fadeIn ?? themeAnim.fadeIn ?? 200;
|
|
1372
|
-
const moveOffset = {
|
|
1373
|
-
dx: anim.move?.dx ?? themeAnim.move?.dx ?? 0,
|
|
1374
|
-
dy: anim.move?.dy ?? themeAnim.move?.dy ?? 0
|
|
1375
|
-
};
|
|
1376
|
-
const pulse = anim.pulse ?? themeAnim.pulse ?? false;
|
|
1377
|
-
const pulseScale = anim.pulseScale ?? [0.75, 1.25];
|
|
1378
|
-
tooltipContainer.setPosition(
|
|
1379
|
-
pos.x + textBounds.width / 2 - moveOffset.dx,
|
|
1380
|
-
pos.y + textBounds.height / 2 - moveOffset.dy
|
|
1381
|
-
);
|
|
1382
|
-
tooltipContainer.setAlpha(0);
|
|
1383
|
-
state.tooltip = tooltipContainer;
|
|
1384
|
-
const fadeTween = scene.tweens.add({
|
|
1385
|
-
targets: tooltipContainer,
|
|
1386
|
-
alpha: 1,
|
|
1387
|
-
x: pos.x + textBounds.width / 2,
|
|
1388
|
-
y: pos.y + textBounds.height / 2,
|
|
1389
|
-
duration: fadeInDuration,
|
|
1390
|
-
ease: "Cubic.Out"
|
|
1391
|
-
});
|
|
1392
|
-
state.activeTweens.push(fadeTween);
|
|
1393
|
-
if (pulse) {
|
|
1394
|
-
const pulseTween = scene.tweens.add({
|
|
1395
|
-
targets: tooltipContainer,
|
|
1396
|
-
scale: { from: pulseScale[0], to: pulseScale[1] },
|
|
1397
|
-
duration: 600,
|
|
1398
|
-
yoyo: true,
|
|
1399
|
-
repeat: -1,
|
|
1400
|
-
ease: "Sine.InOut"
|
|
1401
|
-
});
|
|
1402
|
-
state.activeTweens.push(pulseTween);
|
|
1403
|
-
}
|
|
1404
|
-
if (config.autoDismiss && config.autoDismiss > 0) {
|
|
1405
|
-
state.autoDismissTimer = setTimeout(() => {
|
|
1406
|
-
hideTooltip(container);
|
|
1407
|
-
}, config.autoDismiss);
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
function hideTooltip(container) {
|
|
1411
|
-
const state = tooltipStates.get(container);
|
|
1412
|
-
if (!state || !state.isVisible) return;
|
|
1413
|
-
state.isVisible = false;
|
|
1414
|
-
const config = state.currentConfig;
|
|
1415
|
-
state.currentConfig = null;
|
|
1416
|
-
if (state.autoDismissTimer) {
|
|
1417
|
-
clearTimeout(state.autoDismissTimer);
|
|
1418
|
-
state.autoDismissTimer = null;
|
|
1419
|
-
}
|
|
1420
|
-
if (!state.tooltip) return;
|
|
1421
|
-
const tooltip = state.tooltip;
|
|
1422
|
-
const scene = tooltip.scene;
|
|
1423
|
-
const theme = themeRegistry.getGlobalTheme();
|
|
1424
|
-
const tooltipTheme = theme.Tooltip || {};
|
|
1425
|
-
const themeAnim = tooltipTheme.animation || {};
|
|
1426
|
-
const anim = config?.animation || {};
|
|
1427
|
-
const fadeOutDuration = anim.fadeOut ?? themeAnim.fadeOut ?? 200;
|
|
1428
|
-
state.activeTweens.forEach((tween) => tween.stop());
|
|
1429
|
-
state.activeTweens = [];
|
|
1430
|
-
scene.tweens.add({
|
|
1431
|
-
targets: tooltip,
|
|
1432
|
-
alpha: 0,
|
|
1433
|
-
duration: fadeOutDuration,
|
|
1434
|
-
ease: "Cubic.In",
|
|
1435
|
-
onComplete: () => {
|
|
1436
|
-
tooltip.destroy();
|
|
1437
|
-
}
|
|
1438
|
-
});
|
|
1439
|
-
state.tooltip = null;
|
|
1440
|
-
}
|
|
1441
|
-
function applyTooltip(scene, container, nextCallback, existingOnHoverStart, existingOnHoverEnd) {
|
|
1442
|
-
if (!tooltipStates.has(container)) {
|
|
1443
|
-
tooltipStates.set(container, {
|
|
1444
|
-
isVisible: false,
|
|
1445
|
-
tooltip: null,
|
|
1446
|
-
activeTweens: [],
|
|
1447
|
-
showTimer: null,
|
|
1448
|
-
hideTimer: null,
|
|
1449
|
-
autoDismissTimer: null,
|
|
1450
|
-
currentConfig: null
|
|
1451
|
-
});
|
|
1452
|
-
container.once("destroy", () => {
|
|
1453
|
-
const state2 = tooltipStates.get(container);
|
|
1454
|
-
if (state2) {
|
|
1455
|
-
if (state2.showTimer) clearTimeout(state2.showTimer);
|
|
1456
|
-
if (state2.hideTimer) clearTimeout(state2.hideTimer);
|
|
1457
|
-
if (state2.autoDismissTimer) clearTimeout(state2.autoDismissTimer);
|
|
1458
|
-
state2.activeTweens.forEach((tween) => tween.stop());
|
|
1459
|
-
hideTooltip(container);
|
|
1460
|
-
tooltipStates.delete(container);
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
const state = tooltipStates.get(container);
|
|
1465
|
-
if (!state) {
|
|
1466
|
-
throw new Error("applyTooltip: state not initialized");
|
|
1467
|
-
}
|
|
1468
|
-
const theme = themeRegistry.getGlobalTheme();
|
|
1469
|
-
const tooltipTheme = theme.Tooltip || {};
|
|
1470
|
-
const onHoverStart = (data) => {
|
|
1471
|
-
if (existingOnHoverStart) existingOnHoverStart(data);
|
|
1472
|
-
if (!nextCallback) return;
|
|
1473
|
-
const result = nextCallback();
|
|
1474
|
-
if (!result) return;
|
|
1475
|
-
const config = typeof result === "string" ? { content: result } : result;
|
|
1476
|
-
if (config.disabled) return;
|
|
1477
|
-
if (state.hideTimer) {
|
|
1478
|
-
clearTimeout(state.hideTimer);
|
|
1479
|
-
state.hideTimer = null;
|
|
1480
|
-
}
|
|
1481
|
-
if (state.autoDismissTimer) {
|
|
1482
|
-
clearTimeout(state.autoDismissTimer);
|
|
1483
|
-
state.autoDismissTimer = null;
|
|
1484
|
-
}
|
|
1485
|
-
const showDelay = config.showDelay ?? tooltipTheme.showDelay ?? 500;
|
|
1486
|
-
state.showTimer = setTimeout(() => {
|
|
1487
|
-
showTooltip(scene, container, config);
|
|
1488
|
-
}, showDelay);
|
|
1489
|
-
};
|
|
1490
|
-
const onHoverEnd = (data) => {
|
|
1491
|
-
if (existingOnHoverEnd) existingOnHoverEnd(data);
|
|
1492
|
-
if (state.showTimer) {
|
|
1493
|
-
clearTimeout(state.showTimer);
|
|
1494
|
-
state.showTimer = null;
|
|
1495
|
-
}
|
|
1496
|
-
const hideDelay = state.currentConfig?.hideDelay ?? tooltipTheme.hideDelay ?? 0;
|
|
1497
|
-
if (hideDelay > 0) {
|
|
1498
|
-
state.hideTimer = setTimeout(() => {
|
|
1499
|
-
hideTooltip(container);
|
|
1500
|
-
}, hideDelay);
|
|
1501
|
-
} else {
|
|
1502
|
-
hideTooltip(container);
|
|
1503
|
-
}
|
|
1504
|
-
};
|
|
1505
|
-
return { onHoverStart, onHoverEnd };
|
|
1506
|
-
}
|
|
1507
|
-
function createBackground(scene, container, props) {
|
|
1508
|
-
const hasBackground = props.backgroundColor !== void 0;
|
|
1509
|
-
const hasBorder = props.borderColor !== void 0;
|
|
1510
|
-
if (hasBackground || hasBorder) {
|
|
1511
|
-
const width = typeof props.width === "number" ? props.width : 100;
|
|
1512
|
-
const height = typeof props.height === "number" ? props.height : 100;
|
|
1513
|
-
const bgColor = props.backgroundColor;
|
|
1514
|
-
const bgAlpha = props.backgroundAlpha ?? 1;
|
|
1515
|
-
const cornerRadius = props.cornerRadius ?? 0;
|
|
1516
|
-
const borderColor = props.borderColor;
|
|
1517
|
-
const borderWidth = props.borderWidth ?? 0;
|
|
1518
|
-
const borderAlpha = props.borderAlpha ?? 1;
|
|
1519
|
-
const background = scene.add.graphics();
|
|
1520
|
-
if (bgColor !== void 0) {
|
|
1521
|
-
background.fillStyle(bgColor, bgAlpha);
|
|
1522
|
-
}
|
|
1523
|
-
if (borderWidth > 0 && borderColor !== void 0) {
|
|
1524
|
-
background.lineStyle(borderWidth, borderColor, borderAlpha);
|
|
1525
|
-
}
|
|
1526
|
-
if (cornerRadius !== 0) {
|
|
1527
|
-
if (bgColor !== void 0) {
|
|
1528
|
-
background.fillRoundedRect(0, 0, width, height, cornerRadius);
|
|
1529
|
-
}
|
|
1530
|
-
if (borderWidth > 0 && borderColor !== void 0) {
|
|
1531
|
-
background.strokeRoundedRect(0, 0, width, height, cornerRadius);
|
|
1532
|
-
}
|
|
1533
|
-
} else {
|
|
1534
|
-
if (bgColor !== void 0) {
|
|
1535
|
-
background.fillRect(0, 0, width, height);
|
|
1536
|
-
}
|
|
1537
|
-
if (borderWidth > 0 && borderColor !== void 0) {
|
|
1538
|
-
background.strokeRect(0, 0, width, height);
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
container.addAt(background, 0);
|
|
1542
|
-
container.__background = background;
|
|
1543
|
-
background.__isBackground = true;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
function createGestures(scene, container, props) {
|
|
1547
|
-
const hasAnyGesture = !!(props.onTouch || props.onTouchOutside || props.onTouchMove || props.onDoubleTap || props.onLongPress || props.onHoverStart || props.onHoverEnd || props.onWheel);
|
|
1548
|
-
const shouldEnable = hasAnyGesture && props.enableGestures !== false;
|
|
1549
|
-
if (!shouldEnable) {
|
|
1550
|
-
return;
|
|
1551
|
-
}
|
|
1552
|
-
const manager = getGestureManager(scene);
|
|
1553
|
-
const containerWithLayout = container;
|
|
1554
|
-
let width = 100;
|
|
1555
|
-
let height = 100;
|
|
1556
|
-
if (containerWithLayout.__getLayoutSize) {
|
|
1557
|
-
const size = containerWithLayout.__getLayoutSize();
|
|
1558
|
-
width = size.width;
|
|
1559
|
-
height = size.height;
|
|
1560
|
-
} else {
|
|
1561
|
-
const bounds = container.getBounds();
|
|
1562
|
-
width = bounds.width || 100;
|
|
1563
|
-
height = bounds.height || 100;
|
|
1564
|
-
}
|
|
1565
|
-
const hitArea = new Phaser.Geom.Rectangle(0, 0, width, height);
|
|
1566
|
-
const callbacks = {};
|
|
1567
|
-
if (props.onTouch) callbacks.onTouch = props.onTouch;
|
|
1568
|
-
if (props.onTouchOutside) callbacks.onTouchOutside = props.onTouchOutside;
|
|
1569
|
-
if (props.onTouchMove) callbacks.onTouchMove = props.onTouchMove;
|
|
1570
|
-
if (props.onDoubleTap) callbacks.onDoubleTap = props.onDoubleTap;
|
|
1571
|
-
if (props.onLongPress) callbacks.onLongPress = props.onLongPress;
|
|
1572
|
-
if (props.onHoverStart) callbacks.onHoverStart = props.onHoverStart;
|
|
1573
|
-
if (props.onHoverEnd) callbacks.onHoverEnd = props.onHoverEnd;
|
|
1574
|
-
if (props.onWheel) callbacks.onWheel = props.onWheel;
|
|
1575
|
-
const config = {};
|
|
1576
|
-
if (props.longPressDuration !== void 0) config.longPressDuration = props.longPressDuration;
|
|
1577
|
-
if (props.doubleTapDelay !== void 0) config.doubleTapDelay = props.doubleTapDelay;
|
|
1578
|
-
if (props.maxTouchDuration !== void 0) config.maxTouchDuration = props.maxTouchDuration;
|
|
1579
|
-
manager.registerContainer(container, callbacks, hitArea, config);
|
|
1580
|
-
}
|
|
1581
|
-
function createLayout(container, props) {
|
|
1582
|
-
container.__layoutProps = props;
|
|
1583
|
-
container.__getLayoutSize = () => {
|
|
1584
|
-
const children = container.list;
|
|
1585
|
-
const direction = props.direction ?? "column";
|
|
1586
|
-
const paddingRaw = props.padding ?? {};
|
|
1587
|
-
const padding = typeof paddingRaw === "number" ? { left: paddingRaw, top: paddingRaw, right: paddingRaw, bottom: paddingRaw } : paddingRaw;
|
|
1588
|
-
const paddingLeft = padding.left ?? 0;
|
|
1589
|
-
const paddingTop = padding.top ?? 0;
|
|
1590
|
-
const paddingRight = padding.right ?? 0;
|
|
1591
|
-
const paddingBottom = padding.bottom ?? 0;
|
|
1592
|
-
const gapNormalized = normalizeGap(props.gap);
|
|
1593
|
-
let maxWidth = 0;
|
|
1594
|
-
let maxHeight = 0;
|
|
1595
|
-
let totalMainSize = 0;
|
|
1596
|
-
let childCount = 0;
|
|
1597
|
-
for (const child of children) {
|
|
1598
|
-
if (child.__isBackground) {
|
|
1599
|
-
continue;
|
|
1600
|
-
}
|
|
1601
|
-
childCount++;
|
|
1602
|
-
const marginRaw = child.__layoutProps?.margin ?? {};
|
|
1603
|
-
const margin = typeof marginRaw === "number" ? { top: marginRaw, right: marginRaw, bottom: marginRaw, left: marginRaw } : marginRaw;
|
|
1604
|
-
const marginTop = margin.top ?? 0;
|
|
1605
|
-
const marginBottom = margin.bottom ?? 0;
|
|
1606
|
-
const marginLeft = margin.left ?? 0;
|
|
1607
|
-
const marginRight = margin.right ?? 0;
|
|
1608
|
-
const childSize = getChildSize(child);
|
|
1609
|
-
if (direction === "row") {
|
|
1610
|
-
totalMainSize += marginLeft + childSize.width + marginRight;
|
|
1611
|
-
const childTotalHeight = marginTop + childSize.height + marginBottom;
|
|
1612
|
-
maxHeight = Math.max(maxHeight, childTotalHeight);
|
|
1613
|
-
} else {
|
|
1614
|
-
const childTotalWidth = marginLeft + childSize.width + marginRight;
|
|
1615
|
-
maxWidth = Math.max(maxWidth, childTotalWidth);
|
|
1616
|
-
totalMainSize += marginTop + childSize.height + marginBottom;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
if (childCount > 1) {
|
|
1620
|
-
const gapValue = direction === "row" ? gapNormalized.horizontal : gapNormalized.vertical;
|
|
1621
|
-
totalMainSize += gapValue * (childCount - 1);
|
|
1622
|
-
}
|
|
1623
|
-
const defaultWidth = direction === "row" ? totalMainSize + paddingLeft + paddingRight : maxWidth + paddingLeft + paddingRight;
|
|
1624
|
-
const defaultHeight = direction === "row" ? maxHeight + paddingTop + paddingBottom : totalMainSize + paddingTop + paddingBottom;
|
|
1625
|
-
const parsedWidth = parseSize(props.width);
|
|
1626
|
-
const finalWidth = resolveSize(parsedWidth, void 0, defaultWidth);
|
|
1627
|
-
const parsedHeight = parseSize(props.height);
|
|
1628
|
-
const finalHeight = resolveSize(parsedHeight, void 0, defaultHeight);
|
|
1629
|
-
return {
|
|
1630
|
-
width: finalWidth,
|
|
1631
|
-
height: finalHeight
|
|
1632
|
-
};
|
|
1633
|
-
};
|
|
1634
|
-
}
|
|
1635
|
-
function normalizeBackgroundProps(props) {
|
|
1636
|
-
const bgProps = props;
|
|
1637
|
-
const hasBackground = bgProps.backgroundColor !== void 0;
|
|
1638
|
-
const hasBorder = bgProps.borderColor !== void 0;
|
|
1639
|
-
if (!hasBackground && !hasBorder) {
|
|
1640
|
-
return props;
|
|
1641
|
-
}
|
|
1642
|
-
const normalized = { ...props };
|
|
1643
|
-
if (hasBackground && bgProps.backgroundAlpha === void 0) {
|
|
1644
|
-
normalized.backgroundAlpha = 1;
|
|
1645
|
-
}
|
|
1646
|
-
if (hasBorder) {
|
|
1647
|
-
if (bgProps.borderWidth === void 0 || bgProps.borderWidth === 0) {
|
|
1648
|
-
normalized.borderWidth = 1;
|
|
1649
|
-
}
|
|
1650
|
-
if (bgProps.borderAlpha === void 0 || bgProps.borderAlpha === 0) {
|
|
1651
|
-
normalized.borderAlpha = 1;
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
return normalized;
|
|
1655
|
-
}
|
|
1656
|
-
const viewCreator = (scene, props) => {
|
|
1657
|
-
if (props.backgroundColor !== void 0 || props.cornerRadius !== void 0) {
|
|
1658
|
-
DebugLogger.log("theme", "View Creator - Props received:", {
|
|
1659
|
-
backgroundColor: props.backgroundColor,
|
|
1660
|
-
cornerRadius: props.cornerRadius,
|
|
1661
|
-
width: props.width,
|
|
1662
|
-
height: props.height
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
const normalizedProps = normalizeBackgroundProps(props);
|
|
1666
|
-
const container = scene.add.container(normalizedProps.x ?? 0, normalizedProps.y ?? 0);
|
|
1667
|
-
createTransform(container, normalizedProps);
|
|
1668
|
-
createPhaser(container, normalizedProps);
|
|
1669
|
-
createBackground(
|
|
1670
|
-
scene,
|
|
1671
|
-
container,
|
|
1672
|
-
normalizedProps
|
|
1673
|
-
);
|
|
1674
|
-
createLayout(container, normalizedProps);
|
|
1675
|
-
if (normalizedProps.onTooltip) {
|
|
1676
|
-
const handlers = applyTooltip(
|
|
1677
|
-
scene,
|
|
1678
|
-
container,
|
|
1679
|
-
normalizedProps.onTooltip,
|
|
1680
|
-
normalizedProps.onHoverStart,
|
|
1681
|
-
normalizedProps.onHoverEnd
|
|
1682
|
-
);
|
|
1683
|
-
normalizedProps.onHoverStart = handlers.onHoverStart;
|
|
1684
|
-
normalizedProps.onHoverEnd = handlers.onHoverEnd;
|
|
1685
|
-
}
|
|
1686
|
-
createGestures(scene, container, normalizedProps);
|
|
1687
|
-
DebugLogger.log(
|
|
1688
|
-
"layout",
|
|
1689
|
-
"View creator storing __layoutProps with padding:",
|
|
1690
|
-
normalizedProps.padding
|
|
1691
|
-
);
|
|
1692
|
-
return container;
|
|
1693
|
-
};
|
|
1694
|
-
const viewPatcher = (node, prev, next) => {
|
|
1695
|
-
const normalizedPrev = normalizeBackgroundProps(prev);
|
|
1696
|
-
const normalizedNext = normalizeBackgroundProps(next);
|
|
1697
|
-
applyTransformProps(node, normalizedPrev, normalizedNext);
|
|
1698
|
-
applyPhaserProps(node, normalizedPrev, normalizedNext);
|
|
1699
|
-
const container = node;
|
|
1700
|
-
applyBackgroundProps(container, normalizedPrev, normalizedNext);
|
|
1701
|
-
if (container.scene && container.scene.data) {
|
|
1702
|
-
if (normalizedNext.onTooltip) {
|
|
1703
|
-
const handlers = applyTooltip(
|
|
1704
|
-
container.scene,
|
|
1705
|
-
container,
|
|
1706
|
-
normalizedNext.onTooltip,
|
|
1707
|
-
normalizedNext.onHoverStart,
|
|
1708
|
-
normalizedNext.onHoverEnd
|
|
1709
|
-
);
|
|
1710
|
-
normalizedNext.onHoverStart = handlers.onHoverStart;
|
|
1711
|
-
normalizedNext.onHoverEnd = handlers.onHoverEnd;
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
if (container.scene && container.scene.data) {
|
|
1715
|
-
applyGesturesProps(container.scene, container, normalizedPrev, normalizedNext);
|
|
1716
|
-
}
|
|
1717
|
-
applyLayoutProps(container, normalizedPrev, normalizedNext);
|
|
1718
|
-
};
|
|
1719
|
-
function Sprite(props) {
|
|
1720
|
-
const localTheme = useTheme();
|
|
1721
|
-
const { props: themed, nestedTheme } = getThemedProps("Sprite", localTheme, props);
|
|
1722
|
-
return /* @__PURE__ */ jsx("sprite", { ...themed, theme: nestedTheme });
|
|
1723
|
-
}
|
|
1724
|
-
function TileSprite(props) {
|
|
1725
|
-
const localTheme = useTheme();
|
|
1726
|
-
const { props: themed, nestedTheme } = getThemedProps("TileSprite", localTheme, props);
|
|
1727
|
-
return /* @__PURE__ */ jsx("tilesprite", { ...themed, theme: nestedTheme });
|
|
1728
|
-
}
|
|
1729
|
-
function registerBuiltins() {
|
|
1730
|
-
register("view", { create: viewCreator, patch: viewPatcher });
|
|
1731
|
-
register("text", { create: textCreator, patch: textPatcher });
|
|
1732
|
-
register("nineslice", { create: nineSliceCreator, patch: nineSlicePatcher });
|
|
1733
|
-
register("particles", { create: particlesCreator, patch: particlesPatcher });
|
|
1734
|
-
register("sprite", { create: spriteCreator, patch: spritePatcher });
|
|
1735
|
-
register("image", { create: imageCreator, patch: imagePatcher });
|
|
1736
|
-
register("graphics", { create: graphicsCreator, patch: graphicsPatcher });
|
|
1737
|
-
register("tilesprite", { create: tileSpriteCreator, patch: tileSpritePatcher });
|
|
1738
|
-
register("View", { create: viewCreator, patch: viewPatcher });
|
|
1739
|
-
register("Text", { create: textCreator, patch: textPatcher });
|
|
1740
|
-
register("NineSlice", { create: nineSliceCreator, patch: nineSlicePatcher });
|
|
1741
|
-
register("Particles", { create: particlesCreator, patch: particlesPatcher });
|
|
1742
|
-
register("Sprite", { create: spriteCreator, patch: spritePatcher });
|
|
1743
|
-
register("Image", { create: imageCreator, patch: imagePatcher });
|
|
1744
|
-
register("Graphics", { create: graphicsCreator, patch: graphicsPatcher });
|
|
1745
|
-
register("TileSprite", { create: tileSpriteCreator, patch: tileSpritePatcher });
|
|
1746
|
-
}
|
|
1747
|
-
const createCameraShakeFX = (camera, config) => {
|
|
1748
|
-
const duration = config.duration ?? 250;
|
|
1749
|
-
const intensity = typeof config.intensity === "object" ? new Phaser.Math.Vector2(config.intensity.x, config.intensity.y) : config.intensity ?? 0.01;
|
|
1750
|
-
camera.shake(duration, intensity, config.force ?? false, config.onComplete);
|
|
1751
|
-
};
|
|
1752
|
-
const createCameraFlashFX = (camera, config) => {
|
|
1753
|
-
const duration = config.duration ?? 200;
|
|
1754
|
-
const red = config.red ?? 255;
|
|
1755
|
-
const green = config.green ?? 255;
|
|
1756
|
-
const blue = config.blue ?? 255;
|
|
1757
|
-
camera.flash(duration, red, green, blue, config.force ?? false, config.onComplete);
|
|
1758
|
-
};
|
|
1759
|
-
const createCameraFadeInFX = (camera, config) => {
|
|
1760
|
-
const duration = config.duration ?? 300;
|
|
1761
|
-
const red = config.red ?? 0;
|
|
1762
|
-
const green = config.green ?? 0;
|
|
1763
|
-
const blue = config.blue ?? 0;
|
|
1764
|
-
camera.fadeIn(duration, red, green, blue, config.onComplete);
|
|
1765
|
-
};
|
|
1766
|
-
const createCameraFadeOutFX = (camera, config) => {
|
|
1767
|
-
const duration = config.duration ?? 300;
|
|
1768
|
-
const red = config.red ?? 0;
|
|
1769
|
-
const green = config.green ?? 0;
|
|
1770
|
-
const blue = config.blue ?? 0;
|
|
1771
|
-
camera.fadeOut(duration, red, green, blue, config.onComplete);
|
|
1772
|
-
};
|
|
1773
|
-
const createCameraZoomFX = (camera, config) => {
|
|
1774
|
-
const duration = config.duration ?? 250;
|
|
1775
|
-
const targetZoom = config.zoom ?? camera.zoom * 1.1;
|
|
1776
|
-
camera.zoomTo(targetZoom, duration, config.ease, config.force ?? false, config.onComplete);
|
|
34
|
+
var createCameraZoomFX = (camera, config) => {
|
|
35
|
+
const duration = config.duration ?? 250;
|
|
36
|
+
const targetZoom = config.zoom ?? camera.zoom * 1.1;
|
|
37
|
+
camera.zoomTo(targetZoom, duration, config.ease, config.force ?? false, config.onComplete);
|
|
1777
38
|
};
|
|
1778
39
|
function useCameraFX(cameraRef, options = {}) {
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
}, [getCamera, options.resetZoomOnClear]);
|
|
1815
|
-
useEffect(() => {
|
|
1816
|
-
return () => clearCameraFX();
|
|
1817
|
-
}, [clearCameraFX]);
|
|
1818
|
-
return { applyCameraFX, clearCameraFX };
|
|
40
|
+
const scene = useScene();
|
|
41
|
+
const activeFxRef = useRef(/* @__PURE__ */ new Set());
|
|
42
|
+
const baseZoomRef = useRef(null);
|
|
43
|
+
const getCamera = useCallback(() => {
|
|
44
|
+
return cameraRef?.current ?? scene.cameras.main;
|
|
45
|
+
}, [cameraRef, scene]);
|
|
46
|
+
const applyCameraFX = useCallback((fx, config) => {
|
|
47
|
+
const camera = getCamera();
|
|
48
|
+
if (!camera) {
|
|
49
|
+
console.warn("[useCameraFX] No camera available");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (baseZoomRef.current === null) baseZoomRef.current = camera.zoom;
|
|
53
|
+
const cleanup = fx(camera, config);
|
|
54
|
+
if (typeof cleanup === "function") activeFxRef.current.add(cleanup);
|
|
55
|
+
}, [getCamera]);
|
|
56
|
+
const clearCameraFX = useCallback(() => {
|
|
57
|
+
const camera = getCamera();
|
|
58
|
+
activeFxRef.current.forEach((cleanup) => cleanup());
|
|
59
|
+
activeFxRef.current.clear();
|
|
60
|
+
if (!camera) return;
|
|
61
|
+
const cameraWithStops = camera;
|
|
62
|
+
if (typeof cameraWithStops.stopShake === "function") cameraWithStops.stopShake();
|
|
63
|
+
if (typeof cameraWithStops.stopFlash === "function") cameraWithStops.stopFlash();
|
|
64
|
+
if (typeof cameraWithStops.stopFade === "function") cameraWithStops.stopFade();
|
|
65
|
+
if (options.resetZoomOnClear !== false && baseZoomRef.current !== null) camera.setZoom(baseZoomRef.current);
|
|
66
|
+
}, [getCamera, options.resetZoomOnClear]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
return () => clearCameraFX();
|
|
69
|
+
}, [clearCameraFX]);
|
|
70
|
+
return {
|
|
71
|
+
applyCameraFX,
|
|
72
|
+
clearCameraFX
|
|
73
|
+
};
|
|
1819
74
|
}
|
|
1820
75
|
function useScreenShake(config = {}, cameraRef) {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
76
|
+
const { applyCameraFX, clearCameraFX } = useCameraFX(cameraRef);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
applyCameraFX(createCameraShakeFX, config);
|
|
79
|
+
return () => clearCameraFX();
|
|
80
|
+
}, [
|
|
81
|
+
applyCameraFX,
|
|
82
|
+
clearCameraFX,
|
|
83
|
+
config
|
|
84
|
+
]);
|
|
85
|
+
return { clearCameraFX };
|
|
1827
86
|
}
|
|
1828
87
|
function useCameraFlash(config = {}, cameraRef) {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
88
|
+
const { applyCameraFX, clearCameraFX } = useCameraFX(cameraRef);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
applyCameraFX(createCameraFlashFX, config);
|
|
91
|
+
return () => clearCameraFX();
|
|
92
|
+
}, [
|
|
93
|
+
applyCameraFX,
|
|
94
|
+
clearCameraFX,
|
|
95
|
+
config
|
|
96
|
+
]);
|
|
97
|
+
return { clearCameraFX };
|
|
1835
98
|
}
|
|
1836
99
|
function useCameraFade(config = {}, cameraRef) {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
100
|
+
const { applyCameraFX, clearCameraFX } = useCameraFX(cameraRef);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
applyCameraFX(config.direction === "in" ? createCameraFadeInFX : createCameraFadeOutFX, config);
|
|
103
|
+
return () => clearCameraFX();
|
|
104
|
+
}, [
|
|
105
|
+
applyCameraFX,
|
|
106
|
+
clearCameraFX,
|
|
107
|
+
config
|
|
108
|
+
]);
|
|
109
|
+
return { clearCameraFX };
|
|
1844
110
|
}
|
|
1845
111
|
function useCameraZoom(config = {}, cameraRef) {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
112
|
+
const { applyCameraFX, clearCameraFX } = useCameraFX(cameraRef);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
applyCameraFX(createCameraZoomFX, config);
|
|
115
|
+
return () => clearCameraFX();
|
|
116
|
+
}, [
|
|
117
|
+
applyCameraFX,
|
|
118
|
+
clearCameraFX,
|
|
119
|
+
config
|
|
120
|
+
]);
|
|
121
|
+
return { clearCameraFX };
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/camera/camera-fx-registry.ts
|
|
125
|
+
/**
|
|
126
|
+
* Camera FX registry - string-based lookup with extension support
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Camera FX registry mapping names to FX creators
|
|
130
|
+
*/
|
|
131
|
+
var CAMERA_FX_REGISTRY = {
|
|
132
|
+
shake: createCameraShakeFX,
|
|
133
|
+
flash: createCameraFlashFX,
|
|
134
|
+
fadeIn: createCameraFadeInFX,
|
|
135
|
+
fadeOut: createCameraFadeOutFX,
|
|
136
|
+
zoom: createCameraZoomFX
|
|
1859
137
|
};
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Default camera FX definition
|
|
140
|
+
*/
|
|
141
|
+
var DEFAULT_CAMERA_FX = {
|
|
142
|
+
fx: "shake",
|
|
143
|
+
fxConfig: {
|
|
144
|
+
duration: 200,
|
|
145
|
+
force: false
|
|
146
|
+
}
|
|
1863
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Apply a camera FX by name
|
|
150
|
+
*/
|
|
1864
151
|
function applyCameraFXByName(applyCameraFX, fxName, fxConfig) {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
}
|
|
152
|
+
const name = fxName ?? DEFAULT_CAMERA_FX.fx;
|
|
153
|
+
const config = fxConfig ?? DEFAULT_CAMERA_FX.fxConfig;
|
|
154
|
+
const fx = CAMERA_FX_REGISTRY[name];
|
|
155
|
+
if (fx) {
|
|
156
|
+
applyCameraFX(fx, config);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Resolve camera FX definition with priority: props > default
|
|
163
|
+
*/
|
|
1874
164
|
function resolveCameraFX(props) {
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
}
|
|
165
|
+
return {
|
|
166
|
+
fx: props?.fx ?? DEFAULT_CAMERA_FX.fx,
|
|
167
|
+
fxConfig: props?.fxConfig ?? DEFAULT_CAMERA_FX.fxConfig
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/fx/use-fx.ts
|
|
172
|
+
/**
|
|
173
|
+
* Hook for applying Phaser PostFX/PreFX pipeline effects
|
|
174
|
+
* Manages FX lifecycle with proper cleanup
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Hook for applying FX to GameObject
|
|
178
|
+
* @param ref - Ref to GameObject
|
|
179
|
+
* @returns Object with applyFX and clearFX methods
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```tsx
|
|
183
|
+
* const ref = useRef(null)
|
|
184
|
+
* const { applyFX, clearFX } = useFX(ref)
|
|
185
|
+
*
|
|
186
|
+
* const handleClick = () => {
|
|
187
|
+
* applyFX(createShadowFX, { offsetX: 4, offsetY: 4, blur: 8 })
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* return <View ref={ref} onClick={handleClick}>Click me</View>
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
1880
193
|
function useFX(ref) {
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
194
|
+
const activeEffectsRef = useRef(/* @__PURE__ */ new Set());
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
const obj = ref.current;
|
|
197
|
+
if (obj && typeof obj.enableFilters === "function") obj.enableFilters();
|
|
198
|
+
}, []);
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
return () => {
|
|
201
|
+
activeEffectsRef.current.forEach((cleanup) => {
|
|
202
|
+
if (typeof cleanup === "function") cleanup();
|
|
203
|
+
else if (cleanup?.destroy) cleanup.destroy();
|
|
204
|
+
});
|
|
205
|
+
activeEffectsRef.current.clear();
|
|
206
|
+
};
|
|
207
|
+
}, []);
|
|
208
|
+
const applyFX = (fxCreator, config, type = "internal") => {
|
|
209
|
+
const obj = ref.current;
|
|
210
|
+
if (!obj) {
|
|
211
|
+
console.warn("[useFX] No object found in ref");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const cleanupOrController = fxCreator(obj, config, type);
|
|
215
|
+
if (cleanupOrController) activeEffectsRef.current.add(cleanupOrController);
|
|
216
|
+
};
|
|
217
|
+
const clearFX = () => {
|
|
218
|
+
activeEffectsRef.current.forEach((cleanup) => {
|
|
219
|
+
if (typeof cleanup === "function") cleanup();
|
|
220
|
+
else if (cleanup?.destroy) cleanup.destroy();
|
|
221
|
+
});
|
|
222
|
+
activeEffectsRef.current.clear();
|
|
223
|
+
const obj = ref.current;
|
|
224
|
+
if (obj?.filters) {
|
|
225
|
+
obj.filters.internal.clear();
|
|
226
|
+
obj.filters.external.clear();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
return {
|
|
230
|
+
applyFX,
|
|
231
|
+
clearFX
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/fx/fx-creators/blur.ts
|
|
236
|
+
/**
|
|
237
|
+
* Create blur FX
|
|
238
|
+
* @param obj - GameObject
|
|
239
|
+
* @param config - Blur configuration
|
|
240
|
+
* @param type - 'post' or 'pre' FX
|
|
241
|
+
* @returns Blur controller
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```tsx
|
|
245
|
+
* applyFX(createBlurFX, {
|
|
246
|
+
* quality: 1,
|
|
247
|
+
* x: 4,
|
|
248
|
+
* y: 4,
|
|
249
|
+
* strength: 2
|
|
250
|
+
* })
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
var createBlurFX = (obj, config, type = "internal") => {
|
|
254
|
+
const { quality = 0, x = 2, y = 2, strength = 1, color = 16777215, steps = 4 } = config;
|
|
255
|
+
obj.enableFilters();
|
|
256
|
+
const filters = obj.filters;
|
|
257
|
+
if (!filters) {
|
|
258
|
+
console.warn("[createBlurFX] Filters not available on this GameObject");
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
262
|
+
if (!pipeline) {
|
|
263
|
+
console.warn("[createBlurFX] FX pipeline not available on this GameObject");
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
return pipeline.addBlur(quality, x, y, strength, color, steps);
|
|
1933
267
|
};
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/fx/fx-creators/color-matrix.ts
|
|
270
|
+
/**
|
|
271
|
+
* Create color matrix FX
|
|
272
|
+
* @param obj - GameObject
|
|
273
|
+
* @param config - Color matrix configuration
|
|
274
|
+
* @param type - 'post' or 'pre' FX
|
|
275
|
+
* @returns Color matrix controller
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* applyFX(createColorMatrixFX, {
|
|
280
|
+
* effect: 'grayscale',
|
|
281
|
+
* amount: 1
|
|
282
|
+
* })
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
var createColorMatrixFX = (obj, config, type = "internal") => {
|
|
286
|
+
const { effect = "grayscale", amount = 1 } = config;
|
|
287
|
+
obj.enableFilters();
|
|
288
|
+
const filters = obj.filters;
|
|
289
|
+
if (!filters) {
|
|
290
|
+
console.warn("[createColorMatrixFX] Filters not available on this GameObject");
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
294
|
+
if (!pipeline) {
|
|
295
|
+
console.warn("[createColorMatrixFX] FX pipeline not available on this GameObject");
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const colorMatrixFilter = pipeline.addColorMatrix();
|
|
299
|
+
const cm = colorMatrixFilter.colorMatrix;
|
|
300
|
+
switch (effect) {
|
|
301
|
+
case "grayscale":
|
|
302
|
+
cm.grayscale(amount);
|
|
303
|
+
break;
|
|
304
|
+
case "sepia":
|
|
305
|
+
cm.sepia();
|
|
306
|
+
break;
|
|
307
|
+
case "negative":
|
|
308
|
+
cm.negative();
|
|
309
|
+
break;
|
|
310
|
+
case "blackWhite":
|
|
311
|
+
cm.blackWhite();
|
|
312
|
+
break;
|
|
313
|
+
case "brown":
|
|
314
|
+
cm.brown();
|
|
315
|
+
break;
|
|
316
|
+
case "kodachrome":
|
|
317
|
+
cm.kodachrome();
|
|
318
|
+
break;
|
|
319
|
+
case "technicolor":
|
|
320
|
+
cm.technicolor();
|
|
321
|
+
break;
|
|
322
|
+
case "polaroid":
|
|
323
|
+
cm.polaroid();
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
return colorMatrixFilter;
|
|
1969
327
|
};
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/fx/fx-creators/glow.ts
|
|
330
|
+
/**
|
|
331
|
+
* Create glow FX
|
|
332
|
+
* @param obj - GameObject
|
|
333
|
+
* @param config - Glow configuration
|
|
334
|
+
* @param type - 'post' or 'pre' FX
|
|
335
|
+
* @returns Glow controller
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```tsx
|
|
339
|
+
* applyFX(createGlowFX, {
|
|
340
|
+
* color: 0xff6600,
|
|
341
|
+
* outerStrength: 6,
|
|
342
|
+
* innerStrength: 2
|
|
343
|
+
* })
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
var createGlowFX = (obj, config, type = "internal") => {
|
|
347
|
+
const { color = 16777215, outerStrength = 4, innerStrength = 0, knockout = false, quality = .1, distance = 10 } = config;
|
|
348
|
+
obj.enableFilters();
|
|
349
|
+
const filters = obj.filters;
|
|
350
|
+
if (!filters) {
|
|
351
|
+
console.warn("[createGlowFX] Filters not available on this GameObject");
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
355
|
+
if (!pipeline) {
|
|
356
|
+
console.warn("[createGlowFX] FX pipeline not available on this GameObject");
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
return pipeline.addGlow(color, outerStrength, innerStrength, 1, knockout, quality, distance);
|
|
1986
360
|
};
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/fx/fx-creators/pixelate.ts
|
|
363
|
+
/**
|
|
364
|
+
* Create pixelate FX
|
|
365
|
+
* @param obj - GameObject
|
|
366
|
+
* @param config - Pixelate configuration
|
|
367
|
+
* @param type - 'post' or 'pre' FX
|
|
368
|
+
* @returns Pixelate controller
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```tsx
|
|
372
|
+
* applyFX(createPixelateFX, {
|
|
373
|
+
* amount: 8
|
|
374
|
+
* })
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
var createPixelateFX = (obj, config, type = "internal") => {
|
|
378
|
+
const { amount = 1 } = config;
|
|
379
|
+
obj.enableFilters();
|
|
380
|
+
const filters = obj.filters;
|
|
381
|
+
if (!filters) {
|
|
382
|
+
console.warn("[createPixelateFX] Filters not available on this GameObject");
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
386
|
+
if (!pipeline) {
|
|
387
|
+
console.warn("[createPixelateFX] FX pipeline not available on this GameObject");
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
return pipeline.addPixelate(amount);
|
|
1996
391
|
};
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/fx/fx-creators/shadow.ts
|
|
394
|
+
/**
|
|
395
|
+
* Create shadow FX
|
|
396
|
+
* @param obj - GameObject
|
|
397
|
+
* @param config - Shadow configuration
|
|
398
|
+
* @param type - 'post' or 'pre' FX
|
|
399
|
+
* @returns Shadow controller
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```tsx
|
|
403
|
+
* applyFX(createShadowFX, {
|
|
404
|
+
* x: 0,
|
|
405
|
+
* y: 0,
|
|
406
|
+
* decay: 0.1,
|
|
407
|
+
* power: 1,
|
|
408
|
+
* color: 0x000000,
|
|
409
|
+
* samples: 6,
|
|
410
|
+
* intensity: 1
|
|
411
|
+
* })
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
var createShadowFX = (obj, config, type = "internal") => {
|
|
415
|
+
const { x = 0, y = 1, decay = .05, power = 1, color = 0, samples = 6, intensity = 1 } = config;
|
|
416
|
+
obj.enableFilters();
|
|
417
|
+
const filters = obj.filters;
|
|
418
|
+
if (!filters) {
|
|
419
|
+
console.warn("[createShadowFX] Filters not available on this GameObject");
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
423
|
+
if (!pipeline) {
|
|
424
|
+
console.warn("[createShadowFX] FX pipeline not available on this GameObject");
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
return pipeline.addShadow(x, y, decay, power, color, samples, intensity);
|
|
2014
428
|
};
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/fx/fx-creators/vignette.ts
|
|
431
|
+
/**
|
|
432
|
+
* Create vignette FX
|
|
433
|
+
* @param obj - GameObject
|
|
434
|
+
* @param config - Vignette configuration
|
|
435
|
+
* @param type - 'post' or 'pre' FX
|
|
436
|
+
* @returns Vignette controller
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```tsx
|
|
440
|
+
* applyFX(createVignetteFX, {
|
|
441
|
+
* x: 0.5,
|
|
442
|
+
* y: 0.5,
|
|
443
|
+
* radius: 0.5,
|
|
444
|
+
* strength: 0.7
|
|
445
|
+
* })
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
var createVignetteFX = (obj, config, type = "internal") => {
|
|
449
|
+
const { strength = .5, radius = .5, x = .5, y = .5 } = config;
|
|
450
|
+
obj.enableFilters();
|
|
451
|
+
const filters = obj.filters;
|
|
452
|
+
if (!filters) {
|
|
453
|
+
console.warn("[createVignetteFX] Filters not available on this GameObject");
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
const pipeline = type === "internal" ? filters.internal : filters.external;
|
|
457
|
+
if (!pipeline) {
|
|
458
|
+
console.warn("[createVignetteFX] FX pipeline not available on this GameObject");
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
return pipeline.addVignette(x, y, radius, strength);
|
|
2024
462
|
};
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/fx/fx-registry.ts
|
|
465
|
+
/**
|
|
466
|
+
* FX Registry - string-based FX lookup
|
|
467
|
+
* Similar to effect-registry.ts for animation effects
|
|
468
|
+
*/
|
|
469
|
+
/**
|
|
470
|
+
* FX Registry mapping names to creator functions
|
|
471
|
+
*/
|
|
472
|
+
var FX_REGISTRY = {
|
|
473
|
+
shadow: createShadowFX,
|
|
474
|
+
glow: createGlowFX,
|
|
475
|
+
blur: createBlurFX,
|
|
476
|
+
pixelate: createPixelateFX,
|
|
477
|
+
vignette: createVignetteFX,
|
|
478
|
+
grayscale: (obj, config, type) => createColorMatrixFX(obj, {
|
|
479
|
+
...config,
|
|
480
|
+
effect: "grayscale"
|
|
481
|
+
}, type),
|
|
482
|
+
sepia: (obj, config, type) => createColorMatrixFX(obj, {
|
|
483
|
+
...config,
|
|
484
|
+
effect: "sepia"
|
|
485
|
+
}, type),
|
|
486
|
+
negative: (obj, config, type) => createColorMatrixFX(obj, {
|
|
487
|
+
...config,
|
|
488
|
+
effect: "negative"
|
|
489
|
+
}, type),
|
|
490
|
+
blackWhite: (obj, config, type) => createColorMatrixFX(obj, {
|
|
491
|
+
...config,
|
|
492
|
+
effect: "blackWhite"
|
|
493
|
+
}, type),
|
|
494
|
+
brown: (obj, config, type) => createColorMatrixFX(obj, {
|
|
495
|
+
...config,
|
|
496
|
+
effect: "brown"
|
|
497
|
+
}, type),
|
|
498
|
+
kodachrome: (obj, config, type) => createColorMatrixFX(obj, {
|
|
499
|
+
...config,
|
|
500
|
+
effect: "kodachrome"
|
|
501
|
+
}, type),
|
|
502
|
+
technicolor: (obj, config, type) => createColorMatrixFX(obj, {
|
|
503
|
+
...config,
|
|
504
|
+
effect: "technicolor"
|
|
505
|
+
}, type),
|
|
506
|
+
polaroid: (obj, config, type) => createColorMatrixFX(obj, {
|
|
507
|
+
...config,
|
|
508
|
+
effect: "polaroid"
|
|
509
|
+
}, type)
|
|
2039
510
|
};
|
|
2040
|
-
|
|
511
|
+
/**
|
|
512
|
+
* Default FX (none)
|
|
513
|
+
*/
|
|
514
|
+
var DEFAULT_FX = "grayscale";
|
|
515
|
+
/**
|
|
516
|
+
* Resolve FX by name or function
|
|
517
|
+
* @param fxOrName - FX name string or creator function
|
|
518
|
+
* @returns FX creator function or null
|
|
519
|
+
*/
|
|
2041
520
|
function resolveFX(fxOrName) {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
521
|
+
if (typeof fxOrName === "function") return fxOrName;
|
|
522
|
+
return FX_REGISTRY[fxOrName] ?? null;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Apply FX by name (helper function)
|
|
526
|
+
* @param applyFXFn - applyFX function from useFX hook
|
|
527
|
+
* @param fxName - FX name
|
|
528
|
+
* @param config - FX config
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```tsx
|
|
532
|
+
* const { applyFX } = useFX(ref)
|
|
533
|
+
* applyFXByName(applyFX, 'shadow', { offsetX: 4, offsetY: 4, blur: 8 })
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
2047
536
|
function applyFXByName(applyFXFn, fxName, config = {}) {
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
537
|
+
const creator = resolveFX(fxName);
|
|
538
|
+
if (creator) applyFXFn(creator, config);
|
|
539
|
+
else console.warn(`[applyFXByName] FX "${fxName}" not found in registry`);
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/fx/convenience-hooks/use-blur.ts
|
|
543
|
+
/**
|
|
544
|
+
* Convenience hook for automatic blur FX
|
|
545
|
+
* Applies blur on mount and updates on config changes
|
|
546
|
+
*/
|
|
547
|
+
/**
|
|
548
|
+
* Hook for automatic blur FX
|
|
549
|
+
* @param ref - GameObject ref
|
|
550
|
+
* @param config - Blur config (updates reactively)
|
|
551
|
+
* @returns FX controls
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```tsx
|
|
555
|
+
* const ref = useRef(null)
|
|
556
|
+
* useBlur(ref, { strength: 8, steps: 4 })
|
|
557
|
+
*
|
|
558
|
+
* return <View ref={ref}>Content</View>
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
2055
561
|
function useBlur(ref, config = {}) {
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
562
|
+
const { applyFX, clearFX } = useFX(ref);
|
|
563
|
+
useEffect(() => {
|
|
564
|
+
if (!ref.current) return;
|
|
565
|
+
clearFX();
|
|
566
|
+
applyFX(createBlurFX, config);
|
|
567
|
+
return () => clearFX();
|
|
568
|
+
}, [
|
|
569
|
+
ref,
|
|
570
|
+
config,
|
|
571
|
+
applyFX,
|
|
572
|
+
clearFX
|
|
573
|
+
]);
|
|
574
|
+
return { clearFX };
|
|
575
|
+
}
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/fx/convenience-hooks/use-glow.ts
|
|
578
|
+
/**
|
|
579
|
+
* Convenience hook for automatic glow FX
|
|
580
|
+
* Applies glow on mount and updates on config changes
|
|
581
|
+
*/
|
|
582
|
+
/**
|
|
583
|
+
* Hook for automatic glow FX
|
|
584
|
+
* @param ref - GameObject ref
|
|
585
|
+
* @param config - Glow config (updates reactively)
|
|
586
|
+
* @returns FX controls
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```tsx
|
|
590
|
+
* const ref = useRef(null)
|
|
591
|
+
* useGlow(ref, { color: 0xff6600, outerStrength: 6, innerStrength: 2 })
|
|
592
|
+
*
|
|
593
|
+
* return <View ref={ref}>Content</View>
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
2065
596
|
function useGlow(ref, config = {}) {
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
597
|
+
const { applyFX, clearFX } = useFX(ref);
|
|
598
|
+
useEffect(() => {
|
|
599
|
+
if (!ref.current) return;
|
|
600
|
+
clearFX();
|
|
601
|
+
applyFX(createGlowFX, config);
|
|
602
|
+
return () => clearFX();
|
|
603
|
+
}, [
|
|
604
|
+
ref,
|
|
605
|
+
config,
|
|
606
|
+
applyFX,
|
|
607
|
+
clearFX
|
|
608
|
+
]);
|
|
609
|
+
return { clearFX };
|
|
610
|
+
}
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region src/fx/convenience-hooks/use-shadow.ts
|
|
613
|
+
/**
|
|
614
|
+
* Convenience hook for automatic shadow FX
|
|
615
|
+
* Applies shadow on mount and updates on config changes
|
|
616
|
+
*/
|
|
617
|
+
/**
|
|
618
|
+
* Hook for automatic shadow FX
|
|
619
|
+
* @param ref - GameObject ref
|
|
620
|
+
* @param config - Shadow config (updates reactively)
|
|
621
|
+
* @returns FX controls
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```tsx
|
|
625
|
+
* const ref = useRef(null)
|
|
626
|
+
* useShadow(ref, { x: 4, y: 4, decay: 0.1 })
|
|
627
|
+
*
|
|
628
|
+
* return <View ref={ref}>Content</View>
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
2075
631
|
function useShadow(ref, config = {}) {
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
632
|
+
const { applyFX, clearFX } = useFX(ref);
|
|
633
|
+
useEffect(() => {
|
|
634
|
+
if (!ref.current) return;
|
|
635
|
+
clearFX();
|
|
636
|
+
applyFX(createShadowFX, config);
|
|
637
|
+
return () => clearFX();
|
|
638
|
+
}, [
|
|
639
|
+
ref,
|
|
640
|
+
config,
|
|
641
|
+
applyFX,
|
|
642
|
+
clearFX
|
|
643
|
+
]);
|
|
644
|
+
return { clearFX };
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/memo.ts
|
|
648
|
+
/**
|
|
649
|
+
* Safely sets __memo on a VNode, handling frozen/sealed objects from bundlers
|
|
650
|
+
* @param vnode - VNode to set __memo on
|
|
651
|
+
* @param value - Memoization value
|
|
652
|
+
* @returns Original VNode if extensible, or shallow copy with __memo
|
|
653
|
+
*/
|
|
2085
654
|
function setMemoSafe(vnode, value) {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
655
|
+
if (Object.isExtensible(vnode)) {
|
|
656
|
+
vnode.__memo = value;
|
|
657
|
+
return vnode;
|
|
658
|
+
}
|
|
659
|
+
return {
|
|
660
|
+
...vnode,
|
|
661
|
+
__memo: value
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Marks a component to skip memoization (always re-render on prop changes)
|
|
666
|
+
* Use when component has side effects or needs to re-render every time
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```tsx
|
|
670
|
+
* function AlwaysUpdate({ value }) {
|
|
671
|
+
* console.log('Rendering with:', value)
|
|
672
|
+
* return <Text text={value} />
|
|
673
|
+
* }
|
|
674
|
+
*
|
|
675
|
+
* // Disable memoization
|
|
676
|
+
* <AlwaysUpdate value={counter} __memo={false} />
|
|
677
|
+
* ```
|
|
678
|
+
*
|
|
679
|
+
* @param vnode - VNode to mark
|
|
680
|
+
* @returns Same VNode with memoization disabled (may be a copy if frozen)
|
|
681
|
+
*/
|
|
2092
682
|
function noMemo(vnode) {
|
|
2093
|
-
|
|
2094
|
-
}
|
|
683
|
+
return setMemoSafe(vnode, false);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Explicitly enable memoization for a component (default behavior)
|
|
687
|
+
* This is the default - you don't need to call this unless you want to be explicit
|
|
688
|
+
*
|
|
689
|
+
* @param vnode - VNode to mark
|
|
690
|
+
* @returns Same VNode with memoization enabled (may be a copy if frozen)
|
|
691
|
+
*/
|
|
2095
692
|
function memo(vnode) {
|
|
2096
|
-
|
|
693
|
+
return setMemoSafe(vnode, true);
|
|
2097
694
|
}
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/particles/use-particles.ts
|
|
697
|
+
/**
|
|
698
|
+
* Hook for imperative particle control
|
|
699
|
+
*/
|
|
2098
700
|
function useParticles(ref) {
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
(zones, width, height) => {
|
|
2138
|
-
const emitter = getEmitter();
|
|
2139
|
-
const deathZones = buildDeathZonesFromLayout(zones, width, height);
|
|
2140
|
-
applyDeathZone(emitter, deathZones);
|
|
2141
|
-
},
|
|
2142
|
-
[getEmitter]
|
|
2143
|
-
);
|
|
2144
|
-
return {
|
|
2145
|
-
getManager,
|
|
2146
|
-
getEmitter,
|
|
2147
|
-
start,
|
|
2148
|
-
stop,
|
|
2149
|
-
explode,
|
|
2150
|
-
setConfig,
|
|
2151
|
-
setEmitZone,
|
|
2152
|
-
setExcludeZones
|
|
2153
|
-
};
|
|
2154
|
-
}
|
|
2155
|
-
const DEFAULT_LOGO_KEY = "phaser-jsx-logo";
|
|
2156
|
-
const DEFAULT_BACKGROUND = {
|
|
2157
|
-
type: "grid",
|
|
2158
|
-
animation: "lemniscate",
|
|
2159
|
-
opacity: 0.15,
|
|
2160
|
-
color: 4890367
|
|
701
|
+
const getManager = useCallback(() => ref.current ?? null, [ref]);
|
|
702
|
+
const getEmitter = useCallback(() => {
|
|
703
|
+
const current = ref.current;
|
|
704
|
+
if (!current) return null;
|
|
705
|
+
if (isParticleEmitter(current)) return current;
|
|
706
|
+
return getFirstEmitter(current);
|
|
707
|
+
}, [ref]);
|
|
708
|
+
return {
|
|
709
|
+
getManager,
|
|
710
|
+
getEmitter,
|
|
711
|
+
start: useCallback(() => {
|
|
712
|
+
getEmitter()?.start();
|
|
713
|
+
}, [getEmitter]),
|
|
714
|
+
stop: useCallback(() => {
|
|
715
|
+
getEmitter()?.stop();
|
|
716
|
+
}, [getEmitter]),
|
|
717
|
+
explode: useCallback((count, x, y) => {
|
|
718
|
+
getEmitter()?.explode(count, x, y);
|
|
719
|
+
}, [getEmitter]),
|
|
720
|
+
setConfig: useCallback((config) => {
|
|
721
|
+
applyEmitterConfig(getEmitter(), config);
|
|
722
|
+
}, [getEmitter]),
|
|
723
|
+
setEmitZone: useCallback((zone, width, height) => {
|
|
724
|
+
applyEmitZone(getEmitter(), buildEmitZoneFromLayout(zone, width, height));
|
|
725
|
+
}, [getEmitter]),
|
|
726
|
+
setExcludeZones: useCallback((zones, width, height) => {
|
|
727
|
+
applyDeathZone(getEmitter(), buildDeathZonesFromLayout(zones, width, height));
|
|
728
|
+
}, [getEmitter])
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/scene-backgrounds.ts
|
|
733
|
+
var DEFAULT_LOGO_KEY = "phaser-jsx-logo";
|
|
734
|
+
var DEFAULT_BACKGROUND = {
|
|
735
|
+
type: "grid",
|
|
736
|
+
animation: "lemniscate",
|
|
737
|
+
opacity: .15,
|
|
738
|
+
color: 4890367
|
|
2161
739
|
};
|
|
2162
740
|
function addSceneBackground(scene, config = DEFAULT_BACKGROUND) {
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
scene.events.off(Phaser.Scenes.Events.DESTROY, cleanup);
|
|
2285
|
-
};
|
|
2286
|
-
scene.scale.on(Phaser.Scale.Events.RESIZE, onResize);
|
|
2287
|
-
scene.events.once(Phaser.Scenes.Events.SHUTDOWN, cleanup);
|
|
2288
|
-
scene.events.once(Phaser.Scenes.Events.DESTROY, cleanup);
|
|
2289
|
-
return {
|
|
2290
|
-
background,
|
|
2291
|
-
destroy: cleanup,
|
|
2292
|
-
resize: (width, height) => {
|
|
2293
|
-
if (resizeFn) resizeFn(width, height);
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
741
|
+
const bgConfig = config ?? DEFAULT_BACKGROUND;
|
|
742
|
+
if (bgConfig.type === "none") return null;
|
|
743
|
+
let background;
|
|
744
|
+
let backgroundTween;
|
|
745
|
+
const particleTweens = [];
|
|
746
|
+
let resizeFn;
|
|
747
|
+
let destroyed = false;
|
|
748
|
+
const createGridBackground = () => {
|
|
749
|
+
const graphics = scene.add.graphics();
|
|
750
|
+
const gridSize = 40;
|
|
751
|
+
const color = bgConfig.color ?? 4890367;
|
|
752
|
+
const opacity = bgConfig.opacity ?? .15;
|
|
753
|
+
const drawGrid = (offsetX, offsetY) => {
|
|
754
|
+
graphics.clear();
|
|
755
|
+
graphics.lineStyle(1, color, opacity);
|
|
756
|
+
const width = scene.scale.width;
|
|
757
|
+
const height = scene.scale.height;
|
|
758
|
+
for (let x = offsetX % gridSize; x < width; x += gridSize) graphics.lineBetween(x, 0, x, height);
|
|
759
|
+
for (let y = offsetY % gridSize; y < height; y += gridSize) graphics.lineBetween(0, y, width, y);
|
|
760
|
+
};
|
|
761
|
+
drawGrid(0, 0);
|
|
762
|
+
graphics.__redrawFn = drawGrid;
|
|
763
|
+
background = graphics;
|
|
764
|
+
resizeFn = () => drawGrid(0, 0);
|
|
765
|
+
};
|
|
766
|
+
const createLogoBackground = () => {
|
|
767
|
+
const container = scene.add.container(scene.scale.width / 2, scene.scale.height / 2);
|
|
768
|
+
const opacity = bgConfig.opacity ?? .1;
|
|
769
|
+
const logoKey = bgConfig.logoKey ?? DEFAULT_LOGO_KEY;
|
|
770
|
+
const logo = scene.add.image(0, 0, logoKey);
|
|
771
|
+
logo.setAlpha(opacity);
|
|
772
|
+
logo.setScale(.5);
|
|
773
|
+
container.add(logo);
|
|
774
|
+
background = container;
|
|
775
|
+
resizeFn = (width, height) => {
|
|
776
|
+
container.setPosition(width / 2, height / 2);
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
const createGradientBackground = () => {
|
|
780
|
+
const graphics = scene.add.graphics();
|
|
781
|
+
const color1 = bgConfig.color ?? 4890367;
|
|
782
|
+
const color2 = bgConfig.colorSecondary ?? 7031551;
|
|
783
|
+
const opacity = bgConfig.opacity ?? .2;
|
|
784
|
+
const drawGradient = () => {
|
|
785
|
+
graphics.clear();
|
|
786
|
+
graphics.fillGradientStyle(color1, color1, color2, color2, opacity, opacity, opacity, opacity);
|
|
787
|
+
graphics.fillRect(0, 0, scene.scale.width, scene.scale.height);
|
|
788
|
+
};
|
|
789
|
+
drawGradient();
|
|
790
|
+
background = graphics;
|
|
791
|
+
resizeFn = drawGradient;
|
|
792
|
+
};
|
|
793
|
+
const createParticlesBackground = () => {
|
|
794
|
+
const container = scene.add.container(0, 0);
|
|
795
|
+
const particleCount = 20;
|
|
796
|
+
const color = bgConfig.color ?? 4890367;
|
|
797
|
+
const opacity = bgConfig.opacity ?? .1;
|
|
798
|
+
const particles = [];
|
|
799
|
+
for (let i = 0; i < particleCount; i += 1) {
|
|
800
|
+
const size = Phaser.Math.Between(2, 6);
|
|
801
|
+
const x = Phaser.Math.Between(0, scene.scale.width);
|
|
802
|
+
const y = Phaser.Math.Between(0, scene.scale.height);
|
|
803
|
+
const particle = scene.add.circle(x, y, size, color, opacity);
|
|
804
|
+
container.add(particle);
|
|
805
|
+
particles.push(particle);
|
|
806
|
+
particleTweens.push(scene.tweens.add({
|
|
807
|
+
targets: particle,
|
|
808
|
+
y: particle.y + Phaser.Math.Between(-50, 50),
|
|
809
|
+
x: particle.x + Phaser.Math.Between(-50, 50),
|
|
810
|
+
alpha: opacity * 1.5,
|
|
811
|
+
duration: Phaser.Math.Between(2e3, 4e3),
|
|
812
|
+
yoyo: true,
|
|
813
|
+
repeat: -1,
|
|
814
|
+
ease: "Sine.easeInOut"
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
background = container;
|
|
818
|
+
resizeFn = (width, height) => {
|
|
819
|
+
for (const particle of particles) particle.setPosition(Phaser.Math.Between(0, width), Phaser.Math.Between(0, height));
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
switch (bgConfig.type) {
|
|
823
|
+
case "grid":
|
|
824
|
+
createGridBackground();
|
|
825
|
+
break;
|
|
826
|
+
case "logo":
|
|
827
|
+
createLogoBackground();
|
|
828
|
+
break;
|
|
829
|
+
case "gradient":
|
|
830
|
+
createGradientBackground();
|
|
831
|
+
break;
|
|
832
|
+
case "particles":
|
|
833
|
+
createParticlesBackground();
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
if (!background) return null;
|
|
837
|
+
if (bgConfig.animation && bgConfig.animation !== "static") backgroundTween = applyAnimation(scene, background, bgConfig.animation);
|
|
838
|
+
const onResize = () => {
|
|
839
|
+
if (resizeFn) resizeFn(scene.scale.width, scene.scale.height);
|
|
840
|
+
};
|
|
841
|
+
const cleanup = () => {
|
|
842
|
+
if (destroyed) return;
|
|
843
|
+
destroyed = true;
|
|
844
|
+
backgroundTween?.stop();
|
|
845
|
+
for (const tween of particleTweens) tween.stop();
|
|
846
|
+
background?.destroy();
|
|
847
|
+
background = void 0;
|
|
848
|
+
scene.scale.off(Phaser.Scale.Events.RESIZE, onResize);
|
|
849
|
+
scene.events.off(Phaser.Scenes.Events.SHUTDOWN, cleanup);
|
|
850
|
+
scene.events.off(Phaser.Scenes.Events.DESTROY, cleanup);
|
|
851
|
+
};
|
|
852
|
+
scene.scale.on(Phaser.Scale.Events.RESIZE, onResize);
|
|
853
|
+
scene.events.once(Phaser.Scenes.Events.SHUTDOWN, cleanup);
|
|
854
|
+
scene.events.once(Phaser.Scenes.Events.DESTROY, cleanup);
|
|
855
|
+
return {
|
|
856
|
+
background,
|
|
857
|
+
destroy: cleanup,
|
|
858
|
+
resize: (width, height) => {
|
|
859
|
+
if (resizeFn) resizeFn(width, height);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
2296
862
|
}
|
|
2297
863
|
function applyAnimation(scene, target, animation) {
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
case "rotate":
|
|
2307
|
-
return animateRotate(scene, target);
|
|
2308
|
-
case "static":
|
|
2309
|
-
default:
|
|
2310
|
-
return void 0;
|
|
2311
|
-
}
|
|
864
|
+
const redrawFn = target.__redrawFn;
|
|
865
|
+
switch (animation) {
|
|
866
|
+
case "lemniscate": return redrawFn ? animateLemniscate(scene, redrawFn) : animatePulse(scene, target);
|
|
867
|
+
case "wave": return redrawFn ? animateWave(scene, redrawFn) : animatePulse(scene, target);
|
|
868
|
+
case "pulse": return animatePulse(scene, target);
|
|
869
|
+
case "rotate": return animateRotate(scene, target);
|
|
870
|
+
default: return;
|
|
871
|
+
}
|
|
2312
872
|
}
|
|
2313
873
|
function animateLemniscate(scene, drawFn) {
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
const offsetY = amplitude * Math.sin(2 * t) / 2;
|
|
2326
|
-
drawFn(offsetX, offsetY);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
874
|
+
const amplitude = 30;
|
|
875
|
+
return scene.tweens.addCounter({
|
|
876
|
+
from: 0,
|
|
877
|
+
to: Math.PI * 2,
|
|
878
|
+
duration: 8e3,
|
|
879
|
+
repeat: -1,
|
|
880
|
+
onUpdate: (tween) => {
|
|
881
|
+
const t = tween.getValue();
|
|
882
|
+
if (t !== null) drawFn(amplitude * Math.cos(t), amplitude * Math.sin(2 * t) / 2);
|
|
883
|
+
}
|
|
884
|
+
});
|
|
2330
885
|
}
|
|
2331
886
|
function animateWave(scene, drawFn) {
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
}
|
|
2344
|
-
});
|
|
887
|
+
return scene.tweens.addCounter({
|
|
888
|
+
from: 0,
|
|
889
|
+
to: 40,
|
|
890
|
+
duration: 3e3,
|
|
891
|
+
yoyo: true,
|
|
892
|
+
repeat: -1,
|
|
893
|
+
onUpdate: (tween) => {
|
|
894
|
+
const offset = tween.getValue();
|
|
895
|
+
if (offset !== null) drawFn(offset, 0);
|
|
896
|
+
}
|
|
897
|
+
});
|
|
2345
898
|
}
|
|
2346
899
|
function animatePulse(scene, target) {
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
900
|
+
return scene.tweens.add({
|
|
901
|
+
targets: target,
|
|
902
|
+
scaleX: 1.1,
|
|
903
|
+
scaleY: 1.1,
|
|
904
|
+
duration: 2e3,
|
|
905
|
+
yoyo: true,
|
|
906
|
+
repeat: -1,
|
|
907
|
+
ease: "Sine.easeInOut"
|
|
908
|
+
});
|
|
2356
909
|
}
|
|
2357
910
|
function animateRotate(scene, target) {
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
}
|
|
911
|
+
return scene.tweens.add({
|
|
912
|
+
targets: target,
|
|
913
|
+
angle: 360,
|
|
914
|
+
duration: 2e4,
|
|
915
|
+
repeat: -1,
|
|
916
|
+
ease: "Linear"
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/plugin.ts
|
|
921
|
+
/**
|
|
922
|
+
* PhaserJSX Plugin for automatic JSX mounting
|
|
923
|
+
* Enables declarative initialization via Phaser game config
|
|
924
|
+
*/
|
|
925
|
+
/**
|
|
926
|
+
* Implementation
|
|
927
|
+
*/
|
|
2366
928
|
function createPhaserJSXPlugin(config) {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
929
|
+
return {
|
|
930
|
+
key: "PhaserJSX",
|
|
931
|
+
plugin: PhaserJSXPlugin,
|
|
932
|
+
start: true,
|
|
933
|
+
data: config
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* PhaserJSX Plugin
|
|
938
|
+
* Provides automatic JSX mounting through Phaser plugin system
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```typescript
|
|
942
|
+
* // In game config
|
|
943
|
+
* plugins: {
|
|
944
|
+
* global: [{
|
|
945
|
+
* key: 'PhaserJSX',
|
|
946
|
+
* plugin: PhaserJSXPlugin,
|
|
947
|
+
* start: true,
|
|
948
|
+
* data: {
|
|
949
|
+
* component: App,
|
|
950
|
+
* props: { width: '100%', height: '100%' }
|
|
951
|
+
* }
|
|
952
|
+
* }]
|
|
953
|
+
* }
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
var PhaserJSXPlugin = class extends Phaser.Plugins.BasePlugin {
|
|
957
|
+
config;
|
|
958
|
+
mountHandle;
|
|
959
|
+
container;
|
|
960
|
+
targetScene;
|
|
961
|
+
/**
|
|
962
|
+
* Constructor - receives plugin manager and optional mapping
|
|
963
|
+
*/
|
|
964
|
+
constructor(pluginManager) {
|
|
965
|
+
super(pluginManager);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Init lifecycle - called first with config data
|
|
969
|
+
*/
|
|
970
|
+
init(data) {
|
|
971
|
+
if (data) this.config = { ...data };
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Start lifecycle - called when plugin should start
|
|
975
|
+
*/
|
|
976
|
+
start() {
|
|
977
|
+
this.game.events.on("ready", this.onGameReady, this);
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Game ready handler - scene system is now initialized
|
|
981
|
+
*/
|
|
982
|
+
onGameReady() {
|
|
983
|
+
const scenes = this.game.scene.scenes;
|
|
984
|
+
if (scenes.length > 0) {
|
|
985
|
+
const targetScene = scenes[0];
|
|
986
|
+
if (!targetScene) return;
|
|
987
|
+
this.targetScene = targetScene;
|
|
988
|
+
targetScene.events.once("create", this.onSceneCreate, this);
|
|
989
|
+
if (targetScene.scene.isActive()) this.onSceneCreate();
|
|
990
|
+
} else console.warn("[PhaserJSX Plugin] No scenes found to mount JSX");
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Scene create handler - auto-mount JSX
|
|
994
|
+
*/
|
|
995
|
+
onSceneCreate() {
|
|
996
|
+
if (this.config?.autoMount !== false && this.config?.component) {
|
|
997
|
+
this.mount();
|
|
998
|
+
if (this.config?.autoResize !== false) this.setupResizeHandler();
|
|
999
|
+
} else console.warn("[PhaserJSX Plugin] Auto-mount disabled or no component configured");
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Setup resize event handler
|
|
1003
|
+
*/
|
|
1004
|
+
setupResizeHandler() {
|
|
1005
|
+
if (!this.targetScene) return;
|
|
1006
|
+
this.targetScene.scale.on("resize", this.onResize, this);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Handle scene resize - update component props
|
|
1010
|
+
*/
|
|
1011
|
+
onResize(gameSize) {
|
|
1012
|
+
if (!this.mountHandle || !this.config?.component || !this.container) return;
|
|
1013
|
+
const props = this.config.props || {};
|
|
1014
|
+
const width = props.width ?? gameSize.width;
|
|
1015
|
+
const height = props.height ?? gameSize.height;
|
|
1016
|
+
this.mountHandle = mountJSX(this.container, this.config.component, {
|
|
1017
|
+
...props,
|
|
1018
|
+
width,
|
|
1019
|
+
height
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Configure plugin
|
|
1024
|
+
* Can be called from scene to set up component dynamically
|
|
1025
|
+
*/
|
|
1026
|
+
configure(component, props) {
|
|
1027
|
+
const newConfig = { component };
|
|
1028
|
+
if (props !== void 0) newConfig.props = props;
|
|
1029
|
+
this.config = {
|
|
1030
|
+
...this.config,
|
|
1031
|
+
...newConfig
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Mount JSX component
|
|
1036
|
+
*/
|
|
1037
|
+
mount() {
|
|
1038
|
+
if (!this.targetScene) {
|
|
1039
|
+
console.warn("[PhaserJSX Plugin] No scene available for mounting");
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (!this.config?.component) {
|
|
1043
|
+
console.warn("[PhaserJSX Plugin] No component configured for mounting");
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (!this.container) {
|
|
1047
|
+
const containerConfig = this.config.container || {};
|
|
1048
|
+
this.container = this.targetScene.add.container(containerConfig.x ?? 0, containerConfig.y ?? 0);
|
|
1049
|
+
this.container.setDepth(containerConfig.depth ?? 100);
|
|
1050
|
+
}
|
|
1051
|
+
const props = this.config.props || {};
|
|
1052
|
+
const width = props.width ?? this.targetScene.scale.width;
|
|
1053
|
+
const height = props.height ?? this.targetScene.scale.height;
|
|
1054
|
+
this.mountHandle = mountJSX(this.container, this.config.component, {
|
|
1055
|
+
...props,
|
|
1056
|
+
width,
|
|
1057
|
+
height
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Unmount JSX component
|
|
1062
|
+
*/
|
|
1063
|
+
unmount() {
|
|
1064
|
+
if (this.mountHandle) {
|
|
1065
|
+
this.mountHandle.unmount();
|
|
1066
|
+
this.mountHandle = void 0;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Destroy lifecycle - cleanup
|
|
1071
|
+
*/
|
|
1072
|
+
destroy() {
|
|
1073
|
+
this.unmount();
|
|
1074
|
+
if (this.container) {
|
|
1075
|
+
this.container.destroy();
|
|
1076
|
+
this.container = void 0;
|
|
1077
|
+
}
|
|
1078
|
+
this.game.events.off("ready", this.onGameReady, this);
|
|
1079
|
+
if (this.targetScene) {
|
|
1080
|
+
this.targetScene.events.off("create", this.onSceneCreate, this);
|
|
1081
|
+
this.targetScene.scale.off("resize", this.onResize, this);
|
|
1082
|
+
}
|
|
1083
|
+
this.targetScene = void 0;
|
|
1084
|
+
this.config = void 0;
|
|
1085
|
+
super.destroy();
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region src/colors/use-color-mode.ts
|
|
1090
|
+
/**
|
|
1091
|
+
* Color mode management for dynamic theme switching
|
|
1092
|
+
*/
|
|
1093
|
+
/**
|
|
1094
|
+
* Hook to manage color mode (light/dark) dynamically
|
|
1095
|
+
* @returns Object with current mode, toggle function, and setter
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* function ThemeToggle() {
|
|
1099
|
+
* const { colorMode, toggleColorMode } = useColorMode()
|
|
1100
|
+
*
|
|
1101
|
+
* return (
|
|
1102
|
+
* <Button onClick={toggleColorMode}>
|
|
1103
|
+
* {colorMode === 'light' ? 'Dark' : 'Light'} Mode
|
|
1104
|
+
* </Button>
|
|
1105
|
+
* )
|
|
1106
|
+
* }
|
|
1107
|
+
* ```
|
|
1108
|
+
*/
|
|
2524
1109
|
function useColorMode() {
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
1110
|
+
const [colorMode, setColorModeState] = useState(themeRegistry.getColorMode());
|
|
1111
|
+
useEffect(() => {
|
|
1112
|
+
return themeRegistry.subscribe(() => {
|
|
1113
|
+
setColorModeState(themeRegistry.getColorMode());
|
|
1114
|
+
});
|
|
1115
|
+
}, []);
|
|
1116
|
+
const setColorMode = (mode) => {
|
|
1117
|
+
themeRegistry.setColorMode(mode);
|
|
1118
|
+
};
|
|
1119
|
+
const toggleColorMode = () => {
|
|
1120
|
+
setColorMode(colorMode === "light" ? "dark" : "light");
|
|
1121
|
+
};
|
|
1122
|
+
return {
|
|
1123
|
+
colorMode,
|
|
1124
|
+
setColorMode,
|
|
1125
|
+
toggleColorMode
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/colors/use-colors.ts
|
|
1130
|
+
/**
|
|
1131
|
+
* Color system hooks for component usage
|
|
1132
|
+
*/
|
|
1133
|
+
/**
|
|
1134
|
+
* Hook to access color tokens from theme context
|
|
1135
|
+
* Automatically updates when color mode or preset changes
|
|
1136
|
+
* @returns Current ColorTokens or undefined
|
|
1137
|
+
* @deprecated Use `useThemeTokens()` instead for access to colors, text styles, spacing, and more
|
|
1138
|
+
* @example
|
|
1139
|
+
* ```typescript
|
|
1140
|
+
* // Old way (deprecated):
|
|
1141
|
+
* const colors = useColors()
|
|
1142
|
+
*
|
|
1143
|
+
* // New way:
|
|
1144
|
+
* const tokens = useThemeTokens()
|
|
1145
|
+
* const colors = tokens?.colors
|
|
1146
|
+
*
|
|
1147
|
+
* // Access text styles, spacing, etc.:
|
|
1148
|
+
* <Text style={tokens.textStyles.DEFAULT} />
|
|
1149
|
+
* <View padding={tokens.spacing.lg} />
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
2545
1152
|
function useColors() {
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
1153
|
+
const localTheme = useTheme();
|
|
1154
|
+
const getInitialColors = () => {
|
|
1155
|
+
if (localTheme?.__colorPreset) return getPresetWithMode(localTheme.__colorPreset.name, localTheme.__colorPreset.mode ?? "light").colors;
|
|
1156
|
+
return themeRegistry.getColorTokens();
|
|
1157
|
+
};
|
|
1158
|
+
const [colors, setColors] = useState(getInitialColors());
|
|
1159
|
+
const [, forceUpdate] = useState(0);
|
|
1160
|
+
useEffect(() => {
|
|
1161
|
+
return themeRegistry.subscribe(() => {
|
|
1162
|
+
if (localTheme?.__colorPreset) {
|
|
1163
|
+
const currentMode = themeRegistry.getColorMode();
|
|
1164
|
+
setColors(getPresetWithMode(localTheme.__colorPreset.name, currentMode).colors);
|
|
1165
|
+
} else setColors(themeRegistry.getColorTokens());
|
|
1166
|
+
forceUpdate((n) => n + 1);
|
|
1167
|
+
});
|
|
1168
|
+
}, [localTheme]);
|
|
1169
|
+
return colors;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Hook to subscribe to theme changes without accessing colors
|
|
1173
|
+
* Use this in parent components that don't need colors themselves
|
|
1174
|
+
* but want to ensure children re-render when theme changes
|
|
1175
|
+
*
|
|
1176
|
+
* Note: Since useColors() now triggers re-renders automatically,
|
|
1177
|
+
* this hook is mainly useful if you don't need the colors themselves
|
|
1178
|
+
* but still want to react to theme changes.
|
|
1179
|
+
*
|
|
1180
|
+
* @example
|
|
1181
|
+
* ```typescript
|
|
1182
|
+
* function ParentComponent() {
|
|
1183
|
+
* useThemeSubscription() // Children will re-render on theme changes
|
|
1184
|
+
* return <ChildThatUsesColors />
|
|
1185
|
+
* }
|
|
1186
|
+
* ```
|
|
1187
|
+
*/
|
|
2577
1188
|
function useThemeSubscription() {
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
1189
|
+
const [, forceUpdate] = useState(0);
|
|
1190
|
+
useEffect(() => {
|
|
1191
|
+
return themeRegistry.subscribe(() => {
|
|
1192
|
+
forceUpdate((n) => n + 1);
|
|
1193
|
+
});
|
|
1194
|
+
}, []);
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/colors/color-theme-helpers.ts
|
|
1198
|
+
/**
|
|
1199
|
+
* Convert ColorTokens to a theme-compatible object
|
|
1200
|
+
* Maps semantic color names to Phaser number format for View/Button components
|
|
1201
|
+
* @param colors - ColorTokens to convert
|
|
1202
|
+
* @returns Object with backgroundColor, borderColor, etc.
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```typescript
|
|
1205
|
+
* const colors = getPreset('oceanBlue').colors
|
|
1206
|
+
* const buttonTheme = {
|
|
1207
|
+
* ...colorsToTheme(colors, 'primary'),
|
|
1208
|
+
* padding: 8,
|
|
1209
|
+
* }
|
|
1210
|
+
* // Returns: { backgroundColor: 0x2196f3, borderColor: 0x... }
|
|
1211
|
+
* ```
|
|
1212
|
+
*/
|
|
2586
1213
|
function colorsToTheme(colors, colorKey, options = {}) {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
1214
|
+
const { backgroundShade = "DEFAULT", borderShade = "dark", includeBorder = true } = options;
|
|
1215
|
+
const result = { backgroundColor: colors[colorKey][backgroundShade].toNumber() };
|
|
1216
|
+
if (includeBorder) result.borderColor = colors[colorKey][borderShade].toNumber();
|
|
1217
|
+
return result;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Get text color from ColorTokens as hex string for Phaser Text style
|
|
1221
|
+
* @param colors - ColorTokens to use
|
|
1222
|
+
* @param shade - Which text shade to use (default: 'DEFAULT')
|
|
1223
|
+
* @param alphaValue - Optional alpha value (0-1)
|
|
1224
|
+
* @returns Hex string or rgba string for Text style
|
|
1225
|
+
* @example
|
|
1226
|
+
* ```typescript
|
|
1227
|
+
* const colors = getPreset('oceanBlue').colors
|
|
1228
|
+
* const textStyle = {
|
|
1229
|
+
* color: getTextColor(colors),
|
|
1230
|
+
* fontSize: '18px'
|
|
1231
|
+
* }
|
|
1232
|
+
* ```
|
|
1233
|
+
*/
|
|
2596
1234
|
function getTextColor(colors, shade = "DEFAULT", alphaValue) {
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
}
|
|
1235
|
+
const color = colors.text[shade];
|
|
1236
|
+
return alphaValue !== void 0 ? alpha(color.toNumber(), alphaValue) : color.toString();
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Get background color from ColorTokens
|
|
1240
|
+
* @param colors - ColorTokens to use
|
|
1241
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
1242
|
+
* @returns Phaser color number
|
|
1243
|
+
*/
|
|
2600
1244
|
function getBackgroundColor(colors, shade = "DEFAULT") {
|
|
2601
|
-
|
|
2602
|
-
}
|
|
1245
|
+
return colors.background[shade].toNumber();
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Get surface color from ColorTokens
|
|
1249
|
+
* @param colors - ColorTokens to use
|
|
1250
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
1251
|
+
* @returns Phaser color number
|
|
1252
|
+
*/
|
|
2603
1253
|
function getSurfaceColor(colors, shade = "DEFAULT") {
|
|
2604
|
-
|
|
2605
|
-
}
|
|
1254
|
+
return colors.surface[shade].toNumber();
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* Get border color from ColorTokens
|
|
1258
|
+
* @param colors - ColorTokens to use
|
|
1259
|
+
* @param shade - Which shade to use (default: 'DEFAULT')
|
|
1260
|
+
* @returns Phaser color number
|
|
1261
|
+
*/
|
|
2606
1262
|
function getBorderColor(colors, shade = "DEFAULT") {
|
|
2607
|
-
|
|
2608
|
-
}
|
|
1263
|
+
return colors.border[shade].toNumber();
|
|
1264
|
+
}
|
|
1265
|
+
//#endregion
|
|
1266
|
+
//#region src/colors/preset-manager.ts
|
|
1267
|
+
/**
|
|
1268
|
+
* Dynamic color preset management
|
|
1269
|
+
*/
|
|
1270
|
+
/**
|
|
1271
|
+
* Set the active color preset globally
|
|
1272
|
+
* Applies the preset with the current color mode and updates all components
|
|
1273
|
+
* Triggers complete remount of all active mountJSX instances
|
|
1274
|
+
* @param presetName - Name of the preset to apply
|
|
1275
|
+
* @param colorMode - Optional color mode to apply together with the preset
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```typescript
|
|
1278
|
+
* // Switch to forest green theme
|
|
1279
|
+
* setColorPreset('forestGreen')
|
|
1280
|
+
*
|
|
1281
|
+
* // Apply preset and force dark mode in one go
|
|
1282
|
+
* setColorPreset('midnight', 'dark')
|
|
1283
|
+
*
|
|
1284
|
+
* // Current mode (light/dark) is preserved
|
|
1285
|
+
* ```
|
|
1286
|
+
*/
|
|
2609
1287
|
function setColorPreset(presetName, colorMode) {
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
1288
|
+
const preset = getPresetWithMode(presetName, colorMode ?? themeRegistry.getColorMode());
|
|
1289
|
+
themeRegistry.setColorTokens(preset.colors);
|
|
1290
|
+
themeRegistry.setCurrentPresetName(presetName, true);
|
|
1291
|
+
if (colorMode && themeRegistry.getColorMode() !== colorMode) {
|
|
1292
|
+
themeRegistry.setColorMode(colorMode);
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
setTimeout(() => {
|
|
1296
|
+
remountAll();
|
|
1297
|
+
}, 0);
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Get the currently active preset name
|
|
1301
|
+
* @returns Current preset name or undefined
|
|
1302
|
+
*/
|
|
2622
1303
|
function getCurrentPreset() {
|
|
2623
|
-
|
|
1304
|
+
return themeRegistry.getCurrentPresetName();
|
|
2624
1305
|
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Set the active color mode globally (without changing the preset)
|
|
1308
|
+
* @param mode - Color mode to apply
|
|
1309
|
+
*/
|
|
2625
1310
|
function setColorMode(mode) {
|
|
2626
|
-
|
|
2627
|
-
}
|
|
1311
|
+
themeRegistry.setColorMode(mode);
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Get all available preset names
|
|
1315
|
+
* @returns Array of preset names
|
|
1316
|
+
* @example
|
|
1317
|
+
* ```typescript
|
|
1318
|
+
* const presets = getAvailablePresets() // ['oceanBlue', 'forestGreen', 'midnight']
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
2628
1321
|
function getAvailablePresets() {
|
|
2629
|
-
|
|
2630
|
-
|
|
1322
|
+
return [
|
|
1323
|
+
"oceanBlue",
|
|
1324
|
+
"forestGreen",
|
|
1325
|
+
"midnight"
|
|
1326
|
+
];
|
|
1327
|
+
}
|
|
1328
|
+
//#endregion
|
|
1329
|
+
//#region src/design-tokens/use-theme-tokens.ts
|
|
1330
|
+
/**
|
|
1331
|
+
* Hook to access complete design token system
|
|
1332
|
+
* Combines colors with text styles, spacing, sizes, and radius tokens
|
|
1333
|
+
*/
|
|
1334
|
+
/**
|
|
1335
|
+
* Hook to access complete design token system from theme context
|
|
1336
|
+
* Provides colors, text styles, spacing, sizes, and radius tokens
|
|
1337
|
+
* Automatically updates when color mode or preset changes
|
|
1338
|
+
* @returns Current DesignTokens or undefined
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* function MyComponent() {
|
|
1342
|
+
* const tokens = useThemeTokens()
|
|
1343
|
+
*
|
|
1344
|
+
* if (!tokens) return null
|
|
1345
|
+
*
|
|
1346
|
+
* return (
|
|
1347
|
+
* <View
|
|
1348
|
+
* backgroundColor={tokens.colors.surface.DEFAULT}
|
|
1349
|
+
* padding={tokens.spacing.lg}
|
|
1350
|
+
* cornerRadius={tokens.radius.md}
|
|
1351
|
+
* >
|
|
1352
|
+
* <Text text="Title" style={tokens.textStyles.title} />
|
|
1353
|
+
* <Text text="Body text" style={tokens.textStyles.DEFAULT} />
|
|
1354
|
+
* </View>
|
|
1355
|
+
* )
|
|
1356
|
+
* }
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
2631
1359
|
function useThemeTokens() {
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
}, [localTheme]);
|
|
2690
|
-
return tokens;
|
|
2691
|
-
}
|
|
1360
|
+
const localTheme = useTheme();
|
|
1361
|
+
const getInitialTokens = () => {
|
|
1362
|
+
if (localTheme?.__colorPreset) {
|
|
1363
|
+
const preset = getPresetWithMode(localTheme.__colorPreset.name, localTheme.__colorPreset.mode ?? "light");
|
|
1364
|
+
return {
|
|
1365
|
+
colors: preset.colors,
|
|
1366
|
+
textStyles: createTextStyleTokens(preset.colors.text.DEFAULT.toString()),
|
|
1367
|
+
spacing: defaultSpacingTokens,
|
|
1368
|
+
sizes: defaultSizeTokens,
|
|
1369
|
+
radius: defaultRadiusTokens
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
const colors = themeRegistry.getColorTokens();
|
|
1373
|
+
if (!colors) return void 0;
|
|
1374
|
+
return {
|
|
1375
|
+
colors,
|
|
1376
|
+
textStyles: createTextStyleTokens(colors.text.DEFAULT.toString()),
|
|
1377
|
+
spacing: defaultSpacingTokens,
|
|
1378
|
+
sizes: defaultSizeTokens,
|
|
1379
|
+
radius: defaultRadiusTokens
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1382
|
+
const [tokens, setTokens] = useState(getInitialTokens());
|
|
1383
|
+
const [, forceUpdate] = useState(0);
|
|
1384
|
+
useEffect(() => {
|
|
1385
|
+
return themeRegistry.subscribe(() => {
|
|
1386
|
+
if (localTheme?.__colorPreset) {
|
|
1387
|
+
const currentMode = themeRegistry.getColorMode();
|
|
1388
|
+
const preset = getPresetWithMode(localTheme.__colorPreset.name, currentMode);
|
|
1389
|
+
setTokens({
|
|
1390
|
+
colors: preset.colors,
|
|
1391
|
+
textStyles: createTextStyleTokens(preset.colors.text.DEFAULT.toString()),
|
|
1392
|
+
spacing: defaultSpacingTokens,
|
|
1393
|
+
sizes: defaultSizeTokens,
|
|
1394
|
+
radius: defaultRadiusTokens
|
|
1395
|
+
});
|
|
1396
|
+
} else {
|
|
1397
|
+
const colors = themeRegistry.getColorTokens();
|
|
1398
|
+
if (colors) setTokens({
|
|
1399
|
+
colors,
|
|
1400
|
+
textStyles: createTextStyleTokens(colors.text.DEFAULT.toString()),
|
|
1401
|
+
spacing: defaultSpacingTokens,
|
|
1402
|
+
sizes: defaultSizeTokens,
|
|
1403
|
+
radius: defaultRadiusTokens
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
forceUpdate((n) => n + 1);
|
|
1407
|
+
});
|
|
1408
|
+
}, [localTheme]);
|
|
1409
|
+
return tokens;
|
|
1410
|
+
}
|
|
1411
|
+
//#endregion
|
|
1412
|
+
//#region src/index.ts
|
|
1413
|
+
/**
|
|
1414
|
+
* PhaserJSX UI Library
|
|
1415
|
+
* Provides JSX + hooks + VDOM for Phaser 3 game development
|
|
1416
|
+
*/
|
|
2692
1417
|
registerBuiltins();
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
CAMERA_FX_REGISTRY,
|
|
2698
|
-
C as CharText,
|
|
2699
|
-
b as CharTextInput,
|
|
2700
|
-
DEFAULT_BACKGROUND,
|
|
2701
|
-
DEFAULT_CAMERA_FX,
|
|
2702
|
-
af as DEFAULT_EFFECT,
|
|
2703
|
-
DEFAULT_FX,
|
|
2704
|
-
bj as DEFAULT_SPRING_CONFIG,
|
|
2705
|
-
a7 as DOMInputElement,
|
|
2706
|
-
DebugLogger,
|
|
2707
|
-
ab as DevConfig,
|
|
2708
|
-
ac as DevPresets,
|
|
2709
|
-
D as Dialog,
|
|
2710
|
-
c as Divider,
|
|
2711
|
-
d as Dropdown,
|
|
2712
|
-
ag as EFFECT_REGISTRY,
|
|
2713
|
-
FX_REGISTRY,
|
|
2714
|
-
Fragment,
|
|
2715
|
-
bc as Graphics,
|
|
2716
|
-
bo as HexColor,
|
|
2717
|
-
I as Icon,
|
|
2718
|
-
f as Image,
|
|
2719
|
-
J as Joystick,
|
|
2720
|
-
a8 as KeyboardInputManager,
|
|
2721
|
-
M as Modal,
|
|
2722
|
-
N as NineSlice,
|
|
2723
|
-
g as NineSliceButton,
|
|
2724
|
-
PARTICLE_PRESET_REGISTRY,
|
|
2725
|
-
P as Particles,
|
|
2726
|
-
PhaserJSXPlugin,
|
|
2727
|
-
h as Portal,
|
|
2728
|
-
R as RadioButton,
|
|
2729
|
-
i as RadioGroup,
|
|
2730
|
-
n as RangeSlider,
|
|
2731
|
-
j as RefOriginView,
|
|
2732
|
-
bk as SPRING_PRESETS,
|
|
2733
|
-
S as ScrollSlider,
|
|
2734
|
-
l as ScrollView,
|
|
2735
|
-
m as Sidebar,
|
|
2736
|
-
o as Slider,
|
|
2737
|
-
bl as SpringPhysics,
|
|
2738
|
-
Sprite,
|
|
2739
|
-
T as Tab,
|
|
2740
|
-
p as TabPanel,
|
|
2741
|
-
q as Tabs,
|
|
2742
|
-
bd as Text,
|
|
2743
|
-
TileSprite,
|
|
2744
|
-
r as Toggle,
|
|
2745
|
-
s as TransformOriginView,
|
|
2746
|
-
be as View,
|
|
2747
|
-
W as WrapText,
|
|
2748
|
-
addSceneBackground,
|
|
2749
|
-
alpha,
|
|
2750
|
-
bg as animatedSignal,
|
|
2751
|
-
applyCameraFXByName,
|
|
2752
|
-
bC as applyDarkMode,
|
|
2753
|
-
ah as applyEffectByName,
|
|
2754
|
-
applyFXByName,
|
|
2755
|
-
bD as applyLightMode,
|
|
2756
|
-
buildDeathZonesFromLayout,
|
|
2757
|
-
buildEmitZone,
|
|
2758
|
-
buildEmitZoneFromLayout,
|
|
2759
|
-
k as calculateSliderSize,
|
|
2760
|
-
colorsToTheme,
|
|
2761
|
-
computed,
|
|
2762
|
-
createBlurFX,
|
|
2763
|
-
aj as createBounceEffect,
|
|
2764
|
-
ak as createBreatheEffect,
|
|
2765
|
-
createCameraFadeInFX,
|
|
2766
|
-
createCameraFadeOutFX,
|
|
2767
|
-
createCameraFlashFX,
|
|
2768
|
-
createCameraShakeFX,
|
|
2769
|
-
createCameraZoomFX,
|
|
2770
|
-
createColorMatrixFX,
|
|
2771
|
-
b2 as createDefaultTheme,
|
|
2772
|
-
b7 as createElement,
|
|
2773
|
-
al as createFadeEffect,
|
|
2774
|
-
am as createFlashEffect,
|
|
2775
|
-
an as createFlipInEffect,
|
|
2776
|
-
ao as createFlipOutEffect,
|
|
2777
|
-
ap as createFloatEffect,
|
|
2778
|
-
createGlowFX,
|
|
2779
|
-
e as createIconComponent,
|
|
2780
|
-
aq as createJelloEffect,
|
|
2781
|
-
ar as createNoneEffect,
|
|
2782
|
-
createPhaserJSXPlugin,
|
|
2783
|
-
createPixelateFX,
|
|
2784
|
-
as as createPressEffect,
|
|
2785
|
-
at as createPulseEffect,
|
|
2786
|
-
createShadowFX,
|
|
2787
|
-
au as createShakeEffect,
|
|
2788
|
-
av as createSlideInEffect,
|
|
2789
|
-
aw as createSlideOutEffect,
|
|
2790
|
-
ax as createSpinEffect,
|
|
2791
|
-
ay as createSwingEffect,
|
|
2792
|
-
az as createTadaEffect,
|
|
2793
|
-
bz as createTextStyle,
|
|
2794
|
-
createTextStyleTokens,
|
|
2795
|
-
b5 as createTheme,
|
|
2796
|
-
createVignetteFX,
|
|
2797
|
-
aA as createWiggleEffect,
|
|
2798
|
-
aB as createWobbleEffect,
|
|
2799
|
-
aC as createZoomInEffect,
|
|
2800
|
-
aD as createZoomOutEffect,
|
|
2801
|
-
bu as darken,
|
|
2802
|
-
bv as darkenHex,
|
|
2803
|
-
defaultRadiusTokens,
|
|
2804
|
-
defaultSizeTokens,
|
|
2805
|
-
defaultSpacingTokens,
|
|
2806
|
-
bK as defaultTextStyleTokens,
|
|
2807
|
-
b3 as defaultTheme,
|
|
2808
|
-
aW as disposeCtx,
|
|
2809
|
-
bA as ensureContrast,
|
|
2810
|
-
bE as forestGreenPreset,
|
|
2811
|
-
bF as generateColorScale,
|
|
2812
|
-
getAvailablePresets,
|
|
2813
|
-
getBackgroundColor,
|
|
2814
|
-
aM as getBackgroundGraphics,
|
|
2815
|
-
getBorderColor,
|
|
2816
|
-
bB as getContrastRatio,
|
|
2817
|
-
aE as getCurrent,
|
|
2818
|
-
getCurrentPreset,
|
|
2819
|
-
aL as getLayoutProps,
|
|
2820
|
-
aO as getLayoutRect,
|
|
2821
|
-
aJ as getLayoutSize,
|
|
2822
|
-
a9 as getMountStats,
|
|
2823
|
-
bG as getPreset,
|
|
2824
|
-
getPresetWithMode,
|
|
2825
|
-
aa as getRenderContext,
|
|
2826
|
-
getSurfaceColor,
|
|
2827
|
-
getTextColor,
|
|
2828
|
-
getThemedProps,
|
|
2829
|
-
aQ as getWorldLayoutRect,
|
|
2830
|
-
graphicsCreator,
|
|
2831
|
-
graphicsPatcher,
|
|
2832
|
-
bw as hex,
|
|
2833
|
-
bp as hexToNumber,
|
|
2834
|
-
b1 as host,
|
|
2835
|
-
imageCreator,
|
|
2836
|
-
imagePatcher,
|
|
2837
|
-
bh as isAnimatedSignal,
|
|
2838
|
-
jsx,
|
|
2839
|
-
jsxs,
|
|
2840
|
-
bx as lighten,
|
|
2841
|
-
by as lightenHex,
|
|
2842
|
-
memo,
|
|
2843
|
-
b4 as mergeThemes,
|
|
2844
|
-
bH as midnightPreset,
|
|
2845
|
-
b8 as mount,
|
|
2846
|
-
mountJSX as mountComponent,
|
|
2847
|
-
mountJSX,
|
|
2848
|
-
nineSliceCreator,
|
|
2849
|
-
nineSlicePatcher,
|
|
2850
|
-
noMemo,
|
|
2851
|
-
b0 as nodeRegistry,
|
|
2852
|
-
a5 as normalizeCornerRadius,
|
|
2853
|
-
a6 as normalizeEdgeInsets,
|
|
2854
|
-
normalizeGap,
|
|
2855
|
-
b6 as normalizeVNodeLike,
|
|
2856
|
-
bq as numberToHex,
|
|
2857
|
-
br as numberToRgb,
|
|
2858
|
-
bI as oceanBluePreset,
|
|
2859
|
-
particlesCreator,
|
|
2860
|
-
particlesPatcher,
|
|
2861
|
-
ba as patchVNode,
|
|
2862
|
-
bf as portalRegistry,
|
|
2863
|
-
bJ as presets,
|
|
2864
|
-
register,
|
|
2865
|
-
registerBuiltins,
|
|
2866
|
-
aZ as releaseAllSVGTextures,
|
|
2867
|
-
aX as releaseSVGTexture,
|
|
2868
|
-
aY as releaseSVGTextures,
|
|
2869
|
-
remountAll,
|
|
2870
|
-
resolveCameraFX,
|
|
2871
|
-
ai as resolveEffect,
|
|
2872
|
-
resolveFX,
|
|
2873
|
-
resolveParticlePreset,
|
|
2874
|
-
bs as rgbToHsl,
|
|
2875
|
-
bt as rgbToNumber,
|
|
2876
|
-
setColorMode,
|
|
2877
|
-
setColorPreset,
|
|
2878
|
-
aT as shallowEqual,
|
|
2879
|
-
aU as shouldComponentUpdate,
|
|
2880
|
-
spriteCreator,
|
|
2881
|
-
spritePatcher,
|
|
2882
|
-
ad as svgToTexture,
|
|
2883
|
-
textCreator,
|
|
2884
|
-
textPatcher,
|
|
2885
|
-
themeRegistry,
|
|
2886
|
-
tileSpriteCreator,
|
|
2887
|
-
tileSpritePatcher,
|
|
2888
|
-
b9 as unmount,
|
|
2889
|
-
bb as unmountJSX,
|
|
2890
|
-
bi as unwrapSignal,
|
|
2891
|
-
aN as useBackgroundGraphics,
|
|
2892
|
-
useBlur,
|
|
2893
|
-
useCallback,
|
|
2894
|
-
useCameraFX,
|
|
2895
|
-
useCameraFade,
|
|
2896
|
-
useCameraFlash,
|
|
2897
|
-
useCameraZoom,
|
|
2898
|
-
useColorMode,
|
|
2899
|
-
useColors,
|
|
2900
|
-
useEffect,
|
|
2901
|
-
useFX,
|
|
2902
|
-
aG as useForceRedraw,
|
|
2903
|
-
ae as useGameObjectEffect,
|
|
2904
|
-
useGlow,
|
|
2905
|
-
u as useIconPreload,
|
|
2906
|
-
aS as useLayoutEffect,
|
|
2907
|
-
aP as useLayoutRect,
|
|
2908
|
-
aK as useLayoutSize,
|
|
2909
|
-
aH as useMemo,
|
|
2910
|
-
useParticles,
|
|
2911
|
-
aV as useRedraw,
|
|
2912
|
-
useRef,
|
|
2913
|
-
a_ as useSVGTexture,
|
|
2914
|
-
a$ as useSVGTextures,
|
|
2915
|
-
useScene,
|
|
2916
|
-
useScreenShake,
|
|
2917
|
-
useShadow,
|
|
2918
|
-
bm as useSpring,
|
|
2919
|
-
bn as useSprings,
|
|
2920
|
-
useState,
|
|
2921
|
-
useTheme,
|
|
2922
|
-
useThemeSubscription,
|
|
2923
|
-
useThemeTokens,
|
|
2924
|
-
aI as useViewportSize,
|
|
2925
|
-
aR as useWorldLayoutRect,
|
|
2926
|
-
viewCreator,
|
|
2927
|
-
viewPatcher,
|
|
2928
|
-
viewportRegistry,
|
|
2929
|
-
aF as withHooks
|
|
2930
|
-
};
|
|
2931
|
-
//# sourceMappingURL=index.js.map
|
|
1418
|
+
//#endregion
|
|
1419
|
+
export { Accordion, AlertDialog, Button, CAMERA_FX_REGISTRY, CharText, CharTextInput, DEFAULT_BACKGROUND, DEFAULT_CAMERA_FX, DEFAULT_EFFECT, DEFAULT_FX, DEFAULT_SPRING_CONFIG, DOMInputElement, DebugLogger, DevConfig, DevPresets, Dialog, Divider, Dropdown, EFFECT_REGISTRY, FX_REGISTRY, Fragment, Graphics, HexColor, Icon, Image, Joystick, KeyboardInputManager, Modal, NineSlice, NineSliceButton, PARTICLE_PRESET_REGISTRY, Particles, PhaserJSXPlugin, Portal, RadioButton, RadioGroup, RangeSlider, RefOriginView, SPRING_PRESETS, ScrollSlider, ScrollView, Sidebar, Slider, SpringPhysics, Sprite, Tab, TabPanel, Tabs, Text, TileSprite, Toggle, TransformOriginView, View, WrapText, addSceneBackground, alpha, animatedSignal, applyCameraFXByName, applyDarkMode, applyEffectByName, applyFXByName, applyLightMode, buildDeathZonesFromLayout, buildEmitZone, buildEmitZoneFromLayout, calculateSliderSize, colorsToTheme, computed, createBlurFX, createBounceEffect, createBreatheEffect, createCameraFadeInFX, createCameraFadeOutFX, createCameraFlashFX, createCameraShakeFX, createCameraZoomFX, createColorMatrixFX, createDefaultTheme, createElement, createFadeEffect, createFlashEffect, createFlipInEffect, createFlipOutEffect, createFloatEffect, createGlowFX, createIconComponent, createJelloEffect, createNoneEffect, createPhaserJSXPlugin, createPixelateFX, createPressEffect, createPulseEffect, createShadowFX, createShakeEffect, createSlideInEffect, createSlideOutEffect, createSpinEffect, createSwingEffect, createTadaEffect, createTextStyle, createTextStyleTokens, createTheme, createVignetteFX, createWiggleEffect, createWobbleEffect, createZoomInEffect, createZoomOutEffect, darken, darkenHex, defaultRadiusTokens, defaultSizeTokens, defaultSpacingTokens, defaultTextStyleTokens, defaultTheme, disposeCtx, ensureContrast, forestGreenPreset, generateColorScale, getAvailablePresets, getBackgroundColor, getBackgroundGraphics, getBorderColor, getContrastRatio, getCurrent, getCurrentPreset, getLayoutProps, getLayoutRect, getLayoutSize, getMountStats, getPreset, getPresetWithMode, getRenderContext, getSurfaceColor, getTextColor, getThemedProps, getWorldLayoutRect, graphicsCreator, graphicsPatcher, hex, hexToNumber, host, imageCreator, imagePatcher, isAnimatedSignal, jsx, jsxs, lighten, lightenHex, memo, mergeThemes, midnightPreset, mount, mountJSX as mountComponent, mountJSX, nineSliceCreator, nineSlicePatcher, noMemo, nodeRegistry, normalizeCornerRadius, normalizeEdgeInsets, normalizeGap, normalizeVNodeLike, numberToHex, numberToRgb, oceanBluePreset, particlesCreator, particlesPatcher, patchVNode, portalRegistry, presets, register, registerBuiltins, releaseAllSVGTextures, releaseSVGTexture, releaseSVGTextures, remountAll, resolveCameraFX, resolveEffect, resolveFX, resolveParticlePreset, rgbToHsl, rgbToNumber, setColorMode, setColorPreset, shallowEqual, shouldComponentUpdate, spriteCreator, spritePatcher, svgToTexture, textCreator, textPatcher, themeRegistry, tileSpriteCreator, tileSpritePatcher, unmount, unmountJSX, unwrapSignal, useBackgroundGraphics, useBlur, useCallback, useCameraFX, useCameraFade, useCameraFlash, useCameraZoom, useColorMode, useColors, useEffect, useFX, useForceRedraw, useGameObjectEffect, useGlow, useIconPreload, useLayoutEffect, useLayoutRect, useLayoutSize, useMemo, useParticles, useRedraw, useRef, useSVGTexture, useSVGTextures, useScene, useScreenShake, useShadow, useSpring, useSprings, useState, useTheme, useThemeSubscription, useThemeTokens, useViewportSize, useWorldLayoutRect, viewCreator, viewPatcher, viewportRegistry, withHooks };
|
|
1420
|
+
|
|
1421
|
+
//# sourceMappingURL=index.js.map
|