release: WRNexusJS 0.6.0

This commit is contained in:
Clintchiz committed 2026-08-01 01:09:58 +05:30
1 parent 3e565e8d03
commit 687d345882
502 files changed
+33038 -11358

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { createStoreContainer } from "./index.ts";
let globalContainer: ReturnType<typeof createStoreContainer> | undefined;
export function browserStoreContainer(hydration: Record<string, unknown> = {}) {
if (!globalContainer) {
globalContainer = createStoreContainer({
runtime: "client",
hydration,
onMutation(mutation) {
try {
globalThis.dispatchEvent?.(
new CustomEvent("wrnexus:store-mutation", { detail: mutation }),
);
} catch {
// Minimal DOM and non-browser runtimes may not expose CustomEvent.
}
},
});
(globalThis as any).__wrnexusStoreContainer = globalContainer;
}
return globalContainer;
}
export async function resetBrowserStores() {
await globalContainer?.dispose();
globalContainer = undefined;
delete (globalThis as any).__wrnexusStoreContainer;
}