vue-phaserjs 4.2.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1841 @@
1
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, inject, nextTick, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, shallowRef, toValue, useTemplateRef, watch } from "vue";
2
+ import { ID_SEPARATOR, InvalidOperationError, NotFoundError, NotInitializedError, Operation, getOrCreate, takeOne, toKebabCase } from "@esposter/shared";
3
+ import ClickOutside from "phaser4-rex-plugins/plugins/clickoutside.js";
4
+ import { Cameras, Core, Game, Loader, Scene, Scenes, Tilemaps, Tweens, Utils } from "phaser";
5
+ import { defineStore, storeToRefs } from "pinia";
6
+ import { parseTileset } from "parse-tmx";
7
+ //#region src/services/emit/constants.ts
8
+ const EVENT_PREFIX = "on";
9
+ //#endregion
10
+ //#region src/services/emit/checkIsEvent.ts
11
+ const checkIsEvent = (property) => property.startsWith("on");
12
+ //#endregion
13
+ //#region src/services/emit/GameObjectEventMap.ts
14
+ const GameObjectEventMap = {
15
+ clickoutside: {},
16
+ drag: { drag: true },
17
+ dragend: { drag: true },
18
+ dragenter: { drag: true },
19
+ dragleave: { drag: true },
20
+ dragover: { drag: true },
21
+ dragstart: { drag: true },
22
+ drop: { drag: true },
23
+ pointerdown: { eventIndex: 3 },
24
+ pointermove: { eventIndex: 3 },
25
+ pointerout: { eventIndex: 1 },
26
+ pointerover: { eventIndex: 3 },
27
+ pointerup: { eventIndex: 3 },
28
+ wheel: { eventIndex: 4 }
29
+ };
30
+ //#endregion
31
+ //#region src/services/emit/getEventName.ts
32
+ const getEventName = (event) => {
33
+ if (!event.startsWith("on") || event.length <= 2) throw new InvalidOperationError(Operation.Read, getEventName.name, event);
34
+ return event.slice(2).toLowerCase();
35
+ };
36
+ //#endregion
37
+ //#region src/composables/useInitializeGameObjectEvents.ts
38
+ const useInitializeGameObjectEvents = () => {
39
+ const currentInstance = getCurrentInstance();
40
+ const events = new Set(Object.keys(currentInstance?.attrs ?? {}).filter((key) => checkIsEvent(key)).map((key) => getEventName(key)));
41
+ const gameObjectEvents = Object.keys(GameObjectEventMap).filter((key) => events.has(key));
42
+ const eventStopHandles = [];
43
+ const initializeGameObjectEvents = (gameObject, emit, scene) => {
44
+ if (gameObjectEvents.length === 0) return;
45
+ if (!gameObject.input) gameObject.setInteractive();
46
+ if (gameObjectEvents.some((key) => "drag" in GameObjectEventMap[key])) scene.input.setDraggable(gameObject);
47
+ for (const gameObjectEvent of gameObjectEvents) {
48
+ const context = GameObjectEventMap[gameObjectEvent];
49
+ const eventListener = (...args) => {
50
+ if ("eventIndex" in context) takeOne(args).stopPropagation = takeOne(args, context.eventIndex).stopPropagation;
51
+ emit(gameObjectEvent, ...args);
52
+ };
53
+ const emitter = gameObjectEvent === "clickoutside" ? new ClickOutside(gameObject) : gameObject;
54
+ emitter.on(gameObjectEvent, eventListener);
55
+ eventStopHandles.push(() => {
56
+ emitter.off(gameObjectEvent, eventListener);
57
+ });
58
+ }
59
+ };
60
+ return {
61
+ eventStopHandles,
62
+ initializeGameObjectEvents
63
+ };
64
+ };
65
+ //#endregion
66
+ //#region src/services/shared/InjectionKeyMap.ts
67
+ const InjectionKeyMap = {
68
+ ParentContainer: Symbol("ParentContainer"),
69
+ SceneKey: Symbol("SceneKey")
70
+ };
71
+ //#endregion
72
+ //#region src/composables/useInjectSceneKey.ts
73
+ const useInjectSceneKey = () => {
74
+ const sceneKey = inject(InjectionKeyMap.SceneKey);
75
+ if (!sceneKey) throw new NotInitializedError(InjectionKeyMap.SceneKey.description ?? "");
76
+ return sceneKey;
77
+ };
78
+ //#endregion
79
+ //#region src/models/lifecycle/Lifecycle.ts
80
+ let Lifecycle = /* @__PURE__ */ function(Lifecycle) {
81
+ Lifecycle["Create"] = "Create";
82
+ Lifecycle["Init"] = "Init";
83
+ Lifecycle["NextTick"] = "NextTick";
84
+ Lifecycle["Preload"] = "Preload";
85
+ Lifecycle["Shutdown"] = "Shutdown";
86
+ Lifecycle["Update"] = "Update";
87
+ return Lifecycle;
88
+ }({});
89
+ //#endregion
90
+ //#region src/store/ExternalSceneStore.ts
91
+ const ExternalSceneStore = {
92
+ lifecycleListenersMap: /* @__PURE__ */ new Map(),
93
+ sceneReadyMap: /* @__PURE__ */ new Map()
94
+ };
95
+ //#endregion
96
+ //#region src/services/hooks/pushListener.ts
97
+ const pushListener = (lifecycle, listener, key) => {
98
+ const sceneKey = key ?? useInjectSceneKey();
99
+ const listenersMap = getOrCreate(ExternalSceneStore.lifecycleListenersMap, lifecycle, () => /* @__PURE__ */ new Map());
100
+ getOrCreate(listenersMap, sceneKey, () => []).push(listener);
101
+ };
102
+ //#endregion
103
+ //#region src/hooks/onNextTick.ts
104
+ const onNextTick = (...args) => {
105
+ pushListener("NextTick", ...args);
106
+ };
107
+ //#endregion
108
+ //#region src/services/emit/getUpdateEvent.ts
109
+ const getUpdateEvent = (property) => `update:${toKebabCase(property)}`;
110
+ //#endregion
111
+ //#region src/composables/useInitializeGameObjectSetters.ts
112
+ const useInitializeGameObjectSetters = (gameObject, configuration, emit, setterMap, immediate) => {
113
+ const sceneKey = useInjectSceneKey();
114
+ const setters = [];
115
+ const setterWatchHandles = [];
116
+ for (const [key, value] of Object.entries(toValue(configuration))) {
117
+ const setter = setterMap[key];
118
+ if (!setter) continue;
119
+ const updateEvent = getUpdateEvent(key);
120
+ setters.push((targetGameObject) => {
121
+ setter(targetGameObject, emit)(value);
122
+ if (value !== void 0) emit(updateEvent, value);
123
+ else if (key in targetGameObject) emit(updateEvent, targetGameObject[key]);
124
+ });
125
+ setterWatchHandles.push(watch(() => toValue(configuration)[key], (newValue, oldValue) => {
126
+ if (newValue === oldValue && (newValue === null || typeof newValue !== "object")) return;
127
+ const updater = () => {
128
+ setter(toValue(gameObject), emit)(newValue);
129
+ emit(updateEvent, newValue);
130
+ };
131
+ if (immediate) updater();
132
+ else onNextTick(() => {
133
+ updater();
134
+ }, sceneKey);
135
+ }, { deep: true }));
136
+ }
137
+ const initializeGameObjectSetters = (targetGameObject) => {
138
+ for (const setter of setters) setter(targetGameObject);
139
+ };
140
+ return {
141
+ initializeGameObjectSetters,
142
+ setterWatchHandles
143
+ };
144
+ };
145
+ //#endregion
146
+ //#region src/hooks/onCreate.ts
147
+ const onCreate = (...args) => {
148
+ pushListener("Create", ...args);
149
+ };
150
+ //#endregion
151
+ //#region src/services/hooks/getInitializeGameObjectLifecycleHook.ts
152
+ const getInitializeGameObjectLifecycleHook = (sceneKey) => ExternalSceneStore.sceneReadyMap.get(sceneKey) ? onNextTick : onCreate;
153
+ //#endregion
154
+ //#region src/store/index.ts
155
+ const usePhaserStore = defineStore("phaser", () => {
156
+ let baseGame;
157
+ const game = computed({
158
+ get: () => baseGame,
159
+ set: (newGame) => {
160
+ baseGame = newGame;
161
+ }
162
+ });
163
+ const sceneKey = ref();
164
+ const isSameScene = (newSceneKey) => newSceneKey === sceneKey.value;
165
+ const switchToScene = async (newSceneKey) => {
166
+ if (isSameScene(newSceneKey)) return;
167
+ const activeGame = game.value;
168
+ if (!activeGame) throw new NotInitializedError(Game.name);
169
+ const oldSceneKey = sceneKey.value;
170
+ sceneKey.value = newSceneKey;
171
+ await nextTick();
172
+ if (oldSceneKey && activeGame.scene.isActive(oldSceneKey)) activeGame.scene.stop(oldSceneKey);
173
+ activeGame.scene.start(newSceneKey);
174
+ };
175
+ const parallelSceneKeys = ref([]);
176
+ const prioritizedParallelSceneKeys = ref([]);
177
+ const launchParallelScene = (scene, targetSceneKey) => {
178
+ if (parallelSceneKeys.value.includes(targetSceneKey)) return;
179
+ scene.scene.bringToTop(targetSceneKey);
180
+ for (const prioritizedParallelSceneKey of prioritizedParallelSceneKeys.value) if (parallelSceneKeys.value.includes(prioritizedParallelSceneKey)) scene.scene.bringToTop(prioritizedParallelSceneKey);
181
+ scene.scene.launch(targetSceneKey);
182
+ parallelSceneKeys.value.push(targetSceneKey);
183
+ };
184
+ const removeParallelScene = (scene, targetSceneKey) => {
185
+ const index = parallelSceneKeys.value.indexOf(targetSceneKey);
186
+ if (index === -1) return;
187
+ parallelSceneKeys.value = parallelSceneKeys.value.toSpliced(index, 1);
188
+ scene.scene.stop(targetSceneKey);
189
+ };
190
+ return {
191
+ game,
192
+ isSameScene,
193
+ launchParallelScene,
194
+ parallelSceneKeys,
195
+ prioritizedParallelSceneKeys,
196
+ removeParallelScene,
197
+ rootSceneKey: sceneKey,
198
+ switchToScene
199
+ };
200
+ });
201
+ //#endregion
202
+ //#region src/composables/useGame.ts
203
+ const useGame = () => {
204
+ const phaserStore = usePhaserStore();
205
+ const { game } = storeToRefs(phaserStore);
206
+ if (!game.value) throw new NotInitializedError(Game.name);
207
+ return game.value;
208
+ };
209
+ //#endregion
210
+ //#region src/services/shared/getScene.ts
211
+ const getScene = (sceneKey) => {
212
+ return useGame().scene.getScene(sceneKey);
213
+ };
214
+ //#endregion
215
+ //#region src/services/shared/getDepthInsertIndex.ts
216
+ const getDepthInsertIndex = (list, depth) => typeof depth === "number" ? list.findIndex((gameObject) => "depth" in gameObject && typeof gameObject.depth === "number" && gameObject.depth > depth) : -1;
217
+ //#endregion
218
+ //#region src/services/shared/pushGameObject.ts
219
+ const pushGameObject = (parentContainer, configuration, gameObject) => {
220
+ const depthInsertIndex = getDepthInsertIndex(parentContainer.list, "depth" in configuration ? configuration.depth : void 0);
221
+ if (depthInsertIndex === -1) parentContainer.add(gameObject);
222
+ else parentContainer.addAt(gameObject, depthInsertIndex);
223
+ };
224
+ //#endregion
225
+ //#region src/composables/useInitializeGameObject.ts
226
+ const useInitializeGameObject = (create, configuration, emit, setterMap, immediate) => {
227
+ let gameObject;
228
+ const { initializeGameObjectSetters, setterWatchHandles } = useInitializeGameObjectSetters(() => gameObject, configuration, emit, setterMap, immediate);
229
+ const { eventStopHandles, initializeGameObjectEvents } = useInitializeGameObjectEvents();
230
+ const parentContainer = inject(InjectionKeyMap.ParentContainer, void 0);
231
+ const sceneKey = useInjectSceneKey();
232
+ const lifecycleHook = getInitializeGameObjectLifecycleHook(sceneKey);
233
+ const initializeGameObject = (scene) => {
234
+ gameObject = create(scene);
235
+ initializeGameObjectSetters(gameObject);
236
+ initializeGameObjectEvents(gameObject, emit, scene);
237
+ };
238
+ const pushToParentContainer = () => {
239
+ if (!parentContainer?.value) return;
240
+ pushGameObject(parentContainer.value, toValue(configuration), gameObject);
241
+ };
242
+ if (immediate) {
243
+ initializeGameObject(getScene(sceneKey));
244
+ lifecycleHook(() => {
245
+ pushToParentContainer();
246
+ });
247
+ } else lifecycleHook((scene) => {
248
+ initializeGameObject(scene);
249
+ pushToParentContainer();
250
+ });
251
+ onUnmounted(() => {
252
+ for (const setterWatchHandle of setterWatchHandles) setterWatchHandle();
253
+ for (const eventStopHandle of eventStopHandles) eventStopHandle();
254
+ gameObject.destroy();
255
+ });
256
+ };
257
+ //#endregion
258
+ //#region src/services/setterMap/global/GameObjectSetterMap.ts
259
+ const GameObjectSetterMap = { active: (gameObject) => (value) => {
260
+ if (value === void 0) return;
261
+ gameObject.setActive(value);
262
+ } };
263
+ //#endregion
264
+ //#region src/services/setterMap/global/TweenSetterMap.ts
265
+ const TweenSetterMap = {
266
+ tween: (gameObject, emit) => (value) => {
267
+ if (!value) return;
268
+ gameObject.scene.add.tween({
269
+ ...value,
270
+ targets: gameObject
271
+ }).on(Tweens.Events.TWEEN_COMPLETE, () => {
272
+ emit("update:tween", void 0);
273
+ });
274
+ },
275
+ tweenchain: (gameObject, emit) => (value) => {
276
+ if (!value) return;
277
+ gameObject.scene.add.tweenchain(value.map((configuration) => ({
278
+ ...configuration,
279
+ targets: gameObject
280
+ }))).on(Tweens.Events.TWEEN_COMPLETE, () => {
281
+ emit("update:tweenchain", void 0);
282
+ });
283
+ }
284
+ };
285
+ //#endregion
286
+ //#region src/services/setterMap/global/GlobalSetterMap.ts
287
+ const GlobalSetterMap = {
288
+ ...TweenSetterMap,
289
+ ...GameObjectSetterMap
290
+ };
291
+ //#endregion
292
+ //#region src/services/setterMap/components/AlphaSingleSetterMap.ts
293
+ const AlphaSingleSetterMap = { alpha: (gameObject) => (value) => {
294
+ if (value === void 0) return;
295
+ gameObject.setAlpha(value);
296
+ } };
297
+ //#endregion
298
+ //#region src/services/setterMap/components/DisplaySizeSetterMap.ts
299
+ const DisplaySizeSetterMap = {
300
+ displayHeight: (gameObject) => (value) => {
301
+ if (value === void 0) return;
302
+ gameObject.setDisplaySize(gameObject.displayWidth, value);
303
+ },
304
+ displayWidth: (gameObject) => (value) => {
305
+ if (value === void 0) return;
306
+ gameObject.setDisplaySize(value, gameObject.displayHeight);
307
+ }
308
+ };
309
+ //#endregion
310
+ //#region src/services/setterMap/components/OriginSetterMap.ts
311
+ const OriginSetterMap = {
312
+ displayOriginX: (gameObject) => (value) => {
313
+ if (value === void 0) return;
314
+ gameObject.setDisplayOrigin(value, gameObject.displayOriginY);
315
+ },
316
+ displayOriginY: (gameObject) => (value) => {
317
+ if (value === void 0) return;
318
+ gameObject.setDisplayOrigin(gameObject.displayOriginX, value);
319
+ },
320
+ origin: (gameObject) => (value) => {
321
+ if (value === void 0) return;
322
+ gameObject.setOrigin(value, value);
323
+ },
324
+ originX: (gameObject) => (value) => {
325
+ if (value === void 0) return;
326
+ gameObject.setOrigin(value, gameObject.originY);
327
+ },
328
+ originY: (gameObject) => (value) => {
329
+ if (value === void 0) return;
330
+ gameObject.setOrigin(gameObject.originX, value);
331
+ }
332
+ };
333
+ //#endregion
334
+ //#region src/services/setterMap/components/RenderNodesSetterMap.ts
335
+ const RenderNodesSetterMap = {};
336
+ //#endregion
337
+ //#region src/services/setterMap/components/BlendModeSetterMap.ts
338
+ const BlendModeSetterMap = { blendMode: (gameObject) => (value) => {
339
+ if (value === void 0) return;
340
+ gameObject.setBlendMode(value);
341
+ } };
342
+ //#endregion
343
+ //#region src/services/setterMap/components/DepthSetterMap.ts
344
+ const DepthSetterMap = { depth: (gameObject) => (value) => {
345
+ if (value === void 0) return;
346
+ gameObject.setDepth(value);
347
+ if (!gameObject.parentContainer) return;
348
+ const { list } = gameObject.parentContainer;
349
+ const depthInsertIndex = getDepthInsertIndex(list, gameObject.depth);
350
+ if (depthInsertIndex === -1) gameObject.parentContainer.bringToTop(gameObject);
351
+ else {
352
+ const currentIndex = list.indexOf(gameObject);
353
+ gameObject.parentContainer.moveTo(gameObject, currentIndex < depthInsertIndex ? depthInsertIndex - 1 : depthInsertIndex);
354
+ }
355
+ } };
356
+ //#endregion
357
+ //#region src/services/setterMap/components/MaskSetterMap.ts
358
+ const MaskSetterMap = { mask: (gameObject) => (value) => {
359
+ if (!value) return;
360
+ gameObject.setMask(value);
361
+ } };
362
+ //#endregion
363
+ //#region src/services/setterMap/components/ScrollFactorSetterMap.ts
364
+ const ScrollFactorSetterMap = {
365
+ scrollFactor: (gameObject) => (value) => {
366
+ if (value === void 0) return;
367
+ gameObject.setScrollFactor(value, value);
368
+ },
369
+ scrollFactorX: (gameObject) => (value) => {
370
+ if (value === void 0) return;
371
+ gameObject.setScrollFactor(value, gameObject.scrollFactorY);
372
+ },
373
+ scrollFactorY: (gameObject) => (value) => {
374
+ if (value === void 0) return;
375
+ gameObject.setScrollFactor(gameObject.scrollFactorX, value);
376
+ }
377
+ };
378
+ //#endregion
379
+ //#region src/services/setterMap/components/TransformSetterMap.ts
380
+ const TransformSetterMap = {
381
+ angle: (gameObject) => (value) => {
382
+ if (value === void 0) return;
383
+ gameObject.setAngle(value);
384
+ },
385
+ rotation: (gameObject) => (value) => {
386
+ if (value === void 0) return;
387
+ gameObject.setRotation(value);
388
+ },
389
+ scale: (gameObject) => (value) => {
390
+ if (value === void 0) return;
391
+ gameObject.setScale(value, value);
392
+ },
393
+ scaleX: (gameObject) => (value) => {
394
+ if (value === void 0) return;
395
+ gameObject.setScale(value, gameObject.scaleY);
396
+ },
397
+ scaleY: (gameObject) => (value) => {
398
+ if (value === void 0) return;
399
+ gameObject.setScale(gameObject.scaleX, value);
400
+ },
401
+ w: (gameObject) => (value) => {
402
+ if (value === void 0) return;
403
+ gameObject.setW(value);
404
+ },
405
+ x: (gameObject) => (value) => {
406
+ if (value === void 0) return;
407
+ gameObject.setX(value);
408
+ },
409
+ y: (gameObject) => (value) => {
410
+ if (value === void 0) return;
411
+ gameObject.setY(value);
412
+ },
413
+ z: (gameObject) => (value) => {
414
+ if (value === void 0) return;
415
+ gameObject.setZ(value);
416
+ }
417
+ };
418
+ //#endregion
419
+ //#region src/services/setterMap/components/VisibleSetterMap.ts
420
+ const VisibleSetterMap = { visible: (gameObject) => (value) => {
421
+ if (value === void 0) return;
422
+ gameObject.setVisible(value);
423
+ } };
424
+ //#endregion
425
+ //#region src/services/setterMap/shared/SceneObjectSetterMap.ts
426
+ const SceneObjectSetterMap = {
427
+ ...BlendModeSetterMap,
428
+ ...DepthSetterMap,
429
+ ...MaskSetterMap,
430
+ ...ScrollFactorSetterMap,
431
+ ...TransformSetterMap,
432
+ ...VisibleSetterMap
433
+ };
434
+ //#endregion
435
+ //#region src/services/setterMap/shared/ShapeSetterMap.ts
436
+ const ShapeSetterMap = {
437
+ ...AlphaSingleSetterMap,
438
+ ...SceneObjectSetterMap,
439
+ ...DisplaySizeSetterMap,
440
+ ...GameObjectSetterMap,
441
+ ...OriginSetterMap,
442
+ ...RenderNodesSetterMap,
443
+ fillAlpha: (gameObject) => (value) => {
444
+ gameObject.setFillStyle(gameObject.fillColor, value);
445
+ },
446
+ fillColor: (gameObject) => (value) => {
447
+ gameObject.setFillStyle(value, gameObject.fillAlpha);
448
+ },
449
+ strokeStyle: (gameObject) => (value) => {
450
+ if (!value) return;
451
+ gameObject.setStrokeStyle(...value);
452
+ }
453
+ };
454
+ //#endregion
455
+ //#region src/services/setterMap/ArcSetterMap.ts
456
+ const ArcSetterMap = {
457
+ closePath: (gameObject) => (value) => {
458
+ if (value === void 0) return;
459
+ gameObject.setClosePath(value);
460
+ },
461
+ endAngle: (gameObject) => (value) => {
462
+ if (value === void 0) return;
463
+ gameObject.setEndAngle(value);
464
+ },
465
+ radius: (gameObject) => (value) => {
466
+ if (value === void 0) return;
467
+ gameObject.setRadius(value);
468
+ },
469
+ startAngle: (gameObject) => (value) => {
470
+ if (value === void 0) return;
471
+ gameObject.setStartAngle(value);
472
+ },
473
+ ...ShapeSetterMap,
474
+ ...GlobalSetterMap
475
+ };
476
+ //#endregion
477
+ //#region src/components/Arc.vue
478
+ const _sfc_main = /*@__PURE__*/ defineComponent({
479
+ __name: "Arc",
480
+ props: {
481
+ configuration: {},
482
+ immediate: { type: Boolean },
483
+ onComplete: { type: Function }
484
+ },
485
+ setup(__props, { emit: __emit }) {
486
+ useInitializeGameObject((scene) => {
487
+ const { alpha, endAngle, fillColor, radius, startAngle, x, y } = __props.configuration;
488
+ const arc = scene.add.arc(x, y, radius, startAngle, endAngle, void 0, fillColor, alpha);
489
+ __props.onComplete?.(scene, arc);
490
+ return arc;
491
+ }, () => __props.configuration, __emit, ArcSetterMap, __props.immediate);
492
+ return (_ctx, _cache) => {
493
+ return null;
494
+ };
495
+ }
496
+ });
497
+ //#endregion
498
+ //#region src/services/setterMap/components/AlphaSetterMap.ts
499
+ const AlphaSetterMap = {
500
+ alpha: (gameObject) => (value) => {
501
+ if (value === void 0) return;
502
+ gameObject.setAlpha(value, value, value, value);
503
+ },
504
+ alphaBottomLeft: (gameObject) => (value) => {
505
+ if (value === void 0) return;
506
+ gameObject.setAlpha(gameObject.alphaTopLeft, gameObject.alphaTopRight, value, gameObject.alphaBottomRight);
507
+ },
508
+ alphaBottomRight: (gameObject) => (value) => {
509
+ if (value === void 0) return;
510
+ gameObject.setAlpha(gameObject.alphaTopLeft, gameObject.alphaTopRight, gameObject.alphaBottomLeft, value);
511
+ },
512
+ alphaTopLeft: (gameObject) => (value) => {
513
+ if (value === void 0) return;
514
+ gameObject.setAlpha(value, gameObject.alphaTopRight, gameObject.alphaBottomLeft, gameObject.alphaBottomRight);
515
+ },
516
+ alphaTopRight: (gameObject) => (value) => {
517
+ if (value === void 0) return;
518
+ gameObject.setAlpha(gameObject.alphaTopLeft, value, gameObject.alphaBottomLeft, gameObject.alphaBottomRight);
519
+ }
520
+ };
521
+ //#endregion
522
+ //#region src/services/setterMap/components/TintSetterMap.ts
523
+ const TintSetterMap = {
524
+ tint: (gameObject) => (value) => {
525
+ if (value === void 0) return;
526
+ gameObject.setTint(value, value, value, value);
527
+ },
528
+ tintBottomLeft: (gameObject) => (value) => {
529
+ if (value === void 0) return;
530
+ gameObject.setTint(gameObject.tintTopLeft, gameObject.tintTopRight, value, gameObject.tintBottomRight);
531
+ },
532
+ tintBottomRight: (gameObject) => (value) => {
533
+ if (value === void 0) return;
534
+ gameObject.setTint(gameObject.tintTopLeft, gameObject.tintTopRight, gameObject.tintBottomLeft, value);
535
+ },
536
+ tintTopLeft: (gameObject) => (value) => {
537
+ if (value === void 0) return;
538
+ gameObject.setTint(value, gameObject.tintTopRight, gameObject.tintBottomLeft, gameObject.tintBottomRight);
539
+ },
540
+ tintTopRight: (gameObject) => (value) => {
541
+ if (value === void 0) return;
542
+ gameObject.setTint(gameObject.tintTopLeft, value, gameObject.tintBottomLeft, gameObject.tintBottomRight);
543
+ }
544
+ };
545
+ //#endregion
546
+ //#region src/services/setterMap/shared/RenderableSetterMap.ts
547
+ const RenderableSetterMap = {
548
+ ...AlphaSetterMap,
549
+ ...SceneObjectSetterMap,
550
+ ...OriginSetterMap,
551
+ ...RenderNodesSetterMap,
552
+ ...TintSetterMap,
553
+ ...GlobalSetterMap
554
+ };
555
+ //#endregion
556
+ //#region src/services/setterMap/BitmapTextSetterMap.ts
557
+ const BitmapTextSetterMap = {
558
+ align: (gameObject) => (value) => {
559
+ if (value === void 0) return;
560
+ gameObject.align = value;
561
+ },
562
+ dropShadow: (gameObject) => (value) => {
563
+ if (!value) return;
564
+ gameObject.setDropShadow(...value);
565
+ },
566
+ font: (gameObject) => (value) => {
567
+ if (!value) return;
568
+ gameObject.setFont(value);
569
+ },
570
+ fontSize: (gameObject) => (value) => {
571
+ if (value === void 0) return;
572
+ gameObject.setFontSize(value);
573
+ },
574
+ letterSpacing: (gameObject) => (value) => {
575
+ if (value === void 0) return;
576
+ gameObject.setLetterSpacing(value);
577
+ },
578
+ lineSpacing: (gameObject) => (value) => {
579
+ if (value === void 0) return;
580
+ gameObject.setLineSpacing(value);
581
+ },
582
+ maxWidth: (gameObject) => (value) => {
583
+ if (value === void 0) return;
584
+ gameObject.setMaxWidth(value);
585
+ },
586
+ text: (gameObject) => (value) => {
587
+ if (value === void 0) return;
588
+ gameObject.setText(value);
589
+ },
590
+ wordWrapCharCode: (gameObject) => (value) => {
591
+ if (value === void 0) return;
592
+ gameObject.wordWrapCharCode = value;
593
+ },
594
+ ...RenderableSetterMap
595
+ };
596
+ //#endregion
597
+ //#region src/components/BitmapText.vue
598
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
599
+ __name: "BitmapText",
600
+ props: {
601
+ configuration: {},
602
+ immediate: { type: Boolean },
603
+ onComplete: { type: Function }
604
+ },
605
+ setup(__props, { emit: __emit }) {
606
+ useInitializeGameObject((scene) => {
607
+ const { align, font, fontSize, text, x, y } = __props.configuration;
608
+ const bitmapText = scene.add.bitmapText(x ?? 0, y ?? 0, font, text, fontSize, align);
609
+ __props.onComplete?.(scene, bitmapText);
610
+ return bitmapText;
611
+ }, () => __props.configuration, __emit, BitmapTextSetterMap, __props.immediate);
612
+ return (_ctx, _cache) => {
613
+ return null;
614
+ };
615
+ }
616
+ });
617
+ //#endregion
618
+ //#region src/components/Circle.vue
619
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
620
+ __name: "Circle",
621
+ props: {
622
+ configuration: {},
623
+ immediate: { type: Boolean },
624
+ onComplete: { type: Function }
625
+ },
626
+ setup(__props, { emit: __emit }) {
627
+ useInitializeGameObject((scene) => {
628
+ const { alpha, fillColor, radius, x, y } = __props.configuration;
629
+ const circle = scene.add.circle(x, y, radius, fillColor, alpha);
630
+ __props.onComplete?.(scene, circle);
631
+ return circle;
632
+ }, () => __props.configuration, __emit, ArcSetterMap, __props.immediate);
633
+ return (_ctx, _cache) => {
634
+ return null;
635
+ };
636
+ }
637
+ });
638
+ //#endregion
639
+ //#region src/services/setterMap/ContainerSetterMap.ts
640
+ const ContainerSetterMap = {
641
+ ...AlphaSingleSetterMap,
642
+ ...SceneObjectSetterMap,
643
+ ...GlobalSetterMap
644
+ };
645
+ //#endregion
646
+ //#region src/components/Container.vue
647
+ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
648
+ __name: "Container",
649
+ props: {
650
+ configuration: { default: () => ({}) },
651
+ onComplete: { type: Function }
652
+ },
653
+ setup(__props, { emit: __emit }) {
654
+ const emit = __emit;
655
+ const container = shallowRef();
656
+ useInitializeGameObject((scene) => {
657
+ const { children, x, y } = __props.configuration;
658
+ container.value = scene.add.container(x, y, children);
659
+ __props.onComplete?.(scene, container.value);
660
+ return container.value;
661
+ }, () => __props.configuration, emit, ContainerSetterMap);
662
+ provide(InjectionKeyMap.ParentContainer, container);
663
+ return (_ctx, _cache) => {
664
+ return renderSlot(_ctx.$slots, "default");
665
+ };
666
+ }
667
+ });
668
+ //#endregion
669
+ //#region src/services/setterMap/CurveSetterMap.ts
670
+ const CurveSetterMap = {
671
+ smoothness: (gameObject) => (value) => {
672
+ if (value === void 0) return;
673
+ gameObject.setSmoothness(value);
674
+ },
675
+ ...ShapeSetterMap,
676
+ ...GlobalSetterMap
677
+ };
678
+ //#endregion
679
+ //#region src/components/Curve.vue
680
+ const _sfc_main$4 = /*@__PURE__*/ defineComponent({
681
+ __name: "Curve",
682
+ props: {
683
+ configuration: {},
684
+ immediate: { type: Boolean },
685
+ onComplete: { type: Function }
686
+ },
687
+ setup(__props, { emit: __emit }) {
688
+ useInitializeGameObject((scene) => {
689
+ const { alpha, curve, fillColor, x, y } = __props.configuration;
690
+ const curveObject = scene.add.curve(x, y, curve, fillColor, alpha);
691
+ __props.onComplete?.(scene, curveObject);
692
+ return curveObject;
693
+ }, () => __props.configuration, __emit, CurveSetterMap, __props.immediate);
694
+ return (_ctx, _cache) => {
695
+ return null;
696
+ };
697
+ }
698
+ });
699
+ //#endregion
700
+ //#region src/services/setterMap/components/ComputedSizeSetterMap.ts
701
+ const ComputedSizeSetterMap = {
702
+ ...DisplaySizeSetterMap,
703
+ height: (gameObject) => (value) => {
704
+ if (value === void 0) return;
705
+ gameObject.setSize(gameObject.width, value);
706
+ },
707
+ width: (gameObject) => (value) => {
708
+ if (value === void 0) return;
709
+ gameObject.setSize(value, gameObject.height);
710
+ }
711
+ };
712
+ //#endregion
713
+ //#region src/services/setterMap/EllipseSetterMap.ts
714
+ const EllipseSetterMap = {
715
+ height: ComputedSizeSetterMap.height,
716
+ smoothness: (gameObject) => (value) => {
717
+ if (value === void 0) return;
718
+ gameObject.setSmoothness(value);
719
+ },
720
+ width: ComputedSizeSetterMap.width,
721
+ ...ShapeSetterMap,
722
+ ...GlobalSetterMap
723
+ };
724
+ //#endregion
725
+ //#region src/components/Ellipse.vue
726
+ const _sfc_main$5 = /*@__PURE__*/ defineComponent({
727
+ __name: "Ellipse",
728
+ props: {
729
+ configuration: {},
730
+ immediate: { type: Boolean },
731
+ onComplete: { type: Function }
732
+ },
733
+ setup(__props, { emit: __emit }) {
734
+ useInitializeGameObject((scene) => {
735
+ const { alpha, fillColor, height, width, x, y } = __props.configuration;
736
+ const ellipse = scene.add.ellipse(x, y, width, height, fillColor, alpha);
737
+ __props.onComplete?.(scene, ellipse);
738
+ return ellipse;
739
+ }, () => __props.configuration, __emit, EllipseSetterMap, __props.immediate);
740
+ return (_ctx, _cache) => {
741
+ return null;
742
+ };
743
+ }
744
+ });
745
+ //#endregion
746
+ //#region src/models/plugins/TilesetFile.ts
747
+ const XMLFile = Loader.FileTypes.XMLFile;
748
+ var TilesetFile = class extends XMLFile {
749
+ tilesetIndex;
750
+ constructor(tilesetIndex, ...args) {
751
+ super(...args);
752
+ this.tilesetIndex = tilesetIndex;
753
+ }
754
+ };
755
+ //#endregion
756
+ //#region src/models/plugins/TiledJSONExternalFile.ts
757
+ const GetFastValue = Utils.Objects.GetFastValue;
758
+ const JSONFile$1 = Loader.FileTypes.JSONFile;
759
+ const MultiFile = Loader.MultiFile;
760
+ const PUBLIC_FOLDER = "public";
761
+ var TiledJSONExternalFile = class extends MultiFile {
762
+ constructor(loader, key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings) {
763
+ if (typeof key !== "string") {
764
+ const configuration = key;
765
+ key = GetFastValue(configuration, "key");
766
+ tilemapURL = GetFastValue(configuration, "url");
767
+ tilemapXhrSettings = GetFastValue(configuration, "xhrSettings");
768
+ path = GetFastValue(configuration, "path");
769
+ baseURL = GetFastValue(configuration, "baseURL");
770
+ tilesetXhrSettings = GetFastValue(configuration, "tilesetXhrSettings");
771
+ }
772
+ const tilemapFile = new JSONFile$1(loader, key, tilemapURL, tilemapXhrSettings);
773
+ super(loader, "tilemapJSON", key, [tilemapFile]);
774
+ this.config.path = path;
775
+ this.config.baseURL = baseURL;
776
+ this.config.tilesetXhrSettings = tilesetXhrSettings;
777
+ }
778
+ addToCache() {
779
+ if (!this.isReadyToProcess()) return;
780
+ const [tilemapFile, ...tilesetFiles] = this.files;
781
+ if (!(tilemapFile.type === "json" && Object.hasOwn(tilemapFile.data, "tilesets"))) return;
782
+ const tilemapData = tilemapFile.data;
783
+ const tilemapKey = tilemapFile.key;
784
+ const loader = this.loader;
785
+ const files = this.files;
786
+ this.complete = true;
787
+ for (const tilesetFile of tilesetFiles) {
788
+ const responseText = tilesetFile.xhrLoader?.responseText;
789
+ if (!responseText) throw new InvalidOperationError(Operation.Read, this.addToCache.name, tilesetFile.key);
790
+ const tilesetData = parseTileset(responseText).match((parsedTileset) => parsedTileset, (error) => {
791
+ throw error;
792
+ });
793
+ const index = tilesetFile.tilesetIndex;
794
+ Object.assign(tilemapData.tilesets[index], tilesetData, {
795
+ imageheight: tilesetData.image?.height,
796
+ imagewidth: tilesetData.image?.width,
797
+ source: void 0
798
+ });
799
+ }
800
+ loader.cacheManager.tilemap.add(tilemapKey, {
801
+ data: tilemapData,
802
+ format: Tilemaps.Formats.TILED_JSON
803
+ });
804
+ for (const file of files) file.pendingDestroy();
805
+ }
806
+ onFileComplete(file) {
807
+ if (this.files.indexOf(file) === -1) return;
808
+ this.pending--;
809
+ if (!(file.type === "json" && Object.hasOwn(file.data, "tilesets"))) return;
810
+ const tilesets = file.data.tilesets;
811
+ const config = this.config;
812
+ const loader = this.loader;
813
+ const currentBaseURL = loader.baseURL;
814
+ const currentPath = loader.path;
815
+ const currentPrefix = loader.prefix;
816
+ const baseURL = GetFastValue(config, "baseURL", currentBaseURL);
817
+ const path = GetFastValue(config, "path", currentPath);
818
+ const prefix = GetFastValue(config, "prefix", currentPrefix);
819
+ const tilesetXhrSettings = GetFastValue(config, "tilesetXhrSettings");
820
+ loader.setBaseURL(baseURL);
821
+ loader.setPath(path);
822
+ loader.setPrefix(prefix);
823
+ for (const [tilesetIndex, tileset] of tilesets.entries()) {
824
+ const pathIndex = tileset.source.indexOf(PUBLIC_FOLDER);
825
+ if (pathIndex === -1) throw new NotFoundError(this.onFileComplete.name, tileset.source);
826
+ const relativePath = tileset.source.slice(pathIndex + 6);
827
+ const tilesetFile = new TilesetFile(tilesetIndex, loader, `${file.key}${ID_SEPARATOR}Tileset${ID_SEPARATOR}${relativePath}`, relativePath, tilesetXhrSettings);
828
+ this.addToMultiFile(tilesetFile);
829
+ loader.addFile(tilesetFile);
830
+ }
831
+ loader.setBaseURL(currentBaseURL);
832
+ loader.setPath(currentPath);
833
+ loader.setPrefix(currentPrefix);
834
+ }
835
+ };
836
+ //#endregion
837
+ //#region src/services/shared/constants.ts
838
+ const TILEMAP_TILED_JSON_EXTERNAL_KEY = "tilemapTiledJSONExternal";
839
+ const ANIMATION_COMPLETE_EVENT_PREFIX = "animationcomplete-";
840
+ //#endregion
841
+ //#region src/plugins/registerTiledJSONExternalLoader.ts
842
+ const FileTypesManager = Loader.FileTypesManager;
843
+ const registerTiledJSONExternalLoader = () => {
844
+ FileTypesManager.register(TILEMAP_TILED_JSON_EXTERNAL_KEY, function(...[key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings]) {
845
+ if (Array.isArray(key)) for (const keyElement of key) {
846
+ const multifile = new TiledJSONExternalFile(this, keyElement);
847
+ this.addFile(multifile.files);
848
+ }
849
+ else {
850
+ const multifile = new TiledJSONExternalFile(this, key, tilemapURL, path, baseURL, tilemapXhrSettings, tilesetXhrSettings);
851
+ this.addFile(multifile.files);
852
+ }
853
+ return this;
854
+ });
855
+ };
856
+ //#endregion
857
+ //#region src/components/Game.vue
858
+ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
859
+ __name: "Game",
860
+ props: { configuration: {} },
861
+ setup(__props) {
862
+ const phaserStore = usePhaserStore();
863
+ const { game: storeGame } = storeToRefs(phaserStore);
864
+ const canvasRoot = useTemplateRef("canvasRoot");
865
+ const isReady = ref(false);
866
+ const readyListener = () => {
867
+ isReady.value = true;
868
+ };
869
+ onMounted(() => {
870
+ registerTiledJSONExternalLoader();
871
+ storeGame.value = new Game({
872
+ ...__props.configuration,
873
+ parent: canvasRoot.value
874
+ });
875
+ storeGame.value.events.on(Core.Events.READY, readyListener);
876
+ });
877
+ onUnmounted(() => {
878
+ const game = useGame();
879
+ game.events.off(Core.Events.READY, readyListener);
880
+ game.destroy(true);
881
+ storeGame.value = void 0;
882
+ });
883
+ return (_ctx, _cache) => {
884
+ return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", {
885
+ ref_key: "canvasRoot",
886
+ ref: canvasRoot
887
+ }, null, 512), isReady.value ? renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 0) : createCommentVNode("v-if", true)], 64);
888
+ };
889
+ }
890
+ });
891
+ //#endregion
892
+ //#region src/services/setterMap/GraphicsSetterMap.ts
893
+ const GraphicsSetterMap = {
894
+ ...AlphaSingleSetterMap,
895
+ ...SceneObjectSetterMap,
896
+ ...RenderNodesSetterMap,
897
+ ...GlobalSetterMap
898
+ };
899
+ //#endregion
900
+ //#region src/components/Graphics.vue
901
+ const _sfc_main$7 = /*@__PURE__*/ defineComponent({
902
+ __name: "Graphics",
903
+ props: {
904
+ configuration: { default: () => ({}) },
905
+ immediate: { type: Boolean },
906
+ onComplete: { type: Function }
907
+ },
908
+ setup(__props, { emit: __emit }) {
909
+ useInitializeGameObject((scene) => {
910
+ const { x, y } = __props.configuration;
911
+ const graphics = scene.add.graphics({
912
+ x,
913
+ y
914
+ });
915
+ __props.onComplete?.(scene, graphics);
916
+ return graphics;
917
+ }, () => __props.configuration, __emit, GraphicsSetterMap, __props.immediate);
918
+ return (_ctx, _cache) => {
919
+ return null;
920
+ };
921
+ }
922
+ });
923
+ //#endregion
924
+ //#region src/services/setterMap/components/FlipSetterMap.ts
925
+ const FlipSetterMap = {
926
+ flipX: (gameObject) => (value) => {
927
+ if (value === void 0) return;
928
+ gameObject.setFlipX(value);
929
+ },
930
+ flipY: (gameObject) => (value) => {
931
+ if (value === void 0) return;
932
+ gameObject.setFlipY(value);
933
+ }
934
+ };
935
+ //#endregion
936
+ //#region src/services/setterMap/components/SizeSetterMap.ts
937
+ const SizeSetterMap = { ...ComputedSizeSetterMap };
938
+ //#endregion
939
+ //#region src/services/setterMap/components/BaseTextureSetterMap.ts
940
+ const BaseTextureSetterMap = {
941
+ frame: (gameObject) => (value) => {
942
+ if (value === void 0) return;
943
+ gameObject.setFrame(value);
944
+ },
945
+ texture: (gameObject) => (value) => {
946
+ if (!value) return;
947
+ gameObject.setTexture(value);
948
+ }
949
+ };
950
+ //#endregion
951
+ //#region src/services/setterMap/components/TextureCropSetterMap.ts
952
+ const TextureCropSetterMap = { ...BaseTextureSetterMap };
953
+ //#endregion
954
+ //#region src/services/setterMap/ImageSetterMap.ts
955
+ const ImageSetterMap = {
956
+ ...RenderableSetterMap,
957
+ ...FlipSetterMap,
958
+ ...SizeSetterMap,
959
+ ...TextureCropSetterMap
960
+ };
961
+ //#endregion
962
+ //#region src/components/Image.vue
963
+ const _sfc_main$8 = /*@__PURE__*/ defineComponent({
964
+ __name: "Image",
965
+ props: {
966
+ configuration: {},
967
+ onComplete: { type: Function }
968
+ },
969
+ setup(__props, { emit: __emit }) {
970
+ useInitializeGameObject((scene) => {
971
+ const { frame, texture, x, y } = __props.configuration;
972
+ const image = scene.add.image(x ?? 0, y ?? 0, texture, frame);
973
+ __props.onComplete?.(scene, image);
974
+ return image;
975
+ }, () => __props.configuration, __emit, ImageSetterMap);
976
+ return (_ctx, _cache) => {
977
+ return null;
978
+ };
979
+ }
980
+ });
981
+ //#endregion
982
+ //#region src/services/setterMap/shared/IsoSetterMap.ts
983
+ const IsoSetterMap = {
984
+ fillLeft: (gameObject) => (value) => {
985
+ if (value === void 0) return;
986
+ gameObject.setFillStyle(gameObject.fillTop, value, gameObject.fillRight);
987
+ },
988
+ fillRight: (gameObject) => (value) => {
989
+ if (value === void 0) return;
990
+ gameObject.setFillStyle(gameObject.fillTop, gameObject.fillLeft, value);
991
+ },
992
+ fillTop: (gameObject) => (value) => {
993
+ if (value === void 0) return;
994
+ gameObject.setFillStyle(value, gameObject.fillLeft, gameObject.fillRight);
995
+ },
996
+ projection: (gameObject) => (value) => {
997
+ if (value === void 0) return;
998
+ gameObject.setProjection(value);
999
+ },
1000
+ showLeft: (gameObject) => (value) => {
1001
+ if (value === void 0) return;
1002
+ gameObject.setFaces(gameObject.showTop, value, gameObject.showRight);
1003
+ },
1004
+ showRight: (gameObject) => (value) => {
1005
+ if (value === void 0) return;
1006
+ gameObject.setFaces(gameObject.showTop, gameObject.showLeft, value);
1007
+ },
1008
+ showTop: (gameObject) => (value) => {
1009
+ if (value === void 0) return;
1010
+ gameObject.setFaces(value, gameObject.showLeft, gameObject.showRight);
1011
+ }
1012
+ };
1013
+ //#endregion
1014
+ //#region src/services/setterMap/IsoBoxSetterMap.ts
1015
+ const IsoBoxSetterMap = {
1016
+ ...IsoSetterMap,
1017
+ ...ShapeSetterMap,
1018
+ ...GlobalSetterMap
1019
+ };
1020
+ //#endregion
1021
+ //#region src/components/IsoBox.vue
1022
+ const _sfc_main$9 = /*@__PURE__*/ defineComponent({
1023
+ __name: "IsoBox",
1024
+ props: {
1025
+ configuration: {},
1026
+ immediate: { type: Boolean },
1027
+ onComplete: { type: Function }
1028
+ },
1029
+ setup(__props, { emit: __emit }) {
1030
+ useInitializeGameObject((scene) => {
1031
+ const { fillLeft, fillRight, fillTop, height, size, x, y } = __props.configuration;
1032
+ const isoBox = scene.add.isobox(x, y, size, height, fillTop, fillLeft, fillRight);
1033
+ __props.onComplete?.(scene, isoBox);
1034
+ return isoBox;
1035
+ }, () => __props.configuration, __emit, IsoBoxSetterMap, __props.immediate);
1036
+ return (_ctx, _cache) => {
1037
+ return null;
1038
+ };
1039
+ }
1040
+ });
1041
+ //#endregion
1042
+ //#region src/services/setterMap/IsoTriangleSetterMap.ts
1043
+ const IsoTriangleSetterMap = {
1044
+ isReversed: (gameObject) => (value) => {
1045
+ if (value === void 0) return;
1046
+ gameObject.setReversed(value);
1047
+ },
1048
+ ...IsoSetterMap,
1049
+ ...ShapeSetterMap,
1050
+ ...GlobalSetterMap
1051
+ };
1052
+ //#endregion
1053
+ //#region src/components/IsoTriangle.vue
1054
+ const _sfc_main$10 = /*@__PURE__*/ defineComponent({
1055
+ __name: "IsoTriangle",
1056
+ props: {
1057
+ configuration: {},
1058
+ immediate: { type: Boolean },
1059
+ onComplete: { type: Function }
1060
+ },
1061
+ setup(__props, { emit: __emit }) {
1062
+ useInitializeGameObject((scene) => {
1063
+ const { fillLeft, fillRight, fillTop, height, isReversed, size, x, y } = __props.configuration;
1064
+ const isoTriangle = scene.add.isotriangle(x, y, size, height, isReversed, fillTop, fillLeft, fillRight);
1065
+ __props.onComplete?.(scene, isoTriangle);
1066
+ return isoTriangle;
1067
+ }, () => __props.configuration, __emit, IsoTriangleSetterMap, __props.immediate);
1068
+ return (_ctx, _cache) => {
1069
+ return null;
1070
+ };
1071
+ }
1072
+ });
1073
+ //#endregion
1074
+ //#region src/services/setterMap/LineSetterMap.ts
1075
+ const LineSetterMap = {
1076
+ lineWidth: (gameObject) => (value) => {
1077
+ if (value === void 0) return;
1078
+ gameObject.setLineWidth(value);
1079
+ },
1080
+ to: (gameObject) => (value) => {
1081
+ if (!value) return;
1082
+ gameObject.setTo(...value);
1083
+ },
1084
+ ...ShapeSetterMap,
1085
+ ...GlobalSetterMap
1086
+ };
1087
+ //#endregion
1088
+ //#region src/components/Line.vue
1089
+ const _sfc_main$11 = /*@__PURE__*/ defineComponent({
1090
+ __name: "Line",
1091
+ props: {
1092
+ configuration: {},
1093
+ immediate: { type: Boolean },
1094
+ onComplete: { type: Function }
1095
+ },
1096
+ setup(__props, { emit: __emit }) {
1097
+ useInitializeGameObject((scene) => {
1098
+ const { to, x, y } = __props.configuration;
1099
+ const line = scene.add.line(x, y, to?.[0], to?.[1], to?.[2], to?.[3]);
1100
+ __props.onComplete?.(scene, line);
1101
+ return line;
1102
+ }, () => __props.configuration, __emit, LineSetterMap, __props.immediate);
1103
+ return (_ctx, _cache) => {
1104
+ return null;
1105
+ };
1106
+ }
1107
+ });
1108
+ //#endregion
1109
+ //#region src/services/setterMap/components/TextureSetterMap.ts
1110
+ const TextureSetterMap = { ...BaseTextureSetterMap };
1111
+ //#endregion
1112
+ //#region src/services/setterMap/NinesliceSetterMap.ts
1113
+ const NinesliceSetterMap = {
1114
+ height: ComputedSizeSetterMap.height,
1115
+ width: ComputedSizeSetterMap.width,
1116
+ ...AlphaSingleSetterMap,
1117
+ ...SceneObjectSetterMap,
1118
+ ...OriginSetterMap,
1119
+ ...RenderNodesSetterMap,
1120
+ ...TextureSetterMap,
1121
+ ...GlobalSetterMap
1122
+ };
1123
+ //#endregion
1124
+ //#region src/components/Nineslice.vue
1125
+ const _sfc_main$12 = /*@__PURE__*/ defineComponent({
1126
+ __name: "Nineslice",
1127
+ props: {
1128
+ configuration: {},
1129
+ immediate: { type: Boolean },
1130
+ onComplete: { type: Function }
1131
+ },
1132
+ setup(__props, { emit: __emit }) {
1133
+ useInitializeGameObject((scene) => {
1134
+ const { bottomHeight, frame, height, leftWidth, rightWidth, texture, topHeight, width, x, y } = __props.configuration;
1135
+ const nineSlice = scene.add.nineslice(x ?? 0, y ?? 0, texture, frame, width, height, leftWidth, rightWidth, topHeight, bottomHeight);
1136
+ __props.onComplete?.(scene, nineSlice);
1137
+ return nineSlice;
1138
+ }, () => __props.configuration, __emit, NinesliceSetterMap, __props.immediate);
1139
+ return (_ctx, _cache) => {
1140
+ return null;
1141
+ };
1142
+ }
1143
+ });
1144
+ //#endregion
1145
+ //#region src/services/setterMap/ParticlesSetterMap.ts
1146
+ const ParticlesSetterMap = {
1147
+ config: (gameObject) => (value) => {
1148
+ if (!value) return;
1149
+ gameObject.setConfig(value);
1150
+ },
1151
+ ...AlphaSingleSetterMap,
1152
+ ...SceneObjectSetterMap,
1153
+ ...RenderNodesSetterMap,
1154
+ ...TextureSetterMap,
1155
+ ...GlobalSetterMap
1156
+ };
1157
+ //#endregion
1158
+ //#region src/components/Particles.vue
1159
+ const _sfc_main$13 = /*@__PURE__*/ defineComponent({
1160
+ __name: "Particles",
1161
+ props: {
1162
+ configuration: {},
1163
+ immediate: { type: Boolean },
1164
+ onComplete: { type: Function }
1165
+ },
1166
+ setup(__props, { emit: __emit }) {
1167
+ useInitializeGameObject((scene) => {
1168
+ const { config, texture, x, y } = __props.configuration;
1169
+ const particles = scene.add.particles(x ?? 0, y ?? 0, texture, config);
1170
+ __props.onComplete?.(scene, particles);
1171
+ return particles;
1172
+ }, () => __props.configuration, __emit, ParticlesSetterMap, __props.immediate);
1173
+ return (_ctx, _cache) => {
1174
+ return null;
1175
+ };
1176
+ }
1177
+ });
1178
+ //#endregion
1179
+ //#region src/services/setterMap/components/PathFollowerComponentSetterMap.ts
1180
+ const PathFollowerComponentSetterMap = { path: (gameObject) => (value) => {
1181
+ if (!value) return;
1182
+ gameObject.setPath(value);
1183
+ } };
1184
+ //#endregion
1185
+ //#region src/services/setterMap/PathFollowerSetterMap.ts
1186
+ const PathFollowerSetterMap = {
1187
+ ...RenderableSetterMap,
1188
+ ...FlipSetterMap,
1189
+ ...PathFollowerComponentSetterMap,
1190
+ ...SizeSetterMap,
1191
+ ...TextureSetterMap
1192
+ };
1193
+ //#endregion
1194
+ //#region src/components/PathFollower.vue
1195
+ const _sfc_main$14 = /*@__PURE__*/ defineComponent({
1196
+ __name: "PathFollower",
1197
+ props: {
1198
+ configuration: {},
1199
+ onComplete: { type: Function }
1200
+ },
1201
+ setup(__props, { emit: __emit }) {
1202
+ useInitializeGameObject((scene) => {
1203
+ const { frame, path, texture, x, y } = __props.configuration;
1204
+ const pathFollower = scene.add.follower(path, x ?? 0, y ?? 0, texture, frame);
1205
+ __props.onComplete?.(scene, pathFollower);
1206
+ return pathFollower;
1207
+ }, () => __props.configuration, __emit, PathFollowerSetterMap);
1208
+ return (_ctx, _cache) => {
1209
+ return null;
1210
+ };
1211
+ }
1212
+ });
1213
+ //#endregion
1214
+ //#region src/services/setterMap/PolygonSetterMap.ts
1215
+ const PolygonSetterMap = {
1216
+ points: (gameObject) => (value) => {
1217
+ if (!value) return;
1218
+ gameObject.setTo(value);
1219
+ },
1220
+ ...ShapeSetterMap,
1221
+ ...GlobalSetterMap
1222
+ };
1223
+ //#endregion
1224
+ //#region src/components/Polygon.vue
1225
+ const _sfc_main$15 = /*@__PURE__*/ defineComponent({
1226
+ __name: "Polygon",
1227
+ props: {
1228
+ configuration: {},
1229
+ immediate: { type: Boolean },
1230
+ onComplete: { type: Function }
1231
+ },
1232
+ setup(__props, { emit: __emit }) {
1233
+ useInitializeGameObject((scene) => {
1234
+ const { alpha, fillColor, points, x, y } = __props.configuration;
1235
+ const polygon = scene.add.polygon(x, y, points, fillColor, alpha);
1236
+ __props.onComplete?.(scene, polygon);
1237
+ return polygon;
1238
+ }, () => __props.configuration, __emit, PolygonSetterMap, __props.immediate);
1239
+ return (_ctx, _cache) => {
1240
+ return null;
1241
+ };
1242
+ }
1243
+ });
1244
+ //#endregion
1245
+ //#region src/services/setterMap/RectangleSetterMap.ts
1246
+ const RectangleSetterMap = {
1247
+ height: ComputedSizeSetterMap.height,
1248
+ width: ComputedSizeSetterMap.width,
1249
+ ...ShapeSetterMap,
1250
+ ...GlobalSetterMap
1251
+ };
1252
+ //#endregion
1253
+ //#region src/components/Rectangle.vue
1254
+ const _sfc_main$16 = /*@__PURE__*/ defineComponent({
1255
+ __name: "Rectangle",
1256
+ props: {
1257
+ configuration: {},
1258
+ immediate: { type: Boolean },
1259
+ onComplete: { type: Function }
1260
+ },
1261
+ setup(__props, { emit: __emit }) {
1262
+ useInitializeGameObject((scene) => {
1263
+ const { alpha, fillColor, height, width, x, y } = __props.configuration;
1264
+ const rectangle = scene.add.rectangle(x, y, width, height, fillColor, alpha);
1265
+ __props.onComplete?.(scene, rectangle);
1266
+ return rectangle;
1267
+ }, () => __props.configuration, __emit, RectangleSetterMap, __props.immediate);
1268
+ return (_ctx, _cache) => {
1269
+ return null;
1270
+ };
1271
+ }
1272
+ });
1273
+ //#endregion
1274
+ //#region src/services/setterMap/RenderTextureSetterMap.ts
1275
+ const RenderTextureSetterMap = {
1276
+ ...AlphaSetterMap,
1277
+ ...SceneObjectSetterMap,
1278
+ ...FlipSetterMap,
1279
+ ...OriginSetterMap,
1280
+ ...RenderNodesSetterMap,
1281
+ ...SizeSetterMap,
1282
+ ...TintSetterMap,
1283
+ ...GlobalSetterMap
1284
+ };
1285
+ //#endregion
1286
+ //#region src/components/RenderTexture.vue
1287
+ const _sfc_main$17 = /*@__PURE__*/ defineComponent({
1288
+ __name: "RenderTexture",
1289
+ props: {
1290
+ configuration: {},
1291
+ immediate: { type: Boolean },
1292
+ onComplete: { type: Function }
1293
+ },
1294
+ setup(__props, { emit: __emit }) {
1295
+ useInitializeGameObject((scene) => {
1296
+ const { height, width, x, y } = __props.configuration;
1297
+ const renderTexture = scene.add.renderTexture(x ?? 0, y ?? 0, width, height);
1298
+ __props.onComplete?.(scene, renderTexture);
1299
+ return renderTexture;
1300
+ }, () => __props.configuration, __emit, RenderTextureSetterMap, __props.immediate);
1301
+ return (_ctx, _cache) => {
1302
+ return null;
1303
+ };
1304
+ }
1305
+ });
1306
+ //#endregion
1307
+ //#region src/services/hooks/resetLifecycleListeners.ts
1308
+ const resetLifecycleListeners = (scene, lifecycle) => {
1309
+ const listenersMap = ExternalSceneStore.lifecycleListenersMap.get(lifecycle);
1310
+ if (!listenersMap?.has(scene.scene.key)) return;
1311
+ listenersMap.set(scene.scene.key, []);
1312
+ };
1313
+ //#endregion
1314
+ //#region src/services/hooks/runLifecycleListeners.ts
1315
+ const runLifecycleListeners = (scene, lifecycle, isReset = true) => {
1316
+ const listenersMap = ExternalSceneStore.lifecycleListenersMap.get(lifecycle);
1317
+ if (!listenersMap) return;
1318
+ const listeners = listenersMap.get(scene.scene.key);
1319
+ if (!listeners) return;
1320
+ for (const listener of listeners) listener(scene);
1321
+ if (isReset) resetLifecycleListeners(scene, lifecycle);
1322
+ };
1323
+ //#endregion
1324
+ //#region src/services/hooks/runSceneShutdown.ts
1325
+ const runSceneShutdown = (scene) => {
1326
+ resetLifecycleListeners(scene, "Update");
1327
+ resetLifecycleListeners(scene, "NextTick");
1328
+ runLifecycleListeners(scene, "Shutdown");
1329
+ ExternalSceneStore.sceneReadyMap.set(scene.scene.key, false);
1330
+ };
1331
+ //#endregion
1332
+ //#region src/services/shared/createSceneClass.ts
1333
+ const createSceneClass = (key, hooks = {}) => class extends Scene {
1334
+ constructor() {
1335
+ super({ key });
1336
+ }
1337
+ create() {
1338
+ hooks.onCreate?.(this);
1339
+ runLifecycleListeners(this, "Create");
1340
+ }
1341
+ init() {
1342
+ hooks.onInit?.(this);
1343
+ runLifecycleListeners(this, "Init");
1344
+ }
1345
+ preload() {
1346
+ hooks.onPreload?.(this);
1347
+ runLifecycleListeners(this, "Preload");
1348
+ }
1349
+ update(time, delta) {
1350
+ hooks.onUpdate?.(this, time, delta);
1351
+ runLifecycleListeners(this, "Update", false);
1352
+ runLifecycleListeners(this, "NextTick");
1353
+ }
1354
+ };
1355
+ //#endregion
1356
+ //#region src/store/camera.ts
1357
+ const useCameraStore = defineStore("phaser/camera", () => {
1358
+ const isFading = ref(false);
1359
+ const fadeIn = (scene, ...args) => {
1360
+ isFading.value = true;
1361
+ scene.cameras.main.fadeIn(...args);
1362
+ };
1363
+ const fadeOut = (scene, ...args) => {
1364
+ isFading.value = true;
1365
+ scene.cameras.main.fadeOut(...args);
1366
+ };
1367
+ return {
1368
+ fadeIn,
1369
+ fadeOut,
1370
+ isFading
1371
+ };
1372
+ });
1373
+ //#endregion
1374
+ //#region src/store/input.ts
1375
+ const useInputStore = defineStore("phaser/input", () => {
1376
+ return { isInputActive: ref(false) };
1377
+ });
1378
+ //#endregion
1379
+ //#region src/components/Scene.vue
1380
+ const _sfc_main$18 = /*@__PURE__*/ defineComponent({
1381
+ __name: "Scene",
1382
+ props: {
1383
+ autoStart: { type: Boolean },
1384
+ sceneKey: {}
1385
+ },
1386
+ emits: [
1387
+ "create",
1388
+ "init",
1389
+ "preload",
1390
+ "shutdown",
1391
+ "update"
1392
+ ],
1393
+ setup(__props, { emit: __emit }) {
1394
+ const emit = __emit;
1395
+ const phaserStore = usePhaserStore();
1396
+ const { isSameScene, switchToScene } = phaserStore;
1397
+ const cameraStore = useCameraStore();
1398
+ const { isFading } = storeToRefs(cameraStore);
1399
+ const inputStore = useInputStore();
1400
+ const { isInputActive } = storeToRefs(inputStore);
1401
+ const { parallelSceneKeys } = storeToRefs(phaserStore);
1402
+ const isActive = computed(() => isSameScene(__props.sceneKey) || parallelSceneKeys.value.includes(__props.sceneKey));
1403
+ const fadeStartListener = () => {
1404
+ isInputActive.value = false;
1405
+ };
1406
+ const fadeInCompleteListener = () => {
1407
+ isFading.value = false;
1408
+ isInputActive.value = true;
1409
+ };
1410
+ const fadeOutCompleteListener = () => {
1411
+ isFading.value = false;
1412
+ };
1413
+ const cameraFadeListeners = [
1414
+ [Cameras.Scene2D.Events.FADE_IN_START, fadeStartListener],
1415
+ [Cameras.Scene2D.Events.FADE_IN_COMPLETE, fadeInCompleteListener],
1416
+ [Cameras.Scene2D.Events.FADE_OUT_START, fadeStartListener],
1417
+ [Cameras.Scene2D.Events.FADE_OUT_COMPLETE, fadeOutCompleteListener]
1418
+ ];
1419
+ const NewScene = createSceneClass(__props.sceneKey, {
1420
+ onCreate: (scene) => {
1421
+ emit("create", scene);
1422
+ for (const [event, listener] of cameraFadeListeners) scene.cameras.main.on(event, listener);
1423
+ isInputActive.value = true;
1424
+ },
1425
+ onInit: (scene) => emit("init", scene),
1426
+ onPreload: (scene) => emit("preload", scene),
1427
+ onUpdate: (scene, time, delta) => emit("update", scene, time, delta)
1428
+ });
1429
+ const readyListener = () => {
1430
+ ExternalSceneStore.sceneReadyMap.set(__props.sceneKey, true);
1431
+ };
1432
+ const shutdownListener = () => {
1433
+ const scene = getScene(__props.sceneKey);
1434
+ runSceneShutdown(scene);
1435
+ for (const [event, listener] of cameraFadeListeners) scene.cameras.main.off(event, listener);
1436
+ emit("shutdown", scene);
1437
+ };
1438
+ onMounted(async () => {
1439
+ const scene = useGame().scene.add(__props.sceneKey, NewScene);
1440
+ if (!scene) {
1441
+ console.error(`Failed to add scene: ${__props.sceneKey}`);
1442
+ return;
1443
+ }
1444
+ scene.events.on(Scenes.Events.READY, readyListener);
1445
+ scene.events.on(Scenes.Events.SHUTDOWN, shutdownListener);
1446
+ if (__props.autoStart) await switchToScene(__props.sceneKey);
1447
+ });
1448
+ onUnmounted(() => {
1449
+ const game = useGame();
1450
+ const scene = getScene(__props.sceneKey);
1451
+ scene.events.off(Scenes.Events.READY, readyListener);
1452
+ scene.events.off(Scenes.Events.SHUTDOWN, shutdownListener);
1453
+ game.scene.remove(__props.sceneKey);
1454
+ });
1455
+ provide(InjectionKeyMap.SceneKey, __props.sceneKey);
1456
+ return (_ctx, _cache) => {
1457
+ return isActive.value ? renderSlot(_ctx.$slots, "default", {}, void 0, void 0, 0) : createCommentVNode("v-if", true);
1458
+ };
1459
+ }
1460
+ });
1461
+ //#endregion
1462
+ //#region src/services/setterMap/shared/AnimationSetterMap.ts
1463
+ const completionListeners = /* @__PURE__ */ new WeakMap();
1464
+ const AnimationSetterMap = {
1465
+ animations: (gameObject, emit) => (configurations) => {
1466
+ if (!(configurations && configurations.length > 0)) return;
1467
+ const listeners = completionListeners.get(gameObject) ?? /* @__PURE__ */ new Map();
1468
+ completionListeners.set(gameObject, listeners);
1469
+ for (const configuration of configurations) {
1470
+ if (!configuration.key) continue;
1471
+ const event = `${ANIMATION_COMPLETE_EVENT_PREFIX}${configuration.key}`;
1472
+ const previousListener = listeners.get(event);
1473
+ if (previousListener) gameObject.off(event, previousListener);
1474
+ const listener = () => {
1475
+ emit(event);
1476
+ };
1477
+ listeners.set(event, listener);
1478
+ gameObject.once(event, listener);
1479
+ if (gameObject.scene.anims.exists(configuration.key)) continue;
1480
+ if (!gameObject.scene.anims.create(configuration)) throw new InvalidOperationError(Operation.Create, "Animation", configuration.key);
1481
+ }
1482
+ },
1483
+ playAnimationKey: (gameObject) => (value) => {
1484
+ if (value === void 0) {
1485
+ gameObject.stop();
1486
+ return;
1487
+ }
1488
+ gameObject.play(value);
1489
+ }
1490
+ };
1491
+ //#endregion
1492
+ //#region src/services/setterMap/SpriteSetterMap.ts
1493
+ const SpriteSetterMap = {
1494
+ ...AlphaSetterMap,
1495
+ ...SceneObjectSetterMap,
1496
+ ...FlipSetterMap,
1497
+ ...OriginSetterMap,
1498
+ ...RenderNodesSetterMap,
1499
+ ...SizeSetterMap,
1500
+ ...TextureSetterMap,
1501
+ ...TintSetterMap,
1502
+ ...AnimationSetterMap,
1503
+ ...GlobalSetterMap
1504
+ };
1505
+ //#endregion
1506
+ //#region src/components/Sprite.vue
1507
+ const _sfc_main$19 = /*@__PURE__*/ defineComponent({
1508
+ __name: "Sprite",
1509
+ props: {
1510
+ configuration: {},
1511
+ immediate: { type: Boolean },
1512
+ onComplete: { type: Function }
1513
+ },
1514
+ setup(__props, { emit: __emit }) {
1515
+ useInitializeGameObject((scene) => {
1516
+ const { frame, texture, x, y } = __props.configuration;
1517
+ const sprite = scene.add.sprite(x ?? 0, y ?? 0, texture, frame);
1518
+ __props.onComplete?.(scene, sprite);
1519
+ return sprite;
1520
+ }, () => __props.configuration, __emit, SpriteSetterMap, __props.immediate);
1521
+ return (_ctx, _cache) => {
1522
+ return null;
1523
+ };
1524
+ }
1525
+ });
1526
+ //#endregion
1527
+ //#region src/services/setterMap/StarSetterMap.ts
1528
+ const StarSetterMap = {
1529
+ innerRadius: (gameObject) => (value) => {
1530
+ if (value === void 0) return;
1531
+ gameObject.setInnerRadius(value);
1532
+ },
1533
+ outerRadius: (gameObject) => (value) => {
1534
+ if (value === void 0) return;
1535
+ gameObject.setOuterRadius(value);
1536
+ },
1537
+ points: (gameObject) => (value) => {
1538
+ if (value === void 0) return;
1539
+ gameObject.setPoints(value);
1540
+ },
1541
+ ...ShapeSetterMap,
1542
+ ...GlobalSetterMap
1543
+ };
1544
+ //#endregion
1545
+ //#region src/components/Star.vue
1546
+ const _sfc_main$20 = /*@__PURE__*/ defineComponent({
1547
+ __name: "Star",
1548
+ props: {
1549
+ configuration: {},
1550
+ immediate: { type: Boolean },
1551
+ onComplete: { type: Function }
1552
+ },
1553
+ setup(__props, { emit: __emit }) {
1554
+ useInitializeGameObject((scene) => {
1555
+ const { alpha, fillColor, innerRadius, outerRadius, points, x, y } = __props.configuration;
1556
+ const star = scene.add.star(x, y, points, innerRadius, outerRadius, fillColor, alpha);
1557
+ __props.onComplete?.(scene, star);
1558
+ return star;
1559
+ }, () => __props.configuration, __emit, StarSetterMap, __props.immediate);
1560
+ return (_ctx, _cache) => {
1561
+ return null;
1562
+ };
1563
+ }
1564
+ });
1565
+ //#endregion
1566
+ //#region src/services/setterMap/TextSetterMap.ts
1567
+ const TextSetterMap = {
1568
+ padding: (gameObject) => (value) => {
1569
+ if (!value) return;
1570
+ gameObject.setPadding(value);
1571
+ },
1572
+ style: (gameObject) => (value) => {
1573
+ if (!value) return;
1574
+ gameObject.setStyle(value);
1575
+ },
1576
+ text: (gameObject, emit) => (value) => {
1577
+ if (value === void 0) return;
1578
+ gameObject.setText(value);
1579
+ emit("update:width", gameObject.width);
1580
+ emit("update:displayWidth", gameObject.displayWidth);
1581
+ },
1582
+ ...RenderableSetterMap,
1583
+ ...ComputedSizeSetterMap,
1584
+ ...FlipSetterMap
1585
+ };
1586
+ //#endregion
1587
+ //#region src/store/text.ts
1588
+ const useTextStore = defineStore("phaser/text", () => {
1589
+ return { defaultTextStyle: ref() };
1590
+ });
1591
+ //#endregion
1592
+ //#region src/components/Text.vue
1593
+ const _sfc_main$21 = /*@__PURE__*/ defineComponent({
1594
+ __name: "Text",
1595
+ props: {
1596
+ configuration: {},
1597
+ immediate: { type: Boolean }
1598
+ },
1599
+ setup(__props, { emit: __emit }) {
1600
+ const emit = __emit;
1601
+ const textStore = useTextStore();
1602
+ const { defaultTextStyle } = storeToRefs(textStore);
1603
+ useInitializeGameObject((scene) => {
1604
+ const { style, text, x, y } = __props.configuration;
1605
+ return scene.add.text(x ?? 0, y ?? 0, text, {
1606
+ ...defaultTextStyle.value,
1607
+ ...style
1608
+ });
1609
+ }, () => __props.configuration, emit, TextSetterMap, __props.immediate);
1610
+ return (_ctx, _cache) => {
1611
+ return null;
1612
+ };
1613
+ }
1614
+ });
1615
+ //#endregion
1616
+ //#region src/services/setterMap/TileSpriteSetterMap.ts
1617
+ const TileSpriteSetterMap = {
1618
+ ...RenderableSetterMap,
1619
+ ...ComputedSizeSetterMap,
1620
+ ...FlipSetterMap,
1621
+ ...TextureSetterMap
1622
+ };
1623
+ //#endregion
1624
+ //#region src/components/TileSprite.vue
1625
+ const _sfc_main$22 = /*@__PURE__*/ defineComponent({
1626
+ __name: "TileSprite",
1627
+ props: {
1628
+ configuration: {},
1629
+ immediate: { type: Boolean },
1630
+ onComplete: { type: Function }
1631
+ },
1632
+ setup(__props, { emit: __emit }) {
1633
+ useInitializeGameObject((scene) => {
1634
+ const { frame, height, texture, width, x, y } = __props.configuration;
1635
+ const tileSprite = scene.add.tileSprite(x ?? 0, y ?? 0, width ?? 0, height ?? 0, texture, frame);
1636
+ __props.onComplete?.(scene, tileSprite);
1637
+ return tileSprite;
1638
+ }, () => __props.configuration, __emit, TileSpriteSetterMap, __props.immediate);
1639
+ return (_ctx, _cache) => {
1640
+ return null;
1641
+ };
1642
+ }
1643
+ });
1644
+ //#endregion
1645
+ //#region src/components/Tilemap.vue
1646
+ const _sfc_main$23 = /*@__PURE__*/ defineComponent({
1647
+ __name: "Tilemap",
1648
+ props: {
1649
+ configuration: {},
1650
+ onComplete: { type: Function }
1651
+ },
1652
+ setup(__props) {
1653
+ const sceneKey = useInjectSceneKey();
1654
+ const tilemap = shallowRef();
1655
+ onCreate((newScene) => {
1656
+ tilemap.value = newScene.make.tilemap(__props.configuration);
1657
+ __props.onComplete?.(newScene, tilemap.value);
1658
+ });
1659
+ watch(() => __props.configuration.key, (newKey) => {
1660
+ const scene = getScene(sceneKey);
1661
+ const oldTilemap = tilemap.value;
1662
+ if (newKey) {
1663
+ tilemap.value = scene.make.tilemap(__props.configuration);
1664
+ __props.onComplete?.(scene, tilemap.value);
1665
+ } else tilemap.value = void 0;
1666
+ if (oldTilemap) oldTilemap.destroy();
1667
+ });
1668
+ onUnmounted(() => {
1669
+ if (!tilemap.value) return;
1670
+ tilemap.value.destroy();
1671
+ });
1672
+ return (_ctx, _cache) => {
1673
+ return renderSlot(_ctx.$slots, "default");
1674
+ };
1675
+ }
1676
+ });
1677
+ //#endregion
1678
+ //#region src/services/setterMap/TriangleSetterMap.ts
1679
+ const TriangleSetterMap = {
1680
+ to: (gameObject) => (value) => {
1681
+ if (!value) return;
1682
+ gameObject.setTo(...value);
1683
+ },
1684
+ ...ShapeSetterMap,
1685
+ ...GlobalSetterMap
1686
+ };
1687
+ //#endregion
1688
+ //#region src/components/Triangle.vue
1689
+ const _sfc_main$24 = /*@__PURE__*/ defineComponent({
1690
+ __name: "Triangle",
1691
+ props: {
1692
+ configuration: {},
1693
+ immediate: { type: Boolean },
1694
+ onComplete: { type: Function }
1695
+ },
1696
+ setup(__props, { emit: __emit }) {
1697
+ useInitializeGameObject((scene) => {
1698
+ const { alpha, fillColor, to, x, y } = __props.configuration;
1699
+ const triangle = scene.add.triangle(x, y, to?.[0], to?.[1], to?.[2], to?.[3], to?.[4], to?.[5], fillColor, alpha);
1700
+ __props.onComplete?.(scene, triangle);
1701
+ return triangle;
1702
+ }, () => __props.configuration, __emit, TriangleSetterMap, __props.immediate);
1703
+ return (_ctx, _cache) => {
1704
+ return null;
1705
+ };
1706
+ }
1707
+ });
1708
+ //#endregion
1709
+ //#region src/services/setterMap/VideoSetterMap.ts
1710
+ const VideoSetterMap = {
1711
+ key: (gameObject) => (value) => {
1712
+ if (!value) return;
1713
+ gameObject.changeSource(value);
1714
+ },
1715
+ muted: (gameObject) => (value) => {
1716
+ gameObject.setMute(value);
1717
+ },
1718
+ volume: (gameObject) => (value) => {
1719
+ gameObject.setVolume(value);
1720
+ },
1721
+ ...AlphaSetterMap,
1722
+ ...SceneObjectSetterMap,
1723
+ ...FlipSetterMap,
1724
+ ...OriginSetterMap,
1725
+ ...RenderNodesSetterMap,
1726
+ ...TextureCropSetterMap,
1727
+ ...TintSetterMap,
1728
+ ...GlobalSetterMap
1729
+ };
1730
+ //#endregion
1731
+ //#region src/components/Video.vue
1732
+ const _sfc_main$25 = /*@__PURE__*/ defineComponent({
1733
+ __name: "Video",
1734
+ props: {
1735
+ configuration: {},
1736
+ immediate: { type: Boolean },
1737
+ onComplete: { type: Function }
1738
+ },
1739
+ setup(__props, { emit: __emit }) {
1740
+ useInitializeGameObject((scene) => {
1741
+ const { key, x, y } = __props.configuration;
1742
+ const video = scene.add.video(x ?? 0, y ?? 0, key);
1743
+ __props.onComplete?.(scene, video);
1744
+ return video;
1745
+ }, () => __props.configuration, __emit, VideoSetterMap, __props.immediate);
1746
+ return (_ctx, _cache) => {
1747
+ return null;
1748
+ };
1749
+ }
1750
+ });
1751
+ //#endregion
1752
+ //#region src/services/setterMap/ZoneSetterMap.ts
1753
+ const ZoneSetterMap = {
1754
+ ...ComputedSizeSetterMap,
1755
+ ...DepthSetterMap,
1756
+ ...OriginSetterMap,
1757
+ ...ScrollFactorSetterMap,
1758
+ ...TransformSetterMap,
1759
+ ...VisibleSetterMap,
1760
+ ...GlobalSetterMap
1761
+ };
1762
+ //#endregion
1763
+ //#region src/components/Zone.vue
1764
+ const _sfc_main$26 = /*@__PURE__*/ defineComponent({
1765
+ __name: "Zone",
1766
+ props: { configuration: {} },
1767
+ setup(__props, { emit: __emit }) {
1768
+ useInitializeGameObject((scene) => {
1769
+ const { height, width, x, y } = __props.configuration;
1770
+ return scene.add.zone(x, y, width, height);
1771
+ }, () => __props.configuration, __emit, ZoneSetterMap);
1772
+ return (_ctx, _cache) => {
1773
+ return null;
1774
+ };
1775
+ }
1776
+ });
1777
+ //#endregion
1778
+ //#region src/hooks/onShutdown.ts
1779
+ const onShutdown = (...args) => {
1780
+ pushListener("Shutdown", ...args);
1781
+ };
1782
+ //#endregion
1783
+ //#region src/composables/useAnimations.ts
1784
+ const useAnimations = (createConfigurations, immediate) => {
1785
+ const animations = ref([]);
1786
+ if (immediate) {
1787
+ const sceneKey = useInjectSceneKey();
1788
+ animations.value = createConfigurations(getScene(sceneKey));
1789
+ } else onNextTick((scene) => {
1790
+ animations.value = createConfigurations(scene);
1791
+ });
1792
+ onShutdown((scene) => {
1793
+ for (const { key } of animations.value) {
1794
+ if (!key) continue;
1795
+ scene.anims.remove(key);
1796
+ }
1797
+ });
1798
+ return animations;
1799
+ };
1800
+ //#endregion
1801
+ //#region src/composables/useTween.ts
1802
+ const useTween = (tween, newTween) => {
1803
+ tween.value = {
1804
+ ...newTween,
1805
+ onComplete: (...args) => {
1806
+ tween.value = void 0;
1807
+ newTween.onComplete?.(...args);
1808
+ }
1809
+ };
1810
+ };
1811
+ //#endregion
1812
+ //#region src/hooks/onInit.ts
1813
+ const onInit = (...args) => {
1814
+ pushListener("Init", ...args);
1815
+ };
1816
+ //#endregion
1817
+ //#region src/hooks/onPreload.ts
1818
+ const onPreload = (...args) => {
1819
+ pushListener("Preload", ...args);
1820
+ };
1821
+ //#endregion
1822
+ //#region src/hooks/onUpdate.ts
1823
+ const onUpdate = (...args) => {
1824
+ pushListener("Update", ...args);
1825
+ };
1826
+ //#endregion
1827
+ //#region src/models/plugins/TilemapFile.ts
1828
+ const JSONFile = Loader.FileTypes.JSONFile;
1829
+ var TilemapFile = class extends JSONFile {};
1830
+ //#endregion
1831
+ //#region src/services/shared/sleepScene.ts
1832
+ const sleepScene = (scene, durationMs) => new Promise((resolve) => {
1833
+ const settle = () => {
1834
+ scene.events.off(Scenes.Events.SHUTDOWN, settle);
1835
+ resolve();
1836
+ };
1837
+ scene.time.delayedCall(durationMs, settle);
1838
+ scene.events.once(Scenes.Events.SHUTDOWN, settle);
1839
+ });
1840
+ //#endregion
1841
+ export { ANIMATION_COMPLETE_EVENT_PREFIX, AlphaSetterMap, AlphaSingleSetterMap, AnimationSetterMap, _sfc_main as Arc, ArcSetterMap, BaseTextureSetterMap, _sfc_main$1 as BitmapText, BitmapTextSetterMap, BlendModeSetterMap, _sfc_main$2 as Circle, ComputedSizeSetterMap, _sfc_main$3 as Container, ContainerSetterMap, _sfc_main$4 as Curve, CurveSetterMap, DepthSetterMap, DisplaySizeSetterMap, EVENT_PREFIX, _sfc_main$5 as Ellipse, EllipseSetterMap, ExternalSceneStore, FlipSetterMap, _sfc_main$6 as Game, GameObjectEventMap, GameObjectSetterMap, GlobalSetterMap, _sfc_main$7 as Graphics, GraphicsSetterMap, _sfc_main$8 as Image, ImageSetterMap, InjectionKeyMap, _sfc_main$9 as IsoBox, IsoBoxSetterMap, IsoSetterMap, _sfc_main$10 as IsoTriangle, IsoTriangleSetterMap, Lifecycle, _sfc_main$11 as Line, LineSetterMap, MaskSetterMap, _sfc_main$12 as Nineslice, NinesliceSetterMap, OriginSetterMap, _sfc_main$13 as Particles, ParticlesSetterMap, _sfc_main$14 as PathFollower, PathFollowerComponentSetterMap, PathFollowerSetterMap, _sfc_main$15 as Polygon, PolygonSetterMap, _sfc_main$16 as Rectangle, RectangleSetterMap, RenderNodesSetterMap, _sfc_main$17 as RenderTexture, RenderTextureSetterMap, RenderableSetterMap, _sfc_main$18 as Scene, SceneObjectSetterMap, ScrollFactorSetterMap, ShapeSetterMap, SizeSetterMap, _sfc_main$19 as Sprite, SpriteSetterMap, _sfc_main$20 as Star, StarSetterMap, TILEMAP_TILED_JSON_EXTERNAL_KEY, _sfc_main$21 as Text, TextSetterMap, TextureCropSetterMap, TextureSetterMap, _sfc_main$22 as TileSprite, TileSpriteSetterMap, TiledJSONExternalFile, _sfc_main$23 as Tilemap, TilemapFile, TilesetFile, TintSetterMap, TransformSetterMap, _sfc_main$24 as Triangle, TriangleSetterMap, TweenSetterMap, _sfc_main$25 as Video, VideoSetterMap, VisibleSetterMap, _sfc_main$26 as Zone, ZoneSetterMap, checkIsEvent, createSceneClass, getDepthInsertIndex, getEventName, getInitializeGameObjectLifecycleHook, getScene, getUpdateEvent, onCreate, onInit, onNextTick, onPreload, onShutdown, onUpdate, pushGameObject, pushListener, registerTiledJSONExternalLoader, resetLifecycleListeners, runLifecycleListeners, runSceneShutdown, sleepScene, useAnimations, useCameraStore, useGame, useInitializeGameObject, useInitializeGameObjectEvents, useInitializeGameObjectSetters, useInjectSceneKey, useInputStore, usePhaserStore, useTextStore, useTween };