@frak-labs/react-sdk 0.1.0-beta.8d103039 → 0.1.0-beta.9f335831
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +368 -386
- package/dist/index.d.ts +368 -386
- package/dist/index.js +1 -1
- package/package.json +26 -12
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{displayModal as e,getProductInformation as t,openSso as n,prepareSso as r,processReferral as i,sendInteraction as a,sendTransaction as o,siweAuthenticate as s,watchWalletStatus as c}from"@frak-labs/core-sdk/actions";import{ClientNotFound as l,FrakRpcError as u,RpcErrorCodes as d}from"@frak-labs/frame-connector";import{useMutation as f,useQuery as p,useQueryClient as m}from"@tanstack/react-query";import{Fragment as h,createContext as g,createElement as _,useCallback as v,useContext as y,useEffect as b,useMemo as x,useState as S}from"react";import{FrakContextManager as C,baseIframeProps as w,createIFrameFrakClient as T}from"@frak-labs/core-sdk";const E=g(void 0);function D(e){let{children:t,config:n}=e;return _(E.Provider,{value:{...n,walletUrl:n.walletUrl??`https://wallet.frak.id`,domain:n.domain??(typeof window<`u`?window?.location?.host:void 0)??`not-found`}},t)}const O=g(void 0);function k({style:e,children:t}){let n=L(),[r,i]=S(void 0);return _(h,null,_(`iframe`,{...w,src:`${n.walletUrl}/listener`,style:e??w.style,ref:e=>{!e||r||i(T({iframe:e,config:n}))}}),_(O.Provider,{value:r},t))}function A(){return y(O)}function j(){let e=m(),t=A(),n=v(t=>{e.setQueryData([`frak-sdk`,`wallet-status-listener`],t)},[e]);return p({gcTime:0,staleTime:0,queryKey:[`frak-sdk`,`wallet-status-listener`],queryFn:async()=>{if(!t)throw new l;return c(t,n)},enabled:!!t})}function M(){let[e,t]=S(!1);return b(()=>{t(!0)},[]),e}function N(){let e=M(),[t,n]=S(e?window.location:void 0);return b(()=>{if(!e)return;function r(){n(window.location)}return t||r(),window.addEventListener(`popstate`,r),()=>{window.removeEventListener(`popstate`,r)}},[e,t]),{location:t,href:x(()=>t?.href,[t?.href])}}function P(){let{location:e}=N();return{frakContext:x(()=>e?.href?C.parse({url:e.href}):null,[e?.href]),updateContext:v(t=>{console.log(`Updating context`,{newContext:t}),C.replaceUrl({url:e?.href,context:t})},[e?.href])}}function F({productId:e,modalConfig:t,options:n}={}){let r=A(),{frakContext:a}=P(),{data:o}=j(),{data:s,error:c,status:u}=p({gcTime:0,staleTime:0,queryKey:[`frak-sdk`,`auto-referral-interaction`,a?.r??`no-referrer`,o?.key??`no-wallet-status`,e??`no-product-id`],queryFn:()=>{if(!r)throw new l;return i(r,{walletStatus:o,frakContext:a,modalConfig:t,productId:e,options:n})},enabled:!!o});return x(()=>u===`pending`?`processing`:u===`error`?c:s||`idle`,[s,u,c])}function I({mutations:t}={}){let n=A();return f({...t,mutationKey:[`frak-sdk`,`display-modal`],mutationFn:async t=>{if(!n)throw new l;return e(n,t)}})}function L(){let e=y(E);if(!e)throw new u(d.configError,`Frak config not found`);return e}function R({query:e}={}){let n=A();return p({...e,queryKey:[`frak-sdk`,`get-product-information`],queryFn:async()=>{if(!n)throw new l;return t(n)}})}function z({mutations:e}={}){let t=A();return f({...e,mutationKey:[`frak-sdk`,`open-sso`],mutationFn:async e=>{if(!t)throw new l;return n(t,e)}})}function B(e){let t=A();return p({queryKey:[`frak-sdk`,`prepare-sso`,e],queryFn:async()=>{if(!t)throw new l;return r(t,e)}})}function V({mutations:e}={}){let t=A();return f({...e,mutationKey:[`frak-sdk`,`send-interaction`],mutationFn:async e=>{if(!t)throw new l;return a(t,e)}})}function H({mutations:e}={}){let t=A();return f({...e,mutationKey:[`frak-sdk`,`send-transaction`],mutationFn:async e=>{if(!t)throw new l;return o(t,e)}})}function U({mutations:e}={}){let t=A();return f({...e,mutationKey:[`frak-sdk`,`siwe-authenticate`,t?.config.domain??`no-domain`],mutationFn:async e=>{if(!t)throw new l;return s(t,e)}})}export{E as FrakConfigContext,D as FrakConfigProvider,O as FrakIFrameClientContext,k as FrakIFrameClientProvider,I as useDisplayModal,A as useFrakClient,L as useFrakConfig,R as useGetProductInformation,z as useOpenSso,B as usePrepareSso,F as useReferralInteraction,V as useSendInteraction,H as useSendTransactionAction,U as useSiweAuthenticate,j as useWalletStatus};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.1.0-beta.
|
|
14
|
+
"version": "0.1.0-beta.9f335831",
|
|
15
15
|
"description": "React SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"types": "./dist/index.d.cts",
|
|
40
40
|
"exports": {
|
|
41
41
|
".": {
|
|
42
|
+
"development": "./src/index.ts",
|
|
42
43
|
"import": {
|
|
43
44
|
"types": "./dist/index.d.ts",
|
|
44
45
|
"default": "./dist/index.js"
|
|
@@ -54,10 +55,13 @@
|
|
|
54
55
|
"format:check": "biome check .",
|
|
55
56
|
"format": "biome check --write .",
|
|
56
57
|
"clean": "rimraf dist",
|
|
57
|
-
"build": "
|
|
58
|
-
"build:watch": "
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"build:watch": "tsdown --watch",
|
|
59
60
|
"check-exports": "attw --pack .",
|
|
60
61
|
"typecheck": "tsc --noEmit",
|
|
62
|
+
"test": "vitest",
|
|
63
|
+
"test:ui": "vitest --ui",
|
|
64
|
+
"test:coverage": "vitest --coverage",
|
|
61
65
|
"prepublish": "bun run lint && bun run build",
|
|
62
66
|
"publish": "echo 'Publishing react...'"
|
|
63
67
|
},
|
|
@@ -72,14 +76,24 @@
|
|
|
72
76
|
},
|
|
73
77
|
"devDependencies": {
|
|
74
78
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
+
"@frak-labs/dev-tooling": "0.0.0",
|
|
80
|
+
"@frak-labs/test-foundation": "0.1.0",
|
|
81
|
+
"@frak-labs/wallet-shared": "0.0.0",
|
|
82
|
+
"@tanstack/react-query": "^5.90.12",
|
|
83
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
84
|
+
"@testing-library/react": "^16.3.1",
|
|
85
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
86
|
+
"@testing-library/user-event": "^14.6.1",
|
|
87
|
+
"@types/jsdom": "^27.0.0",
|
|
88
|
+
"@types/node": "^24.10.4",
|
|
89
|
+
"@types/react": "19.2.7",
|
|
90
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
91
|
+
"@vitest/ui": "^4.0.16",
|
|
92
|
+
"jsdom": "^27.3.0",
|
|
93
|
+
"react": "^19.2.3",
|
|
94
|
+
"tsdown": "^0.18.2",
|
|
79
95
|
"typescript": "^5",
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"extends @frak-labs/browserslist-config"
|
|
84
|
-
]
|
|
96
|
+
"viem": "^2.39.0",
|
|
97
|
+
"vitest": "^4.0.16"
|
|
98
|
+
}
|
|
85
99
|
}
|