@rpgjs/client 5.0.0-alpha.21 → 5.0.0-alpha.22
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/Object.d.ts +109 -0
- package/dist/RpgClientEngine.d.ts +111 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index10.js +1 -1
- package/dist/index15.js +42 -3
- package/dist/index15.js.map +1 -1
- package/dist/index19.js.map +1 -1
- package/dist/index2.js +142 -2
- package/dist/index2.js.map +1 -1
- package/dist/index20.js +15 -2
- package/dist/index20.js.map +1 -1
- package/dist/index23.js.map +1 -1
- package/dist/index26.js +2 -2
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +2 -2
- package/dist/index27.js.map +1 -1
- package/dist/index34.js.map +1 -1
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +8 -1
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +1 -1
- package/dist/index38.js +1 -1
- package/dist/index40.js +6 -6
- package/dist/index41.js +320 -3681
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +3686 -183
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +71 -498
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +182 -72
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +500 -2
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +3 -17
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +16 -142
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +206 -8
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +7 -108
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +104 -127
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +122 -123
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +123 -98
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +107 -136
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +139 -7
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +7 -52
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +54 -0
- package/dist/index56.js.map +1 -0
- package/dist/index8.js +8 -0
- package/dist/index8.js.map +1 -1
- package/dist/module.d.ts +43 -4
- package/dist/services/keyboardControls.d.ts +13 -2
- package/dist/services/mmorpg.d.ts +1 -1
- package/dist/services/standalone.d.ts +1 -1
- package/package.json +11 -10
- package/src/Game/Object.ts +82 -8
- package/src/RpgClientEngine.ts +173 -2
- package/src/components/character.ce +67 -4
- package/src/components/prebuilt/index.ts +1 -0
- package/src/components/scenes/draw-map.ce +12 -3
- package/src/index.ts +2 -1
- package/src/module.ts +56 -2
- package/src/services/keyboardControls.ts +13 -1
package/dist/index53.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index53.js","sources":["../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={@parseDynamicValue(@component.@value, @object)} ...getComponentStyle(component) />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { parseDynamicValue } from \"./parse-value\";\n\nconst { object } = defineProps();\nconst component = object._component;\n\n/**\n * Parses a numeric style value that can be a number or a string\n * \n * If the value is a string, it may contain dynamic references like {hp}\n * which need to be parsed using parseDynamicValue. If it's a number,\n * it's returned as-is wrapped in a computed.\n * \n * @param value - Numeric value (number or string)\n * @param object - Object to resolve dynamic references from\n * @returns Computed signal with the numeric value\n */\nconst parseNumericStyleValue = (value, object) => {\n if (value === undefined || value === null) {\n return undefined;\n }\n \n if (typeof value === 'number') {\n return value;\n }\n \n if (typeof value === 'string') {\n // Check if it contains dynamic references\n if (value.includes('{')) {\n // Parse dynamic value and convert to number\n const parsed = parseDynamicValue(value, object);\n return computed(() => {\n const str = parsed();\n const num = parseFloat(str);\n return isNaN(num) ? 0 : num;\n });\n } else {\n // Simple string number, convert directly\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n }\n }\n \n return value;\n};\n\n/**\n * Maps component style properties to Canvas Engine Text component props\n * \n * Converts TextComponentOptions from the server to the format expected\n * by the Canvas Engine Text component. Supports all text styling properties\n * including fill, fontSize, fontFamily, fontStyle, fontWeight, stroke,\n * opacity, wordWrap, and align. Also supports dynamic values (number | string)\n * for numeric properties like fontSize and opacity.\n * \n * @param component - Component definition with style property\n * @returns Object with Text component props\n * \n * @example\n * ```ts\n * // Component with style\n * const component = {\n * style: {\n * fill: '#000000',\n * fontSize: 20,\n * fontFamily: 'Arial',\n * fontWeight: 'bold'\n * }\n * };\n * \n * const props = getComponentStyle(component);\n * // Returns: { color: '#000000', size: 20, fontFamily: 'Arial', style: { fontWeight: 'bold' } }\n * \n * // Component with dynamic fontSize\n * const component2 = {\n * style: {\n * fill: '#000000',\n * fontSize: '{hp}', // Will be resolved from object.hp\n * opacity: '0.8'\n * }\n * };\n * ```\n */\nconst getComponentStyle = (component) => {\n if (!component.style) {\n return {};\n }\n\n const style = component.style;\n const result = {};\n\n // Map fill to color (shortcut property)\n // fill can be a string (hex color) or a dynamic string\n if (style.fill !== undefined) {\n if (typeof style.fill === 'string' && style.fill.includes('{')) {\n result.color = parseDynamicValue(style.fill, object);\n } else {\n result.color = style.fill;\n }\n }\n\n // Map fontSize to size (shortcut property)\n // fontSize can be number or string (with dynamic references)\n if (style.fontSize !== undefined) {\n const fontSizeValue = parseNumericStyleValue(style.fontSize, object);\n if (fontSizeValue !== undefined) {\n result.size = fontSizeValue;\n }\n }\n\n // Map fontFamily (shortcut property)\n if (style.fontFamily !== undefined) {\n if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {\n result.fontFamily = parseDynamicValue(style.fontFamily, object);\n } else {\n result.fontFamily = style.fontFamily;\n }\n }\n\n // Build style object for PixiJS Text properties\n const textStyle = {};\n\n // Font style properties\n if (style.fontStyle !== undefined) {\n if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {\n textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);\n } else {\n textStyle.fontStyle = style.fontStyle;\n }\n }\n\n if (style.fontWeight !== undefined) {\n if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {\n textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);\n } else if (typeof style.fontWeight === 'number') {\n textStyle.fontWeight = style.fontWeight;\n } else {\n textStyle.fontWeight = style.fontWeight;\n }\n }\n\n // Stroke properties\n if (style.stroke !== undefined) {\n if (typeof style.stroke === 'string' && style.stroke.includes('{')) {\n textStyle.stroke = parseDynamicValue(style.stroke, object);\n } else {\n textStyle.stroke = style.stroke;\n }\n }\n\n // Opacity (can be number or string)\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n // Word wrap\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n // Text alignment\n if (style.align !== undefined) {\n if (typeof style.align === 'string' && style.align.includes('{')) {\n textStyle.align = parseDynamicValue(style.align, object);\n } else {\n textStyle.align = style.align;\n }\n }\n\n // Only add style prop if there are style properties\n if (Object.keys(textStyle).length > 0) {\n result.style = textStyle;\n }\n\n return result;\n}\n</script>"],"names":[],"mappings":";;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,QAAQ,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY;AAC9D,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,EAAE;AAC5C,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC7D,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAC5B,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAA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":["import { ZodIssueCode } from \"../ZodError.js\";\nimport { util, ZodParsedType } from \"../helpers/util.js\";\nconst errorMap = (issue, _ctx) => {\n let message;\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n if (issue.received === ZodParsedType.undefined) {\n message = \"Required\";\n }\n else {\n message = `Expected ${issue.expected}, received ${issue.received}`;\n }\n break;\n case ZodIssueCode.invalid_literal:\n message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n break;\n case ZodIssueCode.unrecognized_keys:\n message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, \", \")}`;\n break;\n case ZodIssueCode.invalid_union:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_union_discriminator:\n message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n break;\n case ZodIssueCode.invalid_enum_value:\n message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;\n break;\n case ZodIssueCode.invalid_arguments:\n message = `Invalid function arguments`;\n break;\n case ZodIssueCode.invalid_return_type:\n message = `Invalid function return type`;\n break;\n case ZodIssueCode.invalid_date:\n message = `Invalid date`;\n break;\n case ZodIssueCode.invalid_string:\n if (typeof issue.validation === \"object\") {\n if (\"includes\" in issue.validation) {\n message = `Invalid input: must include \"${issue.validation.includes}\"`;\n if (typeof issue.validation.position === \"number\") {\n message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n }\n }\n else if (\"startsWith\" in issue.validation) {\n message = `Invalid input: must start with \"${issue.validation.startsWith}\"`;\n }\n else if (\"endsWith\" in issue.validation) {\n message = `Invalid input: must end with \"${issue.validation.endsWith}\"`;\n }\n else {\n util.assertNever(issue.validation);\n }\n }\n else if (issue.validation !== \"regex\") {\n message = `Invalid ${issue.validation}`;\n }\n else {\n message = \"Invalid\";\n }\n break;\n case ZodIssueCode.too_small:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? \"exactly\" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === \"bigint\")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.too_big:\n if (issue.type === \"array\")\n message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n else if (issue.type === \"string\")\n message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n else if (issue.type === \"number\")\n message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === \"bigint\")\n message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === \"date\")\n message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;\n else\n message = \"Invalid input\";\n break;\n case ZodIssueCode.custom:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_intersection_types:\n message = `Intersection results could not be merged`;\n break;\n case ZodIssueCode.not_multiple_of:\n message = `Number must be a multiple of ${issue.multipleOf}`;\n break;\n case ZodIssueCode.not_finite:\n message = \"Number must be finite\";\n break;\n default:\n message = _ctx.defaultError;\n util.assertNever(issue);\n }\n return { message };\n};\nexport default errorMap;\n"],"names":[],"mappings":";;;AAEK,MAAC,QAAQ,GAAG,CAAC,KAAK,EAAE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e,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;AAChJ,iBAAiB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;AAC1C,gBAAgB,OAAO,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,wBAAwB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACtK;AACA,gBAAgB,OAAO,GAAG,eAAe;AACzC,YAAY;AACZ,QAAQ,KAAK,YAAY,CAAC,MAAM;AAChC,YAAY,OAAO,GAAG,CAAC,aAAa,CAAC;AACrC,YAAY;AACZ,QAAQ,KAAK,YAAY,CAAC,0BAA0B;AACpD,YAAY,OAAO,GAAG,CAAC,wCAAwC,CAAC;AAChE,YAAY;AACZ,QAAQ,KAAK,YAAY,CAAC,eAAe;AACzC,YAAY,OAAO,GAAG,CAAC,6BAA6B,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;AACxE,YAAY;AACZ,QAAQ,KAAK,YAAY,CAAC,UAAU;AACpC,YAAY,OAAO,GAAG,uBAAuB;AAC7C,YAAY;AACZ,QAAQ;AACR,YAAY,OAAO,GAAG,IAAI,CAAC,YAAY;AACvC,YAAY,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AACnC;AACA,IAAI,OAAO,EAAE,OAAO,EAAE;AACtB;;;;","x_google_ignoreList":[0]}
|
package/dist/index54.js
CHANGED
|
@@ -1,9 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4
|
-
// biome-ignore lint:
|
|
5
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
6
|
-
})(errorUtil || (errorUtil = {}));
|
|
1
|
+
import { useProps, useDefineProps, h, Text, computed } from 'canvasengine';
|
|
2
|
+
import { parseDynamicValue } from './index56.js';
|
|
7
3
|
|
|
8
|
-
|
|
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))
|
|
12
|
+
t[p] = s[p];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
return __assign.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
var object = defineProps().object;
|
|
19
|
+
var component = object._component;
|
|
20
|
+
var parseNumericStyleValue = function (value, object) {
|
|
21
|
+
if (value === undefined || value === null) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value === 'number') {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'string') {
|
|
28
|
+
// Check if it contains dynamic references
|
|
29
|
+
if (value.includes('{')) {
|
|
30
|
+
// Parse dynamic value and convert to number
|
|
31
|
+
var parsed_1 = parseDynamicValue(value, object);
|
|
32
|
+
return computed(function () {
|
|
33
|
+
var str = parsed_1();
|
|
34
|
+
var num = parseFloat(str);
|
|
35
|
+
return isNaN(num) ? 0 : num;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Simple string number, convert directly
|
|
40
|
+
var num = parseFloat(value);
|
|
41
|
+
return isNaN(num) ? undefined : num;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
var getComponentStyle = function (component) {
|
|
47
|
+
if (!component.style) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
var style = component.style;
|
|
51
|
+
var result = {};
|
|
52
|
+
// Map fill to color (shortcut property)
|
|
53
|
+
// fill can be a string (hex color) or a dynamic string
|
|
54
|
+
if (style.fill !== undefined) {
|
|
55
|
+
if (typeof style.fill === 'string' && style.fill.includes('{')) {
|
|
56
|
+
result.color = parseDynamicValue(style.fill, object);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
result.color = style.fill;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Map fontSize to size (shortcut property)
|
|
63
|
+
// fontSize can be number or string (with dynamic references)
|
|
64
|
+
if (style.fontSize !== undefined) {
|
|
65
|
+
var fontSizeValue = parseNumericStyleValue(style.fontSize, object);
|
|
66
|
+
if (fontSizeValue !== undefined) {
|
|
67
|
+
result.size = fontSizeValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Map fontFamily (shortcut property)
|
|
71
|
+
if (style.fontFamily !== undefined) {
|
|
72
|
+
if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {
|
|
73
|
+
result.fontFamily = parseDynamicValue(style.fontFamily, object);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
result.fontFamily = style.fontFamily;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Build style object for PixiJS Text properties
|
|
80
|
+
var textStyle = {};
|
|
81
|
+
// Font style properties
|
|
82
|
+
if (style.fontStyle !== undefined) {
|
|
83
|
+
if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {
|
|
84
|
+
textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
textStyle.fontStyle = style.fontStyle;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (style.fontWeight !== undefined) {
|
|
91
|
+
if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {
|
|
92
|
+
textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);
|
|
93
|
+
}
|
|
94
|
+
else if (typeof style.fontWeight === 'number') {
|
|
95
|
+
textStyle.fontWeight = style.fontWeight;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
textStyle.fontWeight = style.fontWeight;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Stroke properties
|
|
102
|
+
if (style.stroke !== undefined) {
|
|
103
|
+
if (typeof style.stroke === 'string' && style.stroke.includes('{')) {
|
|
104
|
+
textStyle.stroke = parseDynamicValue(style.stroke, object);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
textStyle.stroke = style.stroke;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Opacity (can be number or string)
|
|
111
|
+
if (style.opacity !== undefined) {
|
|
112
|
+
var opacityValue = parseNumericStyleValue(style.opacity, object);
|
|
113
|
+
if (opacityValue !== undefined) {
|
|
114
|
+
textStyle.opacity = opacityValue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Word wrap
|
|
118
|
+
if (style.wordWrap !== undefined) {
|
|
119
|
+
textStyle.wordWrap = style.wordWrap;
|
|
120
|
+
}
|
|
121
|
+
// Text alignment
|
|
122
|
+
if (style.align !== undefined) {
|
|
123
|
+
if (typeof style.align === 'string' && style.align.includes('{')) {
|
|
124
|
+
textStyle.align = parseDynamicValue(style.align, object);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
textStyle.align = style.align;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Only add style prop if there are style properties
|
|
131
|
+
if (Object.keys(textStyle).length > 0) {
|
|
132
|
+
result.style = textStyle;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
};
|
|
136
|
+
let $this = h(Text, { text: parseDynamicValue(component.value, object), ...getComponentStyle(component) });
|
|
137
|
+
return $this
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { component as default };
|
|
9
141
|
//# sourceMappingURL=index54.js.map
|
package/dist/index54.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index54.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js"],"sourcesContent":["export var errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n // biome-ignore lint:\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n"],"names":[],"mappings":"AAAU,IAAC;AACX,CAAC,UAAU,SAAS,EAAE;AACtB,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE;AAC/F;AACA,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,OAAO;AAC9F,CAAC,EAAE,SAAS,KAAK,SAAS,GAAG,EAAE,CAAC,CAAC;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index54.js","sources":["../src/components/dynamics/text.ce"],"sourcesContent":["<Text text={@parseDynamicValue(@component.@value, @object)} ...getComponentStyle(component) />\n\n<script>\nimport { computed } from \"canvasengine\";\nimport { parseDynamicValue } from \"./parse-value\";\n\nconst { object } = defineProps();\nconst component = object._component;\n\n/**\n * Parses a numeric style value that can be a number or a string\n * \n * If the value is a string, it may contain dynamic references like {hp}\n * which need to be parsed using parseDynamicValue. If it's a number,\n * it's returned as-is wrapped in a computed.\n * \n * @param value - Numeric value (number or string)\n * @param object - Object to resolve dynamic references from\n * @returns Computed signal with the numeric value\n */\nconst parseNumericStyleValue = (value, object) => {\n if (value === undefined || value === null) {\n return undefined;\n }\n \n if (typeof value === 'number') {\n return value;\n }\n \n if (typeof value === 'string') {\n // Check if it contains dynamic references\n if (value.includes('{')) {\n // Parse dynamic value and convert to number\n const parsed = parseDynamicValue(value, object);\n return computed(() => {\n const str = parsed();\n const num = parseFloat(str);\n return isNaN(num) ? 0 : num;\n });\n } else {\n // Simple string number, convert directly\n const num = parseFloat(value);\n return isNaN(num) ? undefined : num;\n }\n }\n \n return value;\n};\n\n/**\n * Maps component style properties to Canvas Engine Text component props\n * \n * Converts TextComponentOptions from the server to the format expected\n * by the Canvas Engine Text component. Supports all text styling properties\n * including fill, fontSize, fontFamily, fontStyle, fontWeight, stroke,\n * opacity, wordWrap, and align. Also supports dynamic values (number | string)\n * for numeric properties like fontSize and opacity.\n * \n * @param component - Component definition with style property\n * @returns Object with Text component props\n * \n * @example\n * ```ts\n * // Component with style\n * const component = {\n * style: {\n * fill: '#000000',\n * fontSize: 20,\n * fontFamily: 'Arial',\n * fontWeight: 'bold'\n * }\n * };\n * \n * const props = getComponentStyle(component);\n * // Returns: { color: '#000000', size: 20, fontFamily: 'Arial', style: { fontWeight: 'bold' } }\n * \n * // Component with dynamic fontSize\n * const component2 = {\n * style: {\n * fill: '#000000',\n * fontSize: '{hp}', // Will be resolved from object.hp\n * opacity: '0.8'\n * }\n * };\n * ```\n */\nconst getComponentStyle = (component) => {\n if (!component.style) {\n return {};\n }\n\n const style = component.style;\n const result = {};\n\n // Map fill to color (shortcut property)\n // fill can be a string (hex color) or a dynamic string\n if (style.fill !== undefined) {\n if (typeof style.fill === 'string' && style.fill.includes('{')) {\n result.color = parseDynamicValue(style.fill, object);\n } else {\n result.color = style.fill;\n }\n }\n\n // Map fontSize to size (shortcut property)\n // fontSize can be number or string (with dynamic references)\n if (style.fontSize !== undefined) {\n const fontSizeValue = parseNumericStyleValue(style.fontSize, object);\n if (fontSizeValue !== undefined) {\n result.size = fontSizeValue;\n }\n }\n\n // Map fontFamily (shortcut property)\n if (style.fontFamily !== undefined) {\n if (typeof style.fontFamily === 'string' && style.fontFamily.includes('{')) {\n result.fontFamily = parseDynamicValue(style.fontFamily, object);\n } else {\n result.fontFamily = style.fontFamily;\n }\n }\n\n // Build style object for PixiJS Text properties\n const textStyle = {};\n\n // Font style properties\n if (style.fontStyle !== undefined) {\n if (typeof style.fontStyle === 'string' && style.fontStyle.includes('{')) {\n textStyle.fontStyle = parseDynamicValue(style.fontStyle, object);\n } else {\n textStyle.fontStyle = style.fontStyle;\n }\n }\n\n if (style.fontWeight !== undefined) {\n if (typeof style.fontWeight === 'string' && style.fontWeight.includes('{')) {\n textStyle.fontWeight = parseDynamicValue(style.fontWeight, object);\n } else if (typeof style.fontWeight === 'number') {\n textStyle.fontWeight = style.fontWeight;\n } else {\n textStyle.fontWeight = style.fontWeight;\n }\n }\n\n // Stroke properties\n if (style.stroke !== undefined) {\n if (typeof style.stroke === 'string' && style.stroke.includes('{')) {\n textStyle.stroke = parseDynamicValue(style.stroke, object);\n } else {\n textStyle.stroke = style.stroke;\n }\n }\n\n // Opacity (can be number or string)\n if (style.opacity !== undefined) {\n const opacityValue = parseNumericStyleValue(style.opacity, object);\n if (opacityValue !== undefined) {\n textStyle.opacity = opacityValue;\n }\n }\n\n // Word wrap\n if (style.wordWrap !== undefined) {\n textStyle.wordWrap = style.wordWrap;\n }\n\n // Text alignment\n if (style.align !== undefined) {\n if (typeof style.align === 'string' && style.align.includes('{')) {\n textStyle.align = parseDynamicValue(style.align, object);\n } else {\n textStyle.align = style.align;\n }\n }\n\n // Only add style prop if there are style properties\n if (Object.keys(textStyle).length > 0) {\n result.style = textStyle;\n }\n\n return result;\n}\n</script>"],"names":[],"mappings":";;;AAOqB,SAAS,SAAS,CAAC,OAAO,EAAE;AACjD,QAAuB,QAAQ,CAAC,OAAO;AACvC,QAAQ,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO;AAClD,QAAQ,IAAI,QAAQ,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY;AAC9D,IAAI,QAAQ,GAAG,MAAM,CAAC,MAA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,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,iBAAiB,CAAC,SAAS,CAAC,EAAE;AACjH,QAAQ,OAAO;AACf,MAAM;;;;"}
|
package/dist/index55.js
CHANGED
|
@@ -1,54 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
var errorUtil;
|
|
2
|
+
(function (errorUtil) {
|
|
3
|
+
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
4
|
+
// biome-ignore lint:
|
|
5
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
6
|
+
})(errorUtil || (errorUtil = {}));
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
if (typeof value !== "string") {
|
|
5
|
-
return computed(() => String(value ?? ""));
|
|
6
|
-
}
|
|
7
|
-
const pattern = /\{([^}]+)\}/g;
|
|
8
|
-
const matches = [];
|
|
9
|
-
let match;
|
|
10
|
-
while ((match = pattern.exec(value)) !== null) {
|
|
11
|
-
matches.push({
|
|
12
|
-
property: match[1],
|
|
13
|
-
fullMatch: match[0],
|
|
14
|
-
index: match.index
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (matches.length === 0) {
|
|
18
|
-
return computed(() => value);
|
|
19
|
-
}
|
|
20
|
-
return computed(() => {
|
|
21
|
-
let result = value;
|
|
22
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
23
|
-
const { property, fullMatch } = matches[i];
|
|
24
|
-
let propertyValue = "";
|
|
25
|
-
try {
|
|
26
|
-
const propertyPath = property.split(".");
|
|
27
|
-
let currentValue = object;
|
|
28
|
-
for (let j = 0; j < propertyPath.length; j++) {
|
|
29
|
-
const prop = propertyPath[j];
|
|
30
|
-
if (typeof currentValue === "function") {
|
|
31
|
-
currentValue = currentValue();
|
|
32
|
-
}
|
|
33
|
-
if (currentValue && typeof currentValue === "object" && prop in currentValue) {
|
|
34
|
-
currentValue = currentValue[prop];
|
|
35
|
-
} else {
|
|
36
|
-
currentValue = void 0;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (typeof currentValue === "function") {
|
|
41
|
-
currentValue = currentValue();
|
|
42
|
-
}
|
|
43
|
-
propertyValue = currentValue != null ? String(currentValue) : "";
|
|
44
|
-
} catch (error) {
|
|
45
|
-
propertyValue = "";
|
|
46
|
-
}
|
|
47
|
-
result = result.replace(fullMatch, propertyValue);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { parseDynamicValue };
|
|
8
|
+
export { errorUtil };
|
|
54
9
|
//# sourceMappingURL=index55.js.map
|
package/dist/index55.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index55.js","sources":["
|
|
1
|
+
{"version":3,"file":"index55.js","sources":["../../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js"],"sourcesContent":["export var errorUtil;\n(function (errorUtil) {\n errorUtil.errToObj = (message) => typeof message === \"string\" ? { message } : message || {};\n // biome-ignore lint:\n errorUtil.toString = (message) => typeof message === \"string\" ? message : message?.message;\n})(errorUtil || (errorUtil = {}));\n"],"names":[],"mappings":"AAAU,IAAC;AACX,CAAC,UAAU,SAAS,EAAE;AACtB,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE;AAC/F;AACA,IAAI,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,OAAO;AAC9F,CAAC,EAAE,SAAS,KAAK,SAAS,GAAG,EAAE,CAAC,CAAC;;;;","x_google_ignoreList":[0]}
|
package/dist/index56.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { computed } from 'canvasengine';
|
|
2
|
+
|
|
3
|
+
const parseDynamicValue = (value, object) => {
|
|
4
|
+
if (typeof value !== "string") {
|
|
5
|
+
return computed(() => String(value ?? ""));
|
|
6
|
+
}
|
|
7
|
+
const pattern = /\{([^}]+)\}/g;
|
|
8
|
+
const matches = [];
|
|
9
|
+
let match;
|
|
10
|
+
while ((match = pattern.exec(value)) !== null) {
|
|
11
|
+
matches.push({
|
|
12
|
+
property: match[1],
|
|
13
|
+
fullMatch: match[0],
|
|
14
|
+
index: match.index
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (matches.length === 0) {
|
|
18
|
+
return computed(() => value);
|
|
19
|
+
}
|
|
20
|
+
return computed(() => {
|
|
21
|
+
let result = value;
|
|
22
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
23
|
+
const { property, fullMatch } = matches[i];
|
|
24
|
+
let propertyValue = "";
|
|
25
|
+
try {
|
|
26
|
+
const propertyPath = property.split(".");
|
|
27
|
+
let currentValue = object;
|
|
28
|
+
for (let j = 0; j < propertyPath.length; j++) {
|
|
29
|
+
const prop = propertyPath[j];
|
|
30
|
+
if (typeof currentValue === "function") {
|
|
31
|
+
currentValue = currentValue();
|
|
32
|
+
}
|
|
33
|
+
if (currentValue && typeof currentValue === "object" && prop in currentValue) {
|
|
34
|
+
currentValue = currentValue[prop];
|
|
35
|
+
} else {
|
|
36
|
+
currentValue = void 0;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (typeof currentValue === "function") {
|
|
41
|
+
currentValue = currentValue();
|
|
42
|
+
}
|
|
43
|
+
propertyValue = currentValue != null ? String(currentValue) : "";
|
|
44
|
+
} catch (error) {
|
|
45
|
+
propertyValue = "";
|
|
46
|
+
}
|
|
47
|
+
result = result.replace(fullMatch, propertyValue);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { parseDynamicValue };
|
|
54
|
+
//# sourceMappingURL=index56.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index56.js","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"],"names":[],"mappings":";;AAQO,MAAM,iBAAA,GAAoB,CAAC,KAAA,EAAY,MAAA,KAAiB;AAC3D,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;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IAAgB,OAAO,YAAA,KAAiB,QAAA,IAAY,QAAQ,YAAA,EAAc;AAC1E,YAAA,YAAA,GAAe,aAAa,IAAI,CAAA;AAAA,UACpC,CAAA,MAAO;AACH,YAAA,YAAA,GAAe,KAAA,CAAA;AACf,YAAA;AAAA,UACJ;AAAA,QACJ;AAGA,QAAA,IAAI,OAAO,iBAAiB,UAAA,EAAY;AACpC,UAAA,YAAA,GAAe,YAAA,EAAa;AAAA,QAChC;AAEA,QAAA,aAAA,GAAgB,YAAA,IAAgB,IAAA,GAAO,MAAA,CAAO,YAAY,CAAA,GAAI,EAAA;AAAA,MAClE,SAAS,KAAA,EAAO;AAEZ,QAAA,aAAA,GAAgB,EAAA;AAAA,MACpB;AAEA,MAAA,MAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,SAAA,EAAW,aAAa,CAAA;AAAA,IACpD;AAEA,IAAA,OAAO,MAAA;AAAA,EACX,CAAC,CAAA;AACL;;;;"}
|
package/dist/index8.js
CHANGED
|
@@ -8,6 +8,14 @@ function provideClientModules(modules) {
|
|
|
8
8
|
const mainModuleClient = findModules(context, "Client");
|
|
9
9
|
modules2 = [...mainModuleClient, ...modules2];
|
|
10
10
|
modules2 = modules2.map((module) => {
|
|
11
|
+
if (typeof module === "function") {
|
|
12
|
+
const instance = new module();
|
|
13
|
+
const moduleObj = {};
|
|
14
|
+
for (const key in instance) {
|
|
15
|
+
moduleObj[key] = instance[key];
|
|
16
|
+
}
|
|
17
|
+
module = moduleObj;
|
|
18
|
+
}
|
|
11
19
|
if ("client" in module) {
|
|
12
20
|
module = module.client;
|
|
13
21
|
}
|
package/dist/index8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\nimport { getSoundMetadata } from \"./Sound\";\n\nexport function provideClientModules(modules: RpgClient[]) {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.spritesheetResolver) {\n const resolver = module.spritesheetResolver;\n module.spritesheetResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSpritesheetResolver(resolver);\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n // Check if it's a class decorated with @Sound\n if (typeof sound === 'function' || (sound && sound.constructor && sound.constructor !== Object)) {\n const metadata = getSoundMetadata(sound);\n if (metadata) {\n // Handle single sound\n if (metadata.id && metadata.sound) {\n engine.addSound({\n id: metadata.id,\n src: metadata.sound,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n }\n // Handle multiple sounds\n if (metadata.sounds) {\n Object.entries(metadata.sounds).forEach(([soundId, soundSrc]) => {\n engine.addSound({\n id: soundId,\n src: soundSrc,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n });\n }\n } else {\n // Not a decorated class, treat as regular sound object\n engine.addSound(sound);\n }\n } else {\n // Regular sound object\n engine.addSound(sound);\n }\n });\n },\n };\n }\n if (module.soundResolver) {\n const resolver = module.soundResolver;\n module.soundResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSoundResolver(resolver);\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui);\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.componentAnimations) {\n const componentAnimations = [...module.componentAnimations];\n module.componentAnimations = {\n load: (engine: RpgClientEngine) => {\n componentAnimations.forEach((componentAnimation) => {\n engine.addComponentAnimation(componentAnimation);\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n if (module.sprite) {\n const sprite = {...module.sprite};\n module.sprite = {\n ...sprite,\n load: (engine: RpgClientEngine) => {\n if (sprite.componentsBehind) {\n sprite.componentsBehind.forEach((component) => {\n engine.addSpriteComponentBehind(component);\n });\n }\n if (sprite.componentsInFront) {\n sprite.componentsInFront.forEach((component) => {\n engine.addSpriteComponentInFront(component);\n });\n }\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"names":["modules","gui"],"mappings":";;;;;AAOO,SAAS,qBAAqB,OAAA,EAAsB;AACzD,EAAA,OAAO,cAAA,CAAe,OAAA,EAAS,QAAA,EAAU,CAACA,UAAS,OAAA,KAAY;AAC7D,IAAA,MAAM,gBAAA,GAAmB,WAAA,CAAY,OAAA,EAAS,QAAQ,CAAA;AACtD,IAAAA,QAAAA,GAAU,CAAC,GAAG,gBAAA,EAAkB,GAAGA,QAAO,CAAA;AAC1C,IAAAA,QAAAA,GAAUA,QAAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,KAAW;AAChC,MAAA,IAAI,YAAY,MAAA,EAAQ;AACtB,QAAA,MAAA,GAAS,MAAA,CAAO,MAAA;AAAA,MAClB;AACA,MAAA,IAAI,OAAO,YAAA,EAAc;AACvB,QAAA,MAA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O,0BAA0B,SAAS,CAAA;AAAA,cAC5C,CAAC,CAAA;AAAA,YACH;AAAA,UACF;AAAA,SACF;AAAA,MACF;AACA,MAAA,OAAO,MAAA;AAAA,IACT,CAAC,CAAA;AACD,IAAA,OAAOD,QAAAA;AAAA,EACT,CAAC,CAAA;AACH;AAEO,MAAM,iBAAA,GAAoB;AAE1B,SAAS,oBAAoB,MAAA,EAAa;AAC/C,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,iBAAA;AAAA,IACT,QAAA,EAAU,UAAU;AAAC,GACvB;AACF;AAEO,SAAS,yBAAA,CAA0B,MAAA,GAAc,EAAC,EAAG;AAC1D,EAAA,IAAI,CAAC,OAAO,gBAAA,EAAkB;AAC5B,IAAA,MAAA,CAAO,gBAAA,GAAmB;AAAA,MACxB,EAAA,EAAI,IAAA;AAAA,MACJ,IAAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,OAAA;AAAA,MACP,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AACA,EAAA,OAAO,oBAAoB,MAAM,CAAA;AACnC;;;;"}
|
|
1
|
+
{"version":3,"file":"index8.js","sources":["../src/module.ts"],"sourcesContent":["import { findModules, provideModules } from \"@rpgjs/common\";\nimport { FactoryProvider } from \"@signe/di\";\nimport { RpgClientEngine } from \"./RpgClientEngine\";\nimport { RpgClient } from \"./RpgClient\";\nimport { inject } from \"@signe/di\";\nimport { RpgGui } from \"./Gui/Gui\";\nimport { getSoundMetadata } from \"./Sound\";\n\n/**\n * Type for client modules that can be either:\n * - An object implementing RpgClient interface\n * - A class decorated with @RpgModule decorator\n */\nexport type RpgClientModule = RpgClient | (new () => any);\n\n/**\n * Provides client modules configuration to Dependency Injection\n * \n * This function accepts an array of client modules that can be either:\n * - Objects implementing the RpgClient interface\n * - Classes decorated with the @RpgModule decorator (which will be instantiated)\n * \n * @param modules - Array of client modules (objects or classes)\n * @returns FactoryProvider configuration for DI\n * @example\n * ```ts\n * // Using an object\n * provideClientModules([\n * {\n * engine: {\n * onConnected(engine) {\n * console.log('Client connected')\n * }\n * }\n * }\n * ])\n * \n * // Using a decorated class\n * @RpgModule<RpgClient>({\n * engine: {\n * onStart(engine) {\n * console.log('Client started')\n * }\n * }\n * })\n * class MyClientModule {}\n * \n * provideClientModules([MyClientModule])\n * ```\n */\nexport function provideClientModules(modules: RpgClientModule[]): FactoryProvider {\n return provideModules(modules, \"client\", (modules, context) => {\n const mainModuleClient = findModules(context, 'Client')\n modules = [...mainModuleClient, ...modules]\n modules = modules.map((module) => {\n // If module is a class (constructor function), instantiate it\n // The RpgModule decorator adds properties to the prototype, which will be accessible via the instance\n if (typeof module === 'function') {\n const instance = new module() as any;\n // Copy all enumerable properties (including from prototype) to a plain object\n const moduleObj: any = {};\n for (const key in instance) {\n moduleObj[key] = instance[key];\n }\n module = moduleObj;\n }\n if ('client' in module) {\n module = module.client as any;\n }\n if (module.spritesheets) {\n const spritesheets = [...module.spritesheets];\n module.spritesheets = {\n load: (engine: RpgClientEngine) => {\n spritesheets.forEach((spritesheet) => {\n engine.addSpriteSheet(spritesheet);\n });\n },\n };\n }\n if (module.spritesheetResolver) {\n const resolver = module.spritesheetResolver;\n module.spritesheetResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSpritesheetResolver(resolver);\n },\n };\n }\n if (module.sounds) {\n const sounds = [...module.sounds];\n module.sounds = {\n load: (engine: RpgClientEngine) => {\n sounds.forEach((sound) => {\n // Check if it's a class decorated with @Sound\n if (typeof sound === 'function' || (sound && sound.constructor && sound.constructor !== Object)) {\n const metadata = getSoundMetadata(sound);\n if (metadata) {\n // Handle single sound\n if (metadata.id && metadata.sound) {\n engine.addSound({\n id: metadata.id,\n src: metadata.sound,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n }\n // Handle multiple sounds\n if (metadata.sounds) {\n Object.entries(metadata.sounds).forEach(([soundId, soundSrc]) => {\n engine.addSound({\n id: soundId,\n src: soundSrc,\n loop: metadata.loop,\n volume: metadata.volume,\n });\n });\n }\n } else {\n // Not a decorated class, treat as regular sound object\n engine.addSound(sound);\n }\n } else {\n // Regular sound object\n engine.addSound(sound);\n }\n });\n },\n };\n }\n if (module.soundResolver) {\n const resolver = module.soundResolver;\n module.soundResolver = {\n load: (engine: RpgClientEngine) => {\n engine.setSoundResolver(resolver);\n },\n };\n }\n if (module.gui) {\n const gui = [...module.gui];\n module.gui = {\n load: (engine: RpgClientEngine) => {\n const guiService = inject(engine.context, RpgGui) as RpgGui;\n gui.forEach((gui) => {\n guiService.add(gui);\n });\n },\n };\n }\n if (module.componentAnimations) {\n const componentAnimations = [...module.componentAnimations];\n module.componentAnimations = {\n load: (engine: RpgClientEngine) => {\n componentAnimations.forEach((componentAnimation) => {\n engine.addComponentAnimation(componentAnimation);\n });\n },\n };\n }\n if (module.particles) {\n const particles = [...module.particles];\n module.particles = {\n load: (engine: RpgClientEngine) => {\n particles.forEach((particle) => {\n engine.addParticle(particle);\n });\n },\n };\n }\n if (module.sprite) {\n const sprite = {...module.sprite};\n module.sprite = {\n ...sprite,\n load: (engine: RpgClientEngine) => {\n if (sprite.componentsBehind) {\n sprite.componentsBehind.forEach((component) => {\n engine.addSpriteComponentBehind(component);\n });\n }\n if (sprite.componentsInFront) {\n sprite.componentsInFront.forEach((component) => {\n engine.addSpriteComponentInFront(component);\n });\n }\n },\n };\n }\n return module;\n });\n return modules\n });\n}\n\nexport const GlobalConfigToken = \"GlobalConfigToken\";\n\nexport function provideGlobalConfig(config: any) {\n return {\n provide: GlobalConfigToken,\n useValue: config ?? {},\n };\n}\n\nexport function provideClientGlobalConfig(config: any = {}) {\n if (!config.keyboardControls) {\n config.keyboardControls = {\n up: 'up',\n down: 'down',\n left: 'left',\n right: 'right',\n action: 'space'\n }\n }\n return provideGlobalConfig(config)\n}\n\n"],"names":["modules","gui"],"mappings":";;;;;AAkDO,SAAS,qBAAqB,OAAA,EAA6C;AAChF,EAAA,OAAO,cAAA,CAAe,OAAA,EAAS,QAA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A,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,OAAA;AAAA,MACP,MAAA,EAAQ;AAAA,KACV;AAAA,EACF;AACA,EAAA,OAAO,oBAAoB,MAAM,CAAA;AACnC;;;;"}
|
package/dist/module.d.ts
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
|
+
import { FactoryProvider } from '@signe/di';
|
|
1
2
|
import { RpgClient } from './RpgClient';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Type for client modules that can be either:
|
|
5
|
+
* - An object implementing RpgClient interface
|
|
6
|
+
* - A class decorated with @RpgModule decorator
|
|
7
|
+
*/
|
|
8
|
+
export type RpgClientModule = RpgClient | (new () => any);
|
|
9
|
+
/**
|
|
10
|
+
* Provides client modules configuration to Dependency Injection
|
|
11
|
+
*
|
|
12
|
+
* This function accepts an array of client modules that can be either:
|
|
13
|
+
* - Objects implementing the RpgClient interface
|
|
14
|
+
* - Classes decorated with the @RpgModule decorator (which will be instantiated)
|
|
15
|
+
*
|
|
16
|
+
* @param modules - Array of client modules (objects or classes)
|
|
17
|
+
* @returns FactoryProvider configuration for DI
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Using an object
|
|
21
|
+
* provideClientModules([
|
|
22
|
+
* {
|
|
23
|
+
* engine: {
|
|
24
|
+
* onConnected(engine) {
|
|
25
|
+
* console.log('Client connected')
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ])
|
|
30
|
+
*
|
|
31
|
+
* // Using a decorated class
|
|
32
|
+
* @RpgModule<RpgClient>({
|
|
33
|
+
* engine: {
|
|
34
|
+
* onStart(engine) {
|
|
35
|
+
* console.log('Client started')
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* })
|
|
39
|
+
* class MyClientModule {}
|
|
40
|
+
*
|
|
41
|
+
* provideClientModules([MyClientModule])
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function provideClientModules(modules: RpgClientModule[]): FactoryProvider;
|
|
6
45
|
export declare const GlobalConfigToken = "GlobalConfigToken";
|
|
7
46
|
export declare function provideGlobalConfig(config: any): {
|
|
8
47
|
provide: string;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { KeyboardControls } from 'canvasengine';
|
|
2
|
+
export declare enum Control {
|
|
3
|
+
Action = "action",
|
|
4
|
+
Attack = "attack",
|
|
5
|
+
Defense = "defense",
|
|
6
|
+
Skill = "skill",
|
|
7
|
+
Back = "back",
|
|
8
|
+
Up = 1,
|
|
9
|
+
Down = 3,
|
|
10
|
+
Right = 2,
|
|
11
|
+
Left = 4
|
|
12
|
+
}
|
|
2
13
|
export declare function provideKeyboardControls(): {
|
|
3
|
-
provide:
|
|
14
|
+
provide: typeof KeyboardControls;
|
|
4
15
|
useValue: null;
|
|
5
16
|
};
|
|
@@ -28,7 +28,7 @@ declare class UpdateMapStandaloneService extends UpdateMapService {
|
|
|
28
28
|
update(map: any): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
export declare function provideMmorpg(options: MmorpgOptions): (typeof RpgClientEngine | typeof RpgGui | {
|
|
31
|
-
provide:
|
|
31
|
+
provide: typeof import('canvasengine').KeyboardControls;
|
|
32
32
|
useValue: null;
|
|
33
33
|
} | {
|
|
34
34
|
provide: string;
|
|
@@ -72,7 +72,7 @@ declare class UpdateMapStandaloneService extends UpdateMapService {
|
|
|
72
72
|
update(map: any): Promise<void>;
|
|
73
73
|
}
|
|
74
74
|
export declare function provideRpg(server: any): (typeof RpgClientEngine | typeof RpgGui | {
|
|
75
|
-
provide:
|
|
75
|
+
provide: typeof import('canvasengine').KeyboardControls;
|
|
76
76
|
useValue: null;
|
|
77
77
|
} | {
|
|
78
78
|
provide: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/client",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.22",
|
|
4
4
|
"description": "RPGJS is a framework for creating RPG/MMORPG games",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,19 +22,20 @@
|
|
|
22
22
|
"pixi.js": "^8.9.2"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rpgjs/client": "5.0.0-alpha.
|
|
26
|
-
"@rpgjs/common": "5.0.0-alpha.
|
|
27
|
-
"@rpgjs/server": "5.0.0-alpha.
|
|
28
|
-
"@signe/di": "^2.5.
|
|
29
|
-
"@signe/room": "^2.5.
|
|
30
|
-
"@signe/sync": "^2.5.
|
|
25
|
+
"@rpgjs/client": "5.0.0-alpha.22",
|
|
26
|
+
"@rpgjs/common": "5.0.0-alpha.22",
|
|
27
|
+
"@rpgjs/server": "5.0.0-alpha.22",
|
|
28
|
+
"@signe/di": "^2.5.2",
|
|
29
|
+
"@signe/room": "^2.5.2",
|
|
30
|
+
"@signe/sync": "^2.5.2",
|
|
31
|
+
"pixi-filters": "^6.1.5",
|
|
31
32
|
"rxjs": "^7.8.2"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@canvasengine/compiler": "2.0.0-beta.
|
|
35
|
-
"vite": "^7.2.
|
|
35
|
+
"@canvasengine/compiler": "2.0.0-beta.37",
|
|
36
|
+
"vite": "^7.2.6",
|
|
36
37
|
"vite-plugin-dts": "^4.5.4",
|
|
37
|
-
"vitest": "^4.0.
|
|
38
|
+
"vitest": "^4.0.15"
|
|
38
39
|
},
|
|
39
40
|
"type": "module",
|
|
40
41
|
"scripts": {
|