bruce-models 5.6.7 → 5.6.8
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/bruce-models.es5.js +67 -1
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +67 -1
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/abstract-api.js +60 -0
- package/dist/lib/api/abstract-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/internal/uploader.js +6 -0
- package/dist/lib/internal/uploader.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -555,6 +555,12 @@
|
|
|
555
555
|
if (this.ssidHeader) {
|
|
556
556
|
params.headers[this.ssidHeader] = this.GetSessionId();
|
|
557
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* If we support the legacy request and need it for progress, then we diverge there.
|
|
560
|
+
*/
|
|
561
|
+
if (window && window["XMLHttpRequest"] && params.onProgress) {
|
|
562
|
+
return legacyUpload(url, blob, params);
|
|
563
|
+
}
|
|
558
564
|
const formData = params.formData instanceof FormData ? params.formData : new FormData();
|
|
559
565
|
if (formData.has("file")) {
|
|
560
566
|
formData.delete("file");
|
|
@@ -576,6 +582,60 @@
|
|
|
576
582
|
});
|
|
577
583
|
}
|
|
578
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* Performs a legacy upload with XMLHttpRequest.
|
|
587
|
+
* Unfortunately, this is needed to track progress when it's supported.
|
|
588
|
+
* Fetch doesn't have this capability.
|
|
589
|
+
* @param url
|
|
590
|
+
* @param blob
|
|
591
|
+
* @param params
|
|
592
|
+
*/
|
|
593
|
+
function legacyUpload(url, blob, params) {
|
|
594
|
+
params = Object.assign({}, params);
|
|
595
|
+
params.headers = Object.assign({}, params.headers);
|
|
596
|
+
const formData = new FormData();
|
|
597
|
+
formData.append("file", blob);
|
|
598
|
+
if (params.formData && !(params.formData instanceof FormData)) {
|
|
599
|
+
for (let key in params.formData) {
|
|
600
|
+
if (key !== "file") {
|
|
601
|
+
formData.append(key, params.formData[key]);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return new Promise((resolve, reject) => {
|
|
606
|
+
const xhr = new window["XMLHttpRequest"]();
|
|
607
|
+
xhr.open("POST", url, true);
|
|
608
|
+
// Set custom headers.
|
|
609
|
+
if (params.headers) {
|
|
610
|
+
Object.entries(params.headers).forEach(([key, value]) => {
|
|
611
|
+
xhr.setRequestHeader(key, value);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
// Progress event.
|
|
615
|
+
xhr.upload.onprogress = (event) => {
|
|
616
|
+
if ((params === null || params === void 0 ? void 0 : params.onProgress) && event.lengthComputable) {
|
|
617
|
+
params.onProgress(event);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
// Success and error handling.
|
|
621
|
+
xhr.onload = () => {
|
|
622
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
623
|
+
resolve(JSON.parse(xhr.responseText));
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
reject(new Error(`Failed to upload: ${xhr.status} ${xhr.statusText}`));
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
xhr.onerror = () => reject(new Error("Network error occurred during file upload."));
|
|
630
|
+
if (params.abortSignal) {
|
|
631
|
+
params.abortSignal.addEventListener("abort", () => {
|
|
632
|
+
xhr.abort();
|
|
633
|
+
reject(new Error("Upload aborted."));
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
xhr.send(formData);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
579
639
|
|
|
580
640
|
(function (MessageBroker) {
|
|
581
641
|
let EAction;
|
|
@@ -8270,6 +8330,12 @@
|
|
|
8270
8330
|
}
|
|
8271
8331
|
fileOffset += partSize;
|
|
8272
8332
|
filePartIndex++;
|
|
8333
|
+
// Call onProgress since we completed a portion.
|
|
8334
|
+
// This helps us know progress even when the request callback isn't working properly.
|
|
8335
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
8336
|
+
percent: Math.round((fileOffset / fileSize) * 100),
|
|
8337
|
+
uploaded: false
|
|
8338
|
+
});
|
|
8273
8339
|
}
|
|
8274
8340
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
8275
8341
|
percent: 100,
|
|
@@ -14902,7 +14968,7 @@
|
|
|
14902
14968
|
})(exports.Scenario || (exports.Scenario = {}));
|
|
14903
14969
|
|
|
14904
14970
|
// This is updated with the package.json version on build.
|
|
14905
|
-
const VERSION = "5.6.
|
|
14971
|
+
const VERSION = "5.6.8";
|
|
14906
14972
|
|
|
14907
14973
|
exports.VERSION = VERSION;
|
|
14908
14974
|
exports.AbstractApi = AbstractApi;
|