@askrjs/askr 0.0.52 → 0.0.54

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 (386) hide show
  1. package/README.md +5 -1
  2. package/dist/{runtime/scheduler.js → access-Bg4RJNC8.js} +182 -9
  3. package/dist/actions/index.d.ts +2 -0
  4. package/dist/actions/index.js +103 -0
  5. package/dist/{common/attr-names.js → attr-names-CjhzmHOn.js} +1 -1
  6. package/dist/benchmark.d.ts +6 -2
  7. package/dist/benchmark.js +63 -11
  8. package/dist/boot/index.d.ts +61 -2
  9. package/dist/boot/index.js +1 -203
  10. package/dist/boot-2ZR3MtO0.js +647 -0
  11. package/dist/cleanup-DScKZG2i.js +487 -0
  12. package/dist/component-internal-D9PLuFUc.js +614 -0
  13. package/dist/component-lifecycle-C7lnU9Bt.js +359 -0
  14. package/dist/{runtime/component-scope.js → component-scope-CC3cojX9.js} +8 -1
  15. package/dist/component-scope-CvPba6O6.d.ts +12 -0
  16. package/dist/components/index.d.ts +17 -2
  17. package/dist/components/index.js +39 -1
  18. package/dist/compose-ref-Cc_YkUpM.js +92 -0
  19. package/dist/{foundations/utilities/compose-ref.d.ts → compose-ref-Cizq72-x.d.ts} +1 -1
  20. package/dist/control/index.d.ts +1 -3
  21. package/dist/control/index.js +1 -3
  22. package/dist/control-BI4RMD2z.d.ts +437 -0
  23. package/dist/control-Bf4Wkdvv.d.ts +9 -0
  24. package/dist/{common/control.js → control-DhFRTIoE.js} +1 -1
  25. package/dist/control-mXROCjL3.js +165 -0
  26. package/dist/data/index.d.ts +2 -6
  27. package/dist/data/index.js +4 -5
  28. package/dist/data-B9dauyDn.js +559 -0
  29. package/dist/{data/data-runtime.js → data-runtime-SJ1BSUvk.js} +32 -31
  30. package/dist/deferred-DklLG4qM.js +386 -0
  31. package/dist/{runtime/effect.js → effect-BwnIvLah.js} +4 -4
  32. package/dist/fastlane-Dw8SOBr9.js +343 -0
  33. package/dist/for-internal-CSz8Unkq.js +1563 -0
  34. package/dist/foundations/icon/index.d.ts +68 -2
  35. package/dist/foundations/icon/index.js +85 -1
  36. package/dist/foundations/index.d.ts +2 -5
  37. package/dist/foundations/index.js +2 -5
  38. package/dist/foundations/interactions/index.d.ts +264 -6
  39. package/dist/foundations/interactions/index.js +1 -6
  40. package/dist/foundations/state/index.d.ts +32 -1
  41. package/dist/foundations/state/index.js +78 -1
  42. package/dist/foundations/structures/index.d.ts +2 -7
  43. package/dist/foundations/structures/index.js +2 -7
  44. package/dist/foundations/utilities/index.d.ts +2 -6
  45. package/dist/foundations/utilities/index.js +2 -5
  46. package/dist/fx/index.d.ts +190 -3
  47. package/dist/fx/index.js +454 -4
  48. package/dist/index-B1LNotpU.d.ts +239 -0
  49. package/dist/index-Bki2rqcr.d.ts +233 -0
  50. package/dist/index-BnU0NPwM.d.ts +101 -0
  51. package/dist/index-C8iW3xCt.d.ts +44 -0
  52. package/dist/index-DwxdIA-t.d.ts +48 -0
  53. package/dist/{runtime/runtime.d.ts → index-Zb31mCiU.d.ts} +31 -8
  54. package/dist/index.d.ts +8 -13
  55. package/dist/index.js +150 -15
  56. package/dist/interactions-w7gQN4ha.js +280 -0
  57. package/dist/{data/invalidation-listeners.js → invalidation-listeners-Des3AHYs.js} +1 -1
  58. package/dist/{common/props.d.ts → jsx-CP0gmYwJ.d.ts} +17 -5
  59. package/dist/{common/jsx.js → jsx-CUpRxrLH.js} +1 -1
  60. package/dist/jsx-dev-runtime.d.ts +2 -4
  61. package/dist/jsx-dev-runtime.js +7 -5
  62. package/dist/jsx-runtime-92bV2hSa.d.ts +34 -0
  63. package/dist/jsx-runtime-BVVgDSdq.d.ts +1 -0
  64. package/dist/jsx-runtime.d.ts +2 -35
  65. package/dist/jsx-runtime.js +11 -5
  66. package/dist/{runtime/lifecycle-operations.js → lifecycle-operations-CdRjdsHo.js} +4 -5
  67. package/dist/navigate-BVDCzOuB.d.ts +34 -0
  68. package/dist/navigate-D17eVQyI.js +1449 -0
  69. package/dist/{runtime/portal.js → portal-C47xkwXj.js} +71 -41
  70. package/dist/query-registry-CQIT4mXr.js +73 -0
  71. package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -6
  72. package/dist/renderer-DrLRAD5y.js +6266 -0
  73. package/dist/{runtime/resource-operation.js → resource-operation-BNY29MVH.js} +118 -15
  74. package/dist/resources/index.d.ts +42 -3
  75. package/dist/resources/index.js +3 -4
  76. package/dist/{common/route-activity.js → route-activity-CNJfpwx-.js} +1 -1
  77. package/dist/route-matching-vJpvLVbX.js +515 -0
  78. package/dist/router/index.d.ts +166 -14
  79. package/dist/router/index.js +150 -12
  80. package/dist/{common/router.d.ts → router-DCfwLBr-.d.ts} +72 -28
  81. package/dist/{common/router-internal.js → router-internal-BC0w1_xk.js} +1 -1
  82. package/dist/{runtime/scheduler.d.ts → scheduler-CmLO4Dfm.d.ts} +1 -3
  83. package/dist/{runtime/selector.js → selector-DafVYzV4.js} +34 -11
  84. package/dist/{runtime/snapshot-source.js → snapshot-source-BB42xgwb.js} +1 -1
  85. package/dist/ssg/index.d.ts +252 -4
  86. package/dist/ssg/index.js +857 -1
  87. package/dist/ssr/index.d.ts +225 -8
  88. package/dist/ssr/index.js +3 -6
  89. package/dist/{common/ssr.js → ssr-CbQO5xd3.js} +1 -1
  90. package/dist/ssr-DEARZxJ5.js +1413 -0
  91. package/dist/{runtime/state.js → state-DPl8lffD.js} +3 -5
  92. package/dist/structures-DUB3HchX.js +221 -0
  93. package/dist/testing/index.d.ts +3 -2
  94. package/dist/testing/index.js +2 -5
  95. package/dist/{jsx/types.d.ts → types-DnQVG4ZY.d.ts} +2 -5
  96. package/dist/{foundations/utilities/use-id.js → utilities-C_CGX4Dz.js} +1 -1
  97. package/dist/{ssr/verify-hydration.js → verify-hydration-BWwu-mWu.js} +2 -2
  98. package/dist/{common/vnode.js → vnode-CGMJYPMB.js} +2 -2
  99. package/package.json +12 -7
  100. package/dist/bench/components/benchmark-row.d.ts +0 -20
  101. package/dist/bench/components/benchmark-row.js +0 -40
  102. package/dist/bench/components/benchmark-table.js +0 -23
  103. package/dist/bin/askr-ssg.d.ts +0 -27
  104. package/dist/bin/askr-ssg.js +0 -186
  105. package/dist/boot/hydration.js +0 -139
  106. package/dist/boot/root-lifecycle.d.ts +0 -18
  107. package/dist/boot/root-lifecycle.js +0 -209
  108. package/dist/boot/route-startup.js +0 -54
  109. package/dist/boot/types.d.ts +0 -61
  110. package/dist/common/component.d.ts +0 -18
  111. package/dist/common/control.d.ts +0 -12
  112. package/dist/common/dom-range.d.ts +0 -13
  113. package/dist/common/env.js +0 -41
  114. package/dist/common/error-boundary.d.ts +0 -15
  115. package/dist/common/invariant.js +0 -15
  116. package/dist/common/jsx.d.ts +0 -22
  117. package/dist/common/logger.js +0 -34
  118. package/dist/common/promise.js +0 -6
  119. package/dist/common/ssr-errors.d.ts +0 -10
  120. package/dist/common/ssr-errors.js +0 -14
  121. package/dist/common/ssr.d.ts +0 -41
  122. package/dist/common/vnode.d.ts +0 -21
  123. package/dist/components/error-boundary.d.ts +0 -14
  124. package/dist/components/error-boundary.js +0 -41
  125. package/dist/components/link.d.ts +0 -68
  126. package/dist/components/link.js +0 -74
  127. package/dist/control/case.d.ts +0 -18
  128. package/dist/control/case.js +0 -68
  129. package/dist/control/for.d.ts +0 -23
  130. package/dist/control/for.js +0 -61
  131. package/dist/control/shared.d.ts +0 -8
  132. package/dist/control/shared.js +0 -18
  133. package/dist/control/show.d.ts +0 -14
  134. package/dist/control/show.js +0 -32
  135. package/dist/data/data-runtime.d.ts +0 -27
  136. package/dist/data/invalidation.d.ts +0 -8
  137. package/dist/data/invalidation.js +0 -25
  138. package/dist/data/mutation-cell.d.ts +0 -27
  139. package/dist/data/mutation-cell.js +0 -133
  140. package/dist/data/query-cell.d.ts +0 -47
  141. package/dist/data/query-cell.js +0 -324
  142. package/dist/data/query-key.js +0 -40
  143. package/dist/data/shared.js +0 -20
  144. package/dist/data/testing.js +0 -2
  145. package/dist/data/types.d.ts +0 -160
  146. package/dist/foundations/icon/icon.d.ts +0 -52
  147. package/dist/foundations/icon/icon.js +0 -86
  148. package/dist/foundations/icon/icon.types.d.ts +0 -21
  149. package/dist/foundations/interactions/dismissable.d.ts +0 -71
  150. package/dist/foundations/interactions/dismissable.js +0 -24
  151. package/dist/foundations/interactions/focusable.d.ts +0 -21
  152. package/dist/foundations/interactions/focusable.js +0 -16
  153. package/dist/foundations/interactions/hoverable.d.ts +0 -25
  154. package/dist/foundations/interactions/hoverable.js +0 -13
  155. package/dist/foundations/interactions/interaction-policy.d.ts +0 -49
  156. package/dist/foundations/interactions/interaction-policy.js +0 -120
  157. package/dist/foundations/interactions/pressable.d.ts +0 -60
  158. package/dist/foundations/interactions/pressable.js +0 -49
  159. package/dist/foundations/interactions/roving-focus.d.ts +0 -51
  160. package/dist/foundations/interactions/roving-focus.js +0 -69
  161. package/dist/foundations/state/controllable.d.ts +0 -32
  162. package/dist/foundations/state/controllable.js +0 -80
  163. package/dist/foundations/structures/collection.d.ts +0 -51
  164. package/dist/foundations/structures/collection.js +0 -49
  165. package/dist/foundations/structures/layer.d.ts +0 -80
  166. package/dist/foundations/structures/layer.js +0 -79
  167. package/dist/foundations/structures/layout.d.ts +0 -32
  168. package/dist/foundations/structures/layout.js +0 -11
  169. package/dist/foundations/structures/portal.d.ts +0 -2
  170. package/dist/foundations/structures/portal.js +0 -3
  171. package/dist/foundations/structures/presence.d.ts +0 -36
  172. package/dist/foundations/structures/presence.js +0 -37
  173. package/dist/foundations/structures/slot.d.ts +0 -34
  174. package/dist/foundations/structures/slot.js +0 -39
  175. package/dist/foundations/utilities/aria.d.ts +0 -15
  176. package/dist/foundations/utilities/aria.js +0 -15
  177. package/dist/foundations/utilities/compose-handlers.d.ts +0 -36
  178. package/dist/foundations/utilities/compose-handlers.js +0 -18
  179. package/dist/foundations/utilities/compose-ref.js +0 -16
  180. package/dist/foundations/utilities/event-types.d.ts +0 -19
  181. package/dist/foundations/utilities/merge-props.d.ts +0 -4
  182. package/dist/foundations/utilities/merge-props.js +0 -47
  183. package/dist/foundations/utilities/use-id.d.ts +0 -31
  184. package/dist/fx/fx.d.ts +0 -32
  185. package/dist/fx/fx.js +0 -211
  186. package/dist/fx/noop.js +0 -7
  187. package/dist/fx/timing.d.ts +0 -158
  188. package/dist/fx/timing.js +0 -241
  189. package/dist/jsx/index.d.ts +0 -2
  190. package/dist/jsx/index.js +0 -4
  191. package/dist/jsx/types.js +0 -2
  192. package/dist/jsx/utils.d.ts +0 -4
  193. package/dist/jsx/utils.js +0 -17
  194. package/dist/jsx-runtime2.d.ts +0 -3
  195. package/dist/jsx-runtime2.js +0 -4
  196. package/dist/renderer/attributes.js +0 -254
  197. package/dist/renderer/boundaries.js +0 -142
  198. package/dist/renderer/boundary-materialization.js +0 -72
  199. package/dist/renderer/boundary-range-adoption.js +0 -76
  200. package/dist/renderer/boundary-range-sync.js +0 -101
  201. package/dist/renderer/boundary-state.js +0 -50
  202. package/dist/renderer/child-shape.js +0 -83
  203. package/dist/renderer/children-fastpath.js +0 -149
  204. package/dist/renderer/children.js +0 -158
  205. package/dist/renderer/cleanup.js +0 -267
  206. package/dist/renderer/component-host-cleanup.js +0 -143
  207. package/dist/renderer/component-host-instances.js +0 -116
  208. package/dist/renderer/component-host-replacement.js +0 -105
  209. package/dist/renderer/component-host-results.js +0 -138
  210. package/dist/renderer/component-host.js +0 -172
  211. package/dist/renderer/dom-host.js +0 -11
  212. package/dist/renderer/dom-internal.js +0 -243
  213. package/dist/renderer/dom-range.js +0 -161
  214. package/dist/renderer/dom.js +0 -11
  215. package/dist/renderer/element-children.js +0 -359
  216. package/dist/renderer/env.js +0 -2
  217. package/dist/renderer/error-boundary-dom.js +0 -86
  218. package/dist/renderer/evaluate-dom-range.js +0 -84
  219. package/dist/renderer/evaluate-reconcile.js +0 -257
  220. package/dist/renderer/evaluate.js +0 -95
  221. package/dist/renderer/fastpath.js +0 -142
  222. package/dist/renderer/for-commit-dom-map.js +0 -71
  223. package/dist/renderer/for-commit-removal.js +0 -27
  224. package/dist/renderer/for-commit-reorder.js +0 -87
  225. package/dist/renderer/for-commit.js +0 -442
  226. package/dist/renderer/hydration-boundaries.js +0 -60
  227. package/dist/renderer/hydration-listener-transaction.js +0 -49
  228. package/dist/renderer/index.js +0 -39
  229. package/dist/renderer/intrinsic-blueprint-analysis.js +0 -202
  230. package/dist/renderer/intrinsic-blueprint-bindings.js +0 -152
  231. package/dist/renderer/intrinsic-blueprint-materialization.js +0 -100
  232. package/dist/renderer/intrinsic-blueprint.js +0 -30
  233. package/dist/renderer/intrinsic-hydration-adoption.js +0 -66
  234. package/dist/renderer/keyed-children.js +0 -26
  235. package/dist/renderer/keyed.js +0 -167
  236. package/dist/renderer/namespaces.js +0 -21
  237. package/dist/renderer/prop-bindings.js +0 -315
  238. package/dist/renderer/reactive-child-dom.js +0 -139
  239. package/dist/renderer/reactive-child-sources.js +0 -182
  240. package/dist/renderer/reactive-children.js +0 -303
  241. package/dist/renderer/reconcile-commit.js +0 -36
  242. package/dist/renderer/reconcile-fastpaths.js +0 -100
  243. package/dist/renderer/reconcile-resolution.js +0 -163
  244. package/dist/renderer/reconcile.js +0 -37
  245. package/dist/renderer/retained-element-rollback.js +0 -288
  246. package/dist/renderer/stable-patch.js +0 -80
  247. package/dist/renderer/static-reuse.js +0 -94
  248. package/dist/renderer/types.js +0 -2
  249. package/dist/renderer/utils.js +0 -265
  250. package/dist/router/access.js +0 -34
  251. package/dist/router/activity.d.ts +0 -9
  252. package/dist/router/activity.js +0 -85
  253. package/dist/router/authoring.d.ts +0 -21
  254. package/dist/router/authoring.js +0 -196
  255. package/dist/router/internal-types.d.ts +0 -30
  256. package/dist/router/lazy.d.ts +0 -18
  257. package/dist/router/lazy.js +0 -50
  258. package/dist/router/manifest.d.ts +0 -9
  259. package/dist/router/manifest.js +0 -47
  260. package/dist/router/match.js +0 -120
  261. package/dist/router/navigate.d.ts +0 -10
  262. package/dist/router/navigate.js +0 -73
  263. package/dist/router/navigation-registry.d.ts +0 -31
  264. package/dist/router/navigation-registry.js +0 -103
  265. package/dist/router/navigation-scroll.d.ts +0 -13
  266. package/dist/router/navigation-scroll.js +0 -91
  267. package/dist/router/navigation-targets.d.ts +0 -30
  268. package/dist/router/navigation-targets.js +0 -634
  269. package/dist/router/policy.d.ts +0 -27
  270. package/dist/router/policy.js +0 -130
  271. package/dist/router/rendering.d.ts +0 -9
  272. package/dist/router/rendering.js +0 -47
  273. package/dist/router/resolution.d.ts +0 -3
  274. package/dist/router/resolution.js +0 -84
  275. package/dist/router/route-context.js +0 -77
  276. package/dist/router/route-matching.d.ts +0 -19
  277. package/dist/router/route-matching.js +0 -173
  278. package/dist/router/route-query.d.ts +0 -16
  279. package/dist/router/route-query.js +0 -45
  280. package/dist/router/route.d.ts +0 -8
  281. package/dist/router/route.js +0 -10
  282. package/dist/router/store.d.ts +0 -49
  283. package/dist/router/store.js +0 -169
  284. package/dist/router/testing.js +0 -4
  285. package/dist/runtime/access.d.ts +0 -19
  286. package/dist/runtime/access.js +0 -43
  287. package/dist/runtime/child-scope.d.ts +0 -41
  288. package/dist/runtime/child-scope.js +0 -134
  289. package/dist/runtime/component-cleanup.d.ts +0 -15
  290. package/dist/runtime/component-cleanup.js +0 -68
  291. package/dist/runtime/component-commit.js +0 -167
  292. package/dist/runtime/component-facade.d.ts +0 -5
  293. package/dist/runtime/component-facade.js +0 -6
  294. package/dist/runtime/component-internal.d.ts +0 -105
  295. package/dist/runtime/component-internal.js +0 -237
  296. package/dist/runtime/component-lifecycle.d.ts +0 -10
  297. package/dist/runtime/component-lifecycle.js +0 -33
  298. package/dist/runtime/component-scope.d.ts +0 -54
  299. package/dist/runtime/component.d.ts +0 -5
  300. package/dist/runtime/component.js +0 -6
  301. package/dist/runtime/context.d.ts +0 -72
  302. package/dist/runtime/context.js +0 -236
  303. package/dist/runtime/control.d.ts +0 -62
  304. package/dist/runtime/control.js +0 -239
  305. package/dist/runtime/derive.d.ts +0 -16
  306. package/dist/runtime/derive.js +0 -140
  307. package/dist/runtime/dev-namespace.d.ts +0 -30
  308. package/dist/runtime/dev-namespace.js +0 -64
  309. package/dist/runtime/effect.d.ts +0 -35
  310. package/dist/runtime/error-boundary.d.ts +0 -4
  311. package/dist/runtime/error-boundary.js +0 -29
  312. package/dist/runtime/events.d.ts +0 -58
  313. package/dist/runtime/events.js +0 -201
  314. package/dist/runtime/execution-model.d.ts +0 -6
  315. package/dist/runtime/execution-model.js +0 -13
  316. package/dist/runtime/fastlane.d.ts +0 -33
  317. package/dist/runtime/fastlane.js +0 -173
  318. package/dist/runtime/for-bench.d.ts +0 -40
  319. package/dist/runtime/for-bench.js +0 -13
  320. package/dist/runtime/for-internal.d.ts +0 -106
  321. package/dist/runtime/for-internal.js +0 -285
  322. package/dist/runtime/for-reconcile.d.ts +0 -7
  323. package/dist/runtime/for-reconcile.js +0 -442
  324. package/dist/runtime/for-scopes.d.ts +0 -26
  325. package/dist/runtime/for-scopes.js +0 -280
  326. package/dist/runtime/for-signals.d.ts +0 -39
  327. package/dist/runtime/for-signals.js +0 -213
  328. package/dist/runtime/for-types.d.ts +0 -8
  329. package/dist/runtime/for.d.ts +0 -4
  330. package/dist/runtime/for.js +0 -5
  331. package/dist/runtime/index.d.ts +0 -24
  332. package/dist/runtime/index.js +0 -33
  333. package/dist/runtime/lifecycle-batch.d.ts +0 -59
  334. package/dist/runtime/lifecycle-batch.js +0 -178
  335. package/dist/runtime/lifecycle-operation-settlement.d.ts +0 -5
  336. package/dist/runtime/lifecycle-operation-settlement.js +0 -51
  337. package/dist/runtime/lifecycle-operations.d.ts +0 -30
  338. package/dist/runtime/operations.d.ts +0 -3
  339. package/dist/runtime/operations.js +0 -3
  340. package/dist/runtime/perf-metrics.d.ts +0 -27
  341. package/dist/runtime/perf-metrics.js +0 -6
  342. package/dist/runtime/portal.d.ts +0 -21
  343. package/dist/runtime/readable.d.ts +0 -34
  344. package/dist/runtime/readable.js +0 -183
  345. package/dist/runtime/resource-cell.js +0 -112
  346. package/dist/runtime/resource-operation.d.ts +0 -12
  347. package/dist/runtime/runtime.js +0 -57
  348. package/dist/runtime/selector-store.js +0 -22
  349. package/dist/runtime/selector.d.ts +0 -10
  350. package/dist/runtime/snapshot-source.d.ts +0 -9
  351. package/dist/runtime/state.d.ts +0 -54
  352. package/dist/ssg/batch-render.js +0 -101
  353. package/dist/ssg/create-static-gen.d.ts +0 -66
  354. package/dist/ssg/create-static-gen.js +0 -250
  355. package/dist/ssg/generate-metadata.js +0 -92
  356. package/dist/ssg/generation-plan.js +0 -68
  357. package/dist/ssg/incremental-manifest.js +0 -54
  358. package/dist/ssg/resolve-ssg-data.js +0 -103
  359. package/dist/ssg/route-utils.js +0 -22
  360. package/dist/ssg/static-routes.js +0 -100
  361. package/dist/ssg/types.d.ts +0 -188
  362. package/dist/ssg/write-static-files.js +0 -77
  363. package/dist/ssr/attrs.js +0 -92
  364. package/dist/ssr/boundaries.js +0 -124
  365. package/dist/ssr/component-runtime.js +0 -85
  366. package/dist/ssr/context.d.ts +0 -49
  367. package/dist/ssr/context.js +0 -89
  368. package/dist/ssr/errors.d.ts +0 -9
  369. package/dist/ssr/errors.js +0 -12
  370. package/dist/ssr/escape.js +0 -191
  371. package/dist/ssr/hydration-data.js +0 -8
  372. package/dist/ssr/hydration-verify.d.ts +0 -11
  373. package/dist/ssr/hydration-verify.js +0 -171
  374. package/dist/ssr/index-internal.d.ts +0 -14
  375. package/dist/ssr/index-internal.js +0 -17
  376. package/dist/ssr/render-keys.js +0 -14
  377. package/dist/ssr/render-resolved.d.ts +0 -19
  378. package/dist/ssr/render-resolved.js +0 -33
  379. package/dist/ssr/render-sync.d.ts +0 -20
  380. package/dist/ssr/render-sync.js +0 -283
  381. package/dist/ssr/route-policy-resolution.js +0 -76
  382. package/dist/ssr/route-render.d.ts +0 -76
  383. package/dist/ssr/route-render.js +0 -118
  384. package/dist/ssr/sink.d.ts +0 -25
  385. package/dist/ssr/sink.js +0 -84
  386. package/dist/ssr/types.d.ts +0 -22
@@ -0,0 +1,1413 @@
1
+ import { t as __CONTROL_BOUNDARY__ } from "./control-DhFRTIoE.js";
2
+ import { t as __ERROR_BOUNDARY__ } from "./vnode-CGMJYPMB.js";
3
+ import { v as logger } from "./access-Bg4RJNC8.js";
4
+ import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-CUpRxrLH.js";
5
+ import { f as getExecutionContextFrame, l as callWithContext, m as markVNodeTreeWithContextFrame, n as createComponentInstance, p as getVNodeContextFrame } from "./component-internal-D9PLuFUc.js";
6
+ import { f as getCurrentComponentInstance, w as setCurrentComponentInstance } from "./component-scope-CC3cojX9.js";
7
+ import { h as cleanupComponent, m as isPromiseLike } from "./component-lifecycle-C7lnU9Bt.js";
8
+ import { g as evaluateShowState, h as evaluateCaseState, i as evaluateForState, o as rollbackForStateTransaction, r as commitForStateTransaction } from "./for-internal-CSz8Unkq.js";
9
+ import { c as stopRenderPhase$1, o as startRenderPhase$1, t as configureRenderContextProvider, u as SSRDataMissingError } from "./render-context-Clw3rFiO.js";
10
+ import { a as disposeDefaultPortalScope, t as DefaultPortal } from "./portal-C47xkwXj.js";
11
+ import { t as getPublicAttributeName } from "./attr-names-CjhzmHOn.js";
12
+ import { t as createDataRuntime } from "./data-runtime-SJ1BSUvk.js";
13
+ import { c as withTelemetry, i as dehydrateDataRuntime, t as createQueryPrefetchContext } from "./query-registry-CQIT4mXr.js";
14
+ import { a as resolveRouteFromRoutes, t as _resolveRouteMatchFromRoutes } from "./route-matching-vJpvLVbX.js";
15
+ import { f as resolveRouteRequest, g as isPageRenderEnvelope, h as isEmptyPageRenderEnvelope, i as isDeferred, m as createPageRenderEnvelope, t as DEFERRED_BOUNDARY } from "./deferred-DklLG4qM.js";
16
+ import { n as renderDocument, t as SSR_RENDER_DATA_ATTR } from "./ssr-CbQO5xd3.js";
17
+ //#region src/ssr/escape.ts
18
+ /**
19
+ * HTML escaping utilities for SSR
20
+ *
21
+ * Centralizes text and attribute escaping to avoid duplication
22
+ * between sync and streaming SSR renderers.
23
+ */
24
+ const VOID_ELEMENTS = /* @__PURE__ */ new Set([
25
+ "area",
26
+ "base",
27
+ "br",
28
+ "col",
29
+ "embed",
30
+ "hr",
31
+ "img",
32
+ "input",
33
+ "link",
34
+ "meta",
35
+ "param",
36
+ "source",
37
+ "track",
38
+ "wbr"
39
+ ]);
40
+ const escapeCache = /* @__PURE__ */ new Map();
41
+ const MAX_CACHE_SIZE = 256;
42
+ const CSS_UNSAFE_RE = /[{}<>\\]/g;
43
+ const CSS_URI_SCHEME_RE = /(?:^|[\s(,])([a-z][a-z0-9+.-]*):/i;
44
+ const CSS_FUNCTION_NAME_RE = /([a-z-][a-z0-9-]*)\s*\(/gi;
45
+ const CSS_ALLOWED_FUNCTIONS = /* @__PURE__ */ new Set([
46
+ "var",
47
+ "calc",
48
+ "min",
49
+ "max",
50
+ "clamp",
51
+ "rgb",
52
+ "rgba",
53
+ "hsl",
54
+ "hsla",
55
+ "lab",
56
+ "lch",
57
+ "oklab",
58
+ "oklch",
59
+ "color",
60
+ "color-mix",
61
+ "translate",
62
+ "translatex",
63
+ "translatey",
64
+ "translatez",
65
+ "scale",
66
+ "scalex",
67
+ "scaley",
68
+ "scalez",
69
+ "rotate",
70
+ "rotatex",
71
+ "rotatey",
72
+ "rotatez",
73
+ "skew",
74
+ "skewx",
75
+ "skewy",
76
+ "matrix",
77
+ "matrix3d",
78
+ "linear-gradient",
79
+ "radial-gradient",
80
+ "conic-gradient",
81
+ "repeating-linear-gradient",
82
+ "repeating-radial-gradient",
83
+ "repeating-conic-gradient",
84
+ "cubic-bezier",
85
+ "steps"
86
+ ]);
87
+ const STYLE_PROP_CACHE = /* @__PURE__ */ new Map();
88
+ const MAX_STYLE_PROP_CACHE_SIZE = 512;
89
+ function toKebabCached(prop) {
90
+ const cached = STYLE_PROP_CACHE.get(prop);
91
+ if (cached !== void 0) return cached;
92
+ const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
93
+ if (STYLE_PROP_CACHE.size < MAX_STYLE_PROP_CACHE_SIZE) STYLE_PROP_CACHE.set(prop, kebab);
94
+ return kebab;
95
+ }
96
+ /**
97
+ * Clear the escape cache. Call between SSR requests in long-running servers
98
+ * to prevent memory buildup from unique strings.
99
+ */
100
+ function clearEscapeCache() {
101
+ escapeCache.clear();
102
+ }
103
+ /**
104
+ * Fast check if a string needs text escaping.
105
+ * Used to skip the full escape call when not needed.
106
+ */
107
+ function needsEscapeText(text) {
108
+ for (let i = 0; i < text.length; i++) {
109
+ const ch = text.charCodeAt(i);
110
+ if (ch === 38 || ch === 60 || ch === 62) return true;
111
+ }
112
+ return false;
113
+ }
114
+ /**
115
+ * Fast check if a string needs attribute escaping.
116
+ * Checks for & " ' < > characters.
117
+ */
118
+ function needsEscapeAttr(value) {
119
+ for (let i = 0; i < value.length; i++) {
120
+ const ch = value.charCodeAt(i);
121
+ if (ch === 38 || ch === 34 || ch === 39 || ch === 60 || ch === 62) return true;
122
+ }
123
+ return false;
124
+ }
125
+ /**
126
+ * Escape HTML special characters in text content
127
+ * Fast-path: cache first, then scan-then-escape for new strings
128
+ */
129
+ function escapeText(text) {
130
+ const useCache = text.length <= 64;
131
+ if (useCache) {
132
+ const cached = escapeCache.get(text);
133
+ if (cached !== void 0) return cached;
134
+ }
135
+ if (!needsEscapeText(text)) {
136
+ if (useCache && escapeCache.size < MAX_CACHE_SIZE) escapeCache.set(text, text);
137
+ return text;
138
+ }
139
+ let escaped = "";
140
+ let lastIndex = 0;
141
+ for (let i = 0; i < text.length; i++) {
142
+ const ch = text.charCodeAt(i);
143
+ let entity;
144
+ if (ch === 38) entity = "&amp;";
145
+ else if (ch === 60) entity = "&lt;";
146
+ else if (ch === 62) entity = "&gt;";
147
+ else continue;
148
+ escaped += text.slice(lastIndex, i) + entity;
149
+ lastIndex = i + 1;
150
+ }
151
+ const result = escaped + text.slice(lastIndex);
152
+ if (useCache && escapeCache.size < MAX_CACHE_SIZE) escapeCache.set(text, result);
153
+ return result;
154
+ }
155
+ /**
156
+ * Escape HTML special characters in attribute values.
157
+ * Single-pass scan: returns the original string unchanged when no special
158
+ * characters are found, so callers can drop separate needsEscapeAttr checks.
159
+ */
160
+ function escapeAttr(value) {
161
+ let escaped = "";
162
+ let lastIndex = 0;
163
+ for (let i = 0; i < value.length; i++) {
164
+ const ch = value.charCodeAt(i);
165
+ let entity;
166
+ if (ch === 38) entity = "&amp;";
167
+ else if (ch === 34) entity = "&quot;";
168
+ else if (ch === 39) entity = "&#x27;";
169
+ else if (ch === 60) entity = "&lt;";
170
+ else if (ch === 62) entity = "&gt;";
171
+ else continue;
172
+ escaped += value.slice(lastIndex, i) + entity;
173
+ lastIndex = i + 1;
174
+ }
175
+ return lastIndex === 0 ? value : escaped + value.slice(lastIndex);
176
+ }
177
+ /**
178
+ * Escape CSS value to prevent injection attacks.
179
+ * Removes characters that could break out of CSS context.
180
+ */
181
+ function escapeCssValue(value) {
182
+ const str = String(value);
183
+ if (CSS_URI_SCHEME_RE.test(str)) return "";
184
+ if (str.includes("(")) {
185
+ for (const match of str.matchAll(CSS_FUNCTION_NAME_RE)) if (!CSS_ALLOWED_FUNCTIONS.has(match[1].toLowerCase())) return "";
186
+ }
187
+ return str.replace(CSS_UNSAFE_RE, "");
188
+ }
189
+ /**
190
+ * Convert style object to CSS string with value escaping
191
+ * Optimized to avoid Object.entries allocation
192
+ */
193
+ function styleObjToCss(value) {
194
+ if (!value || typeof value !== "object") return null;
195
+ const styleObj = value;
196
+ let result = "";
197
+ for (const k in styleObj) {
198
+ const v = styleObj[k];
199
+ if (v === null || v === void 0 || v === false) continue;
200
+ const prop = toKebabCached(k);
201
+ const safeValue = escapeCssValue(String(v));
202
+ if (safeValue) result += `${prop}:${safeValue};`;
203
+ }
204
+ return result || null;
205
+ }
206
+ //#endregion
207
+ //#region src/ssr/context.ts
208
+ /**
209
+ * SSR Context Management
210
+ *
211
+ * Provides render-context storage for server-side rendering.
212
+ * Node SSR lazily installs AsyncLocalStorage on first use; browser builds use
213
+ * the fallback stack.
214
+ */
215
+ const FALLBACK_ASYNC_CONTEXT_ERROR = "[Askr] async SSR render context fallback is unsupported in this environment. Use synchronous SSR rendering or a runtime with AsyncLocalStorage.";
216
+ let renderContextAccessor = null;
217
+ let renderContextAccessorInitialized = false;
218
+ let asyncRenderContextAccessor = null;
219
+ let fallbackStack = null;
220
+ function ensureRenderContextAccessor() {
221
+ if (renderContextAccessorInitialized) return;
222
+ renderContextAccessorInitialized = true;
223
+ if (typeof process === "undefined" || !process.versions?.node) return;
224
+ try {
225
+ const asyncHooks = new Function("return require(" + JSON.stringify("async_hooks") + ");")();
226
+ if (asyncHooks.AsyncLocalStorage) {
227
+ const asyncLocalStorage = new asyncHooks.AsyncLocalStorage();
228
+ renderContextAccessor = {
229
+ getStore() {
230
+ return asyncLocalStorage.getStore();
231
+ },
232
+ run(store, fn) {
233
+ return asyncLocalStorage.run(store, fn);
234
+ }
235
+ };
236
+ }
237
+ } catch {}
238
+ }
239
+ function createRenderContext(seed = 12345, opts = {}) {
240
+ clearEscapeCache();
241
+ const queryCache = /* @__PURE__ */ new Map();
242
+ const envelope = opts.envelope ?? createPageRenderEnvelope({
243
+ resources: opts.data,
244
+ framework: opts.framework
245
+ });
246
+ return {
247
+ url: opts.url ?? "",
248
+ seed,
249
+ data: opts.data,
250
+ params: opts.params,
251
+ routes: opts.routes,
252
+ routeAuth: opts.routeAuth,
253
+ signal: opts.signal,
254
+ dataRuntime: opts.dataRuntime ?? createDataRuntime({ queryCache }),
255
+ mode: opts.mode ?? "ssr",
256
+ queryPrefetch: opts.queryPrefetch,
257
+ queryCache,
258
+ resourceDataProvided: opts.envelope ? Object.keys(envelope.resources).some((key) => key.startsWith("r:")) : opts.data !== void 0,
259
+ ssrCleanupFns: [],
260
+ keyCounter: 0,
261
+ renderData: envelope,
262
+ hydrationData: envelope,
263
+ deferredBoundaries: []
264
+ };
265
+ }
266
+ /**
267
+ * Run a function with the given render context.
268
+ * Concurrency-safe in Node.js via AsyncLocalStorage.
269
+ */
270
+ function withRenderContext(ctx, fn) {
271
+ ensureRenderContextAccessor();
272
+ if (renderContextAccessor) return renderContextAccessor.run(ctx, fn);
273
+ const prev = fallbackStack;
274
+ fallbackStack = ctx;
275
+ try {
276
+ const result = fn();
277
+ if (isPromiseLike(result)) throw new Error(FALLBACK_ASYNC_CONTEXT_ERROR);
278
+ return result;
279
+ } finally {
280
+ fallbackStack = prev;
281
+ }
282
+ }
283
+ async function getAsyncRenderContextAccessor() {
284
+ ensureRenderContextAccessor();
285
+ if (renderContextAccessor) return renderContextAccessor;
286
+ if (typeof process === "undefined" || !process.versions?.node) return null;
287
+ asyncRenderContextAccessor ??= (async () => {
288
+ try {
289
+ const module = await import(
290
+ /* @vite-ignore */
291
+ "node:async_hooks"
292
+ );
293
+ if (!module.AsyncLocalStorage) return null;
294
+ const storage = new module.AsyncLocalStorage();
295
+ renderContextAccessor = {
296
+ getStore: () => storage.getStore(),
297
+ run: (store, fn) => storage.run(store, fn)
298
+ };
299
+ return renderContextAccessor;
300
+ } catch {
301
+ return null;
302
+ }
303
+ })();
304
+ return asyncRenderContextAccessor;
305
+ }
306
+ async function withRenderContextAsync(ctx, fn) {
307
+ const accessor = await getAsyncRenderContextAccessor();
308
+ if (accessor) return accessor.run(ctx, () => Promise.resolve(fn()));
309
+ const previous = fallbackStack;
310
+ fallbackStack = ctx;
311
+ try {
312
+ return await fn();
313
+ } finally {
314
+ fallbackStack = previous;
315
+ }
316
+ }
317
+ /**
318
+ * Get the current render context.
319
+ * Returns null if not inside a render.
320
+ */
321
+ function getRenderContext() {
322
+ ensureRenderContextAccessor();
323
+ if (renderContextAccessor) return renderContextAccessor.getStore() ?? null;
324
+ return fallbackStack;
325
+ }
326
+ configureRenderContextProvider({ getRenderContext });
327
+ /**
328
+ * Centralized SSR enforcement helper — throws a consistent error when async
329
+ * data is encountered during synchronous SSR.
330
+ */
331
+ function throwSSRDataMissing() {
332
+ throw new SSRDataMissingError();
333
+ }
334
+ //#endregion
335
+ //#region src/ssr/route-policy-resolution.ts
336
+ const MAX_SSR_REDIRECTS = 20;
337
+ function getRouteRequestResultSync(result) {
338
+ if (isPromiseLike(result)) throwSSRDataMissing();
339
+ return result;
340
+ }
341
+ function buildDeniedRoute(route, status) {
342
+ return {
343
+ ...route,
344
+ handler: () => ({
345
+ type: "div",
346
+ props: { "data-route-denied": String(status) },
347
+ children: [String(status)]
348
+ })
349
+ };
350
+ }
351
+ function routeHasSSRLoader(manifest, route) {
352
+ const routeFallbackPrefix = route.fallbackPrefix;
353
+ return manifest.records.some((record) => {
354
+ const recordFallbackPrefix = record.fallbackPrefix;
355
+ return record.path === route.path && recordFallbackPrefix === routeFallbackPrefix && typeof record.options?.loader === "function";
356
+ });
357
+ }
358
+ function resolvePolicyAwareSSRRoute(opts, routeTable) {
359
+ const manifest = opts.registry?.manifest;
360
+ if (!manifest) {
361
+ const matched = _resolveRouteMatchFromRoutes(new URL(opts.url, "http://localhost").pathname, routeTable);
362
+ if (!matched) throw new Error(`SSR: no route found for url: ${opts.url}`);
363
+ return {
364
+ url: opts.url,
365
+ route: matched.route,
366
+ params: matched.params
367
+ };
368
+ }
369
+ let href = opts.url;
370
+ const visited = /* @__PURE__ */ new Set();
371
+ for (let redirects = 0; redirects <= MAX_SSR_REDIRECTS; redirects += 1) {
372
+ const matched = _resolveRouteMatchFromRoutes(new URL(href, "http://localhost").pathname, routeTable);
373
+ if (!matched) throw new Error(`SSR: no route found for url: ${href}`);
374
+ const resolved = getRouteRequestResultSync(resolveRouteRequest(href, {
375
+ manifest,
376
+ mode: "ssr"
377
+ }));
378
+ if (resolved === null) throw new Error(`SSR: no route found for url: ${href}`);
379
+ if (resolved.kind === "redirect") {
380
+ const redirectTarget = new URL(resolved.to, "http://localhost");
381
+ const redirectHref = `${redirectTarget.pathname}${redirectTarget.search}${redirectTarget.hash}`;
382
+ if (redirectHref === href || visited.has(redirectHref)) throw new Error(`[Askr] SSR redirect cycle detected at ${redirectHref}.`);
383
+ if (redirects >= MAX_SSR_REDIRECTS) throw new Error(`[Askr] SSR redirect limit exceeded (${MAX_SSR_REDIRECTS}).`);
384
+ visited.add(redirectHref);
385
+ href = redirectHref;
386
+ continue;
387
+ }
388
+ if (resolved.kind === "deny") return {
389
+ url: href,
390
+ route: buildDeniedRoute(matched.route, resolved.status),
391
+ params: matched.params
392
+ };
393
+ return {
394
+ url: href,
395
+ route: {
396
+ ...matched.route,
397
+ handler: routeHasSSRLoader(manifest, matched.route) ? resolved.handler : matched.route.handler
398
+ },
399
+ params: matched.params
400
+ };
401
+ }
402
+ throw new Error(`[Askr] SSR redirect limit exceeded (${MAX_SSR_REDIRECTS}).`);
403
+ }
404
+ //#endregion
405
+ //#region src/ssr/sink.ts
406
+ var StringSink = class StringSink {
407
+ constructor() {
408
+ this.chunks = [];
409
+ this.bufferChunks = [];
410
+ this.bufferLen = 0;
411
+ }
412
+ static {
413
+ this.FLUSH_THRESHOLD = 32 * 1024;
414
+ }
415
+ write(html) {
416
+ if (!html) return;
417
+ this.bufferChunks.push(html);
418
+ this.bufferLen += html.length;
419
+ if (this.bufferLen >= StringSink.FLUSH_THRESHOLD) {
420
+ this.chunks.push(this.bufferChunks.join(""));
421
+ this.bufferChunks.length = 0;
422
+ this.bufferLen = 0;
423
+ }
424
+ }
425
+ write2(a, b) {
426
+ if (a) {
427
+ this.bufferChunks.push(a);
428
+ this.bufferLen += a.length;
429
+ }
430
+ if (b) {
431
+ this.bufferChunks.push(b);
432
+ this.bufferLen += b.length;
433
+ }
434
+ if (this.bufferLen >= StringSink.FLUSH_THRESHOLD) {
435
+ this.chunks.push(this.bufferChunks.join(""));
436
+ this.bufferChunks.length = 0;
437
+ this.bufferLen = 0;
438
+ }
439
+ }
440
+ write3(a, b, c) {
441
+ if (a) {
442
+ this.bufferChunks.push(a);
443
+ this.bufferLen += a.length;
444
+ }
445
+ if (b) {
446
+ this.bufferChunks.push(b);
447
+ this.bufferLen += b.length;
448
+ }
449
+ if (c) {
450
+ this.bufferChunks.push(c);
451
+ this.bufferLen += c.length;
452
+ }
453
+ if (this.bufferLen >= StringSink.FLUSH_THRESHOLD) {
454
+ this.chunks.push(this.bufferChunks.join(""));
455
+ this.bufferChunks.length = 0;
456
+ this.bufferLen = 0;
457
+ }
458
+ }
459
+ end() {
460
+ if (this.bufferLen) {
461
+ this.chunks.push(this.bufferChunks.join(""));
462
+ this.bufferChunks.length = 0;
463
+ this.bufferLen = 0;
464
+ }
465
+ }
466
+ toString() {
467
+ if (this.bufferLen) {
468
+ this.chunks.push(this.bufferChunks.join(""));
469
+ this.bufferChunks.length = 0;
470
+ this.bufferLen = 0;
471
+ }
472
+ return this.chunks.join("");
473
+ }
474
+ };
475
+ var StreamSink = class {
476
+ constructor(onChunk, onComplete) {
477
+ this.onChunk = onChunk;
478
+ this.onComplete = onComplete;
479
+ }
480
+ write(html) {
481
+ if (html) this.onChunk(html);
482
+ }
483
+ end() {
484
+ this.onComplete();
485
+ }
486
+ };
487
+ //#endregion
488
+ //#region src/ssr/route-render.ts
489
+ async function resolveRequest(opts) {
490
+ const { url, auth, authContext, request, signal } = opts;
491
+ const manifest = opts.manifest ?? opts.registry?.manifest;
492
+ const routes = opts.routes ?? opts.registry?.routes;
493
+ if (manifest) return await resolveRouteRequest(url, {
494
+ manifest,
495
+ mode: "ssr",
496
+ auth,
497
+ authContext,
498
+ request,
499
+ signal
500
+ });
501
+ if (!routes) throw new Error("resolveRequest requires a route manifest or route table.");
502
+ const resolved = resolveRouteFromRoutes(new URL(url, "http://localhost").pathname, routes);
503
+ if (!resolved) return null;
504
+ return {
505
+ kind: "render",
506
+ handler: resolved.handler,
507
+ params: resolved.params
508
+ };
509
+ }
510
+ function resolveSSRRouteSource(source) {
511
+ const routes = source.routes ?? source.registry?.routes;
512
+ if (!routes || routes.length === 0) throw new Error("SSR requires a route registry or route table.");
513
+ return routes.map((route) => ({
514
+ ...route,
515
+ path: route.path,
516
+ handler: route.handler,
517
+ namespace: route.namespace
518
+ }));
519
+ }
520
+ function resolveSSRRouteRender(opts) {
521
+ const { seed = 12345, data, document } = opts;
522
+ const routeTable = resolveSSRRouteSource(opts);
523
+ const resolvedRoute = resolvePolicyAwareSSRRoute(opts, routeTable);
524
+ const requestUrl = new URL(resolvedRoute.url, "http://localhost");
525
+ const ctx = createRenderContext(seed, {
526
+ url: resolvedRoute.url,
527
+ data,
528
+ params: resolvedRoute.params,
529
+ routes: routeTable,
530
+ dataRuntime: opts.dataRuntime,
531
+ queryPrefetch: opts.queryPrefetch,
532
+ envelope: opts.envelope
533
+ });
534
+ return {
535
+ url: resolvedRoute.url,
536
+ requestUrl,
537
+ route: resolvedRoute.route,
538
+ params: resolvedRoute.params,
539
+ seed,
540
+ data,
541
+ ctx,
542
+ document
543
+ };
544
+ }
545
+ function buildDocumentRenderArgs(resolved, appHtml) {
546
+ return {
547
+ appHtml,
548
+ context: {
549
+ mode: "ssr",
550
+ url: resolved.url,
551
+ pathname: resolved.requestUrl.pathname,
552
+ search: resolved.requestUrl.search,
553
+ hash: resolved.requestUrl.hash,
554
+ params: resolved.params,
555
+ data: resolved.data,
556
+ seed: resolved.seed,
557
+ route: {
558
+ path: resolved.route.path,
559
+ namespace: resolved.route.namespace
560
+ }
561
+ }
562
+ };
563
+ }
564
+ function renderResolvedRouteAppToSink(resolved, sink, host) {
565
+ host.renderAppToSink({
566
+ route: resolved.route,
567
+ params: resolved.params,
568
+ data: resolved.data,
569
+ ctx: resolved.ctx,
570
+ sink
571
+ });
572
+ }
573
+ function renderToSinkInternal(opts, host) {
574
+ const { sink, ...renderOptions } = opts;
575
+ return withTelemetry(renderOptions.telemetry?.ssrRender, {}, () => {
576
+ const resolved = resolveSSRRouteRender(renderOptions);
577
+ if (!resolved.document) {
578
+ renderResolvedRouteAppToSink(resolved, sink, host);
579
+ return;
580
+ }
581
+ const appSink = new StringSink();
582
+ renderResolvedRouteAppToSink(resolved, appSink, host);
583
+ appSink.end();
584
+ sink.write(renderDocument(resolved.document, buildDocumentRenderArgs(resolved, appSink.toString()), "renderToString()/renderToStream()"));
585
+ });
586
+ }
587
+ function renderRouteToString(opts, host) {
588
+ const sink = new StringSink();
589
+ renderToSinkInternal({
590
+ ...opts,
591
+ sink
592
+ }, host);
593
+ sink.end();
594
+ return sink.toString();
595
+ }
596
+ function renderRouteToStream(opts, host) {
597
+ const sink = new StreamSink(opts.onChunk, opts.onComplete);
598
+ renderToSinkInternal({
599
+ ...opts,
600
+ sink
601
+ }, host);
602
+ sink.end();
603
+ }
604
+ //#endregion
605
+ //#region src/ssr/component-runtime.ts
606
+ function executeComponentSync(component, props, ctx, ownerFrame = null) {
607
+ try {
608
+ const prev = getCurrentComponentInstance();
609
+ const temp = createComponentInstance("ssr-temp", component, props || {}, null);
610
+ temp.ssr = true;
611
+ temp.ownerFrame = ownerFrame;
612
+ temp.portalScope = temp;
613
+ ctx.ssrCleanupFns.push(() => {
614
+ let cleanupError = null;
615
+ try {
616
+ cleanupComponent(temp);
617
+ } catch (error) {
618
+ cleanupError = error;
619
+ }
620
+ try {
621
+ disposeDefaultPortalScope(temp);
622
+ } catch (error) {
623
+ if (cleanupError) throw new AggregateError([cleanupError, error], "SSR temporary owner cleanup failed");
624
+ throw error;
625
+ }
626
+ if (cleanupError) throw cleanupError;
627
+ });
628
+ setCurrentComponentInstance(temp);
629
+ try {
630
+ const result = callWithContext(getExecutionContextFrame(ownerFrame), component, props || {}, { ssr: ctx });
631
+ if (isPromiseLike(result)) throwSSRDataMissing();
632
+ if (typeof result === "string" || typeof result === "number" || typeof result === "boolean" || result === null || result === void 0) {
633
+ const inner = result === null || result === void 0 || result === false ? "" : String(result);
634
+ return {
635
+ $$typeof: ELEMENT_TYPE,
636
+ type: Fragment,
637
+ props: { children: inner ? [inner] : [] }
638
+ };
639
+ }
640
+ return markVNodeTreeWithContextFrame(result, ownerFrame);
641
+ } finally {
642
+ setCurrentComponentInstance(prev);
643
+ }
644
+ } finally {}
645
+ }
646
+ function disposeSSRTemporaryOwners(ctx) {
647
+ const cleanupFns = ctx.ssrCleanupFns;
648
+ ctx.ssrCleanupFns = [];
649
+ const cleanupErrors = [];
650
+ for (let index = cleanupFns.length - 1; index >= 0; index -= 1) try {
651
+ cleanupFns[index]();
652
+ } catch (error) {
653
+ cleanupErrors.push(error);
654
+ }
655
+ if (cleanupErrors.length === 1) throw cleanupErrors[0];
656
+ if (cleanupErrors.length > 1) throw new AggregateError(cleanupErrors, "SSR temporary owner cleanup failed");
657
+ }
658
+ function wrapWithDefaultPortal(out) {
659
+ if (isPromiseLike(out)) throwSSRDataMissing();
660
+ const portalVNode = {
661
+ $$typeof: ELEMENT_TYPE,
662
+ type: DefaultPortal,
663
+ props: { __askrAutoDefaultPortal: true },
664
+ key: "__default_portal"
665
+ };
666
+ if (out == null) return {
667
+ $$typeof: ELEMENT_TYPE,
668
+ type: Fragment,
669
+ props: { children: [portalVNode] }
670
+ };
671
+ return {
672
+ $$typeof: ELEMENT_TYPE,
673
+ type: Fragment,
674
+ props: { children: [out, portalVNode] }
675
+ };
676
+ }
677
+ function renderSyncComponentRoot(component, props, ctx) {
678
+ const wrapped = (p, c) => wrapWithDefaultPortal(component(p ?? {}, c));
679
+ return executeComponentSync(wrapped, props || {}, ctx);
680
+ }
681
+ //#endregion
682
+ //#region src/ssr/boundaries.ts
683
+ function normalizeRenderableChildren(value) {
684
+ if (value === null || value === void 0 || value === false) return [];
685
+ return Array.isArray(value) ? value : [value];
686
+ }
687
+ function getRenderableChildren(node) {
688
+ if (Array.isArray(node.children)) return node.children;
689
+ if (Array.isArray(node.props?.children)) return node.props.children;
690
+ if (node.props?.children !== void 0 && node.props.children !== null && node.props.children !== false) return [node.props.children];
691
+ }
692
+ function getErrorBoundaryState(node) {
693
+ return node.__instance?.errorBoundaryState ?? null;
694
+ }
695
+ function resetErrorBoundaryState(node) {
696
+ const state = node.__instance?.errorBoundaryState;
697
+ if (state) {
698
+ state.error = null;
699
+ state.notified = false;
700
+ }
701
+ }
702
+ function createErrorBoundaryReset(node) {
703
+ return () => resetErrorBoundaryState(node);
704
+ }
705
+ function createDefaultErrorBoundaryFallbackVNode(error) {
706
+ const message = error instanceof Error ? error.stack || error.message || error.name : typeof error === "string" ? error : (() => {
707
+ try {
708
+ return JSON.stringify(error);
709
+ } catch {
710
+ return String(error);
711
+ }
712
+ })();
713
+ return {
714
+ $$typeof: ELEMENT_TYPE,
715
+ type: "div",
716
+ props: {
717
+ role: "alert",
718
+ "data-askr-error-boundary": "true",
719
+ style: {
720
+ boxSizing: "border-box",
721
+ padding: "1rem",
722
+ border: "1px solid currentColor",
723
+ borderRadius: "0.75rem",
724
+ display: "grid",
725
+ gap: "0.75rem",
726
+ maxWidth: "100%"
727
+ },
728
+ children: [
729
+ {
730
+ $$typeof: ELEMENT_TYPE,
731
+ type: "strong",
732
+ props: { children: ["Something went wrong while rendering this view."] }
733
+ },
734
+ {
735
+ $$typeof: ELEMENT_TYPE,
736
+ type: "p",
737
+ props: {
738
+ style: { margin: "0" },
739
+ children: ["The app recovered into a visible fallback so the error is not hidden in the console."]
740
+ }
741
+ },
742
+ {
743
+ $$typeof: ELEMENT_TYPE,
744
+ type: "details",
745
+ props: {
746
+ open: false,
747
+ children: [{
748
+ $$typeof: ELEMENT_TYPE,
749
+ type: "summary",
750
+ props: { children: ["Error details"] }
751
+ }, {
752
+ $$typeof: ELEMENT_TYPE,
753
+ type: "pre",
754
+ props: {
755
+ style: {
756
+ margin: "0",
757
+ whiteSpace: "pre-wrap",
758
+ wordBreak: "break-word"
759
+ },
760
+ children: [message]
761
+ }
762
+ }]
763
+ }
764
+ }
765
+ ]
766
+ },
767
+ key: null
768
+ };
769
+ }
770
+ function resolveErrorBoundaryFallbackNode(fallback, error, reset) {
771
+ return typeof fallback === "function" ? fallback(error, reset) : fallback !== void 0 ? fallback : createDefaultErrorBoundaryFallbackVNode(error);
772
+ }
773
+ function getControlBoundaryState(node) {
774
+ const boundaryNode = node;
775
+ return boundaryNode._controlState ?? boundaryNode._forState ?? null;
776
+ }
777
+ function evaluateControlBoundaryChildren(node) {
778
+ if (node.type !== __CONTROL_BOUNDARY__) return;
779
+ const controlState = getControlBoundaryState(node);
780
+ if (!controlState) return [];
781
+ if (controlState.kind === "for") return evaluateForState(controlState);
782
+ if (controlState.kind === "show") return evaluateShowState(controlState);
783
+ return evaluateCaseState(controlState);
784
+ }
785
+ function withControlBoundaryChildren(node, render) {
786
+ const controlState = getControlBoundaryState(node);
787
+ if (!controlState || controlState.kind !== "for") return render(evaluateControlBoundaryChildren(node));
788
+ const children = evaluateForState(controlState);
789
+ try {
790
+ const result = render(children);
791
+ commitForStateTransaction(controlState);
792
+ return result;
793
+ } catch (error) {
794
+ rollbackForStateTransaction(controlState);
795
+ throw error;
796
+ }
797
+ }
798
+ //#endregion
799
+ //#region src/ssr/attrs.ts
800
+ const ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;
801
+ const escapedAttrValueCache = /* @__PURE__ */ new Map();
802
+ function isEventHandler(key) {
803
+ return key.length >= 3 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90;
804
+ }
805
+ function getEscapedAttrValue(value) {
806
+ if (value.length > 64) return escapeAttr(value);
807
+ const cached = escapedAttrValueCache.get(value);
808
+ if (cached !== void 0) return cached;
809
+ const escaped = escapeAttr(value);
810
+ if (escaped === value) return value;
811
+ if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) escapedAttrValueCache.clear();
812
+ escapedAttrValueCache.set(value, escaped);
813
+ return escaped;
814
+ }
815
+ /**
816
+ * Render attributes directly to a sink without intermediate string allocations.
817
+ * This is the hot path for streaming SSR.
818
+ */
819
+ function renderAttrsDirect(props, sink) {
820
+ if (!props || typeof props !== "object") return;
821
+ const propsObj = props;
822
+ for (const key in propsObj) {
823
+ const value = propsObj[key];
824
+ if (key === "children" || key === "key" || key === "ref" || key === "dangerouslySetInnerHTML") continue;
825
+ if (isEventHandler(key)) continue;
826
+ if (key.charCodeAt(0) === 95) continue;
827
+ const attrName = getPublicAttributeName(key);
828
+ if (attrName === "style") {
829
+ const css = typeof value === "string" ? value : styleObjToCss(value);
830
+ if (!css) continue;
831
+ sink.write(" style=\"");
832
+ if (needsEscapeAttr(css)) sink.write(getEscapedAttrValue(css));
833
+ else sink.write(css);
834
+ sink.write("\"");
835
+ continue;
836
+ }
837
+ if (value === true) {
838
+ sink.write(" ");
839
+ sink.write(attrName);
840
+ continue;
841
+ }
842
+ if (value === false || value === null || value === void 0) continue;
843
+ const strValue = String(value);
844
+ sink.write(" ");
845
+ sink.write(attrName);
846
+ sink.write("=\"");
847
+ sink.write(getEscapedAttrValue(strValue));
848
+ sink.write("\"");
849
+ }
850
+ }
851
+ function renderAttrs(props, opts) {
852
+ if (!props || typeof props !== "object") return opts?.returnDangerousHtml ? { attrs: "" } : "";
853
+ const attrParts = [];
854
+ let dangerousHtml;
855
+ const propsObj = props;
856
+ for (const key in propsObj) {
857
+ const value = propsObj[key];
858
+ if (key === "children") continue;
859
+ if (key === "key" || key === "ref") continue;
860
+ if (key === "dangerouslySetInnerHTML") {
861
+ if (value && typeof value === "object" && "__html" in value) dangerousHtml = String(value.__html);
862
+ continue;
863
+ }
864
+ if (isEventHandler(key)) continue;
865
+ if (key.charCodeAt(0) === 95) continue;
866
+ const attrName = key === "class" ? "class" : getPublicAttributeName(key);
867
+ if (attrName === "style") {
868
+ const css = typeof value === "string" ? value : styleObjToCss(value);
869
+ if (css === null || css === "") continue;
870
+ attrParts.push(` style="${getEscapedAttrValue(css)}"`);
871
+ continue;
872
+ }
873
+ if (value === true) attrParts.push(` ${attrName}`);
874
+ else if (value === false || value === null || value === void 0) continue;
875
+ else {
876
+ const strValue = String(value);
877
+ attrParts.push(` ${attrName}="${getEscapedAttrValue(strValue)}"`);
878
+ }
879
+ }
880
+ const result = attrParts.join("");
881
+ if (opts?.returnDangerousHtml) return {
882
+ attrs: result,
883
+ dangerousHtml
884
+ };
885
+ return result;
886
+ }
887
+ //#endregion
888
+ //#region src/ssr/hydration-data.ts
889
+ const DEFERRED_PAYLOAD = "__askr_deferred__";
890
+ function hydrationReplacer(_key, value) {
891
+ if (!isDeferred(value)) return value;
892
+ if (value.state === "fulfilled") return {
893
+ [DEFERRED_PAYLOAD]: "fulfilled",
894
+ value: value.value
895
+ };
896
+ if (value.state === "rejected") return {
897
+ [DEFERRED_PAYLOAD]: "rejected",
898
+ error: value.error instanceof Error ? value.error.message : String(value.error)
899
+ };
900
+ return { [DEFERRED_PAYLOAD]: "pending" };
901
+ }
902
+ function serializeHydrationRenderData(data, runtime) {
903
+ const queryCache = runtime ? dehydrateDataRuntime(runtime) : void 0;
904
+ const current = isPageRenderEnvelope(data) ? data : createPageRenderEnvelope({ resources: data });
905
+ const payload = createPageRenderEnvelope({
906
+ resources: {
907
+ ...current.resources,
908
+ ...queryCache
909
+ },
910
+ route: current.route,
911
+ framework: current.framework
912
+ });
913
+ if (isEmptyPageRenderEnvelope(payload)) return "";
914
+ return `<script type="application/json" ${SSR_RENDER_DATA_ATTR}="true">${JSON.stringify(payload, hydrationReplacer).replace(/</g, "\\u003C").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029")}<\/script>`;
915
+ }
916
+ //#endregion
917
+ //#region src/ssr/render-keys.ts
918
+ function startRenderPhase(data) {
919
+ startRenderPhase$1(data === null ? null : isPageRenderEnvelope(data) ? data : createPageRenderEnvelope({ resources: data }));
920
+ }
921
+ function stopRenderPhase() {
922
+ stopRenderPhase$1();
923
+ }
924
+ //#endregion
925
+ //#region src/ssr/render-sync.ts
926
+ const RANGE_START = "<!--askr-range-start-->";
927
+ const RANGE_END = "<!--askr-range-end-->";
928
+ function renderDeferredBoundarySync(node, ctx) {
929
+ const id = String(node.props?.["id"] ?? "");
930
+ const pending = node.props?.["pending"];
931
+ return `<askr-resolve data-askr-deferred="${id}">${renderRenderableSync(pending, ctx)}</askr-resolve>`;
932
+ }
933
+ function isMultiRangeChild(child) {
934
+ if (Array.isArray(child)) return child.length !== 1;
935
+ if (!child || typeof child !== "object" || !("type" in child)) return false;
936
+ const vnode = child;
937
+ if (vnode.type !== Fragment) return false;
938
+ return (getRenderableChildren(vnode)?.length ?? 0) !== 1;
939
+ }
940
+ function renderControlChildrenSync(node, ctx) {
941
+ const controlState = node._controlState ?? node._forState;
942
+ return withControlBoundaryChildren(node, (children) => {
943
+ const values = children ?? [];
944
+ if (controlState?.kind === "for") return values.map((child) => {
945
+ const rendered = renderChildSync(child, ctx);
946
+ return isMultiRangeChild(child) ? `${RANGE_START}${rendered}${RANGE_END}` : rendered;
947
+ }).join("");
948
+ const rendered = renderChildrenSync(values, ctx);
949
+ return values.length === 1 && isMultiRangeChild(values[0]) ? `${RANGE_START}${rendered}${RANGE_END}` : values.length !== 1 ? `${RANGE_START}${rendered}${RANGE_END}` : rendered;
950
+ });
951
+ }
952
+ function inheritRenderableKey(source, result) {
953
+ const inheritedKey = source.key;
954
+ if (inheritedKey === void 0 || inheritedKey === null) return result;
955
+ if (!result || typeof result !== "object" || !("type" in result)) return result;
956
+ const resultVNode = result;
957
+ if (resultVNode.key === void 0 || resultVNode.key === null) resultVNode.key = inheritedKey;
958
+ if (typeof resultVNode.type === "string") {
959
+ if (!resultVNode.props) resultVNode.props = {};
960
+ if (resultVNode.props["data-key"] === void 0) resultVNode.props["data-key"] = String(inheritedKey);
961
+ if (resultVNode.props["data-askr-key-kind"] === void 0) resultVNode.props["data-askr-key-kind"] = typeof inheritedKey;
962
+ }
963
+ return result;
964
+ }
965
+ function renderRenderableSync(value, ctx) {
966
+ if (typeof value === "string") return escapeText(value);
967
+ if (typeof value === "number") return escapeText(String(value));
968
+ if (value === null || value === void 0 || value === false) return "";
969
+ if (Array.isArray(value)) return renderChildrenSync(value, ctx);
970
+ if (value && typeof value === "object" && "type" in value) return renderNodeSync(value, ctx);
971
+ return "";
972
+ }
973
+ function renderChildSync(child, ctx) {
974
+ return renderRenderableSync(child, ctx);
975
+ }
976
+ function renderRenderableSyncToSink(value, sink, ctx) {
977
+ if (value === null || value === void 0 || value === false) return;
978
+ if (typeof value === "string") {
979
+ sink.write(escapeText(value));
980
+ return;
981
+ }
982
+ if (typeof value === "number") {
983
+ sink.write(escapeText(String(value)));
984
+ return;
985
+ }
986
+ if (Array.isArray(value)) {
987
+ renderChildrenSyncToSink(value, sink, ctx);
988
+ return;
989
+ }
990
+ if (value && typeof value === "object" && "type" in value) renderNodeSyncToSink(value, sink, ctx);
991
+ }
992
+ function renderChildSyncToSink(child, sink, ctx) {
993
+ renderRenderableSyncToSink(child, sink, ctx);
994
+ }
995
+ function renderChildrenSync(children, ctx) {
996
+ if (!children || !Array.isArray(children) || children.length === 0) return "";
997
+ if (children.length === 1) return renderChildSync(children[0], ctx);
998
+ if (children.length <= 8) {
999
+ let result = "";
1000
+ for (const child of children) result += renderChildSync(child, ctx);
1001
+ return result;
1002
+ }
1003
+ return Array.from({ length: children.length }, (_, index) => renderChildSync(children[index], ctx)).join("");
1004
+ }
1005
+ function renderErrorBoundaryFallbackValue(fallback, error, reset, ctx) {
1006
+ const nextValue = resolveErrorBoundaryFallbackNode(fallback, error, reset);
1007
+ return Array.isArray(nextValue) ? renderChildrenSync(normalizeRenderableChildren(nextValue), ctx) : renderChildSync(nextValue, ctx);
1008
+ }
1009
+ function renderErrorBoundaryFallbackValueToSink(fallback, error, reset, sink, ctx) {
1010
+ sink.write(renderErrorBoundaryFallbackValue(fallback, error, reset, ctx));
1011
+ }
1012
+ function renderChildrenSyncToSink(children, sink, ctx) {
1013
+ if (!children || !Array.isArray(children) || children.length === 0) return;
1014
+ if (children.length >= 32) {
1015
+ for (let i = 0; i < children.length; i++) renderRenderableSyncToSink(children[i], sink, ctx);
1016
+ return;
1017
+ }
1018
+ for (let i = 0; i < children.length; i++) renderChildSyncToSink(children[i], sink, ctx);
1019
+ }
1020
+ function sinkWrite2(sink, a, b) {
1021
+ if (typeof sink.write2 === "function") {
1022
+ sink.write2(a, b);
1023
+ return;
1024
+ }
1025
+ sink.write(a);
1026
+ sink.write(b);
1027
+ }
1028
+ function sinkWrite3(sink, a, b, c) {
1029
+ if (typeof sink.write3 === "function") {
1030
+ sink.write3(a, b, c);
1031
+ return;
1032
+ }
1033
+ sink.write(a);
1034
+ sink.write(b);
1035
+ sink.write(c);
1036
+ }
1037
+ function renderNodeSync(node, ctx) {
1038
+ const { type, props } = node;
1039
+ if (typeof type === "function") return renderRenderableSync(inheritRenderableKey(node, executeComponentSync(type, props, ctx, getVNodeContextFrame(node) ?? null)), ctx);
1040
+ if (typeof type === "symbol") {
1041
+ if (type === Fragment) return renderChildrenSync(getRenderableChildren(node), ctx);
1042
+ if (type === __CONTROL_BOUNDARY__) return renderControlChildrenSync(node, ctx);
1043
+ if (type === DEFERRED_BOUNDARY) return renderDeferredBoundarySync(node, ctx);
1044
+ if (type === __ERROR_BOUNDARY__) {
1045
+ const boundaryState = getErrorBoundaryState(node);
1046
+ const fallback = props?.fallback;
1047
+ const reset = createErrorBoundaryReset(node);
1048
+ if (boundaryState?.error != null) return renderErrorBoundaryFallbackValue(fallback, boundaryState.error, reset, ctx);
1049
+ try {
1050
+ return renderChildrenSync(normalizeRenderableChildren(props?.children), ctx);
1051
+ } catch (error) {
1052
+ if (boundaryState) {
1053
+ boundaryState.error = error;
1054
+ boundaryState.notified = true;
1055
+ }
1056
+ logger.error("[Askr] ErrorBoundary caught render error:", error);
1057
+ return renderErrorBoundaryFallbackValue(fallback, error, reset, ctx);
1058
+ }
1059
+ }
1060
+ throw new Error(`renderNodeSync: unsupported VNode symbol type: ${String(type)}`);
1061
+ }
1062
+ const typeStr = type;
1063
+ if (VOID_ELEMENTS.has(typeStr)) return `<${typeStr}${renderAttrs(props)} />`;
1064
+ const maybeDangerous = props?.dangerouslySetInnerHTML;
1065
+ if (maybeDangerous !== void 0 && maybeDangerous !== null) {
1066
+ const { attrs, dangerousHtml } = renderAttrs(props, { returnDangerousHtml: true });
1067
+ if (dangerousHtml !== void 0) return `<${typeStr}${attrs}>${dangerousHtml}</${typeStr}>`;
1068
+ return `<${typeStr}${attrs}>${renderChildrenSync(getRenderableChildren(node), ctx)}</${typeStr}>`;
1069
+ }
1070
+ return `<${typeStr}${renderAttrs(props)}>${renderChildrenSync(getRenderableChildren(node), ctx)}</${typeStr}>`;
1071
+ }
1072
+ function renderNodeSyncToSink(node, sink, ctx) {
1073
+ const { type, props } = node;
1074
+ if (typeof type === "function") {
1075
+ renderRenderableSyncToSink(inheritRenderableKey(node, executeComponentSync(type, props, ctx, getVNodeContextFrame(node) ?? null)), sink, ctx);
1076
+ return;
1077
+ }
1078
+ if (typeof type === "symbol") {
1079
+ if (type === Fragment) {
1080
+ renderChildrenSyncToSink(getRenderableChildren(node), sink, ctx);
1081
+ return;
1082
+ }
1083
+ if (type === __CONTROL_BOUNDARY__) {
1084
+ const rendered = renderControlChildrenSync(node, ctx);
1085
+ sink.write(rendered);
1086
+ return;
1087
+ }
1088
+ if (type === DEFERRED_BOUNDARY) {
1089
+ sink.write(renderDeferredBoundarySync(node, ctx));
1090
+ return;
1091
+ }
1092
+ if (type === __ERROR_BOUNDARY__) {
1093
+ const boundaryState = getErrorBoundaryState(node);
1094
+ const fallback = props?.fallback;
1095
+ const reset = createErrorBoundaryReset(node);
1096
+ if (boundaryState?.error != null) {
1097
+ renderErrorBoundaryFallbackValueToSink(fallback, boundaryState.error, reset, sink, ctx);
1098
+ return;
1099
+ }
1100
+ try {
1101
+ renderChildrenSyncToSink(normalizeRenderableChildren(props?.children), sink, ctx);
1102
+ } catch (error) {
1103
+ if (boundaryState) {
1104
+ boundaryState.error = error;
1105
+ boundaryState.notified = true;
1106
+ }
1107
+ logger.error("[Askr] ErrorBoundary caught render error:", error);
1108
+ renderErrorBoundaryFallbackValueToSink(fallback, error, reset, sink, ctx);
1109
+ }
1110
+ return;
1111
+ }
1112
+ throw new Error(`renderNodeSyncToSink: unsupported VNode symbol type: ${String(type)}`);
1113
+ }
1114
+ const typeStr = type;
1115
+ if (VOID_ELEMENTS.has(typeStr)) {
1116
+ sinkWrite2(sink, "<", typeStr);
1117
+ renderAttrsDirect(props, sink);
1118
+ sink.write(" />");
1119
+ return;
1120
+ }
1121
+ const maybeDangerous = props ? props?.dangerouslySetInnerHTML : void 0;
1122
+ if (maybeDangerous !== void 0 && maybeDangerous !== null) {
1123
+ const dangerousHtml = typeof maybeDangerous === "object" && "__html" in maybeDangerous ? String(maybeDangerous.__html) : void 0;
1124
+ sinkWrite2(sink, "<", typeStr);
1125
+ renderAttrsDirect(props, sink);
1126
+ sink.write(">");
1127
+ if (dangerousHtml !== void 0) sink.write(dangerousHtml);
1128
+ else renderChildrenSyncToSink(getRenderableChildren(node), sink, ctx);
1129
+ sinkWrite3(sink, "</", typeStr, ">");
1130
+ return;
1131
+ }
1132
+ const children = getRenderableChildren(node);
1133
+ if (!children || Array.isArray(children) && children.length === 0) {
1134
+ sinkWrite2(sink, "<", typeStr);
1135
+ renderAttrsDirect(props, sink);
1136
+ sink.write(">");
1137
+ sinkWrite3(sink, "</", typeStr, ">");
1138
+ return;
1139
+ }
1140
+ if (Array.isArray(children) && children.length === 1) {
1141
+ const only = children[0];
1142
+ if (typeof only === "string") {
1143
+ const content = escapeText(only);
1144
+ sinkWrite2(sink, "<", typeStr);
1145
+ renderAttrsDirect(props, sink);
1146
+ sink.write(">");
1147
+ sink.write(content);
1148
+ sinkWrite3(sink, "</", typeStr, ">");
1149
+ return;
1150
+ }
1151
+ if (typeof only === "number") {
1152
+ const content = escapeText(String(only));
1153
+ sinkWrite2(sink, "<", typeStr);
1154
+ renderAttrsDirect(props, sink);
1155
+ sink.write(">");
1156
+ sink.write(content);
1157
+ sinkWrite3(sink, "</", typeStr, ">");
1158
+ return;
1159
+ }
1160
+ }
1161
+ sinkWrite2(sink, "<", typeStr);
1162
+ renderAttrsDirect(props, sink);
1163
+ sink.write(">");
1164
+ renderChildrenSyncToSink(children, sink, ctx);
1165
+ sinkWrite3(sink, "</", typeStr, ">");
1166
+ }
1167
+ function renderToStringSync(component, props, options) {
1168
+ const ctx = createRenderContext(options?.seed ?? 12345, {
1169
+ data: options?.data,
1170
+ envelope: options?.envelope
1171
+ });
1172
+ return withRenderContext(ctx, () => {
1173
+ startRenderPhase(ctx.renderData);
1174
+ try {
1175
+ const node = renderSyncComponentRoot(component, props || {}, ctx);
1176
+ if (!node) throw new Error("renderToStringSync: wrapped component returned empty");
1177
+ const sink = new StringSink();
1178
+ renderNodeSyncToSink(node, sink, ctx);
1179
+ sink.write(serializeHydrationRenderData(ctx.hydrationData ?? void 0, ctx.dataRuntime));
1180
+ sink.end();
1181
+ return sink.toString();
1182
+ } finally {
1183
+ try {
1184
+ stopRenderPhase();
1185
+ } finally {
1186
+ disposeSSRTemporaryOwners(ctx);
1187
+ }
1188
+ }
1189
+ });
1190
+ }
1191
+ function renderSSRRouteAppToSink(input) {
1192
+ const { ctx, data, route, params, sink } = input;
1193
+ withRenderContext(ctx, () => {
1194
+ startRenderPhase(ctx.renderData);
1195
+ try {
1196
+ renderRenderableSyncToSink(executeComponentSync(route.handler, params, ctx), sink, ctx);
1197
+ if (ctx.deferredBoundaries.length === 0) sink.write(serializeHydrationRenderData(ctx.hydrationData ?? data, ctx.dataRuntime));
1198
+ } finally {
1199
+ try {
1200
+ stopRenderPhase();
1201
+ } finally {
1202
+ disposeSSRTemporaryOwners(ctx);
1203
+ }
1204
+ }
1205
+ });
1206
+ }
1207
+ //#endregion
1208
+ //#region src/ssr/render-resolved.ts
1209
+ function sameRouteParams(left, right) {
1210
+ if (!left || !right) return !left && !right;
1211
+ const leftKeys = Object.keys(left);
1212
+ const rightKeys = Object.keys(right);
1213
+ if (leftKeys.length !== rightKeys.length) return false;
1214
+ for (const key of leftKeys) if (left[key] !== right[key]) return false;
1215
+ return true;
1216
+ }
1217
+ function renderResolvedToStringSync(opts) {
1218
+ const { url, routes, handler, params, options } = opts;
1219
+ const requestUrl = new URL(url, "http://localhost");
1220
+ const matchedIndex = routes.findIndex((route) => {
1221
+ const resolved = resolveRouteFromRoutes(requestUrl.pathname, [route]);
1222
+ return resolved !== null && resolved.handler === route.handler && sameRouteParams(resolved.params, params);
1223
+ });
1224
+ if (matchedIndex < 0) throw new Error(`renderResolvedToStringSync: no route found for url: ${url}`);
1225
+ return renderToString({
1226
+ url,
1227
+ routes: routes.map((route, index) => index === matchedIndex ? {
1228
+ ...route,
1229
+ handler
1230
+ } : route),
1231
+ seed: options?.seed,
1232
+ data: options?.data,
1233
+ dataRuntime: options?.dataRuntime,
1234
+ envelope: options?.envelope
1235
+ });
1236
+ }
1237
+ //#endregion
1238
+ //#region src/ssr/route-request-render.ts
1239
+ function abortError() {
1240
+ const error = /* @__PURE__ */ new Error("Deferred route rendering was aborted.");
1241
+ error.name = "AbortError";
1242
+ return error;
1243
+ }
1244
+ function settleWithSignal(promise, signal) {
1245
+ if (signal.aborted) return Promise.reject(abortError());
1246
+ return new Promise((resolve, reject) => {
1247
+ const abort = () => reject(abortError());
1248
+ signal.addEventListener("abort", abort, { once: true });
1249
+ promise.then((value) => {
1250
+ signal.removeEventListener("abort", abort);
1251
+ resolve(value);
1252
+ }, (error) => {
1253
+ signal.removeEventListener("abort", abort);
1254
+ reject(error);
1255
+ });
1256
+ });
1257
+ }
1258
+ function stripHydrationPayload(html) {
1259
+ return html.replace(/<script type="application\/json" data-askr-render-data="true">[\s\S]*?<\/script>$/, "");
1260
+ }
1261
+ function renderBoundary(boundary, state, payload, seed, data) {
1262
+ return stripHydrationPayload(renderToStringSync(() => state === "fulfilled" ? boundary.fulfilled(payload) : boundary.rejected(payload), {}, {
1263
+ seed,
1264
+ envelope: data ?? void 0
1265
+ }));
1266
+ }
1267
+ function patchChunk(id, html) {
1268
+ const selector = `askr-resolve[data-askr-deferred=${JSON.stringify(id)}]`;
1269
+ return `<template data-askr-deferred-patch="${id}">${html}</template><script data-askr-deferred-apply="${id}">(function(s){var t=s.previousElementSibling;var b=document.querySelector(${JSON.stringify(selector)});if(b&&t){b.replaceWith(t.content.cloneNode(true));}if(t)t.remove();s.remove();})(document.currentScript)<\/script>`;
1270
+ }
1271
+ function createDeferredRenderStream(initialHtml, boundaries, signal, seed, data, runtime) {
1272
+ const encoder = new TextEncoder();
1273
+ const local = new AbortController();
1274
+ let cancelled = false;
1275
+ let closed = false;
1276
+ let initialPending = true;
1277
+ let boundaryIndex = 0;
1278
+ let controllerRef;
1279
+ const cleanup = () => signal.removeEventListener("abort", abort);
1280
+ const close = (controller) => {
1281
+ if (closed) return;
1282
+ closed = true;
1283
+ cleanup();
1284
+ controller.close();
1285
+ };
1286
+ const abort = () => {
1287
+ local.abort(signal.reason);
1288
+ if (controllerRef) close(controllerRef);
1289
+ };
1290
+ signal.addEventListener("abort", abort, { once: true });
1291
+ return new ReadableStream({
1292
+ start(controller) {
1293
+ controllerRef = controller;
1294
+ },
1295
+ async pull(controller) {
1296
+ if (cancelled || closed) return;
1297
+ if (initialPending) {
1298
+ initialPending = false;
1299
+ controller.enqueue(encoder.encode(stripHydrationPayload(initialHtml)));
1300
+ return;
1301
+ }
1302
+ const boundary = boundaries[boundaryIndex];
1303
+ if (boundary) {
1304
+ boundaryIndex += 1;
1305
+ try {
1306
+ const value = await settleWithSignal(boundary.promise, local.signal);
1307
+ if (!cancelled && !closed) controller.enqueue(encoder.encode(patchChunk(boundary.id, renderBoundary(boundary, "fulfilled", value, seed, data))));
1308
+ } catch (error) {
1309
+ if (local.signal.aborted) {
1310
+ if (!cancelled && !closed) close(controller);
1311
+ return;
1312
+ }
1313
+ if (!cancelled && !closed) controller.enqueue(encoder.encode(patchChunk(boundary.id, renderBoundary(boundary, "rejected", error, seed, data))));
1314
+ }
1315
+ return;
1316
+ }
1317
+ const hydration = serializeHydrationRenderData(data ?? void 0, runtime);
1318
+ if (hydration) controller.enqueue(encoder.encode(hydration));
1319
+ close(controller);
1320
+ },
1321
+ cancel(reason) {
1322
+ cancelled = true;
1323
+ local.abort(reason);
1324
+ cleanup();
1325
+ }
1326
+ });
1327
+ }
1328
+ async function renderRouteRequest(options) {
1329
+ return renderRouteRequestInternal(options);
1330
+ }
1331
+ async function renderRouteRequestToString(options) {
1332
+ const result = await renderRouteRequestInternal(options);
1333
+ if (result.kind !== "render" || !result.stream) return result;
1334
+ return {
1335
+ ...result,
1336
+ html: await new Response(result.stream).text(),
1337
+ stream: void 0
1338
+ };
1339
+ }
1340
+ async function renderRouteRequestInternal(options) {
1341
+ const manifest = options.manifest ?? options.registry?.manifest;
1342
+ if (!manifest) throw new Error("renderRouteRequestToString requires a route manifest or registry.");
1343
+ const signal = options.signal ?? options.request?.signal ?? new AbortController().signal;
1344
+ const request = options.request ?? new Request(new URL(options.url, "http://localhost"));
1345
+ const runtime = options.dataRuntime ?? createDataRuntime();
1346
+ const prefetch = options.queryPrefetch ?? createQueryPrefetchContext({
1347
+ runtime,
1348
+ registry: options.queryRegistry,
1349
+ request,
1350
+ signal,
1351
+ mode: "ssr",
1352
+ telemetry: options.telemetry
1353
+ });
1354
+ const context = createRenderContext(options.seed, {
1355
+ url: options.url,
1356
+ data: options.data,
1357
+ framework: options.framework,
1358
+ signal,
1359
+ dataRuntime: runtime,
1360
+ queryPrefetch: prefetch,
1361
+ mode: "ssr"
1362
+ });
1363
+ return withTelemetry(options.telemetry?.ssrRender, {}, () => withRenderContextAsync(context, async () => {
1364
+ const resolved = await resolveRouteRequest(options.url, {
1365
+ manifest,
1366
+ mode: "ssr",
1367
+ auth: options.auth ?? manifest.auth,
1368
+ authContext: options.authContext,
1369
+ request,
1370
+ signal,
1371
+ telemetry: options.telemetry
1372
+ });
1373
+ if (!resolved) return { kind: "no-match" };
1374
+ if (resolved.kind !== "render") return resolved;
1375
+ const sink = new StringSink();
1376
+ renderSSRRouteAppToSink({
1377
+ route: {
1378
+ path: "",
1379
+ handler: resolved.handler
1380
+ },
1381
+ params: resolved.params,
1382
+ data: options.data,
1383
+ ctx: context,
1384
+ sink
1385
+ });
1386
+ sink.end();
1387
+ const html = sink.toString();
1388
+ const boundaries = [...context.deferredBoundaries];
1389
+ const result = {
1390
+ kind: "render",
1391
+ html,
1392
+ ...boundaries.length > 0 ? { stream: createDeferredRenderStream(html, boundaries, signal, options.seed, context.hydrationData, runtime) } : {},
1393
+ params: resolved.params
1394
+ };
1395
+ if (resolved.record) Object.defineProperty(result, "record", {
1396
+ value: resolved.record,
1397
+ enumerable: false
1398
+ });
1399
+ return result;
1400
+ }));
1401
+ }
1402
+ //#endregion
1403
+ //#region src/ssr/index-internal.ts
1404
+ const routeRenderHost = { renderAppToSink: renderSSRRouteAppToSink };
1405
+ function renderToString(arg) {
1406
+ if (typeof arg === "function") return renderToStringSync(arg);
1407
+ return renderRouteToString(arg, routeRenderHost);
1408
+ }
1409
+ function renderToStream(opts) {
1410
+ renderRouteToStream(opts, routeRenderHost);
1411
+ }
1412
+ //#endregion
1413
+ export { renderResolvedToStringSync as a, createRenderContext as c, withRenderContextAsync as d, renderRouteRequestToString as i, getRenderContext as l, renderToString as n, renderToStringSync as o, renderRouteRequest as r, resolveRequest as s, renderToStream as t, withRenderContext as u };