@popcraft/kit 0.1.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/index.js +160558 -0
- package/package.json +40 -0
- package/types/design-script.d.ts +39 -0
- package/types/lib/agent/design-script/build.d.ts +35 -0
- package/types/lib/agent/design-script/check.d.ts +11 -0
- package/types/lib/agent/design-script/helper-names.d.ts +1 -0
- package/types/lib/agent/design-script/kit-modules.d.ts +43 -0
- package/types/lib/agent/design-script/recorder.d.ts +52 -0
- package/types/lib/agent/design-script/replay.d.ts +13 -0
- package/types/lib/agent/design-script/run-node.d.ts +2 -0
- package/types/lib/ai/audio-models.d.ts +66 -0
- package/types/lib/ai/content.d.ts +27 -0
- package/types/lib/ai/limits.d.ts +42 -0
- package/types/lib/audio/presentation/loudness.d.ts +80 -0
- package/types/lib/audio/presentation/types.d.ts +112 -0
- package/types/lib/brand/apply.d.ts +25 -0
- package/types/lib/brand/review-kits.d.ts +10 -0
- package/types/lib/brand/types.d.ts +20 -0
- package/types/lib/code/hash.d.ts +2 -0
- package/types/lib/document/auto-layout.d.ts +10 -0
- package/types/lib/document/breakpoints.d.ts +45 -0
- package/types/lib/document/clone.d.ts +6 -0
- package/types/lib/document/color.d.ts +52 -0
- package/types/lib/document/detach.d.ts +12 -0
- package/types/lib/document/effects.d.ts +60 -0
- package/types/lib/document/expressions.d.ts +78 -0
- package/types/lib/document/instance-layout.d.ts +94 -0
- package/types/lib/document/instances.d.ts +63 -0
- package/types/lib/document/libraries.d.ts +97 -0
- package/types/lib/document/node-delta.d.ts +21 -0
- package/types/lib/document/page-tokens.d.ts +16 -0
- package/types/lib/document/photo-frames.d.ts +14 -0
- package/types/lib/document/print-pages.d.ts +85 -0
- package/types/lib/document/scene-graph.d.ts +194 -0
- package/types/lib/document/scene3d.d.ts +76 -0
- package/types/lib/document/shader-graph-effects.d.ts +8 -0
- package/types/lib/document/shader-graph.d.ts +134 -0
- package/types/lib/document/shader-params.d.ts +65 -0
- package/types/lib/document/shape-to-path.d.ts +20 -0
- package/types/lib/document/text-styles.d.ts +28 -0
- package/types/lib/document/text-tokens.d.ts +6 -0
- package/types/lib/document/transform.d.ts +79 -0
- package/types/lib/document/transform3d.d.ts +99 -0
- package/types/lib/document/trim.d.ts +35 -0
- package/types/lib/document/types.d.ts +2560 -0
- package/types/lib/document/variables.d.ts +14 -0
- package/types/lib/editor/easing.d.ts +46 -0
- package/types/lib/editor/modes/types.d.ts +131 -0
- package/types/lib/editor/prototype-connect.d.ts +49 -0
- package/types/lib/editor/smart-animate.d.ts +37 -0
- package/types/lib/engine/geometry/flatten.d.ts +2 -0
- package/types/lib/engine/geometry/shape-outline.d.ts +24 -0
- package/types/lib/engine/pixel/cells.d.ts +12 -0
- package/types/lib/engine/pixel/palettes.d.ts +25 -0
- package/types/lib/engine/readiness.d.ts +20 -0
- package/types/lib/engine/routing.d.ts +41 -0
- package/types/lib/engine/shader-graph-presets.d.ts +22 -0
- package/types/lib/engine/shader-presets-legacy.d.ts +7 -0
- package/types/lib/engine/shader-presets.d.ts +43 -0
- package/types/lib/engine/text/atlas.d.ts +120 -0
- package/types/lib/engine/text/emoji/segment.d.ts +15 -0
- package/types/lib/engine/text/fallback-fonts.d.ts +47 -0
- package/types/lib/engine/text/fontkit-lazy.d.ts +8 -0
- package/types/lib/engine/text/fonts.d.ts +33 -0
- package/types/lib/engine/text/glyph-linear.d.ts +22 -0
- package/types/lib/engine/text/google-fonts.d.ts +17 -0
- package/types/lib/engine/text/hyphenate/en-us.d.ts +6 -0
- package/types/lib/engine/text/hyphenate/liang.d.ts +21 -0
- package/types/lib/engine/text/layout-access.d.ts +16 -0
- package/types/lib/engine/text/layout.d.ts +168 -0
- package/types/lib/engine/text/lists.d.ts +16 -0
- package/types/lib/engine/text/measure.d.ts +58 -0
- package/types/lib/engine/text/outline-sdf.d.ts +34 -0
- package/types/lib/engine/text/shaper.d.ts +88 -0
- package/types/lib/engine/text/text-area.d.ts +16 -0
- package/types/lib/engine/text/text-fit.d.ts +51 -0
- package/types/lib/engine/text/text-path.d.ts +134 -0
- package/types/lib/engine/text/text-rings.d.ts +17 -0
- package/types/lib/engine/text/wrap-obstacles.d.ts +20 -0
- package/types/lib/i18n/catalogs.d.ts +10 -0
- package/types/lib/i18n/format.d.ts +27 -0
- package/types/lib/i18n/locales.d.ts +25 -0
- package/types/lib/i18n/pseudo.d.ts +10 -0
- package/types/lib/i18n/runtime.d.ts +27 -0
- package/types/lib/io/codecs/wav.d.ts +7 -0
- package/types/lib/io/codecs/webp.d.ts +7 -0
- package/types/lib/io/export-ir/children.d.ts +2 -0
- package/types/lib/io/json-export.d.ts +11 -0
- package/types/lib/media-library/types.d.ts +39 -0
- package/types/lib/motion/audio-analysis.d.ts +44 -0
- package/types/lib/motion/audio-clips.d.ts +92 -0
- package/types/lib/motion/audio-onsets.d.ts +13 -0
- package/types/lib/motion/audio-signals.d.ts +59 -0
- package/types/lib/motion/author.d.ts +80 -0
- package/types/lib/motion/composition.d.ts +99 -0
- package/types/lib/motion/instances.d.ts +95 -0
- package/types/lib/motion/key-selection.d.ts +100 -0
- package/types/lib/motion/keys.d.ts +41 -0
- package/types/lib/motion/layer-time-edit.d.ts +40 -0
- package/types/lib/motion/markers.d.ts +31 -0
- package/types/lib/motion/modifier-edit.d.ts +84 -0
- package/types/lib/motion/modifiers.d.ts +44 -0
- package/types/lib/motion/morph.d.ts +14 -0
- package/types/lib/motion/pose-layout.d.ts +6 -0
- package/types/lib/motion/pose.d.ts +115 -0
- package/types/lib/motion/presets.d.ts +148 -0
- package/types/lib/motion/properties.d.ts +74 -0
- package/types/lib/motion/sample-keys.d.ts +8 -0
- package/types/lib/motion/sample.d.ts +51 -0
- package/types/lib/motion/sound.d.ts +25 -0
- package/types/lib/motion/spatial-curve.d.ts +15 -0
- package/types/lib/motion/spatial.d.ts +38 -0
- package/types/lib/motion/text-animators.d.ts +79 -0
- package/types/lib/motion/text-units.d.ts +47 -0
- package/types/lib/motion/time.d.ts +58 -0
- package/types/lib/motion/transitions.d.ts +99 -0
- package/types/lib/motion/values.d.ts +12 -0
- package/types/lib/motion/video-clip.d.ts +63 -0
- package/types/lib/presets/page-presets.d.ts +50 -0
- package/types/lib/storage/media-hash.d.ts +4 -0
- package/types/lib/storage/media-refs.d.ts +2 -0
- package/types/lib/storage/media-store.d.ts +70 -0
- package/types/lib/templates/apply.d.ts +38 -0
- package/types/lib/templates/capture.d.ts +25 -0
- package/types/lib/templates/groups.d.ts +82 -0
- package/types/lib/templates/layout.d.ts +20 -0
- package/types/lib/templates/quality.d.ts +59 -0
- package/types/lib/templates/resize.d.ts +34 -0
- package/types/lib/templates/safe-areas.d.ts +42 -0
- package/types/lib/templates/text-measurer.d.ts +10 -0
- package/types/lib/templates/thumbnail.d.ts +134 -0
- package/types/lib/templates/types.d.ts +95 -0
- package/types/lib/templates/vocabulary.d.ts +50 -0
- package/types/lib/units/units.d.ts +23 -0
- package/types/packages/kit/src/index.d.ts +59 -0
- package/types/packages/runtime/src/expressions.d.ts +41 -0
- package/types/templates/src/app/shared.d.ts +29 -0
- package/types/templates/src/audio/beat-loop.d.ts +9 -0
- package/types/templates/src/audio/media.d.ts +42 -0
- package/types/templates/src/audio/music-synth.d.ts +57 -0
- package/types/templates/src/audio/music-worlds.d.ts +8 -0
- package/types/templates/src/audio/music.d.ts +19 -0
- package/types/templates/src/audio/studio/deck.d.ts +340 -0
- package/types/templates/src/audio/studio/dsp.d.ts +151 -0
- package/types/templates/src/audio/studio/fx.d.ts +96 -0
- package/types/templates/src/audio/studio/mix.d.ts +84 -0
- package/types/templates/src/audio/studio/voices.d.ts +120 -0
- package/types/templates/src/data/geometry.d.ts +16 -0
- package/types/templates/src/effects/shared.d.ts +17 -0
- package/types/templates/src/kit.d.ts +582 -0
- package/types/templates/src/motion3d/devices.d.ts +42 -0
- package/types/templates/src/motion3d/ui.d.ts +48 -0
- package/types/templates/src/saas/video-shared.d.ts +114 -0
- package/types/templates/src/saas/web-shared.d.ts +74 -0
- package/types/templates/src/shared/beat.d.ts +24 -0
- package/types/templates/src/shared/captions.d.ts +24 -0
- package/types/templates/src/shared/devices.d.ts +188 -0
- package/types/templates/src/shared/draw.d.ts +43 -0
- package/types/templates/src/shared/fit.d.ts +73 -0
- package/types/templates/src/shared/marks.d.ts +51 -0
- package/types/templates/src/shared/motion.d.ts +15 -0
- package/types/templates/src/shared/overlays.d.ts +80 -0
- package/types/templates/src/shared/pointer.d.ts +46 -0
- package/types/templates/src/shared/texture.d.ts +41 -0
- package/types/templates/src/shared/type.d.ts +6 -0
- package/types/templates/src/shared/window.d.ts +50 -0
- package/types/templates/src/social/shared.d.ts +66 -0
- package/types/templates/src/web/shared.d.ts +64 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AnyNode, Composition, Document, EaseFamily, Interp, Modifier, MotionValue, NodeMotion, SceneTransition, ShaderParamValue, Stagger, StaggerOrder, TextCounter, TextNode, TimelineFps } from '../document/types.js';
|
|
2
|
+
/** A key as written: at `t` ms (layer time) the value `v`, travelling to the next key along `ease`. */
|
|
3
|
+
export interface KeySpec {
|
|
4
|
+
t: number;
|
|
5
|
+
v: MotionValue;
|
|
6
|
+
ease?: Interp;
|
|
7
|
+
}
|
|
8
|
+
type Direction = 'in' | 'out' | 'in-out';
|
|
9
|
+
/** The curves, by name. `back`'s `c` is its overshoot (1.70158 is the classic; the trailer uses 1.9). */
|
|
10
|
+
export declare const ease: {
|
|
11
|
+
linear: Interp;
|
|
12
|
+
hold: Interp;
|
|
13
|
+
named: (family: EaseFamily, dir?: Direction) => Interp;
|
|
14
|
+
in: (family?: EaseFamily) => Interp;
|
|
15
|
+
out: (family?: EaseFamily) => Interp;
|
|
16
|
+
inOut: (family?: EaseFamily) => Interp;
|
|
17
|
+
back: (c?: number, dir?: Direction) => Interp;
|
|
18
|
+
bezier: (x1: number, y1: number, x2: number, y2: number) => Interp;
|
|
19
|
+
spring: (stiffness?: number, damping?: number, mass?: number) => Interp;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `node` with `path` animated through `keys` (replacing keys it already had at those times). The item the path
|
|
23
|
+
* addresses gets a stable id when it has none (`fills[#0].color` → `fills[@f1].color`).
|
|
24
|
+
*
|
|
25
|
+
* A key's `ease` is the curve out of it, to the next key. The track's last key has no next key, so unless one
|
|
26
|
+
* is given it holds: a curve there would be dead data the graph editor still draws (the templates' motion
|
|
27
|
+
* lint rejects it).
|
|
28
|
+
*/
|
|
29
|
+
export declare function animate(node: AnyNode, path: string, keys: readonly KeySpec[]): AnyNode;
|
|
30
|
+
/**
|
|
31
|
+
* `node` with a SHADER fill's param animated: `fill` is the fill's address (`fills[#0]`), `name` the `struct Params`
|
|
32
|
+
* field (or, on a built-in preset, its param's old name: `speed` for `mesh_speed`). An f32 takes numbers; a colour or
|
|
33
|
+
* vector takes whole values, keyed on each of its components' tracks (`.tint.r`, `.tint.g`, …) with the same times
|
|
34
|
+
* and eases.
|
|
35
|
+
*/
|
|
36
|
+
export declare function animateShaderParam(node: AnyNode, fill: string, name: string, keys: readonly {
|
|
37
|
+
t: number;
|
|
38
|
+
v: ShaderParamValue;
|
|
39
|
+
ease?: Interp;
|
|
40
|
+
}[]): AnyNode;
|
|
41
|
+
/** How long a new counter counts (ms). */
|
|
42
|
+
export declare const COUNT_MS = 1500;
|
|
43
|
+
/**
|
|
44
|
+
* `node` counting: up from `counter.from` to `counter.to` (by default 0 to the figure it shows, or 0 → 100), keyed from
|
|
45
|
+
* layer time `t` over `ms` on an expo-out — what the design panel's "Count up to its figure" makes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function countUp(node: TextNode, t: number, ms?: number, counter?: TextCounter): TextNode;
|
|
48
|
+
/** `node` and its subtree starting `ms` later in its parent's time (a layer start). */
|
|
49
|
+
export declare const delay: (node: AnyNode, ms: number) => AnyNode;
|
|
50
|
+
/** `container` staggering its children: each starts `delayMs` after the one before it, in `order`. */
|
|
51
|
+
export declare function stagger(container: AnyNode, delayMs: number, order?: StaggerOrder, more?: Omit<Stagger, 'delay' | 'order'>): AnyNode;
|
|
52
|
+
/** `motion` with its keyed positions moved by (dx, dy): a layer re-parented keeps travelling where it did. */
|
|
53
|
+
export declare const shiftPositionKeys: (motion: NodeMotion | undefined, dx: number, dy: number) => NodeMotion | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* `ids` and their tracks wrapped into a motion component, in place: the layers play exactly as they did in their
|
|
56
|
+
* frame, and the component gets a timeline of its own that starts where their motion starts (its offset in the
|
|
57
|
+
* frame carries the difference), so every instance plays it from 0. Null when none of the ids exists.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createMotionComponent(doc: Document, ids: readonly string[], fallbackParentId: string, name?: string): {
|
|
60
|
+
document: Document;
|
|
61
|
+
componentId: string;
|
|
62
|
+
} | null;
|
|
63
|
+
/**
|
|
64
|
+
* `node` with behaviours on `path` (spin, sine, wiggle, bounce, loop…), after any it already has — on top of its
|
|
65
|
+
* keys, or on the rest value when it has none (a constant spin needs no keys).
|
|
66
|
+
*/
|
|
67
|
+
export declare function behave(node: AnyNode, path: string, modifiers: readonly Modifier[]): AnyNode;
|
|
68
|
+
/**
|
|
69
|
+
* A composition playing `frames` in order, each for its whole timeline, with `transitions[i]` INTO scene i + 1 (null:
|
|
70
|
+
* a cut). Sized like the first frame, at `fps`. Transitions longer than the two scenes overlap are clamped.
|
|
71
|
+
*/
|
|
72
|
+
export declare function sceneSequence(nodes: Record<string, AnyNode>, opts: {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
frames: readonly string[];
|
|
76
|
+
fps: TimelineFps;
|
|
77
|
+
transitions?: readonly (SceneTransition | null)[];
|
|
78
|
+
background?: Composition['background'];
|
|
79
|
+
}): Composition;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { AnyNode, Composition, FrameTimeline, Interp, SceneClip, SceneTransition, TimelineFps, TransitionType } from '../document/types.js';
|
|
2
|
+
import { type PlaybackMapping } from './time.js';
|
|
3
|
+
import { type RenderRoot, type Stage } from './transitions.js';
|
|
4
|
+
/** How long a clip plays (ms). */
|
|
5
|
+
export declare const clipLength: (c: Pick<SceneClip, "in" | "out">) => number;
|
|
6
|
+
/** Where a clip stops (composition ms). */
|
|
7
|
+
export declare const clipEnd: (c: SceneClip) => number;
|
|
8
|
+
/** How long the composition runs: to the end of its last clip. */
|
|
9
|
+
export declare function compositionDuration(comp: Pick<Composition, 'clips'>): number;
|
|
10
|
+
/** The composition as a timeline (its length, frame rate, work area, markers): what the transport and the ruler read. */
|
|
11
|
+
export declare function compositionTimeline(comp: Composition): FrameTimeline;
|
|
12
|
+
/** A clip's playback: its trim as the range, played at speed 1 from its start, holding its last frame. */
|
|
13
|
+
export declare function clipPlayback(c: Pick<SceneClip, 'in' | 'out'>): PlaybackMapping;
|
|
14
|
+
/** The frame time clip `c` shows at composition time `t`. */
|
|
15
|
+
export declare const clipLocalTime: (c: SceneClip, t: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* `clips` in sequence: the first at 0, each next one where the one before ends minus its transition (clamped to
|
|
18
|
+
* what fits). The same array when nothing moves.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sequenceClips(clips: readonly SceneClip[]): SceneClip[];
|
|
21
|
+
/** A clip playing at a moment: which, and at what frame time. */
|
|
22
|
+
export interface ActiveClip {
|
|
23
|
+
clip: SceneClip;
|
|
24
|
+
index: number;
|
|
25
|
+
local: number;
|
|
26
|
+
}
|
|
27
|
+
/** What a composition shows at `t`: the clip playing, and while its transition runs, the clip it replaces and the eased progress. */
|
|
28
|
+
export interface CompositionMoment {
|
|
29
|
+
current: ActiveClip | null;
|
|
30
|
+
previous: ActiveClip | null;
|
|
31
|
+
transition: {
|
|
32
|
+
type: TransitionType;
|
|
33
|
+
progress: number;
|
|
34
|
+
params?: SceneTransition['params'];
|
|
35
|
+
} | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The clips at composition time `t`. A clip owns [start, end); the last clip also holds its last frame at and past
|
|
39
|
+
* the end, and the first shows its first frame before 0. Inside a clip's transition the clip before plays on
|
|
40
|
+
* underneath it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function compositionAt(comp: Pick<Composition, 'clips'>, t: number): CompositionMoment;
|
|
43
|
+
/** The world rectangle the composition shows on: centred on its first scene's frame. */
|
|
44
|
+
export declare function compositionStage(comp: Composition, centerOf: (frameId: string) => {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
} | null): Stage | null;
|
|
48
|
+
/**
|
|
49
|
+
* The roots the composition draws at `t` on `stage`, bottom to top: every scene centred on the stage, and while a
|
|
50
|
+
* transition runs the two scenes as the transition places them (lib/motion/transitions.ts). Roots that draw
|
|
51
|
+
* nothing (faded out, clipped to nothing) are left out.
|
|
52
|
+
*/
|
|
53
|
+
export declare function compositionRoots(moment: CompositionMoment, stage: Stage, frameOf: (frameId: string) => {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
cx: number;
|
|
57
|
+
cy: number;
|
|
58
|
+
} | null): RenderRoot[];
|
|
59
|
+
/** A new id for a clip or composition (unique within a document for any practical purpose). */
|
|
60
|
+
export declare const compositionId: (prefix: "comp" | "clip") => string;
|
|
61
|
+
/** The default transition curve: ease in-out. */
|
|
62
|
+
export declare const DEFAULT_TRANSITION_INTERP: Interp;
|
|
63
|
+
/** A clip for `frameId`: its whole timeline (`duration` ms). */
|
|
64
|
+
export declare const newClip: (frameId: string, duration: number, id?: string) => SceneClip;
|
|
65
|
+
/**
|
|
66
|
+
* A composition playing `frameIds` in order, each for its whole timeline: sized like the first frame, at its frame
|
|
67
|
+
* rate. `durationOf` gives each frame's timeline length.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createComposition(opts: {
|
|
70
|
+
frames: readonly AnyNode[];
|
|
71
|
+
durationOf: (frameId: string) => number;
|
|
72
|
+
fpsOf: (frameId: string) => TimelineFps;
|
|
73
|
+
name?: string;
|
|
74
|
+
id?: string;
|
|
75
|
+
}): Composition | null;
|
|
76
|
+
/** `comp` with clip `clipId` moved to position `to` (its transition goes with it; the first clip has none). */
|
|
77
|
+
export declare function moveClip(comp: Composition, clipId: string, to: number): Composition;
|
|
78
|
+
/**
|
|
79
|
+
* `comp` with clip `clipId` trimmed: `in` and/or `out` in frame ms, kept `0 ≤ in < out` with at least one frame
|
|
80
|
+
* (at the composition's rate) between them. Later clips ripple.
|
|
81
|
+
*/
|
|
82
|
+
export declare function trimClip(comp: Composition, clipId: string, trim: {
|
|
83
|
+
in?: number;
|
|
84
|
+
out?: number;
|
|
85
|
+
}): Composition;
|
|
86
|
+
/** `comp` with clip `clipId`'s transition in set (null: a cut). Its duration is clamped to what the overlap allows. */
|
|
87
|
+
export declare function setClipTransition(comp: Composition, clipId: string, transition: SceneTransition | null): Composition;
|
|
88
|
+
/** `comp` with a clip for `frameId` added at position `at` (the end by default). */
|
|
89
|
+
export declare function addClip(comp: Composition, frameId: string, duration: number, at?: number): Composition;
|
|
90
|
+
/**
|
|
91
|
+
* `comp` with clip `clipId` playing frame `frameId` instead, its transition kept. A clip that played its whole frame
|
|
92
|
+
* (`wholeOld`: in at 0, out at the old frame's end) plays the whole new one (`newDuration`); a trimmed clip keeps its
|
|
93
|
+
* trim, within the new frame's length.
|
|
94
|
+
*/
|
|
95
|
+
export declare function setClipFrame(comp: Composition, clipId: string, frameId: string, newDuration: number, wholeOld: boolean): Composition;
|
|
96
|
+
/** `comp` without clip `clipId`. */
|
|
97
|
+
export declare function removeClip(comp: Composition, clipId: string): Composition;
|
|
98
|
+
/** The index a clip dropped at composition time `t` lands at: before the first clip whose middle is after `t`. */
|
|
99
|
+
export declare function dropIndex(comp: Composition, clipId: string, t: number): number;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { AnyNode, ComponentPropertyDefinition, ComponentPropertyType, FrameTimeline, PlaybackField } from '../document/types.js';
|
|
2
|
+
import { type PlaybackMapping } from './time.js';
|
|
3
|
+
/** What present mode knows about one instance (by id: real, or virtual for a nested one). */
|
|
4
|
+
export interface InstanceRun {
|
|
5
|
+
/** ms since its trigger fired or its state last changed; unset: not triggered. */
|
|
6
|
+
elapsed?: number;
|
|
7
|
+
/** The variant it shows instead of its stored one (a CHANGE_TO). */
|
|
8
|
+
component?: string;
|
|
9
|
+
/** A state change still gliding (absent once it has landed): the variant it left, that one's time when it left, and the eased progress. */
|
|
10
|
+
from?: {
|
|
11
|
+
componentId: string;
|
|
12
|
+
time: number;
|
|
13
|
+
progress: number;
|
|
14
|
+
};
|
|
15
|
+
/** Held at this component time by a TIMELINE action (a drag scrubbing it, a pause, a seek): its clock does not run. */
|
|
16
|
+
scrub?: number;
|
|
17
|
+
/** A seek or a settle still gliding the held time: later moments look different. */
|
|
18
|
+
gliding?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type InstanceRuntime = ReadonlyMap<string, InstanceRun>;
|
|
21
|
+
/** No triggers, no state changes: Animate's transport and export. */
|
|
22
|
+
export declare const NO_RUNTIME: InstanceRuntime;
|
|
23
|
+
/** The animated layers of `componentId`'s subtree (memoised per node map). */
|
|
24
|
+
export declare function componentLayers(nodes: Record<string, AnyNode>, componentId: string): readonly AnyNode[];
|
|
25
|
+
/** Instances directly inside `rootId`'s subtree (the walk stops at each instance: its own children are its component's). */
|
|
26
|
+
export declare function nestedInstances(nodes: Record<string, AnyNode>, rootId: string): readonly string[];
|
|
27
|
+
/** Whether `componentId` animates: its own layers, or an instance in it of a component that does. */
|
|
28
|
+
export declare function isMotionComponent(nodes: Record<string, AnyNode>, componentId: string, visiting?: Set<string>): boolean;
|
|
29
|
+
/** `componentId`, or any variant of its set, animates: an instance of it can play a timeline. */
|
|
30
|
+
export declare function isMotionFamily(nodes: Record<string, AnyNode>, componentId: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The instance a layer of an instance belongs to: `id` itself when it is one, else the nearest instance up its
|
|
33
|
+
* virtual path (`host::child` → `host`). What a CHANGE_TO on a layer inside a variant (a tab of a tab bar)
|
|
34
|
+
* changes: the whole instance, not the layer that was clicked. Null outside any instance.
|
|
35
|
+
*/
|
|
36
|
+
export declare function hostInstanceOf(nodes: Record<string, AnyNode>, id: string): string | null;
|
|
37
|
+
/** Every instance (real ids) of a motion component, or of a set with one. Memoised per node map. */
|
|
38
|
+
export declare function motionInstanceIds(nodes: Record<string, AnyNode>): readonly string[];
|
|
39
|
+
/** How `instance` plays `componentId`: its own playback over the component's MOTION property defaults, over the defaults. */
|
|
40
|
+
export declare function playbackOf(nodes: Record<string, AnyNode>, instance: AnyNode, componentId: string): PlaybackMapping;
|
|
41
|
+
/**
|
|
42
|
+
* Where instance `id` (real, or `host::…::nested`) is: the component it shows and that component's time, `layerElapsed`
|
|
43
|
+
* ms into its layer time (null when that is unknown, e.g. a nested instance) — what a state change glides from.
|
|
44
|
+
*/
|
|
45
|
+
export declare function instanceNow(nodes: Record<string, AnyNode>, id: string, run: InstanceRun | undefined, layerElapsed: number | null): {
|
|
46
|
+
component: string;
|
|
47
|
+
time: number;
|
|
48
|
+
} | null;
|
|
49
|
+
/** How `id` starts playing on its own trigger (null: it is not a motion instance, or it starts by itself). */
|
|
50
|
+
export declare function instanceTrigger(nodes: Record<string, AnyNode>, id: string, run: InstanceRun | undefined): PlaybackMapping['trigger'] | null;
|
|
51
|
+
/** How long a timeline runs (ms): its set duration, else its content — keys and instances — rounded up to half a second (2 s at least). */
|
|
52
|
+
export declare function timelineDuration(nodes: Record<string, AnyNode>, rootId: string): number;
|
|
53
|
+
/** A frame's (or component's) timeline as stored, or the one it implies when it has none yet. */
|
|
54
|
+
export declare function frameTimeline(nodes: Record<string, AnyNode>, rootId: string): FrameTimeline;
|
|
55
|
+
/** When everything under `rootId` has landed, in its time: its layers' last keys, and each instance's playback end. Loops are left out (see `frameRunsOn`). */
|
|
56
|
+
export declare function frameMotionEnd(nodes: Record<string, AnyNode>, rootId: string): number;
|
|
57
|
+
/** Whether anything under `rootId` keeps changing for ever: a behaviour, or a looping instance. */
|
|
58
|
+
export declare function frameRunsOn(nodes: Record<string, AnyNode>, rootId: string): boolean;
|
|
59
|
+
/** Whether `rootId` has anything to play: animated layers, or instances of motion components. */
|
|
60
|
+
export declare function hasFrameMotion(nodes: Record<string, AnyNode>, rootId: string): boolean;
|
|
61
|
+
/** What one instance contributes to the pose. */
|
|
62
|
+
interface Posed {
|
|
63
|
+
patches: Record<string, AnyNode>;
|
|
64
|
+
live: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Instance `id`'s posed children (and its own node, when it changes) with its component at `componentMs`: one
|
|
68
|
+
* moment of its playback, whatever its mapping. What export samples the component's timeline through.
|
|
69
|
+
*/
|
|
70
|
+
export declare function instancePoseAt(nodes: Record<string, AnyNode>, id: string, componentMs: number): Record<string, AnyNode>;
|
|
71
|
+
/**
|
|
72
|
+
* The posed children (and hosts) of every motion instance under `rootId` with the root at `rootMs`: virtual ids for
|
|
73
|
+
* children, real ids for instances whose own node changes. `base` holds the root's own posed layers (an instance
|
|
74
|
+
* that moves as a layer of the root plays its component from where it is).
|
|
75
|
+
*/
|
|
76
|
+
export declare function sampleInstances(nodes: Record<string, AnyNode>, rootId: string, rootMs: number, runtime?: InstanceRuntime, base?: Record<string, AnyNode>): Posed;
|
|
77
|
+
/**
|
|
78
|
+
* What keeps a motion component's inputs from working, as sentences (empty: none). Every property must reach
|
|
79
|
+
* something — a TEXT property a text layer, a NUMBER / COLOR property a bound path or a bound key, a MOTION property
|
|
80
|
+
* a playback field — and no text layer bound to a TEXT property may key its words with values of its own, which
|
|
81
|
+
* would ignore what each instance types. A variant is checked with its set's properties, over the whole set.
|
|
82
|
+
*/
|
|
83
|
+
export declare function motionComponentProblems(nodes: Record<string, AnyNode>, componentId: string): string[];
|
|
84
|
+
/**
|
|
85
|
+
* A new component property of `type` with its starting values: NUMBER 0 in 0–100, COLOR a blue, MOTION the default of
|
|
86
|
+
* the playback field it `binds` (speed unless given); the others their plain defaults.
|
|
87
|
+
*/
|
|
88
|
+
export declare function newPropertyDefinition(type: ComponentPropertyType, binds?: PlaybackField): ComponentPropertyDefinition;
|
|
89
|
+
/**
|
|
90
|
+
* The props that make `path` of `node` (a layer inside a component) the input fed by property `name` — or, with no
|
|
91
|
+
* path, that stop `name` feeding any of the layer's paths. An item the path addresses without an id yet (a fill made
|
|
92
|
+
* before any motion) gets one, since bound paths address items by id. Null when the path does not resolve on the node.
|
|
93
|
+
*/
|
|
94
|
+
export declare function layerInputPatch(node: AnyNode, name: string, path: string | null): Partial<AnyNode> | null;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { AnyNode, Interp, Key, KeyBinding, MotionValue, NodeMotion, PropPath, Track } from '../document/types.js';
|
|
2
|
+
/** One key: the layer, the track's path, and the key's id within that track. */
|
|
3
|
+
export interface KeyRef {
|
|
4
|
+
nodeId: string;
|
|
5
|
+
path: PropPath;
|
|
6
|
+
keyId: string;
|
|
7
|
+
}
|
|
8
|
+
/** The motion each changed node ends up with (undefined: the node keeps no motion). */
|
|
9
|
+
export type KeyEdit = Record<string, NodeMotion | undefined>;
|
|
10
|
+
/** A key found: its ref and the key itself. */
|
|
11
|
+
export interface ResolvedKey {
|
|
12
|
+
ref: KeyRef;
|
|
13
|
+
key: Key;
|
|
14
|
+
track: Track;
|
|
15
|
+
}
|
|
16
|
+
export declare const keyRefId: (r: KeyRef) => string;
|
|
17
|
+
export declare const sameKeyRef: (a: KeyRef, b: KeyRef) => boolean;
|
|
18
|
+
export type SelectMode = 'replace' | 'add' | 'toggle';
|
|
19
|
+
/**
|
|
20
|
+
* `sel` changed by `refs`: replace it, add them, or toggle them (Shift/⌘-click) — a toggle of several keys at once
|
|
21
|
+
* (a summary diamond) removes them when all were selected and adds the rest otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectKeys(sel: readonly KeyRef[], refs: readonly KeyRef[], mode: SelectMode): KeyRef[];
|
|
24
|
+
/** The ids of the selected keys on one track (`path`), or on every track of the layer (no `path`). */
|
|
25
|
+
export declare function selectedKeyIds(sel: readonly KeyRef[], nodeId: string, path?: PropPath): string[];
|
|
26
|
+
/** The keys `sel` names that still exist, with their tracks. */
|
|
27
|
+
export declare function resolveKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): ResolvedKey[];
|
|
28
|
+
/** `sel` without the keys that no longer exist (the same array when none went). */
|
|
29
|
+
export declare function pruneKeySelection(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): readonly KeyRef[];
|
|
30
|
+
/** Every key of `nodeId` (on `path`, or on all its tracks), as refs. */
|
|
31
|
+
export declare function keysOf(node: AnyNode | undefined, path?: PropPath): KeyRef[];
|
|
32
|
+
/** A row of the dopesheet, for a marquee: one track, or (no `path`) the layer's summary of all its tracks. */
|
|
33
|
+
export interface MarqueeRow {
|
|
34
|
+
nodeId: string;
|
|
35
|
+
path?: PropPath;
|
|
36
|
+
}
|
|
37
|
+
/** The keys on `rows` whose frame time is within [t0, t1]. */
|
|
38
|
+
export declare function marqueeKeys(nodes: Record<string, AnyNode>, frameId: string, rows: readonly MarqueeRow[], t0: number, t1: number): KeyRef[];
|
|
39
|
+
/** The key's frame time: its local time plus its layer's shift. */
|
|
40
|
+
export declare const frameTimeOf: (nodes: Record<string, AnyNode>, frameId: string, rk: ResolvedKey) => number;
|
|
41
|
+
/** Every key time under the frame, in frame time, sorted and unique (J/K, snapping). `except`: keys to leave out. */
|
|
42
|
+
export declare function frameKeyTimes(nodes: Record<string, AnyNode>, frameId: string, except?: readonly KeyRef[]): number[];
|
|
43
|
+
/** The nearest key time before (`dir` −1) or after (+1) `t`, more than half a ms away. */
|
|
44
|
+
export declare function adjacentKeyTime(times: readonly number[], t: number, dir: -1 | 1): number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* `t` snapped: to the nearest of `targets` within `threshold` ms (the playhead, other keys, markers, the work area),
|
|
47
|
+
* else to the frame grid (`frame` ms; 0 leaves whole ms).
|
|
48
|
+
*/
|
|
49
|
+
export declare function snapTime(t: number, targets: readonly number[], threshold: number, frame: number): number;
|
|
50
|
+
/** The selected keys `dt` ms later (earlier when negative), stopping at 0 for the earliest of them. */
|
|
51
|
+
export declare function moveKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[], dt: number): KeyEdit;
|
|
52
|
+
/**
|
|
53
|
+
* The selected keys `dt` ms later and, on number tracks, `dv` higher (the graph editor's drag). Times stop at 0 for
|
|
54
|
+
* the earliest of them; keys of other value types only move in time.
|
|
55
|
+
*/
|
|
56
|
+
export declare function moveKeysBy(nodes: Record<string, AnyNode>, sel: readonly KeyRef[], dt: number, dv: number): KeyEdit;
|
|
57
|
+
/** `edit` completed with the original motion of every other node of the selection, so a drag back to zero undoes. */
|
|
58
|
+
export declare function completeEdit(edit: KeyEdit, nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): KeyEdit;
|
|
59
|
+
/**
|
|
60
|
+
* The selected keys' frame times scaled by `factor` about frame time `pivot` (Alt-drag): 2 spreads them twice as
|
|
61
|
+
* far apart, 0.5 halves the gaps, a negative factor reverses them. Times stop at 0.
|
|
62
|
+
*/
|
|
63
|
+
export declare function scaleKeys(nodes: Record<string, AnyNode>, frameId: string, sel: readonly KeyRef[], pivot: number, factor: number): KeyEdit;
|
|
64
|
+
export declare function deleteKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): KeyEdit;
|
|
65
|
+
/** The selected keys' curve to the next key set to `interp` (discrete tracks always hold, and are left alone). */
|
|
66
|
+
export declare function setKeysInterp(nodes: Record<string, AnyNode>, sel: readonly KeyRef[], interp: Interp): KeyEdit;
|
|
67
|
+
/**
|
|
68
|
+
* The selected keys' values taken from component property `bind` (a motion component's input), or their own again
|
|
69
|
+
* (null). A bound key keeps its value as the fallback where the property has none. Fields `bind` leaves out keep what
|
|
70
|
+
* the key had — choosing the property again keeps its multiplier and offset — and a multiplier of 1 or an offset of 0
|
|
71
|
+
* is stored as none.
|
|
72
|
+
*/
|
|
73
|
+
export declare function setKeysBinding(nodes: Record<string, AnyNode>, sel: readonly KeyRef[], bind: KeyBinding | null): KeyEdit;
|
|
74
|
+
/**
|
|
75
|
+
* The keys whose curves the selection means: a key's curve is the segment it starts, so the last key of a track
|
|
76
|
+
* stands for the segment arriving at it (its previous key). Deduplicated, in selection order.
|
|
77
|
+
*/
|
|
78
|
+
export declare function segmentKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): KeyRef[];
|
|
79
|
+
/**
|
|
80
|
+
* Hold on or off for the selection (After Effects' toggle hold keyframe): every selected key holds unless all
|
|
81
|
+
* of them already do, in which case they get the default ease back.
|
|
82
|
+
*/
|
|
83
|
+
export declare function toggleHoldKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): KeyEdit;
|
|
84
|
+
/** The selected keys' span in frame time, or null with none selected. */
|
|
85
|
+
export declare function selectionSpan(nodes: Record<string, AnyNode>, frameId: string, sel: readonly KeyRef[]): [number, number] | null;
|
|
86
|
+
/** A curve run backwards: ease-in becomes ease-out and a bezier is turned end for end (hold, linear, springs stay). */
|
|
87
|
+
export declare function reverseInterp(interp: Interp): Interp;
|
|
88
|
+
/**
|
|
89
|
+
* The selected keys played backwards, track by track, within their own span: each key's time mirrors about the
|
|
90
|
+
* span's middle, and each segment's curve goes to the key that now starts it, run backwards — so the motion is the
|
|
91
|
+
* same one in reverse (After Effects' Time-Reverse Keyframes).
|
|
92
|
+
*/
|
|
93
|
+
export declare function reverseKeys(nodes: Record<string, AnyNode>, sel: readonly KeyRef[]): KeyEdit;
|
|
94
|
+
/**
|
|
95
|
+
* The selected keys retimed so the first of them (in frame time) lands at frame time `t`, the rest keeping their
|
|
96
|
+
* distance to it (the key inspector's time field).
|
|
97
|
+
*/
|
|
98
|
+
export declare function setKeysTime(nodes: Record<string, AnyNode>, frameId: string, sel: readonly KeyRef[], t: number): KeyEdit;
|
|
99
|
+
/** The selected keys of `valueType`'s tracks set to `v` (the key inspector's value field; other tracks untouched). */
|
|
100
|
+
export declare function setKeysValue(nodes: Record<string, AnyNode>, sel: readonly KeyRef[], v: MotionValue): KeyEdit;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AnyNode, Interp, Key, MotionValue, NodeMotion, PropPath, Track } from '../document/types.js';
|
|
2
|
+
/** Whether `id` is `frameId` or inside it. */
|
|
3
|
+
export declare function isInside(nodes: Record<string, AnyNode>, id: string, frameId: string): boolean;
|
|
4
|
+
/** What owns a timeline: a frame at the top of a page, or a component (a variant too) wherever it sits — a motion
|
|
5
|
+
* component plays its own timeline in every instance. */
|
|
6
|
+
export declare const isTimelineHost: (nodes: Record<string, AnyNode>, n: AnyNode) => boolean;
|
|
7
|
+
/** The timeline `id` plays on: its nearest component, else its top-level frame (`id` itself when it is one); null outside any. */
|
|
8
|
+
export declare function hostFrameOf(nodes: Record<string, AnyNode>, id: string): string | null;
|
|
9
|
+
/** The key of `path` within 1 ms of `t`. */
|
|
10
|
+
export declare function keyAt(motion: NodeMotion | undefined, path: PropPath, t: number): Key | undefined;
|
|
11
|
+
/** `motion` with `track` at `path` (the track removed when null). Undefined when no motion is left. */
|
|
12
|
+
export declare function withTrack(motion: NodeMotion | undefined, path: PropPath, track: Track | null): NodeMotion | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* `motion` with a key for `path` at `t` set to `v`, replacing a key within 1 ms of it (which keeps its id, its
|
|
15
|
+
* spatial handles and, unless `out` is given, its curve). Discrete properties always hold.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setKey(motion: NodeMotion | undefined, path: PropPath, t: number, v: MotionValue, out?: Interp, id?: string): NodeMotion;
|
|
18
|
+
/**
|
|
19
|
+
* `track` (a new one when undefined) with a key at `t` set to `v`: the rule of `setKey`, for a track that is not a
|
|
20
|
+
* layer property's (an audio clip's gain).
|
|
21
|
+
*/
|
|
22
|
+
export declare function setTrackKey<V extends MotionValue>(track: Track<V> | undefined, t: number, v: V, o?: {
|
|
23
|
+
out?: Interp;
|
|
24
|
+
id?: string;
|
|
25
|
+
discrete?: boolean;
|
|
26
|
+
}): Track<V>;
|
|
27
|
+
/** `motion` without the key for `path` at `t`; an emptied track is dropped, and undefined is left when nothing is. */
|
|
28
|
+
export declare function removeKey(motion: NodeMotion | undefined, path: PropPath, t: number): NodeMotion | undefined;
|
|
29
|
+
/** `motion` with `path`'s whole track removed. */
|
|
30
|
+
export declare const removeTrack: (motion: NodeMotion | undefined, path: PropPath) => NodeMotion | undefined;
|
|
31
|
+
/** `motion` with the key for `path` at `from` moved to `to` (a key already at `to` is replaced). */
|
|
32
|
+
export declare function moveKey(motion: NodeMotion, path: PropPath, from: number, to: number): NodeMotion;
|
|
33
|
+
/** The top-level fields of `after` that differ from `before` (fields `after` dropped come back undefined). */
|
|
34
|
+
export declare function nodePatch(before: AnyNode, after: AnyNode): Partial<AnyNode>;
|
|
35
|
+
/** The node props that set `path` to `v` (the inverse of reading it). */
|
|
36
|
+
export declare const propPatch: (node: AnyNode, path: PropPath, v: MotionValue) => Partial<AnyNode>;
|
|
37
|
+
/**
|
|
38
|
+
* The props that key `path` at `t` with `v` on `node`: the motion, plus the ids given to the fill, stroke or effect
|
|
39
|
+
* the path addresses when it had none. Null when the path does not resolve on the node.
|
|
40
|
+
*/
|
|
41
|
+
export declare function keyNode(node: AnyNode, path: PropPath, t: number, v: MotionValue, out?: Interp): Partial<AnyNode> | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AnyNode, NodeMotion } from '../document/types.js';
|
|
2
|
+
/** A layer's bar in frame time: when it starts and ends, and whether it is trimmed there. */
|
|
3
|
+
export interface LayerBar {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
trimmedIn: boolean;
|
|
7
|
+
trimmedOut: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The bar of `id` on `frameId`'s timeline (`duration` long). It starts where the layer's own time starts (its offset
|
|
11
|
+
* and the staggers above it), or where its span begins when that is later, and ends at its span's end, else at the
|
|
12
|
+
* end of the timeline.
|
|
13
|
+
*/
|
|
14
|
+
export declare function layerBar(nodes: Record<string, AnyNode>, id: string, frameId: string, duration: number): LayerBar;
|
|
15
|
+
/** The layer slid `dt` ms later (earlier when negative): its time offset and its span move together. */
|
|
16
|
+
export declare function slideLayer(motion: NodeMotion | undefined, dt: number): NodeMotion | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The layer trimmed: its `edge` set to parent time `at` (ms), kept at least a frame (`minMs`) from the other end.
|
|
19
|
+
* A trim back to the layer's natural start (`naturalIn`) or past the end of the timeline (`endMs`) removes it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function trimLayer(motion: NodeMotion | undefined, edge: 'in' | 'out', at: number, opts: {
|
|
22
|
+
naturalIn: number;
|
|
23
|
+
endMs: number;
|
|
24
|
+
minMs?: number;
|
|
25
|
+
}): NodeMotion | undefined;
|
|
26
|
+
/** One child's step in a container's live stagger: its rank (0 goes first) and when it starts, in frame time. */
|
|
27
|
+
export interface StaggerStep {
|
|
28
|
+
id: string;
|
|
29
|
+
rank: number;
|
|
30
|
+
start: number;
|
|
31
|
+
}
|
|
32
|
+
/** The staircase of `containerId`'s live stagger (empty without one). */
|
|
33
|
+
export declare function staggerSteps(nodes: Record<string, AnyNode>, containerId: string, frameId: string): StaggerStep[];
|
|
34
|
+
/**
|
|
35
|
+
* The stagger delay after dragging the step of rank `rank` by `dt` ms: that step moves by `dt`, so every step moves
|
|
36
|
+
* in proportion (rank 0 does not move, and cannot change it). Never below 0.
|
|
37
|
+
*/
|
|
38
|
+
export declare function staggerDelayAfterDrag(delay: number, rank: number, dt: number): number;
|
|
39
|
+
/** The container's motion with its stagger's delay set (the order and the rest kept). */
|
|
40
|
+
export declare function withStaggerDelay(motion: NodeMotion | undefined, delay: number): NodeMotion | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type FrameTimeline, type TimelineFps, type TimelineMarker } from '../document/types.js';
|
|
2
|
+
/** The rates a timeline offers, in menu order. */
|
|
3
|
+
export declare const TIMELINE_FPS: readonly TimelineFps[];
|
|
4
|
+
export declare const DEFAULT_FPS: TimelineFps;
|
|
5
|
+
export declare const isTimelineFps: (v: unknown) => v is TimelineFps;
|
|
6
|
+
/** The timeline's frame rate. */
|
|
7
|
+
export declare const timelineFps: (tl: FrameTimeline | undefined) => TimelineFps;
|
|
8
|
+
/** One frame at `fps`, in ms. */
|
|
9
|
+
export declare const frameMs: (fps: number) => number;
|
|
10
|
+
/** `t` on the frame grid at `fps` (whole ms, never negative). */
|
|
11
|
+
export declare function toFrame(t: number, fps: number): number;
|
|
12
|
+
/** `tl` with a marker at `t` (a marker already within a ms of it is kept, not doubled). Returns its id too. */
|
|
13
|
+
export declare function addMarker(tl: FrameTimeline, t: number, label?: string): {
|
|
14
|
+
timeline: FrameTimeline;
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
/** `tl` with marker `id` changed (moved, renamed, re-kinded). An empty label removes the label. */
|
|
18
|
+
export declare function updateMarker(tl: FrameTimeline, id: string, patch: Partial<Omit<TimelineMarker, 'id'>>): FrameTimeline;
|
|
19
|
+
export declare function removeMarker(tl: FrameTimeline, id: string): FrameTimeline;
|
|
20
|
+
/** The range playback and export use: the work area, else the whole timeline. */
|
|
21
|
+
export declare function playRange(tl: FrameTimeline | undefined, duration: number): [number, number];
|
|
22
|
+
/** `tl` with work area `range` (null clears it). A range with no length is refused (the timeline is returned). */
|
|
23
|
+
export declare function setWorkArea(tl: FrameTimeline, range: [number, number] | null): FrameTimeline;
|
|
24
|
+
/**
|
|
25
|
+
* `tl` with one edge of the work area at `t` (After Effects' B/N, here I/O). The other edge stays where it was
|
|
26
|
+
* (the timeline's end or start when there was no work area); setting an edge past the other moves that one to the
|
|
27
|
+
* timeline's bound so the range stays the right way round.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setWorkEdge(tl: FrameTimeline, edge: 'in' | 'out', t: number): FrameTimeline;
|
|
30
|
+
/** The moments a dragged key, marker or edge snaps to: every marker and the work area's edges. */
|
|
31
|
+
export declare function timelineSnapTimes(tl: FrameTimeline | undefined): number[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AudioBehaviourMode, AudioSignalName, Color, Key, Modifier, Track } from '../document/types.js';
|
|
2
|
+
import type { PropertyControl } from './properties.js';
|
|
3
|
+
export type ModifierKind = Modifier['kind'];
|
|
4
|
+
type Loop = Extract<Modifier, {
|
|
5
|
+
kind: 'loop';
|
|
6
|
+
}>;
|
|
7
|
+
export type LoopMode = Loop['mode'];
|
|
8
|
+
/** A numeric parameter of a behaviour, as a field. */
|
|
9
|
+
export interface ModifierParam {
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
step: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
unit?: string;
|
|
16
|
+
optional?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A behaviour the panel offers: a kind with starting values that suit the property. `color`: offered on colour
|
|
20
|
+
* tracks too (only a loop and an audio behaviour change a colour).
|
|
21
|
+
*/
|
|
22
|
+
export interface BehaviourPreset {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
hint: string;
|
|
26
|
+
make: (scale: number, seed: number) => Modifier;
|
|
27
|
+
color?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** How big a behaviour starts on a property: 20 px, 15°, a tenth of a percent-style value. */
|
|
30
|
+
export declare function behaviourScale(control: PropertyControl): number;
|
|
31
|
+
export declare const BEHAVIOUR_PRESETS: readonly BehaviourPreset[];
|
|
32
|
+
/** The signals an audio behaviour can follow, in menu order. */
|
|
33
|
+
export declare const AUDIO_SIGNAL_OPTIONS: readonly {
|
|
34
|
+
signal: AudioSignalName;
|
|
35
|
+
label: string;
|
|
36
|
+
hint: string;
|
|
37
|
+
}[];
|
|
38
|
+
/** How an audio behaviour meets the value, in menu order. */
|
|
39
|
+
export declare const AUDIO_MODES: readonly {
|
|
40
|
+
mode: AudioBehaviourMode;
|
|
41
|
+
label: string;
|
|
42
|
+
}[];
|
|
43
|
+
export declare const MODIFIER_LABELS: Record<ModifierKind, string>;
|
|
44
|
+
export declare const LOOP_MODES: readonly {
|
|
45
|
+
mode: LoopMode;
|
|
46
|
+
label: string;
|
|
47
|
+
}[];
|
|
48
|
+
/** A behaviour's numeric parameters, in the order the panel shows them. */
|
|
49
|
+
export declare function modifierParams(m: Modifier): ModifierParam[];
|
|
50
|
+
export declare const isKeyableParam: (m: Modifier, name: string) => boolean;
|
|
51
|
+
/** A parameter's stored value (0 for an unset optional one, except multiply's 1). */
|
|
52
|
+
export declare const storedParam: (m: Modifier, name: string) => number;
|
|
53
|
+
/** A parameter's value at local time `t`: its keys when it has any. */
|
|
54
|
+
export declare function paramAt(m: Modifier, name: string, t: number): number;
|
|
55
|
+
/** The key of parameter `name` within a ms of `t`. */
|
|
56
|
+
export declare const paramKeyAt: (m: Modifier, name: string, t: number) => Key<number> | undefined;
|
|
57
|
+
/** The track's behaviours all with ids (the same list when they already have them). */
|
|
58
|
+
export declare function withModifierIds(mods: readonly Modifier[]): Modifier[];
|
|
59
|
+
/** A seed for a new wiggle: different from the track's others, and the same for the same list (no Math.random). */
|
|
60
|
+
export declare function nextSeed(mods: readonly Modifier[]): number;
|
|
61
|
+
/** `track` (or a new, keyless one) with `m` added at the end — a loop goes first, as it remaps time before the rest. */
|
|
62
|
+
export declare function addModifier(track: Track | undefined, m: Modifier): Track;
|
|
63
|
+
/** `track` without the behaviour `id` (null when nothing is left of the track). */
|
|
64
|
+
export declare function removeModifier(track: Track | undefined, id: string): Track | null;
|
|
65
|
+
/** `track` with behaviour `id` moved to position `to` (clamped): order matters, each adds to what came before it. */
|
|
66
|
+
export declare function moveModifier(track: Track | undefined, id: string, to: number): Track | null;
|
|
67
|
+
/** Behaviour `id` with a parameter set (unset with `undefined`, for optional ones). */
|
|
68
|
+
export declare function setModifierParam(track: Track | undefined, id: string, name: string, value: number | undefined): Track | null;
|
|
69
|
+
export declare function setLoopMode(track: Track | undefined, id: string, mode: LoopMode): Track | null;
|
|
70
|
+
/** Audio behaviour `id` following another signal (a spectrum band starts low-mid when it had none). */
|
|
71
|
+
export declare function setAudioSignal(track: Track | undefined, id: string, signal: AudioSignalName): Track | null;
|
|
72
|
+
/** Audio behaviour `id` meeting the value another way. */
|
|
73
|
+
export declare function setAudioMode(track: Track | undefined, id: string, mode: AudioBehaviourMode): Track | null;
|
|
74
|
+
/** Audio behaviour `id` on a colour track flashing toward `color`. */
|
|
75
|
+
export declare function setAudioColor(track: Track | undefined, id: string, color: Color): Track | null;
|
|
76
|
+
/** Behaviour `id` with a fresh seed (a different wiggle). */
|
|
77
|
+
export declare function reseed(track: Track | undefined, id: string): Track | null;
|
|
78
|
+
/** Behaviour `id` with parameter `name` keyed to `v` at local time `t` (a key within a ms is replaced). */
|
|
79
|
+
export declare function keyModifierParam(track: Track | undefined, id: string, name: string, t: number, v: number): Track | null;
|
|
80
|
+
/** Behaviour `id` without its key of `name` near `t` (all its keys with `t` omitted: the parameter stops being keyed). */
|
|
81
|
+
export declare function unkeyModifierParam(track: Track | undefined, id: string, name: string, t?: number): Track | null;
|
|
82
|
+
/** A short line for a behaviour: "Wiggle · 20 at 2 Hz" ("keyed" for a parameter that has keys). */
|
|
83
|
+
export declare function describeModifier(m: Modifier): string;
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Color, Modifier, PropPath, Track } from '../document/types.js';
|
|
2
|
+
import type { AudioSignalSpec } from './audio-signals.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the behaviours read beyond their own track: another layer's sampled value (`link`), through the same evaluator
|
|
5
|
+
* (cycle-safe on its side), and the audio heard at the moment being sampled (`audio`, lib/motion/audio-signals.ts).
|
|
6
|
+
*/
|
|
7
|
+
export interface ModifierContext {
|
|
8
|
+
sampleLinked(nodeId: string, path: PropPath, tLocalMs: number): number | undefined;
|
|
9
|
+
/** An audio signal (0…1) at the moment being sampled; unset, or 0, where nothing is heard. */
|
|
10
|
+
sampleAudio?(spec: AudioSignalSpec): number;
|
|
11
|
+
}
|
|
12
|
+
type AudioModifier = Extract<Modifier, {
|
|
13
|
+
kind: 'audio';
|
|
14
|
+
}>;
|
|
15
|
+
type Param = (name: string, stored: number) => number;
|
|
16
|
+
/** How far an `audio` behaviour is driven (0…1): the signal, times its gain, past its threshold. */
|
|
17
|
+
export declare function audioAmount(m: AudioModifier, p: Param, ctx: ModifierContext | undefined): number;
|
|
18
|
+
/** A 32-bit integer hash of (seed, i) → [0, 1). */
|
|
19
|
+
export declare function hash01(seed: number, i: number): number;
|
|
20
|
+
/** Fractal noise in [-1, 1]: `octaves` layers, each twice the frequency and half the amplitude. */
|
|
21
|
+
export declare function fbm(seed: number, x: number, octaves?: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* The time the keys are sampled at: past the loop range, `cycle`/`offset` repeat it, `pingpong` mirrors it and
|
|
24
|
+
* `continue` holds the end (its value carries on in `loopCarry`). Before the range, time is left alone.
|
|
25
|
+
*/
|
|
26
|
+
export declare function loopTime(track: Track, t: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* What a `continue`/`offset` loop adds on top of the looped sample (numbers only): `continue` goes on at the speed
|
|
29
|
+
* the keys ended with, `offset` stacks one range's change per completed repeat.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loopCarry(track: Track, t: number, sampleAt: (t: number) => number | undefined): number;
|
|
32
|
+
/** Whether a track animates anything on its own: keys to move between, or behaviours. */
|
|
33
|
+
export declare const hasBehaviour: (track: Track) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The value modifiers, in array order, applied to `base` at local time `tLocalMs` (numbers only). A parameter with
|
|
36
|
+
* keys (`animated`) takes its keyed value. `link` takes the source's value (`· mul + add`); a missing source or a
|
|
37
|
+
* link cycle leaves the value as it is.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyModifiers(track: Track, base: number, tLocalMs: number, ctx?: ModifierContext): number;
|
|
40
|
+
/** Whether a track has an `audio` behaviour (the only one a colour track can have besides a loop). */
|
|
41
|
+
export declare const hasAudioBehaviour: (track: Track) => boolean;
|
|
42
|
+
/** A colour after the track's `audio` behaviours: mixed toward each one's `color` by how far it is driven. */
|
|
43
|
+
export declare function applyAudioColor(track: Track, base: Color, tLocalMs: number, ctx?: ModifierContext): Color;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { VectorPath } from '../document/types.js';
|
|
2
|
+
/** Whether `v` is a keyable outline: an array of paths, each a list of finite points. */
|
|
3
|
+
export declare function isPathValue(v: unknown): v is VectorPath[];
|
|
4
|
+
/** The same outline, compared point by point. */
|
|
5
|
+
export declare function samePaths(a: VectorPath[], b: VectorPath[]): boolean;
|
|
6
|
+
/** The outline `e` of the way from `a` to `b` (`e` may overshoot 0..1 for a back or elastic curve). */
|
|
7
|
+
export declare function morphPaths(a: VectorPath[], b: VectorPath[], e: number): VectorPath[];
|
|
8
|
+
/** `a` and `b` as the matched outlines `morphPaths` blends: point for point alike, each drawing as its original does. */
|
|
9
|
+
export declare function morphPair(a: VectorPath[], b: VectorPath[]): [VectorPath[], VectorPath[]];
|
|
10
|
+
/** How far an outline reaches from its origin: what a vector's box is while it morphs. */
|
|
11
|
+
export declare function pathsExtent(paths: VectorPath[]): {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|