@rpgjs/client 5.0.0-beta.23 → 5.0.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @rpgjs/client
2
2
 
3
+ ## 5.0.0-beta.24
4
+
5
+ ### Patch Changes
6
+
7
+ - e11f2ed: Fix main menu Escape handling, add outside-click and touch close controls for prebuilt modal GUIs, make menu layouts responsive on small screens, restore a compact desktop menu with an integrated sidebar and column-based item views, use fade-only menu transitions, improve Skills/Equipment and save slot spacing, make active menu rows less visually harsh, and improve HUD and dialog border rendering.
8
+ - 3fb2765: Apply Studio media scale as a multiplier of the default RPGJS display scale, then combine it with event instance scale instead of overwriting it.
9
+ - be412cf: Let Studio event-touch pressure plates overlap pushed events without physical separation, wait until ground sensors are mostly covered before firing, clean up touch tracking when collisions exit after z changes, and clamp route overshoot frames that could make pushed events jitter.
10
+ - Updated dependencies [e11f2ed]
11
+ - Updated dependencies [be412cf]
12
+ - @rpgjs/ui-css@5.0.0-beta.22
13
+ - @rpgjs/common@5.0.0-beta.23
14
+ - @rpgjs/server@5.0.0-beta.24
15
+
3
16
  ## 5.0.0-beta.23
4
17
 
5
18
  ### Patch Changes
@@ -25,8 +25,11 @@ type FlashTriggerOptions = Omit<FlashOptions, "tint"> & {
25
25
  type ConfigurableTrigger<T> = Omit<Trigger<T>, "start"> & {
26
26
  start(config?: T): Promise<void>;
27
27
  };
28
+ export declare const multiplyGraphicDisplayScale: (baseScale: unknown, instanceScale: unknown) => [number, number];
28
29
  export declare const withGraphicDisplayScale: (spritesheet: any, scale: unknown) => any;
29
30
  export declare const appendFramePayload: (current: unknown, items: unknown) => Frame[];
31
+ export declare const getFrameTimestamp: (frame: Frame) => number;
32
+ export declare const mergeFreshFramePayload: (current: unknown, items: unknown, lastAppliedFrameTs?: number) => Frame[];
30
33
  export declare abstract class RpgClientObject extends RpgCommonPlayer {
31
34
  abstract _type: string;
32
35
  emitParticleTrigger: Trigger<any>;
@@ -37,8 +40,10 @@ export declare abstract class RpgClientObject extends RpgCommonPlayer {
37
40
  frames: Frame[];
38
41
  graphicsSignals: import('canvasengine').WritableArraySignal<any[]>;
39
42
  flashTrigger: ConfigurableTrigger<FlashTriggerOptions>;
43
+ private lastAppliedFrameTs;
40
44
  private animationRestoreState?;
41
45
  constructor();
46
+ private getFrameTimestamp;
42
47
  /**
43
48
  * Access the shared client hook registry.
44
49
  *
@@ -4,18 +4,57 @@ import { signal, trigger } from "canvasengine";
4
4
  import { ModulesToken, RpgCommonPlayer } from "@rpgjs/common";
5
5
  import { combineLatest, from, map, of, startWith, switchMap } from "rxjs";
6
6
  //#region src/Game/Object.ts
7
+ var toFiniteScale = (value, fallback) => {
8
+ if (typeof value === "number" && Number.isFinite(value)) return value;
9
+ if (typeof value === "string" && value.trim()) {
10
+ const parsed = Number(value);
11
+ return Number.isFinite(parsed) ? parsed : fallback;
12
+ }
13
+ return fallback;
14
+ };
15
+ var normalizeGraphicScale = (value, fallback = [1, 1]) => {
16
+ if (typeof value === "number" || typeof value === "string") {
17
+ const scale = toFiniteScale(value, fallback[0]);
18
+ return [scale, scale];
19
+ }
20
+ if (Array.isArray(value)) {
21
+ const x = toFiniteScale(value[0], fallback[0]);
22
+ return [x, toFiniteScale(value[1] ?? value[0], x)];
23
+ }
24
+ if (value && typeof value === "object") {
25
+ const scale = value;
26
+ const x = toFiniteScale(scale.x, fallback[0]);
27
+ return [x, toFiniteScale(scale.y ?? scale.x, x)];
28
+ }
29
+ return fallback;
30
+ };
31
+ var multiplyGraphicDisplayScale = (baseScale, instanceScale) => {
32
+ const base = normalizeGraphicScale(baseScale);
33
+ const instance = normalizeGraphicScale(instanceScale);
34
+ return [base[0] * instance[0], base[1] * instance[1]];
35
+ };
7
36
  var withGraphicDisplayScale = (spritesheet, scale) => {
8
37
  if (!spritesheet || typeof spritesheet !== "object") return spritesheet;
9
38
  if (scale === void 0 || scale === null) return spritesheet;
10
39
  return {
11
40
  ...spritesheet,
12
- displayScale: scale
41
+ displayScale: multiplyGraphicDisplayScale(spritesheet.displayScale, scale)
13
42
  };
14
43
  };
15
44
  var appendFramePayload = (current, items) => {
16
45
  const nextFrames = (Array.isArray(items) ? items : items ? [items] : []).flatMap((item) => Array.isArray(item) ? item : [item]);
17
46
  return (Array.isArray(current) ? current : []).concat(nextFrames);
18
47
  };
48
+ var getFrameTimestamp = (frame) => {
49
+ const timestamp = Number(frame.ts);
50
+ return Number.isFinite(timestamp) ? timestamp : 0;
51
+ };
52
+ var mergeFreshFramePayload = (current, items, lastAppliedFrameTs = 0) => {
53
+ return appendFramePayload(current, items).filter((frame) => {
54
+ const timestamp = getFrameTimestamp(frame);
55
+ return timestamp === 0 || timestamp > lastAppliedFrameTs;
56
+ }).sort((a, b) => getFrameTimestamp(a) - getFrameTimestamp(b));
57
+ };
19
58
  var RpgClientObject = class extends RpgCommonPlayer {
20
59
  constructor() {
21
60
  super();
@@ -27,11 +66,12 @@ var RpgClientObject = class extends RpgCommonPlayer {
27
66
  this.frames = [];
28
67
  this.graphicsSignals = signal([]);
29
68
  this.flashTrigger = trigger();
69
+ this.lastAppliedFrameTs = 0;
30
70
  const engine = this.engine;
31
71
  this.hooks.callHooks("client-sprite-onInit", this).subscribe();
32
72
  this._frames.observable.subscribe(({ items }) => {
33
73
  if (!this.id) return;
34
- this.frames = appendFramePayload(this.frames, items);
74
+ this.frames = mergeFreshFramePayload(this.frames, items, this.lastAppliedFrameTs);
35
75
  });
36
76
  combineLatest([this.graphics.observable.pipe(map(({ items }) => items)), this._graphicScale.observable.pipe(startWith({ value: this._graphicScale() }), map((payload) => payload?.value ?? payload))]).pipe(switchMap(([graphics, scale]) => {
37
77
  const graphicRefs = Array.isArray(graphics) ? graphics : [];
@@ -46,10 +86,16 @@ var RpgClientObject = class extends RpgCommonPlayer {
46
86
  const frame = this.frames.shift();
47
87
  if (frame) {
48
88
  if (typeof frame.x !== "number" || typeof frame.y !== "number") return;
89
+ const frameTs = this.getFrameTimestamp(frame);
90
+ if (frameTs > 0 && frameTs <= this.lastAppliedFrameTs) return;
49
91
  engine.scene.setBodyPosition(this.id, frame.x, frame.y, "top-left");
92
+ if (frameTs > this.lastAppliedFrameTs) this.lastAppliedFrameTs = frameTs;
50
93
  }
51
94
  });
52
95
  }
96
+ getFrameTimestamp(frame) {
97
+ return getFrameTimestamp(frame);
98
+ }
53
99
  /**
54
100
  * Access the shared client hook registry.
55
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Object.js","names":[],"sources":["../../src/Game/Object.ts"],"sourcesContent":["import { Hooks, ModulesToken, RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal, type Trigger } from \"canvasengine\";\nimport { combineLatest, from, map, of, startWith, Subscription, switchMap } from \"rxjs\";\nimport { inject } from \"../core/inject\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\ntype Frame = { x: number; y: number; ts: number };\n\ntype AnimationRestoreOptions = {\n restoreAnimationName?: string;\n restoreGraphics?: any[];\n timeoutMs?: number;\n};\n\ntype FlashType = 'alpha' | 'tint' | 'both';\n\ntype FlashOptions = {\n type?: FlashType;\n duration?: number;\n cycles?: number;\n alpha?: number;\n tint?: number | string;\n};\n\ntype FlashTriggerOptions = Omit<FlashOptions, \"tint\"> & {\n tint: number;\n};\n\ntype ConfigurableTrigger<T> = Omit<Trigger<T>, \"start\"> & {\n start(config?: T): Promise<void>;\n};\n\nexport const withGraphicDisplayScale = (spritesheet: any, scale: unknown): any => {\n if (!spritesheet || typeof spritesheet !== \"object\") return spritesheet;\n if (scale === undefined || scale === null) return spritesheet;\n return {\n ...spritesheet,\n displayScale: scale,\n };\n};\n\nexport const appendFramePayload = (current: unknown, items: unknown): Frame[] => {\n const frameItems = Array.isArray(items) ? items : items ? [items] : [];\n const nextFrames = frameItems.flatMap((item): Frame[] =>\n Array.isArray(item) ? item : [item as Frame]\n );\n const currentFrames = Array.isArray(current) ? current as Frame[] : [];\n return currentFrames.concat(nextFrames);\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: Frame[] = [];\n graphicsSignals = signal<any[]>([]);\n flashTrigger: ConfigurableTrigger<FlashTriggerOptions> = trigger<FlashTriggerOptions>();\n private animationRestoreState?: {\n animationName: string;\n graphics: any[];\n };\n\n constructor() {\n super();\n const engine = this.engine;\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 = appendFramePayload(this.frames, items);\n });\n\n const graphics$ = this.graphics.observable.pipe(map(({ items }) => items));\n const graphicScale$ = this._graphicScale.observable.pipe(\n startWith({ value: this._graphicScale() }),\n map((payload: any) => payload?.value ?? payload),\n );\n\n combineLatest([graphics$, graphicScale$])\n .pipe(\n switchMap(([graphics, scale]) => {\n const graphicRefs = Array.isArray(graphics) ? graphics : [];\n if (graphicRefs.length === 0) return of([]);\n return from(Promise.all(graphicRefs.map(async (graphic) => {\n const spritesheet = await engine.getSpriteSheet(graphic);\n return withGraphicDisplayScale(spritesheet, scale);\n })));\n })\n )\n .subscribe((sheets) => { \n this.graphicsSignals.set(sheets);\n });\n\n engine.tick\n .pipe\n //throttleTime(10)\n ()\n .subscribe(() => {\n const frame = this.frames.shift();\n if (frame) {\n if (typeof frame.x !== \"number\" || typeof frame.y !== \"number\") return;\n engine.scene.setBodyPosition(\n this.id,\n frame.x,\n frame.y,\n \"top-left\"\n );\n }\n });\n }\n\n /**\n * Access the shared client hook registry.\n *\n * @returns The hook service used to register and trigger client-side hooks.\n */\n get hooks() {\n return inject<Hooks>(ModulesToken);\n }\n\n /**\n * Access the current client engine instance.\n *\n * @returns The active {@link RpgClientEngine} instance.\n */\n get engine() {\n return inject(RpgClientEngine);\n }\n\n setHitbox(width: number, height: number): void {\n if (typeof width !== \"number\" || width <= 0) {\n throw new Error(\"setHitbox: width must be a positive number\");\n }\n if (typeof height !== \"number\" || height <= 0) {\n throw new Error(\"setHitbox: height must be a positive number\");\n }\n\n this.hitbox.set({\n w: width,\n h: height,\n });\n\n const sceneMap = (this.engine as any)?.sceneMap;\n if (sceneMap && this.id) {\n sceneMap.updateHitbox?.(this.id, this.x(), this.y(), width, height);\n }\n }\n\n private animationSubscription?: Subscription;\n private animationResetTimeout?: ReturnType<typeof setTimeout>;\n private animationWaitResolve?: () => void;\n\n private clearAnimationControls() {\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n if (this.animationResetTimeout) {\n clearTimeout(this.animationResetTimeout);\n this.animationResetTimeout = undefined;\n }\n }\n\n private resolveAnimationWait() {\n const resolve = this.animationWaitResolve;\n this.animationWaitResolve = undefined;\n resolve?.();\n }\n\n private finishTemporaryAnimation() {\n const restoreState = this.animationRestoreState;\n this.clearAnimationControls();\n this.animationCurrentIndex.set(0);\n this.animationRestoreState = undefined;\n this.animationIsPlaying.set(false);\n if (restoreState) {\n this.animationName.set(restoreState.animationName);\n this.graphics.set([...restoreState.graphics]);\n }\n this.resolveAnimationWait();\n }\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?: FlashOptions): 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 if (this.animationRestoreState) {\n this.finishTemporaryAnimation();\n return;\n }\n this.animationIsPlaying.set(false);\n this.animationCurrentIndex.set(0);\n this.clearAnimationControls();\n this.resolveAnimationWait();\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 * @param options - Restore and timeout options\n * @returns A promise resolved when a finite animation finishes, is interrupted, or times out\n *\n * @example\n * ```ts\n * // Play attack animation 3 times\n * await player.setAnimation('attack', 3);\n *\n * // Play continuous spell animation\n * player.setAnimation('spell');\n * ```\n */\n setAnimation(animationName: string, nbTimes?: number, options?: AnimationRestoreOptions): Promise<void>;\n /**\n * Set a custom animation with temporary graphic change\n *\n * Plays a custom animation for the specified number of repetitions and temporarily\n * changes the player's graphic (sprite sheet) during the animation. The graphic\n * is automatically reset when the animation finishes.\n *\n * @param animationName - Name of the animation to play\n * @param graphic - The graphic(s) to temporarily use during the animation\n * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)\n * @param options - Restore and timeout options\n * @returns A promise resolved when a finite animation finishes, is interrupted, or times out\n *\n * @example\n * ```ts\n * // Play attack animation with temporary graphic change\n * await player.setAnimation('attack', 'hero_attack', 3);\n * ```\n */\n setAnimation(animationName: string, graphic?: string | string[], nbTimes?: number, options?: AnimationRestoreOptions): Promise<void>;\n setAnimation(\n animationName: string,\n graphicOrNbTimes?: string | string[] | number,\n nbTimesOrOptions?: number | AnimationRestoreOptions,\n options?: AnimationRestoreOptions\n ): Promise<void> {\n let graphic: string | string[] | undefined;\n let finalNbTimes: number = Infinity;\n let restoreOptions: AnimationRestoreOptions | undefined = options;\n\n // Handle overloads\n if (typeof graphicOrNbTimes === 'number') {\n // setAnimation(animationName, nbTimes)\n finalNbTimes = graphicOrNbTimes;\n restoreOptions = typeof nbTimesOrOptions === 'object' ? nbTimesOrOptions : options;\n } else if (graphicOrNbTimes !== undefined) {\n // setAnimation(animationName, graphic, nbTimes)\n graphic = graphicOrNbTimes;\n if (typeof nbTimesOrOptions === 'number') {\n finalNbTimes = nbTimesOrOptions;\n } else {\n finalNbTimes = Infinity;\n restoreOptions = nbTimesOrOptions ?? options;\n }\n } else {\n // setAnimation(animationName) - nbTimes remains Infinity\n finalNbTimes = Infinity;\n }\n\n if (this.animationIsPlaying()) {\n this.finishTemporaryAnimation();\n }\n\n const waitPromise =\n finalNbTimes === Infinity\n ? Promise.resolve()\n : new Promise<void>((resolve) => {\n this.animationWaitResolve = resolve;\n });\n\n this.animationIsPlaying.set(true);\n const previousAnimationName =\n restoreOptions?.restoreAnimationName ?? this.animationName();\n const previousGraphics = restoreOptions?.restoreGraphics\n ? [...restoreOptions.restoreGraphics]\n : [...this.graphics()];\n this.animationRestoreState = {\n animationName: previousAnimationName,\n graphics: previousGraphics,\n };\n this.animationCurrentIndex.set(0);\n\n // Temporarily change graphic if provided\n if (graphic !== undefined) {\n if (Array.isArray(graphic)) {\n this.graphics.set(graphic);\n } else {\n this.graphics.set([graphic]);\n }\n }\n\n this.clearAnimationControls();\n\n this.animationSubscription =\n this.animationCurrentIndex.observable.subscribe((index) => {\n if (index >= finalNbTimes) {\n this.finishTemporaryAnimation();\n }\n });\n\n if (finalNbTimes !== Infinity) {\n this.animationResetTimeout = setTimeout(() => {\n if (this.animationIsPlaying()) {\n this.finishTemporaryAnimation();\n }\n }, restoreOptions?.timeoutMs ?? Math.max(1000, finalNbTimes * 1000));\n }\n\n this.animationName.set(animationName);\n\n return waitPromise;\n }\n\n /**\n * Display a registered component animation effect on this object.\n *\n * @param id - Identifier of the component animation to play.\n * @param params - Parameters forwarded to the animation effect.\n * @returns A promise resolved when the animation component calls `onFinish`.\n */\n showComponentAnimation(id: string, params: any): Promise<void> {\n const engine = inject(RpgClientEngine);\n return engine.getComponentAnimation(id).displayEffect(params, this);\n }\n\n /**\n * Display a registered spritesheet animation effect on this object.\n *\n * @param graphic - Identifier of the spritesheet to use.\n * @param animationName - Name of the animation inside the spritesheet.\n * @returns A promise resolved when the animation component calls `onFinish`.\n */\n showAnimation(graphic: string, animationName: string = 'default'): Promise<void> {\n return this.showComponentAnimation('animation', {\n graphic,\n animationName,\n });\n }\n \n /**\n * Check whether this client object represents an event.\n *\n * @returns `true` if the object type is `event`, otherwise `false`.\n */\n isEvent(): boolean {\n return this._type === 'event';\n }\n\n /**\n * Check whether this client object represents a player.\n *\n * @returns `true` if the object type is `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ClB,OAAO,KAAK,UAAU;CACxB;AACF"}
1
+ {"version":3,"file":"Object.js","names":[],"sources":["../../src/Game/Object.ts"],"sourcesContent":["import { Hooks, ModulesToken, RpgCommonPlayer } from \"@rpgjs/common\";\nimport { trigger, signal, type Trigger } from \"canvasengine\";\nimport { combineLatest, from, map, of, startWith, Subscription, switchMap } from \"rxjs\";\nimport { inject } from \"../core/inject\";\nimport { RpgClientEngine } from \"../RpgClientEngine\";\ntype Frame = { x: number; y: number; ts: number };\n\ntype AnimationRestoreOptions = {\n restoreAnimationName?: string;\n restoreGraphics?: any[];\n timeoutMs?: number;\n};\n\ntype FlashType = 'alpha' | 'tint' | 'both';\n\ntype FlashOptions = {\n type?: FlashType;\n duration?: number;\n cycles?: number;\n alpha?: number;\n tint?: number | string;\n};\n\ntype FlashTriggerOptions = Omit<FlashOptions, \"tint\"> & {\n tint: number;\n};\n\ntype ConfigurableTrigger<T> = Omit<Trigger<T>, \"start\"> & {\n start(config?: T): Promise<void>;\n};\n\nconst toFiniteScale = (value: unknown, fallback: number): number => {\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n if (typeof value === \"string\" && value.trim()) {\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : fallback;\n }\n return fallback;\n};\n\nconst normalizeGraphicScale = (value: unknown, fallback: [number, number] = [1, 1]): [number, number] => {\n if (typeof value === \"number\" || typeof value === \"string\") {\n const scale = toFiniteScale(value, fallback[0]);\n return [scale, scale];\n }\n if (Array.isArray(value)) {\n const x = toFiniteScale(value[0], fallback[0]);\n const y = toFiniteScale(value[1] ?? value[0], x);\n return [x, y];\n }\n if (value && typeof value === \"object\") {\n const scale = value as { x?: unknown; y?: unknown };\n const x = toFiniteScale(scale.x, fallback[0]);\n const y = toFiniteScale(scale.y ?? scale.x, x);\n return [x, y];\n }\n return fallback;\n};\n\nexport const multiplyGraphicDisplayScale = (\n baseScale: unknown,\n instanceScale: unknown,\n): [number, number] => {\n const base = normalizeGraphicScale(baseScale);\n const instance = normalizeGraphicScale(instanceScale);\n return [base[0] * instance[0], base[1] * instance[1]];\n};\n\nexport const withGraphicDisplayScale = (spritesheet: any, scale: unknown): any => {\n if (!spritesheet || typeof spritesheet !== \"object\") return spritesheet;\n if (scale === undefined || scale === null) return spritesheet;\n return {\n ...spritesheet,\n displayScale: multiplyGraphicDisplayScale(spritesheet.displayScale, scale),\n };\n};\n\nexport const appendFramePayload = (current: unknown, items: unknown): Frame[] => {\n const frameItems = Array.isArray(items) ? items : items ? [items] : [];\n const nextFrames = frameItems.flatMap((item): Frame[] =>\n Array.isArray(item) ? item : [item as Frame]\n );\n const currentFrames = Array.isArray(current) ? current as Frame[] : [];\n return currentFrames.concat(nextFrames);\n};\n\nexport const getFrameTimestamp = (frame: Frame): number => {\n const timestamp = Number(frame.ts);\n return Number.isFinite(timestamp) ? timestamp : 0;\n};\n\nexport const mergeFreshFramePayload = (\n current: unknown,\n items: unknown,\n lastAppliedFrameTs = 0,\n): Frame[] => {\n return appendFramePayload(current, items)\n .filter((frame) => {\n const timestamp = getFrameTimestamp(frame);\n return timestamp === 0 || timestamp > lastAppliedFrameTs;\n })\n .sort((a, b) => getFrameTimestamp(a) - getFrameTimestamp(b));\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: Frame[] = [];\n graphicsSignals = signal<any[]>([]);\n flashTrigger: ConfigurableTrigger<FlashTriggerOptions> = trigger<FlashTriggerOptions>();\n private lastAppliedFrameTs = 0;\n private animationRestoreState?: {\n animationName: string;\n graphics: any[];\n };\n\n constructor() {\n super();\n const engine = this.engine;\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 = mergeFreshFramePayload(\n this.frames,\n items,\n this.lastAppliedFrameTs,\n );\n });\n\n const graphics$ = this.graphics.observable.pipe(map(({ items }) => items));\n const graphicScale$ = this._graphicScale.observable.pipe(\n startWith({ value: this._graphicScale() }),\n map((payload: any) => payload?.value ?? payload),\n );\n\n combineLatest([graphics$, graphicScale$])\n .pipe(\n switchMap(([graphics, scale]) => {\n const graphicRefs = Array.isArray(graphics) ? graphics : [];\n if (graphicRefs.length === 0) return of([]);\n return from(Promise.all(graphicRefs.map(async (graphic) => {\n const spritesheet = await engine.getSpriteSheet(graphic);\n return withGraphicDisplayScale(spritesheet, scale);\n })));\n })\n )\n .subscribe((sheets) => { \n this.graphicsSignals.set(sheets);\n });\n\n engine.tick\n .pipe\n //throttleTime(10)\n ()\n .subscribe(() => {\n const frame = this.frames.shift();\n if (frame) {\n if (typeof frame.x !== \"number\" || typeof frame.y !== \"number\") return;\n const frameTs = this.getFrameTimestamp(frame);\n if (frameTs > 0 && frameTs <= this.lastAppliedFrameTs) return;\n engine.scene.setBodyPosition(\n this.id,\n frame.x,\n frame.y,\n \"top-left\"\n );\n if (frameTs > this.lastAppliedFrameTs) {\n this.lastAppliedFrameTs = frameTs;\n }\n }\n });\n }\n\n private getFrameTimestamp(frame: Frame): number {\n return getFrameTimestamp(frame);\n }\n\n /**\n * Access the shared client hook registry.\n *\n * @returns The hook service used to register and trigger client-side hooks.\n */\n get hooks() {\n return inject<Hooks>(ModulesToken);\n }\n\n /**\n * Access the current client engine instance.\n *\n * @returns The active {@link RpgClientEngine} instance.\n */\n get engine() {\n return inject(RpgClientEngine);\n }\n\n setHitbox(width: number, height: number): void {\n if (typeof width !== \"number\" || width <= 0) {\n throw new Error(\"setHitbox: width must be a positive number\");\n }\n if (typeof height !== \"number\" || height <= 0) {\n throw new Error(\"setHitbox: height must be a positive number\");\n }\n\n this.hitbox.set({\n w: width,\n h: height,\n });\n\n const sceneMap = (this.engine as any)?.sceneMap;\n if (sceneMap && this.id) {\n sceneMap.updateHitbox?.(this.id, this.x(), this.y(), width, height);\n }\n }\n\n private animationSubscription?: Subscription;\n private animationResetTimeout?: ReturnType<typeof setTimeout>;\n private animationWaitResolve?: () => void;\n\n private clearAnimationControls() {\n if (this.animationSubscription) {\n this.animationSubscription.unsubscribe();\n this.animationSubscription = undefined;\n }\n if (this.animationResetTimeout) {\n clearTimeout(this.animationResetTimeout);\n this.animationResetTimeout = undefined;\n }\n }\n\n private resolveAnimationWait() {\n const resolve = this.animationWaitResolve;\n this.animationWaitResolve = undefined;\n resolve?.();\n }\n\n private finishTemporaryAnimation() {\n const restoreState = this.animationRestoreState;\n this.clearAnimationControls();\n this.animationCurrentIndex.set(0);\n this.animationRestoreState = undefined;\n this.animationIsPlaying.set(false);\n if (restoreState) {\n this.animationName.set(restoreState.animationName);\n this.graphics.set([...restoreState.graphics]);\n }\n this.resolveAnimationWait();\n }\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?: FlashOptions): 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 if (this.animationRestoreState) {\n this.finishTemporaryAnimation();\n return;\n }\n this.animationIsPlaying.set(false);\n this.animationCurrentIndex.set(0);\n this.clearAnimationControls();\n this.resolveAnimationWait();\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 * @param options - Restore and timeout options\n * @returns A promise resolved when a finite animation finishes, is interrupted, or times out\n *\n * @example\n * ```ts\n * // Play attack animation 3 times\n * await player.setAnimation('attack', 3);\n *\n * // Play continuous spell animation\n * player.setAnimation('spell');\n * ```\n */\n setAnimation(animationName: string, nbTimes?: number, options?: AnimationRestoreOptions): Promise<void>;\n /**\n * Set a custom animation with temporary graphic change\n *\n * Plays a custom animation for the specified number of repetitions and temporarily\n * changes the player's graphic (sprite sheet) during the animation. The graphic\n * is automatically reset when the animation finishes.\n *\n * @param animationName - Name of the animation to play\n * @param graphic - The graphic(s) to temporarily use during the animation\n * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)\n * @param options - Restore and timeout options\n * @returns A promise resolved when a finite animation finishes, is interrupted, or times out\n *\n * @example\n * ```ts\n * // Play attack animation with temporary graphic change\n * await player.setAnimation('attack', 'hero_attack', 3);\n * ```\n */\n setAnimation(animationName: string, graphic?: string | string[], nbTimes?: number, options?: AnimationRestoreOptions): Promise<void>;\n setAnimation(\n animationName: string,\n graphicOrNbTimes?: string | string[] | number,\n nbTimesOrOptions?: number | AnimationRestoreOptions,\n options?: AnimationRestoreOptions\n ): Promise<void> {\n let graphic: string | string[] | undefined;\n let finalNbTimes: number = Infinity;\n let restoreOptions: AnimationRestoreOptions | undefined = options;\n\n // Handle overloads\n if (typeof graphicOrNbTimes === 'number') {\n // setAnimation(animationName, nbTimes)\n finalNbTimes = graphicOrNbTimes;\n restoreOptions = typeof nbTimesOrOptions === 'object' ? nbTimesOrOptions : options;\n } else if (graphicOrNbTimes !== undefined) {\n // setAnimation(animationName, graphic, nbTimes)\n graphic = graphicOrNbTimes;\n if (typeof nbTimesOrOptions === 'number') {\n finalNbTimes = nbTimesOrOptions;\n } else {\n finalNbTimes = Infinity;\n restoreOptions = nbTimesOrOptions ?? options;\n }\n } else {\n // setAnimation(animationName) - nbTimes remains Infinity\n finalNbTimes = Infinity;\n }\n\n if (this.animationIsPlaying()) {\n this.finishTemporaryAnimation();\n }\n\n const waitPromise =\n finalNbTimes === Infinity\n ? Promise.resolve()\n : new Promise<void>((resolve) => {\n this.animationWaitResolve = resolve;\n });\n\n this.animationIsPlaying.set(true);\n const previousAnimationName =\n restoreOptions?.restoreAnimationName ?? this.animationName();\n const previousGraphics = restoreOptions?.restoreGraphics\n ? [...restoreOptions.restoreGraphics]\n : [...this.graphics()];\n this.animationRestoreState = {\n animationName: previousAnimationName,\n graphics: previousGraphics,\n };\n this.animationCurrentIndex.set(0);\n\n // Temporarily change graphic if provided\n if (graphic !== undefined) {\n if (Array.isArray(graphic)) {\n this.graphics.set(graphic);\n } else {\n this.graphics.set([graphic]);\n }\n }\n\n this.clearAnimationControls();\n\n this.animationSubscription =\n this.animationCurrentIndex.observable.subscribe((index) => {\n if (index >= finalNbTimes) {\n this.finishTemporaryAnimation();\n }\n });\n\n if (finalNbTimes !== Infinity) {\n this.animationResetTimeout = setTimeout(() => {\n if (this.animationIsPlaying()) {\n this.finishTemporaryAnimation();\n }\n }, restoreOptions?.timeoutMs ?? Math.max(1000, finalNbTimes * 1000));\n }\n\n this.animationName.set(animationName);\n\n return waitPromise;\n }\n\n /**\n * Display a registered component animation effect on this object.\n *\n * @param id - Identifier of the component animation to play.\n * @param params - Parameters forwarded to the animation effect.\n * @returns A promise resolved when the animation component calls `onFinish`.\n */\n showComponentAnimation(id: string, params: any): Promise<void> {\n const engine = inject(RpgClientEngine);\n return engine.getComponentAnimation(id).displayEffect(params, this);\n }\n\n /**\n * Display a registered spritesheet animation effect on this object.\n *\n * @param graphic - Identifier of the spritesheet to use.\n * @param animationName - Name of the animation inside the spritesheet.\n * @returns A promise resolved when the animation component calls `onFinish`.\n */\n showAnimation(graphic: string, animationName: string = 'default'): Promise<void> {\n return this.showComponentAnimation('animation', {\n graphic,\n animationName,\n });\n }\n \n /**\n * Check whether this client object represents an event.\n *\n * @returns `true` if the object type is `event`, otherwise `false`.\n */\n isEvent(): boolean {\n return this._type === 'event';\n }\n\n /**\n * Check whether this client object represents a player.\n *\n * @returns `true` if the object type is `player`, otherwise `false`.\n */\n isPlayer(): boolean {\n return this._type === 'player';\n }\n}\n"],"mappings":";;;;;;AA+BA,IAAM,iBAAiB,OAAgB,aAA6B;CAClE,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG,OAAO;CAChE,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,GAAG;EAC7C,MAAM,SAAS,OAAO,KAAK;EAC3B,OAAO,OAAO,SAAS,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;;CAOA,WAAoB;EAClB,OAAO,KAAK,UAAU;CACxB;AACF"}
@@ -263,6 +263,13 @@ function component($$props) {
263
263
  if (!canControls()) return;
264
264
  client.processDash({ direction: directionToDashVector(resolveSpriteDirection()) });
265
265
  };
266
+ let lastEscapeActionAt = 0;
267
+ const processEscapeInput = () => {
268
+ const now = Date.now();
269
+ if (now - lastEscapeActionAt < 50) return;
270
+ lastEscapeActionAt = now;
271
+ if (canControls()) client.processAction({ action: "escape" });
272
+ };
266
273
  const actionBind = () => getKeyboardControlBind(keyboardControls.action);
267
274
  const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;
268
275
  const handleNativeActionWhileMoving = (event) => {
@@ -346,13 +353,13 @@ function component($$props) {
346
353
  back: {
347
354
  bind: keyboardControls.escape,
348
355
  keyDown() {
349
- if (canControls()) client.processAction({ action: "escape" });
356
+ processEscapeInput();
350
357
  }
351
358
  },
352
359
  escape: {
353
360
  bind: keyboardControls.escape,
354
361
  keyDown() {
355
- if (canControls()) client.processAction({ action: "escape" });
362
+ processEscapeInput();
356
363
  }
357
364
  },
358
365
  joystick: {
@@ -1 +1 @@
1
- {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container\n x={smoothX}\n y={smoothY}\n zIndex={z}\n controls\n onBeforeDestroy\n visible\n cursor={interactionCursor}\n pointerover={interactionPointerOver}\n pointerout={interactionPointerOut}\n pointerdown={interactionPointerDown}\n pointerup={interactionPointerUp}\n pointermove={interactionPointerMove}\n click={interactionClick}\n>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n } \n <PlayerComponents object={sprite} position=\"bottom\" graphicBounds />\n <PlayerComponents object={sprite} position=\"left\" graphicBounds />\n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of renderedGraphics) {\n <Container scale={graphicContainerScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox={graphicHitbox(graphicObj)}\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\n </Container>\n }\n @for (eventComponent of resolvedEventComponents) {\n <Container dependencies={eventComponent.dependencies}>\n <eventComponent.component ...eventComponent.props />\n </Container>\n }\n </Container>\n <PlayerComponents object={sprite} position=\"center\" graphicBounds />\n <PlayerComponents object={sprite} position=\"right\" graphicBounds />\n <PlayerComponents object={sprite} position=\"top\" graphicBounds />\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n }\n <InteractionComponents\n object={sprite}\n bounds={graphicBounds}\n hitboxBounds={hitboxBounds}\n graphicBounds={graphicBounds}\n />\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} guiOpenId={attachedGui.openId} onFinish={(data, guiOpenId) => {\n onAttachedGuiFinish(attachedGui, data, guiOpenId)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n import { Assets } from \"pixi.js\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken, shouldRenderLightingShadows } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision } from \"../services/cameraFollow\";\n import { resolveScaledHitboxAnchor, scaleHitboxForGraphicDisplay, toPositiveNumber } from \"./character-hitbox\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import { normalizeEventComponent } from \"../Game/EventComponentResolver\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import InteractionComponents from \"./interaction-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n import {\n getKeyboardControlBind,\n keyboardEventMatchesBind,\n resolveKeyboardActionInput,\n resolveKeyboardDirectionInput,\n } from \"../services/actionInput\";\n\n const { object, id } = defineProps();\n const sprite = object();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const readProp = (value) => typeof value === 'function' ? value() : value;\n const isCurrentPlayer = () => {\n const playerId = client.playerIdSignal();\n const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : undefined;\n return readProp(id) === playerId\n || readProp(sprite?.id) === playerId\n || sprite === currentPlayer\n || sprite === client.sceneMap?.getCurrentPlayer?.();\n };\n const isMe = computed(isCurrentPlayer);\n const shadowsEnabled = computed(() => {\n const lighting = client.sceneMap?.lighting?.();\n return shouldRenderLightingShadows(lighting);\n });\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(sprite) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(sprite) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n\n const isEventSprite = () => {\n return typeof sprite?.isEvent === 'function'\n ? sprite.isEvent()\n : sprite?._type === 'event';\n };\n\n const resolvedEventComponents = computed(() => {\n if (!isEventSprite()) return [];\n const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);\n return eventComponent ? [eventComponent] : [];\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = sprite;\n\n const renderedGraphics = computed(() => {\n const eventComponent = resolvedEventComponents()[0];\n if (eventComponent && !eventComponent.renderGraphic) return [];\n return graphicsSignals();\n });\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && getCanMoveValue(sprite)\n const keyboardControls = client.globalConfig.keyboardControls;\n const activeDirectionKeys = new Map();\n const activeControlDirections = new Map();\n const activeControlDirectionReleaseTimers = new Map();\n const CONTROL_DIRECTION_RELEASE_GRACE_MS = 160;\n\n const hasHeldDirection = () =>\n activeDirectionKeys.size > 0 || activeControlDirections.size > 0;\n\n const publishMobileDebug = (type, payload = {}) => {\n const target = typeof window !== \"undefined\" ? window : globalThis;\n if (!target.__RPGJS_MOBILE_DEBUG__) return;\n const event = {\n source: \"character\",\n type,\n time: Date.now(),\n isCurrentPlayer: isCurrentPlayer(),\n animationName: animationName(),\n realAnimationName: realAnimationName?.(),\n activeKeyboardDirections: Array.from(activeDirectionKeys.values()),\n activeControlDirections: Array.from(activeControlDirections.values()),\n heldDirection: resolveHeldDirection(),\n canControls: canControls(),\n x: x(),\n y: y(),\n ...payload\n };\n target.__RPGJS_MOBILE_DEBUG_EVENTS__ = [\n ...(target.__RPGJS_MOBILE_DEBUG_EVENTS__ || []).slice(-199),\n event\n ];\n target.__RPGJS_MOBILE_DEBUG_LAST__ = event;\n };\n\n const resolveHeldDirection = () => {\n const directions = [\n ...Array.from(activeDirectionKeys.values()),\n ...Array.from(activeControlDirections.values()),\n ];\n return directions[directions.length - 1];\n };\n\n const resolveSpriteDirection = () => {\n const heldDirection = resolveHeldDirection();\n if (heldDirection) return heldDirection;\n if (typeof sprite.getDirection === 'function') return sprite.getDirection();\n if (typeof sprite.direction === 'function') return sprite.direction();\n return direction();\n };\n\n const directionToDashVector = (currentDirection) => {\n switch (currentDirection) {\n case Direction.Left:\n return { x: -1, y: 0 };\n case Direction.Right:\n return { x: 1, y: 0 };\n case Direction.Up:\n return { x: 0, y: -1 };\n case Direction.Down:\n default:\n return { x: 0, y: 1 };\n }\n };\n\n const withCurrentDirection = (payload) => {\n if (payload.action !== 'action') return payload;\n const data = payload.data && typeof payload.data === 'object'\n ? { ...payload.data }\n : {};\n return {\n ...payload,\n data: {\n ...data,\n direction: data.direction ?? resolveSpriteDirection(),\n },\n };\n };\n\n const resolveCurrentActionInput = () =>\n withCurrentDirection(\n resolveKeyboardActionInput(keyboardControls.action, client, sprite)\n );\n\n const playPredictedWalkAnimation = () => {\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationFixed\" });\n return;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationIsPlaying\" });\n return;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"predicted\" });\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"notCurrentPlayer\" });\n return false;\n }\n if (!hasHeldDirection()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"noHeldDirection\" });\n return false;\n }\n if (!canControls()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"cannotControl\" });\n return false;\n }\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationFixed\" });\n return false;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationIsPlaying\" });\n return false;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"resumeHeldDirection\" });\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n publishMobileDebug(\"movement:input\", { input });\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const activateControlDirection = (name, directionInput) => {\n const releaseTimer = activeControlDirectionReleaseTimers.get(name);\n if (releaseTimer) {\n clearTimeout(releaseTimer);\n activeControlDirectionReleaseTimers.delete(name);\n }\n activeControlDirections.delete(name);\n activeControlDirections.set(name, directionInput);\n publishMobileDebug(\"control:activate\", { name, directionInput });\n resumeHeldDirectionWalkAnimation();\n };\n\n const releaseControlDirection = (name) => {\n const previousTimer = activeControlDirectionReleaseTimers.get(name);\n if (previousTimer) clearTimeout(previousTimer);\n activeControlDirectionReleaseTimers.set(name, setTimeout(() => {\n activeControlDirectionReleaseTimers.delete(name);\n activeControlDirections.delete(name);\n publishMobileDebug(\"control:release\", { name });\n if (!hasHeldDirection() && animationName() === 'stand') {\n realAnimationName.set('stand');\n publishMobileDebug(\"stand:set\", { reason: \"controlRelease\" });\n }\n }, CONTROL_DIRECTION_RELEASE_GRACE_MS));\n };\n\n const processDashInput = () => {\n if (!canControls()) return;\n client.processDash({\n direction: directionToDashVector(resolveSpriteDirection()),\n });\n };\n\n const actionBind = () => getKeyboardControlBind(keyboardControls.action);\n const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;\n\n const handleNativeActionWhileMoving = (event) => {\n const inputDirection = resolveKeyboardDirectionInput(event, keyboardControls);\n if (inputDirection) {\n const keyId = keyboardEventId(event);\n if (event.type === 'keydown') {\n activeDirectionKeys.delete(keyId);\n activeDirectionKeys.set(keyId, inputDirection);\n resumeHeldDirectionWalkAnimation();\n }\n else {\n activeDirectionKeys.delete(keyId);\n }\n }\n\n if (!isCurrentPlayer()) return;\n if (event.type !== 'keydown' || event.repeat) return;\n if (activeDirectionKeys.size === 0) return;\n if (!keyboardEventMatchesBind(event, actionBind())) return;\n if (!canControls()) return;\n\n client.processAction(resolveCurrentActionInput());\n };\n\n const visible = computed(() => {\n if (sprite.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = {\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n activateControlDirection('down', Direction.Down)\n processMovementInput(Direction.Down)\n },\n keyUp() {\n releaseControlDirection('down')\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n activateControlDirection('up', Direction.Up)\n processMovementInput(Direction.Up)\n },\n keyUp() {\n releaseControlDirection('up')\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n activateControlDirection('left', Direction.Left)\n processMovementInput(Direction.Left)\n },\n keyUp() {\n releaseControlDirection('left')\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n activateControlDirection('right', Direction.Right)\n processMovementInput(Direction.Right)\n },\n keyUp() {\n releaseControlDirection('right')\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n back: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\n },\n joystick: {\n enabled: true,\n directionMapping: {\n top: 'up',\n bottom: 'down',\n left: 'left',\n right: 'right',\n top_left: ['up', 'left'],\n top_right: ['up', 'right'],\n bottom_left: ['down', 'left'],\n bottom_right: ['down', 'right']\n },\n moveInterval: 50,\n threshold: 0.1\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n const box = hitbox?.()\n return sprite.y() + (box?.h ?? 0) + sprite.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.scale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return undefined;\n }\n\n const graphicContainerScale = (graphicObject) => {\n const scale = graphicObject?.displayScale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return [1, 1];\n }\n\n const multiplyScale = (left, right) => {\n const a = normalizePair(left);\n const b = normalizePair(right);\n return [a[0] * b[0], a[1] * b[1]];\n }\n\n const graphicHitbox = (graphicObject) => {\n const box = hitbox();\n const scale = graphicEffectiveScale(graphicObject);\n return scaleHitboxForGraphicDisplay(box, scale);\n }\n\n const shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32);\n\n return {\n enabled: shadowsEnabled,\n height,\n footAnchor: { x: 0.5, y: 1 },\n footOffset: { x: 0, y: 2 },\n alpha: 0.5,\n blur: 3.5,\n gradientPower: 2,\n hardness: 0.42,\n minLength: Math.max(6, (box?.h ?? 32) * 0.25),\n maxLength: Math.max(90, height * 1.8),\n contactAlpha: 0.3,\n contactScale: 0.3,\n };\n }\n\n const imageDimensions = signal({});\n const loadingImageDimensions = new Set();\n\n const toFiniteNumber = (value, fallback = 0) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) ? number : fallback;\n };\n\n const clampRatio = (value) => Math.min(1, Math.max(0, value));\n\n const normalizePair = (value, fallback = [1, 1]) => {\n if (Array.isArray(value)) {\n const x = toFiniteNumber(value[0], fallback[0]);\n const y = toFiniteNumber(value[1] ?? value[0], x);\n return [x, y];\n }\n if (typeof value === 'number') {\n return [value, value];\n }\n if (value && typeof value === 'object') {\n const x = toFiniteNumber(value.x, fallback[0]);\n const y = toFiniteNumber(value.y ?? value.x, x);\n return [x, y];\n }\n return fallback;\n };\n\n const normalizeAnchor = (value) => {\n if (!Array.isArray(value)) return undefined;\n const [x, y] = normalizePair(value, [0, 0]);\n return [clampRatio(x), clampRatio(y)];\n };\n\n const resolveImageSource = (image) => {\n if (typeof image === 'string') return image;\n if (typeof image?.default === 'string') return image.default;\n return undefined;\n };\n\n const parentTextureOptions = (graphicObject) => {\n const props = [\n 'width',\n 'height',\n 'framesHeight',\n 'framesWidth',\n 'rectWidth',\n 'rectHeight',\n 'offset',\n 'image',\n 'sound',\n 'spriteRealSize',\n 'scale',\n 'anchor',\n 'pivot',\n 'x',\n 'y',\n 'opacity'\n ];\n\n return props.reduce((options, prop) => {\n if (graphicObject?.[prop] !== undefined) {\n options[prop] = graphicObject[prop];\n }\n return options;\n }, {});\n };\n\n const resolveTextureOptions = (graphicObject) => {\n const textures = graphicObject?.textures ?? {};\n const texture =\n textures[realAnimationName()] ??\n textures[Animation.Stand] ??\n Object.values(textures)[0] ??\n {};\n\n return {\n ...parentTextureOptions(graphicObject),\n ...texture\n };\n };\n\n const resolveFirstAnimationFrame = (textureOptions) => {\n const animations = textureOptions?.animations;\n if (!animations) return {};\n\n try {\n const frames = typeof animations === 'function'\n ? animations({ direction: direction() })\n : animations;\n if (!Array.isArray(frames)) return {};\n const firstGroup = frames[0];\n return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};\n }\n catch {\n return {};\n }\n };\n\n const optionValue = (prop, frame, textureOptions, graphicObject) => {\n return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];\n };\n\n const graphicEffectiveScale = (graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const spriteScale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\n return multiplyScale(spriteScale, graphicContainerScale(graphicObject));\n };\n\n const resolveFrameSize = (textureOptions, dimensions) => {\n const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;\n const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;\n const imageSource = resolveImageSource(textureOptions?.image);\n const loadedSize = imageSource ? dimensions[imageSource] : undefined;\n const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;\n const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;\n const width = toPositiveNumber(textureOptions?.rectWidth) ??\n toPositiveNumber(textureOptions?.spriteWidth) ??\n (fullWidth ? fullWidth / framesWidth : undefined);\n const height = toPositiveNumber(textureOptions?.rectHeight) ??\n toPositiveNumber(textureOptions?.spriteHeight) ??\n (fullHeight ? fullHeight / framesHeight : undefined);\n\n return {\n width,\n height\n };\n };\n\n const loadImageDimensions = (image) => {\n const source = resolveImageSource(image);\n if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) {\n return;\n }\n\n loadingImageDimensions.add(source);\n Assets.load(source)\n .then((texture) => {\n const width = toPositiveNumber(texture?.width);\n const height = toPositiveNumber(texture?.height);\n if (!width || !height) return;\n\n imageDimensions.update((dimensions) => ({\n ...dimensions,\n [source]: { width, height }\n }));\n })\n .catch(() => {})\n .finally(() => {\n loadingImageDimensions.delete(source);\n });\n };\n\n effect(() => {\n const sources = new Set();\n\n graphicsSignals().forEach((graphicObject) => {\n const baseImage = resolveImageSource(graphicObject?.image);\n if (baseImage) sources.add(baseImage);\n\n Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {\n const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);\n if (image) sources.add(image);\n });\n });\n\n sources.forEach((source) => loadImageDimensions(source));\n });\n\n const hitboxBounds = computed(() => {\n const box = hitbox();\n const width = box?.w ?? 0;\n const height = box?.h ?? 0;\n\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n centerX: width / 2,\n centerY: height / 2\n };\n });\n\n const graphicBounds = computed(() => {\n const box = hitbox();\n const fallback = hitboxBounds();\n const customEventComponent = resolvedEventComponents()[0];\n if (customEventComponent && !customEventComponent.renderGraphic) {\n return fallback;\n }\n const dimensions = imageDimensions();\n const graphics = graphicsSignals();\n let bounds = null;\n\n graphics.forEach((graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const size = resolveFrameSize(textureOptions, dimensions);\n const spriteWidth = size.width ?? box?.w;\n const spriteHeight = size.height ?? box?.h;\n\n if (!spriteWidth || !spriteHeight) {\n return;\n }\n\n const scale = graphicEffectiveScale(graphicObject);\n const explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveScaledHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box,\n scale\n );\n const x = toFiniteNumber(optionValue('x', frame, textureOptions, graphicObject), 0);\n const y = toFiniteNumber(optionValue('y', frame, textureOptions, graphicObject), 0);\n const leftEdge = -anchor[0] * spriteWidth * scale[0];\n const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];\n const topEdge = -anchor[1] * spriteHeight * scale[1];\n const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];\n const graphic = {\n left: x + Math.min(leftEdge, rightEdge),\n top: y + Math.min(topEdge, bottomEdge),\n right: x + Math.max(leftEdge, rightEdge),\n bottom: y + Math.max(topEdge, bottomEdge)\n };\n\n bounds = bounds\n ? {\n left: Math.min(bounds.left, graphic.left),\n top: Math.min(bounds.top, graphic.top),\n right: Math.max(bounds.right, graphic.right),\n bottom: Math.max(bounds.bottom, graphic.bottom)\n }\n : graphic;\n });\n\n if (!bounds) {\n return fallback;\n }\n\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n\n return {\n ...bounds,\n width,\n height,\n centerX: bounds.left + width / 2,\n centerY: bounds.top + height / 2\n };\n });\n\n const interactionBounds = () => ({\n bounds: graphicBounds(),\n hitbox: hitboxBounds(),\n graphic: graphicBounds()\n });\n\n const interactionCursor = computed(() =>\n client.interactions.cursorFor(sprite, interactionBounds())\n );\n\n const handleInteraction = (type) => (event) => {\n client.updatePointerFromInteractionEvent(event);\n client.interactions.handle(sprite, type, {\n event,\n bounds: interactionBounds()\n });\n };\n\n const interactionPointerOver = handleInteraction('pointerover');\n const interactionPointerOut = handleInteraction('pointerout');\n const interactionPointerDown = handleInteraction('pointerdown');\n const interactionPointerUp = handleInteraction('pointerup');\n const interactionPointerMove = handleInteraction('pointermove');\n const interactionClick = handleInteraction('click');\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n let beforeRemovePromise = null;\n let beforeRemoveTransitionValue = null;\n const resolveRemoveContext = () => {\n if (!sprite._removeTransition) return null;\n const value = sprite._removeTransition();\n if (!value || typeof value !== 'string') return null;\n try {\n const context = JSON.parse(value);\n if (!context || typeof context !== 'object' || !context.active) return null;\n context.__transitionValue = value;\n return context;\n }\n catch {\n return null;\n }\n };\n\n const withTimeout = (promise, timeoutMs = 0) => {\n if (!timeoutMs || timeoutMs <= 0) return promise;\n return Promise.race([\n promise,\n new Promise((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n };\n\n const runBeforeRemove = () => {\n const context = resolveRemoveContext();\n if (!context) return Promise.resolve();\n if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) {\n return beforeRemovePromise;\n }\n beforeRemoveTransitionValue = context.__transitionValue;\n beforeRemovePromise = withTimeout(\n lastValueFrom(hooks.callHooks(\"client-sprite-onBeforeRemove\", sprite, context)),\n context.timeoutMs\n );\n return beforeRemovePromise;\n };\n\n const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {\n if (resolveRemoveContext()) {\n runBeforeRemove();\n }\n });\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n const isMovementAnimation = movementAnimations.includes(curr);\n const isTemporaryAnimationPlaying =\n sprite.animationIsPlaying && sprite.animationIsPlaying();\n\n if (sprite.animationFixed && isMovementAnimation) {\n realAnimationName.set(curr);\n return;\n }\n\n if (curr == 'stand' && !isMoving) {\n if (!resumeHeldDirectionWalkAnimation()) {\n realAnimationName.set(curr);\n }\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!isMovementAnimation) {\n realAnimationName.set(curr);\n }\n if (!isMoving && isTemporaryAnimationPlaying) {\n if (isMovementAnimation) {\n if (typeof sprite.resetAnimationState === 'function') {\n sprite.resetAnimationState();\n }\n }\n }\n });\n\n const resumeWalkSubscriptions = [\n sprite._canMove,\n sprite._animationFixed,\n sprite.animationIsPlaying,\n ]\n .filter(signal => signal?.observable)\n .map(signal => signal.observable.subscribe(() => {\n resumeHeldDirectionWalkAnimation();\n }));\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {\n if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let finished = false;\n let timeout;\n let subscription;\n const finish = () => {\n if (finished) return;\n finished = true;\n clearTimeout(timeout);\n subscription?.unsubscribe();\n resolve();\n };\n timeout = setTimeout(finish, maxDuration);\n subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {\n if (!isPlaying) finish();\n });\n if (finished) subscription.unsubscribe();\n });\n };\n\n const onBeforeDestroy = async () => {\n await runBeforeRemove();\n await waitForTemporaryAnimationEnd();\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handleNativeActionWhileMoving);\n document.removeEventListener('keyup', handleNativeActionWhileMoving);\n }\n removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\n resumeWalkSubscriptions.forEach(subscription => subscription.unsubscribe());\n activeControlDirectionReleaseTimers.forEach(timer => clearTimeout(timer));\n activeControlDirectionReleaseTimers.clear();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", sprite)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, sprite))\n }\n\n mount((element) => {\n let appliedCameraFollowRevision = null;\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', handleNativeActionWhileMoving);\n document.addEventListener('keyup', handleNativeActionWhileMoving);\n }\n hooks.callHooks(\"client-sprite-onAdd\", sprite).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, sprite).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n\n effect(() => {\n const followRevision = client.cameraFollowRevision();\n if (!shouldFollowCamera()) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const smoothMove = client.cameraFollowSmoothMove;\n const viewport = element.props.context?.viewport;\n const target = element.componentInstance;\n if (!viewport || !target) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const appliedCameraFollow = applyCameraFollow({\n viewport,\n target,\n smoothMove,\n followRevision,\n isCurrentRevision: (revision) => client.cameraFollowRevision() === revision,\n shouldFollowCamera\n });\n appliedCameraFollowRevision = appliedCameraFollow ? followRevision : null;\n })\n\n return () => {\n if (ownsCameraFollowRevision(appliedCameraFollowRevision, client.cameraFollowRevision())) {\n clearCameraFollowPlugins(element.props.context?.viewport);\n }\n }\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const normalizeOpenId = (value) => {\n const resolved = typeof value === \"function\" ? value() : value;\n return typeof resolved === \"string\" && resolved.length > 0 ? resolved : undefined;\n };\n\n const onAttachedGuiFinish = (gui, data, guiOpenId) => {\n const completedOpenId = normalizeOpenId(guiOpenId);\n const currentOpenId = normalizeOpenId(gui.openId);\n if (completedOpenId && currentOpenId && completedOpenId !== currentOpenId) return;\n guiService.guiClose(gui.name, data, completedOpenId ?? currentOpenId);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;AAsBG,SAAS,UAAM,SAAA;CACN,SAAA,OAAA;CACJ,MAAE,cAAc,eAAkB,OAAA;CAClB,eAAA,OAAsB;CACtC,MAAC,EAAM,QAAA,OAAA,YAAA;CACf,MAAM,SAAS,OAAO;CACtB,MAAM,SAAI,OAAS,eAAA;CACnB,MAAM,QAAQ,OAAA,YAAA;CACd,MAAM,aAAY,OAAA,MAAc;CACtB,OAAc;CACxB,MAAM,mBAAW,OAAW;CAC5B,MAAM,oBAAG,OAAA;CACT,MAAM,YAAW,UAAA,OAAA,UAAA,aAAA,MAAA,IAAA;CACjB,MAAI,wBAAA;EACA,MAAM,WAAA,OAAkB,eAAA;EACxB,MAAG,gBAAU,WAAc,OAAA,UAAe,UAAa,IAAA,YAAA,KAAA;EACvD,OAAK,SAAA,EAAA,MAAe,YAChB,SAAS,QAAA,EAAA,MAAA,YACb,WAAA,iBACA,WAAS,OAAA,UAAA,mBAAA;CACb;CACA,MAAG,OAAA,SAAiB,eAAgB;CACpC,MAAG,iBAAiB,eAAgB;EACjC,MAAK,WAAa,OAAC,UAAA,WAA2B;EAC7C,OAAC,4BAAkC,QAAC;CACxC,CAAC;CACD,MAAM,sBAAS,SAAA;EACb,IAAA;EACC,IAAA;EACC,IAAA;EAEA,IAAA,OAAA,SAAc,cAAY,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;GAC1B,eAAe;GAChB,aAAA,KAAA;GACK,iBAAe,KAAA;EACnB,OAEK,IAAA,QAAY,OAAA,SAAa,YAAY,KAAO,WAAY;GACzD,eAAE,KAAA;GAEF,aAAE,KAAA,UAAyB,KAAA,IAAa,KAAK,QAAK,KAAA;GAClD,iBAAI,KAAA;EACR,OAEF;GACA,eAAS;;GAEJ,iBAAA,KAAA;EACL;EAG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AA,CAAA,CAAA,GAAA,KAAA,0BAAA,mBAAA,EAAA,WAAA,EAAA,cAAA,eAAA,aAAA,GAAA,EAAA,eAAA,WAAA,eAAA,KAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA,QAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA,QAAA;GAAA,QAAA;GAAA;GAAA;EAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA,QAAA;GAAA,WAAA,YAAA;GAAA,WAAA,MAAA,cAAA;;GAExC;GAAG,gBAAgB,MAAA,SAAc;IACjC,yBAAM,aAAA,MAAA,IAAA;GACR;EAAA,CAAA,CAAA,CAAA,CAAA;CAAA,CAAA;AAEA;AAEA,IAAM,iBAAS"}
1
+ {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container\n x={smoothX}\n y={smoothY}\n zIndex={z}\n controls\n onBeforeDestroy\n visible\n cursor={interactionCursor}\n pointerover={interactionPointerOver}\n pointerout={interactionPointerOut}\n pointerdown={interactionPointerDown}\n pointerup={interactionPointerUp}\n pointermove={interactionPointerMove}\n click={interactionClick}\n>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n } \n <PlayerComponents object={sprite} position=\"bottom\" graphicBounds />\n <PlayerComponents object={sprite} position=\"left\" graphicBounds />\n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of renderedGraphics) {\n <Container scale={graphicContainerScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox={graphicHitbox(graphicObj)}\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\n </Container>\n }\n @for (eventComponent of resolvedEventComponents) {\n <Container dependencies={eventComponent.dependencies}>\n <eventComponent.component ...eventComponent.props />\n </Container>\n }\n </Container>\n <PlayerComponents object={sprite} position=\"center\" graphicBounds />\n <PlayerComponents object={sprite} position=\"right\" graphicBounds />\n <PlayerComponents object={sprite} position=\"top\" graphicBounds />\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object={sprite} ...compConfig.props />\n </Container>\n }\n <InteractionComponents\n object={sprite}\n bounds={graphicBounds}\n hitboxBounds={hitboxBounds}\n graphicBounds={graphicBounds}\n />\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} guiOpenId={attachedGui.openId} onFinish={(data, guiOpenId) => {\n onAttachedGuiFinish(attachedGui, data, guiOpenId)\n }} onInteraction={(name, data) => {\n onAttachedGuiInteraction(attachedGui, name, data)\n }} />\n </Container>\n }\n }\n</Container>\n\n<script>\n import { signal, effect, mount, computed, tick, animatedSignal, on } from \"canvasengine\";\n import { Assets } from \"pixi.js\";\n\n import { lastValueFrom, combineLatest, pairwise, filter, map, startWith } from \"rxjs\";\n import { Particle } from \"@canvasengine/presets\";\n import { GameEngineToken, ModulesToken, shouldRenderLightingShadows } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { applyCameraFollow, clearCameraFollowPlugins, ownsCameraFollowRevision } from \"../services/cameraFollow\";\n import { resolveScaledHitboxAnchor, scaleHitboxForGraphicDisplay, toPositiveNumber } from \"./character-hitbox\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import { normalizeEventComponent } from \"../Game/EventComponentResolver\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import InteractionComponents from \"./interaction-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n import {\n getKeyboardControlBind,\n keyboardEventMatchesBind,\n resolveKeyboardActionInput,\n resolveKeyboardDirectionInput,\n } from \"../services/actionInput\";\n\n const { object, id } = defineProps();\n const sprite = object();\n\n const client = inject(RpgClientEngine);\n const hooks = inject(ModulesToken);\n const guiService = inject(RpgGui);\n\n const spritesheets = client.spritesheets;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const readProp = (value) => typeof value === 'function' ? value() : value;\n const isCurrentPlayer = () => {\n const playerId = client.playerIdSignal();\n const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : undefined;\n return readProp(id) === playerId\n || readProp(sprite?.id) === playerId\n || sprite === currentPlayer\n || sprite === client.sceneMap?.getCurrentPlayer?.();\n };\n const isMe = computed(isCurrentPlayer);\n const shadowsEnabled = computed(() => {\n const lighting = client.sceneMap?.lighting?.();\n return shouldRenderLightingShadows(lighting);\n });\n\n /**\n * Normalize a single sprite component configuration\n * \n * Handles both direct component references and configuration objects with optional props and dependencies.\n * Extracts the component reference and creates a computed function that returns the props.\n * \n * ## Design\n * \n * Supports two formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...}, dependencies: (object) => [...] }`\n * \n * The normalization process:\n * - Extracts the actual component from either format\n * - Extracts dependencies function if provided\n * - Creates a computed function that returns props (static object or dynamic function result)\n * - Returns a normalized object with `component`, `props`, and `dependencies`\n * \n * @param comp - Component reference or configuration object\n * @returns Normalized component configuration with component, props, and dependencies\n * \n * @example\n * ```ts\n * // Direct component\n * normalizeComponent(ShadowComponent)\n * // => { component: ShadowComponent, props: {}, dependencies: undefined }\n * \n * // With static props\n * normalizeComponent({ component: LightHalo, props: { radius: 30 } })\n * // => { component: LightHalo, props: { radius: 30 }, dependencies: undefined }\n * \n * // With dynamic props and dependencies\n * normalizeComponent({ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * })\n * // => { component: HealthBar, props: {...}, dependencies: (object) => [...] }\n * ```\n */\n const normalizeComponent = (comp) => {\n let componentRef;\n let propsValue;\n let dependenciesFn;\n \n // If it's a direct component reference\n if (typeof comp === 'function' || (comp && typeof comp === 'object' && !comp.component)) {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n // If it's a configuration object with component and props\n else if (comp && typeof comp === 'object' && comp.component) {\n componentRef = comp.component;\n // Support both \"data\" (legacy) and \"props\" (new) for backward compatibility\n propsValue = comp.props !== undefined ? comp.props : comp.data;\n dependenciesFn = comp.dependencies;\n }\n // Fallback: treat as direct component\n else {\n componentRef = comp;\n propsValue = undefined;\n dependenciesFn = undefined;\n }\n \n // Return props directly (object or function), not as computed\n // The computed will be created in the template when needed\n return {\n component: componentRef,\n props: typeof propsValue === 'function' ? propsValue(sprite) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(sprite) : []\n };\n };\n\n /**\n * Normalize an array of sprite components\n * \n * Applies normalization to each component in the array using `normalizeComponent`.\n * \n * @param components - Array of component references or configuration objects\n * @returns Array of normalized component configurations\n */\n const normalizeComponents = (components) => {\n return components.map((comp) => normalizeComponent(comp));\n };\n\n\n /**\n * Normalized components to render behind sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * Supports multiple formats:\n * 1. Direct component: `ShadowComponent`\n * 2. Configuration object: `{ component: LightHalo, props: {...} }`\n * 3. With dynamic props: `{ component: LightHalo, props: (object) => {...} }`\n * 4. With dependencies: `{ component: HealthBar, dependencies: (object) => [object.hp, object.param.maxHp] }`\n * \n * Components with dependencies will only be displayed when all dependencies are resolved (!= undefined).\n * The object is passed to the dependencies function to allow sprite-specific dependency resolution.\n * \n * @example\n * ```ts\n * // Direct component\n * componentsBehind: [ShadowComponent]\n * \n * // With static props\n * componentsBehind: [{ component: LightHalo, props: { radius: 30 } }]\n * \n * // With dynamic props and dependencies\n * componentsBehind: [{ \n * component: HealthBar, \n * props: (object) => ({ hp: object.hp(), maxHp: object.param.maxHp() }),\n * dependencies: (object) => [object.hp, object.param.maxHp]\n * }]\n * ```\n */\n const normalizedComponentsBehind = computed(() => {\n return normalizeComponents(componentsBehind());\n });\n\n /**\n * Normalized components to render in front of sprites\n * Handles both direct component references and configuration objects with optional props and dependencies\n * \n * See `normalizedComponentsBehind` for format details.\n * Components with dependencies will only be displayed when all dependencies are resolved.\n */\n const normalizedComponentsInFront = computed(() => {\n return normalizeComponents(componentsInFront());\n });\n\n const isEventSprite = () => {\n return typeof sprite?.isEvent === 'function'\n ? sprite.isEvent()\n : sprite?._type === 'event';\n };\n\n const resolvedEventComponents = computed(() => {\n if (!isEventSprite()) return [];\n const eventComponent = normalizeEventComponent(client.resolveEventComponent(sprite), sprite);\n return eventComponent ? [eventComponent] : [];\n });\n \n /**\n * Determine if the camera should follow this sprite\n * \n * The camera follows this sprite if:\n * - It's explicitly set as the camera follow target, OR\n * - It's the current player and no explicit target is set (default behavior)\n */\n const shouldFollowCamera = computed(() => {\n const cameraTargetId = client.cameraFollowTargetId();\n // If a target is explicitly set, only follow if this sprite is the target\n if (cameraTargetId !== null) {\n return id() === cameraTargetId;\n }\n // Otherwise, follow the current player (default behavior)\n return isMe();\n });\n\n /**\n * Get all attached GUI components that should be rendered on sprites\n * These are GUIs with attachToSprite: true\n */\n const attachedGuis = computed(() => {\n return guiService.getAttachedGuis();\n });\n\n /**\n * Check if attached GUIs should be displayed for this sprite\n * This is controlled by showAttachedGui/hideAttachedGui on the server\n */\n const shouldDisplayAttachedGui = computed(() => {\n return guiService.shouldDisplayAttachedGui(id());\n });\n\n const { \n x, \n y, \n tint, \n direction, \n animationName, \n animationCurrentIndex,\n emitParticleTrigger, \n particleName, \n graphics, \n hitbox,\n isConnected,\n graphicsSignals,\n flashTrigger\n } = sprite;\n\n const renderedGraphics = computed(() => {\n const eventComponent = resolvedEventComponents()[0];\n if (eventComponent && !eventComponent.renderGraphic) return [];\n return graphicsSignals();\n });\n\n /**\n * Flash configuration signals for dynamic options\n * These signals are updated when the flash trigger is activated with options\n */\n const flashType = signal<'alpha' | 'tint' | 'both'>('alpha');\n const flashDuration = signal(300);\n const flashCycles = signal(1);\n const flashAlpha = signal(0.3);\n const flashTint = signal(0xffffff);\n\n /**\n * Listen to flash trigger to update configuration dynamically\n * When flash is triggered with options, update the signals\n */\n on(flashTrigger, (data) => {\n if (data && typeof data === 'object') {\n if (data.type !== undefined) flashType.set(data.type);\n if (data.duration !== undefined) flashDuration.set(data.duration);\n if (data.cycles !== undefined) flashCycles.set(data.cycles);\n if (data.alpha !== undefined) flashAlpha.set(data.alpha);\n if (data.tint !== undefined) flashTint.set(data.tint);\n }\n });\n\n /**\n * Flash configuration for the sprite\n * \n * This configuration is used by the flash directive to create visual feedback effects.\n * The flash trigger is exposed through the object, allowing both server events and\n * client-side code to trigger flash animations. Options can be passed dynamically\n * through the trigger, which updates the reactive signals.\n */\n const flashConfig = computed(() => ({\n trigger: flashTrigger,\n type: flashType(),\n duration: flashDuration(),\n cycles: flashCycles(),\n alpha: flashAlpha(),\n tint: flashTint(),\n }));\n\n const particleSettings = client.particleSettings;\n\n const canControls = () => isMe() && getCanMoveValue(sprite)\n const keyboardControls = client.globalConfig.keyboardControls;\n const activeDirectionKeys = new Map();\n const activeControlDirections = new Map();\n const activeControlDirectionReleaseTimers = new Map();\n const CONTROL_DIRECTION_RELEASE_GRACE_MS = 160;\n\n const hasHeldDirection = () =>\n activeDirectionKeys.size > 0 || activeControlDirections.size > 0;\n\n const publishMobileDebug = (type, payload = {}) => {\n const target = typeof window !== \"undefined\" ? window : globalThis;\n if (!target.__RPGJS_MOBILE_DEBUG__) return;\n const event = {\n source: \"character\",\n type,\n time: Date.now(),\n isCurrentPlayer: isCurrentPlayer(),\n animationName: animationName(),\n realAnimationName: realAnimationName?.(),\n activeKeyboardDirections: Array.from(activeDirectionKeys.values()),\n activeControlDirections: Array.from(activeControlDirections.values()),\n heldDirection: resolveHeldDirection(),\n canControls: canControls(),\n x: x(),\n y: y(),\n ...payload\n };\n target.__RPGJS_MOBILE_DEBUG_EVENTS__ = [\n ...(target.__RPGJS_MOBILE_DEBUG_EVENTS__ || []).slice(-199),\n event\n ];\n target.__RPGJS_MOBILE_DEBUG_LAST__ = event;\n };\n\n const resolveHeldDirection = () => {\n const directions = [\n ...Array.from(activeDirectionKeys.values()),\n ...Array.from(activeControlDirections.values()),\n ];\n return directions[directions.length - 1];\n };\n\n const resolveSpriteDirection = () => {\n const heldDirection = resolveHeldDirection();\n if (heldDirection) return heldDirection;\n if (typeof sprite.getDirection === 'function') return sprite.getDirection();\n if (typeof sprite.direction === 'function') return sprite.direction();\n return direction();\n };\n\n const directionToDashVector = (currentDirection) => {\n switch (currentDirection) {\n case Direction.Left:\n return { x: -1, y: 0 };\n case Direction.Right:\n return { x: 1, y: 0 };\n case Direction.Up:\n return { x: 0, y: -1 };\n case Direction.Down:\n default:\n return { x: 0, y: 1 };\n }\n };\n\n const withCurrentDirection = (payload) => {\n if (payload.action !== 'action') return payload;\n const data = payload.data && typeof payload.data === 'object'\n ? { ...payload.data }\n : {};\n return {\n ...payload,\n data: {\n ...data,\n direction: data.direction ?? resolveSpriteDirection(),\n },\n };\n };\n\n const resolveCurrentActionInput = () =>\n withCurrentDirection(\n resolveKeyboardActionInput(keyboardControls.action, client, sprite)\n );\n\n const playPredictedWalkAnimation = () => {\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationFixed\" });\n return;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:skip\", { reason: \"animationIsPlaying\" });\n return;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"predicted\" });\n };\n\n const resumeHeldDirectionWalkAnimation = () => {\n if (!isCurrentPlayer()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"notCurrentPlayer\" });\n return false;\n }\n if (!hasHeldDirection()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"noHeldDirection\" });\n return false;\n }\n if (!canControls()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"cannotControl\" });\n return false;\n }\n if (sprite.animationFixed) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationFixed\" });\n return false;\n }\n if (sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n publishMobileDebug(\"walk:resume-fail\", { reason: \"animationIsPlaying\" });\n return false;\n }\n realAnimationName.set('walk');\n publishMobileDebug(\"walk:set\", { reason: \"resumeHeldDirection\" });\n return true;\n };\n\n const processMovementInput = (input) => {\n if (!canControls()) return;\n publishMobileDebug(\"movement:input\", { input });\n client.processInput({ input });\n playPredictedWalkAnimation();\n };\n\n const activateControlDirection = (name, directionInput) => {\n const releaseTimer = activeControlDirectionReleaseTimers.get(name);\n if (releaseTimer) {\n clearTimeout(releaseTimer);\n activeControlDirectionReleaseTimers.delete(name);\n }\n activeControlDirections.delete(name);\n activeControlDirections.set(name, directionInput);\n publishMobileDebug(\"control:activate\", { name, directionInput });\n resumeHeldDirectionWalkAnimation();\n };\n\n const releaseControlDirection = (name) => {\n const previousTimer = activeControlDirectionReleaseTimers.get(name);\n if (previousTimer) clearTimeout(previousTimer);\n activeControlDirectionReleaseTimers.set(name, setTimeout(() => {\n activeControlDirectionReleaseTimers.delete(name);\n activeControlDirections.delete(name);\n publishMobileDebug(\"control:release\", { name });\n if (!hasHeldDirection() && animationName() === 'stand') {\n realAnimationName.set('stand');\n publishMobileDebug(\"stand:set\", { reason: \"controlRelease\" });\n }\n }, CONTROL_DIRECTION_RELEASE_GRACE_MS));\n };\n\n const processDashInput = () => {\n if (!canControls()) return;\n client.processDash({\n direction: directionToDashVector(resolveSpriteDirection()),\n });\n };\n\n let lastEscapeActionAt = 0;\n const processEscapeInput = () => {\n const now = Date.now();\n if (now - lastEscapeActionAt < 50) return;\n lastEscapeActionAt = now;\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n };\n\n const actionBind = () => getKeyboardControlBind(keyboardControls.action);\n const keyboardEventId = (event) => `${event.keyCode}:${event.code}:${event.key}`;\n\n const handleNativeActionWhileMoving = (event) => {\n const inputDirection = resolveKeyboardDirectionInput(event, keyboardControls);\n if (inputDirection) {\n const keyId = keyboardEventId(event);\n if (event.type === 'keydown') {\n activeDirectionKeys.delete(keyId);\n activeDirectionKeys.set(keyId, inputDirection);\n resumeHeldDirectionWalkAnimation();\n }\n else {\n activeDirectionKeys.delete(keyId);\n }\n }\n\n if (!isCurrentPlayer()) return;\n if (event.type !== 'keydown' || event.repeat) return;\n if (activeDirectionKeys.size === 0) return;\n if (!keyboardEventMatchesBind(event, actionBind())) return;\n if (!canControls()) return;\n\n client.processAction(resolveCurrentActionInput());\n };\n\n const visible = computed(() => {\n if (sprite.isEvent()) {\n return true\n }\n return isConnected()\n });\n\n const controls = {\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n activateControlDirection('down', Direction.Down)\n processMovementInput(Direction.Down)\n },\n keyUp() {\n releaseControlDirection('down')\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n activateControlDirection('up', Direction.Up)\n processMovementInput(Direction.Up)\n },\n keyUp() {\n releaseControlDirection('up')\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n activateControlDirection('left', Direction.Left)\n processMovementInput(Direction.Left)\n },\n keyUp() {\n releaseControlDirection('left')\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n activateControlDirection('right', Direction.Right)\n processMovementInput(Direction.Right)\n },\n keyUp() {\n releaseControlDirection('right')\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveCurrentActionInput())\n }\n },\n },\n dash: {\n bind: keyboardControls.dash,\n keyDown() {\n processDashInput()\n },\n },\n back: {\n bind: keyboardControls.escape,\n keyDown() {\n processEscapeInput()\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n processEscapeInput()\n },\n },\n joystick: {\n enabled: true,\n directionMapping: {\n top: 'up',\n bottom: 'down',\n left: 'left',\n right: 'right',\n top_left: ['up', 'left'],\n top_right: ['up', 'right'],\n bottom_left: ['down', 'left'],\n bottom_right: ['down', 'right']\n },\n moveInterval: 50,\n threshold: 0.1\n },\n gamepad: {\n enabled: true\n }\n };\n\n const smoothX = animatedSignal(x(), {\n duration: isMe() ? 0 : 0\n });\n\n const smoothY = animatedSignal(y(), {\n duration: isMe() ? 0 : 0,\n });\n\n const z = computed(() => {\n const box = hitbox?.()\n return sprite.y() + (box?.h ?? 0) + sprite.z()\n });\n\n const realAnimationName = signal(animationName());\n\n const xSubscription = x.observable.subscribe((value) => {\n smoothX.set(value);\n });\n\n const ySubscription = y.observable.subscribe((value) => {\n smoothY.set(value);\n });\n \n const sheet = (graphicObject) => {\n return {\n definition: graphicObject,\n playing: realAnimationName(),\n params: {\n direction: direction()\n },\n onFinish() {\n animationCurrentIndex.update(index => index + 1)\n }\n };\n }\n\n const graphicScale = (graphicObject) => {\n const scale = graphicObject?.scale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return undefined;\n }\n\n const graphicContainerScale = (graphicObject) => {\n const scale = graphicObject?.displayScale;\n if (Array.isArray(scale)) return scale;\n if (typeof scale === 'number') return [scale, scale];\n if (scale && typeof scale === 'object') {\n const x = typeof scale.x === 'number' ? scale.x : 1;\n const y = typeof scale.y === 'number' ? scale.y : x;\n return [x, y];\n }\n return [1, 1];\n }\n\n const multiplyScale = (left, right) => {\n const a = normalizePair(left);\n const b = normalizePair(right);\n return [a[0] * b[0], a[1] * b[1]];\n }\n\n const graphicHitbox = (graphicObject) => {\n const box = hitbox();\n const scale = graphicEffectiveScale(graphicObject);\n return scaleHitboxForGraphicDisplay(box, scale);\n }\n\n const shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32);\n\n return {\n enabled: shadowsEnabled,\n height,\n footAnchor: { x: 0.5, y: 1 },\n footOffset: { x: 0, y: 2 },\n alpha: 0.5,\n blur: 3.5,\n gradientPower: 2,\n hardness: 0.42,\n minLength: Math.max(6, (box?.h ?? 32) * 0.25),\n maxLength: Math.max(90, height * 1.8),\n contactAlpha: 0.3,\n contactScale: 0.3,\n };\n }\n\n const imageDimensions = signal({});\n const loadingImageDimensions = new Set();\n\n const toFiniteNumber = (value, fallback = 0) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) ? number : fallback;\n };\n\n const clampRatio = (value) => Math.min(1, Math.max(0, value));\n\n const normalizePair = (value, fallback = [1, 1]) => {\n if (Array.isArray(value)) {\n const x = toFiniteNumber(value[0], fallback[0]);\n const y = toFiniteNumber(value[1] ?? value[0], x);\n return [x, y];\n }\n if (typeof value === 'number') {\n return [value, value];\n }\n if (value && typeof value === 'object') {\n const x = toFiniteNumber(value.x, fallback[0]);\n const y = toFiniteNumber(value.y ?? value.x, x);\n return [x, y];\n }\n return fallback;\n };\n\n const normalizeAnchor = (value) => {\n if (!Array.isArray(value)) return undefined;\n const [x, y] = normalizePair(value, [0, 0]);\n return [clampRatio(x), clampRatio(y)];\n };\n\n const resolveImageSource = (image) => {\n if (typeof image === 'string') return image;\n if (typeof image?.default === 'string') return image.default;\n return undefined;\n };\n\n const parentTextureOptions = (graphicObject) => {\n const props = [\n 'width',\n 'height',\n 'framesHeight',\n 'framesWidth',\n 'rectWidth',\n 'rectHeight',\n 'offset',\n 'image',\n 'sound',\n 'spriteRealSize',\n 'scale',\n 'anchor',\n 'pivot',\n 'x',\n 'y',\n 'opacity'\n ];\n\n return props.reduce((options, prop) => {\n if (graphicObject?.[prop] !== undefined) {\n options[prop] = graphicObject[prop];\n }\n return options;\n }, {});\n };\n\n const resolveTextureOptions = (graphicObject) => {\n const textures = graphicObject?.textures ?? {};\n const texture =\n textures[realAnimationName()] ??\n textures[Animation.Stand] ??\n Object.values(textures)[0] ??\n {};\n\n return {\n ...parentTextureOptions(graphicObject),\n ...texture\n };\n };\n\n const resolveFirstAnimationFrame = (textureOptions) => {\n const animations = textureOptions?.animations;\n if (!animations) return {};\n\n try {\n const frames = typeof animations === 'function'\n ? animations({ direction: direction() })\n : animations;\n if (!Array.isArray(frames)) return {};\n const firstGroup = frames[0];\n return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};\n }\n catch {\n return {};\n }\n };\n\n const optionValue = (prop, frame, textureOptions, graphicObject) => {\n return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];\n };\n\n const graphicEffectiveScale = (graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const spriteScale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\n return multiplyScale(spriteScale, graphicContainerScale(graphicObject));\n };\n\n const resolveFrameSize = (textureOptions, dimensions) => {\n const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;\n const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;\n const imageSource = resolveImageSource(textureOptions?.image);\n const loadedSize = imageSource ? dimensions[imageSource] : undefined;\n const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;\n const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;\n const width = toPositiveNumber(textureOptions?.rectWidth) ??\n toPositiveNumber(textureOptions?.spriteWidth) ??\n (fullWidth ? fullWidth / framesWidth : undefined);\n const height = toPositiveNumber(textureOptions?.rectHeight) ??\n toPositiveNumber(textureOptions?.spriteHeight) ??\n (fullHeight ? fullHeight / framesHeight : undefined);\n\n return {\n width,\n height\n };\n };\n\n const loadImageDimensions = (image) => {\n const source = resolveImageSource(image);\n if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) {\n return;\n }\n\n loadingImageDimensions.add(source);\n Assets.load(source)\n .then((texture) => {\n const width = toPositiveNumber(texture?.width);\n const height = toPositiveNumber(texture?.height);\n if (!width || !height) return;\n\n imageDimensions.update((dimensions) => ({\n ...dimensions,\n [source]: { width, height }\n }));\n })\n .catch(() => {})\n .finally(() => {\n loadingImageDimensions.delete(source);\n });\n };\n\n effect(() => {\n const sources = new Set();\n\n graphicsSignals().forEach((graphicObject) => {\n const baseImage = resolveImageSource(graphicObject?.image);\n if (baseImage) sources.add(baseImage);\n\n Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {\n const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);\n if (image) sources.add(image);\n });\n });\n\n sources.forEach((source) => loadImageDimensions(source));\n });\n\n const hitboxBounds = computed(() => {\n const box = hitbox();\n const width = box?.w ?? 0;\n const height = box?.h ?? 0;\n\n return {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height,\n centerX: width / 2,\n centerY: height / 2\n };\n });\n\n const graphicBounds = computed(() => {\n const box = hitbox();\n const fallback = hitboxBounds();\n const customEventComponent = resolvedEventComponents()[0];\n if (customEventComponent && !customEventComponent.renderGraphic) {\n return fallback;\n }\n const dimensions = imageDimensions();\n const graphics = graphicsSignals();\n let bounds = null;\n\n graphics.forEach((graphicObject) => {\n const textureOptions = resolveTextureOptions(graphicObject);\n const frame = resolveFirstAnimationFrame(textureOptions);\n const size = resolveFrameSize(textureOptions, dimensions);\n const spriteWidth = size.width ?? box?.w;\n const spriteHeight = size.height ?? box?.h;\n\n if (!spriteWidth || !spriteHeight) {\n return;\n }\n\n const scale = graphicEffectiveScale(graphicObject);\n const explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveScaledHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box,\n scale\n );\n const x = toFiniteNumber(optionValue('x', frame, textureOptions, graphicObject), 0);\n const y = toFiniteNumber(optionValue('y', frame, textureOptions, graphicObject), 0);\n const leftEdge = -anchor[0] * spriteWidth * scale[0];\n const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];\n const topEdge = -anchor[1] * spriteHeight * scale[1];\n const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];\n const graphic = {\n left: x + Math.min(leftEdge, rightEdge),\n top: y + Math.min(topEdge, bottomEdge),\n right: x + Math.max(leftEdge, rightEdge),\n bottom: y + Math.max(topEdge, bottomEdge)\n };\n\n bounds = bounds\n ? {\n left: Math.min(bounds.left, graphic.left),\n top: Math.min(bounds.top, graphic.top),\n right: Math.max(bounds.right, graphic.right),\n bottom: Math.max(bounds.bottom, graphic.bottom)\n }\n : graphic;\n });\n\n if (!bounds) {\n return fallback;\n }\n\n const width = bounds.right - bounds.left;\n const height = bounds.bottom - bounds.top;\n\n return {\n ...bounds,\n width,\n height,\n centerX: bounds.left + width / 2,\n centerY: bounds.top + height / 2\n };\n });\n\n const interactionBounds = () => ({\n bounds: graphicBounds(),\n hitbox: hitboxBounds(),\n graphic: graphicBounds()\n });\n\n const interactionCursor = computed(() =>\n client.interactions.cursorFor(sprite, interactionBounds())\n );\n\n const handleInteraction = (type) => (event) => {\n client.updatePointerFromInteractionEvent(event);\n client.interactions.handle(sprite, type, {\n event,\n bounds: interactionBounds()\n });\n };\n\n const interactionPointerOver = handleInteraction('pointerover');\n const interactionPointerOut = handleInteraction('pointerout');\n const interactionPointerDown = handleInteraction('pointerdown');\n const interactionPointerUp = handleInteraction('pointerup');\n const interactionPointerMove = handleInteraction('pointermove');\n const interactionClick = handleInteraction('click');\n\n // Combine animation change detection with movement state from smoothX/smoothY\n const movementAnimations = ['walk', 'stand'];\n const epsilon = 0; // movement threshold to consider the easing still running\n\n const stateX$ = smoothX.animatedState.observable;\n const stateY$ = smoothY.animatedState.observable;\n const animationName$ = animationName.observable;\n\n const moving$ = combineLatest([stateX$, stateY$]).pipe(\n map(([sx, sy]) => {\n const xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;\n const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;\n return !xFinished || !yFinished; // moving if X or Y is not finished\n }),\n startWith(false)\n );\n\n const animationChange$ = animationName$.pipe(\n startWith(animationName()),\n pairwise(),\n filter(([prev, curr]) => prev !== curr)\n );\n\n let beforeRemovePromise = null;\n let beforeRemoveTransitionValue = null;\n const resolveRemoveContext = () => {\n if (!sprite._removeTransition) return null;\n const value = sprite._removeTransition();\n if (!value || typeof value !== 'string') return null;\n try {\n const context = JSON.parse(value);\n if (!context || typeof context !== 'object' || !context.active) return null;\n context.__transitionValue = value;\n return context;\n }\n catch {\n return null;\n }\n };\n\n const withTimeout = (promise, timeoutMs = 0) => {\n if (!timeoutMs || timeoutMs <= 0) return promise;\n return Promise.race([\n promise,\n new Promise((resolve) => setTimeout(resolve, timeoutMs)),\n ]);\n };\n\n const runBeforeRemove = () => {\n const context = resolveRemoveContext();\n if (!context) return Promise.resolve();\n if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) {\n return beforeRemovePromise;\n }\n beforeRemoveTransitionValue = context.__transitionValue;\n beforeRemovePromise = withTimeout(\n lastValueFrom(hooks.callHooks(\"client-sprite-onBeforeRemove\", sprite, context)),\n context.timeoutMs\n );\n return beforeRemovePromise;\n };\n\n const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {\n if (resolveRemoveContext()) {\n runBeforeRemove();\n }\n });\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n const isMovementAnimation = movementAnimations.includes(curr);\n const isTemporaryAnimationPlaying =\n sprite.animationIsPlaying && sprite.animationIsPlaying();\n\n if (sprite.animationFixed && isMovementAnimation) {\n realAnimationName.set(curr);\n return;\n }\n\n if (curr == 'stand' && !isMoving) {\n if (!resumeHeldDirectionWalkAnimation()) {\n realAnimationName.set(curr);\n }\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!isMovementAnimation) {\n realAnimationName.set(curr);\n }\n if (!isMoving && isTemporaryAnimationPlaying) {\n if (isMovementAnimation) {\n if (typeof sprite.resetAnimationState === 'function') {\n sprite.resetAnimationState();\n }\n }\n }\n });\n\n const resumeWalkSubscriptions = [\n sprite._canMove,\n sprite._animationFixed,\n sprite.animationIsPlaying,\n ]\n .filter(signal => signal?.observable)\n .map(signal => signal.observable.subscribe(() => {\n resumeHeldDirectionWalkAnimation();\n }));\n\n /**\n * Cleanup subscriptions and call hooks before sprite destruction.\n *\n * # Design\n * - Prevent memory leaks by unsubscribing from all local subscriptions created in this component.\n * - Execute destruction hooks to notify modules and scene map of sprite removal.\n *\n * @example\n * await onBeforeDestroy();\n */\n const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {\n if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n let finished = false;\n let timeout;\n let subscription;\n const finish = () => {\n if (finished) return;\n finished = true;\n clearTimeout(timeout);\n subscription?.unsubscribe();\n resolve();\n };\n timeout = setTimeout(finish, maxDuration);\n subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {\n if (!isPlaying) finish();\n });\n if (finished) subscription.unsubscribe();\n });\n };\n\n const onBeforeDestroy = async () => {\n await runBeforeRemove();\n await waitForTemporaryAnimationEnd();\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handleNativeActionWhileMoving);\n document.removeEventListener('keyup', handleNativeActionWhileMoving);\n }\n removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\n resumeWalkSubscriptions.forEach(subscription => subscription.unsubscribe());\n activeControlDirectionReleaseTimers.forEach(timer => clearTimeout(timer));\n activeControlDirectionReleaseTimers.clear();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", sprite)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, sprite))\n }\n\n mount((element) => {\n let appliedCameraFollowRevision = null;\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', handleNativeActionWhileMoving);\n document.addEventListener('keyup', handleNativeActionWhileMoving);\n }\n hooks.callHooks(\"client-sprite-onAdd\", sprite).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, sprite).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\n }\n })\n\n effect(() => {\n const followRevision = client.cameraFollowRevision();\n if (!shouldFollowCamera()) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const smoothMove = client.cameraFollowSmoothMove;\n const viewport = element.props.context?.viewport;\n const target = element.componentInstance;\n if (!viewport || !target) {\n appliedCameraFollowRevision = null;\n return;\n }\n\n const appliedCameraFollow = applyCameraFollow({\n viewport,\n target,\n smoothMove,\n followRevision,\n isCurrentRevision: (revision) => client.cameraFollowRevision() === revision,\n shouldFollowCamera\n });\n appliedCameraFollowRevision = appliedCameraFollow ? followRevision : null;\n })\n\n return () => {\n if (ownsCameraFollowRevision(appliedCameraFollowRevision, client.cameraFollowRevision())) {\n clearCameraFollowPlugins(element.props.context?.viewport);\n }\n }\n })\n\n /**\n * Handle attached GUI finish event\n * \n * @param gui - The GUI instance\n * @param data - Data passed from the GUI component\n */\n const normalizeOpenId = (value) => {\n const resolved = typeof value === \"function\" ? value() : value;\n return typeof resolved === \"string\" && resolved.length > 0 ? resolved : undefined;\n };\n\n const onAttachedGuiFinish = (gui, data, guiOpenId) => {\n const completedOpenId = normalizeOpenId(guiOpenId);\n const currentOpenId = normalizeOpenId(gui.openId);\n if (completedOpenId && currentOpenId && completedOpenId !== currentOpenId) return;\n guiService.guiClose(gui.name, data, completedOpenId ?? currentOpenId);\n };\n\n /**\n * Handle attached GUI interaction event\n * \n * @param gui - The GUI instance\n * @param name - Interaction name\n * @param data - Interaction data\n */\n const onAttachedGuiInteraction = (gui, name, data) => {\n guiService.guiInteraction(gui.name, name, data);\n };\n\n tick(() => {\n hooks.callHooks(\"client-sprite-onUpdate\").subscribe()\n })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;AAsBG,SAAS,UAAM,SAAA;CACN,SAAA,OAAA;CACJ,MAAE,cAAc,eAAkB,OAAA;CAClB,eAAA,OAAsB;CACtC,MAAC,EAAM,QAAA,OAAA,YAAA;CACf,MAAM,SAAS,OAAO;CACtB,MAAM,SAAI,OAAS,eAAA;CACnB,MAAM,QAAQ,OAAA,YAAA;CACd,MAAM,aAAY,OAAA,MAAc;CACtB,OAAc;CACxB,MAAM,mBAAW,OAAW;CAC5B,MAAM,oBAAG,OAAA;CACT,MAAM,YAAW,UAAA,OAAA,UAAA,aAAA,MAAA,IAAA;CACjB,MAAI,wBAAA;EACA,MAAM,WAAA,OAAkB,eAAA;EACxB,MAAG,gBAAU,WAAc,OAAA,UAAe,UAAa,IAAA,YAAA,KAAA;EACvD,OAAK,SAAA,EAAA,MAAe,YAChB,SAAS,QAAA,EAAA,MAAA,YACb,WAAA,iBACA,WAAS,OAAA,UAAA,mBAAA;CACb;CACA,MAAG,OAAA,SAAiB,eAAgB;CACpC,MAAG,iBAAiB,eAAgB;EACjC,MAAK,WAAa,OAAC,UAAA,WAA2B;EAC7C,OAAC,4BAAkC,QAAC;CACxC,CAAC;CACD,MAAM,sBAAS,SAAA;EACb,IAAA;EACC,IAAA;EACC,IAAA;EAEA,IAAA,OAAA,SAAc,cAAY,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;GAC1B,eAAe;GAChB,aAAA,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88
  if (onFinish) onFinish(value, normalizeOpenId(guiOpenId));
89
89
  }
90
+ const stopEvent = (event) => {
91
+ event?.stopPropagation?.();
92
+ };
93
+ const closeDialog = () => {
94
+ _onFinish();
95
+ };
96
+ const closeDialogFromPointer = (event) => {
97
+ stopEvent(event);
98
+ closeDialog();
99
+ };
90
100
  const onSelect = (index) => {
91
101
  _onFinish(index);
92
102
  };
@@ -155,6 +165,22 @@ function component($$props) {
155
165
  height: "100%",
156
166
  controls: dialogControls
157
167
  }, h(DOMElement, {
168
+ element: "div",
169
+ attrs: {
170
+ class: "rpg-ui-dialog-layer",
171
+ click: closeDialogFromPointer
172
+ }
173
+ }, [h(DOMElement, {
174
+ element: "button",
175
+ attrs: {
176
+ class: "rpg-ui-close-button",
177
+ type: "button",
178
+ title: "Close",
179
+ "aria-label": "Close dialog",
180
+ click: closeDialogFromPointer
181
+ },
182
+ textContent: "x"
183
+ }), h(DOMElement, {
158
184
  element: "div",
159
185
  attrs: {
160
186
  class: "rpg-ui-dialog-container",
@@ -164,7 +190,10 @@ function component($$props) {
164
190
  }
165
191
  }, h(DOMElement, {
166
192
  element: "div",
167
- attrs: { class: "rpg-ui-dialog rpg-anim-fade-in" }
193
+ attrs: {
194
+ class: "rpg-ui-dialog rpg-anim-fade-in",
195
+ click: stopEvent
196
+ }
168
197
  }, [h(DOMElement, {
169
198
  element: "div",
170
199
  attrs: { class: "rpg-ui-dialog-body" }
@@ -206,7 +235,7 @@ function component($$props) {
206
235
  })))]), cond(showIndicator, () => h(DOMElement, {
207
236
  element: "div",
208
237
  attrs: { class: "rpg-ui-dialog-indicator" }
209
- }))])));
238
+ }))]))]));
210
239
  }
211
240
  var __ce_component = component;
212
241
  //#endregion