vue-phaserjs 4.2.0 → 4.3.3

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