@rpgjs/client 5.0.0-beta.6 → 5.0.0-beta.8

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 (147) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/Game/AnimationManager.d.ts +2 -2
  3. package/dist/Game/AnimationManager.js +18 -9
  4. package/dist/Game/AnimationManager.js.map +1 -1
  5. package/dist/Game/AnimationManager.spec.d.ts +1 -0
  6. package/dist/Game/Map.d.ts +7 -9
  7. package/dist/Game/Map.js +5 -4
  8. package/dist/Game/Map.js.map +1 -1
  9. package/dist/Game/Object.d.ts +44 -20
  10. package/dist/Game/Object.js +28 -14
  11. package/dist/Game/Object.js.map +1 -1
  12. package/dist/Gui/Gui.d.ts +19 -6
  13. package/dist/Gui/Gui.js +64 -34
  14. package/dist/Gui/Gui.js.map +1 -1
  15. package/dist/Gui/Gui.spec.d.ts +1 -0
  16. package/dist/Gui/NotificationManager.d.ts +1 -1
  17. package/dist/Gui/NotificationManager.js.map +1 -1
  18. package/dist/Resource.js +1 -1
  19. package/dist/Resource.js.map +1 -1
  20. package/dist/RpgClient.d.ts +57 -2
  21. package/dist/RpgClientEngine.d.ts +55 -16
  22. package/dist/RpgClientEngine.js +60 -5
  23. package/dist/RpgClientEngine.js.map +1 -1
  24. package/dist/Sound.js.map +1 -1
  25. package/dist/_virtual/{_@oxc-project_runtime@0.127.0 → _@oxc-project_runtime@0.128.0}/helpers/decorate.js +1 -1
  26. package/dist/_virtual/{_@oxc-project_runtime@0.127.0 → _@oxc-project_runtime@0.128.0}/helpers/decorateMetadata.js +1 -1
  27. package/dist/components/animations/animation.ce.js.map +1 -1
  28. package/dist/components/animations/hit.ce.js.map +1 -1
  29. package/dist/components/character.ce.js +280 -3
  30. package/dist/components/character.ce.js.map +1 -1
  31. package/dist/components/dynamics/bar.ce.js +96 -0
  32. package/dist/components/dynamics/bar.ce.js.map +1 -0
  33. package/dist/components/dynamics/image.ce.js +23 -0
  34. package/dist/components/dynamics/image.ce.js.map +1 -0
  35. package/dist/components/dynamics/parse-value.d.ts +4 -1
  36. package/dist/components/dynamics/parse-value.js +51 -35
  37. package/dist/components/dynamics/parse-value.js.map +1 -1
  38. package/dist/components/dynamics/parse-value.spec.d.ts +1 -0
  39. package/dist/components/dynamics/shape-utils.d.ts +16 -0
  40. package/dist/components/dynamics/shape-utils.js +73 -0
  41. package/dist/components/dynamics/shape-utils.js.map +1 -0
  42. package/dist/components/dynamics/shape-utils.spec.d.ts +1 -0
  43. package/dist/components/dynamics/shape.ce.js +83 -0
  44. package/dist/components/dynamics/shape.ce.js.map +1 -0
  45. package/dist/components/dynamics/text.ce.js +28 -41
  46. package/dist/components/dynamics/text.ce.js.map +1 -1
  47. package/dist/components/gui/box.ce.js.map +1 -1
  48. package/dist/components/gui/dialogbox/index.ce.js.map +1 -1
  49. package/dist/components/gui/gameover.ce.js.map +1 -1
  50. package/dist/components/gui/hud/hud.ce.js.map +1 -1
  51. package/dist/components/gui/menu/equip-menu.ce.js.map +1 -1
  52. package/dist/components/gui/menu/exit-menu.ce.js.map +1 -1
  53. package/dist/components/gui/menu/items-menu.ce.js.map +1 -1
  54. package/dist/components/gui/menu/main-menu.ce.js.map +1 -1
  55. package/dist/components/gui/menu/options-menu.ce.js.map +1 -1
  56. package/dist/components/gui/menu/skills-menu.ce.js.map +1 -1
  57. package/dist/components/gui/mobile/index.d.ts +1 -1
  58. package/dist/components/gui/mobile/index.js.map +1 -1
  59. package/dist/components/gui/mobile/mobile.ce.js.map +1 -1
  60. package/dist/components/gui/notification/notification.ce.js.map +1 -1
  61. package/dist/components/gui/save-load.ce.js.map +1 -1
  62. package/dist/components/gui/shop/shop.ce.js.map +1 -1
  63. package/dist/components/gui/title-screen.ce.js.map +1 -1
  64. package/dist/components/player-components-utils.d.ts +67 -0
  65. package/dist/components/player-components-utils.js +162 -0
  66. package/dist/components/player-components-utils.js.map +1 -0
  67. package/dist/components/player-components-utils.spec.d.ts +1 -0
  68. package/dist/components/player-components.ce.js +188 -0
  69. package/dist/components/player-components.ce.js.map +1 -0
  70. package/dist/components/prebuilt/hp-bar.ce.js.map +1 -1
  71. package/dist/components/prebuilt/light-halo.ce.js.map +1 -1
  72. package/dist/components/scenes/canvas.ce.js.map +1 -1
  73. package/dist/components/scenes/draw-map.ce.js.map +1 -1
  74. package/dist/components/scenes/event-layer.ce.js.map +1 -1
  75. package/dist/core/inject.js +1 -1
  76. package/dist/core/inject.js.map +1 -1
  77. package/dist/core/setup.js +1 -1
  78. package/dist/core/setup.js.map +1 -1
  79. package/dist/index.js +1 -1
  80. package/dist/module.js +4 -1
  81. package/dist/module.js.map +1 -1
  82. package/dist/node_modules/.pnpm/{@signe_di@2.9.0 → @signe_di@2.10.0}/node_modules/@signe/di/dist/index.js +7 -117
  83. package/dist/node_modules/.pnpm/@signe_di@2.10.0/node_modules/@signe/di/dist/index.js.map +1 -0
  84. package/dist/node_modules/.pnpm/@signe_reactive@2.10.0/node_modules/@signe/reactive/dist/index.js +239 -0
  85. package/dist/node_modules/.pnpm/@signe_reactive@2.10.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
  86. package/dist/node_modules/.pnpm/@signe_room@2.10.0/node_modules/@signe/room/dist/index.js +611 -0
  87. package/dist/node_modules/.pnpm/@signe_room@2.10.0/node_modules/@signe/room/dist/index.js.map +1 -0
  88. package/dist/node_modules/.pnpm/@signe_sync@2.10.0/node_modules/@signe/sync/dist/client/index.js +44 -0
  89. package/dist/node_modules/.pnpm/@signe_sync@2.10.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
  90. package/dist/node_modules/.pnpm/{@signe_sync@2.9.0 → @signe_sync@2.10.0}/node_modules/@signe/sync/dist/index.js +29 -136
  91. package/dist/node_modules/.pnpm/@signe_sync@2.10.0/node_modules/@signe/sync/dist/index.js.map +1 -0
  92. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -1
  93. package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -1
  94. package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -1
  95. package/dist/presets/animation.js.map +1 -1
  96. package/dist/presets/faceset.js.map +1 -1
  97. package/dist/presets/icon.js.map +1 -1
  98. package/dist/presets/lpc.js.map +1 -1
  99. package/dist/presets/rmspritesheet.js.map +1 -1
  100. package/dist/services/AbstractSocket.js.map +1 -1
  101. package/dist/services/keyboardControls.js.map +1 -1
  102. package/dist/services/loadMap.d.ts +6 -0
  103. package/dist/services/loadMap.js +1 -1
  104. package/dist/services/loadMap.js.map +1 -1
  105. package/dist/services/mmorpg.js +1 -1
  106. package/dist/services/mmorpg.js.map +1 -1
  107. package/dist/services/save.js.map +1 -1
  108. package/dist/services/standalone.js +1 -1
  109. package/dist/services/standalone.js.map +1 -1
  110. package/dist/utils/getEntityProp.js.map +1 -1
  111. package/package.json +8 -8
  112. package/src/Game/AnimationManager.spec.ts +30 -0
  113. package/src/Game/AnimationManager.ts +22 -10
  114. package/src/Game/Map.ts +12 -2
  115. package/src/Game/Object.ts +68 -43
  116. package/src/Gui/Gui.spec.ts +273 -0
  117. package/src/Gui/Gui.ts +105 -50
  118. package/src/Resource.ts +1 -2
  119. package/src/RpgClient.ts +63 -2
  120. package/src/RpgClientEngine.ts +82 -12
  121. package/src/components/character.ce +353 -1
  122. package/src/components/dynamics/bar.ce +87 -0
  123. package/src/components/dynamics/image.ce +20 -0
  124. package/src/components/dynamics/parse-value.spec.ts +41 -0
  125. package/src/components/dynamics/parse-value.ts +102 -37
  126. package/src/components/dynamics/shape-utils.spec.ts +46 -0
  127. package/src/components/dynamics/shape-utils.ts +61 -0
  128. package/src/components/dynamics/shape.ce +89 -0
  129. package/src/components/dynamics/text.ce +34 -149
  130. package/src/components/player-components-utils.spec.ts +109 -0
  131. package/src/components/player-components-utils.ts +205 -0
  132. package/src/components/player-components.ce +221 -0
  133. package/src/core/setup.ts +2 -2
  134. package/src/module.ts +5 -1
  135. package/src/services/loadMap.ts +2 -0
  136. package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +0 -1
  137. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +0 -463
  138. package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +0 -1
  139. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +0 -2191
  140. package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +0 -1
  141. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +0 -10
  142. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +0 -1
  143. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +0 -91
  144. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +0 -1
  145. package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +0 -1
  146. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +0 -14
  147. package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"animation.ce.js","names":[],"sources":["../../../src/components/animations/animation.ce"],"sourcesContent":["<Sprite sheet x y anchor={0.5} />\n\n<script>\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { inject } from \"../../core/inject\";\n\n const { x, y, animationName, graphic, onFinish } = defineProps();\n\n const client = inject(RpgClientEngine);\n\n const sheet = {\n definition: client.getSpriteSheet(graphic()),\n playing: animationName() ?? 'default',\n onFinish\n };\n</script>\n"],"mappings":";;;;;AAQuB,UAAC,QAAgB;CAEhC,MAAM,EAAE,GAAA,GAAA,eAAA,SAAA,aAAA,eAAA,QAAA,EAAA;;;GAGZ,YAFW,OAAO,gBAElB,CAAA,eAAA,SAAA,CAAA;GACD,SAAA,eAAA,IAAA;GACD"}
1
+ {"version":3,"file":"animation.ce.js","names":[],"sources":["../../../src/components/animations/animation.ce"],"sourcesContent":["<Sprite sheet x y anchor={0.5} />\n\n<script>\n import { RpgClientEngine } from \"../../RpgClientEngine\";\n import { inject } from \"../../core/inject\";\n\n const { x, y, animationName, graphic, onFinish } = defineProps();\n\n const client = inject(RpgClientEngine);\n\n const sheet = {\n definition: client.getSpriteSheet(graphic()),\n playing: animationName() ?? 'default',\n onFinish\n };\n</script>\n"],"mappings":";;;;;CAQuB,SAAC,QAAgB;CAEhC,MAAM,EAAE,GAAA,GAAA,eAAA,SAAA,aAAA,eAAA,QAAA,EAAA;;;GAGZ,YAFW,OAAO,gBAElB,CAAA,eAAA,SAAA,CAAA;GACD,SAAA,eAAA,IAAA;GACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"hit.ce.js","names":[],"sources":["../../../src/components/animations/hit.ce"],"sourcesContent":["<Text x y zIndex={10000} color scale size={30} text />\n\n<script>\n import { animatedSignal, mount, signal, tick } from \"canvasengine\";\n import { Direction } from \"@rpgjs/common\";\n const {\n text,\n direction,\n onFinish,\n duration,\n color,\n x: positionX,\n y: positionY\n } = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n });\n\n const scale = animatedSignal(1, {\n duration: duration(),\n });\n\n // Generate random initial position\n const randomPosition = () => Math.floor(Math.random() * 60);\n const initialY = randomPosition();\n const x = signal(positionX());\n const y = signal(positionY() - initialY);\n\n // Initial velocity\n let velocityX = 0;\n let velocityY = 0;\n\n // Set initial velocity based on direction\n const speed = 200;\n switch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n }\n\n // Add some randomness to the velocity\n velocityX += (Math.random() - 0.5) * 100;\n velocityY += (Math.random() - 0.5) * 100;\n\n const gravity = 500; // Gravity effect\n const deceleration = 0.98; // Deceleration factor\n\n mount(() => {\n scale.set(0.1);\n });\n\n let elapsedTime = 0;\n\n tick(({ deltaTime }) => {\n elapsedTime += deltaTime;\n \n if (elapsedTime < duration()) {\n // Update position\n x.update((x) => x + (velocityX * deltaTime) / 1000);\n y.update((y) => y + (velocityY * deltaTime) / 1000);\n\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n } else {\n if (onFinish) {\n onFinish();\n }\n }\n });\n</script>\n"],"mappings":";;;AAOI,SAAS,UAAA,SAAA;AACD,UAAA,QAAA;CAER,MAAK,EAAA,MAAA,WAAA,UAAA,UAAA,OAAA,GAAA,WAAA,GAAA,cADG,eAAA,QACH,CAAA;EACL,UAAG,EACA,SAAA,KACF;EACD,OAAA,EACE,SAAS,SACV;EACJ,CAAC;CACF,MAAM,QAAQ,eAAO,GAAA,EACjB,UAAA,UAAA,EACH,CAAC;;CAEF,MAAE,WAAc,gBAAiB;CACjC,MAAI,IAAA,OAAU,WAAU,CAAA;CACxB,MAAI,IAAA,OAAA,WAAA,GAAA,SAAA;;CAEJ,IAAI,YAAU;CACd,MAAE,QAAM;AACR,SAAQ,WAAW,EAAnB;EACE,KAAO,UAAU;AACX,eAAW;;EAEf,KAAC,UAAQ;AACP,eAAa,CAAA;AACb;;AAEE,eAAS;AACT;EACN,KAAO,UAAU;AACX,eAAW,CAAA;AACb;;AAEN,eAAS,KAAU,QAAK,GAAA,MAAA;AACxB,eAAM,KAAa,QAAK,GAAA,MAAA;CACxB,MAAM,UAAK;CACX,MAAI,eAAiB;AACrB,aAAM;AACF,QAAE,IAAK,GAAA;GACT;CACF,IAAI,cAAc;AAClB,OAAM,EAAA,gBAAK;AACT,iBAAA;;AAGA,KAAA,QAAc,MAAK,IAAQ,YAAU,YAAG,IAAA;AACxC,KAAA,QAAc,MAAK,IAAQ,YAAU,YAAG,IAAA;AAElC,gBAAc,UAAI,YAAQ;;AAG1B,gBAAM;sBAIR,WAAe;GAGnB;AAEM,QADL,EAAA,MAAA;EAAA;EAAA;EAAA,QAAA;EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,CACiB;;AAGd,IAAE,iBAEC"}
1
+ {"version":3,"file":"hit.ce.js","names":[],"sources":["../../../src/components/animations/hit.ce"],"sourcesContent":["<Text x y zIndex={10000} color scale size={30} text />\n\n<script>\n import { animatedSignal, mount, signal, tick } from \"canvasengine\";\n import { Direction } from \"@rpgjs/common\";\n const {\n text,\n direction,\n onFinish,\n duration,\n color,\n x: positionX,\n y: positionY\n } = defineProps({\n duration: {\n default: 1000\n },\n color: {\n default: 'black'\n }\n });\n\n const scale = animatedSignal(1, {\n duration: duration(),\n });\n\n // Generate random initial position\n const randomPosition = () => Math.floor(Math.random() * 60);\n const initialY = randomPosition();\n const x = signal(positionX());\n const y = signal(positionY() - initialY);\n\n // Initial velocity\n let velocityX = 0;\n let velocityY = 0;\n\n // Set initial velocity based on direction\n const speed = 200;\n switch (direction()) {\n case Direction.Left:\n velocityX = speed;\n break;\n case Direction.Right:\n velocityX = -speed;\n break;\n case Direction.Up:\n velocityY = speed;\n break;\n case Direction.Down:\n velocityY = -speed;\n break;\n }\n\n // Add some randomness to the velocity\n velocityX += (Math.random() - 0.5) * 100;\n velocityY += (Math.random() - 0.5) * 100;\n\n const gravity = 500; // Gravity effect\n const deceleration = 0.98; // Deceleration factor\n\n mount(() => {\n scale.set(0.1);\n });\n\n let elapsedTime = 0;\n\n tick(({ deltaTime }) => {\n elapsedTime += deltaTime;\n \n if (elapsedTime < duration()) {\n // Update position\n x.update((x) => x + (velocityX * deltaTime) / 1000);\n y.update((y) => y + (velocityY * deltaTime) / 1000);\n\n // Apply gravity\n velocityY += (gravity * deltaTime) / 1000;\n\n // Apply deceleration\n velocityX *= deceleration;\n velocityY *= deceleration;\n } else {\n if (onFinish) {\n onFinish();\n }\n }\n });\n</script>\n"],"mappings":";;;AAOI,SAAS,UAAA,SAAA;CACD,SAAA,QAAA;CAER,MAAK,EAAA,MAAA,WAAA,UAAA,UAAA,OAAA,GAAA,WAAA,GAAA,cADG,eAAA,QACH,CAAA;EACL,UAAG,EACA,SAAA,KACF;EACD,OAAA,EACE,SAAS,SACV;EACJ,CAAC;CACF,MAAM,QAAQ,eAAO,GAAA,EACjB,UAAA,UAAA,EACH,CAAC;;CAEF,MAAE,WAAc,gBAAiB;CACjC,MAAI,IAAA,OAAU,WAAU,CAAA;CACxB,MAAI,IAAA,OAAA,WAAA,GAAA,SAAA;;CAEJ,IAAI,YAAU;CACd,MAAE,QAAM;CACR,QAAQ,WAAW,EAAnB;EACE,KAAO,UAAU;GACX,YAAW;;EAEf,KAAC,UAAQ;GACP,YAAa,CAAA;GACb;;GAEE,YAAS;GACT;EACN,KAAO,UAAU;GACX,YAAW,CAAA;GACb;;CAEN,cAAS,KAAU,QAAK,GAAA,MAAA;CACxB,cAAM,KAAa,QAAK,GAAA,MAAA;CACxB,MAAM,UAAK;CACX,MAAI,eAAiB;CACrB,YAAM;EACF,MAAE,IAAK,GAAA;GACT;CACF,IAAI,cAAc;CAClB,MAAM,EAAA,gBAAK;EACT,eAAA;;GAGA,EAAA,QAAc,MAAK,IAAQ,YAAU,YAAG,IAAA;GACxC,EAAA,QAAc,MAAK,IAAQ,YAAU,YAAG,IAAA;GAElC,aAAc,UAAI,YAAQ;;GAG1B,aAAM;uBAIR,UAAe;GAGnB;CAEM,OADL,EAAA,MAAA;EAAA;EAAA;EAAA,QAAA;EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,CACiB;;AAGd,IAAE,iBAEC"}
@@ -1,10 +1,12 @@
1
1
  import { inject } from "../core/inject.js";
2
2
  import { RpgGui } from "../Gui/Gui.js";
3
3
  import { RpgClientEngine } from "../RpgClientEngine.js";
4
- import { Container, Sprite, animatedSignal, computed, cond, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
4
+ import __ce_component$1 from "./player-components.ce.js";
5
+ import { Container, Sprite, animatedSignal, computed, cond, effect, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
5
6
  import { Particle } from "@canvasengine/presets";
6
- import { Direction, ModulesToken } from "@rpgjs/common";
7
+ import { Animation, Direction, ModulesToken } from "@rpgjs/common";
7
8
  import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
9
+ import { Assets } from "pixi.js";
8
10
  //#region src/components/character.ce
9
11
  function component($$props) {
10
12
  useProps($$props);
@@ -164,6 +166,202 @@ function component($$props) {
164
166
  return [x, typeof scale.y === "number" ? scale.y : x];
165
167
  }
166
168
  };
169
+ const imageDimensions = signal({});
170
+ const loadingImageDimensions = /* @__PURE__ */ new Set();
171
+ const toPositiveNumber = (value) => {
172
+ const number = typeof value === "number" ? value : parseFloat(value);
173
+ return Number.isFinite(number) && number > 0 ? number : void 0;
174
+ };
175
+ const toFiniteNumber = (value, fallback = 0) => {
176
+ const number = typeof value === "number" ? value : parseFloat(value);
177
+ return Number.isFinite(number) ? number : fallback;
178
+ };
179
+ const clampRatio = (value) => Math.min(1, Math.max(0, value));
180
+ const normalizePair = (value, fallback = [1, 1]) => {
181
+ if (Array.isArray(value)) {
182
+ const x = toFiniteNumber(value[0], fallback[0]);
183
+ return [x, toFiniteNumber(value[1] ?? value[0], x)];
184
+ }
185
+ if (typeof value === "number") return [value, value];
186
+ if (value && typeof value === "object") {
187
+ const x = toFiniteNumber(value.x, fallback[0]);
188
+ return [x, toFiniteNumber(value.y ?? value.x, x)];
189
+ }
190
+ return fallback;
191
+ };
192
+ const normalizeAnchor = (value) => {
193
+ if (!Array.isArray(value)) return void 0;
194
+ const [x, y] = normalizePair(value, [0, 0]);
195
+ return [clampRatio(x), clampRatio(y)];
196
+ };
197
+ const resolveImageSource = (image) => {
198
+ if (typeof image === "string") return image;
199
+ if (typeof image?.default === "string") return image.default;
200
+ };
201
+ const parentTextureOptions = (graphicObject) => {
202
+ return [
203
+ "width",
204
+ "height",
205
+ "framesHeight",
206
+ "framesWidth",
207
+ "rectWidth",
208
+ "rectHeight",
209
+ "offset",
210
+ "image",
211
+ "sound",
212
+ "spriteRealSize",
213
+ "scale",
214
+ "anchor",
215
+ "pivot",
216
+ "x",
217
+ "y",
218
+ "opacity"
219
+ ].reduce((options, prop) => {
220
+ if (graphicObject?.[prop] !== void 0) options[prop] = graphicObject[prop];
221
+ return options;
222
+ }, {});
223
+ };
224
+ const resolveTextureOptions = (graphicObject) => {
225
+ const textures = graphicObject?.textures ?? {};
226
+ const texture = textures[realAnimationName()] ?? textures[Animation.Stand] ?? Object.values(textures)[0] ?? {};
227
+ return {
228
+ ...parentTextureOptions(graphicObject),
229
+ ...texture
230
+ };
231
+ };
232
+ const resolveFirstAnimationFrame = (textureOptions) => {
233
+ const animations = textureOptions?.animations;
234
+ if (!animations) return {};
235
+ try {
236
+ const frames = typeof animations === "function" ? animations({ direction: direction() }) : animations;
237
+ if (!Array.isArray(frames)) return {};
238
+ const firstGroup = frames[0];
239
+ return Array.isArray(firstGroup) ? firstGroup[0] ?? {} : firstGroup ?? {};
240
+ } catch {
241
+ return {};
242
+ }
243
+ };
244
+ const optionValue = (prop, frame, textureOptions, graphicObject) => {
245
+ return frame?.[prop] ?? textureOptions?.[prop] ?? graphicObject?.[prop];
246
+ };
247
+ const resolveFrameSize = (textureOptions, dimensions) => {
248
+ const framesWidth = toPositiveNumber(textureOptions?.framesWidth) ?? 1;
249
+ const framesHeight = toPositiveNumber(textureOptions?.framesHeight) ?? 1;
250
+ const imageSource = resolveImageSource(textureOptions?.image);
251
+ const loadedSize = imageSource ? dimensions[imageSource] : void 0;
252
+ const fullWidth = toPositiveNumber(textureOptions?.width) ?? loadedSize?.width;
253
+ const fullHeight = toPositiveNumber(textureOptions?.height) ?? loadedSize?.height;
254
+ return {
255
+ width: toPositiveNumber(textureOptions?.rectWidth) ?? toPositiveNumber(textureOptions?.spriteWidth) ?? (fullWidth ? fullWidth / framesWidth : void 0),
256
+ height: toPositiveNumber(textureOptions?.rectHeight) ?? toPositiveNumber(textureOptions?.spriteHeight) ?? (fullHeight ? fullHeight / framesHeight : void 0)
257
+ };
258
+ };
259
+ const resolveHitboxAnchor = (spriteWidth, spriteHeight, realSize, box) => {
260
+ if (!spriteWidth || !spriteHeight || !box) return [0, 0];
261
+ const resolvedHeight = toPositiveNumber(typeof realSize === "number" ? realSize : realSize?.height) ?? spriteHeight;
262
+ const gap = Math.max(0, (spriteHeight - resolvedHeight) / 2);
263
+ const hitboxTopLeftX = clampRatio((spriteWidth - box.w) / 2 / spriteWidth);
264
+ const hitboxTopLeftY = clampRatio((spriteHeight - box.h - gap) / spriteHeight);
265
+ const hitboxCenterX = clampRatio(hitboxTopLeftX + box.w / 2 / spriteWidth);
266
+ const hitboxCenterY = clampRatio(hitboxTopLeftY + box.h / 2 / spriteHeight);
267
+ const footY = clampRatio((spriteHeight - gap) / spriteHeight);
268
+ switch (box.anchorMode ?? "top-left") {
269
+ case "center": return [hitboxCenterX, hitboxCenterY];
270
+ case "foot": return [hitboxCenterX, footY];
271
+ default: return [hitboxTopLeftX, hitboxTopLeftY];
272
+ }
273
+ };
274
+ const loadImageDimensions = (image) => {
275
+ const source = resolveImageSource(image);
276
+ if (!source || imageDimensions()[source] || loadingImageDimensions.has(source)) return;
277
+ loadingImageDimensions.add(source);
278
+ Assets.load(source).then((texture) => {
279
+ const width = toPositiveNumber(texture?.width);
280
+ const height = toPositiveNumber(texture?.height);
281
+ if (!width || !height) return;
282
+ imageDimensions.update((dimensions) => ({
283
+ ...dimensions,
284
+ [source]: {
285
+ width,
286
+ height
287
+ }
288
+ }));
289
+ }).catch(() => {}).finally(() => {
290
+ loadingImageDimensions.delete(source);
291
+ });
292
+ };
293
+ effect(() => {
294
+ const sources = /* @__PURE__ */ new Set();
295
+ graphicsSignals().forEach((graphicObject) => {
296
+ const baseImage = resolveImageSource(graphicObject?.image);
297
+ if (baseImage) sources.add(baseImage);
298
+ Object.values(graphicObject?.textures ?? {}).forEach((textureOptions) => {
299
+ const image = resolveImageSource(textureOptions?.image ?? graphicObject?.image);
300
+ if (image) sources.add(image);
301
+ });
302
+ });
303
+ sources.forEach((source) => loadImageDimensions(source));
304
+ });
305
+ const hitboxBounds = computed(() => {
306
+ const box = hitbox();
307
+ const width = box?.w ?? 0;
308
+ const height = box?.h ?? 0;
309
+ return {
310
+ left: 0,
311
+ top: 0,
312
+ right: width,
313
+ bottom: height,
314
+ width,
315
+ height,
316
+ centerX: width / 2,
317
+ centerY: height / 2
318
+ };
319
+ });
320
+ const graphicBounds = computed(() => {
321
+ const box = hitbox();
322
+ const fallback = hitboxBounds();
323
+ const dimensions = imageDimensions();
324
+ const graphics = graphicsSignals();
325
+ let bounds = null;
326
+ graphics.forEach((graphicObject) => {
327
+ const textureOptions = resolveTextureOptions(graphicObject);
328
+ const frame = resolveFirstAnimationFrame(textureOptions);
329
+ const size = resolveFrameSize(textureOptions, dimensions);
330
+ const spriteWidth = size.width ?? box?.w;
331
+ const spriteHeight = size.height ?? box?.h;
332
+ if (!spriteWidth || !spriteHeight) return;
333
+ const anchor = normalizeAnchor(optionValue("anchor", frame, textureOptions, graphicObject)) ?? resolveHitboxAnchor(spriteWidth, spriteHeight, optionValue("spriteRealSize", frame, textureOptions, graphicObject), box);
334
+ const scale = normalizePair(optionValue("scale", frame, textureOptions, graphicObject) ?? graphicScale(graphicObject));
335
+ const x = toFiniteNumber(optionValue("x", frame, textureOptions, graphicObject), 0);
336
+ const y = toFiniteNumber(optionValue("y", frame, textureOptions, graphicObject), 0);
337
+ const leftEdge = -anchor[0] * spriteWidth * scale[0];
338
+ const rightEdge = (1 - anchor[0]) * spriteWidth * scale[0];
339
+ const topEdge = -anchor[1] * spriteHeight * scale[1];
340
+ const bottomEdge = (1 - anchor[1]) * spriteHeight * scale[1];
341
+ const graphic = {
342
+ left: x + Math.min(leftEdge, rightEdge),
343
+ top: y + Math.min(topEdge, bottomEdge),
344
+ right: x + Math.max(leftEdge, rightEdge),
345
+ bottom: y + Math.max(topEdge, bottomEdge)
346
+ };
347
+ bounds = bounds ? {
348
+ left: Math.min(bounds.left, graphic.left),
349
+ top: Math.min(bounds.top, graphic.top),
350
+ right: Math.max(bounds.right, graphic.right),
351
+ bottom: Math.max(bounds.bottom, graphic.bottom)
352
+ } : graphic;
353
+ });
354
+ if (!bounds) return fallback;
355
+ const width = bounds.right - bounds.left;
356
+ const height = bounds.bottom - bounds.top;
357
+ return {
358
+ ...bounds,
359
+ width,
360
+ height,
361
+ centerX: bounds.left + width / 2,
362
+ centerY: bounds.top + height / 2
363
+ };
364
+ });
167
365
  const movementAnimations = ["walk", "stand"];
168
366
  const epsilon = 0;
169
367
  const stateX$ = smoothX.animatedState.observable;
@@ -174,7 +372,38 @@ function component($$props) {
174
372
  const yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
175
373
  return !xFinished || !yFinished;
176
374
  }), startWith(false));
177
- const animationMovementSubscription = combineLatest([animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr)), moving$]).subscribe(([[prev, curr], isMoving]) => {
375
+ const animationChange$ = animationName$.pipe(startWith(animationName()), pairwise(), filter(([prev, curr]) => prev !== curr));
376
+ let beforeRemovePromise = null;
377
+ let beforeRemoveTransitionValue = null;
378
+ const resolveRemoveContext = () => {
379
+ if (!object._removeTransition) return null;
380
+ const value = object._removeTransition();
381
+ if (!value || typeof value !== "string") return null;
382
+ try {
383
+ const context = JSON.parse(value);
384
+ if (!context || typeof context !== "object" || !context.active) return null;
385
+ context.__transitionValue = value;
386
+ return context;
387
+ } catch {
388
+ return null;
389
+ }
390
+ };
391
+ const withTimeout = (promise, timeoutMs = 0) => {
392
+ if (!timeoutMs || timeoutMs <= 0) return promise;
393
+ return Promise.race([promise, new Promise((resolve) => setTimeout(resolve, timeoutMs))]);
394
+ };
395
+ const runBeforeRemove = () => {
396
+ const context = resolveRemoveContext();
397
+ if (!context) return Promise.resolve();
398
+ if (beforeRemovePromise && beforeRemoveTransitionValue === context.__transitionValue) return beforeRemovePromise;
399
+ beforeRemoveTransitionValue = context.__transitionValue;
400
+ beforeRemovePromise = withTimeout(lastValueFrom(hooks.callHooks("client-sprite-onBeforeRemove", object, context)), context.timeoutMs);
401
+ return beforeRemovePromise;
402
+ };
403
+ const removeTransitionSubscription = object._removeTransition?.observable?.subscribe(() => {
404
+ if (resolveRemoveContext()) runBeforeRemove();
405
+ });
406
+ const animationMovementSubscription = combineLatest([animationChange$, moving$]).subscribe(([[prev, curr], isMoving]) => {
178
407
  if (curr == "stand" && !isMoving) realAnimationName.set(curr);
179
408
  else if (curr == "walk" && isMoving) realAnimationName.set(curr);
180
409
  else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
@@ -184,7 +413,30 @@ function component($$props) {
184
413
  }
185
414
  }
186
415
  });
416
+ const waitForTemporaryAnimationEnd = (maxDuration = 1200) => {
417
+ if (!object.animationIsPlaying || !object.animationIsPlaying()) return Promise.resolve();
418
+ return new Promise((resolve) => {
419
+ let finished = false;
420
+ let timeout;
421
+ let subscription;
422
+ const finish = () => {
423
+ if (finished) return;
424
+ finished = true;
425
+ clearTimeout(timeout);
426
+ subscription?.unsubscribe();
427
+ resolve();
428
+ };
429
+ timeout = setTimeout(finish, maxDuration);
430
+ subscription = object.animationIsPlaying.observable.subscribe((isPlaying) => {
431
+ if (!isPlaying) finish();
432
+ });
433
+ if (finished) subscription.unsubscribe();
434
+ });
435
+ };
187
436
  const onBeforeDestroy = async () => {
437
+ await runBeforeRemove();
438
+ await waitForTemporaryAnimationEnd();
439
+ removeTransitionSubscription?.unsubscribe();
188
440
  animationMovementSubscription.unsubscribe();
189
441
  xSubscription.unsubscribe();
190
442
  ySubscription.unsubscribe();
@@ -218,6 +470,16 @@ function component($$props) {
218
470
  object,
219
471
  ...compConfig.props
220
472
  }))),
473
+ h(__ce_component$1, {
474
+ object,
475
+ position: "bottom",
476
+ graphicBounds
477
+ }),
478
+ h(__ce_component$1, {
479
+ object,
480
+ position: "left",
481
+ graphicBounds
482
+ }),
221
483
  h(Particle, {
222
484
  emit: emitParticleTrigger,
223
485
  settings: particleSettings,
@@ -232,6 +494,21 @@ function component($$props) {
232
494
  hitbox,
233
495
  flash: flashConfig
234
496
  }))),
497
+ h(__ce_component$1, {
498
+ object,
499
+ position: "center",
500
+ graphicBounds
501
+ }),
502
+ h(__ce_component$1, {
503
+ object,
504
+ position: "right",
505
+ graphicBounds
506
+ }),
507
+ h(__ce_component$1, {
508
+ object,
509
+ position: "top",
510
+ graphicBounds
511
+ }),
235
512
  loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
236
513
  object,
237
514
  ...compConfig.props
@@ -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 <Particle emit={emitParticleTrigger} settings={particleSettings} zIndex={1000} name={particleName} />\n <Container>\n @for (graphicObj of graphicsSignals) {\n <Sprite \n sheet={sheet(graphicObj)} \n scale={graphicScale(graphicObj)}\n direction \n tint \n hitbox\n flash={flashConfig}\n />\n }\n </Container>\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\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 } from \"@rpgjs/common\";\n import Hit from \"./effects/hit.ce\";\n import PlayerComponents from \"./player-components.ce\";\n import { RpgGui } from \"../Gui/Gui\";\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 playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\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() && object.canMove()\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 = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\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 // 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 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 onBeforeDestroy = async () => {\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 if (isMe()) client.setKeyboardControls(element.directives.controls)\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"],"mappings":";;;;;;;;AAcM,SAAE,UAAA,SAAA;AACO,UAAW,QAAA;CAEtB,MAAA,EAAA,QAAA,OADG,eAAA,QACH,EAAA;CACJ,MAAI,SAAS,OAAA,gBAAA;CACb,MAAM,QAAE,OAAa,aAAC;CACtB,MAAK,aAAU,OAAA,OAAc;AACX,QAAU;CAC5B,MAAM,WAAS,OAAA;CACf,MAAE,mBAAA,OAAA;CACF,MAAM,oBAAiB,OAAA;CACvB,MAAK,OAAI,eAAA,IAAA,KAA0B,SAAA;CACnC,MAAM,sBAAU,SAAA;EACZ,IAAI;EACJ,IAAI;EACJ,IAAI;AAEJ,MAAI,OAAI,SAAA,cAAA,QAAA,OAAA,SAAA,YAAA,CAAA,KAAA,WAAA;AACJ,kBAAS;AACb,gBAAA,KAAA;AACF,oBAAA,KAAA;aAGK,QAAA,OAAA,SAAA,YAAA,KAAA,WAAA;AACC,kBAAW,KAAQ;AAEnB,gBAAG,KAAe,UAAA,KAAA,IAAe,KAAU,QAAQ,KAAK;AAC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CAAA,CAAA;EAAA,KAAA,8BAAA,eAAA,EAAA,WAAA,EAAA,cAAA,WAAA,cAAA,EAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;GAAA,CAAA,CAAA,CAAA;EAAA,KAAA,eAAA,gBAAA,KAAA,gCAAA,EAAA,WAAA,MAAA,EAAA,YAAA,WAAA;GAAA,GAAA,YAAA,MAAA;GAAA,cAAA,YAAA;GAAA;GAAA,WAAA,SAAA;AACA,wBAAA,aAAA,KAAA;;;AAEA,6BAAA,aAAA,MAAA,KAAA;;GACO,CAAA,CAAA,CAAA,CAAA;EAAA,CACP;;AAGC,IAAO,iBAER"}
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 <Sprite \n sheet={sheet(graphicObj)} \n scale={graphicScale(graphicObj)}\n direction \n tint \n hitbox\n flash={flashConfig}\n />\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\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 playerId = client.playerId;\n const componentsBehind = client.spriteComponentsBehind;\n const componentsInFront = client.spriteComponentsInFront;\n const isMe = computed(() => id() === playerId);\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() && object.canMove()\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 = signal({\n down: {\n repeat: true,\n bind: keyboardControls.down,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Down })\n },\n },\n up: {\n repeat: true,\n bind: keyboardControls.up,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Up })\n },\n },\n left: {\n repeat: true,\n bind: keyboardControls.left,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Left })\n },\n },\n right: {\n repeat: true,\n bind: keyboardControls.right,\n keyDown() {\n if (canControls()) client.processInput({ input: Direction.Right })\n },\n },\n action: {\n bind: keyboardControls.action,\n keyDown() {\n if (canControls()) {\n client.processAction({ action: 'action' })\n }\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 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 if (isMe()) client.setKeyboardControls(element.directives.controls)\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(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c,mBAAO,WAAA,WAAA,cAAA;IACzB,IAAI,CAAA,WACH,QAAA;KACL;GACJ,IAAA,UACD,aAAA,aAAA;;;CAGH,MAAI,kBAAe,YAAA;EACf,MAAK,iBAAU;EACf,MAAE,8BAAM;EACR,8BAAA,aAAA;;EAEA,cAAA,aAA2B;EAC3B,cAAY,aAAM;EAClB,MAAG,cAAiB,MAAC,UAAA,2BAAA,OAAA,CAAA;EACrB,MAAI,cAAc,MAAA,UAAiB,kCAAe,OAAA,UAAA,OAAA,CAAA;;CAEtD,OAAO,YAAY;;EAEf,MAAI,UAAA,+BAAwC,OAAA,UAAA,OAAA,CAAA,WAAA;EAC5C,IAAI,MAAK,EACL,OAAG,oBAAwB,QAAC,WAAA,SAAA;GAClC;CACF,MAAM,uBAAC,KAAA,SAAA;EACH,WAAW,SAAM,IAAA,MAAA,KAAA;;CAErB,MAAM,4BAAyB,KAAO,MAAO,SAAA;EACzC,WAAI,eAAA,IAAA,MAAA,MAAA,KAAA;;;EAGN,MAAQ,UAAK,yBAAA,CAAA,WAAA;GACb;CAMI,OAAA,EAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAJF,oBAA0B,aAAC,KAAiB;;GACrC,gBAAa,MAAA,SAAkB;IAChC,yBAAuB,aAAU,MAAA,KAAA;;;GAEvB;;AAGd,IAAE,iBAAA"}
@@ -0,0 +1,96 @@
1
+ import { resolveDynamicValue } from "./parse-value.js";
2
+ import { Container, Graphics, Text, computed, cond, h, useDefineProps, useProps } from "canvasengine";
3
+ //#region src/components/dynamics/bar.ce
4
+ function component($$props) {
5
+ useProps($$props);
6
+ const { object, current, max, style, text } = useDefineProps($$props)();
7
+ const read = (prop, fallback) => prop ? prop() : fallback;
8
+ const toNumber = (value, fallback = 0) => {
9
+ const resolved = resolveDynamicValue(value, object);
10
+ const num = typeof resolved === "number" ? resolved : parseFloat(resolved);
11
+ return Number.isFinite(num) ? num : fallback;
12
+ };
13
+ const toColor = (value, fallback) => {
14
+ const resolved = resolveDynamicValue(value, object);
15
+ if (typeof resolved === "number") return resolved;
16
+ if (typeof resolved === "string" && resolved.startsWith("#")) return parseInt(resolved.slice(1), 16);
17
+ return resolved ?? fallback;
18
+ };
19
+ const config = computed(() => read(style, {}) ?? {});
20
+ const width = computed(() => toNumber(config().width, 50));
21
+ const height = computed(() => toNumber(config().height, 8));
22
+ const borderRadius = computed(() => toNumber(config().borderRadius, 3));
23
+ const borderWidth = computed(() => toNumber(config().borderWidth, 1));
24
+ const backgroundColor = computed(() => toColor(config().bgColor, 1450302));
25
+ const fillColor = computed(() => toColor(config().fillColor, 4906624));
26
+ const borderColor = computed(() => toColor(config().borderColor, 4871528));
27
+ const opacity = computed(() => Math.max(0, Math.min(1, toNumber(config().opacity, 1))));
28
+ const currentValue = computed(() => toNumber(read(current, 0), 0));
29
+ const maxValue = computed(() => Math.max(0, toNumber(read(max, 0), 0)));
30
+ const percent = computed(() => {
31
+ const max = maxValue();
32
+ if (max <= 0) return 0;
33
+ return Math.max(0, Math.min(1, currentValue() / max));
34
+ });
35
+ const fillWidth = computed(() => Math.max(0, width() * percent()));
36
+ const labelTemplate = computed(() => read(text, null));
37
+ const labelText = computed(() => {
38
+ const template = labelTemplate();
39
+ if (template == null || template === "") return "";
40
+ 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
+ });
43
+ const labelSize = computed(() => toNumber(config().fontSize, 10));
44
+ const hasLabel = computed(() => labelText().length > 0);
45
+ const labelOffset = computed(() => hasLabel() ? labelSize() + 2 : 0);
46
+ const containerHeight = computed(() => labelOffset() + height());
47
+ const labelColor = computed(() => toColor(config().textColor, 16777215));
48
+ const labelPosition = computed(() => ({
49
+ x: 0,
50
+ y: 0
51
+ }));
52
+ const drawBar = (g) => {
53
+ g.roundRect(0, labelOffset(), width(), height(), borderRadius());
54
+ g.fill({
55
+ color: backgroundColor(),
56
+ alpha: opacity()
57
+ });
58
+ const currentWidth = fillWidth();
59
+ if (currentWidth > 0) {
60
+ g.roundRect(0, labelOffset(), currentWidth, height(), borderRadius());
61
+ g.fill({
62
+ color: fillColor(),
63
+ alpha: opacity()
64
+ });
65
+ }
66
+ const strokeWidth = borderWidth();
67
+ if (strokeWidth <= 0) return;
68
+ g.roundRect(0, labelOffset(), width(), height(), borderRadius());
69
+ g.stroke({
70
+ color: borderColor(),
71
+ width: strokeWidth,
72
+ alpha: opacity()
73
+ });
74
+ };
75
+ return h(Container, {
76
+ width,
77
+ height: containerHeight,
78
+ minWidth: width,
79
+ minHeight: containerHeight
80
+ }, [h(Graphics, {
81
+ width,
82
+ height: containerHeight,
83
+ draw: drawBar
84
+ }), cond(hasLabel, () => h(Text, {
85
+ text: labelText,
86
+ x: labelPosition.x,
87
+ y: labelPosition.y,
88
+ size: labelSize,
89
+ color: labelColor
90
+ }))]);
91
+ }
92
+ var __ce_component = component;
93
+ //#endregion
94
+ export { __ce_component as default };
95
+
96
+ //# sourceMappingURL=bar.ce.js.map
@@ -0,0 +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,QAAA,EAAA;CAE3C,MAAM,QAAQ,MAAM,aAAa,OAAO,MAAM,GAAG;;EAEjD,MAAM,WAAY,oBAAuB,OAAC,OAAA;EACxC,MAAM,MAAQ,OAAG,aAAA,WAA2B,WAAO,WAAA,SAAA;EACnD,OAAS,OAAG,SAAO,IAAU,GAAG,MAAC;;CAEnC,MAAC,WAAA,OAAA,aAAA;;EAED,IAAM,OAAS,aAAS,UAChB,OAAA;EACJ,IAAE,OAAO,aAAc,YAAS,SAAO,WAAQ,IAAA,EAC7C,OAAO,SAAW,SAAS,MAAK,EAAA,EAAA,GAAQ;EAE5C,OAAA,YAAA;;CAEF,MAAC,SAAA,eAAA,KAAA,OAAA,EAAA,CAAA,IAAA,EAAA,CAAA;;CAED,MAAM,SAAS,eAAe,SAAK,QAAY,CAAC,QAAI,EAAA,CAAA;CACpD,MAAM,eAAQ,eAAe,SAAgB,QAAQ,CAAC,cAAI,EAAA,CAAA;CAC1D,MAAM,cAAS,eAAe,SAAS,QAAS,CAAA,aAAW,EAAA,CAAA;CAC3D,MAAM,kBAAe,eAAe,QAAS,QAAS,CAAA,SAAA,QAAiB,CAAA;CACvE,MAAM,YAAY,eAAe,QAAE,QAAS,CAAM,WAAG,QAAgB,CAAA;CACrE,MAAM,cAAA,eAA6B,QAAI,QAAQ,CAAA,aAAkB,QAAS,CAAC;CAC3E,MAAM,UAAU,eAAe,KAAE,IAAO,GAAC,KAAO,IAAE,GAAA,SAAW,QAAU,CAAA,SAAA,EAAA,CAAA,CAAA,CAAA;CACvE,MAAM,eAAc,eAAe,SAAQ,KAAO,SAAE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nB,EAAA,KAAW;IAAE,OAAA,WAAe;IAAK,OAAI,SAAU;IAAA,CAAA;;;EAGjD,IAAM,eAAe,GACjB;EACF,EAAE,UAAU,GAAG,aAAa,EAAE,OAAA,EAAA,QAAc,EAAA,cAAU,CAAA;EACtD,EAAE,OAAO;GAAA,OAAO,aAAa;GAAA,OAAO;GAAY,OAAA,SAAA;GAAA,CAAA;;CAG5C,OADP,EAAA,WAAA;EAAA;EAAA,QAAA;EAAA,UAAA;EAAA,WAAA;EAAA,EAAA,CAAA,EAAA,UAAA;EAAA;EAAA,QAAA;EAAA,MAAA;EAAA,CAAA,EAAA,KAAA,gBAAA,EAAA,MAAA;EAAA,MAAA;EAAA,GAAA,cAAA;EAAA,GAAA,cAAA;EAAA,MAAA;EAAA,OAAA;EAAA,CAAA,CAAA,CAAA,CACmB;;AAGhB,IAAQ,iBAEJ"}
@@ -0,0 +1,23 @@
1
+ import { inject } from "../../core/inject.js";
2
+ import { resolveDynamicValue } from "./parse-value.js";
3
+ import { RpgClientEngine } from "../../RpgClientEngine.js";
4
+ import { Sprite, computed, h, useDefineProps, useProps } from "canvasengine";
5
+ //#region src/components/dynamics/image.ce
6
+ function component($$props) {
7
+ useProps($$props);
8
+ const { object, value } = useDefineProps($$props)();
9
+ const client = inject(RpgClientEngine);
10
+ return h(Sprite, { sheet: computed(() => {
11
+ const id = resolveDynamicValue(value?.(), object);
12
+ if (!id) return null;
13
+ return {
14
+ definition: client.getSpriteSheet(id),
15
+ playing: "default"
16
+ };
17
+ }) });
18
+ }
19
+ var __ce_component = component;
20
+ //#endregion
21
+ export { __ce_component as default };
22
+
23
+ //# sourceMappingURL=image.ce.js.map
@@ -0,0 +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,QACe,EAAA;CAC5C,MAAM,SAAK,OAAW,gBAAA;2BACb,eAAA;EACL,MAAA,KAAW,oBAAQ,SAAkB,EAAA,OAAA;EACrC,IAAA,CAAA,IACD,OAAA;EACD,OAAA;GACM,YAAA,OAAA,eAAA,GAAA"}
@@ -1 +1,4 @@
1
- export declare const parseDynamicValue: (value: any, object?: any) => import('canvasengine').ComputedSignal<string>;
1
+ export declare const getDynamicValue: (property: string, object?: any) => any;
2
+ export declare const resolveDynamicValue: (value: any, object?: any) => any;
3
+ export declare const resolveDynamicProps: (props: any, object?: any) => any;
4
+ export declare const parseDynamicValue: (value: any, object?: any) => any;