@rpgjs/client 5.0.0-beta.1 → 5.0.0-beta.10

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 (200) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +19 -0
  3. package/dist/Game/AnimationManager.d.ts +1 -1
  4. package/dist/Game/AnimationManager.js +18 -9
  5. package/dist/Game/AnimationManager.js.map +1 -1
  6. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  7. package/dist/Game/Event.js.map +1 -1
  8. package/dist/Game/Map.d.ts +9 -1
  9. package/dist/Game/Map.js +63 -5
  10. package/dist/Game/Map.js.map +1 -1
  11. package/dist/Game/Object.d.ts +47 -15
  12. package/dist/Game/Object.js +82 -38
  13. package/dist/Game/Object.js.map +1 -1
  14. package/dist/Game/Player.js.map +1 -1
  15. package/dist/Gui/Gui.d.ts +17 -4
  16. package/dist/Gui/Gui.js +78 -48
  17. package/dist/Gui/Gui.js.map +1 -1
  18. package/dist/Gui/Gui.spec.d.ts +1 -0
  19. package/dist/Gui/NotificationManager.js.map +1 -1
  20. package/dist/Resource.js +1 -1
  21. package/dist/Resource.js.map +1 -1
  22. package/dist/RpgClient.d.ts +57 -2
  23. package/dist/RpgClientEngine.d.ts +61 -6
  24. package/dist/RpgClientEngine.js +122 -14
  25. package/dist/RpgClientEngine.js.map +1 -1
  26. package/dist/Sound.js.map +1 -1
  27. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorate.js +1 -1
  28. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.130.0}/helpers/decorateMetadata.js +1 -1
  29. package/dist/components/animations/animation.ce.js +4 -5
  30. package/dist/components/animations/animation.ce.js.map +1 -1
  31. package/dist/components/animations/hit.ce.js +19 -25
  32. package/dist/components/animations/hit.ce.js.map +1 -1
  33. package/dist/components/animations/index.js +4 -4
  34. package/dist/components/animations/index.js.map +1 -1
  35. package/dist/components/character.ce.js +406 -226
  36. package/dist/components/character.ce.js.map +1 -1
  37. package/dist/components/dynamics/bar.ce.js +96 -0
  38. package/dist/components/dynamics/bar.ce.js.map +1 -0
  39. package/dist/components/dynamics/image.ce.js +23 -0
  40. package/dist/components/dynamics/image.ce.js.map +1 -0
  41. package/dist/components/dynamics/parse-value.d.ts +3 -0
  42. package/dist/components/dynamics/parse-value.js +54 -35
  43. package/dist/components/dynamics/parse-value.js.map +1 -1
  44. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  45. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  46. package/dist/components/dynamics/shape-utils.js +73 -0
  47. package/dist/components/dynamics/shape-utils.js.map +1 -0
  48. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  49. package/dist/components/dynamics/shape.ce.js +83 -0
  50. package/dist/components/dynamics/shape.ce.js.map +1 -0
  51. package/dist/components/dynamics/text.ce.js +33 -56
  52. package/dist/components/dynamics/text.ce.js.map +1 -1
  53. package/dist/components/gui/box.ce.js +6 -8
  54. package/dist/components/gui/box.ce.js.map +1 -1
  55. package/dist/components/gui/dialogbox/index.ce.js +53 -60
  56. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  57. package/dist/components/gui/gameover.ce.js +39 -63
  58. package/dist/components/gui/gameover.ce.js.map +1 -1
  59. package/dist/components/gui/hud/hud.ce.js +21 -30
  60. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  61. package/dist/components/gui/menu/equip-menu.ce.js +110 -164
  62. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  63. package/dist/components/gui/menu/exit-menu.ce.js +6 -5
  64. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  65. package/dist/components/gui/menu/items-menu.ce.js +49 -67
  66. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  67. package/dist/components/gui/menu/main-menu.ce.js +72 -90
  68. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  69. package/dist/components/gui/menu/options-menu.ce.js +5 -4
  70. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  71. package/dist/components/gui/menu/skills-menu.ce.js +12 -17
  72. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  73. package/dist/components/gui/mobile/index.js +2 -2
  74. package/dist/components/gui/mobile/index.js.map +1 -1
  75. package/dist/components/gui/mobile/mobile.ce.js +5 -4
  76. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  77. package/dist/components/gui/notification/notification.ce.js +22 -24
  78. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  79. package/dist/components/gui/save-load.ce.js +70 -248
  80. package/dist/components/gui/save-load.ce.js.map +1 -1
  81. package/dist/components/gui/shop/shop.ce.js +87 -125
  82. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  83. package/dist/components/gui/title-screen.ce.js +42 -68
  84. package/dist/components/gui/title-screen.ce.js.map +1 -1
  85. package/dist/components/player-components-utils.d.ts +67 -0
  86. package/dist/components/player-components-utils.js +162 -0
  87. package/dist/components/player-components-utils.js.map +1 -0
  88. package/dist/components/player-components-utils.spec.d.ts +1 -0
  89. package/dist/components/player-components.ce.js +188 -0
  90. package/dist/components/player-components.ce.js.map +1 -0
  91. package/dist/components/prebuilt/hp-bar.ce.js +41 -44
  92. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  93. package/dist/components/prebuilt/light-halo.ce.js +35 -59
  94. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  95. package/dist/components/scenes/canvas.ce.js +157 -21
  96. package/dist/components/scenes/canvas.ce.js.map +1 -1
  97. package/dist/components/scenes/draw-map.ce.js +19 -29
  98. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  99. package/dist/components/scenes/event-layer.ce.js +9 -8
  100. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  101. package/dist/core/inject.js +1 -1
  102. package/dist/core/inject.js.map +1 -1
  103. package/dist/core/setup.js +1 -1
  104. package/dist/core/setup.js.map +1 -1
  105. package/dist/decorators/spritesheet.d.ts +1 -0
  106. package/dist/decorators/spritesheet.js +11 -0
  107. package/dist/decorators/spritesheet.js.map +1 -0
  108. package/dist/index.d.ts +1 -0
  109. package/dist/index.js +21 -20
  110. package/dist/module.js +4 -1
  111. package/dist/module.js.map +1 -1
  112. package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@3.0.1}/node_modules/@signe/di/dist/index.js +7 -117
  113. package/dist/node_modules/.pnpm/@signe_di@3.0.1/node_modules/@signe/di/dist/index.js.map +1 -0
  114. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js +239 -0
  115. package/dist/node_modules/.pnpm/@signe_reactive@3.0.1/node_modules/@signe/reactive/dist/index.js.map +1 -0
  116. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js +13 -0
  117. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/chunk-EUXUH3YW.js.map +1 -0
  118. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js +696 -0
  119. package/dist/node_modules/.pnpm/@signe_room@3.0.1/node_modules/@signe/room/dist/index.js.map +1 -0
  120. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js +44 -0
  121. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  122. package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@3.0.1}/node_modules/@signe/sync/dist/index.js +57 -141
  123. package/dist/node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js.map +1 -0
  124. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  125. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  126. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +27 -27
  127. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  128. package/dist/presets/animation.js.map +1 -1
  129. package/dist/presets/faceset.js.map +1 -1
  130. package/dist/presets/icon.js.map +1 -1
  131. package/dist/presets/index.js.map +1 -1
  132. package/dist/presets/lpc.js.map +1 -1
  133. package/dist/presets/rmspritesheet.js.map +1 -1
  134. package/dist/services/AbstractSocket.js.map +1 -1
  135. package/dist/services/keyboardControls.js.map +1 -1
  136. package/dist/services/loadMap.d.ts +6 -0
  137. package/dist/services/loadMap.js +1 -1
  138. package/dist/services/loadMap.js.map +1 -1
  139. package/dist/services/mmorpg.js +9 -4
  140. package/dist/services/mmorpg.js.map +1 -1
  141. package/dist/services/save.js.map +1 -1
  142. package/dist/services/save.spec.d.ts +1 -0
  143. package/dist/services/standalone.js +1 -1
  144. package/dist/services/standalone.js.map +1 -1
  145. package/dist/utils/getEntityProp.js +4 -3
  146. package/dist/utils/getEntityProp.js.map +1 -1
  147. package/dist/utils/getEntityProp.spec.d.ts +1 -0
  148. package/dist/utils/readPropValue.d.ts +2 -0
  149. package/dist/utils/readPropValue.js +13 -0
  150. package/dist/utils/readPropValue.js.map +1 -0
  151. package/package.json +13 -14
  152. package/src/Game/AnimationManager.spec.ts +30 -0
  153. package/src/Game/AnimationManager.ts +22 -10
  154. package/src/Game/Map.ts +91 -2
  155. package/src/Game/Object.ts +148 -69
  156. package/src/Gui/Gui.spec.ts +273 -0
  157. package/src/Gui/Gui.ts +105 -50
  158. package/src/Resource.ts +1 -2
  159. package/src/RpgClient.ts +63 -2
  160. package/src/RpgClientEngine.ts +173 -25
  161. package/src/components/character.ce +422 -15
  162. package/src/components/dynamics/bar.ce +87 -0
  163. package/src/components/dynamics/image.ce +20 -0
  164. package/src/components/dynamics/parse-value.spec.ts +83 -0
  165. package/src/components/dynamics/parse-value.ts +111 -37
  166. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  167. package/src/components/dynamics/shape-utils.ts +61 -0
  168. package/src/components/dynamics/shape.ce +89 -0
  169. package/src/components/dynamics/text.ce +34 -149
  170. package/src/components/gui/dialogbox/index.ce +15 -6
  171. package/src/components/player-components-utils.spec.ts +109 -0
  172. package/src/components/player-components-utils.ts +205 -0
  173. package/src/components/player-components.ce +221 -0
  174. package/src/components/scenes/canvas.ce +165 -6
  175. package/src/components/scenes/draw-map.ce +2 -15
  176. package/src/components/scenes/event-layer.ce +1 -2
  177. package/src/core/setup.ts +2 -2
  178. package/src/decorators/spritesheet.ts +8 -0
  179. package/src/index.ts +1 -0
  180. package/src/module.ts +5 -1
  181. package/src/services/loadMap.ts +2 -0
  182. package/src/services/mmorpg.ts +8 -2
  183. package/src/services/save.spec.ts +127 -0
  184. package/src/utils/getEntityProp.spec.ts +96 -0
  185. package/src/utils/getEntityProp.ts +4 -3
  186. package/src/utils/readPropValue.ts +16 -0
  187. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
  188. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +0 -457
  189. package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +0 -1
  190. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
  191. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
  192. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
  193. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
  194. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
  195. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
  196. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
  197. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
  198. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
  199. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
  200. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
@@ -5,6 +5,23 @@ import { RpgClientObject } from './Game/Object';
5
5
  import { MapPhysicsEntityContext, MapPhysicsInitContext } from '@rpgjs/common';
6
6
  type RpgComponent = RpgClientObject;
7
7
  type SceneMap = Container;
8
+ export type SpriteComponentConfig = ComponentFunction | {
9
+ component: ComponentFunction;
10
+ props?: Record<string, any> | ((object: RpgClientObject) => Record<string, any>);
11
+ data?: Record<string, any> | ((object: RpgClientObject) => Record<string, any>);
12
+ dependencies?: (object: RpgClientObject) => any[];
13
+ };
14
+ export interface RpgSpriteBeforeRemoveContext {
15
+ reason?: string;
16
+ data?: any;
17
+ transition?: {
18
+ animation?: string;
19
+ graphic?: string | string[];
20
+ duration?: number;
21
+ effect?: string;
22
+ };
23
+ timeoutMs?: number;
24
+ }
8
25
  export interface RpgClientEngineHooks {
9
26
  /**
10
27
  * When the engine is started. If you send false, you prevent the client from connecting to the server
@@ -74,7 +91,7 @@ export interface RpgSpriteHooks {
74
91
  * }
75
92
  * ```
76
93
  */
77
- componentsBehind?: ComponentFunction[];
94
+ componentsBehind?: SpriteComponentConfig[];
78
95
  /**
79
96
  * Array of components to render in front of the sprite
80
97
  * These components will be displayed with a higher z-index than the sprite itself
@@ -88,7 +105,27 @@ export interface RpgSpriteHooks {
88
105
  * }
89
106
  * ```
90
107
  */
91
- componentsInFront?: ComponentFunction[];
108
+ componentsInFront?: SpriteComponentConfig[];
109
+ /**
110
+ * Reusable sprite components addressable by server-side component definitions.
111
+ *
112
+ * The server sends only the component id and serializable props. The client
113
+ * registry maps that id to the CanvasEngine component that renders it.
114
+ *
115
+ * @prop {Record<string, ComponentFunction>} [components]
116
+ * @memberof RpgSpriteHooks
117
+ * @example
118
+ * ```ts
119
+ * import GuildBadge from './components/guild-badge.ce'
120
+ *
121
+ * const sprite: RpgSpriteHooks = {
122
+ * components: {
123
+ * guildBadge: GuildBadge
124
+ * }
125
+ * }
126
+ * ```
127
+ */
128
+ components?: Record<string, ComponentFunction>;
92
129
  /**
93
130
  * As soon as the sprite is initialized
94
131
  *
@@ -103,6 +140,17 @@ export interface RpgSpriteHooks {
103
140
  * @memberof RpgSpriteHooks
104
141
  */
105
142
  onDestroy?: (sprite: RpgComponent) => any;
143
+ /**
144
+ * Called when a sprite removal is requested, before it disappears from the scene.
145
+ *
146
+ * Return a promise to keep the sprite visible while an animation, effect, or
147
+ * sound transition is running. The server still owns gameplay removal and
148
+ * uses the timeout carried by the remove request as a safety limit.
149
+ *
150
+ * @prop { (sprite: RpgSprite, context: RpgSpriteBeforeRemoveContext) => any } [onBeforeRemove]
151
+ * @memberof RpgSpriteHooks
152
+ */
153
+ onBeforeRemove?: (sprite: RpgComponent, context: RpgSpriteBeforeRemoveContext) => any;
106
154
  /**
107
155
  * As soon as a data is changed on the server side (the name for example), you are able to know the new data but also the old data.
108
156
  *
@@ -457,6 +505,13 @@ export interface RpgClient {
457
505
  * ```
458
506
  */
459
507
  attachToSprite?: boolean;
508
+ /**
509
+ * Vue v4 compatibility alias for `attachToSprite`.
510
+ *
511
+ * Prefer `attachToSprite` in v5 projects. This is read by `@rpgjs/vue`
512
+ * for Vue GUI components migrated from the v4 GUI API.
513
+ */
514
+ rpgAttachToSprite?: boolean;
460
515
  } | any)[];
461
516
  /**
462
517
  * Array containing the list of sounds
@@ -1,9 +1,19 @@
1
+ import { Trigger } from 'canvasengine';
1
2
  import { AbstractWebsocket } from './services/AbstractSocket';
2
3
  import { Direction } from '@rpgjs/common';
3
4
  import { RpgClientMap } from './Game/Map';
4
5
  import { AnimationManager } from './Game/AnimationManager';
5
6
  import { Observable } from 'rxjs';
6
7
  import * as PIXI from "pixi.js";
8
+ type ConfigurableTrigger<T> = Omit<Trigger<T>, "start"> & {
9
+ start(config?: T): Promise<void>;
10
+ };
11
+ type MapShakeOptions = {
12
+ intensity?: number;
13
+ duration?: number;
14
+ frequency?: number;
15
+ direction?: string;
16
+ };
7
17
  export declare class RpgClientEngine<T = any> {
8
18
  context: any;
9
19
  private guiService;
@@ -17,7 +27,7 @@ export declare class RpgClientEngine<T = any> {
17
27
  stopProcessingInput: boolean;
18
28
  width: import('canvasengine').WritableSignal<string>;
19
29
  height: import('canvasengine').WritableSignal<string>;
20
- spritesheets: Map<string, any>;
30
+ spritesheets: Map<string | number, any>;
21
31
  sounds: Map<string, any>;
22
32
  componentAnimations: any[];
23
33
  private spritesheetResolver?;
@@ -32,10 +42,11 @@ export declare class RpgClientEngine<T = any> {
32
42
  playerIdSignal: import('canvasengine').WritableSignal<string | null>;
33
43
  spriteComponentsBehind: import('canvasengine').WritableArraySignal<any[]>;
34
44
  spriteComponentsInFront: import('canvasengine').WritableArraySignal<any[]>;
45
+ spriteComponents: Map<string, any>;
35
46
  /** ID of the sprite that the camera should follow. null means follow the current player */
36
47
  cameraFollowTargetId: import('canvasengine').WritableSignal<string | null>;
37
48
  /** Trigger for map shake animation */
38
- mapShakeTrigger: import('canvasengine').Trigger<any>;
49
+ mapShakeTrigger: ConfigurableTrigger<MapShakeOptions>;
39
50
  controlsReady: import('canvasengine').WritableSignal<undefined>;
40
51
  gamePause: import('canvasengine').WritableSignal<boolean>;
41
52
  private predictionEnabled;
@@ -175,7 +186,7 @@ export declare class RpgClientEngine<T = any> {
175
186
  * });
176
187
  * ```
177
188
  */
178
- setSpritesheetResolver(resolver: (id: string) => any | Promise<any>): void;
189
+ setSpritesheetResolver(resolver: (id: string | number) => any | Promise<any>): void;
179
190
  /**
180
191
  * Get a spritesheet by ID, using resolver if not found in cache
181
192
  *
@@ -183,7 +194,7 @@ export declare class RpgClientEngine<T = any> {
183
194
  * If not found and a resolver is set, it calls the resolver to create the spritesheet.
184
195
  * The resolved spritesheet is automatically cached for future use.
185
196
  *
186
- * @param id - The spritesheet ID to retrieve
197
+ * @param id - The spritesheet ID or legacy tile ID to retrieve
187
198
  * @returns The spritesheet if found or created, or undefined if not found and no resolver
188
199
  * @returns Promise<any> if the resolver is asynchronous
189
200
  *
@@ -196,7 +207,7 @@ export declare class RpgClientEngine<T = any> {
196
207
  * const spritesheet = await engine.getSpriteSheet('dynamic-sprite');
197
208
  * ```
198
209
  */
199
- getSpriteSheet(id: string): any | Promise<any>;
210
+ getSpriteSheet(id: string | number): any | Promise<any>;
200
211
  /**
201
212
  * Add a sound to the engine
202
213
  *
@@ -451,6 +462,30 @@ export declare class RpgClientEngine<T = any> {
451
462
  props: (object: any) => any;
452
463
  dependencies?: (object: any) => any[];
453
464
  }): any;
465
+ /**
466
+ * Register a reusable sprite component that can be addressed by the server.
467
+ *
468
+ * Server-side component definitions only carry the component id and
469
+ * serializable props. The client registry maps that id to the CanvasEngine
470
+ * component that performs the actual rendering.
471
+ *
472
+ * @param id - Stable component id used by server component definitions
473
+ * @param component - CanvasEngine component to render for this id
474
+ * @returns The registered component
475
+ *
476
+ * @example
477
+ * ```ts
478
+ * engine.registerSpriteComponent('guildBadge', GuildBadgeComponent);
479
+ * ```
480
+ */
481
+ registerSpriteComponent(id: string, component: any): any;
482
+ /**
483
+ * Get a reusable sprite component by id.
484
+ *
485
+ * @param id - Component id registered on the client
486
+ * @returns The CanvasEngine component, or undefined when missing
487
+ */
488
+ getSpriteComponent(id: string): any;
454
489
  /**
455
490
  * Add a component animation to the engine
456
491
  *
@@ -520,9 +555,12 @@ export declare class RpgClientEngine<T = any> {
520
555
  * duration: 1000,
521
556
  * onFinish: () => console.log('Fade complete')
522
557
  * });
558
+ *
559
+ * // Wait until the transition component calls onFinish
560
+ * await engine.startTransition('fade', { duration: 1000 });
523
561
  * ```
524
562
  */
525
- startTransition(id: string, props?: any): void;
563
+ startTransition(id: string, props?: any): Promise<void>;
526
564
  processInput({ input }: {
527
565
  input: Direction;
528
566
  }): Promise<void>;
@@ -584,6 +622,22 @@ export declare class RpgClientEngine<T = any> {
584
622
  * ```
585
623
  */
586
624
  clearClientPredictionStates(): void;
625
+ /**
626
+ * Stop local movement immediately and discard pending predicted movement.
627
+ *
628
+ * Use this before a blocking action such as an A-RPG attack, dialog, dash
629
+ * startup, or any client-side state where already buffered movement inputs
630
+ * must not be replayed after server reconciliation.
631
+ *
632
+ * @param player - Player object to stop. Defaults to the current player.
633
+ * @returns `true` when a player was found and interrupted.
634
+ *
635
+ * @example
636
+ * ```ts
637
+ * engine.interruptCurrentPlayerMovement();
638
+ * ```
639
+ */
640
+ interruptCurrentPlayerMovement(player?: any): boolean;
587
641
  /**
588
642
  * Trigger a flash animation on a sprite
589
643
  *
@@ -681,3 +735,4 @@ export declare class RpgClientEngine<T = any> {
681
735
  */
682
736
  clear(): void;
683
737
  }
738
+ export {};
@@ -1,19 +1,24 @@
1
1
  import { inject } from "./core/inject.js";
2
2
  import { WebSocketToken } from "./services/AbstractSocket.js";
3
+ import { getCanMoveValue } from "./utils/readPropValue.js";
3
4
  import { SaveClientService } from "./services/save.js";
4
5
  import { RpgGui } from "./Gui/Gui.js";
5
- import component from "./components/scenes/canvas.ce.js";
6
+ import __ce_component from "./components/scenes/canvas.ce.js";
6
7
  import { LoadMapToken } from "./services/loadMap.js";
7
8
  import { RpgSound } from "./Sound.js";
8
9
  import { RpgResource } from "./Resource.js";
9
- import { load } from "./node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js";
10
+ import { load } from "./node_modules/.pnpm/@signe_sync@3.0.1/node_modules/@signe/sync/dist/index.js";
10
11
  import { RpgClientMap } from "./Game/Map.js";
11
12
  import { AnimationManager } from "./Game/AnimationManager.js";
12
13
  import { GlobalConfigToken } from "./module.js";
13
14
  import { PrebuiltComponentAnimations } from "./components/animations/index.js";
15
+ import __ce_component$1 from "./components/dynamics/text.ce.js";
16
+ import __ce_component$2 from "./components/dynamics/bar.ce.js";
17
+ import __ce_component$3 from "./components/dynamics/shape.ce.js";
18
+ import __ce_component$4 from "./components/dynamics/image.ce.js";
14
19
  import { NotificationManager } from "./Gui/NotificationManager.js";
15
20
  import { Howl, bootstrapCanvas, signal, trigger } from "canvasengine";
16
- import { Direction, ModulesToken, PredictionController } from "@rpgjs/common";
21
+ import { Direction, ModulesToken, PredictionController, normalizeLightingState } from "@rpgjs/common";
17
22
  import { BehaviorSubject, combineLatest, filter, lastValueFrom, switchMap, take } from "rxjs";
18
23
  import * as PIXI from "pixi.js";
19
24
  //#region src/RpgClientEngine.ts
@@ -30,6 +35,7 @@ var RpgClientEngine = class {
30
35
  this.playerIdSignal = signal(null);
31
36
  this.spriteComponentsBehind = signal([]);
32
37
  this.spriteComponentsInFront = signal([]);
38
+ this.spriteComponents = /* @__PURE__ */ new Map();
33
39
  this.cameraFollowTargetId = signal(null);
34
40
  this.mapShakeTrigger = trigger();
35
41
  this.controlsReady = signal(void 0);
@@ -72,6 +78,12 @@ var RpgClientEngine = class {
72
78
  id: "animation",
73
79
  component: PrebuiltComponentAnimations.Animation
74
80
  });
81
+ this.registerSpriteComponent("rpg:text", __ce_component$1);
82
+ this.registerSpriteComponent("rpg:hpBar", __ce_component$2);
83
+ this.registerSpriteComponent("rpg:spBar", __ce_component$2);
84
+ this.registerSpriteComponent("rpg:bar", __ce_component$2);
85
+ this.registerSpriteComponent("rpg:shape", __ce_component$3);
86
+ this.registerSpriteComponent("rpg:image", __ce_component$4);
75
87
  this.predictionEnabled = this.globalConfig?.prediction?.enabled !== false;
76
88
  this.initializePredictionController();
77
89
  }
@@ -122,7 +134,7 @@ var RpgClientEngine = class {
122
134
  this.sceneMap.loadPhysic();
123
135
  this.selector = document.body.querySelector("#rpg");
124
136
  const bootstrapOptions = this.globalConfig?.bootstrapCanvasOptions;
125
- const { app, canvasElement } = await bootstrapCanvas(this.selector, component, bootstrapOptions);
137
+ const { app, canvasElement } = await bootstrapCanvas(this.selector, __ce_component, bootstrapOptions);
126
138
  this.canvasApp = app;
127
139
  this.canvasElement = canvasElement;
128
140
  this.renderer = app.renderer;
@@ -163,7 +175,7 @@ var RpgClientEngine = class {
163
175
  });
164
176
  this.tickSubscriptions.push(tickSubscription);
165
177
  await this.webSocket.connection(() => {
166
- inject(SaveClientService).initialize(this.webSocket);
178
+ inject(SaveClientService).initialize();
167
179
  this.initListeners();
168
180
  this.guiService._initialize();
169
181
  this.startPingPong();
@@ -227,7 +239,8 @@ var RpgClientEngine = class {
227
239
  if ((payload.events || this.sceneMap.events()) !== void 0) this.eventsReceived$.next(true);
228
240
  });
229
241
  this.webSocket.on("pong", (data) => {
230
- this.rtt = Date.now() - data.clientTime;
242
+ const now = Date.now();
243
+ this.rtt = now - data.clientTime;
231
244
  const estimatedTicksInFlight = Math.floor(this.rtt / 2 / (1e3 / 60));
232
245
  const estimatedServerTickNow = data.serverTick + estimatedTicksInFlight;
233
246
  if (this.inputFrameCounter > 0) this.frameOffset = estimatedServerTickNow - data.clientFrame;
@@ -235,6 +248,7 @@ var RpgClientEngine = class {
235
248
  });
236
249
  this.webSocket.on("changeMap", (data) => {
237
250
  this.sceneResetQueued = true;
251
+ this.sceneMap.clearLightSpots();
238
252
  this.cameraFollowTargetId.set(null);
239
253
  const transferToken = typeof data?.transferToken === "string" ? data.transferToken : void 0;
240
254
  this.loadScene(data.mapId, transferToken);
@@ -249,10 +263,15 @@ var RpgClientEngine = class {
249
263
  this.notificationManager.add(data);
250
264
  });
251
265
  this.webSocket.on("setAnimation", (data) => {
252
- const { animationName, nbTimes, object, graphic } = data;
253
- const player = this.sceneMap.getObjectById(object);
254
- if (graphic !== void 0) player.setAnimation(animationName, graphic, nbTimes);
255
- else player.setAnimation(animationName, nbTimes);
266
+ const { animationName, nbTimes, object, graphic, restoreAnimationName, restoreGraphics } = data;
267
+ const player = object ? this.sceneMap.getObjectById(object) : void 0;
268
+ if (!player) return;
269
+ const restoreOptions = {
270
+ restoreAnimationName,
271
+ restoreGraphics
272
+ };
273
+ if (graphic !== void 0) player.setAnimation(animationName, graphic, nbTimes, restoreOptions);
274
+ else player.setAnimation(animationName, nbTimes, restoreOptions);
256
275
  });
257
276
  this.webSocket.on("playSound", (data) => {
258
277
  const { soundId, volume, loop } = data;
@@ -314,6 +333,10 @@ var RpgClientEngine = class {
314
333
  seed: raw.seed
315
334
  });
316
335
  });
336
+ this.webSocket.on("lightingState", (data) => {
337
+ const raw = data && typeof data === "object" && "value" in data ? data.value : data;
338
+ this.sceneMap.lightingState.set(normalizeLightingState(raw));
339
+ });
317
340
  this.webSocket.on("open", () => {
318
341
  this.hooks.callHooks("client-engine-onConnected", this, this.socket).subscribe();
319
342
  this.startPingPong();
@@ -403,7 +426,7 @@ var RpgClientEngine = class {
403
426
  query: transferToken ? { transferToken } : void 0
404
427
  });
405
428
  await this.webSocket.reconnect(() => {
406
- inject(SaveClientService).initialize(this.webSocket);
429
+ inject(SaveClientService).initialize();
407
430
  this.initListeners();
408
431
  this.guiService._initialize();
409
432
  });
@@ -458,7 +481,7 @@ var RpgClientEngine = class {
458
481
  * If not found and a resolver is set, it calls the resolver to create the spritesheet.
459
482
  * The resolved spritesheet is automatically cached for future use.
460
483
  *
461
- * @param id - The spritesheet ID to retrieve
484
+ * @param id - The spritesheet ID or legacy tile ID to retrieve
462
485
  * @returns The spritesheet if found or created, or undefined if not found and no resolver
463
486
  * @returns Promise<any> if the resolver is asynchronous
464
487
  *
@@ -807,6 +830,35 @@ var RpgClientEngine = class {
807
830
  return component;
808
831
  }
809
832
  /**
833
+ * Register a reusable sprite component that can be addressed by the server.
834
+ *
835
+ * Server-side component definitions only carry the component id and
836
+ * serializable props. The client registry maps that id to the CanvasEngine
837
+ * component that performs the actual rendering.
838
+ *
839
+ * @param id - Stable component id used by server component definitions
840
+ * @param component - CanvasEngine component to render for this id
841
+ * @returns The registered component
842
+ *
843
+ * @example
844
+ * ```ts
845
+ * engine.registerSpriteComponent('guildBadge', GuildBadgeComponent);
846
+ * ```
847
+ */
848
+ registerSpriteComponent(id, component) {
849
+ this.spriteComponents.set(id, component);
850
+ return component;
851
+ }
852
+ /**
853
+ * Get a reusable sprite component by id.
854
+ *
855
+ * @param id - Component id registered on the client
856
+ * @returns The CanvasEngine component, or undefined when missing
857
+ */
858
+ getSpriteComponent(id) {
859
+ return this.spriteComponents.get(id);
860
+ }
861
+ /**
810
862
  * Add a component animation to the engine
811
863
  *
812
864
  * Component animations are temporary visual effects that can be displayed
@@ -882,13 +934,34 @@ var RpgClientEngine = class {
882
934
  * duration: 1000,
883
935
  * onFinish: () => console.log('Fade complete')
884
936
  * });
937
+ *
938
+ * // Wait until the transition component calls onFinish
939
+ * await engine.startTransition('fade', { duration: 1000 });
885
940
  * ```
886
941
  */
887
942
  startTransition(id, props = {}) {
888
943
  if (!this.guiService.exists(id)) throw new Error(`Transition with id ${id} not found. Make sure to add it using engine.addTransition() or in your module's transitions property.`);
889
- this.guiService.display(id, props);
944
+ return new Promise((resolve) => {
945
+ let finished = false;
946
+ const finish = (data) => {
947
+ if (finished) return;
948
+ finished = true;
949
+ props?.onFinish?.(data);
950
+ resolve();
951
+ };
952
+ this.guiService.display(id, {
953
+ ...props,
954
+ onFinish: finish
955
+ });
956
+ });
890
957
  }
891
958
  async processInput({ input }) {
959
+ if (this.stopProcessingInput) return;
960
+ const currentPlayer = this.sceneMap.getCurrentPlayer();
961
+ if (!(!currentPlayer || getCanMoveValue(currentPlayer))) {
962
+ this.interruptCurrentPlayerMovement(currentPlayer);
963
+ return;
964
+ }
892
965
  const timestamp = Date.now();
893
966
  let frame;
894
967
  let tick;
@@ -905,7 +978,6 @@ var RpgClientEngine = class {
905
978
  input,
906
979
  playerId: this.playerId
907
980
  }).subscribe();
908
- const currentPlayer = this.sceneMap.getCurrentPlayer();
909
981
  const bodyReady = this.ensureCurrentPlayerBody();
910
982
  if (currentPlayer && bodyReady) {
911
983
  currentPlayer.changeDirection(input);
@@ -920,6 +992,8 @@ var RpgClientEngine = class {
920
992
  }
921
993
  processAction({ action }) {
922
994
  if (this.stopProcessingInput) return;
995
+ const currentPlayer = this.sceneMap.getCurrentPlayer();
996
+ if (!(!currentPlayer || getCanMoveValue(currentPlayer))) return;
923
997
  this.hooks.callHooks("client-engine-onInput", this, {
924
998
  input: "action",
925
999
  playerId: this.playerId
@@ -1008,6 +1082,11 @@ var RpgClientEngine = class {
1008
1082
  }
1009
1083
  flushPendingMovePath() {
1010
1084
  if (!this.predictionEnabled || !this.prediction) return;
1085
+ const player = this.sceneMap?.getCurrentPlayer?.();
1086
+ if (player && !getCanMoveValue(player)) {
1087
+ this.interruptCurrentPlayerMovement(player);
1088
+ return;
1089
+ }
1011
1090
  const pendingInputs = this.prediction.getPendingInputs();
1012
1091
  if (pendingInputs.length === 0) return;
1013
1092
  const latest = pendingInputs[pendingInputs.length - 1];
@@ -1124,6 +1203,31 @@ var RpgClientEngine = class {
1124
1203
  this.lastMovePathSentFrame = 0;
1125
1204
  }
1126
1205
  /**
1206
+ * Stop local movement immediately and discard pending predicted movement.
1207
+ *
1208
+ * Use this before a blocking action such as an A-RPG attack, dialog, dash
1209
+ * startup, or any client-side state where already buffered movement inputs
1210
+ * must not be replayed after server reconciliation.
1211
+ *
1212
+ * @param player - Player object to stop. Defaults to the current player.
1213
+ * @returns `true` when a player was found and interrupted.
1214
+ *
1215
+ * @example
1216
+ * ```ts
1217
+ * engine.interruptCurrentPlayerMovement();
1218
+ * ```
1219
+ */
1220
+ interruptCurrentPlayerMovement(player = this.sceneMap?.getCurrentPlayer?.()) {
1221
+ if (!player) return false;
1222
+ this.sceneMap?.stopMovement?.(player);
1223
+ this.prediction?.clearPendingInputs();
1224
+ this.pendingPredictionFrames = [];
1225
+ this.lastInputTime = 0;
1226
+ this.lastMovePathSentAt = Date.now();
1227
+ this.lastMovePathSentFrame = this.inputFrameCounter;
1228
+ return true;
1229
+ }
1230
+ /**
1127
1231
  * Trigger a flash animation on a sprite
1128
1232
  *
1129
1233
  * This method allows you to trigger a flash effect on any sprite from client-side code.
@@ -1205,6 +1309,10 @@ var RpgClientEngine = class {
1205
1309
  reconcilePrediction(authoritativeState, pendingInputs) {
1206
1310
  const player = this.getCurrentPlayer();
1207
1311
  if (!player) return;
1312
+ if (!getCanMoveValue(player)) {
1313
+ this.interruptCurrentPlayerMovement(player);
1314
+ return;
1315
+ }
1208
1316
  this.sceneMap.stopMovement(player);
1209
1317
  this.applyAuthoritativeState(authoritativeState);
1210
1318
  if (!pendingInputs.length) return;