@vvfx/sdk 0.2.0 → 0.2.1-alpha.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/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.0
6
+ * Version: v0.2.1-alpha.0
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
@@ -59526,11 +59526,11 @@ function loadFFmpegHelper(options) {
59526
59526
  return [
59527
59527
  4,
59528
59528
  Promise.all([
59529
- Promise.resolve().then(function () { return index$1; }).catch(function(err) {
59529
+ import('@ffmpeg/ffmpeg').catch(function(err) {
59530
59530
  var message = _instanceof(err, Error) ? err.message : 'Unknown error';
59531
59531
  throw new Error("Failed to load @ffmpeg/ffmpeg: " + message);
59532
59532
  }),
59533
- Promise.resolve().then(function () { return index; }).catch(function(err) {
59533
+ import('@ffmpeg/util').catch(function(err) {
59534
59534
  var message = _instanceof(err, Error) ? err.message : 'Unknown error';
59535
59535
  throw new Error("Failed to load @ffmpeg/util: " + message);
59536
59536
  })
@@ -95852,782 +95852,5 @@ SDK.config = BaseConfig;
95852
95852
  return _instanceof(obj, CardItem);
95853
95853
  }
95854
95854
 
95855
- var FFMessageType;
95856
- (function(FFMessageType) {
95857
- FFMessageType["LOAD"] = "LOAD";
95858
- FFMessageType["EXEC"] = "EXEC";
95859
- FFMessageType["FFPROBE"] = "FFPROBE";
95860
- FFMessageType["WRITE_FILE"] = "WRITE_FILE";
95861
- FFMessageType["READ_FILE"] = "READ_FILE";
95862
- FFMessageType["DELETE_FILE"] = "DELETE_FILE";
95863
- FFMessageType["RENAME"] = "RENAME";
95864
- FFMessageType["CREATE_DIR"] = "CREATE_DIR";
95865
- FFMessageType["LIST_DIR"] = "LIST_DIR";
95866
- FFMessageType["DELETE_DIR"] = "DELETE_DIR";
95867
- FFMessageType["ERROR"] = "ERROR";
95868
- FFMessageType["DOWNLOAD"] = "DOWNLOAD";
95869
- FFMessageType["PROGRESS"] = "PROGRESS";
95870
- FFMessageType["LOG"] = "LOG";
95871
- FFMessageType["MOUNT"] = "MOUNT";
95872
- FFMessageType["UNMOUNT"] = "UNMOUNT";
95873
- })(FFMessageType || (FFMessageType = {}));
95874
-
95875
- /**
95876
- * Generate an unique message ID.
95877
- */ var getMessageID = function() {
95878
- var messageID = 0;
95879
- return function() {
95880
- return messageID++;
95881
- };
95882
- }();
95883
-
95884
- var ERROR_NOT_LOADED = new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first");
95885
- var ERROR_TERMINATED = new Error("called FFmpeg.terminate()");
95886
-
95887
- var _worker = /*#__PURE__*/ _class_private_field_loose_key("_worker"), /**
95888
- * #resolves and #rejects tracks Promise resolves and rejects to
95889
- * be called when we receive message from web worker.
95890
- */ _resolves = /*#__PURE__*/ _class_private_field_loose_key("_resolves"), _rejects = /*#__PURE__*/ _class_private_field_loose_key("_rejects"), _logEventCallbacks = /*#__PURE__*/ _class_private_field_loose_key("_logEventCallbacks"), _progressEventCallbacks = /*#__PURE__*/ _class_private_field_loose_key("_progressEventCallbacks"), /**
95891
- * register worker message event handlers.
95892
- */ _registerHandlers = /*#__PURE__*/ _class_private_field_loose_key("_registerHandlers"), /**
95893
- * Generic function to send messages to web worker.
95894
- */ _send = /*#__PURE__*/ _class_private_field_loose_key("_send");
95895
- /**
95896
- * Provides APIs to interact with ffmpeg web worker.
95897
- *
95898
- * @example
95899
- * ```ts
95900
- * const ffmpeg = new FFmpeg();
95901
- * ```
95902
- */ var FFmpeg = /*#__PURE__*/ function() {
95903
- function FFmpeg() {
95904
- var _this = this;
95905
- Object.defineProperty(this, _worker, {
95906
- writable: true,
95907
- value: void 0
95908
- });
95909
- Object.defineProperty(this, _resolves, {
95910
- writable: true,
95911
- value: void 0
95912
- });
95913
- Object.defineProperty(this, _rejects, {
95914
- writable: true,
95915
- value: void 0
95916
- });
95917
- Object.defineProperty(this, _logEventCallbacks, {
95918
- writable: true,
95919
- value: void 0
95920
- });
95921
- Object.defineProperty(this, _progressEventCallbacks, {
95922
- writable: true,
95923
- value: void 0
95924
- });
95925
- Object.defineProperty(this, _registerHandlers, {
95926
- writable: true,
95927
- value: void 0
95928
- });
95929
- Object.defineProperty(this, _send, {
95930
- writable: true,
95931
- value: void 0
95932
- });
95933
- _class_private_field_loose_base(this, _worker)[_worker] = null;
95934
- _class_private_field_loose_base(this, _resolves)[_resolves] = {};
95935
- _class_private_field_loose_base(this, _rejects)[_rejects] = {};
95936
- _class_private_field_loose_base(this, _logEventCallbacks)[_logEventCallbacks] = [];
95937
- _class_private_field_loose_base(this, _progressEventCallbacks)[_progressEventCallbacks] = [];
95938
- this.loaded = false;
95939
- _class_private_field_loose_base(this, _registerHandlers)[_registerHandlers] = function() {
95940
- if (_class_private_field_loose_base(_this, _worker)[_worker]) {
95941
- _class_private_field_loose_base(_this, _worker)[_worker].onmessage = function(param) {
95942
- var _param_data = param.data, id = _param_data.id, type = _param_data.type, data = _param_data.data;
95943
- switch(type){
95944
- case FFMessageType.LOAD:
95945
- _this.loaded = true;
95946
- _class_private_field_loose_base(_this, _resolves)[_resolves][id](data);
95947
- break;
95948
- case FFMessageType.MOUNT:
95949
- case FFMessageType.UNMOUNT:
95950
- case FFMessageType.EXEC:
95951
- case FFMessageType.FFPROBE:
95952
- case FFMessageType.WRITE_FILE:
95953
- case FFMessageType.READ_FILE:
95954
- case FFMessageType.DELETE_FILE:
95955
- case FFMessageType.RENAME:
95956
- case FFMessageType.CREATE_DIR:
95957
- case FFMessageType.LIST_DIR:
95958
- case FFMessageType.DELETE_DIR:
95959
- _class_private_field_loose_base(_this, _resolves)[_resolves][id](data);
95960
- break;
95961
- case FFMessageType.LOG:
95962
- _class_private_field_loose_base(_this, _logEventCallbacks)[_logEventCallbacks].forEach(function(f) {
95963
- return f(data);
95964
- });
95965
- break;
95966
- case FFMessageType.PROGRESS:
95967
- _class_private_field_loose_base(_this, _progressEventCallbacks)[_progressEventCallbacks].forEach(function(f) {
95968
- return f(data);
95969
- });
95970
- break;
95971
- case FFMessageType.ERROR:
95972
- _class_private_field_loose_base(_this, _rejects)[_rejects][id](data);
95973
- break;
95974
- }
95975
- delete _class_private_field_loose_base(_this, _resolves)[_resolves][id];
95976
- delete _class_private_field_loose_base(_this, _rejects)[_rejects][id];
95977
- };
95978
- }
95979
- };
95980
- _class_private_field_loose_base(this, _send)[_send] = function(param, trans, signal) {
95981
- var type = param.type, data = param.data;
95982
- if (trans === void 0) trans = [];
95983
- if (!_class_private_field_loose_base(_this, _worker)[_worker]) {
95984
- return Promise.reject(ERROR_NOT_LOADED);
95985
- }
95986
- return new Promise(function(resolve, reject) {
95987
- var id = getMessageID();
95988
- _class_private_field_loose_base(_this, _worker)[_worker] && _class_private_field_loose_base(_this, _worker)[_worker].postMessage({
95989
- id: id,
95990
- type: type,
95991
- data: data
95992
- }, trans);
95993
- _class_private_field_loose_base(_this, _resolves)[_resolves][id] = resolve;
95994
- _class_private_field_loose_base(_this, _rejects)[_rejects][id] = reject;
95995
- signal == null ? void 0 : signal.addEventListener("abort", function() {
95996
- reject(new DOMException("Message # " + id + " was aborted", "AbortError"));
95997
- }, {
95998
- once: true
95999
- });
96000
- });
96001
- };
96002
- /**
96003
- * Loads ffmpeg-core inside web worker. It is required to call this method first
96004
- * as it initializes WebAssembly and other essential variables.
96005
- *
96006
- * @category FFmpeg
96007
- * @returns `true` if ffmpeg core is loaded for the first time.
96008
- */ this.load = function(_0, _1) {
96009
- if (_0 === void 0) _0 = void 0;
96010
- if (_1 === void 0) _1 = void 0;
96011
- var _ref = [
96012
- _0,
96013
- _1
96014
- ], tmp = _ref[0], _ref1 = tmp === void 0 ? {} : tmp, _rest = _ref.slice(1), classWorkerURL = _ref1.classWorkerURL, config = _object_without_properties_loose(_ref1, [
96015
- "classWorkerURL"
96016
- ]), tmp1 = _rest[0], signal = (tmp1 === void 0 ? {} : tmp1).signal;
96017
- if (!_class_private_field_loose_base(_this, _worker)[_worker]) {
96018
- _class_private_field_loose_base(_this, _worker)[_worker] = classWorkerURL ? new Worker(new URL(classWorkerURL, import.meta.url), {
96019
- type: "module"
96020
- }) : // We need to duplicated the code here to enable webpack
96021
- // to bundle worekr.js here.
96022
- new Worker(new URL("./worker.js", import.meta.url), {
96023
- type: "module"
96024
- });
96025
- _class_private_field_loose_base(_this, _registerHandlers)[_registerHandlers]();
96026
- }
96027
- return _class_private_field_loose_base(_this, _send)[_send]({
96028
- type: FFMessageType.LOAD,
96029
- data: config
96030
- }, undefined, signal);
96031
- };
96032
- /**
96033
- * Execute ffmpeg command.
96034
- *
96035
- * @remarks
96036
- * To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
96037
- * by default.
96038
- *
96039
- * @example
96040
- * ```ts
96041
- * const ffmpeg = new FFmpeg();
96042
- * await ffmpeg.load();
96043
- * await ffmpeg.writeFile("video.avi", ...);
96044
- * // ffmpeg -i video.avi video.mp4
96045
- * await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
96046
- * const data = ffmpeg.readFile("video.mp4");
96047
- * ```
96048
- *
96049
- * @returns `0` if no error, `!= 0` if timeout (1) or error.
96050
- * @category FFmpeg
96051
- */ this.exec = function(/** ffmpeg command line args */ args, /**
96052
- * milliseconds to wait before stopping the command execution.
96053
- *
96054
- * @defaultValue -1
96055
- */ timeout, param) {
96056
- if (timeout === void 0) timeout = -1;
96057
- var signal = (param === void 0 ? {} : param).signal;
96058
- return _class_private_field_loose_base(_this, _send)[_send]({
96059
- type: FFMessageType.EXEC,
96060
- data: {
96061
- args: args,
96062
- timeout: timeout
96063
- }
96064
- }, undefined, signal);
96065
- };
96066
- /**
96067
- * Execute ffprobe command.
96068
- *
96069
- * @example
96070
- * ```ts
96071
- * const ffmpeg = new FFmpeg();
96072
- * await ffmpeg.load();
96073
- * await ffmpeg.writeFile("video.avi", ...);
96074
- * // Getting duration of a video in seconds: ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 video.avi -o output.txt
96075
- * await ffmpeg.ffprobe(["-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", "video.avi", "-o", "output.txt"]);
96076
- * const data = ffmpeg.readFile("output.txt");
96077
- * ```
96078
- *
96079
- * @returns `0` if no error, `!= 0` if timeout (1) or error.
96080
- * @category FFmpeg
96081
- */ this.ffprobe = function(/** ffprobe command line args */ args, /**
96082
- * milliseconds to wait before stopping the command execution.
96083
- *
96084
- * @defaultValue -1
96085
- */ timeout, param) {
96086
- if (timeout === void 0) timeout = -1;
96087
- var signal = (param === void 0 ? {} : param).signal;
96088
- return _class_private_field_loose_base(_this, _send)[_send]({
96089
- type: FFMessageType.FFPROBE,
96090
- data: {
96091
- args: args,
96092
- timeout: timeout
96093
- }
96094
- }, undefined, signal);
96095
- };
96096
- /**
96097
- * Terminate all ongoing API calls and terminate web worker.
96098
- * `FFmpeg.load()` must be called again before calling any other APIs.
96099
- *
96100
- * @category FFmpeg
96101
- */ this.terminate = function() {
96102
- var ids = Object.keys(_class_private_field_loose_base(_this, _rejects)[_rejects]);
96103
- // rejects all incomplete Promises.
96104
- for(var _iterator = _create_for_of_iterator_helper_loose(ids), _step; !(_step = _iterator()).done;){
96105
- var id = _step.value;
96106
- _class_private_field_loose_base(_this, _rejects)[_rejects][id](ERROR_TERMINATED);
96107
- delete _class_private_field_loose_base(_this, _rejects)[_rejects][id];
96108
- delete _class_private_field_loose_base(_this, _resolves)[_resolves][id];
96109
- }
96110
- if (_class_private_field_loose_base(_this, _worker)[_worker]) {
96111
- _class_private_field_loose_base(_this, _worker)[_worker].terminate();
96112
- _class_private_field_loose_base(_this, _worker)[_worker] = null;
96113
- _this.loaded = false;
96114
- }
96115
- };
96116
- /**
96117
- * Write data to ffmpeg.wasm.
96118
- *
96119
- * @example
96120
- * ```ts
96121
- * const ffmpeg = new FFmpeg();
96122
- * await ffmpeg.load();
96123
- * await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
96124
- * await ffmpeg.writeFile("text.txt", "hello world");
96125
- * ```
96126
- *
96127
- * @category File System
96128
- */ this.writeFile = function(path, data, param) {
96129
- var signal = (param === void 0 ? {} : param).signal;
96130
- var trans = [];
96131
- if (_instanceof(data, Uint8Array)) {
96132
- trans.push(data.buffer);
96133
- }
96134
- return _class_private_field_loose_base(_this, _send)[_send]({
96135
- type: FFMessageType.WRITE_FILE,
96136
- data: {
96137
- path: path,
96138
- data: data
96139
- }
96140
- }, trans, signal);
96141
- };
96142
- this.mount = function(fsType, options, mountPoint) {
96143
- var trans = [];
96144
- return _class_private_field_loose_base(_this, _send)[_send]({
96145
- type: FFMessageType.MOUNT,
96146
- data: {
96147
- fsType: fsType,
96148
- options: options,
96149
- mountPoint: mountPoint
96150
- }
96151
- }, trans);
96152
- };
96153
- this.unmount = function(mountPoint) {
96154
- var trans = [];
96155
- return _class_private_field_loose_base(_this, _send)[_send]({
96156
- type: FFMessageType.UNMOUNT,
96157
- data: {
96158
- mountPoint: mountPoint
96159
- }
96160
- }, trans);
96161
- };
96162
- /**
96163
- * Read data from ffmpeg.wasm.
96164
- *
96165
- * @example
96166
- * ```ts
96167
- * const ffmpeg = new FFmpeg();
96168
- * await ffmpeg.load();
96169
- * const data = await ffmpeg.readFile("video.mp4");
96170
- * ```
96171
- *
96172
- * @category File System
96173
- */ this.readFile = function(path, /**
96174
- * File content encoding, supports two encodings:
96175
- * - utf8: read file as text file, return data in string type.
96176
- * - binary: read file as binary file, return data in Uint8Array type.
96177
- *
96178
- * @defaultValue binary
96179
- */ encoding, param) {
96180
- if (encoding === void 0) encoding = "binary";
96181
- var signal = (param === void 0 ? {} : param).signal;
96182
- return _class_private_field_loose_base(_this, _send)[_send]({
96183
- type: FFMessageType.READ_FILE,
96184
- data: {
96185
- path: path,
96186
- encoding: encoding
96187
- }
96188
- }, undefined, signal);
96189
- };
96190
- /**
96191
- * Delete a file.
96192
- *
96193
- * @category File System
96194
- */ this.deleteFile = function(path, param) {
96195
- var signal = (param === void 0 ? {} : param).signal;
96196
- return _class_private_field_loose_base(_this, _send)[_send]({
96197
- type: FFMessageType.DELETE_FILE,
96198
- data: {
96199
- path: path
96200
- }
96201
- }, undefined, signal);
96202
- };
96203
- /**
96204
- * Rename a file or directory.
96205
- *
96206
- * @category File System
96207
- */ this.rename = function(oldPath, newPath, param) {
96208
- var signal = (param === void 0 ? {} : param).signal;
96209
- return _class_private_field_loose_base(_this, _send)[_send]({
96210
- type: FFMessageType.RENAME,
96211
- data: {
96212
- oldPath: oldPath,
96213
- newPath: newPath
96214
- }
96215
- }, undefined, signal);
96216
- };
96217
- /**
96218
- * Create a directory.
96219
- *
96220
- * @category File System
96221
- */ this.createDir = function(path, param) {
96222
- var signal = (param === void 0 ? {} : param).signal;
96223
- return _class_private_field_loose_base(_this, _send)[_send]({
96224
- type: FFMessageType.CREATE_DIR,
96225
- data: {
96226
- path: path
96227
- }
96228
- }, undefined, signal);
96229
- };
96230
- /**
96231
- * List directory contents.
96232
- *
96233
- * @category File System
96234
- */ this.listDir = function(path, param) {
96235
- var signal = (param === void 0 ? {} : param).signal;
96236
- return _class_private_field_loose_base(_this, _send)[_send]({
96237
- type: FFMessageType.LIST_DIR,
96238
- data: {
96239
- path: path
96240
- }
96241
- }, undefined, signal);
96242
- };
96243
- /**
96244
- * Delete an empty directory.
96245
- *
96246
- * @category File System
96247
- */ this.deleteDir = function(path, param) {
96248
- var signal = (param === void 0 ? {} : param).signal;
96249
- return _class_private_field_loose_base(_this, _send)[_send]({
96250
- type: FFMessageType.DELETE_DIR,
96251
- data: {
96252
- path: path
96253
- }
96254
- }, undefined, signal);
96255
- };
96256
- }
96257
- var _proto = FFmpeg.prototype;
96258
- _proto.on = function on(event, callback) {
96259
- if (event === "log") {
96260
- _class_private_field_loose_base(this, _logEventCallbacks)[_logEventCallbacks].push(callback);
96261
- } else if (event === "progress") {
96262
- _class_private_field_loose_base(this, _progressEventCallbacks)[_progressEventCallbacks].push(callback);
96263
- }
96264
- };
96265
- _proto.off = function off(event, callback) {
96266
- if (event === "log") {
96267
- _class_private_field_loose_base(this, _logEventCallbacks)[_logEventCallbacks] = _class_private_field_loose_base(this, _logEventCallbacks)[_logEventCallbacks].filter(function(f) {
96268
- return f !== callback;
96269
- });
96270
- } else if (event === "progress") {
96271
- _class_private_field_loose_base(this, _progressEventCallbacks)[_progressEventCallbacks] = _class_private_field_loose_base(this, _progressEventCallbacks)[_progressEventCallbacks].filter(function(f) {
96272
- return f !== callback;
96273
- });
96274
- }
96275
- };
96276
- return FFmpeg;
96277
- }();
96278
-
96279
- var FFFSType;
96280
- (function(FFFSType) {
96281
- FFFSType["MEMFS"] = "MEMFS";
96282
- FFFSType["NODEFS"] = "NODEFS";
96283
- FFFSType["NODERAWFS"] = "NODERAWFS";
96284
- FFFSType["IDBFS"] = "IDBFS";
96285
- FFFSType["WORKERFS"] = "WORKERFS";
96286
- FFFSType["PROXYFS"] = "PROXYFS";
96287
- })(FFFSType || (FFFSType = {}));
96288
-
96289
- var index$1 = /*#__PURE__*/Object.freeze({
96290
- __proto__: null,
96291
- get FFFSType () { return FFFSType; },
96292
- FFmpeg: FFmpeg
96293
- });
96294
-
96295
- var ERROR_RESPONSE_BODY_READER = new Error("failed to get response body reader");
96296
- var ERROR_INCOMPLETED_DOWNLOAD = new Error("failed to complete download");
96297
-
96298
- var HeaderContentLength = "Content-Length";
96299
-
96300
- var readFromBlobOrFile = function readFromBlobOrFile(blob) {
96301
- return new Promise(function(resolve, reject) {
96302
- var fileReader = new FileReader();
96303
- fileReader.onload = function() {
96304
- var result = fileReader.result;
96305
- if (_instanceof(result, ArrayBuffer)) {
96306
- resolve(new Uint8Array(result));
96307
- } else {
96308
- resolve(new Uint8Array());
96309
- }
96310
- };
96311
- fileReader.onerror = function(event) {
96312
- var _event_target_error, _event_target;
96313
- reject(Error("File could not be read! Code=" + ((event == null ? void 0 : (_event_target = event.target) == null ? void 0 : (_event_target_error = _event_target.error) == null ? void 0 : _event_target_error.code) || -1)));
96314
- };
96315
- fileReader.readAsArrayBuffer(blob);
96316
- });
96317
- };
96318
- /**
96319
- * An util function to fetch data from url string, base64, URL, File or Blob format.
96320
- *
96321
- * Examples:
96322
- * ```ts
96323
- * // URL
96324
- * await fetchFile("http://localhost:3000/video.mp4");
96325
- * // base64
96326
- * await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
96327
- * // URL
96328
- * await fetchFile(new URL("video.mp4", import.meta.url));
96329
- * // File
96330
- * fileInput.addEventListener('change', (e) => {
96331
- * await fetchFile(e.target.files[0]);
96332
- * });
96333
- * // Blob
96334
- * const blob = new Blob(...);
96335
- * await fetchFile(blob);
96336
- * ```
96337
- */ var fetchFile = function fetchFile(file) {
96338
- return _async_to_generator(function() {
96339
- var data;
96340
- return _ts_generator(this, function(_state) {
96341
- switch(_state.label){
96342
- case 0:
96343
- if (!(typeof file === "string")) return [
96344
- 3,
96345
- 5
96346
- ];
96347
- if (!/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) return [
96348
- 3,
96349
- 1
96350
- ];
96351
- data = atob(file.split(",")[1]).split("").map(function(c) {
96352
- return c.charCodeAt(0);
96353
- });
96354
- return [
96355
- 3,
96356
- 4
96357
- ];
96358
- case 1:
96359
- return [
96360
- 4,
96361
- fetch(file)
96362
- ];
96363
- case 2:
96364
- return [
96365
- 4,
96366
- _state.sent().arrayBuffer()
96367
- ];
96368
- case 3:
96369
- data = _state.sent();
96370
- _state.label = 4;
96371
- case 4:
96372
- return [
96373
- 3,
96374
- 11
96375
- ];
96376
- case 5:
96377
- if (!_instanceof(file, URL)) return [
96378
- 3,
96379
- 8
96380
- ];
96381
- return [
96382
- 4,
96383
- fetch(file)
96384
- ];
96385
- case 6:
96386
- return [
96387
- 4,
96388
- _state.sent().arrayBuffer()
96389
- ];
96390
- case 7:
96391
- data = _state.sent();
96392
- return [
96393
- 3,
96394
- 11
96395
- ];
96396
- case 8:
96397
- if (!(_instanceof(file, File) || _instanceof(file, Blob))) return [
96398
- 3,
96399
- 10
96400
- ];
96401
- return [
96402
- 4,
96403
- readFromBlobOrFile(file)
96404
- ];
96405
- case 9:
96406
- data = _state.sent();
96407
- return [
96408
- 3,
96409
- 11
96410
- ];
96411
- case 10:
96412
- return [
96413
- 2,
96414
- new Uint8Array()
96415
- ];
96416
- case 11:
96417
- return [
96418
- 2,
96419
- new Uint8Array(data)
96420
- ];
96421
- }
96422
- });
96423
- })();
96424
- };
96425
- /**
96426
- * importScript dynamically import a script, useful when you
96427
- * want to use different versions of ffmpeg.wasm based on environment.
96428
- *
96429
- * Example:
96430
- *
96431
- * ```ts
96432
- * await importScript("http://localhost:3000/ffmpeg.js");
96433
- * ```
96434
- */ var importScript = function importScript(url) {
96435
- return _async_to_generator(function() {
96436
- return _ts_generator(this, function(_state) {
96437
- return [
96438
- 2,
96439
- new Promise(function(resolve) {
96440
- var script = document.createElement("script");
96441
- var eventHandler = function eventHandler1() {
96442
- script.removeEventListener("load", eventHandler);
96443
- resolve();
96444
- };
96445
- script.src = url;
96446
- script.type = "text/javascript";
96447
- script.addEventListener("load", eventHandler);
96448
- document.getElementsByTagName("head")[0].appendChild(script);
96449
- })
96450
- ];
96451
- });
96452
- })();
96453
- };
96454
- /**
96455
- * Download content of a URL with progress.
96456
- *
96457
- * Progress only works when Content-Length is provided by the server.
96458
- *
96459
- */ var downloadWithProgress = function downloadWithProgress(url, cb) {
96460
- return _async_to_generator(function() {
96461
- var resp, buf, _resp_body, total, reader, chunks, received, _ref, done, value, delta, data, position, _iterator, _step, chunk, e;
96462
- return _ts_generator(this, function(_state) {
96463
- switch(_state.label){
96464
- case 0:
96465
- return [
96466
- 4,
96467
- fetch(url)
96468
- ];
96469
- case 1:
96470
- resp = _state.sent();
96471
- _state.label = 2;
96472
- case 2:
96473
- _state.trys.push([
96474
- 2,
96475
- 7,
96476
- ,
96477
- 9
96478
- ]);
96479
- // Set total to -1 to indicate that there is not Content-Type Header.
96480
- total = parseInt(resp.headers.get(HeaderContentLength) || "-1");
96481
- reader = (_resp_body = resp.body) == null ? void 0 : _resp_body.getReader();
96482
- if (!reader) throw ERROR_RESPONSE_BODY_READER;
96483
- chunks = [];
96484
- received = 0;
96485
- _state.label = 3;
96486
- case 3:
96487
- return [
96488
- 4,
96489
- reader.read()
96490
- ];
96491
- case 4:
96492
- _ref = _state.sent(), done = _ref.done, value = _ref.value;
96493
- delta = value ? value.length : 0;
96494
- if (done) {
96495
- if (total != -1 && total !== received) throw ERROR_INCOMPLETED_DOWNLOAD;
96496
- cb && cb({
96497
- url: url,
96498
- total: total,
96499
- received: received,
96500
- delta: delta,
96501
- done: done
96502
- });
96503
- return [
96504
- 3,
96505
- 6
96506
- ];
96507
- }
96508
- chunks.push(value);
96509
- received += delta;
96510
- cb && cb({
96511
- url: url,
96512
- total: total,
96513
- received: received,
96514
- delta: delta,
96515
- done: done
96516
- });
96517
- _state.label = 5;
96518
- case 5:
96519
- return [
96520
- 3,
96521
- 3
96522
- ];
96523
- case 6:
96524
- data = new Uint8Array(received);
96525
- position = 0;
96526
- for(_iterator = _create_for_of_iterator_helper_loose(chunks); !(_step = _iterator()).done;){
96527
- chunk = _step.value;
96528
- data.set(chunk, position);
96529
- position += chunk.length;
96530
- }
96531
- buf = data.buffer;
96532
- return [
96533
- 3,
96534
- 9
96535
- ];
96536
- case 7:
96537
- e = _state.sent();
96538
- console.log("failed to send download progress event: ", e);
96539
- return [
96540
- 4,
96541
- resp.arrayBuffer()
96542
- ];
96543
- case 8:
96544
- // Fetch arrayBuffer directly when it is not possible to get progress.
96545
- buf = _state.sent();
96546
- cb && cb({
96547
- url: url,
96548
- total: buf.byteLength,
96549
- received: buf.byteLength,
96550
- delta: 0,
96551
- done: true
96552
- });
96553
- return [
96554
- 3,
96555
- 9
96556
- ];
96557
- case 9:
96558
- return [
96559
- 2,
96560
- buf
96561
- ];
96562
- }
96563
- });
96564
- })();
96565
- };
96566
- /**
96567
- * toBlobURL fetches data from an URL and return a blob URL.
96568
- *
96569
- * Example:
96570
- *
96571
- * ```ts
96572
- * await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
96573
- * ```
96574
- */ var toBlobURL = function toBlobURL(url, mimeType, progress, cb) {
96575
- if (progress === void 0) progress = false;
96576
- return _async_to_generator(function() {
96577
- var buf, _tmp, blob;
96578
- return _ts_generator(this, function(_state) {
96579
- switch(_state.label){
96580
- case 0:
96581
- if (!progress) return [
96582
- 3,
96583
- 2
96584
- ];
96585
- return [
96586
- 4,
96587
- downloadWithProgress(url, cb)
96588
- ];
96589
- case 1:
96590
- _tmp = _state.sent();
96591
- return [
96592
- 3,
96593
- 5
96594
- ];
96595
- case 2:
96596
- return [
96597
- 4,
96598
- fetch(url)
96599
- ];
96600
- case 3:
96601
- return [
96602
- 4,
96603
- _state.sent().arrayBuffer()
96604
- ];
96605
- case 4:
96606
- _tmp = _state.sent();
96607
- _state.label = 5;
96608
- case 5:
96609
- buf = _tmp;
96610
- blob = new Blob([
96611
- buf
96612
- ], {
96613
- type: mimeType
96614
- });
96615
- return [
96616
- 2,
96617
- URL.createObjectURL(blob)
96618
- ];
96619
- }
96620
- });
96621
- })();
96622
- };
96623
-
96624
- var index = /*#__PURE__*/Object.freeze({
96625
- __proto__: null,
96626
- downloadWithProgress: downloadWithProgress,
96627
- fetchFile: fetchFile,
96628
- importScript: importScript,
96629
- toBlobURL: toBlobURL
96630
- });
96631
-
96632
95855
  export { BackgroundManager, BaseItem, Box2, CardItem, DefaultVFXItems, EffectsItem, FrameItem, GeneratorItem, GroupItem, InteractionUtils, ItemOrderAction, PageDataUtils, SDK, SDKItemType, SafeConstraint, SpriteItem, TextItem, VFXItemFactory, Vector2, VideoItem, addCompositionItemByComposition, addItemInfoToScene, adjustOtherElementsLayoutInfo, arrAdd, assertExist, asserts, autoLayout, calculateAutoLayoutIndicatorLine, calculateAutoLayoutPositionByMouse, calculateDisplacement, calculateInsertPositionFromLayout, calculateLayoutDisplacements, clearItemParentInfo, createCompositionItemJSON, createFrameCompositionScene, createNullItemJSON, createSpriteItemJSON, createTextItemJSON, createVideoGeneratorItemJSON, createVideoItemJSON, deepClone, deepEquals, deleteCompositionFromScene, deleteCompositionItemFromScene, deleteItemInfoFromScene, downloadBlob, extractSubCompositionToScene, fixStandardJSON, getBasicScene, getColorByNormalizeColor, getCompositionDataByRefCompositionItemId, getCompositionIdByRefCompositionItemId, getNormalizeColorByColor, getTextureUrlById, getTransformRatioByViewAndCamera, getUniqueName, globalAutoLayout, isBaseItem, isCardItem, isEffectsItem, isEqual, isFrameItem, isGeneratorItem, isGroupItem, isObj, isSpriteItem, isTextItem, isVideoItem, loadScriptAsync, logger, moveItemBetweenCompositions, removeItemInfoFromScene, resetSubCompositionItemId, setItemJSONParentId, setJSONItemName, updateItemLayoutInfo };
96633
95856
  //# sourceMappingURL=index.js.map