@bigmi/react 0.7.1 → 0.8.0-beta.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/cjs/context.d.ts +15 -0
- package/dist/cjs/context.js +16 -0
- package/dist/cjs/context.js.map +1 -0
- package/dist/cjs/errors/context.d.ts +13 -0
- package/dist/cjs/errors/context.js +13 -0
- package/dist/cjs/errors/context.js.map +1 -0
- package/dist/cjs/hooks/useAccount.d.ts +11 -0
- package/dist/cjs/hooks/useAccount.js +26 -0
- package/dist/cjs/hooks/useAccount.js.map +1 -0
- package/dist/cjs/hooks/useConfig.d.ts +13 -0
- package/dist/cjs/hooks/useConfig.js +15 -0
- package/dist/cjs/hooks/useConfig.js.map +1 -0
- package/dist/cjs/hooks/useConnect.d.ts +20 -0
- package/dist/cjs/hooks/useConnect.js +32 -0
- package/dist/cjs/hooks/useConnect.js.map +1 -0
- package/dist/cjs/hooks/useConnectors.d.ts +11 -0
- package/dist/cjs/hooks/useConnectors.js +15 -0
- package/dist/cjs/hooks/useConnectors.js.map +1 -0
- package/dist/cjs/hooks/useReconnect.d.ts +7 -0
- package/dist/cjs/hooks/useReconnect.js +14 -0
- package/dist/cjs/hooks/useReconnect.js.map +1 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.d.ts +5 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.js +41 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.js.map +1 -0
- package/dist/cjs/hydrate.d.ts +21 -0
- package/dist/cjs/hydrate.js +45 -0
- package/dist/cjs/hydrate.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.ts +12 -0
- package/dist/cjs/types.js +0 -0
- package/dist/cjs/utils/query.d.ts +9 -0
- package/dist/cjs/utils/query.js +1 -0
- package/dist/cjs/version.d.ts +6 -0
- package/dist/cjs/version.js +9 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/context.d.ts +14 -9
- package/dist/esm/context.d.ts.map +1 -0
- package/dist/esm/context.js +12 -8
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/errors/context.d.ts +11 -6
- package/dist/esm/errors/context.d.ts.map +1 -0
- package/dist/esm/errors/context.js +11 -7
- package/dist/esm/errors/context.js.map +1 -1
- package/dist/esm/hooks/useAccount.d.ts +11 -6
- package/dist/esm/hooks/useAccount.d.ts.map +1 -0
- package/dist/esm/hooks/useAccount.js +23 -7
- package/dist/esm/hooks/useAccount.js.map +1 -1
- package/dist/esm/hooks/useConfig.d.ts +12 -7
- package/dist/esm/hooks/useConfig.d.ts.map +1 -0
- package/dist/esm/hooks/useConfig.js +12 -11
- package/dist/esm/hooks/useConfig.js.map +1 -1
- package/dist/esm/hooks/useConnect.d.ts +18 -13
- package/dist/esm/hooks/useConnect.d.ts.map +1 -0
- package/dist/esm/hooks/useConnect.js +29 -28
- package/dist/esm/hooks/useConnect.js.map +1 -1
- package/dist/esm/hooks/useConnectors.d.ts +11 -6
- package/dist/esm/hooks/useConnectors.d.ts.map +1 -0
- package/dist/esm/hooks/useConnectors.js +12 -7
- package/dist/esm/hooks/useConnectors.js.map +1 -1
- package/dist/esm/hooks/useReconnect.d.ts +7 -2
- package/dist/esm/hooks/useReconnect.d.ts.map +1 -0
- package/dist/esm/hooks/useReconnect.js +11 -7
- package/dist/esm/hooks/useReconnect.js.map +1 -1
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.d.ts +5 -1
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.d.ts.map +1 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js +38 -42
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js.map +1 -1
- package/dist/esm/hydrate.d.ts +17 -13
- package/dist/esm/hydrate.d.ts.map +1 -0
- package/dist/esm/hydrate.js +40 -58
- package/dist/esm/hydrate.js.map +1 -1
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +6 -6
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +11 -6
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +0 -1
- package/dist/esm/utils/query.d.ts +9 -4
- package/dist/esm/utils/query.d.ts.map +1 -0
- package/dist/esm/utils/query.js +1 -2
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +3 -3
- package/src/context.ts +10 -5
- package/src/hooks/useAccount.ts +15 -1
- package/src/hooks/useConnectors.ts +3 -1
- package/src/hooks/useReconnect.ts +1 -1
- package/src/hooks/useSyncExternalStoreWithTracked.ts +1 -1
- package/src/hydrate.ts +5 -2
- package/src/version.ts +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/query.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResolvedRegister } from "./types.js";
|
|
2
|
+
import { State } from "@bigmi/client";
|
|
3
|
+
import { Context, PropsWithChildren, ReactElement } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/context.d.ts
|
|
6
|
+
declare const BigmiContext: Context<ResolvedRegister["config"] | undefined>;
|
|
7
|
+
type BigmiProviderProps = {
|
|
8
|
+
config: ResolvedRegister["config"];
|
|
9
|
+
initialState?: State | undefined;
|
|
10
|
+
reconnectOnMount?: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
declare function BigmiProvider(parameters: PropsWithChildren<BigmiProviderProps>): ReactElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { BigmiContext, BigmiProvider, BigmiProviderProps };
|
|
15
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_hydrate = require("./hydrate.js");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
//#region src/context.ts
|
|
6
|
+
const BigmiContext = (0, react.createContext)(void 0);
|
|
7
|
+
function BigmiProvider(parameters) {
|
|
8
|
+
const { children, config } = parameters;
|
|
9
|
+
const props = { value: config };
|
|
10
|
+
return (0, react.createElement)(require_hydrate.Hydrate, parameters, (0, react.createElement)(BigmiContext.Provider, props, children));
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.BigmiContext = BigmiContext;
|
|
14
|
+
exports.BigmiProvider = BigmiProvider;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["Hydrate"],"sources":["../../src/context.ts"],"sourcesContent":["'use client'\nimport type { State } from '@bigmi/client'\nimport {\n type Context,\n createContext,\n createElement,\n type PropsWithChildren,\n type ReactElement,\n} from 'react'\nimport { Hydrate } from './hydrate.js'\nimport type { ResolvedRegister } from './types.js'\n\nexport const BigmiContext: Context<ResolvedRegister['config'] | undefined> =\n createContext<ResolvedRegister['config'] | undefined>(undefined)\n\nexport type BigmiProviderProps = {\n config: ResolvedRegister['config']\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function BigmiProvider(\n parameters: PropsWithChildren<BigmiProviderProps>\n): ReactElement {\n const { children, config } = parameters\n\n const props = { value: config }\n return createElement(\n Hydrate,\n parameters,\n createElement(BigmiContext.Provider, props, children)\n )\n}\n"],"mappings":";;;;;AAYA,MAAa,gBAAA,GAAA,MAAA,eAC2C,KAAA,EAAU;AAQlE,SAAgB,cACd,YACc;CACd,MAAM,EAAE,UAAU,WAAW;CAE7B,MAAM,QAAQ,EAAE,OAAO,QAAQ;AAC/B,SAAA,GAAA,MAAA,eACEA,gBAAAA,SACA,aAAA,GAAA,MAAA,eACc,aAAa,UAAU,OAAO,SAAS,CACtD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseError } from "@bigmi/core";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/context.d.ts
|
|
4
|
+
type BigmiProviderNotFoundErrorType = BigmiProviderNotFoundError & {
|
|
5
|
+
name: "BigmiProviderNotFoundError";
|
|
6
|
+
};
|
|
7
|
+
declare class BigmiProviderNotFoundError extends BaseError {
|
|
8
|
+
override name: string;
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BigmiProviderNotFoundError, BigmiProviderNotFoundErrorType };
|
|
13
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _bigmi_core = require("@bigmi/core");
|
|
3
|
+
//#region src/errors/context.ts
|
|
4
|
+
var BigmiProviderNotFoundError = class extends _bigmi_core.BaseError {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("`useConfig` must be used within `BigmiProvider`.");
|
|
7
|
+
this.name = "BigmiProviderNotFoundError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.BigmiProviderNotFoundError = BigmiProviderNotFoundError;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["BaseError"],"sources":["../../../src/errors/context.ts"],"sourcesContent":["import { BaseError } from '@bigmi/core'\n\nexport type BigmiProviderNotFoundErrorType = BigmiProviderNotFoundError & {\n name: 'BigmiProviderNotFoundError'\n}\nexport class BigmiProviderNotFoundError extends BaseError {\n override name = 'BigmiProviderNotFoundError'\n constructor() {\n super('`useConfig` must be used within `BigmiProvider`.')\n }\n}\n"],"mappings":";;;AAKA,IAAa,6BAAb,cAAgDA,YAAAA,UAAU;CAExD,cAAc;AACZ,QAAM,mDAAmD;cAF3C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ResolvedRegister } from "../types.js";
|
|
2
|
+
import { ConfigParameter } from "./useConfig.js";
|
|
3
|
+
import { Config, GetAccountReturnType } from "@bigmi/client";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/useAccount.d.ts
|
|
6
|
+
type UseAccountParameters<config extends Config = Config> = ConfigParameter<config>;
|
|
7
|
+
type UseAccountReturnType<config extends Config = Config> = GetAccountReturnType<config>;
|
|
8
|
+
declare function useAccount<C extends Config = ResolvedRegister["config"]>(parameters?: UseAccountParameters<C>): UseAccountReturnType<C>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { UseAccountParameters, UseAccountReturnType, useAccount };
|
|
11
|
+
//# sourceMappingURL=useAccount.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_hooks_useConfig = require("./useConfig.js");
|
|
4
|
+
const require_hooks_useSyncExternalStoreWithTracked = require("./useSyncExternalStoreWithTracked.js");
|
|
5
|
+
let _bigmi_client = require("@bigmi/client");
|
|
6
|
+
//#region src/hooks/useAccount.ts
|
|
7
|
+
const DISCONNECTED_ACCOUNT = {
|
|
8
|
+
account: void 0,
|
|
9
|
+
accounts: void 0,
|
|
10
|
+
chain: void 0,
|
|
11
|
+
chainId: void 0,
|
|
12
|
+
connector: void 0,
|
|
13
|
+
isConnected: false,
|
|
14
|
+
isConnecting: false,
|
|
15
|
+
isDisconnected: true,
|
|
16
|
+
isReconnecting: false,
|
|
17
|
+
status: "disconnected"
|
|
18
|
+
};
|
|
19
|
+
function useAccount(parameters = {}) {
|
|
20
|
+
const config = require_hooks_useConfig.useConfig(parameters);
|
|
21
|
+
return require_hooks_useSyncExternalStoreWithTracked.useSyncExternalStoreWithTracked((onChange) => (0, _bigmi_client.watchAccount)(config, { onChange }), () => (0, _bigmi_client.getAccount)(config), () => DISCONNECTED_ACCOUNT);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.useAccount = useAccount;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=useAccount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccount.js","names":["useConfig","useSyncExternalStoreWithTracked"],"sources":["../../../src/hooks/useAccount.ts"],"sourcesContent":["'use client'\n\nimport {\n type Config,\n type GetAccountReturnType,\n getAccount,\n watchAccount,\n} from '@bigmi/client'\n\nimport type { ResolvedRegister } from '../types.js'\nimport { type ConfigParameter, useConfig } from './useConfig.js'\nimport { useSyncExternalStoreWithTracked } from './useSyncExternalStoreWithTracked.js'\n\nexport type UseAccountParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseAccountReturnType<config extends Config = Config> =\n GetAccountReturnType<config>\n\nconst DISCONNECTED_ACCOUNT: GetAccountReturnType = {\n account: undefined,\n accounts: undefined,\n chain: undefined,\n chainId: undefined,\n connector: undefined,\n isConnected: false,\n isConnecting: false,\n isDisconnected: true,\n isReconnecting: false,\n status: 'disconnected',\n}\n\nexport function useAccount<C extends Config = ResolvedRegister['config']>(\n parameters: UseAccountParameters<C> = {}\n): UseAccountReturnType<C> {\n const config = useConfig(parameters)\n\n return useSyncExternalStoreWithTracked(\n (onChange) => watchAccount(config, { onChange }),\n () => getAccount(config),\n () => DISCONNECTED_ACCOUNT as UseAccountReturnType<C>\n )\n}\n"],"mappings":";;;;;;AAmBA,MAAM,uBAA6C;CACjD,SAAS,KAAA;CACT,UAAU,KAAA;CACV,OAAO,KAAA;CACP,SAAS,KAAA;CACT,WAAW,KAAA;CACX,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,gBAAgB;CAChB,QAAQ;CACT;AAED,SAAgB,WACd,aAAsC,EAAE,EACf;CACzB,MAAM,SAASA,wBAAAA,UAAU,WAAW;AAEpC,QAAOC,8CAAAA,iCACJ,cAAA,GAAA,cAAA,cAA0B,QAAQ,EAAE,UAAU,CAAC,SAAA,GAAA,cAAA,YAC/B,OAAO,QAClB,qBACP"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResolvedRegister } from "../types.js";
|
|
2
|
+
import { Config } from "@bigmi/client";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useConfig.d.ts
|
|
5
|
+
type ConfigParameter<config extends Config = Config> = {
|
|
6
|
+
config?: Config | config | undefined;
|
|
7
|
+
};
|
|
8
|
+
type UseConfigParameters<config extends Config = Config> = ConfigParameter<config>;
|
|
9
|
+
type UseConfigReturnType<config extends Config = Config> = config;
|
|
10
|
+
declare function useConfig<C extends Config = ResolvedRegister["config"]>(parameters?: UseConfigParameters<C>): UseConfigReturnType<C>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ConfigParameter, UseConfigParameters, UseConfigReturnType, useConfig };
|
|
13
|
+
//# sourceMappingURL=useConfig.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_context = require("../context.js");
|
|
4
|
+
const require_errors_context = require("../errors/context.js");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
//#region src/hooks/useConfig.ts
|
|
7
|
+
function useConfig(parameters = {}) {
|
|
8
|
+
const config = parameters.config ?? (0, react.useContext)(require_context.BigmiContext);
|
|
9
|
+
if (!config) throw new require_errors_context.BigmiProviderNotFoundError();
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.useConfig = useConfig;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=useConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfig.js","names":["BigmiContext","BigmiProviderNotFoundError"],"sources":["../../../src/hooks/useConfig.ts"],"sourcesContent":["'use client'\n\nimport type { Config } from '@bigmi/client'\nimport { useContext } from 'react'\nimport { BigmiContext } from '../context.js'\nimport { BigmiProviderNotFoundError } from '../errors/context.js'\nimport type { ResolvedRegister } from '../types.js'\n\nexport type ConfigParameter<config extends Config = Config> = {\n config?: Config | config | undefined\n}\n\nexport type UseConfigParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseConfigReturnType<config extends Config = Config> = config\n\nexport function useConfig<C extends Config = ResolvedRegister['config']>(\n parameters: UseConfigParameters<C> = {}\n): UseConfigReturnType<C> {\n // biome-ignore lint/correctness/useHookAtTopLevel: part of the hook\n const config = parameters.config ?? useContext(BigmiContext)\n if (!config) {\n throw new BigmiProviderNotFoundError()\n }\n return config as UseConfigReturnType<C>\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,UACd,aAAqC,EAAE,EACf;CAExB,MAAM,SAAS,WAAW,WAAA,GAAA,MAAA,YAAqBA,gBAAAA,aAAa;AAC5D,KAAI,CAAC,OACH,OAAM,IAAIC,uBAAAA,4BAA4B;AAExC,QAAO"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ResolvedRegister } from "../types.js";
|
|
2
|
+
import { ConfigParameter } from "./useConfig.js";
|
|
3
|
+
import { UseMutationParameters, UseMutationReturnType } from "../utils/query.js";
|
|
4
|
+
import { UseConnectorsReturnType } from "./useConnectors.js";
|
|
5
|
+
import { Config, ConnectData, ConnectErrorType, ConnectMutate, ConnectMutateAsync, ConnectVariables } from "@bigmi/client";
|
|
6
|
+
import { Compute } from "@bigmi/core";
|
|
7
|
+
|
|
8
|
+
//#region src/hooks/useConnect.d.ts
|
|
9
|
+
type UseConnectParameters<config extends Config = Config, context = unknown> = Compute<ConfigParameter<config> & {
|
|
10
|
+
mutation?: UseMutationParameters<ConnectData<config>, ConnectErrorType, ConnectVariables<config, config["connectors"][number]>, context> | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
type UseConnectReturnType<config extends Config = Config, context = unknown> = Compute<UseMutationReturnType<ConnectData<config>, ConnectErrorType, ConnectVariables<config, config["connectors"][number]>, context> & {
|
|
13
|
+
connect: ConnectMutate<config, context>;
|
|
14
|
+
connectAsync: ConnectMutateAsync<config, context>;
|
|
15
|
+
connectors: Compute<UseConnectorsReturnType> | config["connectors"];
|
|
16
|
+
}>;
|
|
17
|
+
declare function useConnect<config extends Config = ResolvedRegister["config"], context = unknown>(parameters?: UseConnectParameters<config, context>): UseConnectReturnType<config, context>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { UseConnectParameters, UseConnectReturnType, useConnect };
|
|
20
|
+
//# sourceMappingURL=useConnect.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_hooks_useConfig = require("./useConfig.js");
|
|
4
|
+
const require_hooks_useConnectors = require("./useConnectors.js");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let _bigmi_client = require("@bigmi/client");
|
|
7
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
8
|
+
//#region src/hooks/useConnect.ts
|
|
9
|
+
function useConnect(parameters = {}) {
|
|
10
|
+
const { mutation } = parameters;
|
|
11
|
+
const config = require_hooks_useConfig.useConfig(parameters);
|
|
12
|
+
const mutationOptions = (0, _bigmi_client.connectMutationOptions)(config);
|
|
13
|
+
const { mutate, mutateAsync, reset, ...result } = (0, _tanstack_react_query.useMutation)({
|
|
14
|
+
...mutation,
|
|
15
|
+
...mutationOptions
|
|
16
|
+
});
|
|
17
|
+
(0, react.useEffect)(() => {
|
|
18
|
+
return config.subscribe(({ status }) => status, (status, previousStatus) => {
|
|
19
|
+
if (previousStatus === "connected" && status === "disconnected") reset();
|
|
20
|
+
});
|
|
21
|
+
}, [config, reset]);
|
|
22
|
+
return {
|
|
23
|
+
...result,
|
|
24
|
+
connect: mutate,
|
|
25
|
+
connectAsync: mutateAsync,
|
|
26
|
+
connectors: require_hooks_useConnectors.useConnectors({ config })
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.useConnect = useConnect;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useConnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnect.js","names":["useConfig","useConnectors"],"sources":["../../../src/hooks/useConnect.ts"],"sourcesContent":["'use client'\n\nimport {\n type Config,\n type ConnectData,\n type ConnectErrorType,\n type ConnectMutate,\n type ConnectMutateAsync,\n type ConnectVariables,\n connectMutationOptions,\n} from '@bigmi/client'\nimport type { Compute } from '@bigmi/core'\nimport { useMutation } from '@tanstack/react-query'\nimport { useEffect } from 'react'\nimport type { ResolvedRegister } from '../types.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { type ConfigParameter, useConfig } from './useConfig.js'\nimport { type UseConnectorsReturnType, useConnectors } from './useConnectors.js'\n\nexport type UseConnectParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n ConnectData<config>,\n ConnectErrorType,\n ConnectVariables<config, config['connectors'][number]>,\n context\n >\n | undefined\n }\n>\n\nexport type UseConnectReturnType<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n UseMutationReturnType<\n ConnectData<config>,\n ConnectErrorType,\n ConnectVariables<config, config['connectors'][number]>,\n context\n > & {\n connect: ConnectMutate<config, context>\n connectAsync: ConnectMutateAsync<config, context>\n connectors: Compute<UseConnectorsReturnType> | config['connectors']\n }\n>\n\nexport function useConnect<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseConnectParameters<config, context> = {}\n): UseConnectReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = connectMutationOptions(config)\n const { mutate, mutateAsync, reset, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n // Reset mutation back to an idle state when the connector disconnects.\n useEffect(() => {\n return config.subscribe(\n ({ status }) => status,\n (status, previousStatus) => {\n if (previousStatus === 'connected' && status === 'disconnected') {\n reset()\n }\n }\n )\n }, [config, reset])\n\n type Return = UseConnectReturnType<config, context>\n return {\n ...(result as Return),\n connect: mutate as Return['connect'],\n connectAsync: mutateAsync as Return['connectAsync'],\n connectors: useConnectors({ config }),\n }\n}\n"],"mappings":";;;;;;;;AAsDA,SAAgB,WAId,aAAoD,EAAE,EACf;CACvC,MAAM,EAAE,aAAa;CAErB,MAAM,SAASA,wBAAAA,UAAU,WAAW;CAEpC,MAAM,mBAAA,GAAA,cAAA,wBAAyC,OAAO;CACtD,MAAM,EAAE,QAAQ,aAAa,OAAO,GAAG,YAAA,GAAA,sBAAA,aAAuB;EAC5D,GAAG;EACH,GAAG;EACJ,CAAC;AAGF,EAAA,GAAA,MAAA,iBAAgB;AACd,SAAO,OAAO,WACX,EAAE,aAAa,SACf,QAAQ,mBAAmB;AAC1B,OAAI,mBAAmB,eAAe,WAAW,eAC/C,QAAO;IAGZ;IACA,CAAC,QAAQ,MAAM,CAAC;AAGnB,QAAO;EACL,GAAI;EACJ,SAAS;EACT,cAAc;EACd,YAAYC,4BAAAA,cAAc,EAAE,QAAQ,CAAC;EACtC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ResolvedRegister } from "../types.js";
|
|
2
|
+
import { ConfigParameter } from "./useConfig.js";
|
|
3
|
+
import { Config, GetConnectorsReturnType } from "@bigmi/client";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/useConnectors.d.ts
|
|
6
|
+
type UseConnectorsParameters<config extends Config = Config> = ConfigParameter<config>;
|
|
7
|
+
type UseConnectorsReturnType<config extends Config = Config> = GetConnectorsReturnType<config>;
|
|
8
|
+
declare function useConnectors<config extends Config = ResolvedRegister["config"]>(parameters?: UseConnectorsParameters<config>): UseConnectorsReturnType<config>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { UseConnectorsParameters, UseConnectorsReturnType, useConnectors };
|
|
11
|
+
//# sourceMappingURL=useConnectors.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_hooks_useConfig = require("./useConfig.js");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let _bigmi_client = require("@bigmi/client");
|
|
6
|
+
//#region src/hooks/useConnectors.ts
|
|
7
|
+
const EMPTY_CONNECTORS = [];
|
|
8
|
+
function useConnectors(parameters = {}) {
|
|
9
|
+
const config = require_hooks_useConfig.useConfig(parameters);
|
|
10
|
+
return (0, react.useSyncExternalStore)((onChange) => (0, _bigmi_client.watchConnectors)(config, { onChange }), () => (0, _bigmi_client.getConnectors)(config), () => EMPTY_CONNECTORS);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.useConnectors = useConnectors;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=useConnectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnectors.js","names":["useConfig"],"sources":["../../../src/hooks/useConnectors.ts"],"sourcesContent":["'use client'\n\nimport {\n type Config,\n type GetConnectorsReturnType,\n getConnectors,\n watchConnectors,\n} from '@bigmi/client'\nimport { useSyncExternalStore } from 'react'\nimport type { ResolvedRegister } from '../types.js'\nimport { type ConfigParameter, useConfig } from './useConfig.js'\n\nexport type UseConnectorsParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseConnectorsReturnType<config extends Config = Config> =\n GetConnectorsReturnType<config>\n\nconst EMPTY_CONNECTORS: readonly [] = []\n\nexport function useConnectors<\n config extends Config = ResolvedRegister['config'],\n>(\n parameters: UseConnectorsParameters<config> = {}\n): UseConnectorsReturnType<config> {\n const config = useConfig(parameters)\n\n return useSyncExternalStore(\n (onChange) => watchConnectors(config, { onChange }),\n () => getConnectors(config),\n () => EMPTY_CONNECTORS as UseConnectorsReturnType<config>\n )\n}\n"],"mappings":";;;;;;AAkBA,MAAM,mBAAgC,EAAE;AAExC,SAAgB,cAGd,aAA8C,EAAE,EACf;CACjC,MAAM,SAASA,wBAAAA,UAAU,WAAW;AAEpC,SAAA,GAAA,MAAA,uBACG,cAAA,GAAA,cAAA,iBAA6B,QAAQ,EAAE,UAAU,CAAC,SAAA,GAAA,cAAA,eAC/B,OAAO,QACrB,iBACP"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _bigmi_client = require("@bigmi/client");
|
|
5
|
+
//#region src/hooks/useReconnect.ts
|
|
6
|
+
const useReconnect = (config) => {
|
|
7
|
+
(0, react.useEffect)(() => {
|
|
8
|
+
(0, _bigmi_client.reconnect)(config);
|
|
9
|
+
}, [config]);
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.useReconnect = useReconnect;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useReconnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReconnect.js","names":[],"sources":["../../../src/hooks/useReconnect.ts"],"sourcesContent":["'use client'\n\nimport { type Config, reconnect } from '@bigmi/client'\n\nimport { useEffect } from 'react'\n\nexport const useReconnect = (config: Config): void => {\n useEffect(() => {\n reconnect(config)\n }, [config])\n}\n"],"mappings":";;;;;AAMA,MAAa,gBAAgB,WAAyB;AACpD,EAAA,GAAA,MAAA,iBAAgB;AACd,GAAA,GAAA,cAAA,WAAU,OAAO;IAChB,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/hooks/useSyncExternalStoreWithTracked.d.ts
|
|
2
|
+
declare function useSyncExternalStoreWithTracked<Snapshot extends Selection, Selection = Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: (() => Snapshot) | undefined, isEqual?: (a: Selection, b: Selection) => boolean): Selection;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { useSyncExternalStoreWithTracked };
|
|
5
|
+
//# sourceMappingURL=useSyncExternalStoreWithTracked.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _bigmi_core = require("@bigmi/core");
|
|
5
|
+
//#region src/hooks/useSyncExternalStoreWithTracked.ts
|
|
6
|
+
const isPlainObject = (obj) => typeof obj === "object" && !Array.isArray(obj);
|
|
7
|
+
function useSyncExternalStoreWithTracked(subscribe, getSnapshot, getServerSnapshot = getSnapshot, isEqual = _bigmi_core.deepEqual) {
|
|
8
|
+
const trackedKeys = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
9
|
+
const previousResult = (0, react.useRef)(void 0);
|
|
10
|
+
const snapshotCache = (0, react.useRef)(getSnapshot());
|
|
11
|
+
const snapshot = (0, react.useSyncExternalStore)((onChange) => subscribe(() => {
|
|
12
|
+
snapshotCache.current = getSnapshot();
|
|
13
|
+
onChange();
|
|
14
|
+
}), () => snapshotCache.current, getServerSnapshot);
|
|
15
|
+
const result = (0, react.useMemo)(() => {
|
|
16
|
+
if (!isPlainObject(snapshot)) return snapshot;
|
|
17
|
+
const trackedResult = { ...snapshot };
|
|
18
|
+
Object.defineProperties(trackedResult, Object.fromEntries(Object.entries(trackedResult).map(([key, value]) => [key, {
|
|
19
|
+
configurable: false,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: () => {
|
|
22
|
+
trackedKeys.current.add(key);
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
}])));
|
|
26
|
+
return trackedResult;
|
|
27
|
+
}, [snapshot]);
|
|
28
|
+
return (0, react.useMemo)(() => {
|
|
29
|
+
if (!trackedKeys.current.size || !previousResult.current) {
|
|
30
|
+
previousResult.current = result;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if (!Array.from(trackedKeys.current).some((key) => !isEqual(result[key], previousResult.current[key]))) return previousResult.current;
|
|
34
|
+
previousResult.current = result;
|
|
35
|
+
return result;
|
|
36
|
+
}, [result, isEqual]);
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.useSyncExternalStoreWithTracked = useSyncExternalStoreWithTracked;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=useSyncExternalStoreWithTracked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSyncExternalStoreWithTracked.js","names":["deepEqual"],"sources":["../../../src/hooks/useSyncExternalStoreWithTracked.ts"],"sourcesContent":["'use client'\nimport { deepEqual } from '@bigmi/core'\nimport { useMemo, useRef, useSyncExternalStore } from 'react'\n\nconst isPlainObject = (obj: unknown): obj is Record<string, any> =>\n typeof obj === 'object' && !Array.isArray(obj)\n\nexport function useSyncExternalStoreWithTracked<\n Snapshot extends Selection,\n Selection = Snapshot,\n>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot: (() => Snapshot) | undefined = getSnapshot,\n isEqual: (a: Selection, b: Selection) => boolean = deepEqual\n): Selection {\n const trackedKeys = useRef<Set<string>>(new Set())\n const previousResult = useRef<Selection | undefined>(undefined)\n const snapshotCache = useRef(getSnapshot())\n\n const snapshot = useSyncExternalStore(\n (onChange) =>\n subscribe(() => {\n snapshotCache.current = getSnapshot()\n onChange()\n }),\n () => snapshotCache.current!,\n getServerSnapshot\n )\n\n const result = useMemo(() => {\n if (!isPlainObject(snapshot)) {\n return snapshot\n }\n\n const trackedResult = { ...snapshot }\n Object.defineProperties(\n trackedResult,\n Object.fromEntries(\n Object.entries(trackedResult).map(([key, value]) => [\n key,\n {\n configurable: false,\n enumerable: true,\n get: () => {\n trackedKeys.current.add(key)\n return value\n },\n },\n ])\n )\n )\n return trackedResult\n }, [snapshot])\n\n return useMemo(() => {\n if (!trackedKeys.current.size || !previousResult.current) {\n previousResult.current = result\n return result\n }\n\n const hasChanged = Array.from(trackedKeys.current).some(\n (key) =>\n !isEqual(\n (result as Record<string, Selection>)[key],\n (previousResult.current as Record<string, Selection>)[key]\n )\n )\n\n if (!hasChanged) {\n return previousResult.current\n }\n previousResult.current = result\n return result\n }, [result, isEqual])\n}\n"],"mappings":";;;;;AAIA,MAAM,iBAAiB,QACrB,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI;AAEhD,SAAgB,gCAId,WACA,aACA,oBAAkD,aAClD,UAAmDA,YAAAA,WACxC;CACX,MAAM,eAAA,GAAA,MAAA,wBAAkC,IAAI,KAAK,CAAC;CAClD,MAAM,kBAAA,GAAA,MAAA,QAA+C,KAAA,EAAU;CAC/D,MAAM,iBAAA,GAAA,MAAA,QAAuB,aAAa,CAAC;CAE3C,MAAM,YAAA,GAAA,MAAA,uBACH,aACC,gBAAgB;AACd,gBAAc,UAAU,aAAa;AACrC,YAAU;GACV,QACE,cAAc,SACpB,kBACD;CAED,MAAM,UAAA,GAAA,MAAA,eAAuB;AAC3B,MAAI,CAAC,cAAc,SAAS,CAC1B,QAAO;EAGT,MAAM,gBAAgB,EAAE,GAAG,UAAU;AACrC,SAAO,iBACL,eACA,OAAO,YACL,OAAO,QAAQ,cAAc,CAAC,KAAK,CAAC,KAAK,WAAW,CAClD,KACA;GACE,cAAc;GACd,YAAY;GACZ,WAAW;AACT,gBAAY,QAAQ,IAAI,IAAI;AAC5B,WAAO;;GAEV,CACF,CAAC,CACH,CACF;AACD,SAAO;IACN,CAAC,SAAS,CAAC;AAEd,SAAA,GAAA,MAAA,eAAqB;AACnB,MAAI,CAAC,YAAY,QAAQ,QAAQ,CAAC,eAAe,SAAS;AACxD,kBAAe,UAAU;AACzB,UAAO;;AAWT,MAAI,CARe,MAAM,KAAK,YAAY,QAAQ,CAAC,MAChD,QACC,CAAC,QACE,OAAqC,MACrC,eAAe,QAAsC,KACvD,CACJ,CAGC,QAAO,eAAe;AAExB,iBAAe,UAAU;AACzB,SAAO;IACN,CAAC,QAAQ,QAAQ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ResolvedRegister } from "./types.js";
|
|
2
|
+
import { Config, State } from "@bigmi/client";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/hydrate.d.ts
|
|
6
|
+
type HydrateProps = {
|
|
7
|
+
config: ResolvedRegister["config"];
|
|
8
|
+
initialState?: State | undefined;
|
|
9
|
+
reconnectOnMount?: boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
type HydrateParameters = {
|
|
12
|
+
initialState?: State | undefined;
|
|
13
|
+
reconnectOnMount?: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
declare function hydrate(config: Config, parameters: HydrateParameters): {
|
|
16
|
+
onMount(): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
declare function Hydrate(parameters: React.PropsWithChildren<HydrateProps>): ReactElement;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Hydrate, HydrateProps, hydrate };
|
|
21
|
+
//# sourceMappingURL=hydrate.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _bigmi_client = require("@bigmi/client");
|
|
5
|
+
//#region src/hydrate.ts
|
|
6
|
+
function hydrate(config, parameters) {
|
|
7
|
+
const { initialState, reconnectOnMount } = parameters;
|
|
8
|
+
if (initialState && !config._internal.store.persist.hasHydrated()) config.setState({
|
|
9
|
+
...initialState,
|
|
10
|
+
chainId: config.chains.some((x) => x.id === initialState.chainId) ? initialState.chainId : config.chains[0].id,
|
|
11
|
+
connections: reconnectOnMount ? initialState.connections : /* @__PURE__ */ new Map(),
|
|
12
|
+
status: reconnectOnMount ? "reconnecting" : "disconnected"
|
|
13
|
+
});
|
|
14
|
+
return { async onMount() {
|
|
15
|
+
if (config._internal.ssr) await config._internal.store.persist.rehydrate();
|
|
16
|
+
if (reconnectOnMount) (0, _bigmi_client.reconnect)(config);
|
|
17
|
+
else if (config.storage) config.setState((x) => ({
|
|
18
|
+
...x,
|
|
19
|
+
connections: /* @__PURE__ */ new Map()
|
|
20
|
+
}));
|
|
21
|
+
} };
|
|
22
|
+
}
|
|
23
|
+
function Hydrate(parameters) {
|
|
24
|
+
const { children, config, initialState, reconnectOnMount = true } = parameters;
|
|
25
|
+
const { onMount } = hydrate(config, {
|
|
26
|
+
initialState,
|
|
27
|
+
reconnectOnMount
|
|
28
|
+
});
|
|
29
|
+
if (!config._internal.ssr) onMount();
|
|
30
|
+
const active = (0, react.useRef)(true);
|
|
31
|
+
(0, react.useEffect)(() => {
|
|
32
|
+
if (!active.current) return;
|
|
33
|
+
if (!config._internal.ssr) return;
|
|
34
|
+
onMount();
|
|
35
|
+
return () => {
|
|
36
|
+
active.current = false;
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
return children;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.Hydrate = Hydrate;
|
|
43
|
+
exports.hydrate = hydrate;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=hydrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.js","names":[],"sources":["../../src/hydrate.ts"],"sourcesContent":["'use client'\n\nimport { type Config, reconnect, type State } from '@bigmi/client'\n\nimport { type ReactElement, useEffect, useRef } from 'react'\n\nimport type { ResolvedRegister } from './types.js'\n\nexport type HydrateProps = {\n config: ResolvedRegister['config']\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\ntype HydrateParameters = {\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function hydrate(\n config: Config,\n parameters: HydrateParameters\n): { onMount(): Promise<void> } {\n const { initialState, reconnectOnMount } = parameters\n\n if (initialState && !config._internal.store.persist.hasHydrated()) {\n config.setState({\n ...initialState,\n chainId: config.chains.some((x) => x.id === initialState.chainId)\n ? initialState.chainId\n : config.chains[0].id,\n connections: reconnectOnMount ? initialState.connections : new Map(),\n status: reconnectOnMount ? 'reconnecting' : 'disconnected',\n })\n }\n\n return {\n async onMount(): Promise<void> {\n if (config._internal.ssr) {\n await config._internal.store.persist.rehydrate()\n }\n\n if (reconnectOnMount) {\n reconnect(config)\n } else if (config.storage) {\n // Reset connections that may have been hydrated from storage.\n config.setState((x) => ({\n ...x,\n connections: new Map(),\n }))\n }\n },\n }\n}\n\nexport function Hydrate(parameters: React.PropsWithChildren<HydrateProps>) {\n const { children, config, initialState, reconnectOnMount = true } = parameters\n\n const { onMount } = hydrate(config, {\n initialState,\n reconnectOnMount,\n })\n\n // Hydrate for non-SSR\n if (!config._internal.ssr) {\n onMount()\n }\n\n // Hydrate for SSR\n const active = useRef(true)\n // biome-ignore lint/correctness/useExhaustiveDependencies: `queryKey` not required\n useEffect(() => {\n if (!active.current) {\n return\n }\n if (!config._internal.ssr) {\n return\n }\n onMount()\n return () => {\n active.current = false\n }\n }, [])\n\n return children as ReactElement\n}\n"],"mappings":";;;;;AAmBA,SAAgB,QACd,QACA,YAC8B;CAC9B,MAAM,EAAE,cAAc,qBAAqB;AAE3C,KAAI,gBAAgB,CAAC,OAAO,UAAU,MAAM,QAAQ,aAAa,CAC/D,QAAO,SAAS;EACd,GAAG;EACH,SAAS,OAAO,OAAO,MAAM,MAAM,EAAE,OAAO,aAAa,QAAQ,GAC7D,aAAa,UACb,OAAO,OAAO,GAAG;EACrB,aAAa,mBAAmB,aAAa,8BAAc,IAAI,KAAK;EACpE,QAAQ,mBAAmB,iBAAiB;EAC7C,CAAC;AAGJ,QAAO,EACL,MAAM,UAAyB;AAC7B,MAAI,OAAO,UAAU,IACnB,OAAM,OAAO,UAAU,MAAM,QAAQ,WAAW;AAGlD,MAAI,iBACF,EAAA,GAAA,cAAA,WAAU,OAAO;WACR,OAAO,QAEhB,QAAO,UAAU,OAAO;GACtB,GAAG;GACH,6BAAa,IAAI,KAAK;GACvB,EAAE;IAGR;;AAGH,SAAgB,QAAQ,YAAmD;CACzE,MAAM,EAAE,UAAU,QAAQ,cAAc,mBAAmB,SAAS;CAEpE,MAAM,EAAE,YAAY,QAAQ,QAAQ;EAClC;EACA;EACD,CAAC;AAGF,KAAI,CAAC,OAAO,UAAU,IACpB,UAAS;CAIX,MAAM,UAAA,GAAA,MAAA,QAAgB,KAAK;AAE3B,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,CAAC,OAAO,QACV;AAEF,MAAI,CAAC,OAAO,UAAU,IACpB;AAEF,WAAS;AACT,eAAa;AACX,UAAO,UAAU;;IAElB,EAAE,CAAC;AAEN,QAAO"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BigmiContext, BigmiProvider, BigmiProviderProps } from "./context.js";
|
|
2
|
+
import { useConfig } from "./hooks/useConfig.js";
|
|
3
|
+
import { useAccount } from "./hooks/useAccount.js";
|
|
4
|
+
import { useConnect } from "./hooks/useConnect.js";
|
|
5
|
+
import { useReconnect } from "./hooks/useReconnect.js";
|
|
6
|
+
export { BigmiContext, BigmiProvider, type BigmiProviderProps, useAccount, useConfig, useConnect, useReconnect };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_context = require("./context.js");
|
|
3
|
+
const require_hooks_useConfig = require("./hooks/useConfig.js");
|
|
4
|
+
const require_hooks_useAccount = require("./hooks/useAccount.js");
|
|
5
|
+
const require_hooks_useConnect = require("./hooks/useConnect.js");
|
|
6
|
+
const require_hooks_useReconnect = require("./hooks/useReconnect.js");
|
|
7
|
+
exports.BigmiContext = require_context.BigmiContext;
|
|
8
|
+
exports.BigmiProvider = require_context.BigmiProvider;
|
|
9
|
+
exports.useAccount = require_hooks_useAccount.useAccount;
|
|
10
|
+
exports.useConfig = require_hooks_useConfig.useConfig;
|
|
11
|
+
exports.useConnect = require_hooks_useConnect.useConnect;
|
|
12
|
+
exports.useReconnect = require_hooks_useReconnect.useReconnect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config } from "@bigmi/client";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type Register = {};
|
|
5
|
+
type ResolvedRegister = {
|
|
6
|
+
config: Register extends {
|
|
7
|
+
config: infer config extends Config;
|
|
8
|
+
} ? config : Config;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Register, ResolvedRegister };
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Compute, UnionStrictOmit } from "@bigmi/core";
|
|
2
|
+
import { UseMutationOptions, UseMutationResult } from "@tanstack/react-query";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/query.d.ts
|
|
5
|
+
type UseMutationParameters<data = unknown, error = Error, variables = void, context = unknown> = Compute<Omit<UseMutationOptions<data, error, Compute<variables>, context>, "mutationFn" | "mutationKey" | "throwOnError">>;
|
|
6
|
+
type UseMutationReturnType<data = unknown, error = Error, variables = void, context = unknown> = Compute<UnionStrictOmit<UseMutationResult<data, error, variables, context>, "mutate" | "mutateAsync">>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { UseMutationParameters, UseMutationReturnType };
|
|
9
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/version.ts
|
|
3
|
+
const name = "@bigmi/react";
|
|
4
|
+
const version = "0.8.0-beta.0";
|
|
5
|
+
//#endregion
|
|
6
|
+
exports.name = name;
|
|
7
|
+
exports.version = version;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@bigmi/react'\nexport const version = '0.8.0-beta.0'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/dist/esm/context.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ResolvedRegister } from "./types.js";
|
|
2
|
+
import { Context, PropsWithChildren, ReactElement } from "react";
|
|
3
|
+
import { State } from "@bigmi/client";
|
|
4
|
+
|
|
5
|
+
//#region src/context.d.ts
|
|
6
|
+
declare const BigmiContext: Context<ResolvedRegister["config"] | undefined>;
|
|
7
|
+
type BigmiProviderProps = {
|
|
8
|
+
config: ResolvedRegister["config"];
|
|
9
|
+
initialState?: State | undefined;
|
|
10
|
+
reconnectOnMount?: boolean | undefined;
|
|
9
11
|
};
|
|
10
|
-
|
|
12
|
+
declare function BigmiProvider(parameters: PropsWithChildren<BigmiProviderProps>): ReactElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { BigmiContext, BigmiProvider, BigmiProviderProps };
|
|
15
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../src/context.ts"],"mappings":";;;;;cAYa,YAAA,EAAc,OAAA,CAAQ,gBAAA;AAAA,KAGvB,kBAAA;EACV,MAAA,EAAQ,gBAAA;EACR,YAAA,GAAe,KAAA;EACf,gBAAA;AAAA;AAAA,iBAGc,aAAA,CACd,UAAA,EAAY,iBAAA,CAAkB,kBAAA,IAC7B,YAAA"}
|
package/dist/esm/context.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Hydrate } from "./hydrate.js";
|
|
3
|
+
import { createContext, createElement } from "react";
|
|
4
|
+
//#region src/context.ts
|
|
5
|
+
const BigmiContext = createContext(void 0);
|
|
6
|
+
function BigmiProvider(parameters) {
|
|
7
|
+
const { children, config } = parameters;
|
|
8
|
+
const props = { value: config };
|
|
9
|
+
return createElement(Hydrate, parameters, createElement(BigmiContext.Provider, props, children));
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BigmiContext, BigmiProvider };
|
|
13
|
+
|
|
10
14
|
//# sourceMappingURL=context.js.map
|
package/dist/esm/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../src/context.ts"],"sourcesContent":["'use client'\nimport type { State } from '@bigmi/client'\nimport {\n type Context,\n createContext,\n createElement,\n type PropsWithChildren,\n type ReactElement,\n} from 'react'\nimport { Hydrate } from './hydrate.js'\nimport type { ResolvedRegister } from './types.js'\n\nexport const BigmiContext: Context<ResolvedRegister['config'] | undefined> =\n createContext<ResolvedRegister['config'] | undefined>(undefined)\n\nexport type BigmiProviderProps = {\n config: ResolvedRegister['config']\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function BigmiProvider(\n parameters: PropsWithChildren<BigmiProviderProps>\n): ReactElement {\n const { children, config } = parameters\n\n const props = { value: config }\n return createElement(\n Hydrate,\n parameters,\n createElement(BigmiContext.Provider, props, children)\n )\n}\n"],"mappings":";;;;AAYA,MAAa,eACX,cAAsD,KAAA,EAAU;AAQlE,SAAgB,cACd,YACc;CACd,MAAM,EAAE,UAAU,WAAW;CAE7B,MAAM,QAAQ,EAAE,OAAO,QAAQ;AAC/B,QAAO,cACL,SACA,YACA,cAAc,aAAa,UAAU,OAAO,SAAS,CACtD"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { BaseError } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BaseError } from "@bigmi/core";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/context.d.ts
|
|
4
|
+
type BigmiProviderNotFoundErrorType = BigmiProviderNotFoundError & {
|
|
5
|
+
name: "BigmiProviderNotFoundError";
|
|
4
6
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare class BigmiProviderNotFoundError extends BaseError {
|
|
8
|
+
override name: string;
|
|
9
|
+
constructor();
|
|
8
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BigmiProviderNotFoundError, BigmiProviderNotFoundErrorType };
|
|
13
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/errors/context.ts"],"mappings":";;;KAEY,8BAAA,GAAiC,0BAAA;EAC3C,IAAA;AAAA;AAAA,cAEW,0BAAA,SAAmC,SAAA;EAAA,SACrC,IAAA;EACT,WAAA,CAAA;AAAA"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { BaseError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { BaseError } from "@bigmi/core";
|
|
2
|
+
//#region src/errors/context.ts
|
|
3
|
+
var BigmiProviderNotFoundError = class extends BaseError {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("`useConfig` must be used within `BigmiProvider`.");
|
|
6
|
+
this.name = "BigmiProviderNotFoundError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { BigmiProviderNotFoundError };
|
|
11
|
+
|
|
8
12
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/errors/context.ts"],"sourcesContent":["import { BaseError } from '@bigmi/core'\n\nexport type BigmiProviderNotFoundErrorType = BigmiProviderNotFoundError & {\n name: 'BigmiProviderNotFoundError'\n}\nexport class BigmiProviderNotFoundError extends BaseError {\n override name = 'BigmiProviderNotFoundError'\n constructor() {\n super('`useConfig` must be used within `BigmiProvider`.')\n }\n}\n"],"mappings":";;AAKA,IAAa,6BAAb,cAAgD,UAAU;CAExD,cAAc;AACZ,QAAM,mDAAmD;cAF3C"}
|