@jibestream-dev/jmap-device-kit
Version:
Kit for the Jibestream SDK to utilize Devices plotted in the CMS
1 lines • 8.39 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["jmap-device-kit"]=t():e["jmap-device-kit"]=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";var i,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":o(window))&&(i=window)}e.exports=i},function(e,t,n){"use strict";(function(t){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=n(3),c=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this,e),n instanceof t.jmap.core.JCore==!1)throw new Error("DeviceKit uses JCore as it's first argument.");if(o instanceof t.jmap.JController==!1)throw new Error("DeviceKit uses JController as it's second argument.");this._core=n,this._control=o,this._activeVenue=o.activeVenue,this._componentMap={},this._renderedDevices={},this.devices=new r}return o(e,[{key:"_focusToDevice",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments[3],o=this.getWaypointFromDevice(e);return this._control.setMapTransform(new jmap.Transform({x:o.coordinates[0],y:o.coordinates[1],scale:t||this._control.currentMapView.scale,rotation:i?-e.heading:this._control.currentMapView.rotation,animation:n})),this}},{key:"_deviceWayfind",value:function(e,t,n,i){var o,r=this.getWaypointFromDevice(t),c=[e,r];i||c.reverse();var a=(o=this._control).wayfindBetweenWaypoints.apply(o,c.concat([n]));return this._control.drawWayfindingPath(a),a}},{key:"_createDeviceDisplayObject",value:function(e,t){var n=this.getWaypointFromDevice(e),i=this._activeVenue.maps.getById(n.mapId);this._control.parseMap(i);var o={id:e.id,name:e.name,orientation:e.heading,rotateWithMap:!0,position:n.coordinates,map:i},r=this._control.createMovingObject(Object.assign(o,t));this._renderedDevices[e.id]=r}},{key:"_getUrl",value:function(){return"/venue/"+this._activeVenue.id+"/device/full"}},{key:"getDevices",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},n=this._getUrl();this._core.get(n,function(n,i){e._responseData=i;var o=i.devices&&i.devices.items?i.devices.items:[];e.devices.createBatch(o),t(n,e.devices)})}},{key:"wayfindToDevice",value:function(e,t,n){return this._deviceWayfind(e,t,n,!0)}},{key:"wayfindFromDevice",value:function(e,t,n){return this._deviceWayfind(e,t,n,!1)}},{key:"focusToDevice",value:function(e,t,n){return this._focusToDevice(e,t,n,!1)}},{key:"focusToDeviceWithHeading",value:function(e,t,n){return this._focusToDevice(e,t,n,!0)}},{key:"getWaypointFromDevice",value:function(e){var t=this._activeVenue.maps.getById(e.mapId);return t?t.waypoints.getById(e.waypointId):null}},{key:"addComponentOverDevice",value:function(e,t){var n=this.getWaypointFromDevice(e),i=this._activeVenue.maps.getById(n.mapId);return this._componentMap[e.id]={component:t,map:i},this._control.addComponent(t,i,n.coordinates),this}},{key:"removeComponentFromDevice",value:function(e){var t=this._componentMap[e.id];return t&&this._control.removeComponent(t.component,t.map),delete this._componentMap[e.id],this}},{key:"showDevice",value:function(e,t){var n=this._renderedDevices[e.id];return n?(this._control.updateMovingObject(n,t),n.visible=!0):this._createDeviceDisplayObject(e,t),this}},{key:"hideDevice",value:function(e){var t=this._renderedDevices[e.id];return t&&(t.visible=!1),this}},{key:"showAllDevices",value:function(e){var t=this;return this._control.pauseRendering(),this.devices.getAll().forEach(function(n){return t.showDevice(n,e)}),this._control.renderCurrentMapView(),this}},{key:"hideAllDevices",value:function(){var e=this;return this.devices.getAll().forEach(function(t){return e.hideDevice(t)}),this}},{key:"pingDevice",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=this._renderedDevices[e.id];if(i){i.pulseVisible=!0;var o=1e3*i.pulseDuration;t.setTimeout(function(){"function"==typeof n&&n(),i.pulseVisible=!1},o)}return this}}]),e}();e.exports=c}).call(t,n(0))},function(e,t,n){"use strict";(function(t){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),r(t,[{key:"_getLocation",value:function(){var e={mapId:null,waypointIds:[]};return Array.isArray(this._.locations)?this._.locations[0]||e:e}},{key:"heading",get:function(){return this.get("heading",null)}},{key:"name",get:function(){return this.get("name",null)}},{key:"waypointId",get:function(){return this._getLocation().waypointIds[0]||null}},{key:"mapId",get:function(){return this._getLocation().mapId||null}}]),t}(t.jmap.core.BaseModel);e.exports=c}).call(t,n(0))},function(e,t,n){"use strict";(function(t){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(2),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,a))}return r(t,e),c(t,[{key:"isDevice",value:function(e){return this.isCollectionItemType(e)}},{key:"getByName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.filter(function(t){return t.name.toLowerCase()===e.toLowerCase()})}},{key:"getByWaypoint",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.filter(function(t){return t.locations.getByWaypointId(e.id)})}},{key:"getByMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.filter(function(t){return t.locations.getByMapId(e.id)})}}]),t}(t.jmap.core.BaseCollection);e.exports=u}).call(t,n(0))},function(e,t,n){"use strict";(function(t){var i=n(1);t.DeviceKit=i,e.exports=i}).call(t,n(0))}])});