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