@telemetryos/root-sdk 1.10.0 → 1.11.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @telemetryos/root-sdk
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added media select component, improved tos init tos publish and tos auth commands, add new store hook
8
+
3
9
  ## 1.10.0
4
10
 
5
11
  ### Minor Changes
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.10.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}}class A{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((l,p)=>{n[p]=l}):Array.isArray(t.headers)?t.headers.forEach(([l,p])=>{n[l]=p}):n=t.headers);const o=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(!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 d=null;if(o.body!==null&&o.body!==void 0)if(o.bodyType==="binary"){const l=atob(o.body),p=new Uint8Array(l.length);for(let f=0;f<l.length;f++)p[f]=l.charCodeAt(f);d=p}else o.bodyType==="text"?d=o.body:o.bodyType==="json"&&(d=JSON.stringify(o.body));return new Response(d,a)}}class k{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,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}}function E(c){return{...c,type:"client"}}const L=N.objectType({type:N.literalType("bridge"),name:N.stringType(),data:N.anyType()});class V{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 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 k(this)}get applications(){return new M(this)}get media(){return new F(this)}get proxy(){return new A(this)}get devices(){return new H(this)}get rootSettingsNavigation(){return new V(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 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 o=i.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=L.safeParse(o.data);if(!a.success)return;u=a.data;const d=this._onHandlers.get(u.name),l=this._onceHandlers.get(u.name);if(d)for(const p of d)p(u.data);if(l){for(const p of l)p(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 i;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=(i=s==null?void 0:s.timeout)!==null&&i!==void 0?i:b;let a=!1,d;const l=new Promise(f=>{d=g=>{a||f(g)},this.once(n,d)});if(u===0)return l;const p=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,d),g(w)},u)});return Promise.race([p,l])}async subscribe(e,t,s){let i,n;typeof t=="function"?n=t:(i=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 d=E({telemetrySdkVersion:q,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,applicationInstance:this._applicationInstance,name:e,data:i,responseName:u,subscriptionName:o});y(d);let l=!1,p;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,p),m(_)},b)}),g=new Promise(w=>{p=m=>{l||w(m)},this.on(u,w)});return Promise.race([f,g])}async unsubscribe(e,t,s){let i,n;typeof t=="function"?n=t:(i=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 d=E({telemetrySdkVersion:q,applicationInstance:this._applicationInstance,applicationName:this._applicationName,applicationSpecifier:this._applicationSpecifier,name:e,data:i,responseName:o,unsubscribeName:a});y(d);let l=!1,p;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,p),_(D)},b)}),g=new Promise(m=>{p=_=>{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 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 I(){return Math.random().toString(36).slice(2,9)}const q=U.version;let r=null;function W(){return r}function O(c){r=new j(c),r.bind()}function G(){r==null||r.unbind(),r=null}function J(...c){return h(r),r.on(...c)}function K(...c){return h(r),r.once(...c)}function z(...c){return h(r),r.off(...c)}function X(...c){return h(r),r.send(...c)}function Y(...c){return h(r),r.request(...c)}function Z(...c){return h(r),r.subscribe(...c)}function ee(...c){return h(r),r.unsubscribe(...c)}function te(){return h(r),r.store}function se(){return h(r),r.applications}function ne(){return h(r),r.media}function ie(){return h(r),r.accounts}function re(){return h(r),r.users}function oe(){return h(r),r.devices}function ce(){return h(r),r.proxy}function ae(){return h(r),r.rootSettingsNavigation}function ue(){return h(r),r.weather}function le(){return h(r),r.currency}function he(){return h(r),r.environment}function pe(){return h(r),r.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=A;exports.Store=k;exports.StoreSlice=v;exports.Users=B;exports.Weather=$;exports.accounts=ie;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=pe;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=re;exports.weather=ue;
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;
package/dist/index.d.ts CHANGED
@@ -3,6 +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, } from './media.js';
6
7
  export { Proxy } from './proxy.js';
7
8
  export { Store, StoreSlice } from './store.js';
8
9
  export { Users } from './users.js';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { o as C, a as H, s as M, l as F } from "./types-CCzf8sMT.js";
2
- const P = "1.10.0", A = {
3
- version: P
1
+ import { o as C, a as H, s as M, l as P } from "./types-CCzf8sMT.js";
2
+ const F = "1.11.0", k = {
3
+ version: F
4
4
  };
5
- class k {
5
+ class A {
6
6
  constructor(e) {
7
7
  this._client = e;
8
8
  }
@@ -219,6 +219,19 @@ class x {
219
219
  id: e
220
220
  })).content;
221
221
  }
222
+ /**
223
+ * Opens a full-screen media picker dialog in the host window.
224
+ * This allows users to browse folders, view media, and select an item.
225
+ *
226
+ * @param options Optional picker options including content type filter and current value
227
+ * @returns A promise that resolves to the selected media, or null if cancelled
228
+ */
229
+ async openPicker(e) {
230
+ return (await this._client.request("media.openPicker", {
231
+ accept: e == null ? void 0 : e.accept,
232
+ currentValue: e == null ? void 0 : e.currentValue
233
+ })).selection;
234
+ }
222
235
  }
223
236
  class j {
224
237
  constructor(e) {
@@ -226,8 +239,8 @@ class j {
226
239
  }
227
240
  async fetch(e, t) {
228
241
  var s;
229
- let i;
230
- typeof e == "string" ? i = e : e instanceof URL ? i = e.toString() : (i = e.url, t || (t = {
242
+ let r;
243
+ typeof e == "string" ? r = e : e instanceof URL ? r = e.toString() : (r = e.url, t || (t = {
231
244
  method: e.method,
232
245
  headers: e.headers,
233
246
  body: e.body,
@@ -238,13 +251,13 @@ class j {
238
251
  integrity: e.integrity
239
252
  }));
240
253
  let n = {};
241
- t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((l, p) => {
242
- n[p] = l;
243
- }) : Array.isArray(t.headers) ? t.headers.forEach(([l, p]) => {
244
- n[l] = p;
254
+ t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((l, d) => {
255
+ n[d] = l;
256
+ }) : Array.isArray(t.headers) ? t.headers.forEach(([l, d]) => {
257
+ n[l] = d;
245
258
  }) : n = t.headers);
246
259
  const o = await this._client.request("proxy.fetch", {
247
- url: i,
260
+ url: r,
248
261
  method: (t == null ? void 0 : t.method) || "GET",
249
262
  headers: n,
250
263
  body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
@@ -258,15 +271,15 @@ class j {
258
271
  statusText: o.statusText,
259
272
  headers: u
260
273
  };
261
- let d = null;
274
+ let p = null;
262
275
  if (o.body !== null && o.body !== void 0)
263
276
  if (o.bodyType === "binary") {
264
- const l = atob(o.body), p = new Uint8Array(l.length);
277
+ const l = atob(o.body), d = new Uint8Array(l.length);
265
278
  for (let f = 0; f < l.length; f++)
266
- p[f] = l.charCodeAt(f);
267
- d = p;
268
- } else o.bodyType === "text" ? d = o.body : o.bodyType === "json" && (d = JSON.stringify(o.body));
269
- return new Response(d, a);
279
+ d[f] = l.charCodeAt(f);
280
+ p = d;
281
+ } else o.bodyType === "text" ? p = o.body : o.bodyType === "json" && (p = JSON.stringify(o.body));
282
+ return new Response(p, a);
270
283
  }
271
284
  }
272
285
  class D {
@@ -631,10 +644,10 @@ class U {
631
644
  * ```
632
645
  */
633
646
  async getRates(e) {
634
- var t, s, i;
647
+ var t, s, r;
635
648
  const n = await this._client.request("currency.getRates", e);
636
649
  if (!n.success || !n.rates)
637
- 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");
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(((r = n.error) === null || r === void 0 ? void 0 : r.message) || "Failed to fetch currency rates");
638
651
  return n.rates;
639
652
  }
640
653
  }
@@ -661,20 +674,20 @@ class V {
661
674
  if (!(await this._client.request("mqtt.disconnect", { clientId: e })).success)
662
675
  throw new Error("Failed to disconnect from MQTT broker");
663
676
  }
664
- async publish(e, t, s, i) {
677
+ async publish(e, t, s, r) {
665
678
  if (!(await this._client.request("mqtt.publish", {
666
679
  clientId: e,
667
680
  topic: t,
668
681
  payload: s,
669
- ...i
682
+ ...r
670
683
  })).success)
671
684
  throw new Error("Failed to publish MQTT message");
672
685
  }
673
- async subscribe(e, t, s, i) {
686
+ async subscribe(e, t, s, r) {
674
687
  return (await this._client.subscribe("mqtt.subscribe", {
675
688
  clientId: e,
676
689
  topic: t,
677
- ...i
690
+ ...r
678
691
  }, s)).success;
679
692
  }
680
693
  async unsubscribe(e, t, s) {
@@ -706,7 +719,7 @@ function q(c) {
706
719
  return { ...c, type: "client" };
707
720
  }
708
721
  const W = C({
709
- type: F("bridge"),
722
+ type: P("bridge"),
710
723
  name: M(),
711
724
  data: H()
712
725
  });
@@ -734,11 +747,11 @@ class G {
734
747
  */
735
748
  async setRootSettingsNavigation(e) {
736
749
  var t;
737
- const s = this._store.shared("root-settings-navigation"), i = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, n = this._store._client._applicationSpecifier;
738
- i[n] = {
750
+ const s = this._store.shared("root-settings-navigation"), r = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, n = this._store._client._applicationSpecifier;
751
+ r[n] = {
739
752
  applicationSpecifier: n,
740
753
  entries: e.entries
741
- }, s.set("navigation", i);
754
+ }, s.set("navigation", r);
742
755
  }
743
756
  /**
744
757
  * Retrieves the current navigation entries for this root application.
@@ -750,8 +763,8 @@ class G {
750
763
  */
751
764
  async getRootSettingsNavigation() {
752
765
  var e;
753
- const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {}, i = this._store._client._applicationSpecifier;
754
- return s[i];
766
+ const s = (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {}, r = this._store._client._applicationSpecifier;
767
+ return s[r];
755
768
  }
756
769
  /**
757
770
  * Retrieves the navigation entries for all root applications.
@@ -797,7 +810,7 @@ class J {
797
810
  * @returns An Accounts instance bound to this client
798
811
  */
799
812
  get accounts() {
800
- return new k(this);
813
+ return new A(this);
801
814
  }
802
815
  /**
803
816
  * Provides access to the users API for retrieving TelemetryOS user information.
@@ -974,11 +987,11 @@ class J {
974
987
  */
975
988
  bind() {
976
989
  var e, t, s;
977
- const i = new URL(v.location.href), n = i.searchParams;
990
+ const r = new URL(v.location.href), n = r.searchParams;
978
991
  if (this._applicationInstance = (e = n.get("applicationInstance")) !== null && e !== void 0 ? e : "", !this._applicationInstance)
979
992
  throw new Error("Missing applicationInstance query parameter");
980
993
  if (this._applicationSpecifier = (t = n.get("applicationSpecifier")) !== null && t !== void 0 ? t : "", !this._applicationSpecifier) {
981
- const o = i.hostname.split(".");
994
+ const o = r.hostname.split(".");
982
995
  this._applicationSpecifier = (s = o[0]) !== null && s !== void 0 ? s : "";
983
996
  }
984
997
  if (!this._applicationSpecifier || this._applicationSpecifier.length !== 40)
@@ -1000,13 +1013,13 @@ class J {
1000
1013
  if (!a.success)
1001
1014
  return;
1002
1015
  u = a.data;
1003
- const d = this._onHandlers.get(u.name), l = this._onceHandlers.get(u.name);
1004
- if (d)
1005
- for (const p of d)
1006
- p(u.data);
1016
+ const p = this._onHandlers.get(u.name), l = this._onceHandlers.get(u.name);
1017
+ if (p)
1018
+ for (const d of p)
1019
+ d(u.data);
1007
1020
  if (l) {
1008
- for (const p of l)
1009
- p(u.data);
1021
+ for (const d of l)
1022
+ d(u.data);
1010
1023
  this._onceHandlers.delete(u.name);
1011
1024
  }
1012
1025
  }
@@ -1075,7 +1088,7 @@ class J {
1075
1088
  * @throws {Error} If the request times out
1076
1089
  */
1077
1090
  request(e, t, s) {
1078
- var i;
1091
+ var r;
1079
1092
  const n = N(), o = q({
1080
1093
  telemetrySdkVersion: E,
1081
1094
  applicationName: this._applicationName,
@@ -1086,56 +1099,56 @@ class J {
1086
1099
  responseName: n
1087
1100
  });
1088
1101
  y(o);
1089
- const u = (i = s == null ? void 0 : s.timeout) !== null && i !== void 0 ? i : b;
1090
- let a = !1, d;
1102
+ const u = (r = s == null ? void 0 : s.timeout) !== null && r !== void 0 ? r : b;
1103
+ let a = !1, p;
1091
1104
  const l = new Promise((f) => {
1092
- d = (g) => {
1105
+ p = (g) => {
1093
1106
  a || f(g);
1094
- }, this.once(n, d);
1107
+ }, this.once(n, p);
1095
1108
  });
1096
1109
  if (u === 0)
1097
1110
  return l;
1098
- const p = new Promise((f, g) => {
1111
+ const d = new Promise((f, g) => {
1099
1112
  const m = new Error(`${e} message request with response name of ${n} timed out after ${u}`);
1100
1113
  setTimeout(() => {
1101
- a = !0, this.off(n, d), g(m);
1114
+ a = !0, this.off(n, p), g(m);
1102
1115
  }, u);
1103
1116
  });
1104
- return Promise.race([p, l]);
1117
+ return Promise.race([d, l]);
1105
1118
  }
1106
1119
  async subscribe(e, t, s) {
1107
- let i, n;
1108
- typeof t == "function" ? n = t : (i = t, n = s);
1120
+ let r, n;
1121
+ typeof t == "function" ? n = t : (r = t, n = s);
1109
1122
  const o = N(), u = N();
1110
1123
  let a = this._subscriptionNamesBySubjectName.get(e);
1111
1124
  a || (a = [], this._subscriptionNamesBySubjectName.set(e, a)), a.push(o), this._subscriptionNamesByHandler.set(n, o), this.on(o, n);
1112
- const d = q({
1125
+ const p = q({
1113
1126
  telemetrySdkVersion: E,
1114
1127
  applicationName: this._applicationName,
1115
1128
  applicationSpecifier: this._applicationSpecifier,
1116
1129
  applicationInstance: this._applicationInstance,
1117
1130
  name: e,
1118
- data: i,
1131
+ data: r,
1119
1132
  responseName: u,
1120
1133
  subscriptionName: o
1121
1134
  });
1122
- y(d);
1123
- let l = !1, p;
1135
+ y(p);
1136
+ let l = !1, d;
1124
1137
  const f = new Promise((m, w) => {
1125
1138
  const _ = new Error(`${e} subscribe request with subscription name of ${o} and response name of ${u} timed out after ${b}`);
1126
1139
  setTimeout(() => {
1127
- l = !0, this.off(u, p), w(_);
1140
+ l = !0, this.off(u, d), w(_);
1128
1141
  }, b);
1129
1142
  }), g = new Promise((m) => {
1130
- p = (w) => {
1143
+ d = (w) => {
1131
1144
  l || m(w);
1132
1145
  }, this.on(u, m);
1133
1146
  });
1134
1147
  return Promise.race([f, g]);
1135
1148
  }
1136
1149
  async unsubscribe(e, t, s) {
1137
- let i, n;
1138
- typeof t == "function" ? n = t : (i = t, n = s);
1150
+ let r, n;
1151
+ typeof t == "function" ? n = t : (r = t, n = s);
1139
1152
  const o = N();
1140
1153
  let u = [];
1141
1154
  if (n) {
@@ -1147,25 +1160,25 @@ class J {
1147
1160
  return { success: !1 };
1148
1161
  for await (const a of u) {
1149
1162
  this.off(a, n);
1150
- const d = q({
1163
+ const p = q({
1151
1164
  telemetrySdkVersion: E,
1152
1165
  applicationInstance: this._applicationInstance,
1153
1166
  applicationName: this._applicationName,
1154
1167
  applicationSpecifier: this._applicationSpecifier,
1155
1168
  name: e,
1156
- data: i,
1169
+ data: r,
1157
1170
  responseName: o,
1158
1171
  unsubscribeName: a
1159
1172
  });
1160
- y(d);
1161
- let l = !1, p;
1173
+ y(p);
1174
+ let l = !1, d;
1162
1175
  const f = new Promise((w, _) => {
1163
1176
  const T = new Error(`${e} unsubscribe request with unsubscribe name of ${a} and response name of ${o} timed out after ${b}`);
1164
1177
  setTimeout(() => {
1165
- l = !0, this.off(o, p), _(T);
1178
+ l = !0, this.off(o, d), _(T);
1166
1179
  }, b);
1167
1180
  }), g = new Promise((w) => {
1168
- p = (_) => {
1181
+ d = (_) => {
1169
1182
  l || w(_);
1170
1183
  }, this.once(o, w);
1171
1184
  });
@@ -1193,8 +1206,8 @@ class J {
1193
1206
  */
1194
1207
  on(e, t) {
1195
1208
  var s;
1196
- const i = (s = this._onHandlers.get(e)) !== null && s !== void 0 ? s : [];
1197
- i.length === 0 && this._onHandlers.set(e, i), i.push(t);
1209
+ const r = (s = this._onHandlers.get(e)) !== null && s !== void 0 ? s : [];
1210
+ r.length === 0 && this._onHandlers.set(e, r), r.push(t);
1198
1211
  }
1199
1212
  /**
1200
1213
  * Registers a one-time handler for a specific message type.
@@ -1212,8 +1225,8 @@ class J {
1212
1225
  */
1213
1226
  once(e, t) {
1214
1227
  var s;
1215
- const i = (s = this._onceHandlers.get(e)) !== null && s !== void 0 ? s : [];
1216
- i.length === 0 && this._onceHandlers.set(e, i), i.push(t);
1228
+ const r = (s = this._onceHandlers.get(e)) !== null && s !== void 0 ? s : [];
1229
+ r.length === 0 && this._onceHandlers.set(e, r), r.push(t);
1217
1230
  }
1218
1231
  /**
1219
1232
  * Removes previously registered message handlers.
@@ -1231,17 +1244,17 @@ class J {
1231
1244
  * all handlers for this message type will be removed.
1232
1245
  */
1233
1246
  off(e, t) {
1234
- const s = this._onHandlers.get(e), i = this._onceHandlers.get(e);
1235
- if (!(!s && !i)) {
1247
+ const s = this._onHandlers.get(e), r = this._onceHandlers.get(e);
1248
+ if (!(!s && !r)) {
1236
1249
  if (s) {
1237
1250
  for (let n = 0; n < s.length; n += 1)
1238
1251
  t && s[n] !== t || (s.splice(n, 1), n -= 1);
1239
1252
  s.length === 0 && this._onHandlers.delete(e);
1240
1253
  }
1241
- if (i) {
1242
- for (let n = 0; n < i.length; n += 1)
1243
- t && i[n] !== t || (i.splice(n, 1), n -= 1);
1244
- i.length === 0 && this._onceHandlers.delete(e);
1254
+ if (r) {
1255
+ for (let n = 0; n < r.length; n += 1)
1256
+ t && r[n] !== t || (r.splice(n, 1), n -= 1);
1257
+ r.length === 0 && this._onceHandlers.delete(e);
1245
1258
  }
1246
1259
  }
1247
1260
  }
@@ -1249,80 +1262,80 @@ class J {
1249
1262
  function N() {
1250
1263
  return Math.random().toString(36).slice(2, 9);
1251
1264
  }
1252
- const E = A.version;
1253
- let r = null;
1265
+ const E = k.version;
1266
+ let i = null;
1254
1267
  function O() {
1255
- return r;
1268
+ return i;
1256
1269
  }
1257
1270
  function z(c) {
1258
- r = new J(c), r.bind();
1271
+ i = new J(c), i.bind();
1259
1272
  }
1260
1273
  function X() {
1261
- r == null || r.unbind(), r = null;
1274
+ i == null || i.unbind(), i = null;
1262
1275
  }
1263
1276
  function Y(...c) {
1264
- return h(r), r.on(...c);
1277
+ return h(i), i.on(...c);
1265
1278
  }
1266
1279
  function Z(...c) {
1267
- return h(r), r.once(...c);
1280
+ return h(i), i.once(...c);
1268
1281
  }
1269
1282
  function ee(...c) {
1270
- return h(r), r.off(...c);
1283
+ return h(i), i.off(...c);
1271
1284
  }
1272
1285
  function te(...c) {
1273
- return h(r), r.send(...c);
1286
+ return h(i), i.send(...c);
1274
1287
  }
1275
1288
  function se(...c) {
1276
- return h(r), r.request(...c);
1289
+ return h(i), i.request(...c);
1277
1290
  }
1278
1291
  function ne(...c) {
1279
- return h(r), r.subscribe(...c);
1292
+ return h(i), i.subscribe(...c);
1280
1293
  }
1281
- function ie(...c) {
1282
- return h(r), r.unsubscribe(...c);
1294
+ function re(...c) {
1295
+ return h(i), i.unsubscribe(...c);
1283
1296
  }
1284
- function re() {
1285
- return h(r), r.store;
1297
+ function ie() {
1298
+ return h(i), i.store;
1286
1299
  }
1287
1300
  function oe() {
1288
- return h(r), r.applications;
1301
+ return h(i), i.applications;
1289
1302
  }
1290
1303
  function ce() {
1291
- return h(r), r.media;
1304
+ return h(i), i.media;
1292
1305
  }
1293
1306
  function ae() {
1294
- return h(r), r.accounts;
1307
+ return h(i), i.accounts;
1295
1308
  }
1296
1309
  function ue() {
1297
- return h(r), r.users;
1310
+ return h(i), i.users;
1298
1311
  }
1299
1312
  function le() {
1300
- return h(r), r.devices;
1313
+ return h(i), i.devices;
1301
1314
  }
1302
1315
  function he() {
1303
- return h(r), r.proxy;
1304
- }
1305
- function pe() {
1306
- return h(r), r.rootSettingsNavigation;
1316
+ return h(i), i.proxy;
1307
1317
  }
1308
1318
  function de() {
1309
- return h(r), r.weather;
1319
+ return h(i), i.rootSettingsNavigation;
1320
+ }
1321
+ function pe() {
1322
+ return h(i), i.weather;
1310
1323
  }
1311
1324
  function fe() {
1312
- return h(r), r.currency;
1325
+ return h(i), i.currency;
1313
1326
  }
1314
1327
  function ge() {
1315
- return h(r), r.environment;
1328
+ return h(i), i.environment;
1316
1329
  }
1317
1330
  function we() {
1318
- return h(r), r.mqtt;
1331
+ return h(i), i.mqtt;
1319
1332
  }
1320
1333
  function h(c) {
1321
1334
  if (!c)
1322
1335
  throw new Error("SDK is not configured");
1323
1336
  }
1324
1337
  export {
1325
- k as Accounts,
1338
+ A as Accounts,
1326
1339
  B as Applications,
1327
1340
  J as Client,
1328
1341
  U as Currency,
@@ -1350,12 +1363,12 @@ export {
1350
1363
  Z as once,
1351
1364
  he as proxy,
1352
1365
  se as request,
1353
- pe as rootSettingsNavigation,
1366
+ de as rootSettingsNavigation,
1354
1367
  te as send,
1355
- re as store,
1368
+ ie as store,
1356
1369
  ne as subscribe,
1357
1370
  E as telemetrySdkVersion,
1358
- ie as unsubscribe,
1371
+ re as unsubscribe,
1359
1372
  ue as users,
1360
- de as weather
1373
+ pe as weather
1361
1374
  };
package/dist/media.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Client } from './client.js';
2
2
  type MediaContentUser = {};
3
- type MediaContent = {
3
+ export type MediaContent = {
4
4
  id: string;
5
5
  contentFolderId: string;
6
6
  contentType: string;
@@ -17,7 +17,7 @@ type MediaContent = {
17
17
  createdAt: Date;
18
18
  updatedAt: Date;
19
19
  };
20
- type MediaFolder = {
20
+ export type MediaFolder = {
21
21
  id: string;
22
22
  parentId: string;
23
23
  name: string;
@@ -26,6 +26,25 @@ type MediaFolder = {
26
26
  updatedAt: Date;
27
27
  createdAt: Date;
28
28
  };
29
+ /**
30
+ * Represents a selected media item with essential display properties.
31
+ */
32
+ export type MediaSelection = {
33
+ id: string;
34
+ name: string;
35
+ thumbnailUrl: string;
36
+ url: string;
37
+ contentType: string;
38
+ };
39
+ /**
40
+ * Options for the media picker dialog.
41
+ */
42
+ export type MediaPickerOptions = {
43
+ /** Filter by content type patterns: ['image/*', 'video/*'] */
44
+ accept?: string[];
45
+ /** Pre-select the current value in the picker */
46
+ currentValue?: MediaSelection;
47
+ };
29
48
  export declare class Media {
30
49
  _client: Client;
31
50
  constructor(client: Client);
@@ -56,5 +75,13 @@ export declare class Media {
56
75
  * @returns A promise that resolves to the media content with the specified ID
57
76
  */
58
77
  getById(id: string): Promise<MediaContent>;
78
+ /**
79
+ * Opens a full-screen media picker dialog in the host window.
80
+ * This allows users to browse folders, view media, and select an item.
81
+ *
82
+ * @param options Optional picker options including content type filter and current value
83
+ * @returns A promise that resolves to the selected media, or null if cancelled
84
+ */
85
+ openPicker(options?: MediaPickerOptions): Promise<MediaSelection | null>;
59
86
  }
60
87
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemetryos/root-sdk",
3
- "version": "1.10.0",
3
+ "version": "1.11.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",