@vertexvis/stream-api
Advanced tools
Comparing version 0.9.19-canary.7 to 0.9.19-canary.8
@@ -375,2 +375,21 @@ 'use strict'; | ||
/** | ||
* Sends a request to update the position of the scene's camera as a fly operation | ||
* | ||
* The payload accepts an optional `frameCorrelationId` that will be sent | ||
* back on the frame that is associated to this request. Use `onRequest` to | ||
* add a callback that'll be invoked when the server sends a request to draw | ||
* the frame. | ||
* | ||
* Use `withResponse` to indicate if the server should reply with a response. | ||
* If `false`, the returned promise will complete immediately. Otherwise, | ||
* it'll complete when a response is received. | ||
* | ||
* @param payload | ||
* @param withResponse | ||
*/ | ||
StreamApi.prototype.flyTo = function (payload, withResponse) { | ||
if (withResponse === void 0) { withResponse = true; } | ||
return this.sendRequest({ flyTo: payload }, withResponse); | ||
}; | ||
/** | ||
* Sends a request to update the dimensions of the frame. | ||
@@ -377,0 +396,0 @@ * |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@vertexvis/frame-streaming-protos"),n=require("tslib"),r=require("@vertexvis/utils"),s=(e=require("long"))&&"object"==typeof e&&"default"in e?e.default:e;function o(e){return t.vertexvis.protobuf.stream.StreamMessage.encode(e).finish()}function i(e){var n=e instanceof ArrayBuffer?new Uint8Array(e):e;return t.vertexvis.protobuf.stream.StreamMessage.decode(n)}var a=function(){function e(){var e=this;this.listeners={},this.onMessageDispatcher=new r.EventDispatcher,this.onCloseDispatcher=new r.EventDispatcher,this.addWebSocketListeners=function(t,n,r,s){var o=function(){return e.onOpen(r)},i=function(){return s()},a=function(t){return e.handleClose(t,n)};return t.addEventListener("message",e.handleMessage),t.addEventListener("open",o),t.addEventListener("error",i),t.addEventListener("close",a),{dispose:function(){t.removeEventListener("message",e.handleMessage),t.removeEventListener("open",o),t.removeEventListener("error",i),t.removeEventListener("close",a)}}},this.handleMessage=function(t){e.onMessageDispatcher.emit(t)},this.handleClose=function(t,n){e.onCloseDispatcher.emit(t),e.removeWebSocketListeners(n)}}return e.prototype.close=function(){null!=this.webSocket&&this.webSocket.close()},e.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,s=this;return n.__generator(this,(function(n){return t=r.UUID.create(),this.webSocket=new WebSocket(e.url,e.protocols),this.webSocket.binaryType="arraybuffer",[2,new Promise((function(e,n){null!=s.webSocket&&(s.listeners[t]=s.addWebSocketListeners(s.webSocket,t,e,n))}))]}))}))},e.prototype.onMessage=function(e){return this.onMessageDispatcher.on(e)},e.prototype.onClose=function(e){return this.onCloseDispatcher.on(e)},e.prototype.send=function(e){null!=this.webSocket&&this.webSocket.send(e)},e.prototype.removeWebSocketListeners=function(e){var t;null===(t=this.listeners[e])||void 0===t||t.dispose()},e.prototype.onOpen=function(e){e()},e}();function u(e){var n=e.getTime();return t.google.protobuf.Timestamp.create(d(n))}function c(){return u(new Date)}function d(e){return{seconds:Math.floor(e/1e3),nanos:e%1e3*1e6}}var p=function(e){function t(t,n,r,s){var o=e.call(this,null!=r&&r.length>0?"Stream request failed ("+r+")":"Stream request failed")||this;return o.requestId=t,o.requestPayload=n,o.summary=r,o.details=s,o}return n.__extends(t,e),t}(Error);function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,r){return n.__assign(n.__assign({},e),r(t))}),{})}}function f(e,t){return m(e,t,(function(e){return"boolean"==typeof e?e?"on":"off":void 0}))}function h(e,t){return m(e,t,(function(e){return"number"==typeof e?e.toString():void 0}))}function v(e,t){return m(e,t,(function(e){return"string"==typeof e?e:void 0}))}function m(e,t,n){return function(r){var s,o=n(r[t]);return null!=o?((s={})[e]=o,s):{}}}function g(e,t){var n={},s=r.Uri.parse(e),o=l(function(e){return y((function(e){return e.EXPERIMENTAL_frameDelivery}),e,l(f("frame-delivery.rate-limit-enabled","rateLimitingEnabled"),h("frame-delivery.packet-loss-threshold","packetLossThreshold"),h("frame-delivery.history-max-size","historyMaxSize"),v("frame-delivery.timeout","timeout"),h("frame-delivery.timeout-ratio-threshold","timeoutRatioThreshold")))}(n.EXPERIMENTAL_frameDelivery),function(e){return y((function(e){return e.EXPERIMENTAL_adaptiveRendering}),e,l(f("adaptive-rendering.enabled","enabled"),v("adaptive-rendering.method","method"),h("adaptive-rendering.jpeg-quality-min","jpegMinQuality"),h("adaptive-rendering.jpeg-quality-max","jpegMaxQuality"),h("adaptive-rendering.image-scale-min","imageMinScale"),h("adaptive-rendering.image-scale-max","imageMaxScale"),h("adaptive-rendering.window-size","windowSize")))}(n.EXPERIMENTAL_adaptiveRendering),function(e){return y((function(e){return e.EXPERIMENTAL_qualityOfService}),e,l(h("qos.history-max-size","historyMaxSize")))}(n.EXPERIMENTAL_qualityOfService))(t);return r.Uri.toString(r.Uri.addQueryParams(o,s))}function y(e,t,n){return function(s){var o=r.Objects.defaults(e(s)||{},t);return n(o)}}var b=function(){function e(e,t){void 0===e&&(e=new a),void 0===t&&(t=!1),this.websocket=e,this.loggingEnabled=t,this.onResponseDispatcher=new r.EventDispatcher,this.onRequestDispatcher=new r.EventDispatcher}return e.prototype.connect=function(e,t){return void 0===t&&(t={}),n.__awaiter(this,void 0,void 0,(function(){var r,s=this;return n.__generator(this,(function(o){switch(o.label){case 0:return r=n.__assign(n.__assign({},e),{url:g(e.url,t)}),[4,this.websocket.connect(r)];case 1:return o.sent(),this.messageSubscription=this.websocket.onMessage((function(e){s.handleMessage(e)})),[2,{dispose:function(){return s.dispose()}}]}}))}))},e.prototype.dispose=function(){var e;this.websocket.close(),null===(e=this.messageSubscription)||void 0===e||e.dispose()},e.prototype.onRequest=function(e){return this.onRequestDispatcher.on(e)},e.prototype.startStream=function(e,t){return void 0===t&&(t=!0),this.sendRequest({startStream:e},t)},e.prototype.reconnect=function(e,t){return void 0===t&&(t=!0),n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(n){return[2,this.sendRequest({reconnect:e},t)]}))}))},e.prototype.updateStream=function(e,t){return void 0===t&&(t=!1),n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(n){return[2,this.sendRequest({updateStream:e},t)]}))}))},e.prototype.beginInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({beginInteraction:{}},e)},e.prototype.replaceCamera=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateCamera:e},t)},e.prototype.updateDimensions=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateDimensions:e},t)},e.prototype.hitItems=function(e,t){return void 0===t&&(t=!0),this.sendRequest({hitItems:e},t)},e.prototype.createSceneAlteration=function(e,t){return void 0===t&&(t=!0),this.sendRequest({createSceneAlteration:e},t)},e.prototype.endInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({endInteraction:{}},e)},e.prototype.syncTime=function(e,t){return void 0===t&&(t=!0),this.sendRequest({syncTime:e},t)},e.prototype.recordPerformance=function(e,t){return void 0===t&&(t=!0),this.sendRequest({recordPerformance:e},t)},e.prototype.replyResult=function(e,t){this.sendResponse(n.__assign({requestId:{value:e}},t))},e.prototype.replyError=function(e,t){this.sendResponse({requestId:{value:e},error:t})},e.prototype.handleMessage=function(e){var t=i(e.data);this.log("WS message received",t),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.response)&&this.onResponseDispatcher.emit({sentAtTime:t.sentAtTime,response:t.response}),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.request)&&this.onRequestDispatcher.emit({sentAtTime:t.sentAtTime,request:t.request})},e.prototype.onResponse=function(e){return this.onResponseDispatcher.on(e)},e.prototype.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.loggingEnabled&&console.debug.apply(console,n.__spreadArrays([e],t))},e.prototype.sendRequest=function(e,t){var s=this,o=c();if(t){var i=r.UUID.create(),a=n.__assign(n.__assign({},e),{requestId:{value:i}});return new Promise((function(t,n){var r=s.onResponse((function(s){var o;if(i===(null===(o=s.response.requestId)||void 0===o?void 0:o.value)){if(null==s.response.error)t(s.response);else{var a=s.response.error,u=a.message,c=a.details;n(new p(i,e,null==u?void 0:u.value,null==c?void 0:c.value))}r.dispose()}}));s.sendMessage({sentAtTime:o,request:a})}))}return this.sendMessage({sentAtTime:o,request:e}),Promise.resolve({})},e.prototype.sendMessage=function(e){this.websocket.send(o(e)),this.log("WS message sent",e)},e.prototype.sendResponse=function(e){var t=c();this.websocket.send(o({sentAtTime:t,response:e}))},e}();function _(e,t){return n.__assign(n.__assign({sentAtTime:c()},t),{request:n.__assign({requestId:null!=e.requestId?{value:e.requestId}:void 0},e.payload)})}var q=Object.freeze({__proto__:null,drawFrame:function(e,t){void 0===e&&(e={});var n={sequenceNumber:1,sceneAttributes:{camera:{position:{x:0,y:0,z:1},lookAt:{x:0,y:0,z:0},up:{x:0,y:1,z:0}}},imageAttributes:{frameDimensions:{width:200,height:150},imageRect:{x:0,y:0,width:200,height:150},scaleFactor:1},frameCorrelationIds:["123"],image:new Uint8Array};return _({requestId:e.requestId,payload:{drawFrame:r.Objects.defaults(e.payload,n)}},t)},gracefulReconnect:function(e,t){void 0===e&&(e={});var n={streamId:{hex:r.UUID.create()},timeToReconnectDuration:{seconds:1,nanos:0}};return _({requestId:e.requestId,payload:{reconnect:r.Objects.defaults(e.payload,n)}},t)}}),w=Object.freeze({__proto__:null,Requests:q}),S=function(){function e(){this.handlers=new Set,this.sentMessages=new Array}return e.prototype.close=function(){},e.prototype.connect=function(e){return Promise.resolve()},e.prototype.onMessage=function(e){var t=this;return this.handlers.add(e),{dispose:function(){return t.handlers.delete(e)}}},e.prototype.send=function(e){this.sentMessages.push(e)},e.prototype.reconnect=function(e){return Promise.resolve()},e.prototype.receiveMessage=function(e){this.handlers.forEach((function(t){return t(new MessageEvent("message",{data:e}))}))},e.prototype.reset=function(){this.sentMessages=[],this.handlers.clear()},e.prototype.hasNextSent=function(){return this.sentMessages.length>0},e.prototype.nextSent=function(e){var t=this.sentMessages.shift();if(null!=t)return null!=e?e(t):t;throw new Error("Sent messages is empty")},e.prototype.skipSent=function(e){if(void 0===e&&(e=1),!(e<=this.sentMessages.length))throw new Error("Cannot skip the next "+e+" messages. Sent message queue only has "+this.sentMessages.length+" messages.");for(var t=0;t<e;t++)this.nextSent();return this},e}();exports.Fixtures=w,exports.StreamApi=b,exports.WebSocketClientImpl=a,exports.WebSocketClientMock=S,exports.currentDateAsProtoTimestamp=c,exports.decode=i,exports.encode=o,exports.protoToDate=function(e){if(null!=e.seconds&&null!=e.nanos){var t=s.isLong(e.seconds)?e.seconds.toNumber():e.seconds;return new Date(1e3*t+e.nanos/1e6)}},exports.toProtoDuration=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2===e.length){var r=e[0],s=e[1],o=s.getTime()-r.getTime();return t.google.protobuf.Duration.create(d(o))}if(1===e.length){o=e[0];return t.google.protobuf.Duration.create(d(o))}throw new Error("Expected input to be a number or start and end date.")},exports.toProtoTimestamp=u; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@vertexvis/frame-streaming-protos"),n=require("tslib"),r=require("@vertexvis/utils"),o=(e=require("long"))&&"object"==typeof e&&"default"in e?e.default:e;function s(e){return t.vertexvis.protobuf.stream.StreamMessage.encode(e).finish()}function i(e){var n=e instanceof ArrayBuffer?new Uint8Array(e):e;return t.vertexvis.protobuf.stream.StreamMessage.decode(n)}var a=function(){function e(){var e=this;this.listeners={},this.onMessageDispatcher=new r.EventDispatcher,this.onCloseDispatcher=new r.EventDispatcher,this.addWebSocketListeners=function(t,n,r,o){var s=function(){return e.onOpen(r)},i=function(){return o()},a=function(t){return e.handleClose(t,n)};return t.addEventListener("message",e.handleMessage),t.addEventListener("open",s),t.addEventListener("error",i),t.addEventListener("close",a),{dispose:function(){t.removeEventListener("message",e.handleMessage),t.removeEventListener("open",s),t.removeEventListener("error",i),t.removeEventListener("close",a)}}},this.handleMessage=function(t){e.onMessageDispatcher.emit(t)},this.handleClose=function(t,n){e.onCloseDispatcher.emit(t),e.removeWebSocketListeners(n)}}return e.prototype.close=function(){null!=this.webSocket&&this.webSocket.close()},e.prototype.connect=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,o=this;return n.__generator(this,(function(n){return t=r.UUID.create(),this.webSocket=new WebSocket(e.url,e.protocols),this.webSocket.binaryType="arraybuffer",[2,new Promise((function(e,n){null!=o.webSocket&&(o.listeners[t]=o.addWebSocketListeners(o.webSocket,t,e,n))}))]}))}))},e.prototype.onMessage=function(e){return this.onMessageDispatcher.on(e)},e.prototype.onClose=function(e){return this.onCloseDispatcher.on(e)},e.prototype.send=function(e){null!=this.webSocket&&this.webSocket.send(e)},e.prototype.removeWebSocketListeners=function(e){var t;null===(t=this.listeners[e])||void 0===t||t.dispose()},e.prototype.onOpen=function(e){e()},e}();function u(e){var n=e.getTime();return t.google.protobuf.Timestamp.create(d(n))}function c(){return u(new Date)}function d(e){return{seconds:Math.floor(e/1e3),nanos:e%1e3*1e6}}var p=function(e){function t(t,n,r,o){var s=e.call(this,null!=r&&r.length>0?"Stream request failed ("+r+")":"Stream request failed")||this;return s.requestId=t,s.requestPayload=n,s.summary=r,s.details=o,s}return n.__extends(t,e),t}(Error);function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,r){return n.__assign(n.__assign({},e),r(t))}),{})}}function f(e,t){return m(e,t,(function(e){return"boolean"==typeof e?e?"on":"off":void 0}))}function h(e,t){return m(e,t,(function(e){return"number"==typeof e?e.toString():void 0}))}function v(e,t){return m(e,t,(function(e){return"string"==typeof e?e:void 0}))}function m(e,t,n){return function(r){var o,s=n(r[t]);return null!=s?((o={})[e]=s,o):{}}}function g(e,t){var n={},o=r.Uri.parse(e),s=l(function(e){return y((function(e){return e.EXPERIMENTAL_frameDelivery}),e,l(f("frame-delivery.rate-limit-enabled","rateLimitingEnabled"),h("frame-delivery.packet-loss-threshold","packetLossThreshold"),h("frame-delivery.history-max-size","historyMaxSize"),v("frame-delivery.timeout","timeout"),h("frame-delivery.timeout-ratio-threshold","timeoutRatioThreshold")))}(n.EXPERIMENTAL_frameDelivery),function(e){return y((function(e){return e.EXPERIMENTAL_adaptiveRendering}),e,l(f("adaptive-rendering.enabled","enabled"),v("adaptive-rendering.method","method"),h("adaptive-rendering.jpeg-quality-min","jpegMinQuality"),h("adaptive-rendering.jpeg-quality-max","jpegMaxQuality"),h("adaptive-rendering.image-scale-min","imageMinScale"),h("adaptive-rendering.image-scale-max","imageMaxScale"),h("adaptive-rendering.window-size","windowSize")))}(n.EXPERIMENTAL_adaptiveRendering),function(e){return y((function(e){return e.EXPERIMENTAL_qualityOfService}),e,l(h("qos.history-max-size","historyMaxSize")))}(n.EXPERIMENTAL_qualityOfService))(t);return r.Uri.toString(r.Uri.addQueryParams(s,o))}function y(e,t,n){return function(o){var s=r.Objects.defaults(e(o)||{},t);return n(s)}}var b=function(){function e(e,t){void 0===e&&(e=new a),void 0===t&&(t=!1),this.websocket=e,this.loggingEnabled=t,this.onResponseDispatcher=new r.EventDispatcher,this.onRequestDispatcher=new r.EventDispatcher}return e.prototype.connect=function(e,t){return void 0===t&&(t={}),n.__awaiter(this,void 0,void 0,(function(){var r,o=this;return n.__generator(this,(function(s){switch(s.label){case 0:return r=n.__assign(n.__assign({},e),{url:g(e.url,t)}),[4,this.websocket.connect(r)];case 1:return s.sent(),this.messageSubscription=this.websocket.onMessage((function(e){o.handleMessage(e)})),[2,{dispose:function(){return o.dispose()}}]}}))}))},e.prototype.dispose=function(){var e;this.websocket.close(),null===(e=this.messageSubscription)||void 0===e||e.dispose()},e.prototype.onRequest=function(e){return this.onRequestDispatcher.on(e)},e.prototype.startStream=function(e,t){return void 0===t&&(t=!0),this.sendRequest({startStream:e},t)},e.prototype.reconnect=function(e,t){return void 0===t&&(t=!0),n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(n){return[2,this.sendRequest({reconnect:e},t)]}))}))},e.prototype.updateStream=function(e,t){return void 0===t&&(t=!1),n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(n){return[2,this.sendRequest({updateStream:e},t)]}))}))},e.prototype.beginInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({beginInteraction:{}},e)},e.prototype.replaceCamera=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateCamera:e},t)},e.prototype.flyTo=function(e,t){return void 0===t&&(t=!0),this.sendRequest({flyTo:e},t)},e.prototype.updateDimensions=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateDimensions:e},t)},e.prototype.hitItems=function(e,t){return void 0===t&&(t=!0),this.sendRequest({hitItems:e},t)},e.prototype.createSceneAlteration=function(e,t){return void 0===t&&(t=!0),this.sendRequest({createSceneAlteration:e},t)},e.prototype.endInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({endInteraction:{}},e)},e.prototype.syncTime=function(e,t){return void 0===t&&(t=!0),this.sendRequest({syncTime:e},t)},e.prototype.recordPerformance=function(e,t){return void 0===t&&(t=!0),this.sendRequest({recordPerformance:e},t)},e.prototype.replyResult=function(e,t){this.sendResponse(n.__assign({requestId:{value:e}},t))},e.prototype.replyError=function(e,t){this.sendResponse({requestId:{value:e},error:t})},e.prototype.handleMessage=function(e){var t=i(e.data);this.log("WS message received",t),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.response)&&this.onResponseDispatcher.emit({sentAtTime:t.sentAtTime,response:t.response}),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.request)&&this.onRequestDispatcher.emit({sentAtTime:t.sentAtTime,request:t.request})},e.prototype.onResponse=function(e){return this.onResponseDispatcher.on(e)},e.prototype.log=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.loggingEnabled&&console.debug.apply(console,n.__spreadArrays([e],t))},e.prototype.sendRequest=function(e,t){var o=this,s=c();if(t){var i=r.UUID.create(),a=n.__assign(n.__assign({},e),{requestId:{value:i}});return new Promise((function(t,n){var r=o.onResponse((function(o){var s;if(i===(null===(s=o.response.requestId)||void 0===s?void 0:s.value)){if(null==o.response.error)t(o.response);else{var a=o.response.error,u=a.message,c=a.details;n(new p(i,e,null==u?void 0:u.value,null==c?void 0:c.value))}r.dispose()}}));o.sendMessage({sentAtTime:s,request:a})}))}return this.sendMessage({sentAtTime:s,request:e}),Promise.resolve({})},e.prototype.sendMessage=function(e){this.websocket.send(s(e)),this.log("WS message sent",e)},e.prototype.sendResponse=function(e){var t=c();this.websocket.send(s({sentAtTime:t,response:e}))},e}();function _(e,t){return n.__assign(n.__assign({sentAtTime:c()},t),{request:n.__assign({requestId:null!=e.requestId?{value:e.requestId}:void 0},e.payload)})}var q=Object.freeze({__proto__:null,drawFrame:function(e,t){void 0===e&&(e={});var n={sequenceNumber:1,sceneAttributes:{camera:{position:{x:0,y:0,z:1},lookAt:{x:0,y:0,z:0},up:{x:0,y:1,z:0}}},imageAttributes:{frameDimensions:{width:200,height:150},imageRect:{x:0,y:0,width:200,height:150},scaleFactor:1},frameCorrelationIds:["123"],image:new Uint8Array};return _({requestId:e.requestId,payload:{drawFrame:r.Objects.defaults(e.payload,n)}},t)},gracefulReconnect:function(e,t){void 0===e&&(e={});var n={streamId:{hex:r.UUID.create()},timeToReconnectDuration:{seconds:1,nanos:0}};return _({requestId:e.requestId,payload:{reconnect:r.Objects.defaults(e.payload,n)}},t)}}),w=Object.freeze({__proto__:null,Requests:q}),S=function(){function e(){this.handlers=new Set,this.sentMessages=new Array}return e.prototype.close=function(){},e.prototype.connect=function(e){return Promise.resolve()},e.prototype.onMessage=function(e){var t=this;return this.handlers.add(e),{dispose:function(){return t.handlers.delete(e)}}},e.prototype.send=function(e){this.sentMessages.push(e)},e.prototype.reconnect=function(e){return Promise.resolve()},e.prototype.receiveMessage=function(e){this.handlers.forEach((function(t){return t(new MessageEvent("message",{data:e}))}))},e.prototype.reset=function(){this.sentMessages=[],this.handlers.clear()},e.prototype.hasNextSent=function(){return this.sentMessages.length>0},e.prototype.nextSent=function(e){var t=this.sentMessages.shift();if(null!=t)return null!=e?e(t):t;throw new Error("Sent messages is empty")},e.prototype.skipSent=function(e){if(void 0===e&&(e=1),!(e<=this.sentMessages.length))throw new Error("Cannot skip the next "+e+" messages. Sent message queue only has "+this.sentMessages.length+" messages.");for(var t=0;t<e;t++)this.nextSent();return this},e}();exports.Fixtures=w,exports.StreamApi=b,exports.WebSocketClientImpl=a,exports.WebSocketClientMock=S,exports.currentDateAsProtoTimestamp=c,exports.decode=i,exports.encode=s,exports.protoToDate=function(e){if(null!=e.seconds&&null!=e.nanos){var t=o.isLong(e.seconds)?e.seconds.toNumber():e.seconds;return new Date(1e3*t+e.nanos/1e6)}},exports.toProtoDuration=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2===e.length){var r=e[0],o=e[1],s=o.getTime()-r.getTime();return t.google.protobuf.Duration.create(d(s))}if(1===e.length){s=e[0];return t.google.protobuf.Duration.create(d(s))}throw new Error("Expected input to be a number or start and end date.")},exports.toProtoTimestamp=u; | ||
//# sourceMappingURL=bundle.cjs.min.js.map |
@@ -369,2 +369,21 @@ import { vertexvis, google } from '@vertexvis/frame-streaming-protos'; | ||
/** | ||
* Sends a request to update the position of the scene's camera as a fly operation | ||
* | ||
* The payload accepts an optional `frameCorrelationId` that will be sent | ||
* back on the frame that is associated to this request. Use `onRequest` to | ||
* add a callback that'll be invoked when the server sends a request to draw | ||
* the frame. | ||
* | ||
* Use `withResponse` to indicate if the server should reply with a response. | ||
* If `false`, the returned promise will complete immediately. Otherwise, | ||
* it'll complete when a response is received. | ||
* | ||
* @param payload | ||
* @param withResponse | ||
*/ | ||
StreamApi.prototype.flyTo = function (payload, withResponse) { | ||
if (withResponse === void 0) { withResponse = true; } | ||
return this.sendRequest({ flyTo: payload }, withResponse); | ||
}; | ||
/** | ||
* Sends a request to update the dimensions of the frame. | ||
@@ -371,0 +390,0 @@ * |
@@ -1,2 +0,2 @@ | ||
import{vertexvis as e,google as t}from"@vertexvis/frame-streaming-protos";import{__awaiter as n,__generator as r,__extends as o,__assign as s,__spreadArrays as i}from"tslib";import{UUID as u,EventDispatcher as a,Uri as c,Objects as d}from"@vertexvis/utils";import p from"long";function l(t){return e.protobuf.stream.StreamMessage.encode(t).finish()}function f(t){var n=t instanceof ArrayBuffer?new Uint8Array(t):t;return e.protobuf.stream.StreamMessage.decode(n)}var h=function(){function e(){var e=this;this.listeners={},this.onMessageDispatcher=new a,this.onCloseDispatcher=new a,this.addWebSocketListeners=function(t,n,r,o){var s=function(){return e.onOpen(r)},i=function(){return o()},u=function(t){return e.handleClose(t,n)};return t.addEventListener("message",e.handleMessage),t.addEventListener("open",s),t.addEventListener("error",i),t.addEventListener("close",u),{dispose:function(){t.removeEventListener("message",e.handleMessage),t.removeEventListener("open",s),t.removeEventListener("error",i),t.removeEventListener("close",u)}}},this.handleMessage=function(t){e.onMessageDispatcher.emit(t)},this.handleClose=function(t,n){e.onCloseDispatcher.emit(t),e.removeWebSocketListeners(n)}}return e.prototype.close=function(){null!=this.webSocket&&this.webSocket.close()},e.prototype.connect=function(e){return n(this,void 0,void 0,(function(){var t,n=this;return r(this,(function(r){return t=u.create(),this.webSocket=new WebSocket(e.url,e.protocols),this.webSocket.binaryType="arraybuffer",[2,new Promise((function(e,r){null!=n.webSocket&&(n.listeners[t]=n.addWebSocketListeners(n.webSocket,t,e,r))}))]}))}))},e.prototype.onMessage=function(e){return this.onMessageDispatcher.on(e)},e.prototype.onClose=function(e){return this.onCloseDispatcher.on(e)},e.prototype.send=function(e){null!=this.webSocket&&this.webSocket.send(e)},e.prototype.removeWebSocketListeners=function(e){var t;null===(t=this.listeners[e])||void 0===t||t.dispose()},e.prototype.onOpen=function(e){e()},e}();function v(e){var n=e.getTime();return t.protobuf.Timestamp.create(b(n))}function m(){return v(new Date)}function g(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2===e.length){var r=e[0],o=e[1],s=o.getTime()-r.getTime();return t.protobuf.Duration.create(b(s))}if(1===e.length){s=e[0];return t.protobuf.Duration.create(b(s))}throw new Error("Expected input to be a number or start and end date.")}function y(e){if(null!=e.seconds&&null!=e.nanos){var t=p.isLong(e.seconds)?e.seconds.toNumber():e.seconds;return new Date(1e3*t+e.nanos/1e6)}}function b(e){return{seconds:Math.floor(e/1e3),nanos:e%1e3*1e6}}var q=function(e){function t(t,n,r,o){var s=e.call(this,null!=r&&r.length>0?"Stream request failed ("+r+")":"Stream request failed")||this;return s.requestId=t,s.requestPayload=n,s.summary=r,s.details=o,s}return o(t,e),t}(Error);function w(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,n){return s(s({},e),n(t))}),{})}}function S(e,t){return E(e,t,(function(e){return"boolean"==typeof e?e?"on":"off":void 0}))}function M(e,t){return E(e,t,(function(e){return"number"==typeof e?e.toString():void 0}))}function R(e,t){return E(e,t,(function(e){return"string"==typeof e?e:void 0}))}function E(e,t,n){return function(r){var o,s=n(r[t]);return null!=s?((o={})[e]=s,o):{}}}function I(e,t){var n={},r=c.parse(e),o=w(function(e){return T((function(e){return e.EXPERIMENTAL_frameDelivery}),e,w(S("frame-delivery.rate-limit-enabled","rateLimitingEnabled"),M("frame-delivery.packet-loss-threshold","packetLossThreshold"),M("frame-delivery.history-max-size","historyMaxSize"),R("frame-delivery.timeout","timeout"),M("frame-delivery.timeout-ratio-threshold","timeoutRatioThreshold")))}(n.EXPERIMENTAL_frameDelivery),function(e){return T((function(e){return e.EXPERIMENTAL_adaptiveRendering}),e,w(S("adaptive-rendering.enabled","enabled"),R("adaptive-rendering.method","method"),M("adaptive-rendering.jpeg-quality-min","jpegMinQuality"),M("adaptive-rendering.jpeg-quality-max","jpegMaxQuality"),M("adaptive-rendering.image-scale-min","imageMinScale"),M("adaptive-rendering.image-scale-max","imageMaxScale"),M("adaptive-rendering.window-size","windowSize")))}(n.EXPERIMENTAL_adaptiveRendering),function(e){return T((function(e){return e.EXPERIMENTAL_qualityOfService}),e,w(M("qos.history-max-size","historyMaxSize")))}(n.EXPERIMENTAL_qualityOfService))(t);return c.toString(c.addQueryParams(o,r))}function T(e,t,n){return function(r){var o=d.defaults(e(r)||{},t);return n(o)}}var A=function(){function e(e,t){void 0===e&&(e=new h),void 0===t&&(t=!1),this.websocket=e,this.loggingEnabled=t,this.onResponseDispatcher=new a,this.onRequestDispatcher=new a}return e.prototype.connect=function(e,t){return void 0===t&&(t={}),n(this,void 0,void 0,(function(){var n,o=this;return r(this,(function(r){switch(r.label){case 0:return n=s(s({},e),{url:I(e.url,t)}),[4,this.websocket.connect(n)];case 1:return r.sent(),this.messageSubscription=this.websocket.onMessage((function(e){o.handleMessage(e)})),[2,{dispose:function(){return o.dispose()}}]}}))}))},e.prototype.dispose=function(){var e;this.websocket.close(),null===(e=this.messageSubscription)||void 0===e||e.dispose()},e.prototype.onRequest=function(e){return this.onRequestDispatcher.on(e)},e.prototype.startStream=function(e,t){return void 0===t&&(t=!0),this.sendRequest({startStream:e},t)},e.prototype.reconnect=function(e,t){return void 0===t&&(t=!0),n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,this.sendRequest({reconnect:e},t)]}))}))},e.prototype.updateStream=function(e,t){return void 0===t&&(t=!1),n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,this.sendRequest({updateStream:e},t)]}))}))},e.prototype.beginInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({beginInteraction:{}},e)},e.prototype.replaceCamera=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateCamera:e},t)},e.prototype.updateDimensions=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateDimensions:e},t)},e.prototype.hitItems=function(e,t){return void 0===t&&(t=!0),this.sendRequest({hitItems:e},t)},e.prototype.createSceneAlteration=function(e,t){return void 0===t&&(t=!0),this.sendRequest({createSceneAlteration:e},t)},e.prototype.endInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({endInteraction:{}},e)},e.prototype.syncTime=function(e,t){return void 0===t&&(t=!0),this.sendRequest({syncTime:e},t)},e.prototype.recordPerformance=function(e,t){return void 0===t&&(t=!0),this.sendRequest({recordPerformance:e},t)},e.prototype.replyResult=function(e,t){this.sendResponse(s({requestId:{value:e}},t))},e.prototype.replyError=function(e,t){this.sendResponse({requestId:{value:e},error:t})},e.prototype.handleMessage=function(e){var t=f(e.data);this.log("WS message received",t),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.response)&&this.onResponseDispatcher.emit({sentAtTime:t.sentAtTime,response:t.response}),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.request)&&this.onRequestDispatcher.emit({sentAtTime:t.sentAtTime,request:t.request})},e.prototype.onResponse=function(e){return this.onResponseDispatcher.on(e)},e.prototype.log=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.loggingEnabled&&console.debug.apply(console,i([e],t))},e.prototype.sendRequest=function(e,t){var n=this,r=m();if(t){var o=u.create(),i=s(s({},e),{requestId:{value:o}});return new Promise((function(t,s){var u=n.onResponse((function(n){var r;if(o===(null===(r=n.response.requestId)||void 0===r?void 0:r.value)){if(null==n.response.error)t(n.response);else{var i=n.response.error,a=i.message,c=i.details;s(new q(o,e,null==a?void 0:a.value,null==c?void 0:c.value))}u.dispose()}}));n.sendMessage({sentAtTime:r,request:i})}))}return this.sendMessage({sentAtTime:r,request:e}),Promise.resolve({})},e.prototype.sendMessage=function(e){this.websocket.send(l(e)),this.log("WS message sent",e)},e.prototype.sendResponse=function(e){var t=m();this.websocket.send(l({sentAtTime:t,response:e}))},e}();function k(e,t){return s(s({sentAtTime:m()},t),{request:s({requestId:null!=e.requestId?{value:e.requestId}:void 0},e.payload)})}var x=Object.freeze({__proto__:null,drawFrame:function(e,t){void 0===e&&(e={});var n={sequenceNumber:1,sceneAttributes:{camera:{position:{x:0,y:0,z:1},lookAt:{x:0,y:0,z:0},up:{x:0,y:1,z:0}}},imageAttributes:{frameDimensions:{width:200,height:150},imageRect:{x:0,y:0,width:200,height:150},scaleFactor:1},frameCorrelationIds:["123"],image:new Uint8Array};return k({requestId:e.requestId,payload:{drawFrame:d.defaults(e.payload,n)}},t)},gracefulReconnect:function(e,t){void 0===e&&(e={});var n={streamId:{hex:u.create()},timeToReconnectDuration:{seconds:1,nanos:0}};return k({requestId:e.requestId,payload:{reconnect:d.defaults(e.payload,n)}},t)}}),D=Object.freeze({__proto__:null,Requests:x}),L=function(){function e(){this.handlers=new Set,this.sentMessages=new Array}return e.prototype.close=function(){},e.prototype.connect=function(e){return Promise.resolve()},e.prototype.onMessage=function(e){var t=this;return this.handlers.add(e),{dispose:function(){return t.handlers.delete(e)}}},e.prototype.send=function(e){this.sentMessages.push(e)},e.prototype.reconnect=function(e){return Promise.resolve()},e.prototype.receiveMessage=function(e){this.handlers.forEach((function(t){return t(new MessageEvent("message",{data:e}))}))},e.prototype.reset=function(){this.sentMessages=[],this.handlers.clear()},e.prototype.hasNextSent=function(){return this.sentMessages.length>0},e.prototype.nextSent=function(e){var t=this.sentMessages.shift();if(null!=t)return null!=e?e(t):t;throw new Error("Sent messages is empty")},e.prototype.skipSent=function(e){if(void 0===e&&(e=1),!(e<=this.sentMessages.length))throw new Error("Cannot skip the next "+e+" messages. Sent message queue only has "+this.sentMessages.length+" messages.");for(var t=0;t<e;t++)this.nextSent();return this},e}();export{D as Fixtures,A as StreamApi,h as WebSocketClientImpl,L as WebSocketClientMock,m as currentDateAsProtoTimestamp,f as decode,l as encode,y as protoToDate,g as toProtoDuration,v as toProtoTimestamp}; | ||
import{vertexvis as e,google as t}from"@vertexvis/frame-streaming-protos";import{__awaiter as n,__generator as r,__extends as o,__assign as s,__spreadArrays as i}from"tslib";import{UUID as u,EventDispatcher as a,Uri as c,Objects as d}from"@vertexvis/utils";import p from"long";function l(t){return e.protobuf.stream.StreamMessage.encode(t).finish()}function f(t){var n=t instanceof ArrayBuffer?new Uint8Array(t):t;return e.protobuf.stream.StreamMessage.decode(n)}var h=function(){function e(){var e=this;this.listeners={},this.onMessageDispatcher=new a,this.onCloseDispatcher=new a,this.addWebSocketListeners=function(t,n,r,o){var s=function(){return e.onOpen(r)},i=function(){return o()},u=function(t){return e.handleClose(t,n)};return t.addEventListener("message",e.handleMessage),t.addEventListener("open",s),t.addEventListener("error",i),t.addEventListener("close",u),{dispose:function(){t.removeEventListener("message",e.handleMessage),t.removeEventListener("open",s),t.removeEventListener("error",i),t.removeEventListener("close",u)}}},this.handleMessage=function(t){e.onMessageDispatcher.emit(t)},this.handleClose=function(t,n){e.onCloseDispatcher.emit(t),e.removeWebSocketListeners(n)}}return e.prototype.close=function(){null!=this.webSocket&&this.webSocket.close()},e.prototype.connect=function(e){return n(this,void 0,void 0,(function(){var t,n=this;return r(this,(function(r){return t=u.create(),this.webSocket=new WebSocket(e.url,e.protocols),this.webSocket.binaryType="arraybuffer",[2,new Promise((function(e,r){null!=n.webSocket&&(n.listeners[t]=n.addWebSocketListeners(n.webSocket,t,e,r))}))]}))}))},e.prototype.onMessage=function(e){return this.onMessageDispatcher.on(e)},e.prototype.onClose=function(e){return this.onCloseDispatcher.on(e)},e.prototype.send=function(e){null!=this.webSocket&&this.webSocket.send(e)},e.prototype.removeWebSocketListeners=function(e){var t;null===(t=this.listeners[e])||void 0===t||t.dispose()},e.prototype.onOpen=function(e){e()},e}();function v(e){var n=e.getTime();return t.protobuf.Timestamp.create(b(n))}function m(){return v(new Date)}function g(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(2===e.length){var r=e[0],o=e[1],s=o.getTime()-r.getTime();return t.protobuf.Duration.create(b(s))}if(1===e.length){s=e[0];return t.protobuf.Duration.create(b(s))}throw new Error("Expected input to be a number or start and end date.")}function y(e){if(null!=e.seconds&&null!=e.nanos){var t=p.isLong(e.seconds)?e.seconds.toNumber():e.seconds;return new Date(1e3*t+e.nanos/1e6)}}function b(e){return{seconds:Math.floor(e/1e3),nanos:e%1e3*1e6}}var q=function(e){function t(t,n,r,o){var s=e.call(this,null!=r&&r.length>0?"Stream request failed ("+r+")":"Stream request failed")||this;return s.requestId=t,s.requestPayload=n,s.summary=r,s.details=o,s}return o(t,e),t}(Error);function w(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.reduce((function(e,n){return s(s({},e),n(t))}),{})}}function S(e,t){return E(e,t,(function(e){return"boolean"==typeof e?e?"on":"off":void 0}))}function R(e,t){return E(e,t,(function(e){return"number"==typeof e?e.toString():void 0}))}function M(e,t){return E(e,t,(function(e){return"string"==typeof e?e:void 0}))}function E(e,t,n){return function(r){var o,s=n(r[t]);return null!=s?((o={})[e]=s,o):{}}}function T(e,t){var n={},r=c.parse(e),o=w(function(e){return I((function(e){return e.EXPERIMENTAL_frameDelivery}),e,w(S("frame-delivery.rate-limit-enabled","rateLimitingEnabled"),R("frame-delivery.packet-loss-threshold","packetLossThreshold"),R("frame-delivery.history-max-size","historyMaxSize"),M("frame-delivery.timeout","timeout"),R("frame-delivery.timeout-ratio-threshold","timeoutRatioThreshold")))}(n.EXPERIMENTAL_frameDelivery),function(e){return I((function(e){return e.EXPERIMENTAL_adaptiveRendering}),e,w(S("adaptive-rendering.enabled","enabled"),M("adaptive-rendering.method","method"),R("adaptive-rendering.jpeg-quality-min","jpegMinQuality"),R("adaptive-rendering.jpeg-quality-max","jpegMaxQuality"),R("adaptive-rendering.image-scale-min","imageMinScale"),R("adaptive-rendering.image-scale-max","imageMaxScale"),R("adaptive-rendering.window-size","windowSize")))}(n.EXPERIMENTAL_adaptiveRendering),function(e){return I((function(e){return e.EXPERIMENTAL_qualityOfService}),e,w(R("qos.history-max-size","historyMaxSize")))}(n.EXPERIMENTAL_qualityOfService))(t);return c.toString(c.addQueryParams(o,r))}function I(e,t,n){return function(r){var o=d.defaults(e(r)||{},t);return n(o)}}var A=function(){function e(e,t){void 0===e&&(e=new h),void 0===t&&(t=!1),this.websocket=e,this.loggingEnabled=t,this.onResponseDispatcher=new a,this.onRequestDispatcher=new a}return e.prototype.connect=function(e,t){return void 0===t&&(t={}),n(this,void 0,void 0,(function(){var n,o=this;return r(this,(function(r){switch(r.label){case 0:return n=s(s({},e),{url:T(e.url,t)}),[4,this.websocket.connect(n)];case 1:return r.sent(),this.messageSubscription=this.websocket.onMessage((function(e){o.handleMessage(e)})),[2,{dispose:function(){return o.dispose()}}]}}))}))},e.prototype.dispose=function(){var e;this.websocket.close(),null===(e=this.messageSubscription)||void 0===e||e.dispose()},e.prototype.onRequest=function(e){return this.onRequestDispatcher.on(e)},e.prototype.startStream=function(e,t){return void 0===t&&(t=!0),this.sendRequest({startStream:e},t)},e.prototype.reconnect=function(e,t){return void 0===t&&(t=!0),n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,this.sendRequest({reconnect:e},t)]}))}))},e.prototype.updateStream=function(e,t){return void 0===t&&(t=!1),n(this,void 0,void 0,(function(){return r(this,(function(n){return[2,this.sendRequest({updateStream:e},t)]}))}))},e.prototype.beginInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({beginInteraction:{}},e)},e.prototype.replaceCamera=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateCamera:e},t)},e.prototype.flyTo=function(e,t){return void 0===t&&(t=!0),this.sendRequest({flyTo:e},t)},e.prototype.updateDimensions=function(e,t){return void 0===t&&(t=!0),this.sendRequest({updateDimensions:e},t)},e.prototype.hitItems=function(e,t){return void 0===t&&(t=!0),this.sendRequest({hitItems:e},t)},e.prototype.createSceneAlteration=function(e,t){return void 0===t&&(t=!0),this.sendRequest({createSceneAlteration:e},t)},e.prototype.endInteraction=function(e){return void 0===e&&(e=!0),this.sendRequest({endInteraction:{}},e)},e.prototype.syncTime=function(e,t){return void 0===t&&(t=!0),this.sendRequest({syncTime:e},t)},e.prototype.recordPerformance=function(e,t){return void 0===t&&(t=!0),this.sendRequest({recordPerformance:e},t)},e.prototype.replyResult=function(e,t){this.sendResponse(s({requestId:{value:e}},t))},e.prototype.replyError=function(e,t){this.sendResponse({requestId:{value:e},error:t})},e.prototype.handleMessage=function(e){var t=f(e.data);this.log("WS message received",t),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.response)&&this.onResponseDispatcher.emit({sentAtTime:t.sentAtTime,response:t.response}),null!=(null==t?void 0:t.sentAtTime)&&null!=(null==t?void 0:t.request)&&this.onRequestDispatcher.emit({sentAtTime:t.sentAtTime,request:t.request})},e.prototype.onResponse=function(e){return this.onResponseDispatcher.on(e)},e.prototype.log=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.loggingEnabled&&console.debug.apply(console,i([e],t))},e.prototype.sendRequest=function(e,t){var n=this,r=m();if(t){var o=u.create(),i=s(s({},e),{requestId:{value:o}});return new Promise((function(t,s){var u=n.onResponse((function(n){var r;if(o===(null===(r=n.response.requestId)||void 0===r?void 0:r.value)){if(null==n.response.error)t(n.response);else{var i=n.response.error,a=i.message,c=i.details;s(new q(o,e,null==a?void 0:a.value,null==c?void 0:c.value))}u.dispose()}}));n.sendMessage({sentAtTime:r,request:i})}))}return this.sendMessage({sentAtTime:r,request:e}),Promise.resolve({})},e.prototype.sendMessage=function(e){this.websocket.send(l(e)),this.log("WS message sent",e)},e.prototype.sendResponse=function(e){var t=m();this.websocket.send(l({sentAtTime:t,response:e}))},e}();function k(e,t){return s(s({sentAtTime:m()},t),{request:s({requestId:null!=e.requestId?{value:e.requestId}:void 0},e.payload)})}var x=Object.freeze({__proto__:null,drawFrame:function(e,t){void 0===e&&(e={});var n={sequenceNumber:1,sceneAttributes:{camera:{position:{x:0,y:0,z:1},lookAt:{x:0,y:0,z:0},up:{x:0,y:1,z:0}}},imageAttributes:{frameDimensions:{width:200,height:150},imageRect:{x:0,y:0,width:200,height:150},scaleFactor:1},frameCorrelationIds:["123"],image:new Uint8Array};return k({requestId:e.requestId,payload:{drawFrame:d.defaults(e.payload,n)}},t)},gracefulReconnect:function(e,t){void 0===e&&(e={});var n={streamId:{hex:u.create()},timeToReconnectDuration:{seconds:1,nanos:0}};return k({requestId:e.requestId,payload:{reconnect:d.defaults(e.payload,n)}},t)}}),D=Object.freeze({__proto__:null,Requests:x}),L=function(){function e(){this.handlers=new Set,this.sentMessages=new Array}return e.prototype.close=function(){},e.prototype.connect=function(e){return Promise.resolve()},e.prototype.onMessage=function(e){var t=this;return this.handlers.add(e),{dispose:function(){return t.handlers.delete(e)}}},e.prototype.send=function(e){this.sentMessages.push(e)},e.prototype.reconnect=function(e){return Promise.resolve()},e.prototype.receiveMessage=function(e){this.handlers.forEach((function(t){return t(new MessageEvent("message",{data:e}))}))},e.prototype.reset=function(){this.sentMessages=[],this.handlers.clear()},e.prototype.hasNextSent=function(){return this.sentMessages.length>0},e.prototype.nextSent=function(e){var t=this.sentMessages.shift();if(null!=t)return null!=e?e(t):t;throw new Error("Sent messages is empty")},e.prototype.skipSent=function(e){if(void 0===e&&(e=1),!(e<=this.sentMessages.length))throw new Error("Cannot skip the next "+e+" messages. Sent message queue only has "+this.sentMessages.length+" messages.");for(var t=0;t<e;t++)this.nextSent();return this},e}();export{D as Fixtures,A as StreamApi,h as WebSocketClientImpl,L as WebSocketClientMock,m as currentDateAsProtoTimestamp,f as decode,l as encode,y as protoToDate,g as toProtoDuration,v as toProtoTimestamp}; | ||
//# sourceMappingURL=bundle.esm.min.js.map |
@@ -109,2 +109,18 @@ import { WebSocketClient } from './webSocketClient'; | ||
/** | ||
* Sends a request to update the position of the scene's camera as a fly operation | ||
* | ||
* The payload accepts an optional `frameCorrelationId` that will be sent | ||
* back on the frame that is associated to this request. Use `onRequest` to | ||
* add a callback that'll be invoked when the server sends a request to draw | ||
* the frame. | ||
* | ||
* Use `withResponse` to indicate if the server should reply with a response. | ||
* If `false`, the returned promise will complete immediately. Otherwise, | ||
* it'll complete when a response is received. | ||
* | ||
* @param payload | ||
* @param withResponse | ||
*/ | ||
flyTo(payload: vertexvis.protobuf.stream.IFlyToPayload, withResponse?: boolean): Promise<vertexvis.protobuf.stream.IStreamResponse>; | ||
/** | ||
* Sends a request to update the dimensions of the frame. | ||
@@ -111,0 +127,0 @@ * |
{ | ||
"name": "@vertexvis/stream-api", | ||
"version": "0.9.19-canary.7", | ||
"version": "0.9.19-canary.8", | ||
"description": "A websocket client for interacting with Vertex's stream API.", | ||
@@ -38,4 +38,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@vertexvis/frame-streaming-protos": "^0.3.13", | ||
"@vertexvis/utils": "^0.9.19-canary.7" | ||
"@vertexvis/frame-streaming-protos": "^0.3.17", | ||
"@vertexvis/utils": "^0.9.19-canary.8" | ||
}, | ||
@@ -46,3 +46,3 @@ "devDependencies": { | ||
"@vertexvis/jest-config-vertexvis": "^0.5.0", | ||
"@vertexwebsdk/build": "^0.9.19-canary.7", | ||
"@vertexwebsdk/build": "^0.9.19-canary.8", | ||
"eslint": "^6.1.0", | ||
@@ -59,3 +59,3 @@ "jest": "^24.9.0", | ||
}, | ||
"gitHead": "269c427c8c72b875a27c85241e67e6c753941227" | ||
"gitHead": "3dc3a368bfca8af41795897c0e068ea7eb5beb63" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
303700
2032