-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(account-kit): separate bundled export for non-react environments (…
- Loading branch information
Showing
12 changed files
with
118 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useAccountModal } from "../useAccountModal"; | ||
import { useAppAccountClient } from "../useAppAccountClient"; | ||
import { useEffect } from "react"; | ||
import { Store } from "./store"; | ||
|
||
export type Props = { | ||
store: Store; | ||
}; | ||
|
||
export function SyncStore({ store }: Props) { | ||
const { accountModalOpen, openAccountModal, closeAccountModal, toggleAccountModal } = useAccountModal(); | ||
const appAccountClient = useAppAccountClient(); | ||
|
||
useEffect(() => { | ||
store.setState({ | ||
accountModalOpen, | ||
openAccountModal, | ||
closeAccountModal, | ||
toggleAccountModal, | ||
appAccountClient, | ||
}); | ||
}, [store, accountModalOpen, appAccountClient, closeAccountModal, openAccountModal, toggleAccountModal]); | ||
|
||
return <></>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { StoreApi, createStore } from "zustand/vanilla"; | ||
import { AppAccountClient } from "../common"; | ||
|
||
export type State = { | ||
accountModalOpen: undefined | boolean; | ||
openAccountModal: undefined | (() => void); | ||
closeAccountModal: undefined | (() => void); | ||
toggleAccountModal: undefined | ((open: boolean) => void); | ||
// TODO: downcast this to a plain wallet client to support non-smart account use cases later | ||
appAccountClient: AppAccountClient | undefined; | ||
}; | ||
|
||
export type Store = StoreApi<State>; | ||
|
||
export const store = createStore<State>(() => ({ | ||
accountModalOpen: undefined, | ||
openAccountModal: undefined, | ||
closeAccountModal: undefined, | ||
toggleAccountModal: undefined, | ||
appAccountClient: undefined, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { mount } from "../bundle/mount"; | ||
export { mount, type MountOptions, type MountResult } from "../bundle/mount"; | ||
export { type Store } from "../bundle/store"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,22 @@ | ||
import { defineConfig } from "tsup"; | ||
import packageJson from "./package.json"; | ||
|
||
export default defineConfig([ | ||
{ | ||
entry: { | ||
index: "src/exports/index.ts", | ||
internal: "src/exports/internal.ts", | ||
"bin/local-bundler": "cli/local-bundler.ts", | ||
}, | ||
target: "esnext", | ||
format: ["esm"], | ||
dts: false, // TODO: figure out how to reenable | ||
sourcemap: true, | ||
clean: true, | ||
minify: true, | ||
// Because we're injecting CSS via shadow DOM, we'll disable style injection and load CSS as a base64 string. | ||
// TODO: figure out how to do this conditionally for only specific imports? | ||
injectStyle: false, | ||
loader: { | ||
".css": "text", | ||
}, | ||
export default defineConfig({ | ||
outDir: "dist/tsup", | ||
entry: { | ||
index: "src/exports/index.ts", | ||
internal: "src/exports/internal.ts", | ||
"bin/local-bundler": "cli/local-bundler.ts", | ||
}, | ||
{ | ||
entry: { | ||
bundle: "src/exports/bundle.ts", | ||
}, | ||
target: "esnext", | ||
format: ["esm"], | ||
dts: false, // TODO: figure out how to reenable | ||
sourcemap: true, | ||
clean: true, | ||
minify: true, | ||
// Because we're injecting CSS via shadow DOM, we'll disable style injection and load CSS as a base64 string. | ||
// TODO: figure out how to do this conditionally for only specific imports? | ||
injectStyle: false, | ||
loader: { | ||
".css": "text", | ||
}, | ||
// don't code split otherwise dep imports in bundle seem to break | ||
splitting: false, | ||
noExternal: Object.keys(packageJson.dependencies), | ||
target: "esnext", | ||
format: ["esm"], | ||
dts: false, // TODO: figure out how to reenable | ||
sourcemap: true, | ||
clean: true, | ||
minify: true, | ||
// Because we're injecting CSS via shadow DOM, we'll disable style injection and load CSS as a base64 string. | ||
// TODO: figure out how to do this conditionally for only specific imports? | ||
injectStyle: false, | ||
loader: { | ||
".css": "text", | ||
}, | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig({ | ||
build: { | ||
outDir: "dist/vite", | ||
sourcemap: true, | ||
lib: { | ||
entry: "src/exports/bundle.ts", | ||
name: "MUD Account Kit", | ||
fileName: "bundle", | ||
// TODO: more formats? | ||
formats: ["es"], | ||
}, | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.