@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,6 @@
|
|
|
1
|
+
import type { AnyNode } from '../document/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `patches` (posed nodes over `base`) with the auto layout their size changes feed laid out again. The same object
|
|
4
|
+
* when no posed layer changed size.
|
|
5
|
+
*/
|
|
6
|
+
export declare function reflowPose(base: Record<string, AnyNode>, patches: Record<string, AnyNode>): Record<string, AnyNode>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { AnyNode, Color, Composition } from '../document/types.js';
|
|
2
|
+
import type { RenderRoot, Stage } from './transitions.js';
|
|
3
|
+
import { frameTimeline, timelineDuration, type InstanceRuntime } from './instances.js';
|
|
4
|
+
import { type AudioScope } from './audio-signals.js';
|
|
5
|
+
export { frameTimeline, timelineDuration };
|
|
6
|
+
/** What a pose is of: a frame's timeline, or a composition's scenes. */
|
|
7
|
+
export type FramePoseTarget = {
|
|
8
|
+
kind: 'frame';
|
|
9
|
+
frameId: string;
|
|
10
|
+
};
|
|
11
|
+
export type CompositionPoseTarget = {
|
|
12
|
+
kind: 'composition';
|
|
13
|
+
compositionId: string;
|
|
14
|
+
};
|
|
15
|
+
export type PoseTarget = FramePoseTarget | CompositionPoseTarget;
|
|
16
|
+
/** The frame a target is the timeline of (null for a composition). */
|
|
17
|
+
export declare const targetFrameId: (t: PoseTarget | null | undefined) => string | null;
|
|
18
|
+
/** The composition a target plays (null for a frame). */
|
|
19
|
+
export declare const targetCompositionId: (t: PoseTarget | null | undefined) => string | null;
|
|
20
|
+
/** Whether two targets are the same timeline. */
|
|
21
|
+
export declare const sameTarget: (a: PoseTarget | null | undefined, b: PoseTarget | null | undefined) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* What drives the pose's time. Under Animate's transport, shader fills and dissolve grain read the pose's time,
|
|
24
|
+
* so a paused playhead shows a still frame and scrubbing is deterministic. Present mode keeps the wall clock.
|
|
25
|
+
*/
|
|
26
|
+
export type PoseClock = 'transport' | 'present';
|
|
27
|
+
export interface PoseOptions {
|
|
28
|
+
clock?: PoseClock;
|
|
29
|
+
/** Where playback holds (present mode's next pause marker): nothing past it will be shown, so the pose is not live there. */
|
|
30
|
+
end?: number;
|
|
31
|
+
/** Present mode's triggered instances and variant changes (lib/motion/instances.ts). */
|
|
32
|
+
runtime?: InstanceRuntime;
|
|
33
|
+
/** The document's compositions: what a composition target plays. */
|
|
34
|
+
compositions?: Record<string, Composition>;
|
|
35
|
+
/**
|
|
36
|
+
* Whether videos follow the pose's time (lib/motion/video-clip.ts): always under the transport and inside a
|
|
37
|
+
* composition; a slide presenting on its own lets them free-run (its time stops at its last key).
|
|
38
|
+
*/
|
|
39
|
+
driveVideo?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* What is heard (lib/motion/audio-signals.ts), for the audio behaviours: a composition hands its scenes its own
|
|
42
|
+
* sound at its own moment. Unset: a frame hears its own sound at `time`.
|
|
43
|
+
*/
|
|
44
|
+
audio?: AudioScope;
|
|
45
|
+
}
|
|
46
|
+
export interface Pose {
|
|
47
|
+
target: PoseTarget;
|
|
48
|
+
/** Target-local ms. */
|
|
49
|
+
time: number;
|
|
50
|
+
clock: PoseClock;
|
|
51
|
+
end?: number;
|
|
52
|
+
runtime: InstanceRuntime;
|
|
53
|
+
/** The node map the pose was evaluated over. */
|
|
54
|
+
base: Record<string, AnyNode>;
|
|
55
|
+
/** `base` with the posed layers swapped in: every node that does not move is the same object as in `base`. */
|
|
56
|
+
nodes: Record<string, AnyNode>;
|
|
57
|
+
/** The layers whose node differs from `base`: real ids, and `host::child` for an instance's posed children. */
|
|
58
|
+
animatedIds: ReadonlySet<string>;
|
|
59
|
+
/** Whether a later time would look different: a key still ahead (before `end`), or a behaviour that never settles. */
|
|
60
|
+
live: boolean;
|
|
61
|
+
/** Whether its videos show the pose's time (`PoseOptions.driveVideo`). */
|
|
62
|
+
videos?: boolean;
|
|
63
|
+
/** Animate's solo (view only): the layers shown alone; the rest of the frame is hidden in `nodes`. */
|
|
64
|
+
solo?: readonly string[];
|
|
65
|
+
/** A composition's: the compositions it was evaluated with (so it can be evaluated again over other nodes). */
|
|
66
|
+
compositions?: Record<string, Composition>;
|
|
67
|
+
/** Present mode's ORBIT_3D drags over it (`withOrbits`), kept so a pose evaluated again gets them too. */
|
|
68
|
+
orbits?: PoseOrbits;
|
|
69
|
+
/** A composition's: the frames to draw instead of the page, bottom to top, and the stage they are shown on. */
|
|
70
|
+
roots?: RenderRoot[];
|
|
71
|
+
stage?: {
|
|
72
|
+
rect: Stage;
|
|
73
|
+
background: Color;
|
|
74
|
+
compositionId: string;
|
|
75
|
+
};
|
|
76
|
+
/** What its audio behaviours heard, and which analyses they read (`analysisVersion`): a later analysis re-poses it. */
|
|
77
|
+
audio?: {
|
|
78
|
+
sound: AudioScope['sound'];
|
|
79
|
+
time: number;
|
|
80
|
+
version: number;
|
|
81
|
+
};
|
|
82
|
+
/** The pose this one was evaluated over (a prototype transition: the frame being left, under the one arriving). */
|
|
83
|
+
beneath?: Pose;
|
|
84
|
+
}
|
|
85
|
+
/** `top` evaluated over `under`'s nodes, remembering `under` (the same object for the same two poses). */
|
|
86
|
+
export declare function poseOver(top: Pose, under: Pose): Pose;
|
|
87
|
+
/** `pose` evaluated again over another node map (the same target, time and options, and whatever it lay over). */
|
|
88
|
+
export declare function reevaluatePose(pose: Pose, base: Record<string, AnyNode>): Pose;
|
|
89
|
+
/** `base` posed for `target` at `time` (ms). Memoised: the same map, target and time give the same Pose. */
|
|
90
|
+
export declare function evaluatePose(base: Record<string, AnyNode>, target: PoseTarget, time: number, opts?: PoseOptions): Pose;
|
|
91
|
+
/**
|
|
92
|
+
* `nodes` with the frame's animated layers written at their values at `time`, and a
|
|
93
|
+
* layer outside its span is left as it is. An Animate gesture edits from this, so every handler and store action
|
|
94
|
+
* starts from where the layer is on screen; committing the gesture puts the rest values back (lib/motion/autokey.ts).
|
|
95
|
+
*/
|
|
96
|
+
export declare function bakeMotion(nodes: Record<string, AnyNode>, frameId: string, time: number): Record<string, AnyNode>;
|
|
97
|
+
/** One layer at frame time `time`: the node itself when it does not move or is not in the frame. */
|
|
98
|
+
export declare function posedNode(nodes: Record<string, AnyNode>, id: string, frameId: string, time: number): AnyNode | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* `pose` with only the soloed layers showing in its frame (Animate's solo switches): every other layer of the frame
|
|
101
|
+
* is hidden, except the containers on the way to a soloed one. The same pose without solo, and the same object for
|
|
102
|
+
* the same inputs. The pose remembers `solo`, so one evaluated again over other nodes (the renderer's, with
|
|
103
|
+
* variables resolved) can be soloed the same way.
|
|
104
|
+
*/
|
|
105
|
+
/** How far the show's drags have turned layers (by layer name: a turn carries to the same-named layer of the next screen, as smart animate matches layers), under which frames. */
|
|
106
|
+
export interface PoseOrbits {
|
|
107
|
+
roots: readonly string[];
|
|
108
|
+
turns: Readonly<Record<string, {
|
|
109
|
+
rotateX: number;
|
|
110
|
+
rotateY: number;
|
|
111
|
+
}>>;
|
|
112
|
+
}
|
|
113
|
+
/** The pose with `orbits` laid over it: each named layer under the roots turned by its drag, on top of its own tilts. */
|
|
114
|
+
export declare function withOrbits(pose: Pose, orbits: PoseOrbits | undefined): Pose;
|
|
115
|
+
export declare function withSolo(pose: Pose, solo: readonly string[] | undefined): Pose;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { AnyNode, Document, Interp, StaggerOrder } from '../document/types.js';
|
|
2
|
+
import { type KeySpec } from './author.js';
|
|
3
|
+
export type PresetCategory = 'entrance' | 'exit' | 'emphasis' | 'camera' | 'text';
|
|
4
|
+
/** Entrances come FROM the direction, exits go TOWARD it, camera moves travel along it. */
|
|
5
|
+
export type PresetDirection = 'left' | 'right' | 'up' | 'down';
|
|
6
|
+
export declare const PRESET_IDS: readonly ["fade-in", "rise-in", "drop-in", "pop-in", "scale-in", "slide-in", "wipe-in", "blur-in", "fade-out", "rise-out", "drop-out", "pop-out", "scale-out", "slide-out", "wipe-out", "blur-out", "pulse", "shake", "bounce", "wobble", "flash", "impact-frame", "push-in", "pull-out", "dolly", "drift", "zoom-through", "truck", "crane", "pan", "orbit", "camera-shake", "whip-pan", "typewriter", "letters-in", "words-in", "lines-in", "letters-out", "words-out", "lines-out"];
|
|
7
|
+
export type PresetId = typeof PRESET_IDS[number];
|
|
8
|
+
/** What a caller may set; everything has a default per preset. */
|
|
9
|
+
export interface PresetParams {
|
|
10
|
+
/** ms. */
|
|
11
|
+
duration?: number;
|
|
12
|
+
/** ms after the start the preset is applied at. */
|
|
13
|
+
delay?: number;
|
|
14
|
+
/** The main curve (back's overshoot is `param`). */
|
|
15
|
+
ease?: Interp;
|
|
16
|
+
/** px the layer travels (rise, slide, shake, dolly…). Unset: from the layer's size where the preset says so. */
|
|
17
|
+
distance?: number;
|
|
18
|
+
direction?: PresetDirection;
|
|
19
|
+
/** The preset's own amount (its `amount.label`): a start scale, an overshoot, a blur radius, degrees. */
|
|
20
|
+
amount?: number;
|
|
21
|
+
}
|
|
22
|
+
interface Resolved {
|
|
23
|
+
duration: number;
|
|
24
|
+
ease: Interp;
|
|
25
|
+
distance: number;
|
|
26
|
+
direction: PresetDirection;
|
|
27
|
+
amount: number;
|
|
28
|
+
}
|
|
29
|
+
/** A track a preset writes: keys at ms from the preset's start. */
|
|
30
|
+
export interface PresetTrack {
|
|
31
|
+
path: string;
|
|
32
|
+
keys: KeySpec[];
|
|
33
|
+
}
|
|
34
|
+
export interface MotionPreset {
|
|
35
|
+
id: PresetId;
|
|
36
|
+
category: PresetCategory;
|
|
37
|
+
label: string;
|
|
38
|
+
description: string;
|
|
39
|
+
duration: number;
|
|
40
|
+
ease: Interp;
|
|
41
|
+
/** Travels in a direction (the default one here). */
|
|
42
|
+
direction?: PresetDirection;
|
|
43
|
+
/** Takes a distance: the default px, or 'auto' (from the layer's size). */
|
|
44
|
+
distance?: number | 'auto';
|
|
45
|
+
amount?: {
|
|
46
|
+
label: string;
|
|
47
|
+
default: number;
|
|
48
|
+
min: number;
|
|
49
|
+
max: number;
|
|
50
|
+
step: number;
|
|
51
|
+
unit?: string;
|
|
52
|
+
};
|
|
53
|
+
/** Which layers it makes sense on (the picker offers it only there; the command refuses the others). */
|
|
54
|
+
appliesTo: (n: AnyNode) => boolean;
|
|
55
|
+
/** Why it does not apply, for the refusal. */
|
|
56
|
+
needs?: string;
|
|
57
|
+
/** Rest changes the keys need (a blur of 0 to animate, clipping for a wipe, a text animator). Undefined: none. */
|
|
58
|
+
prepare?: (n: AnyNode, p: Resolved) => AnyNode;
|
|
59
|
+
/** The 'auto' distance for a layer (unset: half its smaller side, or its size for a slide). */
|
|
60
|
+
autoDistance?: (n: AnyNode) => number;
|
|
61
|
+
tracks: (n: AnyNode, p: Resolved) => PresetTrack[];
|
|
62
|
+
/** In a document, the keys go on a mask revealing the layer (wipes): `tracks` of the mask, given the layer's size. */
|
|
63
|
+
mask?: (mask: AnyNode, p: Resolved, open: boolean) => PresetTrack[];
|
|
64
|
+
}
|
|
65
|
+
/** The ids of a layer's wipe group and mask (stable, so a second wipe on the layer keys the same mask). */
|
|
66
|
+
export declare const wipeGroupId: (layerId: string) => string;
|
|
67
|
+
export declare const wipeMaskId: (layerId: string) => string;
|
|
68
|
+
/**
|
|
69
|
+
* `nodes` with `id` revealed through a wipe mask, and the mask's id: a frame gets the mask as its first child (over
|
|
70
|
+
* everything in it); any other layer is wrapped, in place, in a group holding the mask and the layer (its keyed
|
|
71
|
+
* positions follow it into the group). A layer that already has one reuses it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function ensureWipeMask(nodes: Record<string, AnyNode>, id: string, hostFrameId: string): {
|
|
74
|
+
nodes: Record<string, AnyNode>;
|
|
75
|
+
maskId: string;
|
|
76
|
+
};
|
|
77
|
+
/** Every preset, in picker order. */
|
|
78
|
+
export declare const MOTION_PRESETS: readonly MotionPreset[];
|
|
79
|
+
export declare const PRESET_CATEGORIES: readonly {
|
|
80
|
+
id: PresetCategory;
|
|
81
|
+
label: string;
|
|
82
|
+
}[];
|
|
83
|
+
export declare const presetById: (id: string) => MotionPreset | undefined;
|
|
84
|
+
export declare const isPresetId: (id: string) => id is PresetId;
|
|
85
|
+
/** The preset's parameters for `node`: the caller's, else the preset's defaults (an 'auto' distance from the node). */
|
|
86
|
+
export declare function resolvePresetParams(preset: MotionPreset, node: AnyNode, params?: PresetParams): Resolved;
|
|
87
|
+
/** The tracks `preset` writes on `node` (keys at ms from its start), without writing them. */
|
|
88
|
+
export declare function presetTracks(preset: MotionPreset, node: AnyNode, params?: PresetParams): PresetTrack[];
|
|
89
|
+
/**
|
|
90
|
+
* `node` with `preset` keyed from `at` (+ `params.delay`) ms of its own layer time. Keys the node already has on
|
|
91
|
+
* those paths stay (a key at the same moment is replaced), so presets on one property compose.
|
|
92
|
+
*/
|
|
93
|
+
export declare function applyPreset(node: AnyNode, presetId: PresetId, params?: PresetParams, at?: number): AnyNode;
|
|
94
|
+
/** The orders a stagger can take: the live ones (lib/motion/time.ts) plus the order the ids were given in. */
|
|
95
|
+
export type StaggerPick = StaggerOrder | 'selection';
|
|
96
|
+
/** `ids` in layer-tree order: depth first, each parent's children in their stored order (bottom-most first). */
|
|
97
|
+
export declare function treeOrder(nodes: Record<string, AnyNode>, ids: readonly string[]): string[];
|
|
98
|
+
/** Each id's place in a stagger over `ids` (0 goes first). `selection` keeps the given order; the others work on tree order. */
|
|
99
|
+
export declare function staggerPlaces(nodes: Record<string, AnyNode>, ids: readonly string[], order?: StaggerPick, seed?: number): Map<string, number>;
|
|
100
|
+
export interface ApplyPresetOptions extends PresetParams {
|
|
101
|
+
/** Frame ms the preset starts at (before `delay` and the stagger). Unset: 0, or with `onClick` the end of what the frame already plays. */
|
|
102
|
+
at?: number;
|
|
103
|
+
/** Each further layer starts this many ms later, in `order`. */
|
|
104
|
+
stagger?: {
|
|
105
|
+
delay: number;
|
|
106
|
+
order?: StaggerPick;
|
|
107
|
+
seed?: number;
|
|
108
|
+
};
|
|
109
|
+
/** Present mode waits for a click before it plays: a pause marker goes at `at`. */
|
|
110
|
+
onClick?: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface ApplyPresetResult {
|
|
113
|
+
document: Document;
|
|
114
|
+
ids: string[];
|
|
115
|
+
frameIds: string[];
|
|
116
|
+
skipped: {
|
|
117
|
+
id: string;
|
|
118
|
+
reason: string;
|
|
119
|
+
}[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* `preset` on each of `ids` (layers inside a top-level frame, or the frame itself), at frame time `at`, staggered.
|
|
123
|
+
* Layer time is respected: a delayed or staggered layer gets its keys where they play at `at`. A frame whose stored
|
|
124
|
+
* timeline is shorter than what it now plays is lengthened. Layers the preset does not apply to are skipped (with why).
|
|
125
|
+
*/
|
|
126
|
+
export declare function applyPresetToDocument(doc: Document, ids: readonly string[], presetId: PresetId, opts?: ApplyPresetOptions): ApplyPresetResult;
|
|
127
|
+
/**
|
|
128
|
+
* The parent whose own live stagger can carry a stagger over `ids`: they are all of its children (two or more), it has
|
|
129
|
+
* no stagger yet, and nothing in them animates yet — a live stagger re-times everything under each child (a counting
|
|
130
|
+
* figure inside a staggered card), where a baked one keyed only the layers it was given. Null otherwise.
|
|
131
|
+
*/
|
|
132
|
+
export declare function liveStaggerParent(nodes: Record<string, AnyNode>, ids: readonly string[]): string | null;
|
|
133
|
+
/** A stored timeline long enough for what its frame now plays until `end` (ms); the same object when it already is. */
|
|
134
|
+
export declare const lengthenedTo: <T extends {
|
|
135
|
+
duration: number;
|
|
136
|
+
} | undefined>(tl: T, end: number) => T;
|
|
137
|
+
export interface StaggerOptions {
|
|
138
|
+
delay: number;
|
|
139
|
+
order?: StaggerPick;
|
|
140
|
+
seed?: number; /** Offset of the first layer (ms). */
|
|
141
|
+
start?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Baked stagger: each of `ids` gets `timeOffset = start + place · delay`, so its whole animation (keys unchanged)
|
|
145
|
+
* plays that much later. A layer left with nothing else in its motion loses the empty motion.
|
|
146
|
+
*/
|
|
147
|
+
export declare function staggerDocument(doc: Document, ids: readonly string[], opts: StaggerOptions): Document;
|
|
148
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AnyNode, Color, MotionValue, PropPath, VectorPath } from '../document/types.js';
|
|
2
|
+
export type ValueType = 'number' | 'color' | 'string' | 'boolean' | 'path';
|
|
3
|
+
export type ValueOf<T extends ValueType> = T extends 'number' ? number : T extends 'color' ? Color : T extends 'string' ? string : T extends 'path' ? VectorPath[] : boolean;
|
|
4
|
+
export type PropertyGroup = 'Transform' | '3D' | 'Appearance' | 'Path' | 'Fill' | 'Stroke' | 'Effects' | 'Text' | 'Text animators' | 'Camera' | 'Lights';
|
|
5
|
+
export interface PropertyControl {
|
|
6
|
+
/** `path`: an outline, keyed from the canvas (it has no field to type into). */
|
|
7
|
+
kind: 'number' | 'angle' | 'percent' | 'color' | 'text' | 'toggle' | 'path';
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
unit?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AnimatableProperty<T extends ValueType = ValueType> {
|
|
14
|
+
/** The path with item ids blanked: `fills[@].color`, `effects[@].offset.x`. */
|
|
15
|
+
pattern: string;
|
|
16
|
+
valueType: T;
|
|
17
|
+
group: PropertyGroup;
|
|
18
|
+
/** "Fill 1 · Color", "Drop shadow · Blur". */
|
|
19
|
+
label(node: AnyNode, path: PropPath): string;
|
|
20
|
+
/** Whether the node has this property at all (`parent` for layout-dependent ones: auto-layout children hide x/y). */
|
|
21
|
+
appliesTo(node: AnyNode, parent?: AnyNode): boolean;
|
|
22
|
+
/** The concrete paths on this node (items without an id yet as `[#index]`); `parent` as for `appliesTo`. */
|
|
23
|
+
enumerate(node: AnyNode, parent?: AnyNode): PropPath[];
|
|
24
|
+
read(node: AnyNode, path: PropPath): ValueOf<T> | undefined;
|
|
25
|
+
/** Pure, with structural sharing: only the objects on the path are copied. A value of the wrong type is ignored. */
|
|
26
|
+
write(node: AnyNode, path: PropPath, v: ValueOf<T>): AnyNode;
|
|
27
|
+
control: PropertyControl;
|
|
28
|
+
/** Strings and booleans hold until the next key. */
|
|
29
|
+
interpolation: 'continuous' | 'discrete';
|
|
30
|
+
/** Changing it moves siblings in auto layout (the pose re-runs layout for these). */
|
|
31
|
+
layoutAffecting?: boolean;
|
|
32
|
+
/** The value when the node does not store one (scaleX → 1, anchorX → 0.5). */
|
|
33
|
+
restDefault?: ValueOf<T>;
|
|
34
|
+
/** Listed on every layer by the timeline (the rest appear once animated). */
|
|
35
|
+
essential?: boolean;
|
|
36
|
+
/** Stored as-is in this top-level node field: `write` is `{ ...node, [field]: v }`, so the sampler batches such
|
|
37
|
+
* writes into one copy of the node. */
|
|
38
|
+
field?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PathSegment {
|
|
41
|
+
name: string;
|
|
42
|
+
id?: string;
|
|
43
|
+
index?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare const asPath: (s: string) => PropPath;
|
|
46
|
+
export declare const pathSegments: (path: PropPath) => PathSegment[] | undefined;
|
|
47
|
+
/** The path with item ids blanked (`fills[@f1].color` → `fills[@].color`). */
|
|
48
|
+
export declare const patternOf: (path: PropPath) => string | undefined;
|
|
49
|
+
/** A path fit to store in a track: parseable and addressing items by id only. */
|
|
50
|
+
export declare const isBoundPath: (path: string) => path is PropPath;
|
|
51
|
+
/** How a path addresses a list item: `@id` when it has a usable id, else `#index` (bound to an id when a track is made). */
|
|
52
|
+
export declare const itemRef: (item: unknown, index: number) => string;
|
|
53
|
+
/** Every animatable property, in display order. */
|
|
54
|
+
export declare const ANIMATABLE_PROPERTIES: readonly AnimatableProperty[];
|
|
55
|
+
/** The property a path addresses (either id or index form). */
|
|
56
|
+
export declare function propertyFor(path: PropPath): AnimatableProperty | undefined;
|
|
57
|
+
/** The concrete animatable paths on `node` (`parent` hides layout-owned x/y inside auto layout). */
|
|
58
|
+
export declare function propertiesOf(node: AnyNode, parent?: AnyNode): {
|
|
59
|
+
prop: AnimatableProperty;
|
|
60
|
+
path: PropPath;
|
|
61
|
+
}[];
|
|
62
|
+
/** The path's value on `node` (undefined when the path does not resolve there). */
|
|
63
|
+
export declare function readPath(node: AnyNode, path: PropPath): MotionValue | undefined;
|
|
64
|
+
/** `node` with `v` at `path` (the same node when the path does not resolve or `v` has the wrong type). */
|
|
65
|
+
export declare function writePath(node: AnyNode, path: PropPath, v: MotionValue): AnyNode;
|
|
66
|
+
/**
|
|
67
|
+
* The path in its id form, with ids given to the items it addresses that had none (`fills[#0].color` →
|
|
68
|
+
* `fills[@f1].color`, the node's first fill now carrying `id: 'f1'`). A path already bound comes back as it is,
|
|
69
|
+
* with the same node. Null when the path does not resolve on the node.
|
|
70
|
+
*/
|
|
71
|
+
export declare function bindPath(node: AnyNode, path: PropPath): {
|
|
72
|
+
node: AnyNode;
|
|
73
|
+
path: PropPath;
|
|
74
|
+
} | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Key, MotionValue } from '../document/types.js';
|
|
2
|
+
import type { AnimatableProperty } from './properties.js';
|
|
3
|
+
/** Index of the key that starts the segment containing `t` (keys[0].t < t < keys[last].t). */
|
|
4
|
+
export declare function segmentAt(keys: readonly Key[], t: number): number;
|
|
5
|
+
/** The keys' value at `t`: holds the first before it and the last after it, eases between. */
|
|
6
|
+
export declare function sampleKeys(keys: readonly Key[], prop: Pick<AnimatableProperty, 'valueType' | 'interpolation'>, t: number): MotionValue | undefined;
|
|
7
|
+
/** Number keys at `t` (a behaviour's keyed parameter); undefined without keys. */
|
|
8
|
+
export declare function sampleNumberKeys(keys: readonly Key<number>[], t: number): number | undefined;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AnyNode, MotionValue, Track } from '../document/types.js';
|
|
2
|
+
import { boundValue, type PropertyValues } from '../document/instances.js';
|
|
3
|
+
export { boundValue };
|
|
4
|
+
import { type ModifierContext } from './modifiers.js';
|
|
5
|
+
import { type AnimatableProperty } from './properties.js';
|
|
6
|
+
import { sampleKeys } from './sample-keys.js';
|
|
7
|
+
export { sampleKeys };
|
|
8
|
+
/**
|
|
9
|
+
* A track's value at local time `t`: loop remapping, then the keys (or `rest` when there are none), then the
|
|
10
|
+
* value modifiers. Muted tracks give `rest`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sampleTrack(track: Track, prop: Pick<AnimatableProperty, 'valueType' | 'interpolation'>, rest: MotionValue | undefined, t: number, ctx?: ModifierContext): MotionValue | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Whether a node has motion to sample: an animating track, a span that shows and hides it, or text animators
|
|
15
|
+
* (they draw only on a posed text, so a text with them is always posed).
|
|
16
|
+
*/
|
|
17
|
+
export declare function isAnimated(node: AnyNode | undefined): boolean;
|
|
18
|
+
/** Whether a node's motion never settles: a behaviour keeps changing a value after the last key, or a loop repeats its keys. */
|
|
19
|
+
export declare function runsOn(node: AnyNode | undefined): boolean;
|
|
20
|
+
/** The last key time across a node's tracks, in its own local time (0 when it has none); a text animator's track counts its cascade. */
|
|
21
|
+
export declare function lastKeyTime(node: AnyNode | undefined): number;
|
|
22
|
+
/** Whether any key takes its value from a component property. */
|
|
23
|
+
export declare function hasBinding(track: Track): boolean;
|
|
24
|
+
/** `track` with its bound keys holding their values under `values` (the same track without bindings). Memoised per track and values. */
|
|
25
|
+
export declare function resolveBindings(track: Track, prop: Pick<AnimatableProperty, 'valueType'>, values: PropertyValues | undefined): Track;
|
|
26
|
+
/** How an instance plays a component layer: the values its properties have there (defaults included: bound keys), and those the instance sets itself (inputs, which replace keys). */
|
|
27
|
+
export interface SampleInputs {
|
|
28
|
+
values: PropertyValues;
|
|
29
|
+
set: PropertyValues;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `node` posed at its local time `t`: every animating track written through the registry. The same object when
|
|
33
|
+
* nothing differs from rest. `nodes` lets `link` behaviours read other layers.
|
|
34
|
+
*/
|
|
35
|
+
export declare function sampleNode(node: AnyNode, t: number, nodes?: Record<string, AnyNode>, inputs?: SampleInputs): AnyNode;
|
|
36
|
+
/**
|
|
37
|
+
* Ids of the nodes with motion to sample, in no particular order. Memoised on the node map's identity and carried
|
|
38
|
+
* from one map to the next along the edits' notes (lib/document/node-delta.ts): a drag's pointer move re-checks the
|
|
39
|
+
* layers it moved, not every node of the document.
|
|
40
|
+
*/
|
|
41
|
+
export declare const animatedIds: (nodes: Record<string, AnyNode>) => readonly string[];
|
|
42
|
+
/** Animated layers of `rootId` (the root included), in no particular order. */
|
|
43
|
+
export declare function motionNodes(nodes: Record<string, AnyNode>, rootId: string): AnyNode[];
|
|
44
|
+
/** When the last key under `rootId` lands, in the root's time (offsets and staggers included). */
|
|
45
|
+
export declare function motionEnd(nodes: Record<string, AnyNode>, rootId: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Posed copies of the animated layers under `rootId` with the root at `rootMs`, each sampled in its own layer
|
|
48
|
+
* time. Layers outside their span are hidden (unless `spans` is false: they are then left as they are). Nodes
|
|
49
|
+
* that come out as they are at rest are left out.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sampleSubtree(nodes: Record<string, AnyNode>, rootId: string, rootMs: number, spans?: boolean): Record<string, AnyNode>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AnyNode, AudioClip, Composition } from '../document/types.js';
|
|
2
|
+
import type { PoseTarget } from './pose.js';
|
|
3
|
+
/** File lengths (ms) by media hash, where known (decoded): a looping video's sound repeats with its picture. */
|
|
4
|
+
export type SourceLengths = ReadonlyMap<string, number>;
|
|
5
|
+
/** The id of a video layer's linked sound (its first piece). */
|
|
6
|
+
export declare const soundIdOf: (nodeId: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The linked sound of video layer `id` on `frameId`'s timeline (`duration` ms), as clips in frame ms: heard over the
|
|
9
|
+
* layer's bar (`offset` later), from the same source time as the picture. A looping video whose file length is known
|
|
10
|
+
* gives one clip per pass through the file; muted sound comes back muted (the strip still draws it).
|
|
11
|
+
*/
|
|
12
|
+
export declare function videoSoundClips(nodes: Record<string, AnyNode>, id: string, frameId: string, duration: number, lengths?: SourceLengths): AudioClip[];
|
|
13
|
+
/** `frameId`'s sound: its own lanes, then each video layer's linked sound, in frame ms. Memoised on the node map. */
|
|
14
|
+
export declare function frameSound(nodes: Record<string, AnyNode>, frameId: string, lengths?: SourceLengths): AudioClip[];
|
|
15
|
+
/** `comp`'s sound in composition ms: its own lanes, then each scene's frame sound through the scene. Memoised. */
|
|
16
|
+
export declare function compositionSound(comp: Composition, nodes: Record<string, AnyNode>, lengths?: SourceLengths): AudioClip[];
|
|
17
|
+
/** What `target` sounds like (target ms): a frame's sound or a composition's. Empty for a target that is gone. */
|
|
18
|
+
export declare function targetSound(doc: {
|
|
19
|
+
nodes: Record<string, AnyNode>;
|
|
20
|
+
compositions?: Record<string, Composition>;
|
|
21
|
+
}, target: PoseTarget | null | undefined, lengths?: SourceLengths): AudioClip[];
|
|
22
|
+
/** Whether any of `sound` is heard (an unmuted clip). */
|
|
23
|
+
export declare const audible: (sound: readonly AudioClip[]) => boolean;
|
|
24
|
+
/** Whether video layer `id` has sound on (its linked clip unmuted). */
|
|
25
|
+
export declare function videoSoundOn(node: AnyNode | undefined): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnyNode, Key, PropPath, Track } from '../document/types.js';
|
|
2
|
+
export type PositionPair = readonly [PropPath, PropPath];
|
|
3
|
+
export declare const XY: PositionPair;
|
|
4
|
+
export declare const TRANSLATE: PositionPair;
|
|
5
|
+
export type Vec = [number, number];
|
|
6
|
+
/** The position tracks a layer animates: x/y when it keys them (and places itself), else translate; null for none. */
|
|
7
|
+
export declare function animatedPair(node: AnyNode, parent?: AnyNode): PositionPair | null;
|
|
8
|
+
/** The pair a new position key goes on: x/y where the layer places itself, translate where auto layout does. */
|
|
9
|
+
export declare const positionPair: (node: AnyNode, parent?: AnyNode) => PositionPair;
|
|
10
|
+
export declare const keyNear: (keys: readonly Key[], t: number) => Key | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* How far the spatial curve moves the point off the straight line between the keys, at local time `t` (null when
|
|
13
|
+
* the segment there runs straight). The y value off the line is measured against the y track's own timing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function spatialDelta(xTrack: Track | undefined, yTrack: Track | undefined, t: number): Vec | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AnyNode, NodeMotion } from '../document/types.js';
|
|
2
|
+
import { type PositionPair, type Vec } from './spatial-curve.js';
|
|
3
|
+
/** A key moment on the path: its local time, where the anchor is then (parent space), and its handles. */
|
|
4
|
+
export interface PathDot {
|
|
5
|
+
t: number;
|
|
6
|
+
at: Vec;
|
|
7
|
+
in?: Vec;
|
|
8
|
+
out?: Vec;
|
|
9
|
+
first: boolean;
|
|
10
|
+
last: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface MotionPath {
|
|
13
|
+
pair: PositionPair;
|
|
14
|
+
/** The anchor point along the path, parent space, first key to last. */
|
|
15
|
+
points: Vec[];
|
|
16
|
+
dots: PathDot[];
|
|
17
|
+
}
|
|
18
|
+
/** Where a (posed) layer's anchor — its pivot — is in its parent's space. */
|
|
19
|
+
export declare function anchorPoint(n: AnyNode): Vec;
|
|
20
|
+
/** The layer's motion path over its position keys (null with fewer than two), memoised on the node. */
|
|
21
|
+
export declare function motionPathOf(node: AnyNode, parent?: AnyNode, samplesPerSegment?: number): MotionPath | null;
|
|
22
|
+
/** A dot's handles as drawn: its own tangents, or (none yet) a sixth of the way towards its neighbours. */
|
|
23
|
+
export declare function dotHandles(path: MotionPath, i: number): {
|
|
24
|
+
in?: Vec;
|
|
25
|
+
out?: Vec;
|
|
26
|
+
auto: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The motion after dragging the dot at local time `t` so the anchor lands at `to` (parent space): both keys of the
|
|
30
|
+
* pair at that moment move by the drag (one missing is made there, at the value the track had), so every other key,
|
|
31
|
+
* curve and behaviour is left as it was.
|
|
32
|
+
*/
|
|
33
|
+
export declare function moveDot(node: AnyNode, parent: AnyNode | undefined, t: number, to: Vec): NodeMotion | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The motion after dragging the dot's `side` handle to `vec` (px from the dot). The other handle mirrors it (a
|
|
36
|
+
* smooth path) unless `broken`. The dot gets both of its keys when it had only one, so the segment can curve.
|
|
37
|
+
*/
|
|
38
|
+
export declare function setDotTangent(node: AnyNode, parent: AnyNode | undefined, t: number, side: 'in' | 'out', vec: Vec, broken?: boolean): NodeMotion | undefined;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { AnyNode, PropPath, TextAnimator, TextAnimatorUnit, TextCounter, TextNode } from '../document/types.js';
|
|
2
|
+
import { type TextUnits } from './text-units.js';
|
|
3
|
+
/** The path of an animator's field: `text.animators[@a1].range.start`. */
|
|
4
|
+
export declare const animatorPath: (id: string, field: string) => PropPath;
|
|
5
|
+
export declare const COUNTER_PATH: PropPath;
|
|
6
|
+
export declare const isTextNode: (n: AnyNode | undefined) => n is TextNode;
|
|
7
|
+
/** An animator id the text does not use yet: `ta1`, `ta2` … (deterministic, collab-stable). */
|
|
8
|
+
export declare function freshAnimatorId(node: TextNode): string;
|
|
9
|
+
/** A unit's default cascade gap (ms) and travel (em) for a new animator. */
|
|
10
|
+
export declare const UNIT_DEFAULTS: Record<TextAnimatorUnit, {
|
|
11
|
+
stagger: number;
|
|
12
|
+
rise: number;
|
|
13
|
+
}>;
|
|
14
|
+
/** A new animator that holds every unit faded and lowered (its amount keys decide when they come in). */
|
|
15
|
+
export declare function defaultAnimator(node: TextNode, unit: TextAnimatorUnit, id?: string): TextAnimator;
|
|
16
|
+
/** `node` with `animator` (replacing the one with its id, else added last). */
|
|
17
|
+
export declare function withAnimator(node: TextNode, animator: TextAnimator): TextNode;
|
|
18
|
+
/** `node` without animator `id` and without the tracks that keyed it. */
|
|
19
|
+
export declare function withoutAnimator(node: TextNode, id: string): TextNode;
|
|
20
|
+
/**
|
|
21
|
+
* `node` counting with `counter` (its characters the counter's rest figure), or with no counter (null: its
|
|
22
|
+
* `text.counter` track goes, the characters stay what they show).
|
|
23
|
+
*/
|
|
24
|
+
export declare function withCounter(node: TextNode, counter: TextCounter | null): TextNode;
|
|
25
|
+
/**
|
|
26
|
+
* `node`'s counter with `patch`, and its `text.counter` keys following: the first key holds `from`, the last `to`.
|
|
27
|
+
* A counter with no keys yet only changes its stored figures.
|
|
28
|
+
*/
|
|
29
|
+
export declare function editCounter(node: TextNode, patch: Partial<TextCounter>): TextNode;
|
|
30
|
+
/** What the renderer needs to draw a posed text's animators: its layer time, and the node at rest. */
|
|
31
|
+
export interface TextPoseInfo {
|
|
32
|
+
t: number;
|
|
33
|
+
rest: TextNode;
|
|
34
|
+
}
|
|
35
|
+
/** Marks `node` as the pose of `rest` at layer time `t` (lib/motion/pose.ts): its animators draw. */
|
|
36
|
+
export declare function markTextPose(node: AnyNode, t: number, rest: TextNode): void;
|
|
37
|
+
/** `copy` (a copy of `node` made for drawing it, e.g. with its variables resolved) marked as `node` is. */
|
|
38
|
+
export declare function carryTextPose(node: AnyNode, copy: AnyNode): void;
|
|
39
|
+
/** The pose a text was drawn from, or undefined for a text at rest (its animators draw nothing). */
|
|
40
|
+
export declare const textPoseOf: (node: AnyNode) => TextPoseInfo | undefined;
|
|
41
|
+
/** Whether the text has animators to draw when posed. */
|
|
42
|
+
export declare const hasTextAnimators: (node: AnyNode | undefined) => boolean;
|
|
43
|
+
/** Floats per unit in `AnimatorFrame.poses`. */
|
|
44
|
+
export declare const UNIT_STRIDE = 11;
|
|
45
|
+
/** Offsets into a unit's floats. */
|
|
46
|
+
export declare const U: {
|
|
47
|
+
readonly weight: 0;
|
|
48
|
+
readonly tx: 1;
|
|
49
|
+
readonly ty: 2;
|
|
50
|
+
readonly scale: 3;
|
|
51
|
+
readonly rotation: 4;
|
|
52
|
+
readonly opacity: 5;
|
|
53
|
+
readonly blur: 6;
|
|
54
|
+
readonly r: 7;
|
|
55
|
+
readonly g: 8;
|
|
56
|
+
readonly b: 9;
|
|
57
|
+
readonly a: 10;
|
|
58
|
+
};
|
|
59
|
+
/** One animator's say over one text at one moment: each unit's weighted pose (props already × weight). */
|
|
60
|
+
export interface AnimatorFrame {
|
|
61
|
+
unit: TextAnimatorUnit;
|
|
62
|
+
units: TextUnits;
|
|
63
|
+
/** `units.count × UNIT_STRIDE`: weight, translate x/y (px), scale factor, rotation (°), opacity factor, blur (px), tint rgba (a = mix). */
|
|
64
|
+
poses: Float32Array;
|
|
65
|
+
/** Whether any unit is off rest (a unit with weight 0 is exactly at rest). */
|
|
66
|
+
moving: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Every animator's per-unit pose on the posed text `node` (marked `info` by the pose). `unitsFor` splits the text
|
|
70
|
+
* into an animator's units (the renderer passes its layout's lines for `line`). Without a stagger every unit takes the
|
|
71
|
+
* animator's values at the text's time; with one, unit k samples the animator's keys `k · stagger` ms later.
|
|
72
|
+
*/
|
|
73
|
+
export declare function animatorFrames(node: TextNode, info: TextPoseInfo, unitsFor: (unit: TextAnimatorUnit) => TextUnits): AnimatorFrame[];
|
|
74
|
+
/**
|
|
75
|
+
* How opaque each letter of a posed text is, over all its animators: what a reader sees of each letter at that moment
|
|
76
|
+
* (a text whose letters-in has not started shows nothing, though the layer is fully opaque). `chars` is the text as
|
|
77
|
+
* drawn (brand tokens resolved), the posed text's own words by default. A text without animators is [1].
|
|
78
|
+
*/
|
|
79
|
+
export declare function letterOpacities(posed: TextNode, chars?: string): number[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AnyNode, TextAnimator, TextAnimatorOrder, TextAnimatorUnit, TextCounter } from '../document/types.js';
|
|
2
|
+
/** A layout's line ranges: [startIndex, endIndex) character indices. */
|
|
3
|
+
export interface LineRange {
|
|
4
|
+
startIndex: number;
|
|
5
|
+
endIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TextUnits {
|
|
8
|
+
/** Per character index: its unit, or −1 (whitespace, a joiner: nothing of its own to move). */
|
|
9
|
+
of: Int32Array;
|
|
10
|
+
count: number;
|
|
11
|
+
}
|
|
12
|
+
/** Which unit each character of `chars` belongs to. `lines` (a layout's) are needed for `line`; without, hard breaks. */
|
|
13
|
+
export declare function textUnits(chars: string, unit: TextAnimatorUnit, lines?: readonly LineRange[]): TextUnits;
|
|
14
|
+
export interface UnitSlots {
|
|
15
|
+
/** Each unit's place (0 first; `center` gives equidistant units the same place). */
|
|
16
|
+
rank: Float64Array;
|
|
17
|
+
/** How many places there are: the slot of place r is [r / slots, (r + 1) / slots]. */
|
|
18
|
+
slots: number;
|
|
19
|
+
}
|
|
20
|
+
/** The order `count` units are visited in. Memoised (a text keeps its unit count from frame to frame). */
|
|
21
|
+
export declare function unitSlots(count: number, order: TextAnimatorOrder, seed?: number): UnitSlots;
|
|
22
|
+
/** How much of the slot [a, b] the range selects: 0..1. */
|
|
23
|
+
export declare function rangeCoverage(a: number, b: number, range: TextAnimator['range']): number;
|
|
24
|
+
/** The slot of place `rank` among `slots`. */
|
|
25
|
+
export declare const slotOf: (rank: number, slots: number) => [number, number];
|
|
26
|
+
/** How many units `node` has for `unit` (lines from its last layout when there is one, else its hard breaks). */
|
|
27
|
+
export declare function unitCount(node: AnyNode, unit: TextAnimatorUnit): number;
|
|
28
|
+
/**
|
|
29
|
+
* How long after a track's last key it keeps moving the text (ms): for a text animator's track, the animator's
|
|
30
|
+
* cascade (its last unit plays the keys `stagger · (units − 1)` later); 0 for any other track. The timeline's
|
|
31
|
+
* length and the pose's "still live" test add it to the key.
|
|
32
|
+
*/
|
|
33
|
+
export declare function trackTail(node: AnyNode | undefined, path: string): number;
|
|
34
|
+
/**
|
|
35
|
+
* `v` in the counter's whole steps from `from` (toward `from`: a countdown shows 10 until a full second has gone), or
|
|
36
|
+
* `v` itself with no step. A hair of tolerance keeps a key landing exactly on a step from showing the step before.
|
|
37
|
+
*/
|
|
38
|
+
export declare function steppedCounterValue(c: TextCounter, v: number): number;
|
|
39
|
+
/** `v` as the counter shows it: in its steps, rounded to its decimals, thousands separated, with its prefix and suffix. */
|
|
40
|
+
export declare function formatCounter(c: TextCounter, v: number): string;
|
|
41
|
+
/** The value a counter rests at: the finished figure unless it says otherwise. */
|
|
42
|
+
export declare const counterRest: (c: TextCounter) => number;
|
|
43
|
+
/**
|
|
44
|
+
* A counter read off the figure a text already shows ("$12,400+" → from 0 to 12400, prefix "$", suffix "+", comma
|
|
45
|
+
* separated), so adding a counter to a stat keeps what it says. A text with no figure counts 0 → 100.
|
|
46
|
+
*/
|
|
47
|
+
export declare function counterFromText(chars: string): TextCounter;
|