@rpgjs/client 5.0.0-alpha.2 → 5.0.0-alpha.20

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 (163) hide show
  1. package/dist/Game/AnimationManager.d.ts +8 -0
  2. package/dist/Game/Map.d.ts +7 -1
  3. package/dist/Gui/Gui.d.ts +128 -5
  4. package/dist/RpgClient.d.ts +217 -59
  5. package/dist/RpgClientEngine.d.ts +345 -6
  6. package/dist/Sound.d.ts +199 -0
  7. package/dist/components/animations/index.d.ts +4 -0
  8. package/dist/components/dynamics/parse-value.d.ts +1 -0
  9. package/dist/components/gui/index.d.ts +3 -3
  10. package/dist/components/index.d.ts +3 -1
  11. package/dist/components/prebuilt/index.d.ts +18 -0
  12. package/dist/index.d.ts +4 -1
  13. package/dist/index.js +9 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/index10.js +149 -4
  16. package/dist/index10.js.map +1 -1
  17. package/dist/index11.js +21 -7
  18. package/dist/index11.js.map +1 -1
  19. package/dist/index12.js +6 -4
  20. package/dist/index12.js.map +1 -1
  21. package/dist/index13.js +11 -14
  22. package/dist/index13.js.map +1 -1
  23. package/dist/index14.js +8 -40
  24. package/dist/index14.js.map +1 -1
  25. package/dist/index15.js +187 -180
  26. package/dist/index15.js.map +1 -1
  27. package/dist/index16.js +104 -7
  28. package/dist/index16.js.map +1 -1
  29. package/dist/index17.js +82 -372
  30. package/dist/index17.js.map +1 -1
  31. package/dist/index18.js +361 -26
  32. package/dist/index18.js.map +1 -1
  33. package/dist/index19.js +46 -20
  34. package/dist/index19.js.map +1 -1
  35. package/dist/index2.js +683 -32
  36. package/dist/index2.js.map +1 -1
  37. package/dist/index20.js +5 -2417
  38. package/dist/index20.js.map +1 -1
  39. package/dist/index21.js +383 -97
  40. package/dist/index21.js.map +1 -1
  41. package/dist/index22.js +41 -104
  42. package/dist/index22.js.map +1 -1
  43. package/dist/index23.js +21 -67
  44. package/dist/index23.js.map +1 -1
  45. package/dist/index24.js +2632 -20
  46. package/dist/index24.js.map +1 -1
  47. package/dist/index25.js +107 -34
  48. package/dist/index25.js.map +1 -1
  49. package/dist/index26.js +69 -3
  50. package/dist/index26.js.map +1 -1
  51. package/dist/index27.js +17 -318
  52. package/dist/index27.js.map +1 -1
  53. package/dist/index28.js +24 -22
  54. package/dist/index28.js.map +1 -1
  55. package/dist/index29.js +92 -8
  56. package/dist/index29.js.map +1 -1
  57. package/dist/index3.js +68 -8
  58. package/dist/index3.js.map +1 -1
  59. package/dist/index30.js +37 -7
  60. package/dist/index30.js.map +1 -1
  61. package/dist/index31.js +18 -168
  62. package/dist/index31.js.map +1 -1
  63. package/dist/index32.js +3 -499
  64. package/dist/index32.js.map +1 -1
  65. package/dist/index33.js +332 -9
  66. package/dist/index33.js.map +1 -1
  67. package/dist/index34.js +24 -4400
  68. package/dist/index34.js.map +1 -1
  69. package/dist/index35.js +6 -311
  70. package/dist/index35.js.map +1 -1
  71. package/dist/index36.js +8 -88
  72. package/dist/index36.js.map +1 -1
  73. package/dist/index37.js +182 -56
  74. package/dist/index37.js.map +1 -1
  75. package/dist/index38.js +500 -16
  76. package/dist/index38.js.map +1 -1
  77. package/dist/index39.js +10 -18
  78. package/dist/index39.js.map +1 -1
  79. package/dist/index4.js +23 -5
  80. package/dist/index4.js.map +1 -1
  81. package/dist/index40.js +7 -0
  82. package/dist/index40.js.map +1 -0
  83. package/dist/index41.js +3690 -0
  84. package/dist/index41.js.map +1 -0
  85. package/dist/index42.js +77 -0
  86. package/dist/index42.js.map +1 -0
  87. package/dist/index43.js +6 -0
  88. package/dist/index43.js.map +1 -0
  89. package/dist/index44.js +20 -0
  90. package/dist/index44.js.map +1 -0
  91. package/dist/index45.js +146 -0
  92. package/dist/index45.js.map +1 -0
  93. package/dist/index46.js +12 -0
  94. package/dist/index46.js.map +1 -0
  95. package/dist/index47.js +113 -0
  96. package/dist/index47.js.map +1 -0
  97. package/dist/index48.js +136 -0
  98. package/dist/index48.js.map +1 -0
  99. package/dist/index49.js +137 -0
  100. package/dist/index49.js.map +1 -0
  101. package/dist/index5.js +2 -1
  102. package/dist/index5.js.map +1 -1
  103. package/dist/index50.js +112 -0
  104. package/dist/index50.js.map +1 -0
  105. package/dist/index51.js +141 -0
  106. package/dist/index51.js.map +1 -0
  107. package/dist/index52.js +9 -0
  108. package/dist/index52.js.map +1 -0
  109. package/dist/index53.js +54 -0
  110. package/dist/index53.js.map +1 -0
  111. package/dist/index6.js +1 -1
  112. package/dist/index6.js.map +1 -1
  113. package/dist/index7.js +11 -3
  114. package/dist/index7.js.map +1 -1
  115. package/dist/index8.js +68 -7
  116. package/dist/index8.js.map +1 -1
  117. package/dist/index9.js +230 -15
  118. package/dist/index9.js.map +1 -1
  119. package/dist/presets/animation.d.ts +31 -0
  120. package/dist/presets/faceset.d.ts +30 -0
  121. package/dist/presets/index.d.ts +103 -0
  122. package/dist/presets/lpc.d.ts +89 -0
  123. package/dist/services/loadMap.d.ts +123 -2
  124. package/dist/services/mmorpg.d.ts +9 -4
  125. package/dist/services/standalone.d.ts +51 -2
  126. package/package.json +22 -18
  127. package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
  128. package/src/Game/Map.ts +20 -2
  129. package/src/Game/Object.ts +163 -9
  130. package/src/Gui/Gui.ts +300 -17
  131. package/src/RpgClient.ts +222 -58
  132. package/src/RpgClientEngine.ts +804 -36
  133. package/src/Sound.ts +253 -0
  134. package/src/components/{effects → animations}/animation.ce +3 -6
  135. package/src/components/{effects → animations}/index.ts +1 -1
  136. package/src/components/character.ce +165 -37
  137. package/src/components/dynamics/parse-value.ts +80 -0
  138. package/src/components/dynamics/text.ce +183 -0
  139. package/src/components/gui/box.ce +17 -0
  140. package/src/components/gui/dialogbox/index.ce +73 -35
  141. package/src/components/gui/dialogbox/selection.ce +16 -1
  142. package/src/components/gui/index.ts +3 -4
  143. package/src/components/index.ts +5 -1
  144. package/src/components/prebuilt/hp-bar.ce +255 -0
  145. package/src/components/prebuilt/index.ts +21 -0
  146. package/src/components/scenes/draw-map.ce +6 -23
  147. package/src/components/scenes/event-layer.ce +9 -3
  148. package/src/core/setup.ts +2 -0
  149. package/src/index.ts +5 -2
  150. package/src/module.ts +72 -6
  151. package/src/presets/animation.ts +46 -0
  152. package/src/presets/faceset.ts +60 -0
  153. package/src/presets/index.ts +7 -1
  154. package/src/presets/lpc.ts +108 -0
  155. package/src/services/loadMap.ts +132 -3
  156. package/src/services/mmorpg.ts +27 -5
  157. package/src/services/standalone.ts +68 -6
  158. package/tsconfig.json +1 -1
  159. package/vite.config.ts +1 -1
  160. package/dist/Game/EffectManager.d.ts +0 -5
  161. package/dist/components/effects/index.d.ts +0 -4
  162. package/src/components/scenes/element-map.ce +0 -23
  163. /package/src/components/{effects → animations}/hit.ce +0 -0
@@ -12,18 +12,32 @@ type ClientIo = any;
12
12
  class BridgeWebsocket extends AbstractWebsocket {
13
13
  private room: ServerIo;
14
14
  private socket: ClientIo;
15
+ private rooms = {
16
+ partyFn: async (roomId: string) => {
17
+ this.room = new ServerIo(roomId, this.rooms);
18
+ const server = new this.server(this.room)
19
+ await server.onStart();
20
+ this.context.set('server', server)
21
+ return server
22
+ }
23
+ }
15
24
 
16
25
  constructor(protected context: Context, private server: any) {
17
26
  super(context);
18
27
  // fake room
19
- this.room = new ServerIo("lobby-1");
28
+ this.room = new ServerIo("lobby-1", this.rooms);
20
29
  }
21
30
 
22
31
  async connection(listeners?: (data: any) => void) {
23
32
  const server = new this.server(this.room);
24
33
  await server.onStart();
25
34
  this.context.set('server', server)
26
- this.socket = new ClientIo(server);
35
+ return this._connection(listeners)
36
+ }
37
+
38
+ private async _connection(listeners?: (data: any) => void) {
39
+ const server = this.context.get('server')
40
+ this.socket = new ClientIo(server, 'player-client-id');
27
41
  const url = new URL('http://localhost')
28
42
  const request = new Request(url.toString(), {
29
43
  method: 'GET',
@@ -57,12 +71,45 @@ class BridgeWebsocket extends AbstractWebsocket {
57
71
  });
58
72
  }
59
73
 
74
+ /**
75
+ * Update underlying connection properties before a reconnect
76
+ *
77
+ * Design
78
+ * - Dynamically register a factory for the requested room to ensure a fresh server instance
79
+ * - Swap the internal ServerIo to target the new room
80
+ *
81
+ * @param params - Properties to update
82
+ * @param params.room - The target room id (e.g. `map-simplemap2`)
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * websocket.updateProperties({ room: 'map-simplemap2' })
87
+ * await websocket.reconnect()
88
+ * ```
89
+ */
60
90
  updateProperties({ room }: { room: any }) {
61
- this.room = new ServerIo(room);
91
+ // empty
62
92
  }
63
93
 
94
+ /**
95
+ * Reconnect the client to the current Party room
96
+ *
97
+ * Design
98
+ * - Must be called after `updateProperties()` when switching rooms
99
+ * - Rebuilds the client <-> server bridge and re-triggers connection listeners
100
+ *
101
+ * @param listeners - Optional callback to re-bind event handlers on the new socket
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * websocket.updateProperties({ room: 'map-dungeon' })
106
+ * await websocket.reconnect((socket) => {
107
+ * // re-bind events here
108
+ * })
109
+ * ```
110
+ */
64
111
  async reconnect(listeners?: (data: any) => void) {
65
- await this.connection((socket) => {
112
+ await this._connection((socket) => {
66
113
  listeners?.(socket)
67
114
  })
68
115
  }
@@ -71,10 +118,25 @@ class BridgeWebsocket extends AbstractWebsocket {
71
118
  class UpdateMapStandaloneService extends UpdateMapService {
72
119
  private server: any;
73
120
 
74
- async update(mapId: string, map: any) {
121
+ /**
122
+ * Update the current room map data on the server side
123
+ *
124
+ * Design
125
+ * - Uses the in-memory server instance stored in context (standalone mode)
126
+ * - Builds a local HTTP-like request to the current Party room endpoint
127
+ *
128
+ * @param map - The map payload to apply on the server
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * await updateMapService.update({ width: 1024, height: 768, events: [] })
133
+ * ```
134
+ */
135
+ async update(map: any) {
75
136
  this.server = this.context.get('server')
137
+ const roomId = this.server?.room?.id ?? 'lobby-1'
76
138
  const req = {
77
- url: `http://localhost/parties/main/${mapId}/map/update`,
139
+ url: `http://localhost/parties/main/${roomId}/map/update`,
78
140
  method: 'POST',
79
141
  headers: new Headers({}),
80
142
  json: async () => {
package/tsconfig.json CHANGED
@@ -30,6 +30,6 @@
30
30
  ],
31
31
  "typeRoots": [
32
32
  "node_modules/@types",
33
- "src/types"
33
+ "node_modules/@rpgjs/client"
34
34
  ],
35
35
  }
package/vite.config.ts CHANGED
@@ -24,7 +24,7 @@ export default defineConfig({
24
24
  fileName: 'index'
25
25
  },
26
26
  rollupOptions: {
27
- external: [/@rpgjs/, 'esbuild', 'canvasengine', '@canvasengine/presets', 'rxjs'],
27
+ external: [/@rpgjs/, 'esbuild', 'canvasengine', '@canvasengine/presets', 'rxjs', 'pixi.js'],
28
28
  output: {
29
29
  preserveModules: true,
30
30
  preserveModulesRoot: 'src'
@@ -1,5 +0,0 @@
1
- import { RpgCommonPlayer } from '@rpgjs/common';
2
- export declare class EffectManager {
3
- current: import('canvasengine').WritableArraySignal<any[]>;
4
- displayEffect(params: any, player: RpgCommonPlayer): void;
5
- }
@@ -1,4 +0,0 @@
1
- export declare const PrebuiltEffects: {
2
- Hit: any;
3
- Animation: any;
4
- };
@@ -1,23 +0,0 @@
1
- <Sprite image rectangle x y zIndex />
2
-
3
- <script>
4
- const {
5
- image,
6
- rect,
7
- drawIn,
8
- id,
9
- } = defineProps()
10
-
11
- const rectangle = {
12
- x: rect[0],
13
- y: rect[1],
14
- width: rect[2],
15
- height: rect[3]
16
- }
17
-
18
- const x = drawIn[0]
19
- const y = drawIn[1]
20
-
21
- const zIndex = y + rectangle.height
22
- </script>
23
-
File without changes