@stadiamaps/ferrostar-webcomponents 0.44.0 → 0.45.0
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.
|
@@ -211,5 +211,5 @@
|
|
|
211
211
|
height: 10px;
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
`],p([n({type:Object})],l.FerrostarMap.prototype,"map",2),p([n({type:Object})],l.FerrostarMap.prototype,"stateProvider",2),p([n({type:Object})],l.FerrostarMap.prototype,"customStyles",2),p([n()],l.FerrostarMap.prototype,"tripState",2),p([n({type:Object})],l.FerrostarMap.prototype,"route",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"showNavigationUI",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"showUserMarker",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"geolocateOnLoad",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"addGeolocateControl",2),p([n({type:Function,attribute:!1})],l.FerrostarMap.prototype,"onStopNavigation",2),l.FerrostarMap=p([f("ferrostar-map")],l.FerrostarMap);var Qt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,u=(o,t,e,i)=>{for(var a=i>1?void 0:i?Yt(t,e):t,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&Qt(t,e,a),a};l.FerrostarCore=class extends c.ReactiveElement{constructor(){super(),this.valhallaEndpointUrl="",this.profile="",this.httpClient=fetch,this.options={},this._navState=null,this.useVoiceGuidance=!1,this.shouldRecord=!1,this.routeAdapter=null,this.navigationSession=null,this.lastSpokenUtteranceId=null,this.httpClient===fetch&&(this.httpClient=this.httpClient.bind(window))}updated(t){t.has("locationProvider")&&this.locationProvider&&(this.locationProvider.updateCallback=this.onLocationUpdated.bind(this))}async getRoutes(t,e){this.routeAdapter=new m.RouteAdapter(this.valhallaEndpointUrl,this.profile,JSON.stringify(this.options));const i=this.routeAdapter.generateRequest(t,e),a=i.get("method");let s=new URL(i.get("url"));const r=i.get("body"),d=await this.httpClient(s,{method:a,body:new Uint8Array(r).buffer}),_=new Uint8Array(await d.arrayBuffer());try{return this.routeAdapter.parseResponse(_)}catch(g){throw console.error("Error parsing route response:",g),g}}startNavigation(t,e){this.locationProvider.start(),this.onNavigationStart&&this.onNavigationStart(),this.shouldRecord?this.navigationSession=new m.NavigationSessionRecording(t,e):this.navigationSession=new m.NavigationSession(t,e),this.locationProvider.updateCallback=this.onLocationUpdated.bind(this);const i=this.locationProvider.lastLocation?this.locationProvider.lastLocation:{coordinates:t.geometry[0],horizontalAccuracy:0,courseOverGround:null,timestamp:Date.now(),speed:null};this.navStateUpdate(this.navigationSession.getInitialState(i))}saveRecording(){if(this.navigationSession instanceof m.NavigationSessionRecording){const t=this.navigationSession.getRecording(),e=new Blob([t],{type:"application/json"}),i=document.createElement("a");i.href=URL.createObjectURL(e),i.download="recording.json",i.click(),URL.revokeObjectURL(i.href)}}async stopNavigation(){this.shouldRecord&&this.saveRecording(),this.routeAdapter?.free(),this.routeAdapter=null,this.navigationSession?.free(),this.navigationSession=null,this.navStateUpdate(null),this.locationProvider&&(this.locationProvider.updateCallback=null),this.onNavigationStop&&this.onNavigationStop()}provideState(t){this.dispatchEvent(new CustomEvent("tripstate-update",{detail:{tripState:t},bubbles:!0}))}navStateUpdate(t){this._navState=t,this.onTripStateChange?.(t?.tripState||null),t&&this.provideState(t.tripState)}onLocationUpdated(){if(!this.navigationSession)return;const t=this.navigationSession.updateUserLocation(this.locationProvider.lastLocation,this._navState);this.navStateUpdate(t);const e=this._navState?.tripState;this.useVoiceGuidance&&e!=null&&typeof e=="object"&&"Navigating"in e&&e.Navigating?.spokenInstruction&&e.Navigating?.spokenInstruction.utteranceId!==this.lastSpokenUtteranceId&&(this.lastSpokenUtteranceId=e.Navigating?.spokenInstruction.utteranceId,window.speechSynthesis.cancel(),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e.Navigating?.spokenInstruction.text)))}},u([n()],l.FerrostarCore.prototype,"valhallaEndpointUrl",2),u([n()],l.FerrostarCore.prototype,"profile",2),u([n({attribute:!1})],l.FerrostarCore.prototype,"httpClient",2),u([n({type:Object,attribute:!1})],l.FerrostarCore.prototype,"locationProvider",2),u([n({type:Object,attribute:!1})],l.FerrostarCore.prototype,"options",2),u([o0()],l.FerrostarCore.prototype,"_navState",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onNavigationStart",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onNavigationStop",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onTripStateChange",2),u([n({type:Boolean})],l.FerrostarCore.prototype,"useVoiceGuidance",2),u([n({type:Boolean})],l.FerrostarCore.prototype,"shouldRecord",2),l.FerrostarCore=u([f("ferrostar-core")],l.FerrostarCore);function E(o){let t=null;return o.coords.speed&&(t={value:o.coords.speed}),{coordinates:{lat:o.coords.latitude,lng:o.coords.longitude},horizontalAccuracy:o.coords.accuracy,courseOverGround:{degrees:Math.floor(o.coords.heading||0)},timestamp:o.timestamp,speed:t}}class te{constructor(){this.simulationState=null,this.isRunning=!1,this.lastLocation=null,this.lastHeading=null,this.warpFactor=1,this.updateCallback=()=>{}}setSimulatedRoute(t){this.simulationState=m.locationSimulationFromRoute(t,10,"None"),this.lastLocation=this.simulationState?.current_location,this.start()}async start(){if(!this.isRunning){for(this.isRunning=!0;this.simulationState!==null;){await new Promise(i=>setTimeout(i,1/this.warpFactor*1e3));const t=this.simulationState,e=m.advanceLocationSimulation(t);if(t===e)return;this.simulationState=e,this.lastLocation=e.current_location,this.updateCallback&&this.updateCallback()}this.isRunning=!1}}stop(){this.simulationState=null}}class ee{constructor(){this.geolocationWatchId=null,this.lastLocation=null,this.lastHeading=null,this.updateCallback=()=>{}}start(){if(navigator.geolocation&&!this.geolocationWatchId){const t={enableHighAccuracy:!0};this.geolocationWatchId=navigator.geolocation.watchPosition(e=>{this.lastLocation=E(e),this.updateCallback&&this.updateCallback()},e=>{this.geolocationWatchId=null,alert(e.message)},t)}}getCurrentLocation(t){if(!navigator.geolocation)return new Promise((i,a)=>{a("This navigator does not support geolocation.")});const e=new Date().getTime()-t;return this.lastLocation&&this.lastLocation.timestamp>e?this.lastLocation:new Promise((i,a)=>{navigator.geolocation.getCurrentPosition(s=>{const r=E(s);this.lastLocation=r,i(r)},a)})}stop(){this.lastLocation=null,navigator.geolocation&&this.geolocationWatchId&&(navigator.geolocation.clearWatch(this.geolocationWatchId),this.geolocationWatchId=null)}}l.BrowserLocationProvider=ee,l.SimulatedLocationProvider=te,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
214
|
+
`],p([n({type:Object})],l.FerrostarMap.prototype,"map",2),p([n({type:Object})],l.FerrostarMap.prototype,"stateProvider",2),p([n({type:Object})],l.FerrostarMap.prototype,"customStyles",2),p([n()],l.FerrostarMap.prototype,"tripState",2),p([n({type:Object})],l.FerrostarMap.prototype,"route",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"showNavigationUI",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"showUserMarker",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"geolocateOnLoad",2),p([n({type:Boolean})],l.FerrostarMap.prototype,"addGeolocateControl",2),p([n({type:Function,attribute:!1})],l.FerrostarMap.prototype,"onStopNavigation",2),l.FerrostarMap=p([f("ferrostar-map")],l.FerrostarMap);var Qt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,u=(o,t,e,i)=>{for(var a=i>1?void 0:i?Yt(t,e):t,s=o.length-1,r;s>=0;s--)(r=o[s])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&Qt(t,e,a),a};l.FerrostarCore=class extends c.ReactiveElement{constructor(){super(),this.valhallaEndpointUrl="",this.profile="",this.httpClient=fetch,this.options={},this._navState=null,this.useVoiceGuidance=!1,this.shouldRecord=!1,this.routeAdapter=null,this.navigationSession=null,this.lastSpokenUtteranceId=null,this.httpClient===fetch&&(this.httpClient=this.httpClient.bind(window))}updated(t){t.has("locationProvider")&&this.locationProvider&&(this.locationProvider.updateCallback=this.onLocationUpdated.bind(this))}async getRoutes(t,e){this.routeAdapter=new m.RouteAdapter({Valhalla:{endpointUrl:this.valhallaEndpointUrl,profile:this.profile,optionsJson:JSON.stringify(this.options)}});const i=this.routeAdapter.generateRequest(t,e),a=i.get("method");let s=new URL(i.get("url"));const r=i.get("body"),d=await this.httpClient(s,{method:a,body:new Uint8Array(r).buffer}),_=new Uint8Array(await d.arrayBuffer());try{return this.routeAdapter.parseResponse(_)}catch(g){throw console.error("Error parsing route response:",g),g}}startNavigation(t,e){this.locationProvider.start(),this.onNavigationStart&&this.onNavigationStart(),this.shouldRecord?this.navigationSession=new m.NavigationSessionRecording(t,e):this.navigationSession=new m.NavigationSession(t,e),this.locationProvider.updateCallback=this.onLocationUpdated.bind(this);const i=this.locationProvider.lastLocation?this.locationProvider.lastLocation:{coordinates:t.geometry[0],horizontalAccuracy:0,courseOverGround:null,timestamp:Date.now(),speed:null};this.navStateUpdate(this.navigationSession.getInitialState(i))}saveRecording(){if(this.navigationSession instanceof m.NavigationSessionRecording){const t=this.navigationSession.getRecording(),e=new Blob([t],{type:"application/json"}),i=document.createElement("a");i.href=URL.createObjectURL(e),i.download="recording.json",i.click(),URL.revokeObjectURL(i.href)}}async stopNavigation(){this.shouldRecord&&this.saveRecording(),this.routeAdapter?.free(),this.routeAdapter=null,this.navigationSession?.free(),this.navigationSession=null,this.navStateUpdate(null),this.locationProvider&&(this.locationProvider.updateCallback=null),this.onNavigationStop&&this.onNavigationStop()}provideState(t){this.dispatchEvent(new CustomEvent("tripstate-update",{detail:{tripState:t},bubbles:!0}))}navStateUpdate(t){this._navState=t,this.onTripStateChange?.(t?.tripState||null),t&&this.provideState(t.tripState)}onLocationUpdated(){if(!this.navigationSession)return;const t=this.navigationSession.updateUserLocation(this.locationProvider.lastLocation,this._navState);this.navStateUpdate(t);const e=this._navState?.tripState;this.useVoiceGuidance&&e!=null&&typeof e=="object"&&"Navigating"in e&&e.Navigating?.spokenInstruction&&e.Navigating?.spokenInstruction.utteranceId!==this.lastSpokenUtteranceId&&(this.lastSpokenUtteranceId=e.Navigating?.spokenInstruction.utteranceId,window.speechSynthesis.cancel(),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e.Navigating?.spokenInstruction.text)))}},u([n()],l.FerrostarCore.prototype,"valhallaEndpointUrl",2),u([n()],l.FerrostarCore.prototype,"profile",2),u([n({attribute:!1})],l.FerrostarCore.prototype,"httpClient",2),u([n({type:Object,attribute:!1})],l.FerrostarCore.prototype,"locationProvider",2),u([n({type:Object,attribute:!1})],l.FerrostarCore.prototype,"options",2),u([o0()],l.FerrostarCore.prototype,"_navState",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onNavigationStart",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onNavigationStop",2),u([n({type:Function,attribute:!1})],l.FerrostarCore.prototype,"onTripStateChange",2),u([n({type:Boolean})],l.FerrostarCore.prototype,"useVoiceGuidance",2),u([n({type:Boolean})],l.FerrostarCore.prototype,"shouldRecord",2),l.FerrostarCore=u([f("ferrostar-core")],l.FerrostarCore);function E(o){let t=null;return o.coords.speed&&(t={value:o.coords.speed}),{coordinates:{lat:o.coords.latitude,lng:o.coords.longitude},horizontalAccuracy:o.coords.accuracy,courseOverGround:{degrees:Math.floor(o.coords.heading||0)},timestamp:o.timestamp,speed:t}}class te{constructor(){this.simulationState=null,this.isRunning=!1,this.lastLocation=null,this.lastHeading=null,this.warpFactor=1,this.updateCallback=()=>{}}setSimulatedRoute(t){this.simulationState=m.locationSimulationFromRoute(t,10,"None"),this.lastLocation=this.simulationState?.current_location,this.start()}async start(){if(!this.isRunning){for(this.isRunning=!0;this.simulationState!==null;){await new Promise(i=>setTimeout(i,1/this.warpFactor*1e3));const t=this.simulationState,e=m.advanceLocationSimulation(t);if(t===e)return;this.simulationState=e,this.lastLocation=e.current_location,this.updateCallback&&this.updateCallback()}this.isRunning=!1}}stop(){this.simulationState=null}}class ee{constructor(){this.geolocationWatchId=null,this.lastLocation=null,this.lastHeading=null,this.updateCallback=()=>{}}start(){if(navigator.geolocation&&!this.geolocationWatchId){const t={enableHighAccuracy:!0};this.geolocationWatchId=navigator.geolocation.watchPosition(e=>{this.lastLocation=E(e),this.updateCallback&&this.updateCallback()},e=>{this.geolocationWatchId=null,alert(e.message)},t)}}getCurrentLocation(t){if(!navigator.geolocation)return new Promise((i,a)=>{a("This navigator does not support geolocation.")});const e=new Date().getTime()-t;return this.lastLocation&&this.lastLocation.timestamp>e?this.lastLocation:new Promise((i,a)=>{navigator.geolocation.getCurrentPosition(s=>{const r=E(s);this.lastLocation=r,i(r)},a)})}stop(){this.lastLocation=null,navigator.geolocation&&this.geolocationWatchId&&(navigator.geolocation.clearWatch(this.geolocationWatchId),this.geolocationWatchId=null)}}l.BrowserLocationProvider=ee,l.SimulatedLocationProvider=te,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
215
215
|
//# sourceMappingURL=ferrostar-webcomponents.umd.cjs.map
|