@rpgjs/client 4.3.0 → 5.0.0-alpha.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 (321) hide show
  1. package/dist/Game/EffectManager.d.ts +5 -0
  2. package/dist/Game/Event.d.ts +4 -0
  3. package/dist/Game/Map.d.ts +7 -0
  4. package/dist/Game/Player.d.ts +4 -0
  5. package/dist/Gui/Gui.d.ts +23 -0
  6. package/{lib → dist}/RpgClient.d.ts +9 -6
  7. package/dist/RpgClientEngine.d.ts +43 -0
  8. package/dist/components/effects/index.d.ts +4 -0
  9. package/dist/components/gui/index.d.ts +3 -0
  10. package/dist/components/index.d.ts +2 -0
  11. package/dist/core/inject.d.ts +5 -0
  12. package/dist/core/setup.d.ts +6 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.js +13 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/index10.js +8 -0
  17. package/dist/index10.js.map +1 -0
  18. package/dist/index11.js +10 -0
  19. package/dist/index11.js.map +1 -0
  20. package/dist/index12.js +8 -0
  21. package/dist/index12.js.map +1 -0
  22. package/dist/index13.js +17 -0
  23. package/dist/index13.js.map +1 -0
  24. package/dist/index14.js +50 -0
  25. package/dist/index14.js.map +1 -0
  26. package/dist/index15.js +191 -0
  27. package/dist/index15.js.map +1 -0
  28. package/dist/index16.js +9 -0
  29. package/dist/index16.js.map +1 -0
  30. package/dist/index17.js +387 -0
  31. package/dist/index17.js.map +1 -0
  32. package/dist/index18.js +31 -0
  33. package/dist/index18.js.map +1 -0
  34. package/dist/index19.js +24 -0
  35. package/dist/index19.js.map +1 -0
  36. package/dist/index2.js +112 -0
  37. package/dist/index2.js.map +1 -0
  38. package/dist/index20.js +2421 -0
  39. package/dist/index20.js.map +1 -0
  40. package/dist/index21.js +114 -0
  41. package/dist/index21.js.map +1 -0
  42. package/dist/index22.js +109 -0
  43. package/dist/index22.js.map +1 -0
  44. package/dist/index23.js +71 -0
  45. package/dist/index23.js.map +1 -0
  46. package/dist/index24.js +21 -0
  47. package/dist/index24.js.map +1 -0
  48. package/dist/index25.js +41 -0
  49. package/dist/index25.js.map +1 -0
  50. package/dist/index26.js +5 -0
  51. package/dist/index26.js.map +1 -0
  52. package/dist/index27.js +322 -0
  53. package/dist/index27.js.map +1 -0
  54. package/dist/index28.js +25 -0
  55. package/dist/index28.js.map +1 -0
  56. package/dist/index29.js +11 -0
  57. package/dist/index29.js.map +1 -0
  58. package/dist/index3.js +87 -0
  59. package/dist/index3.js.map +1 -0
  60. package/dist/index30.js +11 -0
  61. package/dist/index30.js.map +1 -0
  62. package/dist/index31.js +174 -0
  63. package/dist/index31.js.map +1 -0
  64. package/dist/index32.js +501 -0
  65. package/dist/index32.js.map +1 -0
  66. package/dist/index33.js +12 -0
  67. package/dist/index33.js.map +1 -0
  68. package/dist/index34.js +4403 -0
  69. package/dist/index34.js.map +1 -0
  70. package/dist/index35.js +91 -0
  71. package/dist/index35.js.map +1 -0
  72. package/dist/index36.js +61 -0
  73. package/dist/index36.js.map +1 -0
  74. package/dist/index37.js +20 -0
  75. package/dist/index37.js.map +1 -0
  76. package/dist/index38.js +20 -0
  77. package/dist/index38.js.map +1 -0
  78. package/dist/index4.js +54 -0
  79. package/dist/index4.js.map +1 -0
  80. package/dist/index5.js +15 -0
  81. package/dist/index5.js.map +1 -0
  82. package/dist/index6.js +17 -0
  83. package/dist/index6.js.map +1 -0
  84. package/dist/index7.js +31 -0
  85. package/dist/index7.js.map +1 -0
  86. package/dist/index8.js +90 -0
  87. package/dist/index8.js.map +1 -0
  88. package/dist/index9.js +76 -0
  89. package/dist/index9.js.map +1 -0
  90. package/dist/module.d.ts +14 -0
  91. package/dist/presets/index.d.ts +22 -0
  92. package/{lib/Presets/AnimationSpritesheet.d.ts → dist/presets/rmspritesheet.d.ts} +6 -2
  93. package/dist/services/AbstractSocket.d.ts +15 -0
  94. package/dist/services/loadMap.d.ts +14 -0
  95. package/dist/services/mmorpg.d.ts +32 -0
  96. package/dist/services/standalone.d.ts +34 -0
  97. package/package.json +25 -41
  98. package/src/Game/EffectManager.ts +20 -0
  99. package/src/Game/Event.ts +5 -0
  100. package/src/Game/Map.ts +10 -0
  101. package/src/Game/Object.ts +16 -0
  102. package/src/Game/Player.ts +5 -0
  103. package/src/Gui/Gui.ts +80 -533
  104. package/src/RpgClient.ts +9 -5
  105. package/src/RpgClientEngine.ts +135 -818
  106. package/src/components/character.ce +104 -0
  107. package/src/components/effects/animation.ce +19 -0
  108. package/src/components/effects/hit.ce +87 -0
  109. package/src/components/effects/index.ts +7 -0
  110. package/src/components/gui/dialogbox/index.ce +194 -0
  111. package/src/components/gui/dialogbox/itemMenu.ce +23 -0
  112. package/src/components/gui/dialogbox/selection.ce +67 -0
  113. package/src/components/gui/index.ts +5 -0
  114. package/src/components/index.ts +3 -0
  115. package/src/components/scenes/canvas.ce +51 -0
  116. package/src/components/scenes/draw-map.ce +56 -0
  117. package/src/components/scenes/element-map.ce +23 -0
  118. package/src/components/scenes/event-layer.ce +20 -0
  119. package/src/core/inject.ts +17 -0
  120. package/src/core/setup.ts +18 -0
  121. package/src/index.ts +13 -29
  122. package/src/module.ts +93 -0
  123. package/src/presets/index.ts +5 -0
  124. package/src/{Presets/AnimationSpritesheet.ts → presets/rmspritesheet.ts} +4 -5
  125. package/src/services/AbstractSocket.ts +14 -0
  126. package/src/services/loadMap.ts +33 -0
  127. package/src/services/mmorpg.ts +64 -0
  128. package/src/services/standalone.ts +101 -0
  129. package/src/types/canvas-engine.d.ts +26 -0
  130. package/tsconfig.json +8 -3
  131. package/vite.config.ts +34 -0
  132. package/CHANGELOG.md +0 -189
  133. package/LICENSE +0 -19
  134. package/browser/React-ece4b906.js +0 -195
  135. package/browser/index-ba657126.js +0 -44229
  136. package/browser/manifest.json +0 -21
  137. package/browser/rpg.client.js +0 -40
  138. package/browser/rpg.client.umd.cjs +0 -44456
  139. package/lib/Components/AbstractComponent.d.ts +0 -32
  140. package/lib/Components/AbstractComponent.js +0 -93
  141. package/lib/Components/AbstractComponent.js.map +0 -1
  142. package/lib/Components/BarComponent.d.ts +0 -21
  143. package/lib/Components/BarComponent.js +0 -169
  144. package/lib/Components/BarComponent.js.map +0 -1
  145. package/lib/Components/Component.d.ts +0 -124
  146. package/lib/Components/Component.js +0 -425
  147. package/lib/Components/Component.js.map +0 -1
  148. package/lib/Components/DebugComponent.d.ts +0 -11
  149. package/lib/Components/DebugComponent.js +0 -32
  150. package/lib/Components/DebugComponent.js.map +0 -1
  151. package/lib/Components/ImageComponent.d.ts +0 -11
  152. package/lib/Components/ImageComponent.js +0 -30
  153. package/lib/Components/ImageComponent.js.map +0 -1
  154. package/lib/Components/ShapeComponent.d.ts +0 -11
  155. package/lib/Components/ShapeComponent.js +0 -57
  156. package/lib/Components/ShapeComponent.js.map +0 -1
  157. package/lib/Components/TextComponent.d.ts +0 -11
  158. package/lib/Components/TextComponent.js +0 -35
  159. package/lib/Components/TextComponent.js.map +0 -1
  160. package/lib/Components/TileComponent.d.ts +0 -10
  161. package/lib/Components/TileComponent.js +0 -40
  162. package/lib/Components/TileComponent.js.map +0 -1
  163. package/lib/Effects/Animation.d.ts +0 -55
  164. package/lib/Effects/Animation.js +0 -233
  165. package/lib/Effects/Animation.js.map +0 -1
  166. package/lib/Effects/AnimationCharacter.d.ts +0 -7
  167. package/lib/Effects/AnimationCharacter.js +0 -9
  168. package/lib/Effects/AnimationCharacter.js.map +0 -1
  169. package/lib/Effects/Spinner.d.ts +0 -7
  170. package/lib/Effects/Spinner.js +0 -18
  171. package/lib/Effects/Spinner.js.map +0 -1
  172. package/lib/Effects/Timeline.d.ts +0 -151
  173. package/lib/Effects/Timeline.js +0 -369
  174. package/lib/Effects/Timeline.js.map +0 -1
  175. package/lib/Effects/TransitionScene.d.ts +0 -18
  176. package/lib/Effects/TransitionScene.js +0 -50
  177. package/lib/Effects/TransitionScene.js.map +0 -1
  178. package/lib/GameEngine.d.ts +0 -68
  179. package/lib/GameEngine.js +0 -254
  180. package/lib/GameEngine.js.map +0 -1
  181. package/lib/Gui/Gui.d.ts +0 -110
  182. package/lib/Gui/Gui.js +0 -489
  183. package/lib/Gui/Gui.js.map +0 -1
  184. package/lib/Gui/React.d.ts +0 -28
  185. package/lib/Gui/React.js +0 -147
  186. package/lib/Gui/React.js.map +0 -1
  187. package/lib/Gui/Vue.d.ts +0 -13
  188. package/lib/Gui/Vue.js +0 -114
  189. package/lib/Gui/Vue.js.map +0 -1
  190. package/lib/Interfaces/Character.d.ts +0 -6
  191. package/lib/Interfaces/Character.js +0 -2
  192. package/lib/Interfaces/Character.js.map +0 -1
  193. package/lib/Interfaces/Scene.d.ts +0 -10
  194. package/lib/Interfaces/Scene.js +0 -2
  195. package/lib/Interfaces/Scene.js.map +0 -1
  196. package/lib/KeyboardControls.d.ts +0 -367
  197. package/lib/KeyboardControls.js +0 -714
  198. package/lib/KeyboardControls.js.map +0 -1
  199. package/lib/Logger.d.ts +0 -1
  200. package/lib/Logger.js +0 -4
  201. package/lib/Logger.js.map +0 -1
  202. package/lib/Presets/AnimationSpritesheet.js +0 -39
  203. package/lib/Presets/AnimationSpritesheet.js.map +0 -1
  204. package/lib/Presets/Scene.d.ts +0 -3
  205. package/lib/Presets/Scene.js +0 -5
  206. package/lib/Presets/Scene.js.map +0 -1
  207. package/lib/Renderer.d.ts +0 -62
  208. package/lib/Renderer.js +0 -300
  209. package/lib/Renderer.js.map +0 -1
  210. package/lib/Resources.d.ts +0 -22
  211. package/lib/Resources.js +0 -38
  212. package/lib/Resources.js.map +0 -1
  213. package/lib/RpgClient.js +0 -2
  214. package/lib/RpgClient.js.map +0 -1
  215. package/lib/RpgClientEngine.d.ts +0 -257
  216. package/lib/RpgClientEngine.js +0 -677
  217. package/lib/RpgClientEngine.js.map +0 -1
  218. package/lib/Scene/EventLayer.d.ts +0 -4
  219. package/lib/Scene/EventLayer.js +0 -8
  220. package/lib/Scene/EventLayer.js.map +0 -1
  221. package/lib/Scene/Map.d.ts +0 -109
  222. package/lib/Scene/Map.js +0 -319
  223. package/lib/Scene/Map.js.map +0 -1
  224. package/lib/Scene/Scene.d.ts +0 -184
  225. package/lib/Scene/Scene.js +0 -250
  226. package/lib/Scene/Scene.js.map +0 -1
  227. package/lib/Scene/SceneData.d.ts +0 -4
  228. package/lib/Scene/SceneData.js +0 -8
  229. package/lib/Scene/SceneData.js.map +0 -1
  230. package/lib/Sound/RpgSound.d.ts +0 -11
  231. package/lib/Sound/RpgSound.js +0 -46
  232. package/lib/Sound/RpgSound.js.map +0 -1
  233. package/lib/Sound/Sound.d.ts +0 -78
  234. package/lib/Sound/Sound.js +0 -12
  235. package/lib/Sound/Sound.js.map +0 -1
  236. package/lib/Sound/Sounds.d.ts +0 -2
  237. package/lib/Sound/Sounds.js +0 -6
  238. package/lib/Sound/Sounds.js.map +0 -1
  239. package/lib/Sprite/Character.d.ts +0 -18
  240. package/lib/Sprite/Character.js +0 -131
  241. package/lib/Sprite/Character.js.map +0 -1
  242. package/lib/Sprite/Player.d.ts +0 -3
  243. package/lib/Sprite/Player.js +0 -4
  244. package/lib/Sprite/Player.js.map +0 -1
  245. package/lib/Sprite/Spritesheet.d.ts +0 -365
  246. package/lib/Sprite/Spritesheet.js +0 -13
  247. package/lib/Sprite/Spritesheet.js.map +0 -1
  248. package/lib/Sprite/Spritesheets.d.ts +0 -3
  249. package/lib/Sprite/Spritesheets.js +0 -6
  250. package/lib/Sprite/Spritesheets.js.map +0 -1
  251. package/lib/Tilemap/CommonLayer.d.ts +0 -10
  252. package/lib/Tilemap/CommonLayer.js +0 -17
  253. package/lib/Tilemap/CommonLayer.js.map +0 -1
  254. package/lib/Tilemap/ImageLayer.d.ts +0 -4
  255. package/lib/Tilemap/ImageLayer.js +0 -16
  256. package/lib/Tilemap/ImageLayer.js.map +0 -1
  257. package/lib/Tilemap/Tile.d.ts +0 -21
  258. package/lib/Tilemap/Tile.js +0 -67
  259. package/lib/Tilemap/Tile.js.map +0 -1
  260. package/lib/Tilemap/TileLayer.d.ts +0 -13
  261. package/lib/Tilemap/TileLayer.js +0 -122
  262. package/lib/Tilemap/TileLayer.js.map +0 -1
  263. package/lib/Tilemap/TileSet.d.ts +0 -7
  264. package/lib/Tilemap/TileSet.js +0 -24
  265. package/lib/Tilemap/TileSet.js.map +0 -1
  266. package/lib/Tilemap/index.d.ts +0 -28
  267. package/lib/Tilemap/index.js +0 -151
  268. package/lib/Tilemap/index.js.map +0 -1
  269. package/lib/clientEntryPoint.d.ts +0 -89
  270. package/lib/clientEntryPoint.js +0 -48
  271. package/lib/clientEntryPoint.js.map +0 -1
  272. package/lib/index.d.ts +0 -26
  273. package/lib/index.js +0 -27
  274. package/lib/index.js.map +0 -1
  275. package/lib/inject.d.ts +0 -23
  276. package/lib/inject.js +0 -30
  277. package/lib/inject.js.map +0 -1
  278. package/rpg.toml +0 -14
  279. package/src/Components/AbstractComponent.ts +0 -120
  280. package/src/Components/BarComponent.ts +0 -181
  281. package/src/Components/Component.ts +0 -515
  282. package/src/Components/DebugComponent.ts +0 -36
  283. package/src/Components/ImageComponent.ts +0 -30
  284. package/src/Components/ShapeComponent.ts +0 -64
  285. package/src/Components/TextComponent.ts +0 -33
  286. package/src/Components/TileComponent.ts +0 -43
  287. package/src/Effects/Animation.ts +0 -310
  288. package/src/Effects/AnimationCharacter.ts +0 -7
  289. package/src/Effects/Spinner.ts +0 -19
  290. package/src/Effects/Timeline.ts +0 -378
  291. package/src/Effects/TransitionScene.ts +0 -59
  292. package/src/GameEngine.ts +0 -289
  293. package/src/Gui/React.ts +0 -193
  294. package/src/Gui/Vue.ts +0 -154
  295. package/src/Interfaces/Character.ts +0 -7
  296. package/src/Interfaces/Scene.ts +0 -9
  297. package/src/KeyboardControls.ts +0 -748
  298. package/src/Logger.ts +0 -3
  299. package/src/Presets/Scene.ts +0 -3
  300. package/src/Renderer.ts +0 -334
  301. package/src/Resources.ts +0 -39
  302. package/src/Scene/EventLayer.ts +0 -9
  303. package/src/Scene/Map.ts +0 -402
  304. package/src/Scene/Scene.ts +0 -305
  305. package/src/Scene/SceneData.ts +0 -13
  306. package/src/Sound/RpgSound.ts +0 -50
  307. package/src/Sound/Sound.ts +0 -91
  308. package/src/Sound/Sounds.ts +0 -7
  309. package/src/Sprite/Character.ts +0 -157
  310. package/src/Sprite/Player.ts +0 -3
  311. package/src/Sprite/Spritesheet.ts +0 -392
  312. package/src/Sprite/Spritesheets.ts +0 -8
  313. package/src/Tilemap/CommonLayer.ts +0 -20
  314. package/src/Tilemap/ImageLayer.ts +0 -20
  315. package/src/Tilemap/Tile.ts +0 -80
  316. package/src/Tilemap/TileLayer.ts +0 -142
  317. package/src/Tilemap/TileSet.ts +0 -40
  318. package/src/Tilemap/index.ts +0 -175
  319. package/src/clientEntryPoint.ts +0 -150
  320. package/src/inject.ts +0 -34
  321. package/src/types/howler.d.ts +0 -73
@@ -0,0 +1,18 @@
1
+ import { Context, FactoryProvider, findProvider, findProviders, inject, injector, Providers } from "@signe/di";
2
+ import { RpgClientEngine } from "../RpgClientEngine";
3
+ import { setInject } from "./inject";
4
+
5
+ interface SetupOptions {
6
+ providers: Providers;
7
+ }
8
+
9
+ export async function startGame(options: SetupOptions) {
10
+ const context = new Context();
11
+ setInject(context);
12
+
13
+ await injector(context, options.providers);
14
+
15
+ const engine = inject(context, RpgClientEngine);
16
+ await engine.start();
17
+ return context;
18
+ }
package/src/index.ts CHANGED
@@ -1,29 +1,13 @@
1
- export { Direction, Control, Input, PrebuiltGui, HookServer, HookClient, RpgPlugin, RpgModule, RpgCommonPlayer as RpgSpriteLogic } from '@rpgjs/common'
2
- export { default as entryPoint } from './clientEntryPoint'
3
- export type { RpgClient, RpgSceneHooks, RpgSceneMapHooks, RpgSpriteHooks, RpgClientEngineHooks } from './RpgClient'
4
- export { RpgRenderer } from './Renderer'
5
- export { Scene as RpgScene } from './Scene/Scene'
6
- export { RpgClientEngine } from './RpgClientEngine'
7
- export { Spritesheet } from './Sprite/Spritesheet'
8
- export { Sound } from './Sound/Sound'
9
- export { Howler as RpgGlobalSound } from 'howler'
10
- export { RpgSound } from './Sound/RpgSound'
11
- export * as Presets from './Presets/AnimationSpritesheet'
12
- export { Animation } from './Effects/AnimationCharacter'
13
- export { Animation as AnimationClass } from './Effects/Animation'
14
- export type { ISpriteCharacter } from './Interfaces/Character'
15
- export { SceneData } from './Scene/SceneData'
16
- export { SceneMap as RpgSceneMap } from './Scene/Map'
17
- export { RpgGui } from './Gui/Gui';
18
- export { Timeline, Ease } from './Effects/Timeline';
19
- export { RpgComponent, RpgComponent as RpgSprite } from './Components/Component'
20
- export { KeyboardControls } from './KeyboardControls'
21
- export { World, room } from 'simple-room-client'
22
-
23
- import { spritesheets } from './Sprite/Spritesheets'
24
- import { sounds } from './Sound/Sounds'
25
- export const RpgResource = {
26
- spritesheets,
27
- sounds
28
- }
29
- export { inject } from './inject'
1
+ export * from "./RpgClientEngine";
2
+ export type * from "./RpgClient";
3
+ export * from "./services/standalone";
4
+ export * from "./services/mmorpg";
5
+ export * from "./core/setup";
6
+ export * from "./core/inject";
7
+ export * from "./services/loadMap";
8
+ export * from "./module";
9
+ export * from "./Gui/Gui";
10
+ export * from "./components/gui";
11
+ export * from "./components/effects";
12
+ export * from "./presets";
13
+ export * from "./components";
package/src/module.ts ADDED
@@ -0,0 +1,93 @@
1
+ import { findModules, provideModules } from "@rpgjs/common";
2
+ import { RpgClientEngine } from "./RpgClientEngine";
3
+ import { RpgClient } from "./RpgClient";
4
+ import { inject } from "@signe/di";
5
+ import { RpgGui } from "./Gui/Gui";
6
+
7
+ export function provideClientModules(modules: RpgClient[]) {
8
+ return provideModules(modules, "client", (modules, context) => {
9
+ const mainModuleClient = findModules(context, 'Client')
10
+ modules = [...mainModuleClient, ...modules]
11
+ modules = modules.map((module) => {
12
+ if ('client' in module) {
13
+ module = module.client as any;
14
+ }
15
+ if (module.spritesheets) {
16
+ const spritesheets = [...module.spritesheets];
17
+ module.spritesheets = {
18
+ load: (engine: RpgClientEngine) => {
19
+ spritesheets.forEach((spritesheet) => {
20
+ engine.addSpriteSheet(spritesheet);
21
+ });
22
+ },
23
+ };
24
+ }
25
+ if (module.sounds) {
26
+ const sounds = [...module.sounds];
27
+ module.sounds = {
28
+ load: (engine: RpgClientEngine) => {
29
+ sounds.forEach((sound) => {
30
+ engine.addSound(sound);
31
+ });
32
+ },
33
+ };
34
+ }
35
+ if (module.gui) {
36
+ const gui = [...module.gui];
37
+ module.gui = {
38
+ load: (engine: RpgClientEngine) => {
39
+ const guiService = inject(engine.context, RpgGui);
40
+ gui.forEach((gui) => {
41
+ guiService.add(gui);
42
+ });
43
+ },
44
+ };
45
+ }
46
+ if (module.effects) {
47
+ const effects = [...module.effects];
48
+ module.effects = {
49
+ load: (engine: RpgClientEngine) => {
50
+ effects.forEach((effect) => {
51
+ engine.addEffect(effect);
52
+ });
53
+ },
54
+ };
55
+ }
56
+ if (module.particles) {
57
+ const particles = [...module.particles];
58
+ module.particles = {
59
+ load: (engine: RpgClientEngine) => {
60
+ particles.forEach((particle) => {
61
+ engine.addParticle(particle);
62
+ });
63
+ },
64
+ };
65
+ }
66
+ return module;
67
+ });
68
+ return modules
69
+ });
70
+ }
71
+
72
+ export const GlobalConfigToken = "GlobalConfigToken";
73
+
74
+ export function provideGlobalConfig(config: any) {
75
+ return {
76
+ provide: GlobalConfigToken,
77
+ useValue: config ?? {},
78
+ };
79
+ }
80
+
81
+ export function provideClientGlobalConfig(config: any = {}) {
82
+ if (!config.keyboardControls) {
83
+ config.keyboardControls = {
84
+ up: 'up',
85
+ down: 'down',
86
+ left: 'left',
87
+ right: 'right',
88
+ action: 'space'
89
+ }
90
+ }
91
+ return provideGlobalConfig(config)
92
+ }
93
+
@@ -0,0 +1,5 @@
1
+ import { RMSpritesheet } from "./rmspritesheet";
2
+
3
+ export const Presets = {
4
+ RMSpritesheet
5
+ }
@@ -1,5 +1,4 @@
1
- import { Direction } from '@rpgjs/common'
2
- import { Animation } from '../Effects/AnimationCharacter'
1
+ import { Direction, Animation } from '@rpgjs/common'
3
2
 
4
3
  export const RMSpritesheet = (framesWidth: number, framesHeight: number, frameStand: number = 1) => {
5
4
 
@@ -31,13 +30,13 @@ export const RMSpritesheet = (framesWidth: number, framesHeight: number, frameSt
31
30
  return {
32
31
  textures: {
33
32
  [Animation.Stand]: {
34
- animations: direction => [stand(direction)]
33
+ animations: ({direction}) => [stand(direction)]
35
34
  },
36
35
  [Animation.Walk]: {
37
- animations: direction => [walk(direction)]
36
+ animations: ({direction}) => [walk(direction)]
38
37
  }
39
38
  },
40
39
  framesHeight,
41
40
  framesWidth
42
41
  }
43
- }
42
+ }
@@ -0,0 +1,14 @@
1
+ import { Context } from "@signe/di";
2
+
3
+ export const WebSocketToken = "websocket";
4
+
5
+ export abstract class AbstractWebsocket {
6
+ constructor(protected context: Context) {}
7
+
8
+ abstract connection(listeners?: (data: any) => void): Promise<void>;
9
+ abstract emit(event: string, data: any): void;
10
+ abstract on(event: string, callback: (data: any) => void): void;
11
+ abstract off(event: string, callback: (data: any) => void): void;
12
+ abstract updateProperties(params: { room: string, host?: string }): void;
13
+ abstract reconnect(listeners?: (data: any) => void): void;
14
+ }
@@ -0,0 +1,33 @@
1
+ import { Context, inject } from "@signe/di";
2
+ import { UpdateMapToken, UpdateMapService } from "@rpgjs/common";
3
+
4
+ export const LoadMapToken = 'LoadMapToken'
5
+
6
+ export type LoadMapOptions = (mapId: string) => Promise<void>
7
+
8
+ export class LoadMapService {
9
+ private updateMapService: UpdateMapService;
10
+
11
+ constructor(private context: Context, private options: LoadMapOptions) {
12
+ this.updateMapService = inject(context, UpdateMapToken);
13
+ }
14
+
15
+ async load(mapId: string) {
16
+ const map = await this.options(mapId.replace('map-', ''))
17
+ await this.updateMapService.update(mapId, map);
18
+ return map;
19
+ }
20
+ }
21
+
22
+ export function provideLoadMap(options: LoadMapOptions) {
23
+ return [
24
+ {
25
+ provide: UpdateMapToken,
26
+ useFactory: (context: Context) => console.warn('UpdateMapToken is not overridden'),
27
+ },
28
+ {
29
+ provide: LoadMapToken,
30
+ useFactory: (context: Context) => new LoadMapService(context, options),
31
+ },
32
+ ];
33
+ }
@@ -0,0 +1,64 @@
1
+ import { Context } from "@signe/di";
2
+ import { connectionRoom } from "@signe/sync/client";
3
+ import { RpgGui } from "../Gui/Gui";
4
+ import { RpgClientEngine } from "../RpgClientEngine";
5
+ import { AbstractWebsocket, WebSocketToken } from "./AbstractSocket";
6
+ import { UpdateMapService, UpdateMapToken } from "@rpgjs/common";
7
+
8
+ interface MmorpgOptions {
9
+ host: string;
10
+ }
11
+
12
+ class BridgeWebsocket extends AbstractWebsocket {
13
+ private socket: any;
14
+
15
+ constructor(protected context: Context, private options: MmorpgOptions) {
16
+ super(context);
17
+ }
18
+
19
+ async connection() {
20
+ // tmp
21
+ class Room {
22
+
23
+ }
24
+ const instance = new Room()
25
+ this.socket = await connectionRoom(this.options, instance)
26
+ }
27
+
28
+ on(key: string, callback: (data: any) => void) {
29
+ this.socket.on(key, callback);
30
+ }
31
+
32
+ off(event: string, callback: (data: any) => void) {
33
+ this.socket.off(event, callback);
34
+ }
35
+
36
+ emit(event: string, data: any) {
37
+ this.socket.emit(event, data);
38
+ }
39
+ }
40
+
41
+ class UpdateMapStandaloneService extends UpdateMapService {
42
+ constructor(protected context: Context, private options: MmorpgOptions) {
43
+ super(context);
44
+ }
45
+
46
+ async update(map: any) {
47
+ // nothing
48
+ }
49
+ }
50
+
51
+ export function provideMmorpg(options: MmorpgOptions) {
52
+ return [
53
+ {
54
+ provide: WebSocketToken,
55
+ useFactory: (context: Context) => new BridgeWebsocket(context, options),
56
+ },
57
+ {
58
+ provide: UpdateMapToken,
59
+ useFactory: (context: Context) => new UpdateMapStandaloneService(context, options),
60
+ },
61
+ RpgGui,
62
+ RpgClientEngine,
63
+ ];
64
+ }
@@ -0,0 +1,101 @@
1
+ import { AbstractWebsocket, WebSocketToken } from "./AbstractSocket";
2
+ import { ClientIo, ServerIo } from "@signe/room";
3
+ import { Context } from "@signe/di";
4
+ import { RpgClientEngine } from "../RpgClientEngine";
5
+ import { UpdateMapService, UpdateMapToken } from "@rpgjs/common";
6
+ import { LoadMapToken } from "./loadMap";
7
+ import { RpgGui } from "../Gui/Gui";
8
+
9
+ type ServerIo = any;
10
+ type ClientIo = any;
11
+
12
+ class BridgeWebsocket extends AbstractWebsocket {
13
+ private room: ServerIo;
14
+ private socket: ClientIo;
15
+
16
+ constructor(protected context: Context, private server: any) {
17
+ super(context);
18
+ // fake room
19
+ this.room = new ServerIo("lobby-1");
20
+ }
21
+
22
+ async connection(listeners?: (data: any) => void) {
23
+ const server = new this.server(this.room);
24
+ await server.onStart();
25
+ this.context.set('server', server)
26
+ this.socket = new ClientIo(server);
27
+ const url = new URL('http://localhost')
28
+ const request = new Request(url.toString(), {
29
+ method: 'GET',
30
+ headers: {
31
+ 'Content-Type': 'application/json'
32
+ }
33
+ })
34
+ listeners?.(this.socket)
35
+ await server.onConnect(this.socket.conn as any, { request } as any);
36
+ this.room.clients.set(this.socket.id, this.socket);
37
+ return this.socket
38
+ }
39
+
40
+ on(key: string, callback: (data: any) => void) {
41
+ this.socket.addEventListener("message", (event) => {
42
+ const object = JSON.parse(event);
43
+ if (object.type === key) {
44
+ callback(object.value);
45
+ }
46
+ });
47
+ }
48
+
49
+ off(event: string, callback: (data: any) => void) {
50
+ this.socket.removeEventListener(event, callback);
51
+ }
52
+
53
+ emit(event: string, data: any) {
54
+ this.socket.send({
55
+ action: event,
56
+ value: data,
57
+ });
58
+ }
59
+
60
+ updateProperties({ room }: { room: any }) {
61
+ this.room = new ServerIo(room);
62
+ }
63
+
64
+ async reconnect(listeners?: (data: any) => void) {
65
+ await this.connection((socket) => {
66
+ listeners?.(socket)
67
+ })
68
+ }
69
+ }
70
+
71
+ class UpdateMapStandaloneService extends UpdateMapService {
72
+ private server: any;
73
+
74
+ async update(mapId: string, map: any) {
75
+ this.server = this.context.get('server')
76
+ const req = {
77
+ url: `http://localhost/parties/main/${mapId}/map/update`,
78
+ method: 'POST',
79
+ headers: new Headers({}),
80
+ json: async () => {
81
+ return map;
82
+ }
83
+ };
84
+ await this.server.onRequest(req)
85
+ }
86
+ }
87
+
88
+ export function provideRpg(server: any) {
89
+ return [
90
+ {
91
+ provide: WebSocketToken,
92
+ useFactory: (context: Context) => new BridgeWebsocket(context, server),
93
+ },
94
+ {
95
+ provide: UpdateMapToken,
96
+ useClass: UpdateMapStandaloneService,
97
+ },
98
+ RpgGui,
99
+ RpgClientEngine,
100
+ ];
101
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Canvas Engine Component Type Declarations
3
+ *
4
+ * This file declares module types for Canvas Engine components (.ce files)
5
+ * to enable TypeScript support and proper import resolution.
6
+ */
7
+
8
+ declare module "*.ce" {
9
+ /**
10
+ * Canvas Engine Component
11
+ *
12
+ * @description Represents a Canvas Engine component that can be imported
13
+ * and used within the application. These components combine template markup
14
+ * with reactive JavaScript logic.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import MyComponent from "./components/my-component.ce";
19
+ *
20
+ * // Use the component in your application
21
+ * const componentInstance = MyComponent;
22
+ * ```
23
+ */
24
+ const component: any;
25
+ export default component;
26
+ }
package/tsconfig.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "sourceMap": true,
10
10
  "strictNullChecks": true,
11
11
  "strictPropertyInitialization": false,
12
- "moduleResolution": "node",
12
+ "moduleResolution": "bundler",
13
13
  "esModuleInterop": true,
14
14
  "removeComments": false,
15
15
  "noUnusedParameters": false,
@@ -24,7 +24,12 @@
24
24
  "skipLibCheck": true
25
25
  },
26
26
  "include": [
27
- "src"
27
+ "src",
28
+ "src/types/**/*",
29
+ "node_modules/canvasengine/*"
30
+ ],
31
+ "typeRoots": [
32
+ "node_modules/@types",
33
+ "src/types"
28
34
  ],
29
-
30
35
  }
package/vite.config.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { defineConfig } from 'vite'
2
+ import canvasengine from '@canvasengine/compiler'
3
+ import dts from 'vite-plugin-dts'
4
+ import path from 'path'
5
+ import { fileURLToPath } from 'url'
6
+
7
+ const dirname = path.dirname(fileURLToPath(import.meta.url))
8
+
9
+ export default defineConfig({
10
+ plugins: [
11
+ canvasengine(),
12
+ dts({
13
+ include: ['src/**/*.ts'],
14
+ outDir: 'dist'
15
+ })
16
+ ],
17
+ build: {
18
+ target: 'esnext',
19
+ sourcemap: true,
20
+ minify: false,
21
+ lib: {
22
+ entry: 'src/index.ts',
23
+ formats: ['es'],
24
+ fileName: 'index'
25
+ },
26
+ rollupOptions: {
27
+ external: [/@rpgjs/, 'esbuild', 'canvasengine', '@canvasengine/presets', 'rxjs'],
28
+ output: {
29
+ preserveModules: true,
30
+ preserveModulesRoot: 'src'
31
+ }
32
+ },
33
+ },
34
+ })
package/CHANGELOG.md DELETED
@@ -1,189 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [4.3.0](https://github.com/RSamaium/RPG-JS/compare/v4.2.2...v4.3.0) (2024-01-29)
7
-
8
-
9
- ### Features
10
-
11
- * loading the game in a React app ([437917a](https://github.com/RSamaium/RPG-JS/commit/437917ace5de1a88777d84c4b39a48e147f77de4))
12
- * reat app integration ([1b9b5d8](https://github.com/RSamaium/RPG-JS/commit/1b9b5d8bb5dd02bcf4a68ccd5eee19c6fc00a4eb))
13
-
14
-
15
-
16
-
17
-
18
- ## [4.2.2](https://github.com/RSamaium/RPG-JS/compare/v4.2.1...v4.2.2) (2024-01-15)
19
-
20
- **Note:** Version bump only for package @rpgjs/client
21
-
22
-
23
-
24
-
25
-
26
- ## [4.2.1](https://github.com/RSamaium/RPG-JS/compare/v4.2.0...v4.2.1) (2024-01-12)
27
-
28
-
29
- ### Bug Fixes
30
-
31
- * #community-261 ([8221085](https://github.com/RSamaium/RPG-JS/commit/8221085a962b1555aa20ba154b6790d4522da971)), closes [#community-261](https://github.com/RSamaium/RPG-JS/issues/community-261)
32
-
33
-
34
-
35
-
36
-
37
- # [4.2.0](https://github.com/RSamaium/RPG-JS/compare/v4.1.3...v4.2.0) (2023-12-09)
38
-
39
-
40
- ### Features
41
-
42
- * inject function ([902e62f](https://github.com/RSamaium/RPG-JS/commit/902e62ff4fdd9b5bd26ee7d5be9ccae2b051f248))
43
- * propagate event directive ([edbab50](https://github.com/RSamaium/RPG-JS/commit/edbab506a2552ff64d2f638d1e088748cbc8cc86))
44
-
45
-
46
-
47
-
48
-
49
- ## [4.1.3](https://github.com/RSamaium/RPG-JS/compare/v4.1.2...v4.1.3) (2023-11-17)
50
-
51
- **Note:** Version bump only for package @rpgjs/client
52
-
53
-
54
-
55
-
56
-
57
- ## [4.1.2](https://github.com/RSamaium/RPG-JS/compare/v4.1.1...v4.1.2) (2023-10-30)
58
-
59
-
60
- ### Bug Fixes
61
-
62
- * **gui:** don't propagate events ([1439e0f](https://github.com/RSamaium/RPG-JS/commit/1439e0fa4718cbdc07cd2ceb8ff4067e116cef9b))
63
-
64
-
65
-
66
-
67
-
68
- ## [4.1.1](https://github.com/RSamaium/RPG-JS/compare/v4.1.0...v4.1.1) (2023-10-27)
69
-
70
-
71
- ### Bug Fixes
72
-
73
- * **gui:** get vue instance #community-215 ([2874815](https://github.com/RSamaium/RPG-JS/commit/287481517028196f1bf8bc327b68134e8f5f63d0)), closes [#community-215](https://github.com/RSamaium/RPG-JS/issues/community-215)
74
- * **scene:** click in scene map ([04d56d6](https://github.com/RSamaium/RPG-JS/commit/04d56d6e07c58e2c039732e35ae3b94fc6751fa5))
75
-
76
-
77
-
78
-
79
-
80
- # [4.1.0](https://github.com/RSamaium/RPG-JS/compare/v4.0.5...v4.1.0) (2023-10-20)
81
-
82
- **Note:** Version bump only for package @rpgjs/client
83
-
84
-
85
-
86
-
87
-
88
- ## 4.0.5 (2023-10-18)
89
-
90
-
91
- ### Bug Fixes
92
-
93
- * flickering motion of an event as it moves ([b2b8832](https://github.com/RSamaium/RPG-JS/commit/b2b8832a1582933afb64c698f40d1b0e72021780))
94
-
95
-
96
-
97
-
98
-
99
- ## 4.0.4 (2023-10-13)
100
-
101
- **Note:** Version bump only for package @rpgjs/client
102
-
103
-
104
-
105
-
106
-
107
- ## 4.0.3 (2023-10-10)
108
-
109
- **Note:** Version bump only for package @rpgjs/client
110
-
111
-
112
-
113
-
114
-
115
- ## 4.0.2 (2023-10-03)
116
-
117
- **Note:** Version bump only for package @rpgjs/client
118
-
119
-
120
-
121
-
122
-
123
- ## 4.0.1 (2023-10-03)
124
-
125
- **Note:** Version bump only for package @rpgjs/client
126
-
127
-
128
-
129
-
130
-
131
- # 4.0.0-rc.13 (2023-09-09)
132
-
133
- **Note:** Version bump only for package @rpgjs/client
134
-
135
-
136
-
137
-
138
-
139
- # 4.0.0-rc.12 (2023-09-08)
140
-
141
- **Note:** Version bump only for package @rpgjs/client
142
-
143
-
144
-
145
-
146
-
147
- # 4.0.0-rc.11 (2023-08-30)
148
-
149
- **Note:** Version bump only for package @rpgjs/client
150
-
151
-
152
-
153
-
154
-
155
- # 4.0.0-rc.10 (2023-08-28)
156
-
157
- **Note:** Version bump only for package @rpgjs/client
158
-
159
-
160
-
161
-
162
-
163
- # 4.0.0-rc.9 (2023-08-25)
164
-
165
- **Note:** Version bump only for package @rpgjs/client
166
-
167
-
168
-
169
-
170
-
171
- # 4.0.0-rc.8 (2023-08-23)
172
-
173
- **Note:** Version bump only for package @rpgjs/client
174
-
175
-
176
-
177
-
178
-
179
- # [4.0.0-rc.6](https://github.com/RSamaium/RPG-JS/compare/v4.0.0-rc.5...v4.0.0-rc.6) (2023-08-20)
180
-
181
- **Note:** Version bump only for package @rpgjs/client
182
-
183
-
184
-
185
-
186
-
187
- # [4.0.0-rc.5](https://github.com/RSamaium/RPG-JS/compare/v4.0.0-rc.4...v4.0.0-rc.5) (2023-08-16)
188
-
189
- **Note:** Version bump only for package @rpgjs/client