@tma.js/sdk-solid 1.1.7 → 1.1.9

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [sdk-solid-code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk-solid
8
8
 
9
- [sdk-solid-docs-link]: https://docs.telegram-mini-apps.com/packages/typescript/tma-js-sdk-solid
9
+ [sdk-solid-docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk-solid
10
10
 
11
11
  [sdk-solid-npm-link]: https://npmjs.com/package/@tma.js/sdk-solid
12
12
 
@@ -20,6 +20,6 @@
20
20
  [![code-badge]][sdk-solid-code-link]
21
21
 
22
22
  Solid JS bindings
23
- for [client SDK](https://docs.telegram-mini-apps.com/packages/typescript/tma-js-sdk/about). Includes
23
+ for [client SDK](https://docs.telegram-mini-apps.com/packages/tma-js-sdk). Includes
24
24
  hooks, components and utilities
25
25
  for comfortable usage of Solid JS on the Telegram Mini Apps platform.
package/dist/index.cjs CHANGED
@@ -1,2 +1 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("solid-js"),c=require("@tma.js/sdk"),l=e.createContext({loading:()=>!1,error:()=>{},initResult:()=>{}},{name:"SDKContext"});function g(t){const[n]=e.createResource(()=>t.options,c.init),o=e.createMemo(()=>n.state==="ready"?n():void 0),u=e.createMemo(()=>n.loading),a=e.createMemo(()=>n.error===void 0?null:n.error);return e.createComponent(l.Provider,{value:{initResult:o,loading:u,error:a},get children(){return t.children}})}function i(){return e.useContext(l)}function d(t){const{initResult:n}=i();return e.createMemo(()=>{const o=n();if(!o)throw new Error(`Unable to get init result key "${t}" as long as SDK is not initialized`);return o[t]})}function h(t){const n=d(t),[o,u]=e.createSignal(n(),{equals:!1});return e.createEffect(()=>{e.onCleanup(n().on("change",()=>{u(a=>a)}))}),o}function r(t,n){return n?()=>h(t):()=>d(t)}const m=r("backButton",!0),p=r("closingBehavior",!0),S=r("cloudStorage"),f=r("hapticFeedback"),v=r("initData"),D=r("initDataRaw"),C=r("invoice",!0);function B(){return c.retrieveLaunchData().launchParams}const P=r("mainButton",!0),w=r("miniApp",!0),M=r("popup",!0),R=r("postEvent"),k=r("qrScanner",!0),b=r("settingsButton",!0),I=r("themeParams",!0),x=r("viewport",!0),y=r("utils");function s(t,n={}){return typeof t=="function"?e.createComponent(t,n):t}function K(t){const{loading:n,error:o,initResult:u}=i();return e.createComponent(e.Switch,{get fallback(){return s(t.initial)},get children(){return[e.createComponent(e.Match,{get when(){return u()},get children(){return t.children}}),e.createComponent(e.Match,{get when(){return o()},get children(){return s(t.error,{error:o()})}}),e.createComponent(e.Match,{get when(){return n()},get children(){return s(t.loading)}})]}})}exports.DisplayGate=K;exports.SDKProvider=g;exports.useBackButton=m;exports.useClosingBehavior=p;exports.useCloudStorage=S;exports.useHapticFeedback=f;exports.useInitData=v;exports.useInitDataRaw=D;exports.useInvoice=C;exports.useLaunchParams=B;exports.useMainButton=P;exports.useMiniApp=w;exports.usePopup=M;exports.usePostEvent=R;exports.useQRScanner=k;exports.useSDKContext=i;exports.useSettingsButton=b;exports.useThemeParams=I;exports.useUtils=y;exports.useViewport=x;
2
- //# sourceMappingURL=index.cjs.map
package/dist/index.mjs CHANGED
@@ -113,4 +113,3 @@ export {
113
113
  Q as useUtils,
114
114
  G as useViewport
115
115
  };
116
- //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tma.js/sdk-solid",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Solid JS bindings for Mini Apps client SDK.",
5
5
  "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
6
6
  "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
@@ -22,8 +22,7 @@
22
22
  "type": "module",
23
23
  "sideEffects": false,
24
24
  "files": [
25
- "dist",
26
- "src"
25
+ "dist"
27
26
  ],
28
27
  "main": "./dist/index.cjs",
29
28
  "module": "./dist/index.mjs",
@@ -37,7 +36,7 @@
37
36
  }
38
37
  },
39
38
  "dependencies": {
40
- "@tma.js/sdk": "1.4.4"
39
+ "@tma.js/sdk": "1.4.6"
41
40
  },
42
41
  "peerDependencies": {
43
42
  "solid-js": "^1.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/provider/SDKContext.ts","../src/provider/SDKProvider.tsx","../src/provider/useSDKContext.ts","../src/provider/useInitResultValue.ts","../src/provider/useInitResultDynamicValue.ts","../src/createHook.ts","../src/tools/back-button.ts","../src/tools/closing-behavior.ts","../src/tools/cloud-storage.ts","../src/tools/haptic-feedback.ts","../src/tools/init-data.ts","../src/tools/init-data-raw.ts","../src/tools/invoice.ts","../src/tools/launch-params.tsx","../src/tools/main-button.ts","../src/tools/mini-app.ts","../src/tools/popup.ts","../src/tools/post-event.ts","../src/tools/qr-scanner.ts","../src/tools/settings-button.ts","../src/tools/theme-params.ts","../src/tools/viewport.ts","../src/tools/utils.ts","../src/DisplayGate.tsx"],"sourcesContent":["import { createContext } from 'solid-js';\n\nimport type { SDKContextType } from './types.js';\n\nexport const SDKContext = createContext<SDKContextType>({\n loading: () => false,\n error: () => undefined,\n initResult: () => undefined,\n}, { name: 'SDKContext' });\n","import { init } from '@tma.js/sdk';\nimport { createMemo, createResource } from 'solid-js';\n\nimport { SDKContext } from './SDKContext.js';\nimport type { SDKProviderProps } from './types.js';\n\nexport function SDKProvider(props: SDKProviderProps) {\n const [data] = createResource(() => props.options, init);\n\n const initResult = createMemo(() => {\n return data.state === 'ready' ? data() : undefined;\n });\n const loading = createMemo(() => data.loading);\n const error = createMemo(() => (data.error === undefined ? null : data.error));\n\n return (\n <SDKContext.Provider value={{ initResult, loading, error }}>\n {props.children}\n </SDKContext.Provider>\n );\n}\n","import { useContext } from 'solid-js';\n\nimport { SDKContext } from './SDKContext.js';\nimport type { SDKContextType } from './types.js';\n\n/**\n * Returns current SDK information.\n */\nexport function useSDKContext(): SDKContextType {\n return useContext(SDKContext);\n}\n","import { type Accessor, createMemo } from 'solid-js';\n\nimport { useSDKContext } from './useSDKContext.js';\nimport type { InitResultKey, InitResultValue } from '../types.js';\n\n/**\n * Returns value by its field name from SDK init result.\n * @param key - init result key.\n * @throws {Error} SDK is not initialized.\n */\nexport function useInitResultValue<K extends InitResultKey>(key: K): Accessor<InitResultValue<K>> {\n const { initResult } = useSDKContext();\n\n // eslint-disable-next-line solid/reactivity\n return createMemo<InitResultValue<K>>(() => {\n const result = initResult();\n\n if (!result) {\n throw new Error(`Unable to get init result key \"${key}\" as long as SDK is not initialized`);\n }\n return result[key];\n });\n}\n","import {\n type Accessor,\n createEffect,\n createSignal,\n onCleanup,\n} from 'solid-js';\n\nimport { useInitResultValue } from './useInitResultValue.js';\nimport type {\n DynamicInitResultKey,\n InitResultValue,\n Trackable,\n} from '../types.js';\n\nexport function useInitResultDynamicValue<K extends DynamicInitResultKey>(\n initResultKey: K,\n): Accessor<InitResultValue<K>> {\n // Extract init result value.\n const initial = useInitResultValue(initResultKey);\n\n // Create value which will be returned to the external environment.\n const [signal, setSignal] = createSignal(initial(), { equals: false });\n\n // Effect which listens to change event and calls update.\n createEffect(() => {\n onCleanup(\n (initial() as Trackable).on('change', () => {\n setSignal((prev) => prev);\n }),\n );\n });\n\n return signal;\n}\n","import type { Accessor } from 'solid-js';\n\nimport { useInitResultDynamicValue, useInitResultValue } from './provider/index.js';\nimport type {\n DynamicInitResultKey,\n InitResultKey,\n InitResultValue,\n StaticInitResultKey,\n} from './types.js';\n\nexport type Hook<K extends InitResultKey> = () => Accessor<InitResultValue<K>>;\n\n/**\n * Creates hook to retrieve static init result value.\n * @param initResultKey - init result key.\n */\nexport function createHook<K extends StaticInitResultKey>(initResultKey: K): Hook<K>;\n\n/**\n * Creates hook to retrieve dynamic init result value.\n * @param initResultKey - init result key.\n * @param dynamic - flag to let function know this init result value is dynamic.\n */\nexport function createHook<K extends DynamicInitResultKey>(\n initResultKey: K,\n dynamic: true,\n): Hook<K>;\n\nexport function createHook(initResultKey: InitResultKey, dynamic?: true): Hook<any> {\n return dynamic\n ? () => useInitResultDynamicValue(initResultKey as DynamicInitResultKey)\n : () => useInitResultValue(initResultKey);\n}\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve BackButton component.\n */\nexport const useBackButton = createHook('backButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve ClosingBehavior component.\n */\nexport const useClosingBehavior = createHook('closingBehavior', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve CloudStorage component.\n */\nexport const useCloudStorage = createHook('cloudStorage');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve HapticFeedback component.\n */\nexport const useHapticFeedback = createHook('hapticFeedback');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve InitData component.\n */\nexport const useInitData = createHook('initData');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve init data raw representation.\n */\nexport const useInitDataRaw = createHook('initDataRaw');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Invoice component.\n */\nexport const useInvoice = createHook('invoice', true);\n","import { type LaunchParams, retrieveLaunchData } from '@tma.js/sdk';\n\n/**\n * Hooks to retrieve launch parameters.\n */\nexport function useLaunchParams(): LaunchParams {\n return retrieveLaunchData().launchParams;\n}\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve MainButton component.\n */\nexport const useMainButton = createHook('mainButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve MiniApp component.\n */\nexport const useMiniApp = createHook('miniApp', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Popup component.\n */\nexport const usePopup = createHook('popup', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve postEvent function.\n */\nexport const usePostEvent = createHook('postEvent');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve QRScanner component.\n */\nexport const useQRScanner = createHook('qrScanner', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve SettingsButton component.\n */\nexport const useSettingsButton = createHook('settingsButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve ThemeParams component.\n */\nexport const useThemeParams = createHook('themeParams', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Viewport component.\n */\nexport const useViewport = createHook('viewport', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Utils component.\n */\nexport const useUtils = createHook('utils');\n","import {\n type Component,\n type JSX,\n Match,\n type ParentProps,\n Switch,\n} from 'solid-js';\n\nimport { useSDKContext } from './provider/index.js';\n\nexport interface DisplayGateProps extends ParentProps {\n /**\n * Element or component, which will be displayed in case, SDK is not loading, didn't receive\n * any error during initialization as well as the initialization result.\n */\n initial?: JSX.Element | Component;\n\n /**\n * Element or component which will be displayed in case, SDK initialization failed.\n */\n error?: JSX.Element | Component<{ error: unknown }>;\n\n /**\n * Element or component which will be displayed in case, SDK is currently loading.\n */\n loading?: JSX.Element | Component;\n}\n\nfunction render(Component: JSX.Element | Component): JSX.Element;\nfunction render<T extends object>(Component: JSX.Element | Component<T>, props: T): JSX.Element;\nfunction render(Component: JSX.Element | Component, props = {}): JSX.Element {\n return typeof Component === 'function' ? <Component {...props}/> : Component;\n}\n\n/**\n * This component is the layer controlling the application display. It displays application in\n * case, the SDK is initialized, displays an error if something went wrong, and a loader\n * if the SDK is warming up.\n */\nexport function DisplayGate(props: DisplayGateProps) {\n const { loading, error, initResult } = useSDKContext();\n\n return (\n <Switch fallback={render(props.initial)}>\n <Match when={initResult()}>\n {props.children}\n </Match>\n <Match when={error()}>\n {render(props.error, { error: error() })}\n </Match>\n <Match when={loading()}>\n {render(props.loading)}\n </Match>\n </Switch>\n );\n}\n"],"names":["SDKContext","createContext","SDKProvider","props","data","createResource","options","init","initResult","createMemo","state","undefined","loading","error","_$createComponent","Provider","value","children","useSDKContext","useContext","useInitResultValue","key","result","useInitResultDynamicValue","initResultKey","initial","signal","setSignal","createSignal","createEffect","onCleanup","prev","createHook","dynamic","useBackButton","useClosingBehavior","useCloudStorage","useHapticFeedback","useInitData","useInitDataRaw","useInvoice","useLaunchParams","retrieveLaunchData","launchParams","useMainButton","useMiniApp","usePopup","usePostEvent","useQRScanner","useSettingsButton","useThemeParams","useViewport","useUtils","render","Component","DisplayGate","Switch","fallback","Match","when"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/provider/SDKContext.ts","../src/provider/SDKProvider.tsx","../src/provider/useSDKContext.ts","../src/provider/useInitResultValue.ts","../src/provider/useInitResultDynamicValue.ts","../src/createHook.ts","../src/tools/back-button.ts","../src/tools/closing-behavior.ts","../src/tools/cloud-storage.ts","../src/tools/haptic-feedback.ts","../src/tools/init-data.ts","../src/tools/init-data-raw.ts","../src/tools/invoice.ts","../src/tools/launch-params.tsx","../src/tools/main-button.ts","../src/tools/mini-app.ts","../src/tools/popup.ts","../src/tools/post-event.ts","../src/tools/qr-scanner.ts","../src/tools/settings-button.ts","../src/tools/theme-params.ts","../src/tools/viewport.ts","../src/tools/utils.ts","../src/DisplayGate.tsx"],"sourcesContent":["import { createContext } from 'solid-js';\n\nimport type { SDKContextType } from './types.js';\n\nexport const SDKContext = createContext<SDKContextType>({\n loading: () => false,\n error: () => undefined,\n initResult: () => undefined,\n}, { name: 'SDKContext' });\n","import { init } from '@tma.js/sdk';\nimport { createMemo, createResource } from 'solid-js';\n\nimport { SDKContext } from './SDKContext.js';\nimport type { SDKProviderProps } from './types.js';\n\nexport function SDKProvider(props: SDKProviderProps) {\n const [data] = createResource(() => props.options, init);\n\n const initResult = createMemo(() => {\n return data.state === 'ready' ? data() : undefined;\n });\n const loading = createMemo(() => data.loading);\n const error = createMemo(() => (data.error === undefined ? null : data.error));\n\n return (\n <SDKContext.Provider value={{ initResult, loading, error }}>\n {props.children}\n </SDKContext.Provider>\n );\n}\n","import { useContext } from 'solid-js';\n\nimport { SDKContext } from './SDKContext.js';\nimport type { SDKContextType } from './types.js';\n\n/**\n * Returns current SDK information.\n */\nexport function useSDKContext(): SDKContextType {\n return useContext(SDKContext);\n}\n","import { type Accessor, createMemo } from 'solid-js';\n\nimport { useSDKContext } from './useSDKContext.js';\nimport type { InitResultKey, InitResultValue } from '../types.js';\n\n/**\n * Returns value by its field name from SDK init result.\n * @param key - init result key.\n * @throws {Error} SDK is not initialized.\n */\nexport function useInitResultValue<K extends InitResultKey>(key: K): Accessor<InitResultValue<K>> {\n const { initResult } = useSDKContext();\n\n // eslint-disable-next-line solid/reactivity\n return createMemo<InitResultValue<K>>(() => {\n const result = initResult();\n\n if (!result) {\n throw new Error(`Unable to get init result key \"${key}\" as long as SDK is not initialized`);\n }\n return result[key];\n });\n}\n","import {\n type Accessor,\n createEffect,\n createSignal,\n onCleanup,\n} from 'solid-js';\n\nimport { useInitResultValue } from './useInitResultValue.js';\nimport type {\n DynamicInitResultKey,\n InitResultValue,\n Trackable,\n} from '../types.js';\n\nexport function useInitResultDynamicValue<K extends DynamicInitResultKey>(\n initResultKey: K,\n): Accessor<InitResultValue<K>> {\n // Extract init result value.\n const initial = useInitResultValue(initResultKey);\n\n // Create value which will be returned to the external environment.\n const [signal, setSignal] = createSignal(initial(), { equals: false });\n\n // Effect which listens to change event and calls update.\n createEffect(() => {\n onCleanup(\n (initial() as Trackable).on('change', () => {\n setSignal((prev) => prev);\n }),\n );\n });\n\n return signal;\n}\n","import type { Accessor } from 'solid-js';\n\nimport { useInitResultDynamicValue, useInitResultValue } from './provider/index.js';\nimport type {\n DynamicInitResultKey,\n InitResultKey,\n InitResultValue,\n StaticInitResultKey,\n} from './types.js';\n\nexport type Hook<K extends InitResultKey> = () => Accessor<InitResultValue<K>>;\n\n/**\n * Creates hook to retrieve static init result value.\n * @param initResultKey - init result key.\n */\nexport function createHook<K extends StaticInitResultKey>(initResultKey: K): Hook<K>;\n\n/**\n * Creates hook to retrieve dynamic init result value.\n * @param initResultKey - init result key.\n * @param dynamic - flag to let function know this init result value is dynamic.\n */\nexport function createHook<K extends DynamicInitResultKey>(\n initResultKey: K,\n dynamic: true,\n): Hook<K>;\n\nexport function createHook(initResultKey: InitResultKey, dynamic?: true): Hook<any> {\n return dynamic\n ? () => useInitResultDynamicValue(initResultKey as DynamicInitResultKey)\n : () => useInitResultValue(initResultKey);\n}\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve BackButton component.\n */\nexport const useBackButton = createHook('backButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve ClosingBehavior component.\n */\nexport const useClosingBehavior = createHook('closingBehavior', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve CloudStorage component.\n */\nexport const useCloudStorage = createHook('cloudStorage');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve HapticFeedback component.\n */\nexport const useHapticFeedback = createHook('hapticFeedback');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve InitData component.\n */\nexport const useInitData = createHook('initData');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve init data raw representation.\n */\nexport const useInitDataRaw = createHook('initDataRaw');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Invoice component.\n */\nexport const useInvoice = createHook('invoice', true);\n","import { type LaunchParams, retrieveLaunchData } from '@tma.js/sdk';\n\n/**\n * Hooks to retrieve launch parameters.\n */\nexport function useLaunchParams(): LaunchParams {\n return retrieveLaunchData().launchParams;\n}\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve MainButton component.\n */\nexport const useMainButton = createHook('mainButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve MiniApp component.\n */\nexport const useMiniApp = createHook('miniApp', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Popup component.\n */\nexport const usePopup = createHook('popup', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve postEvent function.\n */\nexport const usePostEvent = createHook('postEvent');\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve QRScanner component.\n */\nexport const useQRScanner = createHook('qrScanner', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve SettingsButton component.\n */\nexport const useSettingsButton = createHook('settingsButton', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve ThemeParams component.\n */\nexport const useThemeParams = createHook('themeParams', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Viewport component.\n */\nexport const useViewport = createHook('viewport', true);\n","import { createHook } from '../createHook.js';\n\n/**\n * Hook to retrieve Utils component.\n */\nexport const useUtils = createHook('utils');\n","import {\n type Component,\n type JSX,\n Match,\n type ParentProps,\n Switch,\n} from 'solid-js';\n\nimport { useSDKContext } from './provider/index.js';\n\nexport interface DisplayGateProps extends ParentProps {\n /**\n * Element or component, which will be displayed in case, SDK is not loading, didn't receive\n * any error during initialization as well as the initialization result.\n */\n initial?: JSX.Element | Component;\n\n /**\n * Element or component which will be displayed in case, SDK initialization failed.\n */\n error?: JSX.Element | Component<{ error: unknown }>;\n\n /**\n * Element or component which will be displayed in case, SDK is currently loading.\n */\n loading?: JSX.Element | Component;\n}\n\nfunction render(Component: JSX.Element | Component): JSX.Element;\nfunction render<T extends object>(Component: JSX.Element | Component<T>, props: T): JSX.Element;\nfunction render(Component: JSX.Element | Component, props = {}): JSX.Element {\n return typeof Component === 'function' ? <Component {...props}/> : Component;\n}\n\n/**\n * This component is the layer controlling the application display. It displays application in\n * case, the SDK is initialized, displays an error if something went wrong, and a loader\n * if the SDK is warming up.\n */\nexport function DisplayGate(props: DisplayGateProps) {\n const { loading, error, initResult } = useSDKContext();\n\n return (\n <Switch fallback={render(props.initial)}>\n <Match when={initResult()}>\n {props.children}\n </Match>\n <Match when={error()}>\n {render(props.error, { error: error() })}\n </Match>\n <Match when={loading()}>\n {render(props.loading)}\n </Match>\n </Switch>\n );\n}\n"],"names":["SDKContext","createContext","SDKProvider","props","data","createResource","options","init","initResult","createMemo","state","undefined","loading","error","_$createComponent","Provider","value","children","useSDKContext","useContext","useInitResultValue","key","result","useInitResultDynamicValue","initResultKey","initial","signal","setSignal","createSignal","createEffect","onCleanup","prev","createHook","dynamic","useBackButton","useClosingBehavior","useCloudStorage","useHapticFeedback","useInitData","useInitDataRaw","useInvoice","useLaunchParams","retrieveLaunchData","launchParams","useMainButton","useMiniApp","usePopup","usePostEvent","useQRScanner","useSettingsButton","useThemeParams","useViewport","useUtils","render","Component","DisplayGate","Switch","fallback","Match","when"],"mappings":"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"}
@@ -1,56 +0,0 @@
1
- import {
2
- type Component,
3
- type JSX,
4
- Match,
5
- type ParentProps,
6
- Switch,
7
- } from 'solid-js';
8
-
9
- import { useSDKContext } from './provider/index.js';
10
-
11
- export interface DisplayGateProps extends ParentProps {
12
- /**
13
- * Element or component, which will be displayed in case, SDK is not loading, didn't receive
14
- * any error during initialization as well as the initialization result.
15
- */
16
- initial?: JSX.Element | Component;
17
-
18
- /**
19
- * Element or component which will be displayed in case, SDK initialization failed.
20
- */
21
- error?: JSX.Element | Component<{ error: unknown }>;
22
-
23
- /**
24
- * Element or component which will be displayed in case, SDK is currently loading.
25
- */
26
- loading?: JSX.Element | Component;
27
- }
28
-
29
- function render(Component: JSX.Element | Component): JSX.Element;
30
- function render<T extends object>(Component: JSX.Element | Component<T>, props: T): JSX.Element;
31
- function render(Component: JSX.Element | Component, props = {}): JSX.Element {
32
- return typeof Component === 'function' ? <Component {...props}/> : Component;
33
- }
34
-
35
- /**
36
- * This component is the layer controlling the application display. It displays application in
37
- * case, the SDK is initialized, displays an error if something went wrong, and a loader
38
- * if the SDK is warming up.
39
- */
40
- export function DisplayGate(props: DisplayGateProps) {
41
- const { loading, error, initResult } = useSDKContext();
42
-
43
- return (
44
- <Switch fallback={render(props.initial)}>
45
- <Match when={initResult()}>
46
- {props.children}
47
- </Match>
48
- <Match when={error()}>
49
- {render(props.error, { error: error() })}
50
- </Match>
51
- <Match when={loading()}>
52
- {render(props.loading)}
53
- </Match>
54
- </Switch>
55
- );
56
- }
package/src/createHook.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { Accessor } from 'solid-js';
2
-
3
- import { useInitResultDynamicValue, useInitResultValue } from './provider/index.js';
4
- import type {
5
- DynamicInitResultKey,
6
- InitResultKey,
7
- InitResultValue,
8
- StaticInitResultKey,
9
- } from './types.js';
10
-
11
- export type Hook<K extends InitResultKey> = () => Accessor<InitResultValue<K>>;
12
-
13
- /**
14
- * Creates hook to retrieve static init result value.
15
- * @param initResultKey - init result key.
16
- */
17
- export function createHook<K extends StaticInitResultKey>(initResultKey: K): Hook<K>;
18
-
19
- /**
20
- * Creates hook to retrieve dynamic init result value.
21
- * @param initResultKey - init result key.
22
- * @param dynamic - flag to let function know this init result value is dynamic.
23
- */
24
- export function createHook<K extends DynamicInitResultKey>(
25
- initResultKey: K,
26
- dynamic: true,
27
- ): Hook<K>;
28
-
29
- export function createHook(initResultKey: InitResultKey, dynamic?: true): Hook<any> {
30
- return dynamic
31
- ? () => useInitResultDynamicValue(initResultKey as DynamicInitResultKey)
32
- : () => useInitResultValue(initResultKey);
33
- }
package/src/index.ts DELETED
@@ -1,33 +0,0 @@
1
- export {
2
- useThemeParams,
3
- useInitData,
4
- useBackButton,
5
- useClosingBehavior,
6
- useInitDataRaw,
7
- useCloudStorage,
8
- useLaunchParams,
9
- useMainButton,
10
- useHapticFeedback,
11
- useInvoice,
12
- useMiniApp,
13
- usePopup,
14
- usePostEvent,
15
- useQRScanner,
16
- useSettingsButton,
17
- useUtils,
18
- useViewport,
19
- } from './tools/index.js';
20
- export {
21
- useSDKContext,
22
- SDKProvider,
23
- type SDKProviderProps,
24
- type SDKContextType,
25
- } from './provider/index.js';
26
- export {
27
- DisplayGate,
28
- type DisplayGateProps,
29
- } from './DisplayGate.js';
30
- export type {
31
- InitOptions,
32
- InitResult,
33
- } from './types.js';
@@ -1,9 +0,0 @@
1
- import { createContext } from 'solid-js';
2
-
3
- import type { SDKContextType } from './types.js';
4
-
5
- export const SDKContext = createContext<SDKContextType>({
6
- loading: () => false,
7
- error: () => undefined,
8
- initResult: () => undefined,
9
- }, { name: 'SDKContext' });
@@ -1,21 +0,0 @@
1
- import { init } from '@tma.js/sdk';
2
- import { createMemo, createResource } from 'solid-js';
3
-
4
- import { SDKContext } from './SDKContext.js';
5
- import type { SDKProviderProps } from './types.js';
6
-
7
- export function SDKProvider(props: SDKProviderProps) {
8
- const [data] = createResource(() => props.options, init);
9
-
10
- const initResult = createMemo(() => {
11
- return data.state === 'ready' ? data() : undefined;
12
- });
13
- const loading = createMemo(() => data.loading);
14
- const error = createMemo(() => (data.error === undefined ? null : data.error));
15
-
16
- return (
17
- <SDKContext.Provider value={{ initResult, loading, error }}>
18
- {props.children}
19
- </SDKContext.Provider>
20
- );
21
- }
@@ -1,6 +0,0 @@
1
- export * from './SDKContext.js';
2
- export * from './SDKProvider.js';
3
- export * from './types.js';
4
- export * from './useSDKContext.js';
5
- export * from './useInitResultDynamicValue.js';
6
- export * from './useInitResultValue.js';
@@ -1,26 +0,0 @@
1
- import type { InitOptions, InitResult } from '@tma.js/sdk';
2
- import type { Accessor, ParentProps } from 'solid-js';
3
-
4
- export type SDKProviderProps = ParentProps<{
5
- /**
6
- * Init function options.
7
- */
8
- options?: InitOptions;
9
- }>;
10
-
11
- export interface SDKContextType {
12
- /**
13
- * Error occurred during initialization.
14
- */
15
- error: Accessor<unknown | undefined>;
16
-
17
- /**
18
- * Initialization result.
19
- */
20
- initResult: Accessor<InitResult | undefined>;
21
-
22
- /**
23
- * True if SDK is loading.
24
- */
25
- loading: Accessor<boolean>;
26
- }
@@ -1,34 +0,0 @@
1
- import {
2
- type Accessor,
3
- createEffect,
4
- createSignal,
5
- onCleanup,
6
- } from 'solid-js';
7
-
8
- import { useInitResultValue } from './useInitResultValue.js';
9
- import type {
10
- DynamicInitResultKey,
11
- InitResultValue,
12
- Trackable,
13
- } from '../types.js';
14
-
15
- export function useInitResultDynamicValue<K extends DynamicInitResultKey>(
16
- initResultKey: K,
17
- ): Accessor<InitResultValue<K>> {
18
- // Extract init result value.
19
- const initial = useInitResultValue(initResultKey);
20
-
21
- // Create value which will be returned to the external environment.
22
- const [signal, setSignal] = createSignal(initial(), { equals: false });
23
-
24
- // Effect which listens to change event and calls update.
25
- createEffect(() => {
26
- onCleanup(
27
- (initial() as Trackable).on('change', () => {
28
- setSignal((prev) => prev);
29
- }),
30
- );
31
- });
32
-
33
- return signal;
34
- }
@@ -1,23 +0,0 @@
1
- import { type Accessor, createMemo } from 'solid-js';
2
-
3
- import { useSDKContext } from './useSDKContext.js';
4
- import type { InitResultKey, InitResultValue } from '../types.js';
5
-
6
- /**
7
- * Returns value by its field name from SDK init result.
8
- * @param key - init result key.
9
- * @throws {Error} SDK is not initialized.
10
- */
11
- export function useInitResultValue<K extends InitResultKey>(key: K): Accessor<InitResultValue<K>> {
12
- const { initResult } = useSDKContext();
13
-
14
- // eslint-disable-next-line solid/reactivity
15
- return createMemo<InitResultValue<K>>(() => {
16
- const result = initResult();
17
-
18
- if (!result) {
19
- throw new Error(`Unable to get init result key "${key}" as long as SDK is not initialized`);
20
- }
21
- return result[key];
22
- });
23
- }
@@ -1,11 +0,0 @@
1
- import { useContext } from 'solid-js';
2
-
3
- import { SDKContext } from './SDKContext.js';
4
- import type { SDKContextType } from './types.js';
5
-
6
- /**
7
- * Returns current SDK information.
8
- */
9
- export function useSDKContext(): SDKContextType {
10
- return useContext(SDKContext);
11
- }
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve BackButton component.
5
- */
6
- export const useBackButton = createHook('backButton', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve ClosingBehavior component.
5
- */
6
- export const useClosingBehavior = createHook('closingBehavior', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve CloudStorage component.
5
- */
6
- export const useCloudStorage = createHook('cloudStorage');
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve HapticFeedback component.
5
- */
6
- export const useHapticFeedback = createHook('hapticFeedback');
@@ -1,17 +0,0 @@
1
- export * from './back-button.js';
2
- export * from './closing-behavior.js';
3
- export * from './cloud-storage.js';
4
- export * from './haptic-feedback.js';
5
- export * from './init-data.js';
6
- export * from './init-data-raw.js';
7
- export * from './invoice.js';
8
- export * from './launch-params.js';
9
- export * from './main-button.js';
10
- export * from './mini-app.js';
11
- export * from './popup.js';
12
- export * from './post-event.js';
13
- export * from './qr-scanner.js';
14
- export * from './settings-button.js';
15
- export * from './theme-params.js';
16
- export * from './viewport.js';
17
- export * from './utils.js';
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve init data raw representation.
5
- */
6
- export const useInitDataRaw = createHook('initDataRaw');
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve InitData component.
5
- */
6
- export const useInitData = createHook('initData');
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve Invoice component.
5
- */
6
- export const useInvoice = createHook('invoice', true);
@@ -1,8 +0,0 @@
1
- import { type LaunchParams, retrieveLaunchData } from '@tma.js/sdk';
2
-
3
- /**
4
- * Hooks to retrieve launch parameters.
5
- */
6
- export function useLaunchParams(): LaunchParams {
7
- return retrieveLaunchData().launchParams;
8
- }
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve MainButton component.
5
- */
6
- export const useMainButton = createHook('mainButton', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve MiniApp component.
5
- */
6
- export const useMiniApp = createHook('miniApp', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve Popup component.
5
- */
6
- export const usePopup = createHook('popup', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve postEvent function.
5
- */
6
- export const usePostEvent = createHook('postEvent');
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve QRScanner component.
5
- */
6
- export const useQRScanner = createHook('qrScanner', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve SettingsButton component.
5
- */
6
- export const useSettingsButton = createHook('settingsButton', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve ThemeParams component.
5
- */
6
- export const useThemeParams = createHook('themeParams', true);
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve Utils component.
5
- */
6
- export const useUtils = createHook('utils');
@@ -1,6 +0,0 @@
1
- import { createHook } from '../createHook.js';
2
-
3
- /**
4
- * Hook to retrieve Viewport component.
5
- */
6
- export const useViewport = createHook('viewport', true);
package/src/types.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { InitOptions, InitResult } from '@tma.js/sdk';
2
-
3
- export { InitOptions, InitResult };
4
-
5
- export interface Trackable {
6
- on(event: 'change', listener: () => void): () => void;
7
- }
8
-
9
- /**
10
- * SDK init result keys, which describe values with trackable changes.
11
- */
12
- export type DynamicInitResultKey = {
13
- [K in InitResultKey]-?: InitResultValue<K> extends Trackable ? K : never;
14
- }[InitResultKey];
15
-
16
- /**
17
- * SDK init result keys, which describe static values.
18
- */
19
- export type StaticInitResultKey = Exclude<InitResultKey, DynamicInitResultKey>;
20
-
21
- /**
22
- * SDK initialization result key.
23
- */
24
- export type InitResultKey = keyof InitResult;
25
-
26
- /**
27
- * Returns SDK init result value type by its key.
28
- */
29
- export type InitResultValue<K extends InitResultKey> = InitResult[K];