@timber-js/app 0.2.0-alpha.239 → 0.2.0-alpha.240

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 (332) hide show
  1. package/dist/_chunks/{actions-Top9GftB.js → actions-DIgnvDrG.js} +4 -4
  2. package/dist/_chunks/{actions-Top9GftB.js.map → actions-DIgnvDrG.js.map} +1 -1
  3. package/dist/_chunks/{als-registry-DpygwCp0.js → als-registry-PPYstxK0.js} +2 -1
  4. package/dist/_chunks/{als-registry-DpygwCp0.js.map → als-registry-PPYstxK0.js.map} +1 -1
  5. package/dist/_chunks/{cache-api-Bo8c7XVF.js → cache-api-uWQwuxWb.js} +5 -5
  6. package/dist/_chunks/{cache-api-Bo8c7XVF.js.map → cache-api-uWQwuxWb.js.map} +1 -1
  7. package/dist/_chunks/{chains-DMoHX4yH.js → chains-C7CExrUI.js} +2 -2
  8. package/dist/_chunks/{chains-DMoHX4yH.js.map → chains-C7CExrUI.js.map} +1 -1
  9. package/dist/_chunks/chains-CSslTUdI.js +1 -0
  10. package/dist/_chunks/{classify-BwyAd-dZ.js → classify-Cj9EeZoL.js} +2 -2
  11. package/dist/_chunks/{classify-BwyAd-dZ.js.map → classify-Cj9EeZoL.js.map} +1 -1
  12. package/dist/_chunks/{cli-check-DQAD9MLo.js → cli-check-C3QOAru7.js} +3 -3
  13. package/dist/_chunks/{cli-check-DQAD9MLo.js.map → cli-check-C3QOAru7.js.map} +1 -1
  14. package/dist/_chunks/{cli-schema-sync-C_xNLqBj.js → cli-schema-sync-BRxZz66D.js} +1 -1
  15. package/dist/_chunks/{cli-schema-sync-CmGls3dc.js → cli-schema-sync-DQUS_o3V.js} +2 -2
  16. package/dist/_chunks/{cli-schema-sync-CmGls3dc.js.map → cli-schema-sync-DQUS_o3V.js.map} +1 -1
  17. package/dist/_chunks/{client-dep-entries-C5BTQtFS.js → client-dep-entries-ZETBdLgv.js} +2 -2
  18. package/dist/_chunks/{client-dep-entries-C5BTQtFS.js.map → client-dep-entries-ZETBdLgv.js.map} +1 -1
  19. package/dist/_chunks/{convention-lint-GQA6WTRo.js → convention-lint-BoVISNS6.js} +3 -3
  20. package/dist/_chunks/{convention-lint-GQA6WTRo.js.map → convention-lint-BoVISNS6.js.map} +1 -1
  21. package/dist/_chunks/dev-server-B8roKA3Q.js +1 -0
  22. package/dist/_chunks/{dev-server-Cr3_Fu5A.js → dev-server-C5R6jx8Q.js} +2 -2
  23. package/dist/_chunks/{dev-server-Cr3_Fu5A.js.map → dev-server-C5R6jx8Q.js.map} +1 -1
  24. package/dist/_chunks/{dev-span-RsVeYYc_.js → dev-span-0aG7Q_Ph.js} +3 -7
  25. package/dist/_chunks/dev-span-0aG7Q_Ph.js.map +1 -0
  26. package/dist/_chunks/{error-boundary-Bh-egWUI.js → error-boundary-DB51f9ih.js} +98 -419
  27. package/dist/_chunks/error-boundary-DB51f9ih.js.map +1 -0
  28. package/dist/_chunks/{flight-source-node-BsrlUjMO.js → flight-source-node-D9cHBhjP.js} +7 -4
  29. package/dist/_chunks/flight-source-node-D9cHBhjP.js.map +1 -0
  30. package/dist/_chunks/{json-lossy-check-D47R9Fp5.js → json-lossy-check-Y1GxqVX_.js} +2 -2
  31. package/dist/_chunks/{json-lossy-check-D47R9Fp5.js.map → json-lossy-check-Y1GxqVX_.js.map} +1 -1
  32. package/dist/_chunks/{live-graph-HcLScfiV.js → live-graph-BDQWvnMm.js} +4 -4
  33. package/dist/_chunks/{live-graph-HcLScfiV.js.map → live-graph-BDQWvnMm.js.map} +1 -1
  34. package/dist/_chunks/{logger-DDLtp5e-.js → logger-DmRR9tmZ.js} +2 -2
  35. package/dist/_chunks/{logger-DDLtp5e-.js.map → logger-DmRR9tmZ.js.map} +1 -1
  36. package/dist/_chunks/metadata-routes-MXNjWOt5.js.map +1 -1
  37. package/dist/_chunks/{node-response-omewa8e6.js → node-response-yp8zdyRp.js} +2 -2
  38. package/dist/_chunks/{node-response-omewa8e6.js.map → node-response-yp8zdyRp.js.map} +1 -1
  39. package/dist/_chunks/plugin-context-BtaQcMuh.js.map +1 -1
  40. package/dist/_chunks/{poison-scan-DONdiCGX.js → poison-scan-WQgUydF_.js} +2 -2
  41. package/dist/_chunks/{poison-scan-DONdiCGX.js.map → poison-scan-WQgUydF_.js.map} +1 -1
  42. package/dist/_chunks/{scanner-DSAJjH0x.js → scanner-C9Lrf77z.js} +3 -2
  43. package/dist/_chunks/{scanner-DSAJjH0x.js.map → scanner-C9Lrf77z.js.map} +1 -1
  44. package/dist/_chunks/{sizeof-DVhEVN_y.js → sizeof-BISkSaU0.js} +2 -2
  45. package/dist/_chunks/{sizeof-DVhEVN_y.js.map → sizeof-BISkSaU0.js.map} +1 -1
  46. package/dist/_chunks/{walkers-96YopJds.js → walkers-Bxv4v7tX.js} +3 -3
  47. package/dist/_chunks/{walkers-96YopJds.js.map → walkers-Bxv4v7tX.js.map} +1 -1
  48. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  49. package/dist/analyze/crawl-entry.js +3 -3
  50. package/dist/analyze/graph-command.js +2 -2
  51. package/dist/cache/index.js +2 -2
  52. package/dist/cache/stores/memory.js +1 -1
  53. package/dist/cdn/workers-cache-purge.js +1 -1
  54. package/dist/cli.js +3 -3
  55. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
  56. package/dist/client/browser-entry/hydrate.d.ts +1 -1
  57. package/dist/client/browser-entry/router-init.d.ts.map +1 -1
  58. package/dist/client/error-boundary.d.ts +1 -0
  59. package/dist/client/error-boundary.d.ts.map +1 -1
  60. package/dist/client/error-boundary.js +1 -1
  61. package/dist/client/history.d.ts +4 -5
  62. package/dist/client/history.d.ts.map +1 -1
  63. package/dist/client/index.js +6 -7
  64. package/dist/client/index.js.map +1 -1
  65. package/dist/client/internal.d.ts +1 -1
  66. package/dist/client/internal.d.ts.map +1 -1
  67. package/dist/client/internal.js +194 -55
  68. package/dist/client/internal.js.map +1 -1
  69. package/dist/client/navigation-commit.d.ts +6 -25
  70. package/dist/client/navigation-commit.d.ts.map +1 -1
  71. package/dist/client/outlet-content-cache.d.ts +59 -0
  72. package/dist/client/outlet-content-cache.d.ts.map +1 -0
  73. package/dist/client/outlet-scope-context.d.ts +30 -0
  74. package/dist/client/outlet-scope-context.d.ts.map +1 -0
  75. package/dist/client/params-context.d.ts +10 -11
  76. package/dist/client/params-context.d.ts.map +1 -1
  77. package/dist/client/router-pipeline.d.ts +5 -5
  78. package/dist/client/router-pipeline.d.ts.map +1 -1
  79. package/dist/client/router-types.d.ts +10 -24
  80. package/dist/client/router-types.d.ts.map +1 -1
  81. package/dist/client/router.d.ts.map +1 -1
  82. package/dist/client/rsc-fetch.d.ts +4 -17
  83. package/dist/client/rsc-fetch.d.ts.map +1 -1
  84. package/dist/client/segment-cache.d.ts +15 -103
  85. package/dist/client/segment-cache.d.ts.map +1 -1
  86. package/dist/client/segment-outlet.d.ts +28 -52
  87. package/dist/client/segment-outlet.d.ts.map +1 -1
  88. package/dist/client/stale-segment.d.ts +39 -0
  89. package/dist/client/stale-segment.d.ts.map +1 -0
  90. package/dist/client/use-segment-params.d.ts +1 -1
  91. package/dist/config-types.d.ts +7 -6
  92. package/dist/config-types.d.ts.map +1 -1
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +9 -732
  95. package/dist/index.js.map +1 -1
  96. package/dist/native/rsc/manifest.json +6 -4
  97. package/dist/native/rsc/routing/segment-keys.js +3 -11
  98. package/dist/native/rsc/routing/segment-keys.js.map +1 -1
  99. package/dist/native/rsc/server/access-gate.js +3 -7
  100. package/dist/native/rsc/server/access-gate.js.map +1 -1
  101. package/dist/native/rsc/server/als-registry.js +2 -1
  102. package/dist/native/rsc/server/als-registry.js.map +1 -1
  103. package/dist/native/rsc/server/build-manifest.js.map +1 -1
  104. package/dist/native/rsc/server/chain-url-parts.js +1 -6
  105. package/dist/native/rsc/server/chain-url-parts.js.map +1 -1
  106. package/dist/native/rsc/server/client-state-tree.js +33 -0
  107. package/dist/native/rsc/server/client-state-tree.js.map +1 -0
  108. package/dist/native/rsc/server/flight-source-node.js +5 -2
  109. package/dist/native/rsc/server/flight-source-node.js.map +1 -1
  110. package/dist/native/rsc/server/flight-source.js +46 -7
  111. package/dist/native/rsc/server/flight-source.js.map +1 -1
  112. package/dist/native/rsc/server/pipeline-interception.js +1 -1
  113. package/dist/native/rsc/server/publish-params.js.map +1 -1
  114. package/dist/native/rsc/server/route-element-builder.js +43 -61
  115. package/dist/native/rsc/server/route-element-builder.js.map +1 -1
  116. package/dist/native/rsc/server/rsc-entry/helpers.js +5 -28
  117. package/dist/native/rsc/server/rsc-entry/helpers.js.map +1 -1
  118. package/dist/native/rsc/server/rsc-entry/render-route.js +33 -7
  119. package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
  120. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js +2 -1
  121. package/dist/native/rsc/server/rsc-entry/revalidate-renderer.js.map +1 -1
  122. package/dist/native/rsc/server/rsc-entry/rsc-payload.js +2 -5
  123. package/dist/native/rsc/server/rsc-entry/rsc-payload.js.map +1 -1
  124. package/dist/native/rsc/server/rsc-entry/rsc-stream.js +44 -40
  125. package/dist/native/rsc/server/rsc-entry/rsc-stream.js.map +1 -1
  126. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js +1 -1
  127. package/dist/native/rsc/server/rsc-entry/ssr-renderer.js.map +1 -1
  128. package/dist/native/rsc/server/segment-hash/capture.js +107 -0
  129. package/dist/native/rsc/server/segment-hash/capture.js.map +1 -0
  130. package/dist/native/rsc/server/segment-hash/outlet.js +81 -0
  131. package/dist/native/rsc/server/segment-hash/outlet.js.map +1 -0
  132. package/dist/native/rsc/server/segment-hash/stream-tap.js +139 -0
  133. package/dist/native/rsc/server/segment-hash/stream-tap.js.map +1 -0
  134. package/dist/native/rsc/server/segment-hash/value-hash.js +171 -0
  135. package/dist/native/rsc/server/segment-hash/value-hash.js.map +1 -0
  136. package/dist/native/rsc/server/slot-resolver.js +20 -124
  137. package/dist/native/rsc/server/slot-resolver.js.map +1 -1
  138. package/dist/native/rsc/server/vite-handoff-rsc.js.map +1 -1
  139. package/dist/native/rsc/shared/outlet-decision.js +5 -0
  140. package/dist/native/rsc/shared/outlet-decision.js.map +1 -0
  141. package/dist/native/ssr/client/error-boundary.js +16 -3
  142. package/dist/native/ssr/client/error-boundary.js.map +1 -1
  143. package/dist/native/ssr/client/navigation-commit.js +1 -5
  144. package/dist/native/ssr/client/navigation-commit.js.map +1 -1
  145. package/dist/native/ssr/client/outlet-content-cache.js +53 -0
  146. package/dist/native/ssr/client/outlet-content-cache.js.map +1 -0
  147. package/dist/native/ssr/client/outlet-scope-context.js +12 -0
  148. package/dist/native/ssr/client/outlet-scope-context.js.map +1 -0
  149. package/dist/native/ssr/client/params-context.js.map +1 -1
  150. package/dist/native/ssr/client/rsc-fetch.js +1 -12
  151. package/dist/native/ssr/client/rsc-fetch.js.map +1 -1
  152. package/dist/native/ssr/client/segment-outlet.js +34 -13
  153. package/dist/native/ssr/client/segment-outlet.js.map +1 -1
  154. package/dist/native/ssr/client/stale-segment.js +29 -0
  155. package/dist/native/ssr/client/stale-segment.js.map +1 -0
  156. package/dist/native/ssr/manifest.json +5 -4
  157. package/dist/native/ssr/routing/segment-keys.js +5 -1
  158. package/dist/native/ssr/routing/segment-keys.js.map +1 -1
  159. package/dist/native/ssr/server/access-gate.js +3 -7
  160. package/dist/native/ssr/server/access-gate.js.map +1 -1
  161. package/dist/native/ssr/server/als-registry.js +1 -0
  162. package/dist/native/ssr/server/als-registry.js.map +1 -1
  163. package/dist/native/ssr/server/build-manifest.js.map +1 -1
  164. package/dist/native/ssr/server/client-state-tree.js +33 -0
  165. package/dist/native/ssr/server/client-state-tree.js.map +1 -0
  166. package/dist/native/ssr/server/flight-source-node.js +5 -2
  167. package/dist/native/ssr/server/flight-source-node.js.map +1 -1
  168. package/dist/native/ssr/server/flight-source.js +1 -0
  169. package/dist/native/ssr/server/flight-source.js.map +1 -1
  170. package/dist/native/ssr/server/pipeline-interception.js +1 -1
  171. package/dist/native/ssr/server/segment-hash/value-hash.js +162 -0
  172. package/dist/native/ssr/server/segment-hash/value-hash.js.map +1 -0
  173. package/dist/native/ssr/server/ssr-wrappers.js.map +1 -1
  174. package/dist/native/ssr/server/vite-handoff-rsc.js.map +1 -1
  175. package/dist/native/ssr/shared/payload-root.js.map +1 -1
  176. package/dist/plugin-context.d.ts +0 -16
  177. package/dist/plugin-context.d.ts.map +1 -1
  178. package/dist/plugins/build-manifest.d.ts.map +1 -1
  179. package/dist/routing/index.js +2 -2
  180. package/dist/routing/segment-keys.d.ts +8 -21
  181. package/dist/routing/segment-keys.d.ts.map +1 -1
  182. package/dist/server/access-gate.d.ts +0 -14
  183. package/dist/server/access-gate.d.ts.map +1 -1
  184. package/dist/server/als-registry.d.ts +16 -0
  185. package/dist/server/als-registry.d.ts.map +1 -1
  186. package/dist/server/build-manifest.d.ts +1 -10
  187. package/dist/server/build-manifest.d.ts.map +1 -1
  188. package/dist/server/chain-url-parts.d.ts +3 -13
  189. package/dist/server/chain-url-parts.d.ts.map +1 -1
  190. package/dist/server/client-state-tree.d.ts +31 -0
  191. package/dist/server/client-state-tree.d.ts.map +1 -0
  192. package/dist/server/flight-source-node.d.ts +6 -1
  193. package/dist/server/flight-source-node.d.ts.map +1 -1
  194. package/dist/server/flight-source.d.ts +27 -0
  195. package/dist/server/flight-source.d.ts.map +1 -1
  196. package/dist/server/index.js +2 -2
  197. package/dist/server/internal.js +48 -47
  198. package/dist/server/internal.js.map +1 -1
  199. package/dist/server/publish-params.d.ts +5 -4
  200. package/dist/server/publish-params.d.ts.map +1 -1
  201. package/dist/server/route-element-builder.d.ts +4 -19
  202. package/dist/server/route-element-builder.d.ts.map +1 -1
  203. package/dist/server/rsc-entry/helpers.d.ts +7 -13
  204. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  205. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  206. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
  207. package/dist/server/rsc-entry/rsc-payload.d.ts +1 -2
  208. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  209. package/dist/server/rsc-entry/rsc-stream.d.ts +11 -2
  210. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  211. package/dist/server/rsc-entry/ssr-renderer.d.ts +0 -2
  212. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  213. package/dist/server/segment-hash/capture.d.ts +77 -0
  214. package/dist/server/segment-hash/capture.d.ts.map +1 -0
  215. package/dist/server/segment-hash/outlet.d.ts +65 -0
  216. package/dist/server/segment-hash/outlet.d.ts.map +1 -0
  217. package/dist/server/segment-hash/stream-tap.d.ts +49 -0
  218. package/dist/server/segment-hash/stream-tap.d.ts.map +1 -0
  219. package/dist/server/segment-hash/value-hash.d.ts +70 -0
  220. package/dist/server/segment-hash/value-hash.d.ts.map +1 -0
  221. package/dist/server/slot-resolver.d.ts +13 -78
  222. package/dist/server/slot-resolver.d.ts.map +1 -1
  223. package/dist/server/ssr-wrappers.d.ts +7 -9
  224. package/dist/server/ssr-wrappers.d.ts.map +1 -1
  225. package/dist/server/vite-handoff-rsc.d.ts +10 -1
  226. package/dist/server/vite-handoff-rsc.d.ts.map +1 -1
  227. package/dist/shared/outlet-decision.d.ts +48 -0
  228. package/dist/shared/outlet-decision.d.ts.map +1 -0
  229. package/dist/shared/payload-root.d.ts +5 -8
  230. package/dist/shared/payload-root.d.ts.map +1 -1
  231. package/dist/shared/segment-info.d.ts +13 -28
  232. package/dist/shared/segment-info.d.ts.map +1 -1
  233. package/package.json +1 -1
  234. package/src/client/browser-entry/action-dispatch.ts +1 -15
  235. package/src/client/browser-entry/hydrate.ts +3 -3
  236. package/src/client/browser-entry/router-init.ts +28 -47
  237. package/src/client/error-boundary.tsx +49 -9
  238. package/src/client/history.ts +4 -5
  239. package/src/client/internal.ts +1 -1
  240. package/src/client/navigation-commit.ts +25 -83
  241. package/src/client/outlet-content-cache.ts +119 -0
  242. package/src/client/outlet-scope-context.ts +42 -0
  243. package/src/client/params-context.ts +11 -12
  244. package/src/client/router-pipeline.ts +10 -74
  245. package/src/client/router-types.ts +11 -26
  246. package/src/client/router.ts +7 -22
  247. package/src/client/rsc-fetch.ts +5 -30
  248. package/src/client/segment-cache.ts +19 -264
  249. package/src/client/segment-outlet.tsx +80 -72
  250. package/src/client/stale-segment.ts +60 -0
  251. package/src/client/use-segment-params.ts +1 -1
  252. package/src/config-types.ts +7 -6
  253. package/src/index.ts +0 -2
  254. package/src/plugin-context.ts +0 -16
  255. package/src/plugins/build-manifest.ts +1 -22
  256. package/src/routing/scanner.ts +12 -0
  257. package/src/routing/segment-keys.ts +9 -35
  258. package/src/rsc-runtime/vendor-types.d.ts +8 -0
  259. package/src/server/access-gate.tsx +3 -32
  260. package/src/server/als-registry.ts +23 -0
  261. package/src/server/build-manifest.ts +1 -11
  262. package/src/server/chain-url-parts.ts +3 -21
  263. package/src/server/client-state-tree.ts +75 -0
  264. package/src/server/flight-source-node.ts +7 -2
  265. package/src/server/flight-source.ts +102 -9
  266. package/src/server/pipeline-interception.ts +1 -1
  267. package/src/server/publish-params.ts +5 -4
  268. package/src/server/route-element-builder.ts +77 -206
  269. package/src/server/rsc-entry/helpers.ts +11 -65
  270. package/src/server/rsc-entry/render-route.ts +54 -28
  271. package/src/server/rsc-entry/revalidate-renderer.ts +2 -1
  272. package/src/server/rsc-entry/rsc-payload.ts +11 -39
  273. package/src/server/rsc-entry/rsc-stream.ts +123 -101
  274. package/src/server/rsc-entry/ssr-renderer.ts +1 -3
  275. package/src/server/segment-hash/capture.ts +232 -0
  276. package/src/server/segment-hash/outlet.ts +185 -0
  277. package/src/server/segment-hash/stream-tap.ts +244 -0
  278. package/src/server/segment-hash/value-hash.ts +338 -0
  279. package/src/server/slot-resolver.ts +37 -323
  280. package/src/server/ssr-wrappers.tsx +7 -9
  281. package/src/server/vite-handoff-rsc.ts +12 -1
  282. package/src/shared/outlet-decision.ts +54 -0
  283. package/src/shared/payload-root.ts +5 -8
  284. package/src/shared/segment-info.ts +13 -28
  285. package/dist/_chunks/chains-CmzbpG-6.js +0 -1
  286. package/dist/_chunks/dev-server--4_Ogy_6.js +0 -1
  287. package/dist/_chunks/dev-span-RsVeYYc_.js.map +0 -1
  288. package/dist/_chunks/error-boundary-Bh-egWUI.js.map +0 -1
  289. package/dist/_chunks/flight-source-node-BsrlUjMO.js.map +0 -1
  290. package/dist/client/segment-update-context.d.ts +0 -15
  291. package/dist/client/segment-update-context.d.ts.map +0 -1
  292. package/dist/client/slot-content-cache-context.d.ts +0 -35
  293. package/dist/client/slot-content-cache-context.d.ts.map +0 -1
  294. package/dist/native/rsc/server/request-dep.js +0 -12
  295. package/dist/native/rsc/server/request-dep.js.map +0 -1
  296. package/dist/native/rsc/server/route-element-helpers.js +0 -20
  297. package/dist/native/rsc/server/route-element-helpers.js.map +0 -1
  298. package/dist/native/rsc/server/skippable-prefix.js +0 -72
  299. package/dist/native/rsc/server/skippable-prefix.js.map +0 -1
  300. package/dist/native/rsc/server/state-tree-diff.js +0 -35
  301. package/dist/native/rsc/server/state-tree-diff.js.map +0 -1
  302. package/dist/native/ssr/client/segment-cache.js +0 -119
  303. package/dist/native/ssr/client/segment-cache.js.map +0 -1
  304. package/dist/native/ssr/client/segment-update-context.js +0 -9
  305. package/dist/native/ssr/client/segment-update-context.js.map +0 -1
  306. package/dist/native/ssr/client/slot-content-cache-context.js +0 -8
  307. package/dist/native/ssr/client/slot-content-cache-context.js.map +0 -1
  308. package/dist/native/ssr/server/state-tree-diff.js +0 -23
  309. package/dist/native/ssr/server/state-tree-diff.js.map +0 -1
  310. package/dist/plugins/request-dep/analysis.d.ts +0 -106
  311. package/dist/plugins/request-dep/analysis.d.ts.map +0 -1
  312. package/dist/plugins/request-dep/index.d.ts +0 -75
  313. package/dist/plugins/request-dep/index.d.ts.map +0 -1
  314. package/dist/plugins/request-dep/origin.d.ts +0 -61
  315. package/dist/plugins/request-dep/origin.d.ts.map +0 -1
  316. package/dist/server/request-dep.d.ts +0 -15
  317. package/dist/server/request-dep.d.ts.map +0 -1
  318. package/dist/server/route-element-helpers.d.ts +0 -12
  319. package/dist/server/route-element-helpers.d.ts.map +0 -1
  320. package/dist/server/skippable-prefix.d.ts +0 -29
  321. package/dist/server/skippable-prefix.d.ts.map +0 -1
  322. package/dist/server/state-tree-diff.d.ts +0 -78
  323. package/dist/server/state-tree-diff.d.ts.map +0 -1
  324. package/src/client/segment-update-context.ts +0 -23
  325. package/src/client/slot-content-cache-context.ts +0 -43
  326. package/src/plugins/request-dep/analysis.ts +0 -447
  327. package/src/plugins/request-dep/index.ts +0 -376
  328. package/src/plugins/request-dep/origin.ts +0 -310
  329. package/src/server/request-dep.ts +0 -37
  330. package/src/server/route-element-helpers.ts +0 -37
  331. package/src/server/skippable-prefix.ts +0 -172
  332. package/src/server/state-tree-diff.ts +0 -132
@@ -1,78 +0,0 @@
1
- /**
2
- * State Tree Diffing — Server-side parsing and diffing of X-Timber-State-Tree.
3
- *
4
- * The client sends X-Timber-State-Tree on navigation requests, listing
5
- * the sync segments it has cached. The server diffs this against the
6
- * target route's segments to skip re-rendering unchanged sync layouts.
7
- *
8
- * This is a performance optimization only — NOT a security boundary.
9
- * All access.ts files run regardless of the state tree content.
10
- * A fabricated state tree can only cause extra rendering work or stale
11
- * layouts — never auth bypass.
12
- *
13
- * See design/19-client-navigation.md §"X-Timber-State-Tree Header"
14
- * See design/13-security.md §"State tree manipulation"
15
- */
16
- /** Parsed client state tree with segment paths and optional slot paths. */
17
- export interface ClientStateTree extends Set<string> {
18
- slots?: Set<string> | null;
19
- /**
20
- * `app/` directory paths of the segments currently mounted on the client.
21
- * Read only by interception scoping — never by the skip decisions.
22
- * See design/07-routing.md §"Intercepting Routes" (TIM-1282).
23
- */
24
- treePaths?: Set<string> | null;
25
- }
26
- /**
27
- * Parse the X-Timber-State-Tree header from a request.
28
- *
29
- * Returns a Set of segment paths the client has cached (with an
30
- * additional `slots` property for cached slot paths), or null if
31
- * the header is missing, malformed, or empty. Parsing happens before
32
- * renderToReadableStream — not inside the React render pass.
33
- *
34
- * @returns ClientStateTree with segments and slots, or null if no valid state tree
35
- */
36
- export declare function parseClientStateTree(req: Request): ClientStateTree | null;
37
- /**
38
- * Determine whether a segment's layout rendering can be skipped.
39
- *
40
- * A segment is skipped when ALL of the following are true:
41
- * 1. The client sent a state tree (clientSegments is non-null)
42
- * 2. The client has this segment cached (clientSegments contains urlPath)
43
- * 3. The segment has a layout (otherwise nothing to skip)
44
- * 4. The layout is sync (not an async function — async layouts may depend
45
- * on per-request data and must always re-render)
46
- * 5. The segment is NOT the leaf (pages are never cached across navigations)
47
- *
48
- * Additional constraints enforced by the caller (buildRouteElement):
49
- * - Must have a rendered layout below (so SegmentOutlet has content to show)
50
- * - Skipped segments must form a contiguous prefix from root
51
- *
52
- * Access.ts still runs for skipped segments — this is enforced by the caller
53
- * which wraps with AccessGate regardless of skip status.
54
- *
55
- * @param segmentKey - The segment's state-tree key from computeSegmentKeys()
56
- * @param layoutComponent - The loaded layout component function
57
- * @param isLeaf - Whether this is the leaf segment (page segment)
58
- * @param clientSegments - Set of paths from X-Timber-State-Tree, or null
59
- */
60
- export declare function shouldSkipSegment(segmentKey: string, layoutComponent: ((...args: unknown[]) => unknown) | undefined, isLeaf: boolean, clientSegments: Set<string> | null): boolean;
61
- /**
62
- * Determine whether a parallel route slot can be skipped.
63
- *
64
- * A slot is skipped when the destination content key — computed from the
65
- * owning segment's URL parts, the slot name, the matched entry file, and
66
- * the slot's extracted params — is in the set of keys the client advertised.
67
- *
68
- * This replaced URL-based departing/destination diffing in TIM-1370.
69
- * The previous approach reconstructed the client's state by re-matching a
70
- * departing URL against each slot's sub-tree, which was a recurring bug
71
- * source because the reconstruction could drift from the client's actual
72
- * mounted state. The key-based approach is a single set-membership check.
73
- *
74
- * This is a performance optimization only, NOT a security boundary.
75
- * Slot access.ts always runs via SlotAccessGate regardless.
76
- */
77
- export declare function shouldSkipSlot(contentKey: string, clientSlotKeys: Set<string> | null): boolean;
78
- //# sourceMappingURL=state-tree-diff.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state-tree-diff.d.ts","sourceRoot":"","sources":["../../src/server/state-tree-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,2EAA2E;AAC3E,MAAM,WAAW,eAAgB,SAAQ,GAAG,CAAC,MAAM,CAAC;IAClD,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAwBzE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,SAAS,EAC9D,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GACjC,OAAO,CAaT;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAG9F"}
@@ -1,23 +0,0 @@
1
- /**
2
- * SegmentUpdateContext — React context for partial navigation updates.
3
- *
4
- * During partial navigation (server skips unchanged sync layouts), the
5
- * router builds a Map of segment path → ReactNode updates and passes it
6
- * as the context value. Mounted SegmentOutlet components read from this
7
- * context to decide whether to render the update or their cached content.
8
- *
9
- * Singleton across bundler-duplicated chunks via `createGlobalContext`.
10
- * See design/19-client-navigation.md §"Singleton Guarantee via globalThis"
11
- */
12
-
13
- 'use client';
14
-
15
- import type { ReactNode } from 'react';
16
- import { createGlobalContext } from './global-context.ts';
17
-
18
- export const EMPTY_SEGMENT_UPDATES = new Map<string, ReactNode>();
19
-
20
- export const SegmentUpdateContext = createGlobalContext<Map<string, ReactNode>>(
21
- Symbol.for('__timber_segment_update_ctx'),
22
- EMPTY_SEGMENT_UPDATES
23
- );
@@ -1,43 +0,0 @@
1
- /**
2
- * SlotContentCacheContext — the router-owned record of slot content the
3
- * client has *committed*.
4
- *
5
- * The server omits a parallel slot's content when the client advertised a
6
- * matching content key (`skip=true`, TIM-1370), and the outlet at that
7
- * position must render what it displayed before. This Map, keyed by
8
- * segmentPath, is where that content lives.
9
- *
10
- * Ownership and write discipline (TIM-1423):
11
- *
12
- * - **One instance per router.** `createTimberRouter` creates the Map and
13
- * provides it above every tree it hands to React — hydration included,
14
- * which builds its chain through the same `renderTree`. It is not a
15
- * module or `globalThis` singleton: a process-wide Map executed during
16
- * SSR would be shared by concurrent requests.
17
- * - **Written only at commit.** `SegmentOutlet` writes from a layout effect,
18
- * never during render. A render React discards — a transition superseded
19
- * before it commits, a Suspense retry — leaves the Map untouched, so a
20
- * later `skip=true` can only ever resolve to content the user actually saw.
21
- * The content-key record the client advertises (`SegmentCache`, published
22
- * by `NavigationRoot`'s layout effect on the same commit) and this Map
23
- * are therefore written by the same React commit and cannot describe
24
- * different trees.
25
- * - **`null` outside a router.** SSR renders no provider and the outlet then
26
- * neither reads nor writes: the server never emits `skip` during SSR, and
27
- * layout effects do not run there. The default is `null` rather than a
28
- * shared Map so that "no provider" cannot silently become "shared cache".
29
- *
30
- * Singleton across bundler-duplicated chunks via `createGlobalContext`.
31
- */
32
-
33
- 'use client';
34
-
35
- import type { ReactNode } from 'react';
36
- import { createGlobalContext } from './global-context.ts';
37
-
38
- export type SlotContentCache = Map<string, ReactNode>;
39
-
40
- export const SlotContentCacheContext = createGlobalContext<SlotContentCache | null>(
41
- Symbol.for('__timber_slot_content_cache_ctx'),
42
- null
43
- );
@@ -1,447 +0,0 @@
1
- /**
2
- * Per-module syntactic facts for request-dependency analysis.
3
- *
4
- * This module is deliberately dumb: it records *what the source says*, with no
5
- * knowledge of which specifiers or names are interesting. Every judgement —
6
- * "is this an accessor", "is this a definition object" — lives in `origin.ts`,
7
- * which resolves a binding to the module it actually came from.
8
- *
9
- * That split is the point. The previous shape asked each module in isolation
10
- * "do you import `getSearchParams` from `@timber-js/app/server` and call it",
11
- * which any indirection defeats: a barrel re-export, a namespace import, a
12
- * factory reached through the app's own `_lib`. Each of those was a separate
13
- * hole and each was found separately (TIM-1291). Recording bindings and edges
14
- * here, and resolving them across the graph there, closes the family instead of
15
- * its members.
16
- *
17
- * See design/19-client-navigation.md §"Why the slot comparison ignores the query".
18
- */
19
-
20
- import type {
21
- ProgramNode,
22
- PositionedNode,
23
- IdentifierNode,
24
- CallExpressionNode,
25
- MemberExpressionNode,
26
- } from '../callsite-ast.ts';
27
-
28
- /**
29
- * One module-graph edge introduced by an `import` or `export … from`.
30
- *
31
- * `imported` is the name as it exists in the *source* module: an export name,
32
- * `'default'`, or `'*'` for a namespace/star form.
33
- */
34
- export interface ImportEdge {
35
- source: string;
36
- imported: string;
37
- }
38
-
39
- /** The callee of `const x = f()` / `const x = ns.f()`. */
40
- export type CalleeRef =
41
- | { kind: 'local'; name: string }
42
- | { kind: 'member'; object: string; property: string };
43
-
44
- export interface ModuleFacts {
45
- /** Local name → the edge that bound it (`import { a as b } from 'x'`). */
46
- importedBindings: Map<string, ImportEdge>;
47
- /** Exported name → edge, for `export { a as b } from 'x'`. */
48
- reExports: Map<string, ImportEdge>;
49
- /** Sources of anonymous `export * from 'x'`, in source order. */
50
- starReExports: string[];
51
- /** Exported name → local name, for `export { x }`, `export const x = …`. */
52
- localExports: Map<string, string>;
53
- /** Local variable name → the callee that produced its value. */
54
- factoryCalls: Map<string, CalleeRef>;
55
- /** Local names invoked directly: `f()`. */
56
- calledLocals: Set<string>;
57
- /** `ns.f()` → `ns` → `{ f }`. */
58
- calledMembers: Map<string, Set<string>>;
59
- /** Base identifier of a `.get()` chain: `x.get()`, `x().get()`, `x.p.get()`. */
60
- getterLocals: Set<string>;
61
- /** `ns.defs.get()` → `ns` → `{ defs }`. */
62
- getterMembers: Map<string, Set<string>>;
63
- /** Every name the module *body* mentions — import/export clauses excluded. */
64
- referencedLocals: Set<string>;
65
- /** Specifier → resolved module id, filled by the plugin via `this.resolve`. */
66
- resolvedSources: Map<string, string>;
67
- /** Specifiers that failed to resolve — treated as request-dependent. */
68
- unresolvedSources: Set<string>;
69
- }
70
-
71
- /** `export default` has no local name of its own; this stands in for one. */
72
- export const DEFAULT_EXPORT = 'default';
73
-
74
- export function createModuleFacts(): ModuleFacts {
75
- return {
76
- importedBindings: new Map(),
77
- reExports: new Map(),
78
- starReExports: [],
79
- localExports: new Map(),
80
- factoryCalls: new Map(),
81
- calledLocals: new Set(),
82
- calledMembers: new Map(),
83
- getterLocals: new Set(),
84
- getterMembers: new Map(),
85
- referencedLocals: new Set(),
86
- resolvedSources: new Map(),
87
- unresolvedSources: new Set(),
88
- };
89
- }
90
-
91
- /**
92
- * Specifiers the origin walk can actually reach, so the plugin resolves those
93
- * and not every import in the file.
94
- *
95
- * A re-export edge is always reachable — a downstream module can ask for any
96
- * name it forwards. An `import` edge is reachable through any local name the
97
- * module body mentions, or that it re-exports.
98
- *
99
- * The name set must be **the same one the taint rules consult**. Deriving it
100
- * from the call shapes instead (called, `.get()`d, member-called, minted from)
101
- * left `read(filters)` — a definition passed as an argument — with its
102
- * specifier unresolved, so the origin walk reported it inert and the page read
103
- * as request-independent. Two hand-maintained lists of "names that matter" is
104
- * one list too many; this is the one, and `referencedLocals` is a superset of
105
- * every call shape by construction, since each of them is an identifier the
106
- * walk visits. (Codex review round 1 on PR #991.)
107
- */
108
- export function usedSources(facts: ModuleFacts): Set<string> {
109
- const sources = new Set<string>(facts.starReExports);
110
- for (const edge of facts.reExports.values()) sources.add(edge.source);
111
-
112
- for (const local of facts.referencedLocals) {
113
- const edge = facts.importedBindings.get(local);
114
- if (edge) sources.add(edge.source);
115
- }
116
- for (const local of facts.localExports.values()) {
117
- const edge = facts.importedBindings.get(local);
118
- if (edge) sources.add(edge.source);
119
- }
120
- return sources;
121
- }
122
-
123
- /**
124
- * True when the module cannot affect any answer, so its facts need not be kept.
125
- *
126
- * Every judgement bottoms out at a module edge: a call site resolves through
127
- * `importedBindings`, a chain link through `reExports` / `starReExports`. A
128
- * module with none of those can only ever resolve to `none` — its exports lead
129
- * to locals that lead nowhere — which is exactly what a *missing* entry
130
- * produces. Dropping it is behaviour-preserving and keeps the dev-time map from
131
- * holding an entry for every leaf module in the graph.
132
- */
133
- export function contributesNothing(facts: ModuleFacts): boolean {
134
- return (
135
- facts.importedBindings.size === 0 &&
136
- facts.reExports.size === 0 &&
137
- facts.starReExports.length === 0
138
- );
139
- }
140
-
141
- function addToMapSet(map: Map<string, Set<string>>, key: string, value: string): void {
142
- const existing = map.get(key);
143
- if (existing) existing.add(value);
144
- else map.set(key, new Set([value]));
145
- }
146
-
147
- // ─── Declaration collection ──────────────────────────────────────────────
148
-
149
- /**
150
- * A module-export name slot: `Identifier`, or the string-literal form ESTree
151
- * allows (`export { x as "a-b" } from './m'`) — a valid export name that is not
152
- * a valid identifier.
153
- */
154
- type NameNode = PositionedNode | undefined;
155
-
156
- interface SpecifierNode extends PositionedNode {
157
- local?: NameNode;
158
- imported?: NameNode;
159
- exported?: NameNode;
160
- }
161
-
162
- function nameOf(node: NameNode): string | null {
163
- if (!node) return null;
164
- if (node.type === 'Identifier') return (node as IdentifierNode).name;
165
- if (node.type === 'Literal' && typeof node.value === 'string') return node.value;
166
- return null;
167
- }
168
-
169
- /**
170
- * `import type { … }` needs no handling here. Vite's TypeScript transform is a
171
- * core plugin and runs before this one, so types are already erased by the time
172
- * the analysis parses — and the parser it runs on is JavaScript-only, so
173
- * unerased TypeScript would throw rather than be silently misread.
174
- * `tests/request-dep-plugin.test.ts` pins the resulting property through the
175
- * real pipeline: a type-only accessor import is not request-dependent.
176
- */
177
- function collectImportDeclaration(stmt: PositionedNode, facts: ModuleFacts): void {
178
- const source = (stmt.source as { value: string } | undefined)?.value;
179
- if (typeof source !== 'string') return;
180
- for (const spec of (stmt.specifiers as SpecifierNode[] | undefined) ?? []) {
181
- const local = nameOf(spec.local);
182
- if (!local) continue;
183
- if (spec.type === 'ImportNamespaceSpecifier') {
184
- facts.importedBindings.set(local, { source, imported: '*' });
185
- } else if (spec.type === 'ImportDefaultSpecifier') {
186
- facts.importedBindings.set(local, { source, imported: DEFAULT_EXPORT });
187
- } else if (spec.type === 'ImportSpecifier') {
188
- facts.importedBindings.set(local, { source, imported: nameOf(spec.imported) ?? local });
189
- }
190
- }
191
- }
192
-
193
- function collectDeclaredNames(decl: PositionedNode, out: Set<string>): void {
194
- if (decl.type === 'VariableDeclaration') {
195
- for (const d of (decl.declarations as PositionedNode[] | undefined) ?? []) {
196
- const id = d.id as PositionedNode | undefined;
197
- if (id?.type === 'Identifier') out.add((id as IdentifierNode).name);
198
- }
199
- } else if (decl.type === 'FunctionDeclaration' || decl.type === 'ClassDeclaration') {
200
- const id = decl.id as PositionedNode | undefined;
201
- if (id?.type === 'Identifier') out.add((id as IdentifierNode).name);
202
- }
203
- }
204
-
205
- function collectExportNamed(stmt: PositionedNode, facts: ModuleFacts): void {
206
- const source = (stmt.source as { value: string } | undefined)?.value;
207
- const specifiers = (stmt.specifiers as SpecifierNode[] | undefined) ?? [];
208
-
209
- if (typeof source === 'string') {
210
- // `export { a as b } from './m'` — `local` names the export in './m'.
211
- for (const spec of specifiers) {
212
- const imported = nameOf(spec.imported) ?? nameOf(spec.local);
213
- const exported = nameOf(spec.exported);
214
- if (imported && exported) facts.reExports.set(exported, { source, imported });
215
- }
216
- return;
217
- }
218
-
219
- // `export { x }` / `export { x as y }` — `local` is a binding in this module.
220
- for (const spec of specifiers) {
221
- const local = nameOf(spec.local);
222
- const exported = nameOf(spec.exported);
223
- if (local && exported) facts.localExports.set(exported, local);
224
- }
225
-
226
- // `export const x = …`, `export function f() {}`
227
- const declaration = stmt.declaration as PositionedNode | undefined;
228
- if (declaration) {
229
- const names = new Set<string>();
230
- collectDeclaredNames(declaration, names);
231
- for (const name of names) facts.localExports.set(name, name);
232
- }
233
- }
234
-
235
- function collectExportAll(stmt: PositionedNode, facts: ModuleFacts): void {
236
- const source = (stmt.source as { value: string } | undefined)?.value;
237
- if (typeof source !== 'string') return;
238
- const exported = nameOf(stmt.exported as NameNode);
239
- if (exported) {
240
- // `export * as ns from './m'` — a namespace object under one name.
241
- facts.reExports.set(exported, { source, imported: '*' });
242
- } else {
243
- facts.starReExports.push(source);
244
- }
245
- }
246
-
247
- function collectExportDefault(stmt: PositionedNode, facts: ModuleFacts): void {
248
- const declaration = stmt.declaration as PositionedNode | undefined;
249
- if (!declaration) return;
250
- facts.localExports.set(DEFAULT_EXPORT, DEFAULT_EXPORT);
251
- if (declaration.type === 'Identifier') {
252
- // `export default x` — alias the default onto the existing binding.
253
- facts.localExports.set(DEFAULT_EXPORT, (declaration as IdentifierNode).name);
254
- } else if (declaration.type === 'CallExpression') {
255
- const ref = calleeRef(declaration as unknown as CallExpressionNode);
256
- if (ref) facts.factoryCalls.set(DEFAULT_EXPORT, ref);
257
- }
258
- }
259
-
260
- // ─── Expression collection ───────────────────────────────────────────────
261
-
262
- function calleeRef(call: CallExpressionNode): CalleeRef | null {
263
- const callee = call.callee;
264
- if (callee.type === 'Identifier') {
265
- return { kind: 'local', name: (callee as IdentifierNode).name };
266
- }
267
- if (callee.type === 'MemberExpression') {
268
- const member = callee as MemberExpressionNode;
269
- if (
270
- !member.computed &&
271
- member.object.type === 'Identifier' &&
272
- member.property.type === 'Identifier'
273
- ) {
274
- return {
275
- kind: 'member',
276
- object: (member.object as IdentifierNode).name,
277
- property: (member.property as IdentifierNode).name,
278
- };
279
- }
280
- }
281
- return null;
282
- }
283
-
284
- /**
285
- * Walk down a `.get()` receiver to the identifier it is ultimately rooted in,
286
- * along with the first property accessed on that identifier.
287
- *
288
- * `x.get()` → `x`, no property. `x(a).get()` → `x`. `ns.defs.get()` → `ns`
289
- * plus `defs`, which is both the namespace-member shape and the
290
- * `cookies.theme.get()` shape — the resolver tries the base binding and the
291
- * member, so one walk covers both.
292
- */
293
- function chainRoot(node: PositionedNode): { base: string; property: string | null } | null {
294
- let current = node;
295
- let property: string | null = null;
296
- for (;;) {
297
- if (current.type === 'Identifier') {
298
- return { base: (current as IdentifierNode).name, property };
299
- }
300
- if (current.type === 'MemberExpression') {
301
- const member = current as MemberExpressionNode;
302
- if (!member.computed && member.property.type === 'Identifier') {
303
- property = (member.property as IdentifierNode).name;
304
- } else {
305
- property = null;
306
- }
307
- current = member.object;
308
- continue;
309
- }
310
- if (current.type === 'CallExpression') {
311
- property = null;
312
- current = (current as CallExpressionNode).callee;
313
- continue;
314
- }
315
- return null;
316
- }
317
- }
318
-
319
- function collectExpression(node: PositionedNode, facts: ModuleFacts): void {
320
- if (node.type === 'VariableDeclarator') {
321
- const id = node.id as PositionedNode | undefined;
322
- const init = node.init as PositionedNode | undefined;
323
- if (id?.type === 'Identifier' && init?.type === 'CallExpression') {
324
- const ref = calleeRef(init as unknown as CallExpressionNode);
325
- if (ref) facts.factoryCalls.set((id as IdentifierNode).name, ref);
326
- }
327
- return;
328
- }
329
-
330
- if (node.type !== 'CallExpression') return;
331
- const call = node as unknown as CallExpressionNode;
332
- const callee = call.callee;
333
-
334
- if (callee.type === 'Identifier') {
335
- facts.calledLocals.add((callee as IdentifierNode).name);
336
- return;
337
- }
338
- if (callee.type !== 'MemberExpression') return;
339
- const member = callee as MemberExpressionNode;
340
- if (member.computed || member.property.type !== 'Identifier') return;
341
- const propertyName = (member.property as IdentifierNode).name;
342
-
343
- if (propertyName === 'get') {
344
- const root = chainRoot(member.object);
345
- if (root) {
346
- facts.getterLocals.add(root.base);
347
- if (root.property) addToMapSet(facts.getterMembers, root.base, root.property);
348
- }
349
- return;
350
- }
351
- if (member.object.type === 'Identifier') {
352
- addToMapSet(facts.calledMembers, (member.object as IdentifierNode).name, propertyName);
353
- }
354
- }
355
-
356
- /**
357
- * Statements whose whole subtree is an import/export *clause* rather than code.
358
- *
359
- * The walk skips them so `referencedLocals` means "the module body mentions
360
- * this name". Without the skip every imported name would count as referenced,
361
- * and a pure barrel — which mentions its names only in the clauses — would be
362
- * indistinguishable from a module that uses them.
363
- */
364
- function isClauseOnly(node: PositionedNode): boolean {
365
- if (node.type === 'ImportDeclaration' || node.type === 'ExportAllDeclaration') return true;
366
- if (node.type === 'ExportNamedDeclaration') return !node.declaration;
367
- // `export default someBinding` forwards; `export default f()` is code.
368
- if (node.type === 'ExportDefaultDeclaration') {
369
- return (node.declaration as PositionedNode | undefined)?.type === 'Identifier';
370
- }
371
- return false;
372
- }
373
-
374
- /**
375
- * Keys holding *binding* positions rather than references: the name being
376
- * declared, not a mention of one.
377
- *
378
- * `referencedLocals` must exclude these or `export const filters =
379
- * defineSearchParams({})` would count as referencing `filters`, and possession
380
- * would then taint every definition module — and through it every page that
381
- * imports one, whether or not it reads the request. Skipping only these keys
382
- * keeps a shadowing parameter's *body* uses as references, which over-reports
383
- * in the safe direction.
384
- */
385
- const BINDING_KEYS: Readonly<Record<string, readonly string[]>> = {
386
- VariableDeclarator: ['id'],
387
- FunctionDeclaration: ['id', 'params'],
388
- FunctionExpression: ['id', 'params'],
389
- ArrowFunctionExpression: ['params'],
390
- ClassDeclaration: ['id'],
391
- ClassExpression: ['id'],
392
- CatchClause: ['param'],
393
- };
394
-
395
- function walk(node: PositionedNode, facts: ModuleFacts): void {
396
- if (isClauseOnly(node)) return;
397
- if (node.type === 'Identifier') facts.referencedLocals.add((node as IdentifierNode).name);
398
- collectExpression(node, facts);
399
- const bindingKeys = BINDING_KEYS[node.type];
400
- for (const key of Object.keys(node)) {
401
- if (key === 'type' || key === 'start' || key === 'end') continue;
402
- if (bindingKeys?.includes(key)) continue;
403
- const value = node[key];
404
- if (!value || typeof value !== 'object') continue;
405
- if (Array.isArray(value)) {
406
- for (const item of value) {
407
- if (item && typeof item === 'object' && typeof item.type === 'string') {
408
- walk(item as PositionedNode, facts);
409
- }
410
- }
411
- } else if (typeof (value as PositionedNode).type === 'string') {
412
- walk(value as PositionedNode, facts);
413
- }
414
- }
415
- }
416
-
417
- /**
418
- * Record every binding, module edge, and call shape in one module.
419
- *
420
- * Names are recorded without scope analysis, so a parameter that shadows an
421
- * imported name is credited to the import. That direction is deliberate: a
422
- * needlessly request-dependent segment costs a re-render, a wrongly static one
423
- * serves stale content.
424
- */
425
- export function analyzeModule(program: ProgramNode): ModuleFacts {
426
- const facts = createModuleFacts();
427
-
428
- for (const stmt of program.body) {
429
- switch (stmt.type) {
430
- case 'ImportDeclaration':
431
- collectImportDeclaration(stmt, facts);
432
- break;
433
- case 'ExportNamedDeclaration':
434
- collectExportNamed(stmt, facts);
435
- break;
436
- case 'ExportAllDeclaration':
437
- collectExportAll(stmt, facts);
438
- break;
439
- case 'ExportDefaultDeclaration':
440
- collectExportDefault(stmt, facts);
441
- break;
442
- }
443
- }
444
-
445
- walk(program, facts);
446
- return facts;
447
- }