@aicut/react 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +59 -33
  2. package/package.json +35 -2
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # @aicut/react
2
2
 
3
- React 18 / 19 wrapper around **[@aicut/core](https://www.npmjs.com/package/@aicut/core)** — a canvas-rendered video editor component you can drop into any host app. Import the core stylesheet once and you're done.
3
+ > React wrapper for the **AiCut** video editor canvas timeline, custom toolbar slots, theming, i18n, drop-in `<VideoEditor>`.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@aicut/react.svg)](https://www.npmjs.com/package/@aicut/react)
6
+ [![License](https://img.shields.io/npm/l/@aicut/react.svg)](./LICENSE)
7
+ [![GitHub](https://img.shields.io/badge/repo-ziqiangai/AiCut-181717?logo=github)](https://github.com/ziqiangai/AiCut)
8
+
9
+ ![AiCut editor](https://raw.githubusercontent.com/ziqiangai/AiCut/main/docs/screenshots/editor-dark.png)
10
+
11
+ ## Install
4
12
 
5
13
  ```bash
6
14
  pnpm add @aicut/react @aicut/core
@@ -19,12 +27,14 @@ import "@aicut/core/styles.css";
19
27
 
20
28
  const project: Project = {
21
29
  version: 1,
22
- sources: [{ id: "s1", url: "/media/a.mp4", kind: "video", name: "a.mp4" }],
23
- tracks: [
24
- { id: "t1", kind: "video", clips: [
25
- { id: "c1", sourceId: "s1", in: 0, out: 5000, start: 0 },
26
- ]},
30
+ sources: [
31
+ { id: "s1", url: "/media/a.mp4", kind: "video", name: "a.mp4" },
27
32
  ],
33
+ tracks: [{
34
+ id: "t1",
35
+ kind: "video",
36
+ clips: [{ id: "c1", sourceId: "s1", in: 0, out: 5000, start: 0 }],
37
+ }],
28
38
  };
29
39
 
30
40
  export function Editor() {
@@ -44,32 +54,45 @@ export function Editor() {
44
54
  }
45
55
  ```
46
56
 
47
- The component is **uncontrolled for project state** — the editor owns the current project. To restore from JSON later, `apiRef.current?.setProject(saved)`.
57
+ The component is **uncontrolled for project state** — the editor owns the current project. To restore from JSON later:
58
+
59
+ ```ts
60
+ apiRef.current?.setProject(savedJson);
61
+ ```
48
62
 
49
63
  ## Props
50
64
 
51
- | Prop | Type | Notes |
52
- | --- | --- | --- |
53
- | `defaultProject` | `Project` | Initial project. Read once on mount. |
54
- | `theme` | `Theme` | CSS variable overrides. Reactive — mirrors to `editor.setTheme`. |
55
- | `locale` | `Partial<Locale>` | UI strings. English by default; pass `localeZh` for Chinese. Reactive. |
56
- | `toolbarLeft` | `ReactNode` | Portaled into the editor toolbar's left bookend slot. |
57
- | `toolbarRight` | `ReactNode` | Portaled into the right slot — host's Export button lives here. |
58
- | `apiRef` | `Ref<VideoEditorApi \| null>` | Imperative API handle. |
59
- | `onReady` | `(api) => void` | Fires synchronously on mount. |
60
- | `onChange` | `(project) => void` | Any model mutation. |
61
- | `onExport` | `(project) => void` | Fired by `api.requestExport()`. |
62
- | `onTimeUpdate` | `(ms) => void` | Playback tick. |
63
- | `onPlay` / `onPause` | `() => void` | |
64
- | `onSelectionChange` | `(clipId \| null) => void` | |
65
- | `onError` | `(err) => void` | |
66
- | `className` / `style` | `string` / `CSSProperties` | Forwarded to the host `<div>`. |
67
-
68
- The `apiRef` value implements **every method on `EditorApi`** — `play`, `pause`, `seek`, `split`, `trimLeft`, `trimRight`, `setProject`, `getProject`, `addSource`, `addTrack`, `removeClip`, `setSelection`, `undo`, `redo`, `setTheme`, `setLocale`, `requestExport`, etc. See [`@aicut/core`](https://www.npmjs.com/package/@aicut/core) for the full surface.
65
+ ```ts
66
+ interface VideoEditorProps {
67
+ defaultProject?: Project;
68
+
69
+ theme?: Theme; // CSS-var overrides; reactive
70
+ locale?: Partial<Locale>; // EN default; pass localeZh for ZH
71
+
72
+ toolbarLeft?: ReactNode; // host controls left bookend
73
+ toolbarRight?: ReactNode; // right bookend
74
+
75
+ apiRef?: Ref<VideoEditorApi | null>;
76
+
77
+ onReady?: (api: VideoEditorApi) => void;
78
+ onChange?: (project: Project) => void;
79
+ onExport?: (project: Project) => void; // fired by api.requestExport()
80
+ onTimeUpdate?: (ms: number) => void;
81
+ onPlay?: () => void;
82
+ onPause?: () => void;
83
+ onSelectionChange?: (clipId: string | null) => void;
84
+ onError?: (err: Error) => void;
85
+
86
+ className?: string;
87
+ style?: CSSProperties;
88
+ }
89
+ ```
90
+
91
+ The `apiRef` value exposes the full **`EditorApi`** — `play`, `pause`, `seek`, `split`, `trimLeft`, `trimRight`, `setProject`, `getProject`, `addSource`, `addTrack`, `removeClip`, `undo`, `redo`, `setTheme`, `setLocale`, `requestExport`, and more. See [@aicut/core](https://www.npmjs.com/package/@aicut/core) for the complete surface.
69
92
 
70
93
  ## Custom toolbar controls
71
94
 
72
- Drop any React node into `toolbarLeft` / `toolbarRight`. The library renders nothing into the slots and hides the separator until they're populated.
95
+ The editor's top toolbar reserves bookend slots for any React node. The library hides the visual separator until you put something in them.
73
96
 
74
97
  ```tsx
75
98
  <VideoEditor
@@ -88,7 +111,7 @@ Drop any React node into `toolbarLeft` / `toolbarRight`. The library renders not
88
111
  />
89
112
  ```
90
113
 
91
- `api.requestExport()` fires the `export` event with the current project JSON, which flows back through your `onExport` prop. From there, POST it to your own backend.
114
+ `api.requestExport()` fires the `export` event with the current project JSON, which flows back through your `onExport` prop. Your handler decides whether to POST to a backend, download locally, etc.
92
115
 
93
116
  ## Theming
94
117
 
@@ -100,7 +123,7 @@ Drop any React node into `toolbarLeft` / `toolbarRight`. The library renders not
100
123
  controlsBorder: "rgba(0, 0, 0, 0.08)",
101
124
  controlsHover: "rgba(0, 0, 0, 0.06)",
102
125
  controlsActive: "rgba(0, 0, 0, 0.08)",
103
- previewBg: "#e4e4e7", // letterbox colour around the video
126
+ previewBg: "#e4e4e7", // letterbox colour around the video
104
127
  }}
105
128
  /* … */
106
129
  />
@@ -110,18 +133,21 @@ The `theme` prop is reactive — swap it any time and the editor calls `setTheme
110
133
 
111
134
  ## i18n
112
135
 
113
- English is default. Pass the bundled `localeZh` for Chinese, or a partial object to override specific keys.
114
-
115
136
  ```tsx
116
137
  import { VideoEditor, localeZh } from "@aicut/react";
117
138
 
139
+ // Whole-locale swap
118
140
  <VideoEditor locale={localeZh} /* … */ />
141
+
142
+ // Partial override
119
143
  <VideoEditor locale={{ undo: "Annuler" }} /* … */ />
120
144
  ```
121
145
 
146
+ `locale` is reactive too — runtime swap re-titles the toolbar and re-paints canvas labels in place.
147
+
122
148
  ## Standalone `<Timeline>`
123
149
 
124
- Use the canvas timeline without the rest of the editor.
150
+ Use the canvas timeline without the rest of the editor — frame-pickers, thumbnail strips, read-only previews.
125
151
 
126
152
  ```tsx
127
153
  import { Timeline, type TimelineApi } from "@aicut/react";
@@ -138,6 +164,6 @@ import { Timeline, type TimelineApi } from "@aicut/react";
138
164
  />
139
165
  ```
140
166
 
141
- ## License
167
+ ---
142
168
 
143
- MIT
169
+ [Full docs & demo](https://github.com/ziqiangai/AiCut) · [@aicut/core](https://www.npmjs.com/package/@aicut/core) · [@aicut/vue](https://www.npmjs.com/package/@aicut/vue)
package/package.json CHANGED
@@ -1,8 +1,41 @@
1
1
  {
2
2
  "name": "@aicut/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React wrapper for the AiCut video editor — thin declarative shell over @aicut/core.",
5
5
  "license": "MIT",
6
+ "author": "ziqiang <ziqiangytu@gmail.com>",
7
+ "homepage": "https://github.com/ziqiangai/AiCut#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ziqiangai/AiCut.git",
11
+ "directory": "packages/react"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/ziqiangai/AiCut/issues"
15
+ },
16
+ "keywords": [
17
+ "video-editor",
18
+ "video-editing",
19
+ "react",
20
+ "react-component",
21
+ "timeline",
22
+ "timeline-editor",
23
+ "nle",
24
+ "video-cutter",
25
+ "video-clip",
26
+ "canvas",
27
+ "video",
28
+ "editor",
29
+ "mp4",
30
+ "component",
31
+ "capcut",
32
+ "premiere",
33
+ "final-cut",
34
+ "davinci",
35
+ "imovie",
36
+ "veed",
37
+ "filmora"
38
+ ],
6
39
  "type": "module",
7
40
  "main": "./dist/index.cjs",
8
41
  "module": "./dist/index.js",
@@ -19,7 +52,7 @@
19
52
  "README.md"
20
53
  ],
21
54
  "dependencies": {
22
- "@aicut/core": "0.1.0"
55
+ "@aicut/core": "0.1.1"
23
56
  },
24
57
  "peerDependencies": {
25
58
  "react": "^18.0.0 || ^19.0.0",