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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/Game/ProjectileManager.d.ts +89 -0
  3. package/dist/Game/ProjectileManager.js +179 -0
  4. package/dist/Game/ProjectileManager.js.map +1 -0
  5. package/dist/Game/ProjectileManager.spec.d.ts +1 -0
  6. package/dist/RpgClient.d.ts +53 -13
  7. package/dist/RpgClientEngine.d.ts +25 -4
  8. package/dist/RpgClientEngine.js +197 -48
  9. package/dist/RpgClientEngine.js.map +1 -1
  10. package/dist/components/animations/hit.ce.js.map +1 -1
  11. package/dist/components/character.ce.js +32 -30
  12. package/dist/components/character.ce.js.map +1 -1
  13. package/dist/components/dynamics/bar.ce.js +4 -3
  14. package/dist/components/dynamics/bar.ce.js.map +1 -1
  15. package/dist/components/dynamics/image.ce.js +2 -1
  16. package/dist/components/dynamics/image.ce.js.map +1 -1
  17. package/dist/components/dynamics/shape.ce.js +3 -2
  18. package/dist/components/dynamics/shape.ce.js.map +1 -1
  19. package/dist/components/dynamics/text.ce.js +9 -8
  20. package/dist/components/dynamics/text.ce.js.map +1 -1
  21. package/dist/components/gui/dialogbox/index.ce.js +3 -2
  22. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  23. package/dist/components/gui/gameover.ce.js +3 -2
  24. package/dist/components/gui/gameover.ce.js.map +1 -1
  25. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  26. package/dist/components/gui/menu/equip-menu.ce.js +2 -1
  27. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  28. package/dist/components/gui/menu/exit-menu.ce.js +2 -1
  29. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  30. package/dist/components/gui/menu/items-menu.ce.js +3 -2
  31. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  32. package/dist/components/gui/menu/main-menu.ce.js +3 -2
  33. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  34. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  35. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  36. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  37. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  38. package/dist/components/gui/save-load.ce.js +2 -1
  39. package/dist/components/gui/save-load.ce.js.map +1 -1
  40. package/dist/components/gui/shop/shop.ce.js +3 -2
  41. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  42. package/dist/components/gui/title-screen.ce.js +3 -2
  43. package/dist/components/gui/title-screen.ce.js.map +1 -1
  44. package/dist/components/index.d.ts +2 -1
  45. package/dist/components/index.js +1 -0
  46. package/dist/components/player-components.ce.js +11 -10
  47. package/dist/components/player-components.ce.js.map +1 -1
  48. package/dist/components/prebuilt/hp-bar.ce.js +4 -3
  49. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  50. package/dist/components/prebuilt/light-halo.ce.js +2 -1
  51. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  52. package/dist/components/scenes/canvas.ce.js +12 -4
  53. package/dist/components/scenes/canvas.ce.js.map +1 -1
  54. package/dist/components/scenes/draw-map.ce.js +6 -3
  55. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  56. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  57. package/dist/index.d.ts +3 -0
  58. package/dist/index.js +9 -5
  59. package/dist/module.js +11 -0
  60. package/dist/module.js.map +1 -1
  61. package/dist/services/actionInput.d.ts +12 -0
  62. package/dist/services/actionInput.js +27 -0
  63. package/dist/services/actionInput.js.map +1 -0
  64. package/dist/services/actionInput.spec.d.ts +1 -0
  65. package/dist/services/mmorpg-connection.d.ts +5 -0
  66. package/dist/services/mmorpg-connection.js +50 -0
  67. package/dist/services/mmorpg-connection.js.map +1 -0
  68. package/dist/services/mmorpg-connection.spec.d.ts +1 -0
  69. package/dist/services/mmorpg.d.ts +10 -4
  70. package/dist/services/mmorpg.js +48 -30
  71. package/dist/services/mmorpg.js.map +1 -1
  72. package/dist/services/pointerContext.d.ts +11 -0
  73. package/dist/services/pointerContext.js +48 -0
  74. package/dist/services/pointerContext.js.map +1 -0
  75. package/dist/services/pointerContext.spec.d.ts +1 -0
  76. package/dist/services/standalone-message.d.ts +1 -0
  77. package/dist/services/standalone-message.js +9 -0
  78. package/dist/services/standalone-message.js.map +1 -0
  79. package/dist/services/standalone.js +3 -2
  80. package/dist/services/standalone.js.map +1 -1
  81. package/dist/services/standalone.spec.d.ts +1 -0
  82. package/package.json +7 -7
  83. package/src/Game/ProjectileManager.spec.ts +338 -0
  84. package/src/Game/ProjectileManager.ts +324 -0
  85. package/src/RpgClient.ts +62 -15
  86. package/src/RpgClientEngine.ts +287 -65
  87. package/src/components/character.ce +34 -32
  88. package/src/components/dynamics/bar.ce +4 -3
  89. package/src/components/dynamics/image.ce +2 -1
  90. package/src/components/dynamics/shape.ce +3 -2
  91. package/src/components/dynamics/text.ce +9 -8
  92. package/src/components/gui/dialogbox/index.ce +3 -2
  93. package/src/components/gui/gameover.ce +2 -1
  94. package/src/components/gui/menu/equip-menu.ce +2 -1
  95. package/src/components/gui/menu/exit-menu.ce +2 -1
  96. package/src/components/gui/menu/items-menu.ce +3 -2
  97. package/src/components/gui/menu/main-menu.ce +2 -1
  98. package/src/components/gui/save-load.ce +2 -1
  99. package/src/components/gui/shop/shop.ce +3 -2
  100. package/src/components/gui/title-screen.ce +2 -1
  101. package/src/components/index.ts +2 -1
  102. package/src/components/player-components.ce +11 -10
  103. package/src/components/prebuilt/hp-bar.ce +4 -3
  104. package/src/components/prebuilt/light-halo.ce +2 -2
  105. package/src/components/scenes/canvas.ce +10 -2
  106. package/src/components/scenes/draw-map.ce +17 -3
  107. package/src/index.ts +3 -0
  108. package/src/module.ts +13 -0
  109. package/src/services/actionInput.spec.ts +101 -0
  110. package/src/services/actionInput.ts +53 -0
  111. package/src/services/mmorpg-connection.spec.ts +99 -0
  112. package/src/services/mmorpg-connection.ts +69 -0
  113. package/src/services/mmorpg.ts +60 -34
  114. package/src/services/pointerContext.spec.ts +36 -0
  115. package/src/services/pointerContext.ts +84 -0
  116. package/src/services/standalone-message.ts +7 -0
  117. package/src/services/standalone.spec.ts +34 -0
  118. package/src/services/standalone.ts +3 -2
@@ -1,17 +1,19 @@
1
1
  import { inject } from "../core/inject.js";
2
+ import { getKeyboardControlBind, resolveKeyboardActionInput } from "../services/actionInput.js";
2
3
  import { getCanMoveValue } from "../utils/readPropValue.js";
3
4
  import { RpgGui } from "../Gui/Gui.js";
4
5
  import { RpgClientEngine } from "../RpgClientEngine.js";
5
6
  import __ce_component$1 from "./player-components.ce.js";
6
7
  import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
7
- import { Particle } from "@canvasengine/presets";
8
8
  import { Animation, Direction, ModulesToken } from "@rpgjs/common";
9
9
  import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
10
+ import { Particle } from "@canvasengine/presets";
10
11
  import { Assets } from "pixi.js";
11
12
  //#region src/components/character.ce
12
13
  function component($$props) {
13
14
  useProps($$props);
14
15
  const { object, id } = useDefineProps($$props)();
16
+ const sprite = object();
15
17
  const client = inject(RpgClientEngine);
16
18
  const hooks = inject(ModulesToken);
17
19
  const guiService = inject(RpgGui);
@@ -22,7 +24,7 @@ function component($$props) {
22
24
  const isCurrentPlayer = () => {
23
25
  const playerId = client.playerIdSignal();
24
26
  const currentPlayer = playerId ? client.sceneMap?.players?.()?.[playerId] : void 0;
25
- return readProp(id) === playerId || readProp(object?.id) === playerId || object === currentPlayer || object === client.sceneMap?.getCurrentPlayer?.();
27
+ return readProp(id) === playerId || readProp(sprite?.id) === playerId || sprite === currentPlayer || sprite === client.sceneMap?.getCurrentPlayer?.();
26
28
  };
27
29
  const isMe = computed(isCurrentPlayer);
28
30
  const shadowsEnabled = computed(() => {
@@ -48,8 +50,8 @@ function component($$props) {
48
50
  }
49
51
  return {
50
52
  component: componentRef,
51
- props: typeof propsValue === "function" ? propsValue(object) : propsValue || {},
52
- dependencies: dependenciesFn ? dependenciesFn(object) : []
53
+ props: typeof propsValue === "function" ? propsValue(sprite) : propsValue || {},
54
+ dependencies: dependenciesFn ? dependenciesFn(sprite) : []
53
55
  };
54
56
  };
55
57
  const normalizeComponents = (components) => {
@@ -72,7 +74,7 @@ function component($$props) {
72
74
  const shouldDisplayAttachedGui = computed(() => {
73
75
  return guiService.shouldDisplayAttachedGui(id());
74
76
  });
75
- const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = object;
77
+ const { x, y, tint, direction, animationName, animationCurrentIndex, emitParticleTrigger, particleName, graphics, hitbox, isConnected, graphicsSignals, flashTrigger } = sprite;
76
78
  const flashType = signal("alpha");
77
79
  const flashDuration = signal(300);
78
80
  const flashCycles = signal(1);
@@ -96,10 +98,10 @@ function component($$props) {
96
98
  tint: flashTint()
97
99
  }));
98
100
  const particleSettings = client.particleSettings;
99
- const canControls = () => isMe() && getCanMoveValue(object);
101
+ const canControls = () => isMe() && getCanMoveValue(sprite);
100
102
  const keyboardControls = client.globalConfig.keyboardControls;
101
103
  const visible = computed(() => {
102
- if (object.isEvent()) return true;
104
+ if (sprite.isEvent()) return true;
103
105
  return isConnected();
104
106
  });
105
107
  const controls = {
@@ -132,9 +134,9 @@ function component($$props) {
132
134
  }
133
135
  },
134
136
  action: {
135
- bind: keyboardControls.action,
137
+ bind: getKeyboardControlBind(keyboardControls.action),
136
138
  keyDown() {
137
- if (canControls()) client.processAction({ action: "action" });
139
+ if (canControls()) client.processAction(resolveKeyboardActionInput(keyboardControls.action, client, sprite));
138
140
  }
139
141
  },
140
142
  escape: {
@@ -148,7 +150,7 @@ function component($$props) {
148
150
  const smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
149
151
  const smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
150
152
  const z = computed(() => {
151
- return object.y() + object.z();
153
+ return sprite.y() + sprite.z();
152
154
  });
153
155
  const realAnimationName = signal(animationName());
154
156
  const xSubscription = x.observable.subscribe((value) => {
@@ -413,8 +415,8 @@ function component($$props) {
413
415
  let beforeRemovePromise = null;
414
416
  let beforeRemoveTransitionValue = null;
415
417
  const resolveRemoveContext = () => {
416
- if (!object._removeTransition) return null;
417
- const value = object._removeTransition();
418
+ if (!sprite._removeTransition) return null;
419
+ const value = sprite._removeTransition();
418
420
  if (!value || typeof value !== "string") return null;
419
421
  try {
420
422
  const context = JSON.parse(value);
@@ -434,24 +436,24 @@ function component($$props) {
434
436
  if (!context) return Promise.resolve();
435
437
  if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
436
438
  beforeRemoveTransitionValue = context.__transitionValue;
437
- beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", object, context)), context.timeoutMs);
439
+ beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", sprite, context)), context.timeoutMs);
438
440
  return beforeRemovePromise;
439
441
  };
440
- const removeTransitionSubscription = object._removeTransition?.observable?.subscribe(() => {
442
+ const removeTransitionSubscription = sprite._removeTransition?.observable?.subscribe(() => {
441
443
  if (resolveRemoveContext()) runBeforeRemove();
442
444
  });
443
445
  const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
444
446
  if (curr == "stand" && !isMoving) realAnimationName.set(curr);
445
447
  else if (curr == "walk" && isMoving) realAnimationName.set(curr);
446
448
  else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
447
- if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
449
+ if (!isMoving && sprite.animationIsPlaying && sprite.animationIsPlaying()) {
448
450
  if (movementAnimations.includes(curr)) {
449
- if (typeof object.resetAnimationState === "function") object.resetAnimationState();
451
+ if (typeof sprite.resetAnimationState === "function") sprite.resetAnimationState();
450
452
  }
451
453
  }
452
454
  });
453
455
  const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
454
- if (!object.animationIsPlaying || !object.animationIsPlaying()) return Promise.resolve();
456
+ if (!sprite.animationIsPlaying || !sprite.animationIsPlaying()) return Promise.resolve();
455
457
  return new Promise((resolve) => {
456
458
  let finished = false;
457
459
  let timeout;
@@ -464,7 +466,7 @@ function component($$props) {
464
466
  resolve();
465
467
  };
466
468
  timeout = setTimeout(finish, maxDuration);
467
- subscription = object.animationIsPlaying.observable.subscribe((isPlaying) => {
469
+ subscription = sprite.animationIsPlaying.observable.subscribe((isPlaying) => {
468
470
  if (!isPlaying) finish();
469
471
  });
470
472
  if (finished) subscription.unsubscribe();
@@ -477,12 +479,12 @@ function component($$props) {
477
479
  animationMovementSubscription.unsubscribe();
478
480
  xSubscription.unsubscribe();
479
481
  ySubscription.unsubscribe();
480
- await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object));
481
- await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object));
482
+ await lastValueFrom(hooks.callHooks("client-sprite-onDestroy", sprite));
483
+ await lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, sprite));
482
484
  };
483
485
  mount((element) => {
484
- hooks.callHooks("client-sprite-onAdd", object).subscribe();
485
- hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
486
+ hooks.callHooks("client-sprite-onAdd", sprite).subscribe();
487
+ hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, sprite).subscribe();
486
488
  effect(() => {
487
489
  if (isCurrentPlayer()) client.setKeyboardControls(element.directives.controls);
488
490
  });
@@ -506,16 +508,16 @@ function component($$props) {
506
508
  visible
507
509
  }, [
508
510
  loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
509
- object,
511
+ object: sprite,
510
512
  ...compConfig.props
511
513
  }))),
512
514
  h(__ce_component$1, {
513
- object,
515
+ object: sprite,
514
516
  position: "bottom",
515
517
  graphicBounds
516
518
  }),
517
519
  h(__ce_component$1, {
518
- object,
520
+ object: sprite,
519
521
  position: "left",
520
522
  graphicBounds
521
523
  }),
@@ -534,28 +536,28 @@ function component($$props) {
534
536
  flash: flashConfig
535
537
  })))),
536
538
  h(__ce_component$1, {
537
- object,
539
+ object: sprite,
538
540
  position: "center",
539
541
  graphicBounds
540
542
  }),
541
543
  h(__ce_component$1, {
542
- object,
544
+ object: sprite,
543
545
  position: "right",
544
546
  graphicBounds
545
547
  }),
546
548
  h(__ce_component$1, {
547
- object,
549
+ object: sprite,
548
550
  position: "top",
549
551
  graphicBounds
550
552
  }),
551
553
  loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
552
- object,
554
+ object: sprite,
553
555
  ...compConfig.props
554
556
  }))),
555
557
  loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
556
558
  ...attachedGui.data(),
557
559
  dependencies: attachedGui.dependencies,
558
- object,
560
+ object: sprite,
559
561
  onFinish: (data) => {
560
562
  onAttachedGuiFinish(attachedGui, data);
561
563
  },
@@ -1 +1 @@
1
- {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\n @for (compConfig of normalizedComponentsBehind) {\n <Container>\n <compConfig.component object ...compConfig.props />\n </Container>\n } \n <PlayerComponents object position=\"bottom\" graphicBounds />\n <PlayerComponents object position=\"left\" graphicBounds />\n <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Container scale={graphicScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\n </Container>\n }\n </Container>\n <PlayerComponents object position=\"center\" graphicBounds />\n <PlayerComponents object position=\"right\" graphicBounds />\n <PlayerComponents object position=\"top\" graphicBounds />\n @for (compConfig of normalizedComponentsInFront) {\n <Container dependencies={compConfig.dependencies}>\n <compConfig.component object ...compConfig.props />\n </Container>\n }\n @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={object} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\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 } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n\n const { object, id } = defineProps();\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(object?.id) === playerId\n || object === currentPlayer\n || object === client.sceneMap?.getCurrentPlayer?.();\n };\n const isMe = computed(isCurrentPlayer);\n const shadowsEnabled = computed(() => {\n const lighting = client.sceneMap?.lighting?.();\n return Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);\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(object) : propsValue || {},\n dependencies: dependenciesFn ? dependenciesFn(object) : []\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 /**\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 } = object;\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(object)\n const keyboardControls = client.globalConfig.keyboardControls;\n\n const visible = computed(() => {\n if (object.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 if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\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 return object.y() + object.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 shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const scale = graphicScale(graphicObject);\n const scaleY = Array.isArray(scale) && typeof scale[1] === 'number' ? Math.abs(scale[1]) : 1;\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;\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 toPositiveNumber = (value) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) && number > 0 ? number : undefined;\n };\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 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 resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {\n if (!spriteWidth || !spriteHeight || !box) {\n return [0, 0];\n }\n\n const heightOfSprite = typeof realSize === 'number' ? realSize : realSize?.height;\n const resolvedHeight = toPositiveNumber(heightOfSprite) ?? spriteHeight;\n const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);\n const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);\n const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);\n const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);\n const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);\n const footY = clampRatio((spriteHeight - gap) / spriteHeight);\n\n switch (box.anchorMode ?? 'top-left') {\n case 'center':\n return [hitboxCenterX, hitboxCenterY];\n case 'foot':\n return [hitboxCenterX, footY];\n case 'top-left':\n default:\n return [hitboxTopLeftX, hitboxTopLeftY];\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 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 explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box\n );\n const scale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\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 // 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 (!object._removeTransition) return null;\n const value = object._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\", object, context)),\n context.timeoutMs\n );\n return beforeRemovePromise;\n };\n\n const removeTransitionSubscription = object._removeTransition?.observable?.subscribe(() => {\n if (resolveRemoveContext()) {\n runBeforeRemove();\n }\n });\n\n const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {\n if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof object.resetAnimationState === 'function') {\n object.resetAnimationState();\n }\n }\n }\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 (!object.animationIsPlaying || !object.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 = object.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 removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\n xSubscription.unsubscribe();\n ySubscription.unsubscribe();\n await lastValueFrom(hooks.callHooks(\"client-sprite-onDestroy\", object)) \n await lastValueFrom(hooks.callHooks(\"client-sceneMap-onRemoveSprite\", client.sceneMap, object))\n }\n\n mount((element) => {\n hooks.callHooks(\"client-sprite-onAdd\", object).subscribe()\n hooks.callHooks(\"client-sceneMap-onAddSprite\", client.sceneMap, object).subscribe()\n effect(() => {\n if (isCurrentPlayer()) {\n client.setKeyboardControls(element.directives.controls)\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 onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\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"],"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UAAA,CAAA;GAAA,OAAA;EAAA,CAAA,CAAA,CAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,EAAA,kBAAA;GAAA;GAAA,UAAA;GAAA;EAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,aAAA,GAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;EAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA;GAAA,WAAA,SAAA;;GAEzB;GAAA,gBAAkB,MAAS,SAAA;IACzB,yBAAkB,aAAmB,MAAA,IAAe;GAClD;EAAE,CAAA,CAAA,CAAA,CAAA;CAAA,CAAA;AAEJ;AAEA,IAAM,iBAEN"}
1
+ {"version":3,"file":"character.ce.js","names":[],"sources":["../../src/components/character.ce"],"sourcesContent":["<Container x={smoothX} y={smoothY} zIndex={z} viewportFollow={shouldFollowCamera} controls onBeforeDestroy visible>\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 graphicsSignals) {\n <Container scale={graphicScale(graphicObj)}>\n <Sprite \n sheet={sheet(graphicObj)} \n direction \n tint \n hitbox\n shadowCaster={shadowCaster(graphicObj)}\n flash={flashConfig}\n />\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 @for (attachedGui of attachedGuis) {\n @if (shouldDisplayAttachedGui) {\n <Container>\n <attachedGui.component ...attachedGui.data() dependencies={attachedGui.dependencies} object={sprite} onFinish={(data) => {\n onAttachedGuiFinish(attachedGui, data)\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 } from \"@rpgjs/common\";\n import { RpgClientEngine } from \"../RpgClientEngine\";\n import { inject } from \"../core/inject\"; \n import { Direction, Animation } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\n import { getCanMoveValue } from \"../utils/readPropValue\";\n import { getKeyboardControlBind, resolveKeyboardActionInput } 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 Boolean(lighting?.shadows?.enabled || (lighting?.spots?.length ?? 0) > 0);\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 /**\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 /**\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\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 if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: getKeyboardControlBind(keyboardControls.action),\n keyDown() {\n if (canControls()) {\n client.processAction(resolveKeyboardActionInput(keyboardControls.action, client, sprite))\n }\n },\n },\n escape: {\n bind: keyboardControls.escape,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'escape' })\n }\n },\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 return sprite.y() + 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 shadowCaster = (graphicObject) => {\n const box = hitbox();\n const bounds = graphicBounds();\n const scale = graphicScale(graphicObject);\n const scaleY = Array.isArray(scale) && typeof scale[1] === 'number' ? Math.abs(scale[1]) : 1;\n const height = Math.max(bounds?.height ?? box?.h ?? 32, box?.h ?? 32) * scaleY;\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 toPositiveNumber = (value) => {\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Number.isFinite(number) && number > 0 ? number : undefined;\n };\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 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 resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {\n if (!spriteWidth || !spriteHeight || !box) {\n return [0, 0];\n }\n\n const heightOfSprite = typeof realSize === 'number' ? realSize : realSize?.height;\n const resolvedHeight = toPositiveNumber(heightOfSprite) ?? spriteHeight;\n const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);\n const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);\n const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);\n const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);\n const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);\n const footY = clampRatio((spriteHeight - gap) / spriteHeight);\n\n switch (box.anchorMode ?? 'top-left') {\n case 'center':\n return [hitboxCenterX, hitboxCenterY];\n case 'foot':\n return [hitboxCenterX, footY];\n case 'top-left':\n default:\n return [hitboxTopLeftX, hitboxTopLeftY];\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 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 explicitAnchor = normalizeAnchor(optionValue('anchor', frame, textureOptions, graphicObject));\n const anchor = explicitAnchor ?? resolveHitboxAnchor(\n spriteWidth,\n spriteHeight,\n optionValue('spriteRealSize', frame, textureOptions, graphicObject),\n box\n );\n const scale = normalizePair(optionValue('scale', frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));\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 // 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 if (curr == 'stand' && !isMoving) {\n realAnimationName.set(curr);\n }\n else if (curr == 'walk' && isMoving) {\n realAnimationName.set(curr);\n }\n else if (!movementAnimations.includes(curr)) {\n realAnimationName.set(curr);\n }\n if (!isMoving && sprite.animationIsPlaying && sprite.animationIsPlaying()) {\n if (movementAnimations.includes(curr)) {\n if (typeof sprite.resetAnimationState === 'function') {\n sprite.resetAnimationState();\n }\n }\n }\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 removeTransitionSubscription?.unsubscribe();\n animationMovementSubscription.unsubscribe();\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 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\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 onAttachedGuiFinish = (gui, data) => {\n guiService.guiClose(gui.name, data);\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.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OAAA,eAAA,aAAA,UAAA,CAAA,EAAA,GAAA,EAAA,QAAA;GAAA,OAAA,eAAA,MAAA,UAAA,CAAA;GAAA;GAAA;GAAA;GAAA,cAAA,eAAA,aAAA,UAAA,CAAA;GAAA,OAAA;EAAA,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,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,KAAA;GAAA,cAAA,YAAA;GAAA,QAAA;GAAA,WAAA,SAAA;;GAEzB;GAAA,gBAAkB,MAAS,SAAA;IACzB,yBAAkB,aAAmB,MAAA,IAAe;GAClD;EAAE,CAAA,CAAA,CAAA,CAAA;CAAA,CAAA;AAEJ;AAEA,IAAM,iBAAe"}
@@ -4,14 +4,15 @@ import { Container, Graphics, Text, computed, cond, h, useDefineProps, useProps
4
4
  function component($$props) {
5
5
  useProps($$props);
6
6
  const { object, current, max, style, text } = useDefineProps($$props)();
7
+ const sprite = object();
7
8
  const read = (prop, fallback) => prop ? prop() : fallback;
8
9
  const toNumber = (value, fallback = 0) => {
9
- const resolved = resolveDynamicValue(value, object);
10
+ const resolved = resolveDynamicValue(value, sprite);
10
11
  const num = typeof resolved === "number" ? resolved : parseFloat(resolved);
11
12
  return Number.isFinite(num) ? num : fallback;
12
13
  };
13
14
  const toColor = (value, fallback) => {
14
- const resolved = resolveDynamicValue(value, object);
15
+ const resolved = resolveDynamicValue(value, sprite);
15
16
  if (typeof resolved === "number") return resolved;
16
17
  if (typeof resolved === "string" && resolved.startsWith("#")) return parseInt(resolved.slice(1), 16);
17
18
  return resolved ?? fallback;
@@ -38,7 +39,7 @@ function component($$props) {
38
39
  const template = labelTemplate();
39
40
  if (template == null || template === "") return "";
40
41
  const value = String(template).replace(/\{\$current\}/g, String(currentValue())).replace(/\{\$max\}/g, String(maxValue())).replace(/\{\$percent\}/g, String(Math.round(percent() * 100)));
41
- return String(resolveDynamicValue(value, object) ?? "");
42
+ return String(resolveDynamicValue(value, sprite) ?? "");
42
43
  });
43
44
  const labelSize = computed(() => toNumber(config().fontSize, 10));
44
45
  const hasLabel = computed(() => labelText().length > 0);
@@ -1 +1 @@
1
- {"version":3,"file":"bar.ce.js","names":[],"sources":["../../../src/components/dynamics/bar.ce"],"sourcesContent":["<Container width={width} height={containerHeight} minWidth={width} minHeight={containerHeight}>\n <Graphics width={width} height={containerHeight} draw={drawBar} />\n @if (hasLabel) {\n <Text text={labelText} x={labelPosition.x} y={labelPosition.y} size={labelSize} color={labelColor} />\n }\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, current, max, style, text } = defineProps();\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst toNumber = (value, fallback = 0) => {\n const resolved = resolveDynamicValue(value, object);\n const num = typeof resolved === 'number' ? resolved : parseFloat(resolved);\n return Number.isFinite(num) ? num : fallback;\n};\n\nconst toColor = (value, fallback) => {\n const resolved = resolveDynamicValue(value, object);\n if (typeof resolved === 'number') return resolved;\n if (typeof resolved === 'string' && resolved.startsWith('#')) {\n return parseInt(resolved.slice(1), 16);\n }\n return resolved ?? fallback;\n};\n\nconst config = computed(() => read(style, {}) ?? {});\nconst width = computed(() => toNumber(config().width, 50));\nconst height = computed(() => toNumber(config().height, 8));\nconst borderRadius = computed(() => toNumber(config().borderRadius, 3));\nconst borderWidth = computed(() => toNumber(config().borderWidth, 1));\nconst backgroundColor = computed(() => toColor(config().bgColor, 0x16213e));\nconst fillColor = computed(() => toColor(config().fillColor, 0x4ade80));\nconst borderColor = computed(() => toColor(config().borderColor, 0x4a5568));\nconst opacity = computed(() => Math.max(0, Math.min(1, toNumber(config().opacity, 1))));\n\nconst currentValue = computed(() => toNumber(read(current, 0), 0));\nconst maxValue = computed(() => Math.max(0, toNumber(read(max, 0), 0)));\nconst percent = computed(() => {\n const max = maxValue();\n if (max <= 0) return 0;\n return Math.max(0, Math.min(1, currentValue() / max));\n});\n\nconst fillWidth = computed(() => Math.max(0, width() * percent()));\nconst labelTemplate = computed(() => read(text, null));\nconst labelText = computed(() => {\n const template = labelTemplate();\n if (template == null || template === '') return '';\n\n const value = String(template)\n .replace(/\\{\\$current\\}/g, String(currentValue()))\n .replace(/\\{\\$max\\}/g, String(maxValue()))\n .replace(/\\{\\$percent\\}/g, String(Math.round(percent() * 100)));\n\n return String(resolveDynamicValue(value, object) ?? '');\n});\nconst labelSize = computed(() => toNumber(config().fontSize, 10));\nconst hasLabel = computed(() => labelText().length > 0);\nconst labelOffset = computed(() => hasLabel() ? labelSize() + 2 : 0);\nconst containerHeight = computed(() => labelOffset() + height());\nconst labelColor = computed(() => toColor(config().textColor, 0xffffff));\nconst labelPosition = computed(() => ({\n x: 0,\n y: 0\n}));\n\nconst drawBar = (g) => {\n g.roundRect(0, labelOffset(), width(), height(), borderRadius());\n g.fill({ color: backgroundColor(), alpha: opacity() });\n\n const currentWidth = fillWidth();\n if (currentWidth > 0) {\n g.roundRect(0, labelOffset(), currentWidth, height(), borderRadius());\n g.fill({ color: fillColor(), alpha: opacity() });\n }\n \n const strokeWidth = borderWidth();\n if (strokeWidth <= 0) return;\n g.roundRect(0, labelOffset(), width(), height(), borderRadius());\n g.stroke({ color: borderColor(), width: strokeWidth, alpha: opacity() });\n};\n</script>\n"],"mappings":";;;AASM,SAAG,UAAA,SAAsB;;+CAEH,eAAe,OAAA,EAAA;CAE3C,MAAM,QAAQ,MAAM,aAAa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AA;EAAA,QAAA;EAAA,UAAA;EAAA,WAAA;CAAA,GAAA,CAAA,EAAA,UAAA;EAAA;EAAA,QAAA;EAAA,MAAA;CAAA,CAAA,GAAA,KAAA,gBAAA,EAAA,MAAA;EAAA,MAAA;EAAA,GAAA,cAAA;EAAA,GAAA,cAAA;EAAA,MAAA;EAAA,OAAA;CAAA,CAAA,CAAA,CAAA,CACkB;AACb;AAEF,IAAQ,iBAEJ"}
1
+ {"version":3,"file":"bar.ce.js","names":[],"sources":["../../../src/components/dynamics/bar.ce"],"sourcesContent":["<Container width={width} height={containerHeight} minWidth={width} minHeight={containerHeight}>\n <Graphics width={width} height={containerHeight} draw={drawBar} />\n @if (hasLabel) {\n <Text text={labelText} x={labelPosition.x} y={labelPosition.y} size={labelSize} color={labelColor} />\n }\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, current, max, style, text } = defineProps();\nconst sprite = object();\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst toNumber = (value, fallback = 0) => {\n const resolved = resolveDynamicValue(value, sprite);\n const num = typeof resolved === 'number' ? resolved : parseFloat(resolved);\n return Number.isFinite(num) ? num : fallback;\n};\n\nconst toColor = (value, fallback) => {\n const resolved = resolveDynamicValue(value, sprite);\n if (typeof resolved === 'number') return resolved;\n if (typeof resolved === 'string' && resolved.startsWith('#')) {\n return parseInt(resolved.slice(1), 16);\n }\n return resolved ?? fallback;\n};\n\nconst config = computed(() => read(style, {}) ?? {});\nconst width = computed(() => toNumber(config().width, 50));\nconst height = computed(() => toNumber(config().height, 8));\nconst borderRadius = computed(() => toNumber(config().borderRadius, 3));\nconst borderWidth = computed(() => toNumber(config().borderWidth, 1));\nconst backgroundColor = computed(() => toColor(config().bgColor, 0x16213e));\nconst fillColor = computed(() => toColor(config().fillColor, 0x4ade80));\nconst borderColor = computed(() => toColor(config().borderColor, 0x4a5568));\nconst opacity = computed(() => Math.max(0, Math.min(1, toNumber(config().opacity, 1))));\n\nconst currentValue = computed(() => toNumber(read(current, 0), 0));\nconst maxValue = computed(() => Math.max(0, toNumber(read(max, 0), 0)));\nconst percent = computed(() => {\n const max = maxValue();\n if (max <= 0) return 0;\n return Math.max(0, Math.min(1, currentValue() / max));\n});\n\nconst fillWidth = computed(() => Math.max(0, width() * percent()));\nconst labelTemplate = computed(() => read(text, null));\nconst labelText = computed(() => {\n const template = labelTemplate();\n if (template == null || template === '') return '';\n\n const value = String(template)\n .replace(/\\{\\$current\\}/g, String(currentValue()))\n .replace(/\\{\\$max\\}/g, String(maxValue()))\n .replace(/\\{\\$percent\\}/g, String(Math.round(percent() * 100)));\n\n return String(resolveDynamicValue(value, sprite) ?? '');\n});\nconst labelSize = computed(() => toNumber(config().fontSize, 10));\nconst hasLabel = computed(() => labelText().length > 0);\nconst labelOffset = computed(() => hasLabel() ? labelSize() + 2 : 0);\nconst containerHeight = computed(() => labelOffset() + height());\nconst labelColor = computed(() => toColor(config().textColor, 0xffffff));\nconst labelPosition = computed(() => ({\n x: 0,\n y: 0\n}));\n\nconst drawBar = (g) => {\n g.roundRect(0, labelOffset(), width(), height(), borderRadius());\n g.fill({ color: backgroundColor(), alpha: opacity() });\n\n const currentWidth = fillWidth();\n if (currentWidth > 0) {\n g.roundRect(0, labelOffset(), currentWidth, height(), borderRadius());\n g.fill({ color: fillColor(), alpha: opacity() });\n }\n \n const strokeWidth = borderWidth();\n if (strokeWidth <= 0) return;\n g.roundRect(0, labelOffset(), width(), height(), borderRadius());\n g.stroke({ color: borderColor(), width: strokeWidth, alpha: opacity() });\n};\n</script>\n"],"mappings":";;;AASM,SAAG,UAAA,SAAsB;;CAGzB,MAAQ,EAAC,QAAQ,SAAA,KAAA,OAAA,SADK,eAAe,OACpB,EAAA;;CAEvB,MAAM,QAAQ,MAAM,aAAa,OAAO,KAAK,IAAI;;EAEjD,MAAM,WAAY,oBAAuB,OAAC,MAAA;EACxC,MAAM,MAAQ,OAAG,aAAA,WAA2B,WA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AAA,CAAA,GAAA,KAAA,gBAAA,EAAA,MAAA;EAAA,MAAA;EAAA,GAAA,cAAA;EAAA,GAAA,cAAA;EAAA,MAAA;EAAA,OAAA;CAAA,CAAA,CAAA,CAAA,CACkB;AACb;AAEF,IAAQ,iBAAQ"}
@@ -6,9 +6,10 @@ import { Sprite, computed, h, useDefineProps, useProps } from "canvasengine";
6
6
  function component($$props) {
7
7
  useProps($$props);
8
8
  const { object, value } = useDefineProps($$props)();
9
+ const sprite = object();
9
10
  const client = inject(RpgClientEngine);
10
11
  return h(Sprite, { sheet: computed(() => {
11
- const id = resolveDynamicValue(value?.(), object);
12
+ const id = resolveDynamicValue(value?.(), sprite);
12
13
  if (!id) return null;
13
14
  return {
14
15
  definition: client.getSpriteSheet(id),
@@ -1 +1 @@
1
- {"version":3,"file":"image.ce.js","names":[],"sources":["../../../src/components/dynamics/image.ce"],"sourcesContent":["<Sprite sheet={sheet} />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { RpgClientEngine } from \"../../RpgClientEngine\";\nimport { inject } from \"../../core/inject\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, value } = defineProps();\nconst client = inject(RpgClientEngine);\n\nconst sheet = computed(() => {\n const id = resolveDynamicValue(value?.(), object);\n if (!id) return null;\n return {\n definition: client.getSpriteSheet(id),\n playing: 'default'\n };\n});\n</script>\n"],"mappings":";;;;;AASM,SAAS,UAAO,SAAA;;CAGd,MAAK,EAAA,QAAA,UADe,eAAC,OACe,EAAA;CAC5C,MAAM,SAAK,OAAW,eAAA;2BACb,eAAA;EACL,MAAA,KAAW,oBAAQ,QAAkB,GAAA,MAAA;EACrC,IAAA,CAAA,IACD,OAAA;EACD,OAAA;GACM,YAAA,OAAA,eAAA,EAAA"}
1
+ {"version":3,"file":"image.ce.js","names":[],"sources":["../../../src/components/dynamics/image.ce"],"sourcesContent":["<Sprite sheet={sheet} />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { RpgClientEngine } from \"../../RpgClientEngine\";\nimport { inject } from \"../../core/inject\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, value } = defineProps();\nconst sprite = object();\nconst client = inject(RpgClientEngine);\n\nconst sheet = computed(() => {\n const id = resolveDynamicValue(value?.(), sprite);\n if (!id) return null;\n return {\n definition: client.getSpriteSheet(id),\n playing: 'default'\n };\n});\n</script>\n"],"mappings":";;;;;AASM,SAAS,UAAQ,SAAA;CACD,SAAA,OAAgB;CAEhC,MAAQ,EAAA,QAAU,UAAA,eAAA,OAAK,EAAA;CAC7B,MAAE,SAAW,OAAA;CACb,MAAM,SAAK,OAAW,eAAA;2BACb,eAAA;EACL,MAAA,KAAW,oBAAQ,QAAkB,GAAA,MAAA;EACrC,IAAA,CAAA,IACD,OAAA;EACD,OAAA;GACM,YAAA,OAAA,eAAA,EAAA"}
@@ -6,14 +6,15 @@ function component($$props) {
6
6
  useProps($$props);
7
7
  const props = useDefineProps($$props)();
8
8
  const { object } = props;
9
+ const sprite = object();
9
10
  const read = (prop, fallback) => prop ? prop() : fallback;
10
11
  const toNumber = (value, fallback = 0) => {
11
- const resolved = resolveDynamicValue(value, object);
12
+ const resolved = resolveDynamicValue(value, sprite);
12
13
  const num = typeof resolved === "number" ? resolved : parseFloat(resolved);
13
14
  return Number.isFinite(num) ? num : fallback;
14
15
  };
15
16
  const toColor = (value, fallback) => {
16
- const resolved = resolveDynamicValue(value, object);
17
+ const resolved = resolveDynamicValue(value, sprite);
17
18
  if (typeof resolved === "number") return resolved;
18
19
  if (typeof resolved === "string" && resolved.startsWith("#")) return parseInt(resolved.slice(1), 16);
19
20
  return resolved ?? fallback;
@@ -1 +1 @@
1
- {"version":3,"file":"shape.ce.js","names":[],"sources":["../../../src/components/dynamics/shape.ce"],"sourcesContent":["<Container width={shapeWidth} height={shapeHeight} minWidth={shapeWidth} minHeight={shapeHeight}>\n <Graphics width={shapeWidth} height={shapeHeight} draw={drawShape} />\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\nimport { getShapeBox, translatePolygonPoints } from \"./shape-utils\";\n\nconst props = defineProps();\nconst { object } = props;\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst toNumber = (value, fallback = 0) => {\n const resolved = resolveDynamicValue(value, object);\n const num = typeof resolved === 'number' ? resolved : parseFloat(resolved);\n return Number.isFinite(num) ? num : fallback;\n};\n\nconst toColor = (value, fallback) => {\n const resolved = resolveDynamicValue(value, object);\n if (typeof resolved === 'number') return resolved;\n if (typeof resolved === 'string' && resolved.startsWith('#')) {\n return parseInt(resolved.slice(1), 16);\n }\n return resolved ?? fallback;\n};\n\nconst config = computed(() => ({\n type: read(props.type, 'rectangle'),\n fill: toColor(read(props.fill, '#ffffff'), 0xffffff),\n radius: toNumber(read(props.radius, 8), 8),\n width: toNumber(read(props.width, 16), 16),\n height: toNumber(read(props.height, 16), 16),\n x1: toNumber(read(props.x1, 0), 0),\n y1: toNumber(read(props.y1, 0), 0),\n x2: toNumber(read(props.x2, 16), 16),\n y2: toNumber(read(props.y2, 0), 0),\n opacity: Math.max(0, Math.min(1, toNumber(read(props.opacity, 1), 1))),\n points: read(props.points, []),\n line: read(props.line, null)\n}));\n\nconst shapeBox = computed(() => getShapeBox(config(), toNumber));\n\nconst shapeWidth = computed(() => shapeBox().width);\nconst shapeHeight = computed(() => shapeBox().height);\n\nconst drawShape = (g) => {\n const cfg = config();\n const box = shapeBox();\n\n if (cfg.type === 'circle') {\n g.circle(cfg.radius, cfg.radius, cfg.radius);\n } else if (cfg.type === 'ellipse') {\n g.ellipse(box.width / 2, box.height / 2, box.width / 2, box.height / 2);\n } else if (cfg.type === 'line') {\n g.moveTo(cfg.x1 + box.offsetX, cfg.y1 + box.offsetY);\n g.lineTo(cfg.x2 + box.offsetX, cfg.y2 + box.offsetY);\n } else if (cfg.type === 'polygon' && Array.isArray(cfg.points)) {\n g.poly(translatePolygonPoints(cfg.points, box, toNumber));\n } else if (cfg.type === 'rounded-rectangle') {\n g.roundRect(0, 0, box.width, box.height, toNumber(read(props.radius, 4), 4));\n } else {\n g.rect(0, 0, box.width, box.height);\n }\n\n if (cfg.type === 'line') {\n const line = cfg.line ?? {};\n g.stroke({\n color: toColor(line.color, cfg.fill),\n width: toNumber(line.width, 1),\n alpha: toNumber(line.alpha, cfg.opacity)\n });\n return;\n }\n\n g.fill({ color: cfg.fill, alpha: cfg.opacity });\n\n if (cfg.line) {\n g.stroke({\n color: toColor(cfg.line.color, cfg.fill),\n width: toNumber(cfg.line.width, 1),\n alpha: toNumber(cfg.line.alpha, cfg.opacity)\n });\n }\n};\n</script>\n"],"mappings":";;;;AASM,SAAQ,UAAW,SAAE;CACR,SAAK,OAAA;CAElB,MAAQ,QAAA,eAAA,OAAkB,EAAC;;CAEjC,MAAM,QAAQ,MAAI,aAAe,OAAO,KAAE,IAAA;CAC1C,MAAE,YAAgB,OAAC,WAAA,MAAoB;EACrC,MAAM,WAAa,oBAAoB,OAAI,MAAS;EACpD,MAAO,MAAO,OAAA,aAAoB,WAAU,WAAA,WAAA,QAAA;EAC7C,OAAA,OAAA,SAAA,GAAA,IAAA,MAAA;;CAED,MAAM,WAAW,OAAO,aAAa;EACnC,MAAM,WAAW,oBAAoB,OAAO,MAAO;EACjD,IAAE,OAAO,aAAc,UACrB,OAAO;EACT,IAAA,OAAO,aAAiB,YAAW,SAAG,WAAA,GAAA,GACxC,OAAA,SAAA,SAAA,MAAA,CAAA,GAAA,EAAA;EAED,OAAA,YAAA;;CAED,MAAM,SAAS,gBAAgB;EAC7B,MAAM,KAAK,MAAM,MAAO,WAAW;EACnC,MAAM,QAAQ,KAAK,MAAM,MAAQ,SAAS,GAAC,QAAS;EACpD,QAAQ,SAAS,KAAK,MAAM,QAAU,CAAC,GAAG,CAAA;EAC1C,OAAO,SAAS,KAAK,MAAM,OAAS,EAAE,GAAG,EAAC;EAC1C,QAAQ,SAAS,KAAK,MAAM,QAAU,EAAE,GAAG,EAAC;EAC1C,IAAE,SAAS,K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QAAa,KAAM,OAAK,IAAK,IAAA;IAC9B,OAAC,SAAc,KAAM,OAAG,CAAA;IACxB,OAAC,SAAc,KAAM,OAAK,IAAA,OAAO;GACvC,CAAA;GACF;EACF;;;;;EAEE,IAAI,IAAG,MAAA,EAAA,OAAA;GAED,OAAM,QAAA,IAAA,KAAA,OAAA,IAAA,IAAA;GACJ,OAAC,SAAA,IAAA,KAAA,OAAA,CAAA;GACD,OAAC,SAAY,IAAK,KAAO,OAAI,IAAK,OAAA;EACxC,CAAA;CAEN;CAEC,OADC,EAAA,WAAA;EAAA,OAAA;EAAA,QAAA;EAAA,UAAA;EAAA,WAAA;CAAA,GAAA,EAAA,UAAA;EAAA,OAAA;EAAA,QAAA;EAAA,MAAA;CAAA,CAAA,CACD;AACC"}
1
+ {"version":3,"file":"shape.ce.js","names":[],"sources":["../../../src/components/dynamics/shape.ce"],"sourcesContent":["<Container width={shapeWidth} height={shapeHeight} minWidth={shapeWidth} minHeight={shapeHeight}>\n <Graphics width={shapeWidth} height={shapeHeight} draw={drawShape} />\n</Container>\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\nimport { getShapeBox, translatePolygonPoints } from \"./shape-utils\";\n\nconst props = defineProps();\nconst { object } = props;\nconst sprite = object();\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst toNumber = (value, fallback = 0) => {\n const resolved = resolveDynamicValue(value, sprite);\n const num = typeof resolved === 'number' ? resolved : parseFloat(resolved);\n return Number.isFinite(num) ? num : fallback;\n};\n\nconst toColor = (value, fallback) => {\n const resolved = resolveDynamicValue(value, sprite);\n if (typeof resolved === 'number') return resolved;\n if (typeof resolved === 'string' && resolved.startsWith('#')) {\n return parseInt(resolved.slice(1), 16);\n }\n return resolved ?? fallback;\n};\n\nconst config = computed(() => ({\n type: read(props.type, 'rectangle'),\n fill: toColor(read(props.fill, '#ffffff'), 0xffffff),\n radius: toNumber(read(props.radius, 8), 8),\n width: toNumber(read(props.width, 16), 16),\n height: toNumber(read(props.height, 16), 16),\n x1: toNumber(read(props.x1, 0), 0),\n y1: toNumber(read(props.y1, 0), 0),\n x2: toNumber(read(props.x2, 16), 16),\n y2: toNumber(read(props.y2, 0), 0),\n opacity: Math.max(0, Math.min(1, toNumber(read(props.opacity, 1), 1))),\n points: read(props.points, []),\n line: read(props.line, null)\n}));\n\nconst shapeBox = computed(() => getShapeBox(config(), toNumber));\n\nconst shapeWidth = computed(() => shapeBox().width);\nconst shapeHeight = computed(() => shapeBox().height);\n\nconst drawShape = (g) => {\n const cfg = config();\n const box = shapeBox();\n\n if (cfg.type === 'circle') {\n g.circle(cfg.radius, cfg.radius, cfg.radius);\n } else if (cfg.type === 'ellipse') {\n g.ellipse(box.width / 2, box.height / 2, box.width / 2, box.height / 2);\n } else if (cfg.type === 'line') {\n g.moveTo(cfg.x1 + box.offsetX, cfg.y1 + box.offsetY);\n g.lineTo(cfg.x2 + box.offsetX, cfg.y2 + box.offsetY);\n } else if (cfg.type === 'polygon' && Array.isArray(cfg.points)) {\n g.poly(translatePolygonPoints(cfg.points, box, toNumber));\n } else if (cfg.type === 'rounded-rectangle') {\n g.roundRect(0, 0, box.width, box.height, toNumber(read(props.radius, 4), 4));\n } else {\n g.rect(0, 0, box.width, box.height);\n }\n\n if (cfg.type === 'line') {\n const line = cfg.line ?? {};\n g.stroke({\n color: toColor(line.color, cfg.fill),\n width: toNumber(line.width, 1),\n alpha: toNumber(line.alpha, cfg.opacity)\n });\n return;\n }\n\n g.fill({ color: cfg.fill, alpha: cfg.opacity });\n\n if (cfg.line) {\n g.stroke({\n color: toColor(cfg.line.color, cfg.fill),\n width: toNumber(cfg.line.width, 1),\n alpha: toNumber(cfg.line.alpha, cfg.opacity)\n });\n }\n};\n</script>\n"],"mappings":";;;;AASM,SAAQ,UAAW,SAAE;CACR,SAAK,OAAA;eACD,eAAA,OAAA,EAAA;CAEvB,MAAM,EAAA,WAAa;;CAEnB,MAAM,QAAQ,MAAI,aAAe,OA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DefineProps, useProps } from "canvasengine";
4
4
  function component($$props) {
5
5
  useProps($$props);
6
6
  const { object, value, style } = useDefineProps($$props)();
7
+ const sprite = object();
7
8
  const read = (prop, fallback) => prop ? prop() : fallback;
8
9
  const parseNumericStyleValue = (value, object) => {
9
- value = resolveDynamicValue(value, object);
10
+ value = resolveDynamicValue(value, sprite);
10
11
  if (value === void 0 || value === null) return void 0;
11
12
  if (typeof value === "number") return value;
12
13
  const num = parseFloat(value);
@@ -15,22 +16,22 @@ function component($$props) {
15
16
  const getTextStyle = (style) => {
16
17
  if (!style) return {};
17
18
  const textStyle = {};
18
- if (style.fontStyle !== void 0) textStyle.fontStyle = resolveDynamicValue(style.fontStyle, object);
19
- if (style.fontWeight !== void 0) textStyle.fontWeight = resolveDynamicValue(style.fontWeight, object);
20
- if (style.stroke !== void 0) textStyle.stroke = resolveDynamicValue(style.stroke, object);
19
+ if (style.fontStyle !== void 0) textStyle.fontStyle = resolveDynamicValue(style.fontStyle, sprite);
20
+ if (style.fontWeight !== void 0) textStyle.fontWeight = resolveDynamicValue(style.fontWeight, sprite);
21
+ if (style.stroke !== void 0) textStyle.stroke = resolveDynamicValue(style.stroke, sprite);
21
22
  if (style.opacity !== void 0) {
22
23
  const opacityValue = parseNumericStyleValue(style.opacity, object);
23
24
  if (opacityValue !== void 0) textStyle.opacity = opacityValue;
24
25
  }
25
26
  if (style.wordWrap !== void 0) textStyle.wordWrap = style.wordWrap;
26
- if (style.align !== void 0) textStyle.align = resolveDynamicValue(style.align, object);
27
+ if (style.align !== void 0) textStyle.align = resolveDynamicValue(style.align, sprite);
27
28
  return textStyle;
28
29
  };
29
30
  return h(Text, {
30
- text: computed(() => String(resolveDynamicValue(read(value, ""), object) ?? "")),
31
+ text: computed(() => String(resolveDynamicValue(read(value, ""), sprite) ?? "")),
31
32
  color: computed(() => {
32
33
  const currentStyle = read(style, {});
33
- return currentStyle.fill !== void 0 ? resolveDynamicValue(currentStyle.fill, object) : void 0;
34
+ return currentStyle.fill !== void 0 ? resolveDynamicValue(currentStyle.fill, sprite) : void 0;
34
35
  }),
35
36
  size: computed(() => {
36
37
  const currentStyle = read(style, {});
@@ -38,7 +39,7 @@ function component($$props) {
38
39
  }),
39
40
  fontFamily: computed(() => {
40
41
  const currentStyle = read(style, {});
41
- return currentStyle.fontFamily !== void 0 ? resolveDynamicValue(currentStyle.fontFamily, object) : void 0;
42
+ return currentStyle.fontFamily !== void 0 ? resolveDynamicValue(currentStyle.fontFamily, sprite) : void 0;
42
43
  }),
43
44
  style: computed(() => getTextStyle(read(style, {})))
44
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"text.ce.js","names":[],"sources":["../../../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={textValue} color={textColor} size={textSize} fontFamily={textFontFamily} style={textStyle} />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, value, style } = defineProps();\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst parseNumericStyleValue = (value, object) => {\n value = resolveDynamicValue(value, object);\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'number') return value;\n\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n};\n\nconst getTextStyle = (style) => {\n if (!style) return {};\n const textStyle = {};\n\n if (style.fontStyle !== undefined) {\n textStyle.fontStyle = resolveDynamicValue(style.fontStyle, object);\n }\n\n if (style.fontWeight !== undefined) {\n textStyle.fontWeight = resolveDynamicValue(style.fontWeight, object);\n }\n\n if (style.stroke !== undefined) {\n textStyle.stroke = resolveDynamicValue(style.stroke, object);\n }\n\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n if (style.align !== undefined) {\n textStyle.align = resolveDynamicValue(style.align, object);\n }\n\n return textStyle;\n};\n\nconst textValue = computed(() => String(resolveDynamicValue(read(value, ''), object) ?? ''));\nconst textColor = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fill !== undefined ? resolveDynamicValue(currentStyle.fill, object) : undefined;\n});\nconst textSize = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fontSize !== undefined ? parseNumericStyleValue(currentStyle.fontSize, object) : undefined;\n});\nconst textFontFamily = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fontFamily !== undefined ? resolveDynamicValue(currentStyle.fontFamily, object) : undefined;\n});\nconst textStyle = computed(() => getTextStyle(read(style, {})));\n</script>\n"],"mappings":";;;;CAQoB,SAAY,OAAO;CAEjC,MAAA,EAAA,QAAA,OAAyB,UAAA,eAAA,OAAmB,EAAA;CAClD,MAAI,QAAQ,MAAA,aAAoB,OAAO,KAAM,IAAC;CAC9C,MAAM,0BAAyB,OAAQ,WAAQ;EAC3C,QAAI,oBAAwB,OAAG,MAAO;0CAEtC,OAAW,KAAA;EACX,IAAA,OAAO,UAAa,UACvB,OAAA;;EAED,OAAM,MAAA,GAAc,IAAE,KAAA,IAAU;CAChC;CACA,MAAI,gBAAkB,UAAE;cAEhB,OAAM,CAAA;EACV,MAAI,YAAU,CAAA;EACd,IAAA,MAAA,cAAA,KAAA,GAAA,UAAA,YAAA,oBAAA,MAAA,WAAA,MAAA;EAGA,IAAI,MAAA,eAAqB,KAAA,GACzB,UAAA,aAAA,oBAAA,MAAA,YAAA,MAAA;EAEA,IAAI,MAAM,WAAW,KAAA,GACjB,UAAU,SAAS,oBAAoB,MAAM,QAAQ,MAAM;;GAG3D,MAAM,eAAY,uBAAW,MAAA,SAAA,MAAA;GAC7B,IAAA,iBAAqB,KAAA,GACjB,UAAA,UAAiB;EAEzB;EACA,IAAA,MAAA,aAAA,KAAA,GAAA,UAAA,WAAA,MAAA;EAGA,IAAI,MAAA,UAAU,KAAA,GACd,UAAA,QAAA,oBAAA,MAAA,OAAA,MAAA;EAEA,OAAI;CACR;CAgBI,OADgB,EAAE,MAAC;EAAA,MAdnB,eAAA,OAAA,oBAAA,KAAA,OAAA,EAAA,GAAA,MAAA,KAAA,EAAA,CAckC;EAAA,OAAA,eAAA;GAZlC,MAAM,eAAU,KAAA,OAAA,CAAA,CAAA;GACnB,OAAA,aAAA,SAAA,KAAA,IAAA,oBAAA,aAAA,MAAA,MAAA,IAAA,KAAA;GAWqC;EAAA,MATrB,eAAe;GAChC,MAAM,eAAY,KAAY,OAAG,CAAA,CAAA;GAC7B,OAAM,aAAc,aAAa,KAAA,IAAG,uBAAA,aAAA,UAAA,MAAA,IAAA,KAAA;EACxC,CAMsC;EAAA,YALpC,eAAA;GACF,MAAM,eAAmB,KAAK,OAAE,CAAA,CAAA;GAC5B,OAAM,aAAc,eAAe,KAAA,IAAC,oBAAA,aAAA,YAAA,MAAA,IAAA,KAAA;EACxC,CAEsC;EAAA,OADpC,eAAA,aAAA,KAAA,OAAA,CAAA,CAAA,CAAA,CACoC;CAAA,CAC5B;AACN;AAEE,IAAA,iBAAA"}
1
+ {"version":3,"file":"text.ce.js","names":[],"sources":["../../../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={textValue} color={textColor} size={textSize} fontFamily={textFontFamily} style={textStyle} />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { resolveDynamicValue } from \"./parse-value\";\n\nconst { object, value, style } = defineProps();\nconst sprite = object();\n\nconst read = (prop, fallback) => prop ? prop() : fallback;\n\nconst parseNumericStyleValue = (value, object) => {\n value = resolveDynamicValue(value, sprite);\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'number') return value;\n\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n};\n\nconst getTextStyle = (style) => {\n if (!style) return {};\n const textStyle = {};\n\n if (style.fontStyle !== undefined) {\n textStyle.fontStyle = resolveDynamicValue(style.fontStyle, sprite);\n }\n\n if (style.fontWeight !== undefined) {\n textStyle.fontWeight = resolveDynamicValue(style.fontWeight, sprite);\n }\n\n if (style.stroke !== undefined) {\n textStyle.stroke = resolveDynamicValue(style.stroke, sprite);\n }\n\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n if (style.align !== undefined) {\n textStyle.align = resolveDynamicValue(style.align, sprite);\n }\n\n return textStyle;\n};\n\nconst textValue = computed(() => String(resolveDynamicValue(read(value, ''), sprite) ?? ''));\nconst textColor = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fill !== undefined ? resolveDynamicValue(currentStyle.fill, sprite) : undefined;\n});\nconst textSize = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fontSize !== undefined ? parseNumericStyleValue(currentStyle.fontSize, object) : undefined;\n});\nconst textFontFamily = computed(() => {\n const currentStyle = read(style, {});\n return currentStyle.fontFamily !== undefined ? resolveDynamicValue(currentStyle.fontFamily, sprite) : undefined;\n});\nconst textStyle = computed(() => getTextStyle(read(style, {})));\n</script>\n"],"mappings":";;;AAOM,SAAS,UAAQ,SAAA;;kCAEK,eAAY,OAAA,EAAA;CAExC,MAAM,SAAA,OAAA;CACN,MAAI,QAAQ,MAAA,aAAoB,OAAO,KAAM,IAAC;CAC9C,MAAM,0BAAyB,OAAQ,WAAQ;EAC3C,QAAI,oBAAwB,OAAG,MAAO;0CAEtC,OAAW,KAAA;EACX,IAAA,OAAO,UAAa,UACvB,OAAA;;EAED,OAAM,MAAA,GAAc,IAAE,KAAA,IAAU;CAChC;CACA,MAAI,gBAAkB,UAAE;cAEhB,OAAM,CAAA;EACV,MAAI,YAAU,CAAA;EACd,IAAA,MAAA,cAAA,KAAA,GAAA,UAAA,YAAA,oBAAA,MAAA,WAAA,MAAA;EAGA,IAAI,MAAA,eAAqB,KAAA,GACzB,UAAA,aAAA,oBAAA,MAAA,YAAA,MAAA;EAEA,IAAI,MAAM,WAAW,KAAA,GACjB,UAAU,SAAS,oBAAoB,MAAM,QAAQ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