@aurora-is-near/intents-swap-widget 1.3.3 → 1.4.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/dist/config.d.ts +1 -0
- package/dist/config.js +21 -18
- package/dist/config.js.map +1 -1
- package/package.json +1 -1
- package/src/config.tsx +4 -0
package/dist/config.d.ts
CHANGED
|
@@ -46,5 +46,6 @@ export declare const useConfig: () => {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
export declare const resetConfig: (config: WipgetConfig) => void;
|
|
49
50
|
export declare const WipgetConfigProvider: ({ children, config: userConfig, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
50
51
|
export {};
|
package/dist/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { deepClone as
|
|
3
|
-
import { proxy as a, useSnapshot as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { QueryClient as u, QueryClientProvider as
|
|
6
|
-
import { EVM_CHAINS as
|
|
2
|
+
import { deepClone as i } from "valtio/utils";
|
|
3
|
+
import { proxy as a, useSnapshot as c } from "valtio";
|
|
4
|
+
import { createContext as l, useContext as p, useEffect as f } from "react";
|
|
5
|
+
import { QueryClient as u, QueryClientProvider as g } from "@tanstack/react-query";
|
|
6
|
+
import { EVM_CHAINS as d } from "./constants/chains.js";
|
|
7
7
|
import { useAddClassToPortal as m } from "./hooks/useAddClassToPortal.js";
|
|
8
8
|
const w = new u({
|
|
9
9
|
defaultOptions: {
|
|
@@ -11,7 +11,7 @@ const w = new u({
|
|
|
11
11
|
staleTime: 2e3 * 60
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
}),
|
|
14
|
+
}), r = {
|
|
15
15
|
appName: "Unknown",
|
|
16
16
|
appIcon: "https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg",
|
|
17
17
|
// 74px - height of the header
|
|
@@ -19,7 +19,7 @@ const w = new u({
|
|
|
19
19
|
topScreenOffset: "10vh + 74px",
|
|
20
20
|
defaultMaxSlippage: 0.01,
|
|
21
21
|
intentsAccountType: "evm",
|
|
22
|
-
walletSupportedChains:
|
|
22
|
+
walletSupportedChains: d,
|
|
23
23
|
walletAddress: void 0,
|
|
24
24
|
filterChains: () => !0,
|
|
25
25
|
filterTokens: () => !0,
|
|
@@ -28,21 +28,24 @@ const w = new u({
|
|
|
28
28
|
source: { external: "wallet-supported", intents: "with-balance" },
|
|
29
29
|
target: { external: "all", intents: "all" }
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
config:
|
|
31
|
+
}, s = l(r), n = a({
|
|
32
|
+
config: r
|
|
33
33
|
}), b = () => {
|
|
34
|
-
const e =
|
|
35
|
-
return
|
|
36
|
-
}, k = ({
|
|
34
|
+
const e = p(s);
|
|
35
|
+
return c(e);
|
|
36
|
+
}, k = (e) => {
|
|
37
|
+
n.config = i(e);
|
|
38
|
+
}, A = ({
|
|
37
39
|
children: e,
|
|
38
|
-
config: t =
|
|
40
|
+
config: t = r
|
|
39
41
|
}) => (f(() => {
|
|
40
|
-
|
|
41
|
-
}, [t]), m("headlessui-portal-root", "sw"), /* @__PURE__ */ o(
|
|
42
|
+
n.config = i(t);
|
|
43
|
+
}, [t]), m("headlessui-portal-root", "sw"), /* @__PURE__ */ o(g, { client: w, children: /* @__PURE__ */ o(s.Provider, { value: n.config, children: /* @__PURE__ */ o("div", { className: "sw", children: e }) }) }));
|
|
42
44
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
A as WipgetConfigProvider,
|
|
46
|
+
n as configStore,
|
|
47
|
+
r as defaultConfig,
|
|
48
|
+
k as resetConfig,
|
|
46
49
|
b as useConfig
|
|
47
50
|
};
|
|
48
51
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../src/config.tsx"],"sourcesContent":["import { deepClone } from 'valtio/utils';\nimport { proxy, useSnapshot } from 'valtio';\nimport { createContext, useContext, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\n\nimport { EVM_CHAINS } from '@/constants/chains';\nimport { useAddClassToPortal } from '@/hooks/useAddClassToPortal';\nimport type { Chain, Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nexport type WipgetConfig = {\n // Application metadata\n appName: string;\n appIcon: string;\n\n // Layout and UI\n topScreenOffset: string;\n\n // Connected wallet\n intentsAccountType: 'evm' | 'near' | 'sol';\n walletSupportedChains: ReadonlyArray<Chains>;\n walletAddress: string | undefined | null;\n\n // Quotes & Transfers\n defaultMaxSlippage: number;\n\n // Chains & Tokens filtering\n showIntentTokens: boolean;\n filterTokens: (token: Token) => boolean;\n filterChains: (chain: Chain) => boolean;\n\n chainsFilter: {\n source: DefaultChainsFilter;\n target: DefaultChainsFilter;\n };\n};\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 2000 * 60,\n },\n },\n});\n\nexport const defaultConfig: WipgetConfig = {\n appName: 'Unknown',\n appIcon:\n 'https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg',\n\n // 74px - height of the header\n // 10vh - desired offset from the top of the screen\n topScreenOffset: '10vh + 74px',\n defaultMaxSlippage: 0.01,\n\n intentsAccountType: 'evm',\n walletSupportedChains: EVM_CHAINS,\n walletAddress: undefined,\n\n filterChains: () => true,\n filterTokens: () => true,\n showIntentTokens: true,\n chainsFilter: {\n source: { external: 'wallet-supported', intents: 'with-balance' },\n target: { external: 'all', intents: 'all' },\n },\n};\n\ntype WipgetConfigContextType = WipgetConfig;\n\nconst WipgetConfigContext =\n createContext<WipgetConfigContextType>(defaultConfig);\n\ntype Props = PropsWithChildren<{ config?: WipgetConfig }>;\n\nexport const configStore = proxy<{ config: WipgetConfig }>({\n config: defaultConfig,\n});\n\nexport const useConfig = () => {\n const configState = useContext(WipgetConfigContext);\n const config = useSnapshot(configState);\n\n return config;\n};\n\nexport const WipgetConfigProvider = ({\n children,\n config: userConfig = defaultConfig,\n}: Props) => {\n useEffect(() => {\n configStore.config = deepClone(userConfig);\n }, [userConfig]);\n\n // add tailwind parent class to portal root\n useAddClassToPortal('headlessui-portal-root', 'sw');\n\n return (\n <QueryClientProvider client={queryClient}>\n <WipgetConfigContext.Provider value={configStore.config}>\n <div className=\"sw\">{children}</div>\n </WipgetConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"],"names":["queryClient","QueryClient","defaultConfig","EVM_CHAINS","WipgetConfigContext","createContext","configStore","proxy","useConfig","configState","useContext","useSnapshot","WipgetConfigProvider","children","userConfig","useEffect","
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config.tsx"],"sourcesContent":["import { deepClone } from 'valtio/utils';\nimport { proxy, useSnapshot } from 'valtio';\nimport { createContext, useContext, useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\n\nimport { EVM_CHAINS } from '@/constants/chains';\nimport { useAddClassToPortal } from '@/hooks/useAddClassToPortal';\nimport type { Chain, Chains, DefaultChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\nexport type WipgetConfig = {\n // Application metadata\n appName: string;\n appIcon: string;\n\n // Layout and UI\n topScreenOffset: string;\n\n // Connected wallet\n intentsAccountType: 'evm' | 'near' | 'sol';\n walletSupportedChains: ReadonlyArray<Chains>;\n walletAddress: string | undefined | null;\n\n // Quotes & Transfers\n defaultMaxSlippage: number;\n\n // Chains & Tokens filtering\n showIntentTokens: boolean;\n filterTokens: (token: Token) => boolean;\n filterChains: (chain: Chain) => boolean;\n\n chainsFilter: {\n source: DefaultChainsFilter;\n target: DefaultChainsFilter;\n };\n};\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 2000 * 60,\n },\n },\n});\n\nexport const defaultConfig: WipgetConfig = {\n appName: 'Unknown',\n appIcon:\n 'https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg',\n\n // 74px - height of the header\n // 10vh - desired offset from the top of the screen\n topScreenOffset: '10vh + 74px',\n defaultMaxSlippage: 0.01,\n\n intentsAccountType: 'evm',\n walletSupportedChains: EVM_CHAINS,\n walletAddress: undefined,\n\n filterChains: () => true,\n filterTokens: () => true,\n showIntentTokens: true,\n chainsFilter: {\n source: { external: 'wallet-supported', intents: 'with-balance' },\n target: { external: 'all', intents: 'all' },\n },\n};\n\ntype WipgetConfigContextType = WipgetConfig;\n\nconst WipgetConfigContext =\n createContext<WipgetConfigContextType>(defaultConfig);\n\ntype Props = PropsWithChildren<{ config?: WipgetConfig }>;\n\nexport const configStore = proxy<{ config: WipgetConfig }>({\n config: defaultConfig,\n});\n\nexport const useConfig = () => {\n const configState = useContext(WipgetConfigContext);\n const config = useSnapshot(configState);\n\n return config;\n};\n\nexport const resetConfig = (config: WipgetConfig) => {\n configStore.config = deepClone(config);\n};\n\nexport const WipgetConfigProvider = ({\n children,\n config: userConfig = defaultConfig,\n}: Props) => {\n useEffect(() => {\n configStore.config = deepClone(userConfig);\n }, [userConfig]);\n\n // add tailwind parent class to portal root\n useAddClassToPortal('headlessui-portal-root', 'sw');\n\n return (\n <QueryClientProvider client={queryClient}>\n <WipgetConfigContext.Provider value={configStore.config}>\n <div className=\"sw\">{children}</div>\n </WipgetConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"],"names":["queryClient","QueryClient","defaultConfig","EVM_CHAINS","WipgetConfigContext","createContext","configStore","proxy","useConfig","configState","useContext","useSnapshot","resetConfig","config","deepClone","WipgetConfigProvider","children","userConfig","useEffect","useAddClassToPortal","QueryClientProvider","jsx"],"mappings":";;;;;;;AAsCA,MAAMA,IAAc,IAAIC,EAAY;AAAA,EAClC,gBAAgB;AAAA,IACd,SAAS;AAAA,MACP,WAAW,MAAO;AAAA,IAAA;AAAA,EACpB;AAEJ,CAAC,GAEYC,IAA8B;AAAA,EACzC,SAAS;AAAA,EACT,SACE;AAAA;AAAA;AAAA,EAIF,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EAEpB,oBAAoB;AAAA,EACpB,uBAAuBC;AAAA,EACvB,eAAe;AAAA,EAEf,cAAc,MAAM;AAAA,EACpB,cAAc,MAAM;AAAA,EACpB,kBAAkB;AAAA,EAClB,cAAc;AAAA,IACZ,QAAQ,EAAE,UAAU,oBAAoB,SAAS,eAAA;AAAA,IACjD,QAAQ,EAAE,UAAU,OAAO,SAAS,MAAA;AAAA,EAAM;AAE9C,GAIMC,IACJC,EAAuCH,CAAa,GAIzCI,IAAcC,EAAgC;AAAA,EACzD,QAAQL;AACV,CAAC,GAEYM,IAAY,MAAM;AAC7B,QAAMC,IAAcC,EAAWN,CAAmB;AAGlD,SAFeO,EAAYF,CAAW;AAGxC,GAEaG,IAAc,CAACC,MAAyB;AACnD,EAAAP,EAAY,SAASQ,EAAUD,CAAM;AACvC,GAEaE,IAAuB,CAAC;AAAA,EACnC,UAAAC;AAAA,EACA,QAAQC,IAAaf;AACvB,OACEgB,EAAU,MAAM;AACd,EAAAZ,EAAY,SAASQ,EAAUG,CAAU;AAC3C,GAAG,CAACA,CAAU,CAAC,GAGfE,EAAoB,0BAA0B,IAAI,qBAG/CC,GAAA,EAAoB,QAAQpB,GAC3B,UAAA,gBAAAqB,EAACjB,EAAoB,UAApB,EAA6B,OAAOE,EAAY,QAC/C,UAAA,gBAAAe,EAAC,OAAA,EAAI,WAAU,MAAM,UAAAL,EAAA,CAAS,GAChC,GACF;"}
|
package/package.json
CHANGED
package/src/config.tsx
CHANGED
|
@@ -85,6 +85,10 @@ export const useConfig = () => {
|
|
|
85
85
|
return config;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export const resetConfig = (config: WipgetConfig) => {
|
|
89
|
+
configStore.config = deepClone(config);
|
|
90
|
+
};
|
|
91
|
+
|
|
88
92
|
export const WipgetConfigProvider = ({
|
|
89
93
|
children,
|
|
90
94
|
config: userConfig = defaultConfig,
|