@rpgjs/client 5.0.0-alpha.22 → 5.0.0-alpha.24

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 (134) hide show
  1. package/dist/Game/Object.d.ts +2 -0
  2. package/dist/RpgClientEngine.d.ts +115 -9
  3. package/dist/components/gui/mobile/index.d.ts +8 -0
  4. package/dist/components/prebuilt/index.d.ts +1 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.js +13 -8
  7. package/dist/index.js.map +1 -1
  8. package/dist/index10.js +1 -1
  9. package/dist/index11.js +6 -5
  10. package/dist/index11.js.map +1 -1
  11. package/dist/index12.js +2 -2
  12. package/dist/index13.js +102 -10
  13. package/dist/index13.js.map +1 -1
  14. package/dist/index14.js +67 -9
  15. package/dist/index14.js.map +1 -1
  16. package/dist/index15.js +10 -263
  17. package/dist/index15.js.map +1 -1
  18. package/dist/index16.js +9 -97
  19. package/dist/index16.js.map +1 -1
  20. package/dist/index17.js +300 -89
  21. package/dist/index17.js.map +1 -1
  22. package/dist/index18.js +63 -80
  23. package/dist/index18.js.map +1 -1
  24. package/dist/index19.js +96 -348
  25. package/dist/index19.js.map +1 -1
  26. package/dist/index2.js +176 -24
  27. package/dist/index2.js.map +1 -1
  28. package/dist/index20.js +360 -17
  29. package/dist/index20.js.map +1 -1
  30. package/dist/index21.js +19 -50
  31. package/dist/index21.js.map +1 -1
  32. package/dist/index22.js +212 -5
  33. package/dist/index22.js.map +1 -1
  34. package/dist/index23.js +6 -395
  35. package/dist/index23.js.map +1 -1
  36. package/dist/index24.js +4 -39
  37. package/dist/index24.js.map +1 -1
  38. package/dist/index25.js +19 -20
  39. package/dist/index25.js.map +1 -1
  40. package/dist/index26.js +43 -2624
  41. package/dist/index26.js.map +1 -1
  42. package/dist/index27.js +5 -110
  43. package/dist/index27.js.map +1 -1
  44. package/dist/index28.js +394 -65
  45. package/dist/index28.js.map +1 -1
  46. package/dist/index29.js +40 -15
  47. package/dist/index29.js.map +1 -1
  48. package/dist/index3.js +3 -3
  49. package/dist/index30.js +21 -23
  50. package/dist/index30.js.map +1 -1
  51. package/dist/index31.js +2624 -86
  52. package/dist/index31.js.map +1 -1
  53. package/dist/index32.js +107 -34
  54. package/dist/index32.js.map +1 -1
  55. package/dist/index33.js +69 -22
  56. package/dist/index33.js.map +1 -1
  57. package/dist/index34.js +19 -3
  58. package/dist/index34.js.map +1 -1
  59. package/dist/index35.js +21 -329
  60. package/dist/index35.js.map +1 -1
  61. package/dist/index36.js +91 -30
  62. package/dist/index36.js.map +1 -1
  63. package/dist/index37.js +37 -7
  64. package/dist/index37.js.map +1 -1
  65. package/dist/index38.js +22 -9
  66. package/dist/index38.js.map +1 -1
  67. package/dist/index39.js +139 -10
  68. package/dist/index39.js.map +1 -1
  69. package/dist/index4.js +3 -3
  70. package/dist/index40.js +16 -6
  71. package/dist/index40.js.map +1 -1
  72. package/dist/index41.js +1 -325
  73. package/dist/index41.js.map +1 -1
  74. package/dist/index42.js +530 -3680
  75. package/dist/index42.js.map +1 -1
  76. package/dist/index43.js +24 -67
  77. package/dist/index43.js.map +1 -1
  78. package/dist/index44.js +9 -184
  79. package/dist/index44.js.map +1 -1
  80. package/dist/index45.js +6 -503
  81. package/dist/index45.js.map +1 -1
  82. package/dist/index46.js +325 -2
  83. package/dist/index46.js.map +1 -1
  84. package/dist/index47.js +3687 -17
  85. package/dist/index47.js.map +1 -1
  86. package/dist/index48.js +69 -202
  87. package/dist/index48.js.map +1 -1
  88. package/dist/index49.js +182 -7
  89. package/dist/index49.js.map +1 -1
  90. package/dist/index5.js +1 -1
  91. package/dist/index50.js +497 -106
  92. package/dist/index50.js.map +1 -1
  93. package/dist/index51.js +48 -130
  94. package/dist/index51.js.map +1 -1
  95. package/dist/index52.js +17 -134
  96. package/dist/index52.js.map +1 -1
  97. package/dist/index53.js +3 -109
  98. package/dist/index53.js.map +1 -1
  99. package/dist/index54.js +9 -138
  100. package/dist/index54.js.map +1 -1
  101. package/dist/index55.js +111 -7
  102. package/dist/index55.js.map +1 -1
  103. package/dist/index56.js +130 -48
  104. package/dist/index56.js.map +1 -1
  105. package/dist/index57.js +137 -0
  106. package/dist/index57.js.map +1 -0
  107. package/dist/index58.js +112 -0
  108. package/dist/index58.js.map +1 -0
  109. package/dist/index59.js +9 -0
  110. package/dist/index59.js.map +1 -0
  111. package/dist/index6.js +1 -1
  112. package/dist/index7.js +1 -1
  113. package/dist/index8.js +17 -2
  114. package/dist/index8.js.map +1 -1
  115. package/dist/index9.js +10 -27
  116. package/dist/index9.js.map +1 -1
  117. package/dist/services/keyboardControls.d.ts +1 -2
  118. package/dist/services/mmorpg.d.ts +1 -1
  119. package/dist/services/standalone.d.ts +1 -1
  120. package/package.json +9 -9
  121. package/src/Game/Object.ts +8 -0
  122. package/src/Gui/Gui.ts +4 -31
  123. package/src/RpgClientEngine.ts +193 -20
  124. package/src/components/character.ce +146 -9
  125. package/src/components/gui/mobile/index.ts +24 -0
  126. package/src/components/gui/mobile/mobile.ce +80 -0
  127. package/src/components/prebuilt/index.ts +1 -0
  128. package/src/components/prebuilt/light-halo.ce +148 -0
  129. package/src/components/scenes/canvas.ce +2 -2
  130. package/src/components/scenes/event-layer.ce +1 -0
  131. package/src/components/scenes/transition.ce +60 -0
  132. package/src/index.ts +6 -1
  133. package/src/module.ts +15 -0
  134. package/src/services/keyboardControls.ts +1 -1
package/dist/index22.js CHANGED
@@ -1,9 +1,216 @@
1
- const WebSocketToken = "websocket";
2
- class AbstractWebsocket {
3
- constructor(context) {
4
- this.context = context;
1
+ import { RpgCommonPlayer, ModulesToken } from '@rpgjs/common';
2
+ import { trigger, signal } from 'canvasengine';
3
+ import { map, filter, switchMap, from } from 'rxjs';
4
+ import { inject } from './index6.js';
5
+ import { RpgClientEngine } from './index2.js';
6
+ import component from './index39.js';
7
+
8
+ const DYNAMIC_COMPONENTS = {
9
+ text: component
10
+ };
11
+ class RpgClientObject extends RpgCommonPlayer {
12
+ constructor() {
13
+ super();
14
+ this.emitParticleTrigger = trigger();
15
+ this.particleName = signal("");
16
+ this.animationCurrentIndex = signal(0);
17
+ this.animationIsPlaying = signal(false);
18
+ this._param = signal({});
19
+ this.frames = [];
20
+ this.graphicsSignals = signal([]);
21
+ this._component = {};
22
+ // temporary component memory
23
+ this.flashTrigger = trigger();
24
+ this.hooks.callHooks("client-sprite-onInit", this).subscribe();
25
+ this._frames.observable.subscribe(({ items }) => {
26
+ if (!this.id) return;
27
+ this.frames = [...this.frames, ...items];
28
+ });
29
+ this.graphics.observable.pipe(
30
+ map(({ items }) => items),
31
+ filter((graphics) => graphics.length > 0),
32
+ switchMap((graphics) => from(Promise.all(graphics.map((graphic) => this.engine.getSpriteSheet(graphic)))))
33
+ ).subscribe((sheets) => {
34
+ this.graphicsSignals.set(sheets);
35
+ });
36
+ this.componentsTop.observable.pipe(
37
+ filter((value) => value !== null && value !== void 0),
38
+ map((value) => typeof value === "string" ? JSON.parse(value) : value)
39
+ ).subscribe(({ components }) => {
40
+ for (const component of components) {
41
+ for (const [key, value] of Object.entries(component)) {
42
+ this._component = value;
43
+ console.log(value);
44
+ const type = value.type;
45
+ if (DYNAMIC_COMPONENTS[type]) {
46
+ this.engine.addSpriteComponentInFront(DYNAMIC_COMPONENTS[type]);
47
+ }
48
+ }
49
+ }
50
+ });
51
+ this.engine.tick.pipe().subscribe(() => {
52
+ const frame = this.frames.shift();
53
+ if (frame) {
54
+ if (!frame.x || !frame.y) return;
55
+ this.engine.scene.setBodyPosition(
56
+ this.id,
57
+ frame.x,
58
+ frame.y,
59
+ "top-left"
60
+ );
61
+ }
62
+ });
63
+ }
64
+ get hooks() {
65
+ return inject(ModulesToken);
66
+ }
67
+ get engine() {
68
+ return inject(RpgClientEngine);
69
+ }
70
+ /**
71
+ * Trigger a flash animation on this sprite
72
+ *
73
+ * This method triggers a flash effect using CanvasEngine's flash directive.
74
+ * The flash can be configured with various options including type (alpha, tint, or both),
75
+ * duration, cycles, and color.
76
+ *
77
+ * ## Design
78
+ *
79
+ * The flash uses a trigger system that is connected to the flash directive in the
80
+ * character component. This allows for flexible configuration and can be triggered
81
+ * from both server events and client-side code.
82
+ *
83
+ * @param options - Flash configuration options
84
+ * @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')
85
+ * @param options.duration - Duration of the flash animation in milliseconds (default: 300)
86
+ * @param options.cycles - Number of flash cycles (flash on/off) (default: 1)
87
+ * @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)
88
+ * @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // Simple flash with default settings (alpha flash)
93
+ * player.flash();
94
+ *
95
+ * // Flash with red tint
96
+ * player.flash({ type: 'tint', tint: 0xff0000 });
97
+ *
98
+ * // Flash with both alpha and tint
99
+ * player.flash({
100
+ * type: 'both',
101
+ * alpha: 0.5,
102
+ * tint: 0xff0000,
103
+ * duration: 200,
104
+ * cycles: 2
105
+ * });
106
+ *
107
+ * // Quick damage flash
108
+ * player.flash({
109
+ * type: 'tint',
110
+ * tint: 0xff0000,
111
+ * duration: 150,
112
+ * cycles: 1
113
+ * });
114
+ * ```
115
+ */
116
+ flash(options) {
117
+ const flashOptions = {
118
+ type: options?.type || "alpha",
119
+ duration: options?.duration ?? 300,
120
+ cycles: options?.cycles ?? 1,
121
+ alpha: options?.alpha ?? 0.3,
122
+ tint: options?.tint ?? 16777215
123
+ };
124
+ let tintValue = flashOptions.tint;
125
+ if (typeof tintValue === "string") {
126
+ const colorMap = {
127
+ "white": 16777215,
128
+ "red": 16711680,
129
+ "green": 65280,
130
+ "blue": 255,
131
+ "yellow": 16776960,
132
+ "cyan": 65535,
133
+ "magenta": 16711935,
134
+ "black": 0
135
+ };
136
+ tintValue = colorMap[tintValue.toLowerCase()] ?? 16777215;
137
+ }
138
+ this.flashTrigger.start({
139
+ ...flashOptions,
140
+ tint: tintValue
141
+ });
142
+ }
143
+ /**
144
+ * Reset animation state when animation changes externally
145
+ *
146
+ * This method should be called when the animation changes due to movement
147
+ * or other external factors to ensure the animation system doesn't get stuck
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * // Reset when player starts moving
152
+ * player.resetAnimationState();
153
+ * ```
154
+ */
155
+ resetAnimationState() {
156
+ this.animationIsPlaying.set(false);
157
+ this.animationCurrentIndex.set(0);
158
+ if (this.animationSubscription) {
159
+ this.animationSubscription.unsubscribe();
160
+ this.animationSubscription = void 0;
161
+ }
162
+ }
163
+ /**
164
+ * Set a custom animation for a specific number of times
165
+ *
166
+ * Plays a custom animation for the specified number of repetitions.
167
+ * The animation system prevents overlapping animations and automatically
168
+ * returns to the previous animation when complete.
169
+ *
170
+ * @param animationName - Name of the animation to play
171
+ * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * // Play attack animation 3 times
176
+ * player.setAnimation('attack', 3);
177
+ *
178
+ * // Play continuous spell animation
179
+ * player.setAnimation('spell');
180
+ * ```
181
+ */
182
+ setAnimation(animationName, nbTimes = Infinity) {
183
+ if (this.animationIsPlaying()) return;
184
+ this.animationIsPlaying.set(true);
185
+ const previousAnimationName = this.animationName();
186
+ this.animationCurrentIndex.set(0);
187
+ if (this.animationSubscription) {
188
+ this.animationSubscription.unsubscribe();
189
+ }
190
+ this.animationSubscription = this.animationCurrentIndex.observable.subscribe((index) => {
191
+ if (index >= nbTimes) {
192
+ this.animationCurrentIndex.set(0);
193
+ this.animationName.set(previousAnimationName);
194
+ this.animationIsPlaying.set(false);
195
+ if (this.animationSubscription) {
196
+ this.animationSubscription.unsubscribe();
197
+ this.animationSubscription = void 0;
198
+ }
199
+ }
200
+ });
201
+ this.animationName.set(animationName);
202
+ }
203
+ showComponentAnimation(id, params) {
204
+ const engine = inject(RpgClientEngine);
205
+ engine.getComponentAnimation(id).displayEffect(params, this);
206
+ }
207
+ isEvent() {
208
+ return this.type === "event";
209
+ }
210
+ isPlayer() {
211
+ return this.type === "player";
5
212
  }
6
213
  }
7
214
 
8
- export { AbstractWebsocket, WebSocketToken };
215
+ export { RpgClientObject };
9
216
  //# sourceMappingURL=index22.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index22.js","sources":["../src/services/AbstractSocket.ts"],"sourcesContent":["import { Context } from \"@signe/di\";\n\nexport const WebSocketToken = \"websocket\";\n\nexport abstract class AbstractWebsocket {\n constructor(protected context: Context) {}\n\n abstract connection(listeners?: (data: any) => void): Promise<void>;\n abstract emit(event: string, data: any): void;\n abstract on(event: string, callback: (data: any) => void): void;\n abstract off(event: string, callback: (data: any) => void): void;\n abstract updateProperties(params: { room: string, host?: string }): void;\n abstract reconnect(listeners?: (data: any) => void): void;\n}\n"],"names":[],"mappings":"AAEO,MAAM,cAAA,GAAiB;AAEvB,MAAe,iBAAA,CAAkB;AAAA,EACtC,YAAsB,OAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA,EAAmB;AAQ3C;;;;"}
1
+ {"version":3,"file":"index22.js","sources":["../src/Game/Object.ts"],"sourcesContent":["import { Hooks, ModulesToken, RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal } from \"canvasengine\";\nimport { filter, from, map, Subscription, switchMap } from \"rxjs\";\nimport { inject } from \"../core/inject\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\nimport TextComponent from \"../components/dynamics/text.ce\";\n\nconst DYNAMIC_COMPONENTS = {\n text: TextComponent,\n}\n\nexport abstract class RpgClientObject extends RpgCommonPlayer {\n abstract type: string;\n emitParticleTrigger = trigger();\n particleName = signal(\"\");\n animationCurrentIndex = signal(0);\n animationIsPlaying = signal(false);\n _param = signal({});\n frames: { x: number; y: number; ts: number }[] = [];\n graphicsSignals = signal<any[]>([]);\n _component = {} // temporary component memory\n flashTrigger = trigger();\n\n constructor() {\n super();\n this.hooks.callHooks(\"client-sprite-onInit\", this).subscribe();\n\n this._frames.observable.subscribe(({ items }) => {\n if (!this.id) return;\n //if (this.id == this.engine.playerIdSignal()!) return;\n this.frames = [...this.frames, ...items];\n });\n\n this.graphics.observable\n .pipe(\n map(({ items }) => items),\n filter(graphics => graphics.length > 0),\n switchMap(graphics => from(Promise.all(graphics.map(graphic => this.engine.getSpriteSheet(graphic)))))\n )\n .subscribe((sheets) => { \n this.graphicsSignals.set(sheets);\n });\n\n this.componentsTop.observable\n .pipe(\n filter(value => value !== null && value !== undefined),\n map((value) => typeof value === 'string' ? JSON.parse(value) : value),\n )\n .subscribe(({components}) => {\n for (const component of components) {\n for (const [key, value] of Object.entries(component)) {\n this._component = value as any; // temporary component memory\n console.log(value)\n const type = (value as any).type as keyof typeof DYNAMIC_COMPONENTS;\n if (DYNAMIC_COMPONENTS[type]) {\n this.engine.addSpriteComponentInFront(DYNAMIC_COMPONENTS[type]);\n }\n }\n }\n });\n\n this.engine.tick\n .pipe\n //throttleTime(10)\n ()\n .subscribe(() => {\n const frame = this.frames.shift();\n if (frame) {\n if (!frame.x || !frame.y) return;\n this.engine.scene.setBodyPosition(\n this.id,\n frame.x,\n frame.y,\n \"top-left\"\n );\n }\n });\n }\n\n get hooks() {\n return inject<Hooks>(ModulesToken);\n }\n\n get engine() {\n return inject(RpgClientEngine);\n }\n\n private animationSubscription?: Subscription;\n\n /**\n * Trigger a flash animation on this sprite\n * \n * This method triggers a flash effect using CanvasEngine's flash directive.\n * The flash can be configured with various options including type (alpha, tint, or both),\n * duration, cycles, and color.\n * \n * ## Design\n * \n * The flash uses a trigger system that is connected to the flash directive in the\n * character component. This allows for flexible configuration and can be triggered\n * from both server events and client-side code.\n * \n * @param options - Flash configuration options\n * @param options.type - Type of flash effect: 'alpha' (opacity), 'tint' (color), or 'both' (default: 'alpha')\n * @param options.duration - Duration of the flash animation in milliseconds (default: 300)\n * @param options.cycles - Number of flash cycles (flash on/off) (default: 1)\n * @param options.alpha - Alpha value when flashing, from 0 to 1 (default: 0.3)\n * @param options.tint - Tint color when flashing as hex value or color name (default: 0xffffff - white)\n * \n * @example\n * ```ts\n * // Simple flash with default settings (alpha flash)\n * player.flash();\n * \n * // Flash with red tint\n * player.flash({ type: 'tint', tint: 0xff0000 });\n * \n * // Flash with both alpha and tint\n * player.flash({ \n * type: 'both', \n * alpha: 0.5, \n * tint: 0xff0000,\n * duration: 200,\n * cycles: 2\n * });\n * \n * // Quick damage flash\n * player.flash({ \n * type: 'tint', \n * tint: 0xff0000, \n * duration: 150,\n * cycles: 1\n * });\n * ```\n */\n flash(options?: {\n type?: 'alpha' | 'tint' | 'both';\n duration?: number;\n cycles?: number;\n alpha?: number;\n tint?: number | string;\n }): void {\n const flashOptions = {\n type: options?.type || 'alpha',\n duration: options?.duration ?? 300,\n cycles: options?.cycles ?? 1,\n alpha: options?.alpha ?? 0.3,\n tint: options?.tint ?? 0xffffff,\n };\n \n // Convert color name to hex if needed\n let tintValue = flashOptions.tint;\n if (typeof tintValue === 'string') {\n // Common color name to hex mapping\n const colorMap: Record<string, number> = {\n 'white': 0xffffff,\n 'red': 0xff0000,\n 'green': 0x00ff00,\n 'blue': 0x0000ff,\n 'yellow': 0xffff00,\n 'cyan': 0x00ffff,\n 'magenta': 0xff00ff,\n 'black': 0x000000,\n };\n tintValue = colorMap[tintValue.toLowerCase()] ?? 0xffffff;\n }\n \n this.flashTrigger.start({\n ...flashOptions,\n tint: tintValue,\n });\n }\n\n /**\n * Reset animation state when animation changes externally\n *\n * This method should be called when the animation changes due to movement\n * or other external factors to ensure the animation system doesn't get stuck\n *\n * @example\n * ```ts\n * // Reset when player starts moving\n * player.resetAnimationState();\n * ```\n */\n resetAnimationState() {\n this.animationIsPlaying.set(false);\n this.animationCurrentIndex.set(0);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n\n /**\n * Set a custom animation for a specific number of times\n *\n * Plays a custom animation for the specified number of repetitions.\n * The animation system prevents overlapping animations and automatically\n * returns to the previous animation when complete.\n *\n * @param animationName - Name of the animation to play\n * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)\n *\n * @example\n * ```ts\n * // Play attack animation 3 times\n * player.setAnimation('attack', 3);\n *\n * // Play continuous spell animation\n * player.setAnimation('spell');\n * ```\n */\n setAnimation(animationName: string, nbTimes: number = Infinity) {\n if (this.animationIsPlaying()) return;\n this.animationIsPlaying.set(true);\n const previousAnimationName = this.animationName();\n this.animationCurrentIndex.set(0);\n\n // Clean up any existing subscription\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n }\n\n this.animationSubscription =\n this.animationCurrentIndex.observable.subscribe((index) => {\n if (index >= nbTimes) {\n this.animationCurrentIndex.set(0);\n this.animationName.set(previousAnimationName);\n this.animationIsPlaying.set(false);\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n }\n });\n this.animationName.set(animationName);\n }\n\n showComponentAnimation(id: string, params: any) {\n const engine = inject(RpgClientEngine);\n engine.getComponentAnimation(id).displayEffect(params, this);\n }\n \n isEvent(): boolean {\n return this.type === 'event';\n }\n\n isPlayer(): boolean {\n return this.type === 'player';\n }\n}\n"],"names":["TextComponent"],"mappings":";;;;;;;AAOA,MAAM,kBAAA,GAAqB;AAAA,EACzB,IAAA,EAAMA;AACR,CAAA;AAEO,MAAe,wBAAwB,eAAA,CAAgB;AAAA,EAY5D,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AAXR,IAAA,IAAA,CAAA,mBAAA,GAAsB,OAAA,EAAQ;AAC9B,IAAA,IAAA,CAAA,YAAA,GAAe,OAAO,EAAE,CAAA;AACxB,IAAA,IAAA,CAAA,qBAAA,GAAwB,OAAO,CAAC,CAAA;AAChC,IAAA,IAAA,CAAA,kBAAA,GAAqB,OAAO,KAAK,CAAA;AACjC,IAAA,IAAA,CAAA,MAAA,GAAS,MAAA,CAAO,EAAE,CAAA;AAClB,IAAA,IAAA,CAAA,MAAA,GAAiD,EAAC;AAClD,IAAA,IAAA,CAAA,eAAA,GAAkB,MAAA,CAAc,EAAE,C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A,CAAO,qBAAA,CAAsB,EAAE,CAAA,CAAE,aAAA,CAAc,QAAQ,IAAI,CAAA;AAAA,EAC7D;AAAA,EAEA,OAAA,GAAmB;AACjB,IAAA,OAAO,KAAK,IAAA,KAAS,OAAA;AAAA,EACvB;AAAA,EAEA,QAAA,GAAoB;AAClB,IAAA,OAAO,KAAK,IAAA,KAAS,QAAA;AAAA,EACvB;AACF;;;;"}
package/dist/index23.js CHANGED
@@ -1,400 +1,11 @@
1
- import { __name } from './index34.js';
2
- import { isSignal, isComputed, isObjectSubject, isArraySubject } from './index35.js';
1
+ import { RpgClientObject } from './index22.js';
3
2
 
4
- // src/utils.ts
5
- function isFunction(val) {
6
- return {}.toString.call(val) === "[object Function]";
7
- }
8
- __name(isFunction, "isFunction");
9
- function isClass(obj) {
10
- return typeof obj === "function" && obj.prototype && obj.prototype.constructor === obj;
11
- }
12
- __name(isClass, "isClass");
13
- var isObject = /* @__PURE__ */ __name((item) => item && typeof item === "object" && !Array.isArray(item) && item !== null, "isObject");
14
- function isInstanceOfClass(value) {
15
- if (value === null || typeof value !== "object" || value === void 0 || Array.isArray(value)) {
16
- return false;
17
- }
18
- return Object.getPrototypeOf(value) !== Object.prototype;
19
- }
20
- __name(isInstanceOfClass, "isInstanceOfClass");
21
- function generateShortUUID() {
22
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
23
- let uuid = "";
24
- for (let i = 0; i < 8; i++) {
25
- const randomIndex = Math.floor(Math.random() * chars.length);
26
- uuid += chars[randomIndex];
27
- }
28
- return uuid;
29
- }
30
- __name(generateShortUUID, "generateShortUUID");
31
-
32
- // src/core.ts
33
- var DELETE_TOKEN = "$delete";
34
- var syncClass = /* @__PURE__ */ __name((instance, options = {}) => {
35
- const cacheSync = /* @__PURE__ */ new Map();
36
- const cachePersist = /* @__PURE__ */ new Map();
37
- instance.$valuesChanges = {
38
- set: /* @__PURE__ */ __name((path, value) => {
39
- cacheSync.set(path, value);
40
- options.onSync?.(cacheSync);
41
- }, "set"),
42
- setPersist: /* @__PURE__ */ __name((path, value) => {
43
- if (path == "") path = ".";
44
- cachePersist.set(path, value);
45
- options.onPersist?.(cachePersist);
46
- }, "setPersist"),
47
- has: /* @__PURE__ */ __name((path) => {
48
- return cacheSync.has(path);
49
- }, "has"),
50
- get: /* @__PURE__ */ __name((path) => {
51
- return cacheSync.get(path);
52
- }, "get")
53
- };
54
- createSyncClass(instance);
55
- }, "syncClass");
56
- function createStatesSnapshot(instance) {
57
- let persistObject = {};
58
- if (instance?.$snapshot) {
59
- for (const key of instance.$snapshot.keys()) {
60
- const signal = instance.$snapshot.get(key);
61
- const persist2 = signal.options.persist ?? true;
62
- let value = signal();
63
- if (isObject(value) || Array.isArray(value)) {
64
- continue;
65
- }
66
- if (persist2) {
67
- persistObject[key] = value;
68
- }
69
- }
70
- }
71
- return persistObject;
72
- }
73
- __name(createStatesSnapshot, "createStatesSnapshot");
74
- function setMetadata(target, key, value) {
75
- const meta = target.constructor._propertyMetadata;
76
- const propId = meta?.get(key);
77
- if (propId) {
78
- if (isSignal(target[propId])) {
79
- target[propId].set(value);
80
- } else {
81
- target[propId] = value;
82
- }
83
- }
84
- }
85
- __name(setMetadata, "setMetadata");
86
- var createSyncClass = /* @__PURE__ */ __name((currentClass, parentKey = null, parentClass = null, path = "") => {
87
- currentClass.$path = path;
88
- if (parentClass) {
89
- currentClass.$valuesChanges = parentClass.$valuesChanges;
90
- }
91
- if (parentKey) {
92
- setMetadata(currentClass, "id", parentKey);
93
- }
94
- if (currentClass.$snapshot) {
95
- for (const key of currentClass.$snapshot.keys()) {
96
- const signal = currentClass.$snapshot.get(key);
97
- const syncToClient = signal.options?.syncToClient ?? true;
98
- const persist2 = signal.options?.persist ?? true;
99
- const transform = signal.options?.transform;
100
- let signalValue = signal();
101
- if (transform) {
102
- signalValue = transform(signalValue);
103
- }
104
- if (isObject(signalValue) || Array.isArray(signalValue)) {
105
- signalValue = {
106
- ...signalValue
107
- };
108
- }
109
- const transformedValue = signalValue;
110
- const newPath = (path ? path + "." : "") + key;
111
- if (syncToClient) {
112
- currentClass.$valuesChanges.set(newPath, transformedValue);
113
- }
114
- if (persist2) {
115
- if (parentClass) currentClass.$valuesChanges.setPersist(path, transformedValue);
116
- }
117
- if (isComputed(signal)) {
118
- signal.observable.subscribe((newValue) => {
119
- if (syncToClient) {
120
- const transformedNewValue = transform ? transform(newValue) : newValue;
121
- currentClass.$valuesChanges.set(newPath, transformedNewValue);
122
- }
123
- });
124
- }
125
- }
126
- }
127
- }, "createSyncClass");
128
- var type = /* @__PURE__ */ __name((_signal, path, options = {}, currentInstance) => {
129
- const { syncToClient = true, persist: persist2 = true, transform } = options;
130
- let init = true;
131
- const handleObjectSubject = /* @__PURE__ */ __name((value, propPath) => {
132
- const newPath = `${propPath}${value.key ? `.${value.key}` : ""}`;
133
- if ([
134
- "add",
135
- "reset",
136
- "update"
137
- ].includes(value.type)) {
138
- if (isInstanceOfClass(value.value)) {
139
- createSyncClass(value.value, value.key, currentInstance, newPath);
140
- } else if (value.type === "update" && (isObject(value.value) || Array.isArray(value.value))) {
141
- createSyncClass(value.value, value.key, currentInstance, newPath);
142
- } else {
143
- savePath(newPath, value.value);
144
- }
145
- } else if (value.type === "remove") {
146
- savePath(newPath, DELETE_TOKEN);
147
- }
148
- }, "handleObjectSubject");
149
- const handleArraySubject = /* @__PURE__ */ __name((value, propPath) => {
150
- if (value.type === "reset" && Array.isArray(value.items)) {
151
- value.items.forEach((item, index) => {
152
- const newPath2 = `${propPath}.${index}`;
153
- if (isInstanceOfClass(item)) {
154
- createSyncClass(item, value.key, currentInstance, newPath2);
155
- } else {
156
- savePath(newPath2, item);
157
- }
158
- });
159
- return;
160
- }
161
- const newPath = `${propPath}.${value.index}`;
162
- const firstItem = value.items?.[0];
163
- if ([
164
- "add",
165
- "update"
166
- ].includes(value.type) && firstItem !== void 0) {
167
- if (isInstanceOfClass(firstItem)) {
168
- createSyncClass(firstItem, value.key, currentInstance, newPath);
169
- } else if (value.type === "update" && (isObject(firstItem) || Array.isArray(firstItem))) {
170
- createSyncClass(firstItem, value.key, currentInstance, newPath);
171
- } else {
172
- savePath(newPath, firstItem);
173
- }
174
- } else if (value.type === "remove") {
175
- savePath(newPath, DELETE_TOKEN);
176
- }
177
- }, "handleArraySubject");
178
- const savePath = /* @__PURE__ */ __name((propPath, value) => {
179
- const transformedValue = transform && value !== DELETE_TOKEN ? transform(value) : value;
180
- if (syncToClient) {
181
- currentInstance.$valuesChanges.set(propPath, transformedValue);
182
- }
183
- if (persist2 && currentInstance.$path !== void 0) {
184
- currentInstance.$valuesChanges.setPersist(transformedValue == DELETE_TOKEN ? propPath : currentInstance.$path, transformedValue);
185
- }
186
- }, "savePath");
187
- const setupSubscription = /* @__PURE__ */ __name((signal, signalPath) => {
188
- if (!isSignal(signal)) return;
189
- if (syncToClient && currentInstance.$valuesChanges) {
190
- const initialValue = signal();
191
- const transformedInitialValue = transform ? transform(initialValue) : initialValue;
192
- currentInstance.$valuesChanges.set(signalPath, transformedInitialValue);
193
- }
194
- signal.options = options;
195
- signal.observable.subscribe((value) => {
196
- if (init) return;
197
- if (currentInstance.$path !== void 0) {
198
- const fullPath = `${currentInstance.$path ? currentInstance.$path + "." : ""}${signalPath}`;
199
- if (isComputed(signal)) {
200
- savePath(fullPath, value);
201
- } else if (isObjectSubject(signal._subject)) {
202
- handleObjectSubject(value, fullPath);
203
- } else if (isArraySubject(signal._subject)) {
204
- handleArraySubject(value, fullPath);
205
- } else {
206
- savePath(fullPath, value);
207
- }
208
- }
209
- });
210
- if (!currentInstance.$snapshot) {
211
- currentInstance.$snapshot = /* @__PURE__ */ new Map();
212
- }
213
- currentInstance.$snapshot.set(path, signal);
214
- }, "setupSubscription");
215
- if (!isSignal(_signal)) {
216
- if (_signal && typeof _signal === "object" && !Array.isArray(_signal)) {
217
- for (const key in _signal) {
218
- if (Object.prototype.hasOwnProperty.call(_signal, key)) {
219
- const value = _signal[key];
220
- const propertyPath = `${path}.${key}`;
221
- if (isSignal(value)) {
222
- setupSubscription(value, propertyPath);
223
- } else if (value && typeof value === "object" && !Array.isArray(value)) {
224
- type(value, propertyPath, options, currentInstance);
225
- }
226
- }
227
- }
228
- init = false;
229
- }
230
- return _signal;
231
- }
232
- setupSubscription(_signal, path);
233
- init = false;
234
- return _signal;
235
- }, "type");
236
-
237
- // src/decorators.ts
238
- function sync(options) {
239
- let classType;
240
- let persist2 = true;
241
- let syncToClient = true;
242
- let transform;
243
- if (typeof options === "function") {
244
- classType = options;
245
- } else if (typeof options === "object") {
246
- classType = options.classType;
247
- if (options.hasOwnProperty("persist")) {
248
- persist2 = options.persist;
249
- }
250
- if (options.hasOwnProperty("syncToClient")) {
251
- syncToClient = options.syncToClient;
252
- }
253
- if (options.hasOwnProperty("transform")) {
254
- transform = options.transform;
255
- }
256
- }
257
- return function(target, propertyKey) {
258
- const privatePropertyKey = `__${propertyKey}`;
259
- const getter = /* @__PURE__ */ __name(function() {
260
- return this[privatePropertyKey];
261
- }, "getter");
262
- const setter = /* @__PURE__ */ __name(function(newVal) {
263
- this[privatePropertyKey] = type(newVal, propertyKey, {
264
- classType,
265
- persist: persist2,
266
- syncToClient,
267
- transform
268
- }, this);
269
- }, "setter");
270
- Object.defineProperty(target, propertyKey, {
271
- get: getter,
272
- set: setter,
273
- enumerable: true,
274
- configurable: true
275
- });
276
- };
277
- }
278
- __name(sync, "sync");
279
- function id() {
280
- return function(target, propertyKey) {
281
- if (!target.constructor._propertyMetadata) {
282
- target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
283
- }
284
- target.constructor._propertyMetadata.set("id", propertyKey);
285
- };
286
- }
287
- __name(id, "id");
288
- function users(options) {
289
- return function(target, propertyKey) {
290
- if (!target.constructor._propertyMetadata) {
291
- target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
292
- }
293
- target.constructor._propertyMetadata.set("users", propertyKey);
294
- sync(options)(target, propertyKey);
295
- };
296
- }
297
- __name(users, "users");
298
- function persist() {
299
- return sync({
300
- persist: true,
301
- syncToClient: false
302
- });
303
- }
304
- __name(persist, "persist");
305
- function connected() {
306
- return function(target, propertyKey) {
307
- if (!target.constructor._propertyMetadata) {
308
- target.constructor._propertyMetadata = /* @__PURE__ */ new Map();
309
- }
310
- target.constructor._propertyMetadata.set("connected", propertyKey);
311
- sync({
312
- persist: false
313
- })(target, propertyKey);
314
- };
315
- }
316
- __name(connected, "connected");
317
- function load(rootInstance, values, valueIsObject) {
318
- if (valueIsObject) {
319
- loadFromObject(rootInstance, values);
320
- } else {
321
- loadFromPaths(rootInstance, values);
322
- }
323
- }
324
- __name(load, "load");
325
- function loadFromPaths(rootInstance, values) {
326
- for (const [path, value] of Object.entries(values)) {
327
- const parts = path.split(".");
328
- loadValue(rootInstance, parts, value);
329
- }
330
- }
331
- __name(loadFromPaths, "loadFromPaths");
332
- function loadFromObject(rootInstance, values, currentPath = "") {
333
- for (let key in values) {
334
- const value = values[key];
335
- const newPath = currentPath ? `${currentPath}.${key}` : key;
336
- if (typeof value === "object" && !Array.isArray(value) && value !== null) {
337
- loadFromObject(rootInstance, value, newPath);
338
- } else {
339
- const parts = newPath.split(".");
340
- loadValue(rootInstance, parts, value);
341
- }
342
- }
343
- }
344
- __name(loadFromObject, "loadFromObject");
345
- function loadValue(rootInstance, parts, value) {
346
- let current = rootInstance;
347
- for (let i = 0; i < parts.length; i++) {
348
- const part = parts[i];
349
- if (i === parts.length - 1) {
350
- if (value == DELETE_TOKEN) {
351
- if (isSignal(current)) {
352
- current = current();
353
- }
354
- Reflect.deleteProperty(current, part);
355
- } else if (current[part]?._subject) {
356
- current[part].set(value);
357
- } else if (isSignal(current) && Array.isArray(current()) && !isNaN(Number(part))) {
358
- current()[Number(part)] = value;
359
- } else {
360
- current[part] = value;
361
- }
362
- } else {
363
- if (isSignal(current)) {
364
- current = current();
365
- }
366
- const currentValue = current[part];
367
- if (currentValue === void 0) {
368
- const parentInstance = getByPath(rootInstance, parts.slice(0, i).join("."));
369
- const classType = parentInstance?.options?.classType;
370
- if (classType) {
371
- current[part] = !isClass(classType) ? classType(part) : new classType();
372
- setMetadata(current[part], "id", part);
373
- } else {
374
- current[part] = {};
375
- }
376
- }
377
- current = current[part];
378
- }
379
- }
380
- }
381
- __name(loadValue, "loadValue");
382
- function getByPath(root, path) {
383
- const parts = path.split(".");
384
- let current = root;
385
- for (const part of parts) {
386
- if (isSignal(current)) {
387
- current = current();
388
- }
389
- if (current[part]) {
390
- current = current[part];
391
- } else {
392
- return void 0;
393
- }
3
+ class RpgClientPlayer extends RpgClientObject {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.type = "player";
394
7
  }
395
- return current;
396
8
  }
397
- __name(getByPath, "getByPath");
398
9
 
399
- export { DELETE_TOKEN, connected, createStatesSnapshot, createSyncClass, generateShortUUID, getByPath, id, isClass, isFunction, isInstanceOfClass, isObject, load, persist, setMetadata, sync, syncClass, type, users };
10
+ export { RpgClientPlayer };
400
11
  //# sourceMappingURL=index23.js.map