@volcengine/amk-editor 0.0.1 → 0.0.2-beta.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/README.md +20 -1
- package/dist/amk-editor.d.ts +83 -11
- package/dist/api/client.d.ts +14 -0
- package/dist/assets/import-menu-chevron-down.svg +3 -0
- package/dist/assets/import-menu-local.svg +3 -0
- package/dist/assets/import-menu-system-arrow.svg +3 -0
- package/dist/assets/import-menu-system-cloud.svg +3 -0
- package/dist/assets/import-menu-url.svg +3 -0
- package/dist/export-modal.d.ts +13 -0
- package/dist/i18n/keys.d.ts +2 -0
- package/dist/import-actions-dropdown-view.d.ts +15 -0
- package/dist/import-actions.d.ts +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +96445 -76252
- package/dist/public-types.d.ts +5 -0
- package/dist/tos-upload.d.ts +46 -0
- package/dist/types.d.ts +67 -3
- package/dist/utils/material-extract.d.ts +9 -6
- package/dist/veveditor.css +188 -2
- package/package.json +8 -3
- package/third_party_notice.txt +25 -0
package/dist/public-types.d.ts
CHANGED
|
@@ -65,6 +65,10 @@ export interface VeVeditorMaterialOptions<TMaterialItem = VeVeditorMaterialItem>
|
|
|
65
65
|
}
|
|
66
66
|
export interface VeVeditorOptions<TMaterialOptions = VeVeditorMaterialOptions, TI18nOptions = VeVeditorI18nOptions, TResourceOptions extends VeVeditorResourceOptionTypes = VeVeditorResourceOptionTypes> {
|
|
67
67
|
container: HTMLElement;
|
|
68
|
+
/** 埋点来源标识,用于区分业务接入方。 */
|
|
69
|
+
source?: string;
|
|
70
|
+
/** 埋点账号 ID;上报时写入事件 params.AccountID(对齐 master)。 */
|
|
71
|
+
accountId?: string;
|
|
68
72
|
theme?: VeVeditorTheme;
|
|
69
73
|
material?: TMaterialOptions;
|
|
70
74
|
i18n?: TI18nOptions;
|
|
@@ -101,6 +105,7 @@ export interface VeVeditorOptions<TMaterialOptions = VeVeditorMaterialOptions, T
|
|
|
101
105
|
item?: unknown;
|
|
102
106
|
}) => void;
|
|
103
107
|
onNodePreviewError?: (type: 'video' | 'audio', node: unknown) => void;
|
|
108
|
+
onPreviewNodeRefresh?: (type: 'video' | 'audio', node: unknown) => void | Promise<void>;
|
|
104
109
|
onBeforeUndo?: (payload: unknown) => boolean | void;
|
|
105
110
|
onBeforeRedo?: (payload: unknown) => boolean | void;
|
|
106
111
|
onBeforeTimestampMount?: (params: Record<string, unknown>) => boolean | Promise<boolean>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AmkEditorStorageConfig, AmkEditorUploadSTSCredentials, MaterialItem } from './types';
|
|
2
|
+
export declare const DEFAULT_TOS_REGION = "cn-beijing";
|
|
3
|
+
export declare const DEFAULT_SIGNED_URL_EXPIRES_SECONDS: number;
|
|
4
|
+
export declare const TOS_SIGNED_URL_REFRESH_AHEAD_MS: number;
|
|
5
|
+
/** 签名最长 24 小时,但不能超过本次 STS 凭证的剩余有效期。 */
|
|
6
|
+
export declare function resolveSignedUrlExpiresSeconds(credentials: AmkEditorUploadSTSCredentials, now?: number): number;
|
|
7
|
+
/** 解析 TOS V4 签名 URL 的绝对过期时间;非 TOS 签名链返回 null。 */
|
|
8
|
+
export declare function resolveTosSignedUrlExpiresAt(urlValue: unknown): number | null;
|
|
9
|
+
interface TosClientLike {
|
|
10
|
+
putObject(input: {
|
|
11
|
+
bucket: string;
|
|
12
|
+
key: string;
|
|
13
|
+
body: File;
|
|
14
|
+
contentType?: string;
|
|
15
|
+
}): Promise<unknown>;
|
|
16
|
+
getPreSignedUrl(input: {
|
|
17
|
+
bucket: string;
|
|
18
|
+
key: string;
|
|
19
|
+
method?: 'GET' | 'PUT';
|
|
20
|
+
expires?: number;
|
|
21
|
+
}): string;
|
|
22
|
+
}
|
|
23
|
+
interface UploadFilesToTosOptions {
|
|
24
|
+
files: File[];
|
|
25
|
+
projectId: string;
|
|
26
|
+
storage: AmkEditorStorageConfig;
|
|
27
|
+
createClient?: (credentials: AmkEditorUploadSTSCredentials, region: string) => TosClientLike;
|
|
28
|
+
}
|
|
29
|
+
interface RefreshTosMaterialUrlsOptions {
|
|
30
|
+
materials: MaterialItem[];
|
|
31
|
+
storage: AmkEditorStorageConfig;
|
|
32
|
+
createClient?: UploadFilesToTosOptions['createClient'];
|
|
33
|
+
}
|
|
34
|
+
/** 使用宿主下发的临时 STS 将本地文件直传客户 TOS,并转换为编辑器素材。 */
|
|
35
|
+
export declare function uploadFilesToTos(options: UploadFilesToTosOptions): Promise<MaterialItem[]>;
|
|
36
|
+
/** 为已持久化的私有 TOS 素材重新生成播放签名,供初始化和按需刷新使用。 */
|
|
37
|
+
export declare function refreshTosMaterialUrls(options: RefreshTosMaterialUrlsOptions): Promise<Array<Partial<MaterialItem> & {
|
|
38
|
+
material_id: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/** 为资产库导入的 TOS 素材签发播放 URL;稳定身份仍保留在 source_material_id。 */
|
|
41
|
+
export declare function signTosImportedMaterialUrls(options: {
|
|
42
|
+
materials: MaterialItem[];
|
|
43
|
+
storage: AmkEditorStorageConfig;
|
|
44
|
+
createClient?: UploadFilesToTosOptions['createClient'];
|
|
45
|
+
}): Promise<MaterialItem[]>;
|
|
46
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,17 @@ export interface MaterialItem extends VeVeditorMaterialItem {
|
|
|
5
5
|
source_material_id: string;
|
|
6
6
|
/** Editing API 生成的服务端 id;业务方不必传,传了也不会入库。 */
|
|
7
7
|
material_id?: string;
|
|
8
|
+
/** poster 抽帧任务 ID;任务完成或不再使用时显式写回 null。 */
|
|
9
|
+
poster_task_id?: string | null;
|
|
10
|
+
/** sprite 抽帧任务 ID;任务完成或不再使用时显式写回 null。 */
|
|
11
|
+
sprite_task_id?: string | null;
|
|
8
12
|
}
|
|
13
|
+
export type SystemMaterialItem = Omit<Partial<MaterialItem>, 'source_material_id' | 'source'> & {
|
|
14
|
+
source_material_id: string;
|
|
15
|
+
source?: string;
|
|
16
|
+
type: NonNullable<MaterialItem['type']>;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
9
19
|
/**
|
|
10
20
|
* 抽帧产物存储 key 的推荐命名,仅用于提供接入提示,不属于强制素材 Schema。
|
|
11
21
|
* 业务可以直接使用这两个字段,也可以把 key 放进任意自定义字段或嵌套对象。
|
|
@@ -30,7 +40,12 @@ export interface MaterialConfig {
|
|
|
30
40
|
uploadAccept?: string;
|
|
31
41
|
onUploadMaterial?: (files: File[]) => Promise<MaterialItem[]> | MaterialItem[];
|
|
32
42
|
onUploadUrlMaterial?: (urls: string[]) => Promise<MaterialItem[]> | MaterialItem[];
|
|
33
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 从业务资产库选择素材。业务方自行实现弹窗、列表查询与勾选,只返回选中数组。
|
|
45
|
+
* `tos://bucket/key` 条目会由 SDK 用 storage.getUploadSTS 自动签名和补齐元信息。
|
|
46
|
+
* 返回 `undefined` / `null` / `[]` 视为取消或未选择,不提示失败。
|
|
47
|
+
*/
|
|
48
|
+
onUploadFromSystem?: () => Promise<SystemMaterialItem[] | undefined | null> | SystemMaterialItem[] | undefined | null;
|
|
34
49
|
/**
|
|
35
50
|
* 刷新播放信息。未配置时用素材库已有字段;
|
|
36
51
|
* 配置后:入参为待刷新素材列表(按服务端 material_id 区分,支持批量),
|
|
@@ -64,6 +79,34 @@ export interface AmkEditorExportConfig {
|
|
|
64
79
|
*/
|
|
65
80
|
qualityEnhancement?: boolean;
|
|
66
81
|
}
|
|
82
|
+
/** 浏览器直传 TOS 使用的临时凭证;字段可直接用于初始化 TOS Browser SDK。 */
|
|
83
|
+
export interface AmkEditorUploadSTSCredentials {
|
|
84
|
+
accessKeyId: string;
|
|
85
|
+
accessKeySecret: string;
|
|
86
|
+
/** 临时凭证必填;使用长期 AK/SK 做本地联调时可省略。 */
|
|
87
|
+
stsToken?: string;
|
|
88
|
+
/** 凭证过期时间,支持 ISO 8601、秒时间戳或毫秒时间戳;用于限制签名 URL 有效期。 */
|
|
89
|
+
expiration?: string | number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 产物 / 主动上传的存储目标。
|
|
93
|
+
* `media_output_destination` 用于 TOS 直传的 Bucket 定位;当前不会自动写入 AMK tools 请求体。
|
|
94
|
+
* @see https://docs.volcengine.com/docs/6448/2386113
|
|
95
|
+
*/
|
|
96
|
+
export interface AmkEditorStorageConfig {
|
|
97
|
+
/**
|
|
98
|
+
* 处理产物存储目标。支持 `vod://<空间名>` 或 `tos://<桶名>`。
|
|
99
|
+
* 配置后任务结果中的 url 为对应资源地址,而不是临时下载链。
|
|
100
|
+
*/
|
|
101
|
+
media_output_destination?: string;
|
|
102
|
+
/**
|
|
103
|
+
* 配置后,本地上传会优先使用 TOS Browser SDK 直传
|
|
104
|
+
* `media_output_destination` 指定的 TOS Bucket;未配置时沿用
|
|
105
|
+
* `material.onUploadMaterial`。业务服务端应返回最小权限、短有效期凭证,
|
|
106
|
+
* 浏览器端不得保存客户长期 AK/SK。
|
|
107
|
+
*/
|
|
108
|
+
getUploadSTS?: () => AmkEditorUploadSTSCredentials | Promise<AmkEditorUploadSTSCredentials>;
|
|
109
|
+
}
|
|
67
110
|
export interface ExportVideoParams {
|
|
68
111
|
videoName: string;
|
|
69
112
|
qualityEnhancement: boolean;
|
|
@@ -73,12 +116,24 @@ export interface ExportVideoParams {
|
|
|
73
116
|
format: 'mp4' | 'mp3';
|
|
74
117
|
codec: 'h264' | 'h265' | 'vp9' | 'mp3';
|
|
75
118
|
}
|
|
119
|
+
/** Result of {@link AmkEditor.requestExport} for Agent/frontend-tool callers. */
|
|
120
|
+
export type AmkExportRequestResult = {
|
|
121
|
+
status: 'success';
|
|
122
|
+
taskId: string;
|
|
123
|
+
} | {
|
|
124
|
+
status: 'cancel';
|
|
125
|
+
} | {
|
|
126
|
+
status: 'failed';
|
|
127
|
+
error: string;
|
|
128
|
+
};
|
|
76
129
|
export interface VeVeditorInstance {
|
|
77
130
|
destroy: () => void;
|
|
78
131
|
on?: (eventName: string, handler: (...args: any[]) => void) => void;
|
|
79
132
|
off?: (eventName: string, handler: (...args: any[]) => void) => void;
|
|
80
133
|
getTrack?: () => any[];
|
|
81
|
-
setTrack?: (track: any[]
|
|
134
|
+
setTrack?: (track: any[], options?: {
|
|
135
|
+
recordHistory?: boolean;
|
|
136
|
+
}) => Promise<void>;
|
|
82
137
|
setTrackElementMarker?: (elementId: string, marker: {
|
|
83
138
|
key?: string;
|
|
84
139
|
content: string;
|
|
@@ -124,15 +179,24 @@ type AmkResourceOptionTypes = {
|
|
|
124
179
|
filter: boolean;
|
|
125
180
|
effect: boolean;
|
|
126
181
|
};
|
|
127
|
-
type AmkInheritedVeVeditorOptions = Omit<VeVeditorOptions<MaterialConfig, VeVeditorI18nOptions, AmkResourceOptionTypes>, 'initialData' | 'recording' | 'onSketchItemsChange' | 'onNodePreviewError' | 'onBeforeUndo' | 'onBeforeRedo' | 'onBeforeTimestampMount' | 'onBeforeKeyframeMount' | 'onTrackChanged' | 'onRecordingUpload' | 'decode'>;
|
|
182
|
+
type AmkInheritedVeVeditorOptions = Omit<VeVeditorOptions<MaterialConfig, VeVeditorI18nOptions, AmkResourceOptionTypes>, 'initialData' | 'recording' | 'onSketchItemsChange' | 'onNodePreviewError' | 'onPreviewNodeRefresh' | 'onBeforeUndo' | 'onBeforeRedo' | 'onBeforeTimestampMount' | 'onBeforeKeyframeMount' | 'onTrackChanged' | 'onRecordingUpload' | 'decode'>;
|
|
128
183
|
export type AmkEditorDecodeOptions = VeVeditorDecodeOptions;
|
|
184
|
+
/** 客户业务代理的浏览器侧鉴权配置。SDK 不约定鉴权协议,仅透传接入方返回的请求头。 */
|
|
185
|
+
export interface AmkEditorAuthConfig {
|
|
186
|
+
getHeaders: () => Record<string, string> | undefined | Promise<Record<string, string> | undefined>;
|
|
187
|
+
}
|
|
129
188
|
export interface AmkEditorOptions extends AmkInheritedVeVeditorOptions {
|
|
130
189
|
projectId: string;
|
|
190
|
+
/** AMK Editing API 的业务代理地址。 */
|
|
131
191
|
endpoint: string;
|
|
192
|
+
/** 可选:返回访问客户业务代理所需的自定义请求头。 */
|
|
193
|
+
auth?: AmkEditorAuthConfig;
|
|
132
194
|
header?: AmkEditorHeaderConfig;
|
|
133
195
|
export?: AmkEditorExportConfig;
|
|
134
196
|
getLicenseUrl?: string | (() => string | Promise<string>);
|
|
135
197
|
decode?: AmkEditorDecodeOptions;
|
|
198
|
+
/** 产物 / 主动上传的存储目标,包括 TOS / VOD。 */
|
|
199
|
+
storage?: AmkEditorStorageConfig;
|
|
136
200
|
}
|
|
137
201
|
export interface AmkEditorInternalConfig {
|
|
138
202
|
projectId: string;
|
|
@@ -6,7 +6,7 @@ export type SpriteState = {
|
|
|
6
6
|
/**
|
|
7
7
|
* 素材 `sprite`:
|
|
8
8
|
* - object `{ storeurls, capturenum }`:已完成;链接是否失效由实际网络请求判断
|
|
9
|
-
* -
|
|
9
|
+
* - 进行中任务放在 `sprite_task_id`;旧 `sprite` 字符串仅用于一次性迁移
|
|
10
10
|
* - 缺省:需要新建任务
|
|
11
11
|
*/
|
|
12
12
|
export declare function resolveSpriteState(material: MaterialItem): SpriteState;
|
|
@@ -16,18 +16,21 @@ export declare function isPersistablePosterUrl(value: unknown): boolean;
|
|
|
16
16
|
export declare function isRuntimeOnlyPosterUrl(value: unknown): boolean;
|
|
17
17
|
/** http poster;有效性由实际网络请求判断 */
|
|
18
18
|
export declare function isPosterAssetReady(material: MaterialItem): boolean;
|
|
19
|
+
/** poster 任务只能存在独立字段;旧 poster 非 http/dataURL 字符串仅用于一次性迁移。 */
|
|
20
|
+
export declare function resolvePosterTaskId(material: MaterialItem): string | undefined;
|
|
19
21
|
export declare function isExtractableVideoMaterial(material: MaterialItem): boolean;
|
|
20
22
|
export declare function resolveMaterialMediaUrl(material: MaterialItem): string;
|
|
21
23
|
export type MaterialExtractActions = {
|
|
22
24
|
url: string;
|
|
23
|
-
/** 需要新建 sprite
|
|
25
|
+
/** 需要新建 sprite 抽帧任务,任务 ID 写入 sprite_task_id */
|
|
24
26
|
createSpriteTask: boolean;
|
|
25
|
-
/** 已有 taskId
|
|
27
|
+
/** 已有 taskId,从 sprite_task_id 继续轮询 */
|
|
26
28
|
resumeSpriteTaskId?: string;
|
|
29
|
+
/** 已有 poster 任务,从 poster_task_id 继续轮询。 */
|
|
30
|
+
resumePosterTaskId?: string;
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - 前端解码模式:无运行时缓存时也可抓取(dataURL 不落盘)
|
|
32
|
+
* 需要抓封面:缺有效 http poster,或需恢复进行中的 poster_task_id。
|
|
33
|
+
* 前端 DataURL 仅作会话预览,不单独驱动 capturePoster。
|
|
31
34
|
*/
|
|
32
35
|
capturePoster: boolean;
|
|
33
36
|
};
|