@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bohdan Snisar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,74 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="https://raw.githubusercontent.com/prefix-tree/cutcraft/main/docs/public/logo.svg" width="64" alt="CutCraft"></p>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # @cutcraft/kit
4
+
5
+ The core of [CutCraft](https://prefix-tree.github.io/cutcraft/): the elements a video file is written in, the resolver
6
+ that turns a file into exact placements, the actions an editor runs on it, and the tools that write those edits back
7
+ into the file's text. It has no DOM and runs anywhere.
8
+
9
+ ```sh
10
+ npm install @cutcraft/kit react zod
11
+ ```
12
+
13
+ ## A file
14
+
15
+ ```tsx
16
+ import { z } from "zod";
17
+ import { Clip, Composition, Title, Track, Transition } from "@cutcraft/kit";
18
+
19
+ export const schema = z.object({ title: z.string(), accent: z.string() });
20
+ export const defaults = { title: "Why we built it", accent: "#ff5a1f" };
21
+
22
+ export default function Video({ title, accent }: z.infer<typeof schema>) {
23
+ return (
24
+ <Composition fps={30} width={1920} height={1080}>
25
+ <Track id="main">
26
+ <Clip id="c1" src="asset:interview" in="word:3" out="word:18" />
27
+ <Transition id="x1" type="crossfade" duration={0.5} />
28
+ <Clip id="c2" src="asset:city" duration={4} fit="cover" />
29
+ </Track>
30
+ <Track id="overlays">
31
+ <Title id="t1" anchor="c1" offset={1} duration={3} color={accent}>{title}</Title>
32
+ </Track>
33
+ </Composition>
34
+ );
35
+ }
36
+ ```
37
+
38
+ `in` and `out` can point into the asset manifest (`word:N`, `shot:N.end`, `silence:N`, `marker:ID`), so a cut stays on
39
+ its word when the clip moves. Each timeline element has a literal `id`. A track is a magnetic sequence unless it says
40
+ `layout="free"`. A `<Layer>` holds any React you like.
41
+
42
+ ## Using it
43
+
44
+ ```ts
45
+ import { collectModule, resolve, Executor } from "@cutcraft/kit";
46
+ import { lint, foldToSource } from "@cutcraft/kit/source";
47
+ import * as file from "./video";
48
+
49
+ const state = resolve(collectModule(file), manifest); // every element placed in time, by id
50
+ const diagnostics = lint(text, { manifest }); // problems in the file, at their line
51
+
52
+ const exec = new Executor({ tree: collectModule(file), manifest });
53
+ exec.execute({ type: "clip/trim", params: { id: "c1", edge: "out", value: 9.5 } });
54
+ exec.undo();
55
+ const { text: edited } = foldToSource(text, exec.log(), exec.state()); // the edit as a text change
56
+ ```
57
+
58
+ | | |
59
+ |---|---|
60
+ | `collectModule(mod)`, `resolve(tree, manifest, log?)` | Read a file and place everything in it: sequences, gaps, transitions, anchors, `fill` and `match` durations, transcript references and multicam cuts. Errors are typed and point at the element that caused them. A change costs about 2 µs per element, and placements that did not change keep their identity, so a UI can memoise on them. |
61
+ | `Executor` | Runs 131 editor actions (trim, split, move, ripple, keyframes, captions and more). Each one validates, applies and undoes; history groups a drag into one step. |
62
+ | `@cutcraft/kit/source` | `loadModule(source, { imports })` evaluates a file's text in the browser or in Node; the file may import `react`, `zod` and the kit, plus the modules you pass in `imports`. `buildSourceIndex` maps ids to their place in the text, `foldToSource` writes edits back as small token changes, and `lint` checks the file. |
63
+ | `interpolate`, `spring`, `random` | Pure animation helpers for free code. `useT()` and `useLayer()` give the current time once a player is mounted. |
64
+
65
+ The kit doesn't draw anything. [`@cutcraft/player`](https://www.npmjs.com/package/@cutcraft/player) plays a resolved
66
+ file in the browser, and [`cutcraft`](https://www.npmjs.com/package/cutcraft) exports it.
67
+
68
+ ## Docs
69
+
70
+ - [The file](https://prefix-tree.github.io/cutcraft/guide/the-file) and [Time by meaning](https://prefix-tree.github.io/cutcraft/guide/time)
71
+ - [Editing](https://prefix-tree.github.io/cutcraft/guide/editing)
72
+ - [Elements](https://prefix-tree.github.io/cutcraft/reference/elements/) and [actions](https://prefix-tree.github.io/cutcraft/reference/actions)
73
+
74
+ MIT licensed.