@lifi/widget 2.2.6 → 2.2.7
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/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/stores/StoreProvider.js +2 -1
- package/cjs/stores/chains/ChainOrderStore.d.ts +9 -0
- package/cjs/stores/chains/ChainOrderStore.js +31 -0
- package/cjs/stores/chains/createChainOrderStore.d.ts +4 -0
- package/cjs/stores/chains/{useChainOrderStore.js → createChainOrderStore.js} +4 -3
- package/cjs/stores/chains/index.d.ts +2 -1
- package/cjs/stores/chains/index.js +2 -1
- package/cjs/stores/chains/useChainOrder.js +2 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/package.json +1 -1
- package/stores/StoreProvider.js +2 -1
- package/stores/chains/ChainOrderStore.d.ts +9 -0
- package/stores/chains/ChainOrderStore.js +25 -0
- package/stores/chains/createChainOrderStore.d.ts +4 -0
- package/stores/chains/{useChainOrderStore.js → createChainOrderStore.js} +2 -2
- package/stores/chains/index.d.ts +2 -1
- package/stores/chains/index.js +2 -1
- package/stores/chains/useChainOrder.js +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/cjs/stores/chains/useChainOrderStore.d.ts +0 -3
- package/stores/chains/useChainOrderStore.d.ts +0 -3
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.2.
|
|
2
|
+
export declare const version = "2.2.7";
|
package/cjs/config/version.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StoreProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const chains_1 = require("./chains");
|
|
5
6
|
const header_1 = require("./header");
|
|
6
7
|
const routes_1 = require("./routes");
|
|
7
8
|
const settings_1 = require("./settings");
|
|
8
9
|
const StoreProvider = ({ children, config, }) => {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(header_1.HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }));
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(header_1.HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: (0, jsx_runtime_1.jsx)(chains_1.ChainOrderStoreProvider, { namePrefix: config?.keyPrefix, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }) }));
|
|
10
11
|
};
|
|
11
12
|
exports.StoreProvider = StoreProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand';
|
|
3
|
+
import type { PersistStoreProviderProps } from '../types';
|
|
4
|
+
import type { ChainOrderState } from './types';
|
|
5
|
+
export type ChainOrderStore = UseBoundStore<StoreApi<ChainOrderState>>;
|
|
6
|
+
export declare const ChainOrderStoreContext: import("react").Context<ChainOrderStore | null>;
|
|
7
|
+
export declare function ChainOrderStoreProvider({ children, ...props }: PersistStoreProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function useChainOrderStore<T>(selector: (state: ChainOrderState) => T, equalityFn?: (left: T, right: T) => boolean): T;
|
|
9
|
+
export declare function useChainOrderStoreContext(): ChainOrderStore;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useChainOrderStoreContext = exports.useChainOrderStore = exports.ChainOrderStoreProvider = exports.ChainOrderStoreContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const createChainOrderStore_1 = require("./createChainOrderStore");
|
|
7
|
+
exports.ChainOrderStoreContext = (0, react_1.createContext)(null);
|
|
8
|
+
function ChainOrderStoreProvider({ children, ...props }) {
|
|
9
|
+
const storeRef = (0, react_1.useRef)();
|
|
10
|
+
if (!storeRef.current) {
|
|
11
|
+
storeRef.current = (0, createChainOrderStore_1.createChainOrderStore)(props);
|
|
12
|
+
}
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(exports.ChainOrderStoreContext.Provider, { value: storeRef.current, children: children }));
|
|
14
|
+
}
|
|
15
|
+
exports.ChainOrderStoreProvider = ChainOrderStoreProvider;
|
|
16
|
+
function useChainOrderStore(selector, equalityFn) {
|
|
17
|
+
const useStore = (0, react_1.useContext)(exports.ChainOrderStoreContext);
|
|
18
|
+
if (!useStore) {
|
|
19
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
20
|
+
}
|
|
21
|
+
return useStore(selector, equalityFn);
|
|
22
|
+
}
|
|
23
|
+
exports.useChainOrderStore = useChainOrderStore;
|
|
24
|
+
function useChainOrderStoreContext() {
|
|
25
|
+
const useStore = (0, react_1.useContext)(exports.ChainOrderStoreContext);
|
|
26
|
+
if (!useStore) {
|
|
27
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
28
|
+
}
|
|
29
|
+
return useStore;
|
|
30
|
+
}
|
|
31
|
+
exports.useChainOrderStoreContext = useChainOrderStoreContext;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PersistStoreProps } from '../types';
|
|
2
|
+
import type { ChainOrderState } from './types';
|
|
3
|
+
export declare const maxChainToOrder = 9;
|
|
4
|
+
export declare const createChainOrderStore: ({ namePrefix }: PersistStoreProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<ChainOrderState>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createChainOrderStore = exports.maxChainToOrder = void 0;
|
|
4
4
|
const zustand_1 = require("zustand");
|
|
5
5
|
const middleware_1 = require("zustand/middleware");
|
|
6
6
|
exports.maxChainToOrder = 9;
|
|
7
|
-
|
|
7
|
+
const createChainOrderStore = ({ namePrefix }) => (0, zustand_1.create)((0, middleware_1.persist)((set, get) => ({
|
|
8
8
|
chainOrder: [],
|
|
9
9
|
availableChains: [],
|
|
10
10
|
initializeChains: (chainIds) => {
|
|
@@ -46,7 +46,8 @@ exports.useChainOrderStore = (0, zustand_1.create)((0, middleware_1.persist)((se
|
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
48
|
}), {
|
|
49
|
-
name:
|
|
49
|
+
name: `${namePrefix || 'li.fi'}-widget-chains-order`,
|
|
50
50
|
version: 0,
|
|
51
51
|
partialize: (state) => ({ chainOrder: state.chainOrder }),
|
|
52
52
|
}));
|
|
53
|
+
exports.createChainOrderStore = createChainOrderStore;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ChainOrderStore"), exports);
|
|
18
|
+
__exportStar(require("./createChainOrderStore"), exports);
|
|
17
19
|
__exportStar(require("./types"), exports);
|
|
18
20
|
__exportStar(require("./useChainOrder"), exports);
|
|
19
|
-
__exportStar(require("./useChainOrderStore"), exports);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useChainOrder = void 0;
|
|
4
4
|
const shallow_1 = require("zustand/shallow");
|
|
5
|
-
const
|
|
5
|
+
const ChainOrderStore_1 = require("./ChainOrderStore");
|
|
6
6
|
const useChainOrder = () => {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, ChainOrderStore_1.useChainOrderStore)((state) => [state.chainOrder, state.setChain], shallow_1.shallow);
|
|
8
8
|
};
|
|
9
9
|
exports.useChainOrder = useChainOrder;
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.2.
|
|
2
|
+
export declare const version = "2.2.7";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.2.
|
|
2
|
+
export const version = '2.2.7';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
package/stores/StoreProvider.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChainOrderStoreProvider } from './chains';
|
|
2
3
|
import { HeaderStoreProvider } from './header';
|
|
3
4
|
import { RouteExecutionStoreProvider } from './routes';
|
|
4
5
|
import { SplitSubvariantStoreProvider } from './settings';
|
|
5
6
|
export const StoreProvider = ({ children, config, }) => {
|
|
6
|
-
return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: _jsx(HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: _jsx(RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }));
|
|
7
|
+
return (_jsx(SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: _jsx(HeaderStoreProvider, { namePrefix: config?.keyPrefix, children: _jsx(ChainOrderStoreProvider, { namePrefix: config?.keyPrefix, children: _jsx(RouteExecutionStoreProvider, { namePrefix: config?.keyPrefix, children: children }) }) }) }));
|
|
7
8
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand';
|
|
3
|
+
import type { PersistStoreProviderProps } from '../types';
|
|
4
|
+
import type { ChainOrderState } from './types';
|
|
5
|
+
export type ChainOrderStore = UseBoundStore<StoreApi<ChainOrderState>>;
|
|
6
|
+
export declare const ChainOrderStoreContext: import("react").Context<ChainOrderStore | null>;
|
|
7
|
+
export declare function ChainOrderStoreProvider({ children, ...props }: PersistStoreProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function useChainOrderStore<T>(selector: (state: ChainOrderState) => T, equalityFn?: (left: T, right: T) => boolean): T;
|
|
9
|
+
export declare function useChainOrderStoreContext(): ChainOrderStore;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from 'react';
|
|
3
|
+
import { createChainOrderStore } from './createChainOrderStore';
|
|
4
|
+
export const ChainOrderStoreContext = createContext(null);
|
|
5
|
+
export function ChainOrderStoreProvider({ children, ...props }) {
|
|
6
|
+
const storeRef = useRef();
|
|
7
|
+
if (!storeRef.current) {
|
|
8
|
+
storeRef.current = createChainOrderStore(props);
|
|
9
|
+
}
|
|
10
|
+
return (_jsx(ChainOrderStoreContext.Provider, { value: storeRef.current, children: children }));
|
|
11
|
+
}
|
|
12
|
+
export function useChainOrderStore(selector, equalityFn) {
|
|
13
|
+
const useStore = useContext(ChainOrderStoreContext);
|
|
14
|
+
if (!useStore) {
|
|
15
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
16
|
+
}
|
|
17
|
+
return useStore(selector, equalityFn);
|
|
18
|
+
}
|
|
19
|
+
export function useChainOrderStoreContext() {
|
|
20
|
+
const useStore = useContext(ChainOrderStoreContext);
|
|
21
|
+
if (!useStore) {
|
|
22
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
23
|
+
}
|
|
24
|
+
return useStore;
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PersistStoreProps } from '../types';
|
|
2
|
+
import type { ChainOrderState } from './types';
|
|
3
|
+
export declare const maxChainToOrder = 9;
|
|
4
|
+
export declare const createChainOrderStore: ({ namePrefix }: PersistStoreProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<ChainOrderState>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist } from 'zustand/middleware';
|
|
3
3
|
export const maxChainToOrder = 9;
|
|
4
|
-
export const
|
|
4
|
+
export const createChainOrderStore = ({ namePrefix }) => create(persist((set, get) => ({
|
|
5
5
|
chainOrder: [],
|
|
6
6
|
availableChains: [],
|
|
7
7
|
initializeChains: (chainIds) => {
|
|
@@ -43,7 +43,7 @@ export const useChainOrderStore = create(persist((set, get) => ({
|
|
|
43
43
|
});
|
|
44
44
|
},
|
|
45
45
|
}), {
|
|
46
|
-
name:
|
|
46
|
+
name: `${namePrefix || 'li.fi'}-widget-chains-order`,
|
|
47
47
|
version: 0,
|
|
48
48
|
partialize: (state) => ({ chainOrder: state.chainOrder }),
|
|
49
49
|
}));
|
package/stores/chains/index.d.ts
CHANGED
package/stores/chains/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shallow } from 'zustand/shallow';
|
|
2
|
-
import { useChainOrderStore } from '
|
|
2
|
+
import { useChainOrderStore } from './ChainOrderStore';
|
|
3
3
|
export const useChainOrder = () => {
|
|
4
4
|
return useChainOrderStore((state) => [state.chainOrder, state.setChain], shallow);
|
|
5
5
|
};
|