skia-motion-runtime 0.0.0-stage → 3.0.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.
@@ -0,0 +1,410 @@
1
+ import { validateMachine } from './machine-schema.js';
2
+ import { EASE_IN, EASE_IN_OUT, EASE_OUT } from '../templates/motion/motion';
3
+ import type { Clips, Machine, StateEntry } from '../templates/motion/machine';
4
+ import type { AssetAnchor } from './asset-layout';
5
+ import { imageSize } from './asset-image';
6
+ import type { MeshNode, MeshVertex } from './asset-mesh';
7
+
8
+ export const ASSET_SCHEMA = 'skac.asset/1';
9
+ export const MAX_ASSET_BYTES = 1024 * 1024;
10
+ export const MAX_FEATHER = 64;
11
+
12
+ export type Scalar = number | string;
13
+ type Ease = 'linear' | 'in' | 'out' | 'inOut' | 'hold';
14
+ type Key = readonly [ms: number, value: number, ease?: Ease];
15
+ type Track = readonly Key[];
16
+ export type PathCommand =
17
+ | readonly [op: 'M' | 'L', x: Scalar, y: Scalar]
18
+ | readonly [op: 'Q', controlX: Scalar, controlY: Scalar, x: Scalar, y: Scalar]
19
+ | readonly [op: 'C', control1X: Scalar, control1Y: Scalar, control2X: Scalar, control2Y: Scalar, x: Scalar, y: Scalar]
20
+ | readonly [op: 'Z'];
21
+ type Shade = string | { kind: 'radial'; x: Scalar; y: Scalar; radius: Scalar; colors: readonly [string, string] };
22
+
23
+ type Group = {
24
+ kind: 'group'; x?: Scalar; y?: Scalar; scaleX?: Scalar; scaleY?: Scalar; rotation?: Scalar;
25
+ anchor?: AssetAnchor;
26
+ clip?: readonly PathCommand[];
27
+ points?: Readonly<Record<string, { x: Scalar; y: Scalar }>>;
28
+ children: readonly AssetNode[];
29
+ };
30
+ type Shape = { fill: Shade; opacity?: Scalar; feather?: Scalar } & (
31
+ | { kind: 'ellipse'; x: Scalar; y: Scalar; width: Scalar; height: Scalar }
32
+ | { kind: 'roundRect'; x: Scalar; y: Scalar; width: Scalar; height: Scalar; radius: Scalar }
33
+ | { kind: 'path'; commands: readonly PathCommand[] }
34
+ );
35
+
36
+ type ImageNode = {
37
+ kind: 'image'; image: string; opacity?: Scalar;
38
+ x: Scalar; y: Scalar; width: Scalar; height: Scalar;
39
+ };
40
+
41
+ export type AssetNode = Group | Shape | ImageNode | MeshNode;
42
+ export type AssetMarker = { name: string; layer: string; state: string };
43
+ export type AssetMarkerEvent = AssetMarker & { at: number };
44
+ export type AssetAttachment = { from: string; to: string; maxDistance: number };
45
+ export type MotionAsset<M extends Machine = Machine> = {
46
+ schema: typeof ASSET_SCHEMA;
47
+ name: string;
48
+ artboard: { width: number; height: number; nodes: readonly AssetNode[] };
49
+ channels: Readonly<Record<string, number>>;
50
+ images?: Readonly<Record<string, string>>;
51
+ clips: Readonly<Record<string, { ms: number; reducedAt?: number; tracks: Readonly<Record<string, Track>> }>>;
52
+ machine: M;
53
+ markers?: readonly AssetMarker[];
54
+ attachments?: readonly AssetAttachment[];
55
+ };
56
+
57
+ const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
58
+ const HEX_COLOR = /^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/;
59
+ const PATH_ARGUMENTS: Record<string, number> = { M: 2, L: 2, Q: 4, C: 6, Z: 0 };
60
+ const EASES = ['linear', 'in', 'out', 'inOut', 'hold'];
61
+ const RESERVED_KEYS = new Set([...Object.getOwnPropertyNames(Object.prototype), 'prototype']);
62
+
63
+ function invalid(at: string, message: string): never {
64
+ throw new Error(`${at}: ${message}`);
65
+ }
66
+
67
+ function record(value: unknown, at: string, keys?: readonly string[]): Record<string, unknown> {
68
+ if (!value || typeof value !== 'object' || Array.isArray(value)) invalid(at, 'expected an object');
69
+ const data = value as Record<string, unknown>;
70
+ if (keys) for (const key of Object.keys(data)) if (!keys.includes(key)) invalid(`${at}.${key}`, 'unknown field');
71
+ return data;
72
+ }
73
+
74
+ function list(value: unknown, at: string, limit: number): unknown[] {
75
+ if (!Array.isArray(value) || value.length > limit) invalid(at, `expected an array of up to ${limit} items`);
76
+ return value;
77
+ }
78
+
79
+ function number(value: unknown, at: string, min = -1e7, max = 1e7): number {
80
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max) {
81
+ invalid(at, `expected a number from ${min} to ${max}`);
82
+ }
83
+ return value;
84
+ }
85
+
86
+ function identifier(value: unknown, at: string): string {
87
+ if (typeof value !== 'string' || !IDENTIFIER.test(value) || RESERVED_KEYS.has(value)) invalid(at, 'expected an identifier');
88
+ return value;
89
+ }
90
+
91
+ function scalar(value: unknown, at: string, channels: Record<string, unknown>, min?: number, max?: number): void {
92
+ if (typeof value === 'string' && Object.hasOwn(channels, value)) return;
93
+ if (typeof value === 'string') invalid(at, `unknown channel "${value}"`);
94
+ number(value, at, min, max);
95
+ }
96
+
97
+ function color(value: unknown, at: string): void {
98
+ if (typeof value !== 'string' || !HEX_COLOR.test(value)) invalid(at, 'expected #RRGGBB or #RRGGBBAA');
99
+ }
100
+
101
+ function checkPath(value: unknown, at: string, channels: Record<string, unknown>): void {
102
+ const commands = list(value, at, 1024);
103
+ if (!commands.length) invalid(at, 'a path must start with M');
104
+ commands.forEach((value, i) => {
105
+ const key = `${at}[${i}]`;
106
+ const [op, ...args] = list(value, key, 7);
107
+ if (typeof op !== 'string' || !Object.hasOwn(PATH_ARGUMENTS, op) || args.length !== PATH_ARGUMENTS[op] || (!i && op !== 'M')) {
108
+ invalid(key, 'expected M, L, Q, C or Z with the correct coordinates, starting with M');
109
+ }
110
+ args.forEach((arg, j) => scalar(arg, `${key}[${j + 1}]`, channels));
111
+ });
112
+ }
113
+
114
+ type NodeValidation = {
115
+ channels: Record<string, unknown>;
116
+ images: Record<string, unknown>;
117
+ points: Set<string>;
118
+ };
119
+
120
+ function registerPoint(name: string, at: string, points: Set<string>): void {
121
+ identifier(name, at);
122
+ if (points.has(name)) invalid(at, 'duplicate point name');
123
+ points.add(name);
124
+ }
125
+
126
+ function checkChildren(value: unknown, at: string, context: NodeValidation, depth: number): void {
127
+ if (depth >= 16) invalid(at, 'nodes are nested more than 16 levels');
128
+ list(value, at, 256).forEach((child, i) => checkNode(child, `${at}[${i}]`, context, depth + 1));
129
+ }
130
+
131
+ function checkMesh(node: Record<string, unknown>, at: string, context: NodeValidation, depth: number): void {
132
+ record(node, at, ['kind', 'image', 'vertices', 'indices', 'opacity', 'pins']);
133
+ const vertices = list(node.vertices, `${at}.vertices`, 1024).map((value, i) => {
134
+ const key = `${at}.vertices[${i}]`;
135
+ const vertex = list(value, key, 4);
136
+ if (vertex.length !== 4) invalid(key, 'expected [x, y, u, v]');
137
+ scalar(vertex[0], `${key}[0]`, context.channels);
138
+ scalar(vertex[1], `${key}[1]`, context.channels);
139
+ number(vertex[2], `${key}[2]`, 0, 1);
140
+ number(vertex[3], `${key}[3]`, 0, 1);
141
+ return vertex as unknown as MeshVertex;
142
+ });
143
+ if (vertices.length < 3) invalid(`${at}.vertices`, 'expected at least three vertices');
144
+ const indices = list(node.indices, `${at}.indices`, 6144).map((value, i) => {
145
+ const key = `${at}.indices[${i}]`;
146
+ const index = number(value, key, 0, vertices.length - 1);
147
+ if (!Number.isInteger(index)) invalid(key, 'expected an integer vertex index');
148
+ return index;
149
+ });
150
+ if (!indices.length || indices.length % 3 !== 0) invalid(`${at}.indices`, 'expected index triples');
151
+ for (let i = 0; i < indices.length; i += 3) {
152
+ const [, , au, av] = vertices[indices[i]!]!;
153
+ const [, , bu, bv] = vertices[indices[i + 1]!]!;
154
+ const [, , cu, cv] = vertices[indices[i + 2]!]!;
155
+ const area = (bu - au) * (cv - av) - (bv - av) * (cu - au);
156
+ if (Math.abs(area) < 1e-9) invalid(`${at}.indices[${i}]`, 'triangle needs three non-collinear texture coordinates');
157
+ }
158
+ if (node.pins === undefined) return;
159
+ for (const [name, value] of Object.entries(record(node.pins, `${at}.pins`))) {
160
+ const key = `${at}.pins.${name}`;
161
+ registerPoint(name, key, context.points);
162
+ const pin = record(value, key, ['triangle', 'weights', 'children']);
163
+ const triangle = number(pin.triangle, `${key}.triangle`, 0, indices.length / 3 - 1);
164
+ if (!Number.isInteger(triangle)) invalid(`${key}.triangle`, 'expected an integer triangle index');
165
+ const weights = list(pin.weights, `${key}.weights`, 3);
166
+ if (weights.length !== 3) invalid(`${key}.weights`, 'expected one weight per vertex');
167
+ const sum = weights.reduce<number>((total, value, i) => total + number(value, `${key}.weights[${i}]`, 0, 1), 0);
168
+ if (Math.abs(sum - 1) > 1e-6) invalid(`${key}.weights`, 'weights must add up to 1');
169
+ if (pin.children !== undefined) checkChildren(pin.children, `${key}.children`, context, depth);
170
+ }
171
+ }
172
+
173
+ function checkNode(value: unknown, at: string, context: NodeValidation, depth: number): void {
174
+ const { channels, images, points } = context;
175
+ const node = record(value, at);
176
+ if (node.kind === 'group') {
177
+ record(node, at, ['kind', 'children', 'x', 'y', 'scaleX', 'scaleY', 'rotation', 'anchor', 'clip', 'points']);
178
+ for (const key of ['x', 'y', 'scaleX', 'scaleY', 'rotation']) {
179
+ if (node[key] !== undefined) scalar(node[key], `${at}.${key}`, channels);
180
+ }
181
+ if (node.points !== undefined) {
182
+ for (const [name, rawPoint] of Object.entries(record(node.points, `${at}.points`))) {
183
+ const key = `${at}.points.${name}`;
184
+ registerPoint(name, key, points);
185
+ const point = record(rawPoint, key, ['x', 'y']);
186
+ scalar(point.x, `${key}.x`, channels);
187
+ scalar(point.y, `${key}.y`, channels);
188
+ }
189
+ }
190
+ if (node.clip !== undefined) checkPath(node.clip, `${at}.clip`, channels);
191
+ if (node.anchor !== undefined) {
192
+ if (depth > 0) invalid(`${at}.anchor`, 'anchors belong to top-level groups');
193
+ const anchor = record(node.anchor, `${at}.anchor`, ['x', 'y']);
194
+ if (anchor.x === undefined && anchor.y === undefined) invalid(`${at}.anchor`, 'give an x or y anchor');
195
+ if (anchor.x !== undefined && !['left', 'center', 'right'].some((value) => value === anchor.x)) {
196
+ invalid(`${at}.anchor.x`, 'expected left, center or right');
197
+ }
198
+ if (anchor.y !== undefined && !['top', 'center', 'bottom'].some((value) => value === anchor.y)) {
199
+ invalid(`${at}.anchor.y`, 'expected top, center or bottom');
200
+ }
201
+ }
202
+ checkChildren(node.children, `${at}.children`, context, depth);
203
+ return;
204
+ }
205
+ if (node.kind === 'image' || node.kind === 'mesh') {
206
+ if (typeof node.image !== 'string' || !Object.hasOwn(images, node.image)) invalid(`${at}.image`, 'expected a name from images');
207
+ if (node.opacity !== undefined) scalar(node.opacity, `${at}.opacity`, channels, 0, 1);
208
+ if (node.kind === 'mesh') {
209
+ checkMesh(node, at, context, depth);
210
+ } else {
211
+ record(node, at, ['kind', 'image', 'x', 'y', 'width', 'height', 'opacity']);
212
+ for (const key of ['x', 'y']) scalar(node[key], `${at}.${key}`, channels);
213
+ for (const key of ['width', 'height']) scalar(node[key], `${at}.${key}`, channels, 0);
214
+ }
215
+ return;
216
+ }
217
+ if (node.kind === 'path') {
218
+ record(node, at, ['kind', 'fill', 'opacity', 'feather', 'commands']);
219
+ checkPath(node.commands, `${at}.commands`, channels);
220
+ } else if (node.kind === 'ellipse' || node.kind === 'roundRect') {
221
+ const keys = ['kind', 'fill', 'opacity', 'feather', 'x', 'y', 'width', 'height'];
222
+ if (node.kind === 'roundRect') keys.push('radius');
223
+ record(node, at, keys);
224
+ for (const key of ['x', 'y', 'width', 'height']) scalar(node[key], `${at}.${key}`, channels, key === 'x' || key === 'y' ? undefined : 0);
225
+ if (node.kind === 'roundRect') scalar(node.radius, `${at}.radius`, channels, 0);
226
+ } else {
227
+ invalid(`${at}.kind`, 'expected ellipse, roundRect, path, image, mesh or group');
228
+ }
229
+ if (node.opacity !== undefined) scalar(node.opacity, `${at}.opacity`, channels, 0, 1);
230
+ if (node.feather !== undefined) scalar(node.feather, `${at}.feather`, channels, 0, MAX_FEATHER);
231
+ if (typeof node.fill === 'string') {
232
+ color(node.fill, `${at}.fill`);
233
+ return;
234
+ }
235
+ const fill = record(node.fill, `${at}.fill`, ['kind', 'x', 'y', 'radius', 'colors']);
236
+ if (fill.kind !== 'radial') invalid(`${at}.fill.kind`, 'expected radial');
237
+ scalar(fill.x, `${at}.fill.x`, channels);
238
+ scalar(fill.y, `${at}.fill.y`, channels);
239
+ scalar(fill.radius, `${at}.fill.radius`, channels, 0.001);
240
+ const colors = list(fill.colors, `${at}.fill.colors`, 2);
241
+ if (colors.length !== 2) invalid(`${at}.fill.colors`, 'expected two colors');
242
+ colors.forEach((item, i) => color(item, `${at}.fill.colors[${i}]`));
243
+ }
244
+
245
+ function validateAsset(value: unknown): MotionAsset {
246
+ const data = record(value, 'asset', ['schema', 'name', 'artboard', 'channels', 'clips', 'machine', 'markers', 'images', 'attachments']);
247
+ if (data.schema !== ASSET_SCHEMA) invalid('asset.schema', `this player reads ${ASSET_SCHEMA}`);
248
+ identifier(data.name, 'asset.name');
249
+ const channels = record(data.channels, 'channels');
250
+ for (const [name, value] of Object.entries(channels)) {
251
+ identifier(name, `channels.${name}`);
252
+ number(value, `channels.${name}`);
253
+ }
254
+ const images = data.images === undefined ? {} : record(data.images, 'images');
255
+ let pixels = 0;
256
+ for (const [name, uri] of Object.entries(images)) {
257
+ const at = `images.${name}`;
258
+ identifier(name, at);
259
+ const size = imageSize(uri);
260
+ if (!size || size.width < 1 || size.height < 1 || size.width > 4096 || size.height > 4096) {
261
+ invalid(at, 'expected an embedded PNG or WebP data URI with dimensions from 1 to 4096 pixels');
262
+ }
263
+ pixels += size.width * size.height;
264
+ if (pixels > 16 * 1024 * 1024) invalid('images', 'embedded images exceed 16 Mi pixels in total');
265
+ }
266
+ const artboard = record(data.artboard, 'artboard', ['width', 'height', 'nodes']);
267
+ number(artboard.width, 'artboard.width', 1, 4096);
268
+ number(artboard.height, 'artboard.height', 1, 4096);
269
+ const nodes = list(artboard.nodes, 'artboard.nodes', 256);
270
+ if (!nodes.length) invalid('artboard.nodes', 'add at least one shape');
271
+ const context = { channels, images, points: new Set<string>() };
272
+ nodes.forEach((node, i) => checkNode(node, `artboard.nodes[${i}]`, context, 0));
273
+ if (data.attachments !== undefined) {
274
+ list(data.attachments, 'attachments', 256).forEach((item, i) => {
275
+ const at = `attachments[${i}]`;
276
+ const attachment = record(item, at, ['from', 'to', 'maxDistance']);
277
+ for (const key of ['from', 'to']) {
278
+ const point = identifier(attachment[key], `${at}.${key}`);
279
+ if (!context.points.has(point)) invalid(`${at}.${key}`, `unknown point "${point}"`);
280
+ }
281
+ number(attachment.maxDistance, `${at}.maxDistance`, 0);
282
+ });
283
+ }
284
+ const clips = record(data.clips, 'clips');
285
+ for (const [name, value] of Object.entries(clips)) {
286
+ const at = `clips.${name}`;
287
+ identifier(name, at);
288
+ const clip = record(value, at, ['ms', 'reducedAt', 'tracks']);
289
+ const ms = number(clip.ms, `${at}.ms`, 0, 60000);
290
+ if (clip.reducedAt !== undefined) number(clip.reducedAt, `${at}.reducedAt`, 0, ms);
291
+ for (const [channel, value] of Object.entries(record(clip.tracks, `${at}.tracks`))) {
292
+ const key = `${at}.tracks.${channel}`;
293
+ if (!Object.hasOwn(channels, channel)) invalid(key, 'unknown channel');
294
+ const track = list(value, key, 1024);
295
+ if (!track.length) invalid(key, 'a track needs at least one keyframe');
296
+ let previous = -1;
297
+ track.forEach((value, i) => {
298
+ const at = `${key}[${i}]`;
299
+ const frame = list(value, at, 3);
300
+ if (frame.length < 2) invalid(at, 'expected [ms, value, ease?]');
301
+ const time = number(frame[0], `${at}[0]`, 0, ms);
302
+ if (time <= previous) invalid(at, 'keyframe times must be strictly increasing');
303
+ previous = time;
304
+ number(frame[1], `${at}[1]`);
305
+ if (frame.length === 3 && (typeof frame[2] !== 'string' || !EASES.includes(frame[2]))) {
306
+ invalid(`${at}[2]`, 'expected linear, in, out, inOut or hold');
307
+ }
308
+ });
309
+ }
310
+ }
311
+ const machine = record(data.machine, 'machine');
312
+ if (machine.clocks !== undefined || machine.hits !== undefined) invalid('machine', 'this asset version uses frame clocks and host input');
313
+ list(machine.layers, 'machine.layers', 32).forEach((value, i) => {
314
+ const at = `machine.layers[${i}]`;
315
+ const layer = record(value, at);
316
+ if (Object.keys(record(layer.states, `${at}.states`)).length > 128) invalid(`${at}.states`, 'maximum of 128 states per layer');
317
+ if (layer.transitions !== undefined) list(layer.transitions, `${at}.transitions`, 512);
318
+ });
319
+ const checked = validateMachine(machine, { clips: clips as MotionAsset['clips'] });
320
+ if (checked.problems.length) {
321
+ const { where, error, hint } = checked.problems[0]!;
322
+ invalid(where ? `machine.${where}` : 'machine', `${error}. ${hint}`);
323
+ }
324
+ const typed = data as MotionAsset;
325
+ const names = new Set();
326
+ if (data.markers !== undefined) {
327
+ list(data.markers, 'markers', 256).forEach((item, i) => {
328
+ const at = `markers[${i}]`;
329
+ const marker = record(item, at, ['name', 'layer', 'state']);
330
+ const name = identifier(marker.name, `${at}.name`);
331
+ if (names.has(name)) invalid(`${at}.name`, 'duplicate marker name');
332
+ names.add(name);
333
+ const layer = typed.machine.layers.find((layer) => layer.name === marker.layer);
334
+ const state = identifier(marker.state, `${at}.state`);
335
+ if (!layer || !Object.hasOwn(layer.states, state)) invalid(at, 'unknown layer or state');
336
+ });
337
+ }
338
+ return typed;
339
+ }
340
+
341
+ /** Decode the same data file on a React Native JS thread and in the CLI. */
342
+ export function parseAsset(text: string): MotionAsset {
343
+ if (typeof text !== 'string' || text.length > MAX_ASSET_BYTES) invalid('asset', 'expected a JSON asset of at most 1 MiB');
344
+ const bytes = encodeURI(text).replace(/%[0-9A-F]{2}/g, 'x').length;
345
+ if (bytes > MAX_ASSET_BYTES) invalid('asset', 'expected a JSON asset of at most 1 MiB');
346
+ const decoded: unknown = JSON.parse(text, (key, value: unknown) => {
347
+ if (RESERVED_KEYS.has(key)) invalid(key, 'reserved field name');
348
+ if (typeof value === 'number' && !Number.isFinite(value)) invalid(key, 'expected a finite number');
349
+ return value;
350
+ });
351
+ return validateAsset(decoded);
352
+ }
353
+
354
+ /** Image names used by the drawing. Unreferenced library entries can be omitted from playback. */
355
+ export function usedAssetImages(nodes: readonly AssetNode[], names = new Set<string>()): Set<string> {
356
+ for (const node of nodes) {
357
+ if (node.kind === 'image' || node.kind === 'mesh') names.add(node.image);
358
+ if (node.kind === 'group') usedAssetImages(node.children, names);
359
+ if (node.kind === 'mesh') {
360
+ for (const pin of Object.values(node.pins ?? {})) {
361
+ if (pin.children) usedAssetImages(pin.children, names);
362
+ }
363
+ }
364
+ }
365
+ return names;
366
+ }
367
+
368
+ function trackValue(track: Track, ms: number): number {
369
+ 'worklet';
370
+ const first = track[0]!;
371
+ if (ms <= first[0]) return first[1];
372
+ let low = 1;
373
+ let high = track.length - 1;
374
+ const last = track[high]!;
375
+ if (!(ms <= last[0])) return last[1];
376
+ // Find the first key at or after the sample. Its easing controls the segment ending there.
377
+ while (low < high) {
378
+ const middle = Math.floor((low + high) / 2);
379
+ if (ms <= track[middle]![0]) high = middle;
380
+ else low = middle + 1;
381
+ }
382
+ const [end, to, ease] = track[low]!;
383
+ const [start, from] = track[low - 1]!;
384
+ if (ease === 'hold') return ms < end ? from : to;
385
+ const p = (ms - start) / (end - start);
386
+ const eased = ease === 'in' ? EASE_IN(p) : ease === 'out' ? EASE_OUT(p) : ease === 'inOut' ? EASE_IN_OUT(p) : p;
387
+ return from + (to - from) * eased;
388
+ }
389
+
390
+ /** Adapt data tracks to the existing state-machine clip interface. */
391
+ export function assetClips(asset: MotionAsset): Clips {
392
+ return Object.fromEntries(Object.entries(asset.clips).map(([name, { ms, reducedAt, tracks }]) => {
393
+ const channels = Object.entries(tracks);
394
+ return [name, {
395
+ ms, reducedAt,
396
+ play(localMs: number) {
397
+ 'worklet';
398
+ const pose: Record<string, number> = {};
399
+ for (const [channel, keys] of channels) pose[channel] = trackValue(keys, localMs);
400
+ return { channels: pose };
401
+ },
402
+ }];
403
+ }));
404
+ }
405
+
406
+ export function assetMarkerEvents(asset: Pick<MotionAsset, 'markers'>, entries: StateEntry[]): AssetMarkerEvent[] {
407
+ const markers = asset.markers ?? [];
408
+ return entries.flatMap(({ layer, state, at }) =>
409
+ markers.filter((marker) => marker.layer === layer && marker.state === state).map((marker) => ({ ...marker, at })));
410
+ }
@@ -0,0 +1,7 @@
1
+ // Machine bindings for apps, exported by skia-motion-runtime/machine.
2
+ // The machine core and motion engine are shared with the authoring tools.
3
+ export * from '../templates/motion/motion';
4
+ export * from '../templates/motion/face';
5
+ export * from '../templates/motion/machine';
6
+ export { useMachine, type MachineHandle, type MachineOptions, type MachineProbe } from './useMachine';
7
+ export { runtimeVersion } from './version';
@@ -0,0 +1,6 @@
1
+ type Finding = { where: string; error: string; hint: string };
2
+
3
+ export function validateMachine(
4
+ machine: unknown,
5
+ options?: { clips?: Record<string, { ms: number }>; clipNames?: string[] },
6
+ ): { problems: Finding[]; warnings: Finding[] };