bruce-models 5.6.9 → 5.7.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/bruce-models.es5.js +53 -1
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +53 -1
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/abstract-api.js +17 -26
- package/dist/lib/api/abstract-api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -561,6 +561,12 @@ class AbstractApi {
|
|
|
561
561
|
formData.append(key, params.formData[key]);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* If we support the legacy request and need it for progress, then we diverge there.
|
|
566
|
+
*/
|
|
567
|
+
if (window && window["XMLHttpRequest"] && params.onProgress) {
|
|
568
|
+
return legacyUpload(url, params.headers, formData, params.onProgress, params.abortSignal);
|
|
569
|
+
}
|
|
564
570
|
const res = yield fetch(url, {
|
|
565
571
|
headers: params.headers,
|
|
566
572
|
method: "POST",
|
|
@@ -571,6 +577,52 @@ 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 params
|
|
586
|
+
*/
|
|
587
|
+
function legacyUpload(url, headers, formData, onProgress, abortSignal) {
|
|
588
|
+
return new Promise((resolve, reject) => {
|
|
589
|
+
const xhr = new window["XMLHttpRequest"]();
|
|
590
|
+
xhr.open("POST", url, true);
|
|
591
|
+
// Set custom headers.
|
|
592
|
+
if (headers) {
|
|
593
|
+
Object.keys(headers).forEach((key) => {
|
|
594
|
+
let value = headers[key];
|
|
595
|
+
if (!value) {
|
|
596
|
+
value = "";
|
|
597
|
+
}
|
|
598
|
+
xhr.setRequestHeader(key, value);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
// Progress event.
|
|
602
|
+
xhr.upload.onprogress = (event) => {
|
|
603
|
+
if (onProgress && event.lengthComputable) {
|
|
604
|
+
onProgress(event);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
// Success and error handling.
|
|
608
|
+
xhr.onload = () => {
|
|
609
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
610
|
+
resolve(JSON.parse(xhr.responseText));
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
reject(new Error(`Failed to upload: ${xhr.status} ${xhr.statusText}`));
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
xhr.onerror = () => reject(new Error("Network error occurred during file upload."));
|
|
617
|
+
if (abortSignal) {
|
|
618
|
+
abortSignal.addEventListener("abort", () => {
|
|
619
|
+
xhr.abort();
|
|
620
|
+
reject(new Error("Upload aborted."));
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
xhr.send(formData);
|
|
624
|
+
});
|
|
625
|
+
}
|
|
574
626
|
|
|
575
627
|
/**
|
|
576
628
|
* TODO: rewrite.
|
|
@@ -15211,7 +15263,7 @@ var Scenario;
|
|
|
15211
15263
|
})(Scenario || (Scenario = {}));
|
|
15212
15264
|
|
|
15213
15265
|
// This is updated with the package.json version on build.
|
|
15214
|
-
const VERSION = "5.
|
|
15266
|
+
const VERSION = "5.7.0";
|
|
15215
15267
|
|
|
15216
15268
|
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 };
|
|
15217
15269
|
//# sourceMappingURL=bruce-models.es5.js.map
|