mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 14:49:09 +02:00
- Create NavigationAdapter interface (push, replace, back, pathname, searchParams) - Create AppLink component replacing next/link in 4 files - Replace useRouter → useNavigation in 3 files (issue-detail, create-issue, create-workspace) - Create WebNavigationProvider wrapping Next.js useRouter/usePathname/useSearchParams - Move ~85 feature UI files (issues, editor, modals, my-issues, skills, runtimes) to packages/views/ - Add store singleton registration pattern (registerAuthStore, registerWorkspaceStore) - Create data-aware wrappers in packages/views/common/ (ActorAvatar, Markdown) - Update all app-layer imports to @multica/views/* - Add @source directive for Tailwind to scan views package - packages/views/ has zero next/* imports Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
export { createAuthStore } from "./store";
|
|
export type { AuthStoreOptions, AuthState } from "./store";
|
|
|
|
import type { createAuthStore as CreateAuthStoreFn } from "./store";
|
|
|
|
type AuthStoreInstance = ReturnType<typeof CreateAuthStoreFn>;
|
|
|
|
/** Module-level singleton — set once at app boot via `registerAuthStore()`. */
|
|
let _store: AuthStoreInstance | null = null;
|
|
|
|
/**
|
|
* Register the auth store instance created by the app.
|
|
* Must be called at boot before any component renders.
|
|
*/
|
|
export function registerAuthStore(store: AuthStoreInstance) {
|
|
_store = store;
|
|
}
|
|
|
|
/**
|
|
* Singleton accessor — a Zustand hook backed by the registered instance.
|
|
* Supports `useAuthStore(selector)` and `useAuthStore.getState()`.
|
|
*/
|
|
export const useAuthStore: AuthStoreInstance = new Proxy(
|
|
(() => {}) as unknown as AuthStoreInstance,
|
|
{
|
|
apply(_target, _thisArg, args) {
|
|
if (!_store)
|
|
throw new Error(
|
|
"Auth store not initialised — call registerAuthStore() first",
|
|
);
|
|
return (_store as unknown as (...a: unknown[]) => unknown)(...args);
|
|
},
|
|
get(_target, prop) {
|
|
// Allow property inspection (HMR/React Refresh) before registration
|
|
if (!_store) return undefined;
|
|
return Reflect.get(_store, prop);
|
|
},
|
|
},
|
|
);
|