@vertexvis/stream-api 0.24.5-canary.1 → 0.24.5-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 +296 -358
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +297 -359
- package/dist/bundle.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/bundle.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Uri, Objects, UUID, EventDispatcher } from '@vertexvis/utils';
|
|
1
|
+
import { Uri, Objects, EventDispatcher, UUID } from '@vertexvis/utils';
|
|
3
2
|
|
|
4
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
4
|
|
|
@@ -48973,43 +48972,36 @@ function encode(message) {
|
|
|
48973
48972
|
return vertexvis.protobuf.stream.StreamMessage.encode(message).finish();
|
|
48974
48973
|
}
|
|
48975
48974
|
function decode(bufferOrBytes) {
|
|
48976
|
-
|
|
48975
|
+
const bytes = bufferOrBytes instanceof ArrayBuffer
|
|
48977
48976
|
? new Uint8Array(bufferOrBytes)
|
|
48978
48977
|
: bufferOrBytes;
|
|
48979
|
-
|
|
48978
|
+
const message = vertexvis.protobuf.stream.StreamMessage.decode(bytes);
|
|
48980
48979
|
return vertexvis.protobuf.stream.StreamMessage.toObject(message, {
|
|
48981
48980
|
defaults: true,
|
|
48982
48981
|
});
|
|
48983
48982
|
}
|
|
48984
48983
|
|
|
48985
|
-
|
|
48986
|
-
|
|
48987
|
-
|
|
48988
|
-
|
|
48989
|
-
|
|
48990
|
-
|
|
48991
|
-
|
|
48992
|
-
|
|
48993
|
-
|
|
48994
|
-
_this.details = details;
|
|
48984
|
+
class StreamRequestError extends Error {
|
|
48985
|
+
constructor(requestId, requestPayload, summary, details) {
|
|
48986
|
+
super(summary != null && summary.length > 0
|
|
48987
|
+
? `Stream request failed (${summary})`
|
|
48988
|
+
: 'Stream request failed');
|
|
48989
|
+
this.requestId = requestId;
|
|
48990
|
+
this.requestPayload = requestPayload;
|
|
48991
|
+
this.summary = summary;
|
|
48992
|
+
this.details = details;
|
|
48995
48993
|
// Allows for `instanceof` checks. See https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
48996
|
-
Object.setPrototypeOf(
|
|
48997
|
-
return _this;
|
|
48994
|
+
Object.setPrototypeOf(this, StreamRequestError.prototype);
|
|
48998
48995
|
}
|
|
48999
|
-
|
|
49000
|
-
}(Error));
|
|
48996
|
+
}
|
|
49001
48997
|
|
|
49002
|
-
function defineParams() {
|
|
49003
|
-
|
|
49004
|
-
|
|
49005
|
-
definitions[_i] = arguments[_i];
|
|
49006
|
-
}
|
|
49007
|
-
return function (settings) {
|
|
49008
|
-
return definitions.reduce(function (result, def) { return (__assign(__assign({}, result), def(settings))); }, {});
|
|
48998
|
+
function defineParams(...definitions) {
|
|
48999
|
+
return (settings) => {
|
|
49000
|
+
return definitions.reduce((result, def) => ({ ...result, ...def(settings) }), {});
|
|
49009
49001
|
};
|
|
49010
49002
|
}
|
|
49011
49003
|
function defineBoolean(param, prop) {
|
|
49012
|
-
return defineValue(param, prop,
|
|
49004
|
+
return defineValue(param, prop, (v) => {
|
|
49013
49005
|
if (typeof v === 'boolean') {
|
|
49014
49006
|
return v ? 'on' : 'off';
|
|
49015
49007
|
}
|
|
@@ -49019,21 +49011,16 @@ function defineBoolean(param, prop) {
|
|
|
49019
49011
|
});
|
|
49020
49012
|
}
|
|
49021
49013
|
function defineNumber(param, prop) {
|
|
49022
|
-
return defineValue(param, prop,
|
|
49023
|
-
return typeof v === 'number' ? v.toString() : undefined;
|
|
49024
|
-
});
|
|
49014
|
+
return defineValue(param, prop, (v) => typeof v === 'number' ? v.toString() : undefined);
|
|
49025
49015
|
}
|
|
49026
49016
|
function defineString(param, prop) {
|
|
49027
|
-
return defineValue(param, prop,
|
|
49028
|
-
return typeof v === 'string' ? v : undefined;
|
|
49029
|
-
});
|
|
49017
|
+
return defineValue(param, prop, (v) => typeof v === 'string' ? v : undefined);
|
|
49030
49018
|
}
|
|
49031
49019
|
function defineValue(param, prop, f) {
|
|
49032
|
-
return
|
|
49033
|
-
|
|
49034
|
-
var value = f(settings[prop]);
|
|
49020
|
+
return (settings) => {
|
|
49021
|
+
const value = f(settings[prop]);
|
|
49035
49022
|
if (value != null) {
|
|
49036
|
-
return
|
|
49023
|
+
return { [param]: value };
|
|
49037
49024
|
}
|
|
49038
49025
|
else {
|
|
49039
49026
|
return {};
|
|
@@ -49042,26 +49029,26 @@ function defineValue(param, prop, f) {
|
|
|
49042
49029
|
}
|
|
49043
49030
|
|
|
49044
49031
|
function appendSettingsToUrl(url, settings) {
|
|
49045
|
-
|
|
49032
|
+
const defaults = {
|
|
49046
49033
|
// Settings that you want to set on each WS connection should go here.
|
|
49047
49034
|
};
|
|
49048
|
-
|
|
49049
|
-
|
|
49050
|
-
|
|
49035
|
+
const uri = Uri.parse(url);
|
|
49036
|
+
const builder = defineParams(toFrameDeliverySettingsParams(defaults.EXPERIMENTAL_frameDelivery), toAdaptiveRenderingSettingsParams(defaults.EXPERIMENTAL_adaptiveRendering), toQualityOfServiceSettingsParams(defaults.EXPERIMENTAL_qualityOfService));
|
|
49037
|
+
const params = builder(settings);
|
|
49051
49038
|
return Uri.toString(Uri.addQueryParams(params, uri));
|
|
49052
49039
|
}
|
|
49053
49040
|
function toFrameDeliverySettingsParams(defaults) {
|
|
49054
|
-
return defineSettings(
|
|
49041
|
+
return defineSettings((s) => s.EXPERIMENTAL_frameDelivery, defaults, defineParams(defineBoolean('frame-delivery.rate-limit-enabled', 'rateLimitingEnabled'), defineNumber('frame-delivery.packet-loss-threshold', 'packetLossThreshold'), defineNumber('frame-delivery.history-max-size', 'historyMaxSize'), defineString('frame-delivery.timeout', 'timeout'), defineNumber('frame-delivery.timeout-ratio-threshold', 'timeoutRatioThreshold')));
|
|
49055
49042
|
}
|
|
49056
49043
|
function toAdaptiveRenderingSettingsParams(defaults) {
|
|
49057
|
-
return defineSettings(
|
|
49044
|
+
return defineSettings((s) => s.EXPERIMENTAL_adaptiveRendering, defaults, defineParams(defineBoolean('adaptive-rendering.enabled', 'enabled'), defineString('adaptive-rendering.method', 'method'), defineNumber('adaptive-rendering.jpeg-quality-min', 'jpegMinQuality'), defineNumber('adaptive-rendering.jpeg-quality-max', 'jpegMaxQuality'), defineNumber('adaptive-rendering.image-scale-min', 'imageMinScale'), defineNumber('adaptive-rendering.image-scale-max', 'imageMaxScale'), defineNumber('adaptive-rendering.window-size', 'windowSize')));
|
|
49058
49045
|
}
|
|
49059
49046
|
function toQualityOfServiceSettingsParams(defaults) {
|
|
49060
|
-
return defineSettings(
|
|
49047
|
+
return defineSettings((s) => s.EXPERIMENTAL_qualityOfService, defaults, defineParams(defineNumber('qos.history-max-size', 'historyMaxSize')));
|
|
49061
49048
|
}
|
|
49062
49049
|
function defineSettings(getter, defaults, builder) {
|
|
49063
|
-
return
|
|
49064
|
-
|
|
49050
|
+
return (settings) => {
|
|
49051
|
+
const merged = Objects.defaults(getter(settings) || {}, defaults);
|
|
49065
49052
|
return builder(merged);
|
|
49066
49053
|
};
|
|
49067
49054
|
}
|
|
@@ -49073,7 +49060,7 @@ function defineSettings(getter, defaults, builder) {
|
|
|
49073
49060
|
* @param date The date to convert.
|
|
49074
49061
|
*/
|
|
49075
49062
|
function toProtoTimestamp(date) {
|
|
49076
|
-
|
|
49063
|
+
const millis = date.getTime();
|
|
49077
49064
|
return google.protobuf.Timestamp.create(parseEpochMillis(millis));
|
|
49078
49065
|
}
|
|
49079
49066
|
/**
|
|
@@ -49082,19 +49069,15 @@ function toProtoTimestamp(date) {
|
|
|
49082
49069
|
function currentDateAsProtoTimestamp() {
|
|
49083
49070
|
return toProtoTimestamp(new Date());
|
|
49084
49071
|
}
|
|
49085
|
-
function toProtoDuration() {
|
|
49086
|
-
var args = [];
|
|
49087
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
49088
|
-
args[_i] = arguments[_i];
|
|
49089
|
-
}
|
|
49072
|
+
function toProtoDuration(...args) {
|
|
49090
49073
|
if (args.length === 2) {
|
|
49091
|
-
|
|
49092
|
-
|
|
49093
|
-
|
|
49074
|
+
const start = args[0];
|
|
49075
|
+
const end = args[1];
|
|
49076
|
+
const millis = end.getTime() - start.getTime();
|
|
49094
49077
|
return google.protobuf.Duration.create(parseEpochMillis(millis));
|
|
49095
49078
|
}
|
|
49096
49079
|
else if (args.length === 1) {
|
|
49097
|
-
|
|
49080
|
+
const millis = args[0];
|
|
49098
49081
|
return google.protobuf.Duration.create(parseEpochMillis(millis));
|
|
49099
49082
|
}
|
|
49100
49083
|
else {
|
|
@@ -49103,24 +49086,24 @@ function toProtoDuration() {
|
|
|
49103
49086
|
}
|
|
49104
49087
|
function protoToDate(time) {
|
|
49105
49088
|
if (time.seconds != null && time.nanos != null) {
|
|
49106
|
-
|
|
49089
|
+
const seconds = typeof time.seconds === 'number' ? time.seconds : time.seconds.toNumber();
|
|
49107
49090
|
return new Date(seconds * 1000 + time.nanos / 1000000);
|
|
49108
49091
|
}
|
|
49109
49092
|
}
|
|
49110
49093
|
/* eslint-enable padding-line-between-statements */
|
|
49111
49094
|
function parseEpochMillis(millis) {
|
|
49112
|
-
|
|
49113
|
-
|
|
49114
|
-
return { seconds: seconds * (millis < 0 ? -1 : 1), nanos
|
|
49095
|
+
const seconds = Math.floor(Math.abs(millis) / 1000);
|
|
49096
|
+
const nanos = (millis % 1000) * 1000000;
|
|
49097
|
+
return { seconds: seconds * (millis < 0 ? -1 : 1), nanos };
|
|
49115
49098
|
}
|
|
49116
49099
|
|
|
49117
49100
|
function validateBoundingBox(boundingBox) {
|
|
49118
|
-
|
|
49119
|
-
|
|
49120
|
-
|
|
49121
|
-
|
|
49122
|
-
|
|
49123
|
-
|
|
49101
|
+
const boundingBoxXMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmax) != null && Number.isFinite(boundingBox.xmax);
|
|
49102
|
+
const boundingBoxXMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.xmin) != null && Number.isFinite(boundingBox.xmin);
|
|
49103
|
+
const boundingBoxYMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymax) != null && Number.isFinite(boundingBox.ymax);
|
|
49104
|
+
const boundingBoxYMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.ymin) != null && Number.isFinite(boundingBox.ymin);
|
|
49105
|
+
const boundingBoxZMaxValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmax) != null && Number.isFinite(boundingBox.zmax);
|
|
49106
|
+
const boundingBoxZMinValid = (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.zmin) != null && Number.isFinite(boundingBox.zmin);
|
|
49124
49107
|
return (boundingBoxXMaxValid &&
|
|
49125
49108
|
boundingBoxXMinValid &&
|
|
49126
49109
|
boundingBoxYMaxValid &&
|
|
@@ -49131,29 +49114,29 @@ function validateBoundingBox(boundingBox) {
|
|
|
49131
49114
|
function validateCamera(camera) {
|
|
49132
49115
|
// If a perspective camera is provided, verify it is valid
|
|
49133
49116
|
if (camera.perspective != null) {
|
|
49134
|
-
|
|
49117
|
+
const perspectiveCameraIsValid = validatePerspectiveCamera(camera.perspective);
|
|
49135
49118
|
return perspectiveCameraIsValid;
|
|
49136
49119
|
}
|
|
49137
49120
|
// If an orthographic camera is provided, verify it is valid
|
|
49138
49121
|
if (camera.orthographic != null) {
|
|
49139
|
-
|
|
49122
|
+
const orthographicCameraIsValid = validateOrthographicCamera(camera.orthographic);
|
|
49140
49123
|
return orthographicCameraIsValid;
|
|
49141
49124
|
}
|
|
49142
49125
|
return false;
|
|
49143
49126
|
}
|
|
49144
49127
|
function validatePerspectiveCamera(camera) {
|
|
49145
49128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
49146
|
-
|
|
49147
|
-
|
|
49148
|
-
|
|
49149
|
-
|
|
49150
|
-
|
|
49151
|
-
|
|
49152
|
-
|
|
49153
|
-
|
|
49154
|
-
|
|
49129
|
+
const lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
49130
|
+
const lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
49131
|
+
const lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
49132
|
+
const positionXValid = ((_d = camera.position) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.position.x);
|
|
49133
|
+
const positionYValid = ((_e = camera.position) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.position.y);
|
|
49134
|
+
const positionZValid = ((_f = camera.position) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.position.z);
|
|
49135
|
+
const upXValid = ((_g = camera.up) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.up.x);
|
|
49136
|
+
const upYValid = ((_h = camera.up) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.up.y);
|
|
49137
|
+
const upZValid = ((_j = camera.up) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.up.z);
|
|
49155
49138
|
// Validate up vector has non-zero length
|
|
49156
|
-
|
|
49139
|
+
const 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);
|
|
49157
49140
|
return (lookAtXValid &&
|
|
49158
49141
|
lookAtYValid &&
|
|
49159
49142
|
lookAtZValid &&
|
|
@@ -49167,18 +49150,18 @@ function validatePerspectiveCamera(camera) {
|
|
|
49167
49150
|
}
|
|
49168
49151
|
function validateOrthographicCamera(camera) {
|
|
49169
49152
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
49170
|
-
|
|
49171
|
-
|
|
49172
|
-
|
|
49173
|
-
|
|
49174
|
-
|
|
49175
|
-
|
|
49176
|
-
|
|
49177
|
-
|
|
49178
|
-
|
|
49179
|
-
|
|
49153
|
+
const fovHeightValid = camera.fovHeight != null && Number.isFinite(camera.fovHeight);
|
|
49154
|
+
const lookAtXValid = ((_a = camera.lookAt) === null || _a === void 0 ? void 0 : _a.x) != null && Number.isFinite(camera.lookAt.x);
|
|
49155
|
+
const lookAtYValid = ((_b = camera.lookAt) === null || _b === void 0 ? void 0 : _b.y) != null && Number.isFinite(camera.lookAt.y);
|
|
49156
|
+
const lookAtZValid = ((_c = camera.lookAt) === null || _c === void 0 ? void 0 : _c.z) != null && Number.isFinite(camera.lookAt.z);
|
|
49157
|
+
const upXValid = ((_d = camera.up) === null || _d === void 0 ? void 0 : _d.x) != null && Number.isFinite(camera.up.x);
|
|
49158
|
+
const upYValid = ((_e = camera.up) === null || _e === void 0 ? void 0 : _e.y) != null && Number.isFinite(camera.up.y);
|
|
49159
|
+
const upZValid = ((_f = camera.up) === null || _f === void 0 ? void 0 : _f.z) != null && Number.isFinite(camera.up.z);
|
|
49160
|
+
const viewVectorXValid = ((_g = camera.viewVector) === null || _g === void 0 ? void 0 : _g.x) != null && Number.isFinite(camera.viewVector.x);
|
|
49161
|
+
const viewVectorYValid = ((_h = camera.viewVector) === null || _h === void 0 ? void 0 : _h.y) != null && Number.isFinite(camera.viewVector.y);
|
|
49162
|
+
const viewVectorZValid = ((_j = camera.viewVector) === null || _j === void 0 ? void 0 : _j.z) != null && Number.isFinite(camera.viewVector.z);
|
|
49180
49163
|
// Validate up vector has non-zero length
|
|
49181
|
-
|
|
49164
|
+
const 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);
|
|
49182
49165
|
return (fovHeightValid &&
|
|
49183
49166
|
lookAtXValid &&
|
|
49184
49167
|
lookAtYValid &&
|
|
@@ -49192,10 +49175,10 @@ function validateOrthographicCamera(camera) {
|
|
|
49192
49175
|
upVectorValid);
|
|
49193
49176
|
}
|
|
49194
49177
|
function validateDimensions(dimensions) {
|
|
49195
|
-
|
|
49178
|
+
const heightValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.height) != null &&
|
|
49196
49179
|
Number.isFinite(dimensions.height) &&
|
|
49197
49180
|
dimensions.height > 0;
|
|
49198
|
-
|
|
49181
|
+
const widthValid = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) != null &&
|
|
49199
49182
|
Number.isFinite(dimensions.width) &&
|
|
49200
49183
|
dimensions.width > 0;
|
|
49201
49184
|
return heightValid && widthValid;
|
|
@@ -49204,19 +49187,19 @@ function validateNumber(number) {
|
|
|
49204
49187
|
return number != null && Number.isFinite(number);
|
|
49205
49188
|
}
|
|
49206
49189
|
function validatePoint(point) {
|
|
49207
|
-
|
|
49208
|
-
|
|
49190
|
+
const xValid = (point === null || point === void 0 ? void 0 : point.x) != null && Number.isFinite(point.x);
|
|
49191
|
+
const yValid = (point === null || point === void 0 ? void 0 : point.y) != null && Number.isFinite(point.y);
|
|
49209
49192
|
return xValid && yValid;
|
|
49210
49193
|
}
|
|
49211
49194
|
function validateVector(vector, verifyNonZeroLength) {
|
|
49212
|
-
|
|
49213
|
-
|
|
49214
|
-
|
|
49215
|
-
|
|
49195
|
+
const xValid = (vector === null || vector === void 0 ? void 0 : vector.x) != null && Number.isFinite(vector.x);
|
|
49196
|
+
const yValid = (vector === null || vector === void 0 ? void 0 : vector.y) != null && Number.isFinite(vector.y);
|
|
49197
|
+
const zValid = (vector === null || vector === void 0 ? void 0 : vector.z) != null && Number.isFinite(vector.z);
|
|
49198
|
+
const vectorComponentsValid = xValid && yValid && zValid;
|
|
49216
49199
|
if (verifyNonZeroLength) {
|
|
49217
49200
|
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) {
|
|
49218
|
-
|
|
49219
|
-
|
|
49201
|
+
const vectorMagnitudeSquared = vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
|
|
49202
|
+
const vectorHasNonZeroLength = vectorMagnitudeSquared !== 0;
|
|
49220
49203
|
return vectorComponentsValid && vectorHasNonZeroLength;
|
|
49221
49204
|
}
|
|
49222
49205
|
else {
|
|
@@ -49227,91 +49210,81 @@ function validateVector(vector, verifyNonZeroLength) {
|
|
|
49227
49210
|
return vectorComponentsValid;
|
|
49228
49211
|
}
|
|
49229
49212
|
|
|
49230
|
-
|
|
49231
|
-
|
|
49232
|
-
var _this = this;
|
|
49213
|
+
class WebSocketClientImpl {
|
|
49214
|
+
constructor() {
|
|
49233
49215
|
this.listeners = {};
|
|
49234
49216
|
this.onMessageDispatcher = new EventDispatcher();
|
|
49235
49217
|
this.onCloseDispatcher = new EventDispatcher();
|
|
49236
|
-
this.addWebSocketListeners =
|
|
49237
|
-
|
|
49238
|
-
|
|
49239
|
-
|
|
49240
|
-
ws.addEventListener('message',
|
|
49218
|
+
this.addWebSocketListeners = (ws, wsId, resolve, reject) => {
|
|
49219
|
+
const onOpen = () => this.onOpen(resolve);
|
|
49220
|
+
const onError = () => reject();
|
|
49221
|
+
const onClose = (event) => this.handleClose(event, wsId);
|
|
49222
|
+
ws.addEventListener('message', this.handleMessage);
|
|
49241
49223
|
ws.addEventListener('open', onOpen);
|
|
49242
49224
|
ws.addEventListener('error', onError);
|
|
49243
49225
|
ws.addEventListener('close', onClose);
|
|
49244
49226
|
return {
|
|
49245
|
-
dispose:
|
|
49246
|
-
ws.removeEventListener('message',
|
|
49227
|
+
dispose: () => {
|
|
49228
|
+
ws.removeEventListener('message', this.handleMessage);
|
|
49247
49229
|
ws.removeEventListener('open', onOpen);
|
|
49248
49230
|
ws.removeEventListener('error', onError);
|
|
49249
49231
|
ws.removeEventListener('close', onClose);
|
|
49250
49232
|
},
|
|
49251
49233
|
};
|
|
49252
49234
|
};
|
|
49253
|
-
this.handleMessage =
|
|
49254
|
-
|
|
49235
|
+
this.handleMessage = (event) => {
|
|
49236
|
+
this.onMessageDispatcher.emit(event);
|
|
49255
49237
|
};
|
|
49256
|
-
this.handleClose =
|
|
49257
|
-
|
|
49258
|
-
|
|
49238
|
+
this.handleClose = (event, webSocketId) => {
|
|
49239
|
+
this.onCloseDispatcher.emit(event);
|
|
49240
|
+
this.removeWebSocketListeners(webSocketId);
|
|
49259
49241
|
};
|
|
49260
49242
|
}
|
|
49261
|
-
|
|
49243
|
+
close() {
|
|
49262
49244
|
if (this.webSocket != null) {
|
|
49263
49245
|
this.webSocket.close();
|
|
49264
49246
|
}
|
|
49265
|
-
}
|
|
49266
|
-
|
|
49267
|
-
|
|
49268
|
-
|
|
49269
|
-
|
|
49270
|
-
|
|
49271
|
-
|
|
49272
|
-
|
|
49273
|
-
|
|
49274
|
-
|
|
49275
|
-
|
|
49276
|
-
|
|
49277
|
-
this.
|
|
49278
|
-
|
|
49279
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
49280
|
-
if (_this.webSocket != null) {
|
|
49281
|
-
_this.listeners[id] = _this.addWebSocketListeners(_this.webSocket, id, resolve, reject);
|
|
49282
|
-
}
|
|
49283
|
-
})];
|
|
49284
|
-
});
|
|
49247
|
+
}
|
|
49248
|
+
async connect(descriptor) {
|
|
49249
|
+
const id = UUID.create();
|
|
49250
|
+
// Ensure that any existing websocket connection has been closed prior
|
|
49251
|
+
// to opening a new one to ensure we don't leave open connections.
|
|
49252
|
+
if (this.webSocket != null) {
|
|
49253
|
+
this.close();
|
|
49254
|
+
}
|
|
49255
|
+
this.webSocket = new WebSocket(descriptor.url, descriptor.protocols);
|
|
49256
|
+
this.webSocket.binaryType = 'arraybuffer';
|
|
49257
|
+
return new Promise((resolve, reject) => {
|
|
49258
|
+
if (this.webSocket != null) {
|
|
49259
|
+
this.listeners[id] = this.addWebSocketListeners(this.webSocket, id, resolve, reject);
|
|
49260
|
+
}
|
|
49285
49261
|
});
|
|
49286
|
-
}
|
|
49287
|
-
|
|
49262
|
+
}
|
|
49263
|
+
onMessage(handler) {
|
|
49288
49264
|
return this.onMessageDispatcher.on(handler);
|
|
49289
|
-
}
|
|
49290
|
-
|
|
49265
|
+
}
|
|
49266
|
+
onClose(handler) {
|
|
49291
49267
|
return this.onCloseDispatcher.on(handler);
|
|
49292
|
-
}
|
|
49293
|
-
|
|
49268
|
+
}
|
|
49269
|
+
send(data) {
|
|
49294
49270
|
if (this.webSocket != null) {
|
|
49295
49271
|
this.webSocket.send(data);
|
|
49296
49272
|
}
|
|
49297
|
-
}
|
|
49298
|
-
|
|
49273
|
+
}
|
|
49274
|
+
removeWebSocketListeners(webSocketId) {
|
|
49299
49275
|
var _a;
|
|
49300
49276
|
(_a = this.listeners[webSocketId]) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
49301
|
-
}
|
|
49302
|
-
|
|
49277
|
+
}
|
|
49278
|
+
onOpen(resolve) {
|
|
49303
49279
|
resolve();
|
|
49304
|
-
}
|
|
49305
|
-
|
|
49306
|
-
}());
|
|
49280
|
+
}
|
|
49281
|
+
}
|
|
49307
49282
|
|
|
49308
49283
|
/**
|
|
49309
49284
|
* The API client to interact with Vertex's streaming API.
|
|
49310
49285
|
*/
|
|
49311
|
-
|
|
49312
|
-
|
|
49313
|
-
if (websocket === void 0) { websocket = new WebSocketClientImpl(); }
|
|
49314
|
-
if (opts === void 0) { opts = {}; }
|
|
49286
|
+
class StreamApi {
|
|
49287
|
+
constructor(websocket = new WebSocketClientImpl(), opts = {}) {
|
|
49315
49288
|
var _a;
|
|
49316
49289
|
this.websocket = websocket;
|
|
49317
49290
|
this.onResponseDispatcher = new EventDispatcher();
|
|
@@ -49330,60 +49303,51 @@ var StreamApi = /** @class */ (function () {
|
|
|
49330
49303
|
* a WS connection.
|
|
49331
49304
|
* @param settings A configuration to use when initializing the WS connection.
|
|
49332
49305
|
*/
|
|
49333
|
-
|
|
49334
|
-
|
|
49335
|
-
|
|
49336
|
-
|
|
49337
|
-
|
|
49338
|
-
|
|
49339
|
-
|
|
49340
|
-
|
|
49341
|
-
desc = __assign(__assign({}, descriptor), { url: appendSettingsToUrl(descriptor.url, settings) });
|
|
49342
|
-
return [4 /*yield*/, this.websocket.connect(desc)];
|
|
49343
|
-
case 1:
|
|
49344
|
-
_a.sent();
|
|
49345
|
-
this.messageSubscription = this.websocket.onMessage(function (message) {
|
|
49346
|
-
_this.handleMessage(message);
|
|
49347
|
-
});
|
|
49348
|
-
return [2 /*return*/, { dispose: function () { return _this.dispose(); } }];
|
|
49349
|
-
}
|
|
49350
|
-
});
|
|
49306
|
+
async connect(descriptor, settings = {}) {
|
|
49307
|
+
const desc = {
|
|
49308
|
+
...descriptor,
|
|
49309
|
+
url: appendSettingsToUrl(descriptor.url, settings),
|
|
49310
|
+
};
|
|
49311
|
+
await this.websocket.connect(desc);
|
|
49312
|
+
this.messageSubscription = this.websocket.onMessage((message) => {
|
|
49313
|
+
this.handleMessage(message);
|
|
49351
49314
|
});
|
|
49352
|
-
|
|
49315
|
+
return { dispose: () => this.dispose() };
|
|
49316
|
+
}
|
|
49353
49317
|
/**
|
|
49354
49318
|
* Closes any open WS connections and disposes of resources.
|
|
49355
49319
|
*/
|
|
49356
|
-
|
|
49320
|
+
dispose() {
|
|
49357
49321
|
var _a;
|
|
49358
49322
|
this.websocket.close();
|
|
49359
49323
|
(_a = this.messageSubscription) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
49360
|
-
}
|
|
49324
|
+
}
|
|
49361
49325
|
/**
|
|
49362
49326
|
* Adds a callback that is invoked when the client receives a request from the
|
|
49363
49327
|
* server. Returns a `Disposable` that can be used to remove the listener.
|
|
49364
49328
|
*
|
|
49365
49329
|
* @param handler A handler function.
|
|
49366
49330
|
*/
|
|
49367
|
-
|
|
49331
|
+
onRequest(handler) {
|
|
49368
49332
|
return this.onRequestDispatcher.on(handler);
|
|
49369
|
-
}
|
|
49333
|
+
}
|
|
49370
49334
|
/**
|
|
49371
49335
|
* Adds a callback that is invoked when the client receives an event from the
|
|
49372
49336
|
* server. Returns a `Disposable` that can be used to remove the listener.
|
|
49373
49337
|
*
|
|
49374
49338
|
* @param handler - A handler function.
|
|
49375
49339
|
*/
|
|
49376
|
-
|
|
49340
|
+
onEvent(handler) {
|
|
49377
49341
|
return this.onEventDispatcher.on(handler);
|
|
49378
|
-
}
|
|
49342
|
+
}
|
|
49379
49343
|
/**
|
|
49380
49344
|
* Adds a callback that is invoked when the websocket connection is closed.
|
|
49381
49345
|
*
|
|
49382
49346
|
* @param handler A handler function.
|
|
49383
49347
|
*/
|
|
49384
|
-
|
|
49348
|
+
onClose(handler) {
|
|
49385
49349
|
return this.websocket.onClose(handler);
|
|
49386
|
-
}
|
|
49350
|
+
}
|
|
49387
49351
|
/**
|
|
49388
49352
|
* Sends a request to initiate a streaming session.
|
|
49389
49353
|
*
|
|
@@ -49400,10 +49364,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49400
49364
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49401
49365
|
* Defaults to `true`.
|
|
49402
49366
|
*/
|
|
49403
|
-
|
|
49404
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49367
|
+
startStream(payload, withResponse = true) {
|
|
49405
49368
|
return this.sendRequest({ startStream: payload }, withResponse);
|
|
49406
|
-
}
|
|
49369
|
+
}
|
|
49407
49370
|
/**
|
|
49408
49371
|
* Sends a request to reconnect to an existing streaming session.
|
|
49409
49372
|
*
|
|
@@ -49420,22 +49383,12 @@ var StreamApi = /** @class */ (function () {
|
|
|
49420
49383
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49421
49384
|
* Defaults to `true`.
|
|
49422
49385
|
*/
|
|
49423
|
-
|
|
49424
|
-
|
|
49425
|
-
|
|
49426
|
-
|
|
49427
|
-
|
|
49428
|
-
|
|
49429
|
-
});
|
|
49430
|
-
};
|
|
49431
|
-
StreamApi.prototype.updateStream = function (payload, withResponse) {
|
|
49432
|
-
if (withResponse === void 0) { withResponse = false; }
|
|
49433
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
49434
|
-
return __generator(this, function (_a) {
|
|
49435
|
-
return [2 /*return*/, this.sendRequest({ updateStream: payload }, withResponse)];
|
|
49436
|
-
});
|
|
49437
|
-
});
|
|
49438
|
-
};
|
|
49386
|
+
async reconnect(payload, withResponse = true) {
|
|
49387
|
+
return this.sendRequest({ reconnect: payload }, withResponse);
|
|
49388
|
+
}
|
|
49389
|
+
async updateStream(payload, withResponse = false) {
|
|
49390
|
+
return this.sendRequest({ updateStream: payload }, withResponse);
|
|
49391
|
+
}
|
|
49439
49392
|
/**
|
|
49440
49393
|
* Sends a request to signal to the rendering pipeline that an interaction has
|
|
49441
49394
|
* started. The rendering pipeline will use this as a hint to perform more
|
|
@@ -49451,11 +49404,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49451
49404
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49452
49405
|
* Defaults to `true`.
|
|
49453
49406
|
*/
|
|
49454
|
-
|
|
49455
|
-
if (payload === void 0) { payload = {}; }
|
|
49456
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49407
|
+
beginInteraction(payload = {}, withResponse = true) {
|
|
49457
49408
|
return this.sendRequest({ beginInteraction: payload }, withResponse);
|
|
49458
|
-
}
|
|
49409
|
+
}
|
|
49459
49410
|
/**
|
|
49460
49411
|
* Sends a request to update the position of the scene's camera.
|
|
49461
49412
|
*
|
|
@@ -49472,18 +49423,17 @@ var StreamApi = /** @class */ (function () {
|
|
|
49472
49423
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49473
49424
|
* Defaults to `true`.
|
|
49474
49425
|
*/
|
|
49475
|
-
|
|
49476
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49426
|
+
replaceCamera(payload, withResponse = true) {
|
|
49477
49427
|
// If a camera is provided, verify it is valid
|
|
49478
49428
|
if (payload.camera != null) {
|
|
49479
|
-
|
|
49429
|
+
const cameraIsValid = validateCamera(payload.camera);
|
|
49480
49430
|
if (!cameraIsValid) {
|
|
49481
49431
|
console.warn('Invalid camera provided. Canceling replaceCamera operation.');
|
|
49482
49432
|
return Promise.resolve({});
|
|
49483
49433
|
}
|
|
49484
49434
|
}
|
|
49485
49435
|
return this.sendRequest({ updateCamera: payload }, withResponse);
|
|
49486
|
-
}
|
|
49436
|
+
}
|
|
49487
49437
|
/**
|
|
49488
49438
|
* Sends a request to update the position of the scene's camera as a fly operation
|
|
49489
49439
|
*
|
|
@@ -49499,11 +49449,10 @@ var StreamApi = /** @class */ (function () {
|
|
|
49499
49449
|
* @param payload
|
|
49500
49450
|
* @param withResponse
|
|
49501
49451
|
*/
|
|
49502
|
-
|
|
49503
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49452
|
+
flyTo(payload, withResponse = true) {
|
|
49504
49453
|
// If a bounding box is provided, verify it is valid
|
|
49505
49454
|
if (payload.boundingBox != null) {
|
|
49506
|
-
|
|
49455
|
+
const validBoundingBox = validateBoundingBox(payload.boundingBox);
|
|
49507
49456
|
if (!validBoundingBox) {
|
|
49508
49457
|
console.warn('Invalid bounding box provided. Canceling flyTo operation.');
|
|
49509
49458
|
return Promise.resolve({});
|
|
@@ -49511,7 +49460,7 @@ var StreamApi = /** @class */ (function () {
|
|
|
49511
49460
|
}
|
|
49512
49461
|
// If a camera is provided, verify it is valid
|
|
49513
49462
|
if (payload.camera != null) {
|
|
49514
|
-
|
|
49463
|
+
const cameraIsValid = validateCamera(payload.camera);
|
|
49515
49464
|
if (!cameraIsValid) {
|
|
49516
49465
|
console.warn('Invalid camera provided. Canceling flyTo operation.');
|
|
49517
49466
|
return Promise.resolve({});
|
|
@@ -49519,14 +49468,14 @@ var StreamApi = /** @class */ (function () {
|
|
|
49519
49468
|
}
|
|
49520
49469
|
// If a base camera is provided, verify it is valid
|
|
49521
49470
|
if (payload.baseCamera != null) {
|
|
49522
|
-
|
|
49471
|
+
const baseCameraIsValid = validateCamera(payload.baseCamera);
|
|
49523
49472
|
if (!baseCameraIsValid) {
|
|
49524
49473
|
console.warn('Invalid base camera provided. Canceling flyTo operation.');
|
|
49525
49474
|
return Promise.resolve({});
|
|
49526
49475
|
}
|
|
49527
49476
|
}
|
|
49528
49477
|
return this.sendRequest({ flyTo: payload }, withResponse);
|
|
49529
|
-
}
|
|
49478
|
+
}
|
|
49530
49479
|
/**
|
|
49531
49480
|
* Sends a request to update the specified interaction.
|
|
49532
49481
|
*
|
|
@@ -49538,10 +49487,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49538
49487
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49539
49488
|
* Defaults to `true`.
|
|
49540
49489
|
*/
|
|
49541
|
-
|
|
49542
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49490
|
+
updateInteraction(payload, withResponse = true) {
|
|
49543
49491
|
return this.sendRequest({ updateInteraction: payload }, withResponse);
|
|
49544
|
-
}
|
|
49492
|
+
}
|
|
49545
49493
|
/**
|
|
49546
49494
|
* Sends a request to update the dimensions of the frame.
|
|
49547
49495
|
*
|
|
@@ -49558,18 +49506,17 @@ var StreamApi = /** @class */ (function () {
|
|
|
49558
49506
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49559
49507
|
* Defaults to `true`.
|
|
49560
49508
|
*/
|
|
49561
|
-
|
|
49562
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49509
|
+
updateDimensions(payload, withResponse = true) {
|
|
49563
49510
|
// Verify the provided dimensions are valid
|
|
49564
49511
|
if (payload.dimensions != null) {
|
|
49565
|
-
|
|
49512
|
+
const validDimensions = validateDimensions(payload.dimensions);
|
|
49566
49513
|
if (!validDimensions) {
|
|
49567
49514
|
console.warn('Invalid dimensions provided. Canceling updateDimensions operation.');
|
|
49568
49515
|
return Promise.resolve({});
|
|
49569
49516
|
}
|
|
49570
49517
|
}
|
|
49571
49518
|
return this.sendRequest({ updateDimensions: payload }, withResponse);
|
|
49572
|
-
}
|
|
49519
|
+
}
|
|
49573
49520
|
/**
|
|
49574
49521
|
* Sends a request to update the cross sectioning planes of the frame.
|
|
49575
49522
|
*
|
|
@@ -49586,13 +49533,12 @@ var StreamApi = /** @class */ (function () {
|
|
|
49586
49533
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49587
49534
|
* Defaults to `true`.
|
|
49588
49535
|
*/
|
|
49589
|
-
|
|
49536
|
+
updateCrossSectioning(payload, withResponse = true) {
|
|
49590
49537
|
var _a, _b;
|
|
49591
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49592
49538
|
// If a section plane is provided, verify it is valid
|
|
49593
|
-
|
|
49594
|
-
|
|
49595
|
-
|
|
49539
|
+
const invalidSectionPlane = (_b = (_a = payload.crossSectioning) === null || _a === void 0 ? void 0 : _a.sectionPlanes) === null || _b === void 0 ? void 0 : _b.some((plane) => {
|
|
49540
|
+
const validNormal = plane.normal != null && validateVector(plane.normal, true);
|
|
49541
|
+
const validOffset = plane.offset != null && validateNumber(plane.offset);
|
|
49596
49542
|
return !validNormal || !validOffset;
|
|
49597
49543
|
});
|
|
49598
49544
|
if (invalidSectionPlane) {
|
|
@@ -49600,7 +49546,7 @@ var StreamApi = /** @class */ (function () {
|
|
|
49600
49546
|
return Promise.resolve({});
|
|
49601
49547
|
}
|
|
49602
49548
|
return this.sendRequest({ updateCrossSectioning: payload }, withResponse);
|
|
49603
|
-
}
|
|
49549
|
+
}
|
|
49604
49550
|
/**
|
|
49605
49551
|
* Sends a request to set or clear the model view of the frame.
|
|
49606
49552
|
*
|
|
@@ -49617,10 +49563,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49617
49563
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49618
49564
|
* Defaults to `true`.
|
|
49619
49565
|
*/
|
|
49620
|
-
|
|
49621
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49566
|
+
updateModelView(payload, withResponse = true) {
|
|
49622
49567
|
return this.sendRequest({ updateModelView: payload }, withResponse);
|
|
49623
|
-
}
|
|
49568
|
+
}
|
|
49624
49569
|
/**
|
|
49625
49570
|
* Sends a request to perform hit detection.
|
|
49626
49571
|
*
|
|
@@ -49632,18 +49577,17 @@ var StreamApi = /** @class */ (function () {
|
|
|
49632
49577
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49633
49578
|
* Defaults to `true`.
|
|
49634
49579
|
*/
|
|
49635
|
-
|
|
49636
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49580
|
+
hitItems(payload, withResponse = true) {
|
|
49637
49581
|
// If a point is provided, verify it is valid
|
|
49638
49582
|
if (payload.point != null) {
|
|
49639
|
-
|
|
49583
|
+
const validPoint = validatePoint(payload.point);
|
|
49640
49584
|
if (!validPoint) {
|
|
49641
49585
|
console.warn('Invalid point provided. Canceling hitItems operation.');
|
|
49642
49586
|
return Promise.resolve({});
|
|
49643
49587
|
}
|
|
49644
49588
|
}
|
|
49645
49589
|
return this.sendRequest({ hitItems: payload }, withResponse);
|
|
49646
|
-
}
|
|
49590
|
+
}
|
|
49647
49591
|
/**
|
|
49648
49592
|
* Sends a request to perform an alteration to a scene. Alterations include
|
|
49649
49593
|
* changing item visibility and changing the materials of items.
|
|
@@ -49656,10 +49600,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49656
49600
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49657
49601
|
* Defaults to `true`.
|
|
49658
49602
|
*/
|
|
49659
|
-
|
|
49660
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49603
|
+
createSceneAlteration(payload, withResponse = true) {
|
|
49661
49604
|
return this.sendRequest({ createSceneAlteration: payload }, withResponse);
|
|
49662
|
-
}
|
|
49605
|
+
}
|
|
49663
49606
|
/**
|
|
49664
49607
|
* Sends a request to reset all overrides for a given scene and optionally to
|
|
49665
49608
|
* reset the camera to that of the base scene.
|
|
@@ -49672,10 +49615,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49672
49615
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49673
49616
|
* Defaults to `true`.
|
|
49674
49617
|
*/
|
|
49675
|
-
|
|
49676
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49618
|
+
resetSceneView(payload, withResponse = true) {
|
|
49677
49619
|
return this.sendRequest({ resetView: payload }, withResponse);
|
|
49678
|
-
}
|
|
49620
|
+
}
|
|
49679
49621
|
/**
|
|
49680
49622
|
* Sends a request to tell the rendering pipeline that an interaction has
|
|
49681
49623
|
* ended.
|
|
@@ -49687,11 +49629,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49687
49629
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49688
49630
|
* Defaults to `true`.
|
|
49689
49631
|
*/
|
|
49690
|
-
|
|
49691
|
-
if (payload === void 0) { payload = {}; }
|
|
49692
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49632
|
+
endInteraction(payload = {}, withResponse = true) {
|
|
49693
49633
|
return this.sendRequest({ endInteraction: payload }, withResponse);
|
|
49694
|
-
}
|
|
49634
|
+
}
|
|
49695
49635
|
/**
|
|
49696
49636
|
* Sends a request to sync the clocks between the client and server.
|
|
49697
49637
|
*
|
|
@@ -49703,10 +49643,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49703
49643
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49704
49644
|
* Defaults to `true`.
|
|
49705
49645
|
*/
|
|
49706
|
-
|
|
49707
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49646
|
+
syncTime(payload, withResponse = true) {
|
|
49708
49647
|
return this.sendRequest({ syncTime: payload }, withResponse);
|
|
49709
|
-
}
|
|
49648
|
+
}
|
|
49710
49649
|
/**
|
|
49711
49650
|
* Sends a request to record performance timings that were measured in the
|
|
49712
49651
|
* client. The server may use these timings as hints to optimize the rendering
|
|
@@ -49720,10 +49659,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49720
49659
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49721
49660
|
* Defaults to `true`.
|
|
49722
49661
|
*/
|
|
49723
|
-
|
|
49724
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49662
|
+
recordPerformance(payload, withResponse = true) {
|
|
49725
49663
|
return this.sendRequest({ recordPerformance: payload }, withResponse);
|
|
49726
|
-
}
|
|
49664
|
+
}
|
|
49727
49665
|
/**
|
|
49728
49666
|
* Sends a request to update the current scene view with the state present
|
|
49729
49667
|
* in the specified scene view state.
|
|
@@ -49735,17 +49673,15 @@ var StreamApi = /** @class */ (function () {
|
|
|
49735
49673
|
* @param payload
|
|
49736
49674
|
* @param withResponse
|
|
49737
49675
|
*/
|
|
49738
|
-
|
|
49739
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49676
|
+
loadSceneViewState(payload, withResponse = true) {
|
|
49740
49677
|
return this.sendRequest({ loadSceneViewState: payload }, withResponse);
|
|
49741
|
-
}
|
|
49678
|
+
}
|
|
49742
49679
|
/**
|
|
49743
49680
|
* Sends a request to get a stencil buffer image for the current scene view.
|
|
49744
49681
|
*/
|
|
49745
|
-
|
|
49746
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49682
|
+
getStencilBuffer(payload, withResponse = true) {
|
|
49747
49683
|
return this.sendRequest({ getStencilBuffer: payload }, withResponse);
|
|
49748
|
-
}
|
|
49684
|
+
}
|
|
49749
49685
|
/**
|
|
49750
49686
|
* Sends a request to retrieve a new token. This token can be used to
|
|
49751
49687
|
* authenticate with other Vertex services.
|
|
@@ -49753,10 +49689,9 @@ var StreamApi = /** @class */ (function () {
|
|
|
49753
49689
|
* @param withResponse Indicates if the server should reply with a response.
|
|
49754
49690
|
* @returns A promise that completes with the refreshed token.
|
|
49755
49691
|
*/
|
|
49756
|
-
|
|
49757
|
-
if (withResponse === void 0) { withResponse = true; }
|
|
49692
|
+
refreshToken(withResponse = true) {
|
|
49758
49693
|
return this.sendRequest({ refreshToken: {} }, withResponse);
|
|
49759
|
-
}
|
|
49694
|
+
}
|
|
49760
49695
|
/**
|
|
49761
49696
|
* Acknowledges a successful request by sending a reply back to the server
|
|
49762
49697
|
* with an optional result body.
|
|
@@ -49764,20 +49699,20 @@ var StreamApi = /** @class */ (function () {
|
|
|
49764
49699
|
* @param reqId The ID of the received request.
|
|
49765
49700
|
* @param result A result to reply with.
|
|
49766
49701
|
*/
|
|
49767
|
-
|
|
49768
|
-
this.sendResponse(
|
|
49769
|
-
}
|
|
49702
|
+
replyResult(reqId, result) {
|
|
49703
|
+
this.sendResponse({ requestId: { value: reqId }, ...result });
|
|
49704
|
+
}
|
|
49770
49705
|
/**
|
|
49771
49706
|
* Acknowledges a failed request by sending a reply back to the server.
|
|
49772
49707
|
*
|
|
49773
49708
|
* @param reqId The ID of the received request.
|
|
49774
49709
|
* @param error An error to reply with.
|
|
49775
49710
|
*/
|
|
49776
|
-
|
|
49777
|
-
this.sendResponse({ requestId: { value: reqId }, error
|
|
49778
|
-
}
|
|
49779
|
-
|
|
49780
|
-
|
|
49711
|
+
replyError(reqId, error) {
|
|
49712
|
+
this.sendResponse({ requestId: { value: reqId }, error });
|
|
49713
|
+
}
|
|
49714
|
+
handleMessage(message) {
|
|
49715
|
+
const msg = decode(message.data);
|
|
49781
49716
|
this.log('WS message received', msg);
|
|
49782
49717
|
if ((msg === null || msg === void 0 ? void 0 : msg.sentAtTime) != null) {
|
|
49783
49718
|
if (msg.response != null) {
|
|
@@ -49799,65 +49734,67 @@ var StreamApi = /** @class */ (function () {
|
|
|
49799
49734
|
});
|
|
49800
49735
|
}
|
|
49801
49736
|
}
|
|
49802
|
-
}
|
|
49803
|
-
|
|
49737
|
+
}
|
|
49738
|
+
onResponse(handler) {
|
|
49804
49739
|
return this.onResponseDispatcher.on(handler);
|
|
49805
|
-
}
|
|
49806
|
-
|
|
49807
|
-
var other = [];
|
|
49808
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
49809
|
-
other[_i - 1] = arguments[_i];
|
|
49810
|
-
}
|
|
49740
|
+
}
|
|
49741
|
+
log(msg, ...other) {
|
|
49811
49742
|
if (this.opts.loggingEnabled) {
|
|
49812
|
-
console.debug
|
|
49743
|
+
console.debug(msg, ...other);
|
|
49813
49744
|
}
|
|
49814
|
-
}
|
|
49815
|
-
|
|
49816
|
-
|
|
49817
|
-
var sentAtTime = currentDateAsProtoTimestamp();
|
|
49745
|
+
}
|
|
49746
|
+
sendRequest(req, withResponse) {
|
|
49747
|
+
const sentAtTime = currentDateAsProtoTimestamp();
|
|
49818
49748
|
if (withResponse) {
|
|
49819
|
-
|
|
49820
|
-
|
|
49821
|
-
return new Promise(
|
|
49822
|
-
|
|
49749
|
+
const requestId = UUID.create();
|
|
49750
|
+
const request = { ...req, requestId: { value: requestId } };
|
|
49751
|
+
return new Promise((resolve, reject) => {
|
|
49752
|
+
const subscription = this.onResponse((msg) => {
|
|
49823
49753
|
var _a;
|
|
49824
|
-
if (
|
|
49754
|
+
if (requestId === ((_a = msg.response.requestId) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
49825
49755
|
if (msg.response.error == null) {
|
|
49826
49756
|
resolve(msg.response);
|
|
49827
49757
|
}
|
|
49828
49758
|
else {
|
|
49829
|
-
|
|
49830
|
-
reject(new StreamRequestError(
|
|
49759
|
+
const { message: summary, details } = msg.response.error;
|
|
49760
|
+
reject(new StreamRequestError(requestId, req, summary === null || summary === void 0 ? void 0 : summary.value, details === null || details === void 0 ? void 0 : details.value));
|
|
49831
49761
|
}
|
|
49832
49762
|
subscription.dispose();
|
|
49833
49763
|
}
|
|
49834
49764
|
});
|
|
49835
|
-
|
|
49765
|
+
this.sendMessage({ sentAtTime, request });
|
|
49836
49766
|
});
|
|
49837
49767
|
}
|
|
49838
|
-
this.sendMessage({ sentAtTime
|
|
49768
|
+
this.sendMessage({ sentAtTime, request: req });
|
|
49839
49769
|
return Promise.resolve({});
|
|
49840
|
-
}
|
|
49841
|
-
|
|
49770
|
+
}
|
|
49771
|
+
sendMessage(msg) {
|
|
49842
49772
|
this.websocket.send(encode(msg));
|
|
49843
49773
|
this.log('WS message sent', msg);
|
|
49844
|
-
}
|
|
49845
|
-
|
|
49846
|
-
|
|
49847
|
-
this.websocket.send(encode({ sentAtTime
|
|
49848
|
-
}
|
|
49849
|
-
|
|
49850
|
-
}());
|
|
49774
|
+
}
|
|
49775
|
+
sendResponse(response) {
|
|
49776
|
+
const sentAtTime = currentDateAsProtoTimestamp();
|
|
49777
|
+
this.websocket.send(encode({ sentAtTime, response }));
|
|
49778
|
+
}
|
|
49779
|
+
}
|
|
49851
49780
|
|
|
49852
49781
|
function event(req, meta) {
|
|
49853
|
-
return
|
|
49782
|
+
return {
|
|
49783
|
+
sentAtTime: currentDateAsProtoTimestamp(),
|
|
49784
|
+
event: {
|
|
49785
|
+
...req,
|
|
49786
|
+
},
|
|
49787
|
+
...meta,
|
|
49788
|
+
};
|
|
49854
49789
|
}
|
|
49855
49790
|
function animationCompleted(id) {
|
|
49856
|
-
|
|
49791
|
+
const def = {
|
|
49857
49792
|
animationId: { hex: id },
|
|
49858
49793
|
};
|
|
49859
49794
|
return event({
|
|
49860
|
-
animationCompleted:
|
|
49795
|
+
animationCompleted: {
|
|
49796
|
+
...def,
|
|
49797
|
+
},
|
|
49861
49798
|
});
|
|
49862
49799
|
}
|
|
49863
49800
|
|
|
@@ -49867,11 +49804,17 @@ var events = /*#__PURE__*/Object.freeze({
|
|
|
49867
49804
|
});
|
|
49868
49805
|
|
|
49869
49806
|
function request(req, meta) {
|
|
49870
|
-
return
|
|
49807
|
+
return {
|
|
49808
|
+
sentAtTime: currentDateAsProtoTimestamp(),
|
|
49809
|
+
...meta,
|
|
49810
|
+
request: {
|
|
49811
|
+
requestId: req.requestId != null ? { value: req.requestId } : undefined,
|
|
49812
|
+
...req.payload,
|
|
49813
|
+
},
|
|
49814
|
+
};
|
|
49871
49815
|
}
|
|
49872
|
-
function drawFrame(req, meta) {
|
|
49873
|
-
|
|
49874
|
-
var def = {
|
|
49816
|
+
function drawFrame(req = {}, meta) {
|
|
49817
|
+
const def = {
|
|
49875
49818
|
sequenceNumber: 1,
|
|
49876
49819
|
sceneAttributes: {
|
|
49877
49820
|
camera: {
|
|
@@ -49912,9 +49855,8 @@ function drawFrame(req, meta) {
|
|
|
49912
49855
|
payload: { drawFrame: Objects.defaults(req.payload, def) },
|
|
49913
49856
|
}, meta);
|
|
49914
49857
|
}
|
|
49915
|
-
function gracefulReconnect(req, meta) {
|
|
49916
|
-
|
|
49917
|
-
var def = {
|
|
49858
|
+
function gracefulReconnect(req = {}, meta) {
|
|
49859
|
+
const def = {
|
|
49918
49860
|
streamId: { hex: UUID.create() },
|
|
49919
49861
|
timeToReconnectDuration: { seconds: 1, nanos: 0 },
|
|
49920
49862
|
};
|
|
@@ -49931,11 +49873,17 @@ var requests = /*#__PURE__*/Object.freeze({
|
|
|
49931
49873
|
});
|
|
49932
49874
|
|
|
49933
49875
|
function response(res, meta) {
|
|
49934
|
-
return
|
|
49876
|
+
return {
|
|
49877
|
+
sentAtTime: currentDateAsProtoTimestamp(),
|
|
49878
|
+
...meta,
|
|
49879
|
+
response: {
|
|
49880
|
+
requestId: res.requestId != null ? { value: res.requestId } : undefined,
|
|
49881
|
+
...res.result,
|
|
49882
|
+
},
|
|
49883
|
+
};
|
|
49935
49884
|
}
|
|
49936
|
-
function startStream(res, meta) {
|
|
49937
|
-
|
|
49938
|
-
var def = {
|
|
49885
|
+
function startStream(res = {}, meta) {
|
|
49886
|
+
const def = {
|
|
49939
49887
|
streamId: { hex: UUID.create() },
|
|
49940
49888
|
sceneId: { hex: UUID.create() },
|
|
49941
49889
|
sceneViewId: { hex: UUID.create() },
|
|
@@ -49952,17 +49900,15 @@ function startStream(res, meta) {
|
|
|
49952
49900
|
result: { startStream: Objects.defaults(res.result, def) },
|
|
49953
49901
|
}, meta);
|
|
49954
49902
|
}
|
|
49955
|
-
function syncTime(res, meta) {
|
|
49956
|
-
|
|
49957
|
-
var def = { replyTime: { seconds: 1, nanos: 0 } };
|
|
49903
|
+
function syncTime(res = {}, meta) {
|
|
49904
|
+
const def = { replyTime: { seconds: 1, nanos: 0 } };
|
|
49958
49905
|
return response({
|
|
49959
49906
|
requestId: res.requestId,
|
|
49960
49907
|
result: { syncTime: Objects.defaults(res.result, def) },
|
|
49961
49908
|
});
|
|
49962
49909
|
}
|
|
49963
|
-
function reconnect(res, meta) {
|
|
49964
|
-
|
|
49965
|
-
var def = {
|
|
49910
|
+
function reconnect(res = {}, meta) {
|
|
49911
|
+
const def = {
|
|
49966
49912
|
jwt: 'jwt',
|
|
49967
49913
|
token: { token: 'token', expiresIn: new Date().getTime() + 10000 },
|
|
49968
49914
|
};
|
|
@@ -49971,17 +49917,15 @@ function reconnect(res, meta) {
|
|
|
49971
49917
|
result: { reconnect: Objects.defaults(res.result, def) },
|
|
49972
49918
|
}, meta);
|
|
49973
49919
|
}
|
|
49974
|
-
function loadSceneViewState(res, meta) {
|
|
49975
|
-
|
|
49976
|
-
var def = {};
|
|
49920
|
+
function loadSceneViewState(res = {}, meta) {
|
|
49921
|
+
const def = {};
|
|
49977
49922
|
return response({
|
|
49978
49923
|
requestId: res.requestId,
|
|
49979
49924
|
result: { loadSceneViewState: Objects.defaults(res.result, def) },
|
|
49980
49925
|
}, meta);
|
|
49981
49926
|
}
|
|
49982
|
-
function refreshToken(res, meta) {
|
|
49983
|
-
|
|
49984
|
-
var def = {
|
|
49927
|
+
function refreshToken(res = {}, meta) {
|
|
49928
|
+
const def = {
|
|
49985
49929
|
token: { token: 'token', expiresIn: new Date().getTime() + 10000 },
|
|
49986
49930
|
};
|
|
49987
49931
|
return response({
|
|
@@ -50006,62 +49950,58 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
50006
49950
|
Responses: responses
|
|
50007
49951
|
});
|
|
50008
49952
|
|
|
50009
|
-
|
|
50010
|
-
|
|
49953
|
+
class WebSocketClientMock {
|
|
49954
|
+
constructor() {
|
|
50011
49955
|
this.closeHandlers = new Set();
|
|
50012
49956
|
this.msgHandlers = new Set();
|
|
50013
49957
|
this.sentMessages = new Array();
|
|
50014
49958
|
}
|
|
50015
|
-
|
|
50016
|
-
this.closeHandlers.forEach(
|
|
50017
|
-
}
|
|
50018
|
-
|
|
49959
|
+
close() {
|
|
49960
|
+
this.closeHandlers.forEach((handler) => handler(new CloseEvent('close')));
|
|
49961
|
+
}
|
|
49962
|
+
connect(descriptor) {
|
|
50019
49963
|
return Promise.resolve();
|
|
50020
|
-
}
|
|
50021
|
-
|
|
50022
|
-
var _this = this;
|
|
49964
|
+
}
|
|
49965
|
+
onClose(handler) {
|
|
50023
49966
|
this.closeHandlers.add(handler);
|
|
50024
|
-
return { dispose:
|
|
50025
|
-
}
|
|
50026
|
-
|
|
50027
|
-
var _this = this;
|
|
49967
|
+
return { dispose: () => this.closeHandlers.delete(handler) };
|
|
49968
|
+
}
|
|
49969
|
+
onMessage(handler) {
|
|
50028
49970
|
this.msgHandlers.add(handler);
|
|
50029
|
-
return { dispose:
|
|
50030
|
-
}
|
|
50031
|
-
|
|
49971
|
+
return { dispose: () => this.msgHandlers.delete(handler) };
|
|
49972
|
+
}
|
|
49973
|
+
send(data) {
|
|
50032
49974
|
this.sentMessages.push(data);
|
|
50033
|
-
}
|
|
50034
|
-
|
|
49975
|
+
}
|
|
49976
|
+
reconnect(descriptor) {
|
|
50035
49977
|
return Promise.resolve();
|
|
50036
|
-
}
|
|
49978
|
+
}
|
|
50037
49979
|
/**
|
|
50038
49980
|
* Simulates a websocket message that was sent by the server and received by
|
|
50039
49981
|
* the client.
|
|
50040
49982
|
*
|
|
50041
49983
|
* @param data The websocket message data.
|
|
50042
49984
|
*/
|
|
50043
|
-
|
|
50044
|
-
this.msgHandlers.forEach(
|
|
50045
|
-
|
|
50046
|
-
});
|
|
50047
|
-
};
|
|
49985
|
+
receiveMessage(data) {
|
|
49986
|
+
this.msgHandlers.forEach((handler) => handler(new MessageEvent('message', { data })));
|
|
49987
|
+
}
|
|
50048
49988
|
/**
|
|
50049
49989
|
* Resets the internal state of the mock by clearing any accrued sent messages
|
|
50050
49990
|
* and removing all handlers.
|
|
50051
49991
|
*/
|
|
50052
|
-
|
|
49992
|
+
reset() {
|
|
50053
49993
|
this.sentMessages = [];
|
|
50054
49994
|
this.msgHandlers.clear();
|
|
50055
49995
|
this.closeHandlers.clear();
|
|
50056
|
-
}
|
|
49996
|
+
}
|
|
50057
49997
|
/**
|
|
50058
49998
|
* Returns `true` if there are remaining sent messages..
|
|
50059
49999
|
*/
|
|
50060
|
-
|
|
50000
|
+
hasNextSent() {
|
|
50061
50001
|
return this.sentMessages.length > 0;
|
|
50062
|
-
}
|
|
50063
|
-
|
|
50064
|
-
|
|
50002
|
+
}
|
|
50003
|
+
nextSent(decoder) {
|
|
50004
|
+
const next = this.sentMessages.shift();
|
|
50065
50005
|
if (next != null) {
|
|
50066
50006
|
if (decoder != null) {
|
|
50067
50007
|
return decoder(next);
|
|
@@ -50073,7 +50013,7 @@ var WebSocketClientMock = /** @class */ (function () {
|
|
|
50073
50013
|
else {
|
|
50074
50014
|
throw new Error('Sent messages is empty');
|
|
50075
50015
|
}
|
|
50076
|
-
}
|
|
50016
|
+
}
|
|
50077
50017
|
/**
|
|
50078
50018
|
* Skips the next N sent messages.
|
|
50079
50019
|
*
|
|
@@ -50090,20 +50030,18 @@ var WebSocketClientMock = /** @class */ (function () {
|
|
|
50090
50030
|
*
|
|
50091
50031
|
* @param n The number of sent messages to skip over.
|
|
50092
50032
|
*/
|
|
50093
|
-
|
|
50094
|
-
if (n === void 0) { n = 1; }
|
|
50033
|
+
skipSent(n = 1) {
|
|
50095
50034
|
if (n <= this.sentMessages.length) {
|
|
50096
|
-
for (
|
|
50035
|
+
for (let i = 0; i < n; i++) {
|
|
50097
50036
|
this.nextSent();
|
|
50098
50037
|
}
|
|
50099
50038
|
}
|
|
50100
50039
|
else {
|
|
50101
|
-
throw new Error(
|
|
50040
|
+
throw new Error(`Cannot skip the next ${n} messages. Sent message queue only has ${this.sentMessages.length} messages.`);
|
|
50102
50041
|
}
|
|
50103
50042
|
return this;
|
|
50104
|
-
}
|
|
50105
|
-
|
|
50106
|
-
}());
|
|
50043
|
+
}
|
|
50044
|
+
}
|
|
50107
50045
|
|
|
50108
50046
|
export { index as Fixtures, StreamApi, StreamRequestError, WebSocketClientImpl, WebSocketClientMock, currentDateAsProtoTimestamp, decode, encode, protoToDate, toProtoDuration, toProtoTimestamp };
|
|
50109
50047
|
//# sourceMappingURL=bundle.esm.js.map
|