@cutcraft/kit 0.0.0-stage → 0.2.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/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { Jn as ANIMATION_UNITS, Yn as AUTOMATION_LANES, lt as AUTO_GROUP_TYPES, ct as ActionHistory, tn as Adjustment, nn as Angle, rn as Audio, Xn as BLEND_MODES, c as BUNDLED_FONTS, l as BUNDLED_FONT_WEIGHTS, Zn as CAPTION_ANIMATIONS, Qn as CAPTION_POSITIONS, in as Caption, an as Captions, on as Clip, sn as ColorGrade, cn as Composition, ln as Cut, St as DEFAULT_CUE_OPTIONS, Vn as DEFAULT_THEME, $n as EASINGS, kt as EASING_FN, un as ELEMENTS, Ht as EMPTY_MANIFEST, dn as ENGINE_LAYERS, fn as ENGINE_SCHEMAS, pn as Effect, rt as Executor, er as FIT_MODES, Hn as FONT_KEYS, mn as Freeze, tr as GRAPHIC_ANIMATIONS, hn as Gap, gn as Graphic, yt as INTERIOR_PREFIX, nr as KEYFRAME_PROPERTIES, rr as KEYFRAME_PROPERTY_PATTERN, Pr as KIND_CAPABILITIES, _n as Keyframe, vn as Layer, b as MASKED_KINDS, ir as MASK_EASINGS, x as MASK_NOT_RENDERED, ar as MASK_TYPES, u as MODULE_FONTS, Jt as MODULE_SHADERS, Un as MOTIONS, Wn as MOTION_NAMES, yn as Marker, bn as Mask, xn as Motion, Sn as Multicam, S as NOT_RENDERED, Cn as Nested, N as NotImplemented, Gn as PALETTE_KEYS, C as RENDERED_VALUES, wn as SCHEMAS_BY_KIND, or as SHAPE_TYPES, In as STYLED_KINDS, sr as SVG_COLOR_MODES, Tn as Shape, En as SpeedKey, Dn as Sticker, On as Svg, ut as TARGET_PARAM_KEYS, cr as TEXT_ALIGNS, lr as TEXT_ANIMATION_PRESETS, ur as TEXT_DECORATIONS, dr as TEXT_VALIGNS, Kn as THEMES, qn as THEME_NAMES, Ln as TOKEN_PATTERN, fr as TRACK_FLAGS, pr as TRACK_LAYOUTS, mr as TRACK_ROLES, Pn as TRANSITION_PARAMS, hr as TRANSITION_TYPES, kn as Three, An as Title, jn as Track, Mn as Transition, gr as VIDEO_EFFECT_TYPES, zt as applyTheme, Ir as asJson, Ut as assetIdOf, Fr as capabilitiesOf, P as childAt, F as childIndex, o as collect, I as collectErrors, d as collectFonts, s as collectModule, Yt as collectShaders, Lr as createPatchLog, Ct as cueNodes, Fn as defaultTransitionParams, L as define, Xt as defineEffect, jr as defineElement, Zt as defineTransition, dt as describeAction, Nn as engineOf, bt as findParentOf, f as font, p as fontsOf, At as freezeHoldsOf, jt as freezeShift, Mt as freezeUnshift, it as getHandler, m as googleFont, t as graphicControls, E as holdLayerFrame, Nt as holdTotal, R as insertNode, _ as installLayerClock, D as installLayerEngine, A as interpolate, pt as invalid, at as inverseOf, h as isBundledFont, z as isError, _r as isKeyframeProperty, a as isResolveError, Gt as isTimeRefString, Mr as isVocabulary, Nr as kindOf, B as lastChildId, O as layerEngine, k as layerFramesPending, ot as listHandlers, Wt as lookupAsset, V as makePropHandler, w as motionBlurOf, Rn as motionStyleSchema, mt as nodeOfSpec, ht as nodeSpecOf, Rr as nodesEqual, gt as ok, wt as onTimeline, Kt as parseTimeRef, g as parseTranscript, H as placeNode, U as placementOf, W as placementProps, Tt as planCues, Et as playsKey, Pt as rampAdvance, Ft as rampInverse, It as rampSpeed, j as random, G as rawNode, K as rawProp, zr as reduceInto, st as registerHandler, q as requireElement, J as requireLayout, Y as requireLiteralProp, X as requireNotOpaque, Z as requireUnlocked, _t as resolve, i as resolveScene, Bt as resolveTheme, qt as resolveTimeRef, Dt as sameAsset, vt as samePlacement, Q as setProps, Qt as shaderFor, $t as shadersOf, T as shutterTimes, $ as siblingAfter, Lt as speedKeysOf, M as spring, Rt as springAt, Br as stableJson, et as stub, r as subtitles, ft as targetIdOf, zn as themeSchema, Vt as themeToken, Ot as timelineWords, Bn as tokenSchema, tt as uniqueId, v as useLayer, y as useT, en as usesShaders, nt as validateTarget, xt as walk, vr as zBlendMode, yr as zCaptionAnimation, br as zEasing, xr as zFitMode, Sr as zGraphicAnimation, Cr as zKeyframeProperty, wr as zMaskEasing, Tr as zShapeType, Er as zTextAnimationPreset, Dr as zTrackLayout, Or as zTrackRole, kr as zTransitionType, Ar as zVideoEffectType } from "./src-CcFjz_DV.mjs";
@@ -0,0 +1,236 @@
1
+ import { O as NodeSpec, Rn as AssetManifest, V as ResolvedState, an as PatchLog, nn as Json } from "../index-BYYpzZuS.mjs";
2
+ import { ZodObject } from "zod";
3
+ import { ReactNode } from "react";
4
+ import * as t from "@babel/types";
5
+ import { ParseResult } from "@babel/parser";
6
+ interface ParsedSource {
7
+ readonly text: string;
8
+ readonly ast: ParseResult<t.File>;
9
+ }
10
+ export declare function parseSource(text: string): ParsedSource;
11
+ type Range = readonly [start: number, end: number];
12
+ export declare function rangeOf(node: {
13
+ start?: number | null;
14
+ end?: number | null;
15
+ }): Range;
16
+ type SourceEdit = {
17
+ readonly kind: "prop";
18
+ readonly id: string;
19
+ readonly prop: string;
20
+ readonly range: Range;
21
+ readonly text: string;
22
+ } | {
23
+ readonly kind: "text";
24
+ readonly id: string;
25
+ readonly range: Range;
26
+ readonly text: string;
27
+ } | {
28
+ readonly kind: "insert";
29
+ readonly id: string;
30
+ readonly range: Range;
31
+ readonly text: string;
32
+ } | {
33
+ readonly kind: "remove";
34
+ readonly id: string;
35
+ readonly range: Range;
36
+ readonly text: "";
37
+ } | {
38
+ readonly kind: "move";
39
+ readonly id: string;
40
+ readonly range: Range;
41
+ readonly text: string;
42
+ readonly from: Range;
43
+ } | {
44
+ readonly kind: "bake";
45
+ readonly id: string;
46
+ readonly range: Range;
47
+ readonly text: string;
48
+ } | {
49
+ readonly kind: "defaults";
50
+ readonly id: string;
51
+ readonly range: Range;
52
+ readonly text: string;
53
+ };
54
+ /** Splice edits into the text, last range first, refusing overlaps. */
55
+ export declare function applyEdits(text: string, edits: readonly SourceEdit[]): string;
56
+ /** Widen an element range to swallow its own line(s): leading indentation and the trailing newline. */
57
+ export declare function lineRange(text: string, range: Range): Range;
58
+ interface PropSite {
59
+ readonly name: string;
60
+ /** The whole attribute, including the name. */
61
+ readonly range: Range;
62
+ /** The value token: the string literal, or the expression inside `{}`. Null for a bare attribute. */
63
+ readonly valueRange: Range | null;
64
+ /** The value when it is a literal (or a bare attribute, which is `true`). */
65
+ readonly literal: Json | undefined;
66
+ readonly isExpression: boolean;
67
+ /** The `schema` key this prop reads, when the expression is a plain reference to one of the file's props. */
68
+ readonly binding?: string;
69
+ }
70
+ /** The one component inside a Layer: its props are the Layer's handles, its body is opaque. */
71
+ interface InteriorSite {
72
+ readonly component: string;
73
+ readonly range: Range;
74
+ readonly openingTag: Range;
75
+ readonly props: ReadonlyMap<string, PropSite>;
76
+ readonly lockedProps: readonly string[];
77
+ readonly boundProps: Readonly<Record<string, string>>;
78
+ }
79
+ interface ElementSite {
80
+ readonly generated: false;
81
+ readonly id: string;
82
+ readonly kind: string;
83
+ readonly name: string;
84
+ readonly range: Range;
85
+ readonly openingTag: Range;
86
+ readonly closingTag: Range | null;
87
+ /** Between the opening and closing tags; null when self-closing. */
88
+ readonly childrenRange: Range | null;
89
+ readonly props: ReadonlyMap<string, PropSite>;
90
+ readonly parent: string | null;
91
+ readonly siblingIndex: number;
92
+ /** Expression props with no binding: the editor cannot write them without baking. */
93
+ readonly lockedProps: readonly string[];
94
+ /** Prop → schema key for props that reference the file's props; edits to them rewrite `defaults`. */
95
+ readonly boundProps: Readonly<Record<string, string>>;
96
+ readonly indent: string;
97
+ /** Set on a Layer whose interior is exactly one component element; its props also appear on the Layer as `interior.<name>`. */
98
+ readonly interior?: InteriorSite;
99
+ }
100
+ interface HelperCallSite {
101
+ readonly helper: string;
102
+ /** The helper's nth use in the file, in source order; matches `CollectedNode.origin.callIndex`. */
103
+ readonly callIndex: number;
104
+ readonly range: Range;
105
+ readonly parent: string | null;
106
+ readonly siblingIndex: number;
107
+ readonly indent: string;
108
+ }
109
+ interface HelperSite {
110
+ readonly name: string;
111
+ readonly range: Range;
112
+ readonly pure: boolean;
113
+ readonly hooks: readonly string[];
114
+ /** Whether its JSX names vocabulary elements: such a helper is expanded by the resolver, not mounted by React. */
115
+ readonly producesElements: boolean;
116
+ }
117
+ interface SourceIndex {
118
+ readonly text: string;
119
+ readonly ast: t.File;
120
+ readonly elements: ReadonlyMap<string, ElementSite>;
121
+ readonly calls: readonly HelperCallSite[];
122
+ readonly helpers: ReadonlyMap<string, HelperSite>;
123
+ /** The `export const defaults = {...}` object literal. */
124
+ readonly defaults: {
125
+ readonly range: Range;
126
+ readonly props: ReadonlyMap<string, PropSite>;
127
+ } | null;
128
+ readonly hasSchema: boolean;
129
+ readonly hasDefaultExport: boolean;
130
+ readonly compositionId: string | null;
131
+ /** Vocabulary elements without a literal id, for the lint. */
132
+ readonly anonymous: readonly {
133
+ readonly kind: string;
134
+ readonly range: Range;
135
+ readonly reason: string;
136
+ }[];
137
+ /** Every vocabulary element's literal `id` attribute, in source order, duplicates included. */
138
+ readonly idSites: readonly {
139
+ readonly id: string;
140
+ readonly range: Range;
141
+ }[];
142
+ /** HTML (`<div>`, `<span>`…) placed straight in a `<Track>` or `<Composition>`, where nothing draws it. */
143
+ readonly strays: readonly {
144
+ readonly name: string;
145
+ readonly range: Range;
146
+ readonly parent: string;
147
+ }[];
148
+ /** Vocabulary elements whose id is an expression (`id={id}` in a helper, `` id={`dot-${i}`} `` in a loop): the JSX that makes them, with the id's source text. */
149
+ readonly dynamic: readonly {
150
+ readonly kind: string;
151
+ readonly range: Range;
152
+ readonly idText: string;
153
+ }[];
154
+ }
155
+ /**
156
+ * Index every vocabulary JSX element with a literal id so patches can be
157
+ * written back as text edits. Elements inside helper functions are indexed
158
+ * too; whether they are literal or generated at runtime is decided by
159
+ * `collect`, which sees how often the helper is used.
160
+ */
161
+ export declare function buildSourceIndex(text: string): SourceIndex;
162
+ /** Evaluate a literal expression (numbers, strings, booleans, null, arrays and objects of literals, template strings without holes). */
163
+ export declare function literalOf(node: t.Node | null | undefined): {
164
+ ok: boolean;
165
+ value: Json | undefined;
166
+ };
167
+ export declare function indentOf(text: string, pos: number): string;
168
+ /**
169
+ * Replace the helper call that produced a generated element with the literal
170
+ * elements that call produced, so the editor can address them. Multicam cuts
171
+ * are baked by appending their generated clips after the generator.
172
+ */
173
+ export declare function bake(text: string, id: string, state: ResolvedState, index?: SourceIndex): SourceEdit[];
174
+ interface FoldResult {
175
+ readonly text: string;
176
+ readonly edits: readonly SourceEdit[];
177
+ readonly baked: readonly string[];
178
+ /** Ids whose patches could not be written (opaque interiors, missing sites). */
179
+ readonly skipped: readonly {
180
+ readonly id: string;
181
+ readonly reason: string;
182
+ }[];
183
+ }
184
+ /**
185
+ * Turn the patch log's net effect into text edits against the index.
186
+ * Targets without a literal site are reported, not folded; `foldToSource`
187
+ * bakes them first and folds again.
188
+ */
189
+ export declare function fold(log: PatchLog, index: SourceIndex, state: ResolvedState): {
190
+ edits: SourceEdit[];
191
+ needsBake: string[];
192
+ skipped: FoldResult["skipped"];
193
+ };
194
+ /** Fold with baking: generated targets are baked into literals, the file is re-indexed, and the fold is retried. */
195
+ export declare function foldToSource(text: string, log: PatchLog, state: ResolvedState, maxRounds?: number): FoldResult;
196
+ interface Rule {
197
+ readonly name: string;
198
+ check(index: SourceIndex, options: LintOptions): Diagnostic[];
199
+ }
200
+ export declare const rules: readonly Rule[];
201
+ interface Diagnostic {
202
+ readonly rule: string;
203
+ readonly severity: "error" | "warning";
204
+ readonly message: string;
205
+ readonly range: Range;
206
+ readonly id?: string;
207
+ readonly prop?: string;
208
+ }
209
+ interface LintOptions {
210
+ readonly manifest?: AssetManifest;
211
+ readonly rules?: readonly string[];
212
+ }
213
+ type LintRule = (index: SourceIndex, options: LintOptions) => Diagnostic[];
214
+ /** Static checks on a video file: the conventions that keep it editable by the UI. */
215
+ export declare function lint(text: string, options?: LintOptions): Diagnostic[];
216
+ /** What a cut file exports: the schema of its tweakable values, their defaults, and the video itself. */
217
+ interface CutModule {
218
+ schema?: ZodObject;
219
+ defaults?: Record<string, unknown>;
220
+ default: (props: Record<string, unknown>) => ReactNode;
221
+ }
222
+ /** The modules a cut file may import. `@cut/kit` is the kit's old name, still accepted from older files. */
223
+ export declare const ALLOWED_IMPORTS: Readonly<Record<string, unknown>>;
224
+ interface LoadOptions {
225
+ /** Modules the host offers beyond `ALLOWED_IMPORTS`, by import name: the libraries free code in a Layer may use. */
226
+ readonly imports?: Readonly<Record<string, unknown>>;
227
+ }
228
+ export declare function loadModule(source: string, options?: LoadOptions): CutModule;
229
+ /** JavaScript source for a JSON value, compact, double-quoted. */
230
+ export declare function printLiteral(value: Json | undefined): string;
231
+ /** One JSX attribute. Strings as `name="…"`, everything else as `name={…}`, `true` as a bare attribute. */
232
+ export declare function printProp(name: string, value: Json | undefined): string;
233
+ export declare function elementName(kind: string): string;
234
+ /** A whole element as JSX text, indented with `indent`, children on their own lines. */
235
+ export declare function printElement(spec: NodeSpec, indent?: string, step?: string): string;
236
+ export type { CutModule, Diagnostic, ElementSite, FoldResult, HelperCallSite, HelperSite, LintOptions, LintRule, LoadOptions, PropSite, Range, SourceEdit, SourceIndex };