@cut-workbench/workbench 0.2.0 → 0.3.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.
@@ -8,6 +8,12 @@ interface DropZoneProps {
8
8
  /**
9
9
  * 拖拽 / 点击导入区域。
10
10
  *
11
+ * 两条入口:
12
+ * - **拖拽**:走 react-dropzone(宿主无法介入,这是浏览器原生行为);
13
+ * - **点击**:优先走 `HostBridge.files.pickFiles` —— 宿主可能不用系统文件
14
+ * 对话框,而是从自己的素材库 / 云端 / URL 导入。宿主返回 `null`(不接管)
15
+ * 时才回退到内置 `<input type=file>`。
16
+ *
11
17
  * 注意:react-dropzone 的 accept 只做初筛,真正按 MIME + 扩展名校验在
12
18
  * core/media/file-reader,从而保证「拖入 .webm 得到明确错误」而不是被静默拒绝。
13
19
  */
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 选择素材文件:宿主优先,回退到浏览器的 `<input type=file>`。
3
+ *
4
+ * 为什么不能只用 react-dropzone 的 input:
5
+ * 素材来源不一定在本地文件系统 —— 宿主可能从自己的素材库、云端、录制器或
6
+ * URL 导入。`HostBridge.files.pickFiles` 就是给这类宿主用的口子。
7
+ *
8
+ * 三种结果必须区分清楚:
9
+ * - `File[]`:宿主或浏览器选到了文件;
10
+ * - `[]`:用户主动取消 —— **不要**再回退,否则会连弹两个选择框;
11
+ * - `null`:宿主不接管 —— 回退到内置 input。
12
+ */
13
+ import type { HostBridge } from '@cut-workbench/core';
14
+ export interface PickMediaOptions {
15
+ /** MIME 或扩展名,形如 `video/mp4`、`.srt` */
16
+ accept: string[];
17
+ multiple?: boolean;
18
+ /** 给宿主 UI 用的提示文案 */
19
+ description?: string;
20
+ }
21
+ /**
22
+ * @returns 选中的文件;用户取消时为空数组
23
+ */
24
+ export declare function pickMediaFiles(bridge: HostBridge | null | undefined, options: PickMediaOptions): Promise<File[]>;
@@ -12,10 +12,18 @@ export interface EditorActions {
12
12
  jumpToStart: () => void;
13
13
  jumpToEnd: () => void;
14
14
  }
15
- /** 统一把异常转成可见提示,禁止静默吞掉 */
15
+ /**
16
+ * 把异常转成可见提示,禁止静默吞掉。
17
+ *
18
+ * 这是**非 hook** 版本,供事件回调 / 非组件代码调用(例如 `useAvCanvas` 的
19
+ * 初始化失败)。它拿不到 React context,因此走 `notify` 注册的默认桥:
20
+ * `WorkbenchProvider` 挂载时会把 `bridge` 注册进来,宿主实现了 `notify`
21
+ * 就交给宿主,否则退回库内 toast。
22
+ */
16
23
  export declare function reportError(error: unknown, fallback?: string): void;
17
24
  export declare function useToastSafe(): {
18
25
  success: (message: string, description?: string) => void;
19
26
  error: (message: string, description?: string) => void;
20
27
  info: (message: string, description?: string) => void;
28
+ warning: (message: string, description?: string) => void;
21
29
  };