@scaleflex/widget-tus 4.0.7 → 4.1.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 scaleflex
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 scaleflex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,29 +1,29 @@
1
- # @scaleflex/widget-tus
2
-
3
- [![Plugins][plugins-image]](#plugins)
4
- [![Website][filerobot-image]][sfx-url]
5
- [![Version][filerobot-version]][version-url]
6
- [![Scaleflex team][made-by-image]][sfx-url]
7
- [![License][license-image]][license-url]
8
- [![CodeSandbox][codeSandbox-image]][codeSandbox-url]
9
-
10
-
11
- <div align='center'>
12
- <img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
13
- </div>
14
-
15
- <!-- Variables -->
16
-
17
- [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-tus
18
- [license-url]: https://opensource.org/licenses/MIT
19
- [sfx-url]: https://www.scaleflex.com/
20
- [version-url]: https://www.npmjs.com/package/@scaleflex/widget-tus
21
- [codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
22
-
23
- [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
24
- [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
25
- [made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
26
- [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
27
- [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
28
- [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-tus?label=Version&style=for-the-badge&logo=npm
29
- [codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
1
+ # @scaleflex/widget-tus
2
+
3
+ [![Plugins][plugins-image]](#plugins)
4
+ [![Website][filerobot-image]][sfx-url]
5
+ [![Version][filerobot-version]][version-url]
6
+ [![Scaleflex team][made-by-image]][sfx-url]
7
+ [![License][license-image]][license-url]
8
+ [![CodeSandbox][codeSandbox-image]][codeSandbox-url]
9
+
10
+
11
+ <div align='center'>
12
+ <img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
13
+ </div>
14
+
15
+ <!-- Variables -->
16
+
17
+ [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-tus
18
+ [license-url]: https://opensource.org/licenses/MIT
19
+ [sfx-url]: https://www.scaleflex.com/
20
+ [version-url]: https://www.npmjs.com/package/@scaleflex/widget-tus
21
+ [codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
22
+
23
+ [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
24
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
25
+ [made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
26
+ [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
27
+ [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
28
+ [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-tus?label=Version&style=for-the-badge&logo=npm
29
+ [codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
package/lib/index.js CHANGED
@@ -49,11 +49,11 @@ import getFingerprint from './getFingerprint';
49
49
  /** @typedef {import('@scaleflex/widget-core').FilerobotFile} FilerobotFile */
50
50
  /** @typedef {import('@scaleflex/widget-core').FailedFilerobotFile<{}>} FailedFilerobotFile */
51
51
 
52
- /**
53
- * Extracted from https://github.com/tus/tus-js-client/blob/master/lib/upload.js#L13
54
- * excepted we removed 'fingerprint' key to avoid adding more dependencies
55
- *
56
- * @type {RawTusOptions}
52
+ /**
53
+ * Extracted from https://github.com/tus/tus-js-client/blob/master/lib/upload.js#L13
54
+ * excepted we removed 'fingerprint' key to avoid adding more dependencies
55
+ *
56
+ * @type {RawTusOptions}
57
57
  */
58
58
  var tusDefaultOptions = {
59
59
  endpoint: '',
@@ -76,15 +76,15 @@ var tusDefaultOptions = {
76
76
  uploadDataDuringCreation: false
77
77
  };
78
78
 
79
- /**
80
- * Tus resumable file filerobot
79
+ /**
80
+ * Tus resumable file filerobot
81
81
  */
82
82
  var Tus = /*#__PURE__*/function (_Plugin) {
83
83
  // static VERSION = packageInfo.version
84
84
 
85
- /**
86
- * @param {Filerobot} filerobot
87
- * @param {TusOptions} opts
85
+ /**
86
+ * @param {Filerobot} filerobot
87
+ * @param {TusOptions} opts
88
88
  */
89
89
  function Tus(filerobot) {
90
90
  var _this$opts$retryDelay;
@@ -263,10 +263,10 @@ var Tus = /*#__PURE__*/function (_Plugin) {
263
263
  _this.opts.jsonEndpoint = "".concat(filerobot.opts.dev ? COMPANION_URLS.DEV : companionProdUrl, "/json");
264
264
  }
265
265
 
266
- /**
267
- * Simultaneous upload limiting is shared across all uploads with this plugin.
268
- *
269
- * @type {RateLimitedQueue}
266
+ /**
267
+ * Simultaneous upload limiting is shared across all uploads with this plugin.
268
+ *
269
+ * @type {RateLimitedQueue}
270
270
  */
271
271
  _this.requests = new RateLimitedQueue(_this.opts.limit);
272
272
  _this.retryDelayIterator = (_this$opts$retryDelay = _this.opts.retryDelays) === null || _this$opts$retryDelay === void 0 ? void 0 : _this$opts$retryDelay.values();
@@ -304,11 +304,11 @@ var Tus = /*#__PURE__*/function (_Plugin) {
304
304
  this.i18n = this.translator.translate.bind(this.translator);
305
305
  }
306
306
 
307
- /**
308
- * Clean up all references for a file's upload: the tus.Upload instance,
309
- * any events related to the file, and the Companion WebSocket connection.
310
- *
311
- * @param {string} fileId
307
+ /**
308
+ * Clean up all references for a file's upload: the tus.Upload instance,
309
+ * any events related to the file, and the Companion WebSocket connection.
310
+ *
311
+ * @param {string} fileId
312
312
  */
313
313
  }, {
314
314
  key: "resetFilerobotReferences",
@@ -334,40 +334,40 @@ var Tus = /*#__PURE__*/function (_Plugin) {
334
334
  }, {
335
335
  key: "upload",
336
336
  value:
337
- /**
338
- * Create a new Tus upload.
339
- *
340
- * A lot can happen during an upload, so this is quite hard to follow!
341
- * - First, the upload is started. If the file was already paused by the time the upload starts, nothing should happen.
342
- * If the `limit` option is used, the upload must be queued onto the `this.requests` queue.
343
- * When an upload starts, we store the tus.Upload instance, and an EventTracker instance that manages the event listeners
344
- * for pausing, cancellation, removal, etc.
345
- * - While the upload is in progress, it may be paused or cancelled.
346
- * Pausing aborts the underlying tus.Upload, and removes the upload from the `this.requests` queue. All other state is
347
- * maintained.
348
- * Cancelling removes the upload from the `this.requests` queue, and completely aborts the upload-- the `tus.Upload`
349
- * instance is aborted and discarded, the EventTracker instance is destroyed (removing all listeners).
350
- * Resuming the upload uses the `this.requests` queue as well, to prevent selectively pausing and resuming uploads from
351
- * bypassing the limit.
352
- * - After completing an upload, the tus.Upload and EventTracker instances are cleaned up, and the upload is marked as done
353
- * in the `this.requests` queue.
354
- * - When an upload completed with an error, the same happens as on successful completion, but the `upload()` promise is
355
- * rejected.
356
- *
357
- * When working on this function, keep in mind:
358
- * - When an upload is completed or cancelled for any reason, the tus.Upload and EventTracker instances need to be cleaned
359
- * up using this.resetFilerobotReferences().
360
- * - When an upload is cancelled or paused, for any reason, it needs to be removed from the `this.requests` queue using
361
- * `queuedRequest.abort()`.
362
- * - When an upload is completed for any reason, including errors, it needs to be marked as such using
363
- * `queuedRequest.done()`.
364
- * - When an upload is started or resumed, it needs to go through the `this.requests` queue. The `queuedRequest` variable
365
- * must be updated so the other uses of it are valid.
366
- * - Before replacing the `queuedRequest` variable, the previous `queuedRequest` must be aborted, else it will keep taking
367
- * up a spot in the queue.
368
- *
369
- * @param {FilerobotFile} file for use with upload
370
- * @returns {Promise<void>}
337
+ /**
338
+ * Create a new Tus upload.
339
+ *
340
+ * A lot can happen during an upload, so this is quite hard to follow!
341
+ * - First, the upload is started. If the file was already paused by the time the upload starts, nothing should happen.
342
+ * If the `limit` option is used, the upload must be queued onto the `this.requests` queue.
343
+ * When an upload starts, we store the tus.Upload instance, and an EventTracker instance that manages the event listeners
344
+ * for pausing, cancellation, removal, etc.
345
+ * - While the upload is in progress, it may be paused or cancelled.
346
+ * Pausing aborts the underlying tus.Upload, and removes the upload from the `this.requests` queue. All other state is
347
+ * maintained.
348
+ * Cancelling removes the upload from the `this.requests` queue, and completely aborts the upload-- the `tus.Upload`
349
+ * instance is aborted and discarded, the EventTracker instance is destroyed (removing all listeners).
350
+ * Resuming the upload uses the `this.requests` queue as well, to prevent selectively pausing and resuming uploads from
351
+ * bypassing the limit.
352
+ * - After completing an upload, the tus.Upload and EventTracker instances are cleaned up, and the upload is marked as done
353
+ * in the `this.requests` queue.
354
+ * - When an upload completed with an error, the same happens as on successful completion, but the `upload()` promise is
355
+ * rejected.
356
+ *
357
+ * When working on this function, keep in mind:
358
+ * - When an upload is completed or cancelled for any reason, the tus.Upload and EventTracker instances need to be cleaned
359
+ * up using this.resetFilerobotReferences().
360
+ * - When an upload is cancelled or paused, for any reason, it needs to be removed from the `this.requests` queue using
361
+ * `queuedRequest.abort()`.
362
+ * - When an upload is completed for any reason, including errors, it needs to be marked as such using
363
+ * `queuedRequest.done()`.
364
+ * - When an upload is started or resumed, it needs to go through the `this.requests` queue. The `queuedRequest` variable
365
+ * must be updated so the other uses of it are valid.
366
+ * - Before replacing the `queuedRequest` variable, the previous `queuedRequest` must be aborted, else it will keep taking
367
+ * up a spot in the queue.
368
+ *
369
+ * @param {FilerobotFile} file for use with upload
370
+ * @returns {Promise<void>}
371
371
  */
372
372
  function upload(file, uploadId) {
373
373
  var _this2 = this;
@@ -613,9 +613,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
613
613
  value:
614
614
  // NOTE! Keep this duplicated code in sync with other plugins
615
615
  // TODO we should probably abstract this into a common function
616
- /**
617
- * @param {FilerobotFile} file for use with upload
618
- * @returns {Promise<void>}
616
+ /**
617
+ * @param {FilerobotFile} file for use with upload
618
+ * @returns {Promise<void>}
619
619
  */
620
620
  async function uploadRemote(file, uploadId) {
621
621
  this.resetFilerobotReferences(file.id);
@@ -646,13 +646,13 @@ var Tus = /*#__PURE__*/function (_Plugin) {
646
646
  }
647
647
  }
648
648
 
649
- /**
650
- * See the comment on the upload() method.
651
- *
652
- * Additionally, when an upload is removed, completed, or cancelled, we need to close the WebSocket connection. This is
653
- * handled by the resetFilerobotReferences() function, so the same guidelines apply as in upload().
654
- *
655
- * @param {FilerobotFile} file
649
+ /**
650
+ * See the comment on the upload() method.
651
+ *
652
+ * Additionally, when an upload is removed, completed, or cancelled, we need to close the WebSocket connection. This is
653
+ * handled by the resetFilerobotReferences() function, so the same guidelines apply as in upload().
654
+ *
655
+ * @param {FilerobotFile} file
656
656
  */
657
657
  }, {
658
658
  key: "connectToServerSocket",
@@ -787,12 +787,12 @@ var Tus = /*#__PURE__*/function (_Plugin) {
787
787
  });
788
788
  }
789
789
 
790
- /**
791
- * Store the uploadUrl on the file options, so that when Golden Retriever
792
- * restores state, we will continue uploading to the correct URL.
793
- *
794
- * @param {FilerobotFile} file
795
- * @param {string} uploadURL
790
+ /**
791
+ * Store the uploadUrl on the file options, so that when Golden Retriever
792
+ * restores state, we will continue uploading to the correct URL.
793
+ *
794
+ * @param {FilerobotFile} file
795
+ * @param {string} uploadURL
796
796
  */
797
797
  }, {
798
798
  key: "onReceiveUploadUrl",
@@ -810,9 +810,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
810
810
  }
811
811
  }
812
812
 
813
- /**
814
- * @param {string} fileId
815
- * @param {function(string): void} cb
813
+ /**
814
+ * @param {string} fileId
815
+ * @param {function(string): void} cb
816
816
  */
817
817
  }, {
818
818
  key: "onFileRemove",
@@ -822,9 +822,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
822
822
  });
823
823
  }
824
824
 
825
- /**
826
- * @param {string} fileId
827
- * @param {function(boolean): void} cb
825
+ /**
826
+ * @param {string} fileId
827
+ * @param {function(boolean): void} cb
828
828
  */
829
829
  }, {
830
830
  key: "onPause",
@@ -836,9 +836,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
836
836
  });
837
837
  }
838
838
 
839
- /**
840
- * @param {string} fileId
841
- * @param {function(): void} cb
839
+ /**
840
+ * @param {string} fileId
841
+ * @param {function(): void} cb
842
842
  */
843
843
  }, {
844
844
  key: "onRetry",
@@ -850,9 +850,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
850
850
  });
851
851
  }
852
852
 
853
- /**
854
- * @param {string} fileId
855
- * @param {function(): void} cb
853
+ /**
854
+ * @param {string} fileId
855
+ * @param {function(): void} cb
856
856
  */
857
857
  }, {
858
858
  key: "onRetryAll",
@@ -864,9 +864,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
864
864
  });
865
865
  }
866
866
 
867
- /**
868
- * @param {string} fileId
869
- * @param {function(): void} cb
867
+ /**
868
+ * @param {string} fileId
869
+ * @param {function(): void} cb
870
870
  */
871
871
  }, {
872
872
  key: "onPauseAll",
@@ -878,9 +878,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
878
878
  });
879
879
  }
880
880
 
881
- /**
882
- * @param {string} fileId
883
- * @param {function(): void} cb
881
+ /**
882
+ * @param {string} fileId
883
+ * @param {function(): void} cb
884
884
  */
885
885
  }, {
886
886
  key: "onCancelAll",
@@ -892,9 +892,9 @@ var Tus = /*#__PURE__*/function (_Plugin) {
892
892
  });
893
893
  }
894
894
 
895
- /**
896
- * @param {string} fileId
897
- * @param {function(): void} cb
895
+ /**
896
+ * @param {string} fileId
897
+ * @param {function(): void} cb
898
898
  */
899
899
  }, {
900
900
  key: "onResumeAll",
@@ -906,8 +906,8 @@ var Tus = /*#__PURE__*/function (_Plugin) {
906
906
  });
907
907
  }
908
908
 
909
- /**
910
- * @param {(FilerobotFile | FailedFilerobotFile)[]} files
909
+ /**
910
+ * @param {(FilerobotFile | FailedFilerobotFile)[]} files
911
911
  */
912
912
  }, {
913
913
  key: "uploadFiles",
@@ -939,8 +939,8 @@ var Tus = /*#__PURE__*/function (_Plugin) {
939
939
  return settle(promises);
940
940
  }
941
941
 
942
- /**
943
- * @param {string[]} fileIds
942
+ /**
943
+ * @param {string[]} fileIds
944
944
  */
945
945
  }, {
946
946
  key: "handleUpload",
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@scaleflex/widget-tus",
3
3
  "description": "Resumable uploads for Scaleflex using Tus.io",
4
- "version": "4.0.7",
4
+ "version": "4.1.0",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "types": "types/index.d.ts",
8
8
  "dependencies": {
9
- "@scaleflex/widget-companion-client": "^4.0.7",
10
- "@scaleflex/widget-utils": "^4.0.7",
9
+ "@scaleflex/widget-companion-client": "^4.1.0",
10
+ "@scaleflex/widget-utils": "^4.1.0",
11
11
  "tus-js-client": "^3.1.0"
12
12
  },
13
13
  "peerDependencies": {
@@ -21,5 +21,5 @@
21
21
  "publishConfig": {
22
22
  "access": "public"
23
23
  },
24
- "gitHead": "a940492ab76142f7041379f9a8a1d0bc8367214f"
24
+ "gitHead": "471120d67066617a0d8824eae11b07d1f2259473"
25
25
  }
package/types/index.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- import Filerobot = require("@scaleflex/widget-core");
2
- import { UploadOptions } from "tus-js-client";
3
-
4
- declare module Tus {
5
- type TusUploadOptions = Pick<
6
- UploadOptions,
7
- Exclude<
8
- keyof UploadOptions,
9
- | "fingerprint"
10
- | "metadata"
11
- | "onProgress"
12
- | "onChunkComplete"
13
- | "onSuccess"
14
- | "onError"
15
- | "uploadUrl"
16
- | "uploadSize"
17
- >
18
- >;
19
-
20
- export interface TusOptions
21
- extends Filerobot.PluginOptions,
22
- TusUploadOptions {
23
- autoRetry?: boolean;
24
- resume?: boolean;
25
- limit?: number;
26
- retryDelays?: number[];
27
- useFastRemoteRetry?: boolean;
28
- }
29
- }
30
-
31
- declare class Tus extends Filerobot.Plugin<Tus.TusOptions> {}
32
-
33
- export = Tus;
1
+ import Filerobot = require("@scaleflex/widget-core");
2
+ import { UploadOptions } from "tus-js-client";
3
+
4
+ declare module Tus {
5
+ type TusUploadOptions = Pick<
6
+ UploadOptions,
7
+ Exclude<
8
+ keyof UploadOptions,
9
+ | "fingerprint"
10
+ | "metadata"
11
+ | "onProgress"
12
+ | "onChunkComplete"
13
+ | "onSuccess"
14
+ | "onError"
15
+ | "uploadUrl"
16
+ | "uploadSize"
17
+ >
18
+ >;
19
+
20
+ export interface TusOptions
21
+ extends Filerobot.PluginOptions,
22
+ TusUploadOptions {
23
+ autoRetry?: boolean;
24
+ resume?: boolean;
25
+ limit?: number;
26
+ retryDelays?: number[];
27
+ useFastRemoteRetry?: boolean;
28
+ }
29
+ }
30
+
31
+ declare class Tus extends Filerobot.Plugin<Tus.TusOptions> {}
32
+
33
+ export = Tus;