@rpgjs/client 4.1.3 → 4.2.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/browser/{React-da18564b.js → React-f6f9b1de.js} +25 -0
  3. package/browser/index-e74a289f.js +44225 -0
  4. package/browser/manifest.json +10 -1
  5. package/browser/rpg.client.js +33 -44122
  6. package/browser/rpg.client.umd.cjs +470 -341
  7. package/lib/Effects/TransitionScene.d.ts +4 -3
  8. package/lib/Effects/TransitionScene.js +4 -2
  9. package/lib/Effects/TransitionScene.js.map +1 -1
  10. package/lib/GameEngine.d.ts +1 -1
  11. package/lib/GameEngine.js +4 -1
  12. package/lib/GameEngine.js.map +1 -1
  13. package/lib/Gui/Gui.d.ts +2 -1
  14. package/lib/Gui/Gui.js +7 -5
  15. package/lib/Gui/Gui.js.map +1 -1
  16. package/lib/Gui/React.d.ts +1 -0
  17. package/lib/Gui/React.js +23 -0
  18. package/lib/Gui/React.js.map +1 -1
  19. package/lib/Gui/Vue.js +21 -2
  20. package/lib/Gui/Vue.js.map +1 -1
  21. package/lib/KeyboardControls.d.ts +40 -14
  22. package/lib/KeyboardControls.js +42 -15
  23. package/lib/KeyboardControls.js.map +1 -1
  24. package/lib/Presets/AnimationSpritesheet.d.ts +3 -3
  25. package/lib/Presets/AnimationSpritesheet.js +7 -3
  26. package/lib/Presets/AnimationSpritesheet.js.map +1 -1
  27. package/lib/Renderer.d.ts +13 -5
  28. package/lib/Renderer.js +40 -16
  29. package/lib/Renderer.js.map +1 -1
  30. package/lib/Resources.js.map +1 -1
  31. package/lib/RpgClientEngine.d.ts +10 -4
  32. package/lib/RpgClientEngine.js +26 -17
  33. package/lib/RpgClientEngine.js.map +1 -1
  34. package/lib/Scene/Map.d.ts +4 -5
  35. package/lib/Scene/Map.js +6 -4
  36. package/lib/Scene/Map.js.map +1 -1
  37. package/lib/Scene/Scene.d.ts +7 -2
  38. package/lib/Scene/Scene.js +9 -3
  39. package/lib/Scene/Scene.js.map +1 -1
  40. package/lib/Tilemap/index.d.ts +4 -3
  41. package/lib/Tilemap/index.js +7 -3
  42. package/lib/Tilemap/index.js.map +1 -1
  43. package/lib/clientEntryPoint.js +5 -5
  44. package/lib/clientEntryPoint.js.map +1 -1
  45. package/lib/index.d.ts +3 -0
  46. package/lib/index.js +3 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/inject.d.ts +23 -0
  49. package/lib/inject.js +30 -0
  50. package/lib/inject.js.map +1 -0
  51. package/package.json +6 -6
  52. package/src/Effects/TransitionScene.ts +3 -1
  53. package/src/GameEngine.ts +2 -2
  54. package/src/Gui/Gui.ts +5 -5
  55. package/src/Gui/React.ts +26 -1
  56. package/src/Gui/Vue.ts +24 -6
  57. package/src/KeyboardControls.ts +43 -15
  58. package/src/Presets/AnimationSpritesheet.ts +9 -4
  59. package/src/Renderer.ts +44 -19
  60. package/src/Resources.ts +0 -1
  61. package/src/RpgClientEngine.ts +29 -18
  62. package/src/Scene/Map.ts +8 -7
  63. package/src/Scene/Scene.ts +8 -4
  64. package/src/Tilemap/index.ts +6 -4
  65. package/src/clientEntryPoint.ts +6 -4
  66. package/src/index.ts +4 -1
  67. package/src/inject.ts +34 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.1](https://github.com/RSamaium/RPG-JS/compare/v4.2.0...v4.2.1) (2024-01-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * #community-261 ([8221085](https://github.com/RSamaium/RPG-JS/commit/8221085a962b1555aa20ba154b6790d4522da971)), closes [#community-261](https://github.com/RSamaium/RPG-JS/issues/community-261)
12
+
13
+
14
+
15
+
16
+
17
+ # [4.2.0](https://github.com/RSamaium/RPG-JS/compare/v4.1.3...v4.2.0) (2023-12-09)
18
+
19
+
20
+ ### Features
21
+
22
+ * inject function ([902e62f](https://github.com/RSamaium/RPG-JS/commit/902e62ff4fdd9b5bd26ee7d5be9ccae2b051f248))
23
+ * propagate event directive ([edbab50](https://github.com/RSamaium/RPG-JS/commit/edbab506a2552ff64d2f638d1e088748cbc8cc86))
24
+
25
+
26
+
27
+
28
+
6
29
  ## [4.1.3](https://github.com/RSamaium/RPG-JS/compare/v4.1.2...v4.1.3) (2023-11-17)
7
30
 
8
31
  **Note:** Version bump only for package @rpgjs/client
@@ -1,6 +1,9 @@
1
1
  import require$$0 from "react-dom";
2
2
  import { useCallback, useSyncExternalStore, createContext, useState, useContext, useEffect, useRef, createElement } from "react";
3
+ import { i as inject, R as RpgRenderer, E as EVENTS_MAP } from "./index-e74a289f.js";
3
4
  import { map, tap, BehaviorSubject } from "rxjs";
5
+ import "@rpgjs/common";
6
+ import "vue";
4
7
  var createRoot;
5
8
  var m = require$$0;
6
9
  if ({}.NODE_ENV === "production") {
@@ -65,6 +68,27 @@ const useCurrentPlayer = () => {
65
68
  }, []);
66
69
  return useSyncExternalStore(subscribe, () => currentPlayerRef.current);
67
70
  };
71
+ const useEventPropagator = () => {
72
+ const ref = useRef(null);
73
+ useEffect(() => {
74
+ if (ref.current) {
75
+ const element = ref.current;
76
+ const eventListeners = {};
77
+ const renderer = inject(RpgRenderer);
78
+ EVENTS_MAP.MouseEvent.forEach((eventType) => {
79
+ const listener = (event) => renderer.propagateEvent(event);
80
+ element.addEventListener(eventType, listener);
81
+ eventListeners[eventType] = listener;
82
+ });
83
+ return () => {
84
+ EVENTS_MAP.MouseEvent.forEach((eventType) => {
85
+ element.removeEventListener(eventType, eventListeners[eventType]);
86
+ });
87
+ };
88
+ }
89
+ }, [ref]);
90
+ return ref;
91
+ };
68
92
  class ReactGui {
69
93
  //private _tooltips: BehaviorSubject<any[]> = new BehaviorSubject([] as any)
70
94
  constructor(rootEl, parentGui) {
@@ -127,6 +151,7 @@ export {
127
151
  ReactGui,
128
152
  RpgReactContext,
129
153
  useCurrentPlayer,
154
+ useEventPropagator,
130
155
  useObjects,
131
156
  useStore
132
157
  };