@timber-js/app 0.1.23 → 0.1.25

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 (61) hide show
  1. package/dist/_chunks/{ssr-data-B2yikEEB.js → ssr-data-DLnbYpj1.js} +2 -4
  2. package/dist/_chunks/{ssr-data-B2yikEEB.js.map → ssr-data-DLnbYpj1.js.map} +1 -1
  3. package/dist/_chunks/{use-cookie-D5aS4slY.js → use-cookie-dDbpCTx-.js} +2 -2
  4. package/dist/_chunks/{use-cookie-D5aS4slY.js.map → use-cookie-dDbpCTx-.js.map} +1 -1
  5. package/dist/adapters/nitro.d.ts.map +1 -1
  6. package/dist/adapters/nitro.js +4 -3
  7. package/dist/adapters/nitro.js.map +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client/browser-dev.d.ts +29 -0
  11. package/dist/client/browser-dev.d.ts.map +1 -0
  12. package/dist/client/browser-links.d.ts +32 -0
  13. package/dist/client/browser-links.d.ts.map +1 -0
  14. package/dist/client/error-boundary.js +1 -1
  15. package/dist/client/index.d.ts +2 -0
  16. package/dist/client/index.d.ts.map +1 -1
  17. package/dist/client/index.js +150 -122
  18. package/dist/client/index.js.map +1 -1
  19. package/dist/client/navigation-context.d.ts +52 -0
  20. package/dist/client/navigation-context.d.ts.map +1 -0
  21. package/dist/client/router.d.ts.map +1 -1
  22. package/dist/client/transition-root.d.ts +54 -0
  23. package/dist/client/transition-root.d.ts.map +1 -0
  24. package/dist/client/use-params.d.ts +35 -25
  25. package/dist/client/use-params.d.ts.map +1 -1
  26. package/dist/client/use-pathname.d.ts +11 -4
  27. package/dist/client/use-pathname.d.ts.map +1 -1
  28. package/dist/client/use-router.d.ts +14 -0
  29. package/dist/client/use-router.d.ts.map +1 -1
  30. package/dist/cookies/index.js +2 -2
  31. package/dist/server/index.js +264 -218
  32. package/dist/server/index.js.map +1 -1
  33. package/dist/server/metadata-platform.d.ts +34 -0
  34. package/dist/server/metadata-platform.d.ts.map +1 -0
  35. package/dist/server/metadata-render.d.ts.map +1 -1
  36. package/dist/server/metadata-social.d.ts +24 -0
  37. package/dist/server/metadata-social.d.ts.map +1 -0
  38. package/dist/server/pipeline-interception.d.ts +32 -0
  39. package/dist/server/pipeline-interception.d.ts.map +1 -0
  40. package/dist/server/pipeline-metadata.d.ts +31 -0
  41. package/dist/server/pipeline-metadata.d.ts.map +1 -0
  42. package/dist/server/pipeline.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/src/adapters/nitro.ts +9 -7
  45. package/src/cli.ts +9 -2
  46. package/src/client/browser-dev.ts +142 -0
  47. package/src/client/browser-entry.ts +73 -223
  48. package/src/client/browser-links.ts +90 -0
  49. package/src/client/index.ts +4 -0
  50. package/src/client/navigation-context.ts +118 -0
  51. package/src/client/router.ts +37 -33
  52. package/src/client/transition-root.tsx +86 -0
  53. package/src/client/use-params.ts +50 -54
  54. package/src/client/use-pathname.ts +31 -24
  55. package/src/client/use-router.ts +17 -15
  56. package/src/server/metadata-platform.ts +229 -0
  57. package/src/server/metadata-render.ts +9 -363
  58. package/src/server/metadata-social.ts +184 -0
  59. package/src/server/pipeline-interception.ts +76 -0
  60. package/src/server/pipeline-metadata.ts +90 -0
  61. package/src/server/pipeline.ts +2 -148
@@ -18,10 +18,11 @@
18
18
  * (populated by ssr-entry.ts) to ensure correct per-request isolation
19
19
  * across concurrent requests with streaming Suspense.
20
20
  *
21
- * Reactivity: useParams() uses useSyncExternalStore so that components
22
- * in unchanged layouts (e.g., sidebar items) re-render atomically when
23
- * params change during client-side navigation. This matches the pattern
24
- * used by usePathname() and useSearchParams().
21
+ * Reactivity: On the client, useParams() reads from NavigationContext
22
+ * which is updated atomically with the RSC tree render. This replaces
23
+ * the previous useSyncExternalStore approach that suffered from a
24
+ * timing gap between tree render and store notification — causing
25
+ * preserved layout components to briefly show stale active state.
25
26
  *
26
27
  * All mutable state is delegated to client/state.ts for singleton guarantees.
27
28
  * See design/18-build-system.md §"Singleton State Registry"
@@ -30,37 +31,40 @@
30
31
  */
31
32
  import type { Routes } from '#/index.js';
32
33
  /**
33
- * Subscribe to params changes. Called by useSyncExternalStore.
34
- * Exported for testing not intended for direct use by app code.
34
+ * Subscribe to params changes.
35
+ * Retained for backward compatibility with tests that verify the
36
+ * subscribe/notify contract. On the client, useParams() reads from
37
+ * NavigationContext instead.
35
38
  */
36
39
  export declare function subscribe(callback: () => void): () => void;
37
40
  /**
38
- * Get the current params snapshot (client).
39
- * Exported for testing not intended for direct use by app code.
41
+ * Get the current params snapshot (module-level fallback).
42
+ * Used by tests and by the hook when called outside a React component.
40
43
  */
41
44
  export declare function getSnapshot(): Record<string, string | string[]>;
42
45
  /**
43
- * Set the current route params WITHOUT notifying subscribers.
44
- * Called by the router before renderPayload() so that new components
45
- * in the RSC tree see the updated params via getSnapshot(), but
46
- * preserved layout components don't re-render prematurely with
47
- * {old tree, new params}.
46
+ * Set the current route params in the module-level store.
48
47
  *
49
- * After the React render commits, the router calls notifyParamsListeners()
50
- * to trigger re-renders in preserved layouts that read useParams().
48
+ * Called by the router on each navigation. This updates the fallback
49
+ * snapshot used by tests and by the hook when called outside a React
50
+ * component (no NavigationContext available).
51
+ *
52
+ * On the client, the primary reactivity path is NavigationContext —
53
+ * the router calls setNavigationState() then renderRoot() which wraps
54
+ * the element in NavigationProvider. setCurrentParams is still called
55
+ * for the module-level fallback.
51
56
  *
52
- * On the client, the segment router calls this on each navigation.
53
57
  * During SSR, params are also available via getSsrData().params
54
- * (ALS-backed), but setCurrentParams is still called for the
55
- * module-level fallback path.
58
+ * (ALS-backed).
56
59
  */
57
60
  export declare function setCurrentParams(params: Record<string, string | string[]>): void;
58
61
  /**
59
- * Notify all useSyncExternalStore subscribers that params have changed.
60
- * Called by the router AFTER renderPayload() so that preserved layout
61
- * components re-render only after the new tree is committed — producing
62
- * an atomic {new tree, new params} update instead of a stale
63
- * {old tree, new params} intermediate state.
62
+ * Notify all legacy subscribers that params have changed.
63
+ *
64
+ * Retained for backward compatibility with tests. On the client,
65
+ * the NavigationContext + renderRoot pattern replaces this params
66
+ * update atomically with the tree render, so explicit notification
67
+ * is no longer needed.
64
68
  */
65
69
  export declare function notifyParamsListeners(): void;
66
70
  /**
@@ -69,9 +73,15 @@ export declare function notifyParamsListeners(): void;
69
73
  * The optional `_route` argument exists only for TypeScript narrowing —
70
74
  * it does not affect the runtime return value.
71
75
  *
76
+ * On the client, reads from NavigationContext (provided by
77
+ * NavigationProvider in renderRoot). This ensures params update
78
+ * atomically with the RSC tree — no timing gap.
79
+ *
72
80
  * During SSR, reads from the ALS-backed SSR data context to ensure
73
- * per-request isolation. On the client, subscribes to the module-level
74
- * params store via useSyncExternalStore.
81
+ * per-request isolation across concurrent requests with streaming Suspense.
82
+ *
83
+ * When called outside a React component (e.g., in test assertions),
84
+ * falls back to the module-level snapshot.
75
85
  *
76
86
  * @overload Typed — when a known route path is passed, returns the
77
87
  * exact params shape from the generated Routes interface.
@@ -1 +1 @@
1
- {"version":3,"file":"use-params.d.ts","sourceRoot":"","sources":["../../src/client/use-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAQzC;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAE/D;AAeD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACjF,wBAAgB,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"use-params.d.ts","sourceRoot":"","sources":["../../src/client/use-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AASzC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAE/D;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACjF,wBAAgB,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC"}
@@ -4,17 +4,24 @@
4
4
  * Returns the pathname portion of the current URL (e.g. '/dashboard/settings').
5
5
  * Updates when client-side navigation changes the URL.
6
6
  *
7
- * This is a thin wrapper over window.location.pathname, provided for
8
- * Next.js API compatibility (libraries like nuqs import usePathname
9
- * from next/navigation).
7
+ * On the client, reads from NavigationContext which is updated atomically
8
+ * with the RSC tree render. This replaces the previous useSyncExternalStore
9
+ * approach which only subscribed to popstate events — meaning usePathname()
10
+ * did NOT re-render on forward navigation (pushState). The context approach
11
+ * fixes this: pathname updates in the same render pass as the new tree.
10
12
  *
11
13
  * During SSR, reads the request pathname from the SSR ALS context
12
14
  * (populated by ssr-entry.ts) instead of window.location.
15
+ *
16
+ * Compatible with Next.js's `usePathname()` from `next/navigation`.
13
17
  */
14
18
  /**
15
19
  * Read the current URL pathname.
16
20
  *
17
- * Compatible with Next.js's `usePathname()` from `next/navigation`.
21
+ * On the client, reads from NavigationContext (provided by
22
+ * NavigationProvider in renderRoot). During SSR, reads from the
23
+ * ALS-backed SSR data context. Falls back to window.location.pathname
24
+ * when called outside a React component (e.g., in tests).
18
25
  */
19
26
  export declare function usePathname(): string;
20
27
  //# sourceMappingURL=use-pathname.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-pathname.d.ts","sourceRoot":"","sources":["../../src/client/use-pathname.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAuBH;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
1
+ {"version":3,"file":"use-pathname.d.ts","sourceRoot":"","sources":["../../src/client/use-pathname.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAoBpC"}
@@ -7,6 +7,20 @@
7
7
  *
8
8
  * This wraps timber's internal RouterInstance in the Next.js-compatible
9
9
  * AppRouterInstance shape that ecosystem libraries expect.
10
+ *
11
+ * NOTE: Unlike Next.js, these methods do NOT wrap navigation in
12
+ * startTransition. In Next.js, router state is React state (useReducer)
13
+ * so startTransition defers the update and provides isPending tracking.
14
+ * In timber, navigation calls reactRoot.render() which is a root-level
15
+ * render — startTransition has no effect on root renders.
16
+ *
17
+ * Navigation state (params, pathname) is delivered atomically via
18
+ * NavigationContext embedded in the element tree passed to
19
+ * reactRoot.render(). See design/19-client-navigation.md §"NavigationContext".
20
+ *
21
+ * For loading UI during navigation, use:
22
+ * - useLinkStatus() — per-link pending indicator (inside <Link>)
23
+ * - useNavigationPending() — global navigation pending state
10
24
  */
11
25
  export interface AppRouterInstance {
12
26
  /** Navigate to a URL, pushing a new history entry */
@@ -1 +1 @@
1
- {"version":3,"file":"use-router.d.ts","sourceRoot":"","sources":["../../src/client/use-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACzD,6DAA6D;IAC7D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5D,sDAAsD;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,+BAA+B;IAC/B,IAAI,IAAI,IAAI,CAAC;IACb,kCAAkC;IAClC,OAAO,IAAI,IAAI,CAAC;IAChB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CAuD7C"}
1
+ {"version":3,"file":"use-router.d.ts","sourceRoot":"","sources":["../../src/client/use-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACzD,6DAA6D;IAC7D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5D,sDAAsD;IACtD,OAAO,IAAI,IAAI,CAAC;IAChB,+BAA+B;IAC/B,IAAI,IAAI,IAAI,CAAC;IACb,kCAAkC;IAClC,OAAO,IAAI,IAAI,CAAC;IAChB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CA4C7C"}
@@ -1,7 +1,7 @@
1
1
  import "../_chunks/als-registry-c0AGnbqS.js";
2
2
  import { n as cookies } from "../_chunks/request-context-C69VW4xS.js";
3
- import "../_chunks/ssr-data-B2yikEEB.js";
4
- import { t as useCookie } from "../_chunks/use-cookie-D5aS4slY.js";
3
+ import "../_chunks/ssr-data-DLnbYpj1.js";
4
+ import { t as useCookie } from "../_chunks/use-cookie-dDbpCTx-.js";
5
5
  //#region src/cookies/define-cookie.ts
6
6
  /**
7
7
  * defineCookie — typed cookie definitions.