@naylour/telegram
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -1,2 +0,1 @@ | ||
import type { Subscriber } from 'svelte/store'; | ||
export declare class TelegramStore { | ||
@@ -8,6 +7,6 @@ #private; | ||
get platform(): import("./Telegram/WebApp").Platform; | ||
get fullscreen(): ITelegram['fullscreen']; | ||
get fullscreen(): ITelegram['fullscreen'] | undefined; | ||
set fullscreen(newStatus: boolean); | ||
get isReady(): boolean; | ||
subscribe: (this: void, run: Subscriber<ITelegram>, invalidate?: () => void) => import("svelte/store").Unsubscriber; | ||
subscribe: (this: void, run: import("svelte/store").Subscriber<ITelegram>, invalidate?: () => void) => import("svelte/store").Unsubscriber; | ||
get store(): ITelegram; | ||
@@ -14,0 +13,0 @@ constructor(); |
import { BROWSER } from 'esm-env'; | ||
import { setContext as _setContext, getContext as _getContext, } from 'svelte'; | ||
import { get, writable } from 'svelte/store'; | ||
import { setContext as _setContext, getContext as _getContext, onMount, } from 'svelte'; | ||
import { fromStore, writable } from 'svelte/store'; | ||
import platforms from './platforms'; | ||
export class TelegramStore { | ||
get WebView() { | ||
return get(this.#store).WebView; | ||
return this.store?.WebView; | ||
} | ||
get Utils() { | ||
return get(this.#store).Utils; | ||
return this.store?.Utils; | ||
} | ||
get WebApp() { | ||
return get(this.#store).WebApp; | ||
return this.store?.WebApp; | ||
} | ||
get platform() { | ||
return get(this.#store).platform; | ||
return this.store?.platform; | ||
} | ||
get fullscreen() { | ||
return get(this.#store).fullscreen; | ||
return this.store?.fullscreen; | ||
} | ||
@@ -31,3 +31,3 @@ set fullscreen(newStatus) { | ||
get isReady() { | ||
return get(this.#store).isReady; | ||
return !!this.store?.isReady; | ||
} | ||
@@ -37,3 +37,3 @@ #store = writable(); | ||
get store() { | ||
return get(this.#store); | ||
return fromStore(this.#store).current; | ||
} | ||
@@ -46,3 +46,3 @@ constructor() { | ||
active: window.Telegram.WebApp.isFullscreen, | ||
available: platforms.includes(window.Telegram.WebApp.platform) && parseFloat(this.WebApp.version) >= 8.0 | ||
available: platforms.includes(window.Telegram.WebApp.platform) && parseFloat(window.Telegram.WebApp.version) >= 8.0 | ||
}; | ||
@@ -60,3 +60,3 @@ set({ | ||
})); | ||
this.setup(get(this.#store)); | ||
this.setup(this.store); | ||
} | ||
@@ -67,3 +67,3 @@ } | ||
setFullscreen = (status, callback) => { | ||
if (!this.fullscreen.available) | ||
if (!this.fullscreen?.available) | ||
return false; | ||
@@ -76,3 +76,3 @@ if (status) | ||
this.onFullscreen(status); | ||
callback?.(get(this.#store)); | ||
callback?.(this.store); | ||
return true; | ||
@@ -83,3 +83,3 @@ }; | ||
if (this.isReady) | ||
callback(get(this.#store)); | ||
callback(this.store); | ||
else | ||
@@ -90,3 +90,3 @@ this.#readyQueue.set(crypto.randomUUID(), callback); | ||
for (const [id, pender] of this.#readyQueue) { | ||
pender(get(this.#store)); | ||
pender(this.store); | ||
this.#readyQueue.delete(id); | ||
@@ -93,0 +93,0 @@ } |
{ | ||
"name": "@naylour/telegram", | ||
"module": "./dist/store.js", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"types": "./dist/types.d.ts", | ||
@@ -25,5 +25,4 @@ "private": false, | ||
".": { | ||
"types": "./dist/store.d.ts", | ||
"svelte": "./dist/store.js", | ||
"import": "./dist/store.js" | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
@@ -38,2 +37,7 @@ "./types": { | ||
"import": "./dist/reactivity.svelte.js" | ||
}, | ||
"./store": { | ||
"types": "./dist/store.d.ts", | ||
"svelte": "./dist/store.js", | ||
"import": "./dist/store.js" | ||
} | ||
@@ -40,0 +44,0 @@ }, |
74504
1624