@vertexvis/stream-api 0.24.3-canary.0 → 0.24.3-canary.2
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/bundle.cjs.js +180 -3
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +180 -3
- package/dist/bundle.esm.js.map +1 -1
- package/dist/validators.d.ts +9 -0
- package/package.json +7 -7
package/dist/bundle.esm.js
CHANGED
|
@@ -2289,9 +2289,14 @@ Reader$1.prototype.bytes = function read_bytes() {
|
|
|
2289
2289
|
this.pos += length;
|
|
2290
2290
|
if (Array.isArray(this.buf)) // plain array
|
|
2291
2291
|
return this.buf.slice(start, end);
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2292
|
+
|
|
2293
|
+
if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
|
|
2294
|
+
var nativeBuffer = util$2.Buffer;
|
|
2295
|
+
return nativeBuffer
|
|
2296
|
+
? nativeBuffer.alloc(0)
|
|
2297
|
+
: new this.buf.constructor(0);
|
|
2298
|
+
}
|
|
2299
|
+
return this._slice.call(this.buf, start, end);
|
|
2295
2300
|
};
|
|
2296
2301
|
|
|
2297
2302
|
/**
|
|
@@ -48833,6 +48838,119 @@ function parseEpochMillis(millis) {
|
|
|
48833
48838
|
return { seconds: seconds * (millis < 0 ? -1 : 1), nanos: nanos };
|
|
48834
48839
|
}
|
|
48835
48840
|
|
|
48841
|
+
function validateBoundingBox(boundingBox) {
|
|
48842
|
+
var boundingBoxXMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmax) != null && Number.isFinite(boundingBox.xmax);
|
|
48843
|
+
var boundingBoxXMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmin) != null && Number.isFinite(boundingBox.xmin);
|
|
48844
|
+
var boundingBoxYMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymax) != null && Number.isFinite(boundingBox.ymax);
|
|
48845
|
+
var boundingBoxYMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymin) != null && Number.isFinite(boundingBox.ymin);
|
|
48846
|
+
var boundingBoxZMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmax) != null && Number.isFinite(boundingBox.zmax);
|
|
48847
|
+
var boundingBoxZMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmin) != null && Number.isFinite(boundingBox.zmin);
|
|
48848
|
+
return (boundingBoxXMaxValid &&
|
|
48849
|
+
boundingBoxXMinValid &&
|
|
48850
|
+
boundingBoxYMaxValid &&
|
|
48851
|
+
boundingBoxYMinValid &&
|
|
48852
|
+
boundingBoxZMaxValid &&
|
|
48853
|
+
boundingBoxZMinValid);
|
|
48854
|
+
}
|
|
48855
|
+
function validateCamera(camera) {
|
|
48856
|
+
// If a perspective camera is provided, verify it is valid
|
|
48857
|
+
if (camera.perspective != null) {
|
|
48858
|
+
var perspectiveCameraIsValid = validatePerspectiveCamera(camera.perspective);
|
|
48859
|
+
return perspectiveCameraIsValid;
|
|
48860
|
+
}
|
|
48861
|
+
// If an orthographic camera is provided, verify it is valid
|
|
48862
|
+
if (camera.orthographic != null) {
|
|
48863
|
+
var orthographicCameraIsValid = validateOrthographicCamera(camera.orthographic);
|
|
48864
|
+
return orthographicCameraIsValid;
|
|
48865
|
+
}
|
|
48866
|
+
return false;
|
|
48867
|
+
}
|
|
48868
|
+
function validatePerspectiveCamera(camera) {
|
|
48869
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
48870
|
+
var lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
48871
|
+
var lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
48872
|
+
var lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
48873
|
+
var positionXValid = ((_d = camera.position) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.position.x);
|
|
48874
|
+
var positionYValid = ((_e = camera.position) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.position.y);
|
|
48875
|
+
var positionZValid = ((_f = camera.position) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.position.z);
|
|
48876
|
+
var upXValid = ((_g = camera.up) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.up.x);
|
|
48877
|
+
var upYValid = ((_h = camera.up) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.up.y);
|
|
48878
|
+
var upZValid = ((_j = camera.up) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.up.z);
|
|
48879
|
+
// Validate up vector has non-zero length
|
|
48880
|
+
var upVectorValid = validateVector({ x: (_k = camera === null || camera === void 0 ? void 0 : camera.up) === null || _k === void 0 ? void 0 : _k.x, y: (_l = camera === null || camera === void 0 ? void 0 : camera.up) === null || _l === void 0 ? void 0 : _l.y, z: (_m = camera === null || camera === void 0 ? void 0 : camera.up) === null || _m === void 0 ? void 0 : _m.z }, true);
|
|
48881
|
+
return (lookAtXValid &&
|
|
48882
|
+
lookAtYValid &&
|
|
48883
|
+
lookAtZValid &&
|
|
48884
|
+
positionXValid &&
|
|
48885
|
+
positionYValid &&
|
|
48886
|
+
positionZValid &&
|
|
48887
|
+
upXValid &&
|
|
48888
|
+
upYValid &&
|
|
48889
|
+
upZValid &&
|
|
48890
|
+
upVectorValid);
|
|
48891
|
+
}
|
|
48892
|
+
function validateOrthographicCamera(camera) {
|
|
48893
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
48894
|
+
var fovHeightValid = camera.fovHeight != null && Number.isFinite(camera.fovHeight);
|
|
48895
|
+
var lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
48896
|
+
var lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
48897
|
+
var lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
48898
|
+
var upXValid = ((_d = camera.up) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.up.x);
|
|
48899
|
+
var upYValid = ((_e = camera.up) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.up.y);
|
|
48900
|
+
var upZValid = ((_f = camera.up) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.up.z);
|
|
48901
|
+
var viewVectorXValid = ((_g = camera.viewVector) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.viewVector.x);
|
|
48902
|
+
var viewVectorYValid = ((_h = camera.viewVector) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.viewVector.y);
|
|
48903
|
+
var viewVectorZValid = ((_j = camera.viewVector) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.viewVector.z);
|
|
48904
|
+
// Validate up vector has non-zero length
|
|
48905
|
+
var upVectorValid = validateVector({ x: (_k = camera === null || camera === void 0 ? void 0 : camera.up) === null || _k === void 0 ? void 0 : _k.x, y: (_l = camera === null || camera === void 0 ? void 0 : camera.up) === null || _l === void 0 ? void 0 : _l.y, z: (_m = camera === null || camera === void 0 ? void 0 : camera.up) === null || _m === void 0 ? void 0 : _m.z }, true);
|
|
48906
|
+
return (fovHeightValid &&
|
|
48907
|
+
lookAtXValid &&
|
|
48908
|
+
lookAtYValid &&
|
|
48909
|
+
lookAtZValid &&
|
|
48910
|
+
viewVectorXValid &&
|
|
48911
|
+
viewVectorYValid &&
|
|
48912
|
+
viewVectorZValid &&
|
|
48913
|
+
upXValid &&
|
|
48914
|
+
upYValid &&
|
|
48915
|
+
upZValid &&
|
|
48916
|
+
upVectorValid);
|
|
48917
|
+
}
|
|
48918
|
+
function validateDimensions(dimensions) {
|
|
48919
|
+
var heightValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.height) != null &&
|
|
48920
|
+
Number.isFinite(dimensions.height) &&
|
|
48921
|
+
dimensions.height > 0;
|
|
48922
|
+
var widthValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) != null &&
|
|
48923
|
+
Number.isFinite(dimensions.width) &&
|
|
48924
|
+
dimensions.width > 0;
|
|
48925
|
+
return heightValid && widthValid;
|
|
48926
|
+
}
|
|
48927
|
+
function validateNumber(number) {
|
|
48928
|
+
return number != null && Number.isFinite(number);
|
|
48929
|
+
}
|
|
48930
|
+
function validatePoint(point) {
|
|
48931
|
+
var xValid = (point === null || point === void 0 ? void 0 : point.x) != null && Number.isFinite(point.x);
|
|
48932
|
+
var yValid = (point === null || point === void 0 ? void 0 : point.y) != null && Number.isFinite(point.y);
|
|
48933
|
+
return xValid && yValid;
|
|
48934
|
+
}
|
|
48935
|
+
function validateVector(vector, verifyNonZeroLength) {
|
|
48936
|
+
var xValid = (vector === null || vector === void 0 ? void 0 : vector.x) != null && Number.isFinite(vector.x);
|
|
48937
|
+
var yValid = (vector === null || vector === void 0 ? void 0 : vector.y) != null && Number.isFinite(vector.y);
|
|
48938
|
+
var zValid = (vector === null || vector === void 0 ? void 0 : vector.z) != null && Number.isFinite(vector.z);
|
|
48939
|
+
var vectorComponentsValid = xValid && yValid && zValid;
|
|
48940
|
+
if (verifyNonZeroLength) {
|
|
48941
|
+
if ((vector === null || vector === void 0 ? void 0 : vector.x) != null && (vector === null || vector === void 0 ? void 0 : vector.y) != null && (vector === null || vector === void 0 ? void 0 : vector.z) != null) {
|
|
48942
|
+
var vectorMagnitudeSquared = vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
|
|
48943
|
+
var vectorHasNonZeroLength = vectorMagnitudeSquared !== 0;
|
|
48944
|
+
return vectorComponentsValid && vectorHasNonZeroLength;
|
|
48945
|
+
}
|
|
48946
|
+
else {
|
|
48947
|
+
// If one or more components are undefined, then the vector does not have non-zero length
|
|
48948
|
+
return false;
|
|
48949
|
+
}
|
|
48950
|
+
}
|
|
48951
|
+
return vectorComponentsValid;
|
|
48952
|
+
}
|
|
48953
|
+
|
|
48836
48954
|
var WebSocketClientImpl = /** @class */ (function () {
|
|
48837
48955
|
function WebSocketClientImpl() {
|
|
48838
48956
|
var _this = this;
|
|
@@ -49075,6 +49193,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49075
49193
|
*/
|
|
49076
49194
|
StreamApi.prototype.replaceCamera = function (payload, withResponse) {
|
|
49077
49195
|
if (withResponse === void 0) { withResponse = true; }
|
|
49196
|
+
// If a camera is provided, verify it is valid
|
|
49197
|
+
if (payload.camera != null) {
|
|
49198
|
+
var cameraIsValid = validateCamera(payload.camera);
|
|
49199
|
+
if (!cameraIsValid) {
|
|
49200
|
+
console.warn('Invalid camera provided. Canceling replaceCamera operation.');
|
|
49201
|
+
return Promise.resolve({});
|
|
49202
|
+
}
|
|
49203
|
+
}
|
|
49078
49204
|
return this.sendRequest({ updateCamera: payload }, withResponse);
|
|
49079
49205
|
};
|
|
49080
49206
|
/**
|
|
@@ -49094,6 +49220,30 @@ var StreamApi = /** @class */ (function () {
|
|
|
49094
49220
|
*/
|
|
49095
49221
|
StreamApi.prototype.flyTo = function (payload, withResponse) {
|
|
49096
49222
|
if (withResponse === void 0) { withResponse = true; }
|
|
49223
|
+
// If a bounding box is provided, verify it is valid
|
|
49224
|
+
if (payload.boundingBox != null) {
|
|
49225
|
+
var validBoundingBox = validateBoundingBox(payload.boundingBox);
|
|
49226
|
+
if (!validBoundingBox) {
|
|
49227
|
+
console.warn('Invalid bounding box provided. Canceling flyTo operation.');
|
|
49228
|
+
return Promise.resolve({});
|
|
49229
|
+
}
|
|
49230
|
+
}
|
|
49231
|
+
// If a camera is provided, verify it is valid
|
|
49232
|
+
if (payload.camera != null) {
|
|
49233
|
+
var cameraIsValid = validateCamera(payload.camera);
|
|
49234
|
+
if (!cameraIsValid) {
|
|
49235
|
+
console.warn('Invalid camera provided. Canceling flyTo operation.');
|
|
49236
|
+
return Promise.resolve({});
|
|
49237
|
+
}
|
|
49238
|
+
}
|
|
49239
|
+
// If a base camera is provided, verify it is valid
|
|
49240
|
+
if (payload.baseCamera != null) {
|
|
49241
|
+
var baseCameraIsValid = validateCamera(payload.baseCamera);
|
|
49242
|
+
if (!baseCameraIsValid) {
|
|
49243
|
+
console.warn('Invalid base camera provided. Canceling flyTo operation.');
|
|
49244
|
+
return Promise.resolve({});
|
|
49245
|
+
}
|
|
49246
|
+
}
|
|
49097
49247
|
return this.sendRequest({ flyTo: payload }, withResponse);
|
|
49098
49248
|
};
|
|
49099
49249
|
/**
|
|
@@ -49129,6 +49279,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49129
49279
|
*/
|
|
49130
49280
|
StreamApi.prototype.updateDimensions = function (payload, withResponse) {
|
|
49131
49281
|
if (withResponse === void 0) { withResponse = true; }
|
|
49282
|
+
// Verify the provided dimensions are valid
|
|
49283
|
+
if (payload.dimensions != null) {
|
|
49284
|
+
var validDimensions = validateDimensions(payload.dimensions);
|
|
49285
|
+
if (!validDimensions) {
|
|
49286
|
+
console.warn('Invalid dimensions provided. Canceling updateDimensions operation.');
|
|
49287
|
+
return Promise.resolve({});
|
|
49288
|
+
}
|
|
49289
|
+
}
|
|
49132
49290
|
return this.sendRequest({ updateDimensions: payload }, withResponse);
|
|
49133
49291
|
};
|
|
49134
49292
|
/**
|
|
@@ -49148,7 +49306,18 @@ var StreamApi = /** @class */ (function () {
|
|
|
49148
49306
|
* Defaults to `true`.
|
|
49149
49307
|
*/
|
|
49150
49308
|
StreamApi.prototype.updateCrossSectioning = function (payload, withResponse) {
|
|
49309
|
+
var _a, _b;
|
|
49151
49310
|
if (withResponse === void 0) { withResponse = true; }
|
|
49311
|
+
// If a section plane is provided, verify it is valid
|
|
49312
|
+
var invalidSectionPlane = (_b = (_a = payload.crossSectioning) === null || _a === void 0 ? void 0 : _a.sectionPlanes) === null || _b === void 0 ? void 0 : _b.some(function (plane) {
|
|
49313
|
+
var validNormal = plane.normal != null && validateVector(plane.normal, true);
|
|
49314
|
+
var validOffset = plane.offset != null && validateNumber(plane.offset);
|
|
49315
|
+
return !validNormal || !validOffset;
|
|
49316
|
+
});
|
|
49317
|
+
if (invalidSectionPlane) {
|
|
49318
|
+
console.warn('Invalid cross section plane provided. Canceling updateCrossSectioning operation.');
|
|
49319
|
+
return Promise.resolve({});
|
|
49320
|
+
}
|
|
49152
49321
|
return this.sendRequest({ updateCrossSectioning: payload }, withResponse);
|
|
49153
49322
|
};
|
|
49154
49323
|
/**
|
|
@@ -49184,6 +49353,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49184
49353
|
*/
|
|
49185
49354
|
StreamApi.prototype.hitItems = function (payload, withResponse) {
|
|
49186
49355
|
if (withResponse === void 0) { withResponse = true; }
|
|
49356
|
+
// If a point is provided, verify it is valid
|
|
49357
|
+
if (payload.point != null) {
|
|
49358
|
+
var validPoint = validatePoint(payload.point);
|
|
49359
|
+
if (!validPoint) {
|
|
49360
|
+
console.warn('Invalid point provided. Canceling hitItems operation.');
|
|
49361
|
+
return Promise.resolve({});
|
|
49362
|
+
}
|
|
49363
|
+
}
|
|
49187
49364
|
return this.sendRequest({ hitItems: payload }, withResponse);
|
|
49188
49365
|
};
|
|
49189
49366
|
/**
|