@volcengine/amk-editor 0.0.2-beta.0 → 0.0.2

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.
@@ -6,7 +6,7 @@ export interface CreateLocalUploadModalOptions {
6
6
  onConfirm: (files: File[]) => void;
7
7
  }
8
8
  export interface LocalUploadModalController {
9
- open: (files: File[]) => void;
9
+ open: (files?: File[]) => void;
10
10
  close: () => void;
11
11
  destroy: () => void;
12
12
  }
@@ -31,12 +31,23 @@ interface RefreshTosMaterialUrlsOptions {
31
31
  storage: AmkEditorStorageConfig;
32
32
  createClient?: UploadFilesToTosOptions['createClient'];
33
33
  }
34
+ /** TOS 素材的稳定标识已包含 bucket 与 object key,无需额外持久化内部字段。 */
35
+ export declare function parseTosResourceUrl(value: unknown): {
36
+ bucket: string;
37
+ key: string;
38
+ } | null;
34
39
  /** 使用宿主下发的临时 STS 将本地文件直传客户 TOS,并转换为编辑器素材。 */
35
40
  export declare function uploadFilesToTos(options: UploadFilesToTosOptions): Promise<MaterialItem[]>;
36
41
  /** 为已持久化的私有 TOS 素材重新生成播放签名,供初始化和按需刷新使用。 */
37
42
  export declare function refreshTosMaterialUrls(options: RefreshTosMaterialUrlsOptions): Promise<Array<Partial<MaterialItem> & {
38
43
  material_id: string;
39
44
  }>>;
45
+ /** 将任意任务产物中的 tos:// 地址批量签成浏览器可访问的 HTTP URL。 */
46
+ export declare function signTosResourceUrls(options: {
47
+ urls: unknown[];
48
+ storage: AmkEditorStorageConfig;
49
+ createClient?: UploadFilesToTosOptions['createClient'];
50
+ }): Promise<unknown[]>;
40
51
  /** 为资产库导入的 TOS 素材签发播放 URL;稳定身份仍保留在 source_material_id。 */
41
52
  export declare function signTosImportedMaterialUrls(options: {
42
53
  materials: MaterialItem[];
package/dist/types.d.ts CHANGED
@@ -16,14 +16,21 @@ export type SystemMaterialItem = Omit<Partial<MaterialItem>, 'source_material_id
16
16
  type: NonNullable<MaterialItem['type']>;
17
17
  name?: string;
18
18
  };
19
+ /** 可由外部工具栏复用的素材导入入口。 */
20
+ export type AmkMaterialImportType = 'local' | 'url' | 'system';
21
+ /** Optional callbacks scoped to one externally triggered material import. */
22
+ export interface AmkMaterialImportRequestOptions {
23
+ /** Called with persisted materials only for this request. */
24
+ onMaterialsImported?: (materials: MaterialItem[]) => void | Promise<void>;
25
+ }
19
26
  /**
20
- * 抽帧产物存储 key 的推荐命名,仅用于提供接入提示,不属于强制素材 Schema。
21
- * 业务可以直接使用这两个字段,也可以把 key 放进任意自定义字段或嵌套对象。
27
+ * 抽帧产物的稳定存储身份。TOS 产物会保存完整 `tos://bucket/key`,
28
+ * SDK 用它在签名 URL 过期后重新签发;非 TOS 业务仍可使用自定义字段。
22
29
  */
23
30
  export interface RecommendedExtractStorageFields {
24
- /** 推荐字段:封面图业务存储 key;业务也可以使用自定义字段。 */
31
+ /** 封面图稳定身份;内置 TOS 链路保存 `tos://bucket/key`。 */
25
32
  poster_storage_key?: string;
26
- /** 推荐字段:与 sprite.storeurls 对应的业务存储 key;也可自定义。 */
33
+ /** sprite.storeurls 等长的稳定身份数组;内置 TOS 链路保存 tos:// 地址。 */
27
34
  sprite_storage_keys?: string[];
28
35
  }
29
36
  export interface PersistExtractUrlsResult {
@@ -46,6 +53,11 @@ export interface MaterialConfig {
46
53
  * 返回 `undefined` / `null` / `[]` 视为取消或未选择,不提示失败。
47
54
  */
48
55
  onUploadFromSystem?: () => Promise<SystemMaterialItem[] | undefined | null> | SystemMaterialItem[] | undefined | null;
56
+ /**
57
+ * 素材成功入库后回调(已合并 Editing API 返回的 `material_id`)。
58
+ * 本地 / URL / 资产库三条导入链路都会走到这里;失败或用户取消不会触发。
59
+ */
60
+ onMaterialsImported?: (materials: MaterialItem[]) => void | Promise<void>;
49
61
  /**
50
62
  * 刷新播放信息。未配置时用素材库已有字段;
51
63
  * 配置后:入参为待刷新素材列表(按服务端 material_id 区分,支持批量),
@@ -58,7 +70,8 @@ export interface MaterialConfig {
58
70
  * SDK 会先用临时链上屏/落盘,再后台调用本回调换链;失败则保留临时链。
59
71
  * 未配置则只落盘临时链;若带 auth_key 且过期,SDK 会自动重抽。
60
72
  * 推荐返回 urls + materialPatch,把刷新 URL 所需的 storage key 或其他业务字段写入素材。
61
- * SDK 不限定 materialPatch 的字段名;poster_storage_key / sprite_storage_keys 仅为推荐命名。
73
+ * SDK 不限制其他 materialPatch 字段;poster_storage_key / sprite_storage_keys
74
+ * 中的 `tos://` 地址会作为后续自动重签依据。
62
75
  * 兼容只返回 string[],但该形式无法附带业务字段。
63
76
  */
64
77
  onPersistExtractUrls?: (params: {
@@ -67,10 +80,24 @@ export interface MaterialConfig {
67
80
  material: MaterialItem;
68
81
  }) => Promise<PersistExtractUrlsResult | string[]> | PersistExtractUrlsResult | string[];
69
82
  }
83
+ export interface AmkEditorHeaderTitleUpdateSuccess {
84
+ readonly projectId: string;
85
+ /** Project title persisted successfully by the Editing API. */
86
+ readonly title: string;
87
+ }
70
88
  export interface AmkEditorHeaderConfig {
71
89
  show?: boolean;
90
+ /** 是否展示导出任务列表入口,默认开启。 */
91
+ exportTaskList?: boolean;
92
+ /**
93
+ * When set, the header is rendered into this element instead of inside the
94
+ * editor root. Use this to place a full-width header above a host split layout.
95
+ */
96
+ mount?: HTMLElement;
72
97
  onBack?: () => void;
73
98
  onClose?: () => void;
99
+ /** Fired only after the project title is persisted successfully. */
100
+ onTitleUpdateSuccess?: (change: AmkEditorHeaderTitleUpdateSuccess) => void;
74
101
  }
75
102
  export interface AmkEditorExportConfig {
76
103
  /**
@@ -90,13 +117,14 @@ export interface AmkEditorUploadSTSCredentials {
90
117
  }
91
118
  /**
92
119
  * 产物 / 主动上传的存储目标。
93
- * `media_output_destination` 用于 TOS 直传的 Bucket 定位;当前不会自动写入 AMK tools 请求体。
120
+ * `media_output_destination` 用于 TOS 直传的 Bucket 定位,并默认写入会产生媒体产物的 AMK tools 请求体。
94
121
  * @see https://docs.volcengine.com/docs/6448/2386113
95
122
  */
96
123
  export interface AmkEditorStorageConfig {
97
124
  /**
98
- * 处理产物存储目标。支持 `vod://<空间名>` 或 `tos://<桶名>`。
99
- * 配置后任务结果中的 url 为对应资源地址,而不是临时下载链。
125
+ * 处理产物存储目标。支持 `vod://<空间名>` 或 `tos://<桶名>/<可选子目录>`。
126
+ * 配置后任务结果中的 url 为对应资源地址,而不是临时下载链;当返回
127
+ * `tos://bucket/key` 且同时配置 getUploadSTS 时,SDK 会自动签成 HTTP 播放地址。
100
128
  */
101
129
  media_output_destination?: string;
102
130
  /**
@@ -181,16 +209,14 @@ type AmkResourceOptionTypes = {
181
209
  };
182
210
  type AmkInheritedVeVeditorOptions = Omit<VeVeditorOptions<MaterialConfig, VeVeditorI18nOptions, AmkResourceOptionTypes>, 'initialData' | 'recording' | 'onSketchItemsChange' | 'onNodePreviewError' | 'onPreviewNodeRefresh' | 'onBeforeUndo' | 'onBeforeRedo' | 'onBeforeTimestampMount' | 'onBeforeKeyframeMount' | 'onTrackChanged' | 'onRecordingUpload' | 'decode'>;
183
211
  export type AmkEditorDecodeOptions = VeVeditorDecodeOptions;
184
- /** 客户业务代理的浏览器侧鉴权配置。SDK 不约定鉴权协议,仅透传接入方返回的请求头。 */
185
- export interface AmkEditorAuthConfig {
186
- getHeaders: () => Record<string, string> | undefined | Promise<Record<string, string> | undefined>;
187
- }
212
+ /** 每次 AMK 请求前动态获取、原样透传给 endpoint 的业务请求头。 */
213
+ export type AmkEditorGetHeaders = () => Readonly<Record<string, string>> | undefined | Promise<Readonly<Record<string, string>> | undefined>;
188
214
  export interface AmkEditorOptions extends AmkInheritedVeVeditorOptions {
189
215
  projectId: string;
190
216
  /** AMK Editing API 的业务代理地址。 */
191
217
  endpoint: string;
192
- /** 可选:返回访问客户业务代理所需的自定义请求头。 */
193
- auth?: AmkEditorAuthConfig;
218
+ /** 每次请求前调用;返回值不解析、不改写,仅透传给 endpoint。 */
219
+ getHeaders?: AmkEditorGetHeaders;
194
220
  header?: AmkEditorHeaderConfig;
195
221
  export?: AmkEditorExportConfig;
196
222
  getLicenseUrl?: string | (() => string | Promise<string>);