@flatkit/types 0.19.5 → 0.19.7

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 +26 -2
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -122,6 +122,20 @@ type Keyframe = {
122
122
  };
123
123
  /** Channels animatable by expression (= the decomposed components + opacity). */
124
124
  type ExprChannel = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'opacity';
125
+ /** A STATEFUL channel modifier: instead of a pure expression, the channel INTEGRATES over time toward
126
+ * `target` (a normal expression). State lives per (instance, channel) in the player, advanced at a fixed
127
+ * step, independent of `onEnterFrame`/input; on random access (seek/render) it snaps to `target` (the rest
128
+ * pose). Pure & bounded — cannot diverge. See docs/design-channel-modifiers-spike.md. */
129
+ type ChannelModifier = {
130
+ kind: 'smooth';
131
+ target: string;
132
+ k: number;
133
+ } | {
134
+ kind: 'spring';
135
+ target: string;
136
+ stiffness: number;
137
+ damping: number;
138
+ };
125
139
  type TimelineTrack = {
126
140
  id: string;
127
141
  targetId: string;
@@ -330,7 +344,10 @@ type ItemInteractionState = {
330
344
  pressed: number;
331
345
  };
332
346
  /** Resolution context (container expressions + guide layer). `itemState` lets channel expressions read the
333
- * object's own interaction state (`self.hovered`…); the PLAYER provides it, absent elsewhere (flags → 0). */
347
+ * object's own interaction state (`self.hovered`…); the PLAYER provides it, absent elsewhere (flags → 0).
348
+ * `statePath` is the composed ancestor-instance path of the current scope (empty at the root) and
349
+ * `channelValue` returns the PLAYER's integrated value for a stateful channel modifier (`smooth`/`spring`)
350
+ * keyed by `statePath+itemId`; absent (random access: seek/render) → the channel snaps to its target. */
334
351
  type ResolveOpts = {
335
352
  fps?: number;
336
353
  ctx?: ExprContext;
@@ -338,6 +355,9 @@ type ResolveOpts = {
338
355
  orient?: boolean;
339
356
  parent?: Transform;
340
357
  itemState?: (id: string) => ItemInteractionState | undefined;
358
+ statePath?: string;
359
+ channelValue?: (key: string, ch: ExprChannel) => number | undefined;
360
+ onModifierTarget?: (key: string, ch: ExprChannel, mod: ChannelModifier, target: number) => void;
341
361
  };
342
362
  type Region = {
343
363
  id: string;
@@ -381,6 +401,7 @@ type Group = {
381
401
  h: number;
382
402
  };
383
403
  expressions?: Partial<Record<ExprChannel, string>>;
404
+ modifiers?: Partial<Record<ExprChannel, ChannelModifier>>;
384
405
  clip?: ClipRect;
385
406
  };
386
407
  /** Instance of a reusable symbol: a transform + a reference to the symbol. */
@@ -399,6 +420,7 @@ type Instance = {
399
420
  filters?: Filter[];
400
421
  blend?: BlendMode;
401
422
  expressions?: Partial<Record<ExprChannel, string>>;
423
+ modifiers?: Partial<Record<ExprChannel, ChannelModifier>>;
402
424
  params?: Record<string, string>;
403
425
  clip?: ClipRect;
404
426
  };
@@ -515,6 +537,7 @@ type Text = {
515
537
  filters?: Filter[];
516
538
  blend?: BlendMode;
517
539
  expressions?: Partial<Record<ExprChannel, string>>;
540
+ modifiers?: Partial<Record<ExprChannel, ChannelModifier>>;
518
541
  };
519
542
  /** Bitmap image: a leaf item animatable like text. References an asset; `w`/`h` = intrinsic size in px
520
543
  * (local coords, origin = top-left corner). */
@@ -534,6 +557,7 @@ type Image = {
534
557
  filters?: Filter[];
535
558
  blend?: BlendMode;
536
559
  expressions?: Partial<Record<ExprChannel, string>>;
560
+ modifiers?: Partial<Record<ExprChannel, ChannelModifier>>;
537
561
  };
538
562
  /** Layer content: material, one-off group, symbol instance, text, or image. */
539
563
  type Item = Region | Group | Instance | Text | Image;
@@ -589,4 +613,4 @@ type EditFrame = {
589
613
  };
590
614
  type Tool = 'brush' | 'rect' | 'ellipse' | 'eraser' | 'fill' | 'select' | 'transform' | 'text' | 'pan' | 'pen' | 'pathselect' | 'ink';
591
615
 
592
- 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, TextPath, Timeline, TimelineTrack, Tint, Tool, Transform };
616
+ export type { Action, Asset, BBox, BlendMode, Cel, ChannelModifier, 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, TextPath, Timeline, TimelineTrack, Tint, Tool, Transform };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkit/types",
3
- "version": "0.19.5",
3
+ "version": "0.19.7",
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",