@haiyue/animation-spec 0.1.0 → 0.2.0
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/README.md +40 -6
- package/SPECIFICATION.md +12 -2
- package/bin/hya-live2d-convert.mjs +76 -0
- package/bin/{hya-convert.mjs → hya-lottie-convert.mjs} +1 -1
- package/dist/chunks/binary-DvuTJ_hy.js +1 -0
- package/dist/chunks/clip-baked-Dv-wjX9d.js +1 -0
- package/dist/chunks/errors-Bzs3GOD9.js +1 -0
- package/dist/chunks/expression-D1cKtNwM.js +1 -0
- package/dist/chunks/extensions-DxL4AxOC.js +1 -0
- package/dist/conversion.d.ts +1 -0
- package/dist/conversion.js +1 -0
- package/dist/cubism.d.ts +1 -0
- package/dist/cubism.js +1 -0
- package/dist/deformable2d.d.ts +1 -0
- package/dist/deformable2d.js +1 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.js +1 -2927
- package/dist/live2d/clip-baked.d.ts +1 -0
- package/dist/live2d/clip-baked.js +1 -0
- package/dist/live2d.d.ts +1 -0
- package/dist/live2d.js +1 -0
- package/dist/lottie.d.ts +1 -62
- package/dist/lottie.js +1 -2642
- package/dist/native3d.d.ts +1 -2
- package/dist/native3d.js +1 -907
- package/dist/shared.d.ts +1493 -0
- package/package.json +30 -10
- package/schema/animation.schema.json +92 -0
- package/schema/deformable-mesh-2d-extension.schema.json +18 -0
- package/schema/deformable-mesh-2d.contract.json +58 -0
- package/schema/parameterized-rig-2d.contract.json +63 -0
- package/schema/parameterized-rig-2d.schema.json +57 -0
- package/schema/parameterized-rig-census-map.json +128 -0
- package/schema/responsive-layout-2d-census-map.json +49 -0
- package/schema/responsive-layout-2d.contract.json +58 -0
- package/schema/responsive-layout-2d.schema.json +34 -0
- package/schema/state-machine-v2-census-map.json +1 -0
- package/schema/state-machine-v2.contract.json +66 -0
- package/schema/state-machine-v2.schema.json +55 -0
- package/schema/vector-visual-census-map.json +120 -0
- package/schema/vector-visual.contract.json +47 -0
- package/schema/vector-visual.schema.json +72 -0
- package/dist/binary.d.ts +0 -7
- package/dist/chunks/types-l6nBVYwx.js +0 -8
- package/dist/chunks/types-l6nBVYwx.js.map +0 -1
- package/dist/errors.d.ts +0 -7
- package/dist/extensions.d.ts +0 -19
- package/dist/index.js.map +0 -1
- package/dist/lottie-merge-path.d.ts +0 -11
- package/dist/lottie.js.map +0 -1
- package/dist/native3d/Animation3DError.d.ts +0 -8
- package/dist/native3d/Animation3DParser.d.ts +0 -7
- package/dist/native3d/Animation3DTypes.d.ts +0 -285
- package/dist/native3d/index.d.ts +0 -5
- package/dist/native3d.js.map +0 -1
- package/dist/parser.d.ts +0 -2
- package/dist/state-machine.d.ts +0 -130
- package/dist/text-selector.d.ts +0 -2
- package/dist/types.d.ts +0 -419
- package/dist/validation.d.ts +0 -32
- package/src/binary.ts +0 -1441
- package/src/errors.ts +0 -18
- package/src/extensions.ts +0 -55
- package/src/index.ts +0 -90
- package/src/lottie-merge-path.ts +0 -204
- package/src/lottie.ts +0 -3073
- package/src/native3d/Animation3DError.ts +0 -20
- package/src/native3d/Animation3DParser.ts +0 -964
- package/src/native3d/Animation3DTypes.ts +0 -322
- package/src/native3d/index.ts +0 -14
- package/src/native3d.ts +0 -2
- package/src/parser.ts +0 -41
- package/src/state-machine.ts +0 -645
- package/src/text-selector.ts +0 -7
- package/src/types.ts +0 -483
- package/src/validation.ts +0 -1286
- package/test/fixtures/basic-lottie.json +0 -31
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnimationDocument,
|
|
3
|
-
AnimationParseLimits,
|
|
4
|
-
AnimationResource,
|
|
5
|
-
AnimationSource,
|
|
6
|
-
ParsedAnimation,
|
|
7
|
-
} from '../types';
|
|
8
|
-
|
|
9
|
-
export const NATIVE_3D_ANIMATION_EXTENSION_ID = 'org.haiyue.animation-3d@1' as const;
|
|
10
|
-
export const NATIVE_3D_ANIMATION_FORMAT = 'haiyue-animation-3d@1' as const;
|
|
11
|
-
export const NATIVE_3D_CLIP_FORMAT = 'haiyue-animation3d-clip@1' as const;
|
|
12
|
-
export const NATIVE_3D_STATE_MACHINE_FORMAT = 'haiyue-animation3d-state-machine@1' as const;
|
|
13
|
-
|
|
14
|
-
export type Native3DVec2 = readonly [number, number];
|
|
15
|
-
export type Native3DVec3 = readonly [number, number, number];
|
|
16
|
-
export type Native3DVec4 = readonly [number, number, number, number];
|
|
17
|
-
export type Native3DQuaternion = Native3DVec4;
|
|
18
|
-
export type Native3DScalarRange = number | readonly [number, number];
|
|
19
|
-
|
|
20
|
-
export interface Native3DCoordinateSystem {
|
|
21
|
-
readonly handedness: 'right';
|
|
22
|
-
readonly upAxis: '+y';
|
|
23
|
-
readonly forwardAxis: '-z';
|
|
24
|
-
readonly unit: 'meter';
|
|
25
|
-
readonly angles: 'radian';
|
|
26
|
-
readonly rotationStorage: 'normalized-xyzw-quaternion';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface Native3DViewport {
|
|
30
|
-
readonly width: number;
|
|
31
|
-
readonly height: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface Native3DTransform {
|
|
35
|
-
readonly translation: Native3DVec3;
|
|
36
|
-
readonly rotation: Native3DQuaternion;
|
|
37
|
-
readonly scale: Native3DVec3;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface Native3DMaterial {
|
|
41
|
-
readonly id: string;
|
|
42
|
-
readonly name: string;
|
|
43
|
-
readonly baseColorFactor: Native3DVec4;
|
|
44
|
-
readonly metallicFactor: number;
|
|
45
|
-
readonly roughnessFactor: number;
|
|
46
|
-
readonly emissiveFactor: Native3DVec3;
|
|
47
|
-
readonly alphaMode: 'opaque' | 'mask' | 'blend';
|
|
48
|
-
readonly alphaCutoff?: number;
|
|
49
|
-
readonly doubleSided: boolean;
|
|
50
|
-
readonly baseColorTexture?: string;
|
|
51
|
-
readonly normalTexture?: string;
|
|
52
|
-
readonly metallicRoughnessTexture?: string;
|
|
53
|
-
readonly emissiveTexture?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type Native3DCameraProjection =
|
|
57
|
-
| Readonly<{
|
|
58
|
-
kind: 'perspective';
|
|
59
|
-
fovYRadians: number;
|
|
60
|
-
near: number;
|
|
61
|
-
far: number;
|
|
62
|
-
}>
|
|
63
|
-
| Readonly<{
|
|
64
|
-
kind: 'orthographic';
|
|
65
|
-
orthoHeight: number;
|
|
66
|
-
near: number;
|
|
67
|
-
far: number;
|
|
68
|
-
}>;
|
|
69
|
-
|
|
70
|
-
export interface Native3DCameraComponent {
|
|
71
|
-
readonly id: string;
|
|
72
|
-
readonly kind: 'camera3d';
|
|
73
|
-
readonly projection: Native3DCameraProjection;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface Native3DPrimitiveComponent {
|
|
77
|
-
readonly id: string;
|
|
78
|
-
readonly kind: 'primitive3d';
|
|
79
|
-
readonly primitive: 'box' | 'sphere' | 'plane' | 'cylinder' | 'cone';
|
|
80
|
-
readonly materialId: string;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface Native3DModelComponent {
|
|
84
|
-
readonly id: string;
|
|
85
|
-
readonly kind: 'model3d';
|
|
86
|
-
readonly resource: string;
|
|
87
|
-
readonly materialOverrides?: readonly Readonly<{ slot: string; materialId: string }>[];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface Native3DParticleDescriptor {
|
|
91
|
-
readonly maxParticles: number;
|
|
92
|
-
readonly emissionRate: number;
|
|
93
|
-
readonly burst: number;
|
|
94
|
-
readonly duration: number;
|
|
95
|
-
readonly loop: boolean;
|
|
96
|
-
readonly seed: number;
|
|
97
|
-
readonly lifetime: Native3DScalarRange;
|
|
98
|
-
readonly speed: Native3DScalarRange;
|
|
99
|
-
readonly direction: Native3DVec3;
|
|
100
|
-
readonly spread: number;
|
|
101
|
-
readonly gravity: Native3DVec3;
|
|
102
|
-
readonly startSize: Native3DScalarRange;
|
|
103
|
-
readonly endSize: Native3DScalarRange;
|
|
104
|
-
readonly rotation: Native3DScalarRange;
|
|
105
|
-
readonly angularVelocity: Native3DScalarRange;
|
|
106
|
-
readonly startColor: Native3DVec4;
|
|
107
|
-
readonly endColor: Native3DVec4;
|
|
108
|
-
readonly shape: 'point' | 'box' | 'sphere';
|
|
109
|
-
readonly shapeSize?: Native3DVec3;
|
|
110
|
-
readonly shapeRadius?: number;
|
|
111
|
-
readonly blendMode: 'normal' | 'additive';
|
|
112
|
-
readonly textureResource?: string;
|
|
113
|
-
readonly radial: boolean;
|
|
114
|
-
readonly opacity: number;
|
|
115
|
-
readonly depthTest: boolean;
|
|
116
|
-
readonly depthWrite: boolean;
|
|
117
|
-
readonly sortMode: 'none' | 'back-to-front';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface Native3DParticleComponent {
|
|
121
|
-
readonly id: string;
|
|
122
|
-
readonly kind: 'particle3d';
|
|
123
|
-
readonly descriptor: Native3DParticleDescriptor;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export type Native3DComponent =
|
|
127
|
-
| Native3DCameraComponent
|
|
128
|
-
| Native3DPrimitiveComponent
|
|
129
|
-
| Native3DModelComponent
|
|
130
|
-
| Native3DParticleComponent;
|
|
131
|
-
|
|
132
|
-
export interface Native3DNode {
|
|
133
|
-
readonly id: string;
|
|
134
|
-
readonly name: string;
|
|
135
|
-
readonly parent?: string;
|
|
136
|
-
readonly start?: number;
|
|
137
|
-
readonly duration?: number;
|
|
138
|
-
readonly transform: Native3DTransform;
|
|
139
|
-
readonly components: readonly Native3DComponent[];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export type Native3DBindingTarget =
|
|
143
|
-
| Readonly<{ kind: 'node-id'; nodeId: string }>
|
|
144
|
-
| Readonly<{ kind: 'node-path'; segments: readonly string[] }>
|
|
145
|
-
| Readonly<{ kind: 'slot'; slot: string }>;
|
|
146
|
-
|
|
147
|
-
export type Native3DBinding =
|
|
148
|
-
| Readonly<{
|
|
149
|
-
id: string;
|
|
150
|
-
target: Native3DBindingTarget;
|
|
151
|
-
path: 'transform.translation';
|
|
152
|
-
valueType: 'vec3';
|
|
153
|
-
valueSize: 3;
|
|
154
|
-
}>
|
|
155
|
-
| Readonly<{
|
|
156
|
-
id: string;
|
|
157
|
-
target: Native3DBindingTarget;
|
|
158
|
-
path: 'transform.rotation';
|
|
159
|
-
valueType: 'quaternion';
|
|
160
|
-
valueSize: 4;
|
|
161
|
-
}>
|
|
162
|
-
| Readonly<{
|
|
163
|
-
id: string;
|
|
164
|
-
target: Native3DBindingTarget;
|
|
165
|
-
path: 'transform.scale';
|
|
166
|
-
valueType: 'vec3';
|
|
167
|
-
valueSize: 3;
|
|
168
|
-
}>
|
|
169
|
-
| Readonly<{
|
|
170
|
-
id: string;
|
|
171
|
-
target: Native3DBindingTarget;
|
|
172
|
-
path: 'morph.weights';
|
|
173
|
-
valueType: 'weights';
|
|
174
|
-
valueSize: number;
|
|
175
|
-
}>
|
|
176
|
-
| Readonly<{
|
|
177
|
-
id: string;
|
|
178
|
-
target: Native3DBindingTarget;
|
|
179
|
-
path: 'property';
|
|
180
|
-
component: 'material3d' | 'camera3d';
|
|
181
|
-
property:
|
|
182
|
-
| 'baseColorFactor'
|
|
183
|
-
| 'metallicFactor'
|
|
184
|
-
| 'roughnessFactor'
|
|
185
|
-
| 'emissiveFactor'
|
|
186
|
-
| 'alphaCutoff'
|
|
187
|
-
| 'fovYRadians'
|
|
188
|
-
| 'near'
|
|
189
|
-
| 'far'
|
|
190
|
-
| 'orthoHeight';
|
|
191
|
-
valueType: 'scalar' | 'vec3' | 'vec4';
|
|
192
|
-
valueSize: 1 | 3 | 4;
|
|
193
|
-
}>;
|
|
194
|
-
|
|
195
|
-
export interface Native3DTrack {
|
|
196
|
-
readonly id: string;
|
|
197
|
-
readonly binding: Native3DBinding;
|
|
198
|
-
readonly interpolation: 'step' | 'linear' | 'cubic-spline';
|
|
199
|
-
readonly times: readonly number[];
|
|
200
|
-
readonly values: readonly number[];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export interface Native3DEvent {
|
|
204
|
-
readonly id: string;
|
|
205
|
-
readonly time: number;
|
|
206
|
-
readonly name: string;
|
|
207
|
-
readonly payload?: Readonly<Record<string, unknown>>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export interface Native3DClip {
|
|
211
|
-
readonly format: typeof NATIVE_3D_CLIP_FORMAT;
|
|
212
|
-
readonly id: string;
|
|
213
|
-
readonly name: string;
|
|
214
|
-
readonly duration: number;
|
|
215
|
-
readonly tracks: readonly Native3DTrack[];
|
|
216
|
-
readonly events: readonly Native3DEvent[];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export type Native3DStateMachineParameter =
|
|
220
|
-
| Readonly<{ name: string; type: 'float'; defaultValue: number }>
|
|
221
|
-
| Readonly<{ name: string; type: 'integer'; defaultValue: number }>
|
|
222
|
-
| Readonly<{ name: string; type: 'boolean'; defaultValue: boolean }>
|
|
223
|
-
| Readonly<{ name: string; type: 'trigger' }>;
|
|
224
|
-
|
|
225
|
-
export type Native3DStateMachineMotion =
|
|
226
|
-
| Readonly<{ kind: 'clip'; clipId: string }>
|
|
227
|
-
| Readonly<{
|
|
228
|
-
kind: 'blend-1d';
|
|
229
|
-
parameter: string;
|
|
230
|
-
children: readonly Readonly<{ threshold: number; motion: Native3DStateMachineMotion }>[];
|
|
231
|
-
}>
|
|
232
|
-
| Readonly<{
|
|
233
|
-
kind: 'blend-2d';
|
|
234
|
-
algorithm: 'cartesian' | 'directional';
|
|
235
|
-
parameterX: string;
|
|
236
|
-
parameterY: string;
|
|
237
|
-
children: readonly Readonly<{ position: Native3DVec2; motion: Native3DStateMachineMotion }>[];
|
|
238
|
-
}>;
|
|
239
|
-
|
|
240
|
-
export interface Native3DStateMachineCondition {
|
|
241
|
-
readonly parameter: string;
|
|
242
|
-
readonly operator:
|
|
243
|
-
| 'greater'
|
|
244
|
-
| 'greater-or-equal'
|
|
245
|
-
| 'less'
|
|
246
|
-
| 'less-or-equal'
|
|
247
|
-
| 'equal'
|
|
248
|
-
| 'not-equal'
|
|
249
|
-
| 'is-true'
|
|
250
|
-
| 'is-false'
|
|
251
|
-
| 'triggered';
|
|
252
|
-
readonly value?: number | boolean;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export interface Native3DStateMachineState {
|
|
256
|
-
readonly id: string;
|
|
257
|
-
readonly name: string;
|
|
258
|
-
readonly motion: Native3DStateMachineMotion;
|
|
259
|
-
readonly speed?: number;
|
|
260
|
-
readonly speedParameter?: string;
|
|
261
|
-
readonly loop?: 'once' | 'repeat' | 'ping-pong';
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export interface Native3DStateMachineTransition {
|
|
265
|
-
readonly id: string;
|
|
266
|
-
readonly from: string;
|
|
267
|
-
readonly to: string;
|
|
268
|
-
readonly conditions: readonly Native3DStateMachineCondition[];
|
|
269
|
-
readonly duration: number;
|
|
270
|
-
readonly hasExitTime?: boolean;
|
|
271
|
-
readonly exitTime?: number;
|
|
272
|
-
readonly destinationOffset?: number;
|
|
273
|
-
readonly interruption?: 'none' | 'source' | 'destination' | 'source-then-destination' | 'destination-then-source';
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export interface Native3DStateMachineLayer {
|
|
277
|
-
readonly id: string;
|
|
278
|
-
readonly name: string;
|
|
279
|
-
readonly initialStateId: string;
|
|
280
|
-
readonly states: readonly Native3DStateMachineState[];
|
|
281
|
-
readonly transitions: readonly Native3DStateMachineTransition[];
|
|
282
|
-
readonly blendMode?: 'override' | 'additive';
|
|
283
|
-
readonly weight?: number;
|
|
284
|
-
readonly mask?: Readonly<{ include?: readonly string[]; exclude?: readonly string[] }>;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface Native3DStateMachine {
|
|
288
|
-
readonly format: typeof NATIVE_3D_STATE_MACHINE_FORMAT;
|
|
289
|
-
readonly id: string;
|
|
290
|
-
readonly name: string;
|
|
291
|
-
readonly parameters: readonly Native3DStateMachineParameter[];
|
|
292
|
-
readonly layers: readonly Native3DStateMachineLayer[];
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export interface Native3DAnimationPayload {
|
|
296
|
-
readonly format: typeof NATIVE_3D_ANIMATION_FORMAT;
|
|
297
|
-
readonly mode: 'native-3d';
|
|
298
|
-
readonly coordinateSystem: Native3DCoordinateSystem;
|
|
299
|
-
readonly viewport: Native3DViewport;
|
|
300
|
-
readonly materials: readonly Native3DMaterial[];
|
|
301
|
-
readonly nodes: readonly Native3DNode[];
|
|
302
|
-
readonly clips: readonly Native3DClip[];
|
|
303
|
-
readonly stateMachine?: Native3DStateMachine | null;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export interface Native3DParseLimits {
|
|
307
|
-
readonly maxMaterials?: number;
|
|
308
|
-
readonly maxClips?: number;
|
|
309
|
-
readonly maxStateMachineDepth?: number;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export interface Native3DAnimationParseOptions extends AnimationParseLimits, Native3DParseLimits {
|
|
313
|
-
readonly copyFloatData?: boolean;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export interface ParsedNative3DAnimation {
|
|
317
|
-
readonly document: ParsedAnimation;
|
|
318
|
-
readonly payload: Native3DAnimationPayload;
|
|
319
|
-
readonly resources: readonly Readonly<AnimationResource>[];
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export type Native3DAnimationSource = AnimationSource | AnimationDocument;
|
package/src/native3d/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
NATIVE_3D_ANIMATION_EXTENSION_ID,
|
|
3
|
-
NATIVE_3D_ANIMATION_FORMAT,
|
|
4
|
-
NATIVE_3D_CLIP_FORMAT,
|
|
5
|
-
NATIVE_3D_STATE_MACHINE_FORMAT,
|
|
6
|
-
} from './Animation3DTypes';
|
|
7
|
-
export type * from './Animation3DTypes';
|
|
8
|
-
export { Native3DAnimationFormatError } from './Animation3DError';
|
|
9
|
-
export type { Native3DAnimationDiagnosticCode } from './Animation3DError';
|
|
10
|
-
export {
|
|
11
|
-
createNative3DAnimationExtensionHandler,
|
|
12
|
-
parseNative3DAnimation,
|
|
13
|
-
parseNative3DAnimationPayload,
|
|
14
|
-
} from './Animation3DParser';
|
package/src/native3d.ts
DELETED
package/src/parser.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { AnimationFormatError } from './errors';
|
|
2
|
-
import { tryDecodeAnimationBinary } from './binary';
|
|
3
|
-
import type { AnimationParseOptions, AnimationSource, ParsedAnimation } from './types';
|
|
4
|
-
import { parseAnimationValue, resolveAnimationParseLimits } from './validation';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_PARSE_OPTIONS: AnimationParseOptions = Object.freeze({});
|
|
7
|
-
const UTF8_DECODER = new TextDecoder();
|
|
8
|
-
const UTF8_ENCODER = new TextEncoder();
|
|
9
|
-
|
|
10
|
-
export function parseAnimation(source: AnimationSource, options: AnimationParseOptions = DEFAULT_PARSE_OPTIONS): ParsedAnimation {
|
|
11
|
-
if (source instanceof ArrayBuffer) {
|
|
12
|
-
const binary = tryDecodeAnimationBinary(source, options);
|
|
13
|
-
if (binary) return binary;
|
|
14
|
-
const limits = resolveAnimationParseLimits(options);
|
|
15
|
-
if (source.byteLength > limits.maxInputBytes) {
|
|
16
|
-
throw new AnimationFormatError('E_ANIMATION_LIMIT_EXCEEDED', `Input exceeds ${limits.maxInputBytes} bytes.`, '$');
|
|
17
|
-
}
|
|
18
|
-
return parseJsonText(UTF8_DECODER.decode(source), options);
|
|
19
|
-
}
|
|
20
|
-
if (typeof source === 'string') return parseJsonText(source, options);
|
|
21
|
-
return parseAnimationValue(source, options, 'json');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function parseJsonText(source: string, options: AnimationParseOptions): ParsedAnimation {
|
|
25
|
-
const limits = resolveAnimationParseLimits(options);
|
|
26
|
-
const bytes = UTF8_ENCODER.encode(source).byteLength;
|
|
27
|
-
if (bytes > limits.maxInputBytes) {
|
|
28
|
-
throw new AnimationFormatError('E_ANIMATION_LIMIT_EXCEEDED', `Input exceeds ${limits.maxInputBytes} bytes.`, '$');
|
|
29
|
-
}
|
|
30
|
-
let value: unknown;
|
|
31
|
-
try {
|
|
32
|
-
value = JSON.parse(source);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
throw new AnimationFormatError(
|
|
35
|
-
'E_ANIMATION_INVALID_FORMAT',
|
|
36
|
-
`Animation JSON cannot be decoded: ${error instanceof Error ? error.message : String(error)}.`,
|
|
37
|
-
'$',
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return parseAnimationValue(value, options, 'json');
|
|
41
|
-
}
|