@mysten/dapp-kit-react 1.0.2 → 2.0.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/index.d.mts CHANGED
@@ -1,36 +1,20 @@
1
- import * as _mysten_dapp_kit_core1 from "@mysten/dapp-kit-core";
1
+ import * as _mysten_dapp_kit_core5 from "@mysten/dapp-kit-core";
2
2
  import { DAppKit, DefaultExpectedDppKit, RegisteredDAppKit } from "@mysten/dapp-kit-core";
3
- import { ComponentProps, PropsWithChildren } from "react";
4
- import * as _lit_react0 from "@lit/react";
5
- import { DAppKitConnectButton, DAppKitConnectModal } from "@mysten/dapp-kit-core/web";
6
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as react0 from "react";
4
+ import { PropsWithChildren } from "react";
5
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
7
6
  import * as nanostores0 from "nanostores";
8
7
  export * from "@mysten/dapp-kit-core";
9
8
 
10
- //#region src/components/ConnectButton.d.ts
11
- type ConnectButtonProps = ComponentProps<typeof ConnectButtonComponent>;
12
- declare const ConnectButtonComponent: _lit_react0.ReactWebComponent<DAppKitConnectButton, {}>;
13
- declare function ConnectButton({
14
- instance,
15
- ...props
16
- }: ConnectButtonProps): react_jsx_runtime0.JSX.Element;
17
- //#endregion
18
- //#region src/components/ConnectModal.d.ts
19
- type ConnectModalProps = ComponentProps<typeof ConnectModalComponent>;
20
- declare const ConnectModalComponent: _lit_react0.ReactWebComponent<DAppKitConnectModal, {}>;
21
- declare function ConnectModal({
22
- instance,
23
- ...props
24
- }: ConnectModalProps): react_jsx_runtime0.JSX.Element;
25
- //#endregion
26
9
  //#region src/components/DAppKitProvider.d.ts
10
+ declare const DAppKitContext: react0.Context<_mysten_dapp_kit_core5.DAppKit<any, _mysten_dapp_kit_core5.ClientWithCoreApi> | null>;
27
11
  type DAppKitProviderProps = PropsWithChildren<{
28
12
  dAppKit: DefaultExpectedDppKit;
29
13
  }>;
30
14
  declare function DAppKitProvider({
31
15
  dAppKit,
32
16
  children
33
- }: DAppKitProviderProps): react_jsx_runtime0.JSX.Element;
17
+ }: DAppKitProviderProps): react_jsx_runtime1.JSX.Element;
34
18
  //#endregion
35
19
  //#region src/hooks/useDAppKit.d.ts
36
20
  declare function useDAppKit<TDAppKit extends DAppKit<any> = RegisteredDAppKit>(dAppKit?: TDAppKit): TDAppKit;
@@ -41,7 +25,7 @@ type UseWalletsOptions<TDAppKit extends DAppKit> = {
41
25
  };
42
26
  declare function useWallets<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
43
27
  dAppKit
44
- }?: UseWalletsOptions<TDAppKit>): _mysten_dapp_kit_core1.UiWallet[];
28
+ }?: UseWalletsOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWallet[];
45
29
  //#endregion
46
30
  //#region src/hooks/useWalletConnection.d.ts
47
31
  type UseWalletConnectionOptions<TDAppKit extends DAppKit<any>> = {
@@ -50,8 +34,17 @@ type UseWalletConnectionOptions<TDAppKit extends DAppKit<any>> = {
50
34
  declare function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKit>({
51
35
  dAppKit
52
36
  }?: UseWalletConnectionOptions<TDAppKit>): {
53
- readonly wallet: _mysten_dapp_kit_core1.UiWallet;
54
- readonly account: _mysten_dapp_kit_core1.UiWalletAccount;
37
+ readonly wallet: null;
38
+ readonly account: null;
39
+ readonly status: "disconnected";
40
+ readonly supportedIntents: readonly [];
41
+ readonly isConnected: false;
42
+ readonly isConnecting: false;
43
+ readonly isReconnecting: false;
44
+ readonly isDisconnected: true;
45
+ } | {
46
+ readonly wallet: _mysten_dapp_kit_core5.UiWallet;
47
+ readonly account: _mysten_dapp_kit_core5.UiWalletAccount;
55
48
  readonly status: "connected";
56
49
  readonly supportedIntents: string[];
57
50
  readonly isConnected: true;
@@ -68,23 +61,14 @@ declare function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKi
68
61
  readonly isReconnecting: false;
69
62
  readonly isDisconnected: false;
70
63
  } | {
71
- readonly wallet: _mysten_dapp_kit_core1.UiWallet;
72
- readonly account: _mysten_dapp_kit_core1.UiWalletAccount;
64
+ readonly wallet: _mysten_dapp_kit_core5.UiWallet;
65
+ readonly account: _mysten_dapp_kit_core5.UiWalletAccount;
73
66
  readonly status: "reconnecting";
74
67
  readonly supportedIntents: string[];
75
68
  readonly isConnected: false;
76
69
  readonly isConnecting: false;
77
70
  readonly isReconnecting: true;
78
71
  readonly isDisconnected: false;
79
- } | {
80
- readonly wallet: null;
81
- readonly account: null;
82
- readonly status: "disconnected";
83
- readonly supportedIntents: readonly [];
84
- readonly isConnected: false;
85
- readonly isConnecting: false;
86
- readonly isReconnecting: false;
87
- readonly isDisconnected: true;
88
72
  };
89
73
  //#endregion
90
74
  //#region src/hooks/useCurrentAccount.d.ts
@@ -93,7 +77,7 @@ type UseCurrentAccountOptions<TDAppKit extends DAppKit> = {
93
77
  };
94
78
  declare function useCurrentAccount<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
95
79
  dAppKit
96
- }?: UseCurrentAccountOptions<TDAppKit>): _mysten_dapp_kit_core1.UiWalletAccount | null;
80
+ }?: UseCurrentAccountOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWalletAccount | null;
97
81
  //#endregion
98
82
  //#region src/hooks/useCurrentWallet.d.ts
99
83
  type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {
@@ -101,7 +85,7 @@ type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {
101
85
  };
102
86
  declare function useCurrentWallet<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({
103
87
  dAppKit
104
- }?: UseCurrentWalletOptions<TDAppKit>): _mysten_dapp_kit_core1.UiWallet | null;
88
+ }?: UseCurrentWalletOptions<TDAppKit>): _mysten_dapp_kit_core5.UiWallet | null;
105
89
  //#endregion
106
90
  //#region src/hooks/useCurrentClient.d.ts
107
91
  type UseCurrentClientOptions<TDAppKit extends DAppKit<any>> = {
@@ -119,5 +103,5 @@ declare function useCurrentNetwork<TDAppKit extends DAppKit<any> = RegisteredDAp
119
103
  dAppKit
120
104
  }?: UseCurrentNetworkOptions<TDAppKit>): nanostores0.StoreValue<TDAppKit["stores"]["$currentNetwork"]>;
121
105
  //#endregion
122
- export { ConnectButton, type ConnectButtonProps, ConnectModal, type ConnectModalProps, DAppKitProvider, type DAppKitProviderProps, useCurrentAccount, useCurrentClient, useCurrentNetwork, useCurrentWallet, useDAppKit, useWalletConnection, useWallets };
106
+ export { DAppKitContext, DAppKitProvider, type DAppKitProviderProps, useCurrentAccount, useCurrentClient, useCurrentNetwork, useCurrentWallet, useDAppKit, useWalletConnection, useWallets };
123
107
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/components/ConnectButton.tsx","../src/components/ConnectModal.tsx","../src/components/DAppKitProvider.tsx","../src/hooks/useDAppKit.ts","../src/hooks/useWallets.ts","../src/hooks/useWalletConnection.ts","../src/hooks/useCurrentAccount.ts","../src/hooks/useCurrentWallet.ts","../src/hooks/useCurrentClient.ts","../src/hooks/useCurrentNetwork.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;KASY,kBAAA,GAAqB,sBAAsB;cAEjD,wBAAsB,WAAA,CAAA,kBAAA;iBAMZ,aAAA;;;GAAsC,qBAAkB,kBAAA,CAAA,GAAA,CAAA;;;KCR5D,iBAAA,GAAoB,sBAAsB;cAEhD,uBAAqB,WAAA,CAAA,kBAAA;iBAMX,YAAA;;;GAAqC,oBAAiB,kBAAA,CAAA,GAAA,CAAA;;;KCR1D,oBAAA,GAAuB;WACzB;;iBAGM,eAAA;;;GAAuC,uBAAoB,kBAAA,CAAA,GAAA,CAAA;;;iBCN3D,4BAA4B,eAAe,6BAA6B,WAAQ;;;KCApF,mCAAmC;YACpC;;iBAGK,4BAA4B,eAAe;;IAExD,kBAAkB,YAAD,sBAAA,CAAe,QAAA;;;KCNvB,4CAA4C;YAC7C;;iBAGK,qCAAqC,UAAU;;IAE5D,2BAA2B;mBAAD,sBAAA,CAAA;;;;;;ELJjB,SAAA,cAAkB,EAAA,KAAA;EAExB,SAAA,cAAA,EAIJ,KAAA;AAEF,CAAA,GAAgB;EAAgB,SAAA,MAAA,EAAA,IAAA;EAAsB,SAAA,OAAA,EAAA,IAAA;EAAkB,SAAA,MAAA,EAAA,YAAA;EAAA,SAAA,gBAAA,EAAA,SAAA,EAAA;;;;ECR5D,SAAA,cAAiB,EAAA,KAAA;AAAgD,CAAA,GAEvE;EAMU,SAAA,MAAY,iCAAA;EAAG,SAAA,OAAA,wCAAA;EAAsB,SAAA,MAAA,EAAA,cAAA;EAAiB,SAAA,gBAAA,EAAA,MAAA,EAAA;EAAA,SAAA,WAAA,EAAA,KAAA;;;;ACRtE,CAAA,GAAY;EAII,SAAA,MAAA,EAAA,IAAe;EAAG,SAAA,OAAA,EAAA,IAAA;EAAS,SAAA,MAAA,EAAA,cAAA;EAAY,SAAA,gBAAA,EAAA,SAAA,EAAA;EAAoB,SAAA,WAAA,EAAA,KAAA;EAAA,SAAA,YAAA,EAAA,KAAA;;;;;;KIP/D,0CAA0C;YAC3C;;iBAGK,mCAAmC,eAAe;;IAE/D,yBAAyB,YAAD,sBAAA,CAAe,eAAA;;;KCN9B,yCAAyC;YAC1C;;iBAGK,kCAAkC,eAAe;;IAE9D,wBAAwB,YAAD,sBAAA,CAAe,QAAA;;;KCL7B,yCAAyC;YAC1C;;iBAGK,kCAAkC,eAAe;;IAE9D,wBAAwB,YAEyB,WAAW;;;KCRnD,0CAA0C;YAC3C;;iBAGK,mCAAmC,eAAe;;IAE/D,yBAAyB,YAAc,WAAA,CAAA,WAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/components/DAppKitProvider.tsx","../src/hooks/useDAppKit.ts","../src/hooks/useWallets.ts","../src/hooks/useWalletConnection.ts","../src/hooks/useCurrentAccount.ts","../src/hooks/useCurrentWallet.ts","../src/hooks/useCurrentClient.ts","../src/hooks/useCurrentNet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Ae,eAAA;;;KCN9B,yCAAyC;YAC1C;;iBAGK,kCAAkC,eAAe;;IAE9D,wBAAwB,YAAD,sBAAA,CAAe,QAAA;;;KCL7B,yCAAyC;YAC1C;;iBAGK,kCAAkC,eAAe;;IAE9D,wBAAwB,YAEyB,WAAW;;;KCRnD,0CAA0C;YAC3C;;iBAGK,mCAAmC,eAAe;;IAE/D,yBAAyB,YAAc,WAAA,CAAA,WAAA"}
package/dist/index.mjs CHANGED
@@ -1,61 +1,8 @@
1
- import * as React from "react";
2
- import { createContext, useContext } from "react";
3
- import { createComponent } from "@lit/react";
4
- import { DAppKitConnectButton, DAppKitConnectModal } from "@mysten/dapp-kit-core/web";
5
- import { jsx } from "react/jsx-runtime";
1
+ import { n as DAppKitContext, r as DAppKitProvider, t as useDAppKit } from "./useDAppKit-LUp-KcgG.mjs";
6
2
  import { useStore } from "@nanostores/react";
7
3
 
8
4
  export * from "@mysten/dapp-kit-core"
9
5
 
10
- //#region src/components/DAppKitProvider.tsx
11
- const DAppKitContext = createContext(null);
12
- function DAppKitProvider({ dAppKit, children }) {
13
- return /* @__PURE__ */ jsx(DAppKitContext.Provider, {
14
- value: dAppKit,
15
- children
16
- });
17
- }
18
-
19
- //#endregion
20
- //#region src/hooks/useDAppKit.ts
21
- function useDAppKit(dAppKit) {
22
- const contextValue = useContext(DAppKitContext);
23
- if (dAppKit) return dAppKit;
24
- if (!contextValue) throw new Error("Could not find DAppKitContext. Ensure that you have set up the `DAppKitProvider` component.");
25
- return contextValue;
26
- }
27
-
28
- //#endregion
29
- //#region src/components/ConnectButton.tsx
30
- const ConnectButtonComponent = createComponent({
31
- react: React,
32
- tagName: "mysten-dapp-kit-connect-button",
33
- elementClass: DAppKitConnectButton
34
- });
35
- function ConnectButton({ instance, ...props }) {
36
- const dAppKit = useDAppKit(instance);
37
- return /* @__PURE__ */ jsx(ConnectButtonComponent, {
38
- ...props,
39
- instance: dAppKit
40
- });
41
- }
42
-
43
- //#endregion
44
- //#region src/components/ConnectModal.tsx
45
- const ConnectModalComponent = createComponent({
46
- react: React,
47
- tagName: "mysten-dapp-kit-connect-modal",
48
- elementClass: DAppKitConnectModal
49
- });
50
- function ConnectModal({ instance, ...props }) {
51
- const dAppKit = useDAppKit(instance);
52
- return /* @__PURE__ */ jsx(ConnectModalComponent, {
53
- ...props,
54
- instance: dAppKit
55
- });
56
- }
57
-
58
- //#endregion
59
6
  //#region src/hooks/useWallets.ts
60
7
  function useWallets({ dAppKit } = {}) {
61
8
  return useStore(useDAppKit(dAppKit).stores.$wallets);
@@ -92,5 +39,5 @@ function useCurrentNetwork({ dAppKit } = {}) {
92
39
  }
93
40
 
94
41
  //#endregion
95
- export { ConnectButton, ConnectModal, DAppKitProvider, useCurrentAccount, useCurrentClient, useCurrentNetwork, useCurrentWallet, useDAppKit, useWalletConnection, useWallets };
42
+ export { DAppKitContext, DAppKitProvider, useCurrentAccount, useCurrentClient, useCurrentNetwork, useCurrentWallet, useDAppKit, useWalletConnection, useWallets };
96
43
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["ConnectButtonElement","ConnectModalElement"],"sources":["../src/components/DAppKitProvider.tsx","../src/hooks/useDAppKit.ts","../src/components/ConnectButton.tsx","../src/components/ConnectModal.tsx","../src/hooks/useWallets.ts","../src/hooks/useWalletConnection.ts","../src/hooks/useCurrentAccount.ts","../src/hooks/useCurrentWallet.ts","../src/hooks/useCurrentClient.ts","../src/hooks/useCurrentNetwork.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DefaultExpectedDppKit } from '@mysten/dapp-kit-core';\nimport { createContext } from 'react';\nimport type { PropsWithChildren } from 'react';\n\nexport const DAppKitContext = createContext<DefaultExpectedDppKit | null>(null);\n\nexport type DAppKitProviderProps = PropsWithChildren<{\n\tdAppKit: DefaultExpectedDppKit;\n}>;\n\nexport function DAppKitProvider({ dAppKit, children }: DAppKitProviderProps) {\n\treturn <DAppKitContext.Provider value={dAppKit}>{children}</DAppKitContext.Provider>;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { DAppKitContext } from '../components/DAppKitProvider.js';\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\n\nexport function useDAppKit<TDAppKit extends DAppKit<any> = RegisteredDAppKit>(dAppKit?: TDAppKit) {\n\tconst contextValue = useContext(DAppKitContext);\n\n\tif (dAppKit) {\n\t\treturn dAppKit;\n\t}\n\n\tif (!contextValue) {\n\t\tthrow new Error(\n\t\t\t'Could not find DAppKitContext. Ensure that you have set up the `DAppKitProvider` component.',\n\t\t);\n\t}\n\n\treturn contextValue as TDAppKit;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport { DAppKitConnectButton as ConnectButtonElement } from '@mysten/dapp-kit-core/web';\nimport { useDAppKit } from '../hooks/useDAppKit.js';\nimport type { ComponentProps } from 'react';\n\nexport type ConnectButtonProps = ComponentProps<typeof ConnectButtonComponent>;\n\nconst ConnectButtonComponent = createComponent({\n\treact: React,\n\ttagName: 'mysten-dapp-kit-connect-button',\n\telementClass: ConnectButtonElement,\n});\n\nexport function ConnectButton({ instance, ...props }: ConnectButtonProps) {\n\tconst dAppKit = useDAppKit(instance);\n\treturn <ConnectButtonComponent {...props} instance={dAppKit} />;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport { DAppKitConnectModal as ConnectModalElement } from '@mysten/dapp-kit-core/web';\nimport { useDAppKit } from '../hooks/useDAppKit.js';\nimport type { ComponentProps } from 'react';\n\nexport type ConnectModalProps = ComponentProps<typeof ConnectModalComponent>;\n\nconst ConnectModalComponent = createComponent({\n\treact: React,\n\ttagName: 'mysten-dapp-kit-connect-modal',\n\telementClass: ConnectModalElement,\n});\n\nexport function ConnectModal({ instance, ...props }: ConnectModalProps) {\n\tconst dAppKit = useDAppKit(instance);\n\treturn <ConnectModalComponent {...props} instance={dAppKit} />;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseWalletsOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useWallets<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseWalletsOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$wallets);\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseWalletConnectionOptions<TDAppKit extends DAppKit<any>> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKit>({\n\tdAppKit,\n}: UseWalletConnectionOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$connection);\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useWalletConnection } from './useWalletConnection.js';\n\nexport type UseCurrentAccountOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentAccount<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentAccountOptions<TDAppKit> = {}) {\n\tconst connection = useWalletConnection({ dAppKit });\n\treturn connection.account;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useWalletConnection } from './useWalletConnection.js';\n\nexport type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentWallet<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentWalletOptions<TDAppKit> = {}) {\n\tconst connection = useWalletConnection({ dAppKit });\n\treturn connection.wallet;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseCurrentClientOptions<TDAppKit extends DAppKit<any>> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentClient<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentClientOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$currentClient) as ReturnType<TDAppKit['getClient']>;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useDAppKit } from './useDAppKit.js';\nimport { useStore } from '@nanostores/react';\n\nexport type UseCurrentNetworkOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentNetwork<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentNetworkOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore<TDAppKit['stores']['$currentNetwork']>(instance.stores.$currentNetwork);\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,iBAAiB,cAA4C,KAAK;AAM/E,SA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AO,gBAAgB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/hooks/useWallets.ts","../src/hooks/useWalletConnection.ts","../src/hooks/useCurrentAccount.ts","../src/hooks/useCurrentWallet.ts","../src/hooks/useCurrentClient.ts","../src/hooks/useCurrentNetwork.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseWalletsOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useWallets<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseWalletsOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$wallets);\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseWalletConnectionOptions<TDAppKit extends DAppKit<any>> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useWalletConnection<TDAppKit extends DAppKit = RegisteredDAppKit>({\n\tdAppKit,\n}: UseWalletConnectionOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$connection);\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useWalletConnection } from './useWalletConnection.js';\n\nexport type UseCurrentAccountOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentAccount<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentAccountOptions<TDAppKit> = {}) {\n\tconst connection = useWalletConnection({ dAppKit });\n\treturn connection.account;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useWalletConnection } from './useWalletConnection.js';\n\nexport type UseCurrentWalletOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentWallet<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentWalletOptions<TDAppKit> = {}) {\n\tconst connection = useWalletConnection({ dAppKit });\n\treturn connection.wallet;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useStore } from '@nanostores/react';\nimport { useDAppKit } from './useDAppKit.js';\n\nexport type UseCurrentClientOptions<TDAppKit extends DAppKit<any>> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentClient<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentClientOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore(instance.stores.$currentClient) as ReturnType<TDAppKit['getClient']>;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\nimport { useDAppKit } from './useDAppKit.js';\nimport { useStore } from '@nanostores/react';\n\nexport type UseCurrentNetworkOptions<TDAppKit extends DAppKit> = {\n\tdAppKit?: TDAppKit;\n};\n\nexport function useCurrentNetwork<TDAppKit extends DAppKit<any> = RegisteredDAppKit>({\n\tdAppKit,\n}: UseCurrentNetworkOptions<TDAppKit> = {}) {\n\tconst instance = useDAppKit(dAppKit);\n\treturn useStore<TDAppKit['stores']['$currentNetwork']>(instance.stores.$currentNetwork);\n}\n"],"mappings":";;;;;;AAWA,SAAgB,WAA8D,EAC7E,YACgC,EAAE,EAAE;AAEpC,QAAO,SADU,WAAW,QAAQ,CACX,OAAO,SAAS;;;;;ACJ1C,SAAgB,oBAAkE,EACjF,YACyC,EAAE,EAAE;AAE7C,QAAO,SADU,WAAW,QAAQ,CACX,OAAO,YAAY;;;;;ACL7C,SAAgB,kBAAqE,EACpF,YACuC,EAAE,EAAE;AAE3C,QADmB,oBAAoB,EAAE,SAAS,CAAC,CACjC;;;;;ACJnB,SAAgB,iBAAoE,EACnF,YACsC,EAAE,EAAE;AAE1C,QADmB,oBAAoB,EAAE,SAAS,CAAC,CACjC;;;;;ACHnB,SAAgB,iBAAoE,EACnF,YACsC,EAAE,EAAE;AAE1C,QAAO,SADU,WAAW,QAAQ,CACX,OAAO,eAAe;;;;;ACJhD,SAAgB,kBAAqE,EACpF,YACuC,EAAE,EAAE;AAE3C,QAAO,SADU,WAAW,QAAQ,CAC4B,OAAO,gBAAgB"}
package/dist/ui.d.mts ADDED
@@ -0,0 +1,23 @@
1
+ import { ComponentProps } from "react";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _lit_react0 from "@lit/react";
4
+ import { DAppKitConnectButton, DAppKitConnectModal } from "@mysten/dapp-kit-core/web";
5
+
6
+ //#region src/components/ConnectButton.d.ts
7
+ type ConnectButtonProps = ComponentProps<typeof ConnectButtonComponent>;
8
+ declare const ConnectButtonComponent: _lit_react0.ReactWebComponent<DAppKitConnectButton, {}>;
9
+ declare function ConnectButton({
10
+ instance,
11
+ ...props
12
+ }: ConnectButtonProps): react_jsx_runtime0.JSX.Element;
13
+ //#endregion
14
+ //#region src/components/ConnectModal.d.ts
15
+ type ConnectModalProps = ComponentProps<typeof ConnectModalComponent>;
16
+ declare const ConnectModalComponent: _lit_react0.ReactWebComponent<DAppKitConnectModal, {}>;
17
+ declare function ConnectModal({
18
+ instance,
19
+ ...props
20
+ }: ConnectModalProps): react_jsx_runtime0.JSX.Element;
21
+ //#endregion
22
+ export { ConnectButton, type ConnectButtonProps, ConnectModal, type ConnectModalProps };
23
+ //# sourceMappingURL=ui.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.mts","names":[],"sources":["../src/components/ConnectButton.tsx","../src/components/ConnectModal.tsx"],"sourcesContent":[],"mappings":";;;;;;KASY,kBAAA,GAAqB,sBAAsB;cAEjD,wBAAsB,WAAA,CAAA,kBAAA;iBAMZ,aAAA;;;GAAsC,qBAAkB,kBAAA,CAAA,GAAA,CAAA;;;KCR5D,iBAAA,GAAoB,sBAAsB;cAEhD,uBAAqB,WAAA,CAAA,kBAAA;iBAMX,YAAA;;;GAAqC,oBAAiB,kBAAA,CAAA,GAAA,CAAA"}
package/dist/ui.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import { t as useDAppKit } from "./useDAppKit-LUp-KcgG.mjs";
2
+ import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createComponent } from "@lit/react";
5
+ import { DAppKitConnectButton, DAppKitConnectModal } from "@mysten/dapp-kit-core/web";
6
+
7
+ //#region src/components/ConnectButton.tsx
8
+ const ConnectButtonComponent = createComponent({
9
+ react: React,
10
+ tagName: "mysten-dapp-kit-connect-button",
11
+ elementClass: DAppKitConnectButton
12
+ });
13
+ function ConnectButton({ instance, ...props }) {
14
+ const dAppKit = useDAppKit(instance);
15
+ return /* @__PURE__ */ jsx(ConnectButtonComponent, {
16
+ ...props,
17
+ instance: dAppKit
18
+ });
19
+ }
20
+
21
+ //#endregion
22
+ //#region src/components/ConnectModal.tsx
23
+ const ConnectModalComponent = createComponent({
24
+ react: React,
25
+ tagName: "mysten-dapp-kit-connect-modal",
26
+ elementClass: DAppKitConnectModal
27
+ });
28
+ function ConnectModal({ instance, ...props }) {
29
+ const dAppKit = useDAppKit(instance);
30
+ return /* @__PURE__ */ jsx(ConnectModalComponent, {
31
+ ...props,
32
+ instance: dAppKit
33
+ });
34
+ }
35
+
36
+ //#endregion
37
+ export { ConnectButton, ConnectModal };
38
+ //# sourceMappingURL=ui.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.mjs","names":["ConnectButtonElement","ConnectModalElement"],"sources":["../src/components/ConnectButton.tsx","../src/components/ConnectModal.tsx"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport { DAppKitConnectButton as ConnectButtonElement } from '@mysten/dapp-kit-core/web';\nimport { useDAppKit } from '../hooks/useDAppKit.js';\nimport type { ComponentProps } from 'react';\n\nexport type ConnectButtonProps = ComponentProps<typeof ConnectButtonComponent>;\n\nconst ConnectButtonComponent = createComponent({\n\treact: React,\n\ttagName: 'mysten-dapp-kit-connect-button',\n\telementClass: ConnectButtonElement,\n});\n\nexport function ConnectButton({ instance, ...props }: ConnectButtonProps) {\n\tconst dAppKit = useDAppKit(instance);\n\treturn <ConnectButtonComponent {...props} instance={dAppKit} />;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as React from 'react';\nimport { createComponent } from '@lit/react';\nimport { DAppKitConnectModal as ConnectModalElement } from '@mysten/dapp-kit-core/web';\nimport { useDAppKit } from '../hooks/useDAppKit.js';\nimport type { ComponentProps } from 'react';\n\nexport type ConnectModalProps = ComponentProps<typeof ConnectModalComponent>;\n\nconst ConnectModalComponent = createComponent({\n\treact: React,\n\ttagName: 'mysten-dapp-kit-connect-modal',\n\telementClass: ConnectModalElement,\n});\n\nexport function ConnectModal({ instance, ...props }: ConnectModalProps) {\n\tconst dAppKit = useDAppKit(instance);\n\treturn <ConnectModalComponent {...props} instance={dAppKit} />;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,yBAAyB,gBAAgB;CAC9C,OAAO;CACP,SAAS;CACT,cAAcA;CACd,CAAC;AAEF,SAAgB,cAAc,EAAE,UAAU,GAAG,SAA6B;CACzE,MAAM,UAAU,WAAW,SAAS;AACpC,QAAO,oBAAC;EAAuB,GAAI;EAAO,UAAU;GAAW;;;;;ACRhE,MAAM,wBAAwB,gBAAgB;CAC7C,OAAO;CACP,SAAS;CACT,cAAcC;CACd,CAAC;AAEF,SAAgB,aAAa,EAAE,UAAU,GAAG,SAA4B;CACvE,MAAM,UAAU,WAAW,SAAS;AACpC,QAAO,oBAAC;EAAsB,GAAI;EAAO,UAAU;GAAW"}
@@ -0,0 +1,24 @@
1
+ import { createContext, useContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/components/DAppKitProvider.tsx
5
+ const DAppKitContext = createContext(null);
6
+ function DAppKitProvider({ dAppKit, children }) {
7
+ return /* @__PURE__ */ jsx(DAppKitContext.Provider, {
8
+ value: dAppKit,
9
+ children
10
+ });
11
+ }
12
+
13
+ //#endregion
14
+ //#region src/hooks/useDAppKit.ts
15
+ function useDAppKit(dAppKit) {
16
+ const contextValue = useContext(DAppKitContext);
17
+ if (dAppKit) return dAppKit;
18
+ if (!contextValue) throw new Error("Could not find DAppKitContext. Ensure that you have set up the `DAppKitProvider` component.");
19
+ return contextValue;
20
+ }
21
+
22
+ //#endregion
23
+ export { DAppKitContext as n, DAppKitProvider as r, useDAppKit as t };
24
+ //# sourceMappingURL=useDAppKit-LUp-KcgG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDAppKit-LUp-KcgG.mjs","names":[],"sources":["../src/components/DAppKitProvider.tsx","../src/hooks/useDAppKit.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { DefaultExpectedDppKit } from '@mysten/dapp-kit-core';\nimport { createContext } from 'react';\nimport type { PropsWithChildren } from 'react';\n\nexport const DAppKitContext = createContext<DefaultExpectedDppKit | null>(null);\n\nexport type DAppKitProviderProps = PropsWithChildren<{\n\tdAppKit: DefaultExpectedDppKit;\n}>;\n\nexport function DAppKitProvider({ dAppKit, children }: DAppKitProviderProps) {\n\treturn <DAppKitContext.Provider value={dAppKit}>{children}</DAppKitContext.Provider>;\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { DAppKitContext } from '../components/DAppKitProvider.js';\nimport type { DAppKit, RegisteredDAppKit } from '@mysten/dapp-kit-core';\n\nexport function useDAppKit<TDAppKit extends DAppKit<any> = RegisteredDAppKit>(dAppKit?: TDAppKit) {\n\tconst contextValue = useContext(DAppKitContext);\n\n\tif (dAppKit) {\n\t\treturn dAppKit;\n\t}\n\n\tif (!contextValue) {\n\t\tthrow new Error(\n\t\t\t'Could not find DAppKitContext. Ensure that you have set up the `DAppKitProvider` component.',\n\t\t);\n\t}\n\n\treturn contextValue as TDAppKit;\n}\n"],"mappings":";;;;AAOA,MAAa,iBAAiB,cAA4C,KAAK;AAM/E,SAAgB,gBAAgB,EAAE,SAAS,YAAkC;AAC5E,QAAO,oBAAC,eAAe;EAAS,OAAO;EAAU;GAAmC;;;;;ACPrF,SAAgB,WAA8D,SAAoB;CACjG,MAAM,eAAe,WAAW,eAAe;AAE/C,KAAI,QACH,QAAO;AAGR,KAAI,CAAC,aACJ,OAAM,IAAI,MACT,8FACA;AAGF,QAAO"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@mysten/dapp-kit-react",
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "React bindings for @mysten/dapp-kit-core",
5
- "version": "1.0.2",
5
+ "version": "2.0.0",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "LICENSE",
@@ -18,6 +18,11 @@
18
18
  "types": "./dist/index.d.mts",
19
19
  "import": "./dist/index.mjs",
20
20
  "default": "./dist/index.mjs"
21
+ },
22
+ "./ui": {
23
+ "types": "./dist/ui.d.mts",
24
+ "import": "./dist/ui.mjs",
25
+ "default": "./dist/ui.mjs"
21
26
  }
22
27
  },
23
28
  "repository": {
@@ -40,7 +45,7 @@
40
45
  "@lit/react": "^1.0.8",
41
46
  "@nanostores/react": "^1.0.0",
42
47
  "nanostores": "^1.1.0",
43
- "@mysten/dapp-kit-core": "^1.0.4"
48
+ "@mysten/dapp-kit-core": "^1.1.1"
44
49
  },
45
50
  "peerDependencies": {
46
51
  "@types/react": ">=17.0.0",
package/src/index.ts CHANGED
@@ -3,13 +3,7 @@
3
3
 
4
4
  export * from '@mysten/dapp-kit-core';
5
5
 
6
- export { ConnectButton } from './components/ConnectButton.js';
7
- export type { ConnectButtonProps } from './components/ConnectButton.js';
8
-
9
- export { ConnectModal } from './components/ConnectModal.js';
10
- export type { ConnectModalProps } from './components/ConnectModal.js';
11
-
12
- export { DAppKitProvider } from './components/DAppKitProvider.js';
6
+ export { DAppKitProvider, DAppKitContext } from './components/DAppKitProvider.js';
13
7
  export type { DAppKitProviderProps } from './components/DAppKitProvider.js';
14
8
 
15
9
  export { useDAppKit } from './hooks/useDAppKit.js';
package/src/ui.ts ADDED
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { ConnectButton } from './components/ConnectButton.js';
5
+ export type { ConnectButtonProps } from './components/ConnectButton.js';
6
+
7
+ export { ConnectModal } from './components/ConnectModal.js';
8
+ export type { ConnectModalProps } from './components/ConnectModal.js';