@bytescale/sdk 3.0.0-alpha.12 → 3.0.0-alpha.14

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.
@@ -1,25 +1,3 @@
1
- // ----------------------------------------
2
- // POLYFILL GUIDE:
3
- // ----------------------------------------
4
- //
5
- // "buffer" & "stream" are not required for browser environments.
6
- //
7
- // They are only used when the code detects it's running in Node.js (at runtime).
8
- //
9
- // You may polyfill them with empty objects (for browser environments):
10
- //
11
- // ----------------------------------------
12
- // Webpack:
13
- // {
14
- // resolve: {
15
- // fallback: {
16
- // buffer: false,
17
- // stream: false
18
- // }
19
- // }
20
- // }
21
- // ----------------------------------------
22
- //
23
1
  import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
24
2
  import * as __WEBPACK_EXTERNAL_MODULE_buffer__ from "buffer";
25
3
  /******/ // The require scope
@@ -2053,10 +2031,13 @@ var UploadManagerBase = /*#__PURE__*/function () {
2053
2031
  _this2.assertNotCancelled(request);
2054
2032
  var source = _this2.processUploadSource(request.data);
2055
2033
  var preUploadInfo = _this2.getPreUploadInfo(request, source);
2056
- var onProgress = _this2.makeProgressCallback(request, preUploadInfo.size);
2034
+ var bytesTotal = preUploadInfo.size;
2035
+ var makeOnProgressForPart = _this2.makeOnProgressForPartFactory(request, bytesTotal);
2057
2036
  var init = _this2.preUpload(source);
2058
2037
  // Raise initial progress event SYNCHRONOUSLY.
2059
- onProgress(0);
2038
+ if (request.onProgress !== undefined) {
2039
+ request.onProgress(_this2.makeProgressEvent(0, bytesTotal));
2040
+ }
2060
2041
  return UploadManagerBase_await(_this2.beginUpload(request, preUploadInfo), function (uploadInfo) {
2061
2042
  var partCount = uploadInfo.uploadParts.count;
2062
2043
  var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
@@ -2066,7 +2047,7 @@ var UploadManagerBase = /*#__PURE__*/function () {
2066
2047
  var intervalHandle = setInterval(_this2.onIntervalTick(request, cancel), _this2.intervalMs);
2067
2048
  return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2068
2049
  return UploadManagerBase_await(_this2.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2069
- return _this2.uploadPart(request, source, part, uploadInfo, onProgress, addCancellationHandler);
2050
+ return _this2.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler);
2070
2051
  })), function () {
2071
2052
  return UploadManagerBase_awaitIgnored(_this2.postUpload(init));
2072
2053
  });
@@ -2122,21 +2103,37 @@ var UploadManagerBase = /*#__PURE__*/function () {
2122
2103
  addCancellationHandler: addCancellationHandler
2123
2104
  };
2124
2105
  }
2106
+ /**
2107
+ * Returns a callback, which when called, returns a callback that can be used by ONE specific part to report its progress.
2108
+ */
2125
2109
  }, {
2126
- key: "makeProgressCallback",
2127
- value: function makeProgressCallback(request, bytesTotal) {
2110
+ key: "makeOnProgressForPartFactory",
2111
+ value: function makeOnProgressForPartFactory(request, bytesTotal) {
2112
+ var _this4 = this;
2128
2113
  var onProgress = request.onProgress;
2129
2114
  if (onProgress === undefined) {
2130
- return function () {};
2115
+ return function () {
2116
+ return function () {};
2117
+ };
2131
2118
  }
2132
2119
  var bytesSent = 0;
2133
- return function (bytesSentDelta) {
2134
- bytesSent += bytesSentDelta;
2135
- onProgress({
2136
- bytesTotal: bytesTotal,
2137
- bytesSent: bytesSent,
2138
- progress: Math.round(bytesSent / bytesTotal * 100)
2139
- });
2120
+ return function () {
2121
+ var bytesSentForPart = 0;
2122
+ return function (bytesSentTotalForPart) {
2123
+ var delta = bytesSentTotalForPart - bytesSentForPart;
2124
+ bytesSentForPart += delta;
2125
+ bytesSent += delta;
2126
+ onProgress(_this4.makeProgressEvent(bytesSent, bytesTotal));
2127
+ };
2128
+ };
2129
+ }
2130
+ }, {
2131
+ key: "makeProgressEvent",
2132
+ value: function makeProgressEvent(bytesSent, bytesTotal) {
2133
+ return {
2134
+ bytesTotal: bytesTotal,
2135
+ bytesSent: bytesSent,
2136
+ progress: Math.round(bytesSent / bytesTotal * 100)
2140
2137
  };
2141
2138
  }
2142
2139
  }, {
@@ -2159,9 +2156,9 @@ var UploadManagerBase = /*#__PURE__*/function () {
2159
2156
  mime = _ref2.mime,
2160
2157
  originalFileName = _ref2.originalFileName;
2161
2158
  try {
2162
- var _this5 = this;
2163
- return UploadManagerBase_await(_this5.uploadApi.beginMultipartUpload({
2164
- accountId: _this5.accountId,
2159
+ var _this6 = this;
2160
+ return UploadManagerBase_await(_this6.uploadApi.beginMultipartUpload({
2161
+ accountId: _this6.accountId,
2165
2162
  beginMultipartUploadRequest: {
2166
2163
  metadata: request.metadata,
2167
2164
  mime: mime,
@@ -2180,14 +2177,14 @@ var UploadManagerBase = /*#__PURE__*/function () {
2180
2177
  key: "uploadPart",
2181
2178
  value: function uploadPart(request, source, partIndex, uploadInfo, onProgress, addCancellationHandler) {
2182
2179
  try {
2183
- var _this7 = this;
2184
- _this7.assertNotCancelled(request);
2185
- return UploadManagerBase_await(_this7.getUploadPart(partIndex, uploadInfo), function (part) {
2186
- _this7.assertNotCancelled(request);
2187
- return UploadManagerBase_await(_this7.putUploadPart(part, source, onProgress, addCancellationHandler), function (etag) {
2188
- _this7.assertNotCancelled(request);
2189
- return UploadManagerBase_awaitIgnored(_this7.uploadApi.completeUploadPart({
2190
- accountId: _this7.accountId,
2180
+ var _this8 = this;
2181
+ _this8.assertNotCancelled(request);
2182
+ return UploadManagerBase_await(_this8.getUploadPart(partIndex, uploadInfo), function (part) {
2183
+ _this8.assertNotCancelled(request);
2184
+ return UploadManagerBase_await(_this8.putUploadPart(part, source, onProgress, addCancellationHandler), function (etag) {
2185
+ _this8.assertNotCancelled(request);
2186
+ return UploadManagerBase_awaitIgnored(_this8.uploadApi.completeUploadPart({
2187
+ accountId: _this8.accountId,
2191
2188
  uploadId: uploadInfo.uploadId,
2192
2189
  uploadPartIndex: partIndex,
2193
2190
  completeUploadPartRequest: {
@@ -2207,9 +2204,9 @@ var UploadManagerBase = /*#__PURE__*/function () {
2207
2204
  key: "putUploadPart",
2208
2205
  value: function putUploadPart(part, source, onProgress, addCancellationHandler) {
2209
2206
  try {
2210
- var _this9 = this;
2207
+ var _this10 = this;
2211
2208
  var contentLength = part.range.inclusiveEnd + 1 - part.range.inclusiveStart;
2212
- return UploadManagerBase_await(_this9.doPutUploadPart(part, contentLength, source, onProgress, addCancellationHandler), function (_ref3) {
2209
+ return UploadManagerBase_await(_this10.doPutUploadPart(part, contentLength, source, onProgress, addCancellationHandler), function (_ref3) {
2213
2210
  var status = _ref3.status,
2214
2211
  etag = _ref3.etag;
2215
2212
  if (Math.floor(status / 100) !== 2) {
@@ -2218,6 +2215,8 @@ var UploadManagerBase = /*#__PURE__*/function () {
2218
2215
  if (etag === undefined) {
2219
2216
  throw new Error("No 'etag' response header found in upload part response.");
2220
2217
  }
2218
+ // Always send 100% for part, as some UploadManager implementations either don't report progress, or may not report the last chunk uploaded.
2219
+ onProgress(contentLength);
2221
2220
  return etag;
2222
2221
  });
2223
2222
  } catch (e) {
@@ -2228,13 +2227,13 @@ var UploadManagerBase = /*#__PURE__*/function () {
2228
2227
  key: "getUploadPart",
2229
2228
  value: function getUploadPart(partIndex, uploadInfo) {
2230
2229
  try {
2231
- var _this11 = this;
2230
+ var _this12 = this;
2232
2231
  if (partIndex === 0) {
2233
2232
  return uploadInfo.uploadParts.first;
2234
2233
  }
2235
- return UploadManagerBase_await(_this11.uploadApi.getUploadPart({
2234
+ return UploadManagerBase_await(_this12.uploadApi.getUploadPart({
2236
2235
  uploadId: uploadInfo.uploadId,
2237
- accountId: _this11.accountId,
2236
+ accountId: _this12.accountId,
2238
2237
  uploadPartIndex: partIndex
2239
2238
  }));
2240
2239
  } catch (e) {
@@ -2307,6 +2306,11 @@ var StreamUtils = /*#__PURE__*/function () {
2307
2306
  StreamUtils.endStream(readable);
2308
2307
  return readable;
2309
2308
  }
2309
+ }, {
2310
+ key: "fromArrayBuffer",
2311
+ value: function fromArrayBuffer(buffer) {
2312
+ return StreamUtils.fromBuffer(Buffer.from(buffer));
2313
+ }
2310
2314
  }, {
2311
2315
  key: "fromBuffer",
2312
2316
  value: function fromBuffer(buffer) {
@@ -2517,6 +2521,61 @@ var NodeChunkedStream = /*#__PURE__*/function () {
2517
2521
  var external_buffer_x = y => { var x = {}; __lib_require__.d(x, y); return x; }
2518
2522
  var external_buffer_y = x => () => x
2519
2523
  var external_buffer_namespaceObject = external_buffer_x({ ["Blob"]: () => __WEBPACK_EXTERNAL_MODULE_buffer__.Blob });
2524
+ ;// CONCATENATED MODULE: ./src/private/UploadManagerFetchUtils.ts
2525
+ function UploadManagerFetchUtils_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerFetchUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, UploadManagerFetchUtils_typeof(obj); }
2526
+ function UploadManagerFetchUtils_await(value, then, direct) {
2527
+ if (direct) {
2528
+ return then ? then(value) : value;
2529
+ }
2530
+ if (!value || !value.then) {
2531
+ value = Promise.resolve(value);
2532
+ }
2533
+ return then ? value.then(then) : value;
2534
+ }
2535
+ function UploadManagerFetchUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2536
+ function UploadManagerFetchUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, UploadManagerFetchUtils_toPropertyKey(descriptor.key), descriptor); } }
2537
+ function UploadManagerFetchUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadManagerFetchUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadManagerFetchUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2538
+ function UploadManagerFetchUtils_toPropertyKey(arg) { var key = UploadManagerFetchUtils_toPrimitive(arg, "string"); return UploadManagerFetchUtils_typeof(key) === "symbol" ? key : String(key); }
2539
+ function UploadManagerFetchUtils_toPrimitive(input, hint) { if (UploadManagerFetchUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadManagerFetchUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2540
+
2541
+ var UploadManagerFetchUtils = /*#__PURE__*/function () {
2542
+ function UploadManagerFetchUtils() {
2543
+ UploadManagerFetchUtils_classCallCheck(this, UploadManagerFetchUtils);
2544
+ }
2545
+ UploadManagerFetchUtils_createClass(UploadManagerFetchUtils, null, [{
2546
+ key: "doPutUploadPart",
2547
+ value: function doPutUploadPart(config, part, content, contentLength, addCancellationHandler) {
2548
+ try {
2549
+ var _a;
2550
+ var fetchApi = BytescaleApiClientConfigUtils.getFetchApi(config);
2551
+ // Configure cancellation:
2552
+ var controller = new AbortController();
2553
+ var signal = controller.signal;
2554
+ addCancellationHandler(function () {
2555
+ return controller.abort();
2556
+ });
2557
+ var headers = {
2558
+ // Required to prevent fetch using "Transfer-Encoding: Chunked" when body is a stream.
2559
+ "content-length": contentLength.toString()
2560
+ };
2561
+ return UploadManagerFetchUtils_await(fetchApi(part.uploadUrl, {
2562
+ method: "PUT",
2563
+ headers: headers,
2564
+ body: content,
2565
+ signal: signal
2566
+ }), function (response) {
2567
+ return {
2568
+ etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
2569
+ status: response.status
2570
+ };
2571
+ });
2572
+ } catch (e) {
2573
+ return Promise.reject(e);
2574
+ }
2575
+ }
2576
+ }]);
2577
+ return UploadManagerFetchUtils;
2578
+ }();
2520
2579
  ;// CONCATENATED MODULE: ./src/public/node/UploadManagerNode.ts
2521
2580
  function UploadManagerNode_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerNode_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, UploadManagerNode_typeof(obj); }
2522
2581
  function UploadManagerNode_empty() {}
@@ -2716,6 +2775,7 @@ function UploadManagerNode_getPrototypeOf(o) { UploadManagerNode_getPrototypeOf
2716
2775
 
2717
2776
 
2718
2777
 
2778
+
2719
2779
  var UploadManager = /*#__PURE__*/function (_UploadManagerBase) {
2720
2780
  UploadManagerNode_inherits(UploadManager, _UploadManagerBase);
2721
2781
  var _super = UploadManagerNode_createSuper(UploadManager);
@@ -2747,13 +2807,19 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBase) {
2747
2807
  value: data
2748
2808
  };
2749
2809
  }
2810
+ if (data.byteLength !== undefined) {
2811
+ return {
2812
+ type: "ArrayBuffer",
2813
+ value: data
2814
+ };
2815
+ }
2750
2816
  if (data.size !== undefined) {
2751
2817
  return {
2752
2818
  type: "Blob",
2753
2819
  value: data
2754
2820
  };
2755
2821
  }
2756
- throw new Error("Unsupported type for 'data' parameter. Please provide a String, Blob, or Readable (Node.js).");
2822
+ throw new Error("Unsupported type for 'data' parameter. Please provide a String, Blob, Buffer, ArrayBuffer, or ReadableStream (Node.js).");
2757
2823
  }
2758
2824
  }, {
2759
2825
  key: "getPreUploadInfoPartial",
@@ -2762,9 +2828,10 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBase) {
2762
2828
  case "Blob":
2763
2829
  return this.getBlobInfo(data);
2764
2830
  case "Buffer":
2831
+ case "ArrayBuffer":
2765
2832
  return {
2766
2833
  mime: undefined,
2767
- size: data.value.length,
2834
+ size: data.value.byteLength,
2768
2835
  originalFileName: undefined,
2769
2836
  maxConcurrentUploadParts: undefined
2770
2837
  };
@@ -2815,40 +2882,20 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBase) {
2815
2882
  value: function doPutUploadPart(part, contentLength, source, onProgress, addCancellationHandler) {
2816
2883
  try {
2817
2884
  var _this2 = this;
2818
- var _a, _b;
2819
- var fetchApi = (_a = _this2.config.fetchApi) !== null && _a !== void 0 ? _a : fetch;
2820
- var headers = {
2821
- // Required to prevent fetch using "Transfer-Encoding: Chunked" when body is a stream.
2822
- "content-length": contentLength.toString()
2823
- };
2824
- // Configure cancellation:
2825
- var controller = new AbortController();
2826
- var signal = controller.signal;
2827
- addCancellationHandler(function () {
2828
- return controller.abort();
2829
- });
2830
2885
  // Report progress:
2831
2886
  var hasWarned = false;
2887
+ var bytesSent = 0;
2832
2888
  return UploadManagerNode_await(_this2.sliceDataForRequest(source, part), function (stream) {
2833
2889
  var streamWithProgress = stream.on("data", function (data) {
2834
- if (data.length !== undefined) {
2835
- onProgress(data.length);
2890
+ if (data.byteLength !== undefined) {
2891
+ bytesSent += data.byteLength;
2892
+ onProgress(bytesSent);
2836
2893
  } else if (!hasWarned) {
2837
2894
  hasWarned = true;
2838
2895
  console.warn("Expected stream to contain buffers, but it did not, so upload progress won't be reported.");
2839
2896
  }
2840
2897
  });
2841
- return UploadManagerNode_await(fetchApi(part.uploadUrl, {
2842
- method: "PUT",
2843
- headers: headers,
2844
- body: _this2.coerceRequestBody(streamWithProgress),
2845
- signal: signal
2846
- }), function (response) {
2847
- return {
2848
- etag: (_b = response.headers.get("etag")) !== null && _b !== void 0 ? _b : undefined,
2849
- status: response.status
2850
- };
2851
- });
2898
+ return UploadManagerNode_await(UploadManagerFetchUtils.doPutUploadPart(_this2.config, part, _this2.coerceRequestBody(streamWithProgress), contentLength, addCancellationHandler));
2852
2899
  });
2853
2900
  } catch (e) {
2854
2901
  return Promise.reject(e);
@@ -2872,12 +2919,14 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBase) {
2872
2919
  return _switch(data.type, [[function () {
2873
2920
  return "Blob";
2874
2921
  }, function () {
2875
- var _fromBuffer = StreamUtils.fromBuffer,
2876
- _Buffer = Buffer,
2877
- _from = _Buffer.from;
2922
+ var _fromArrayBuffer = StreamUtils.fromArrayBuffer;
2878
2923
  return UploadManagerNode_await(data.value.slice(start, endExclusive).arrayBuffer(), function (_data$value$slice$arr) {
2879
- return _fromBuffer.call(StreamUtils, _from.call(_Buffer, _data$value$slice$arr));
2924
+ return _fromArrayBuffer.call(StreamUtils, _data$value$slice$arr);
2880
2925
  });
2926
+ }], [function () {
2927
+ return "ArrayBuffer";
2928
+ }, function () {
2929
+ return StreamUtils.fromArrayBuffer(data.value.slice(start, endExclusive));
2881
2930
  }], [function () {
2882
2931
  return "Buffer";
2883
2932
  }, function () {
@@ -2908,17 +2957,17 @@ var EnvChecker = /*#__PURE__*/function () {
2908
2957
  EnvChecker_classCallCheck(this, EnvChecker);
2909
2958
  }
2910
2959
  EnvChecker_createClass(EnvChecker, null, [{
2911
- key: "isNodeJs",
2912
- value: function isNodeJs() {
2913
- return typeof process !== "undefined" && process.versions !== undefined && process.versions.node !== undefined;
2960
+ key: "isBrowser",
2961
+ value: function isBrowser() {
2962
+ return typeof window !== "undefined";
2914
2963
  }
2915
2964
  }, {
2916
2965
  key: "methodRequiresBrowser",
2917
2966
  value: function methodRequiresBrowser(methodName) {
2918
- if (EnvChecker.isNodeJs()) {
2919
- return new Error("You must call '".concat(methodName, "' in the browser. (You are currently in Node.js.)"));
2967
+ if (!EnvChecker.isBrowser()) {
2968
+ return new Error("You must call '".concat(methodName, "' in your client-side code. (You have called it in your server-side code.)"));
2920
2969
  }
2921
- return new Error("The '".concat(methodName, "' method cannot be called because you have bundled the Node.js implementation of the Bytescale JavaScript SDK into your client-side code. Please ensure your bundling tool (Webpack, Rollup, etc.) is honouring the \"browser\" field of the \"package.json\" file for this package, as this will allow the browser implementation of the Bytescale JavaScript SDK to be included in your client-side code."));
2970
+ return new Error("The '".concat(methodName, "' method cannot be called because you have bundled a non-browser implementation of the Bytescale JavaScript SDK into your client-side code. Please ensure your bundling tool (Webpack, Rollup, etc.) is honouring the \"browser\" field of the \"package.json\" file for this package, as this will allow the browser implementation of the Bytescale JavaScript SDK to be included in your client-side code."));
2922
2971
  }
2923
2972
  }]);
2924
2973
  return EnvChecker;
@@ -0,0 +1,2 @@
1
+ export * from "./public/shared";
2
+ export * from "./public/worker";
@@ -1,4 +1,4 @@
1
1
  export declare class EnvChecker {
2
- static isNodeJs(): boolean;
2
+ static isBrowser(): boolean;
3
3
  static methodRequiresBrowser(methodName: string): Error;
4
4
  }
@@ -3,6 +3,7 @@ import type * as stream from "stream";
3
3
  export declare class StreamUtils {
4
4
  static create(): stream.Readable;
5
5
  static empty(): NodeJS.ReadableStream;
6
+ static fromArrayBuffer(buffer: ArrayBuffer): NodeJS.ReadableStream;
6
7
  static fromBuffer(buffer: Buffer): NodeJS.ReadableStream;
7
8
  static endStream(readable: stream.Readable): void;
8
9
  }
@@ -29,7 +29,11 @@ export declare abstract class UploadManagerBase<TSource, TInit> implements Uploa
29
29
  protected abstract doPutUploadPart(part: UploadPart, contentLength: number, source: TSource, onProgress: (bytesSentDelta: number) => void, addCancellationHandler: AddCancellationHandler): Promise<PutUploadPartResult>;
30
30
  private onIntervalTick;
31
31
  private makeCancellationMethods;
32
- private makeProgressCallback;
32
+ /**
33
+ * Returns a callback, which when called, returns a callback that can be used by ONE specific part to report its progress.
34
+ */
35
+ private makeOnProgressForPartFactory;
36
+ private makeProgressEvent;
33
37
  private assertNotCancelled;
34
38
  private isCancelled;
35
39
  private beginUpload;
@@ -0,0 +1,19 @@
1
+ import { UploadManagerBase } from "./UploadManagerBase";
2
+ import { UploadSourceProcessedBrowser, UploadSourceProcessedWorker } from "./model/UploadSourceProcessed";
3
+ import { PreUploadInfo } from "./model/PreUploadInfo";
4
+ import { UploadPart } from "../public/shared/generated";
5
+ import { UploadManagerParams, UploadSource } from "../public/shared/CommonTypes";
6
+ declare type BrowserOrWorkerUploadSource = UploadSourceProcessedBrowser | UploadSourceProcessedWorker;
7
+ /**
8
+ * The "browser" and "worker" runtimes support the same input types, but the former uses XHR and the latter uses Fetch.
9
+ */
10
+ export declare abstract class UploadManagerBrowserWorkerBase extends UploadManagerBase<BrowserOrWorkerUploadSource, undefined> {
11
+ protected processUploadSource(data: UploadSource): BrowserOrWorkerUploadSource;
12
+ protected getPreUploadInfoPartial(_request: UploadManagerParams, data: BrowserOrWorkerUploadSource): Partial<PreUploadInfo> & {
13
+ size: number;
14
+ };
15
+ protected preUpload(_source: BrowserOrWorkerUploadSource): undefined;
16
+ protected postUpload(_init: undefined): Promise<void>;
17
+ protected getRequestBody(part: UploadPart, blob: BrowserOrWorkerUploadSource): Blob | ArrayBuffer;
18
+ }
19
+ export {};
@@ -0,0 +1,8 @@
1
+ import { BytescaleApiClientConfig, UploadPart } from "../public/shared";
2
+ import { AddCancellationHandler } from "./model/AddCancellationHandler";
3
+ export declare class UploadManagerFetchUtils {
4
+ static doPutUploadPart(config: BytescaleApiClientConfig, part: UploadPart, content: BodyInit, contentLength: number, addCancellationHandler: AddCancellationHandler): Promise<{
5
+ etag: string | undefined;
6
+ status: number;
7
+ }>;
8
+ }
@@ -1 +1 @@
1
- export declare type OnPartProgress = (bytesSentDelta: number) => void;
1
+ export declare type OnPartProgress = (bytesSentTotalForPart: number) => void;
@@ -9,10 +9,15 @@ export interface UploadSourceBuffer {
9
9
  type: "Buffer";
10
10
  value: Buffer;
11
11
  }
12
+ export interface UploadSourceArrayBuffer {
13
+ type: "ArrayBuffer";
14
+ value: ArrayBuffer;
15
+ }
12
16
  export interface UploadSourceStream {
13
17
  type: "Stream";
14
18
  value: NodeChunkedStream;
15
19
  }
16
- export declare type UploadSourceProcessedIsomorphic = UploadSourceBlob;
20
+ export declare type UploadSourceProcessedIsomorphic = UploadSourceBlob | UploadSourceArrayBuffer;
17
21
  export declare type UploadSourceProcessedBrowser = UploadSourceProcessedIsomorphic;
22
+ export declare type UploadSourceProcessedWorker = UploadSourceProcessedIsomorphic;
18
23
  export declare type UploadSourceProcessedNode = UploadSourceStream | UploadSourceBuffer | UploadSourceProcessedIsomorphic;
@@ -1,17 +1,8 @@
1
- import { UploadManagerBase } from "../../private/UploadManagerBase";
2
1
  import { UploadSourceProcessedBrowser } from "../../private/model/UploadSourceProcessed";
3
- import { PreUploadInfo } from "../../private/model/PreUploadInfo";
4
2
  import { UploadPart } from "../shared/generated";
5
3
  import { PutUploadPartResult } from "../../private/model/PutUploadPartResult";
6
4
  import { AddCancellationHandler } from "../../private/model/AddCancellationHandler";
7
- import { UploadManagerParams, UploadSource } from "../shared/CommonTypes";
8
- export declare class UploadManager extends UploadManagerBase<UploadSourceProcessedBrowser, undefined> {
9
- protected processUploadSource(data: UploadSource): UploadSourceProcessedBrowser;
10
- protected getPreUploadInfoPartial(_request: UploadManagerParams, data: UploadSourceProcessedBrowser): Partial<PreUploadInfo> & {
11
- size: number;
12
- };
13
- protected preUpload(_source: UploadSourceProcessedBrowser): undefined;
14
- protected postUpload(_init: undefined): Promise<void>;
15
- protected doPutUploadPart(part: UploadPart, contentLength: number, source: UploadSourceProcessedBrowser, onProgress: (bytesSentDelta: number) => void, addCancellationHandler: AddCancellationHandler): Promise<PutUploadPartResult>;
16
- private getRequestBody;
5
+ import { UploadManagerBrowserWorkerBase } from "../../private/UploadManagerBrowserWorkerBase";
6
+ export declare class UploadManager extends UploadManagerBrowserWorkerBase {
7
+ protected doPutUploadPart(part: UploadPart, _contentLength: number, source: UploadSourceProcessedBrowser, onProgress: (bytesSentDelta: number) => void, addCancellationHandler: AddCancellationHandler): Promise<PutUploadPartResult>;
17
8
  }
@@ -0,0 +1,8 @@
1
+ import { UploadSourceProcessedWorker } from "../../private/model/UploadSourceProcessed";
2
+ import { UploadPart } from "../shared/generated";
3
+ import { PutUploadPartResult } from "../../private/model/PutUploadPartResult";
4
+ import { AddCancellationHandler } from "../../private/model/AddCancellationHandler";
5
+ import { UploadManagerBrowserWorkerBase } from "../../private/UploadManagerBrowserWorkerBase";
6
+ export declare class UploadManager extends UploadManagerBrowserWorkerBase {
7
+ protected doPutUploadPart(part: UploadPart, contentLength: number, source: UploadSourceProcessedWorker, _onProgress: (bytesSentDelta: number) => void, addCancellationHandler: AddCancellationHandler): Promise<PutUploadPartResult>;
8
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./UploadManagerWorker";
2
+ export * from "../node/AuthManagerNode";