@rpgjs/client 5.0.0-alpha.8 → 5.0.0-beta.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 (305) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/Game/AnimationManager.js +26 -0
  3. package/dist/Game/AnimationManager.js.map +1 -0
  4. package/dist/Game/Event.d.ts +1 -1
  5. package/dist/Game/Event.js +12 -0
  6. package/dist/Game/Event.js.map +1 -0
  7. package/dist/Game/Map.d.ts +23 -2
  8. package/dist/Game/Map.js +80 -0
  9. package/dist/Game/Map.js.map +1 -0
  10. package/dist/Game/Object.d.ts +157 -0
  11. package/dist/Game/Object.js +211 -0
  12. package/dist/Game/Object.js.map +1 -0
  13. package/dist/Game/Player.d.ts +1 -1
  14. package/dist/Game/Player.js +12 -0
  15. package/dist/Game/Player.js.map +1 -0
  16. package/dist/Gui/Gui.d.ts +177 -5
  17. package/dist/Gui/Gui.js +445 -0
  18. package/dist/Gui/Gui.js.map +1 -0
  19. package/dist/Gui/NotificationManager.d.ts +23 -0
  20. package/dist/Gui/NotificationManager.js +49 -0
  21. package/dist/Gui/NotificationManager.js.map +1 -0
  22. package/dist/Resource.d.ts +97 -0
  23. package/dist/Resource.js +133 -0
  24. package/dist/Resource.js.map +1 -0
  25. package/dist/RpgClient.d.ts +290 -58
  26. package/dist/RpgClientEngine.d.ts +649 -9
  27. package/dist/RpgClientEngine.js +1334 -0
  28. package/dist/RpgClientEngine.js.map +1 -0
  29. package/dist/Sound.d.ts +199 -0
  30. package/dist/Sound.js +167 -0
  31. package/dist/Sound.js.map +1 -0
  32. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
  33. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
  34. package/dist/components/animations/animation.ce.js +24 -0
  35. package/dist/components/animations/animation.ce.js.map +1 -0
  36. package/dist/components/animations/hit.ce.js +70 -0
  37. package/dist/components/animations/hit.ce.js.map +1 -0
  38. package/dist/components/animations/index.d.ts +4 -0
  39. package/dist/components/animations/index.js +11 -0
  40. package/dist/components/animations/index.js.map +1 -0
  41. package/dist/components/character.ce.js +392 -0
  42. package/dist/components/character.ce.js.map +1 -0
  43. package/dist/components/dynamics/parse-value.d.ts +1 -0
  44. package/dist/components/dynamics/parse-value.js +44 -0
  45. package/dist/components/dynamics/parse-value.js.map +1 -0
  46. package/dist/components/dynamics/text.ce.js +73 -0
  47. package/dist/components/dynamics/text.ce.js.map +1 -0
  48. package/dist/components/gui/box.ce.js +28 -0
  49. package/dist/components/gui/box.ce.js.map +1 -0
  50. package/dist/components/gui/dialogbox/index.ce.js +205 -0
  51. package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
  52. package/dist/components/gui/gameover.ce.js +193 -0
  53. package/dist/components/gui/gameover.ce.js.map +1 -0
  54. package/dist/components/gui/hud/hud.ce.js +92 -0
  55. package/dist/components/gui/hud/hud.ce.js.map +1 -0
  56. package/dist/components/gui/index.d.ts +15 -3
  57. package/dist/components/gui/index.js +14 -0
  58. package/dist/components/gui/menu/equip-menu.ce.js +481 -0
  59. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
  60. package/dist/components/gui/menu/exit-menu.ce.js +54 -0
  61. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
  62. package/dist/components/gui/menu/items-menu.ce.js +344 -0
  63. package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
  64. package/dist/components/gui/menu/main-menu.ce.js +417 -0
  65. package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
  66. package/dist/components/gui/menu/options-menu.ce.js +48 -0
  67. package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
  68. package/dist/components/gui/menu/skills-menu.ce.js +107 -0
  69. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
  70. package/dist/components/gui/mobile/index.d.ts +8 -0
  71. package/dist/components/gui/mobile/index.js +21 -0
  72. package/dist/components/gui/mobile/index.js.map +1 -0
  73. package/dist/components/gui/mobile/mobile.ce.js +78 -0
  74. package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
  75. package/dist/components/gui/notification/notification.ce.js +64 -0
  76. package/dist/components/gui/notification/notification.ce.js.map +1 -0
  77. package/dist/components/gui/save-load.ce.js +389 -0
  78. package/dist/components/gui/save-load.ce.js.map +1 -0
  79. package/dist/components/gui/shop/shop.ce.js +652 -0
  80. package/dist/components/gui/shop/shop.ce.js.map +1 -0
  81. package/dist/components/gui/title-screen.ce.js +190 -0
  82. package/dist/components/gui/title-screen.ce.js.map +1 -0
  83. package/dist/components/index.d.ts +1 -0
  84. package/dist/components/index.js +4 -0
  85. package/dist/components/prebuilt/hp-bar.ce.js +116 -0
  86. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
  87. package/dist/components/prebuilt/index.d.ts +19 -0
  88. package/dist/components/prebuilt/index.js +2 -0
  89. package/dist/components/prebuilt/light-halo.ce.js +94 -0
  90. package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
  91. package/dist/components/scenes/canvas.ce.js +60 -0
  92. package/dist/components/scenes/canvas.ce.js.map +1 -0
  93. package/dist/components/scenes/draw-map.ce.js +89 -0
  94. package/dist/components/scenes/draw-map.ce.js.map +1 -0
  95. package/dist/components/scenes/event-layer.ce.js +28 -0
  96. package/dist/components/scenes/event-layer.ce.js.map +1 -0
  97. package/dist/core/inject.js +18 -0
  98. package/dist/core/inject.js.map +1 -0
  99. package/dist/core/setup.js +16 -0
  100. package/dist/core/setup.js.map +1 -0
  101. package/dist/index.d.ts +15 -1
  102. package/dist/index.js +44 -14
  103. package/dist/module.d.ts +43 -4
  104. package/dist/module.js +176 -0
  105. package/dist/module.js.map +1 -0
  106. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js +277 -0
  107. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -0
  108. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +457 -0
  109. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -0
  110. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +463 -0
  111. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
  112. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +2191 -0
  113. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -0
  114. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +10 -0
  115. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
  116. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +91 -0
  117. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  118. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js +325 -0
  119. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -0
  120. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +14 -0
  121. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
  122. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
  123. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
  124. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
  125. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
  126. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
  127. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
  128. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
  129. package/dist/presets/animation.d.ts +31 -0
  130. package/dist/presets/animation.js +39 -0
  131. package/dist/presets/animation.js.map +1 -0
  132. package/dist/presets/faceset.d.ts +30 -0
  133. package/dist/presets/faceset.js +51 -0
  134. package/dist/presets/faceset.js.map +1 -0
  135. package/dist/presets/icon.d.ts +20 -0
  136. package/dist/presets/icon.js +15 -0
  137. package/dist/presets/icon.js.map +1 -0
  138. package/dist/presets/index.d.ts +123 -0
  139. package/dist/presets/index.js +17 -0
  140. package/dist/presets/index.js.map +1 -0
  141. package/dist/presets/lpc.d.ts +89 -0
  142. package/dist/presets/lpc.js +98 -0
  143. package/dist/presets/lpc.js.map +1 -0
  144. package/dist/presets/rmspritesheet.js +42 -0
  145. package/dist/presets/rmspritesheet.js.map +1 -0
  146. package/dist/services/AbstractSocket.d.ts +9 -5
  147. package/dist/services/AbstractSocket.js +11 -0
  148. package/dist/services/AbstractSocket.js.map +1 -0
  149. package/dist/services/keyboardControls.d.ts +15 -0
  150. package/dist/services/keyboardControls.js +23 -0
  151. package/dist/services/keyboardControls.js.map +1 -0
  152. package/dist/services/loadMap.js +123 -0
  153. package/dist/services/loadMap.js.map +1 -0
  154. package/dist/services/mmorpg.d.ts +21 -9
  155. package/dist/services/mmorpg.js +131 -0
  156. package/dist/services/mmorpg.js.map +1 -0
  157. package/dist/services/save.d.ts +19 -0
  158. package/dist/services/save.js +77 -0
  159. package/dist/services/save.js.map +1 -0
  160. package/dist/services/standalone.d.ts +67 -7
  161. package/dist/services/standalone.js +168 -0
  162. package/dist/services/standalone.js.map +1 -0
  163. package/dist/utils/getEntityProp.d.ts +39 -0
  164. package/dist/utils/getEntityProp.js +52 -0
  165. package/dist/utils/getEntityProp.js.map +1 -0
  166. package/package.json +13 -9
  167. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  168. package/src/Game/Event.ts +1 -1
  169. package/src/Game/Map.ts +95 -3
  170. package/src/Game/Object.ts +330 -14
  171. package/src/Game/Player.ts +1 -1
  172. package/src/Gui/Gui.ts +506 -18
  173. package/src/Gui/NotificationManager.ts +69 -0
  174. package/src/Resource.ts +150 -0
  175. package/src/RpgClient.ts +300 -58
  176. package/src/RpgClientEngine.ts +1707 -48
  177. package/src/Sound.ts +253 -0
  178. package/src/components/{effects → animations}/animation.ce +3 -6
  179. package/src/components/{effects → animations}/index.ts +1 -1
  180. package/src/components/character.ce +406 -40
  181. package/src/components/dynamics/parse-value.ts +80 -0
  182. package/src/components/dynamics/text.ce +183 -0
  183. package/src/components/gui/box.ce +17 -0
  184. package/src/components/gui/dialogbox/index.ce +204 -187
  185. package/src/components/gui/gameover.ce +158 -0
  186. package/src/components/gui/hud/hud.ce +61 -0
  187. package/src/components/gui/index.ts +30 -4
  188. package/src/components/gui/menu/equip-menu.ce +410 -0
  189. package/src/components/gui/menu/exit-menu.ce +41 -0
  190. package/src/components/gui/menu/items-menu.ce +317 -0
  191. package/src/components/gui/menu/main-menu.ce +294 -0
  192. package/src/components/gui/menu/options-menu.ce +35 -0
  193. package/src/components/gui/menu/skills-menu.ce +83 -0
  194. package/src/components/gui/mobile/index.ts +24 -0
  195. package/src/components/gui/mobile/mobile.ce +80 -0
  196. package/src/components/gui/notification/notification.ce +51 -0
  197. package/src/components/gui/save-load.ce +208 -0
  198. package/src/components/gui/shop/shop.ce +493 -0
  199. package/src/components/gui/title-screen.ce +163 -0
  200. package/src/components/index.ts +3 -0
  201. package/src/components/prebuilt/hp-bar.ce +255 -0
  202. package/src/components/prebuilt/index.ts +24 -0
  203. package/src/components/prebuilt/light-halo.ce +148 -0
  204. package/src/components/scenes/canvas.ce +20 -15
  205. package/src/components/scenes/draw-map.ce +60 -13
  206. package/src/components/scenes/event-layer.ce +9 -2
  207. package/src/components/scenes/transition.ce +60 -0
  208. package/src/index.ts +16 -2
  209. package/src/module.ts +145 -9
  210. package/src/presets/animation.ts +46 -0
  211. package/src/presets/faceset.ts +60 -0
  212. package/src/presets/icon.ts +17 -0
  213. package/src/presets/index.ts +9 -1
  214. package/src/presets/lpc.ts +108 -0
  215. package/src/services/AbstractSocket.ts +10 -2
  216. package/src/services/keyboardControls.ts +20 -0
  217. package/src/services/loadMap.ts +1 -1
  218. package/src/services/mmorpg.ts +100 -12
  219. package/src/services/save.ts +103 -0
  220. package/src/services/standalone.ts +110 -18
  221. package/src/utils/getEntityProp.ts +87 -0
  222. package/tsconfig.json +1 -1
  223. package/vite.config.ts +4 -2
  224. package/dist/Game/EffectManager.d.ts +0 -5
  225. package/dist/components/effects/index.d.ts +0 -4
  226. package/dist/index.js.map +0 -1
  227. package/dist/index10.js +0 -8
  228. package/dist/index10.js.map +0 -1
  229. package/dist/index11.js +0 -10
  230. package/dist/index11.js.map +0 -1
  231. package/dist/index12.js +0 -8
  232. package/dist/index12.js.map +0 -1
  233. package/dist/index13.js +0 -17
  234. package/dist/index13.js.map +0 -1
  235. package/dist/index14.js +0 -91
  236. package/dist/index14.js.map +0 -1
  237. package/dist/index15.js +0 -50
  238. package/dist/index15.js.map +0 -1
  239. package/dist/index16.js +0 -191
  240. package/dist/index16.js.map +0 -1
  241. package/dist/index17.js +0 -9
  242. package/dist/index17.js.map +0 -1
  243. package/dist/index18.js +0 -387
  244. package/dist/index18.js.map +0 -1
  245. package/dist/index19.js +0 -31
  246. package/dist/index19.js.map +0 -1
  247. package/dist/index2.js +0 -112
  248. package/dist/index2.js.map +0 -1
  249. package/dist/index20.js +0 -24
  250. package/dist/index20.js.map +0 -1
  251. package/dist/index21.js +0 -2421
  252. package/dist/index21.js.map +0 -1
  253. package/dist/index22.js +0 -114
  254. package/dist/index22.js.map +0 -1
  255. package/dist/index23.js +0 -109
  256. package/dist/index23.js.map +0 -1
  257. package/dist/index24.js +0 -71
  258. package/dist/index24.js.map +0 -1
  259. package/dist/index25.js +0 -21
  260. package/dist/index25.js.map +0 -1
  261. package/dist/index26.js +0 -41
  262. package/dist/index26.js.map +0 -1
  263. package/dist/index27.js +0 -5
  264. package/dist/index27.js.map +0 -1
  265. package/dist/index28.js +0 -322
  266. package/dist/index28.js.map +0 -1
  267. package/dist/index29.js +0 -27
  268. package/dist/index29.js.map +0 -1
  269. package/dist/index3.js +0 -87
  270. package/dist/index3.js.map +0 -1
  271. package/dist/index30.js +0 -11
  272. package/dist/index30.js.map +0 -1
  273. package/dist/index31.js +0 -11
  274. package/dist/index31.js.map +0 -1
  275. package/dist/index32.js +0 -12
  276. package/dist/index32.js.map +0 -1
  277. package/dist/index33.js +0 -4403
  278. package/dist/index33.js.map +0 -1
  279. package/dist/index34.js +0 -316
  280. package/dist/index34.js.map +0 -1
  281. package/dist/index35.js +0 -174
  282. package/dist/index35.js.map +0 -1
  283. package/dist/index36.js +0 -501
  284. package/dist/index36.js.map +0 -1
  285. package/dist/index37.js +0 -61
  286. package/dist/index37.js.map +0 -1
  287. package/dist/index38.js +0 -20
  288. package/dist/index38.js.map +0 -1
  289. package/dist/index39.js +0 -20
  290. package/dist/index39.js.map +0 -1
  291. package/dist/index4.js +0 -67
  292. package/dist/index4.js.map +0 -1
  293. package/dist/index5.js +0 -16
  294. package/dist/index5.js.map +0 -1
  295. package/dist/index6.js +0 -17
  296. package/dist/index6.js.map +0 -1
  297. package/dist/index7.js +0 -39
  298. package/dist/index7.js.map +0 -1
  299. package/dist/index8.js +0 -90
  300. package/dist/index8.js.map +0 -1
  301. package/dist/index9.js +0 -76
  302. package/dist/index9.js.map +0 -1
  303. package/src/components/gui/dialogbox/itemMenu.ce +0 -23
  304. package/src/components/gui/dialogbox/selection.ce +0 -67
  305. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -0,0 +1,89 @@
1
+ import { inject } from "../../core/inject.js";
2
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
3
+ import { Container, computed, cond, h, loop, signal, useDefineProps, useProps } from "canvasengine";
4
+ import { Weather } from "@canvasengine/presets";
5
+ //#region src/components/scenes/draw-map.ce
6
+ function component($$props) {
7
+ useProps($$props);
8
+ useDefineProps($$props);
9
+ var _a, _b, _c, _d;
10
+ var engine = inject(RpgClientEngine);
11
+ var componentAnimations = engine.componentAnimations;
12
+ var map = (_a = engine.sceneMap) === null || _a === void 0 ? void 0 : _a.data;
13
+ var sceneComponent = computed(function() {
14
+ var _a;
15
+ return (_a = map()) === null || _a === void 0 ? void 0 : _a.component;
16
+ });
17
+ (_b = map()) === null || _b === void 0 || _b.params;
18
+ var mapParams = (_c = map()) === null || _c === void 0 ? void 0 : _c.params;
19
+ engine.sceneMap.animations;
20
+ var weather = engine.sceneMap.weather;
21
+ var backgroundMusic = {
22
+ src: mapParams === null || mapParams === void 0 ? void 0 : mapParams.backgroundMusic,
23
+ autoplay: true,
24
+ loop: true
25
+ };
26
+ var backgroundAmbientSound = {
27
+ src: mapParams === null || mapParams === void 0 ? void 0 : mapParams.backgroundAmbientSound,
28
+ autoplay: true,
29
+ loop: true
30
+ };
31
+ signal((_d = map()) === null || _d === void 0 ? void 0 : _d.data);
32
+ var scale = (mapParams === null || mapParams === void 0 ? void 0 : mapParams.scale) || 1;
33
+ ((mapParams === null || mapParams === void 0 ? void 0 : mapParams.width) || 2048) * scale;
34
+ ((mapParams === null || mapParams === void 0 ? void 0 : mapParams.height) || 2048) * scale;
35
+ var shakeConfig = {
36
+ trigger: engine.mapShakeTrigger,
37
+ intensity: 10,
38
+ duration: 500,
39
+ frequency: 10,
40
+ direction: "both"
41
+ };
42
+ var weatherProps = computed(function() {
43
+ var _a, _b;
44
+ var state = weather === null || weather === void 0 ? void 0 : weather();
45
+ if (!state) return null;
46
+ if (![
47
+ "rain",
48
+ "snow",
49
+ "fog",
50
+ "cloud"
51
+ ].includes(state.effect)) return null;
52
+ var params = (_a = state.params) !== null && _a !== void 0 ? _a : {};
53
+ return {
54
+ effect: state.effect,
55
+ speed: params.speed,
56
+ windDirection: params.windDirection,
57
+ windStrength: params.windStrength,
58
+ density: params.density,
59
+ maxDrops: params.maxDrops,
60
+ height: params.height,
61
+ scale: params.scale,
62
+ sunIntensity: params.sunIntensity,
63
+ sunAngle: params.sunAngle,
64
+ raySpread: params.raySpread,
65
+ rayTwinkle: params.rayTwinkle,
66
+ rayTwinkleSpeed: params.rayTwinkleSpeed,
67
+ zIndex: (_b = params.zIndex) !== null && _b !== void 0 ? _b : 1e3,
68
+ alpha: params.alpha,
69
+ blendMode: params.blendMode
70
+ };
71
+ });
72
+ return h(Container, {
73
+ sound: backgroundMusic,
74
+ shake: shakeConfig,
75
+ freeze: engine.gamePause
76
+ }, [
77
+ h(Container, { sound: backgroundAmbientSound }),
78
+ cond(computed(() => map() && sceneComponent()), () => h(sceneComponent(), {
79
+ data: computed(() => map().data),
80
+ params: computed(() => map().params)
81
+ })),
82
+ loop(componentAnimations, (componentAnimation) => h(Container, null, loop(componentAnimation.current, (animation) => h(componentAnimation.component, animation)))),
83
+ cond(weatherProps, () => h(Weather, weatherProps()))
84
+ ]);
85
+ }
86
+ //#endregion
87
+ export { component as default };
88
+
89
+ //# sourceMappingURL=draw-map.ce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw-map.ce.js","names":[],"sources":["../../../src/components/scenes/draw-map.ce"],"sourcesContent":["<Container sound={backgroundMusic} shake={shakeConfig} freeze={engine.gamePause}>\n <Container sound={backgroundAmbientSound} />\n\n @if (map() && sceneComponent()) {\n <sceneComponent() data={map().data} params={map().params} />\n }\n\n @for (componentAnimation of componentAnimations) {\n <Container>\n @for (animation of componentAnimation.current) {\n <componentAnimation.component ...animation />\n }\n </Container>\n }\n\n @if (weatherProps) {\n <Weather ...weatherProps() />\n }\n</Container>\n\n<script>\n import { NoiseFilter } from 'pixi-filters';\n import { effect, signal, computed, mount, on, tick } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { Weather } from '@canvasengine/presets'\n\n const engine = inject(RpgClientEngine);\n const componentAnimations = engine.componentAnimations\n const map = engine.sceneMap?.data\n const sceneComponent = computed(() => map()?.component)\n const sceneParams = map()?.params\n const mapParams = map()?.params\n const animations = engine.sceneMap.animations\n const weather = engine.sceneMap.weather\n const backgroundMusic = { src: mapParams?.backgroundMusic, autoplay: true, loop: true }\n const backgroundAmbientSound = { src: mapParams?.backgroundAmbientSound, autoplay: true, loop: true }\n\n const data = signal(map()?.data)\n\n const scale = mapParams?.scale || 1\n const worldWidth = (mapParams?.width || 2048) * scale\n const worldHeight = (mapParams?.height || 2048) * scale\n \n const clamp = {\n direction: \"all\"\n }\n\n const shakeConfig = {\n trigger: engine.mapShakeTrigger,\n intensity: 10,\n duration: 500,\n frequency: 10,\n direction: 'both'\n }\n\n const weatherProps = computed(() => {\n const state = weather?.()\n if (!state) {\n return null\n }\n const validEffects = ['rain', 'snow', 'fog', 'cloud']\n if (!validEffects.includes(state.effect)) {\n return null\n }\n const params = state.params ?? {}\n return {\n effect: state.effect,\n speed: params.speed,\n windDirection: params.windDirection,\n windStrength: params.windStrength,\n density: params.density,\n maxDrops: params.maxDrops,\n height: params.height,\n scale: params.scale,\n sunIntensity: params.sunIntensity,\n sunAngle: params.sunAngle,\n raySpread: params.raySpread,\n rayTwinkle: params.rayTwinkle,\n rayTwinkleSpeed: params.rayTwinkleSpeed,\n zIndex: params.zIndex ?? 1000,\n alpha: params.alpha,\n blendMode: params.blendMode,\n }\n })\n</script>\n"],"mappings":";;;;;AASM,SAAmB,UAAA,SAAmB;AACnC,UAAmB,QAAY;AAClC,gBAAA,QAAA;CACA,IAAA,IAAS,IAAA,IAAA;CACf,IAAE,SAAA,OAAA,gBAAA;;CAEF,IAAG,OAAI,KAAA,OAAc,cAAA,QAAA,OAAA,KAAA,IAAA,KAAA,IAAA,GAAA;CACrB,IAAI,iBAAY,SAAc,WAAE;EAAA,IAAA;AAAA,UAAA,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;GACH;AAEM,QADQ,EAAM,WAAM;EAAA,OAAA;EAAA,OAAA;EAAA,QAAA,OAAA;EAAA,EAAA;EAAA,EAAA,WAAA,EAAA,OAAA,wBAAA,CAAA;EAAA,KAAA,eAAA,KAAA,IAAA,gBAAA,CAAA,QAAA,EAAA,gBAAA,EAAA;GAAA,MAAA,eAAA,KAAA,CAAA,KAAA;GAAA,QAAA,eAAA,KAAA,CAAA,OAAA;GAAA,CAAA,CAAA;EAAA,KAAA,sBAAA,uBAAA,EAAA,WAAA,MAAA,KAAA,mBAAA,UAAA,cAAA,EAAA,mBAAA,WAAA,UAAA,CAAA,CAAA,CAAA;EAAA,KAAA,oBAAA,EAAA,SAAA,cAAA,CAAA,CAAA;EAAA,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { inject } from "../../core/inject.js";
2
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
3
+ import component$1 from "../character.ce.js";
4
+ import { Container, h, loop, useDefineProps, useProps } from "canvasengine";
5
+ //#region src/components/scenes/event-layer.ce
6
+ function component($$props) {
7
+ useProps($$props);
8
+ const defineProps = useDefineProps($$props);
9
+ var engine = inject(RpgClientEngine);
10
+ var children = defineProps().children;
11
+ var players = engine.sceneMap.players;
12
+ var events = engine.sceneMap.events;
13
+ return h(Container, { sortableChildren: true }, [
14
+ loop(events, (event, id) => h(component$1, {
15
+ id,
16
+ object: event
17
+ })),
18
+ loop(players, (player, id) => h(component$1, {
19
+ id,
20
+ object: player
21
+ })),
22
+ loop(children, (child) => h(child))
23
+ ]);
24
+ }
25
+ //#endregion
26
+ export { component as default };
27
+
28
+ //# sourceMappingURL=event-layer.ce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-layer.ce.js","names":[],"sources":["../../../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { effect, signal } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n import LightHalo from \"../prebuilt/light-halo.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children } = defineProps()\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>"],"mappings":";;;;;;AASmB,UAAU,QAAA;CACrB,MAAM,cAAE,eAAA,QAAA;CACZ,IAAA,SAAA,OAAA,gBAAA;CACJ,IAAE,WAAS,aAAA,CAAA;;CAEX,IAAC,SAAM,OAAA,SAAA;AAEH,QADgB,EAAC,WAAS,EAAK,kBAAa,MAAA,EAAA;EAAA,KAAA,SAAA,OAAA,OAAA,EAAA,aAAA;GAAA;GAAA,QAAA;GAAA,CAAA,CAAA;EAAA,KAAA,UAAA,QAAA,OAAA,EAAA,aAAA;GAAA;GAAA,QAAA;GAAA,CAAA,CAAA;EAAA,KAAA,WAAA,UAAA,EAAA,MAAA,CAAA;EAAA,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { inject as inject$1 } from "../node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js";
2
+ //#region src/core/inject.ts
3
+ var context = null;
4
+ function inject(service, _context) {
5
+ const c = _context ?? context;
6
+ if (!c) throw new Error("Context is not set. use setInject() to set the context");
7
+ return inject$1(c, service);
8
+ }
9
+ function setInject(_context) {
10
+ context = _context;
11
+ }
12
+ function clearInject() {
13
+ context = null;
14
+ }
15
+ //#endregion
16
+ export { clearInject, context, inject, setInject };
17
+
18
+ //# sourceMappingURL=inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.js","names":[],"sources":["../../src/core/inject.ts"],"sourcesContent":["import { Context, inject as injector } from \"@signe/di\";\n\nexport let context: Context | null = null\n\nexport function inject<T>(service: (new (...args: any[]) => T) | string, _context?: Context): T {\n const c = _context ?? context\n if (!c) throw new Error(\"Context is not set. use setInject() to set the context\");\n return injector(c, service);\n}\n\nexport function setInject(_context: Context) {\n context = _context;\n}\n\nexport function clearInject() {\n context = null\n}"],"mappings":";;AAEA,IAAW,UAA0B;AAErC,SAAgB,OAAU,SAA+C,UAAuB;CAC5F,MAAM,IAAI,YAAY;AACtB,KAAI,CAAC,EAAG,OAAM,IAAI,MAAM,yDAAyD;AACjF,QAAO,SAAS,GAAG,QAAQ;;AAG/B,SAAgB,UAAU,UAAmB;AACzC,WAAU;;AAGd,SAAgB,cAAc;AAC1B,WAAU"}
@@ -0,0 +1,16 @@
1
+ import { Context, inject, injector } from "../node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js";
2
+ import { setInject } from "./inject.js";
3
+ import { RpgClientEngine } from "../RpgClientEngine.js";
4
+ //#region src/core/setup.ts
5
+ async function startGame(options) {
6
+ const context = new Context();
7
+ context["side"] = "client";
8
+ setInject(context);
9
+ await injector(context, options.providers);
10
+ await inject(context, RpgClientEngine).start();
11
+ return context;
12
+ }
13
+ //#endregion
14
+ export { startGame };
15
+
16
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","names":[],"sources":["../../src/core/setup.ts"],"sourcesContent":["import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from \"@signe/di\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport { setInject } from \"./inject\";\n\ninterface SetupOptions {\n providers: Providers;\n}\n\n\nexport async function startGame(options: SetupOptions) {\n const context = new Context();\n context['side'] = 'client'\n setInject(context);\n\n await injector(context, options.providers);\n\n const engine = inject(context, RpgClientEngine);\n await engine.start();\n return context;\n}"],"mappings":";;;;AASA,eAAsB,UAAU,SAAuB;CACrD,MAAM,UAAU,IAAI,SAAS;AAC7B,SAAQ,UAAU;AAClB,WAAU,QAAQ;AAElB,OAAM,SAAS,SAAS,QAAQ,UAAU;AAG1C,OADe,OAAO,SAAS,gBAAgB,CAClC,OAAO;AACpB,QAAO"}
package/dist/index.d.ts CHANGED
@@ -2,12 +2,26 @@ export * from './RpgClientEngine';
2
2
  export type * from './RpgClient';
3
3
  export * from './services/standalone';
4
4
  export * from './services/mmorpg';
5
+ export * from './services/save';
5
6
  export * from './core/setup';
6
7
  export * from './core/inject';
7
8
  export * from './services/loadMap';
8
9
  export * from './module';
9
10
  export * from './Gui/Gui';
10
11
  export * from './components/gui';
11
- export * from './components/effects';
12
+ export * from './components/animations';
13
+ export * from './components/prebuilt';
12
14
  export * from './presets';
13
15
  export * from './components';
16
+ export * from './components/gui';
17
+ export * from './Sound';
18
+ export * from './Resource';
19
+ export * from './utils/getEntityProp';
20
+ export { Context } from '@signe/di';
21
+ export { KeyboardControls, Input } from 'canvasengine';
22
+ export { Control } from './services/keyboardControls';
23
+ export { RpgClientObject } from './Game/Object';
24
+ export { RpgClientPlayer } from './Game/Player';
25
+ export { RpgClientEvent } from './Game/Event';
26
+ export { withMobile } from './components/gui/mobile';
27
+ export * from './services/AbstractSocket';
package/dist/index.js CHANGED
@@ -1,14 +1,44 @@
1
- export { RpgClientEngine } from './index2.js';
2
- export { provideRpg } from './index3.js';
3
- export { provideMmorpg } from './index4.js';
4
- export { startGame } from './index5.js';
5
- export { clearInject, context, inject, setInject } from './index6.js';
6
- export { LoadMapService, LoadMapToken, provideLoadMap } from './index7.js';
7
- export { GlobalConfigToken, provideClientGlobalConfig, provideClientModules, provideGlobalConfig } from './index8.js';
8
- export { RpgGui } from './index9.js';
9
- export { PrebuiltGui } from './index10.js';
10
- export { PrebuiltEffects } from './index11.js';
11
- export { Presets } from './index12.js';
12
- export { default as EventLayerComponent } from './index13.js';
13
- export { default as CharacterComponent } from './index14.js';
14
- //# sourceMappingURL=index.js.map
1
+ import { Context } from "./node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js";
2
+ import { clearInject, context, inject, setInject } from "./core/inject.js";
3
+ import { AbstractWebsocket, WebSocketToken } from "./services/AbstractSocket.js";
4
+ import component$2 from "./components/gui/dialogbox/index.ce.js";
5
+ import component from "./components/gui/box.ce.js";
6
+ import component$15 from "./components/gui/shop/shop.ce.js";
7
+ import { getEntityProp } from "./utils/getEntityProp.js";
8
+ import component$8 from "./components/gui/hud/hud.ce.js";
9
+ import { SaveClientService, SaveClientToken, provideSaveClient } from "./services/save.js";
10
+ import component$14 from "./components/gui/save-load.ce.js";
11
+ import component$9 from "./components/gui/menu/items-menu.ce.js";
12
+ import component$16 from "./components/gui/menu/skills-menu.ce.js";
13
+ import component$3 from "./components/gui/menu/equip-menu.ce.js";
14
+ import component$13 from "./components/gui/menu/options-menu.ce.js";
15
+ import component$5 from "./components/gui/menu/exit-menu.ce.js";
16
+ import component$11 from "./components/gui/menu/main-menu.ce.js";
17
+ import component$12 from "./components/gui/notification/notification.ce.js";
18
+ import component$17 from "./components/gui/title-screen.ce.js";
19
+ import component$6 from "./components/gui/gameover.ce.js";
20
+ import "./components/gui/index.js";
21
+ import { RpgGui } from "./Gui/Gui.js";
22
+ import { LoadMapService, LoadMapToken, provideLoadMap } from "./services/loadMap.js";
23
+ import { RpgSound, Sound, getSoundMetadata } from "./Sound.js";
24
+ import { RpgResource } from "./Resource.js";
25
+ import { RpgClientObject } from "./Game/Object.js";
26
+ import { RpgClientPlayer } from "./Game/Player.js";
27
+ import { RpgClientEvent } from "./Game/Event.js";
28
+ import { GlobalConfigToken, provideClientGlobalConfig, provideClientModules, provideGlobalConfig } from "./module.js";
29
+ import { PrebuiltComponentAnimations } from "./components/animations/index.js";
30
+ import { RpgClientEngine } from "./RpgClientEngine.js";
31
+ import { Control } from "./services/keyboardControls.js";
32
+ import { provideRpg } from "./services/standalone.js";
33
+ import { provideMmorpg } from "./services/mmorpg.js";
34
+ import { startGame } from "./core/setup.js";
35
+ import component$7 from "./components/prebuilt/hp-bar.ce.js";
36
+ import component$10 from "./components/prebuilt/light-halo.ce.js";
37
+ import "./components/prebuilt/index.js";
38
+ import { Presets } from "./presets/index.js";
39
+ import component$1 from "./components/character.ce.js";
40
+ import component$4 from "./components/scenes/event-layer.ce.js";
41
+ import "./components/index.js";
42
+ import { withMobile } from "./components/gui/mobile/index.js";
43
+ import { Input, KeyboardControls } from "canvasengine";
44
+ export { AbstractWebsocket, component as BoxComponent, component$1 as CharacterComponent, Context, Control, component$2 as DialogboxComponent, component$3 as EquipMenuComponent, component$4 as EventLayerComponent, component$5 as ExitMenuComponent, component$6 as GameoverComponent, GlobalConfigToken, component$7 as HpBar, component$8 as HudComponent, Input, component$9 as ItemsMenuComponent, KeyboardControls, component$10 as LightHalo, LoadMapService, LoadMapToken, component$11 as MainMenuComponent, component$12 as NotificationComponent, component$13 as OptionsMenuComponent, PrebuiltComponentAnimations, Presets, RpgClientEngine, RpgClientEvent, RpgClientObject, RpgClientPlayer, RpgGui, RpgResource, RpgSound, SaveClientService, SaveClientToken, component$14 as SaveLoadComponent, component$15 as ShopComponent, component$16 as SkillsMenuComponent, Sound, component$17 as TitleScreenComponent, WebSocketToken, clearInject, context, getEntityProp, getSoundMetadata, inject, provideClientGlobalConfig, provideClientModules, provideGlobalConfig, provideLoadMap, provideMmorpg, provideRpg, provideSaveClient, setInject, startGame, withMobile };
package/dist/module.d.ts CHANGED
@@ -1,8 +1,47 @@
1
+ import { FactoryProvider } from '@signe/di';
1
2
  import { RpgClient } from './RpgClient';
2
- export declare function provideClientModules(modules: RpgClient[]): {
3
- provide: string;
4
- useFactory: (context: import('@signe/di').Context) => import('@rpgjs/common').Hooks;
5
- };
3
+ /**
4
+ * Type for client modules that can be either:
5
+ * - An object implementing RpgClient interface
6
+ * - A class decorated with @RpgModule decorator
7
+ */
8
+ export type RpgClientModule = RpgClient | (new () => any);
9
+ /**
10
+ * Provides client modules configuration to Dependency Injection
11
+ *
12
+ * This function accepts an array of client modules that can be either:
13
+ * - Objects implementing the RpgClient interface
14
+ * - Classes decorated with the @RpgModule decorator (which will be instantiated)
15
+ *
16
+ * @param modules - Array of client modules (objects or classes)
17
+ * @returns FactoryProvider configuration for DI
18
+ * @example
19
+ * ```ts
20
+ * // Using an object
21
+ * provideClientModules([
22
+ * {
23
+ * engine: {
24
+ * onConnected(engine) {
25
+ * console.log('Client connected')
26
+ * }
27
+ * }
28
+ * }
29
+ * ])
30
+ *
31
+ * // Using a decorated class
32
+ * @RpgModule<RpgClient>({
33
+ * engine: {
34
+ * onStart(engine) {
35
+ * console.log('Client started')
36
+ * }
37
+ * }
38
+ * })
39
+ * class MyClientModule {}
40
+ *
41
+ * provideClientModules([MyClientModule])
42
+ * ```
43
+ */
44
+ export declare function provideClientModules(modules: RpgClientModule[]): FactoryProvider;
6
45
  export declare const GlobalConfigToken = "GlobalConfigToken";
7
46
  export declare function provideGlobalConfig(config: any): {
8
47
  provide: string;
package/dist/module.js ADDED
@@ -0,0 +1,176 @@
1
+ import { inject } from "./node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js";
2
+ import { RpgGui } from "./Gui/Gui.js";
3
+ import { getSoundMetadata } from "./Sound.js";
4
+ import { findModules, provideModules } from "@rpgjs/common";
5
+ //#region src/module.ts
6
+ /**
7
+ * Provides client modules configuration to Dependency Injection
8
+ *
9
+ * This function accepts an array of client modules that can be either:
10
+ * - Objects implementing the RpgClient interface
11
+ * - Classes decorated with the @RpgModule decorator (which will be instantiated)
12
+ *
13
+ * @param modules - Array of client modules (objects or classes)
14
+ * @returns FactoryProvider configuration for DI
15
+ * @example
16
+ * ```ts
17
+ * // Using an object
18
+ * provideClientModules([
19
+ * {
20
+ * engine: {
21
+ * onConnected(engine) {
22
+ * console.log('Client connected')
23
+ * }
24
+ * }
25
+ * }
26
+ * ])
27
+ *
28
+ * // Using a decorated class
29
+ * @RpgModule<RpgClient>({
30
+ * engine: {
31
+ * onStart(engine) {
32
+ * console.log('Client started')
33
+ * }
34
+ * }
35
+ * })
36
+ * class MyClientModule {}
37
+ *
38
+ * provideClientModules([MyClientModule])
39
+ * ```
40
+ */
41
+ function provideClientModules(modules) {
42
+ return provideModules(modules, "client", (modules, context) => {
43
+ modules = [...findModules(context, "Client"), ...modules];
44
+ modules = modules.map((module) => {
45
+ if (typeof module === "function") {
46
+ const instance = new module();
47
+ const moduleObj = {};
48
+ for (const key in instance) moduleObj[key] = instance[key];
49
+ module = moduleObj;
50
+ }
51
+ if ("client" in module) module = module.client;
52
+ if (module.spritesheets) {
53
+ const spritesheets = [...module.spritesheets];
54
+ module.spritesheets = { load: (engine) => {
55
+ spritesheets.forEach((spritesheet) => {
56
+ engine.addSpriteSheet(spritesheet);
57
+ });
58
+ } };
59
+ }
60
+ if (module.spritesheetResolver) {
61
+ const resolver = module.spritesheetResolver;
62
+ module.spritesheetResolver = { load: (engine) => {
63
+ engine.setSpritesheetResolver(resolver);
64
+ } };
65
+ }
66
+ if (module.sounds) {
67
+ const sounds = [...module.sounds];
68
+ module.sounds = { load: (engine) => {
69
+ sounds.forEach((sound) => {
70
+ if (typeof sound === "function" || sound && sound.constructor && sound.constructor !== Object) {
71
+ const metadata = getSoundMetadata(sound);
72
+ if (metadata) {
73
+ if (metadata.id && metadata.sound) engine.addSound({
74
+ id: metadata.id,
75
+ src: metadata.sound,
76
+ loop: metadata.loop,
77
+ volume: metadata.volume
78
+ });
79
+ if (metadata.sounds) Object.entries(metadata.sounds).forEach(([soundId, soundSrc]) => {
80
+ engine.addSound({
81
+ id: soundId,
82
+ src: soundSrc,
83
+ loop: metadata.loop,
84
+ volume: metadata.volume
85
+ });
86
+ });
87
+ } else engine.addSound(sound);
88
+ } else engine.addSound(sound);
89
+ });
90
+ } };
91
+ }
92
+ if (module.soundResolver) {
93
+ const resolver = module.soundResolver;
94
+ module.soundResolver = { load: (engine) => {
95
+ engine.setSoundResolver(resolver);
96
+ } };
97
+ }
98
+ if (module.gui) {
99
+ const gui = [...module.gui];
100
+ module.gui = { load: (engine) => {
101
+ const guiService = inject(engine.context, RpgGui);
102
+ gui.forEach((gui) => {
103
+ guiService.add(gui);
104
+ });
105
+ } };
106
+ }
107
+ if (module.componentAnimations) {
108
+ const componentAnimations = [...module.componentAnimations];
109
+ module.componentAnimations = { load: (engine) => {
110
+ componentAnimations.forEach((componentAnimation) => {
111
+ engine.addComponentAnimation(componentAnimation);
112
+ });
113
+ } };
114
+ }
115
+ if (module.transitions) {
116
+ const transitions = [...module.transitions];
117
+ module.transitions = { load: (engine) => {
118
+ const guiService = inject(engine.context, RpgGui);
119
+ transitions.forEach((transition) => {
120
+ guiService.add({
121
+ name: transition.id,
122
+ component: transition.component,
123
+ data: transition.props || {}
124
+ });
125
+ });
126
+ } };
127
+ }
128
+ if (module.particles) {
129
+ const particles = [...module.particles];
130
+ module.particles = { load: (engine) => {
131
+ particles.forEach((particle) => {
132
+ engine.addParticle(particle);
133
+ });
134
+ } };
135
+ }
136
+ if (module.sprite) {
137
+ const sprite = { ...module.sprite };
138
+ module.sprite = {
139
+ ...sprite,
140
+ load: (engine) => {
141
+ if (sprite.componentsBehind) sprite.componentsBehind.forEach((component) => {
142
+ engine.addSpriteComponentBehind(component);
143
+ });
144
+ if (sprite.componentsInFront) sprite.componentsInFront.forEach((component) => {
145
+ engine.addSpriteComponentInFront(component);
146
+ });
147
+ }
148
+ };
149
+ }
150
+ return module;
151
+ });
152
+ return modules;
153
+ });
154
+ }
155
+ var GlobalConfigToken = "GlobalConfigToken";
156
+ function provideGlobalConfig(config) {
157
+ return {
158
+ provide: GlobalConfigToken,
159
+ useValue: config ?? {}
160
+ };
161
+ }
162
+ function provideClientGlobalConfig(config = {}) {
163
+ if (!config.keyboardControls) config.keyboardControls = {
164
+ up: "up",
165
+ down: "down",
166
+ left: "left",
167
+ right: "right",
168
+ action: "space",
169
+ escape: "escape"
170
+ };
171
+ return provideGlobalConfig(config);
172
+ }
173
+ //#endregion
174
+ export { GlobalConfigToken, provideClientGlobalConfig, provideClientModules, provideGlobalConfig };
175
+
176
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { FactoryProvider } from \"@signe/di\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\nimport { getSoundMetadata } from \"./Sound\";\n\n/**\n * Type for client modules that can be either:\n * - An object implementing RpgClient interface\n * - A class decorated with @RpgModule decorator\n */\nexport type RpgClientModule = RpgClient | (new () => any);\n\n/**\n * Provides client modules configuration to Dependency Injection\n * \n * This function accepts an array of client modules that can be either:\n * - Objects implementing the RpgClient interface\n * - Classes decorated with the @RpgModule decorator (which will be instantiated)\n * \n * @param modules - Array of client modules (objects or classes)\n * @returns FactoryProvider configuration for DI\n * @example\n * ```ts\n * // Using an object\n * provideClientModules([\n * {\n * engine: {\n * onConnected(engine) {\n * console.log('Client connected')\n * }\n * }\n * }\n * ])\n * \n * // Using a decorated class\n * @RpgModule<RpgClient>({\n * engine: {\n * onStart(engine) {\n * console.log('Client started')\n * }\n * }\n * })\n * class MyClientModule {}\n * \n * provideClientModules([MyClientModule])\n * ```\n */\nexport function provideClientModules(modules: RpgClientModule[]): FactoryProvider {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n // If module is a class (constructor function), instantiate it\n // The RpgModule decorator adds properties to the prototype, which will be accessible via the instance\n if (typeof module === 'function') {\n const instance = new module() as any;\n // Copy all enumerable properties (including from prototype) to a plain object\n const moduleObj: any = {};\n for (const key in instance) {\n moduleObj[key] = instance[key];\n }\n module = moduleObj;\n }\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.spritesheetResolver) {\n const resolver = module.spritesheetResolver;\n module.spritesheetResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSpritesheetResolver(resolver);\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n // Check if it's a class decorated with @Sound\n if (typeof sound === 'function' || (sound && sound.constructor && sound.constructor !== Object)) {\n const metadata = getSoundMetadata(sound);\n if (metadata) {\n // Handle single sound\n if (metadata.id && metadata.sound) {\n engine.addSound({\n id: metadata.id,\n src: metadata.sound,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n }\n // Handle multiple sounds\n if (metadata.sounds) {\n Object.entries(metadata.sounds).forEach(([soundId, soundSrc]) => {\n engine.addSound({\n id: soundId,\n src: soundSrc,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n });\n }\n } else {\n // Not a decorated class, treat as regular sound object\n engine.addSound(sound);\n }\n } else {\n // Regular sound object\n engine.addSound(sound);\n }\n });\n },\n };\n }\n if (module.soundResolver) {\n const resolver = module.soundResolver;\n module.soundResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSoundResolver(resolver);\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui) as RpgGui;\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.componentAnimations) {\n const componentAnimations = [...module.componentAnimations];\n module.componentAnimations = {\n load: (engine: RpgClientEngine) => {\n componentAnimations.forEach((componentAnimation) => {\n engine.addComponentAnimation(componentAnimation);\n });\n },\n };\n }\n if (module.transitions) {\n const transitions = [...module.transitions];\n module.transitions = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui) as RpgGui;\n transitions.forEach((transition) => {\n guiService.add({\n name: transition.id,\n component: transition.component,\n data: transition.props || {}\n });\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n if (module.sprite) {\n const sprite = {...module.sprite};\n module.sprite = {\n ...sprite,\n load: (engine: RpgClientEngine) => {\n if (sprite.componentsBehind) {\n sprite.componentsBehind.forEach((component) => {\n engine.addSpriteComponentBehind(component);\n });\n }\n if (sprite.componentsInFront) {\n sprite.componentsInFront.forEach((component) => {\n engine.addSpriteComponentInFront(component);\n });\n }\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space',\n escape: 'escape'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,qBAAqB,SAA6C;AAChF,QAAO,eAAe,SAAS,WAAW,SAAS,YAAY;AAE7D,YAAU,CAAC,GADc,YAAY,SAAS,SAAS,EACvB,GAAG,QAAQ;AAC3C,YAAU,QAAQ,KAAK,WAAW;AAGhC,OAAI,OAAO,WAAW,YAAY;IAChC,MAAM,WAAW,IAAI,QAAQ;IAE7B,MAAM,YAAiB,EAAE;AACzB,SAAK,MAAM,OAAO,SAChB,WAAU,OAAO,SAAS;AAE5B,aAAS;;AAEX,OAAI,YAAY,OACd,UAAS,OAAO;AAElB,OAAI,OAAO,cAAc;IACvB,MAAM,eAAe,CAAC,GAAG,OAAO,aAAa;AAC7C,WAAO,eAAe,EACpB,OAAO,WAA4B;AACjC,kBAAa,SAAS,gBAAgB;AACpC,aAAO,eAAe,YAAY;OAClC;OAEL;;AAEH,OAAI,OAAO,qBAAqB;IAC9B,MAAM,WAAW,OAAO;AACxB,WAAO,sBAAsB,EAC3B,OAAO,WAA4B;AACjC,YAAO,uBAAuB,SAAS;OAE1C;;AAEH,OAAI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