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