import { StoreRegistry } from "./stores.mjs"; import { SessionStore } from "./session-store.mjs"; import { ParseSession, RedirectFn, Session } from "./types.mjs"; import { FetchInit } from "./plugin.mjs"; //#region src/context.d.ts /** Context passed to route handlers and plugin actions. */ type RouteContext = { /** * Fetch a path relative to the plugin base path. Pass * `init.absolute = true` to resolve from the client base path instead. */ fetch: (path: string, init?: FetchInit) => Promise; /** Navigate to an absolute URL. Returns whether navigation happened. */ readonly redirect: RedirectFn; /** Parse a session-bearing response. */ readonly parseSession: ParseSession; /** Write a session into the reactive store, or `null` to clear it. */ setSession: (session: Session | null) => void; /** Revalidate the current session. */ refetchSession: () => Promise; readonly currentSession: () => Session | null; readonly store: SessionStore; /** Stores other plugins published, resolved by {@link StoreRef}. */ readonly stores: StoreRegistry; }; type AnyRouteContext = RouteContext; //#endregion export { AnyRouteContext, RouteContext };