locusmaps-sdk
Advanced tools
Comparing version 1.1.0 to 1.1.2
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).LMInit=n()}(this,function(){"use strict";function e(e){this._observers.splice(this._observers.indexOf(e),1)}function n(e){const n=o();return this.observe(function(){e.apply(this,arguments)&&n.fire.apply(n,arguments)}),n}const t={detach:e,filter:n,fire:function(){const e=this._observers;if(e){for(let n=0;n<e.length;n++)try{e[n].apply(this,arguments)}catch(e){console.error(e)}return this}},observe:function(n){return this._observers||(this._observers=[]),this._observers.push(n),{detach:e.bind(this,n),ob:this}},on:function(e,t){return function(e){return n.call(this,function(n){return e===n})}.call(this,e).observe(t)}};function o(e){return e?function(e,n){for(var t in n)e[t]=n[t];return e}(e,t):Object.create(t)}let s="https://maps.locuslabs.com/sdk/dist/current/",r=null,i=1;const c={};let a=!1;const d=[`%cLocusMaps SDK %c(${(()=>{const e=new Date;return`${e.getMinutes()}:${e.getSeconds()}.${e.getMilliseconds()}`})()})%c: `,"color: orange","font-size: 8px","font-size: inherit; color: inherit"],l=function(){a&&console.log.apply(null,d.concat(Array.from(arguments)))};function u(e){const n=e.data;n&&"LL-server"===n.type&&(n.clientMsgId?(n.error?l("Received error message",n.payload):l("Received message",n.payload),c[n.clientMsgId]&&(n.error?c[n.clientMsgId].reject(n.payload):c[n.clientMsgId].resolve(n.payload))):n.event&&r.fire(n.event,n.payload))}let f=null;const p={getVersion:()=>"1.1.0",newMap:function(e,n,t){const a=()=>window.postMessage({type:"LL-INIT",config:{...n,renderDiv:e}},"*");return t&&(s=t),new Promise((e,n)=>{r?(f.detach(),a(),f=r.on("ready",()=>{e(r)})):(window.addEventListener("message",u,!1),o(r=((e,n)=>{"string"==typeof e&&(e={...n,command:e});const t={payload:e,type:"LL-client",msgId:i++};return l("Sending command object: ",e),window.postMessage(t,"*"),new Promise((e,n)=>{c[t.msgId]={resolve:e,reject:n}})})),function(e){window.LLpublicPath=s;const n=document.createElement("script");n.setAttribute("src",s+"main.js"),document.head.appendChild(n),n.addEventListener("load",e)}(a),f=r.on("ready",(t,o)=>{const{commands:s}=o.commandJSON;try{d=r,s.forEach(e=>{d[e.command]=function(){const n={command:e.command};for(let t=0;t<arguments.length;t++)n[e.args[t].name]=arguments[t];return d(n)}}),r=d}catch(e){n(e)}l("map ready"),r.observe(function(){const e=Array.from(arguments);e.unshift("Event: "),l.apply(null,e)}),r.setLogging=p.setLogging,e(r)}))});var d},setLogging:e=>{a=e}};return p}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LMInit=t()}(this,function(){"use strict";function e(e){this._observers.splice(this._observers.indexOf(e),1)}function t(e){const t=o();return this.observe(function(){e.apply(this,arguments)&&t.fire.apply(t,arguments)}),t}const n={detach:e,filter:t,fire:function(){const e=this._observers;if(e){for(let t=0;t<e.length;t++)try{e[t].apply(this,arguments)}catch(e){console.error(e)}return this}},observe:function(t){return this._observers||(this._observers=[]),this._observers.push(t),{detach:e.bind(this,t),ob:this}},on:function(e,n){return function(e){return t.call(this,function(t){return e===t})}.call(this,e).observe(n)}};function o(e){return e?function(e,t){for(var n in t)e[n]=t[n];return e}(e,n):Object.create(n)}let s="https://maps.locuslabs.com/sdk/dist/current/",r=null,i=1;const c={};let a=!1;const l=e=>e.toString().length<2?"0"+e:e,d=()=>[`%cLocusMaps SDK %c(${(()=>{const e=new Date;return`${e.getHours()}:${l(e.getMinutes())}:${l(e.getSeconds())}.${e.getMilliseconds()}`})()})%c: `,"color: orange","font-size: 8px","font-size: inherit; color: inherit"],u=function(){a&&console.log.apply(null,d().concat(Array.from(arguments)))};function f(e){const t=e.data;t&&"LL-server"===t.type&&(t.clientMsgId?(t.error?u("Received error message",t.payload):u("Received message",t.payload),c[t.clientMsgId]&&(t.error?c[t.clientMsgId].reject(t.payload):c[t.clientMsgId].resolve(t.payload))):t.event&&r.fire(t.event,t.payload))}let p=null;const g={getVersion:()=>"1.1.2",newMap:function(e,t,n){const a=()=>window.postMessage({type:"LL-INIT",config:{...t,renderDiv:e}},"*");return n&&(s=n),new Promise((e,n)=>{r?(p.detach(),a(),p=r.on("ready",()=>{e(r)})):(window.addEventListener("message",f,!1),o(r=((e,t)=>{"string"==typeof e&&(e={...t,command:e});const n={payload:e,type:"LL-client",msgId:i++};return u("Sending command object: ",e),window.postMessage(n,"*"),new Promise((e,t)=>{c[n.msgId]={resolve:e,reject:t}})})),t&&function(e){window.LLpublicPath=s;const t=document.createElement("script");t.setAttribute("src",s+"main.js"),document.head.appendChild(t),t.addEventListener("load",e)}(a),p=r.on("ready",(t,o)=>{const{commands:s}=o.commandJSON;try{l=r,s.forEach(e=>{l[e.command]=function(){const t={command:e.command};for(let n=0;n<arguments.length;n++)t[e.args[n].name]=arguments[n];return l(t)}}),r=l}catch(e){n(e)}u("map ready"),r.observe(function(){const e=Array.from(arguments);e.unshift("Event: "),u.apply(null,e)}),r.setLogging=g.setLogging,e(r)}))});var l},setLogging:e=>{a=e,e&&u("Atrius Maps JS SDK Client Logging enabled.")}};return g}); |
@@ -1,1 +0,1 @@ | ||
function fire(){const e=this._observers;if(e){for(let t=0;t<e.length;t++)try{e[t].apply(this,arguments)}catch(e){console.error(e)}return this}}function observe(e){return this._observers||(this._observers=[]),this._observers.push(e),{detach:detach.bind(this,e),ob:this}}function detach(e){this._observers.splice(this._observers.indexOf(e),1)}function filter(e){const t=create();return this.observe(function(){e.apply(this,arguments)&&t.fire.apply(t,arguments)}),t}function filterByName(e){return filter.call(this,function(t){return e===t})}function on(e,t){return filterByName.call(this,e).observe(t)}const observable={detach:detach,filter:filter,fire:fire,observe:observe,on:on};function extend(e,t){for(var n in t)e[n]=t[n];return e}function create(e){return e?extend(e,observable):Object.create(observable)}const SDK_CLIENT_VERSION="1.1.0";let CODE_HOME="https://maps.locuslabs.com/sdk/dist/current/",map=null,msgId=1;const sentMsgs={};let showLogFlag=!1;const ts=()=>{const e=new Date;return`${e.getMinutes()}:${e.getSeconds()}.${e.getMilliseconds()}`},logPre=[`%cLocusMaps SDK %c(${ts()})%c: `,"color: orange","font-size: 8px","font-size: inherit; color: inherit"],log=function(){showLogFlag&&console.log.apply(null,logPre.concat(Array.from(arguments)))};function installComs(){window.addEventListener("message",msgHandler,!1),create(map=((e,t)=>{"string"==typeof e&&(e={...t,command:e});const n={payload:e,type:"LL-client",msgId:msgId++};return log("Sending command object: ",e),window.postMessage(n,"*"),new Promise((e,t)=>{sentMsgs[n.msgId]={resolve:e,reject:t}})}))}function msgHandler(e){const t=e.data;t&&"LL-server"===t.type&&(t.clientMsgId?(t.error?log("Received error message",t.payload):log("Received message",t.payload),sentMsgs[t.clientMsgId]&&(t.error?sentMsgs[t.clientMsgId].reject(t.payload):sentMsgs[t.clientMsgId].resolve(t.payload))):t.event&&map.fire(t.event,t.payload))}function bootstrapCode(e){window.LLpublicPath=CODE_HOME;const t=document.createElement("script");t.setAttribute("src",CODE_HOME+"main.js"),document.head.appendChild(t),t.addEventListener("load",e)}function addCommands(e,t){return t.forEach(t=>{e[t.command]=function(){const n={command:t.command};for(let e=0;e<arguments.length;e++)n[t.args[e].name]=arguments[e];return e(n)}}),e}let mapReadyObservable=null;function newMap(e,t,n){const s=()=>window.postMessage({type:"LL-INIT",config:{...t,renderDiv:e}},"*");return n&&(CODE_HOME=n),new Promise((e,t)=>{map?(mapReadyObservable.detach(),s(),mapReadyObservable=map.on("ready",()=>{e(map)})):(installComs(),bootstrapCode(s),mapReadyObservable=map.on("ready",(n,s)=>{const{commands:o}=s.commandJSON;try{map=addCommands(map,o)}catch(e){t(e)}log("map ready"),map.observe(function(){const e=Array.from(arguments);e.unshift("Event: "),log.apply(null,e)}),map.setLogging=LMInit.setLogging,e(map)}))})}const LMInit={getVersion:()=>"1.1.0",newMap:newMap,setLogging:e=>{showLogFlag=e}};export default LMInit; | ||
function fire(){const e=this._observers;if(e){for(let t=0;t<e.length;t++)try{e[t].apply(this,arguments)}catch(e){console.error(e)}return this}}function observe(e){return this._observers||(this._observers=[]),this._observers.push(e),{detach:detach.bind(this,e),ob:this}}function detach(e){this._observers.splice(this._observers.indexOf(e),1)}function filter(e){const t=create();return this.observe(function(){e.apply(this,arguments)&&t.fire.apply(t,arguments)}),t}function filterByName(e){return filter.call(this,function(t){return e===t})}function on(e,t){return filterByName.call(this,e).observe(t)}const observable={detach:detach,filter:filter,fire:fire,observe:observe,on:on};function extend(e,t){for(var n in t)e[n]=t[n];return e}function create(e){return e?extend(e,observable):Object.create(observable)}const LIB_NAME="Atrius Maps JS SDK Client",CLIENT_VERSION="1.1.2";let CODE_HOME="https://maps.locuslabs.com/sdk/dist/current/",map=null,msgId=1;const sentMsgs={};let showLogFlag=!1;const pad2=e=>e.toString().length<2?"0"+e:e,ts=()=>{const e=new Date;return`${e.getHours()}:${pad2(e.getMinutes())}:${pad2(e.getSeconds())}.${e.getMilliseconds()}`},logPre=()=>[`%cLocusMaps SDK %c(${ts()})%c: `,"color: orange","font-size: 8px","font-size: inherit; color: inherit"],log=function(){showLogFlag&&console.log.apply(null,logPre().concat(Array.from(arguments)))};function installComs(){window.addEventListener("message",msgHandler,!1),create(map=((e,t)=>{"string"==typeof e&&(e={...t,command:e});const n={payload:e,type:"LL-client",msgId:msgId++};return log("Sending command object: ",e),window.postMessage(n,"*"),new Promise((e,t)=>{sentMsgs[n.msgId]={resolve:e,reject:t}})}))}function msgHandler(e){const t=e.data;t&&"LL-server"===t.type&&(t.clientMsgId?(t.error?log("Received error message",t.payload):log("Received message",t.payload),sentMsgs[t.clientMsgId]&&(t.error?sentMsgs[t.clientMsgId].reject(t.payload):sentMsgs[t.clientMsgId].resolve(t.payload))):t.event&&map.fire(t.event,t.payload))}function bootstrapCode(e){window.LLpublicPath=CODE_HOME;const t=document.createElement("script");t.setAttribute("src",CODE_HOME+"main.js"),document.head.appendChild(t),t.addEventListener("load",e)}function addCommands(e,t){return t.forEach(t=>{e[t.command]=function(){const n={command:t.command};for(let e=0;e<arguments.length;e++)n[t.args[e].name]=arguments[e];return e(n)}}),e}let mapReadyObservable=null;function newMap(e,t,n){const o=()=>window.postMessage({type:"LL-INIT",config:{...t,renderDiv:e}},"*");return n&&(CODE_HOME=n),new Promise((e,n)=>{map?(mapReadyObservable.detach(),o(),mapReadyObservable=map.on("ready",()=>{e(map)})):(installComs(),t&&bootstrapCode(o),mapReadyObservable=map.on("ready",(t,o)=>{const{commands:s}=o.commandJSON;try{map=addCommands(map,s)}catch(e){n(e)}log("map ready"),map.observe(function(){const e=Array.from(arguments);e.unshift("Event: "),log.apply(null,e)}),map.setLogging=LMInit.setLogging,e(map)}))})}const LMInit={getVersion:()=>"1.1.2",newMap:newMap,setLogging:e=>{showLogFlag=e,e&&log(`${LIB_NAME} Logging enabled.`)}};export default LMInit; |
{ | ||
"name": "locusmaps-sdk", | ||
"version": "1.1.0", | ||
"description": "This project contains a small script which can be used to initialize and control a LocusMaps instance. See https://locuslabs.com/ for more information.", | ||
"keywords": [ | ||
"map", "mapping", "maps", "indoor", "venue", "geolocation", "geospatial", "locuslabs", "acuitybrands" | ||
], | ||
"version": "1.1.2", | ||
"main": "dist/LocusMapsSDK-umd.js", | ||
"module": "src/sdk.js", | ||
"files": [ | ||
"/dist", | ||
"/src" | ||
], | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://gitlab.com/locuslabspublic/locusmaps-sdk" | ||
}, | ||
"author": "Glenn Crownover <crownover@locuslabs.com>", | ||
"repository": "git@gitlab.com:locuslabs/webengine/locusmaps-sdk.git", | ||
"author": "Glenn Crownover <glenn@bluejava.com>", | ||
"license": "MIT", | ||
@@ -20,0 +9,0 @@ "devDependencies": { |
import observable from './observable.js' | ||
const SDK_CLIENT_VERSION = '1.1.0' | ||
const LIB_NAME = 'Atrius Maps JS SDK Client' | ||
const CLIENT_VERSION = '1.1.2' | ||
@@ -14,7 +15,8 @@ let CODE_HOME = 'https://maps.locuslabs.com/sdk/dist/current/' | ||
// logging setup | ||
const ts = () => { const d = new Date(); return `${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}` } | ||
const logPre = [`%cLocusMaps SDK %c(${ts()})%c: `, 'color: orange', 'font-size: 8px', 'font-size: inherit; color: inherit'] | ||
const pad2 = x => x.toString().length < 2 ? "0" + x : x | ||
const ts = () => { const d = new Date(); return `${d.getHours()}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}.${d.getMilliseconds()}` } | ||
const logPre = () => [`%cLocusMaps SDK %c(${ts()})%c: `, 'color: orange', 'font-size: 8px', 'font-size: inherit; color: inherit'] | ||
const log = function () { | ||
if (showLogFlag) | ||
console.log.apply(null, logPre.concat(Array.from(arguments))) | ||
console.log.apply(null, logPre().concat(Array.from(arguments))) | ||
} | ||
@@ -101,3 +103,4 @@ | ||
installComs() | ||
bootstrapCode(initMap) | ||
if(config) | ||
bootstrapCode(initMap) | ||
mapReadyObservable = map.on('ready', (eName, data) => { | ||
@@ -126,7 +129,7 @@ const { commands/*, customTypes */ } = data.commandJSON | ||
const LMInit = { | ||
getVersion: () => SDK_CLIENT_VERSION, | ||
getVersion: () => CLIENT_VERSION, | ||
newMap, | ||
setLogging: flag => { showLogFlag = flag } | ||
setLogging: flag => { showLogFlag = flag; if(flag) log(`${LIB_NAME} Logging enabled.`) } | ||
} | ||
export default LMInit |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17454
9
190
0
1