-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtypes.ts
More file actions
204 lines (175 loc) · 4.42 KB
/
Copy pathtypes.ts
File metadata and controls
204 lines (175 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
export type FFFSPath = string;
/**
* Binary file data that can be passed directly instead of a URL.
* When provided, a Blob URL is created internally so the worker
* can consume it as a regular URL.
*/
export type BinaryFileData = ArrayBuffer | Uint8Array | Blob;
/**
* ffmpeg-core loading configuration.
*/
export interface FFMessageLoadConfig {
/**
* `ffmpeg-core.js` URL.
*
* @defaultValue `https://cdn.jsdelivr.net/npm/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;
*/
coreURL?: string;
/**
* `ffmpeg-core.wasm` URL.
*
* @defaultValue `https://cdn.jsdelivr.net/npm/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.wasm`;
*/
wasmURL?: string;
/**
* `ffmpeg-core.worker.js` URL. This worker is spawned when using multithread version of ffmpeg-core.
*
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
* @defaultValue `https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
*/
workerURL?: string;
/**
* `ffmpeg-core.js` file content as binary data. When provided, takes
* precedence over `coreURL` and a Blob URL is created internally.
*/
coreData?: BinaryFileData;
/**
* `ffmpeg-core.wasm` file content as binary data. When provided, takes
* precedence over `wasmURL` and a Blob URL is created internally.
*/
wasmData?: BinaryFileData;
/**
* `ffmpeg-core.worker.js` file content as binary data. When provided,
* takes precedence over `workerURL` and a Blob URL is created internally.
*/
workerData?: BinaryFileData;
/**
* `ffmpeg.worker.js` URL. This worker is spawned when FFmpeg.load() is called, it is an essential worker and usually you don't need to update this config.
*
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
* @defaultValue `./worker.js`
*/
classWorkerURL?: string;
}
export interface FFMessageExecData {
args: string[];
timeout?: number;
}
export interface FFMessageWriteFileData {
path: FFFSPath;
data: FileData;
}
export interface FFMessageReadFileData {
path: FFFSPath;
encoding: string;
}
export interface FFMessageDeleteFileData {
path: FFFSPath;
}
export interface FFMessageRenameData {
oldPath: FFFSPath;
newPath: FFFSPath;
}
export interface FFMessageCreateDirData {
path: FFFSPath;
}
export interface FFMessageListDirData {
path: FFFSPath;
}
/**
* @remarks
* Only deletes empty directory.
*/
export interface FFMessageDeleteDirData {
path: FFFSPath;
}
export enum FFFSType {
MEMFS = "MEMFS",
NODEFS = "NODEFS",
NODERAWFS = "NODERAWFS",
IDBFS = "IDBFS",
WORKERFS = "WORKERFS",
PROXYFS = "PROXYFS",
}
export type WorkerFSFileEntry =
| File;
export interface WorkerFSBlobEntry {
name: string;
data: Blob;
}
export interface WorkerFSMountData {
blobs?: WorkerFSBlobEntry[];
files?: WorkerFSFileEntry[];
}
export type FFFSMountOptions =
| WorkerFSMountData;
export interface FFMessageMountData {
fsType: FFFSType;
options: FFFSMountOptions;
mountPoint: FFFSPath;
}
export interface FFMessageUnmountData {
mountPoint: FFFSPath;
}
export type FFMessageData =
| FFMessageLoadConfig
| FFMessageExecData
| FFMessageWriteFileData
| FFMessageReadFileData
| FFMessageDeleteFileData
| FFMessageRenameData
| FFMessageCreateDirData
| FFMessageListDirData
| FFMessageDeleteDirData
| FFMessageMountData
| FFMessageUnmountData;
export interface Message {
type: string;
data?: FFMessageData;
}
export interface FFMessage extends Message {
id: number;
}
export interface FFMessageEvent extends MessageEvent {
data: FFMessage;
}
export interface LogEvent {
type: string;
message: string;
}
export interface ProgressEvent {
progress: number;
time: number;
}
export type ExitCode = number;
export type ErrorMessage = string;
export type FileData = Uint8Array | string;
export type IsFirst = boolean;
export type OK = boolean;
export interface FSNode {
name: string;
isDir: boolean;
}
export type CallbackData =
| FileData
| ExitCode
| ErrorMessage
| LogEvent
| ProgressEvent
| IsFirst
| OK // eslint-disable-line
| Error
| FSNode[]
| undefined;
export interface Callbacks {
[id: number | string]: (data: CallbackData) => void;
}
export type LogEventCallback = (event: LogEvent) => void;
export type ProgressEventCallback = (event: ProgressEvent) => void;
export interface FFMessageEventCallback {
data: {
id: number;
type: string;
data: CallbackData;
};
}