@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,51 @@
|
|
|
1
|
+
import type { TextFit, TextPath } from '../../document/types.js';
|
|
2
|
+
/** The fields a fit scales, and what `scaleTypography` reads. */
|
|
3
|
+
interface Scalable {
|
|
4
|
+
fontSize?: number;
|
|
5
|
+
letterSpacing?: number;
|
|
6
|
+
lineHeight?: number | 'AUTO';
|
|
7
|
+
paragraphSpacing?: number;
|
|
8
|
+
paragraphIndent?: number;
|
|
9
|
+
spaceBefore?: number;
|
|
10
|
+
styledSegments?: {
|
|
11
|
+
fontSize?: number;
|
|
12
|
+
letterSpacing?: number;
|
|
13
|
+
lineHeight?: number | 'AUTO';
|
|
14
|
+
}[];
|
|
15
|
+
paragraphs?: {
|
|
16
|
+
paragraphSpacing?: number;
|
|
17
|
+
spaceBefore?: number;
|
|
18
|
+
paragraphIndent?: number;
|
|
19
|
+
}[];
|
|
20
|
+
textPath?: TextPath;
|
|
21
|
+
}
|
|
22
|
+
interface FitNode extends Scalable {
|
|
23
|
+
textFit?: TextFit;
|
|
24
|
+
textAutoResize?: string;
|
|
25
|
+
textAreaRings?: unknown[] | null;
|
|
26
|
+
characters?: string;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
/** The fit a node asks for, or null when it has none or nothing fixed to fit into. */
|
|
31
|
+
export declare function fitModeOf(node: FitNode): 'SHRINK' | 'FIT' | null;
|
|
32
|
+
/** `node` with every type size scaled by `s`: font sizes, spacing, line heights, the path's shift and spacing. */
|
|
33
|
+
export declare function scaleTypography<T extends Scalable>(node: T, s: number): T;
|
|
34
|
+
/** What a fit reads off a layout. */
|
|
35
|
+
export interface FitLayout {
|
|
36
|
+
overflow?: boolean;
|
|
37
|
+
contentHeight: number;
|
|
38
|
+
lines: {
|
|
39
|
+
width: number;
|
|
40
|
+
}[];
|
|
41
|
+
}
|
|
42
|
+
/** Whether a layout of `node` fits its container. */
|
|
43
|
+
export declare function fitsContainer(result: FitLayout, node: FitNode): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The layout at the largest scale that fits (`FIT`), or at 1 unless that overflows (`SHRINK`). `run` lays out a
|
|
46
|
+
* scaled node; it is called a dozen times at most.
|
|
47
|
+
*/
|
|
48
|
+
export declare function fitLayout<T extends FitNode, R extends FitLayout>(node: T, mode: 'SHRINK' | 'FIT', run: (n: T, scale: number) => R): R & {
|
|
49
|
+
fitScale: number;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { AnyNode, TextPath, TextPathEffect } from '../../document/types.js';
|
|
2
|
+
import type { TextLayoutResult, TextLineLayout } from './layout.js';
|
|
3
|
+
/** A flattened path: x,y pairs plus the cumulative length at each point. */
|
|
4
|
+
export interface Polyline {
|
|
5
|
+
pts: number[];
|
|
6
|
+
cum: number[];
|
|
7
|
+
length: number;
|
|
8
|
+
closed: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function polylineOf(pts: number[], closed: boolean): Polyline;
|
|
11
|
+
/**
|
|
12
|
+
* Point and tangent angle at arc length `s`: wrapped on a closed path; on an open one clamped to its ends, or with
|
|
13
|
+
* `extend` carried on straight past them along the end tangents (text allowed to overflow keeps its spacing).
|
|
14
|
+
*/
|
|
15
|
+
export declare function pointAt(p: Polyline, s: number, extend?: boolean): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
angle: number;
|
|
19
|
+
};
|
|
20
|
+
/** The nearest point of `p` to (x, y): its arc length, distance, and whether it lies on the glyphs' up side. */
|
|
21
|
+
export declare function nearestArc(p: Polyline, x: number, y: number): {
|
|
22
|
+
s: number;
|
|
23
|
+
dist: number;
|
|
24
|
+
up: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A closed path re-started at arc length `s` (same shape, same direction): for writers whose paths cannot run past
|
|
28
|
+
* their own end, like SVG's `<textPath>`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function reseamAt(p: Polyline, s: number): number[];
|
|
31
|
+
/** The same path run the other way (a closed one keeps its seam, so an arc length s becomes length − s). */
|
|
32
|
+
export declare function reversePolyline(p: Polyline): Polyline;
|
|
33
|
+
/**
|
|
34
|
+
* A closed outline as text runs on it: clockwise on screen (text on the outside, reading left to right over the
|
|
35
|
+
* top) and starting at its top centre, so a start bracket of 0 is 12 o'clock on any shape.
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeClosed(pts: number[]): number[];
|
|
38
|
+
/**
|
|
39
|
+
* The arc a line of `lineWidth` bends onto at `bend` (−100…100): 100 closes a full circle, positive bends
|
|
40
|
+
* the ends down (text over the top of a circle), negative bends them up. Zero is a straight line.
|
|
41
|
+
*/
|
|
42
|
+
export declare function arcPolyline(lineWidth: number, bend: number): Polyline;
|
|
43
|
+
/** A circle of `radius` about (radius, radius), clockwise from 12 o'clock (as `normalizeClosed` leaves any shape). */
|
|
44
|
+
export declare function circlePolyline(radius: number): Polyline;
|
|
45
|
+
/** The default circle radius for a line: it wraps about 80% of the way round. */
|
|
46
|
+
export declare const defaultCircleRadius: (lineWidth: number) => number;
|
|
47
|
+
/**
|
|
48
|
+
* A sine wave `frequency` periods long whose arc length is `lineWidth` (so the text just fills it), rising first.
|
|
49
|
+
* The x extent is solved for: a wave is longer than it is wide.
|
|
50
|
+
*/
|
|
51
|
+
export declare function wavePolyline(lineWidth: number, amplitude: number, frequency: number): Polyline;
|
|
52
|
+
/**
|
|
53
|
+
* Another node's closed or open outlines in the text node's own space (both may sit anywhere in the tree,
|
|
54
|
+
* rotated), flattened. Null when either node is missing or the node has no outline.
|
|
55
|
+
*/
|
|
56
|
+
export declare function nodeOutlineInTextSpace(nodes: Record<string, AnyNode>, textId: string, shapeId: string): {
|
|
57
|
+
pts: number[];
|
|
58
|
+
closed: boolean;
|
|
59
|
+
}[] | null;
|
|
60
|
+
/** Another layer's outline as the text follows it: its first path, a closed one normalized (see `normalizeClosed`). */
|
|
61
|
+
export declare function nodePathPolyline(nodes: Record<string, AnyNode>, textId: string, pathId: string): Polyline | null;
|
|
62
|
+
/**
|
|
63
|
+
* A text node with its linked geometry resolved for layout: the path it follows (`PATH`) or the shape it flows
|
|
64
|
+
* inside (area type). Both need other nodes, so callers that have the document attach them here; the layout cache
|
|
65
|
+
* compares them like any other layout input.
|
|
66
|
+
*/
|
|
67
|
+
export declare function attachTextPath<T extends object>(node: T, nodes: Record<string, AnyNode>): T;
|
|
68
|
+
type PathNode = {
|
|
69
|
+
textPath?: TextPath;
|
|
70
|
+
textPathPolyline?: number[] | null;
|
|
71
|
+
textPathClosed?: boolean;
|
|
72
|
+
fontSize?: number;
|
|
73
|
+
};
|
|
74
|
+
/** The polyline a laid-out text bends onto, or null when the text runs straight. */
|
|
75
|
+
export declare function polylineFor(node: PathNode, lineWidth: number): Polyline | null;
|
|
76
|
+
/** Whether the path is the text's own geometry (it moves with the text box) rather than another layer's. */
|
|
77
|
+
export declare const ownsPath: (tp: TextPath | undefined) => boolean;
|
|
78
|
+
/** The brackets as arc lengths on the (unflipped) path: `[start, end]`, end > start. */
|
|
79
|
+
export declare function bracketRange(tp: TextPath, path: Polyline): [number, number];
|
|
80
|
+
/** One laid-out line's run along the path. */
|
|
81
|
+
export interface TextPathLine {
|
|
82
|
+
startIndex: number;
|
|
83
|
+
endIndex: number;
|
|
84
|
+
/** Arc length of the line's pen x = 0 (its own left edge). */
|
|
85
|
+
base: number;
|
|
86
|
+
/** Extra arc length added before each successive character (spacing, justification). */
|
|
87
|
+
gap: number;
|
|
88
|
+
/** The line's straight left edge (subtracted from glyph pens). */
|
|
89
|
+
x0: number;
|
|
90
|
+
/** The line's baseline offset below the path, in the glyph frame (placement, shift, later lines). */
|
|
91
|
+
down: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* How a layout maps onto its path — what the caret, hit-testing, the on-canvas brackets and the SVG `<textPath>`
|
|
95
|
+
* exporter read, so none of them re-derives the path rules. Coordinates are the layout's (after any re-base).
|
|
96
|
+
*/
|
|
97
|
+
export interface TextPathMap {
|
|
98
|
+
/** The path the glyphs ride on, already reversed when flipped, in layout coordinates. */
|
|
99
|
+
pts: number[];
|
|
100
|
+
closed: boolean;
|
|
101
|
+
/** The unflipped path and its brackets (arc lengths on it): what the start/end handles sit on. */
|
|
102
|
+
basePts: number[];
|
|
103
|
+
range: [number, number];
|
|
104
|
+
flip: boolean;
|
|
105
|
+
effect: TextPathEffect;
|
|
106
|
+
lines: TextPathLine[];
|
|
107
|
+
ascent: number;
|
|
108
|
+
descent: number;
|
|
109
|
+
/** Gravity's centre. */
|
|
110
|
+
center: [number, number];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Bend a laid-out text onto `path`. Each line runs between the brackets as `tp.align` says (LEFT, CENTER, RIGHT or
|
|
114
|
+
* JUSTIFY, which stretches it to fill them), riding on the path by `tp.placement` and `tp.baselineShift`, later
|
|
115
|
+
* lines stacked below the first. A glyph whose advance falls outside the brackets is dropped and the result marked
|
|
116
|
+
* `overflow` (unless `tp.overflow` is VISIBLE, which extends an open path's ends). `rebase` moves the result so its
|
|
117
|
+
* bounds start at the origin (the text's own geometry, which moves with its box); otherwise the glyphs keep their
|
|
118
|
+
* place and `pathBox` says where they landed (another layer's outline, which the box has to follow). Decorations
|
|
119
|
+
* do not follow a path.
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyTextPath(layout: TextLayoutResult, path: Polyline, tp: TextPath, rebase?: boolean): TextLayoutResult;
|
|
122
|
+
/** A caret on the path: its centre, the tangent it stands on (radians, layout space) and its height. */
|
|
123
|
+
export interface PathCaret {
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
angle: number;
|
|
127
|
+
height: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Where the caret before character `index` stands on a path layout (the pen at that character, spanning the glyphs'
|
|
131
|
+
* ascent and descent), or null for a layout that is not on a path.
|
|
132
|
+
*/
|
|
133
|
+
export declare function pathCaretAt(layout: TextLayoutResult, index: number, straightX: (line: TextLineLayout, index: number) => number): PathCaret | null;
|
|
134
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GlyphInstance } from './layout.js';
|
|
2
|
+
import { type PathCommand } from './outline-sdf.js';
|
|
3
|
+
export type Ring = [number, number][];
|
|
4
|
+
/** A glyph's outline commands (font units) and the map from font units into node space; null for a glyph with no outline. */
|
|
5
|
+
export declare function glyphOutline(g: GlyphInstance): {
|
|
6
|
+
commands: PathCommand[];
|
|
7
|
+
place: (x: number, y: number) => [number, number];
|
|
8
|
+
} | null;
|
|
9
|
+
/**
|
|
10
|
+
* Closed rings for the glyphs of a laid-out text node, in node space (top-left origin).
|
|
11
|
+
*
|
|
12
|
+
* Curves are flattened with the shared `flattenPath`, the same routine that feeds the SDF rasterizer, so an
|
|
13
|
+
* outline and the glyph drawn from it agree. Counters (the hole in an "o") come back as their own rings with
|
|
14
|
+
* opposite winding — callers union/even-odd them, which is what `polygon-clipping` and the GPU triangulator
|
|
15
|
+
* already do for multi-path vectors.
|
|
16
|
+
*/
|
|
17
|
+
export declare function glyphInstancesToRings(instances: readonly GlyphInstance[]): Ring[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface WrapObstacle {
|
|
2
|
+
/** Bounds in the text node's local space. */
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
padding?: number;
|
|
8
|
+
sides?: 'BOTH' | 'LEFT' | 'RIGHT';
|
|
9
|
+
}
|
|
10
|
+
export interface WrapInterval {
|
|
11
|
+
left: number;
|
|
12
|
+
right: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Free intervals on the baseline band `[lineTop, lineBottom]` within `[0, boxWidth]`,
|
|
16
|
+
* after punching out obstacles that intersect the band.
|
|
17
|
+
*/
|
|
18
|
+
export declare function availableIntervals(lineTop: number, lineBottom: number, boxWidth: number, obstacles: readonly WrapObstacle[]): WrapInterval[];
|
|
19
|
+
/** First usable interval for a line that needs at least `minWidth` px, or null. */
|
|
20
|
+
export declare function firstInterval(lineTop: number, lineBottom: number, boxWidth: number, obstacles: readonly WrapObstacle[], minWidth?: number): WrapInterval | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Catalog = Record<string, string>;
|
|
2
|
+
export declare const SOURCE_CATALOG: Catalog;
|
|
3
|
+
/** Locales with a translated catalog (English and the pseudo-locales come from the source). */
|
|
4
|
+
export declare const TRANSLATED_LOCALES: string[];
|
|
5
|
+
/** Translations loaded so far, by locale code. */
|
|
6
|
+
export declare const TRANSLATIONS: Record<string, Catalog>;
|
|
7
|
+
/** Whether `code` can render now: its catalog is loaded, or it needs none. */
|
|
8
|
+
export declare function catalogReady(code: string): boolean;
|
|
9
|
+
/** Load `code`'s catalog (once; concurrent calls share the request). Rejects when the chunk can't be fetched. */
|
|
10
|
+
export declare function loadCatalog(code: string): Promise<Catalog | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** 1234.5 → "1,234.5" (en), "1.234,5" (de). */
|
|
2
|
+
export declare function formatNumber(n: number, opts?: Intl.NumberFormatOptions): string;
|
|
3
|
+
/** 0.42 → "42%". */
|
|
4
|
+
export declare function formatPercent(fraction: number, maximumFractionDigits?: number): string;
|
|
5
|
+
/** Design units keep their symbol; the number is localised: (12.5, 'px') → "12.5 px" / "12,5 px". */
|
|
6
|
+
export declare function formatUnitValue(value: number, unit: 'px' | 'mm' | 'cm' | 'in' | 'pt' | 'pc' | '%', maximumFractionDigits?: number): string;
|
|
7
|
+
/**
|
|
8
|
+
* A byte count in the largest sensible unit, using Intl's byte units: 1536 → "1.5 kB", 3e9 → "2.8 GB". It starts at
|
|
9
|
+
* kB (0 → "0 kB", 300 → "0.3 kB"), because Intl's short form of a plain byte count reads "0 byte".
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatFileSize(bytes: number): string;
|
|
12
|
+
/**
|
|
13
|
+
* A duration as a gallery card or a timeline says it: "3 s", "4.5 s", "1 min 20 s" (and "3 Sek." in German), with
|
|
14
|
+
* Intl's unit formats. `ms` in milliseconds.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatDuration(ms: number): string;
|
|
17
|
+
/** "3 minutes ago", "yesterday", "in 2 days" — the largest unit that fits. `now` for tests. */
|
|
18
|
+
export declare function formatRelativeTime(date: Date | number, now?: number, style?: Intl.RelativeTimeFormatStyle): string;
|
|
19
|
+
/** One relative amount in a given unit: (-3, 'hour') → "3 hours ago"; (-1, 'day') → "yesterday". */
|
|
20
|
+
export declare function formatRelative(value: number, unit: Intl.RelativeTimeFormatUnit, style?: Intl.RelativeTimeFormatStyle): string;
|
|
21
|
+
/** Dates and times: `formatDate(d)` "Sep 29, 2026"; pass Intl options for anything else. */
|
|
22
|
+
export declare function formatDate(date: Date | number, opts?: Intl.DateTimeFormatOptions): string;
|
|
23
|
+
export declare function formatTime(date: Date | number, opts?: Intl.DateTimeFormatOptions): string;
|
|
24
|
+
/** ["Ada", "Bo", "Cy"] → "Ada, Bo, and Cy" (en), "Ada, Bo und Cy" (de). */
|
|
25
|
+
export declare function formatList(items: readonly string[], type?: Intl.ListFormatType): string;
|
|
26
|
+
/** Tests only: forget cached formatters (the locale changed under them). */
|
|
27
|
+
export declare function resetFormatCache(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface LocaleInfo {
|
|
2
|
+
code: string;
|
|
3
|
+
/** The language's own name for itself ("Deutsch"), which is what a picker should show. */
|
|
4
|
+
name: string;
|
|
5
|
+
dir: 'ltr' | 'rtl';
|
|
6
|
+
/** Pseudo-locales are for testing; they are listed under a separator in Settings, outside production. */
|
|
7
|
+
pseudo?: 'accented' | 'bidi';
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
10
|
+
export declare const PSEUDO_LOCALES_ENABLED: boolean;
|
|
11
|
+
export declare const LOCALES: readonly LocaleInfo[];
|
|
12
|
+
export declare const LOCALE_CODES: string[];
|
|
13
|
+
export declare function localeInfo(code: string): LocaleInfo;
|
|
14
|
+
export declare function directionOf(lang: string | undefined): 'ltr' | 'rtl';
|
|
15
|
+
/**
|
|
16
|
+
* The best shipped locale for a list of preferred languages (navigator.languages), falling back to English. Exact
|
|
17
|
+
* tag first, then the language without its region ("de-AT" → "de"), in the person's order. Pseudo-locales never match.
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchLocale(preferred: readonly string[]): string;
|
|
20
|
+
export declare const LOCALE_STORAGE_KEY = "popcraft-locale";
|
|
21
|
+
/**
|
|
22
|
+
* Inline, pre-hydration: sets <html lang dir> from the stored choice (or the browser's languages), so the first
|
|
23
|
+
* paint already has the right direction. Mirrors `initialLocale()` in lib/i18n/runtime.ts.
|
|
24
|
+
*/
|
|
25
|
+
export declare const localeBootScript: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MessageFormatElement } from '@formatjs/icu-messageformat-parser';
|
|
2
|
+
export declare const PSEUDO_OPEN = "\u27E6";
|
|
3
|
+
export declare const PSEUDO_CLOSE = "\u27E7";
|
|
4
|
+
/** One run of literal text, accented and lengthened. */
|
|
5
|
+
export declare function accentText(s: string): string;
|
|
6
|
+
export declare function bidiText(s: string): string;
|
|
7
|
+
type Mode = 'accented' | 'bidi';
|
|
8
|
+
/** A pseudo-localised copy of a parsed English message. */
|
|
9
|
+
export declare function pseudoAst(ast: MessageFormatElement[], mode: Mode): MessageFormatElement[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import en from './messages/en.json';
|
|
2
|
+
export type MessageKey = keyof typeof en;
|
|
3
|
+
export type MessageValues = Record<string, string | number | boolean | Date | null | undefined>;
|
|
4
|
+
/** The stored choice, else the browser's languages matched to a shipped locale. Client only. */
|
|
5
|
+
export declare function initialLocale(): string;
|
|
6
|
+
export declare function getLocale(): string;
|
|
7
|
+
/** The language a switch is waiting on (its catalog is loading), else null. */
|
|
8
|
+
export declare function pendingLocale(): string | null;
|
|
9
|
+
/** The locale `Intl` should format with: a pseudo-locale formats numbers and dates as English does. */
|
|
10
|
+
export declare function intlLocale(code?: string): string;
|
|
11
|
+
export declare function getDirection(code?: string): 'ltr' | 'rtl';
|
|
12
|
+
/**
|
|
13
|
+
* Switch language (Settings › Language). `null` forgets the choice and follows the browser again. The UI keeps its
|
|
14
|
+
* current language until the new catalog has loaded; false when it could not be (offline, never fetched before). A
|
|
15
|
+
* switch overtaken by a later one resolves true: nothing went wrong.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setLocale(code: string | null): Promise<boolean>;
|
|
18
|
+
export declare function subscribeLocale(fn: () => void): () => void;
|
|
19
|
+
/** A message from the catalog, in the current language. `values` fill its ICU arguments. */
|
|
20
|
+
export declare function t(key: MessageKey, values?: MessageValues): string;
|
|
21
|
+
/**
|
|
22
|
+
* A message whose key is built at run time (a command id, a plugin's own string) with the English to use when the
|
|
23
|
+
* catalog has no entry for it. Keeps a dynamic lookup honest: the source text is always at hand.
|
|
24
|
+
*/
|
|
25
|
+
export declare function tx(key: string, fallback: string, values?: MessageValues): string;
|
|
26
|
+
/** Whether the current catalog (or the source) has `key`. */
|
|
27
|
+
export declare function hasMessage(key: string): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** `channels` (−1…1, all the same length) as a 16-bit PCM WAV file. */
|
|
2
|
+
export declare function encodeWav(channels: readonly Float32Array[], sampleRate: number): Uint8Array;
|
|
3
|
+
/** A 16-bit PCM WAV's samples (−1…1 per channel) and rate. Throws on anything else. */
|
|
4
|
+
export declare function decodeWav(bytes: Uint8Array): {
|
|
5
|
+
channels: Float32Array[];
|
|
6
|
+
sampleRate: number;
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Huffman code lengths for `freq`, limited to `maxLen` bits. A lone used symbol gets length 1. */
|
|
2
|
+
export declare function huffmanLengths(freq: ArrayLike<number>, maxLen: number): Uint8Array;
|
|
3
|
+
/**
|
|
4
|
+
* Encode straight-alpha RGBA8 pixels (row-major, top-down) as a lossless WebP (VP8L) file.
|
|
5
|
+
* Exact round-trip, including fully transparent pixels' color.
|
|
6
|
+
*/
|
|
7
|
+
export declare function encodeWebpLossless(width: number, height: number, rgba: Uint8Array | Uint8ClampedArray): Uint8Array;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Document } from '../document/types.js';
|
|
2
|
+
export interface DocumentJSON {
|
|
3
|
+
version: string;
|
|
4
|
+
name: string;
|
|
5
|
+
document: Document;
|
|
6
|
+
exportedAt: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function exportToJSON(document: Document): string;
|
|
9
|
+
export declare function downloadJSON(document: Document, filename?: string): Promise<void>;
|
|
10
|
+
export declare function importFromJSON(jsonString: string): Document | null;
|
|
11
|
+
export declare function importJSONFile(file: File): Promise<Document | null>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type MediaKind = 'image' | 'video' | 'audio';
|
|
2
|
+
/** Where media came from, as the device that stored it first recorded it (`media.source`; null = unknown). */
|
|
3
|
+
export type MediaSource = 'generated' | 'upload' | 'stock';
|
|
4
|
+
export declare const MEDIA_SOURCES: readonly MediaSource[];
|
|
5
|
+
export declare const isMediaSource: (v: unknown) => v is MediaSource;
|
|
6
|
+
/** The header an upload carries its source in (POST /api/media). */
|
|
7
|
+
export declare const MEDIA_SOURCE_HEADER = "x-media-source";
|
|
8
|
+
export declare const MEDIA_KINDS: readonly MediaKind[];
|
|
9
|
+
export interface MediaLibraryItem {
|
|
10
|
+
hash: string;
|
|
11
|
+
contentType: string;
|
|
12
|
+
size: number;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
/** A file of the workspace that references it: read the bytes through `/api/media/<hash>?file=<fileKey>`. */
|
|
15
|
+
fileKey: string;
|
|
16
|
+
fileName: string;
|
|
17
|
+
/** How many of the listed scope's files reference it. */
|
|
18
|
+
fileCount: number;
|
|
19
|
+
/** Where it came from; null when unknown (stored before this was recorded). */
|
|
20
|
+
source: MediaSource | null;
|
|
21
|
+
}
|
|
22
|
+
export interface MediaLibraryPage {
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
items: MediaLibraryItem[];
|
|
25
|
+
nextCursor: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface MediaLibraryQuery {
|
|
28
|
+
workspace?: string | null;
|
|
29
|
+
/** A project id, or `none` for files at the workspace's top level. */
|
|
30
|
+
project?: string | null;
|
|
31
|
+
file?: string | null;
|
|
32
|
+
type?: MediaKind | null;
|
|
33
|
+
/** One origin, or every item (`all`, the default; unknown-origin items show only here). */
|
|
34
|
+
source?: MediaSource | 'all' | null;
|
|
35
|
+
cursor?: string | null;
|
|
36
|
+
limit?: number;
|
|
37
|
+
}
|
|
38
|
+
/** The kind an item's content type is (null for anything the library does not show). */
|
|
39
|
+
export declare function mediaKindOf(contentType: string): MediaKind | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Analysis frames a second: a 10 ms hop. */
|
|
2
|
+
export declare const ANALYSIS_FPS = 100;
|
|
3
|
+
/** Log-spaced bands in the spectrum. */
|
|
4
|
+
export declare const SPECTRUM_BINS = 32;
|
|
5
|
+
/** Bumped whenever the features' maths or layout change, so a cached analysis is made again. */
|
|
6
|
+
export declare const ANALYSIS_VERSION = 1;
|
|
7
|
+
/** The band edges (Hz) of bass, mid and treble. */
|
|
8
|
+
export declare const BANDS: {
|
|
9
|
+
readonly bass: readonly [20, 250];
|
|
10
|
+
readonly mid: readonly [250, 4000];
|
|
11
|
+
readonly treble: readonly [4000, 16000];
|
|
12
|
+
};
|
|
13
|
+
export type Band = keyof typeof BANDS;
|
|
14
|
+
export interface AudioAnalysis {
|
|
15
|
+
version: number;
|
|
16
|
+
/** Analysis frames a second (`ANALYSIS_FPS`). */
|
|
17
|
+
fps: number;
|
|
18
|
+
/** Frames. */
|
|
19
|
+
length: number;
|
|
20
|
+
/** ms of audio analysed. */
|
|
21
|
+
durationMs: number;
|
|
22
|
+
level: Float32Array;
|
|
23
|
+
bass: Float32Array;
|
|
24
|
+
mid: Float32Array;
|
|
25
|
+
treble: Float32Array;
|
|
26
|
+
onset: Float32Array;
|
|
27
|
+
/** `length × SPECTRUM_BINS`, frame-major: bin `b` of frame `f` is `spectrum[f * SPECTRUM_BINS + b]`. */
|
|
28
|
+
spectrum: Float32Array;
|
|
29
|
+
/** ms of each hit, ascending. */
|
|
30
|
+
beats: Float32Array;
|
|
31
|
+
/** The tempo the hits suggest, or null. */
|
|
32
|
+
bpm: number | null;
|
|
33
|
+
}
|
|
34
|
+
/** The FFT size for `rate`: the power of two nearest 40 ms (2048 at 44.1/48 kHz, 1024 at 32 kHz or less). */
|
|
35
|
+
export declare const fftSize: (rate: number) => number;
|
|
36
|
+
/**
|
|
37
|
+
* The analysis of `channels` at `sampleRate`: pure and deterministic. Silence analyses to zeros (never NaN), and an
|
|
38
|
+
* empty input to a zero-length analysis.
|
|
39
|
+
*/
|
|
40
|
+
export declare function analyzeAudio(channels: readonly Float32Array[], sampleRate: number): AudioAnalysis;
|
|
41
|
+
/** Whether `v` is an analysis of the current version (a cached one from before is made again). */
|
|
42
|
+
export declare const isCurrentAnalysis: (v: unknown) => v is AudioAnalysis;
|
|
43
|
+
/** The arrays an analysis holds (what a worker transfers). */
|
|
44
|
+
export declare const analysisBuffers: (a: AudioAnalysis) => ArrayBuffer[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { AudioClip, Composition, Interp } from '../document/types.js';
|
|
2
|
+
/** How many lanes a composition's sound can use. */
|
|
3
|
+
export declare const MAX_AUDIO_LANES = 8;
|
|
4
|
+
/** The gain a clip's level can be raised to (≈ +12 dB). */
|
|
5
|
+
export declare const MAX_GAIN = 4;
|
|
6
|
+
/** How a gain track is sampled: a continuous number, like any layer property. */
|
|
7
|
+
export declare const GAIN_PROPERTY: {
|
|
8
|
+
readonly valueType: "number";
|
|
9
|
+
readonly interpolation: "continuous";
|
|
10
|
+
};
|
|
11
|
+
/** The label onset markers carry (lib/motion/audio-onsets.ts): the set a new detection replaces. */
|
|
12
|
+
export declare const ONSET_LABEL = "onsets";
|
|
13
|
+
/** The slowest and fastest a clip can play (file ms per clip ms). */
|
|
14
|
+
export declare const MIN_AUDIO_SPEED = 0.25, MAX_AUDIO_SPEED = 4;
|
|
15
|
+
/** A clip's speed: 1 unless it holds a finite one in range. */
|
|
16
|
+
export declare const audioSpeed: (c: Pick<AudioClip, "speed">) => number;
|
|
17
|
+
/** How long a clip plays (ms): its piece of the file, at its speed. */
|
|
18
|
+
export declare const audioClipLength: (c: Pick<AudioClip, "in" | "out" | "speed">) => number;
|
|
19
|
+
/** Where a clip stops (composition ms). */
|
|
20
|
+
export declare const audioClipEnd: (c: Pick<AudioClip, "start" | "in" | "out" | "speed">) => number;
|
|
21
|
+
/** What holds audio clips on lanes: a composition, or a frame's timeline. */
|
|
22
|
+
export type AudioHolder = {
|
|
23
|
+
audio?: AudioClip[];
|
|
24
|
+
};
|
|
25
|
+
/** How many lanes to draw: every lane in use plus one empty one to drop on (at least one). */
|
|
26
|
+
export declare const audioLaneCount: (h: AudioHolder) => number;
|
|
27
|
+
/** The clip's level at clip time `t` from its gain track (1 without one): the sampler every layer property uses. */
|
|
28
|
+
export declare function clipGainAt(clip: Pick<AudioClip, 'gain'>, t: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* The fade envelope at clip time `t` (0 at an edge with a fade, 1 inside); fades that overlap are shortened to meet.
|
|
31
|
+
* Straight lines, or equal power (`fadeCurve`): sin of the straight line's quarter turn, so a clip fading out over one
|
|
32
|
+
* fading in the same way sums to constant power (cos² + sin² = 1) — the crossfade whose level does not dip.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fadeAt(clip: Pick<AudioClip, 'in' | 'out' | 'speed' | 'fadeIn' | 'fadeOut' | 'fadeCurve'>, t: number): number;
|
|
35
|
+
/** Fade lengths that fit a clip of `len` ms: each within the clip, and together no longer than it (scaled down evenly). */
|
|
36
|
+
export declare function fitFades(len: number, fadeIn: number, fadeOut: number): [number, number];
|
|
37
|
+
/**
|
|
38
|
+
* `clips` with `clip` placed: on its lane when nothing there overlaps it, else on the first lane below (then above)
|
|
39
|
+
* where it fits; the last lane takes it when every lane is full. The others never move.
|
|
40
|
+
*/
|
|
41
|
+
export declare function placeAudio(clips: readonly AudioClip[], clip: AudioClip): AudioClip[];
|
|
42
|
+
/** `comp` with `audio` as its sound (the field dropped when empty). */
|
|
43
|
+
export declare function withAudio<T extends AudioHolder>(comp: T, audio: AudioClip[]): T;
|
|
44
|
+
/** `comp` with a clip of `mediaHash` (a file `duration` ms long) heard from `start`, on the first free lane from `lane`. */
|
|
45
|
+
export declare function addAudioClip<T extends AudioHolder>(comp: T, o: {
|
|
46
|
+
mediaHash: string;
|
|
47
|
+
name: string;
|
|
48
|
+
duration: number;
|
|
49
|
+
start?: number;
|
|
50
|
+
lane?: number;
|
|
51
|
+
id?: string;
|
|
52
|
+
}): {
|
|
53
|
+
composition: T;
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
/** What an edit may change on a clip. */
|
|
57
|
+
export type AudioClipPatch = Partial<Pick<AudioClip, 'name' | 'start' | 'in' | 'out' | 'lane' | 'fadeIn' | 'fadeOut' | 'fadeCurve' | 'muted' | 'pan' | 'speed'>>;
|
|
58
|
+
/**
|
|
59
|
+
* `comp` with clip `id` changed: times whole ms, `in` ≥ 0, at least 1 ms long, fades within it, pan in −1…1, then
|
|
60
|
+
* placed on a lane where it fits. The same composition when nothing changes.
|
|
61
|
+
*/
|
|
62
|
+
export declare function editAudioClip<T extends AudioHolder>(comp: T, id: string, patch: AudioClipPatch): T;
|
|
63
|
+
/**
|
|
64
|
+
* Clip `id` trimmed at an edge by `delta` ms: its start edge moves the start and `in` together (the sound stays where
|
|
65
|
+
* it was in time), its end edge moves `out`. `sourceMs`, when known, is the file's length, which `out` stays within.
|
|
66
|
+
*/
|
|
67
|
+
export declare function trimAudioClip<T extends AudioHolder>(comp: T, id: string, edge: 'in' | 'out', delta: number, sourceMs?: number): T;
|
|
68
|
+
/** Clip `id` without it. */
|
|
69
|
+
export declare function removeAudioClip<T extends AudioHolder>(comp: T, id: string): T;
|
|
70
|
+
/** Clip `id` with a gain key at clip time `t` set to `v` (clamped to 0…MAX_GAIN), or removed (`v` null). */
|
|
71
|
+
export declare function setGainKey<T extends AudioHolder>(comp: T, id: string, t: number, v: number | null, out?: Interp): T;
|
|
72
|
+
/** The key on clip `id`'s gain within a ms of clip time `t`, if any. */
|
|
73
|
+
export declare const gainKeyAt: (clip: AudioClip, t: number) => import("../document/types.js").Key<number> | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* `comp` with its onset markers replaced by markers at `times` (composition ms), labelled `ONSET_LABEL`. Other
|
|
76
|
+
* markers stay; an onset within a ms of one of them is not doubled.
|
|
77
|
+
*/
|
|
78
|
+
export declare function setOnsetMarkers(comp: Composition, times: readonly number[]): Composition;
|
|
79
|
+
/** The composition ms of its onset markers (the hits `detect onsets` found), in order. */
|
|
80
|
+
export declare const onsetTimes: (comp: Pick<Composition, "markers">) => number[];
|
|
81
|
+
/**
|
|
82
|
+
* `comp` cut to the beat: each scene's end trimmed (later scenes rippling) so the next scene starts on the onset
|
|
83
|
+
* nearest where it starts now — every `every`th onset only, a scene never shorter than `minScene` ms, cuts always
|
|
84
|
+
* moving forward. The transitions keep their lengths; a transition starts on its beat. Returns the cut times too.
|
|
85
|
+
*/
|
|
86
|
+
export declare function cutToBeat(comp: Composition, opts?: {
|
|
87
|
+
every?: number;
|
|
88
|
+
minScene?: number;
|
|
89
|
+
}): {
|
|
90
|
+
composition: Composition;
|
|
91
|
+
cuts: number[];
|
|
92
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface OnsetResult {
|
|
2
|
+
/** ms from the start of the samples, ascending. */
|
|
3
|
+
onsets: number[];
|
|
4
|
+
/** Beats per minute the onsets suggest (60…200), or null when they are too few or too irregular. */
|
|
5
|
+
bpm: number | null;
|
|
6
|
+
}
|
|
7
|
+
/** Onsets in `channels` (at `sampleRate`), and a tempo estimate. `sensitivity` (0…1) lowers the bar a hit must clear. */
|
|
8
|
+
export declare function detectOnsets(channels: readonly Float32Array[], sampleRate: number, sensitivity?: number): OnsetResult;
|
|
9
|
+
/**
|
|
10
|
+
* The tempo whose beat best explains the gaps between onsets: every gap votes for the tempos (60…200 BPM) it is a
|
|
11
|
+
* whole or half number of beats of, and the best-supported one wins (to a tenth of a BPM).
|
|
12
|
+
*/
|
|
13
|
+
export declare function estimateBpm(onsets: readonly number[]): number | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AudioClip, AudioSignalName } from '../document/types.js';
|
|
2
|
+
import { type AudioAnalysis } from './audio-analysis.js';
|
|
3
|
+
export type { AudioSignalName };
|
|
4
|
+
/** Every signal, in the order the behaviours panel lists them. */
|
|
5
|
+
export declare const AUDIO_SIGNALS: readonly AudioSignalName[];
|
|
6
|
+
/** How a signal is read: which one, where in the spectrum, how it is smoothed and how far behind it looks. */
|
|
7
|
+
export interface AudioSignalSpec {
|
|
8
|
+
signal: AudioSignalName;
|
|
9
|
+
/** `spectrum`: where in it, 0 (40 Hz) … 1 (16 kHz), log-spaced. */
|
|
10
|
+
bin?: number;
|
|
11
|
+
/** ms a rise takes to follow (a one-pole attack). `beat`: ms the flash takes to rise to its peak. */
|
|
12
|
+
attack?: number;
|
|
13
|
+
/** ms a fall takes (release). `beat`: the flash's decay time constant (default `BEAT_RELEASE_MS`). */
|
|
14
|
+
release?: number;
|
|
15
|
+
/** ms behind the moment the signal is read at (a waveform's history: each point a little further back). */
|
|
16
|
+
lag?: number;
|
|
17
|
+
/** Only this clip (by id or media hash). Unset: the loudest of whatever is heard. */
|
|
18
|
+
clip?: string;
|
|
19
|
+
}
|
|
20
|
+
/** How long a beat's flash takes to die down when no release is set (ms, time constant). */
|
|
21
|
+
export declare const BEAT_RELEASE_MS = 220;
|
|
22
|
+
/** Keep `analysis` as media `hash`'s (and redraw whatever follows it). */
|
|
23
|
+
export declare function setAnalysis(hash: string, analysis: AudioAnalysis): void;
|
|
24
|
+
/** Forget every analysis (tests). */
|
|
25
|
+
export declare function clearAnalyses(): void;
|
|
26
|
+
/** The media hashes analysed so far. */
|
|
27
|
+
export declare const analysedHashes: () => string[];
|
|
28
|
+
/** The analysis of media `hash`, when it has been made. */
|
|
29
|
+
export declare const analysisOf: (hash: string) => AudioAnalysis | undefined;
|
|
30
|
+
/** Changes whenever an analysis arrives. */
|
|
31
|
+
export declare const analysisVersion: () => number;
|
|
32
|
+
/** Called whenever an analysis arrives; returns the unsubscribe. */
|
|
33
|
+
export declare function subscribeAnalyses(fn: () => void): () => void;
|
|
34
|
+
export declare function setAnalysisRequester(fn: ((hash: string) => void) | null): void;
|
|
35
|
+
/** Ask for the analysis of every unmuted clip of `sound` that has none yet (a no-op where nothing can make one). */
|
|
36
|
+
export declare function requestAnalyses(sound: readonly AudioClip[]): void;
|
|
37
|
+
/** What is heard while a pose is sampled: the clips (target ms) and the moment (target ms). */
|
|
38
|
+
export interface AudioScope {
|
|
39
|
+
sound: readonly AudioClip[];
|
|
40
|
+
time: number;
|
|
41
|
+
}
|
|
42
|
+
/** `fn` run with `scope` as what is heard (nested scopes restore the outer one). */
|
|
43
|
+
export declare function withAudioScope<T>(scope: AudioScope | null, fn: () => T): T;
|
|
44
|
+
/** What is heard now, while a pose is sampled (null outside one: editing at rest hears nothing). */
|
|
45
|
+
export declare const audioScope: () => AudioScope | null;
|
|
46
|
+
/** Whether a scope has anything to follow (an unmuted clip). */
|
|
47
|
+
export declare const scopeAudible: (scope: AudioScope | null) => boolean;
|
|
48
|
+
type Series = Float32Array;
|
|
49
|
+
/** Spectrum band index for position `bin` (0…1). */
|
|
50
|
+
export declare const spectrumIndex: (bin: number | undefined) => number;
|
|
51
|
+
/** A one-pole follower over `x`: rises with time constant `attack` ms, falls with `release` ms. */
|
|
52
|
+
export declare function follow(x: Series, attack: number, release: number, fps?: number): Series;
|
|
53
|
+
/** Signal `spec` of one analysis at file ms `ms` (0…1). */
|
|
54
|
+
export declare function signalAt(a: AudioAnalysis, spec: AudioSignalSpec, ms: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Signal `spec` as heard in `scope` (0…1): each clip that plays at the moment (`lag` ms earlier) read at its file time,
|
|
57
|
+
* times its level (fades, gain; never above 1), and the loudest wins. 0 with nothing heard or nothing analysed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function sampleSignal(spec: AudioSignalSpec, scope?: AudioScope | null): number;
|