UNPKG

@wener/console

Version:

Base console UI toolkit

32 lines (31 loc) 1.06 kB
import { computeIfAbsent, getGlobalStates } from "@wener/utils"; import { merge } from "es-toolkit"; import { createStore } from "zustand"; import { mutative } from "zustand-mutative"; import { createStoreSelectorHook } from "../../zustand/index.js"; function createSiteStore() { return createStore(mutative((setState, getState, store) => { return { title: "", baseUrl: typeof window === "undefined" ? "http://localhost:3000" : window.location.origin, metadata: {}, features: [], load(init) { if (!init) { return; } setState((s) => { merge(s, init); }); } }; })); } export function getSiteState() { return getSiteStore().getState(); } export function getSiteStore() { return computeIfAbsent(getGlobalStates(), "SiteStore", createSiteStore); } export const useSiteStore = createStoreSelectorHook(getSiteStore); //# sourceMappingURL=SiteStore.js.map