@cut-workbench/workbench 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 +21 -0
- package/README.md +234 -2
- package/dist/CutWorkbench.d.ts +62 -0
- package/dist/app/debug-bridge.d.ts +8 -0
- package/dist/assets/export.worker-BoHEWmFf.js +10177 -0
- package/dist/assets/export.worker-BoHEWmFf.js.map +1 -0
- package/dist/atoms-root.d.ts +46 -0
- package/dist/auto.cjs +4 -0
- package/dist/auto.d.ts +19 -0
- package/dist/auto.js +8 -0
- package/dist/components/common/ConfirmDialog.d.ts +13 -0
- package/dist/components/common/EmptyState.d.ts +13 -0
- package/dist/components/common/LoadingOverlay.d.ts +14 -0
- package/dist/components/common/Timecode.d.ts +16 -0
- package/dist/components/common/UnsupportedBrowser.d.ts +14 -0
- package/dist/components/layout/AppShell.d.ts +40 -0
- package/dist/components/layout/CapabilityBadge.d.ts +7 -0
- package/dist/components/layout/PanelResizer.d.ts +22 -0
- package/dist/components/layout/WorkbenchToolbar.d.ts +61 -0
- package/dist/components/layout/use-capability-info.d.ts +11 -0
- package/dist/components/layout/use-panel-resize.d.ts +19 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/context-menu.d.ts +25 -0
- package/dist/components/ui/dialog.d.ts +30 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/popover.d.ts +10 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/sonner.d.ts +9 -0
- package/dist/components/ui/switch.d.ts +6 -0
- package/dist/components/ui/tabs.d.ts +11 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/context.d.ts +64 -0
- package/dist/cut-workbench.css +4193 -0
- package/dist/default-bridge.d.ts +18 -0
- package/dist/features/canvas-settings/components/CanvasSettingsDialog.d.ts +16 -0
- package/dist/features/canvas-settings/index.d.ts +4 -0
- package/dist/features/export/components/ExportDialog.d.ts +6 -0
- package/dist/features/export/components/ExportProgress.d.ts +8 -0
- package/dist/features/export/components/ExportResult.d.ts +15 -0
- package/dist/features/export/export-runner.d.ts +65 -0
- package/dist/features/export/export.worker.d.ts +7 -0
- package/dist/features/export/hooks/useExportState.d.ts +39 -0
- package/dist/features/export/index.d.ts +15 -0
- package/dist/features/export/worker-factory.d.ts +24 -0
- package/dist/features/export/worker-url.d.ts +1 -0
- package/dist/features/export/worker-url.umd.d.ts +8 -0
- package/dist/features/index.d.ts +13 -0
- package/dist/features/inspector/components/AudioProps.d.ts +13 -0
- package/dist/features/inspector/components/Field.d.ts +44 -0
- package/dist/features/inspector/components/ImageProps.d.ts +16 -0
- package/dist/features/inspector/components/InspectorPanel.d.ts +6 -0
- package/dist/features/inspector/components/SubtitleProps.d.ts +14 -0
- package/dist/features/inspector/components/TextProps.d.ts +16 -0
- package/dist/features/inspector/components/VideoProps.d.ts +17 -0
- package/dist/features/inspector/hooks/useClipInspector.d.ts +18 -0
- package/dist/features/inspector/index.d.ts +17 -0
- package/dist/features/lab/components/ChromakeyLab.d.ts +1 -0
- package/dist/features/lab/components/ConcatenateLab.d.ts +7 -0
- package/dist/features/lab/components/CustomClipLab.d.ts +10 -0
- package/dist/features/lab/components/LabCard.d.ts +12 -0
- package/dist/features/lab/components/LabPage.d.ts +6 -0
- package/dist/features/lab/components/RecorderLab.d.ts +9 -0
- package/dist/features/lab/components/RemuxLab.d.ts +6 -0
- package/dist/features/lab/components/SubtitleLab.d.ts +7 -0
- package/dist/features/lab/components/ThumbnailLab.d.ts +7 -0
- package/dist/features/lab/components/TrackSplitLab.d.ts +7 -0
- package/dist/features/lab/components/shared.d.ts +33 -0
- package/dist/features/lab/hooks/use-lab-action.d.ts +7 -0
- package/dist/features/lab/index.d.ts +8 -0
- package/dist/features/media-library/components/DropZone.d.ts +15 -0
- package/dist/features/media-library/components/MediaCard.d.ts +14 -0
- package/dist/features/media-library/components/MediaGrid.d.ts +16 -0
- package/dist/features/media-library/components/MediaLibraryPanel.d.ts +10 -0
- package/dist/features/media-library/hooks/useMediaImport.d.ts +22 -0
- package/dist/features/media-library/index.d.ts +14 -0
- package/dist/features/preview/components/CaptureButton.d.ts +13 -0
- package/dist/features/preview/components/PlaybackControls.d.ts +19 -0
- package/dist/features/preview/components/PreviewPanel.d.ts +14 -0
- package/dist/features/preview/components/PreviewStage.d.ts +30 -0
- package/dist/features/preview/components/SelectionOverlay.d.ts +21 -0
- package/dist/features/preview/hooks/useAvCanvas.d.ts +48 -0
- package/dist/features/preview/hooks/useCanvasInteraction.d.ts +66 -0
- package/dist/features/preview/hooks/usePlaybackClock.d.ts +36 -0
- package/dist/features/preview/hooks/usePreviewSync.d.ts +26 -0
- package/dist/features/preview/index.d.ts +13 -0
- package/dist/features/preview/lib/download.d.ts +2 -0
- package/dist/features/timeline/components/ClipBlock.d.ts +42 -0
- package/dist/features/timeline/components/ClipContextMenu.d.ts +17 -0
- package/dist/features/timeline/components/Marquee.d.ts +9 -0
- package/dist/features/timeline/components/Playhead.d.ts +8 -0
- package/dist/features/timeline/components/Ruler.d.ts +18 -0
- package/dist/features/timeline/components/Timeline.d.ts +14 -0
- package/dist/features/timeline/components/TimelineToolbar.d.ts +20 -0
- package/dist/features/timeline/components/TrackHeader.d.ts +18 -0
- package/dist/features/timeline/constants.d.ts +11 -0
- package/dist/features/timeline/hooks/useLazyVisibility.d.ts +11 -0
- package/dist/features/timeline/hooks/useSnap.d.ts +29 -0
- package/dist/features/timeline/hooks/useTimelineDrag.d.ts +50 -0
- package/dist/features/timeline/hooks/useTimelineZoom.d.ts +20 -0
- package/dist/features/timeline/index.d.ts +20 -0
- package/dist/format--DhqHMgX.cjs +208 -0
- package/dist/format--DhqHMgX.cjs.map +1 -0
- package/dist/format-CV2aoZZC.js +109 -0
- package/dist/format-CV2aoZZC.js.map +1 -0
- package/dist/hooks/use-capability.d.ts +13 -0
- package/dist/hooks/use-editor-actions.d.ts +15 -0
- package/dist/hooks/use-event-listener.d.ts +14 -0
- package/dist/hooks/use-keyboard-shortcuts.d.ts +20 -0
- package/dist/hooks/use-toast-safe.d.ts +21 -0
- package/dist/index.cjs +7859 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +7797 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +98 -0
- package/dist/lab-disabled.cjs +6 -0
- package/dist/lab-disabled.cjs.map +1 -0
- package/dist/lab-disabled.d.ts +13 -0
- package/dist/lab-disabled.js +5 -0
- package/dist/lab-disabled.js.map +1 -0
- package/dist/lab.cjs +1178 -0
- package/dist/lab.cjs.map +1 -0
- package/dist/lab.d.ts +32 -0
- package/dist/lab.js +1177 -0
- package/dist/lab.js.map +1 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/constants.d.ts +33 -0
- package/dist/lib/format.d.ts +12 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/portal-container.d.ts +21 -0
- package/dist/provider.d.ts +46 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/ui-store.d.ts +41 -0
- package/dist/theme-tokens.d.ts +83 -0
- package/dist/theme.d.ts +24 -0
- package/dist/umd/cut-workbench.umd.js +1 -0
- package/package.json +82 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cut Workbench contributors
|
|
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,235 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cut-workbench/workbench
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
可嵌入的浏览器端剪辑台 UI:素材库、预览、时间轴、属性面板与导出对话框。
|
|
4
|
+
基于 React 19 + Tailwind CSS v4 + Radix,样式已作用域化,嵌进任何宿主都不污染。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
**只需要装这一个包**:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @cut-workbench/workbench
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`@cut-workbench/core`、`@cut-workbench/react` 以及引擎依赖
|
|
15
|
+
`@webav/av-cliper`、`@webav/av-canvas`、`@webav/av-recorder` 都是它的
|
|
16
|
+
**dependencies**,会一起装上 —— 不需要你再显式安装,也不需要知道有这些东西。
|
|
17
|
+
|
|
18
|
+
选装(按需):
|
|
19
|
+
|
|
20
|
+
| 想要什么 | 装什么 |
|
|
21
|
+
|---|---|
|
|
22
|
+
| 只取纯逻辑,不渲染 UI | `npm i @cut-workbench/core` |
|
|
23
|
+
| 只要 React hooks,自己写 UI | `npm i @cut-workbench/core @cut-workbench/react` |
|
|
24
|
+
| Electron 宿主桥(「下载」→「保存到指定路径」) | `npm i @cut-workbench/host-electron` |
|
|
25
|
+
| 需要控制 React 实例 | 宿主自己提供 `react` / `react-dom` / `zustand`(见下) |
|
|
26
|
+
|
|
27
|
+
### 关于 `react` / `react-dom` / `zustand`
|
|
28
|
+
|
|
29
|
+
这三个是 **peer 依赖**,由宿主提供,库不会替你装 —— 一旦出现两份 React,
|
|
30
|
+
宿主会碰到 `Cannot read properties of null (reading 'useContext')`。项目已有
|
|
31
|
+
React 时无需任何额外操作。
|
|
32
|
+
|
|
33
|
+
`zustand` 同理:`@cut-workbench/react` 直接 import 它,两份实例会让订阅错乱,
|
|
34
|
+
所以必须由宿主提供(React 项目通常已有)。
|
|
35
|
+
|
|
36
|
+
### 为什么 WebAV 是 dependencies 而不是 peer
|
|
37
|
+
|
|
38
|
+
`@webav/*` 是**运行时必需**的:没有 `av-cliper` / `av-canvas` 就没有预览和
|
|
39
|
+
导出,功能直接不可用。所以这个包选择把它们带上,让「装一个包就能用」成立。
|
|
40
|
+
|
|
41
|
+
`@cut-workbench/core` 则相反 —— 它的定位是「只取纯逻辑」,有人只要 timeline
|
|
42
|
+
模型和工程序列化,不该被迫装 WebAV,所以 core 那边是 `optional` peer。
|
|
43
|
+
|
|
44
|
+
> ⚠️ 0.1.0 的 WebAV 是 peer,只靠 npm 7+ 自动安装 peer 的隐式行为碰巧能跑;
|
|
45
|
+
> **pnpm / yarn 不会自动装 peer**,在它们下面构建会报
|
|
46
|
+
> `[MISSING_EXPORT] "Combinator" is not exported by "__vite-optional-peer-dep:…"`。
|
|
47
|
+
> 0.2.0 起改为 dependencies,与包管理器无关。
|
|
48
|
+
|
|
49
|
+
## React 项目
|
|
50
|
+
|
|
51
|
+
**推荐:用 `/auto` 子入口**,一行自带样式:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { createEditor } from '@cut-workbench/core/engine'
|
|
55
|
+
import { CutEditorProvider } from '@cut-workbench/react'
|
|
56
|
+
import { CutWorkbench, CutWorkbenchProvider } from '@cut-workbench/workbench/auto'
|
|
57
|
+
|
|
58
|
+
const editor = createEditor()
|
|
59
|
+
|
|
60
|
+
createRoot(el).render(
|
|
61
|
+
<CutEditorProvider editor={editor}>
|
|
62
|
+
<CutWorkbenchProvider theme="dark">
|
|
63
|
+
<CutWorkbench className="h-screen" onSaveProject={save} onOpenProject={open} />
|
|
64
|
+
</CutWorkbenchProvider>
|
|
65
|
+
</CutEditorProvider>,
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**根入口不自带样式** —— 给已经有自己的构建流程、需要控制 CSS 顺序
|
|
70
|
+
(例如要压过某条全局重置)的场景:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { CutWorkbench, CutWorkbenchProvider } from '@cut-workbench/workbench'
|
|
74
|
+
import '@cut-workbench/workbench/style.css' // ← 必须自己引,忘了就是无样式
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
两者的 API 完全一致,`/auto` 只是多了一行 `import './cut-workbench.css'`。
|
|
78
|
+
**不要同时引两个入口** —— 样式会被引入两次(作用域化之后是幂等的,但没必要)。
|
|
79
|
+
|
|
80
|
+
## 布局
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
┌───────────────────────────────────────────┐
|
|
84
|
+
│ 顶栏 │
|
|
85
|
+
├──────────┬──────────────┬─────────────────┤
|
|
86
|
+
│ 素材库 │ 预览 │ 属性 │ ← 上半区,可纵向滚动
|
|
87
|
+
├──────────┴──────────────┴─────────────────┤
|
|
88
|
+
│ 时间轴(横跨整行) │ ← 下栏
|
|
89
|
+
└───────────────────────────────────────────┘
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
时间轴**通栏占满底部一行**,不随左右面板宽度变化。左上「素材」、中「预览」、
|
|
93
|
+
右「属性」三栏可拖拽调整,面板内的内容各自滚动。
|
|
94
|
+
|
|
95
|
+
> 0.2.0 之前时间轴被塞在中间列里,左右面板一拉宽就把它挤窄,工具条按钮会
|
|
96
|
+
> 溢出到属性面板上;窄列下播放控制条的时间码也会被裁掉。现在布局与控件都有
|
|
97
|
+
> 容器级自适应(按容器宽度分档收起次要控件,而不是按视口宽度),
|
|
98
|
+
> `scripts/layout-test.mjs` 守着这两条。
|
|
99
|
+
|
|
100
|
+
## 顶栏定制
|
|
101
|
+
|
|
102
|
+
内置顶栏分三层可定制,由浅到深:
|
|
103
|
+
|
|
104
|
+
**1. 改文案** —— `labels`:
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<CutWorkbench toolbar={{ labels: { export: '导出成片', untitledProject: '新建项目' } }} />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**2. 改局部** —— `brand` / `title` / `status` / `actions`:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<CutWorkbench
|
|
114
|
+
toolbar={{
|
|
115
|
+
brand: <MyLogo />, // 默认**没有**品牌区,避免露出本库名字
|
|
116
|
+
title: null, // 不要工程名区
|
|
117
|
+
status: <AutoSaveBadge />, // 默认「空工程 · 16:9」
|
|
118
|
+
actions: <MyShareButton />, // 追加在右侧按钮组末尾
|
|
119
|
+
editableTitle: true, // 双击工程名重命名(走撤销栈)
|
|
120
|
+
showCapabilityBadge: false, // 隐藏引擎能力徽标
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**3. 整条替换** —— `slots.topBar`(优先级最高):
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<CutWorkbench slots={{ topBar: <MyHeader /> }} /> // 传 null 表示完全不要顶栏
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> `slots.topBar` 会替换**整条**顶栏,撤销/导出等内置动作一并由宿主负责;
|
|
132
|
+
> `toolbar` 只换其中一块,其余保留。可运行示例见 playground 的
|
|
133
|
+
> `/toolbar-demo.html`。
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
## 非 React 项目
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
import { initCutWorkbench } from '@cut-workbench/workbench/auto'
|
|
140
|
+
|
|
141
|
+
const wb = initCutWorkbench('#app', { theme: 'dark', namespace: 'my-project' })
|
|
142
|
+
await wb.whenReady()
|
|
143
|
+
wb.on('export:done', ({ blob, filename }) => upload(blob, filename))
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## script 标签 / 微前端
|
|
147
|
+
|
|
148
|
+
UMD 单文件已把 React、WebAV、Worker 与样式全部内联,暴露 `window.CutWorkbench`:
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<script src="https://unpkg.com/@cut-workbench/workbench/dist/umd/cut-workbench.umd.js"></script>
|
|
152
|
+
<script>
|
|
153
|
+
const wb = CutWorkbench.initCutWorkbench('#app', { theme: 'dark' })
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
> ⚠️ React 19 不再发布 UMD 产物,因此 UMD 版本内置了一份 React。有任何构建工具时
|
|
158
|
+
> 都优先选 ESM。
|
|
159
|
+
|
|
160
|
+
## 类型与依赖缺失
|
|
161
|
+
|
|
162
|
+
如果引擎依赖没解析到(例如被 npm 的 hoisting 拔掉、或在 pnpm 下版本冲突),
|
|
163
|
+
工作台不会白屏:能力探测会把「缺依赖」和「浏览器不支持」分开报告,
|
|
164
|
+
阻断页直接给出可执行的安装命令:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
缺少 @webav/av-cliper,请执行 npm i @webav/av-cliper @webav/av-canvas @webav/av-recorder
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
注意缺失依赖只在**构建期**解析 —— 装完必须重新跑一次构建,刷新浏览器没用。
|
|
171
|
+
|
|
172
|
+
## 关掉能力实验室(可选)
|
|
173
|
+
|
|
174
|
+
`config.features.lab` 是**运行时**开关,默认 `false`。lab 本体是独立子入口
|
|
175
|
+
`@cut-workbench/workbench/lab`,主包对它做动态 import —— 所以默认配置下
|
|
176
|
+
lab 的代码(含 `@webav/av-recorder`)不会加载,但打包器仍会产出一个约 33 KB 的
|
|
177
|
+
lab chunk。
|
|
178
|
+
|
|
179
|
+
要在产物里**彻底删掉**它,在宿主的构建配置里把子入口指到空实现:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
// vite.config.ts
|
|
183
|
+
export default {
|
|
184
|
+
resolve: {
|
|
185
|
+
alias: [
|
|
186
|
+
{
|
|
187
|
+
find: /^@cut-workbench\/workbench\/lab$/,
|
|
188
|
+
replacement: '@cut-workbench/workbench/lab-disabled',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
验证方式:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
grep -c "FrameCounterClip" dist/assets/*.js # 应为 0
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
> 为什么不是 `define: { __CUT_WORKBENCH_LAB__: 'false' }`:实测(Vite 8 /
|
|
202
|
+
> Rolldown)动态 import 只要出现在模块图里,chunk 就会被写进 dist,即便所在
|
|
203
|
+
> 分支已被折成死代码。只有把模块解析本身换掉才真正生效。
|
|
204
|
+
|
|
205
|
+
## 主题定制
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<CutWorkbenchProvider theme="inherit" /> // 跟随宿主 <html class="dark">
|
|
209
|
+
<CutWorkbenchProvider tokens={{ primary: '#4d6bfe', radius: '8px' }} />
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
token 通过根节点 inline style 应用,优先级高于样式表,不依赖引入顺序;变量都带
|
|
213
|
+
`--cw-` 前缀且挂在 `.cw-root` 上,不污染宿主 `:root`。
|
|
214
|
+
|
|
215
|
+
## 样式隔离
|
|
216
|
+
|
|
217
|
+
- 不引 preflight,宿主 `h1` / `button` 默认样式不变;
|
|
218
|
+
- 每条 utility 前置 `.cw-root`,宿主的 `.flex` 与工作台的互不干扰;
|
|
219
|
+
- 不使用 `@layer`,避免被宿主未分层样式压过。
|
|
220
|
+
|
|
221
|
+
## 导出与 Worker
|
|
222
|
+
|
|
223
|
+
导出默认在 Web Worker 中执行,产物里的 `assets/export.worker-*.js` 由
|
|
224
|
+
`@cut-workbench/workbench` 自身携带。若宿主有严格 CSP,可用
|
|
225
|
+
`HostBridge.createExportWorker` 完全接管 Worker 的创建。
|
|
226
|
+
|
|
227
|
+
含文字片段的工程会自动回退主线程渲染(文字依赖 DOM)。
|
|
228
|
+
|
|
229
|
+
## 浏览器要求
|
|
230
|
+
|
|
231
|
+
仅支持 Chromium 内核(Chrome / Edge):WebAV 依赖 WebCodecs 与 OPFS。
|
|
232
|
+
|
|
233
|
+
## License
|
|
234
|
+
|
|
235
|
+
MIT
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工作台容器:把「三栏骨架 + 顶栏 + 弹窗」组装成一个可配置组件。
|
|
3
|
+
*
|
|
4
|
+
* 与旧 `App` 的区别:
|
|
5
|
+
* - 不自己创建编辑器(由外层 Provider 注入),因此支持多实例;
|
|
6
|
+
* - 顶栏的保存/打开走调用方传入的回调,不写死 IndexedDB;
|
|
7
|
+
* - 每个面板都可以被 `slots` 替换,宿主想换掉哪块就换哪块;
|
|
8
|
+
* - 不强制能力阻断页(宿主可自行决定)。
|
|
9
|
+
*/
|
|
10
|
+
import { type ReactNode } from 'react';
|
|
11
|
+
import { type WorkbenchToolbarLabels } from './components/layout/WorkbenchToolbar';
|
|
12
|
+
export interface CutWorkbenchSlots {
|
|
13
|
+
/** 替换内置顶栏;传 `null` 表示不要顶栏 */
|
|
14
|
+
topBar?: ReactNode | null;
|
|
15
|
+
mediaLibrary?: ReactNode;
|
|
16
|
+
preview?: ReactNode;
|
|
17
|
+
inspector?: ReactNode;
|
|
18
|
+
timeline?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 顶栏的局部自定义。
|
|
22
|
+
*
|
|
23
|
+
* 与 `slots.topBar` 的区别:`slots.topBar` 会替换**整条**顶栏(撤销、导出等
|
|
24
|
+
* 内置动作一并消失,宿主自己负责);`toolbar` 只替换其中某一块,其余保留。
|
|
25
|
+
*/
|
|
26
|
+
export interface CutWorkbenchToolbarOptions {
|
|
27
|
+
/** 左侧品牌区;传 `null` 表示不要(默认就没有,避免在宿主产品里露出本库品牌) */
|
|
28
|
+
brand?: ReactNode | null;
|
|
29
|
+
/** 工程名区;传 `null` 表示不要 */
|
|
30
|
+
title?: ReactNode | null;
|
|
31
|
+
/** 工程名右侧状态(默认「空工程 · 16:9」);传 `null` 表示不要 */
|
|
32
|
+
status?: ReactNode | null;
|
|
33
|
+
/** 在右侧按钮组末尾追加宿主动作 */
|
|
34
|
+
actions?: ReactNode;
|
|
35
|
+
/** 是否显示引擎能力徽标,默认 true */
|
|
36
|
+
showCapabilityBadge?: boolean;
|
|
37
|
+
/** 是否允许双击工程名重命名,默认 false */
|
|
38
|
+
editableTitle?: boolean;
|
|
39
|
+
/** 覆盖内置文案 */
|
|
40
|
+
labels?: WorkbenchToolbarLabels;
|
|
41
|
+
}
|
|
42
|
+
export interface CutWorkbenchProps {
|
|
43
|
+
slots?: CutWorkbenchSlots;
|
|
44
|
+
/** 顶栏的局部自定义(`slots.topBar` 优先级更高) */
|
|
45
|
+
toolbar?: CutWorkbenchToolbarOptions;
|
|
46
|
+
className?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 工程持久化回调。
|
|
49
|
+
*
|
|
50
|
+
* 不传则顶栏的「保存 / 打开」按钮隐藏 —— 库不假设宿主用 IndexedDB、文件还是云端。
|
|
51
|
+
*/
|
|
52
|
+
onSaveProject?: () => Promise<void> | void;
|
|
53
|
+
onOpenProject?: () => Promise<void> | void;
|
|
54
|
+
/** 是否在能力不足时显示阻断页(宿主自己负责环境校验时可关闭) */
|
|
55
|
+
enforceCapability?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 工作台主体。
|
|
59
|
+
*
|
|
60
|
+
* 必须在 `<WorkbenchProvider>` + `<CutEditorProvider>` 之内使用。
|
|
61
|
+
*/
|
|
62
|
+
export declare function CutWorkbench({ slots, toolbar: toolbarOptions, className, onSaveProject, onOpenProject, enforceCapability, }: CutWorkbenchProps): import("react").JSX.Element;
|