@telemetryos/root-sdk 1.11.0 → 1.13.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.
- package/CHANGELOG.md +27 -0
- package/README.md +58 -0
- package/dist/client.d.ts +2 -0
- package/dist/currency.spec.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +251 -226
- package/dist/navigation.d.ts +13 -0
- package/dist/navigation.spec.d.ts +1 -0
- package/dist/weather.spec.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @telemetryos/root-sdk
|
|
2
2
|
|
|
3
|
+
## 1.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ### New Features
|
|
8
|
+
- **Web mount point support** — Applications can now define a third UI surface (`/web`) alongside Render and Settings, enabling web-portal-style interfaces with full navigation control via a postMessage bridge.
|
|
9
|
+
- **`playlist.getDuration()`** — New async method returns the playlist-configured page duration in seconds.
|
|
10
|
+
- **Custom logo support** — Projects can specify a `logoPath` in `telemetry.config.json` for branding in the dev host.
|
|
11
|
+
- **`tos claude-code` command** — New CLI command to apply or update Claude Code skills and settings in existing projects.
|
|
12
|
+
- **Web project template** — New `vite-react-typescript-web` template scaffolds a project with all three mount points pre-configured.
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
- Fixed SDK client not properly validating bridge message responses.
|
|
16
|
+
- Fixed canvas not resizing when the sidebar toggles or window resizes after a manual drag-resize.
|
|
17
|
+
- Fixed `isLoading` usage and `useEffect` dependency arrays in Claude Code skill examples.
|
|
18
|
+
- Fixed stale active tab when the tabs array changes in the dev host.
|
|
19
|
+
|
|
20
|
+
### Infrastructure
|
|
21
|
+
- Renamed `generate-application` to `create-project`; extracted shared template utilities.
|
|
22
|
+
- Added unit tests for Navigation, Currency, and Weather classes.
|
|
23
|
+
|
|
24
|
+
## 1.12.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- Revamp the dev host
|
|
29
|
+
|
|
3
30
|
## 1.11.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -301,6 +301,64 @@ const blob = await response.blob();
|
|
|
301
301
|
const imageUrl = URL.createObjectURL(blob);
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
+
### Weather API
|
|
305
|
+
|
|
306
|
+
Access weather data including current conditions, forecasts, and alerts. Weather data is sourced from WeatherBit and uses city IDs for location lookup.
|
|
307
|
+
|
|
308
|
+
```javascript
|
|
309
|
+
import { weather } from '@telemetryos/root-sdk';
|
|
310
|
+
|
|
311
|
+
// Search for cities to get a cityId
|
|
312
|
+
const cities = await weather().getCities({ search: 'New York', countryCode: 'US' });
|
|
313
|
+
const cityId = cities[0].cityId;
|
|
314
|
+
|
|
315
|
+
// Get current weather conditions
|
|
316
|
+
const conditions = await weather().getConditions({ cityId });
|
|
317
|
+
console.log(`${conditions.temperatureC}°C / ${conditions.temperatureF}°F`);
|
|
318
|
+
console.log(`Wind: ${conditions.windSpeedKph} kph`);
|
|
319
|
+
console.log(`Humidity: ${conditions.humidity}%`);
|
|
320
|
+
|
|
321
|
+
// Get daily forecast (up to 16 days)
|
|
322
|
+
const daily = await weather().getDailyForecast({ cityId, days: 7 });
|
|
323
|
+
daily.data.forEach(day => {
|
|
324
|
+
console.log(`${day.forecastDate}: ${day.weatherDescription}`);
|
|
325
|
+
console.log(`High: ${day.maxTemperatureC}°C, Low: ${day.minTemperatureC}°C`);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Get hourly forecast (up to 120 hours)
|
|
329
|
+
const hourly = await weather().getHourlyForecast({ cityId, hours: 24 });
|
|
330
|
+
hourly.data.forEach(hour => {
|
|
331
|
+
console.log(`${hour.forecastTimeLocal}: ${hour.temperatureC}°C`);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Get weather alerts
|
|
335
|
+
const alerts = await weather().getAlerts({ cityId });
|
|
336
|
+
alerts.alerts.forEach(alert => {
|
|
337
|
+
console.log(`${alert.severity}: ${alert.title}`);
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
All weather responses include dual units (Celsius/Fahrenheit, kph/mph, mb/inHg, km/mi) so you can display data in the user's preferred format. An optional `language` parameter is available on all methods for localized weather descriptions.
|
|
342
|
+
|
|
343
|
+
### Currency API
|
|
344
|
+
|
|
345
|
+
Access currency exchange rates and symbols:
|
|
346
|
+
|
|
347
|
+
```javascript
|
|
348
|
+
import { currency } from '@telemetryos/root-sdk';
|
|
349
|
+
|
|
350
|
+
// Get all available currency symbols
|
|
351
|
+
const symbols = await currency().getSymbols();
|
|
352
|
+
// { "USD": "United States Dollar", "EUR": "Euro", ... }
|
|
353
|
+
|
|
354
|
+
// Get exchange rates for a base currency
|
|
355
|
+
const rates = await currency().getRates({
|
|
356
|
+
base: 'USD',
|
|
357
|
+
symbols: 'EUR,GBP,JPY'
|
|
358
|
+
});
|
|
359
|
+
// { "EUR": 0.92, "GBP": 0.79, "JPY": 149.50 }
|
|
360
|
+
```
|
|
361
|
+
|
|
304
362
|
## Communication Patterns
|
|
305
363
|
|
|
306
364
|
The SDK uses a request-response pattern for most operations. All requests have a 30-second timeout by default to prevent hanging promises:
|
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Weather } from './weather.js';
|
|
|
10
10
|
import { Currency } from './currency.js';
|
|
11
11
|
import { Environment } from './environment.js';
|
|
12
12
|
import { Mqtt } from './mqtt.js';
|
|
13
|
+
import { Navigation } from './navigation.js';
|
|
13
14
|
import { BridgeMessage } from './bridge.js';
|
|
14
15
|
/**
|
|
15
16
|
* The maximum time in milliseconds to wait for a response to a request call.
|
|
@@ -78,6 +79,7 @@ export declare class Client {
|
|
|
78
79
|
_applicationName: string;
|
|
79
80
|
_applicationInstance: string;
|
|
80
81
|
_applicationSpecifier: string;
|
|
82
|
+
_navigation: Navigation;
|
|
81
83
|
_messageInterceptors: Map<string, MessageInterceptor>;
|
|
82
84
|
_onHandlers: Map<string, MessageHandler<any>[]>;
|
|
83
85
|
_onceHandlers: Map<string, MessageHandler<any>[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./types-mYnxD5LM.cjs"),Q="1.11.0",U={version:Q};class T{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class M{constructor(e){this._client=e}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async getByName(e){return(await this._client.request("applications.getByName",{name:e})).application}async setDependencies(e){return await this._client.request("applications.setDependencies",{applicationSpecifiers:e},{timeout:0})}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class H{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}async getCapabilities(){const e=await this._client.request("devices.getCapabilities",{});if(!e.success)throw new Error("Failed to get device capabilities");return e.capabilities}}class P{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class F{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}async openPicker(e){return(await this._client.request("media.openPicker",{accept:e==null?void 0:e.accept,currentValue:e==null?void 0:e.currentValue})).selection}}class k{constructor(e){this._client=e}async fetch(e,t){var s;let r;typeof e=="string"?r=e:e instanceof URL?r=e.toString():(r=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let n={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((l,d)=>{n[d]=l}):Array.isArray(t.headers)?t.headers.forEach(([l,d])=>{n[l]=d}):n=t.headers);const o=await this._client.request("proxy.fetch",{url:r,method:(t==null?void 0:t.method)||"GET",headers:n,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!o.success)throw new TypeError(o.errorMessage,{cause:o.errorCause?Error(o.errorCause):void 0});const u=new Headers(o.headers),a={status:o.status,statusText:o.statusText,headers:u};let p=null;if(o.body!==null&&o.body!==void 0)if(o.bodyType==="binary"){const l=atob(o.body),d=new Uint8Array(l.length);for(let f=0;f<l.length;f++)d[f]=l.charCodeAt(f);p=d}else o.bodyType==="text"?p=o.body:o.bodyType==="json"&&(p=JSON.stringify(o.body));return new Response(p,a)}}class A{constructor(e){this._client=e}get application(){return new v("application","",this._client)}get instance(){return new v("instance",this._client.applicationInstance,this._client)}get device(){return new v("device",this._client.applicationInstance,this._client)}shared(e){return new v("shared",e,this._client)}}class v{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class B{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current user");return e.user}}class ${constructor(e){this._client=e}async getCities(e){const t=await this._client.request("weather.getCities",e);if(!t.success)throw new Error(t.error||"Failed to fetch cities");return t.data||[]}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather conditions");return t}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch daily forecast");return t}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch hourly forecast");return t}async getAlerts(e){const t=await this._client.request("weather.getAlerts",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather alerts");return t}}class R{constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,r;const n=await this._client.request("currency.getRates",e);if(!n.success||!n.rates)throw((t=n.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=n.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((r=n.error)===null||r===void 0?void 0:r.message)||"Failed to fetch currency rates");return n.rates}}class x{constructor(e){this._client=e}async discover(){const e=await this._client.request("mqtt.discover",{});if(!e.success)throw new Error("Failed to discover MQTT brokers");return e.brokers}async connect(e,t){const s=await this._client.request("mqtt.connect",{brokerUrl:e,...t});if(!s.success)throw new Error("Failed to connect to MQTT broker");return s.clientId}async disconnect(e){if(!(await this._client.request("mqtt.disconnect",{clientId:e})).success)throw new Error("Failed to disconnect from MQTT broker")}async publish(e,t,s,r){if(!(await this._client.request("mqtt.publish",{clientId:e,topic:t,payload:s,...r})).success)throw new Error("Failed to publish MQTT message")}async subscribe(e,t,s,r){return(await this._client.subscribe("mqtt.subscribe",{clientId:e,topic:t,...r},s)).success}async unsubscribe(e,t,s){return(await this._client.unsubscribe("mqtt.unsubscribe",{clientId:e,topic:t},s)).success}async getConnectionStatus(e){const t=await this._client.request("mqtt.getConnectionStatus",{clientId:e});if(!t.success)throw new Error("Failed to get MQTT connection status");return t.status}async subscribeConnectionStatus(e,t){return(await this._client.subscribe("mqtt.subscribeConnectionStatus",{clientId:e},t)).success}async unsubscribeConnectionStatus(e,t){return(await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus",{clientId:e},t)).success}}function E(c){return{...c,type:"client"}}const V=N.objectType({type:N.literalType("bridge"),name:N.stringType(),data:N.anyType()});class L{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),r=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},n=this._store._client._applicationSpecifier;r[n]={applicationSpecifier:n,entries:e.entries},s.set("navigation",r)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},r=this._store._client._applicationSpecifier;return s[r]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}const b=1e3*30,C=typeof window>"u"&&typeof self<"u",S=C?self:window;function y(c){C?self.postMessage(c):S.parent.postMessage(c,"*")}class j{constructor(e){this._applicationName=e,this._applicationInstance="",this._applicationSpecifier="",this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map}get accounts(){return new T(this)}get users(){return new B(this)}get store(){return new A(this)}get applications(){return new M(this)}get media(){return new F(this)}get proxy(){return new k(this)}get devices(){return new H(this)}get rootSettingsNavigation(){return new L(this.store)}get weather(){return new $(this)}get currency(){return new R(this)}get environment(){return new P(this)}get mqtt(){return new x(this)}get applicationName(){return this._applicationName}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}bind(){var e,t,s;const r=new URL(S.location.href),n=r.searchParams;if(this._applicationInstance=(e=n.get("applicationInstance"))!==null&&e!==void 0?e:"",!this._applicationInstance)throw new Error("Missing applicationInstance query parameter");if(this._applicationSpecifier=(t=n.get("applicationSpecifier"))!==null&&t!==void 0?t:"",!this._applicationSpecifier){const o=r.hostname.split(".");this._applicationSpecifier=(s=o[0])!==null&&s!==void 0?s:""}if(!this._applicationSpecifier||this._applicationSpecifier.length!==40)throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=o=>{if(o.source===S||!o.data||typeof o.data!="object"||!("type"in o.data)||o.data.type!=="client"&&o.data.type!=="bridge")return;let u;if(o.data.type==="client"){const a=this._messageInterceptors.get(o.data.name);if(!a){y(o.data);return}u={...a(o.data.data),type:"bridge"}}if(!u){const a=V.safeParse(o.data);if(!a.success)return;u=a.data;const p=this._onHandlers.get(u.name),l=this._onceHandlers.get(u.name);if(p)for(const d of p)d(u.data);if(l){for(const d of l)d(u.data);this._onceHandlers.delete(u.name)}}if(!C)for(let a=0;a<window.frames.length;a+=1)window.frames[a].postMessage(u,"*")},S.addEventListener("message",this._windowMessageHandler)}unbind(){this._windowMessageHandler&&S.removeEventListener("message",this._windowMessageHandler)}send(e,t){const s=E({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t});y(s)}request(e,t,s){var r;const n=I(),o=E({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t,responseName:n});y(o);const u=(r=s==null?void 0:s.timeout)!==null&&r!==void 0?r:b;let a=!1,p;const l=new Promise(f=>{p=g=>{a||f(g)},this.once(n,p)});if(u===0)return l;const d=new Promise((f,g)=>{const w=new Error(`${e} message request with response name of ${n} timed out after ${u}`);setTimeout(()=>{a=!0,this.off(n,p),g(w)},u)});return Promise.race([d,l])}async subscribe(e,t,s){let r,n;typeof t=="function"?n=t:(r=t,n=s);const o=I(),u=I();let a=this._subscriptionNamesBySubjectName.get(e);a||(a=[],this._subscriptionNamesBySubjectName.set(e,a)),a.push(o),this._subscriptionNamesByHandler.set(n,o),this.on(o,n);const p=E({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:r,responseName:u,subscriptionName:o});y(p);let l=!1,d;const f=new Promise((w,m)=>{const _=new Error(`${e} subscribe request with subscription name of ${o} and response name of ${u} timed out after ${b}`);setTimeout(()=>{l=!0,this.off(u,d),m(_)},b)}),g=new Promise(w=>{d=m=>{l||w(m)},this.on(u,w)});return Promise.race([f,g])}async unsubscribe(e,t,s){let r,n;typeof t=="function"?n=t:(r=t,n=s);const o=I();let u=[];if(n){const a=this._subscriptionNamesByHandler.get(n);if(!a)return{success:!1};u=[a],this._subscriptionNamesByHandler.delete(n)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const a of u){this.off(a,n);const p=E({telemetrySdkVersion:q,applicationInstance:this._applicationInstance,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,name:e,data:r,responseName:o,unsubscribeName:a});y(p);let l=!1,d;const f=new Promise((m,_)=>{const D=new Error(`${e} unsubscribe request with unsubscribe name of ${a} and response name of ${o} timed out after ${b}`);setTimeout(()=>{l=!0,this.off(o,d),_(D)},b)}),g=new Promise(m=>{d=_=>{l||m(_)},this.once(o,m)});if(!(await Promise.race([f,g])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const r=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];r.length===0&&this._onHandlers.set(e,r),r.push(t)}once(e,t){var s;const r=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];r.length===0&&this._onceHandlers.set(e,r),r.push(t)}off(e,t){const s=this._onHandlers.get(e),r=this._onceHandlers.get(e);if(!(!s&&!r)){if(s){for(let n=0;n<s.length;n+=1)t&&s[n]!==t||(s.splice(n,1),n-=1);s.length===0&&this._onHandlers.delete(e)}if(r){for(let n=0;n<r.length;n+=1)t&&r[n]!==t||(r.splice(n,1),n-=1);r.length===0&&this._onceHandlers.delete(e)}}}}function I(){return Math.random().toString(36).slice(2,9)}const q=U.version;let i=null;function W(){return i}function O(c){i=new j(c),i.bind()}function G(){i==null||i.unbind(),i=null}function J(...c){return h(i),i.on(...c)}function K(...c){return h(i),i.once(...c)}function z(...c){return h(i),i.off(...c)}function X(...c){return h(i),i.send(...c)}function Y(...c){return h(i),i.request(...c)}function Z(...c){return h(i),i.subscribe(...c)}function ee(...c){return h(i),i.unsubscribe(...c)}function te(){return h(i),i.store}function se(){return h(i),i.applications}function ne(){return h(i),i.media}function re(){return h(i),i.accounts}function ie(){return h(i),i.users}function oe(){return h(i),i.devices}function ce(){return h(i),i.proxy}function ae(){return h(i),i.rootSettingsNavigation}function ue(){return h(i),i.weather}function le(){return h(i),i.currency}function he(){return h(i),i.environment}function de(){return h(i),i.mqtt}function h(c){if(!c)throw new Error("SDK is not configured")}exports.Accounts=T;exports.Applications=M;exports.Client=j;exports.Currency=R;exports.Devices=H;exports.Environment=P;exports.Media=F;exports.Mqtt=x;exports.Proxy=k;exports.Store=A;exports.StoreSlice=v;exports.Users=B;exports.Weather=$;exports.accounts=re;exports.applications=se;exports.configure=O;exports.currency=le;exports.destroy=G;exports.devices=oe;exports.environment=he;exports.globalClient=W;exports.media=ne;exports.mqtt=de;exports.off=z;exports.on=J;exports.once=K;exports.proxy=ce;exports.request=Y;exports.rootSettingsNavigation=ae;exports.send=X;exports.store=te;exports.subscribe=Z;exports.telemetrySdkVersion=q;exports.unsubscribe=ee;exports.users=ie;exports.weather=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./types-mYnxD5LM.cjs"),Q="1.13.0",U={version:Q};class I{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("accounts.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current account");return e.account}}class P{constructor(e){this._client=e}async getAllByMountPoint(e){return(await this._client.request("applications.getAllByMountPoint",{mountPoint:e})).applications}async getByName(e){return(await this._client.request("applications.getByName",{name:e})).application}async setDependencies(e){return await this._client.request("applications.setDependencies",{applicationSpecifiers:e},{timeout:0})}bind(e,t){if(this._client._messageInterceptors.has(e))throw new Error(`Interceptor already bound for message ${e}`);this._client._messageInterceptors.set(e,t)}}class T{constructor(e){this._client=e}async getInformation(){const e=await this._client.request("devices.getInformation",{});if(!e.success)throw new Error("Failed to get device information");return e.deviceInformation}async getCapabilities(){const e=await this._client.request("devices.getCapabilities",{});if(!e.success)throw new Error("Failed to get device capabilities");return e.capabilities}}class M{constructor(e){this._client=e}async getColorScheme(){return(await this._client.request("environment.getColorScheme",{})).colorScheme}async subscribeColorScheme(e){return(await this._client.subscribe("environment.subscribeColorScheme",{},e)).success}async unsubscribeColorScheme(e){return(await this._client.unsubscribe("environment.unsubscribeColorScheme",{},e)).success}}class k{constructor(e){this._client=e}async getAllFolders(){return(await this._client.request("mediaFolders.getAll",{})).folders}async getAllByFolderId(e){return(await this._client.request("media.getAllByFolderId",{folderId:e})).contents}async getAllByTag(e){return(await this._client.request("media.getAllByTag",{tagName:e})).contents}async getById(e){return(await this._client.request("media.getById",{id:e})).content}async openPicker(e){return(await this._client.request("media.openPicker",{accept:e==null?void 0:e.accept,currentValue:e==null?void 0:e.currentValue})).selection}}class F{constructor(e){this._client=e}async fetch(e,t){var s;let i;typeof e=="string"?i=e:e instanceof URL?i=e.toString():(i=e.url,t||(t={method:e.method,headers:e.headers,body:e.body,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}));let n={};t!=null&&t.headers&&(t.headers instanceof Headers?t.headers.forEach((h,u)=>{n[u]=h}):Array.isArray(t.headers)?t.headers.forEach(([h,u])=>{n[h]=u}):n=t.headers);const a=await this._client.request("proxy.fetch",{url:i,method:(t==null?void 0:t.method)||"GET",headers:n,body:(s=t==null?void 0:t.body)!==null&&s!==void 0?s:null});if(!a.success)throw new TypeError(a.errorMessage,{cause:a.errorCause?Error(a.errorCause):void 0});const l=new Headers(a.headers),c={status:a.status,statusText:a.statusText,headers:l};let p=null;if(a.body!==null&&a.body!==void 0)if(a.bodyType==="binary"){const h=atob(a.body),u=new Uint8Array(h.length);for(let f=0;f<h.length;f++)u[f]=h.charCodeAt(f);p=u}else a.bodyType==="text"?p=a.body:a.bodyType==="json"&&(p=JSON.stringify(a.body));return new Response(p,c)}}class A{constructor(e){this._client=e}get application(){return new v("application","",this._client)}get instance(){return new v("instance",this._client.applicationInstance,this._client)}get device(){return new v("device",this._client.applicationInstance,this._client)}shared(e){return new v("shared",e,this._client)}}class v{constructor(e,t,s){this._kind=e,this._namespace=t,this._client=s}async set(e,t){return(await this._client.request("store.set",{kind:this._kind,namespace:this._namespace,key:e,value:t})).success}async get(e){return(await this._client.request("store.get",{kind:this._kind,namespace:this._namespace,key:e})).value}async subscribe(e,t){return(await this._client.subscribe("store.subscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async unsubscribe(e,t){return(await this._client.unsubscribe("store.unsubscribe",{kind:this._kind,namespace:this._namespace,key:e},t)).success}async delete(e){return(await this._client.request("store.delete",{kind:this._kind,namespace:this._namespace,key:e})).success}}class R{constructor(e){this._client=e}async getCurrent(){const e=await this._client.request("users.getCurrent",{});if(!e.success)throw new Error("Failed to fetch current user");return e.user}}class B{constructor(e){this._client=e}async getCities(e){const t=await this._client.request("weather.getCities",e);if(!t.success)throw new Error(t.error||"Failed to fetch cities");return t.data||[]}async getConditions(e){const t=await this._client.request("weather.getConditions",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather conditions");return t}async getDailyForecast(e){const t=await this._client.request("weather.getDailyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch daily forecast");return t}async getHourlyForecast(e){const t=await this._client.request("weather.getHourlyForecast",e);if(!t.success)throw new Error(t.error||"Failed to fetch hourly forecast");return t}async getAlerts(e){const t=await this._client.request("weather.getAlerts",e);if(!t.success)throw new Error(t.error||"Failed to fetch weather alerts");return t}}class ${constructor(e){this._client=e}async getSymbols(){const e=await this._client.request("currency.getSymbols",{});if(!e.success||!e.symbols)throw new Error("Failed to fetch currency symbols");return e.symbols}async getRates(e){var t,s,i;const n=await this._client.request("currency.getRates",e);if(!n.success||!n.rates)throw((t=n.error)===null||t===void 0?void 0:t.code)===201?new Error(`Invalid base currency '${e.base}'`):((s=n.error)===null||s===void 0?void 0:s.code)===202?new Error(`Invalid target currency symbol '${e.symbols}'`):new Error(((i=n.error)===null||i===void 0?void 0:i.message)||"Failed to fetch currency rates");return n.rates}}class x{constructor(e){this._client=e}async discover(){const e=await this._client.request("mqtt.discover",{});if(!e.success)throw new Error("Failed to discover MQTT brokers");return e.brokers}async connect(e,t){const s=await this._client.request("mqtt.connect",{brokerUrl:e,...t});if(!s.success)throw new Error("Failed to connect to MQTT broker");return s.clientId}async disconnect(e){if(!(await this._client.request("mqtt.disconnect",{clientId:e})).success)throw new Error("Failed to disconnect from MQTT broker")}async publish(e,t,s,i){if(!(await this._client.request("mqtt.publish",{clientId:e,topic:t,payload:s,...i})).success)throw new Error("Failed to publish MQTT message")}async subscribe(e,t,s,i){return(await this._client.subscribe("mqtt.subscribe",{clientId:e,topic:t,...i},s)).success}async unsubscribe(e,t,s){return(await this._client.unsubscribe("mqtt.unsubscribe",{clientId:e,topic:t},s)).success}async getConnectionStatus(e){const t=await this._client.request("mqtt.getConnectionStatus",{clientId:e});if(!t.success)throw new Error("Failed to get MQTT connection status");return t.status}async subscribeConnectionStatus(e,t){return(await this._client.subscribe("mqtt.subscribeConnectionStatus",{clientId:e},t)).success}async unsubscribeConnectionStatus(e,t){return(await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus",{clientId:e},t)).success}}class L{constructor(e){this._originalPushState=null,this._originalReplaceState=null,this._popstateHandler=null,this._backHandler=null,this._forwardHandler=null,this._client=e}bind(){typeof window>"u"||this._originalPushState||(this._originalPushState=history.pushState.bind(history),history.pushState=(...e)=>{this._originalPushState(...e),this._sendLocationChanged()},this._originalReplaceState=history.replaceState.bind(history),history.replaceState=(...e)=>{this._originalReplaceState(...e),this._sendLocationChanged()},this._popstateHandler=()=>this._sendLocationChanged(),window.addEventListener("popstate",this._popstateHandler),this._backHandler=()=>history.back(),this._forwardHandler=()=>history.forward(),this._client.on("navigation.back",this._backHandler),this._client.on("navigation.forward",this._forwardHandler),this._sendLocationChanged())}unbind(){typeof window>"u"||(this._originalPushState&&(history.pushState=this._originalPushState,this._originalPushState=null),this._originalReplaceState&&(history.replaceState=this._originalReplaceState,this._originalReplaceState=null),this._popstateHandler&&(window.removeEventListener("popstate",this._popstateHandler),this._popstateHandler=null),this._backHandler&&(this._client.off("navigation.back",this._backHandler),this._backHandler=null),this._forwardHandler&&(this._client.off("navigation.forward",this._forwardHandler),this._forwardHandler=null))}_sendLocationChanged(){this._client.send("navigation.locationChanged",{pathname:window.location.pathname})}}function H(o){return{...o,type:"client"}}const V=N.objectType({type:N.literalType("bridge"),name:N.stringType(),data:N.anyType()});class W{constructor(e){if(e._client._applicationSpecifier!=="rootSettingsNavigation")throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");this._store=e}async setRootSettingsNavigation(e){var t;const s=this._store.shared("root-settings-navigation"),i=(t=await s.get("navigation"))!==null&&t!==void 0?t:{},n=this._store._client._applicationSpecifier;i[n]={applicationSpecifier:n,entries:e.entries},s.set("navigation",i)}async getRootSettingsNavigation(){var e;const s=(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{},i=this._store._client._applicationSpecifier;return s[i]}async getAllRootSettingsNavigation(){var e;return(e=await this._store.shared("root-settings-navigation").get("navigation"))!==null&&e!==void 0?e:{}}}const m=1e3*30,C=typeof window>"u"&&typeof self<"u",S=C?self:window;function y(o){C?self.postMessage(o):S.parent.postMessage(o,"*")}class j{constructor(e){this._applicationName=e,this._applicationInstance="",this._applicationSpecifier="",this._navigation=new L(this),this._messageInterceptors=new Map,this._onHandlers=new Map,this._onceHandlers=new Map,this._subscriptionNamesByHandler=new Map,this._subscriptionNamesBySubjectName=new Map}get accounts(){return new I(this)}get users(){return new R(this)}get store(){return new A(this)}get applications(){return new P(this)}get media(){return new k(this)}get proxy(){return new F(this)}get devices(){return new T(this)}get rootSettingsNavigation(){return new W(this.store)}get weather(){return new B(this)}get currency(){return new $(this)}get environment(){return new M(this)}get mqtt(){return new x(this)}get applicationName(){return this._applicationName}get applicationSpecifier(){return this._applicationSpecifier}get applicationInstance(){return this._applicationInstance}bind(){var e,t,s;const i=new URL(S.location.href),n=i.searchParams;if(this._applicationInstance=(e=n.get("applicationInstance"))!==null&&e!==void 0?e:"",!this._applicationInstance)throw new Error("Missing applicationInstance query parameter");if(this._applicationSpecifier=(t=n.get("applicationSpecifier"))!==null&&t!==void 0?t:"",!this._applicationSpecifier){const a=i.hostname.split(".");this._applicationSpecifier=(s=a[0])!==null&&s!==void 0?s:""}if(!this._applicationSpecifier||this._applicationSpecifier.length!==40)throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);this._windowMessageHandler=a=>{if(a.source===S||!a.data||typeof a.data!="object"||!("type"in a.data)||a.data.type!=="client"&&a.data.type!=="bridge")return;let l;if(a.data.type==="client"){const c=this._messageInterceptors.get(a.data.name);if(!c){y(a.data);return}l={...c(a.data.data),type:"bridge",...a.data.responseName?{name:a.data.responseName}:{}}}if(!l){const c=V.safeParse(a.data);if(!c.success)return;l=c.data;const p=this._onHandlers.get(l.name),h=this._onceHandlers.get(l.name);if(p)for(const u of p)u(l.data);if(h){for(const u of h)u(l.data);this._onceHandlers.delete(l.name)}}if(!C)for(let c=0;c<window.frames.length;c+=1)window.frames[c].postMessage(l,"*")},S.addEventListener("message",this._windowMessageHandler),this._navigation.bind()}unbind(){this._windowMessageHandler&&(this._navigation.unbind(),S.removeEventListener("message",this._windowMessageHandler))}send(e,t){const s=H({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t});y(s)}request(e,t,s){var i;const n=E(),a=H({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:t,responseName:n});y(a);const l=(i=s==null?void 0:s.timeout)!==null&&i!==void 0?i:m;let c=!1,p;const h=new Promise(f=>{p=g=>{c||f(g)},this.once(n,p)});if(l===0)return h;const u=new Promise((f,g)=>{const w=new Error(`${e} message request with response name of ${n} timed out after ${l}`);setTimeout(()=>{c=!0,this.off(n,p),g(w)},l)});return Promise.race([u,h])}async subscribe(e,t,s){let i,n;typeof t=="function"?n=t:(i=t,n=s);const a=E(),l=E();let c=this._subscriptionNamesBySubjectName.get(e);c||(c=[],this._subscriptionNamesBySubjectName.set(e,c)),c.push(a),this._subscriptionNamesByHandler.set(n,a),this.on(a,n);const p=H({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:i,responseName:l,subscriptionName:a});y(p);let h=!1,u;const f=new Promise((w,_)=>{const b=new Error(`${e} subscribe request with subscription name of ${a} and response name of ${l} timed out after ${m}`);setTimeout(()=>{h=!0,this.off(l,u),_(b)},m)}),g=new Promise(w=>{u=_=>{h||w(_)},this.once(l,u)});return Promise.race([f,g])}async unsubscribe(e,t,s){let i,n;typeof t=="function"?n=t:(i=t,n=s);const a=E();let l=[];if(n){const c=this._subscriptionNamesByHandler.get(n);if(!c)return{success:!1};l=[c],this._subscriptionNamesByHandler.delete(n)}else if(!this._subscriptionNamesBySubjectName.get(e))return{success:!1};for await(const c of l){this.off(c,n);const p=H({telemetrySdkVersion:q,applicationInstance:this._applicationInstance,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,name:e,data:i,responseName:a,unsubscribeName:c});y(p);let h=!1,u;const f=new Promise((_,b)=>{const D=new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${a} timed out after ${m}`);setTimeout(()=>{h=!0,this.off(a,u),b(D)},m)}),g=new Promise(_=>{u=b=>{h||_(b)},this.once(a,u)});if(!(await Promise.race([f,g])).success)return{success:!1}}return{success:!0}}on(e,t){var s;const i=(s=this._onHandlers.get(e))!==null&&s!==void 0?s:[];i.length===0&&this._onHandlers.set(e,i),i.push(t)}once(e,t){var s;const i=(s=this._onceHandlers.get(e))!==null&&s!==void 0?s:[];i.length===0&&this._onceHandlers.set(e,i),i.push(t)}off(e,t){const s=this._onHandlers.get(e),i=this._onceHandlers.get(e);if(!(!s&&!i)){if(s){for(let n=0;n<s.length;n+=1)t&&s[n]!==t||(s.splice(n,1),n-=1);s.length===0&&this._onHandlers.delete(e)}if(i){for(let n=0;n<i.length;n+=1)t&&i[n]!==t||(i.splice(n,1),n-=1);i.length===0&&this._onceHandlers.delete(e)}}}}function E(){return Math.random().toString(36).slice(2,9)}const q=U.version;let r=null;function O(){return r}function G(o){r=new j(o),r.bind()}function J(){r==null||r.unbind(),r=null}function K(...o){return d(r),r.on(...o)}function z(...o){return d(r),r.once(...o)}function X(...o){return d(r),r.off(...o)}function Y(...o){return d(r),r.send(...o)}function Z(...o){return d(r),r.request(...o)}function ee(...o){return d(r),r.subscribe(...o)}function te(...o){return d(r),r.unsubscribe(...o)}function se(){return d(r),r.store}function ne(){return d(r),r.applications}function ie(){return d(r),r.media}function re(){return d(r),r.accounts}function ae(){return d(r),r.users}function oe(){return d(r),r.devices}function ce(){return d(r),r.proxy}function le(){return d(r),r.rootSettingsNavigation}function ue(){return d(r),r.weather}function he(){return d(r),r.currency}function de(){return d(r),r.environment}function pe(){return d(r),r.mqtt}function d(o){if(!o)throw new Error("SDK is not configured")}exports.Accounts=I;exports.Applications=P;exports.Client=j;exports.Currency=$;exports.Devices=T;exports.Environment=M;exports.Media=k;exports.Mqtt=x;exports.Navigation=L;exports.Proxy=F;exports.Store=A;exports.StoreSlice=v;exports.Users=R;exports.Weather=B;exports.accounts=re;exports.applications=ne;exports.configure=G;exports.currency=he;exports.destroy=J;exports.devices=oe;exports.environment=de;exports.globalClient=O;exports.media=ie;exports.mqtt=pe;exports.off=X;exports.on=K;exports.once=z;exports.proxy=ce;exports.request=Z;exports.rootSettingsNavigation=le;exports.send=Y;exports.store=se;exports.subscribe=ee;exports.telemetrySdkVersion=q;exports.unsubscribe=te;exports.users=ae;exports.weather=ue;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { Applications } from './applications.js';
|
|
|
3
3
|
export { Devices, type DeviceCapability } from './devices.js';
|
|
4
4
|
export { Environment, type ColorScheme } from './environment.js';
|
|
5
5
|
export { Media } from './media.js';
|
|
6
|
-
export type { MediaContent, MediaFolder, MediaSelection, MediaPickerOptions
|
|
6
|
+
export type { MediaContent, MediaFolder, MediaSelection, MediaPickerOptions } from './media.js';
|
|
7
7
|
export { Proxy } from './proxy.js';
|
|
8
8
|
export { Store, StoreSlice } from './store.js';
|
|
9
9
|
export { Users } from './users.js';
|
|
@@ -12,6 +12,7 @@ export type { CitiesSearchParams, DailyForecast, DailyForecastData, DailyForecas
|
|
|
12
12
|
export { Currency } from './currency.js';
|
|
13
13
|
export type { CurrencySymbols, CurrencyRates, CurrencyRatesParams } from './currency.js';
|
|
14
14
|
export { Mqtt } from './mqtt.js';
|
|
15
|
+
export { Navigation } from './navigation.js';
|
|
15
16
|
export type { MqttBrokerInfo, MqttConnectOptions, MqttPublishOptions, MqttSubscribeOptions, MqttConnectionStatus, MqttMessage, } from './mqtt.js';
|
|
16
17
|
import { Client } from './client.js';
|
|
17
18
|
export { Client, type SubscriptionResult, type MessageHandler } from './client.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as C, a as
|
|
2
|
-
const
|
|
3
|
-
version:
|
|
1
|
+
import { o as C, a as P, s as T, l as k } from "./types-CCzf8sMT.js";
|
|
2
|
+
const M = "1.13.0", F = {
|
|
3
|
+
version: M
|
|
4
4
|
};
|
|
5
5
|
class A {
|
|
6
6
|
constructor(e) {
|
|
@@ -21,7 +21,7 @@ class A {
|
|
|
21
21
|
return e.account;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
class
|
|
24
|
+
class R {
|
|
25
25
|
constructor(e) {
|
|
26
26
|
this._client = e;
|
|
27
27
|
}
|
|
@@ -116,7 +116,7 @@ class B {
|
|
|
116
116
|
this._client._messageInterceptors.set(e, t);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class B {
|
|
120
120
|
constructor(e) {
|
|
121
121
|
this._client = e;
|
|
122
122
|
}
|
|
@@ -160,7 +160,7 @@ class $ {
|
|
|
160
160
|
return e.capabilities;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
class
|
|
163
|
+
class $ {
|
|
164
164
|
constructor(e) {
|
|
165
165
|
this._client = e;
|
|
166
166
|
}
|
|
@@ -174,7 +174,7 @@ class R {
|
|
|
174
174
|
return (await this._client.unsubscribe("environment.unsubscribeColorScheme", {}, e)).success;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
class
|
|
177
|
+
class L {
|
|
178
178
|
constructor(e) {
|
|
179
179
|
this._client = e;
|
|
180
180
|
}
|
|
@@ -233,14 +233,14 @@ class x {
|
|
|
233
233
|
})).selection;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
class
|
|
236
|
+
class x {
|
|
237
237
|
constructor(e) {
|
|
238
238
|
this._client = e;
|
|
239
239
|
}
|
|
240
240
|
async fetch(e, t) {
|
|
241
241
|
var s;
|
|
242
|
-
let
|
|
243
|
-
typeof e == "string" ?
|
|
242
|
+
let i;
|
|
243
|
+
typeof e == "string" ? i = e : e instanceof URL ? i = e.toString() : (i = e.url, t || (t = {
|
|
244
244
|
method: e.method,
|
|
245
245
|
headers: e.headers,
|
|
246
246
|
body: e.body,
|
|
@@ -251,38 +251,38 @@ class j {
|
|
|
251
251
|
integrity: e.integrity
|
|
252
252
|
}));
|
|
253
253
|
let n = {};
|
|
254
|
-
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((
|
|
255
|
-
n[
|
|
256
|
-
}) : Array.isArray(t.headers) ? t.headers.forEach(([
|
|
257
|
-
n[
|
|
254
|
+
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((h, u) => {
|
|
255
|
+
n[u] = h;
|
|
256
|
+
}) : Array.isArray(t.headers) ? t.headers.forEach(([h, u]) => {
|
|
257
|
+
n[h] = u;
|
|
258
258
|
}) : n = t.headers);
|
|
259
|
-
const
|
|
260
|
-
url:
|
|
259
|
+
const a = await this._client.request("proxy.fetch", {
|
|
260
|
+
url: i,
|
|
261
261
|
method: (t == null ? void 0 : t.method) || "GET",
|
|
262
262
|
headers: n,
|
|
263
263
|
body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
|
|
264
264
|
});
|
|
265
|
-
if (!
|
|
266
|
-
throw new TypeError(
|
|
267
|
-
cause:
|
|
265
|
+
if (!a.success)
|
|
266
|
+
throw new TypeError(a.errorMessage, {
|
|
267
|
+
cause: a.errorCause ? Error(a.errorCause) : void 0
|
|
268
268
|
});
|
|
269
|
-
const
|
|
270
|
-
status:
|
|
271
|
-
statusText:
|
|
272
|
-
headers:
|
|
269
|
+
const l = new Headers(a.headers), c = {
|
|
270
|
+
status: a.status,
|
|
271
|
+
statusText: a.statusText,
|
|
272
|
+
headers: l
|
|
273
273
|
};
|
|
274
274
|
let p = null;
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
const
|
|
278
|
-
for (let f = 0; f <
|
|
279
|
-
|
|
280
|
-
p =
|
|
281
|
-
} else
|
|
282
|
-
return new Response(p,
|
|
275
|
+
if (a.body !== null && a.body !== void 0)
|
|
276
|
+
if (a.bodyType === "binary") {
|
|
277
|
+
const h = atob(a.body), u = new Uint8Array(h.length);
|
|
278
|
+
for (let f = 0; f < h.length; f++)
|
|
279
|
+
u[f] = h.charCodeAt(f);
|
|
280
|
+
p = u;
|
|
281
|
+
} else a.bodyType === "text" ? p = a.body : a.bodyType === "json" && (p = JSON.stringify(a.body));
|
|
282
|
+
return new Response(p, c);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
class
|
|
285
|
+
class j {
|
|
286
286
|
constructor(e) {
|
|
287
287
|
this._client = e;
|
|
288
288
|
}
|
|
@@ -438,7 +438,7 @@ class S {
|
|
|
438
438
|
})).success;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
class D {
|
|
442
442
|
constructor(e) {
|
|
443
443
|
this._client = e;
|
|
444
444
|
}
|
|
@@ -461,7 +461,7 @@ class Q {
|
|
|
461
461
|
return e.user;
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
class
|
|
464
|
+
class Q {
|
|
465
465
|
constructor(e) {
|
|
466
466
|
this._client = e;
|
|
467
467
|
}
|
|
@@ -644,10 +644,10 @@ class U {
|
|
|
644
644
|
* ```
|
|
645
645
|
*/
|
|
646
646
|
async getRates(e) {
|
|
647
|
-
var t, s,
|
|
647
|
+
var t, s, i;
|
|
648
648
|
const n = await this._client.request("currency.getRates", e);
|
|
649
649
|
if (!n.success || !n.rates)
|
|
650
|
-
throw ((t = n.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = n.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((
|
|
650
|
+
throw ((t = n.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = n.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((i = n.error) === null || i === void 0 ? void 0 : i.message) || "Failed to fetch currency rates");
|
|
651
651
|
return n.rates;
|
|
652
652
|
}
|
|
653
653
|
}
|
|
@@ -674,20 +674,20 @@ class V {
|
|
|
674
674
|
if (!(await this._client.request("mqtt.disconnect", { clientId: e })).success)
|
|
675
675
|
throw new Error("Failed to disconnect from MQTT broker");
|
|
676
676
|
}
|
|
677
|
-
async publish(e, t, s,
|
|
677
|
+
async publish(e, t, s, i) {
|
|
678
678
|
if (!(await this._client.request("mqtt.publish", {
|
|
679
679
|
clientId: e,
|
|
680
680
|
topic: t,
|
|
681
681
|
payload: s,
|
|
682
|
-
...
|
|
682
|
+
...i
|
|
683
683
|
})).success)
|
|
684
684
|
throw new Error("Failed to publish MQTT message");
|
|
685
685
|
}
|
|
686
|
-
async subscribe(e, t, s,
|
|
686
|
+
async subscribe(e, t, s, i) {
|
|
687
687
|
return (await this._client.subscribe("mqtt.subscribe", {
|
|
688
688
|
clientId: e,
|
|
689
689
|
topic: t,
|
|
690
|
-
...
|
|
690
|
+
...i
|
|
691
691
|
}, s)).success;
|
|
692
692
|
}
|
|
693
693
|
async unsubscribe(e, t, s) {
|
|
@@ -715,15 +715,35 @@ class V {
|
|
|
715
715
|
}, t)).success;
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
|
|
719
|
-
|
|
718
|
+
class W {
|
|
719
|
+
constructor(e) {
|
|
720
|
+
this._originalPushState = null, this._originalReplaceState = null, this._popstateHandler = null, this._backHandler = null, this._forwardHandler = null, this._client = e;
|
|
721
|
+
}
|
|
722
|
+
bind() {
|
|
723
|
+
typeof window > "u" || this._originalPushState || (this._originalPushState = history.pushState.bind(history), history.pushState = (...e) => {
|
|
724
|
+
this._originalPushState(...e), this._sendLocationChanged();
|
|
725
|
+
}, this._originalReplaceState = history.replaceState.bind(history), history.replaceState = (...e) => {
|
|
726
|
+
this._originalReplaceState(...e), this._sendLocationChanged();
|
|
727
|
+
}, this._popstateHandler = () => this._sendLocationChanged(), window.addEventListener("popstate", this._popstateHandler), this._backHandler = () => history.back(), this._forwardHandler = () => history.forward(), this._client.on("navigation.back", this._backHandler), this._client.on("navigation.forward", this._forwardHandler), this._sendLocationChanged());
|
|
728
|
+
}
|
|
729
|
+
unbind() {
|
|
730
|
+
typeof window > "u" || (this._originalPushState && (history.pushState = this._originalPushState, this._originalPushState = null), this._originalReplaceState && (history.replaceState = this._originalReplaceState, this._originalReplaceState = null), this._popstateHandler && (window.removeEventListener("popstate", this._popstateHandler), this._popstateHandler = null), this._backHandler && (this._client.off("navigation.back", this._backHandler), this._backHandler = null), this._forwardHandler && (this._client.off("navigation.forward", this._forwardHandler), this._forwardHandler = null));
|
|
731
|
+
}
|
|
732
|
+
_sendLocationChanged() {
|
|
733
|
+
this._client.send("navigation.locationChanged", {
|
|
734
|
+
pathname: window.location.pathname
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function q(o) {
|
|
739
|
+
return { ...o, type: "client" };
|
|
720
740
|
}
|
|
721
|
-
const
|
|
722
|
-
type:
|
|
723
|
-
name:
|
|
724
|
-
data:
|
|
741
|
+
const G = C({
|
|
742
|
+
type: k("bridge"),
|
|
743
|
+
name: T(),
|
|
744
|
+
data: P()
|
|
725
745
|
});
|
|
726
|
-
class
|
|
746
|
+
class J {
|
|
727
747
|
/**
|
|
728
748
|
* Creates a new RootSettingsNavigation API instance.
|
|
729
749
|
*
|
|
@@ -747,11 +767,11 @@ class G {
|
|
|
747
767
|
*/
|
|
748
768
|
async setRootSettingsNavigation(e) {
|
|
749
769
|
var t;
|
|
750
|
-
const s = this._store.shared("root-settings-navigation"),
|
|
751
|
-
|
|
770
|
+
const s = this._store.shared("root-settings-navigation"), i = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, n = this._store._client._applicationSpecifier;
|
|
771
|
+
i[n] = {
|
|
752
772
|
applicationSpecifier: n,
|
|
753
773
|
entries: e.entries
|
|
754
|
-
}, s.set("navigation",
|
|
774
|
+
}, s.set("navigation", i);
|
|
755
775
|
}
|
|
756
776
|
/**
|
|
757
777
|
* Retrieves the current navigation entries for this root application.
|
|
@@ -763,8 +783,8 @@ class G {
|
|
|
763
783
|
*/
|
|
764
784
|
async getRootSettingsNavigation() {
|
|
765
785
|
var e;
|
|
766
|
-
const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {},
|
|
767
|
-
return s[
|
|
786
|
+
const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {}, i = this._store._client._applicationSpecifier;
|
|
787
|
+
return s[i];
|
|
768
788
|
}
|
|
769
789
|
/**
|
|
770
790
|
* Retrieves the navigation entries for all root applications.
|
|
@@ -780,11 +800,11 @@ class G {
|
|
|
780
800
|
return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
|
|
781
801
|
}
|
|
782
802
|
}
|
|
783
|
-
const b = 1e3 * 30,
|
|
784
|
-
function y(
|
|
785
|
-
|
|
803
|
+
const b = 1e3 * 30, E = typeof window > "u" && typeof self < "u", v = E ? self : window;
|
|
804
|
+
function y(o) {
|
|
805
|
+
E ? self.postMessage(o) : v.parent.postMessage(o, "*");
|
|
786
806
|
}
|
|
787
|
-
class
|
|
807
|
+
class K {
|
|
788
808
|
/**
|
|
789
809
|
* Creates a new Client instance for communicating with the TelemetryOS platform.
|
|
790
810
|
*
|
|
@@ -796,7 +816,7 @@ class J {
|
|
|
796
816
|
* in your application's telemetry.config.json file
|
|
797
817
|
*/
|
|
798
818
|
constructor(e) {
|
|
799
|
-
this._applicationName = e, this._applicationInstance = "", this._applicationSpecifier = "", this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
|
|
819
|
+
this._applicationName = e, this._applicationInstance = "", this._applicationSpecifier = "", this._navigation = new W(this), this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
|
|
800
820
|
}
|
|
801
821
|
/**
|
|
802
822
|
* Provides access to the accounts API for retrieving TelemetryOS account information.
|
|
@@ -824,7 +844,7 @@ class J {
|
|
|
824
844
|
* @returns A Users instance bound to this client
|
|
825
845
|
*/
|
|
826
846
|
get users() {
|
|
827
|
-
return new
|
|
847
|
+
return new D(this);
|
|
828
848
|
}
|
|
829
849
|
/**
|
|
830
850
|
* Provides access to the store API for data persistence with multiple storage scopes.
|
|
@@ -838,7 +858,7 @@ class J {
|
|
|
838
858
|
* @returns A Store instance bound to this client
|
|
839
859
|
*/
|
|
840
860
|
get store() {
|
|
841
|
-
return new
|
|
861
|
+
return new j(this);
|
|
842
862
|
}
|
|
843
863
|
/**
|
|
844
864
|
* Provides access to the applications API for discovering other TelemetryOS applications.
|
|
@@ -852,7 +872,7 @@ class J {
|
|
|
852
872
|
* @returns An Applications instance bound to this client
|
|
853
873
|
*/
|
|
854
874
|
get applications() {
|
|
855
|
-
return new
|
|
875
|
+
return new R(this);
|
|
856
876
|
}
|
|
857
877
|
/**
|
|
858
878
|
* Provides access to the media API for working with content hosted on the TelemetryOS platform.
|
|
@@ -867,7 +887,7 @@ class J {
|
|
|
867
887
|
* @returns A Media instance bound to this client
|
|
868
888
|
*/
|
|
869
889
|
get media() {
|
|
870
|
-
return new
|
|
890
|
+
return new L(this);
|
|
871
891
|
}
|
|
872
892
|
/**
|
|
873
893
|
* Provides access to the proxy API for fetching third-party content through the TelemetryOS API.
|
|
@@ -881,7 +901,7 @@ class J {
|
|
|
881
901
|
* @returns A Proxy instance bound to this client
|
|
882
902
|
*/
|
|
883
903
|
get proxy() {
|
|
884
|
-
return new
|
|
904
|
+
return new x(this);
|
|
885
905
|
}
|
|
886
906
|
/**
|
|
887
907
|
* Provides access to the devices API for interacting with the current device.
|
|
@@ -896,7 +916,7 @@ class J {
|
|
|
896
916
|
* @returns A Devices instance bound to this client
|
|
897
917
|
*/
|
|
898
918
|
get devices() {
|
|
899
|
-
return new
|
|
919
|
+
return new B(this);
|
|
900
920
|
}
|
|
901
921
|
/**
|
|
902
922
|
* Provides access to the root settings navigation API for TelemetryOS administration UI integration.
|
|
@@ -914,7 +934,7 @@ class J {
|
|
|
914
934
|
* @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
|
|
915
935
|
*/
|
|
916
936
|
get rootSettingsNavigation() {
|
|
917
|
-
return new
|
|
937
|
+
return new J(this.store);
|
|
918
938
|
}
|
|
919
939
|
/**
|
|
920
940
|
* Provides access to the weather API for retrieving weather data.
|
|
@@ -928,7 +948,7 @@ class J {
|
|
|
928
948
|
* @returns A Weather instance bound to this client
|
|
929
949
|
*/
|
|
930
950
|
get weather() {
|
|
931
|
-
return new
|
|
951
|
+
return new Q(this);
|
|
932
952
|
}
|
|
933
953
|
/**
|
|
934
954
|
* Provides access to the currency API for retrieving currency exchange rates.
|
|
@@ -956,7 +976,7 @@ class J {
|
|
|
956
976
|
* @returns An Environment instance bound to this client
|
|
957
977
|
*/
|
|
958
978
|
get environment() {
|
|
959
|
-
return new
|
|
979
|
+
return new $(this);
|
|
960
980
|
}
|
|
961
981
|
get mqtt() {
|
|
962
982
|
return new V(this);
|
|
@@ -987,46 +1007,50 @@ class J {
|
|
|
987
1007
|
*/
|
|
988
1008
|
bind() {
|
|
989
1009
|
var e, t, s;
|
|
990
|
-
const
|
|
1010
|
+
const i = new URL(v.location.href), n = i.searchParams;
|
|
991
1011
|
if (this._applicationInstance = (e = n.get("applicationInstance")) !== null && e !== void 0 ? e : "", !this._applicationInstance)
|
|
992
1012
|
throw new Error("Missing applicationInstance query parameter");
|
|
993
1013
|
if (this._applicationSpecifier = (t = n.get("applicationSpecifier")) !== null && t !== void 0 ? t : "", !this._applicationSpecifier) {
|
|
994
|
-
const
|
|
995
|
-
this._applicationSpecifier = (s =
|
|
1014
|
+
const a = i.hostname.split(".");
|
|
1015
|
+
this._applicationSpecifier = (s = a[0]) !== null && s !== void 0 ? s : "";
|
|
996
1016
|
}
|
|
997
1017
|
if (!this._applicationSpecifier || this._applicationSpecifier.length !== 40)
|
|
998
1018
|
throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
999
|
-
this._windowMessageHandler = (
|
|
1000
|
-
if (
|
|
1019
|
+
this._windowMessageHandler = (a) => {
|
|
1020
|
+
if (a.source === v || !a.data || typeof a.data != "object" || !("type" in a.data) || a.data.type !== "client" && a.data.type !== "bridge")
|
|
1001
1021
|
return;
|
|
1002
|
-
let
|
|
1003
|
-
if (
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1006
|
-
y(
|
|
1022
|
+
let l;
|
|
1023
|
+
if (a.data.type === "client") {
|
|
1024
|
+
const c = this._messageInterceptors.get(a.data.name);
|
|
1025
|
+
if (!c) {
|
|
1026
|
+
y(a.data);
|
|
1007
1027
|
return;
|
|
1008
1028
|
}
|
|
1009
|
-
|
|
1029
|
+
l = {
|
|
1030
|
+
...c(a.data.data),
|
|
1031
|
+
type: "bridge",
|
|
1032
|
+
...a.data.responseName ? { name: a.data.responseName } : {}
|
|
1033
|
+
};
|
|
1010
1034
|
}
|
|
1011
|
-
if (!
|
|
1012
|
-
const
|
|
1013
|
-
if (!
|
|
1035
|
+
if (!l) {
|
|
1036
|
+
const c = G.safeParse(a.data);
|
|
1037
|
+
if (!c.success)
|
|
1014
1038
|
return;
|
|
1015
|
-
|
|
1016
|
-
const p = this._onHandlers.get(
|
|
1039
|
+
l = c.data;
|
|
1040
|
+
const p = this._onHandlers.get(l.name), h = this._onceHandlers.get(l.name);
|
|
1017
1041
|
if (p)
|
|
1018
|
-
for (const
|
|
1019
|
-
|
|
1020
|
-
if (
|
|
1021
|
-
for (const
|
|
1022
|
-
|
|
1023
|
-
this._onceHandlers.delete(
|
|
1042
|
+
for (const u of p)
|
|
1043
|
+
u(l.data);
|
|
1044
|
+
if (h) {
|
|
1045
|
+
for (const u of h)
|
|
1046
|
+
u(l.data);
|
|
1047
|
+
this._onceHandlers.delete(l.name);
|
|
1024
1048
|
}
|
|
1025
1049
|
}
|
|
1026
|
-
if (!
|
|
1027
|
-
for (let
|
|
1028
|
-
window.frames[
|
|
1029
|
-
}, v.addEventListener("message", this._windowMessageHandler);
|
|
1050
|
+
if (!E)
|
|
1051
|
+
for (let c = 0; c < window.frames.length; c += 1)
|
|
1052
|
+
window.frames[c].postMessage(l, "*");
|
|
1053
|
+
}, v.addEventListener("message", this._windowMessageHandler), this._navigation.bind();
|
|
1030
1054
|
}
|
|
1031
1055
|
/**
|
|
1032
1056
|
* Removes the message event listener and cleans up resources.
|
|
@@ -1042,7 +1066,7 @@ class J {
|
|
|
1042
1066
|
* of managing their own Client instances.
|
|
1043
1067
|
*/
|
|
1044
1068
|
unbind() {
|
|
1045
|
-
this._windowMessageHandler && v.removeEventListener("message", this._windowMessageHandler);
|
|
1069
|
+
this._windowMessageHandler && (this._navigation.unbind(), v.removeEventListener("message", this._windowMessageHandler));
|
|
1046
1070
|
}
|
|
1047
1071
|
/**
|
|
1048
1072
|
* Sends a one-way message to the TelemetryOS platform.
|
|
@@ -1059,7 +1083,7 @@ class J {
|
|
|
1059
1083
|
*/
|
|
1060
1084
|
send(e, t) {
|
|
1061
1085
|
const s = q({
|
|
1062
|
-
telemetrySdkVersion:
|
|
1086
|
+
telemetrySdkVersion: H,
|
|
1063
1087
|
applicationName: this._applicationName,
|
|
1064
1088
|
applicationSpecifier: this._applicationSpecifier,
|
|
1065
1089
|
applicationInstance: this._applicationInstance,
|
|
@@ -1088,9 +1112,9 @@ class J {
|
|
|
1088
1112
|
* @throws {Error} If the request times out
|
|
1089
1113
|
*/
|
|
1090
1114
|
request(e, t, s) {
|
|
1091
|
-
var
|
|
1092
|
-
const n = N(),
|
|
1093
|
-
telemetrySdkVersion:
|
|
1115
|
+
var i;
|
|
1116
|
+
const n = N(), a = q({
|
|
1117
|
+
telemetrySdkVersion: H,
|
|
1094
1118
|
applicationName: this._applicationName,
|
|
1095
1119
|
applicationSpecifier: this._applicationSpecifier,
|
|
1096
1120
|
applicationInstance: this._applicationInstance,
|
|
@@ -1098,91 +1122,91 @@ class J {
|
|
|
1098
1122
|
data: t,
|
|
1099
1123
|
responseName: n
|
|
1100
1124
|
});
|
|
1101
|
-
y(
|
|
1102
|
-
const
|
|
1103
|
-
let
|
|
1104
|
-
const
|
|
1105
|
-
p = (
|
|
1106
|
-
|
|
1125
|
+
y(a);
|
|
1126
|
+
const l = (i = s == null ? void 0 : s.timeout) !== null && i !== void 0 ? i : b;
|
|
1127
|
+
let c = !1, p;
|
|
1128
|
+
const h = new Promise((f) => {
|
|
1129
|
+
p = (_) => {
|
|
1130
|
+
c || f(_);
|
|
1107
1131
|
}, this.once(n, p);
|
|
1108
1132
|
});
|
|
1109
|
-
if (
|
|
1110
|
-
return
|
|
1111
|
-
const
|
|
1112
|
-
const
|
|
1133
|
+
if (l === 0)
|
|
1134
|
+
return h;
|
|
1135
|
+
const u = new Promise((f, _) => {
|
|
1136
|
+
const w = new Error(`${e} message request with response name of ${n} timed out after ${l}`);
|
|
1113
1137
|
setTimeout(() => {
|
|
1114
|
-
|
|
1115
|
-
},
|
|
1138
|
+
c = !0, this.off(n, p), _(w);
|
|
1139
|
+
}, l);
|
|
1116
1140
|
});
|
|
1117
|
-
return Promise.race([
|
|
1141
|
+
return Promise.race([u, h]);
|
|
1118
1142
|
}
|
|
1119
1143
|
async subscribe(e, t, s) {
|
|
1120
|
-
let
|
|
1121
|
-
typeof t == "function" ? n = t : (
|
|
1122
|
-
const
|
|
1123
|
-
let
|
|
1124
|
-
|
|
1144
|
+
let i, n;
|
|
1145
|
+
typeof t == "function" ? n = t : (i = t, n = s);
|
|
1146
|
+
const a = N(), l = N();
|
|
1147
|
+
let c = this._subscriptionNamesBySubjectName.get(e);
|
|
1148
|
+
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(a), this._subscriptionNamesByHandler.set(n, a), this.on(a, n);
|
|
1125
1149
|
const p = q({
|
|
1126
|
-
telemetrySdkVersion:
|
|
1150
|
+
telemetrySdkVersion: H,
|
|
1127
1151
|
applicationName: this._applicationName,
|
|
1128
1152
|
applicationSpecifier: this._applicationSpecifier,
|
|
1129
1153
|
applicationInstance: this._applicationInstance,
|
|
1130
1154
|
name: e,
|
|
1131
|
-
data:
|
|
1132
|
-
responseName:
|
|
1133
|
-
subscriptionName:
|
|
1155
|
+
data: i,
|
|
1156
|
+
responseName: l,
|
|
1157
|
+
subscriptionName: a
|
|
1134
1158
|
});
|
|
1135
1159
|
y(p);
|
|
1136
|
-
let
|
|
1137
|
-
const f = new Promise((
|
|
1138
|
-
const
|
|
1160
|
+
let h = !1, u;
|
|
1161
|
+
const f = new Promise((w, g) => {
|
|
1162
|
+
const m = new Error(`${e} subscribe request with subscription name of ${a} and response name of ${l} timed out after ${b}`);
|
|
1139
1163
|
setTimeout(() => {
|
|
1140
|
-
|
|
1164
|
+
h = !0, this.off(l, u), g(m);
|
|
1141
1165
|
}, b);
|
|
1142
|
-
}),
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
}, this.
|
|
1166
|
+
}), _ = new Promise((w) => {
|
|
1167
|
+
u = (g) => {
|
|
1168
|
+
h || w(g);
|
|
1169
|
+
}, this.once(l, u);
|
|
1146
1170
|
});
|
|
1147
|
-
return Promise.race([f,
|
|
1171
|
+
return Promise.race([f, _]);
|
|
1148
1172
|
}
|
|
1149
1173
|
async unsubscribe(e, t, s) {
|
|
1150
|
-
let
|
|
1151
|
-
typeof t == "function" ? n = t : (
|
|
1152
|
-
const
|
|
1153
|
-
let
|
|
1174
|
+
let i, n;
|
|
1175
|
+
typeof t == "function" ? n = t : (i = t, n = s);
|
|
1176
|
+
const a = N();
|
|
1177
|
+
let l = [];
|
|
1154
1178
|
if (n) {
|
|
1155
|
-
const
|
|
1156
|
-
if (!
|
|
1179
|
+
const c = this._subscriptionNamesByHandler.get(n);
|
|
1180
|
+
if (!c)
|
|
1157
1181
|
return { success: !1 };
|
|
1158
|
-
|
|
1182
|
+
l = [c], this._subscriptionNamesByHandler.delete(n);
|
|
1159
1183
|
} else if (!this._subscriptionNamesBySubjectName.get(e))
|
|
1160
1184
|
return { success: !1 };
|
|
1161
|
-
for await (const
|
|
1162
|
-
this.off(
|
|
1185
|
+
for await (const c of l) {
|
|
1186
|
+
this.off(c, n);
|
|
1163
1187
|
const p = q({
|
|
1164
|
-
telemetrySdkVersion:
|
|
1188
|
+
telemetrySdkVersion: H,
|
|
1165
1189
|
applicationInstance: this._applicationInstance,
|
|
1166
1190
|
applicationName: this._applicationName,
|
|
1167
1191
|
applicationSpecifier: this._applicationSpecifier,
|
|
1168
1192
|
name: e,
|
|
1169
|
-
data:
|
|
1170
|
-
responseName:
|
|
1171
|
-
unsubscribeName:
|
|
1193
|
+
data: i,
|
|
1194
|
+
responseName: a,
|
|
1195
|
+
unsubscribeName: c
|
|
1172
1196
|
});
|
|
1173
1197
|
y(p);
|
|
1174
|
-
let
|
|
1175
|
-
const f = new Promise((
|
|
1176
|
-
const
|
|
1198
|
+
let h = !1, u;
|
|
1199
|
+
const f = new Promise((g, m) => {
|
|
1200
|
+
const I = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${a} timed out after ${b}`);
|
|
1177
1201
|
setTimeout(() => {
|
|
1178
|
-
|
|
1202
|
+
h = !0, this.off(a, u), m(I);
|
|
1179
1203
|
}, b);
|
|
1180
|
-
}),
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
}, this.once(
|
|
1204
|
+
}), _ = new Promise((g) => {
|
|
1205
|
+
u = (m) => {
|
|
1206
|
+
h || g(m);
|
|
1207
|
+
}, this.once(a, u);
|
|
1184
1208
|
});
|
|
1185
|
-
if (!(await Promise.race([f,
|
|
1209
|
+
if (!(await Promise.race([f, _])).success)
|
|
1186
1210
|
return { success: !1 };
|
|
1187
1211
|
}
|
|
1188
1212
|
return { success: !0 };
|
|
@@ -1206,8 +1230,8 @@ class J {
|
|
|
1206
1230
|
*/
|
|
1207
1231
|
on(e, t) {
|
|
1208
1232
|
var s;
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1233
|
+
const i = (s = this._onHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
1234
|
+
i.length === 0 && this._onHandlers.set(e, i), i.push(t);
|
|
1211
1235
|
}
|
|
1212
1236
|
/**
|
|
1213
1237
|
* Registers a one-time handler for a specific message type.
|
|
@@ -1225,8 +1249,8 @@ class J {
|
|
|
1225
1249
|
*/
|
|
1226
1250
|
once(e, t) {
|
|
1227
1251
|
var s;
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1252
|
+
const i = (s = this._onceHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
1253
|
+
i.length === 0 && this._onceHandlers.set(e, i), i.push(t);
|
|
1230
1254
|
}
|
|
1231
1255
|
/**
|
|
1232
1256
|
* Removes previously registered message handlers.
|
|
@@ -1244,17 +1268,17 @@ class J {
|
|
|
1244
1268
|
* all handlers for this message type will be removed.
|
|
1245
1269
|
*/
|
|
1246
1270
|
off(e, t) {
|
|
1247
|
-
const s = this._onHandlers.get(e),
|
|
1248
|
-
if (!(!s && !
|
|
1271
|
+
const s = this._onHandlers.get(e), i = this._onceHandlers.get(e);
|
|
1272
|
+
if (!(!s && !i)) {
|
|
1249
1273
|
if (s) {
|
|
1250
1274
|
for (let n = 0; n < s.length; n += 1)
|
|
1251
1275
|
t && s[n] !== t || (s.splice(n, 1), n -= 1);
|
|
1252
1276
|
s.length === 0 && this._onHandlers.delete(e);
|
|
1253
1277
|
}
|
|
1254
|
-
if (
|
|
1255
|
-
for (let n = 0; n <
|
|
1256
|
-
t &&
|
|
1257
|
-
|
|
1278
|
+
if (i) {
|
|
1279
|
+
for (let n = 0; n < i.length; n += 1)
|
|
1280
|
+
t && i[n] !== t || (i.splice(n, 1), n -= 1);
|
|
1281
|
+
i.length === 0 && this._onceHandlers.delete(e);
|
|
1258
1282
|
}
|
|
1259
1283
|
}
|
|
1260
1284
|
}
|
|
@@ -1262,113 +1286,114 @@ class J {
|
|
|
1262
1286
|
function N() {
|
|
1263
1287
|
return Math.random().toString(36).slice(2, 9);
|
|
1264
1288
|
}
|
|
1265
|
-
const
|
|
1266
|
-
let
|
|
1267
|
-
function
|
|
1268
|
-
return
|
|
1289
|
+
const H = F.version;
|
|
1290
|
+
let r = null;
|
|
1291
|
+
function z() {
|
|
1292
|
+
return r;
|
|
1269
1293
|
}
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1294
|
+
function X(o) {
|
|
1295
|
+
r = new K(o), r.bind();
|
|
1272
1296
|
}
|
|
1273
|
-
function
|
|
1274
|
-
|
|
1297
|
+
function Y() {
|
|
1298
|
+
r == null || r.unbind(), r = null;
|
|
1275
1299
|
}
|
|
1276
|
-
function
|
|
1277
|
-
return
|
|
1300
|
+
function Z(...o) {
|
|
1301
|
+
return d(r), r.on(...o);
|
|
1278
1302
|
}
|
|
1279
|
-
function
|
|
1280
|
-
return
|
|
1303
|
+
function ee(...o) {
|
|
1304
|
+
return d(r), r.once(...o);
|
|
1281
1305
|
}
|
|
1282
|
-
function
|
|
1283
|
-
return
|
|
1306
|
+
function te(...o) {
|
|
1307
|
+
return d(r), r.off(...o);
|
|
1284
1308
|
}
|
|
1285
|
-
function
|
|
1286
|
-
return
|
|
1309
|
+
function se(...o) {
|
|
1310
|
+
return d(r), r.send(...o);
|
|
1287
1311
|
}
|
|
1288
|
-
function
|
|
1289
|
-
return
|
|
1312
|
+
function ne(...o) {
|
|
1313
|
+
return d(r), r.request(...o);
|
|
1290
1314
|
}
|
|
1291
|
-
function
|
|
1292
|
-
return
|
|
1315
|
+
function ie(...o) {
|
|
1316
|
+
return d(r), r.subscribe(...o);
|
|
1293
1317
|
}
|
|
1294
|
-
function re(...
|
|
1295
|
-
return
|
|
1318
|
+
function re(...o) {
|
|
1319
|
+
return d(r), r.unsubscribe(...o);
|
|
1296
1320
|
}
|
|
1297
|
-
function
|
|
1298
|
-
return
|
|
1321
|
+
function ae() {
|
|
1322
|
+
return d(r), r.store;
|
|
1299
1323
|
}
|
|
1300
1324
|
function oe() {
|
|
1301
|
-
return
|
|
1325
|
+
return d(r), r.applications;
|
|
1302
1326
|
}
|
|
1303
1327
|
function ce() {
|
|
1304
|
-
return
|
|
1328
|
+
return d(r), r.media;
|
|
1305
1329
|
}
|
|
1306
|
-
function
|
|
1307
|
-
return
|
|
1330
|
+
function le() {
|
|
1331
|
+
return d(r), r.accounts;
|
|
1308
1332
|
}
|
|
1309
1333
|
function ue() {
|
|
1310
|
-
return
|
|
1311
|
-
}
|
|
1312
|
-
function le() {
|
|
1313
|
-
return h(i), i.devices;
|
|
1334
|
+
return d(r), r.users;
|
|
1314
1335
|
}
|
|
1315
1336
|
function he() {
|
|
1316
|
-
return
|
|
1337
|
+
return d(r), r.devices;
|
|
1317
1338
|
}
|
|
1318
1339
|
function de() {
|
|
1319
|
-
return
|
|
1340
|
+
return d(r), r.proxy;
|
|
1320
1341
|
}
|
|
1321
1342
|
function pe() {
|
|
1322
|
-
return
|
|
1343
|
+
return d(r), r.rootSettingsNavigation;
|
|
1323
1344
|
}
|
|
1324
1345
|
function fe() {
|
|
1325
|
-
return
|
|
1346
|
+
return d(r), r.weather;
|
|
1347
|
+
}
|
|
1348
|
+
function _e() {
|
|
1349
|
+
return d(r), r.currency;
|
|
1326
1350
|
}
|
|
1327
1351
|
function ge() {
|
|
1328
|
-
return
|
|
1352
|
+
return d(r), r.environment;
|
|
1329
1353
|
}
|
|
1330
1354
|
function we() {
|
|
1331
|
-
return
|
|
1355
|
+
return d(r), r.mqtt;
|
|
1332
1356
|
}
|
|
1333
|
-
function
|
|
1334
|
-
if (!
|
|
1357
|
+
function d(o) {
|
|
1358
|
+
if (!o)
|
|
1335
1359
|
throw new Error("SDK is not configured");
|
|
1336
1360
|
}
|
|
1337
1361
|
export {
|
|
1338
1362
|
A as Accounts,
|
|
1339
|
-
|
|
1340
|
-
|
|
1363
|
+
R as Applications,
|
|
1364
|
+
K as Client,
|
|
1341
1365
|
U as Currency,
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1366
|
+
B as Devices,
|
|
1367
|
+
$ as Environment,
|
|
1368
|
+
L as Media,
|
|
1345
1369
|
V as Mqtt,
|
|
1346
|
-
|
|
1347
|
-
|
|
1370
|
+
W as Navigation,
|
|
1371
|
+
x as Proxy,
|
|
1372
|
+
j as Store,
|
|
1348
1373
|
S as StoreSlice,
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1374
|
+
D as Users,
|
|
1375
|
+
Q as Weather,
|
|
1376
|
+
le as accounts,
|
|
1352
1377
|
oe as applications,
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1378
|
+
X as configure,
|
|
1379
|
+
_e as currency,
|
|
1380
|
+
Y as destroy,
|
|
1381
|
+
he as devices,
|
|
1357
1382
|
ge as environment,
|
|
1358
|
-
|
|
1383
|
+
z as globalClient,
|
|
1359
1384
|
ce as media,
|
|
1360
1385
|
we as mqtt,
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1386
|
+
te as off,
|
|
1387
|
+
Z as on,
|
|
1388
|
+
ee as once,
|
|
1389
|
+
de as proxy,
|
|
1390
|
+
ne as request,
|
|
1391
|
+
pe as rootSettingsNavigation,
|
|
1392
|
+
se as send,
|
|
1393
|
+
ae as store,
|
|
1394
|
+
ie as subscribe,
|
|
1395
|
+
H as telemetrySdkVersion,
|
|
1371
1396
|
re as unsubscribe,
|
|
1372
1397
|
ue as users,
|
|
1373
|
-
|
|
1398
|
+
fe as weather
|
|
1374
1399
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client } from './client.js';
|
|
2
|
+
export declare class Navigation {
|
|
3
|
+
private _client;
|
|
4
|
+
private _originalPushState;
|
|
5
|
+
private _originalReplaceState;
|
|
6
|
+
private _popstateHandler;
|
|
7
|
+
private _backHandler;
|
|
8
|
+
private _forwardHandler;
|
|
9
|
+
constructor(client: Client);
|
|
10
|
+
bind(): void;
|
|
11
|
+
unbind(): void;
|
|
12
|
+
private _sendLocationChanged;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telemetryos/root-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "The official TelemetryOS root application sdk package. Provides types and apis for building root TelemetryOS applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|