@rpgjs/client 5.0.0-alpha.9 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Game/AnimationManager.d.ts +8 -0
- package/dist/Game/AnimationManager.js +26 -0
- package/dist/Game/AnimationManager.js.map +1 -0
- package/dist/Game/Event.d.ts +1 -1
- package/dist/Game/Event.js +12 -0
- package/dist/Game/Event.js.map +1 -0
- package/dist/Game/Map.d.ts +23 -2
- package/dist/Game/Map.js +80 -0
- package/dist/Game/Map.js.map +1 -0
- package/dist/Game/Object.d.ts +157 -0
- package/dist/Game/Object.js +211 -0
- package/dist/Game/Object.js.map +1 -0
- package/dist/Game/Player.d.ts +1 -1
- package/dist/Game/Player.js +12 -0
- package/dist/Game/Player.js.map +1 -0
- package/dist/Gui/Gui.d.ts +177 -5
- package/dist/Gui/Gui.js +445 -0
- package/dist/Gui/Gui.js.map +1 -0
- package/dist/Gui/NotificationManager.d.ts +23 -0
- package/dist/Gui/NotificationManager.js +49 -0
- package/dist/Gui/NotificationManager.js.map +1 -0
- package/dist/Resource.d.ts +97 -0
- package/dist/Resource.js +133 -0
- package/dist/Resource.js.map +1 -0
- package/dist/RpgClient.d.ts +238 -11
- package/dist/RpgClientEngine.d.ts +615 -14
- package/dist/RpgClientEngine.js +1334 -0
- package/dist/RpgClientEngine.js.map +1 -0
- package/dist/Sound.d.ts +199 -0
- package/dist/Sound.js +167 -0
- package/dist/Sound.js.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/animations/animation.ce.js +24 -0
- package/dist/components/animations/animation.ce.js.map +1 -0
- package/dist/components/animations/hit.ce.js +70 -0
- package/dist/components/animations/hit.ce.js.map +1 -0
- package/dist/components/animations/index.d.ts +4 -0
- package/dist/components/animations/index.js +11 -0
- package/dist/components/animations/index.js.map +1 -0
- package/dist/components/character.ce.js +392 -0
- package/dist/components/character.ce.js.map +1 -0
- package/dist/components/dynamics/parse-value.d.ts +1 -0
- package/dist/components/dynamics/parse-value.js +44 -0
- package/dist/components/dynamics/parse-value.js.map +1 -0
- package/dist/components/dynamics/text.ce.js +73 -0
- package/dist/components/dynamics/text.ce.js.map +1 -0
- package/dist/components/gui/box.ce.js +28 -0
- package/dist/components/gui/box.ce.js.map +1 -0
- package/dist/components/gui/dialogbox/index.ce.js +205 -0
- package/dist/components/gui/dialogbox/index.ce.js.map +1 -0
- package/dist/components/gui/gameover.ce.js +193 -0
- package/dist/components/gui/gameover.ce.js.map +1 -0
- package/dist/components/gui/hud/hud.ce.js +92 -0
- package/dist/components/gui/hud/hud.ce.js.map +1 -0
- package/dist/components/gui/index.d.ts +15 -3
- package/dist/components/gui/index.js +14 -0
- package/dist/components/gui/menu/equip-menu.ce.js +481 -0
- package/dist/components/gui/menu/equip-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/exit-menu.ce.js +54 -0
- package/dist/components/gui/menu/exit-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/items-menu.ce.js +344 -0
- package/dist/components/gui/menu/items-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/main-menu.ce.js +417 -0
- package/dist/components/gui/menu/main-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/options-menu.ce.js +48 -0
- package/dist/components/gui/menu/options-menu.ce.js.map +1 -0
- package/dist/components/gui/menu/skills-menu.ce.js +107 -0
- package/dist/components/gui/menu/skills-menu.ce.js.map +1 -0
- package/dist/components/gui/mobile/index.d.ts +8 -0
- package/dist/components/gui/mobile/index.js +21 -0
- package/dist/components/gui/mobile/index.js.map +1 -0
- package/dist/components/gui/mobile/mobile.ce.js +78 -0
- package/dist/components/gui/mobile/mobile.ce.js.map +1 -0
- package/dist/components/gui/notification/notification.ce.js +64 -0
- package/dist/components/gui/notification/notification.ce.js.map +1 -0
- package/dist/components/gui/save-load.ce.js +389 -0
- package/dist/components/gui/save-load.ce.js.map +1 -0
- package/dist/components/gui/shop/shop.ce.js +652 -0
- package/dist/components/gui/shop/shop.ce.js.map +1 -0
- package/dist/components/gui/title-screen.ce.js +190 -0
- package/dist/components/gui/title-screen.ce.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/prebuilt/hp-bar.ce.js +116 -0
- package/dist/components/prebuilt/hp-bar.ce.js.map +1 -0
- package/dist/components/prebuilt/index.d.ts +19 -0
- package/dist/components/prebuilt/index.js +2 -0
- package/dist/components/prebuilt/light-halo.ce.js +94 -0
- package/dist/components/prebuilt/light-halo.ce.js.map +1 -0
- package/dist/components/scenes/canvas.ce.js +60 -0
- package/dist/components/scenes/canvas.ce.js.map +1 -0
- package/dist/components/scenes/draw-map.ce.js +89 -0
- package/dist/components/scenes/draw-map.ce.js.map +1 -0
- package/dist/components/scenes/event-layer.ce.js +28 -0
- package/dist/components/scenes/event-layer.ce.js.map +1 -0
- package/dist/core/inject.js +18 -0
- package/dist/core/inject.js.map +1 -0
- package/dist/core/setup.js +16 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +44 -14
- package/dist/module.d.ts +43 -4
- package/dist/module.js +176 -0
- package/dist/module.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js +277 -0
- package/dist/node_modules/.pnpm/@signe_di@2.9.0/node_modules/@signe/di/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js +457 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.8.3/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js +463 -0
- package/dist/node_modules/.pnpm/@signe_reactive@2.9.0/node_modules/@signe/reactive/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js +2191 -0
- package/dist/node_modules/.pnpm/@signe_room@2.9.0/node_modules/@signe/room/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js +10 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/chunk-7QVYU63E.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js +91 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/client/index.js.map +1 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js +325 -0
- package/dist/node_modules/.pnpm/@signe_sync@2.9.0/node_modules/@signe/sync/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js +14 -0
- package/dist/node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js +115 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-HAC622V3.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js +401 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/chunk-S74YV6PU.js.map +1 -0
- package/dist/node_modules/.pnpm/partysocket@1.1.3/node_modules/partysocket/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js +3756 -0
- package/dist/node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.js.map +1 -0
- package/dist/presets/animation.d.ts +31 -0
- package/dist/presets/animation.js +39 -0
- package/dist/presets/animation.js.map +1 -0
- package/dist/presets/faceset.d.ts +30 -0
- package/dist/presets/faceset.js +51 -0
- package/dist/presets/faceset.js.map +1 -0
- package/dist/presets/icon.d.ts +20 -0
- package/dist/presets/icon.js +15 -0
- package/dist/presets/icon.js.map +1 -0
- package/dist/presets/index.d.ts +123 -0
- package/dist/presets/index.js +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/lpc.d.ts +89 -0
- package/dist/presets/lpc.js +98 -0
- package/dist/presets/lpc.js.map +1 -0
- package/dist/presets/rmspritesheet.js +42 -0
- package/dist/presets/rmspritesheet.js.map +1 -0
- package/dist/services/AbstractSocket.d.ts +9 -5
- package/dist/services/AbstractSocket.js +11 -0
- package/dist/services/AbstractSocket.js.map +1 -0
- package/dist/services/keyboardControls.d.ts +15 -0
- package/dist/services/keyboardControls.js +23 -0
- package/dist/services/keyboardControls.js.map +1 -0
- package/dist/services/loadMap.js +123 -0
- package/dist/services/loadMap.js.map +1 -0
- package/dist/services/mmorpg.d.ts +21 -9
- package/dist/services/mmorpg.js +131 -0
- package/dist/services/mmorpg.js.map +1 -0
- package/dist/services/save.d.ts +19 -0
- package/dist/services/save.js +77 -0
- package/dist/services/save.js.map +1 -0
- package/dist/services/standalone.d.ts +67 -7
- package/dist/services/standalone.js +168 -0
- package/dist/services/standalone.js.map +1 -0
- package/dist/utils/getEntityProp.d.ts +39 -0
- package/dist/utils/getEntityProp.js +52 -0
- package/dist/utils/getEntityProp.js.map +1 -0
- package/package.json +13 -9
- package/src/Game/{EffectManager.ts → AnimationManager.ts} +3 -2
- package/src/Game/Event.ts +1 -1
- package/src/Game/Map.ts +95 -3
- package/src/Game/Object.ts +330 -14
- package/src/Game/Player.ts +1 -1
- package/src/Gui/Gui.ts +506 -18
- package/src/Gui/NotificationManager.ts +69 -0
- package/src/Resource.ts +150 -0
- package/src/RpgClient.ts +246 -12
- package/src/RpgClientEngine.ts +1641 -62
- package/src/Sound.ts +253 -0
- package/src/components/{effects → animations}/animation.ce +3 -6
- package/src/components/{effects → animations}/index.ts +1 -1
- package/src/components/character.ce +387 -52
- package/src/components/dynamics/parse-value.ts +80 -0
- package/src/components/dynamics/text.ce +183 -0
- package/src/components/gui/box.ce +17 -0
- package/src/components/gui/dialogbox/index.ce +204 -187
- package/src/components/gui/gameover.ce +158 -0
- package/src/components/gui/hud/hud.ce +61 -0
- package/src/components/gui/index.ts +30 -4
- package/src/components/gui/menu/equip-menu.ce +410 -0
- package/src/components/gui/menu/exit-menu.ce +41 -0
- package/src/components/gui/menu/items-menu.ce +317 -0
- package/src/components/gui/menu/main-menu.ce +294 -0
- package/src/components/gui/menu/options-menu.ce +35 -0
- package/src/components/gui/menu/skills-menu.ce +83 -0
- package/src/components/gui/mobile/index.ts +24 -0
- package/src/components/gui/mobile/mobile.ce +80 -0
- package/src/components/gui/notification/notification.ce +51 -0
- package/src/components/gui/save-load.ce +208 -0
- package/src/components/gui/shop/shop.ce +493 -0
- package/src/components/gui/title-screen.ce +163 -0
- package/src/components/index.ts +3 -0
- package/src/components/prebuilt/hp-bar.ce +255 -0
- package/src/components/prebuilt/index.ts +24 -0
- package/src/components/prebuilt/light-halo.ce +148 -0
- package/src/components/scenes/canvas.ce +20 -15
- package/src/components/scenes/draw-map.ce +60 -13
- package/src/components/scenes/event-layer.ce +7 -0
- package/src/components/scenes/transition.ce +60 -0
- package/src/index.ts +16 -2
- package/src/module.ts +127 -9
- package/src/presets/animation.ts +46 -0
- package/src/presets/faceset.ts +60 -0
- package/src/presets/icon.ts +17 -0
- package/src/presets/index.ts +9 -1
- package/src/presets/lpc.ts +108 -0
- package/src/services/AbstractSocket.ts +10 -2
- package/src/services/keyboardControls.ts +20 -0
- package/src/services/loadMap.ts +1 -1
- package/src/services/mmorpg.ts +100 -12
- package/src/services/save.ts +103 -0
- package/src/services/standalone.ts +110 -18
- package/src/utils/getEntityProp.ts +87 -0
- package/vite.config.ts +4 -2
- package/dist/Game/EffectManager.d.ts +0 -5
- package/dist/components/effects/index.d.ts +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index10.js +0 -8
- package/dist/index10.js.map +0 -1
- package/dist/index11.js +0 -10
- package/dist/index11.js.map +0 -1
- package/dist/index12.js +0 -8
- package/dist/index12.js.map +0 -1
- package/dist/index13.js +0 -17
- package/dist/index13.js.map +0 -1
- package/dist/index14.js +0 -107
- package/dist/index14.js.map +0 -1
- package/dist/index15.js +0 -50
- package/dist/index15.js.map +0 -1
- package/dist/index16.js +0 -191
- package/dist/index16.js.map +0 -1
- package/dist/index17.js +0 -9
- package/dist/index17.js.map +0 -1
- package/dist/index18.js +0 -387
- package/dist/index18.js.map +0 -1
- package/dist/index19.js +0 -31
- package/dist/index19.js.map +0 -1
- package/dist/index2.js +0 -181
- package/dist/index2.js.map +0 -1
- package/dist/index20.js +0 -24
- package/dist/index20.js.map +0 -1
- package/dist/index21.js +0 -2421
- package/dist/index21.js.map +0 -1
- package/dist/index22.js +0 -114
- package/dist/index22.js.map +0 -1
- package/dist/index23.js +0 -109
- package/dist/index23.js.map +0 -1
- package/dist/index24.js +0 -71
- package/dist/index24.js.map +0 -1
- package/dist/index25.js +0 -21
- package/dist/index25.js.map +0 -1
- package/dist/index26.js +0 -41
- package/dist/index26.js.map +0 -1
- package/dist/index27.js +0 -5
- package/dist/index27.js.map +0 -1
- package/dist/index28.js +0 -322
- package/dist/index28.js.map +0 -1
- package/dist/index29.js +0 -27
- package/dist/index29.js.map +0 -1
- package/dist/index3.js +0 -87
- package/dist/index3.js.map +0 -1
- package/dist/index30.js +0 -11
- package/dist/index30.js.map +0 -1
- package/dist/index31.js +0 -11
- package/dist/index31.js.map +0 -1
- package/dist/index32.js +0 -174
- package/dist/index32.js.map +0 -1
- package/dist/index33.js +0 -501
- package/dist/index33.js.map +0 -1
- package/dist/index34.js +0 -12
- package/dist/index34.js.map +0 -1
- package/dist/index35.js +0 -4403
- package/dist/index35.js.map +0 -1
- package/dist/index36.js +0 -316
- package/dist/index36.js.map +0 -1
- package/dist/index37.js +0 -61
- package/dist/index37.js.map +0 -1
- package/dist/index38.js +0 -20
- package/dist/index38.js.map +0 -1
- package/dist/index39.js +0 -20
- package/dist/index39.js.map +0 -1
- package/dist/index4.js +0 -67
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -16
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -17
- package/dist/index6.js.map +0 -1
- package/dist/index7.js +0 -39
- package/dist/index7.js.map +0 -1
- package/dist/index8.js +0 -108
- package/dist/index8.js.map +0 -1
- package/dist/index9.js +0 -76
- package/dist/index9.js.map +0 -1
- package/src/components/gui/dialogbox/itemMenu.ce +0 -23
- package/src/components/gui/dialogbox/selection.ce +0 -67
- /package/src/components/{effects → animations}/hit.ce +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Text, animatedSignal, h, mount, signal, tick, useDefineProps, useProps } from "canvasengine";
|
|
2
|
+
import { Direction } from "@rpgjs/common";
|
|
3
|
+
//#region src/components/animations/hit.ce
|
|
4
|
+
function component($$props) {
|
|
5
|
+
useProps($$props);
|
|
6
|
+
var _a = useDefineProps($$props)({
|
|
7
|
+
duration: { default: 1e3 },
|
|
8
|
+
color: { default: "black" }
|
|
9
|
+
}), text = _a.text, direction = _a.direction, onFinish = _a.onFinish, duration = _a.duration, color = _a.color, positionX = _a.x, positionY = _a.y;
|
|
10
|
+
var scale = animatedSignal(1, { duration: duration() });
|
|
11
|
+
var randomPosition = function() {
|
|
12
|
+
return Math.floor(Math.random() * 60);
|
|
13
|
+
};
|
|
14
|
+
var initialY = randomPosition();
|
|
15
|
+
var x = signal(positionX());
|
|
16
|
+
var y = signal(positionY() - initialY);
|
|
17
|
+
var velocityX = 0;
|
|
18
|
+
var velocityY = 0;
|
|
19
|
+
var speed = 200;
|
|
20
|
+
switch (direction()) {
|
|
21
|
+
case Direction.Left:
|
|
22
|
+
velocityX = speed;
|
|
23
|
+
break;
|
|
24
|
+
case Direction.Right:
|
|
25
|
+
velocityX = -speed;
|
|
26
|
+
break;
|
|
27
|
+
case Direction.Up:
|
|
28
|
+
velocityY = speed;
|
|
29
|
+
break;
|
|
30
|
+
case Direction.Down:
|
|
31
|
+
velocityY = -speed;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
velocityX += (Math.random() - .5) * 100;
|
|
35
|
+
velocityY += (Math.random() - .5) * 100;
|
|
36
|
+
var gravity = 500;
|
|
37
|
+
var deceleration = .98;
|
|
38
|
+
mount(function() {
|
|
39
|
+
scale.set(.1);
|
|
40
|
+
});
|
|
41
|
+
var elapsedTime = 0;
|
|
42
|
+
tick(function(_a) {
|
|
43
|
+
var deltaTime = _a.deltaTime;
|
|
44
|
+
elapsedTime += deltaTime;
|
|
45
|
+
if (elapsedTime < duration()) {
|
|
46
|
+
x.update(function(x) {
|
|
47
|
+
return x + velocityX * deltaTime / 1e3;
|
|
48
|
+
});
|
|
49
|
+
y.update(function(y) {
|
|
50
|
+
return y + velocityY * deltaTime / 1e3;
|
|
51
|
+
});
|
|
52
|
+
velocityY += gravity * deltaTime / 1e3;
|
|
53
|
+
velocityX *= deceleration;
|
|
54
|
+
velocityY *= deceleration;
|
|
55
|
+
} else if (onFinish) onFinish();
|
|
56
|
+
});
|
|
57
|
+
return h(Text, {
|
|
58
|
+
x,
|
|
59
|
+
y,
|
|
60
|
+
zIndex: 1e4,
|
|
61
|
+
color,
|
|
62
|
+
scale,
|
|
63
|
+
size: 30,
|
|
64
|
+
text
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { component as default };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=hit.ce.js.map
|
|
@@ -0,0 +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,IAAK,KADG,eAAA,QAAA,CACH;EACL,UAAG,EACA,SAAA,KACF;EACD,OAAA,EACE,SAAS,SACV;EACJ,CAAC,EAAE,OAAO,GAAA,MAAA,YAAA,GAAA,WAAA,WAAA,GAAA,UAAA,WAAA,GAAA,UAAA,QAAA,GAAA,OAAA,YAAA,GAAA,GAAA,YAAA,GAAA;CACX,IAAI,QAAE,eAAe,GAAA,EACjB,UAAA,UAAA,EACH,CAAC;;;;CAEF,IAAE,WAAa,gBAAgB;CAC/B,IAAI,IAAA,OAAU,WAAU,CAAA;CACxB,IAAI,IAAA,OAAA,WAAA,GAAA,SAAA;;CAEJ,IAAI,YAAU;CACd,IAAE,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,IAAI,UAAO;CACX,IAAI,eAAe;AACnB,OAAM,WAAY;AACd,QAAE,IAAK,GAAA;GACT;CACF,IAAI,cAAc;AAClB,MAAK,SAAM,IAAA;EACT,IAAA,YAAA,GAAA;;AAEE,MAAI,cAAM,UAAkB,EAAA;AAE9B,KAAA,OAAc,SAAW,GAAG;AAAE,WAAO,IAAG,YAAA,YAAA;KAAA;;;;AAGlC,gBAAc,UAAU,YAAa;AAErC,gBAAM;AACV,gBAAc;aAGZ,SAAA,WAAA;GAIJ;AAEM,QADY,EAAE,MAAA;EAAQ;EAAG;EAAC,QAAA;EAAA;EAAA;EAAA,MAAA;EAAA;EAAA,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import component from "./hit.ce.js";
|
|
2
|
+
import component$1 from "./animation.ce.js";
|
|
3
|
+
//#region src/components/animations/index.ts
|
|
4
|
+
var PrebuiltComponentAnimations = {
|
|
5
|
+
Hit: component,
|
|
6
|
+
Animation: component$1
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { PrebuiltComponentAnimations };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/animations/index.ts"],"sourcesContent":["import Hit from \"./hit.ce\";\nimport Animation from \"./animation.ce\";\n\nexport const PrebuiltComponentAnimations = {\n Hit,\n Animation\n}"],"mappings":";;;AAGA,IAAa,8BAA8B;CACvC,KAAA;CACA,WAAA"}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { inject } from "../core/inject.js";
|
|
2
|
+
import { RpgGui } from "../Gui/Gui.js";
|
|
3
|
+
import { RpgClientEngine } from "../RpgClientEngine.js";
|
|
4
|
+
import { Container, Sprite, animatedSignal, computed, cond, h, loop, mount, on, signal, tick, useDefineProps, useProps } from "canvasengine";
|
|
5
|
+
import { Particle } from "@canvasengine/presets";
|
|
6
|
+
import { Direction, ModulesToken } from "@rpgjs/common";
|
|
7
|
+
import { combineLatest, filter, lastValueFrom, map, pairwise, startWith } from "rxjs";
|
|
8
|
+
//#region src/components/character.ce
|
|
9
|
+
function component($$props) {
|
|
10
|
+
useProps($$props);
|
|
11
|
+
const defineProps = useDefineProps($$props);
|
|
12
|
+
var __assign = this && this.__assign || function() {
|
|
13
|
+
__assign = Object.assign || function(t) {
|
|
14
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15
|
+
s = arguments[i];
|
|
16
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
return __assign.apply(this, arguments);
|
|
21
|
+
};
|
|
22
|
+
var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
23
|
+
function adopt(value) {
|
|
24
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
29
|
+
function fulfilled(value) {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.next(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function rejected(value) {
|
|
37
|
+
try {
|
|
38
|
+
step(generator["throw"](value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function step(result) {
|
|
44
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
45
|
+
}
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
50
|
+
var _ = {
|
|
51
|
+
label: 0,
|
|
52
|
+
sent: function() {
|
|
53
|
+
if (t[0] & 1) throw t[1];
|
|
54
|
+
return t[1];
|
|
55
|
+
},
|
|
56
|
+
trys: [],
|
|
57
|
+
ops: []
|
|
58
|
+
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
59
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
60
|
+
return this;
|
|
61
|
+
}), g;
|
|
62
|
+
function verb(n) {
|
|
63
|
+
return function(v) {
|
|
64
|
+
return step([n, v]);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function step(op) {
|
|
68
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
69
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
70
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
71
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
72
|
+
switch (op[0]) {
|
|
73
|
+
case 0:
|
|
74
|
+
case 1:
|
|
75
|
+
t = op;
|
|
76
|
+
break;
|
|
77
|
+
case 4:
|
|
78
|
+
_.label++;
|
|
79
|
+
return {
|
|
80
|
+
value: op[1],
|
|
81
|
+
done: false
|
|
82
|
+
};
|
|
83
|
+
case 5:
|
|
84
|
+
_.label++;
|
|
85
|
+
y = op[1];
|
|
86
|
+
op = [0];
|
|
87
|
+
continue;
|
|
88
|
+
case 7:
|
|
89
|
+
op = _.ops.pop();
|
|
90
|
+
_.trys.pop();
|
|
91
|
+
continue;
|
|
92
|
+
default:
|
|
93
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
94
|
+
_ = 0;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
98
|
+
_.label = op[1];
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
102
|
+
_.label = t[1];
|
|
103
|
+
t = op;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (t && _.label < t[2]) {
|
|
107
|
+
_.label = t[2];
|
|
108
|
+
_.ops.push(op);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (t[2]) _.ops.pop();
|
|
112
|
+
_.trys.pop();
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
op = body.call(thisArg, _);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
op = [6, e];
|
|
118
|
+
y = 0;
|
|
119
|
+
} finally {
|
|
120
|
+
f = t = 0;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] & 5) throw op[1];
|
|
123
|
+
return {
|
|
124
|
+
value: op[0] ? op[1] : void 0,
|
|
125
|
+
done: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var _a = defineProps(), object = _a.object, id = _a.id;
|
|
130
|
+
var client = inject(RpgClientEngine);
|
|
131
|
+
var hooks = inject(ModulesToken);
|
|
132
|
+
var guiService = inject(RpgGui);
|
|
133
|
+
client.spritesheets;
|
|
134
|
+
var playerId = client.playerId;
|
|
135
|
+
var componentsBehind = client.spriteComponentsBehind;
|
|
136
|
+
var componentsInFront = client.spriteComponentsInFront;
|
|
137
|
+
var isMe = computed(function() {
|
|
138
|
+
return id() === playerId;
|
|
139
|
+
});
|
|
140
|
+
var normalizeComponent = function(comp) {
|
|
141
|
+
var componentRef;
|
|
142
|
+
var propsValue;
|
|
143
|
+
var dependenciesFn;
|
|
144
|
+
if (typeof comp === "function" || comp && typeof comp === "object" && !comp.component) {
|
|
145
|
+
componentRef = comp;
|
|
146
|
+
propsValue = void 0;
|
|
147
|
+
dependenciesFn = void 0;
|
|
148
|
+
} else if (comp && typeof comp === "object" && comp.component) {
|
|
149
|
+
componentRef = comp.component;
|
|
150
|
+
propsValue = comp.props !== void 0 ? comp.props : comp.data;
|
|
151
|
+
dependenciesFn = comp.dependencies;
|
|
152
|
+
} else {
|
|
153
|
+
componentRef = comp;
|
|
154
|
+
propsValue = void 0;
|
|
155
|
+
dependenciesFn = void 0;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
component: componentRef,
|
|
159
|
+
props: typeof propsValue === "function" ? propsValue(object) : propsValue || {},
|
|
160
|
+
dependencies: dependenciesFn ? dependenciesFn(object) : []
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
var normalizeComponents = function(components) {
|
|
164
|
+
return components.map(function(comp) {
|
|
165
|
+
return normalizeComponent(comp);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
var normalizedComponentsBehind = computed(function() {
|
|
169
|
+
return normalizeComponents(componentsBehind());
|
|
170
|
+
});
|
|
171
|
+
var normalizedComponentsInFront = computed(function() {
|
|
172
|
+
return normalizeComponents(componentsInFront());
|
|
173
|
+
});
|
|
174
|
+
var shouldFollowCamera = computed(function() {
|
|
175
|
+
var cameraTargetId = client.cameraFollowTargetId();
|
|
176
|
+
if (cameraTargetId !== null) return id() === cameraTargetId;
|
|
177
|
+
return isMe();
|
|
178
|
+
});
|
|
179
|
+
var attachedGuis = computed(function() {
|
|
180
|
+
return guiService.getAttachedGuis();
|
|
181
|
+
});
|
|
182
|
+
var shouldDisplayAttachedGui = computed(function() {
|
|
183
|
+
return guiService.shouldDisplayAttachedGui(id());
|
|
184
|
+
}), x = object.x, y = object.y, tint = object.tint, direction = object.direction, animationName = object.animationName, animationCurrentIndex = object.animationCurrentIndex, emitParticleTrigger = object.emitParticleTrigger, particleName = object.particleName;
|
|
185
|
+
object.graphics;
|
|
186
|
+
var hitbox = object.hitbox, isConnected = object.isConnected, graphicsSignals = object.graphicsSignals, flashTrigger = object.flashTrigger;
|
|
187
|
+
var flashType = signal("alpha");
|
|
188
|
+
var flashDuration = signal(300);
|
|
189
|
+
var flashCycles = signal(1);
|
|
190
|
+
var flashAlpha = signal(.3);
|
|
191
|
+
var flashTint = signal(16777215);
|
|
192
|
+
on(flashTrigger, function(data) {
|
|
193
|
+
if (data && typeof data === "object") {
|
|
194
|
+
if (data.type !== void 0) flashType.set(data.type);
|
|
195
|
+
if (data.duration !== void 0) flashDuration.set(data.duration);
|
|
196
|
+
if (data.cycles !== void 0) flashCycles.set(data.cycles);
|
|
197
|
+
if (data.alpha !== void 0) flashAlpha.set(data.alpha);
|
|
198
|
+
if (data.tint !== void 0) flashTint.set(data.tint);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
var flashConfig = computed(function() {
|
|
202
|
+
return {
|
|
203
|
+
trigger: flashTrigger,
|
|
204
|
+
type: flashType(),
|
|
205
|
+
duration: flashDuration(),
|
|
206
|
+
cycles: flashCycles(),
|
|
207
|
+
alpha: flashAlpha(),
|
|
208
|
+
tint: flashTint()
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
var particleSettings = client.particleSettings;
|
|
212
|
+
var canControls = function() {
|
|
213
|
+
return isMe() && object.canMove();
|
|
214
|
+
};
|
|
215
|
+
var keyboardControls = client.globalConfig.keyboardControls;
|
|
216
|
+
var visible = computed(function() {
|
|
217
|
+
if (object.isEvent()) return true;
|
|
218
|
+
return isConnected();
|
|
219
|
+
});
|
|
220
|
+
var controls = signal({
|
|
221
|
+
down: {
|
|
222
|
+
repeat: true,
|
|
223
|
+
bind: keyboardControls.down,
|
|
224
|
+
keyDown: function() {
|
|
225
|
+
if (canControls()) client.processInput({ input: Direction.Down });
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
up: {
|
|
229
|
+
repeat: true,
|
|
230
|
+
bind: keyboardControls.up,
|
|
231
|
+
keyDown: function() {
|
|
232
|
+
if (canControls()) client.processInput({ input: Direction.Up });
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
left: {
|
|
236
|
+
repeat: true,
|
|
237
|
+
bind: keyboardControls.left,
|
|
238
|
+
keyDown: function() {
|
|
239
|
+
if (canControls()) client.processInput({ input: Direction.Left });
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
right: {
|
|
243
|
+
repeat: true,
|
|
244
|
+
bind: keyboardControls.right,
|
|
245
|
+
keyDown: function() {
|
|
246
|
+
if (canControls()) client.processInput({ input: Direction.Right });
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
action: {
|
|
250
|
+
bind: keyboardControls.action,
|
|
251
|
+
keyDown: function() {
|
|
252
|
+
if (canControls()) client.processAction({ action: "action" });
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
escape: {
|
|
256
|
+
bind: keyboardControls.escape,
|
|
257
|
+
keyDown: function() {
|
|
258
|
+
if (canControls()) client.processAction({ action: "escape" });
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
gamepad: { enabled: true }
|
|
262
|
+
});
|
|
263
|
+
var smoothX = animatedSignal(x(), { duration: isMe() ? 0 : 0 });
|
|
264
|
+
var smoothY = animatedSignal(y(), { duration: isMe() ? 0 : 0 });
|
|
265
|
+
var z = computed(function() {
|
|
266
|
+
return object.y() + object.z();
|
|
267
|
+
});
|
|
268
|
+
var realAnimationName = signal(animationName());
|
|
269
|
+
var xSubscription = x.observable.subscribe(function(value) {
|
|
270
|
+
smoothX.set(value);
|
|
271
|
+
});
|
|
272
|
+
var ySubscription = y.observable.subscribe(function(value) {
|
|
273
|
+
smoothY.set(value);
|
|
274
|
+
});
|
|
275
|
+
var sheet = function(graphicObject) {
|
|
276
|
+
return {
|
|
277
|
+
definition: graphicObject,
|
|
278
|
+
playing: realAnimationName(),
|
|
279
|
+
params: { direction: direction() },
|
|
280
|
+
onFinish: function() {
|
|
281
|
+
animationCurrentIndex.update(function(index) {
|
|
282
|
+
return index + 1;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
var movementAnimations = ["walk", "stand"];
|
|
288
|
+
var epsilon = 0;
|
|
289
|
+
var stateX$ = smoothX.animatedState.observable;
|
|
290
|
+
var stateY$ = smoothY.animatedState.observable;
|
|
291
|
+
var animationName$ = animationName.observable;
|
|
292
|
+
var moving$ = combineLatest([stateX$, stateY$]).pipe(map(function(_a) {
|
|
293
|
+
var sx = _a[0], sy = _a[1];
|
|
294
|
+
var xFinished = Math.abs(sx.value.current - sx.value.end) <= epsilon;
|
|
295
|
+
var yFinished = Math.abs(sy.value.current - sy.value.end) <= epsilon;
|
|
296
|
+
return !xFinished || !yFinished;
|
|
297
|
+
}), startWith(false));
|
|
298
|
+
var animationMovementSubscription = combineLatest([animationName$.pipe(startWith(animationName()), pairwise(), filter(function(_a) {
|
|
299
|
+
return _a[0] !== _a[1];
|
|
300
|
+
})), moving$]).subscribe(function(_a) {
|
|
301
|
+
var _b = _a[0];
|
|
302
|
+
_b[0];
|
|
303
|
+
var curr = _b[1], isMoving = _a[1];
|
|
304
|
+
if (curr == "stand" && !isMoving) realAnimationName.set(curr);
|
|
305
|
+
else if (curr == "walk" && isMoving) realAnimationName.set(curr);
|
|
306
|
+
else if (!movementAnimations.includes(curr)) realAnimationName.set(curr);
|
|
307
|
+
if (!isMoving && object.animationIsPlaying && object.animationIsPlaying()) {
|
|
308
|
+
if (movementAnimations.includes(curr)) {
|
|
309
|
+
if (typeof object.resetAnimationState === "function") object.resetAnimationState();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
var onBeforeDestroy = function() {
|
|
314
|
+
return __awaiter(void 0, void 0, void 0, function() {
|
|
315
|
+
return __generator(this, function(_a) {
|
|
316
|
+
switch (_a.label) {
|
|
317
|
+
case 0:
|
|
318
|
+
animationMovementSubscription.unsubscribe();
|
|
319
|
+
xSubscription.unsubscribe();
|
|
320
|
+
ySubscription.unsubscribe();
|
|
321
|
+
return [4, lastValueFrom(hooks.callHooks("client-sprite-onDestroy", object))];
|
|
322
|
+
case 1:
|
|
323
|
+
_a.sent();
|
|
324
|
+
return [4, lastValueFrom(hooks.callHooks("client-sceneMap-onRemoveSprite", client.sceneMap, object))];
|
|
325
|
+
case 2:
|
|
326
|
+
_a.sent();
|
|
327
|
+
return [2];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
mount(function(element) {
|
|
333
|
+
hooks.callHooks("client-sprite-onAdd", object).subscribe();
|
|
334
|
+
hooks.callHooks("client-sceneMap-onAddSprite", client.sceneMap, object).subscribe();
|
|
335
|
+
if (isMe()) client.setKeyboardControls(element.directives.controls);
|
|
336
|
+
});
|
|
337
|
+
var onAttachedGuiFinish = function(gui, data) {
|
|
338
|
+
guiService.guiClose(gui.name, data);
|
|
339
|
+
};
|
|
340
|
+
var onAttachedGuiInteraction = function(gui, name, data) {
|
|
341
|
+
guiService.guiInteraction(gui.name, name, data);
|
|
342
|
+
};
|
|
343
|
+
tick(function() {
|
|
344
|
+
hooks.callHooks("client-sprite-onUpdate").subscribe();
|
|
345
|
+
});
|
|
346
|
+
return h(Container, {
|
|
347
|
+
x: smoothX,
|
|
348
|
+
y: smoothY,
|
|
349
|
+
zIndex: z,
|
|
350
|
+
viewportFollow: shouldFollowCamera,
|
|
351
|
+
controls,
|
|
352
|
+
onBeforeDestroy,
|
|
353
|
+
visible
|
|
354
|
+
}, [
|
|
355
|
+
loop(normalizedComponentsBehind, (compConfig) => h(Container, null, h(compConfig.component, {
|
|
356
|
+
object,
|
|
357
|
+
...compConfig.props
|
|
358
|
+
}))),
|
|
359
|
+
h(Particle, {
|
|
360
|
+
emit: emitParticleTrigger,
|
|
361
|
+
settings: particleSettings,
|
|
362
|
+
zIndex: 1e3,
|
|
363
|
+
name: particleName
|
|
364
|
+
}),
|
|
365
|
+
h(Container, null, loop(graphicsSignals, (graphicObj) => h(Sprite, {
|
|
366
|
+
sheet: computed(() => sheet(graphicObj)),
|
|
367
|
+
direction,
|
|
368
|
+
tint,
|
|
369
|
+
hitbox,
|
|
370
|
+
flash: flashConfig
|
|
371
|
+
}))),
|
|
372
|
+
loop(normalizedComponentsInFront, (compConfig) => h(Container, { dependencies: compConfig.dependencies }, h(compConfig.component, {
|
|
373
|
+
object,
|
|
374
|
+
...compConfig.props
|
|
375
|
+
}))),
|
|
376
|
+
loop(attachedGuis, (attachedGui) => cond(shouldDisplayAttachedGui, () => h(Container, null, h(attachedGui.component, {
|
|
377
|
+
...attachedGui.data(),
|
|
378
|
+
dependencies: attachedGui.dependencies,
|
|
379
|
+
object,
|
|
380
|
+
onFinish: (data) => {
|
|
381
|
+
onAttachedGuiFinish(attachedGui, data);
|
|
382
|
+
},
|
|
383
|
+
onInteraction: (name, data) => {
|
|
384
|
+
onAttachedGuiInteraction(attachedGui, name, data);
|
|
385
|
+
}
|
|
386
|
+
}))))
|
|
387
|
+
]);
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
export { component as default };
|
|
391
|
+
|
|
392
|
+
//# sourceMappingURL=character.ce.js.map
|
|
@@ -0,0 +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 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 // 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>"],"mappings":";;;;;;;;AAcM,SAAoB,UAAA,SAAA;AACnB,UAAA,QAAA;CACH,MAAA,cAAA,eAAA,QAAA;CACA,IAAA,WAAS,QAAA,KAAA,YAAA,WAAA;AACV,aAAK,OAAc,UAAA,SAAA,GAAA;AACjB,QAAA,IAAU,GAAA,IAAA,GAAY,IAAE,UAAW,QAAA,IAAa,GAAA,KAAA;AAC9C,QAAA,UAAW;AACZ,SAAS,IAAA,KAAA,EAAA,KAAA,OAAA,UAAA,eAAA,KAAA,GAAA,EAAA,CACb,GAAA,KAAA,EAAA;;AAEM,UAAC;;AAEL,SAAK,SAAW,MAAC,MAAW,UAAE;;CAElC,IAAI,YAAO,QAAc,KAAE,aAAe,SAAA,SAAA,YAAA,GAAA,WAAA;EACtC,SAAM,MAAA,OAAA;AAAA,UAAyB,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GACH;CACF,IAAI,sBAAc,SAAA,KAAA,MAAA;AACd,aAAQ,SAAA,IAAgB,MAAG,KAAA;;CAE/B,IAAI,2BAAuB,SAAO,KAAY,MAAG,MAAO;AACpD,aAAG,eAAA,IAAA,MAAA,MAAA,KAAA;;AAEP,MAAI,WAAM;AACN,QAAE,UAAY,yBAAA,CAAA,WAAA;GAChB;AAMI,QALU,EAAA,WAAA;EAAA,GAAA;EAAA,GAAA;EAAA,QAAA;EAAA,gBAAA;EAAA;EAAA;EAAA;EAAA,EAAA;EAAA,KAAA,6BAAA,eAAA,EAAA,WAAA,MAAA,EAAA,WAAA,WAAA;GAAA;GAAA,GAAA,WAAA;GAAA,CAAA,CAAA,CAAA;EAAA,EAAA,UAAA;GAAA,MAAA;GAAA,UAAA;GAAA,QAAA;GAAA,MAAA;GAAA,CAAA;EAAA,EAAA,WAAA,MAAA,KAAA,kBAAA,eAAA,EAAA,QAAA;GAAA,OAAA,eAAA,MAAA,WAAA,CAAA;GAAA;GAAA;GAAA;GAAA,OAAA;GAAA,CAAA,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;AACN,wBAAiB,aAAO,KAAc;;GACzC,gBAAA,MAAA,SAAA;AACF,6BAAA,aAAA,MAAA,KAAA;;GACM,CAAA,CAAA,CAAA,CAAA;EAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseDynamicValue: (value: any, object?: any) => import('canvasengine').ComputedSignal<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { computed } from "canvasengine";
|
|
2
|
+
//#region src/components/dynamics/parse-value.ts
|
|
3
|
+
var parseDynamicValue = (value, object) => {
|
|
4
|
+
if (typeof value !== "string") return computed(() => String(value ?? ""));
|
|
5
|
+
const pattern = /\{([^}]+)\}/g;
|
|
6
|
+
const matches = [];
|
|
7
|
+
let match;
|
|
8
|
+
while ((match = pattern.exec(value)) !== null) matches.push({
|
|
9
|
+
property: match[1],
|
|
10
|
+
fullMatch: match[0],
|
|
11
|
+
index: match.index
|
|
12
|
+
});
|
|
13
|
+
if (matches.length === 0) return computed(() => value);
|
|
14
|
+
return computed(() => {
|
|
15
|
+
let result = value;
|
|
16
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
17
|
+
const { property, fullMatch } = matches[i];
|
|
18
|
+
let propertyValue = "";
|
|
19
|
+
try {
|
|
20
|
+
const propertyPath = property.split(".");
|
|
21
|
+
let currentValue = object;
|
|
22
|
+
for (let j = 0; j < propertyPath.length; j++) {
|
|
23
|
+
const prop = propertyPath[j];
|
|
24
|
+
if (typeof currentValue === "function") currentValue = currentValue();
|
|
25
|
+
if (currentValue && typeof currentValue === "object" && prop in currentValue) currentValue = currentValue[prop];
|
|
26
|
+
else {
|
|
27
|
+
currentValue = void 0;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (typeof currentValue === "function") currentValue = currentValue();
|
|
32
|
+
propertyValue = currentValue != null ? String(currentValue) : "";
|
|
33
|
+
} catch (error) {
|
|
34
|
+
propertyValue = "";
|
|
35
|
+
}
|
|
36
|
+
result = result.replace(fullMatch, propertyValue);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { parseDynamicValue };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=parse-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-value.js","names":[],"sources":["../../../src/components/dynamics/parse-value.ts"],"sourcesContent":["import { computed } from \"canvasengine\";\n\ninterface MatchResult {\n property: string;\n fullMatch: string;\n index: number;\n}\n\nexport const parseDynamicValue = (value: any, object?: any) => {\n if (typeof value !== 'string') {\n return computed(() => String(value ?? ''));\n }\n\n // Find all dynamic references like {propertyName}\n const pattern = /\\{([^}]+)\\}/g;\n const matches: MatchResult[] = [];\n let match;\n \n while ((match = pattern.exec(value)) !== null) {\n matches.push({\n property: match[1],\n fullMatch: match[0],\n index: match.index!\n });\n }\n\n // If no dynamic references found, return simple computed\n if (matches.length === 0) {\n return computed(() => value);\n }\n\n // Create computed that tracks all referenced signals\n return computed(() => {\n let result = value;\n \n // Replace from end to start to preserve indices\n for (let i = matches.length - 1; i >= 0; i--) {\n const { property, fullMatch } = matches[i];\n \n // Try to access the property from the object\n // Support nested properties like {param.maxHp}\n let propertyValue = '';\n try {\n const propertyPath = property.split('.');\n let currentValue = object;\n \n for (let j = 0; j < propertyPath.length; j++) {\n const prop = propertyPath[j];\n \n // Check if currentValue is a signal (function) and call it\n if (typeof currentValue === 'function') {\n currentValue = currentValue();\n }\n \n // Access the property\n if (currentValue && typeof currentValue === 'object' && prop in currentValue) {\n currentValue = currentValue[prop];\n } else {\n currentValue = undefined;\n break;\n }\n }\n \n // If the final value is a signal, call it\n if (typeof currentValue === 'function') {\n currentValue = currentValue();\n }\n \n propertyValue = currentValue != null ? String(currentValue) : '';\n } catch (error) {\n // If property doesn't exist or can't be accessed, use empty string\n propertyValue = '';\n }\n \n result = result.replace(fullMatch, propertyValue);\n }\n \n return result;\n });\n};\n"],"mappings":";;AAQA,IAAa,qBAAqB,OAAY,WAAiB;AAC3D,KAAI,OAAO,UAAU,SACjB,QAAO,eAAe,OAAO,SAAS,GAAG,CAAC;CAI9C,MAAM,UAAU;CAChB,MAAM,UAAyB,EAAE;CACjC,IAAI;AAEJ,SAAQ,QAAQ,QAAQ,KAAK,MAAM,MAAM,KACrC,SAAQ,KAAK;EACT,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,OAAO,MAAM;EAChB,CAAC;AAIN,KAAI,QAAQ,WAAW,EACnB,QAAO,eAAe,MAAM;AAIhC,QAAO,eAAe;EAClB,IAAI,SAAS;AAGb,OAAK,IAAI,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;GAC1C,MAAM,EAAE,UAAU,cAAc,QAAQ;GAIxC,IAAI,gBAAgB;AACpB,OAAI;IACA,MAAM,eAAe,SAAS,MAAM,IAAI;IACxC,IAAI,eAAe;AAEnB,SAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;KAC1C,MAAM,OAAO,aAAa;AAG1B,SAAI,OAAO,iBAAiB,WACxB,gBAAe,cAAc;AAIjC,SAAI,gBAAgB,OAAO,iBAAiB,YAAY,QAAQ,aAC5D,gBAAe,aAAa;UACzB;AACH,qBAAe,KAAA;AACf;;;AAKR,QAAI,OAAO,iBAAiB,WACxB,gBAAe,cAAc;AAGjC,oBAAgB,gBAAgB,OAAO,OAAO,aAAa,GAAG;YACzD,OAAO;AAEZ,oBAAgB;;AAGpB,YAAS,OAAO,QAAQ,WAAW,cAAc;;AAGrD,SAAO;GACT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { parseDynamicValue } from "./parse-value.js";
|
|
2
|
+
import { Text, computed, h, useDefineProps, useProps } from "canvasengine";
|
|
3
|
+
//#region src/components/dynamics/text.ce
|
|
4
|
+
function component($$props) {
|
|
5
|
+
useProps($$props);
|
|
6
|
+
const defineProps = useDefineProps($$props);
|
|
7
|
+
var __assign = this && this.__assign || function() {
|
|
8
|
+
__assign = Object.assign || function(t) {
|
|
9
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
+
s = arguments[i];
|
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
return __assign.apply(this, arguments);
|
|
16
|
+
};
|
|
17
|
+
var object = defineProps().object;
|
|
18
|
+
var component = object._component;
|
|
19
|
+
var parseNumericStyleValue = function(value, object) {
|
|
20
|
+
if (value === void 0 || value === null) return;
|
|
21
|
+
if (typeof value === "number") return value;
|
|
22
|
+
if (typeof value === "string") if (value.includes("{")) {
|
|
23
|
+
var parsed_1 = parseDynamicValue(value, object);
|
|
24
|
+
return computed(function() {
|
|
25
|
+
var str = parsed_1();
|
|
26
|
+
var num = parseFloat(str);
|
|
27
|
+
return isNaN(num) ? 0 : num;
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
var num = parseFloat(value);
|
|
31
|
+
return isNaN(num) ? void 0 : num;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
var getComponentStyle = function(component) {
|
|
36
|
+
if (!component.style) return {};
|
|
37
|
+
var style = component.style;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (style.fill !== void 0) if (typeof style.fill === "string" && style.fill.includes("{")) result.color = parseDynamicValue(style.fill, object);
|
|
40
|
+
else result.color = style.fill;
|
|
41
|
+
if (style.fontSize !== void 0) {
|
|
42
|
+
var fontSizeValue = parseNumericStyleValue(style.fontSize, object);
|
|
43
|
+
if (fontSizeValue !== void 0) result.size = fontSizeValue;
|
|
44
|
+
}
|
|
45
|
+
if (style.fontFamily !== void 0) if (typeof style.fontFamily === "string" && style.fontFamily.includes("{")) result.fontFamily = parseDynamicValue(style.fontFamily, object);
|
|
46
|
+
else result.fontFamily = style.fontFamily;
|
|
47
|
+
var textStyle = {};
|
|
48
|
+
if (style.fontStyle !== void 0) if (typeof style.fontStyle === "string" && style.fontStyle.includes("{")) textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);
|
|
49
|
+
else textStyle.fontStyle = style.fontStyle;
|
|
50
|
+
if (style.fontWeight !== void 0) if (typeof style.fontWeight === "string" && style.fontWeight.includes("{")) textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);
|
|
51
|
+
else if (typeof style.fontWeight === "number") textStyle.fontWeight = style.fontWeight;
|
|
52
|
+
else textStyle.fontWeight = style.fontWeight;
|
|
53
|
+
if (style.stroke !== void 0) if (typeof style.stroke === "string" && style.stroke.includes("{")) textStyle.stroke = parseDynamicValue(style.stroke, object);
|
|
54
|
+
else textStyle.stroke = style.stroke;
|
|
55
|
+
if (style.opacity !== void 0) {
|
|
56
|
+
var opacityValue = parseNumericStyleValue(style.opacity, object);
|
|
57
|
+
if (opacityValue !== void 0) textStyle.opacity = opacityValue;
|
|
58
|
+
}
|
|
59
|
+
if (style.wordWrap !== void 0) textStyle.wordWrap = style.wordWrap;
|
|
60
|
+
if (style.align !== void 0) if (typeof style.align === "string" && style.align.includes("{")) textStyle.align = parseDynamicValue(style.align, object);
|
|
61
|
+
else textStyle.align = style.align;
|
|
62
|
+
if (Object.keys(textStyle).length > 0) result.style = textStyle;
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
return h(Text, {
|
|
66
|
+
text: computed(() => parseDynamicValue(component.value, object)),
|
|
67
|
+
...getComponentStyle(component)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { component as default };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=text.ce.js.map
|