@timber-js/app 0.2.0-alpha.71 → 0.2.0-alpha.72

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 (248) hide show
  1. package/dist/_chunks/actions-Dg-ANYHb.js +421 -0
  2. package/dist/_chunks/actions-Dg-ANYHb.js.map +1 -0
  3. package/dist/_chunks/{als-registry-BJARkOcu.js → als-registry-HS0LGUl2.js} +1 -1
  4. package/dist/_chunks/als-registry-HS0LGUl2.js.map +1 -0
  5. package/dist/_chunks/{define-Dz1bqwaS.js → define-C77ScO0m.js} +14 -14
  6. package/dist/_chunks/define-C77ScO0m.js.map +1 -0
  7. package/dist/_chunks/{define-CGuYoRHU.js → define-CZqDwhSu.js} +15 -15
  8. package/dist/_chunks/define-CZqDwhSu.js.map +1 -0
  9. package/dist/_chunks/{define-cookie-B5mewxwM.js → define-cookie-C2IkoFGN.js} +9 -8
  10. package/dist/_chunks/{define-cookie-B5mewxwM.js.map → define-cookie-C2IkoFGN.js.map} +1 -1
  11. package/dist/_chunks/{format-Rn922VH2.js → dev-warnings-DpGRGoDi.js} +4 -26
  12. package/dist/_chunks/dev-warnings-DpGRGoDi.js.map +1 -0
  13. package/dist/_chunks/format-CYBGxKtc.js +14 -0
  14. package/dist/_chunks/format-CYBGxKtc.js.map +1 -0
  15. package/dist/_chunks/{interception-CEdHHviP.js → interception-Dpn_UfAD.js} +2 -2
  16. package/dist/_chunks/{interception-CEdHHviP.js.map → interception-Dpn_UfAD.js.map} +1 -1
  17. package/dist/_chunks/{segment-context-hzuJ048X.js → merge-search-params-Cm_KIWDX.js} +2 -33
  18. package/dist/_chunks/merge-search-params-Cm_KIWDX.js.map +1 -0
  19. package/dist/_chunks/{request-context-CywiO4jV.js → request-context-qMsWgy9C.js} +72 -36
  20. package/dist/_chunks/request-context-qMsWgy9C.js.map +1 -0
  21. package/dist/_chunks/{schema-bridge-C4SwjCQD.js → schema-bridge-C3xl_vfb.js} +1 -1
  22. package/dist/_chunks/{schema-bridge-C4SwjCQD.js.map → schema-bridge-C3xl_vfb.js.map} +1 -1
  23. package/dist/_chunks/segment-context-fHFLF1PE.js +34 -0
  24. package/dist/_chunks/segment-context-fHFLF1PE.js.map +1 -0
  25. package/dist/_chunks/ssr-data-DzuI0bIV.js +88 -0
  26. package/dist/_chunks/ssr-data-DzuI0bIV.js.map +1 -0
  27. package/dist/_chunks/{stale-reload-BLUC_Pl_.js → stale-reload-C2plcNtG.js} +1 -1
  28. package/dist/_chunks/{stale-reload-BLUC_Pl_.js.map → stale-reload-C2plcNtG.js.map} +1 -1
  29. package/dist/_chunks/{handler-store-BVePM7hp.js → tracing-CCYbKn5n.js} +60 -60
  30. package/dist/_chunks/tracing-CCYbKn5n.js.map +1 -0
  31. package/dist/_chunks/use-params-B1AuhI1p.js +307 -0
  32. package/dist/_chunks/use-params-B1AuhI1p.js.map +1 -0
  33. package/dist/_chunks/{use-query-states-DAhgj8Gx.js → use-query-states-Lo_s_pw2.js} +4 -4
  34. package/dist/_chunks/use-query-states-Lo_s_pw2.js.map +1 -0
  35. package/dist/_chunks/{wrappers-LZbghvn0.js → wrappers-_DTmImGt.js} +1 -1
  36. package/dist/_chunks/{wrappers-LZbghvn0.js.map → wrappers-_DTmImGt.js.map} +1 -1
  37. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  38. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  39. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  40. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  41. package/dist/cache/index.d.ts +18 -4
  42. package/dist/cache/index.d.ts.map +1 -1
  43. package/dist/cache/index.js +78 -12
  44. package/dist/cache/index.js.map +1 -1
  45. package/dist/cache/sizeof.d.ts +22 -0
  46. package/dist/cache/sizeof.d.ts.map +1 -0
  47. package/dist/cli.d.ts +6 -1
  48. package/dist/cli.d.ts.map +1 -1
  49. package/dist/cli.js +6 -1
  50. package/dist/cli.js.map +1 -1
  51. package/dist/client/browser-dev.d.ts +27 -1
  52. package/dist/client/browser-dev.d.ts.map +1 -1
  53. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  54. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  55. package/dist/client/browser-entry/hmr.d.ts +21 -0
  56. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  57. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  58. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  59. package/dist/client/browser-entry/index.d.ts +30 -0
  60. package/dist/client/browser-entry/index.d.ts.map +1 -0
  61. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  62. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  63. package/dist/client/browser-entry/router-init.d.ts +23 -0
  64. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  65. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  66. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  67. package/dist/client/browser-entry/scroll.d.ts +19 -0
  68. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  69. package/dist/client/error-boundary.js +131 -1
  70. package/dist/client/error-boundary.js.map +1 -0
  71. package/dist/client/index.d.ts +4 -19
  72. package/dist/client/index.d.ts.map +1 -1
  73. package/dist/client/index.js +14 -1191
  74. package/dist/client/index.js.map +1 -1
  75. package/dist/client/internal.d.ts +18 -0
  76. package/dist/client/internal.d.ts.map +1 -0
  77. package/dist/client/internal.js +890 -0
  78. package/dist/client/internal.js.map +1 -0
  79. package/dist/client/navigation-context.d.ts.map +1 -1
  80. package/dist/client/router-ref.d.ts +1 -1
  81. package/dist/client/top-loader.d.ts +2 -2
  82. package/dist/client/use-link-status.d.ts +1 -1
  83. package/dist/client/{use-navigation-pending.d.ts → use-pending-navigation.d.ts} +4 -4
  84. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  85. package/dist/client/use-router.d.ts +1 -1
  86. package/dist/codec.d.ts +10 -0
  87. package/dist/codec.d.ts.map +1 -1
  88. package/dist/codec.js +1 -1
  89. package/dist/config-types.d.ts +210 -0
  90. package/dist/config-types.d.ts.map +1 -0
  91. package/dist/content/index.d.ts +1 -10
  92. package/dist/content/index.d.ts.map +1 -1
  93. package/dist/content/index.js +0 -2
  94. package/dist/cookies/define-cookie.d.ts.map +1 -1
  95. package/dist/cookies/index.d.ts +0 -2
  96. package/dist/cookies/index.d.ts.map +1 -1
  97. package/dist/cookies/index.js +2 -3
  98. package/dist/index.d.ts +25 -288
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +261 -43
  101. package/dist/index.js.map +1 -1
  102. package/dist/plugin-context.d.ts +84 -0
  103. package/dist/plugin-context.d.ts.map +1 -0
  104. package/dist/plugins/adapter-build.d.ts +1 -1
  105. package/dist/plugins/adapter-build.d.ts.map +1 -1
  106. package/dist/plugins/build-manifest.d.ts +1 -1
  107. package/dist/plugins/build-manifest.d.ts.map +1 -1
  108. package/dist/plugins/build-report.d.ts +1 -1
  109. package/dist/plugins/build-report.d.ts.map +1 -1
  110. package/dist/plugins/content.d.ts +1 -1
  111. package/dist/plugins/content.d.ts.map +1 -1
  112. package/dist/plugins/dev-browser-logs.d.ts +1 -1
  113. package/dist/plugins/dev-browser-logs.d.ts.map +1 -1
  114. package/dist/plugins/dev-logs.d.ts +1 -1
  115. package/dist/plugins/dev-logs.d.ts.map +1 -1
  116. package/dist/plugins/dev-server.d.ts +1 -1
  117. package/dist/plugins/dev-server.d.ts.map +1 -1
  118. package/dist/plugins/entries.d.ts +1 -1
  119. package/dist/plugins/entries.d.ts.map +1 -1
  120. package/dist/plugins/fonts.d.ts +1 -1
  121. package/dist/plugins/fonts.d.ts.map +1 -1
  122. package/dist/plugins/mdx.d.ts +1 -1
  123. package/dist/plugins/mdx.d.ts.map +1 -1
  124. package/dist/plugins/routing.d.ts +1 -1
  125. package/dist/plugins/routing.d.ts.map +1 -1
  126. package/dist/plugins/shims.d.ts +1 -1
  127. package/dist/plugins/shims.d.ts.map +1 -1
  128. package/dist/plugins/static-build.d.ts +4 -4
  129. package/dist/plugins/static-build.d.ts.map +1 -1
  130. package/dist/routing/index.js +1 -1
  131. package/dist/search-params/define.d.ts +6 -6
  132. package/dist/search-params/define.d.ts.map +1 -1
  133. package/dist/search-params/index.d.ts +1 -2
  134. package/dist/search-params/index.d.ts.map +1 -1
  135. package/dist/search-params/index.js +4 -4
  136. package/dist/search-params/registry.d.ts +1 -1
  137. package/dist/search-params/registry.d.ts.map +1 -1
  138. package/dist/segment-params/define.d.ts +6 -6
  139. package/dist/segment-params/define.d.ts.map +1 -1
  140. package/dist/segment-params/index.d.ts +0 -1
  141. package/dist/segment-params/index.d.ts.map +1 -1
  142. package/dist/segment-params/index.js +3 -3
  143. package/dist/server/als-registry.d.ts +1 -1
  144. package/dist/server/dev-holding-server.d.ts +52 -0
  145. package/dist/server/dev-holding-server.d.ts.map +1 -0
  146. package/dist/server/dev-warnings.d.ts +1 -7
  147. package/dist/server/dev-warnings.d.ts.map +1 -1
  148. package/dist/server/index.d.ts +6 -45
  149. package/dist/server/index.d.ts.map +1 -1
  150. package/dist/server/index.js +7 -3272
  151. package/dist/server/index.js.map +1 -1
  152. package/dist/server/internal.d.ts +46 -0
  153. package/dist/server/internal.d.ts.map +1 -0
  154. package/dist/server/internal.js +2865 -0
  155. package/dist/server/internal.js.map +1 -0
  156. package/dist/server/pipeline.d.ts.map +1 -1
  157. package/dist/server/primitives.d.ts +41 -17
  158. package/dist/server/primitives.d.ts.map +1 -1
  159. package/dist/server/request-context.d.ts +45 -15
  160. package/dist/server/request-context.d.ts.map +1 -1
  161. package/dist/server/tracing.d.ts +4 -4
  162. package/dist/server/tracing.d.ts.map +1 -1
  163. package/dist/shims/headers.d.ts +2 -1
  164. package/dist/shims/headers.d.ts.map +1 -1
  165. package/dist/shims/navigation.d.ts +2 -1
  166. package/dist/shims/navigation.d.ts.map +1 -1
  167. package/package.json +19 -13
  168. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  169. package/src/cache/handler-store.ts +2 -2
  170. package/src/cache/index.ts +74 -15
  171. package/src/cache/sizeof.ts +31 -0
  172. package/src/cli.ts +6 -1
  173. package/src/client/browser-dev.ts +128 -1
  174. package/src/client/browser-entry/action-dispatch.ts +116 -0
  175. package/src/client/browser-entry/hmr.ts +81 -0
  176. package/src/client/browser-entry/hydrate.ts +145 -0
  177. package/src/client/browser-entry/index.ts +138 -0
  178. package/src/client/browser-entry/post-hydration.ts +119 -0
  179. package/src/client/browser-entry/router-init.ts +184 -0
  180. package/src/client/browser-entry/rsc-stream.ts +157 -0
  181. package/src/client/browser-entry/scroll.ts +27 -0
  182. package/src/client/index.ts +10 -38
  183. package/src/client/internal.ts +57 -0
  184. package/src/client/navigation-context.ts +6 -2
  185. package/src/client/navigation-root.tsx +1 -1
  186. package/src/client/router-ref.ts +1 -1
  187. package/src/client/top-loader.tsx +2 -2
  188. package/src/client/use-link-status.ts +1 -1
  189. package/src/client/{use-navigation-pending.ts → use-pending-navigation.ts} +5 -5
  190. package/src/client/use-query-states.ts +2 -2
  191. package/src/client/use-router.ts +1 -1
  192. package/src/codec.ts +15 -0
  193. package/src/config-types.ts +208 -0
  194. package/src/content/index.ts +5 -13
  195. package/src/cookies/define-cookie.ts +9 -7
  196. package/src/cookies/index.ts +6 -5
  197. package/src/index.ts +84 -416
  198. package/src/plugin-context.ts +200 -0
  199. package/src/plugins/adapter-build.ts +1 -1
  200. package/src/plugins/build-manifest.ts +1 -1
  201. package/src/plugins/build-report.ts +1 -1
  202. package/src/plugins/content.ts +1 -1
  203. package/src/plugins/dev-browser-logs.ts +1 -1
  204. package/src/plugins/dev-logs.ts +1 -1
  205. package/src/plugins/dev-server.ts +16 -1
  206. package/src/plugins/entries.ts +2 -2
  207. package/src/plugins/fonts.ts +4 -3
  208. package/src/plugins/mdx.ts +1 -1
  209. package/src/plugins/routing.ts +1 -1
  210. package/src/plugins/shims.ts +53 -5
  211. package/src/plugins/static-build.ts +8 -6
  212. package/src/search-params/define.ts +22 -22
  213. package/src/search-params/index.ts +3 -3
  214. package/src/search-params/registry.ts +1 -1
  215. package/src/segment-params/define.ts +18 -18
  216. package/src/segment-params/index.ts +2 -1
  217. package/src/server/action-handler.ts +1 -1
  218. package/src/server/als-registry.ts +3 -3
  219. package/src/server/dev-holding-server.ts +185 -0
  220. package/src/server/dev-warnings.ts +2 -21
  221. package/src/server/html-injectors.ts +3 -3
  222. package/src/server/index.ts +25 -180
  223. package/src/server/internal.ts +169 -0
  224. package/src/server/pipeline.ts +12 -7
  225. package/src/server/primitives.ts +71 -30
  226. package/src/server/request-context.ts +77 -39
  227. package/src/server/route-element-builder.ts +1 -1
  228. package/src/server/rsc-entry/index.ts +2 -2
  229. package/src/server/rsc-entry/ssr-renderer.ts +1 -1
  230. package/src/server/slot-resolver.ts +1 -1
  231. package/src/server/tracing.ts +6 -6
  232. package/src/server/tree-builder.ts +1 -1
  233. package/src/shims/headers.ts +5 -1
  234. package/src/shims/navigation.ts +5 -1
  235. package/dist/_chunks/als-registry-BJARkOcu.js.map +0 -1
  236. package/dist/_chunks/define-CGuYoRHU.js.map +0 -1
  237. package/dist/_chunks/define-Dz1bqwaS.js.map +0 -1
  238. package/dist/_chunks/error-boundary-D9hzsveV.js +0 -216
  239. package/dist/_chunks/error-boundary-D9hzsveV.js.map +0 -1
  240. package/dist/_chunks/format-Rn922VH2.js.map +0 -1
  241. package/dist/_chunks/handler-store-BVePM7hp.js.map +0 -1
  242. package/dist/_chunks/request-context-CywiO4jV.js.map +0 -1
  243. package/dist/_chunks/segment-context-hzuJ048X.js.map +0 -1
  244. package/dist/_chunks/use-query-states-DAhgj8Gx.js.map +0 -1
  245. package/dist/client/browser-entry.d.ts +0 -21
  246. package/dist/client/browser-entry.d.ts.map +0 -1
  247. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  248. package/src/client/browser-entry.ts +0 -846
@@ -1,57 +1,37 @@
1
1
  // @timber-js/app/client — Client-side primitives
2
2
  // These are the primary imports for client components.
3
+ //
4
+ // Framework-internal bootstrap, SSR bridge, and segment plumbing is in
5
+ // #client-internal (Node package import).
6
+ // Design doc: design/triage/api-naming-spike.md §8.5
3
7
 
4
- export type { JsonSerializable, RenderErrorDigest } from './types';
8
+ // JsonSerializable moved to @timber-js/app/codec as the single canonical path.
9
+ // Re-export removed per TIM-721.
10
+ export type { RenderErrorDigest } from './types';
5
11
 
6
12
  // Navigation
7
13
  export { Link, interpolateParams, resolveHref, validateLinkHref, buildLinkProps } from './link';
8
14
  export { mergePreservedSearchParams } from '../shared/merge-search-params.js';
9
15
  export type { LinkFunction, LinkProps, LinkPropsWithHref, LinkPropsWithParams } from './link';
10
16
  export type { LinkSegmentParams, OnNavigateHandler, OnNavigateEvent } from './link';
11
- export { createRouter } from './router';
12
- export type {
13
- RouterInstance,
14
- NavigationOptions,
15
- RouterDeps,
16
- RouterPhase,
17
- RscDecoder,
18
- RootRenderer,
19
- } from './router';
20
- export { useNavigationPending } from './use-navigation-pending';
17
+ export { usePendingNavigation } from './use-pending-navigation';
21
18
  export { useLinkStatus, LinkStatusContext } from './use-link-status';
22
19
  export type { LinkStatus } from './use-link-status';
23
- export { getRouter, getRouterOrNull, setGlobalRouter } from './router-ref';
24
20
  export { useRouter } from './use-router';
25
21
  export type { AppRouterInstance } from './use-router';
26
22
  export { usePathname } from './use-pathname';
27
23
  export { useSearchParams } from './use-search-params';
28
24
  export { useSelectedLayoutSegment, useSelectedLayoutSegments } from './use-selected-layout-segment';
29
25
 
30
- // Segment context (internal, used by rsc-entry to inject layout position)
31
- export { SegmentProvider, useSegmentContext } from './segment-context';
32
- export type { SegmentContextValue } from './segment-context';
33
-
34
- // Segment cache (internal, but exported for advanced use)
35
- export { SegmentCache, PrefetchCache } from './segment-cache';
36
- export type { SegmentNode, StateTree } from './segment-cache';
37
-
38
- // History (internal, but exported for advanced use)
39
- export { HistoryStack } from './history';
40
- export type { HistoryEntry } from './history';
41
-
42
26
  // Forms
43
27
  export { useActionState, useFormAction, useFormErrors } from './form';
44
28
  export type { UseActionStateFn, UseActionStateReturn, FormErrorsResult } from './form';
45
29
 
46
30
  // Params
47
- export { useSegmentParams, setCurrentParams } from './use-params';
48
-
49
- // Navigation context (framework-internal, used by browser-entry for atomic updates)
50
- export { NavigationProvider, getNavigationState, setNavigationState } from './navigation-context';
51
- export type { NavigationState } from './navigation-context';
31
+ export { useSegmentParams } from './use-params';
52
32
 
53
33
  // Query states (URL-synced search params)
54
- export { useQueryStates, bindUseQueryStates } from './use-query-states';
34
+ export { useQueryStates } from './use-query-states';
55
35
 
56
36
  // Cookies
57
37
  export { useCookie } from './use-cookie';
@@ -63,11 +43,3 @@ export type { ClientCookieOptions, CookieSetter } from './use-cookie';
63
43
  import * as _useCookieMod from './use-cookie.js';
64
44
  import { _registerUseCookieModule } from '../cookies/define-cookie.js';
65
45
  _registerUseCookieModule(_useCookieMod);
66
-
67
- // SSR data (framework-internal, used by ssr-entry to provide request data to hooks)
68
- export { setSsrData, clearSsrData, getSsrData } from './ssr-data';
69
- export type { SsrData } from './ssr-data';
70
-
71
- // Error boundary (framework-internal, used by tree-builder and rsc-entry)
72
- export { TimberErrorBoundary } from './error-boundary';
73
- export type { TimberErrorBoundaryProps } from './error-boundary';
@@ -0,0 +1,57 @@
1
+ // #client-internal — Framework-internal client exports
2
+ //
3
+ // This module is a Node package import (#client-internal in package.json
4
+ // "imports" field). It is only resolvable from within @timber-js/app —
5
+ // external consumers cannot import it.
6
+ //
7
+ // These exports are consumed by browser-entry, ssr-entry, and build plugins.
8
+ // They are NOT part of the user-facing API and should not appear in
9
+ // documentation or autocomplete for application developers.
10
+ //
11
+ // Design doc: design/triage/api-naming-spike.md §8.5
12
+
13
+ // ── Bootstrap ────────────────────────────────────────────────────────────
14
+ export { createRouter } from './router.js';
15
+ export type {
16
+ RouterInstance,
17
+ NavigationOptions,
18
+ RouterDeps,
19
+ RouterPhase,
20
+ RscDecoder,
21
+ RootRenderer,
22
+ } from './router.js';
23
+ export { getRouter, getRouterOrNull, setGlobalRouter } from './router-ref.js';
24
+
25
+ // ── SSR bridge ───────────────────────────────────────────────────────────
26
+ export { setSsrData, clearSsrData, getSsrData } from './ssr-data.js';
27
+ export type { SsrData } from './ssr-data.js';
28
+
29
+ // ── Segment context ──────────────────────────────────────────────────────
30
+ export { SegmentProvider, useSegmentContext } from './segment-context.js';
31
+ export type { SegmentContextValue } from './segment-context.js';
32
+
33
+ // ── Segment cache ────────────────────────────────────────────────────────
34
+ export { SegmentCache, PrefetchCache } from './segment-cache.js';
35
+ export type { SegmentNode, StateTree } from './segment-cache.js';
36
+
37
+ // ── History ──────────────────────────────────────────────────────────────
38
+ export { HistoryStack } from './history.js';
39
+ export type { HistoryEntry } from './history.js';
40
+
41
+ // ── Params (internal setter) ─────────────────────────────────────────────
42
+ export { setCurrentParams } from './use-params.js';
43
+
44
+ // ── Navigation context ───────────────────────────────────────────────────
45
+ export {
46
+ NavigationProvider,
47
+ getNavigationState,
48
+ setNavigationState,
49
+ } from './navigation-context.js';
50
+ export type { NavigationState } from './navigation-context.js';
51
+
52
+ // ── Query states (internal binder) ───────────────────────────────────────
53
+ export { bindUseQueryStates } from './use-query-states.js';
54
+
55
+ // ── Error boundary ───────────────────────────────────────────────────────
56
+ export { TimberErrorBoundary } from './error-boundary.js';
57
+ export type { TimberErrorBoundaryProps } from './error-boundary.js';
@@ -63,10 +63,14 @@ export interface NavigationState {
63
63
  * variables) because the ESM bundler can duplicate this module across
64
64
  * chunks. Module-level variables would create separate instances per
65
65
  * chunk — the provider in NavigationRoot (index chunk) would use
66
- * context A while the consumer in useNavigationPending (shared chunk)
66
+ * context A while the consumer in usePendingNavigation (shared chunk)
67
67
  * reads from context B. globalThis guarantees a single instance.
68
68
  *
69
69
  * See design/27-chunking-strategy.md §"Singleton Safety"
70
+ *
71
+ * NOTE: Despite similar naming, `usePendingNavigationUrl()` here is an
72
+ * internal helper — the public hook is `usePendingNavigation()` in
73
+ * use-pending-navigation.ts.
70
74
  */
71
75
 
72
76
  // Symbol keys for globalThis storage — prevents collisions with user code
@@ -168,7 +172,7 @@ export function getNavigationState(): NavigationState {
168
172
 
169
173
  /**
170
174
  * Separate context for the in-flight navigation URL. Provided by
171
- * NavigationRoot (urgent useState), consumed by useNavigationPending
175
+ * NavigationRoot (urgent useState), consumed by usePendingNavigation
172
176
  * and TopLoader. Per-link pending state uses useOptimistic instead
173
177
  * (see link-pending-store.ts).
174
178
  *
@@ -195,7 +195,7 @@ export function NavigationRoot({
195
195
  // both apply in the same React commit — making the pending→active transition
196
196
  // atomic (no frame where pending is false but the old tree is still visible).
197
197
  _navigateTransition = (url: string, perform: () => Promise<ReactNode>) => {
198
- // Urgent: show pending state immediately (for TopLoader / useNavigationPending)
198
+ // Urgent: show pending state immediately (for TopLoader / usePendingNavigation)
199
199
  setPendingUrl(url);
200
200
 
201
201
  // Increment the transition counter SYNCHRONOUSLY (before startTransition
@@ -18,7 +18,7 @@ export function setGlobalRouter(router: RouterInstance): void {
18
18
 
19
19
  /**
20
20
  * Get the global router instance. Throws if called before bootstrap.
21
- * Used by client-side hooks (useNavigationPending, etc.)
21
+ * Used by client-side hooks (usePendingNavigation, etc.)
22
22
  */
23
23
  export function getRouter(): RouterInstance {
24
24
  if (!globalRouter) {
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Configuration is via timber.config.ts `topLoader` key. Enabled by default.
9
9
  * Users who want a fully custom progress indicator disable the built-in one
10
- * (`topLoader: { enabled: false }`) and use `useNavigationPending()` directly.
10
+ * (`topLoader: { enabled: false }`) and use `usePendingNavigation()` directly.
11
11
  *
12
12
  * Animation approach: pure CSS @keyframes. The bar crawls from 0% to ~90%
13
13
  * width over ~30s using ease-out timing. When navigation completes, the bar
@@ -21,7 +21,7 @@
21
21
  * stays invisible during the delay period. If navigation finishes before the
22
22
  * delay, the bar was never visible so the finish transition is also invisible.
23
23
  *
24
- * See design/19-client-navigation.md §"useNavigationPending()"
24
+ * See design/19-client-navigation.md §"usePendingNavigation()"
25
25
  * See LOCAL-336 for design decisions.
26
26
  */
27
27
 
@@ -20,7 +20,7 @@ export const LinkStatusContext = createContext<LinkStatus>({ pending: false });
20
20
  * Returns `{ pending: true }` while the nearest parent `<Link>` component's
21
21
  * navigation is in flight. Must be used inside a `<Link>` component's children.
22
22
  *
23
- * Unlike `useNavigationPending()` which is global, this hook is scoped to
23
+ * Unlike `usePendingNavigation()` which is global, this hook is scoped to
24
24
  * the nearest parent `<Link>` — only the link the user clicked shows pending.
25
25
  *
26
26
  * ```tsx
@@ -1,5 +1,5 @@
1
- // useNavigationPending — returns true while an RSC navigation is in flight.
2
- // See design/19-client-navigation.md §"useNavigationPending()"
1
+ // usePendingNavigation — returns true while an RSC navigation is in flight.
2
+ // See design/19-client-navigation.md §"usePendingNavigation()"
3
3
  //
4
4
  // Reads from PendingNavigationContext (provided by NavigationRoot) so the
5
5
  // pending state shows immediately (urgent update) and clears atomically
@@ -19,10 +19,10 @@ import { usePendingNavigationUrl } from './navigation-context.js';
19
19
  *
20
20
  * ```tsx
21
21
  * 'use client'
22
- * import { useNavigationPending } from '@timber-js/app/client'
22
+ * import { usePendingNavigation } from '@timber-js/app/client'
23
23
  *
24
24
  * export function NavBar() {
25
- * const isPending = useNavigationPending()
25
+ * const isPending = usePendingNavigation()
26
26
  * return (
27
27
  * <nav className={isPending ? 'opacity-50' : ''}>
28
28
  * <Link href="/dashboard">Dashboard</Link>
@@ -31,7 +31,7 @@ import { usePendingNavigationUrl } from './navigation-context.js';
31
31
  * }
32
32
  * ```
33
33
  */
34
- export function useNavigationPending(): boolean {
34
+ export function usePendingNavigation(): boolean {
35
35
  const pendingUrl = usePendingNavigationUrl();
36
36
  // During SSR or outside PendingNavigationProvider, no navigation is pending
37
37
  return pendingUrl !== null;
@@ -18,7 +18,7 @@ import type {
18
18
  SetParams,
19
19
  QueryStatesOptions,
20
20
  } from '../search-params/define.js';
21
- import { getSearchParams } from '../search-params/registry.js';
21
+ import { getSearchParamsDefinition } from '../search-params/registry.js';
22
22
 
23
23
  // ─── Codec Bridge ─────────────────────────────────────────────────
24
24
 
@@ -79,7 +79,7 @@ export function useQueryStates<T extends Record<string, unknown>>(
79
79
  let codecs: { [K in keyof T]: SearchParamCodec<T[K]> };
80
80
  let resolvedUrlKeys = urlKeys;
81
81
  if (typeof codecsOrRoute === 'string') {
82
- const definition = getSearchParams(codecsOrRoute);
82
+ const definition = getSearchParamsDefinition(codecsOrRoute);
83
83
  if (!definition) {
84
84
  throw new Error(
85
85
  `useQueryStates('${codecsOrRoute}'): no search params registered for this route. ` +
@@ -20,7 +20,7 @@
20
20
  *
21
21
  * For loading UI during navigation, use:
22
22
  * - useLinkStatus() — per-link pending indicator (inside <Link>)
23
- * - useNavigationPending() — global navigation pending state
23
+ * - usePendingNavigation() — global navigation pending state
24
24
  */
25
25
 
26
26
  import { getRouterOrNull } from './router-ref.js';
package/src/codec.ts CHANGED
@@ -22,6 +22,21 @@ export interface Codec<T> {
22
22
  serialize(value: T): string | null;
23
23
  }
24
24
 
25
+ /**
26
+ * Recursive JSON-serializable type. The canonical definition for data that
27
+ * can safely cross the RSC → client boundary.
28
+ *
29
+ * Previously exported from both @timber-js/app/server and @timber-js/app/client.
30
+ * Moved here so there is exactly one canonical import path.
31
+ */
32
+ export type JsonSerializable =
33
+ | string
34
+ | number
35
+ | boolean
36
+ | null
37
+ | JsonSerializable[]
38
+ | { [key: string]: JsonSerializable };
39
+
25
40
  // ─── Standard Schema bridge ──────────────────────────────────────────────
26
41
 
27
42
  export {
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Timber configuration types.
3
+ *
4
+ * Extracted to a shared file so both the public entry point (index.ts)
5
+ * and internal plugin-context.ts can import them without circular deps.
6
+ */
7
+
8
+ /** Configuration for client-side JavaScript output. */
9
+ export interface ClientJavascriptConfig {
10
+ /** When true, no client JS bundles are emitted or referenced in HTML. */
11
+ disabled: boolean;
12
+ /**
13
+ * When `disabled` is true, still inject the Vite HMR client in dev mode
14
+ * so hot reloading works during development. Default: true.
15
+ */
16
+ enableHMRInDev?: boolean;
17
+ }
18
+
19
+ export interface TimberUserConfig {
20
+ output?: 'server' | 'static';
21
+ /**
22
+ * Enable timber debug logging in production builds.
23
+ *
24
+ * When `true`, timber's own diagnostics (dev warnings, verbose logging)
25
+ * are active even in production mode. React stays in production mode —
26
+ * only timber's logs are affected.
27
+ *
28
+ * Can also be enabled at runtime via the `TIMBER_DEBUG` environment variable.
29
+ *
30
+ * Default: `false`.
31
+ */
32
+ debug?: boolean;
33
+ /**
34
+ * Control client-side JavaScript output.
35
+ *
36
+ * Boolean shorthand:
37
+ * `clientJavascript: false` disables all client JS (equivalent to `{ disabled: true }`).
38
+ * `clientJavascript: true` enables client JS (the default).
39
+ *
40
+ * Object form:
41
+ * `clientJavascript: { disabled: true, enableHMRInDev: true }` disables client JS
42
+ * in production but preserves Vite HMR in dev mode.
43
+ *
44
+ * When `disabled` is true, `enableHMRInDev` defaults to `true`.
45
+ * Server-side JS still runs — this only affects what is sent to the browser.
46
+ */
47
+ clientJavascript?: boolean | ClientJavascriptConfig;
48
+ adapter?: unknown;
49
+ cacheHandler?: unknown;
50
+ allowedOrigins?: string[];
51
+ csrf?: boolean;
52
+ limits?: {
53
+ actionBodySize?: string;
54
+ uploadBodySize?: string;
55
+ maxFields?: number;
56
+ };
57
+ pageExtensions?: string[];
58
+ /**
59
+ * Slow request threshold in milliseconds. Requests exceeding this emit
60
+ * a warning via the logger. Set to 0 to disable. Default: 3000.
61
+ *
62
+ * See design/17-logging.md §"slowRequestMs".
63
+ */
64
+ slowRequestMs?: number;
65
+ /**
66
+ * Render timeout in milliseconds. If an SSR render or RSC stream read
67
+ * does not complete within this duration, the render is aborted and
68
+ * the connection is closed. Protects against hung fetches and Suspense
69
+ * components that never resolve.
70
+ *
71
+ * Set to 0 to disable (not recommended in production).
72
+ * Default: 30000 (30 seconds).
73
+ *
74
+ * See design/02-rendering-pipeline.md §"Streaming Constraints".
75
+ */
76
+ renderTimeoutMs?: number;
77
+ /**
78
+ * Forward browser console output to the server terminal in dev mode.
79
+ *
80
+ * Sets the minimum log level to forward:
81
+ * - `'error'` — only `console.error`
82
+ * - `'warn'` — `console.error` + `console.warn` (default)
83
+ * - `'info'` — `console.error` + `console.warn` + `console.info`
84
+ * - `'none'` — disabled
85
+ *
86
+ * Does not intercept `console.log` or `console.debug` (too noisy).
87
+ * No effect in production builds.
88
+ *
89
+ * See TIM-513.
90
+ */
91
+ devBrowserLogs?: 'error' | 'warn' | 'info' | 'none';
92
+ /** Dev-mode options. These have no effect in production builds. */
93
+ dev?: {
94
+ /** Threshold in ms to highlight slow phases in dev logging output. Default: 200. */
95
+ slowPhaseMs?: number;
96
+ };
97
+ /**
98
+ * Control Server-Timing header output.
99
+ *
100
+ * - `'detailed'` — per-phase breakdown (proxy, middleware, render). Useful
101
+ * for APM / network monitoring. Exposes phase names to clients.
102
+ * - `'total'` — single `total;dur=N` entry. Safe to expose, gives
103
+ * browser DevTools useful timing without internal details.
104
+ * - `false` — no Server-Timing header at all.
105
+ *
106
+ * Default: `'detailed'` in dev, `'total'` in production.
107
+ *
108
+ * This is separate from `debug` / `TIMBER_DEBUG` — it's an intentional
109
+ * decision to expose timing data to clients, not a side effect of debug
110
+ * logging.
111
+ */
112
+ serverTiming?: 'detailed' | 'total' | false;
113
+ /**
114
+ * Override the app directory location. By default, timber auto-detects
115
+ * `app/` at the project root, falling back to `src/app/`.
116
+ *
117
+ * Set this to a relative path from the project root (e.g. `'src/app'`)
118
+ * to use a custom location.
119
+ */
120
+ appDir?: string;
121
+ /** MDX compilation options passed to @mdx-js/rollup. See design/20-content-collections.md. */
122
+ mdx?: {
123
+ remarkPlugins?: unknown[];
124
+ rehypePlugins?: unknown[];
125
+ recmaPlugins?: unknown[];
126
+ remarkRehypeOptions?: Record<string, unknown>;
127
+ };
128
+ /**
129
+ * Server action bound args encryption configuration.
130
+ *
131
+ * The RSC plugin encrypts closure variables captured by 'use server' functions
132
+ * using AES-256-GCM so they are opaque and tamper-proof in the Flight payload.
133
+ * Encryption is always enabled in production.
134
+ *
135
+ * The encryption key is auto-generated at build time and embedded in the server bundle,
136
+ * so all instances running the same build share the same key automatically.
137
+ * For rolling/blue-green deployments where multiple builds coexist, set
138
+ * `TIMBER_ACTIONS_ENCRYPTION_KEY` env var to share a key across builds.
139
+ *
140
+ * See design/08-forms-and-actions.md §"Security"
141
+ */
142
+ actionEncryption?: {
143
+ /**
144
+ * Disable encryption in dev mode for easier debugging of bound args.
145
+ * Has no effect in production — encryption is always enabled.
146
+ * Default: false (encryption is on in dev too).
147
+ */
148
+ disableInDev?: boolean;
149
+ };
150
+ /**
151
+ * Enable the React Compiler (babel-plugin-react-compiler) for automatic
152
+ * memoization of components and hooks at build time.
153
+ *
154
+ * - `true` — enable with default options
155
+ * - `{ compilationMode, target }` — enable with custom options
156
+ * - `compilationMode: 'annotation'` — only compile files with `'use memo'`
157
+ * - `target: '18'` — target React 18 (uses react-compiler-runtime package)
158
+ * - `false` or omitted — disabled (default)
159
+ *
160
+ * Uses `@vitejs/plugin-react`'s built-in `reactCompilerPreset`, which:
161
+ * - Applies Babel only for the compiler pass (OXC handles JSX)
162
+ * - Automatically scopes to client environment only
163
+ * - Uses `react/compiler-runtime` built into React 19
164
+ *
165
+ * Requires `babel-plugin-react-compiler` as a peer dependency.
166
+ */
167
+ reactCompiler?: boolean | { compilationMode?: string; target?: string };
168
+ /**
169
+ * Auto-generate sitemap.xml from the route tree.
170
+ *
171
+ * When enabled, timber walks the file-system route tree and produces a sitemap
172
+ * for all discoverable pages. Dynamic routes with `generateStaticParams()` are
173
+ * enumerated. Routes protected by `access.ts` are excluded by default.
174
+ *
175
+ * If a user-authored `sitemap.ts` or `sitemap.xml` exists at the app root,
176
+ * auto-generation is disabled — the user takes full control.
177
+ *
178
+ * Supports automatic pagination (sitemap index) for sites with > 50,000 URLs.
179
+ *
180
+ * See design/16-metadata.md §"Auto-generated Sitemap"
181
+ */
182
+ sitemap?: {
183
+ /** Must be explicitly `true` to enable auto-generation. Default: false. */
184
+ enabled?: boolean;
185
+ /** Base URL for absolute URLs in the sitemap. Required when enabled. e.g., 'https://example.com' */
186
+ baseUrl?: string;
187
+ /** Default `<changefreq>` for all entries. Optional. */
188
+ defaultChangeFrequency?: string;
189
+ /** Default `<priority>` for all entries (0.0–1.0). Optional. */
190
+ defaultPriority?: number;
191
+ /** Include routes protected by `access.ts`. Default: false. */
192
+ includeProtected?: boolean;
193
+ };
194
+ topLoader?: {
195
+ /** Whether the top-loader is enabled. Default: true. */
196
+ enabled?: boolean;
197
+ /** Bar color. Default: '#2299DD'. */
198
+ color?: string;
199
+ /** Bar height in pixels. Default: 3. */
200
+ height?: number;
201
+ /** Show subtle glow/shadow effect. Default: true. */
202
+ shadow?: boolean;
203
+ /** Delay in ms before showing the bar (avoids flash on fast navs). Default: 0. */
204
+ delay?: number;
205
+ /** CSS z-index. Default: 1600. */
206
+ zIndex?: number;
207
+ };
208
+ }
@@ -1,13 +1,5 @@
1
- /**
2
- * @timber-js/app/content — Public API for content collections.
3
- *
4
- * Re-exports from content-collections and provides timber-specific utilities.
5
- * Users can import directly from 'content-collections' for generated types,
6
- * or use this module for the re-exports.
7
- *
8
- * Design doc: 20-content-collections.md §"Querying Collections"
9
- */
10
-
11
- // Re-export defineCollection and defineConfig for convenience.
12
- // Users can also import these directly from @content-collections/core.
13
- export { defineCollection, defineConfig } from '@content-collections/core';
1
+ // @timber-js/app/content entry point removed per TIM-722.
2
+ //
3
+ // Import defineCollection and defineConfig directly from @content-collections/core.
4
+ // This file is kept for the content plugin which uses other files in this directory.
5
+ export {};
@@ -130,28 +130,30 @@ export function defineCookie<T>(
130
130
  codec,
131
131
 
132
132
  async getCookie(): Promise<T> {
133
- const { cookies } = await import('../server/request-context.js');
134
- const jar = cookies();
133
+ const { getCookies } = await import('../server/request-context.js');
134
+ const jar = await getCookies();
135
135
  const raw = jar.get(name);
136
136
  return codec.parse(raw);
137
137
  },
138
138
 
139
139
  async setCookie(value: T): Promise<void> {
140
- const { cookies } = await import('../server/request-context.js');
140
+ const { getCookies } = await import('../server/request-context.js');
141
+ const jar = await getCookies();
141
142
  const serialized = codec.serialize(value);
142
143
  if (serialized === null) {
143
- cookies().delete(name, {
144
+ jar.delete(name, {
144
145
  path: resolvedOptions.path,
145
146
  domain: resolvedOptions.domain,
146
147
  });
147
148
  } else {
148
- cookies().set(name, serialized, resolvedOptions);
149
+ jar.set(name, serialized, resolvedOptions);
149
150
  }
150
151
  },
151
152
 
152
153
  async deleteCookie(): Promise<void> {
153
- const { cookies } = await import('../server/request-context.js');
154
- cookies().delete(name, {
154
+ const { getCookies } = await import('../server/request-context.js');
155
+ const jar = await getCookies();
156
+ jar.delete(name, {
155
157
  path: resolvedOptions.path,
156
158
  domain: resolvedOptions.domain,
157
159
  });
@@ -4,9 +4,10 @@
4
4
  export { defineCookie } from './define-cookie.js';
5
5
  export type { CookieDefinition, CookieCodec, DefineCookieOptions } from './define-cookie.js';
6
6
 
7
- // Codec protocol
8
- export type { Codec } from '../codec.js';
7
+ // Codec is the canonical home for the Codec type — import from
8
+ // @timber-js/app/codec. Re-export removed per TIM-721.
9
9
 
10
- // Re-export cookies() so there's one import path for all cookie concerns.
11
- // cookies() is also available from @timber-js/app/server.
12
- export { cookies } from '../server/request-context.js';
10
+ // cookies() is a server-only function (requires AsyncLocalStorage) and is
11
+ // exported from @timber-js/app/server. It is intentionally NOT re-exported
12
+ // here so that client-side code importing defineCookie doesn't pull in
13
+ // server ALS code. See TIM-704.