@vyr/engine 0.0.36 → 0.0.37
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/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyr/engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@vyr/locale": "0.0.
|
|
9
|
+
"@vyr/locale": "0.0.37",
|
|
10
10
|
"decamelize-keys": "^2.0.1",
|
|
11
11
|
"camelcase-keys": "^10.0.1",
|
|
12
12
|
"tinycolor2": "1.6.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationFrameData, parseFrameData, Vector2FrameDataSchema } from "../schema"
|
|
1
|
+
import { AnimationFrameData, parseFrameData, PropertyPathSchema, Vector2FrameDataSchema } from "../schema"
|
|
2
2
|
import { DeserializationObject } from "../Serialization"
|
|
3
3
|
import { Descriptor } from "./Descriptor"
|
|
4
4
|
|
|
@@ -69,7 +69,7 @@ export class AnimationUnit extends Descriptor {
|
|
|
69
69
|
this.count = descriptor.count ?? Infinity
|
|
70
70
|
this.mode = descriptor.mode ?? 1
|
|
71
71
|
this.startTime = descriptor.startTime ?? 0
|
|
72
|
-
this.propertyPath = descriptor.propertyPath
|
|
72
|
+
this.propertyPath = PropertyPathSchema.parse(descriptor.propertyPath)
|
|
73
73
|
this.frameData = descriptor.frameData ? parseFrameData(descriptor.frameData) : Vector2FrameDataSchema.parse({})
|
|
74
74
|
}
|
|
75
75
|
}
|
package/src/schema/Descriptor.ts
CHANGED
|
@@ -19,23 +19,25 @@ export interface DescriptorAdjacency {
|
|
|
19
19
|
next: string
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const propertyPathRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\[\d+\])*$/
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const validatePropertyPath = (path: string) => {
|
|
25
25
|
const value = path.trim()
|
|
26
|
-
return value === '' ||
|
|
26
|
+
return value === '' || propertyPathRegex.test(value)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export const PropertyPathSchema = z.string().default('').refine(
|
|
30
|
+
validatePropertyPath,
|
|
31
|
+
language.get('descriptor.variables.config.value')
|
|
32
|
+
)
|
|
33
|
+
|
|
29
34
|
export const VariabConfigSchema = z.object({
|
|
30
35
|
type: z.enum(['key', 'custom']).default('key'),
|
|
31
36
|
enabled: z.boolean().default(false),
|
|
32
|
-
value:
|
|
33
|
-
validatePath,
|
|
34
|
-
language.get('descriptor.variables.config.value')
|
|
35
|
-
)
|
|
37
|
+
value: PropertyPathSchema
|
|
36
38
|
})
|
|
37
39
|
export type VariabConfig = z.infer<typeof VariabConfigSchema>
|
|
38
40
|
|
|
39
|
-
export const DescriptorVariablesSchema = z.
|
|
41
|
+
export const DescriptorVariablesSchema = z.record(PropertyPathSchema, VariabConfigSchema).default({})
|
|
40
42
|
export type DescriptorVariables = z.infer<typeof DescriptorVariablesSchema>
|
|
41
43
|
|