@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.cjs.js
CHANGED
|
@@ -2293,9 +2293,14 @@ Reader$1.prototype.bytes = function read_bytes() {
|
|
|
2293
2293
|
this.pos += length;
|
|
2294
2294
|
if (Array.isArray(this.buf)) // plain array
|
|
2295
2295
|
return this.buf.slice(start, end);
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2296
|
+
|
|
2297
|
+
if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
|
|
2298
|
+
var nativeBuffer = util$2.Buffer;
|
|
2299
|
+
return nativeBuffer
|
|
2300
|
+
? nativeBuffer.alloc(0)
|
|
2301
|
+
: new this.buf.constructor(0);
|
|
2302
|
+
}
|
|
2303
|
+
return this._slice.call(this.buf, start, end);
|
|
2299
2304
|
};
|
|
2300
2305
|
|
|
2301
2306
|
/**
|
|
@@ -48837,6 +48842,119 @@ function parseEpochMillis(millis) {
|
|
|
48837
48842
|
return { seconds: seconds * (millis < 0 ? -1 : 1), nanos: nanos };
|
|
48838
48843
|
}
|
|
48839
48844
|
|
|
48845
|
+
function validateBoundingBox(boundingBox) {
|
|
48846
|
+
var boundingBoxXMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmax) != null && Number.isFinite(boundingBox.xmax);
|
|
48847
|
+
var boundingBoxXMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmin) != null && Number.isFinite(boundingBox.xmin);
|
|
48848
|
+
var boundingBoxYMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymax) != null && Number.isFinite(boundingBox.ymax);
|
|
48849
|
+
var boundingBoxYMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymin) != null && Number.isFinite(boundingBox.ymin);
|
|
48850
|
+
var boundingBoxZMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmax) != null && Number.isFinite(boundingBox.zmax);
|
|
48851
|
+
var boundingBoxZMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmin) != null && Number.isFinite(boundingBox.zmin);
|
|
48852
|
+
return (boundingBoxXMaxValid &&
|
|
48853
|
+
boundingBoxXMinValid &&
|
|
48854
|
+
boundingBoxYMaxValid &&
|
|
48855
|
+
boundingBoxYMinValid &&
|
|
48856
|
+
boundingBoxZMaxValid &&
|
|
48857
|
+
boundingBoxZMinValid);
|
|
48858
|
+
}
|
|
48859
|
+
function validateCamera(camera) {
|
|
48860
|
+
// If a perspective camera is provided, verify it is valid
|
|
48861
|
+
if (camera.perspective != null) {
|
|
48862
|
+
var perspectiveCameraIsValid = validatePerspectiveCamera(camera.perspective);
|
|
48863
|
+
return perspectiveCameraIsValid;
|
|
48864
|
+
}
|
|
48865
|
+
// If an orthographic camera is provided, verify it is valid
|
|
48866
|
+
if (camera.orthographic != null) {
|
|
48867
|
+
var orthographicCameraIsValid = validateOrthographicCamera(camera.orthographic);
|
|
48868
|
+
return orthographicCameraIsValid;
|
|
48869
|
+
}
|
|
48870
|
+
return false;
|
|
48871
|
+
}
|
|
48872
|
+
function validatePerspectiveCamera(camera) {
|
|
48873
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
48874
|
+
var lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
48875
|
+
var lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
48876
|
+
var lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
48877
|
+
var positionXValid = ((_d = camera.position) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.position.x);
|
|
48878
|
+
var positionYValid = ((_e = camera.position) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.position.y);
|
|
48879
|
+
var positionZValid = ((_f = camera.position) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.position.z);
|
|
48880
|
+
var upXValid = ((_g = camera.up) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.up.x);
|
|
48881
|
+
var upYValid = ((_h = camera.up) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.up.y);
|
|
48882
|
+
var upZValid = ((_j = camera.up) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.up.z);
|
|
48883
|
+
// Validate up vector has non-zero length
|
|
48884
|
+
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);
|
|
48885
|
+
return (lookAtXValid &&
|
|
48886
|
+
lookAtYValid &&
|
|
48887
|
+
lookAtZValid &&
|
|
48888
|
+
positionXValid &&
|
|
48889
|
+
positionYValid &&
|
|
48890
|
+
positionZValid &&
|
|
48891
|
+
upXValid &&
|
|
48892
|
+
upYValid &&
|
|
48893
|
+
upZValid &&
|
|
48894
|
+
upVectorValid);
|
|
48895
|
+
}
|
|
48896
|
+
function validateOrthographicCamera(camera) {
|
|
48897
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
48898
|
+
var fovHeightValid = camera.fovHeight != null && Number.isFinite(camera.fovHeight);
|
|
48899
|
+
var lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
48900
|
+
var lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
48901
|
+
var lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
48902
|
+
var upXValid = ((_d = camera.up) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.up.x);
|
|
48903
|
+
var upYValid = ((_e = camera.up) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.up.y);
|
|
48904
|
+
var upZValid = ((_f = camera.up) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.up.z);
|
|
48905
|
+
var viewVectorXValid = ((_g = camera.viewVector) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.viewVector.x);
|
|
48906
|
+
var viewVectorYValid = ((_h = camera.viewVector) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.viewVector.y);
|
|
48907
|
+
var viewVectorZValid = ((_j = camera.viewVector) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.viewVector.z);
|
|
48908
|
+
// Validate up vector has non-zero length
|
|
48909
|
+
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);
|
|
48910
|
+
return (fovHeightValid &&
|
|
48911
|
+
lookAtXValid &&
|
|
48912
|
+
lookAtYValid &&
|
|
48913
|
+
lookAtZValid &&
|
|
48914
|
+
viewVectorXValid &&
|
|
48915
|
+
viewVectorYValid &&
|
|
48916
|
+
viewVectorZValid &&
|
|
48917
|
+
upXValid &&
|
|
48918
|
+
upYValid &&
|
|
48919
|
+
upZValid &&
|
|
48920
|
+
upVectorValid);
|
|
48921
|
+
}
|
|
48922
|
+
function validateDimensions(dimensions) {
|
|
48923
|
+
var heightValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.height) != null &&
|
|
48924
|
+
Number.isFinite(dimensions.height) &&
|
|
48925
|
+
dimensions.height > 0;
|
|
48926
|
+
var widthValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) != null &&
|
|
48927
|
+
Number.isFinite(dimensions.width) &&
|
|
48928
|
+
dimensions.width > 0;
|
|
48929
|
+
return heightValid && widthValid;
|
|
48930
|
+
}
|
|
48931
|
+
function validateNumber(number) {
|
|
48932
|
+
return number != null && Number.isFinite(number);
|
|
48933
|
+
}
|
|
48934
|
+
function validatePoint(point) {
|
|
48935
|
+
var xValid = (point === null || point === void 0 ? void 0 : point.x) != null && Number.isFinite(point.x);
|
|
48936
|
+
var yValid = (point === null || point === void 0 ? void 0 : point.y) != null && Number.isFinite(point.y);
|
|
48937
|
+
return xValid && yValid;
|
|
48938
|
+
}
|
|
48939
|
+
function validateVector(vector, verifyNonZeroLength) {
|
|
48940
|
+
var xValid = (vector === null || vector === void 0 ? void 0 : vector.x) != null && Number.isFinite(vector.x);
|
|
48941
|
+
var yValid = (vector === null || vector === void 0 ? void 0 : vector.y) != null && Number.isFinite(vector.y);
|
|
48942
|
+
var zValid = (vector === null || vector === void 0 ? void 0 : vector.z) != null && Number.isFinite(vector.z);
|
|
48943
|
+
var vectorComponentsValid = xValid && yValid && zValid;
|
|
48944
|
+
if (verifyNonZeroLength) {
|
|
48945
|
+
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) {
|
|
48946
|
+
var vectorMagnitudeSquared = vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
|
|
48947
|
+
var vectorHasNonZeroLength = vectorMagnitudeSquared !== 0;
|
|
48948
|
+
return vectorComponentsValid && vectorHasNonZeroLength;
|
|
48949
|
+
}
|
|
48950
|
+
else {
|
|
48951
|
+
// If one or more components are undefined, then the vector does not have non-zero length
|
|
48952
|
+
return false;
|
|
48953
|
+
}
|
|
48954
|
+
}
|
|
48955
|
+
return vectorComponentsValid;
|
|
48956
|
+
}
|
|
48957
|
+
|
|
48840
48958
|
var WebSocketClientImpl = /** @class */ (function () {
|
|
48841
48959
|
function WebSocketClientImpl() {
|
|
48842
48960
|
var _this = this;
|
|
@@ -49079,6 +49197,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49079
49197
|
*/
|
|
49080
49198
|
StreamApi.prototype.replaceCamera = function (payload, withResponse) {
|
|
49081
49199
|
if (withResponse === void 0) { withResponse = true; }
|
|
49200
|
+
// If a camera is provided, verify it is valid
|
|
49201
|
+
if (payload.camera != null) {
|
|
49202
|
+
var cameraIsValid = validateCamera(payload.camera);
|
|
49203
|
+
if (!cameraIsValid) {
|
|
49204
|
+
console.warn('Invalid camera provided. Canceling replaceCamera operation.');
|
|
49205
|
+
return Promise.resolve({});
|
|
49206
|
+
}
|
|
49207
|
+
}
|
|
49082
49208
|
return this.sendRequest({ updateCamera: payload }, withResponse);
|
|
49083
49209
|
};
|
|
49084
49210
|
/**
|
|
@@ -49098,6 +49224,30 @@ var StreamApi = /** @class */ (function () {
|
|
|
49098
49224
|
*/
|
|
49099
49225
|
StreamApi.prototype.flyTo = function (payload, withResponse) {
|
|
49100
49226
|
if (withResponse === void 0) { withResponse = true; }
|
|
49227
|
+
// If a bounding box is provided, verify it is valid
|
|
49228
|
+
if (payload.boundingBox != null) {
|
|
49229
|
+
var validBoundingBox = validateBoundingBox(payload.boundingBox);
|
|
49230
|
+
if (!validBoundingBox) {
|
|
49231
|
+
console.warn('Invalid bounding box provided. Canceling flyTo operation.');
|
|
49232
|
+
return Promise.resolve({});
|
|
49233
|
+
}
|
|
49234
|
+
}
|
|
49235
|
+
// If a camera is provided, verify it is valid
|
|
49236
|
+
if (payload.camera != null) {
|
|
49237
|
+
var cameraIsValid = validateCamera(payload.camera);
|
|
49238
|
+
if (!cameraIsValid) {
|
|
49239
|
+
console.warn('Invalid camera provided. Canceling flyTo operation.');
|
|
49240
|
+
return Promise.resolve({});
|
|
49241
|
+
}
|
|
49242
|
+
}
|
|
49243
|
+
// If a base camera is provided, verify it is valid
|
|
49244
|
+
if (payload.baseCamera != null) {
|
|
49245
|
+
var baseCameraIsValid = validateCamera(payload.baseCamera);
|
|
49246
|
+
if (!baseCameraIsValid) {
|
|
49247
|
+
console.warn('Invalid base camera provided. Canceling flyTo operation.');
|
|
49248
|
+
return Promise.resolve({});
|
|
49249
|
+
}
|
|
49250
|
+
}
|
|
49101
49251
|
return this.sendRequest({ flyTo: payload }, withResponse);
|
|
49102
49252
|
};
|
|
49103
49253
|
/**
|
|
@@ -49133,6 +49283,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49133
49283
|
*/
|
|
49134
49284
|
StreamApi.prototype.updateDimensions = function (payload, withResponse) {
|
|
49135
49285
|
if (withResponse === void 0) { withResponse = true; }
|
|
49286
|
+
// Verify the provided dimensions are valid
|
|
49287
|
+
if (payload.dimensions != null) {
|
|
49288
|
+
var validDimensions = validateDimensions(payload.dimensions);
|
|
49289
|
+
if (!validDimensions) {
|
|
49290
|
+
console.warn('Invalid dimensions provided. Canceling updateDimensions operation.');
|
|
49291
|
+
return Promise.resolve({});
|
|
49292
|
+
}
|
|
49293
|
+
}
|
|
49136
49294
|
return this.sendRequest({ updateDimensions: payload }, withResponse);
|
|
49137
49295
|
};
|
|
49138
49296
|
/**
|
|
@@ -49152,7 +49310,18 @@ var StreamApi = /** @class */ (function () {
|
|
|
49152
49310
|
* Defaults to `true`.
|
|
49153
49311
|
*/
|
|
49154
49312
|
StreamApi.prototype.updateCrossSectioning = function (payload, withResponse) {
|
|
49313
|
+
var _a, _b;
|
|
49155
49314
|
if (withResponse === void 0) { withResponse = true; }
|
|
49315
|
+
// If a section plane is provided, verify it is valid
|
|
49316
|
+
var invalidSectionPlane = (_b = (_a = payload.crossSectioning) === null || _a === void 0 ? void 0 : _a.sectionPlanes) === null || _b === void 0 ? void 0 : _b.some(function (plane) {
|
|
49317
|
+
var validNormal = plane.normal != null && validateVector(plane.normal, true);
|
|
49318
|
+
var validOffset = plane.offset != null && validateNumber(plane.offset);
|
|
49319
|
+
return !validNormal || !validOffset;
|
|
49320
|
+
});
|
|
49321
|
+
if (invalidSectionPlane) {
|
|
49322
|
+
console.warn('Invalid cross section plane provided. Canceling updateCrossSectioning operation.');
|
|
49323
|
+
return Promise.resolve({});
|
|
49324
|
+
}
|
|
49156
49325
|
return this.sendRequest({ updateCrossSectioning: payload }, withResponse);
|
|
49157
49326
|
};
|
|
49158
49327
|
/**
|
|
@@ -49188,6 +49357,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49188
49357
|
*/
|
|
49189
49358
|
StreamApi.prototype.hitItems = function (payload, withResponse) {
|
|
49190
49359
|
if (withResponse === void 0) { withResponse = true; }
|
|
49360
|
+
// If a point is provided, verify it is valid
|
|
49361
|
+
if (payload.point != null) {
|
|
49362
|
+
var validPoint = validatePoint(payload.point);
|
|
49363
|
+
if (!validPoint) {
|
|
49364
|
+
console.warn('Invalid point provided. Canceling hitItems operation.');
|
|
49365
|
+
return Promise.resolve({});
|
|
49366
|
+
}
|
|
49367
|
+
}
|
|
49191
49368
|
return this.sendRequest({ hitItems: payload }, withResponse);
|
|
49192
49369
|
};
|
|
49193
49370
|
/**
|