vue-phaserjs 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +434 -434
  2. package/dist/index.js +11 -24
  3. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, inject, nextTick, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, toValue, useTemplateRef, watch } from "vue";
2
- import { ID_SEPARATOR, InvalidOperationError, NotFoundError, NotInitializedError, Operation, checkIsPlainObject, takeOne, toKebabCase } from "@esposter/shared";
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, checkIsPlainObject, getOrCreate, takeOne, toKebabCase } from "@esposter/shared";
3
3
  import ClickOutside from "phaser4-rex-plugins/plugins/clickoutside.js";
4
4
  import { Animations, Cameras, Core, Game, Loader, Scene, Scenes, Tilemaps, Tweens, Utils } from "phaser";
5
5
  import { defineStore, storeToRefs } from "pinia";
@@ -50,17 +50,10 @@ const useInitializeGameObjectEvents = () => {
50
50
  if ("eventIndex" in context) takeOne(args).stopPropagation = takeOne(args, context.eventIndex).stopPropagation;
51
51
  emit(gameObjectEvent, ...args);
52
52
  };
53
- if (gameObjectEvent === "clickoutside") {
54
- const clickOutside = new ClickOutside(gameObject);
55
- clickOutside.on(gameObjectEvent, eventListener);
56
- eventStopHandles.push(() => {
57
- clickOutside.off(gameObjectEvent, eventListener);
58
- });
59
- continue;
60
- }
61
- gameObject.on(gameObjectEvent, eventListener);
53
+ const emitter = gameObjectEvent === "clickoutside" ? new ClickOutside(gameObject) : gameObject;
54
+ emitter.on(gameObjectEvent, eventListener);
62
55
  eventStopHandles.push(() => {
63
- gameObject.off(gameObjectEvent, eventListener);
56
+ emitter.off(gameObjectEvent, eventListener);
64
57
  });
65
58
  }
66
59
  };
@@ -103,14 +96,8 @@ const ExternalSceneStore = {
103
96
  //#region src/services/hooks/pushListener.ts
104
97
  const pushListener = (lifecycle, listener, key) => {
105
98
  const sceneKey = key ?? useInjectSceneKey();
106
- const listenersMap = ExternalSceneStore.lifecycleListenersMap.get(lifecycle);
107
- if (!listenersMap) {
108
- ExternalSceneStore.lifecycleListenersMap.set(lifecycle, /* @__PURE__ */ new Map([[sceneKey, [listener]]]));
109
- return;
110
- }
111
- const listeners = listenersMap.get(sceneKey);
112
- if (listeners) listeners.push(listener);
113
- else listenersMap.set(sceneKey, [listener]);
99
+ const listenersMap = getOrCreate(ExternalSceneStore.lifecycleListenersMap, lifecycle, () => /* @__PURE__ */ new Map());
100
+ getOrCreate(listenersMap, sceneKey, () => []).push(listener);
114
101
  };
115
102
  //#endregion
116
103
  //#region src/hooks/onNextTick.ts
@@ -704,7 +691,7 @@ const _sfc_main$23 = /*@__PURE__*/ defineComponent({
704
691
  },
705
692
  setup(__props) {
706
693
  const sceneKey = useInjectSceneKey();
707
- const tilemap = ref();
694
+ const tilemap = shallowRef();
708
695
  onCreate((newScene) => {
709
696
  tilemap.value = newScene.make.tilemap(__props.configuration);
710
697
  __props.onComplete?.(newScene, tilemap.value);
@@ -1518,7 +1505,7 @@ var TiledJSONExternalFile = class extends MultiFile {
1518
1505
  const loader = this.loader;
1519
1506
  const files = this.files;
1520
1507
  this.complete = true;
1521
- for (const tilesetFile of tilesetFiles) {
1508
+ await Promise.all(tilesetFiles.map(async (tilesetFile) => {
1522
1509
  const responseText = tilesetFile.xhrLoader?.responseText;
1523
1510
  if (!responseText) throw new InvalidOperationError(Operation.Read, this.addToCache.name, tilesetFile.key);
1524
1511
  const responseData = await parseXmlString(responseText);
@@ -1529,7 +1516,7 @@ var TiledJSONExternalFile = class extends MultiFile {
1529
1516
  imagewidth: tilesetData.image.width,
1530
1517
  source: void 0
1531
1518
  });
1532
- }
1519
+ }));
1533
1520
  loader.cacheManager.tilemap.add(tilemapKey, {
1534
1521
  data: tilemapData,
1535
1522
  format: Tilemaps.Formats.TILED_JSON
@@ -1706,7 +1693,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
1706
1693
  },
1707
1694
  setup(__props, { emit: __emit }) {
1708
1695
  const emit = __emit;
1709
- const container = ref();
1696
+ const container = shallowRef();
1710
1697
  useInitializeGameObject((scene) => {
1711
1698
  const { children, x, y } = __props.configuration;
1712
1699
  container.value = scene.add.container(x, y, children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-phaserjs",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "A component library to integrate Phaser Framework with Vue.",
5
5
  "keywords": [
6
6
  "component-library",
@@ -55,18 +55,18 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@arethetypeswrong/core": "^0.18.5",
58
- "@esposter/configuration": "3.2.0",
58
+ "@esposter/configuration": "3.4.0",
59
59
  "@vue/test-utils": "^2.5.1",
60
60
  "publint": "^0.3.24",
61
61
  "tsdown": "^0.23.0",
62
62
  "type-fest": "^5.10.0",
63
63
  "typedoc": "^0.28.20",
64
- "vitest": "^5.0.1",
64
+ "vitest": "^5.0.2",
65
65
  "vue-tsc": "^3.3.11"
66
66
  },
67
67
  "peerDependencies": {
68
- "@esposter/shared": "3.1.0",
69
- "parse-tmx": "3.1.0",
68
+ "@esposter/shared": "3.3.0",
69
+ "parse-tmx": "3.3.0",
70
70
  "phaser": "^4.2.1",
71
71
  "phaser4-rex-plugins": "^4.2.0",
72
72
  "pinia": "^4.0.3",
@@ -75,5 +75,5 @@
75
75
  "inlinedDependencies": {
76
76
  "type-fest": "5.10.0"
77
77
  },
78
- "gitHead": "bc055ed2f154eff219a355016a6b586962dbfa9c"
78
+ "gitHead": "8eed442bbd2c402cdd4a09cd286595bb8feb3951"
79
79
  }