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.es5.js
CHANGED
|
@@ -550,6 +550,12 @@ class AbstractApi {
|
|
|
550
550
|
if (this.ssidHeader) {
|
|
551
551
|
params.headers[this.ssidHeader] = this.GetSessionId();
|
|
552
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* If we support the legacy request and need it for progress, then we diverge there.
|
|
555
|
+
*/
|
|
556
|
+
if (window && window["XMLHttpRequest"] && params.onProgress) {
|
|
557
|
+
return legacyUpload(url, blob, params);
|
|
558
|
+
}
|
|
553
559
|
const formData = params.formData instanceof FormData ? params.formData : new FormData();
|
|
554
560
|
if (formData.has("file")) {
|
|
555
561
|
formData.delete("file");
|
|
@@ -571,6 +577,60 @@ class AbstractApi {
|
|
|
571
577
|
});
|
|
572
578
|
}
|
|
573
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Performs a legacy upload with XMLHttpRequest.
|
|
582
|
+
* Unfortunately, this is needed to track progress when it's supported.
|
|
583
|
+
* Fetch doesn't have this capability.
|
|
584
|
+
* @param url
|
|
585
|
+
* @param blob
|
|
586
|
+
* @param params
|
|
587
|
+
*/
|
|
588
|
+
function legacyUpload(url, blob, params) {
|
|
589
|
+
params = Object.assign({}, params);
|
|
590
|
+
params.headers = Object.assign({}, params.headers);
|
|
591
|
+
const formData = new FormData();
|
|
592
|
+
formData.append("file", blob);
|
|
593
|
+
if (params.formData && !(params.formData instanceof FormData)) {
|
|
594
|
+
for (let key in params.formData) {
|
|
595
|
+
if (key !== "file") {
|
|
596
|
+
formData.append(key, params.formData[key]);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return new Promise((resolve, reject) => {
|
|
601
|
+
const xhr = new window["XMLHttpRequest"]();
|
|
602
|
+
xhr.open("POST", url, true);
|
|
603
|
+
// Set custom headers.
|
|
604
|
+
if (params.headers) {
|
|
605
|
+
Object.entries(params.headers).forEach(([key, value]) => {
|
|
606
|
+
xhr.setRequestHeader(key, value);
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
// Progress event.
|
|
610
|
+
xhr.upload.onprogress = (event) => {
|
|
611
|
+
if ((params === null || params === void 0 ? void 0 : params.onProgress) && event.lengthComputable) {
|
|
612
|
+
params.onProgress(event);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
// Success and error handling.
|
|
616
|
+
xhr.onload = () => {
|
|
617
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
618
|
+
resolve(JSON.parse(xhr.responseText));
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
reject(new Error(`Failed to upload: ${xhr.status} ${xhr.statusText}`));
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
xhr.onerror = () => reject(new Error("Network error occurred during file upload."));
|
|
625
|
+
if (params.abortSignal) {
|
|
626
|
+
params.abortSignal.addEventListener("abort", () => {
|
|
627
|
+
xhr.abort();
|
|
628
|
+
reject(new Error("Upload aborted."));
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
xhr.send(formData);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
574
634
|
|
|
575
635
|
/**
|
|
576
636
|
* TODO: rewrite.
|
|
@@ -8423,6 +8483,12 @@ var Uploader;
|
|
|
8423
8483
|
}
|
|
8424
8484
|
fileOffset += partSize;
|
|
8425
8485
|
filePartIndex++;
|
|
8486
|
+
// Call onProgress since we completed a portion.
|
|
8487
|
+
// This helps us know progress even when the request callback isn't working properly.
|
|
8488
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
8489
|
+
percent: Math.round((fileOffset / fileSize) * 100),
|
|
8490
|
+
uploaded: false
|
|
8491
|
+
});
|
|
8426
8492
|
}
|
|
8427
8493
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
8428
8494
|
percent: 100,
|
|
@@ -15205,7 +15271,7 @@ var Scenario;
|
|
|
15205
15271
|
})(Scenario || (Scenario = {}));
|
|
15206
15272
|
|
|
15207
15273
|
// This is updated with the package.json version on build.
|
|
15208
|
-
const VERSION = "5.6.
|
|
15274
|
+
const VERSION = "5.6.8";
|
|
15209
15275
|
|
|
15210
15276
|
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario };
|
|
15211
15277
|
//# sourceMappingURL=bruce-models.es5.js.map
|