@timber-js/app 0.2.0-alpha.249 → 0.2.0-alpha.250

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.
Files changed (100) hide show
  1. package/dist/_chunks/{actions-C7_xl9iA.js → actions-DH_TCxJb.js} +2 -2
  2. package/dist/_chunks/{actions-C7_xl9iA.js.map → actions-DH_TCxJb.js.map} +1 -1
  3. package/dist/_chunks/dev-span-0aG7Q_Ph.js.map +1 -1
  4. package/dist/_chunks/{dist-GyaJm4GA.js → dist-ob734WH3.js} +20 -19
  5. package/dist/_chunks/dist-ob734WH3.js.map +1 -0
  6. package/dist/_chunks/{error-boundary-wuNvAJ4n.js → error-boundary-BR21tTQc.js} +3 -3
  7. package/dist/_chunks/{error-boundary-wuNvAJ4n.js.map → error-boundary-BR21tTQc.js.map} +1 -1
  8. package/dist/_chunks/global-context-DbxNWeBP.js +47 -0
  9. package/dist/_chunks/global-context-DbxNWeBP.js.map +1 -0
  10. package/dist/_chunks/{navigation-root-Cvb7P1ud.js → navigation-root-AuCD35Sv.js} +42 -47
  11. package/dist/_chunks/navigation-root-AuCD35Sv.js.map +1 -0
  12. package/dist/_chunks/ssr-data-BfsCqCLl.js +47 -0
  13. package/dist/_chunks/ssr-data-BfsCqCLl.js.map +1 -0
  14. package/dist/client/browser-entry/post-hydration.d.ts +2 -2
  15. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
  16. package/dist/client/browser-entry/scroll.d.ts +11 -8
  17. package/dist/client/browser-entry/scroll.d.ts.map +1 -1
  18. package/dist/client/error-boundary.js +1 -1
  19. package/dist/client/index.js +12 -9
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/internal.d.ts +0 -2
  22. package/dist/client/internal.d.ts.map +1 -1
  23. package/dist/client/internal.js +6 -6
  24. package/dist/client/internal.js.map +1 -1
  25. package/dist/client/link.d.ts.map +1 -1
  26. package/dist/client/ssr-data.d.ts +35 -38
  27. package/dist/client/ssr-data.d.ts.map +1 -1
  28. package/dist/client/state.d.ts +1 -8
  29. package/dist/client/state.d.ts.map +1 -1
  30. package/dist/client/use-cookie.d.ts.map +1 -1
  31. package/dist/client/use-search-params.d.ts.map +1 -1
  32. package/dist/cookies/index.js +3 -3
  33. package/dist/cookies/index.js.map +1 -1
  34. package/dist/native/rsc/client/global-context.js +20 -0
  35. package/dist/native/rsc/client/global-context.js.map +1 -0
  36. package/dist/native/rsc/client/ssr-data.js +9 -4
  37. package/dist/native/rsc/client/ssr-data.js.map +1 -1
  38. package/dist/native/rsc/client/use-cookie.js +4 -4
  39. package/dist/native/rsc/client/use-cookie.js.map +1 -1
  40. package/dist/native/rsc/manifest.json +1 -1
  41. package/dist/native/rsc/server/build-manifest.js +1 -4
  42. package/dist/native/rsc/server/build-manifest.js.map +1 -1
  43. package/dist/native/rsc/server/html-injectors.js +6 -7
  44. package/dist/native/rsc/server/html-injectors.js.map +1 -1
  45. package/dist/native/rsc/server/react-cache-bridge.js +2 -2
  46. package/dist/native/rsc/server/react-cache-bridge.js.map +1 -1
  47. package/dist/native/rsc/server/rsc-entry/render-route.js +3 -5
  48. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
  49. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js +3 -2
  50. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js.map +1 -1
  51. package/dist/native/ssr/client/link.js +10 -8
  52. package/dist/native/ssr/client/link.js.map +1 -1
  53. package/dist/native/ssr/client/ssr-data.js +10 -6
  54. package/dist/native/ssr/client/ssr-data.js.map +1 -1
  55. package/dist/native/ssr/client/state.js +1 -5
  56. package/dist/native/ssr/client/state.js.map +1 -1
  57. package/dist/native/ssr/client/use-cookie.js +2 -2
  58. package/dist/native/ssr/client/use-cookie.js.map +1 -1
  59. package/dist/native/ssr/client/use-search-params.js +3 -2
  60. package/dist/native/ssr/client/use-search-params.js.map +1 -1
  61. package/dist/native/ssr/server/ssr-wrappers.js +11 -4
  62. package/dist/native/ssr/server/ssr-wrappers.js.map +1 -1
  63. package/dist/server/build-manifest.d.ts +0 -7
  64. package/dist/server/build-manifest.d.ts.map +1 -1
  65. package/dist/server/html-injectors.d.ts +5 -4
  66. package/dist/server/html-injectors.d.ts.map +1 -1
  67. package/dist/server/index.js +1 -1
  68. package/dist/server/internal.js +1 -1
  69. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  70. package/dist/server/rsc-entry/ssr-renderer.d.ts +2 -0
  71. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  72. package/dist/server/ssr-bridge-types.d.ts +6 -0
  73. package/dist/server/ssr-bridge-types.d.ts.map +1 -1
  74. package/dist/server/ssr-entry.d.ts.map +1 -1
  75. package/dist/server/ssr-wrappers.d.ts +14 -9
  76. package/dist/server/ssr-wrappers.d.ts.map +1 -1
  77. package/package.json +5 -5
  78. package/src/client/browser-entry/post-hydration.ts +27 -22
  79. package/src/client/browser-entry/scroll.ts +12 -9
  80. package/src/client/internal.ts +0 -4
  81. package/src/client/link.tsx +14 -13
  82. package/src/client/ssr-data.ts +50 -57
  83. package/src/client/state.ts +1 -14
  84. package/src/client/use-cookie.ts +4 -3
  85. package/src/client/use-search-params.ts +5 -4
  86. package/src/server/build-manifest.ts +0 -10
  87. package/src/server/html-injectors.ts +11 -13
  88. package/src/server/rsc-entry/render-route.ts +9 -8
  89. package/src/server/rsc-entry/ssr-renderer.ts +4 -1
  90. package/src/server/ssr-bridge-types.ts +6 -0
  91. package/src/server/ssr-entry.ts +180 -207
  92. package/src/server/ssr-wrappers.tsx +52 -14
  93. package/dist/_chunks/dist-GyaJm4GA.js.map +0 -1
  94. package/dist/_chunks/navigation-root-Cvb7P1ud.js.map +0 -1
  95. package/dist/_chunks/ssr-data-9hPtcNOr.js +0 -48
  96. package/dist/_chunks/ssr-data-9hPtcNOr.js.map +0 -1
  97. package/dist/_chunks/state-B-EBjeER.js +0 -49
  98. package/dist/_chunks/state-B-EBjeER.js.map +0 -1
  99. package/dist/native/rsc/client/state.js +0 -14
  100. package/dist/native/rsc/client/state.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-root-Cvb7P1ud.js","names":[],"sources":["../../src/client/router-ref.ts","../../src/client/global-context.ts","../../src/client/navigation-context.ts","../../src/client/router-url.ts","../../src/client/use-pending-navigation.ts","../../src/client/navigation-root.tsx"],"sourcesContent":["// Global router reference — shared between browser-entry and client hooks.\n//\n// Delegates to client/state.ts for the actual module-level variable.\n// This ensures singleton semantics regardless of import path — all\n// callers converge on the same state.ts instance via the barrel.\n//\n// See design/18-build-system.md §\"Module Singleton Strategy\"\n\nimport type { RouterInstance } from './router-types.ts';\nimport { globalRouter, _setGlobalRouter } from './state.ts';\n\n/**\n * Set the global router instance. Called once during bootstrap.\n */\nexport function setGlobalRouter(router: RouterInstance): void {\n _setGlobalRouter(router);\n}\n\n/**\n * Get the global router instance. Throws if called before bootstrap.\n * Used by client-side hooks (usePendingNavigation, etc.)\n */\nexport function getRouter(): RouterInstance {\n if (!globalRouter) {\n throw new Error('[timber] Router not initialized. getRouter() was called before bootstrap().');\n }\n return globalRouter;\n}\n\n/**\n * Get the global router instance or null if not yet initialized.\n * Used by useRouter() methods to avoid silent failures — callers\n * can log a meaningful warning instead of silently no-oping.\n */\nexport function getRouterOrNull(): RouterInstance | null {\n return globalRouter;\n}\n\n/**\n * Reset the global router to null. Used only in tests to isolate\n * module-level state between test cases.\n * @internal\n */\nexport function resetGlobalRouter(): void {\n _setGlobalRouter(null);\n}\n","/**\n * createGlobalContext — a React context with a process-wide singleton identity.\n *\n * SINGLETON GUARANTEE: Uses globalThis + Symbol.for — same pattern as\n * NavigationContext. The RSC client bundler can duplicate a module across\n * chunks (browser-entry graph + client-reference graph). With ESM output,\n * each chunk gets its own module scope — a bare createContext at module\n * level would create separate instances per chunk. globalThis guarantees a\n * single instance regardless of duplication.\n *\n * One context per React instance, not per process. Duplicated chunks share\n * one React, so they share the context. A dev SSR program reload evaluates\n * React and react-dom/server again, in the same process: the new renderer\n * must get a context of its own. Handed the previous one, React logs\n * \"Detected multiple renderers concurrently rendering the same context\n * provider\" on every client-component edit, and the stale context keeps a\n * piece of the discarded copy alive (TIM-1590).\n *\n * See design/19-client-navigation.md §\"Singleton Guarantee via globalThis\"\n */\n\nimport React from 'react';\n\n/** The part of a React instance a context comes from. */\nexport interface ContextFactory {\n createContext?: typeof React.createContext;\n}\n\n/**\n * The context `key` names for this React instance, created on first use.\n * Pass the key as a `Symbol.for('…')` literal at the call site, so each key\n * stays greppable in the build output (tests/bundle-singleton-audit.test.ts\n * checks `__timber_nav_ctx`).\n */\nexport function createGlobalContext<T>(key: symbol, defaultValue: T): React.Context<T> {\n return createGlobalContextFor(React, key, defaultValue);\n}\n\n/** createGlobalContext for a given React instance. Exported for tests. */\nexport function createGlobalContextFor<T>(\n react: ContextFactory,\n key: symbol,\n defaultValue: T\n): React.Context<T> {\n if (typeof react.createContext !== 'function') {\n // RSC environment — createContext not available. Return a dummy that\n // won't be used (the consumers only render on the client / during SSR).\n return undefined as unknown as React.Context<T>;\n }\n const slot: unknown = Reflect.get(globalThis, key);\n const byReact = slot instanceof WeakMap ? slot : new WeakMap<object, React.Context<T>>();\n if (byReact !== slot) Reflect.set(globalThis, key, byReact);\n let ctx: React.Context<T> | undefined = byReact.get(react);\n if (!ctx) {\n ctx = react.createContext<T>(defaultValue);\n byReact.set(react, ctx);\n }\n return ctx;\n}\n","'use client';\n\n/**\n * NavigationContext — React context for navigation state.\n *\n * Holds the current pathname and search, updated atomically with the RSC\n * tree on each navigation. This replaces the previous useSyncExternalStore\n * approach for usePathname() and useSearchParams(), which suffered from a\n * timing gap: the new tree could commit before the external store\n * re-renders fired, causing a frame where both old and new active states\n * were visible simultaneously.\n *\n * Segment params are NOT here — see the note on NavigationState below.\n *\n * By wrapping the RSC payload element in NavigationProvider inside the\n * router's `renderTree` (browser-entry/router-init.ts), the context value and the element tree are passed to\n * reactRoot.render() in the same call — atomic by construction.\n * All consumers (usePathname, useSearchParams) see the new values in the\n * same render pass as the new tree.\n *\n * During SSR, the wrapper chain mounts this same provider with the\n * request's pathname and raw search string (TIM-1424), so the hooks\n * resolve through the identical code path on both sides. Per-request\n * isolation is by construction — the value is part of the request's\n * element tree.\n *\n * This module is `'use client'` and is never evaluated in the RSC\n * environment. The shims plugin resolves next/navigation to\n * navigation-rsc.ts in RSC, which has throwing stubs (TIM-1420).\n *\n * SINGLETON GUARANTEE: All shared mutable state uses globalThis via\n * Symbol.for keys. The RSC client bundler can duplicate this module\n * across chunks (browser-entry graph + client-reference graph). With\n * ESM output, each chunk gets its own module scope — module-level\n * variables would create separate singleton instances per chunk.\n * globalThis guarantees a single instance regardless of duplication.\n *\n * This workaround will be removed when Rolldown ships `format: 'app'`\n * (module registry format that deduplicates like webpack/Turbopack).\n * See design/27-chunking-strategy.md.\n *\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport { useContext, createElement, type ReactNode } from 'react';\nimport { createGlobalContext } from './global-context.ts';\n\n// ---------------------------------------------------------------------------\n// Context type\n// ---------------------------------------------------------------------------\n\n/**\n * What the browser knows about the current location.\n *\n * Params are deliberately absent: they are a property of the tree the server\n * rendered, not of the address bar, and they now travel inside the payload as\n * the payload root. Keeping a copy here meant the router had to thread\n * the record from a response header into context on every path — navigation,\n * traversal, prefetch, revalidation — and each of those was a place to drop it\n * (TIM-1294).\n */\nexport interface NavigationState {\n pathname: string;\n search: string;\n}\n\n// ---------------------------------------------------------------------------\n// Lazy context initialization\n// ---------------------------------------------------------------------------\n\n/**\n * Context instances are stored on globalThis (NOT in module-level\n * variables) because the ESM bundler can duplicate this module across\n * chunks. Module-level variables would create separate instances per\n * chunk — the provider in NavigationRoot (index chunk) would use\n * context A while the consumer in usePendingNavigation (shared chunk)\n * reads from context B. globalThis guarantees a single instance.\n *\n * This module is `'use client'` so it is never evaluated in the RSC\n * environment — `createContext` and `useContext` are always available.\n * The shims plugin resolves next/navigation to navigation-rsc.ts in RSC,\n * which has throwing stubs for the hooks (TIM-1420).\n *\n * See design/19-client-navigation.md §\"Singleton Guarantee via globalThis\"\n *\n * Exported for `usePendingNavigation(select)`, which reads it with React\n * `use()` — only in its selector form, so the plain form does not re-render\n * on every commit.\n */\nexport function getOrCreateContext(): import('react').Context<NavigationState | null> {\n return createGlobalContext<NavigationState | null>(Symbol.for('__timber_nav_ctx'), null);\n}\n\n/**\n * Read the navigation context. Returns null only when no provider is above\n * the caller — a component rendered outside the timber app.\n *\n * Internal — used by usePathname() and useSearchParams().\n */\nexport function useNavigationContext(): NavigationState | null {\n return useContext(getOrCreateContext());\n}\n\n// ---------------------------------------------------------------------------\n// Provider component\n// ---------------------------------------------------------------------------\n\nexport interface NavigationProviderProps {\n value: NavigationState;\n children?: ReactNode;\n}\n\n/**\n * Wraps children with NavigationContext.Provider.\n *\n * Used in browser-entry/router-init.ts `renderTree` to wrap the RSC payload element\n * so that navigation state updates atomically with the tree render.\n */\nexport function NavigationProvider({\n value,\n children,\n}: NavigationProviderProps): import('react').ReactElement {\n return createElement(getOrCreateContext().Provider, { value }, children);\n}\n\n// ---------------------------------------------------------------------------\n// Pending navigation state lives in the router, not here\n// ---------------------------------------------------------------------------\n\n/**\n * There was a second React context here — `PendingNavigationContext`, holding\n * the in-flight navigation URL, provided by `NavigationRoot` out of a\n * `useState` — plus a `usePendingNavigationUrl()` reader for it. Both are gone\n * (TIM-1307).\n *\n * Nothing read them. `usePendingNavigation()` (use-pending-navigation.ts) and\n * `TopLoader` both subscribe to the router's external pending store via\n * `useSyncExternalStore`: sync priority, immune to transition entanglement,\n * and cleared by `runNavigation`'s supersession-guarded `finally` (TIM-1034).\n * The context was a parallel representation of the same fact that no consumer\n * ever migrated to, and one that could not even agree with the store — a\n * navigation superseded by a cached popstate replay left its URL set until the\n * next full navigation, because the staleness guard skipped the clear and no\n * other path touched it.\n *\n * One representation, and it is the router's. See\n * design/19-client-navigation.md §\"How Pending State Works\".\n */\n","/**\n * How the client router reads the URLs it is handed.\n *\n * One parser, so the places that key or compare by URL — the history stack,\n * the navigation state a page renders with, the departing page sent as\n * `X-Timber-URL` — cannot disagree about what a URL says. They did: a\n * history entry stored under `navigate('/café')`'s spelling was looked up\n * under the address bar's `/caf%C3%A9`, and missed (TIM-1541).\n */\n\nconst BASE = 'http://localhost';\n\n/**\n * Parse a router URL. A URL that starts with \"/\" is a path — including one\n * that starts with \"//\": that is the pathname a document at\n * `https://host//a/b` reports, and resolved against a base it would parse as\n * a scheme-relative reference to host `a`. Anything else resolves against a\n * placeholder origin, so an absolute URL keeps its own.\n */\nexport function parseRouterUrl(url: string): URL {\n return url.startsWith('/') ? new URL(BASE + url) : new URL(url, BASE);\n}\n\n/**\n * The spelling a URL is stored and looked up under: the browser's own\n * pathname + search, so `/a?` and `/a`, `/café` and `/caf%C3%A9`, are one\n * key. The fragment is dropped — it is client-only.\n */\nexport function routerUrlKey(url: string): string {\n const parsed = parseRouterUrl(url);\n return parsed.pathname + parsed.search;\n}\n","import { use, useMemo, useRef, useSyncExternalStore } from 'react';\nimport { getOrCreateContext } from './navigation-context.ts';\nimport { getRouterOrNull } from './router-ref.ts';\nimport { parseRouterUrl } from './router-url.ts';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const router = getRouterOrNull();\n if (!router) return () => {};\n return router.onPendingChange(onStoreChange);\n}\n\nfunction isPending(): boolean {\n const router = getRouterOrNull();\n return router ? router.isPending() : false;\n}\n\nconst HAS_SCHEME = /^[a-z][a-z\\d+.-]*:/i;\n\n/**\n * A router URL as a `URL`, read the way the router reads it (`parseRouterUrl`)\n * so `to` names the page the router will commit. Anything without a scheme is\n * a path on this document's origin; an absolute URL keeps its own.\n */\nfunction pageUrl(url: string): URL {\n const parsed = parseRouterUrl(url);\n if (HAS_SCHEME.test(url)) return parsed;\n return new URL(window.location.origin + parsed.pathname + parsed.search + parsed.hash);\n}\n\n/**\n * Decides what a component wants to know about the navigation in flight.\n *\n * `to` is where the router is going, with the `#fragment` of a link or\n * `router.push()` that has one (traversals and refreshes carry none). `from`\n * is the page the navigation departs from, as the calling component rendered\n * it — not the address bar, which on Back/Forward has already moved. Both are\n * fresh `URL`s; don't mutate them.\n */\nexport type PendingNavigationSelector<T> = (to: URL, from: URL) => T;\n\n/**\n * Whether an RSC navigation is in flight — until its payload has decoded and\n * React has committed the destination, so it never turns false while the\n * departing page is still on screen.\n *\n * Reads the router's external pending store via `useSyncExternalStore`, so\n * only components that call this hook re-render when a navigation starts or\n * ends.\n *\n * ```tsx\n * 'use client'\n * import { usePendingNavigation } from '@timber-js/app/client'\n *\n * export function NavBar() {\n * const isPending = usePendingNavigation()\n * return <nav className={isPending ? 'opacity-50' : ''}>…</nav>\n * }\n * ```\n */\nexport function usePendingNavigation(): boolean;\n/**\n * The selector form: `select(to, from)` while a navigation is in flight,\n * `false` when none is. A navigation starting, being superseded or ending\n * re-renders the component only when the result changes (`Object.is`), so\n * return a primitive. The selector form also re-renders on commits, as\n * `usePathname()` does. A superseded navigation reports the newest target; a\n * followed redirect reports the redirect's destination.\n *\n * ```tsx\n * // Dim a list only while its own sort/filter/page navigation is in flight.\n * const replacing = usePendingNavigation((to, from) => to.pathname === from.pathname)\n * ```\n *\n * See design/19-client-navigation.md §\"Where the navigation is going\".\n */\nexport function usePendingNavigation<T>(select: PendingNavigationSelector<T>): T | false;\nexport function usePendingNavigation<T>(select?: PendingNavigationSelector<T>): T | boolean {\n // Read only by the selector form, so the plain form — TopLoader, a global\n // spinner — does not re-render on every commit.\n const nav = select ? use(getOrCreateContext()) : null;\n if (select && nav === null) {\n throw new Error(\n '[timber] usePendingNavigation(select) was called outside the timber app tree ' +\n '(no NavigationProvider found). In tests, render the component ' +\n 'inside the timber providers.'\n );\n }\n const rendered = nav ? nav.pathname + nav.search : null;\n\n // The page each navigation departs from: what this component was rendering\n // when it first saw the target. Held for the navigation's lifetime because\n // the location context moves to the destination at its commit, while the\n // router is still pending — read live, a link away would report \"same page\"\n // for that commit and for any streaming tail after it.\n const departure = useRef<{ target: string; from: string } | null>(null);\n\n const getSnapshot = useMemo((): (() => T | boolean) => {\n if (!select || rendered === null) return isPending;\n // `getSnapshot` must return the same value for the same store state, and\n // a selector returning `to` would otherwise hand React a new URL per call.\n let last: { target: string; from: string; value: T } | null = null;\n return () => {\n const target = getRouterOrNull()?.getPendingUrl() ?? null;\n if (target === null) {\n departure.current = null;\n return false;\n }\n if (departure.current?.target !== target) departure.current = { target, from: rendered };\n const from = departure.current.from;\n if (last?.target !== target || last.from !== from) {\n last = { target, from, value: select(pageUrl(target), pageUrl(from)) };\n }\n return last.value;\n };\n }, [select, rendered]);\n\n // The same read on the server: no router there, so it reports idle.\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * NavigationRoot — the component the router renders the page through.\n *\n * It is stateless. The router owns the displayed tree and drives React with\n * `root.render(<NavigationRoot rendered={{ element, publish }} />)` inside a\n * synchronous `startTransition` (see `client/react-root.ts`). A transition\n * update keeps the committed tree on screen while the incoming one resolves,\n * instead of replacing it with a Suspense fallback — the reason this\n * component exists (TIM-1306).\n *\n * It used to hold the tree in `useState` and register `setState` closures\n * into module globals during render so the router could reach into it, with a\n * second set of stand-in closures for the window before a root existed\n * (TIM-600). Inverting that — router calls React, not the reverse — deleted\n * all of it (TIM-1431). Next.js's `use-action-queue.ts` says it wants this\n * shape and cannot have it because it must decode Flight during render;\n * timber decodes in `router-pipeline.ts`, so nothing stands in the way.\n *\n * What this component does own is **the commit-time publish**: a navigation's\n * state (segment cache, address bar, history stack, pathname) is published\n * from a layout effect keyed on the tree object, so the event that puts a\n * route on screen is the event that makes it current (TIM-1301). Props work\n * for that exactly as state did.\n *\n * This component holds no pending state. The `TopLoader` it renders and the\n * public `usePendingNavigation()` both subscribe to the router's external\n * pending store; NavigationRoot's own `pendingUrl` was a second, unread\n * representation of the same fact and is gone (TIM-1307).\n *\n * Hard navigation guard: When a hard navigation is triggered (500 error,\n * version skew), the component throws an unresolved thenable AFTER all\n * hooks to suspend forever — preventing React from rendering children\n * during page teardown. The throw must come after hooks to satisfy\n * React's rules (same hook count every render) while still preventing\n * child renders that could hit hook count mismatches in components\n * whose positions shift during teardown. This pattern is borrowed from\n * Next.js (app-router.tsx pushRef.mpaNavigation — also after hooks).\n *\n * See design/05-streaming.md §\"deferSuspenseFor\"\n * See design/19-client-navigation.md §\"NavigationContext\"\n */\n\nimport { createElement, Fragment, useLayoutEffect, useRef, type ReactNode } from 'react';\nimport { TopLoader, type TopLoaderConfig } from './top-loader.tsx';\n\n// ─── Rendered Tree ──────────────────────────────────────────────\n\n/**\n * The tree the router has handed to React, and the state publish that belongs\n * to it. They travel as one object so React's commit of the tree is the event\n * that publishes — see the effect in NavigationRoot. Every `render` builds a\n * fresh one, which is what keys that effect: a tree is published once, however\n * many times React re-runs the effect for it.\n */\nexport interface RenderedTree {\n element: ReactNode;\n /**\n * Publishes the navigation's state — segment cache, pathname, address bar,\n * history stack, and the client's record of the mounted tree — and\n * announces it to listeners outside React. Runs when React commits\n * `element`, never before (TIM-1301). Null for a render that has nothing to\n * publish on commit (hydration, the shallow search re-wrap).\n */\n publish: (() => void) | null;\n}\n\n/**\n * Hand a tree to React in a transition. `publish` runs when React commits it.\n *\n * Every path that puts a page on screen goes through one of these — a\n * navigation, a revalidation, a popstate replay, a shallow search re-wrap —\n * and it is always a synchronous `startTransition` around `root.render`.\n * The production one is `createReactRoot().render`.\n *\n * `types` are the view transition types this render animates as\n * (design/37-navigation-api.md §\"Transition types\"). They are added with\n * `addTransitionType` inside that same `startTransition`, and nowhere else:\n * React queues types per root and hands them to the next transition-only\n * commit, so a type added in any other scope describes whichever tree commits\n * next rather than this one (TIM-1463, TIM-1471). Empty for the shallow search\n * re-wrap, which re-renders the displayed page rather than changing it.\n */\nexport type NavigationRender = (\n element: ReactNode,\n publish: (() => void) | null,\n types: readonly string[]\n) => void;\n\n// ─── Hard Navigation Guard ──────────────────────────────────────\n\n/**\n * Module-level flag indicating a hard (MPA) navigation is in progress.\n *\n * When true:\n * - NavigationRoot throws an unresolved thenable to suspend forever,\n * preventing React from rendering children during page teardown\n * (avoids \"Rendered more hooks\" crashes).\n * - The Navigation API handler skips interception, letting the browser\n * perform a full page load (prevents infinite loops where\n * window.location.href → navigate event → router.navigate → 500 →\n * window.location.href → ...).\n *\n * Uses globalThis for singleton guarantee across chunks (same pattern\n * as NavigationContext). See design/19-client-navigation.md §\"Singleton\n * Guarantee via globalThis\".\n */\nconst HARD_NAV_KEY = Symbol.for('__timber_hard_navigating');\n\nfunction getHardNavStore(): { value: boolean } {\n const g = globalThis as Record<symbol, unknown>;\n if (!g[HARD_NAV_KEY]) {\n g[HARD_NAV_KEY] = { value: false };\n }\n return g[HARD_NAV_KEY] as { value: boolean };\n}\n\n/**\n * Set the hard-navigating flag. Call this BEFORE setting\n * window.location.href or window.location.reload() to prevent:\n * 1. React from rendering children during page teardown\n * 2. Navigation API from intercepting the hard navigation\n */\nexport function setHardNavigating(value: boolean): void {\n getHardNavStore().value = value;\n}\n\n/**\n * Check if a hard navigation is in progress.\n * Used by NavigationRoot (throw unresolvedThenable) and by the\n * Navigation API handler (skip interception).\n */\nexport function isHardNavigating(): boolean {\n return getHardNavStore().value;\n}\n\n/**\n * A thenable that never resolves. When thrown during React render,\n * it causes the component to suspend forever — React keeps the\n * old committed tree visible and never attempts to render children.\n *\n * This is the same pattern Next.js uses in app-router.tsx for MPA\n * navigations (pushRef.mpaNavigation → throw unresolvedThenable).\n */\n// for React's Suspense mechanism. Same pattern as Next.js's unresolvedThenable.\n// eslint-disable-next-line unicorn/no-thenable -- Intentionally a never-resolving thenable\nconst unresolvedThenable = { then() {} } as PromiseLike<never>;\n\n// ─── Component ───────────────────────────────────────────────────\n\n/**\n * Root component the router renders the page through.\n *\n * Renders the TopLoader alongside the tree it is given. Neither adds a DOM\n * element on the hydration path, so the tree matches the server HTML.\n *\n * Rendered only by `createReactRoot` (client/react-root.ts): hydration passes\n * `{ element, publish: null }`, and every later render is a synchronous\n * `startTransition(() => root.render(...))` with a fresh `rendered` object.\n */\nexport function NavigationRoot({\n rendered,\n topLoaderConfig,\n}: {\n rendered: RenderedTree;\n topLoaderConfig?: TopLoaderConfig;\n}): ReactNode {\n // Publish the navigation's state when React commits its tree — not when the\n // tree is handed over. A tree React is still waiting on, or one a later\n // navigation replaces before React renders it, has been *given* to React\n // without being on screen; publishing then describes a route the user never\n // saw, which is the defect this ordering exists to prevent (TIM-1301).\n //\n // A **layout** effect, so the publish lands before the browser paints and,\n // more importantly, before every descendant's passive effect. A destination\n // component that navigates from a mount effect — a redirect guard, a\n // `refresh()` on mount — would otherwise start its navigation while the\n // segment cache, address bar and pathname still described the departing\n // route, and send an X-Timber-State-Tree for a tree that is no longer\n // mounted (codex on #998).\n //\n // Descendant *layout* effects still run first: React runs layout effects\n // child-before-parent, and the only way to precede them would be a fiber\n // rendered as an earlier sibling of the payload. That is not free here —\n // `server/ssr-wrappers.tsx` mirrors this component's fiber shape so `useId`\n // agrees across hydration, and an extra sibling shifts every id in the\n // payload subtree. A layout effect that navigates on mount is the price.\n //\n // Keyed on the tree object rather than on the effect run. A publish moves\n // the address bar, which is not idempotent, so any second invocation for the\n // same tree — an effect re-run React is entitled to perform, StrictMode's\n // double-invoke — must be a no-op rather than a second history entry.\n const publishedRef = useRef<RenderedTree | null>(null);\n useLayoutEffect(() => {\n if (publishedRef.current === rendered) return;\n publishedRef.current = rendered;\n rendered.publish?.();\n }, [rendered]);\n\n // ─── Hard navigation guard ─────────────────────────────────\n // When a hard navigation is in progress (500 error, version skew),\n // suspend forever to prevent React from rendering children during\n // page teardown. This avoids \"Rendered more hooks\" crashes in\n // CHILD components whose hook counts may shift during teardown.\n //\n // CRITICAL: This throw MUST come AFTER all hooks (the useRef and\n // useLayoutEffect above). React requires the same hooks to run on every\n // render. If we threw before hooks, React would see 0 hooks on the\n // re-render vs 2 on the initial render — triggering the exact \"Rendered\n // more hooks\" error we're trying to prevent.\n //\n // By placing it after hooks but before the return, all hooks\n // satisfy React's rules, but the thrown thenable prevents any\n // children from rendering. Same pattern as Next.js app-router.tsx\n // (pushRef.mpaNavigation — also placed after all hooks).\n if (isHardNavigating()) {\n throw unresolvedThenable;\n }\n\n // Inject TopLoader alongside the element tree. It subscribes to the router's\n // pending store itself, so it takes no props from here beyond its config,\n // and only it re-renders when a navigation starts or ends. Its slot holds\n // `null` when the loader is disabled via config.\n //\n // This Fragment is a FORK — two children — so it advances React's tree\n // context and shifts every `useId` below it. `server/ssr-wrappers.tsx`\n // mirrors it for exactly that reason, and renders the document's default\n // <meta> tags in the first slot. The fork is unconditional so the server\n // never needs to know whether the loader is enabled: a `null` child still\n // counts toward the fork on both sides. See tests/ssr-wrapper-parity.test.ts.\n const showTopLoader = topLoaderConfig?.enabled !== false;\n return createElement(\n Fragment,\n null,\n showTopLoader ? createElement(TopLoader, { config: topLoaderConfig }) : null,\n rendered.element\n );\n}\n"],"mappings":"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"}
@@ -1,48 +0,0 @@
1
- import { d as ssrDataProvider, i as _setSsrDataProvider } from "./state-B-EBjeER.js";
2
- // src/client/ssr-data.ts
3
- /**
4
- * SSR Data — per-request state for client hooks during server-side rendering.
5
- *
6
- * `useCookie()` and `<Link preserveSearchParams>` have no React context to
7
- * read their request values from during SSR, so the SSR entry hands them
8
- * the request's cookies and search string through this module.
9
- * `useSearchParams()` reads NavigationContext and uses getSsrData() only to
10
- * detect that it is rendering on the server. Route
11
- * params do not travel here — client components read them from
12
- * `ParamsContext`, decoded from the payload root.
13
- *
14
- * Request isolation: ssr-entry.ts registers an ALS-backed provider via
15
- * registerSsrDataProvider(), so getSsrData() reads the current request's
16
- * store even when Suspense boundaries resolve asynchronously across
17
- * concurrent requests. There is no module-level fallback: outside an SSR
18
- * render (in the browser, or before the provider is registered) there is no
19
- * request, and getSsrData() returns undefined.
20
- *
21
- * IMPORTANT: This module must NOT import node:async_hooks or any Node.js-only
22
- * APIs, as it's imported by 'use client' hooks that are bundled for the browser.
23
- * The ALS instance lives in ssr-entry.ts (server-only); this module only holds
24
- * a reference to the provider function.
25
- *
26
- * All mutable state is delegated to client/state.ts for singleton guarantees.
27
- * See design/18-build-system.md §"Singleton State Registry"
28
- */
29
- /**
30
- * Register the SSR data provider. Called once at module load by
31
- * ssr-entry.ts to wire up per-request data via AsyncLocalStorage; tests
32
- * register their own provider (and `undefined` to reset).
33
- */
34
- function registerSsrDataProvider(provider) {
35
- _setSsrDataProvider(provider);
36
- }
37
- /**
38
- * Read the current request's SSR data. Returns undefined when called
39
- * outside an SSR render (i.e. on the client after hydration).
40
- *
41
- * Used by client hooks' server snapshot functions.
42
- */
43
- function getSsrData() {
44
- return ssrDataProvider?.();
45
- }
46
- export { registerSsrDataProvider as n, getSsrData as t };
47
-
48
- //# sourceMappingURL=ssr-data-9hPtcNOr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssr-data-9hPtcNOr.js","names":[],"sources":["../../src/client/ssr-data.ts"],"sourcesContent":["/**\n * SSR Data — per-request state for client hooks during server-side rendering.\n *\n * `useCookie()` and `<Link preserveSearchParams>` have no React context to\n * read their request values from during SSR, so the SSR entry hands them\n * the request's cookies and search string through this module.\n * `useSearchParams()` reads NavigationContext and uses getSsrData() only to\n * detect that it is rendering on the server. Route\n * params do not travel here — client components read them from\n * `ParamsContext`, decoded from the payload root.\n *\n * Request isolation: ssr-entry.ts registers an ALS-backed provider via\n * registerSsrDataProvider(), so getSsrData() reads the current request's\n * store even when Suspense boundaries resolve asynchronously across\n * concurrent requests. There is no module-level fallback: outside an SSR\n * render (in the browser, or before the provider is registered) there is no\n * request, and getSsrData() returns undefined.\n *\n * IMPORTANT: This module must NOT import node:async_hooks or any Node.js-only\n * APIs, as it's imported by 'use client' hooks that are bundled for the browser.\n * The ALS instance lives in ssr-entry.ts (server-only); this module only holds\n * a reference to the provider function.\n *\n * All mutable state is delegated to client/state.ts for singleton guarantees.\n * See design/18-build-system.md §\"Singleton State Registry\"\n */\n\nimport { ssrDataProvider, _setSsrDataProvider } from './state.ts';\n\n// ─── Types ────────────────────────────────────────────────────────\n\nexport interface SsrData {\n /**\n * The request's raw app-visible query string (`''` or `?…`), matching what\n * `window.location.search` will hold after hydration. The raw string is\n * the only representation carried here: it preserves repeated keys\n * (`?tag=a&tag=b`), which a collapsed `Record<string, string>` cannot\n * (TIM-1428). Parse with `new URLSearchParams(search)` where needed.\n */\n search: string;\n /** The request's cookies as name→value pairs */\n cookies: Map<string, string>;\n}\n\n// ─── ALS-Backed Provider ─────────────────────────────────────────\n//\n// Server-side code (ssr-entry.ts) registers a provider that reads\n// from AsyncLocalStorage. This avoids importing node:async_hooks\n// in this browser-bundled module.\n//\n// Module singleton guarantee: In Vite's SSR environment, both\n// ssr-entry.ts (via #/client/ssr-data.js) and client component hooks\n// (via @timber-js/app/client) must resolve to the SAME module instance\n// of this file. The timber-shims plugin ensures this by remapping\n// @timber-js/app/client → src/client/index.ts in the SSR environment.\n// Without this remap, @timber-js/app/client resolves to dist/ (via\n// package.json exports), creating a split where registerSsrDataProvider\n// writes to one instance but getSsrData reads from another.\n// See timber-shims plugin resolveId for details.\n\n/**\n * Register the SSR data provider. Called once at module load by\n * ssr-entry.ts to wire up per-request data via AsyncLocalStorage; tests\n * register their own provider (and `undefined` to reset).\n */\nexport function registerSsrDataProvider(provider: (() => SsrData | undefined) | undefined): void {\n _setSsrDataProvider(provider);\n}\n\n/**\n * Read the current request's SSR data. Returns undefined when called\n * outside an SSR render (i.e. on the client after hydration).\n *\n * Used by client hooks' server snapshot functions.\n */\nexport function getSsrData(): SsrData | undefined {\n return ssrDataProvider?.();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,wBAAwB,UAAyD;CAC/F,oBAAoB,QAAQ;AAC9B;;;;;;;AAQA,SAAgB,aAAkC;CAChD,OAAO,kBAAkB;AAC3B"}
@@ -1,49 +0,0 @@
1
- // src/client/state.ts
2
- /** The global router singleton — set once during bootstrap. */
3
- var globalRouter = null;
4
- function _setGlobalRouter(router) {
5
- globalRouter = router;
6
- }
7
- /**
8
- * ALS-backed SSR data provider, registered by the SSR entry. getSsrData()
9
- * reads through it; unset in the browser.
10
- */
11
- var ssrDataProvider;
12
- function _setSsrDataProvider(provider) {
13
- ssrDataProvider = provider;
14
- }
15
- /** Cached search string — avoids reparsing when URL hasn't changed. */
16
- var cachedSearch = "";
17
- var cachedSearchParams = new URLSearchParams();
18
- function _setCachedSearch(search, params) {
19
- cachedSearch = search;
20
- cachedSearchParams = params;
21
- }
22
- /** Whether the page is currently being unloaded. */
23
- var unloading = false;
24
- function _setUnloading(value) {
25
- unloading = value;
26
- }
27
- /**
28
- * Whether a status page for the main route has rendered since the last
29
- * navigation was prepared. Raised by `StatusPageMarker`, consumed by the
30
- * navigation's commit. See navigation-commit.ts §"What a status page
31
- * teaches the cache".
32
- */
33
- var statusPageRendered = false;
34
- function _setStatusPageRendered(value) {
35
- statusPageRendered = value;
36
- }
37
- /**
38
- * What a status page report does beyond raising the flag: registered by the
39
- * router's committer so the report can clear the segment cache at once, for
40
- * the commits no navigation consumes (a row arriving inside Suspense after
41
- * its navigation published, a status document being hydrated).
42
- */
43
- var onStatusPageRendered;
44
- function _setOnStatusPageRendered(handler) {
45
- onStatusPageRendered = handler;
46
- }
47
- export { _setStatusPageRendered as a, cachedSearchParams as c, ssrDataProvider as d, statusPageRendered as f, _setSsrDataProvider as i, globalRouter as l, _setGlobalRouter as n, _setUnloading as o, unloading as p, _setOnStatusPageRendered as r, cachedSearch as s, _setCachedSearch as t, onStatusPageRendered as u };
48
-
49
- //# sourceMappingURL=state-B-EBjeER.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state-B-EBjeER.js","names":[],"sources":["../../src/client/state.ts"],"sourcesContent":["/**\n * Centralized client singleton state registry.\n *\n * ALL mutable module-level state that must have singleton semantics across\n * the client bundle lives here. Individual modules (router-ref.ts, ssr-data.ts,\n * use-segment-params.ts, use-search-params.ts, unload-guard.ts) import from this file\n * and re-export thin wrapper functions.\n *\n * Why: In Vite dev, a module is instantiated separately if reached via different\n * import paths (e.g., relative `./foo.js` vs barrel `@timber-js/app/client`).\n * By centralizing all mutable state in a single module that is always reached\n * through the same dependency chain (barrel → wrapper → state.ts), we guarantee\n * a single instance of every piece of shared state.\n *\n * DO NOT import this file from outside client/. Server code must never depend\n * on client state. The barrel (client/index.ts) is the public entry point.\n *\n * See design/18-build-system.md §\"Module Singleton Strategy\" and\n * §\"Singleton State Registry\".\n */\n\nimport type { RouterInstance } from './router-types.ts';\nimport type { SsrData } from './ssr-data.ts';\n\n// ─── Router (from router-ref.ts) ──────────────────────────────────────────\n\n/** The global router singleton — set once during bootstrap. */\nexport let globalRouter: RouterInstance | null = null;\n\nexport function _setGlobalRouter(router: RouterInstance | null): void {\n globalRouter = router;\n}\n\n// ─── SSR Data Provider (from ssr-data.ts) ──────────────────────────────────\n\n/**\n * ALS-backed SSR data provider, registered by the SSR entry. getSsrData()\n * reads through it; unset in the browser.\n */\nexport let ssrDataProvider: (() => SsrData | undefined) | undefined;\n\nexport function _setSsrDataProvider(provider: (() => SsrData | undefined) | undefined): void {\n ssrDataProvider = provider;\n}\n\n// ─── Search Params Cache (from use-search-params.ts) ────────────────────────\n\n/** Cached search string — avoids reparsing when URL hasn't changed. */\nexport let cachedSearch = '';\nexport let cachedSearchParams = new URLSearchParams();\n\nexport function _setCachedSearch(search: string, params: URLSearchParams): void {\n cachedSearch = search;\n cachedSearchParams = params;\n}\n\n// ─── Unload Guard (from unload-guard.ts) ─────────────────────────────────────\n\n/** Whether the page is currently being unloaded. */\nexport let unloading = false;\n\nexport function _setUnloading(value: boolean): void {\n unloading = value;\n}\n\n// ─── Status Page Commit Flag (from navigation-commit.ts) ────────────────────\n\n/**\n * Whether a status page for the main route has rendered since the last\n * navigation was prepared. Raised by `StatusPageMarker`, consumed by the\n * navigation's commit. See navigation-commit.ts §\"What a status page\n * teaches the cache\".\n */\nexport let statusPageRendered = false;\n\nexport function _setStatusPageRendered(value: boolean): void {\n statusPageRendered = value;\n}\n\n/**\n * What a status page report does beyond raising the flag: registered by the\n * router's committer so the report can clear the segment cache at once, for\n * the commits no navigation consumes (a row arriving inside Suspense after\n * its navigation published, a status document being hydrated).\n */\nexport let onStatusPageRendered: (() => void) | undefined;\n\nexport function _setOnStatusPageRendered(handler: (() => void) | undefined): void {\n onStatusPageRendered = handler;\n}\n"],"mappings":";;AA2BA,IAAW,eAAsC;AAEjD,SAAgB,iBAAiB,QAAqC;CACpE,eAAe;AACjB;;;;;AAQA,IAAW;AAEX,SAAgB,oBAAoB,UAAyD;CAC3F,kBAAkB;AACpB;;AAKA,IAAW,eAAe;AAC1B,IAAW,qBAAqB,IAAI,gBAAgB;AAEpD,SAAgB,iBAAiB,QAAgB,QAA+B;CAC9E,eAAe;CACf,qBAAqB;AACvB;;AAKA,IAAW,YAAY;AAEvB,SAAgB,cAAc,OAAsB;CAClD,YAAY;AACd;;;;;;;AAUA,IAAW,qBAAqB;AAEhC,SAAgB,uBAAuB,OAAsB;CAC3D,qBAAqB;AACvB;;;;;;;AAQA,IAAW;AAEX,SAAgB,yBAAyB,SAAyC;CAChF,uBAAuB;AACzB"}
@@ -1,14 +0,0 @@
1
- // src/client/state.ts
2
- var globalRouter = null;
3
- var ssrDataProvider;
4
- function _setSsrDataProvider(provider) {
5
- ssrDataProvider = provider;
6
- }
7
- var cachedSearch = "";
8
- var cachedSearchParams = new URLSearchParams();
9
- var unloading = false;
10
- var statusPageRendered = false;
11
- var onStatusPageRendered;
12
- export { _setSsrDataProvider, cachedSearch, cachedSearchParams, globalRouter, onStatusPageRendered, ssrDataProvider, statusPageRendered, unloading };
13
-
14
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.js","names":[],"sources":["../../../../src/client/state.ts"],"mappings":";AA2BA,IAAW,eAAsC;AAYjD,IAAW;AAEX,SAAgB,oBAAoB,UAAyD;CAC3F,kBAAkB;AACpB;AAKA,IAAW,eAAe;AAC1B,IAAW,qBAAqB,IAAI,gBAAgB;AAUpD,IAAW,YAAY;AAcvB,IAAW,qBAAqB;AAYhC,IAAW"}