@rpgjs/client 5.0.0-alpha.10 → 5.0.0-alpha.11

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 (72) hide show
  1. package/dist/Game/Map.d.ts +4 -0
  2. package/dist/Gui/Gui.d.ts +82 -5
  3. package/dist/RpgClient.d.ts +35 -5
  4. package/dist/RpgClientEngine.d.ts +3 -0
  5. package/dist/components/gui/index.d.ts +3 -3
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +6 -5
  8. package/dist/index.js.map +1 -1
  9. package/dist/index10.js +105 -4
  10. package/dist/index10.js.map +1 -1
  11. package/dist/index11.js +20 -7
  12. package/dist/index11.js.map +1 -1
  13. package/dist/index12.js +6 -8
  14. package/dist/index12.js.map +1 -1
  15. package/dist/index13.js +9 -14
  16. package/dist/index13.js.map +1 -1
  17. package/dist/index14.js +8 -100
  18. package/dist/index14.js.map +1 -1
  19. package/dist/index15.js +141 -35
  20. package/dist/index15.js.map +1 -1
  21. package/dist/index16.js +45 -186
  22. package/dist/index16.js.map +1 -1
  23. package/dist/index17.js +229 -5
  24. package/dist/index17.js.map +1 -1
  25. package/dist/index18.js +5 -383
  26. package/dist/index18.js.map +1 -1
  27. package/dist/index19.js +384 -28
  28. package/dist/index19.js.map +1 -1
  29. package/dist/index2.js +15 -8
  30. package/dist/index2.js.map +1 -1
  31. package/dist/index20.js +31 -17
  32. package/dist/index20.js.map +1 -1
  33. package/dist/index21.js +17 -2413
  34. package/dist/index21.js.map +1 -1
  35. package/dist/index22.js +2587 -88
  36. package/dist/index22.js.map +1 -1
  37. package/dist/index23.js +108 -103
  38. package/dist/index23.js.map +1 -1
  39. package/dist/index29.js.map +1 -1
  40. package/dist/index3.js +2 -2
  41. package/dist/index30.js +14 -1
  42. package/dist/index30.js.map +1 -1
  43. package/dist/index37.js +56 -169
  44. package/dist/index37.js.map +1 -1
  45. package/dist/index38.js +162 -489
  46. package/dist/index38.js.map +1 -1
  47. package/dist/index39.js +496 -56
  48. package/dist/index39.js.map +1 -1
  49. package/dist/index4.js +2 -2
  50. package/dist/index41.js +21 -7
  51. package/dist/index41.js.map +1 -1
  52. package/dist/index5.js +1 -1
  53. package/dist/index6.js +1 -1
  54. package/dist/index7.js +1 -1
  55. package/dist/index8.js +1 -1
  56. package/dist/index9.js +105 -14
  57. package/dist/index9.js.map +1 -1
  58. package/dist/services/mmorpg.d.ts +1 -1
  59. package/dist/services/standalone.d.ts +1 -1
  60. package/package.json +7 -5
  61. package/src/Game/AnimationManager.ts +1 -0
  62. package/src/Game/Map.ts +9 -1
  63. package/src/Game/Object.ts +28 -6
  64. package/src/Gui/Gui.ts +141 -16
  65. package/src/RpgClient.ts +36 -5
  66. package/src/RpgClientEngine.ts +11 -1
  67. package/src/components/character.ce +11 -9
  68. package/src/components/gui/box.ce +17 -0
  69. package/src/components/gui/dialogbox/index.ce +1 -0
  70. package/src/components/gui/index.ts +3 -4
  71. package/src/components/scenes/event-layer.ce +6 -0
  72. package/src/index.ts +2 -1
@@ -1,7 +1,11 @@
1
1
  import { RpgCommonMap } from '@rpgjs/common';
2
2
  import { RpgClientPlayer } from './Player';
3
3
  import { RpgClientEvent } from './Event';
4
+ import { RpgClientEngine } from '../RpgClientEngine';
4
5
  export declare class RpgClientMap extends RpgCommonMap<RpgClientPlayer> {
6
+ engine: RpgClientEngine;
5
7
  players: import('canvasengine').WritableObjectSignal<Record<string, RpgClientPlayer>>;
6
8
  events: import('canvasengine').WritableObjectSignal<Record<string, RpgClientEvent>>;
9
+ currentPlayer: import('canvasengine').ComputedSignal<RpgClientPlayer>;
10
+ getCurrentPlayer(): RpgClientPlayer;
7
11
  }
package/dist/Gui/Gui.d.ts CHANGED
@@ -1,23 +1,100 @@
1
1
  import { Context } from '@signe/di';
2
+ import { Signal, WritableSignal } from 'canvasengine';
3
+ import { Subscription } from 'rxjs';
2
4
  interface GuiOptions {
3
- name: string;
5
+ name?: string;
6
+ id?: string;
4
7
  component: any;
5
8
  display?: boolean;
6
9
  data?: any;
10
+ /**
11
+ * Auto display the GUI when added to the system
12
+ * @default false
13
+ */
14
+ autoDisplay?: boolean;
15
+ /**
16
+ * Function that returns an array of Signal dependencies
17
+ * The GUI will only display when all dependencies are resolved (!= undefined)
18
+ * @returns Array of Signal dependencies
19
+ */
20
+ dependencies?: () => Signal[];
21
+ }
22
+ interface GuiInstance {
23
+ name: string;
24
+ component: any;
25
+ display: WritableSignal<boolean>;
26
+ data: WritableSignal<any>;
27
+ autoDisplay: boolean;
28
+ dependencies?: () => Signal[];
29
+ subscription?: Subscription;
7
30
  }
8
31
  export declare class RpgGui {
9
32
  private context;
10
33
  private webSocket;
11
- gui: import('canvasengine').WritableArraySignal<any>;
34
+ gui: import('canvasengine').WritableObjectSignal<Record<string, GuiInstance>>;
12
35
  constructor(context: Context);
13
36
  _initialize(): Promise<void>;
14
37
  guiInteraction(guiId: string, name: string, data: any): void;
15
38
  guiClose(guiId: string, data?: any): void;
39
+ /**
40
+ * Add a GUI component to the system
41
+ *
42
+ * @param gui - GUI configuration options
43
+ * @param gui.name - Name or ID of the GUI component
44
+ * @param gui.id - Alternative ID if name is not provided
45
+ * @param gui.component - The component to render
46
+ * @param gui.display - Initial display state (default: false)
47
+ * @param gui.data - Initial data for the component
48
+ * @param gui.autoDisplay - Auto display when added (default: false)
49
+ * @param gui.dependencies - Function returning Signal dependencies
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * gui.add({
54
+ * name: 'inventory',
55
+ * component: InventoryComponent,
56
+ * autoDisplay: true,
57
+ * dependencies: () => [playerSignal, inventorySignal]
58
+ * });
59
+ * ```
60
+ */
16
61
  add(gui: GuiOptions): void;
17
- get(id: string | GuiOptions): any;
62
+ get(id: string): GuiInstance | undefined;
18
63
  exists(id: string): boolean;
19
- getAll(): any;
20
- display(id: string, data?: {}): void;
64
+ getAll(): Record<string, GuiInstance>;
65
+ /**
66
+ * Display a GUI component
67
+ *
68
+ * Displays the GUI immediately if no dependencies are configured,
69
+ * or waits for all dependencies to be resolved if dependencies are present.
70
+ * Automatically manages subscriptions to prevent memory leaks.
71
+ *
72
+ * @param id - The GUI component ID
73
+ * @param data - Data to pass to the component
74
+ * @param dependencies - Optional runtime dependencies (overrides config dependencies)
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * // Display immediately
79
+ * gui.display('inventory', { items: [] });
80
+ *
81
+ * // Display with runtime dependencies
82
+ * gui.display('shop', { shopId: 1 }, [playerSignal, shopSignal]);
83
+ * ```
84
+ */
85
+ display(id: string, data?: {}, dependencies?: Signal[]): void;
86
+ /**
87
+ * Hide a GUI component
88
+ *
89
+ * Hides the GUI and cleans up any active subscriptions.
90
+ *
91
+ * @param id - The GUI component ID
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * gui.hide('inventory');
96
+ * ```
97
+ */
21
98
  hide(id: string): void;
22
99
  }
23
100
  export {};
@@ -1,7 +1,8 @@
1
- import { ComponentFunction } from 'canvasengine';
1
+ import { ComponentFunction, Signal } from 'canvasengine';
2
2
  import { RpgClientEngine } from './RpgClientEngine';
3
3
  import { Loader, Container } from 'pixi.js';
4
- type RpgComponent = Container;
4
+ import { RpgClientObject } from './Game/Object';
5
+ type RpgComponent = RpgClientObject;
5
6
  type SceneMap = Container;
6
7
  export interface RpgClientEngineHooks {
7
8
  /**
@@ -283,15 +284,43 @@ export interface RpgClient {
283
284
  * */
284
285
  spritesheets?: any[];
285
286
  /**
286
- * Array containing the list of VueJS components
287
+ * Array containing the list of GUI components
287
288
  *
289
+ * ```ts
290
+ * import { defineModule, RpgClient } from '@rpgjs/client'
291
+ * import InventoryComponent from './inventory.ce'
292
+ *
293
+ * defineModule<RpgClient>({
294
+ * gui: [
295
+ * {
296
+ * id: 'inventory',
297
+ * component: InventoryComponent,
298
+ * autoDisplay: true,
299
+ * dependencies: () => [playerSignal, inventorySignal]
300
+ * }
301
+ * ]
302
+ * })
303
+ * ```
288
304
  *
289
305
  * [Guide: Create GUI](/guide/create-gui.html)
290
306
  *
291
- * @prop {Array<Component of CanvasEngine>} [gui]
307
+ * @prop {Array<GuiOptions>} [gui]
292
308
  * @memberof RpgClient
293
309
  * */
294
- gui?: ComponentFunction[];
310
+ gui?: {
311
+ id: string;
312
+ component: ComponentFunction;
313
+ /**
314
+ * Auto display the GUI when added to the system
315
+ * @default false
316
+ */
317
+ autoDisplay?: boolean;
318
+ /**
319
+ * Function that returns an array of Signal dependencies
320
+ * The GUI will only display when all dependencies are resolved (!= undefined)
321
+ */
322
+ dependencies?: () => Signal[];
323
+ }[];
295
324
  /**
296
325
  * Array containing the list of sounds
297
326
  * Each element is a simple object containing sound definitions
@@ -356,6 +385,7 @@ export interface RpgClient {
356
385
  scenes?: {
357
386
  map: RpgSceneMapHooks;
358
387
  };
388
+ sceneMap?: RpgSceneMapHooks;
359
389
  /**
360
390
  * Array containing the list of component animations
361
391
  * Each element defines a temporary component to display for animations like hits, effects, etc.
@@ -1,5 +1,6 @@
1
1
  import { Context } from '@signe/di';
2
2
  import { AbstractWebsocket } from './services/AbstractSocket';
3
+ import { RpgClientMap } from './Game/Map';
3
4
  import { AnimationManager } from './Game/AnimationManager';
4
5
  import { Observable } from 'rxjs';
5
6
  import * as PIXI from "pixi.js";
@@ -122,4 +123,6 @@ export declare class RpgClientEngine<T = any> {
122
123
  get PIXI(): typeof PIXI;
123
124
  get socket(): AbstractWebsocket;
124
125
  get playerId(): string | null;
126
+ get scene(): RpgClientMap;
127
+ getCurrentPlayer(): import('./Game/Player').RpgClientPlayer;
125
128
  }
@@ -1,3 +1,3 @@
1
- export declare const PrebuiltGui: {
2
- Dialogbox: any;
3
- };
1
+ import { default as DialogboxComponent } from './dialogbox/index.ce';
2
+ import { default as BoxComponent } from './box.ce';
3
+ export { DialogboxComponent, BoxComponent };
package/dist/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export * from './components/gui';
11
11
  export * from './components/animations';
12
12
  export * from './presets';
13
13
  export * from './components';
14
+ export * from './components/gui';
package/dist/index.js CHANGED
@@ -6,9 +6,10 @@ export { clearInject, context, inject, setInject } from './index6.js';
6
6
  export { LoadMapService, LoadMapToken, provideLoadMap } from './index7.js';
7
7
  export { GlobalConfigToken, provideClientGlobalConfig, provideClientModules, provideGlobalConfig } from './index8.js';
8
8
  export { RpgGui } from './index9.js';
9
- export { PrebuiltGui } from './index10.js';
10
- export { PrebuiltComponentAnimations } from './index11.js';
11
- export { Presets } from './index12.js';
12
- export { default as EventLayerComponent } from './index13.js';
13
- export { default as CharacterComponent } from './index14.js';
9
+ export { default as DialogboxComponent } from './index10.js';
10
+ export { default as BoxComponent } from './index11.js';
11
+ export { PrebuiltComponentAnimations } from './index12.js';
12
+ export { Presets } from './index13.js';
13
+ export { default as EventLayerComponent } from './index14.js';
14
+ export { default as CharacterComponent } from './index15.js';
14
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
package/dist/index10.js CHANGED
@@ -1,8 +1,109 @@
1
- import component from './index23.js';
1
+ import { useProps, useDefineProps, signal, animatedSignal, computed, trigger, mount, effect, h, Container, Rect, cond, Text } from 'canvasengine';
2
+ import component$1 from './index37.js';
3
+ import { inject } from './index6.js';
4
+ import { RpgClientEngine } from './index2.js';
2
5
 
3
- const PrebuiltGui = {
4
- Dialogbox: component
6
+ function component($$props) {
7
+ useProps($$props);
8
+ const defineProps = useDefineProps($$props);
9
+ var _a = defineProps(), message = _a.message, _choices = _a.choices, onFinish = _a.onFinish; _a.onInteraction;
10
+ var client = inject(RpgClientEngine);
11
+ var keyboardControls = client.globalConfig.keyboardControls;
12
+ client.stopProcessingInput = true;
13
+ var isDestroyed = false;
14
+ var texts = [message()];
15
+ var height = signal(250);
16
+ var isTextCompleted = signal(false);
17
+ var border = signal({ width: 5, color: "#595971" });
18
+ var shadow = signal({ color: "#000", blur: 10, offsetX: 10, offsetY: 10 });
19
+ var contentOpacity = animatedSignal(0, {
20
+ duration: 1000,
21
+ });
22
+ var scaleX = animatedSignal(0, {
23
+ duration: 500,
24
+ });
25
+ scaleX.set(1);
26
+ contentOpacity.set(1);
27
+ var currentTextIndex = signal(0);
28
+ var currentText = computed(function () { var _a; return (_a = texts === null || texts === void 0 ? void 0 : texts[currentTextIndex()]) !== null && _a !== void 0 ? _a : ''; });
29
+ var isChoiceDisplayed = signal(false);
30
+ var text = computed(function () {
31
+ var current = currentText();
32
+ return typeof current === "string" ? current : current.text;
33
+ });
34
+ var choices = computed(function () {
35
+ //const current = currentText();
36
+ //return typeof current === "string" ? null : current.choices;
37
+ return _choices;
38
+ });
39
+ var visibleSelection = computed(function () { return isChoiceDisplayed() && choices().length != 0; });
40
+ var triggerSkip = trigger();
41
+ var typewriter = {
42
+ speed: 0.3,
43
+ skip: triggerSkip,
44
+ onComplete: function () {
45
+ isTextCompleted.set(true);
46
+ }
5
47
  };
48
+ var textStyle = {
49
+ wordWrap: true,
50
+ wordWrapWidth: 700 - 256 - 80
51
+ };
52
+ signal({ x: 0, y: 0, width: 256, height: 256 });
53
+ mount(function (element) {
54
+ var dialogbox = element.props.children[0];
55
+ return function () {
56
+ dialogbox.directives.controls.onDestroy();
57
+ isDestroyed = true;
58
+ // Wait destroy is finished before start processing input
59
+ setTimeout(function () {
60
+ client.stopProcessingInput = false;
61
+ }, 500);
62
+ };
63
+ });
64
+ var controls = signal({
65
+ next: {
66
+ bind: keyboardControls.action,
67
+ keyDown: function (e) {
68
+ if (isDestroyed)
69
+ return;
70
+ if (isChoiceDisplayed()) {
71
+ // If choices are displayed, do nothing (wait for selection)
72
+ return;
73
+ }
74
+ // If text is still typing, just skip (fast forward) the animation
75
+ if (!isTextCompleted()) {
76
+ triggerSkip.start();
77
+ isTextCompleted.set(true);
78
+ }
79
+ else {
80
+ var isFinished = currentTextIndex() === texts.length - 1;
81
+ currentTextIndex.update(function (index) {
82
+ if (index < texts.length - 1) {
83
+ return index + 1;
84
+ }
85
+ return index;
86
+ });
87
+ isChoiceDisplayed.set(false);
88
+ isTextCompleted.set(false);
89
+ if (isFinished && onFinish) {
90
+ onFinish();
91
+ }
92
+ }
93
+ },
94
+ },
95
+ });
96
+ var onSelect = function (index) {
97
+ onFinish(index);
98
+ };
99
+ effect(function () {
100
+ if (choices().length != 0) {
101
+ isChoiceDisplayed.set(true);
102
+ }
103
+ });
104
+ let $this = h(Container, { justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' }, h(Container, { ref: 'dialogbox', scale: { x: scaleX }, anchor: [0.5, 0.5], width: 700, height, controls, positionType: 'absolute', bottom: 10 }, [h(Rect, { width: 700, height: 250, color: '#1a1a2e' }), h(Rect, { x: 0, y: 0, width: 700, height, color: '#1a1a2e', alpha: 0.9, borderRadius: 10, border, shadow }), h(Container, { flexDirection: 'row', width: 700, height, alpha: contentOpacity }, h(Container, { flexDirection: 'column' }, [h(Text, { text, color: '#fff', fontSize: 18, margin: 40, typewriter, style: textStyle }), cond(visibleSelection, () => h(component$1, { selectedIndex: 0, items: choices, onSelect }))]))]));
105
+ return $this
106
+ }
6
107
 
7
- export { PrebuiltGui };
108
+ export { component as default };
8
109
  //# sourceMappingURL=index10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index10.js","sources":["../src/components/gui/index.ts"],"sourcesContent":["import Dialogbox from \"./dialogbox/index.ce\";\n\nexport const PrebuiltGui = {\n Dialogbox\n}"],"names":["Dialogbox"],"mappings":";;AAEO,MAAM,WAAc,GAAA;AAAA,aACvBA;AACJ;;;;"}
1
+ {"version":3,"file":"index10.js","sources":["../src/components/gui/dialogbox/index.ce"],"sourcesContent":["<Container justifyContent=\"center\" alignItems=\"center\" width=\"100%\" height=\"100%\">\n <Container\n ref=\"dialogbox\"\n scale={{ x: scaleX }}\n anchor={[0.5, 0.5]}\n width={700}\n height\n controls\n positionType=\"absolute\"\n bottom={10}\n >\n <Rect width={700} height={250} color=\"#1a1a2e\" />\n <Rect\n x={0}\n y={0}\n width={700}\n height\n color=\"#1a1a2e\"\n alpha={0.9}\n borderRadius={10}\n border\n shadow\n />\n <Container\n flexDirection=\"row\"\n width={700}\n height\n alpha={contentOpacity}\n >\n <Container flexDirection=\"column\">\n <Text\n text\n color=\"#fff\"\n fontSize={18}\n margin={40}\n typewriter\n style={textStyle}\n />\n @if (visibleSelection) {\n <Selection selectedIndex={0} items={choices} onSelect />\n }\n </Container>\n </Container>\n</Container> \n\n \n</Container>\n<script>\n import Selection from './selection.ce'\n\n import {\n animatedSignal,\n computed,\n effect,\n signal,\n trigger,\n mount\n } from \"canvasengine\";\n\n import { inject } from \"../../../core/inject\";\n import { RpgClientEngine } from \"../../../RpgClientEngine\";\n import BoxComponent from \"../box.ce\";\n\n const {\n message,\n choices: _choices,\n onFinish,\n onInteraction\n } = defineProps();\n\n const client = inject(RpgClientEngine);\n const keyboardControls = client.globalConfig.keyboardControls;\n\n client.stopProcessingInput = true;\n let isDestroyed = false;\n\n const texts = [message()]\n const height = signal(250);\n const isTextCompleted = signal(false);\n\n const drawSpeaker = (g) => {\n g.beginFill(0xffa500); // Orange color\n g.lineStyle(2, 0x000000); // Black border\n g.moveTo(0, 0);\n g.lineTo(70, 0);\n g.lineTo(80, 15);\n g.lineTo(70, 30);\n g.lineTo(0, 30);\n g.lineTo(0, 0);\n g.endFill();\n };\n\n const border = signal({ width: 5, color: \"#595971\" });\n const shadow = signal({ color: \"#000\", blur: 10, offsetX: 10, offsetY: 10 });\n\n const contentOpacity = animatedSignal(0, {\n duration: 1000,\n });\n\n const scaleX = animatedSignal(0, {\n duration: 500,\n });\n\n scaleX.set(1);\n contentOpacity.set(1);\n\n const currentTextIndex = signal(0);\n const currentText = computed(() => texts?.[currentTextIndex()] ?? '');\n const isChoiceDisplayed = signal(false);\n\n const text = computed(() => {\n const current = currentText();\n return typeof current === \"string\" ? current : current.text;\n });\n\n const choices = computed(() => {\n //const current = currentText();\n //return typeof current === \"string\" ? null : current.choices;\n return _choices;\n });\n\n const visibleSelection = computed(() => isChoiceDisplayed() && choices().length != 0)\n\n const triggerSkip = trigger();\n\n const typewriter = {\n speed: 0.3,\n skip: triggerSkip,\n onComplete: () => {\n isTextCompleted.set(true);\n }\n }\n\n const textStyle = {\n wordWrap: true,\n wordWrapWidth: 700 - 256 - 80\n }\n\n const face = signal({ x: 0, y: 0, width: 256, height: 256 });\n\n mount((element) => {\n const [dialogbox] = element.props.children\n return () => {\n dialogbox.directives.controls.onDestroy()\n isDestroyed = true;\n // Wait destroy is finished before start processing input\n setTimeout(() => {\n client.stopProcessingInput = false;\n }, 500)\n }\n })\n\n const controls = signal({\n next: {\n bind: keyboardControls.action,\n keyDown(e) {\n if (isDestroyed) return;\n if (isChoiceDisplayed()) {\n // If choices are displayed, do nothing (wait for selection)\n return;\n }\n\n // If text is still typing, just skip (fast forward) the animation\n if (!isTextCompleted()) {\n triggerSkip.start();\n isTextCompleted.set(true);\n }\n else {\n const isFinished = currentTextIndex() === texts.length - 1;\n currentTextIndex.update((index) => {\n if (index < texts.length - 1) {\n return index + 1;\n }\n return index;\n });\n isChoiceDisplayed.set(false);\n isTextCompleted.set(false);\n if (isFinished && onFinish) {\n onFinish();\n } \n }\n },\n },\n });\n\n const onSelect = (index) => {\n onFinish(index);\n }\n \n effect(() => {\n if (choices().length != 0) {\n isChoiceDisplayed.set(true);\n }\n });\n</script>"],"names":["Selection"],"mappings":";;;;;AAWqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAW,IAAC,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAiB,EAAE,CAAC;AACxH,IA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AO;AACf;;;;"}
package/dist/index11.js CHANGED
@@ -1,10 +1,23 @@
1
- import component$1 from './index24.js';
2
- import component from './index25.js';
1
+ import { useProps, useDefineProps, computed, h, Container, Rect } from 'canvasengine';
2
+ import { RpgClientEngine } from './index2.js';
3
+ import './index22.js';
4
+ import '@rpgjs/common';
5
+ import './index17.js';
6
+ import { inject } from './index6.js';
7
+ import 'rxjs';
8
+ import './index23.js';
9
+ import '@canvasengine/presets';
3
10
 
4
- const PrebuiltComponentAnimations = {
5
- Hit: component$1,
6
- Animation: component
7
- };
11
+ function component($$props) {
12
+ useProps($$props);
13
+ const defineProps = useDefineProps($$props);
14
+ var _a = defineProps(), width = _a.width, height = _a.height, children = _a.children, color = _a.color, top = _a.top, left = _a.left;
15
+ var engine = inject(RpgClientEngine);
16
+ var child = children[0];
17
+ var _color = computed(function () { var _a; return ((_a = engine.globalConfig.gui) === null || _a === void 0 ? void 0 : _a.windowColor) || (color === null || color === void 0 ? void 0 : color()) || "#1a1a2e"; });
18
+ let $this = h(Container, { positionType: 'absolute', top: top, left: left }, h(Container, { anchor: [0.5, 0.5] }, [h(Rect, { width, height, color: _color }), h(Container, { attach: child })]));
19
+ return $this
20
+ }
8
21
 
9
- export { PrebuiltComponentAnimations };
22
+ export { component as default };
10
23
  //# sourceMappingURL=index11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index11.js","sources":["../src/components/animations/index.ts"],"sourcesContent":["import Hit from \"./hit.ce\";\nimport Animation from \"./animation.ce\";\n\nexport const PrebuiltComponentAnimations = {\n Hit,\n Animation\n}"],"names":["Hit","Animation"],"mappings":";;;AAGO,MAAM,2BAA8B,GAAA;AAAA,OACvCA,WAAA;AAAA,aACAC;AACJ;;;;"}
1
+ {"version":3,"file":"index11.js","sources":["../src/components/gui/box.ce"],"sourcesContent":["<Container positionType=\"absolute\" top={top} left={left}>\n <Container\n anchor={[0.5, 0.5]}\n >\n <Rect width height color={_color} />\n <Container attach={child}></Container>\n </Container> \n</Container>\n\n<script>\n import { RpgClientEngine, inject } from \"../../index\";\n\n const { width, height, children, color, top, left } = defineProps();\n const engine = inject(RpgClientEngine)\n const child = children[0]\n const _color = computed(() => engine.globalConfig.gui?.windowColor || color?.() || \"#1a1a2e\")\n</script>"],"names":[],"mappings":";;;;;;;;;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI;AAC5I,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvB,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,WAAW,MAAM,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,IAAI,SAAS,CAAC,EAAE;AAClN,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACvM,QAAQ,OAAO;AACf;;;;"}
package/dist/index12.js CHANGED
@@ -1,12 +1,10 @@
1
- import { AnimationSpritesheetPreset } from './index26.js';
2
- import { LPCSpritesheetPreset } from './index27.js';
3
- import { RMSpritesheet } from './index28.js';
1
+ import component$1 from './index24.js';
2
+ import component from './index25.js';
4
3
 
5
- const Presets = {
6
- RMSpritesheet,
7
- LPCSpritesheetPreset,
8
- AnimationSpritesheetPreset
4
+ const PrebuiltComponentAnimations = {
5
+ Hit: component$1,
6
+ Animation: component
9
7
  };
10
8
 
11
- export { Presets };
9
+ export { PrebuiltComponentAnimations };
12
10
  //# sourceMappingURL=index12.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index12.js","sources":["../src/presets/index.ts"],"sourcesContent":["import { AnimationSpritesheetPreset } from \"./animation\";\nimport { LPCSpritesheetPreset } from \"./lpc\";\nimport { RMSpritesheet } from \"./rmspritesheet\";\n\nexport const Presets = {\n RMSpritesheet,\n LPCSpritesheetPreset,\n AnimationSpritesheetPreset\n}"],"names":[],"mappings":";;;;AAIO,MAAM,OAAU,GAAA;AAAA,EACnB,aAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACJ;;;;"}
1
+ {"version":3,"file":"index12.js","sources":["../src/components/animations/index.ts"],"sourcesContent":["import Hit from \"./hit.ce\";\nimport Animation from \"./animation.ce\";\n\nexport const PrebuiltComponentAnimations = {\n Hit,\n Animation\n}"],"names":["Hit","Animation"],"mappings":";;;AAGO,MAAM,2BAA8B,GAAA;AAAA,OACvCA,WAAA;AAAA,aACAC;AACJ;;;;"}
package/dist/index13.js CHANGED
@@ -1,17 +1,12 @@
1
- import { useProps, useDefineProps, h, Container, loop } from 'canvasengine';
2
- import { inject } from './index6.js';
3
- import { RpgClientEngine } from './index2.js';
4
- import component$1 from './index14.js';
1
+ import { AnimationSpritesheetPreset } from './index26.js';
2
+ import { LPCSpritesheetPreset } from './index27.js';
3
+ import { RMSpritesheet } from './index28.js';
5
4
 
6
- function component($$props) {
7
- useProps($$props);
8
- useDefineProps($$props);
9
- var engine = inject(RpgClientEngine);
10
- var players = engine.sceneMap.players;
11
- var events = engine.sceneMap.events;
12
- let $this = h(Container, { sortableChildren: true }, [loop(events, (event, id) => h(component$1, { id: id, object: event })), loop(players, (player, id) => h(component$1, { id: id, object: player }))]);
13
- return $this
14
- }
5
+ const Presets = {
6
+ RMSpritesheet,
7
+ LPCSpritesheetPreset,
8
+ AnimationSpritesheetPreset
9
+ };
15
10
 
16
- export { component as default };
11
+ export { Presets };
17
12
  //# sourceMappingURL=index13.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index13.js","sources":["../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n</Container>\n\n<script>\n import { effect, signal } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n \n const engine = inject(RpgClientEngine);\n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>"],"names":["Character"],"mappings":";;;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAA4B,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AAC5C,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO;AACrC,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC5M,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index13.js","sources":["../src/presets/index.ts"],"sourcesContent":["import { AnimationSpritesheetPreset } from \"./animation\";\nimport { LPCSpritesheetPreset } from \"./lpc\";\nimport { RMSpritesheet } from \"./rmspritesheet\";\n\nexport const Presets = {\n RMSpritesheet,\n LPCSpritesheetPreset,\n AnimationSpritesheetPreset\n}"],"names":[],"mappings":";;;;AAIO,MAAM,OAAU,GAAA;AAAA,EACnB,aAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACJ;;;;"}
package/dist/index14.js CHANGED
@@ -1,108 +1,16 @@
1
- import { useProps, useDefineProps, computed, signal, effect, mount, tick, h, Container, loop, Sprite } from 'canvasengine';
2
- import { Particle } from '@canvasengine/presets';
3
- import { Direction, ModulesToken } from '@rpgjs/common';
4
- import { RpgClientEngine } from './index2.js';
1
+ import { useProps, useDefineProps, h, Container, loop } from 'canvasengine';
5
2
  import { inject } from './index6.js';
3
+ import { RpgClientEngine } from './index2.js';
4
+ import component$1 from './index15.js';
6
5
 
7
6
  function component($$props) {
8
7
  useProps($$props);
9
8
  const defineProps = useDefineProps($$props);
10
- var _a = defineProps(), object = _a.object, id = _a.id;
11
- var client = inject(RpgClientEngine);
12
- var hooks = inject(ModulesToken);
13
- var spritesheets = client.spritesheets;
14
- var playerId = client.playerId;
15
- var componentsBehind = client.spriteComponentsBehind;
16
- var componentsInFront = client.spriteComponentsInFront;
17
- var isMe = computed(function () { return id() === playerId; });
18
- var x = object.x, y = object.y, tint = object.tint, direction = object.direction, animationName = object.animationName, animationCurrentIndex = object.animationCurrentIndex, emitParticleTrigger = object.emitParticleTrigger, particleName = object.particleName, graphics = object.graphics, hitbox = object.hitbox;
19
- var particleSettings = client.particleSettings;
20
- var canControls = function () { return isMe() && object.canMove(); };
21
- var keyboardControls = client.globalConfig.keyboardControls;
22
- var controls = signal({
23
- down: {
24
- repeat: true,
25
- bind: keyboardControls.down,
26
- keyDown: function () {
27
- if (canControls())
28
- client.processInput({ input: Direction.Down });
29
- },
30
- },
31
- up: {
32
- repeat: true,
33
- bind: keyboardControls.up,
34
- keyDown: function () {
35
- if (canControls())
36
- client.processInput({ input: Direction.Up });
37
- },
38
- },
39
- left: {
40
- repeat: true,
41
- bind: keyboardControls.left,
42
- keyDown: function () {
43
- if (canControls())
44
- client.processInput({ input: Direction.Left });
45
- },
46
- },
47
- right: {
48
- repeat: true,
49
- bind: keyboardControls.right,
50
- keyDown: function () {
51
- if (canControls())
52
- client.processInput({ input: Direction.Right });
53
- },
54
- },
55
- action: {
56
- bind: keyboardControls.action,
57
- keyDown: function () {
58
- if (canControls()) {
59
- client.processAction({ action: 'action' });
60
- // particleName.set('hit')
61
- // emitParticleTrigger.start()
62
- // object.flash('red')
63
- }
64
- },
65
- },
66
- });
67
- var sheet = function (graphicId) {
68
- return {
69
- definition: spritesheets.get(graphicId),
70
- playing: animationName,
71
- params: {
72
- direction: direction
73
- },
74
- onFinish: function () {
75
- animationCurrentIndex.update(function (index) { return index + 1; });
76
- }
77
- };
78
- };
79
- var previousAnimationName = animationName();
80
- effect(function () {
81
- var currentAnimationName = animationName();
82
- // If animation changed externally (not through setAnimation), reset the state
83
- if (currentAnimationName !== previousAnimationName && object.animationIsPlaying && object.animationIsPlaying()) {
84
- // Check if this is a movement animation (walk, stand) that should interrupt custom animations
85
- var movementAnimations = ['walk', 'stand'];
86
- if (movementAnimations.includes(currentAnimationName)) {
87
- if (typeof object.resetAnimationState === 'function') {
88
- object.resetAnimationState();
89
- }
90
- }
91
- }
92
- previousAnimationName = currentAnimationName;
93
- });
94
- mount(function (element) {
95
- hooks.callHooks("client-sprite-onInit", element.componentInstance);
96
- hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, element.componentInstance);
97
- return function () {
98
- hooks.callHooks("client-sprite-onDestroy", element.componentInstance);
99
- hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, element.componentInstance);
100
- };
101
- });
102
- tick(function () {
103
- hooks.callHooks("client-sprite-onUpdate");
104
- });
105
- let $this = h(Container, { x, y, zIndex: y, viewportFollow: isMe, controls }, [loop(componentsBehind, component => h(Container, null, h(component, { object }))), h(Particle, { emit: emitParticleTrigger, settings: particleSettings, zIndex: 1000, name: particleName }), h(Container, null, loop(graphics, graphicId => h(Sprite, { sheet: sheet(graphicId), direction, tint, hitbox }))), loop(componentsInFront, component => h(Container, null, h(component, { object })))]);
9
+ var engine = inject(RpgClientEngine);
10
+ var children = defineProps().children;
11
+ var players = engine.sceneMap.players;
12
+ var events = engine.sceneMap.events;
13
+ let $this = h(Container, { sortableChildren: true }, [loop(events, (event, id) => h(component$1, { id: id, object: event })), loop(players, (player, id) => h(component$1, { id: id, object: player })), loop(children, child => h(child))]);
106
14
  return $this
107
15
  }
108
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"index14.js","sources":["../src/components/character.ce"],"sourcesContent":["<Container x y zIndex={y} viewportFollow={isMe} controls>\n @for (component of componentsBehind) {\n <Container>\n <component object />\n </Container>\n } \n <Particle emit={@emitParticleTrigger} settings={@particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicId of graphics) {\n <Sprite sheet={@sheet(@graphicId)} direction tint hitbox />\n }\n </Container>\n @for (component of componentsInFront) {\n <Container>\n <component object />\n </Container>\n } \n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick } from \"canvasengine\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n\n const { object, id } = defineProps();\n \n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n\n const spritesheets = client.spritesheets;\n const playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox \n } = object;\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && object.canMove()\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const controls = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n // particleName.set('hit') \n // emitParticleTrigger.start()\n // object.flash('red')\n }\n },\n },\n });\n\n const sheet = (graphicId) => {\n return {\n definition: spritesheets.get(graphicId),\n playing: animationName,\n params: {\n direction\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n // Track animation changes to reset animation state when needed\n let previousAnimationName = animationName();\n effect(() => {\n const currentAnimationName = animationName();\n \n // If animation changed externally (not through setAnimation), reset the state\n if (currentAnimationName !== previousAnimationName && object.animationIsPlaying && object.animationIsPlaying()) {\n // Check if this is a movement animation (walk, stand) that should interrupt custom animations\n const movementAnimations = ['walk', 'stand'];\n if (movementAnimations.includes(currentAnimationName)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\n \n previousAnimationName = currentAnimationName;\n });\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onInit\", element.componentInstance)\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, element.componentInstance)\n\n return () => {\n hooks.callHooks(\"client-sprite-onDestroy\", element.componentInstance)\n hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, element.componentInstance)\n }\n })\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\")\n })\n</script>"],"names":[],"mappings":";;;;;;AAYqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,EAAE,GAAG,WAAW,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;AAC9D,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AACpC,IAAI,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;AAChC,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY;AACtC,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ;AAC9B,IAAI,gBAAgB,GAAG,MAAM,CAAC,sBAAsB;AACpD,IAAI,iBAAiB,GAAG,MAAM,CAAC,uBAAuB;AACtD,IAAI,IAAI,GAAG,QAAQ,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,KAAK,QAAQ,CAAC,EAAE,CAAC;AAC9D,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAAC,aAAa,EAAE,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,EAAE,mBAA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AQ,EAAE,SAAS,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AACzd,QAAQ,OAAO;AACf;;;;"}
1
+ {"version":3,"file":"index14.js","sources":["../src/components/scenes/event-layer.ce"],"sourcesContent":["<Container sortableChildren={true}>\n @for ((event,id) of events) {\n <Character id={id} object={event} />\n }\n\n @for ((player,id) of players) {\n <Character id={id} object={player} />\n }\n\n @for (child of children) {\n <child />\n }\n</Container>\n\n<script>\n import { effect, signal } from 'canvasengine'\n import { inject } from \"../../core/inject\";\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import Character from \"../character.ce\";\n \n const engine = inject(RpgClientEngine);\n const { children } = defineProps()\n \n const players = engine.sceneMap.players\n const events = engine.sceneMap.events\n</script>"],"names":["Character"],"mappings":";;;;;AAQqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;AAC5C,IAAI,QAAQ,GAAG,WAAW,EAAE,CAAC,QAAQ;AACrC,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO;AACrC,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC7B,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAACA,WAAS,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/O,QAAQ,OAAO;AACf;;;;"}