gemi 0.120.0 → 0.120.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../testing/Page.tsx","../../internal/islandRuntime.ts","../../internal/staticNavigationRuntime.ts","../../testing/staticDocument.ts"],"sourcesContent":["import {\n Suspense,\n useContext,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type PropsWithChildren,\n type ReactNode,\n} from \"react\";\nimport { ErrorBoundary, type FallbackProps } from \"react-error-boundary\";\nimport { Action, createMemoryHistory } from \"history\";\n\nimport type { User } from \"../auth/types\";\nimport { ClientRouterContext } from \"../client/ClientRouterContext\";\nimport { I18nProvider } from \"../client/I18nContext\";\nimport { ProgressManager } from \"../client/ProgressManager\";\nimport {\n QueryManagerContext,\n QueryManagerProvider,\n type QueryConfig,\n} from \"../client/QueryManagerContext\";\nimport {\n RouteStateProvider,\n type PageData,\n type RouteState,\n} from \"../client/RouteStateContext\";\nimport { RouteTransitionProvider } from \"../client/RouteTransitionProvider\";\nimport {\n ServerDataContext,\n type ServerDataContextValue,\n} from \"../client/ServerDataProvider\";\nimport { ThemeProvider } from \"../client/ThemeProvider\";\nimport type { ClientFeatureKey } from \"../client/rpc\";\nimport type { Breadcrumb } from \"../client/useBreadcrumbs\";\nimport { applyParams } from \"../utils/applyParams\";\nimport { Subject } from \"../utils/Subject\";\nimport { toVariantKey } from \"../utils/variantKey\";\n\n/**\n * A dictionary as `Dictionary.create` produces it: a name and a\n * `{ key: { locale: string } }` map.\n *\n * Typed structurally rather than as `Dictionary<T>` for two reasons. It keeps\n * `gemi/testing` from importing `gemi/i18n` — a server entry, which reaches the\n * `Lang` facade and through it the container. And it means an object literal of\n * the same shape is accepted, so a test never *has* to import the app's\n * dictionaries at all.\n *\n * Only `name` and `dictionary` are read — both plain data. `Dictionary`'s\n * server-only methods (`render`, `reference`, which throw once `window` is\n * defined) are never called from here.\n */\nexport interface PageDictionary {\n name: string;\n dictionary: Record<string, Record<string, string>>;\n}\n\nexport interface PageProps {\n /**\n * The URL the view is mounted at. A template (`/app/:orgId/chat`) is resolved\n * against `params`, so the same string can be pasted from the router.\n */\n pathname?: string;\n /** Route params, as the router would have parsed them out of `pathname`. */\n params?: Record<string, string>;\n /** `\"?tab=recent\"`, `\"tab=recent\"`, or `{ tab: \"recent\" }`. */\n searchParams?: string | Record<string, string | number | boolean>;\n hash?: string;\n /** The locale `useTranslator` and `useLocale` report. */\n locale?: string;\n /**\n * The app's default locale. Links and `useNavigate` omit the locale segment\n * for it, so leaving this equal to `locale` (the default) keeps hrefs\n * unprefixed — set it to seed a page being viewed in a non-default locale.\n */\n defaultLocale?: string;\n supportedLocales?: string[];\n /** The zone `useFormatter` formats dates in. Defaults to `UTC`, like an app with no `translation.timeZone`. */\n timeZone?: string;\n /**\n * Dictionaries the components under test translate against — the app's own,\n * or literals of the same shape.\n *\n * Note what importing the app's costs: `app/i18n/index.ts` imports\n * `gemi/i18n`, a server entry, so the test file pulls the container and\n * `node:async_hooks` into its module graph. Nothing there runs (and nothing\n * here calls it), so it is fine under any runner that has Node builtins —\n * vitest, `bun test` — and not under one that renders in a real browser. Use\n * `translations` there, which is the shape the client actually receives.\n */\n dictionaries?: PageDictionary[];\n /**\n * Translations for the current locale, already resolved: dictionary name →\n * key → string. This is the shape the server serializes onto the page, so it\n * is what the client reads at runtime — and it imports nothing.\n *\n * ```tsx\n * <Page translations={{ Chat: { greeting: \"Hello {{name}}\" } }}>\n * ```\n *\n * Merged over `dictionaries`, so the two compose: seed from the app's real\n * dictionary and override the one key a test is about.\n */\n translations?: Record<string, Record<string, string>>;\n /**\n * Data `useQuery` finds already cached, keyed by API path — the path passed\n * to `useQuery`, without the `/api` prefix the client adds when it fetches.\n * A key may carry a query string (`\"/lists?page=2\"`) to seed one search\n * variant.\n *\n * The cache is keyed by the *resolved* path, so a key's `:params` are\n * resolved against the page's `params` — and a key naming one the page does\n * not carry is an error, naming the key. That case is common enough to be\n * worth the loud failure: a query often takes its params from the call site\n * rather than the route (`useQuery(\"/orgs/:orgId/lists\", { params: { orgId } })`\n * with `orgId` in component state), and the right seed for it is the resolved\n * path, `\"/orgs/abc/lists\"`.\n *\n * Seeded at mount only: a component that mutates or refetches its data owns\n * the cache from then on.\n */\n queryData?: Record<string, unknown>;\n /** App-wide `useQuery` defaults, as `createRoot` threads them. */\n queryConfig?: QueryConfig;\n /**\n * What `useUser()` reports. Defaults to `null` — an anonymous visitor — and\n * either way the hook resolves from here without issuing a request.\n */\n user?: Partial<User> | null;\n /** What `useBreadcrumbs()` returns, in order. */\n breadcrumbs?: Breadcrumb[];\n /**\n * The `route.domains` group the page is served under, as `useDomain()`\n * reports it. Left out, `useDomain()` reads empty — the shape an app without\n * `route.domains` sees — and `useDomain().url()` throws, exactly as it does\n * there.\n *\n * `root` and `origin` default off the host, so the common case is one field:\n * `domain={{ host: \"acme.example.com\", params: { tenant: \"acme\" } }}`.\n */\n domain?: {\n host: string;\n group?: string;\n params?: Record<string, string>;\n custom?: boolean;\n root?: string;\n origin?: string;\n } | null;\n /**\n * What `useFeature()` reports, keyed by feature key. Anything left out reads\n * as off, exactly as an undeclared key does in a real request.\n *\n * A test seeds the *outcome*, not the declaration: `app/features` owns the\n * targeting and the rollout, and re-deriving those here would mean building a\n * request context — a user, a `session_id`, a bot verdict — to assert a\n * branch that only cares which way the feature came out. Cover the targeting\n * where it lives, with a server test.\n */\n features?: Partial<Record<ClientFeatureKey, boolean>>;\n /**\n * The theme `useTheme()` starts on. The app reads a visitor's stored choice\n * out of `localStorage`; a test has no session to have made one in, so this\n * seeds it without writing to storage. `setTheme` works from either.\n */\n theme?: \"light\" | \"dark\" | \"system\";\n /**\n * Fallback for the `Suspense` boundary wrapped around the children — the\n * stand-in for the view's own `Loading` export, which the real router\n * supplies. Defaults to `null`.\n */\n fallback?: ReactNode;\n /**\n * Renders in place of the children when one throws, mirroring a view's\n * `Error` export. Without it a thrown render (an errored suspense query,\n * say) propagates out of `render()` and fails the test, which is usually\n * what you want.\n */\n errorFallback?: ComponentType<FallbackProps>;\n /**\n * Called when something navigates — a `Link` click, `useNavigate().push`.\n * The navigation is reported, not performed: `<Page>` renders one route and\n * does not re-resolve the tree, so `useLocation()` keeps reporting the\n * pathname it was given.\n */\n onNavigate?: (href: string, action: \"push\" | \"replace\") => void;\n}\n\n/** `\"?a=b\"` (or `\"\"`) from any of the shapes `searchParams` accepts. */\nfunction toSearchString(search: PageProps[\"searchParams\"]): string {\n if (!search) return \"\";\n const query =\n typeof search === \"string\"\n ? search.replace(/^\\?/, \"\")\n : new URLSearchParams(\n Object.entries(search).map(([key, value]) => [key, String(value)]),\n ).toString();\n return query ? `?${query}` : \"\";\n}\n\n/**\n * The `:params` a seed key needs supplied. Wildcards (`:rest*`) are excluded —\n * `applyParams` drops those when missing, which is a resolution rather than a\n * failure.\n *\n * Optional params (`:id?`) cannot reach here at all: a key is split at its\n * first `?` to separate the search string, so `\"/lists/:folderId?\"` arrives as\n * the path `/lists/:folderId`. Seed the resolved path for those.\n */\nfunction requiredParamsOf(path: string): string[] {\n return Array.from(path.matchAll(/:([^/]+)/g), ([, name]) => name).filter(\n (name) => !name.endsWith(\"*\"),\n );\n}\n\n/**\n * Fails a `queryData` key whose `:params` the page does not carry, saying so\n * in terms of the key.\n *\n * Without this the two documented runners disagree, and neither is legible.\n * `applyParams` throws `Missing parameter: orgId` under `import.meta.env.DEV`\n * (vitest) — a router-utility stack trace out of `<Page>`'s render, before\n * anything mounts, naming nothing that appears in the test. Under `bun test`\n * that flag is falsy, so it logs and seeds the literal `/orgs/undefined/lists`\n * instead: the seed misses, the query goes to the network, and the assertion\n * runs against a loading state.\n *\n * The case is common because a query's params often come from the call site\n * rather than the route — `useQuery(\"/orgs/:orgId/lists\", { params: { orgId } })`\n * with `orgId` in component state. The cache is keyed by the *resolved* path,\n * so the way out is to seed that path directly.\n */\nfunction resolveSeedPath(\n key: string,\n rawPath: string,\n params: Record<string, string>,\n): string {\n const missing = requiredParamsOf(rawPath).filter(\n (name) => params[name] === undefined,\n );\n if (missing.length > 0) {\n throw new Error(\n `[gemi] <Page> cannot resolve the queryData key \"${key}\": no value for ` +\n `${missing.map((name) => `:${name}`).join(\", \")}. The query cache is ` +\n `keyed by the resolved path, so either add ${missing\n .map((name) => `\\`${name}\\``)\n .join(\", \")} to the page's \\`params\\`, or seed the resolved path ` +\n `(e.g. \"${applyParams(\n rawPath,\n Object.fromEntries(missing.map((name) => [name, \"123\"])),\n )}\") — which is what a query taking its params from component state ` +\n `reads under.`,\n );\n }\n return applyParams(rawPath, params);\n}\n\n/**\n * `queryData` in the shape the query cache seeds from: `{ [path]: { [variant]:\n * data } }`, the same payload `Query.prefetch` puts on a server-rendered page.\n */\nfunction toPrefetchedData(\n queryData: Record<string, unknown>,\n params: Record<string, string>,\n warned: Set<string>,\n) {\n const prefetchedData: Record<string, Record<string, unknown>> = {};\n for (const [key, data] of Object.entries(queryData)) {\n const [rawPath, rawSearch = \"\"] = key.split(\"?\");\n // Once per key per page, not once per render: this runs again on every\n // re-render, and a duplicated warning reads as a second mistake.\n if (rawPath.startsWith(\"/api/\") && !warned.has(key)) {\n warned.add(key);\n console.warn(\n `[gemi] queryData key \"${key}\" starts with /api. useQuery is keyed by ` +\n `the path you pass it — the /api prefix is added when it fetches — ` +\n `so this entry seeds a path no query reads.`,\n );\n }\n const path = resolveSeedPath(key, rawPath, params);\n prefetchedData[path] = {\n ...prefetchedData[path],\n [toVariantKey(rawSearch)]: data,\n };\n }\n return prefetchedData;\n}\n\n/**\n * `{ [locale]: { [dictionary]: { [key]: string } } }` — the payload\n * `Translator` serializes onto the page, which is the only form the client\n * ever sees. `dictionaries` are transposed into it (they are keyed the other\n * way round, by key then locale); `translations` is already in it and lands\n * under `locale`, last, so it wins.\n */\nfunction toClientDictionary(\n dictionaries: PageDictionary[],\n locales: string[],\n locale: string,\n translations: Record<string, Record<string, string>>,\n): Record<string, Record<string, Record<string, string>>> {\n const clientDictionary: Record<\n string,\n Record<string, Record<string, string>>\n > = {};\n for (const supported of locales) {\n clientDictionary[supported] ??= {};\n }\n for (const { name, dictionary } of dictionaries) {\n for (const [key, byLocale] of Object.entries(dictionary ?? {})) {\n for (const [dictLocale, translation] of Object.entries(byLocale ?? {})) {\n clientDictionary[dictLocale] ??= {};\n clientDictionary[dictLocale][name] ??= {};\n clientDictionary[dictLocale][name][key] = translation;\n }\n }\n }\n for (const [name, keys] of Object.entries(translations)) {\n clientDictionary[locale] ??= {};\n clientDictionary[locale][name] = {\n ...clientDictionary[locale][name],\n ...keys,\n };\n }\n return clientDictionary;\n}\n\n/**\n * Mounts a component with the inputs a view normally arrives with — route\n * params, the current locale and its dictionaries, prefetched query data, the\n * signed-in user — so a unit test can assert what it renders rather than only\n * its empty state.\n *\n * ```tsx\n * import { render, screen } from \"@testing-library/react\";\n * import { Page } from \"gemi/testing\";\n *\n * render(\n * <Page\n * pathname=\"/app/:orgId/chat\"\n * params={{ orgId: \"abc\" }}\n * queryData={{ \"/organizations/:orgId/messages\": [{ id: 1, body: \"hi\" }] }}\n * dictionaries={[ChatDictionary]}\n * >\n * <OrgChat />\n * </Page>,\n * );\n *\n * expect(screen.getByText(\"hi\")).toBeDefined();\n * ```\n *\n * It is a plain component, so it composes with any renderer — Testing\n * Library's `render`, `react-test-renderer`, or `renderToString`.\n *\n * Two things it does not do.\n *\n * It does not route: there is no view tree and no route manifest behind it, so\n * a navigation is reported through `onNavigate` rather than resolved. To\n * assert the page *after* one, render a second `<Page>`.\n *\n * And under `renderToString` it renders the server's own no-data branch for an\n * *unseeded* query rather than suspending — deliberately, because suspending\n * there is the streaming server's job: `createRoot` threads the request's\n * `ServerQueryStore` through `ServerQueryContext`, and that store is what runs\n * the route handler. A harness has no request and no handler to run, so there\n * is nothing to suspend on. Seeded queries render their data on the server\n * exactly as they do in the browser; unseeded ones behave as a route with no\n * `Query.prefetch` does, framework warning included.\n */\nexport const Page = (props: PropsWithChildren<PageProps>) => {\n const {\n children,\n pathname: routePath = \"/\",\n params = {},\n searchParams,\n hash = \"\",\n locale = \"en-US\",\n defaultLocale = locale,\n timeZone = \"UTC\",\n dictionaries = [],\n translations = {},\n queryData = {},\n queryConfig,\n user = null,\n breadcrumbs = [],\n domain = null,\n features = {},\n theme,\n fallback = null,\n errorFallback,\n onNavigate,\n } = props;\n\n // The caller's list, in the caller's order — a language switcher maps over\n // it, so hoisting the page's own locale to the front would reorder the\n // rendered options. The defaults are appended, only to guarantee presence.\n const supportedLocales = useMemo(\n () =>\n Array.from(\n new Set([...(props.supportedLocales ?? []), defaultLocale, locale]),\n ),\n [props.supportedLocales, defaultLocale, locale],\n );\n const pathname = applyParams(routePath, params) || \"/\";\n // `root` defaults to the host minus its first label, so a tenant subdomain\n // needs only its host; `origin` to https on that host. Either can be given\n // outright when the test is about the other.\n const domainValue = useMemo(() => {\n if (!domain) {\n return null;\n }\n const labels = domain.host.split(\".\");\n return {\n host: domain.host,\n group: domain.group ?? \"\",\n params: domain.params ?? {},\n custom: domain.custom ?? false,\n root:\n domain.root ?? (labels.length > 2 ? labels.slice(1).join(\".\") : domain.host),\n origin: domain.origin ?? `https://${domain.host}`,\n };\n }, [domain]);\n const search = toSearchString(searchParams);\n // The URL's locale segment, which the default locale does not get.\n const urlLocaleSegment = locale === defaultLocale ? null : locale;\n\n const dictionary = useMemo(\n () =>\n toClientDictionary(dictionaries, supportedLocales, locale, translations),\n [dictionaries, supportedLocales, locale, translations],\n );\n\n // Keys that have already drawn a warning, so a re-render does not repeat it.\n const warnedRef = useRef<Set<string>>(new Set());\n const prefetchedData = useMemo(() => {\n const seeded = toPrefetchedData(queryData, params, warnedRef.current);\n // `useUser` reads `/auth/me` like any other query. Seeding it — with `null`\n // for the anonymous default — is what keeps a component test off the\n // network for a hook nothing in the test asked for.\n seeded[\"/auth/me\"] ??= { \"\": user ?? null };\n return seeded;\n }, [queryData, params, user]);\n\n // Keyed by `${view}:${pathname}` in the router's cache; the view names are\n // ours to choose here, and only their order reaches `useBreadcrumbs`.\n const { breadcrumbViews, breadcrumbsCache, breadcrumbsRecord } =\n useMemo(() => {\n const views = breadcrumbs.map((_, index) => `breadcrumb-${index}`);\n const cache = new Map<string, Breadcrumb>(\n breadcrumbs.map((breadcrumb, index) => [\n `${views[index]}:${pathname}`,\n breadcrumb,\n ]),\n );\n return {\n breadcrumbViews: views,\n breadcrumbsCache: cache,\n breadcrumbsRecord: Object.fromEntries(cache),\n };\n }, [breadcrumbs, pathname]);\n\n const [isNavigatingSubject] = useState(() => new Subject<boolean>(false));\n const [progressManager] = useState(\n () => new ProgressManager(isNavigatingSubject),\n );\n const [history] = useState(() =>\n createMemoryHistory({ initialEntries: [`${pathname}${search}${hash}`] }),\n );\n\n const routeState: RouteState & PageData = useMemo(\n () => ({\n views: [],\n params,\n search,\n state: {},\n pathname,\n hash,\n action: null,\n routePath,\n locale: urlLocaleSegment,\n data: {},\n i18n: {\n currentLocale: locale,\n dictionary,\n supportedLocales,\n defaultLocale,\n timeZone,\n },\n prefetchedData,\n breadcrumbs: breadcrumbsRecord,\n features: features as Record<string, boolean>,\n appId: \"test\",\n }),\n [\n params,\n search,\n pathname,\n hash,\n routePath,\n urlLocaleSegment,\n locale,\n dictionary,\n supportedLocales,\n defaultLocale,\n timeZone,\n prefetchedData,\n breadcrumbsRecord,\n features,\n ],\n );\n\n const [routerSubject] = useState(() => new Subject<RouteState>(routeState));\n\n const onNavigateRef = useRef(onNavigate);\n onNavigateRef.current = onNavigate;\n // Subscribed during render, not in an effect, because React flushes child\n // effects before parent ones — and mount-time navigation is a real pattern:\n // `<Redirect>` pushes from its own mount effect, as does any auth guard. A\n // listener registered in `<Page>`'s effect is not there yet when those fire,\n // so `onNavigate` would silently miss exactly the redirects a test most\n // wants to assert. Ref-guarded, so React's double-invoke registers one.\n //\n // Nothing unsubscribes: this history is created per `<Page>` and reachable\n // from nowhere else, so it is collected with the page it belongs to.\n const listeningRef = useRef(false);\n if (!listeningRef.current) {\n listeningRef.current = true;\n history.listen(({ location, action }) => {\n const href = `${location.pathname}${location.search}${location.hash}`;\n onNavigateRef.current?.(\n href,\n action === Action.Replace ? \"replace\" : \"push\",\n );\n });\n }\n\n const serverData: ServerDataContextValue = useMemo(\n () => ({\n routeManifest: {},\n pageData: {},\n breadcrumbs: breadcrumbsRecord,\n prefetchedData,\n router: {\n pathname,\n params,\n currentPath: routePath,\n is404: false,\n searchParams: search,\n urlLocaleSegment,\n domain: domainValue,\n },\n i18n: {\n dictionary,\n currentLocale: locale,\n supportedLocales,\n defaultLocale,\n timeZone,\n },\n componentTree: [],\n auth: { user: user as User },\n features: features as Record<string, boolean>,\n __csrf: \"test-csrf-token\",\n cssManifest: {},\n modulePreloadManifest: {},\n meta: {},\n appId: \"test\",\n }),\n [\n breadcrumbsRecord,\n prefetchedData,\n pathname,\n params,\n routePath,\n search,\n urlLocaleSegment,\n dictionary,\n locale,\n supportedLocales,\n defaultLocale,\n timeZone,\n user,\n features,\n ],\n );\n\n // Everything the router hooks read, inert: nothing here fetches, preloads or\n // resolves a route, but every hook finds the shape it expects rather than an\n // empty context to crash on.\n const [viewEntriesSubject] = useState(() => new Subject<string[]>([]));\n const routerContext = useMemo(\n () => ({\n viewEntriesSubject,\n history,\n updatePageData: () => {},\n getPageData: () => ({}),\n getScrollPosition: () => 0,\n getViewPathsFromPathname: () => breadcrumbViews,\n getRoutePathnameFromHref: (href: string) => href,\n isNavigatingSubject,\n setNavigationAbortController: () => {},\n progressManager,\n fetchRouteCSS: async () => {},\n preloadRouteModules: () => {},\n prefetchRoute: async () => {},\n takePrefetched: () => null,\n clearPrefetchCache: () => {},\n breadcrumbsCache,\n routerSubject,\n urlLocaleSegment,\n }),\n [\n viewEntriesSubject,\n history,\n breadcrumbViews,\n isNavigatingSubject,\n progressManager,\n breadcrumbsCache,\n routerSubject,\n urlLocaleSegment,\n ],\n );\n\n return (\n <ThemeProvider theme={theme}>\n <ServerDataContext.Provider value={serverData}>\n <I18nProvider>\n <QueryManagerProvider queryConfig={queryConfig}>\n <ClientRouterContext.Provider value={routerContext}>\n <RouteTransitionProvider\n isPending={false}\n isFetching={false}\n transitionPath={[\"\", pathname]}\n >\n <RouteStateProvider state={routeState}>\n <Boundary\n errorFallback={errorFallback}\n fallback={fallback}\n resetKey={pathname}\n >\n {children}\n </Boundary>\n </RouteStateProvider>\n </RouteTransitionProvider>\n </ClientRouterContext.Provider>\n </QueryManagerProvider>\n </I18nProvider>\n </ServerDataContext.Provider>\n </ThemeProvider>\n );\n};\n\n/**\n * The `Suspense` boundary every view renders inside, and — when the test\n * supplies a fallback for it — the error boundary too.\n *\n * `onReset={clearErrors}` is the part that has to be here rather than inline\n * above: it needs `QueryManagerContext`, and it is what makes a view's real\n * `Error` export testable. A fallback whose \"Try again\" calls\n * `resetErrorBoundary()` re-renders the child, and `useQuery` reads the\n * failure still stored on the `QueryResource` and throws it straight back —\n * so without this the fallback never goes away and the retry path that works\n * in the app cannot be exercised. `ClientRouter`'s own boundary wires exactly\n * this pair.\n */\nconst Boundary = (\n props: PropsWithChildren<{\n errorFallback?: ComponentType<FallbackProps>;\n fallback: ReactNode;\n resetKey: string;\n }>,\n) => {\n const { errorFallback: ErrorFallback, fallback, resetKey, children } = props;\n const { clearErrors } = useContext(QueryManagerContext);\n const content = <Suspense fallback={fallback}>{children}</Suspense>;\n\n if (!ErrorFallback) {\n return content;\n }\n\n return (\n <ErrorBoundary\n FallbackComponent={ErrorFallback}\n resetKeys={[resetKey]}\n onReset={clearErrors}\n >\n {content}\n </ErrorBoundary>\n );\n};\n","/**\n * The browser side of islands, shared by the Vite plugin (which builds it), the\n * servers (which point the loader at it) and the tests.\n *\n * No imports: the Vite plugin is built on its own and the servers load it at\n * boot, so this file stays plain strings.\n */\n\n/**\n * The module that hydrates islands: React, `react-dom/client` and the small\n * `h(marker, Component)` below. A virtual module of gemi's Vite plugin that\n * every island entry imports, so the islands on a page share one copy of\n * React, in one chunk.\n */\nexport const ISLAND_RUNTIME_ID = \"virtual:gemi-island-runtime\";\n\n/** What `resolveId` turns `ISLAND_RUNTIME_ID` into (Vite's virtual-module convention). */\nexport const RESOLVED_ISLAND_RUNTIME_ID = `\\0${ISLAND_RUNTIME_ID}`;\n\n/**\n * The query that turns a module into its island entry: `Counter.tsx?gemi-island`\n * is a module of the plugin's that re-exports `Counter.tsx` as `m` next to the\n * runtime's `h`. It is what a static page imports for an island, and so it\n * is what the client manifest lists, keyed `app/…/Counter.tsx?gemi-island`,\n * with React and `react-dom/client` among its imports.\n */\nexport const ISLAND_ENTRY_QUERY = \"?gemi-island\";\n\n/** The island entry module for `file` (an absolute path or a root-relative URL). */\nexport function islandEntrySource(file: string) {\n return `import * as m from ${JSON.stringify(file)};\nexport { m };\nexport { h } from ${JSON.stringify(ISLAND_RUNTIME_ID)};\n`;\n}\n\n/**\n * `h(marker, Component)`: hydrates one `<gemi-island>` marker with the island's\n * component and the props the server serialised into `data-props`.\n *\n * The island's static children were rendered on the server into a\n * `<gemi-slot>` (the first one that belongs to this marker, not to an island\n * nested in it). They are handed back to the component as that same element\n * with the server's HTML, so hydration matches and React leaves them alone.\n *\n * `data-uid` is the `identifierPrefix` the server rendered the island with, so\n * `useId` agrees on both sides and two islands never share an id.\n *\n * Written as a function body with `createElement` and `hydrateRoot` free, so a\n * test can run it against real React without a bundler.\n */\nexport const ISLAND_HYDRATE_SOURCE = `function h(marker, Component) {\n if (typeof Component !== \"function\" && (typeof Component !== \"object\" || Component === null)) {\n throw new Error(\"gemi: island module has no component export for \" + marker.outerHTML.slice(0, 80));\n }\n const json = marker.getAttribute(\"data-props\");\n const props = json ? JSON.parse(json) : {};\n let slot = null;\n for (const candidate of marker.querySelectorAll(\"gemi-slot\")) {\n if (candidate.closest(\"gemi-island\") === marker) {\n slot = candidate;\n break;\n }\n }\n const children = slot\n ? [createElement(\"gemi-slot\", {\n style: { display: \"contents\" },\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: { __html: slot.innerHTML },\n })]\n : [];\n return hydrateRoot(marker, createElement(Component, props, ...children), {\n identifierPrefix: marker.getAttribute(\"data-uid\") || undefined,\n });\n}`;\n\n/** The runtime module's source, as the plugin serves and builds it. */\nexport const ISLAND_RUNTIME_SOURCE = `import { createElement } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nexport ${ISLAND_HYDRATE_SOURCE}\n`;\n\n/**\n * The island loader, inlined into a static document that uses islands.\n *\n * Kept byte-for-byte constant (the per-page island table travels in a\n * separate `<script type=\"application/json\">`, which a Content Security Policy\n * does not treat as script), so a strict policy can allow it by hash:\n * `script-src 'sha256-…'` with `ISLAND_LOADER_CSP_HASH`. Everything it loads\n * is a plain `import()` of a same-origin (or asset-base) file.\n *\n * The table is `{ i: [{ s: entry URL, e: export, l: load }] }` and each\n * marker's `data-island` indexes `i`. Per marker, on its schedule: import the\n * island's entry (the module as `m`, the runtime's `h`), then\n * `h(marker, m[export])`, which calls `hydrateRoot`. A failure is logged and\n * leaves the server-rendered markup in place.\n */\nexport const ISLAND_LOADER_SOURCE =\n 'const d=document,c=JSON.parse(d.getElementById(\"gemi-islands\").textContent),' +\n \"w=f=>(window.requestIdleCallback||setTimeout)(f),\" +\n \"m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};\" +\n 'for(const e of d.querySelectorAll(\"gemi-island\")){const o=c.i[e.dataset.island];if(!o)continue;' +\n 'if(o.l==\"eager\")m(e,o);else if(o.l==\"idle\"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));' +\n \"else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}\";\n","// Generated by `bun scripts/build-static-navigation.ts` from\n// `internal/staticNavigation/runtime.js`. Do not edit; edit the source and regenerate.\n// No imports: `gemi/testing` (a browser bundle) and `gemi stats` read it too.\n\n/** The sha-256 of the source this was built from, so a test can tell it is stale. */\nexport const STATIC_NAVIGATION_SOURCE_HASH = \"0a7425eb046f290e83ec8441ef6df27cd3eea9dd68c2a71bd6908a4a9cf6e4f3\";\n\n/**\n * The navigation runtime (with the island loader) a static view with\n * `.static({ navigation })` inlines. Byte-for-byte constant.\n */\nexport const STATIC_NAVIGATION_SOURCE =\n \"var r=document,i=window,a=history;i.__gemi_nav?.d();var C=new AbortController,h=(t,e,n,s)=>t.addEventListener(e,n,{signal:C.signal,...s}),q=i.__gemi_nav={d:()=>C.abort()},y=(t,e)=>{if(!t.g)t.g=1,import(e.s).then((n)=>{if(t.isConnected)t.r=n.h(t,n.m[e.e])}).catch((n)=>console.error(n))},L=(t)=>{let e=t.getElementById(\\\"gemi-islands\\\");return e?JSON.parse(e.textContent):{i:[]}},D=(t,e)=>{for(let n of t.querySelectorAll(\\\"gemi-island\\\")){let s=e.i[n.dataset.island];if(!s||n.o)continue;if(s.l==\\\"eager\\\")y(n,s);else if(s.l==\\\"idle\\\"||!i.IntersectionObserver||!n.children.length)(i.requestIdleCallback||setTimeout)(()=>y(n,s));else{let l=new IntersectionObserver((m)=>{if(m.some((d)=>d.isIntersecting))l.disconnect(),y(n,s)});for(let m of n.children)l.observe(m)}}},R='meta[name=\\\"gemi-static\\\"]',A=\\\"style:not([data-gemi-fonts]),link[rel=stylesheet]\\\",I='meta[name]:not([name=viewport]),meta[property],link[rel~=canonical],link[rel~=alternate],link[rel~=icon],link[rel=preload][as=font],style[data-gemi-fonts],script[type=\\\"application/ld+json\\\"]',w=(t)=>t.querySelector(R)?.content,T=(t)=>[...t.querySelectorAll(A)].map((e)=>e.outerHTML).join(),c=(t)=>t.href.split(\\\"#\\\")[0],p=r.createElement(\\\"div\\\");p.setAttribute(\\\"aria-live\\\",\\\"polite\\\");p.style.cssText=\\\"position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap\\\";r.body.append(p);var _=(t)=>{q.p={url:location.href,title:r.title,initial:t},r.dispatchEvent(new CustomEvent(\\\"gemi:page-load\\\",{detail:q.p}))},f=new Map,O=(t)=>{let e=f.get(t);if(!e||Date.now()-e[0]>30000){let n=fetch(t,{headers:{accept:\\\"text/html\\\",\\\"x-gemi-navigate\\\":\\\"1\\\"},signal:AbortSignal.timeout(1e4)}).then((s)=>{if(!s.ok||!/^text\\\\/html/.test(s.headers.get(\\\"content-type\\\"))||new URL(s.url||t).origin!=location.origin)throw s;return s.text().then((l)=>[s.url||t,l])});e=[Date.now(),n],n.catch(()=>f.get(t)==e&&f.delete(t))}if(f.delete(t),f.set(t,e),f.size>10)f.delete(f.keys().next().value);return e[1]},U=(t)=>{let e=t.target.closest?.(\\\"a[href]\\\"),n=e?.getAttribute(\\\"target\\\");if(!e||n&&n!=\\\"_self\\\"||e.hasAttribute(\\\"download\\\")||/(^|\\\\s)external(\\\\s|$)/i.test(e.getAttribute(\\\"rel\\\"))||e.closest(\\\"[data-gemi-reload]\\\"))return;let s=new URL(e.getAttribute(\\\"href\\\"),r.baseURI);if(s.origin==location.origin&&!(s.href.includes(\\\"#\\\")&&c(s)==c(location)))return s},v={},k=()=>Math.random().toString(36).slice(2),x=()=>a.state?.g||a.replaceState({...a.state,g:k()},\\\"\\\"),M=c(location),b=0,K=(t)=>{if(!t.hasAttribute(\\\"tabindex\\\"))t.setAttribute(\\\"tabindex\\\",\\\"-1\\\"),t.addEventListener(\\\"blur\\\",()=>t.removeAttribute(\\\"tabindex\\\"),{once:!0});t.focus({preventScroll:!0})},N=(t)=>{let e=r.body,n=t.body,s=L(t),l=r.documentElement;r.title=t.title;for(let o of[\\\"lang\\\",\\\"dir\\\"]){let u=t.documentElement.getAttribute(o);if(u==null)l.removeAttribute(o);else l.setAttribute(o,u)}for(let o of r.head.querySelectorAll(I))o.remove();let m=new Set([...r.querySelectorAll(\\\"link[rel=modulepreload]\\\")].map((o)=>o.getAttribute(\\\"href\\\")));r.head.append(...t.head.querySelectorAll(I),...[...t.head.querySelectorAll(\\\"link[rel=modulepreload]\\\")].filter((o)=>!m.has(o.getAttribute(\\\"href\\\"))));let d=new Map([...e.querySelectorAll(\\\"[data-gemi-persist]\\\")].map((o)=>[o.dataset.gemiPersist,o])),g=[...n.querySelectorAll(\\\"[data-gemi-persist]\\\")].map((o)=>[o,d.get(o.dataset.gemiPersist)]).filter((o)=>o[1]);for(let o of[...e.querySelectorAll(\\\"gemi-island\\\")].reverse())if(o.o=1,!g.some((u)=>u[1].contains(o)))try{o.r?.unmount()}catch(u){console.error(u)}for(let[o,u]of g)o.replaceWith(u);for(let o of[...e.childNodes])if(!o.matches?.(A))o.remove();for(let o of[...n.children])if(o.matches(A))o.remove();for(let o of[...e.attributes])e.removeAttribute(o.name);for(let o of n.attributes)e.setAttribute(o.name,o.value);e.append(...n.childNodes,p),D(e,s)},H=async(t,e)=>{let n=++b,s=!e&&v[a.state?.g];a.scrollRestoration=\\\"manual\\\";try{let[l,m]=await O(c(t));if(n!=b)return;let d=new DOMParser().parseFromString(m,\\\"text/html\\\");if(w(d)==null||w(d)!=w(r)||T(d)!=T(r))throw 0;if(e){let o=new URL(l);o.hash=t.hash,a.pushState({g:k()},\\\"\\\",o.href)}M=c(location),N(d);let g=e&&t.hash&&r.getElementById(decodeURIComponent(t.hash.slice(1)));if(g)g.scrollIntoView({behavior:\\\"instant\\\"});else i.scrollTo({left:s?.[0]||0,top:s?.[1]||0,behavior:\\\"instant\\\"});if(e)K(g||r.querySelector(\\\"h1\\\")||r.querySelector(\\\"main\\\")||r.body);p.textContent=r.title,_(!1)}catch{if(n!=b)return;if(e)location.assign(t.href);else location.reload()}};h(r,\\\"click\\\",(t)=>{if(t.defaultPrevented||t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=U(t);if(e&&r.dispatchEvent(new CustomEvent(\\\"gemi:before-navigate\\\",{cancelable:!0,detail:{url:e.href}})))t.preventDefault(),x(),v[a.state.g]=[i.scrollX,i.scrollY],H(e,1)});h(i,\\\"popstate\\\",()=>{if(b++,c(location)==M){let t=v[a.state?.g];if(t)i.scrollTo({left:t[0],top:t[1],behavior:\\\"instant\\\"})}else if(a.state?.g)H(new URL(location.href),0);else location.reload()});h(i,\\\"hashchange\\\",x);h(i,\\\"scroll\\\",()=>a.state?.g&&(v[a.state.g]=[i.scrollX,i.scrollY]),{passive:!0});var S,E=(t)=>{if(r.querySelector(R)?.dataset.prefetch==\\\"none\\\"||navigator.connection?.saveData)return;let e=U(t);if(e&&c(e)!=c(location))O(c(e))};h(r,\\\"pointerover\\\",(t)=>{clearTimeout(S),S=setTimeout(()=>E(t),65)});h(r,\\\"pointerout\\\",()=>clearTimeout(S));h(r,\\\"focusin\\\",E);h(r,\\\"touchstart\\\",E,{passive:!0});x();D(r,L(r));_(!0);\";\n","import { createElement } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { ISLAND_HYDRATE_SOURCE } from \"../internal/islandRuntime\";\nimport { STATIC_NAVIGATION_SOURCE } from \"../internal/staticNavigationRuntime\";\n\n/**\n * One page `renderStaticDocument` serves to the navigation runtime: its HTML, or\n * a response of another kind to see the runtime fall back to a full load.\n */\nexport interface StaticTestPage {\n html?: string;\n /** Default 200. */\n status?: number;\n /** Default `text/html; charset=utf-8`. */\n contentType?: string;\n /** The URL the response ends at, as after a redirect. Default: the one asked for. */\n url?: string;\n}\n\nexport interface StaticDocumentOptions {\n /** The document's URL, resolved against the test window's origin. Default `/`. */\n url?: string;\n /**\n * What the runtime's `fetch` gets, by path (`/about`, `/about?x=1`) or full\n * URL: HTML, a `StaticTestPage`, or a function for anything else. A URL\n * not listed is a 404.\n */\n pages?:\n | Record<string, string | StaticTestPage>\n | ((url: URL) => string | StaticTestPage | Promise<string | StaticTestPage>);\n /**\n * The island modules, by the entry URL the page's island table names (`s`):\n * each a module whose exports include the islands' components. Hydrated\n * with React, as `<module>?gemi-island` would.\n */\n islands?: Record<string, Record<string, unknown>>;\n}\n\n/** How a navigation ended. */\nexport type StaticNavigationResult =\n /** The runtime swapped the fetched page in. */\n | { kind: \"swap\"; url: string }\n /** The runtime gave up on a swap and asked for a full page load of `url`. */\n | { kind: \"full-load\"; url: string }\n /** The runtime left the click alone: the browser would follow the link itself. */\n | { kind: \"native\" };\n\nexport interface StaticDocumentHandle {\n /**\n * Clicks the page's first `<a>` whose `href` attribute is `href` and waits\n * for the outcome. Throws when there is no such link.\n */\n navigate(href: string, init?: MouseEventInit): Promise<StaticNavigationResult>;\n /** `history.back()`, and waits for the runtime to show that entry. */\n back(): Promise<StaticNavigationResult>;\n /** Every URL the runtime fetched, prefetches included, in order. */\n requests: string[];\n /** Every full page load the runtime asked for. */\n fullLoads: string[];\n /** Stops the runtime and restores what the helper stubbed. */\n dispose(): void;\n}\n\nconst hydrate = new Function(\n \"createElement\",\n \"hydrateRoot\",\n `${ISLAND_HYDRATE_SOURCE};return h;`,\n)(createElement, hydrateRoot) as (marker: Element, component: unknown) => unknown;\n\n/**\n * Puts a static document (`.static({ navigation })`) into the test's DOM and\n * starts its navigation runtime against stubbed pages, so a test can check that\n * a site's links are followed client-side, and what the next page looks like.\n * Needs a DOM (`// @vitest-environment jsdom`).\n *\n * ```ts\n * const html = await (await render(\"/\")).text(); // the page, from your app\n * const page = renderStaticDocument(html, { pages: { \"/about\": aboutHtml } });\n * expect(await page.navigate(\"/about\")).toEqual({ kind: \"swap\", url: \"http://localhost:3000/about\" });\n * expect(document.querySelector(\"h1\")!.textContent).toBe(\"About\");\n * page.dispose();\n * ```\n *\n * The document's own scripts do not run (the helper runs the runtime itself),\n * and a link the runtime leaves alone is not followed. Islands hydrate\n * asynchronously, as in a browser: wrap what follows in `act`, or wait for it.\n */\nexport function renderStaticDocument(\n html: string,\n options: StaticDocumentOptions = {},\n): StaticDocumentHandle {\n const requests: string[] = [];\n const fullLoads: string[] = [];\n let settle: ((result: StaticNavigationResult) => void) | undefined;\n const outcome = () =>\n new Promise<StaticNavigationResult>((resolve, reject) => {\n const timer = setTimeout(() => reject(new Error(\"the navigation did not finish in 5 s\")), 5000);\n settle = (result) => {\n clearTimeout(timer);\n settle = undefined;\n resolve(result);\n };\n });\n\n history.replaceState(null, \"\", options.url ?? \"/\");\n const parsed = new DOMParser().parseFromString(html, \"text/html\");\n for (const script of Array.from(parsed.querySelectorAll(\"script\"))) {\n if (!/json/.test(script.type)) script.remove();\n }\n document.replaceChild(document.importNode(parsed.documentElement, true), document.documentElement);\n\n const fullLoad = (url: string) => {\n fullLoads.push(url);\n settle?.({ kind: \"full-load\", url });\n };\n const location = {\n get href() {\n return window.location.href;\n },\n get origin() {\n return window.location.origin;\n },\n assign: (url: string) => fullLoad(new URL(url, window.location.href).href),\n reload: () => fullLoad(window.location.href),\n };\n\n const pages = options.pages ?? {};\n const fetch = async (input: string) => {\n const url = new URL(input, window.location.href);\n requests.push(url.href);\n const page =\n typeof pages === \"function\"\n ? await pages(url)\n : (pages[url.href] ?? pages[url.pathname + url.search]);\n const spec: StaticTestPage =\n page === undefined\n ? { status: 404, html: \"not found\", contentType: \"text/plain\" }\n : typeof page === \"string\"\n ? { html: page }\n : page;\n const response = new Response(spec.html ?? \"\", {\n status: spec.status ?? 200,\n headers: { \"content-type\": spec.contentType ?? \"text/html; charset=utf-8\" },\n });\n Object.defineProperty(response, \"url\", { value: new URL(spec.url ?? url.href, url).href });\n return response;\n };\n\n const importIsland = async (src: string) => {\n const module = options.islands?.[src];\n if (!module) throw new Error(`renderStaticDocument: no island module for ${src} in options.islands`);\n return { m: module, h: hydrate };\n };\n\n // The runtime announces a click it takes with `gemi:before-navigate`; one\n // it does not take (or one a listener cancelled) is the browser's, which\n // jsdom would try (and fail) to follow, so it is stopped here, on `window`,\n // after every listener on the way.\n let announced: Event | undefined;\n const onBeforeNavigate = (event: Event) => {\n announced = event;\n };\n document.addEventListener(\"gemi:before-navigate\", onBeforeNavigate);\n const onClick = (event: Event) => {\n const taken = announced !== undefined && !announced.defaultPrevented;\n announced = undefined;\n if (taken || !(event.target as Element).closest?.(\"a[href]\")) return;\n event.preventDefault();\n settle?.({ kind: \"native\" });\n };\n window.addEventListener(\"click\", onClick);\n const onPageLoad = (event: Event) => {\n const detail = (event as CustomEvent<{ url: string; initial: boolean }>).detail;\n if (!detail.initial) settle?.({ kind: \"swap\", url: detail.url });\n };\n document.addEventListener(\"gemi:page-load\", onPageLoad);\n\n // Not implemented by jsdom.\n const scrollTo = window.scrollTo;\n window.scrollTo = () => {};\n const scrollIntoView = Element.prototype.scrollIntoView;\n Element.prototype.scrollIntoView = function () {};\n\n const source = STATIC_NAVIGATION_SOURCE.replace(\"import(\", \"__import(\");\n new Function(\"__import\", \"location\", \"fetch\", source)(importIsland, location, fetch);\n\n return {\n requests,\n fullLoads,\n async navigate(href, init) {\n const link = Array.from(document.querySelectorAll(\"a[href]\")).find(\n (a) => a.getAttribute(\"href\") === href,\n );\n if (!link) throw new Error(`renderStaticDocument: no <a href=\"${href}\"> on the page`);\n const done = outcome();\n link.dispatchEvent(new MouseEvent(\"click\", { bubbles: true, cancelable: true, ...init }));\n return await done;\n },\n async back() {\n const done = outcome();\n history.back();\n return await done;\n },\n dispose() {\n (window as unknown as { __gemi_nav?: { d: () => void } }).__gemi_nav?.d();\n window.removeEventListener(\"click\", onClick);\n document.removeEventListener(\"gemi:before-navigate\", onBeforeNavigate);\n document.removeEventListener(\"gemi:page-load\", onPageLoad);\n window.scrollTo = scrollTo;\n Element.prototype.scrollIntoView = scrollIntoView;\n },\n };\n}\n"],"mappings":";;;;;;;AA6LA,SAAS,eAAe,QAA2C;CACjE,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QACJ,OAAO,WAAW,WACd,OAAO,QAAQ,OAAO,EAAE,IACxB,IAAI,gBACF,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,OAAO,KAAK,CAAC,CAAC,CACnE,CAAC,CAAC,SAAS;CACjB,OAAO,QAAQ,IAAI,UAAU;AAC/B;;;;;;;;;;AAWA,SAAS,iBAAiB,MAAwB;CAChD,OAAO,MAAM,KAAK,KAAK,SAAS,WAAW,IAAI,GAAG,UAAU,IAAI,CAAC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AO,QAAQ;GACrB,KAAK,cAAc,IAAI,WAAW,SAAS;IAAE,SAAS;IAAM,YAAY;IAAM,GAAG;GAAK,CAAC,CAAC;GACxF,OAAO,MAAM;EACf;EACA,MAAM,OAAO;GACX,MAAM,OAAO,QAAQ;GACrB,QAAQ,KAAK;GACb,OAAO,MAAM;EACf;EACA,UAAU;GACR,OAA0D,YAAY,EAAE;GACxE,OAAO,oBAAoB,SAAS,OAAO;GAC3C,SAAS,oBAAoB,wBAAwB,gBAAgB;GACrE,SAAS,oBAAoB,kBAAkB,UAAU;GACzD,OAAO,WAAW;GAClB,QAAQ,UAAU,iBAAiB;EACrC;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../testing/Page.tsx","../../internal/islandRuntime.ts","../../internal/staticNavigationRuntime.ts","../../testing/staticDocument.ts"],"sourcesContent":["import {\n Suspense,\n useContext,\n useMemo,\n useRef,\n useState,\n type ComponentType,\n type PropsWithChildren,\n type ReactNode,\n} from \"react\";\nimport { ErrorBoundary, type FallbackProps } from \"react-error-boundary\";\nimport { Action, createMemoryHistory } from \"history\";\n\nimport type { User } from \"../auth/types\";\nimport { ClientRouterContext } from \"../client/ClientRouterContext\";\nimport { I18nProvider } from \"../client/I18nContext\";\nimport { ProgressManager } from \"../client/ProgressManager\";\nimport {\n QueryManagerContext,\n QueryManagerProvider,\n type QueryConfig,\n} from \"../client/QueryManagerContext\";\nimport {\n RouteStateProvider,\n type PageData,\n type RouteState,\n} from \"../client/RouteStateContext\";\nimport { RouteTransitionProvider } from \"../client/RouteTransitionProvider\";\nimport {\n ServerDataContext,\n type ServerDataContextValue,\n} from \"../client/ServerDataProvider\";\nimport { ThemeProvider } from \"../client/ThemeProvider\";\nimport type { ClientFeatureKey } from \"../client/rpc\";\nimport type { Breadcrumb } from \"../client/useBreadcrumbs\";\nimport { applyParams } from \"../utils/applyParams\";\nimport { Subject } from \"../utils/Subject\";\nimport { toVariantKey } from \"../utils/variantKey\";\n\n/**\n * A dictionary as `Dictionary.create` produces it: a name and a\n * `{ key: { locale: string } }` map.\n *\n * Typed structurally rather than as `Dictionary<T>` for two reasons. It keeps\n * `gemi/testing` from importing `gemi/i18n` — a server entry, which reaches the\n * `Lang` facade and through it the container. And it means an object literal of\n * the same shape is accepted, so a test never *has* to import the app's\n * dictionaries at all.\n *\n * Only `name` and `dictionary` are read — both plain data. `Dictionary`'s\n * server-only methods (`render`, `reference`, which throw once `window` is\n * defined) are never called from here.\n */\nexport interface PageDictionary {\n name: string;\n dictionary: Record<string, Record<string, string>>;\n}\n\nexport interface PageProps {\n /**\n * The URL the view is mounted at. A template (`/app/:orgId/chat`) is resolved\n * against `params`, so the same string can be pasted from the router.\n */\n pathname?: string;\n /** Route params, as the router would have parsed them out of `pathname`. */\n params?: Record<string, string>;\n /** `\"?tab=recent\"`, `\"tab=recent\"`, or `{ tab: \"recent\" }`. */\n searchParams?: string | Record<string, string | number | boolean>;\n hash?: string;\n /** The locale `useTranslator` and `useLocale` report. */\n locale?: string;\n /**\n * The app's default locale. Links and `useNavigate` omit the locale segment\n * for it, so leaving this equal to `locale` (the default) keeps hrefs\n * unprefixed — set it to seed a page being viewed in a non-default locale.\n */\n defaultLocale?: string;\n supportedLocales?: string[];\n /** The zone `useFormatter` formats dates in. Defaults to `UTC`, like an app with no `translation.timeZone`. */\n timeZone?: string;\n /**\n * Dictionaries the components under test translate against — the app's own,\n * or literals of the same shape.\n *\n * Note what importing the app's costs: `app/i18n/index.ts` imports\n * `gemi/i18n`, a server entry, so the test file pulls the container and\n * `node:async_hooks` into its module graph. Nothing there runs (and nothing\n * here calls it), so it is fine under any runner that has Node builtins —\n * vitest, `bun test` — and not under one that renders in a real browser. Use\n * `translations` there, which is the shape the client actually receives.\n */\n dictionaries?: PageDictionary[];\n /**\n * Translations for the current locale, already resolved: dictionary name →\n * key → string. This is the shape the server serializes onto the page, so it\n * is what the client reads at runtime — and it imports nothing.\n *\n * ```tsx\n * <Page translations={{ Chat: { greeting: \"Hello {{name}}\" } }}>\n * ```\n *\n * Merged over `dictionaries`, so the two compose: seed from the app's real\n * dictionary and override the one key a test is about.\n */\n translations?: Record<string, Record<string, string>>;\n /**\n * Data `useQuery` finds already cached, keyed by API path — the path passed\n * to `useQuery`, without the `/api` prefix the client adds when it fetches.\n * A key may carry a query string (`\"/lists?page=2\"`) to seed one search\n * variant.\n *\n * The cache is keyed by the *resolved* path, so a key's `:params` are\n * resolved against the page's `params` — and a key naming one the page does\n * not carry is an error, naming the key. That case is common enough to be\n * worth the loud failure: a query often takes its params from the call site\n * rather than the route (`useQuery(\"/orgs/:orgId/lists\", { params: { orgId } })`\n * with `orgId` in component state), and the right seed for it is the resolved\n * path, `\"/orgs/abc/lists\"`.\n *\n * Seeded at mount only: a component that mutates or refetches its data owns\n * the cache from then on.\n */\n queryData?: Record<string, unknown>;\n /** App-wide `useQuery` defaults, as `createRoot` threads them. */\n queryConfig?: QueryConfig;\n /**\n * What `useUser()` reports. Defaults to `null` — an anonymous visitor — and\n * either way the hook resolves from here without issuing a request.\n */\n user?: Partial<User> | null;\n /** What `useBreadcrumbs()` returns, in order. */\n breadcrumbs?: Breadcrumb[];\n /**\n * The `route.domains` group the page is served under, as `useDomain()`\n * reports it. Left out, `useDomain()` reads empty — the shape an app without\n * `route.domains` sees — and `useDomain().url()` throws, exactly as it does\n * there.\n *\n * `root` and `origin` default off the host, so the common case is one field:\n * `domain={{ host: \"acme.example.com\", params: { tenant: \"acme\" } }}`.\n */\n domain?: {\n host: string;\n group?: string;\n params?: Record<string, string>;\n custom?: boolean;\n root?: string;\n origin?: string;\n } | null;\n /**\n * What `useFeature()` reports, keyed by feature key. Anything left out reads\n * as off, exactly as an undeclared key does in a real request.\n *\n * A test seeds the *outcome*, not the declaration: `app/features` owns the\n * targeting and the rollout, and re-deriving those here would mean building a\n * request context — a user, a `session_id`, a bot verdict — to assert a\n * branch that only cares which way the feature came out. Cover the targeting\n * where it lives, with a server test.\n */\n features?: Partial<Record<ClientFeatureKey, boolean>>;\n /**\n * The theme `useTheme()` starts on. The app reads a visitor's stored choice\n * out of `localStorage`; a test has no session to have made one in, so this\n * seeds it without writing to storage. `setTheme` works from either.\n */\n theme?: \"light\" | \"dark\" | \"system\";\n /**\n * Fallback for the `Suspense` boundary wrapped around the children — the\n * stand-in for the view's own `Loading` export, which the real router\n * supplies. Defaults to `null`.\n */\n fallback?: ReactNode;\n /**\n * Renders in place of the children when one throws, mirroring a view's\n * `Error` export. Without it a thrown render (an errored suspense query,\n * say) propagates out of `render()` and fails the test, which is usually\n * what you want.\n */\n errorFallback?: ComponentType<FallbackProps>;\n /**\n * Called when something navigates — a `Link` click, `useNavigate().push`.\n * The navigation is reported, not performed: `<Page>` renders one route and\n * does not re-resolve the tree, so `useLocation()` keeps reporting the\n * pathname it was given.\n */\n onNavigate?: (href: string, action: \"push\" | \"replace\") => void;\n}\n\n/** `\"?a=b\"` (or `\"\"`) from any of the shapes `searchParams` accepts. */\nfunction toSearchString(search: PageProps[\"searchParams\"]): string {\n if (!search) return \"\";\n const query =\n typeof search === \"string\"\n ? search.replace(/^\\?/, \"\")\n : new URLSearchParams(\n Object.entries(search).map(([key, value]) => [key, String(value)]),\n ).toString();\n return query ? `?${query}` : \"\";\n}\n\n/**\n * The `:params` a seed key needs supplied. Wildcards (`:rest*`) are excluded —\n * `applyParams` drops those when missing, which is a resolution rather than a\n * failure.\n *\n * Optional params (`:id?`) cannot reach here at all: a key is split at its\n * first `?` to separate the search string, so `\"/lists/:folderId?\"` arrives as\n * the path `/lists/:folderId`. Seed the resolved path for those.\n */\nfunction requiredParamsOf(path: string): string[] {\n return Array.from(path.matchAll(/:([^/]+)/g), ([, name]) => name).filter(\n (name) => !name.endsWith(\"*\"),\n );\n}\n\n/**\n * Fails a `queryData` key whose `:params` the page does not carry, saying so\n * in terms of the key.\n *\n * Without this the two documented runners disagree, and neither is legible.\n * `applyParams` throws `Missing parameter: orgId` under `import.meta.env.DEV`\n * (vitest) — a router-utility stack trace out of `<Page>`'s render, before\n * anything mounts, naming nothing that appears in the test. Under `bun test`\n * that flag is falsy, so it logs and seeds the literal `/orgs/undefined/lists`\n * instead: the seed misses, the query goes to the network, and the assertion\n * runs against a loading state.\n *\n * The case is common because a query's params often come from the call site\n * rather than the route — `useQuery(\"/orgs/:orgId/lists\", { params: { orgId } })`\n * with `orgId` in component state. The cache is keyed by the *resolved* path,\n * so the way out is to seed that path directly.\n */\nfunction resolveSeedPath(\n key: string,\n rawPath: string,\n params: Record<string, string>,\n): string {\n const missing = requiredParamsOf(rawPath).filter(\n (name) => params[name] === undefined,\n );\n if (missing.length > 0) {\n throw new Error(\n `[gemi] <Page> cannot resolve the queryData key \"${key}\": no value for ` +\n `${missing.map((name) => `:${name}`).join(\", \")}. The query cache is ` +\n `keyed by the resolved path, so either add ${missing\n .map((name) => `\\`${name}\\``)\n .join(\", \")} to the page's \\`params\\`, or seed the resolved path ` +\n `(e.g. \"${applyParams(\n rawPath,\n Object.fromEntries(missing.map((name) => [name, \"123\"])),\n )}\") — which is what a query taking its params from component state ` +\n `reads under.`,\n );\n }\n return applyParams(rawPath, params);\n}\n\n/**\n * `queryData` in the shape the query cache seeds from: `{ [path]: { [variant]:\n * data } }`, the same payload `Query.prefetch` puts on a server-rendered page.\n */\nfunction toPrefetchedData(\n queryData: Record<string, unknown>,\n params: Record<string, string>,\n warned: Set<string>,\n) {\n const prefetchedData: Record<string, Record<string, unknown>> = {};\n for (const [key, data] of Object.entries(queryData)) {\n const [rawPath, rawSearch = \"\"] = key.split(\"?\");\n // Once per key per page, not once per render: this runs again on every\n // re-render, and a duplicated warning reads as a second mistake.\n if (rawPath.startsWith(\"/api/\") && !warned.has(key)) {\n warned.add(key);\n console.warn(\n `[gemi] queryData key \"${key}\" starts with /api. useQuery is keyed by ` +\n `the path you pass it — the /api prefix is added when it fetches — ` +\n `so this entry seeds a path no query reads.`,\n );\n }\n const path = resolveSeedPath(key, rawPath, params);\n prefetchedData[path] = {\n ...prefetchedData[path],\n [toVariantKey(rawSearch)]: data,\n };\n }\n return prefetchedData;\n}\n\n/**\n * `{ [locale]: { [dictionary]: { [key]: string } } }` — the payload\n * `Translator` serializes onto the page, which is the only form the client\n * ever sees. `dictionaries` are transposed into it (they are keyed the other\n * way round, by key then locale); `translations` is already in it and lands\n * under `locale`, last, so it wins.\n */\nfunction toClientDictionary(\n dictionaries: PageDictionary[],\n locales: string[],\n locale: string,\n translations: Record<string, Record<string, string>>,\n): Record<string, Record<string, Record<string, string>>> {\n const clientDictionary: Record<\n string,\n Record<string, Record<string, string>>\n > = {};\n for (const supported of locales) {\n clientDictionary[supported] ??= {};\n }\n for (const { name, dictionary } of dictionaries) {\n for (const [key, byLocale] of Object.entries(dictionary ?? {})) {\n for (const [dictLocale, translation] of Object.entries(byLocale ?? {})) {\n clientDictionary[dictLocale] ??= {};\n clientDictionary[dictLocale][name] ??= {};\n clientDictionary[dictLocale][name][key] = translation;\n }\n }\n }\n for (const [name, keys] of Object.entries(translations)) {\n clientDictionary[locale] ??= {};\n clientDictionary[locale][name] = {\n ...clientDictionary[locale][name],\n ...keys,\n };\n }\n return clientDictionary;\n}\n\n/**\n * Mounts a component with the inputs a view normally arrives with — route\n * params, the current locale and its dictionaries, prefetched query data, the\n * signed-in user — so a unit test can assert what it renders rather than only\n * its empty state.\n *\n * ```tsx\n * import { render, screen } from \"@testing-library/react\";\n * import { Page } from \"gemi/testing\";\n *\n * render(\n * <Page\n * pathname=\"/app/:orgId/chat\"\n * params={{ orgId: \"abc\" }}\n * queryData={{ \"/organizations/:orgId/messages\": [{ id: 1, body: \"hi\" }] }}\n * dictionaries={[ChatDictionary]}\n * >\n * <OrgChat />\n * </Page>,\n * );\n *\n * expect(screen.getByText(\"hi\")).toBeDefined();\n * ```\n *\n * It is a plain component, so it composes with any renderer — Testing\n * Library's `render`, `react-test-renderer`, or `renderToString`.\n *\n * Two things it does not do.\n *\n * It does not route: there is no view tree and no route manifest behind it, so\n * a navigation is reported through `onNavigate` rather than resolved. To\n * assert the page *after* one, render a second `<Page>`.\n *\n * And under `renderToString` it renders the server's own no-data branch for an\n * *unseeded* query rather than suspending — deliberately, because suspending\n * there is the streaming server's job: `createRoot` threads the request's\n * `ServerQueryStore` through `ServerQueryContext`, and that store is what runs\n * the route handler. A harness has no request and no handler to run, so there\n * is nothing to suspend on. Seeded queries render their data on the server\n * exactly as they do in the browser; unseeded ones behave as a route with no\n * `Query.prefetch` does, framework warning included.\n */\nexport const Page = (props: PropsWithChildren<PageProps>) => {\n const {\n children,\n pathname: routePath = \"/\",\n params = {},\n searchParams,\n hash = \"\",\n locale = \"en-US\",\n defaultLocale = locale,\n timeZone = \"UTC\",\n dictionaries = [],\n translations = {},\n queryData = {},\n queryConfig,\n user = null,\n breadcrumbs = [],\n domain = null,\n features = {},\n theme,\n fallback = null,\n errorFallback,\n onNavigate,\n } = props;\n\n // The caller's list, in the caller's order — a language switcher maps over\n // it, so hoisting the page's own locale to the front would reorder the\n // rendered options. The defaults are appended, only to guarantee presence.\n const supportedLocales = useMemo(\n () =>\n Array.from(\n new Set([...(props.supportedLocales ?? []), defaultLocale, locale]),\n ),\n [props.supportedLocales, defaultLocale, locale],\n );\n const pathname = applyParams(routePath, params) || \"/\";\n // `root` defaults to the host minus its first label, so a tenant subdomain\n // needs only its host; `origin` to https on that host. Either can be given\n // outright when the test is about the other.\n const domainValue = useMemo(() => {\n if (!domain) {\n return null;\n }\n const labels = domain.host.split(\".\");\n return {\n host: domain.host,\n group: domain.group ?? \"\",\n params: domain.params ?? {},\n custom: domain.custom ?? false,\n root:\n domain.root ?? (labels.length > 2 ? labels.slice(1).join(\".\") : domain.host),\n origin: domain.origin ?? `https://${domain.host}`,\n };\n }, [domain]);\n const search = toSearchString(searchParams);\n // The URL's locale segment, which the default locale does not get.\n const urlLocaleSegment = locale === defaultLocale ? null : locale;\n\n const dictionary = useMemo(\n () =>\n toClientDictionary(dictionaries, supportedLocales, locale, translations),\n [dictionaries, supportedLocales, locale, translations],\n );\n\n // Keys that have already drawn a warning, so a re-render does not repeat it.\n const warnedRef = useRef<Set<string>>(new Set());\n const prefetchedData = useMemo(() => {\n const seeded = toPrefetchedData(queryData, params, warnedRef.current);\n // `useUser` reads `/auth/me` like any other query. Seeding it — with `null`\n // for the anonymous default — is what keeps a component test off the\n // network for a hook nothing in the test asked for.\n seeded[\"/auth/me\"] ??= { \"\": user ?? null };\n return seeded;\n }, [queryData, params, user]);\n\n // Keyed by `${view}:${pathname}` in the router's cache; the view names are\n // ours to choose here, and only their order reaches `useBreadcrumbs`.\n const { breadcrumbViews, breadcrumbsCache, breadcrumbsRecord } =\n useMemo(() => {\n const views = breadcrumbs.map((_, index) => `breadcrumb-${index}`);\n const cache = new Map<string, Breadcrumb>(\n breadcrumbs.map((breadcrumb, index) => [\n `${views[index]}:${pathname}`,\n breadcrumb,\n ]),\n );\n return {\n breadcrumbViews: views,\n breadcrumbsCache: cache,\n breadcrumbsRecord: Object.fromEntries(cache),\n };\n }, [breadcrumbs, pathname]);\n\n const [isNavigatingSubject] = useState(() => new Subject<boolean>(false));\n const [progressManager] = useState(\n () => new ProgressManager(isNavigatingSubject),\n );\n const [history] = useState(() =>\n createMemoryHistory({ initialEntries: [`${pathname}${search}${hash}`] }),\n );\n\n const routeState: RouteState & PageData = useMemo(\n () => ({\n views: [],\n params,\n search,\n state: {},\n pathname,\n hash,\n action: null,\n routePath,\n locale: urlLocaleSegment,\n data: {},\n i18n: {\n currentLocale: locale,\n dictionary,\n supportedLocales,\n defaultLocale,\n timeZone,\n },\n prefetchedData,\n breadcrumbs: breadcrumbsRecord,\n features: features as Record<string, boolean>,\n appId: \"test\",\n }),\n [\n params,\n search,\n pathname,\n hash,\n routePath,\n urlLocaleSegment,\n locale,\n dictionary,\n supportedLocales,\n defaultLocale,\n timeZone,\n prefetchedData,\n breadcrumbsRecord,\n features,\n ],\n );\n\n const [routerSubject] = useState(() => new Subject<RouteState>(routeState));\n\n const onNavigateRef = useRef(onNavigate);\n onNavigateRef.current = onNavigate;\n // Subscribed during render, not in an effect, because React flushes child\n // effects before parent ones — and mount-time navigation is a real pattern:\n // `<Redirect>` pushes from its own mount effect, as does any auth guard. A\n // listener registered in `<Page>`'s effect is not there yet when those fire,\n // so `onNavigate` would silently miss exactly the redirects a test most\n // wants to assert. Ref-guarded, so React's double-invoke registers one.\n //\n // Nothing unsubscribes: this history is created per `<Page>` and reachable\n // from nowhere else, so it is collected with the page it belongs to.\n const listeningRef = useRef(false);\n if (!listeningRef.current) {\n listeningRef.current = true;\n history.listen(({ location, action }) => {\n const href = `${location.pathname}${location.search}${location.hash}`;\n onNavigateRef.current?.(\n href,\n action === Action.Replace ? \"replace\" : \"push\",\n );\n });\n }\n\n const serverData: ServerDataContextValue = useMemo(\n () => ({\n routeManifest: {},\n pageData: {},\n breadcrumbs: breadcrumbsRecord,\n prefetchedData,\n router: {\n pathname,\n params,\n currentPath: routePath,\n is404: false,\n searchParams: search,\n urlLocaleSegment,\n domain: domainValue,\n },\n i18n: {\n dictionary,\n currentLocale: locale,\n supportedLocales,\n defaultLocale,\n timeZone,\n },\n componentTree: [],\n auth: { user: user as User },\n features: features as Record<string, boolean>,\n __csrf: \"test-csrf-token\",\n cssManifest: {},\n modulePreloadManifest: {},\n meta: {},\n appId: \"test\",\n }),\n [\n breadcrumbsRecord,\n prefetchedData,\n pathname,\n params,\n routePath,\n search,\n urlLocaleSegment,\n dictionary,\n locale,\n supportedLocales,\n defaultLocale,\n timeZone,\n user,\n features,\n ],\n );\n\n // Everything the router hooks read, inert: nothing here fetches, preloads or\n // resolves a route, but every hook finds the shape it expects rather than an\n // empty context to crash on.\n const [viewEntriesSubject] = useState(() => new Subject<string[]>([]));\n const routerContext = useMemo(\n () => ({\n viewEntriesSubject,\n history,\n updatePageData: () => {},\n getPageData: () => ({}),\n getScrollPosition: () => 0,\n getViewPathsFromPathname: () => breadcrumbViews,\n getRoutePathnameFromHref: (href: string) => href,\n isNavigatingSubject,\n setNavigationAbortController: () => {},\n progressManager,\n fetchRouteCSS: async () => {},\n preloadRouteModules: () => {},\n prefetchRoute: async () => {},\n takePrefetched: () => null,\n clearPrefetchCache: () => {},\n breadcrumbsCache,\n routerSubject,\n urlLocaleSegment,\n }),\n [\n viewEntriesSubject,\n history,\n breadcrumbViews,\n isNavigatingSubject,\n progressManager,\n breadcrumbsCache,\n routerSubject,\n urlLocaleSegment,\n ],\n );\n\n return (\n <ThemeProvider theme={theme}>\n <ServerDataContext.Provider value={serverData}>\n <I18nProvider>\n <QueryManagerProvider queryConfig={queryConfig}>\n <ClientRouterContext.Provider value={routerContext}>\n <RouteTransitionProvider\n isPending={false}\n isFetching={false}\n transitionPath={[\"\", pathname]}\n >\n <RouteStateProvider state={routeState}>\n <Boundary\n errorFallback={errorFallback}\n fallback={fallback}\n resetKey={pathname}\n >\n {children}\n </Boundary>\n </RouteStateProvider>\n </RouteTransitionProvider>\n </ClientRouterContext.Provider>\n </QueryManagerProvider>\n </I18nProvider>\n </ServerDataContext.Provider>\n </ThemeProvider>\n );\n};\n\n/**\n * The `Suspense` boundary every view renders inside, and — when the test\n * supplies a fallback for it — the error boundary too.\n *\n * `onReset={clearErrors}` is the part that has to be here rather than inline\n * above: it needs `QueryManagerContext`, and it is what makes a view's real\n * `Error` export testable. A fallback whose \"Try again\" calls\n * `resetErrorBoundary()` re-renders the child, and `useQuery` reads the\n * failure still stored on the `QueryResource` and throws it straight back —\n * so without this the fallback never goes away and the retry path that works\n * in the app cannot be exercised. `ClientRouter`'s own boundary wires exactly\n * this pair.\n */\nconst Boundary = (\n props: PropsWithChildren<{\n errorFallback?: ComponentType<FallbackProps>;\n fallback: ReactNode;\n resetKey: string;\n }>,\n) => {\n const { errorFallback: ErrorFallback, fallback, resetKey, children } = props;\n const { clearErrors } = useContext(QueryManagerContext);\n const content = <Suspense fallback={fallback}>{children}</Suspense>;\n\n if (!ErrorFallback) {\n return content;\n }\n\n return (\n <ErrorBoundary\n FallbackComponent={ErrorFallback}\n resetKeys={[resetKey]}\n onReset={clearErrors}\n >\n {content}\n </ErrorBoundary>\n );\n};\n","/**\n * The browser side of islands, shared by the Vite plugin (which builds it), the\n * servers (which point the loader at it) and the tests.\n *\n * No imports: the Vite plugin is built on its own and the servers load it at\n * boot, so this file stays plain strings.\n */\n\n/**\n * The module that hydrates islands: React, `react-dom/client` and the small\n * `h(marker, Component)` below. A virtual module of gemi's Vite plugin that\n * every island entry imports, so the islands on a page share one copy of\n * React, in one chunk.\n */\nexport const ISLAND_RUNTIME_ID = \"virtual:gemi-island-runtime\";\n\n/** What `resolveId` turns `ISLAND_RUNTIME_ID` into (Vite's virtual-module convention). */\nexport const RESOLVED_ISLAND_RUNTIME_ID = `\\0${ISLAND_RUNTIME_ID}`;\n\n/**\n * The query that turns a module into its island entry: `Counter.tsx?gemi-island`\n * is a module of the plugin's that re-exports `Counter.tsx` as `m` next to the\n * runtime's `h`. It is what a static page imports for an island, and so it\n * is what the client manifest lists, keyed `app/…/Counter.tsx?gemi-island`,\n * with React and `react-dom/client` among its imports.\n */\nexport const ISLAND_ENTRY_QUERY = \"?gemi-island\";\n\n/** The island entry module for `file` (an absolute path or a root-relative URL). */\nexport function islandEntrySource(file: string) {\n return `import * as m from ${JSON.stringify(file)};\nexport { m };\nexport { h } from ${JSON.stringify(ISLAND_RUNTIME_ID)};\n`;\n}\n\n/**\n * `h(marker, Component)`: hydrates one `<gemi-island>` marker with the island's\n * component and the props the server serialised into `data-props`.\n *\n * The island's static children were rendered on the server into a\n * `<gemi-slot>` (the first one that belongs to this marker, not to an island\n * nested in it). They are handed back to the component as that same element\n * with the server's HTML, so hydration matches and React leaves them alone.\n *\n * `data-uid` is the `identifierPrefix` the server rendered the island with, so\n * `useId` agrees on both sides and two islands never share an id.\n *\n * Written as a function body with `createElement` and `hydrateRoot` free, so a\n * test can run it against real React without a bundler.\n */\nexport const ISLAND_HYDRATE_SOURCE = `function h(marker, Component) {\n if (typeof Component !== \"function\" && (typeof Component !== \"object\" || Component === null)) {\n throw new Error(\"gemi: island module has no component export for \" + marker.outerHTML.slice(0, 80));\n }\n const json = marker.getAttribute(\"data-props\");\n const props = json ? JSON.parse(json) : {};\n let slot = null;\n for (const candidate of marker.querySelectorAll(\"gemi-slot\")) {\n if (candidate.closest(\"gemi-island\") === marker) {\n slot = candidate;\n break;\n }\n }\n const children = slot\n ? [createElement(\"gemi-slot\", {\n style: { display: \"contents\" },\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: { __html: slot.innerHTML },\n })]\n : [];\n return hydrateRoot(marker, createElement(Component, props, ...children), {\n identifierPrefix: marker.getAttribute(\"data-uid\") || undefined,\n });\n}`;\n\n/** The runtime module's source, as the plugin serves and builds it. */\nexport const ISLAND_RUNTIME_SOURCE = `import { createElement } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nexport ${ISLAND_HYDRATE_SOURCE}\n`;\n\n/**\n * The island loader, inlined into a static document that uses islands.\n *\n * Kept byte-for-byte constant (the per-page island table travels in a\n * separate `<script type=\"application/json\">`, which a Content Security Policy\n * does not treat as script), so a strict policy can allow it by hash:\n * `script-src 'sha256-…'` with `ISLAND_LOADER_CSP_HASH`. Everything it loads\n * is a plain `import()` of a same-origin (or asset-base) file.\n *\n * The table is `{ i: [{ s: entry URL, e: export, l: load }] }` and each\n * marker's `data-island` indexes `i`. Per marker, on its schedule: import the\n * island's entry (the module as `m`, the runtime's `h`), then\n * `h(marker, m[export])`, which calls `hydrateRoot`. A failure is logged and\n * leaves the server-rendered markup in place.\n */\nexport const ISLAND_LOADER_SOURCE =\n 'const d=document,c=JSON.parse(d.getElementById(\"gemi-islands\").textContent),' +\n \"w=f=>(window.requestIdleCallback||setTimeout)(f),\" +\n \"m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};\" +\n 'for(const e of d.querySelectorAll(\"gemi-island\")){const o=c.i[e.dataset.island];if(!o)continue;' +\n 'if(o.l==\"eager\")m(e,o);else if(o.l==\"idle\"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));' +\n \"else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}\";\n","// Generated by `bun scripts/build-static-navigation.ts` from\n// `internal/staticNavigation/runtime.js`. Do not edit; edit the source and regenerate.\n// No imports: `gemi/testing` (a browser bundle) and `gemi stats` read it too.\n\n/** The sha-256 of the source this was built from, so a test can tell it is stale. */\nexport const STATIC_NAVIGATION_SOURCE_HASH = \"38d6cb0484aa686a8b39adf41de1992d084fe0e504fbc0a1da2f066187451bce\";\n\n/**\n * The navigation runtime (with the island loader) a static view with\n * `.static({ navigation })` inlines. Byte-for-byte constant.\n */\nexport const STATIC_NAVIGATION_SOURCE =\n \"var r=document,i=window,a=history;i.__gemi_nav?.d();var L=new AbortController,h=(t,e,n,s)=>t.addEventListener(e,n,{signal:L.signal,...s}),q=i.__gemi_nav={d:()=>L.abort()},v=(t,e)=>{if(!t.g)t.g=1,import(e.s).then((n)=>{if(t.isConnected)t.r=n.h(t,n.m[e.e])}).catch((n)=>console.error(n))},D=(t)=>{let e=t.getElementById(\\\"gemi-islands\\\");return e?JSON.parse(e.textContent):{i:[]}},R=(t,e)=>{for(let n of t.querySelectorAll(\\\"gemi-island\\\")){let s=e.i[n.dataset.island];if(!s||n.o)continue;if(s.l==\\\"eager\\\")v(n,s);else if(s.l==\\\"idle\\\"||!i.IntersectionObserver||!n.children.length)(i.requestIdleCallback||setTimeout)(()=>v(n,s));else{let l=new IntersectionObserver((m)=>{if(m.some((d)=>d.isIntersecting))l.disconnect(),v(n,s)});for(let m of n.children)l.observe(m)}}},O='meta[name=\\\"gemi-static\\\"]',A=\\\"style:not([data-gemi-fonts])\\\",T=A+\\\",link[rel=stylesheet]\\\",K=`head>${A},body>${A},link[rel=stylesheet]`,I='meta[name]:not([name=viewport]),meta[property],link[rel~=canonical],link[rel~=alternate],link[rel~=icon],link[rel=preload][as=font],style[data-gemi-fonts],script[type=\\\"application/ld+json\\\"]',w=(t)=>t.querySelector(O)?.content,C=(t)=>[...t.querySelectorAll(K)].map((e)=>e.outerHTML).join(),c=(t)=>t.href.split(\\\"#\\\")[0],p=r.createElement(\\\"div\\\");p.setAttribute(\\\"aria-live\\\",\\\"polite\\\");p.style.cssText=\\\"position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap\\\";r.body.append(p);var _=(t)=>{q.p={url:location.href,title:r.title,initial:t},r.dispatchEvent(new CustomEvent(\\\"gemi:page-load\\\",{detail:q.p}))},f=new Map,k=(t)=>{let e=f.get(t);if(!e||Date.now()-e[0]>30000){let n=fetch(t,{headers:{accept:\\\"text/html\\\",\\\"x-gemi-navigate\\\":\\\"1\\\"},signal:AbortSignal.timeout(1e4)}).then((s)=>{if(!s.ok||!/^text\\\\/html/.test(s.headers.get(\\\"content-type\\\"))||new URL(s.url||t).origin!=location.origin)throw s;return s.text().then((l)=>[s.url||t,l])});e=[Date.now(),n],n.catch(()=>f.get(t)==e&&f.delete(t))}if(f.delete(t),f.set(t,e),f.size>10)f.delete(f.keys().next().value);return e[1]},M=(t)=>{let e=t.target.closest?.(\\\"a[href]\\\"),n=e?.getAttribute(\\\"target\\\");if(!e||n&&n!=\\\"_self\\\"||e.hasAttribute(\\\"download\\\")||/(^|\\\\s)external(\\\\s|$)/i.test(e.getAttribute(\\\"rel\\\"))||e.closest(\\\"[data-gemi-reload]\\\"))return;let s=new URL(e.getAttribute(\\\"href\\\"),r.baseURI);if(s.origin==location.origin&&!(s.href.includes(\\\"#\\\")&&c(s)==c(location)))return s},y={},U=()=>Math.random().toString(36).slice(2),E=()=>a.state?.g||a.replaceState({...a.state,g:U()},\\\"\\\"),P=c(location),b=0,N=(t)=>{if(!t.hasAttribute(\\\"tabindex\\\"))t.setAttribute(\\\"tabindex\\\",\\\"-1\\\"),t.addEventListener(\\\"blur\\\",()=>t.removeAttribute(\\\"tabindex\\\"),{once:!0});t.focus({preventScroll:!0})},Y=(t)=>{let e=r.body,n=t.body,s=D(t),l=r.documentElement;r.title=t.title;for(let o of[\\\"lang\\\",\\\"dir\\\"]){let u=t.documentElement.getAttribute(o);if(u==null)l.removeAttribute(o);else l.setAttribute(o,u)}for(let o of r.head.querySelectorAll(I))o.remove();let m=new Set([...r.querySelectorAll(\\\"link[rel=modulepreload]\\\")].map((o)=>o.getAttribute(\\\"href\\\")));r.head.append(...t.head.querySelectorAll(I),...[...t.head.querySelectorAll(\\\"link[rel=modulepreload]\\\")].filter((o)=>!m.has(o.getAttribute(\\\"href\\\"))));let d=new Map([...e.querySelectorAll(\\\"[data-gemi-persist]\\\")].map((o)=>[o.dataset.gemiPersist,o])),g=[...n.querySelectorAll(\\\"[data-gemi-persist]\\\")].map((o)=>[o,d.get(o.dataset.gemiPersist)]).filter((o)=>o[1]);for(let o of[...e.querySelectorAll(\\\"gemi-island\\\")].reverse())if(o.o=1,!g.some((u)=>u[1].contains(o)))try{o.r?.unmount()}catch(u){console.error(u)}for(let[o,u]of g)o.replaceWith(u);for(let o of[...e.childNodes])if(!o.matches?.(T))o.remove();for(let o of[...n.children])if(o.matches(T))o.remove();for(let o of[...e.attributes])e.removeAttribute(o.name);for(let o of n.attributes)e.setAttribute(o.name,o.value);e.append(...n.childNodes,p),R(e,s)},H=async(t,e)=>{let n=++b,s=!e&&y[a.state?.g];a.scrollRestoration=\\\"manual\\\";try{let[l,m]=await k(c(t));if(n!=b)return;let d=new DOMParser().parseFromString(m,\\\"text/html\\\");if(w(d)==null||w(d)!=w(r)||C(d)!=C(r))throw 0;if(e){let o=new URL(l);o.hash=t.hash,a.pushState({g:U()},\\\"\\\",o.href)}P=c(location),Y(d);let g=e&&t.hash&&r.getElementById(decodeURIComponent(t.hash.slice(1)));if(g)g.scrollIntoView({behavior:\\\"instant\\\"});else i.scrollTo({left:s?.[0]||0,top:s?.[1]||0,behavior:\\\"instant\\\"});if(e)N(g||r.querySelector(\\\"h1\\\")||r.querySelector(\\\"main\\\")||r.body);p.textContent=r.title,_(!1)}catch{if(n!=b)return;if(e)location.assign(t.href);else location.reload()}};h(r,\\\"click\\\",(t)=>{if(t.defaultPrevented||t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=M(t);if(e&&r.dispatchEvent(new CustomEvent(\\\"gemi:before-navigate\\\",{cancelable:!0,detail:{url:e.href}})))t.preventDefault(),E(),y[a.state.g]=[i.scrollX,i.scrollY],H(e,1)});h(i,\\\"popstate\\\",()=>{if(b++,c(location)==P){let t=y[a.state?.g];if(t)i.scrollTo({left:t[0],top:t[1],behavior:\\\"instant\\\"})}else if(a.state?.g)H(new URL(location.href),0);else location.reload()});h(i,\\\"hashchange\\\",E);h(i,\\\"scroll\\\",()=>a.state?.g&&(y[a.state.g]=[i.scrollX,i.scrollY]),{passive:!0});var S,x=(t)=>{if(r.querySelector(O)?.dataset.prefetch==\\\"none\\\"||navigator.connection?.saveData)return;let e=M(t);if(e&&c(e)!=c(location))k(c(e))};h(r,\\\"pointerover\\\",(t)=>{clearTimeout(S),S=setTimeout(()=>x(t),65)});h(r,\\\"pointerout\\\",()=>clearTimeout(S));h(r,\\\"focusin\\\",x);h(r,\\\"touchstart\\\",x,{passive:!0});E();R(r,D(r));_(!0);\";\n","import { createElement } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nimport { ISLAND_HYDRATE_SOURCE } from \"../internal/islandRuntime\";\nimport { STATIC_NAVIGATION_SOURCE } from \"../internal/staticNavigationRuntime\";\n\n/**\n * One page `renderStaticDocument` serves to the navigation runtime: its HTML, or\n * a response of another kind to see the runtime fall back to a full load.\n */\nexport interface StaticTestPage {\n html?: string;\n /** Default 200. */\n status?: number;\n /** Default `text/html; charset=utf-8`. */\n contentType?: string;\n /** The URL the response ends at, as after a redirect. Default: the one asked for. */\n url?: string;\n}\n\nexport interface StaticDocumentOptions {\n /** The document's URL, resolved against the test window's origin. Default `/`. */\n url?: string;\n /**\n * What the runtime's `fetch` gets, by path (`/about`, `/about?x=1`) or full\n * URL: HTML, a `StaticTestPage`, or a function for anything else. A URL\n * not listed is a 404.\n */\n pages?:\n | Record<string, string | StaticTestPage>\n | ((url: URL) => string | StaticTestPage | Promise<string | StaticTestPage>);\n /**\n * The island modules, by the entry URL the page's island table names (`s`):\n * each a module whose exports include the islands' components. Hydrated\n * with React, as `<module>?gemi-island` would.\n */\n islands?: Record<string, Record<string, unknown>>;\n}\n\n/** How a navigation ended. */\nexport type StaticNavigationResult =\n /** The runtime swapped the fetched page in. */\n | { kind: \"swap\"; url: string }\n /** The runtime gave up on a swap and asked for a full page load of `url`. */\n | { kind: \"full-load\"; url: string }\n /** The runtime left the click alone: the browser would follow the link itself. */\n | { kind: \"native\" };\n\nexport interface StaticDocumentHandle {\n /**\n * Clicks the page's first `<a>` whose `href` attribute is `href` and waits\n * for the outcome. Throws when there is no such link.\n */\n navigate(href: string, init?: MouseEventInit): Promise<StaticNavigationResult>;\n /** `history.back()`, and waits for the runtime to show that entry. */\n back(): Promise<StaticNavigationResult>;\n /** Every URL the runtime fetched, prefetches included, in order. */\n requests: string[];\n /** Every full page load the runtime asked for. */\n fullLoads: string[];\n /** Stops the runtime and restores what the helper stubbed. */\n dispose(): void;\n}\n\nconst hydrate = new Function(\n \"createElement\",\n \"hydrateRoot\",\n `${ISLAND_HYDRATE_SOURCE};return h;`,\n)(createElement, hydrateRoot) as (marker: Element, component: unknown) => unknown;\n\n/**\n * Puts a static document (`.static({ navigation })`) into the test's DOM and\n * starts its navigation runtime against stubbed pages, so a test can check that\n * a site's links are followed client-side, and what the next page looks like.\n * Needs a DOM (`// @vitest-environment jsdom`).\n *\n * ```ts\n * const html = await (await render(\"/\")).text(); // the page, from your app\n * const page = renderStaticDocument(html, { pages: { \"/about\": aboutHtml } });\n * expect(await page.navigate(\"/about\")).toEqual({ kind: \"swap\", url: \"http://localhost:3000/about\" });\n * expect(document.querySelector(\"h1\")!.textContent).toBe(\"About\");\n * page.dispose();\n * ```\n *\n * The document's own scripts do not run (the helper runs the runtime itself),\n * and a link the runtime leaves alone is not followed. Islands hydrate\n * asynchronously, as in a browser: wrap what follows in `act`, or wait for it.\n */\nexport function renderStaticDocument(\n html: string,\n options: StaticDocumentOptions = {},\n): StaticDocumentHandle {\n const requests: string[] = [];\n const fullLoads: string[] = [];\n let settle: ((result: StaticNavigationResult) => void) | undefined;\n const outcome = () =>\n new Promise<StaticNavigationResult>((resolve, reject) => {\n const timer = setTimeout(() => reject(new Error(\"the navigation did not finish in 5 s\")), 5000);\n settle = (result) => {\n clearTimeout(timer);\n settle = undefined;\n resolve(result);\n };\n });\n\n history.replaceState(null, \"\", options.url ?? \"/\");\n const parsed = new DOMParser().parseFromString(html, \"text/html\");\n for (const script of Array.from(parsed.querySelectorAll(\"script\"))) {\n if (!/json/.test(script.type)) script.remove();\n }\n document.replaceChild(document.importNode(parsed.documentElement, true), document.documentElement);\n\n const fullLoad = (url: string) => {\n fullLoads.push(url);\n settle?.({ kind: \"full-load\", url });\n };\n const location = {\n get href() {\n return window.location.href;\n },\n get origin() {\n return window.location.origin;\n },\n assign: (url: string) => fullLoad(new URL(url, window.location.href).href),\n reload: () => fullLoad(window.location.href),\n };\n\n const pages = options.pages ?? {};\n const fetch = async (input: string) => {\n const url = new URL(input, window.location.href);\n requests.push(url.href);\n const page =\n typeof pages === \"function\"\n ? await pages(url)\n : (pages[url.href] ?? pages[url.pathname + url.search]);\n const spec: StaticTestPage =\n page === undefined\n ? { status: 404, html: \"not found\", contentType: \"text/plain\" }\n : typeof page === \"string\"\n ? { html: page }\n : page;\n const response = new Response(spec.html ?? \"\", {\n status: spec.status ?? 200,\n headers: { \"content-type\": spec.contentType ?? \"text/html; charset=utf-8\" },\n });\n Object.defineProperty(response, \"url\", { value: new URL(spec.url ?? url.href, url).href });\n return response;\n };\n\n const importIsland = async (src: string) => {\n const module = options.islands?.[src];\n if (!module) throw new Error(`renderStaticDocument: no island module for ${src} in options.islands`);\n return { m: module, h: hydrate };\n };\n\n // The runtime announces a click it takes with `gemi:before-navigate`; one\n // it does not take (or one a listener cancelled) is the browser's, which\n // jsdom would try (and fail) to follow, so it is stopped here, on `window`,\n // after every listener on the way.\n let announced: Event | undefined;\n const onBeforeNavigate = (event: Event) => {\n announced = event;\n };\n document.addEventListener(\"gemi:before-navigate\", onBeforeNavigate);\n const onClick = (event: Event) => {\n const taken = announced !== undefined && !announced.defaultPrevented;\n announced = undefined;\n if (taken || !(event.target as Element).closest?.(\"a[href]\")) return;\n event.preventDefault();\n settle?.({ kind: \"native\" });\n };\n window.addEventListener(\"click\", onClick);\n const onPageLoad = (event: Event) => {\n const detail = (event as CustomEvent<{ url: string; initial: boolean }>).detail;\n if (!detail.initial) settle?.({ kind: \"swap\", url: detail.url });\n };\n document.addEventListener(\"gemi:page-load\", onPageLoad);\n\n // Not implemented by jsdom.\n const scrollTo = window.scrollTo;\n window.scrollTo = () => {};\n const scrollIntoView = Element.prototype.scrollIntoView;\n Element.prototype.scrollIntoView = function () {};\n\n const source = STATIC_NAVIGATION_SOURCE.replace(\"import(\", \"__import(\");\n new Function(\"__import\", \"location\", \"fetch\", source)(importIsland, location, fetch);\n\n return {\n requests,\n fullLoads,\n async navigate(href, init) {\n const link = Array.from(document.querySelectorAll(\"a[href]\")).find(\n (a) => a.getAttribute(\"href\") === href,\n );\n if (!link) throw new Error(`renderStaticDocument: no <a href=\"${href}\"> on the page`);\n const done = outcome();\n link.dispatchEvent(new MouseEvent(\"click\", { bubbles: true, cancelable: true, ...init }));\n return await done;\n },\n async back() {\n const done = outcome();\n history.back();\n return await done;\n },\n dispose() {\n (window as unknown as { __gemi_nav?: { d: () => void } }).__gemi_nav?.d();\n window.removeEventListener(\"click\", onClick);\n document.removeEventListener(\"gemi:before-navigate\", onBeforeNavigate);\n document.removeEventListener(\"gemi:page-load\", onPageLoad);\n window.scrollTo = scrollTo;\n Element.prototype.scrollIntoView = scrollIntoView;\n },\n };\n}\n"],"mappings":";;;;;;;AA6LA,SAAS,eAAe,QAA2C;CACjE,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM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QAAQ,WAAW,WAAW;CACtE,IAAI,SAAS,YAAY,YAAY,SAAS,MAAM,CAAC,CAAC,cAAc,UAAU,KAAK;CAEnF,OAAO;EACL;EACA;EACA,MAAM,SAAS,MAAM,MAAM;GACzB,MAAM,OAAO,MAAM,KAAK,SAAS,iBAAiB,SAAS,CAAC,CAAC,CAAC,MAC3D,MAAM,EAAE,aAAa,MAAM,MAAM,IACpC;GACA,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,qCAAqC,KAAK,eAAe;GACpF,MAAM,OAAO,QAAQ;GACrB,KAAK,cAAc,IAAI,WAAW,SAAS;IAAE,SAAS;IAAM,YAAY;IAAM,GAAG;GAAK,CAAC,CAAC;GACxF,OAAO,MAAM;EACf;EACA,MAAM,OAAO;GACX,MAAM,OAAO,QAAQ;GACrB,QAAQ,KAAK;GACb,OAAO,MAAM;EACf;EACA,UAAU;GACR,OAA0D,YAAY,EAAE;GACxE,OAAO,oBAAoB,SAAS,OAAO;GAC3C,SAAS,oBAAoB,wBAAwB,gBAAgB;GACrE,SAAS,oBAAoB,kBAAkB,UAAU;GACzD,OAAO,WAAW;GAClB,QAAQ,UAAU,iBAAiB;EACrC;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.120.0",
3
+ "version": "0.120.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",