@flatkit/types 0.6.0 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +54 -1
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -203,6 +203,11 @@ type Action = {
203
203
  name: string;
204
204
  index: string;
205
205
  value: string;
206
+ } | {
207
+ do: 'setParam';
208
+ target: string;
209
+ param: string;
210
+ value: string;
206
211
  } | {
207
212
  do: 'if';
208
213
  cond: string;
@@ -322,7 +327,9 @@ type Region = {
322
327
  color: string;
323
328
  path: Path;
324
329
  paint?: Paint;
330
+ fillParam?: string;
325
331
  stroke?: Stroke;
332
+ strokeParam?: string;
326
333
  noFill?: boolean;
327
334
  xform?: Transform;
328
335
  opacity?: number;
@@ -356,6 +363,7 @@ type Group = {
356
363
  h: number;
357
364
  };
358
365
  expressions?: Partial<Record<ExprChannel, string>>;
366
+ clip?: ClipRect;
359
367
  };
360
368
  /** Instance of a reusable symbol: a transform + a reference to the symbol. */
361
369
  type Instance = {
@@ -373,6 +381,15 @@ type Instance = {
373
381
  filters?: Filter[];
374
382
  blend?: BlendMode;
375
383
  expressions?: Partial<Record<ExprChannel, string>>;
384
+ params?: Record<string, string>;
385
+ clip?: ClipRect;
386
+ };
387
+ /** A rectangular clip region in a container's LOCAL coordinates (`clip <x> <y> <w> <h>`). */
388
+ type ClipRect = {
389
+ x: number;
390
+ y: number;
391
+ w: number;
392
+ h: number;
376
393
  };
377
394
  /**
378
395
  * Library folder (pure organization, Flash style): a tree by `parent`. SYMBOLS stay FLAT (referenced by
@@ -384,12 +401,48 @@ type Folder = {
384
401
  parent?: string;
385
402
  collapsed?: boolean;
386
403
  };
404
+ /** One named state of a symbol: a label on the symbol's timeline (e.g. `closed at 0`, `open at 24`). */
405
+ type StateAnchor = {
406
+ name: string;
407
+ frame: number;
408
+ };
409
+ /**
410
+ * A symbol's exposed STATE MACHINE: the param `param` selects a named state, which drives the symbol's
411
+ * local playhead to that state's frame. A fractional/animated value between states plays the authored
412
+ * in-between animation (the timeline frames between the two anchors). `transition`/`ease` describe the
413
+ * default move between states (used by the live runtime; metadata for selection).
414
+ */
415
+ type StateMachine = {
416
+ param: string;
417
+ states: StateAnchor[];
418
+ initial?: string;
419
+ transition?: number;
420
+ ease?: Easing;
421
+ };
422
+ /** Type of an exposed symbol param. `color` → a fill (`fill <name>`); `number`/`bool` → a scope variable. */
423
+ type ParamType = 'color' | 'number' | 'bool';
424
+ /**
425
+ * One exposed param of a symbol — its public, named, defaulted, documented interface. A consumer sets it
426
+ * at the instance call-site (`instance "Boat" { hull = #fff }`), in `--preview --set`, or (number/bool)
427
+ * at runtime (`Boat.wave = 1.5`). `color` params feed `fill <name>`; `number`/`bool` become variables in
428
+ * the symbol's expressions.
429
+ */
430
+ type ParamDef = {
431
+ name: string;
432
+ type: ParamType;
433
+ default: string;
434
+ min?: number;
435
+ max?: number;
436
+ doc?: string;
437
+ };
387
438
  /** Reusable definition (Flash MovieClip-style symbol) stored in the library. */
388
439
  type SymbolDef = {
389
440
  id: string;
390
441
  name: string;
391
442
  layers: Layer[];
392
443
  timeline?: Timeline;
444
+ states?: StateMachine[];
445
+ params?: ParamDef[];
393
446
  folderId?: string;
394
447
  };
395
448
  /**
@@ -503,4 +556,4 @@ type EditFrame = {
503
556
  };
504
557
  type Tool = 'brush' | 'rect' | 'ellipse' | 'eraser' | 'fill' | 'select' | 'transform' | 'text' | 'pan' | 'pen' | 'pathselect' | 'ink';
505
558
 
506
- export type { Action, Asset, BBox, BlendMode, Cel, ContentKey, ContentTrack, Doc, Easing, EditFrame, ExprChannel, ExprContext, Filter, Folder, FrameAction, FrameLabel, FuncDef, Group, Image, Instance, InstanceBind, InstancePlayback, Interaction, Interactor, Item, ItemEvent, ItemInteractionState, Keyframe, Layer, Paint, Path, PlaybackMode, Point, PolyGroup, Polygon, Pose, Region, ResolveOpts, Ring, Seg, SendPayload, Shape, SoundClip, SpinDir, Stop, Stroke, Subpath, SymbolDef, Text, Timeline, TimelineTrack, Tint, Tool, Transform };
559
+ export type { Action, Asset, BBox, BlendMode, Cel, ClipRect, ContentKey, ContentTrack, Doc, Easing, EditFrame, ExprChannel, ExprContext, Filter, Folder, FrameAction, FrameLabel, FuncDef, Group, Image, Instance, InstanceBind, InstancePlayback, Interaction, Interactor, Item, ItemEvent, ItemInteractionState, Keyframe, Layer, Paint, ParamDef, ParamType, Path, PlaybackMode, Point, PolyGroup, Polygon, Pose, Region, ResolveOpts, Ring, Seg, SendPayload, Shape, SoundClip, SpinDir, StateAnchor, StateMachine, Stop, Stroke, Subpath, SymbolDef, Text, Timeline, TimelineTrack, Tint, Tool, Transform };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkit/types",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Shared types for the FlatInk format (Doc, Layer, Item, …). The leaf of the dependency graph.",
5
5
  "license": "MIT",
6
6
  "author": "Zwyk Studio",