/** * The polyfill bootstrap — the ONLY non-SDK surface of the client. * * It injects the REAL SDK and the polyfill settings; afterwards the SDK-shaped * exports (`ng`, `useShape`, `inbox`) behave as drop-ins. This is exposed at the * subpath `@ng-eventually/client/polyfill` so the main entry * (`@ng-eventually/client`) stays a **pure, SDK-identical** surface. Everything * here is removed at migration. */ import type { NgLike, UseShapeLike, PrincipalId } from "./types"; export interface EventuallyConfig { /** The REAL `@ng-org/web` `ng` (injected to avoid a hard import / alias loop). */ ng: NgLike; /** The REAL `@ng-org/orm` `useShape`. */ useShape: UseShapeLike; /** Shared-wallet credentials — polyfill only (one wallet for everyone). */ sharedWallet?: { name: string; secret: string }; /** Initial current user; may also be set later via {@link setCurrentUser}. */ currentUser?: PrincipalId; } let cfg: EventuallyConfig | null = null; let currentUser: PrincipalId | null = null; export function configure(c: EventuallyConfig): void { cfg = c; currentUser = c.currentUser ?? null; } /** @internal — used by the SDK-shaped wrappers to reach the injected real SDK. */ export function getConfig(): EventuallyConfig { if (!cfg) throw new Error("[ng-eventually] configure() must be called before use"); return cfg; } /** Set the current app-level user (the polyfill's notion of "who am I"). */ export function setCurrentUser(id: PrincipalId | null): void { currentUser = id; } export function getCurrentUser(): PrincipalId | null { return currentUser; } // Capability helpers — polyfill-era surface (caps are emulated now; native at // migration). Re-exported here so the whole polyfill API lives under /polyfill. export { canRead, canWrite, defaultGrant, grantRead } from "./access";