@askrjs/askr 0.0.27 → 0.0.29

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 (442) hide show
  1. package/README.md +55 -147
  2. package/dist/_virtual/_rolldown/runtime.js +7 -0
  3. package/dist/bench/components/benchmark-row.d.ts +20 -0
  4. package/dist/bench/components/benchmark-row.d.ts.map +1 -0
  5. package/dist/bench/components/benchmark-row.js +42 -0
  6. package/dist/bench/components/benchmark-row.js.map +1 -0
  7. package/dist/bench/components/benchmark-table.js +25 -0
  8. package/dist/bench/components/benchmark-table.js.map +1 -0
  9. package/dist/benchmark.d.ts +22 -0
  10. package/dist/benchmark.d.ts.map +1 -0
  11. package/dist/benchmark.js +64 -1
  12. package/dist/benchmark.js.map +1 -0
  13. package/dist/bin/askr-ssg.d.ts +28 -0
  14. package/dist/bin/askr-ssg.d.ts.map +1 -0
  15. package/dist/bin/askr-ssg.js +171 -0
  16. package/dist/bin/askr-ssg.js.map +1 -0
  17. package/dist/boot/index.d.ts +64 -42
  18. package/dist/boot/index.d.ts.map +1 -1
  19. package/dist/boot/index.js +416 -2
  20. package/dist/boot/index.js.map +1 -0
  21. package/dist/common/component.d.ts +14 -13
  22. package/dist/common/component.d.ts.map +1 -1
  23. package/dist/common/control.d.ts +13 -0
  24. package/dist/common/control.d.ts.map +1 -0
  25. package/dist/common/control.js +14 -0
  26. package/dist/common/control.js.map +1 -0
  27. package/dist/common/env.js +47 -0
  28. package/dist/common/env.js.map +1 -0
  29. package/dist/common/jsx.d.ts +17 -15
  30. package/dist/common/jsx.d.ts.map +1 -1
  31. package/dist/common/jsx.js +8 -1
  32. package/dist/common/jsx.js.map +1 -0
  33. package/dist/common/props.d.ts +14 -11
  34. package/dist/common/props.d.ts.map +1 -1
  35. package/dist/common/router.d.ts +190 -32
  36. package/dist/common/router.d.ts.map +1 -1
  37. package/dist/common/ssr-errors.d.ts +6 -3
  38. package/dist/common/ssr-errors.d.ts.map +1 -1
  39. package/dist/common/ssr-errors.js +16 -1
  40. package/dist/common/ssr-errors.js.map +1 -0
  41. package/dist/common/ssr.d.ts +12 -9
  42. package/dist/common/ssr.d.ts.map +1 -1
  43. package/dist/common/vnode.d.ts +17 -15
  44. package/dist/common/vnode.d.ts.map +1 -1
  45. package/dist/common/vnode.js +10 -1
  46. package/dist/common/vnode.js.map +1 -0
  47. package/dist/components/link.d.ts +37 -25
  48. package/dist/components/link.d.ts.map +1 -1
  49. package/dist/components/link.js +64 -1
  50. package/dist/components/link.js.map +1 -0
  51. package/dist/control/case.d.ts +17 -0
  52. package/dist/control/case.d.ts.map +1 -0
  53. package/dist/control/case.js +69 -0
  54. package/dist/control/case.js.map +1 -0
  55. package/dist/control/for.d.ts +23 -0
  56. package/dist/control/for.d.ts.map +1 -0
  57. package/dist/control/for.js +62 -0
  58. package/dist/control/for.js.map +1 -0
  59. package/dist/control/index.d.ts +4 -0
  60. package/dist/control/index.js +4 -0
  61. package/dist/control/shared.js +20 -0
  62. package/dist/control/shared.js.map +1 -0
  63. package/dist/control/show.d.ts +14 -0
  64. package/dist/control/show.d.ts.map +1 -0
  65. package/dist/control/show.js +33 -0
  66. package/dist/control/show.js.map +1 -0
  67. package/dist/dev/invariant.js +29 -2
  68. package/dist/dev/invariant.js.map +1 -0
  69. package/dist/dev/logger.js +37 -1
  70. package/dist/dev/logger.js.map +1 -0
  71. package/dist/foundations/icon/icon.d.ts +53 -0
  72. package/dist/foundations/icon/icon.d.ts.map +1 -0
  73. package/dist/foundations/icon/icon.js +88 -0
  74. package/dist/foundations/icon/icon.js.map +1 -0
  75. package/dist/foundations/icon/icon.types.d.ts +21 -0
  76. package/dist/foundations/icon/icon.types.d.ts.map +1 -0
  77. package/dist/foundations/index.d.ts +10 -3
  78. package/dist/foundations/index.js +9 -1
  79. package/dist/foundations/interactions/interaction-policy.js +93 -1
  80. package/dist/foundations/interactions/interaction-policy.js.map +1 -0
  81. package/dist/foundations/interactions/pressable.js +51 -1
  82. package/dist/foundations/interactions/pressable.js.map +1 -0
  83. package/dist/foundations/structures/collection.d.ts +25 -40
  84. package/dist/foundations/structures/collection.d.ts.map +1 -1
  85. package/dist/foundations/structures/collection.js +51 -1
  86. package/dist/foundations/structures/collection.js.map +1 -0
  87. package/dist/foundations/structures/layer.d.ts +47 -68
  88. package/dist/foundations/structures/layer.d.ts.map +1 -1
  89. package/dist/foundations/structures/layer.js +81 -1
  90. package/dist/foundations/structures/layer.js.map +1 -0
  91. package/dist/foundations/structures/layout.d.ts +6 -3
  92. package/dist/foundations/structures/layout.d.ts.map +1 -1
  93. package/dist/foundations/structures/layout.js +13 -1
  94. package/dist/foundations/structures/layout.js.map +1 -0
  95. package/dist/foundations/structures/portal.d.ts +17 -10
  96. package/dist/foundations/structures/portal.d.ts.map +1 -1
  97. package/dist/foundations/structures/portal.js +105 -1
  98. package/dist/foundations/structures/portal.js.map +1 -0
  99. package/dist/foundations/structures/presence.d.ts +11 -5
  100. package/dist/foundations/structures/presence.d.ts.map +1 -1
  101. package/dist/foundations/structures/presence.js +39 -1
  102. package/dist/foundations/structures/presence.js.map +1 -0
  103. package/dist/foundations/structures/slot.d.ts +11 -8
  104. package/dist/foundations/structures/slot.d.ts.map +1 -1
  105. package/dist/foundations/structures/slot.js +41 -1
  106. package/dist/foundations/structures/slot.js.map +1 -0
  107. package/dist/foundations/structures.d.ts +7 -14
  108. package/dist/foundations/structures.js +6 -1
  109. package/dist/foundations/utilities/aria.js +11 -1
  110. package/dist/foundations/utilities/aria.js.map +1 -0
  111. package/dist/foundations/utilities/compose-handlers.js +20 -1
  112. package/dist/foundations/utilities/compose-handlers.js.map +1 -0
  113. package/dist/foundations/utilities/compose-ref.d.ts +7 -4
  114. package/dist/foundations/utilities/compose-ref.d.ts.map +1 -1
  115. package/dist/foundations/utilities/compose-ref.js +18 -1
  116. package/dist/foundations/utilities/compose-ref.js.map +1 -0
  117. package/dist/foundations/utilities/merge-props.js +49 -1
  118. package/dist/foundations/utilities/merge-props.js.map +1 -0
  119. package/dist/fx/fx.d.ts +24 -21
  120. package/dist/fx/fx.d.ts.map +1 -1
  121. package/dist/fx/fx.js +212 -1
  122. package/dist/fx/fx.js.map +1 -0
  123. package/dist/fx/index.d.ts +4 -7
  124. package/dist/fx/index.js +4 -1
  125. package/dist/fx/noop.js +9 -1
  126. package/dist/fx/noop.js.map +1 -0
  127. package/dist/fx/timing.d.ts +24 -21
  128. package/dist/fx/timing.d.ts.map +1 -1
  129. package/dist/fx/timing.js +236 -1
  130. package/dist/fx/timing.js.map +1 -0
  131. package/dist/index.d.ts +21 -20
  132. package/dist/index.js +34 -1
  133. package/dist/index.js.map +1 -0
  134. package/dist/jsx/index.d.ts +1 -4
  135. package/dist/jsx/index.js +3 -1
  136. package/dist/jsx/types.d.ts +18 -25
  137. package/dist/jsx/types.d.ts.map +1 -1
  138. package/dist/jsx/types.js +1 -1
  139. package/dist/jsx/utils.d.ts +4 -3
  140. package/dist/jsx/utils.d.ts.map +1 -1
  141. package/dist/jsx/utils.js +19 -1
  142. package/dist/jsx/utils.js.map +1 -0
  143. package/dist/jsx-dev-runtime.d.ts +8 -0
  144. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  145. package/dist/jsx-dev-runtime.js +32 -1
  146. package/dist/jsx-dev-runtime.js.map +1 -0
  147. package/dist/jsx-runtime.d.ts +12 -0
  148. package/dist/jsx-runtime.d.ts.map +1 -0
  149. package/dist/jsx-runtime.js +45 -1
  150. package/dist/jsx-runtime.js.map +1 -0
  151. package/dist/jsx-runtime2.d.ts +2 -0
  152. package/dist/jsx-runtime2.js +3 -0
  153. package/dist/renderer/children.js +293 -0
  154. package/dist/renderer/children.js.map +1 -0
  155. package/dist/renderer/cleanup.js +150 -1
  156. package/dist/renderer/cleanup.js.map +1 -0
  157. package/dist/renderer/dom.js +2439 -1
  158. package/dist/renderer/dom.js.map +1 -0
  159. package/dist/renderer/env.js +1 -0
  160. package/dist/renderer/evaluate.js +450 -1
  161. package/dist/renderer/evaluate.js.map +1 -0
  162. package/dist/renderer/fastpath.js +145 -1
  163. package/dist/renderer/fastpath.js.map +1 -0
  164. package/dist/renderer/index.js +24 -1
  165. package/dist/renderer/index.js.map +1 -0
  166. package/dist/renderer/keyed.js +119 -1
  167. package/dist/renderer/keyed.js.map +1 -0
  168. package/dist/renderer/reconcile.js +359 -1
  169. package/dist/renderer/reconcile.js.map +1 -0
  170. package/dist/renderer/types.js +1 -1
  171. package/dist/renderer/utils.js +220 -1
  172. package/dist/renderer/utils.js.map +1 -0
  173. package/dist/resources/index.d.ts +3 -9
  174. package/dist/resources/index.js +3 -1
  175. package/dist/router/index.d.ts +6 -10
  176. package/dist/router/index.js +5 -1
  177. package/dist/router/match.js +83 -1
  178. package/dist/router/match.js.map +1 -0
  179. package/dist/router/navigate.d.ts +20 -8
  180. package/dist/router/navigate.d.ts.map +1 -1
  181. package/dist/router/navigate.js +288 -1
  182. package/dist/router/navigate.js.map +1 -0
  183. package/dist/router/policy.d.ts +22 -0
  184. package/dist/router/policy.d.ts.map +1 -0
  185. package/dist/router/policy.js +116 -0
  186. package/dist/router/policy.js.map +1 -0
  187. package/dist/router/route-context.js +79 -0
  188. package/dist/router/route-context.js.map +1 -0
  189. package/dist/router/route.d.ts +101 -33
  190. package/dist/router/route.d.ts.map +1 -1
  191. package/dist/router/route.js +599 -1
  192. package/dist/router/route.js.map +1 -0
  193. package/dist/runtime/child-scope.d.ts +21 -0
  194. package/dist/runtime/child-scope.d.ts.map +1 -0
  195. package/dist/runtime/child-scope.js +77 -0
  196. package/dist/runtime/child-scope.js.map +1 -0
  197. package/dist/runtime/component.d.ts +67 -53
  198. package/dist/runtime/component.d.ts.map +1 -1
  199. package/dist/runtime/component.js +462 -1
  200. package/dist/runtime/component.js.map +1 -0
  201. package/dist/runtime/context.d.ts +28 -42
  202. package/dist/runtime/context.d.ts.map +1 -1
  203. package/dist/runtime/context.js +205 -1
  204. package/dist/runtime/context.js.map +1 -0
  205. package/dist/runtime/control.d.ts +43 -0
  206. package/dist/runtime/control.d.ts.map +1 -0
  207. package/dist/runtime/control.js +125 -0
  208. package/dist/runtime/control.js.map +1 -0
  209. package/dist/runtime/derive.d.ts +15 -6
  210. package/dist/runtime/derive.d.ts.map +1 -1
  211. package/dist/runtime/derive.js +134 -1
  212. package/dist/runtime/derive.js.map +1 -0
  213. package/dist/runtime/dev-namespace.js +57 -1
  214. package/dist/runtime/dev-namespace.js.map +1 -0
  215. package/dist/runtime/effect.d.ts +32 -0
  216. package/dist/runtime/effect.d.ts.map +1 -0
  217. package/dist/runtime/effect.js +146 -0
  218. package/dist/runtime/effect.js.map +1 -0
  219. package/dist/runtime/events.js +162 -1
  220. package/dist/runtime/events.js.map +1 -0
  221. package/dist/runtime/execution-model.js +15 -1
  222. package/dist/runtime/execution-model.js.map +1 -0
  223. package/dist/runtime/fastlane.js +204 -1
  224. package/dist/runtime/fastlane.js.map +1 -0
  225. package/dist/runtime/for-bench.d.ts +41 -0
  226. package/dist/runtime/for-bench.d.ts.map +1 -0
  227. package/dist/runtime/for-bench.js +173 -0
  228. package/dist/runtime/for-bench.js.map +1 -0
  229. package/dist/runtime/for.d.ts +62 -49
  230. package/dist/runtime/for.d.ts.map +1 -1
  231. package/dist/runtime/for.js +668 -1
  232. package/dist/runtime/for.js.map +1 -0
  233. package/dist/runtime/operations.d.ts +18 -15
  234. package/dist/runtime/operations.d.ts.map +1 -1
  235. package/dist/runtime/operations.js +209 -1
  236. package/dist/runtime/operations.js.map +1 -0
  237. package/dist/runtime/perf-metrics.js +64 -0
  238. package/dist/runtime/perf-metrics.js.map +1 -0
  239. package/dist/runtime/readable.d.ts +27 -0
  240. package/dist/runtime/readable.d.ts.map +1 -0
  241. package/dist/runtime/readable.js +118 -0
  242. package/dist/runtime/readable.js.map +1 -0
  243. package/dist/runtime/resource-cell.js +102 -1
  244. package/dist/runtime/resource-cell.js.map +1 -0
  245. package/dist/runtime/scheduler.d.ts +51 -35
  246. package/dist/runtime/scheduler.d.ts.map +1 -1
  247. package/dist/runtime/scheduler.js +328 -1
  248. package/dist/runtime/scheduler.js.map +1 -0
  249. package/dist/runtime/selector.d.ts +11 -0
  250. package/dist/runtime/selector.d.ts.map +1 -0
  251. package/dist/runtime/selector.js +188 -0
  252. package/dist/runtime/selector.js.map +1 -0
  253. package/dist/runtime/ssr-bridge.js +24 -1
  254. package/dist/runtime/ssr-bridge.js.map +1 -0
  255. package/dist/runtime/state.d.ts +11 -21
  256. package/dist/runtime/state.d.ts.map +1 -1
  257. package/dist/runtime/state.js +99 -1
  258. package/dist/runtime/state.js.map +1 -0
  259. package/dist/ssg/batch-render.d.ts +16 -0
  260. package/dist/ssg/batch-render.d.ts.map +1 -0
  261. package/dist/ssg/batch-render.js +84 -0
  262. package/dist/ssg/batch-render.js.map +1 -0
  263. package/dist/ssg/create-static-gen.d.ts +50 -0
  264. package/dist/ssg/create-static-gen.d.ts.map +1 -0
  265. package/dist/ssg/create-static-gen.js +282 -0
  266. package/dist/ssg/create-static-gen.js.map +1 -0
  267. package/dist/ssg/generate-metadata.d.ts +24 -0
  268. package/dist/ssg/generate-metadata.d.ts.map +1 -0
  269. package/dist/ssg/generate-metadata.js +94 -0
  270. package/dist/ssg/generate-metadata.js.map +1 -0
  271. package/dist/ssg/incremental-manifest.js +56 -0
  272. package/dist/ssg/incremental-manifest.js.map +1 -0
  273. package/dist/ssg/index.d.ts +8 -0
  274. package/dist/ssg/index.js +7 -0
  275. package/dist/ssg/resolve-ssg-data.d.ts +23 -0
  276. package/dist/ssg/resolve-ssg-data.d.ts.map +1 -0
  277. package/dist/ssg/resolve-ssg-data.js +46 -0
  278. package/dist/ssg/resolve-ssg-data.js.map +1 -0
  279. package/dist/ssg/route-utils.d.ts +16 -0
  280. package/dist/ssg/route-utils.d.ts.map +1 -0
  281. package/dist/ssg/route-utils.js +24 -0
  282. package/dist/ssg/route-utils.js.map +1 -0
  283. package/dist/ssg/types.d.ts +177 -0
  284. package/dist/ssg/types.d.ts.map +1 -0
  285. package/dist/ssg/write-static-files.d.ts +15 -0
  286. package/dist/ssg/write-static-files.d.ts.map +1 -0
  287. package/dist/ssg/write-static-files.js +73 -0
  288. package/dist/ssg/write-static-files.js.map +1 -0
  289. package/dist/ssr/attrs.js +93 -1
  290. package/dist/ssr/attrs.js.map +1 -0
  291. package/dist/ssr/context.d.ts +31 -32
  292. package/dist/ssr/context.d.ts.map +1 -1
  293. package/dist/ssr/context.js +63 -1
  294. package/dist/ssr/context.js.map +1 -0
  295. package/dist/ssr/errors.d.ts +6 -4
  296. package/dist/ssr/errors.d.ts.map +1 -1
  297. package/dist/ssr/errors.js +4 -1
  298. package/dist/ssr/errors.js.map +1 -0
  299. package/dist/ssr/escape.js +153 -1
  300. package/dist/ssr/escape.js.map +1 -0
  301. package/dist/ssr/index.d.ts +75 -46
  302. package/dist/ssr/index.d.ts.map +1 -1
  303. package/dist/ssr/index.js +543 -1
  304. package/dist/ssr/index.js.map +1 -0
  305. package/dist/ssr/render-keys.d.ts +27 -29
  306. package/dist/ssr/render-keys.d.ts.map +1 -1
  307. package/dist/ssr/render-keys.js +39 -1
  308. package/dist/ssr/render-keys.js.map +1 -0
  309. package/dist/ssr/sink.js +86 -1
  310. package/dist/ssr/sink.js.map +1 -0
  311. package/dist/ssr/stream-render.js +76 -1
  312. package/dist/ssr/stream-render.js.map +1 -0
  313. package/dist/ssr/types.d.ts +14 -13
  314. package/dist/ssr/types.d.ts.map +1 -1
  315. package/package.json +53 -48
  316. package/dist/_virtual/___vite-browser-external.js +0 -1
  317. package/dist/_virtual/__vite-browser-external.js +0 -1
  318. package/dist/_virtual/_commonjsHelpers.js +0 -1
  319. package/dist/_virtual/main.js +0 -1
  320. package/dist/_virtual/preload-helper.js +0 -1
  321. package/dist/bench/benchmark-entry.d.ts +0 -14
  322. package/dist/bench/benchmark-entry.d.ts.map +0 -1
  323. package/dist/common/errors.d.ts +0 -53
  324. package/dist/common/errors.d.ts.map +0 -1
  325. package/dist/common/index.d.ts +0 -14
  326. package/dist/common/index.d.ts.map +0 -1
  327. package/dist/dev/invariant.d.ts +0 -83
  328. package/dist/dev/invariant.d.ts.map +0 -1
  329. package/dist/dev/logger.d.ts +0 -13
  330. package/dist/dev/logger.d.ts.map +0 -1
  331. package/dist/dev/vite-plugin-askr.d.ts +0 -18
  332. package/dist/dev/vite-plugin-askr.d.ts.map +0 -1
  333. package/dist/dev/warnings.d.ts +0 -5
  334. package/dist/dev/warnings.d.ts.map +0 -1
  335. package/dist/for/for.d.ts +0 -16
  336. package/dist/for/for.d.ts.map +0 -1
  337. package/dist/for/for.js +0 -1
  338. package/dist/for/index.d.ts +0 -2
  339. package/dist/for/index.d.ts.map +0 -1
  340. package/dist/for/index.js +0 -1
  341. package/dist/foundations/core.d.ts +0 -23
  342. package/dist/foundations/core.d.ts.map +0 -1
  343. package/dist/foundations/core.js +0 -1
  344. package/dist/foundations/index.d.ts.map +0 -1
  345. package/dist/foundations/interactions/dismissable.d.ts +0 -58
  346. package/dist/foundations/interactions/dismissable.d.ts.map +0 -1
  347. package/dist/foundations/interactions/dismissable.js +0 -1
  348. package/dist/foundations/interactions/focusable.d.ts +0 -16
  349. package/dist/foundations/interactions/focusable.d.ts.map +0 -1
  350. package/dist/foundations/interactions/focusable.js +0 -1
  351. package/dist/foundations/interactions/hoverable.d.ts +0 -19
  352. package/dist/foundations/interactions/hoverable.d.ts.map +0 -1
  353. package/dist/foundations/interactions/hoverable.js +0 -1
  354. package/dist/foundations/interactions/index.d.ts +0 -5
  355. package/dist/foundations/interactions/index.d.ts.map +0 -1
  356. package/dist/foundations/interactions/interaction-policy.d.ts +0 -96
  357. package/dist/foundations/interactions/interaction-policy.d.ts.map +0 -1
  358. package/dist/foundations/interactions/pressable.d.ts +0 -54
  359. package/dist/foundations/interactions/pressable.d.ts.map +0 -1
  360. package/dist/foundations/interactions/roving-focus.d.ts +0 -117
  361. package/dist/foundations/interactions/roving-focus.d.ts.map +0 -1
  362. package/dist/foundations/interactions/roving-focus.js +0 -1
  363. package/dist/foundations/state/controllable.d.ts +0 -53
  364. package/dist/foundations/state/controllable.d.ts.map +0 -1
  365. package/dist/foundations/state/controllable.js +0 -1
  366. package/dist/foundations/state/index.d.ts +0 -2
  367. package/dist/foundations/state/index.d.ts.map +0 -1
  368. package/dist/foundations/structures/index.d.ts +0 -5
  369. package/dist/foundations/structures/index.d.ts.map +0 -1
  370. package/dist/foundations/structures.d.ts.map +0 -1
  371. package/dist/foundations/utilities/aria.d.ts +0 -13
  372. package/dist/foundations/utilities/aria.d.ts.map +0 -1
  373. package/dist/foundations/utilities/compose-handlers.d.ts +0 -34
  374. package/dist/foundations/utilities/compose-handlers.d.ts.map +0 -1
  375. package/dist/foundations/utilities/event-types.d.ts +0 -17
  376. package/dist/foundations/utilities/event-types.d.ts.map +0 -1
  377. package/dist/foundations/utilities/index.d.ts +0 -7
  378. package/dist/foundations/utilities/index.d.ts.map +0 -1
  379. package/dist/foundations/utilities/merge-props.d.ts +0 -2
  380. package/dist/foundations/utilities/merge-props.d.ts.map +0 -1
  381. package/dist/foundations/utilities/use-id.d.ts +0 -29
  382. package/dist/foundations/utilities/use-id.d.ts.map +0 -1
  383. package/dist/foundations/utilities/use-id.js +0 -1
  384. package/dist/fx/index.d.ts.map +0 -1
  385. package/dist/fx/noop.d.ts +0 -12
  386. package/dist/fx/noop.d.ts.map +0 -1
  387. package/dist/index.d.ts.map +0 -1
  388. package/dist/jsx/index.d.ts.map +0 -1
  389. package/dist/jsx/jsx-dev-runtime.d.ts +0 -4
  390. package/dist/jsx/jsx-dev-runtime.d.ts.map +0 -1
  391. package/dist/jsx/jsx-runtime.d.ts +0 -10
  392. package/dist/jsx/jsx-runtime.d.ts.map +0 -1
  393. package/dist/node_modules/esbuild/lib/main.js +0 -65
  394. package/dist/renderer/cleanup.d.ts +0 -25
  395. package/dist/renderer/cleanup.d.ts.map +0 -1
  396. package/dist/renderer/dom.d.ts +0 -62
  397. package/dist/renderer/dom.d.ts.map +0 -1
  398. package/dist/renderer/evaluate.d.ts +0 -4
  399. package/dist/renderer/evaluate.d.ts.map +0 -1
  400. package/dist/renderer/fastpath.d.ts +0 -7
  401. package/dist/renderer/fastpath.d.ts.map +0 -1
  402. package/dist/renderer/index.d.ts +0 -6
  403. package/dist/renderer/index.d.ts.map +0 -1
  404. package/dist/renderer/keyed.d.ts +0 -23
  405. package/dist/renderer/keyed.d.ts.map +0 -1
  406. package/dist/renderer/reconcile.d.ts +0 -88
  407. package/dist/renderer/reconcile.d.ts.map +0 -1
  408. package/dist/renderer/types.d.ts +0 -3
  409. package/dist/renderer/types.d.ts.map +0 -1
  410. package/dist/renderer/utils.d.ts +0 -63
  411. package/dist/renderer/utils.d.ts.map +0 -1
  412. package/dist/resources/index.d.ts.map +0 -1
  413. package/dist/router/index.d.ts.map +0 -1
  414. package/dist/router/match.d.ts +0 -22
  415. package/dist/router/match.d.ts.map +0 -1
  416. package/dist/runtime/dev-namespace.d.ts +0 -31
  417. package/dist/runtime/dev-namespace.d.ts.map +0 -1
  418. package/dist/runtime/events.d.ts +0 -52
  419. package/dist/runtime/events.d.ts.map +0 -1
  420. package/dist/runtime/execution-model.d.ts +0 -4
  421. package/dist/runtime/execution-model.d.ts.map +0 -1
  422. package/dist/runtime/fastlane.d.ts +0 -27
  423. package/dist/runtime/fastlane.d.ts.map +0 -1
  424. package/dist/runtime/hydration.d.ts +0 -25
  425. package/dist/runtime/hydration.d.ts.map +0 -1
  426. package/dist/runtime/resource-cell.d.ts +0 -35
  427. package/dist/runtime/resource-cell.d.ts.map +0 -1
  428. package/dist/runtime/snapshot.d.ts +0 -25
  429. package/dist/runtime/snapshot.d.ts.map +0 -1
  430. package/dist/runtime/ssr-bridge.d.ts +0 -10
  431. package/dist/runtime/ssr-bridge.d.ts.map +0 -1
  432. package/dist/ssr/attrs.d.ts +0 -26
  433. package/dist/ssr/attrs.d.ts.map +0 -1
  434. package/dist/ssr/create-ssr.d.ts +0 -19
  435. package/dist/ssr/create-ssr.d.ts.map +0 -1
  436. package/dist/ssr/escape.d.ts +0 -38
  437. package/dist/ssr/escape.d.ts.map +0 -1
  438. package/dist/ssr/sink.d.ts +0 -23
  439. package/dist/ssr/sink.d.ts.map +0 -1
  440. package/dist/ssr/stream-render.d.ts +0 -7
  441. package/dist/ssr/stream-render.d.ts.map +0 -1
  442. package/dist/vite/index.js +0 -3
@@ -0,0 +1,73 @@
1
+ import "./route-utils.js";
2
+ import * as fs from "node:fs/promises";
3
+ import * as fsSync from "node:fs";
4
+ import * as pathModule from "node:path";
5
+ //#region src/ssg/write-static-files.ts
6
+ /**
7
+ * File I/O for Static Site Generation
8
+ *
9
+ * Uses Node.js fs/path modules to write rendered HTML files to disk.
10
+ * This module is Node-only and not intended for browser builds.
11
+ */
12
+ /**
13
+ * Write rendered routes to disk
14
+ * Creates outputDir/{route-path}/index.html structure
15
+ */
16
+ async function writeStaticFiles(results, outputDir, options = {}) {
17
+ await fs.mkdir(outputDir, { recursive: true });
18
+ for (const result of results) {
19
+ if (result.status !== "removed") continue;
20
+ const fullPath = pathModule.join(outputDir, result.filePath);
21
+ if (fsSync.existsSync(fullPath)) {
22
+ await fs.rm(fullPath, { force: true });
23
+ await pruneEmptyDirs(pathModule.dirname(fullPath), outputDir);
24
+ }
25
+ }
26
+ const pendingWrites = [];
27
+ for (let index = 0; index < results.length; index += 1) {
28
+ const result = results[index];
29
+ if (result.status === "error") {
30
+ console.warn(`Skipping failed route: ${result.path} - ${result.error}`);
31
+ continue;
32
+ }
33
+ if (result.status === "success" && result.written) pendingWrites.push(result);
34
+ }
35
+ const directories = [];
36
+ const seenDirectories = /* @__PURE__ */ new Set();
37
+ for (const result of pendingWrites) {
38
+ const dir = pathModule.dirname(pathModule.join(outputDir, result.filePath));
39
+ if (!seenDirectories.has(dir)) {
40
+ seenDirectories.add(dir);
41
+ directories.push(dir);
42
+ }
43
+ }
44
+ for (const dir of directories) await fs.mkdir(dir, { recursive: true });
45
+ const concurrency = Math.max(1, Math.min(options.concurrency ?? 8, pendingWrites.length || 1));
46
+ let nextIndex = 0;
47
+ const worker = async () => {
48
+ while (true) {
49
+ const current = nextIndex;
50
+ nextIndex += 1;
51
+ if (current >= pendingWrites.length) return;
52
+ const result = pendingWrites[current];
53
+ const fullPath = pathModule.join(outputDir, result.filePath);
54
+ await fs.writeFile(fullPath, result.html, "utf8");
55
+ }
56
+ };
57
+ await Promise.all(Array.from({ length: concurrency }, () => worker()));
58
+ }
59
+ async function pruneEmptyDirs(startDir, rootDir) {
60
+ let current = startDir;
61
+ const normalizedRoot = pathModule.resolve(rootDir);
62
+ while (current.startsWith(normalizedRoot)) {
63
+ if (!fsSync.existsSync(current)) break;
64
+ if ((await fs.readdir(current)).length > 0) break;
65
+ await fs.rmdir(current);
66
+ if (pathModule.resolve(current) === normalizedRoot) break;
67
+ current = pathModule.dirname(current);
68
+ }
69
+ }
70
+ //#endregion
71
+ export { writeStaticFiles };
72
+
73
+ //# sourceMappingURL=write-static-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-static-files.js","names":[],"sources":["../../src/ssg/write-static-files.ts"],"sourcesContent":["/**\n * File I/O for Static Site Generation\n *\n * Uses Node.js fs/path modules to write rendered HTML files to disk.\n * This module is Node-only and not intended for browser builds.\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as fsSync from 'node:fs';\nimport * as pathModule from 'node:path';\nimport type { RouteRenderResult } from './types';\n\ninterface WriteStaticFilesOptions {\n concurrency?: number;\n}\n\n/**\n * Write rendered routes to disk\n * Creates outputDir/{route-path}/index.html structure\n */\nexport async function writeStaticFiles(\n results: RouteRenderResult[],\n outputDir: string,\n options: WriteStaticFilesOptions = {}\n): Promise<void> {\n await fs.mkdir(outputDir, { recursive: true });\n\n for (const result of results) {\n if (result.status !== 'removed') {\n continue;\n }\n\n const fullPath = pathModule.join(outputDir, result.filePath);\n if (fsSync.existsSync(fullPath)) {\n await fs.rm(fullPath, { force: true });\n await pruneEmptyDirs(pathModule.dirname(fullPath), outputDir);\n }\n }\n\n const pendingWrites: RouteRenderResult[] = [];\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index];\n if (result.status === 'error') {\n console.warn(`Skipping failed route: ${result.path} - ${result.error}`);\n continue;\n }\n if (result.status === 'success' && result.written) {\n pendingWrites.push(result);\n }\n }\n\n const directories: string[] = [];\n const seenDirectories = new Set<string>();\n for (const result of pendingWrites) {\n const dir = pathModule.dirname(pathModule.join(outputDir, result.filePath));\n if (!seenDirectories.has(dir)) {\n seenDirectories.add(dir);\n directories.push(dir);\n }\n }\n\n for (const dir of directories) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n const concurrency = Math.max(\n 1,\n Math.min(options.concurrency ?? 8, pendingWrites.length || 1)\n );\n let nextIndex = 0;\n\n const worker = async () => {\n while (true) {\n const current = nextIndex;\n nextIndex += 1;\n if (current >= pendingWrites.length) {\n return;\n }\n\n const result = pendingWrites[current];\n const fullPath = pathModule.join(outputDir, result.filePath);\n await fs.writeFile(fullPath, result.html, 'utf8');\n }\n };\n\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\n}\n\n/**\n * Get the output file path for a route\n * E.g., \"/blog/post\" -> \"blog/post\" or \"/\" -> \"\"\n */\nexport { getOutputFilePath } from './route-utils';\n\nasync function pruneEmptyDirs(\n startDir: string,\n rootDir: string\n): Promise<void> {\n let current = startDir;\n const normalizedRoot = pathModule.resolve(rootDir);\n\n while (current.startsWith(normalizedRoot)) {\n if (!fsSync.existsSync(current)) {\n break;\n }\n\n if ((await fs.readdir(current)).length > 0) {\n break;\n }\n\n await fs.rmdir(current);\n if (pathModule.resolve(current) === normalizedRoot) {\n break;\n }\n current = pathModule.dirname(current);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,iBACpB,SACA,WACA,UAAmC,EAAE,EACtB;AACf,OAAM,GAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;AAE9C,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,OAAO,WAAW,UACpB;EAGF,MAAM,WAAW,WAAW,KAAK,WAA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,UAAU;CACd,MAAM,iBAAiB,WAAW,QAAQ,QAAQ;AAElD,QAAO,QAAQ,WAAW,eAAe,EAAE;AACzC,MAAI,CAAC,OAAO,WAAW,QAAQ,CAC7B;AAGF,OAAK,MAAM,GAAG,QAAQ,QAAQ,EAAE,SAAS,EACvC;AAGF,QAAM,GAAG,MAAM,QAAQ;AACvB,MAAI,WAAW,QAAQ,QAAQ,KAAK,eAClC;AAEF,YAAU,WAAW,QAAQ,QAAQ"}
package/dist/ssr/attrs.js CHANGED
@@ -1 +1,93 @@
1
- import{styleObjToCss as d,needsEscapeAttr as a,escapeAttr as l}from"./escape.js";function h(r){return r.length>=3&&r.charCodeAt(0)===111&&r.charCodeAt(1)===110&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90}function y(r,e){if(!r||typeof r!="object")return;const c=r;for(const i in c){const o=c[i];if(i==="children"||i==="key"||i==="ref"||i==="dangerouslySetInnerHTML"||h(i)||i.charCodeAt(0)===95)continue;const s=i==="className"?"class":i;if(s==="style"){const t=typeof o=="string"?o:d(o);if(!t)continue;e.write(' style="'),a(t)?e.write(l(t)):e.write(t),e.write('"');continue}if(o===!0){e.write(" "),e.write(s);continue}if(o===!1||o===null||o===void 0)continue;const n=String(o);e.write(" "),e.write(s),e.write('="'),a(n)?e.write(l(n)):e.write(n),e.write('"')}}function g(r,e){if(!r||typeof r!="object")return e?.returnDangerousHtml?{attrs:""}:"";const c=[];let i;const o=r;for(const n in o){const t=o[n];if(n==="children"||n==="key"||n==="ref")continue;if(n==="dangerouslySetInnerHTML"){t&&typeof t=="object"&&"__html"in t&&(i=String(t.__html));continue}if(h(n)||n.charCodeAt(0)===95)continue;const f=n==="class"||n==="className"?"class":n;if(f==="style"){const u=typeof t=="string"?t:d(t);if(u===null||u==="")continue;c.push(` style="${l(u)}"`);continue}if(t===!0)c.push(` ${f}`);else{if(t===!1||t===null||t===void 0)continue;{const u=String(t);c.push(` ${f}="${l(u)}"`)}}}const s=c.join("");return e?.returnDangerousHtml?{attrs:s,dangerousHtml:i}:s}export{g as renderAttrs,y as renderAttrsDirect};
1
+ import { escapeAttr, needsEscapeAttr, styleObjToCss } from "./escape.js";
2
+ //#region src/ssr/attrs.ts
3
+ const ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;
4
+ const escapedAttrValueCache = /* @__PURE__ */ new Map();
5
+ function isEventHandler(key) {
6
+ return key.length >= 3 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) >= 65 && key.charCodeAt(2) <= 90;
7
+ }
8
+ function getEscapedAttrValue(value) {
9
+ if (value.length > 64) return escapeAttr(value);
10
+ const cached = escapedAttrValueCache.get(value);
11
+ if (cached !== void 0) return cached;
12
+ const escaped = escapeAttr(value);
13
+ if (escaped === value) return value;
14
+ if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) escapedAttrValueCache.clear();
15
+ escapedAttrValueCache.set(value, escaped);
16
+ return escaped;
17
+ }
18
+ /**
19
+ * Render attributes directly to a sink without intermediate string allocations.
20
+ * This is the hot path for streaming SSR.
21
+ */
22
+ function renderAttrsDirect(props, sink) {
23
+ if (!props || typeof props !== "object") return;
24
+ const propsObj = props;
25
+ for (const key in propsObj) {
26
+ const value = propsObj[key];
27
+ if (key === "children" || key === "key" || key === "ref" || key === "dangerouslySetInnerHTML") continue;
28
+ if (isEventHandler(key)) continue;
29
+ if (key.charCodeAt(0) === 95) continue;
30
+ const attrName = key === "className" ? "class" : key;
31
+ if (attrName === "style") {
32
+ const css = typeof value === "string" ? value : styleObjToCss(value);
33
+ if (!css) continue;
34
+ sink.write(" style=\"");
35
+ if (needsEscapeAttr(css)) sink.write(getEscapedAttrValue(css));
36
+ else sink.write(css);
37
+ sink.write("\"");
38
+ continue;
39
+ }
40
+ if (value === true) {
41
+ sink.write(" ");
42
+ sink.write(attrName);
43
+ continue;
44
+ }
45
+ if (value === false || value === null || value === void 0) continue;
46
+ const strValue = String(value);
47
+ sink.write(" ");
48
+ sink.write(attrName);
49
+ sink.write("=\"");
50
+ sink.write(getEscapedAttrValue(strValue));
51
+ sink.write("\"");
52
+ }
53
+ }
54
+ function renderAttrs(props, opts) {
55
+ if (!props || typeof props !== "object") return opts?.returnDangerousHtml ? { attrs: "" } : "";
56
+ const attrParts = [];
57
+ let dangerousHtml;
58
+ const propsObj = props;
59
+ for (const key in propsObj) {
60
+ const value = propsObj[key];
61
+ if (key === "children") continue;
62
+ if (key === "key" || key === "ref") continue;
63
+ if (key === "dangerouslySetInnerHTML") {
64
+ if (value && typeof value === "object" && "__html" in value) dangerousHtml = String(value.__html);
65
+ continue;
66
+ }
67
+ if (isEventHandler(key)) continue;
68
+ if (key.charCodeAt(0) === 95) continue;
69
+ const attrName = key === "class" || key === "className" ? "class" : key;
70
+ if (attrName === "style") {
71
+ const css = typeof value === "string" ? value : styleObjToCss(value);
72
+ if (css === null || css === "") continue;
73
+ attrParts.push(` style="${getEscapedAttrValue(css)}"`);
74
+ continue;
75
+ }
76
+ if (value === true) attrParts.push(` ${attrName}`);
77
+ else if (value === false || value === null || value === void 0) continue;
78
+ else {
79
+ const strValue = String(value);
80
+ attrParts.push(` ${attrName}="${getEscapedAttrValue(strValue)}"`);
81
+ }
82
+ }
83
+ const result = attrParts.join("");
84
+ if (opts?.returnDangerousHtml) return {
85
+ attrs: result,
86
+ dangerousHtml
87
+ };
88
+ return result;
89
+ }
90
+ //#endregion
91
+ export { renderAttrs, renderAttrsDirect };
92
+
93
+ //# sourceMappingURL=attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.js","names":[],"sources":["../../src/ssr/attrs.ts"],"sourcesContent":["/**\n * HTML attribute rendering for SSR\n */\n\nimport type { Props } from '../common/props';\nimport type { RenderSink } from './sink';\nimport { escapeAttr, needsEscapeAttr, styleObjToCss } from './escape';\n\n/** Result of renderAttrs including any raw HTML from dangerouslySetInnerHTML */\nexport type AttrsResult = {\n attrs: string;\n dangerousHtml?: string;\n};\n\nconst ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;\nconst escapedAttrValueCache = new Map<string, string>();\n\n// Fast check for event handler pattern (on + uppercase letter)\nfunction isEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 && // 'o'\n key.charCodeAt(1) === 110 && // 'n'\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 // 'A'-'Z'\n );\n}\n\nfunction getEscapedAttrValue(value: string): string {\n if (value.length > 64) {\n return escapeAttr(value);\n }\n\n const cached = escapedAttrValueCache.get(value);\n if (cached !== undefined) {\n return cached;\n }\n\n const escaped = escapeAttr(value);\n // Skip caching strings that required no escaping — same reference returned,\n // no point occupying cache slots with identity entries.\n if (escaped === value) return value;\n if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) {\n escapedAttrValueCache.clear();\n }\n escapedAttrValueCache.set(value, escaped);\n return escaped;\n}\n\n/**\n * Render attributes directly to a sink without intermediate string allocations.\n * This is the hot path for streaming SSR.\n */\nexport function renderAttrsDirect(\n props: Props | undefined,\n sink: Pick<RenderSink, 'write'>\n): void {\n if (!props || typeof props !== 'object') return;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip special props\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n )\n continue;\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute\n const attrName = key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n sink.write(' style=\"');\n // Escape inline - most style values don't need escaping\n if (needsEscapeAttr(css)) {\n sink.write(getEscapedAttrValue(css));\n } else {\n sink.write(css);\n }\n sink.write('\"');\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n sink.write(' ');\n sink.write(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) continue;\n\n // Regular attributes\n const strValue = String(value);\n sink.write(' ');\n sink.write(attrName);\n sink.write('=\"');\n // escapeAttr returns the original string when nothing needs escaping,\n // so no separate needsEscapeAttr pre-scan is required.\n sink.write(getEscapedAttrValue(strValue));\n sink.write('\"');\n }\n}\n\n/**\n * Render attributes to HTML string, excluding event handlers\n * Optimized for minimal allocations using push-based approach\n *\n * Returns both the attribute string and any dangerouslySetInnerHTML content.\n */\nexport function renderAttrs(props?: Props): string;\nexport function renderAttrs(\n props: Props | undefined,\n opts: { returnDangerousHtml: true }\n): AttrsResult;\nexport function renderAttrs(\n props?: Props,\n opts?: { returnDangerousHtml?: boolean }\n): string | AttrsResult {\n if (!props || typeof props !== 'object') {\n return opts?.returnDangerousHtml ? { attrs: '' } : '';\n }\n\n const attrParts: string[] = [];\n let dangerousHtml: string | undefined;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip children in attrs\n if (key === 'children') continue;\n\n // Skip internal identity refs (framework-only)\n if (key === 'key' || key === 'ref') continue;\n\n // Handle dangerouslySetInnerHTML\n if (key === 'dangerouslySetInnerHTML') {\n if (value && typeof value === 'object' && '__html' in (value as object)) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize class attribute (`class` preferred, accept `className` for compatibility)\n const attrName = key === 'class' || key === 'className' ? 'class' : key;\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (css === null || css === '') continue;\n attrParts.push(` style=\"${getEscapedAttrValue(css)}\"`);\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n attrParts.push(` ${attrName}`);\n } else if (value === false || value === null || value === undefined) {\n continue;\n } else {\n const strValue = String(value);\n attrParts.push(` ${attrName}=\"${getEscapedAttrValue(strValue)}\"`);\n }\n }\n\n const result = attrParts.join('');\n\n if (opts?.returnDangerousHtml) {\n return { attrs: result, dangerousHtml };\n }\n return result;\n}\n"],"mappings":";;AAcA,MAAM,iCAAiC;AACvC,MAAM,wCAAwB,IAAI,KAAqB;AAGvD,SAAS,eAAe,KAAsB;AAC5C,QACE,IAAI,UAAU,KACd,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,KAAK,OACtB,IAAI,WAAW,EAAE,IAAI,MACrB,IAAI,WAAW,EAAE,IAAI;;AAIzB,SAAS,oBAAoB,OAAuB;AAClD,KAAI,MAAM,SAAS,GACjB,QAAO,WAAW,MAAM;CAG1B,MAAM,SAAS,sBAAsB,IAAI,MAAM;AAC/C,KAAI,WAAW,OACb,QAAO;CAGT,MAAM,UAAU,WAAW,MAAM;AAGjC,KAAI,YAAY,MAAO,QAAO;AAC9B,KAAI,sBAAsB,QAAQ,+BAChC,uBAAsB,OAAO;AAE/B,uBAAsB,IAAI,OAAO,QAAQ;AACzC,QAAO;;;;;;AAOT,SAAgB,kBACd,OACA,MACM;AACN,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;CAEzC,MAAM,WAAW;AACjB,MAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,QAAQ,SAAS;AAGvB,MACE,QAAQ,cACR,QAAQ,SACR,QAAQ,SACR,QAAQ,0BAER;AAGF,MAAI,eAAe,IAAI,CAAE;AAGzB,MAAI,IAAI,WAAW,EAAE,KAAK,GAAI;EAG9B,MAAM,WAAW,QAAQ,cAAc,UAAU;AAGjD,MAAI,aAAa,SAAS;GACxB,MAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,cAAc,MAAM;AACpE,OAAI,CAAC,IAAK;AACV,QAAK,MAAM,YAAW;AAEtB,OAAI,gBAAgB,IAAI,CACtB,MAAK,MAAM,oBAAoB,IAAI,CAAC;OAEpC,MAAK,MAAM,IAAI;AAEjB,QAAK,MAAM,KAAI;AACf;;AAIF,MA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;AAEjC,KAAI,MAAM,oBACR,QAAO;EAAE,OAAO;EAAQ;EAAe;AAEzC,QAAO"}
@@ -1,47 +1,46 @@
1
- /**
2
- * SSR Context Management
3
- *
4
- * Provides concurrency-safe context for server-side rendering.
5
- * In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.
6
- * Falls back to stack-based approach in non-Node environments.
7
- */
8
- import { SSRDataMissingError } from './errors';
9
- export type { SSRData } from '../common/ssr';
10
- import type { SSRData } from '../common/ssr';
11
- export interface RenderContext {
12
- url: string;
13
- seed: number;
14
- data?: SSRData;
15
- params?: Record<string, string>;
16
- signal?: AbortSignal;
17
- keyCounter: number;
18
- renderData: Record<string, unknown> | null;
1
+ import { Route, RouteAuthOptions } from "../common/router.js";
2
+ import { SSRData } from "../common/ssr.js";
3
+ import { SSRDataMissingError } from "../common/ssr-errors.js";
4
+ //#region src/ssr/context.d.ts
5
+ interface RenderContext {
6
+ url: string;
7
+ seed: number;
8
+ data?: SSRData;
9
+ params?: Record<string, string>;
10
+ routes?: readonly Route[];
11
+ routeAuth?: RouteAuthOptions;
12
+ signal?: AbortSignal;
13
+ keyCounter: number;
14
+ renderData: Record<string, unknown> | null;
19
15
  }
20
- export type SSRContext = RenderContext;
21
- export declare function createRenderContext(seed?: number, opts?: {
22
- url?: string;
23
- data?: SSRData;
24
- params?: Record<string, string>;
25
- signal?: AbortSignal;
16
+ type SSRContext = RenderContext;
17
+ declare function createRenderContext(seed?: number, opts?: {
18
+ url?: string;
19
+ data?: SSRData;
20
+ params?: Record<string, string>;
21
+ routes?: readonly Route[];
22
+ routeAuth?: RouteAuthOptions;
23
+ signal?: AbortSignal;
26
24
  }): RenderContext;
27
25
  /**
28
26
  * Run a function with the given render context.
29
27
  * Concurrency-safe in Node.js via AsyncLocalStorage.
30
28
  */
31
- export declare function withRenderContext<T>(ctx: RenderContext, fn: () => T): T;
29
+ declare function withRenderContext<T>(ctx: RenderContext, fn: () => T): T;
32
30
  /**
33
31
  * Get the current render context.
34
32
  * Returns null if not inside a render.
35
33
  */
36
- export declare function getRenderContext(): RenderContext | null;
37
- export declare const getSSRContext: typeof getRenderContext;
38
- export declare const withSSRContext: typeof withRenderContext;
39
- export declare const getCurrentSSRContext: typeof getRenderContext;
40
- export declare function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T;
34
+ declare function getRenderContext(): RenderContext | null;
35
+ declare const getSSRContext: typeof getRenderContext;
36
+ declare const withSSRContext: typeof withRenderContext;
37
+ declare const getCurrentSSRContext: typeof getRenderContext;
38
+ declare function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T;
41
39
  /**
42
40
  * Centralized SSR enforcement helper — throws a consistent error when async
43
41
  * data is encountered during synchronous SSR.
44
42
  */
45
- export declare function throwSSRDataMissing(): never;
46
- export { SSRDataMissingError };
43
+ declare function throwSSRDataMissing(): never;
44
+ //#endregion
45
+ export { RenderContext };
47
46
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ssr/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC5C;AAGD,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;AA0BvC,wBAAgB,mBAAmB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AsDgB,iBAAA,GAAA,CAAqB,GAAA,EAAK,aAAA,EAAe,EAAA,QAAU,CAAA,GAAI,CAAA;;;;AA5BvE;iBA8CgB,gBAAA,CAAA,GAAoB,aAAA;AAAA,cAQvB,aAAA,SAAa,gBAAA;AAAA,cACb,cAAA,SAAc,iBAAA;AAAA,cACd,oBAAA,SAAoB,gBAAA;AAAA,iBAEjB,iBAAA,GAAA,CAAqB,GAAA,EAAK,aAAA,EAAe,EAAA,QAAU,CAAA,GAAI,CAAA;;;;;iBASvD,mBAAA,CAAA"}
@@ -1 +1,63 @@
1
- import"./errors.js";import{SSRDataMissingError as c}from"../common/ssr-errors.js";let r=null;try{const t=require("async_hooks");t?.AsyncLocalStorage&&(r=new t.AsyncLocalStorage)}catch{}let e=null;function S(t=12345,n={}){return{url:n.url??"",seed:t,data:n.data,params:n.params,signal:n.signal,keyCounter:0,renderData:null}}function o(t,n){if(r)return r.run(t,n);const u=e;e=t;try{return n()}finally{e=u}}function a(){return r?r.getStore()??null:e}const s=a,g=o,f=a;function C(t,n){return o(t,n)}function R(){throw new c}export{c as SSRDataMissingError,S as createRenderContext,f as getCurrentSSRContext,a as getRenderContext,s as getSSRContext,C as runWithSSRContext,R as throwSSRDataMissing,o as withRenderContext,g as withSSRContext};
1
+ import { __require } from "../_virtual/_rolldown/runtime.js";
2
+ import { SSRDataMissingError } from "../common/ssr-errors.js";
3
+ import "./errors.js";
4
+ //#region src/ssr/context.ts
5
+ /**
6
+ * SSR Context Management
7
+ *
8
+ * Provides concurrency-safe context for server-side rendering.
9
+ * In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.
10
+ * Falls back to stack-based approach in non-Node environments.
11
+ */
12
+ let asyncLocalStorage = null;
13
+ try {
14
+ const asyncHooks = __require("async_hooks");
15
+ if (asyncHooks?.AsyncLocalStorage) asyncLocalStorage = new asyncHooks.AsyncLocalStorage();
16
+ } catch {}
17
+ let fallbackStack = null;
18
+ function createRenderContext(seed = 12345, opts = {}) {
19
+ return {
20
+ url: opts.url ?? "",
21
+ seed,
22
+ data: opts.data,
23
+ params: opts.params,
24
+ routes: opts.routes,
25
+ routeAuth: opts.routeAuth,
26
+ signal: opts.signal,
27
+ keyCounter: 0,
28
+ renderData: null
29
+ };
30
+ }
31
+ /**
32
+ * Run a function with the given render context.
33
+ * Concurrency-safe in Node.js via AsyncLocalStorage.
34
+ */
35
+ function withRenderContext(ctx, fn) {
36
+ if (asyncLocalStorage) return asyncLocalStorage.run(ctx, fn);
37
+ const prev = fallbackStack;
38
+ fallbackStack = ctx;
39
+ try {
40
+ return fn();
41
+ } finally {
42
+ fallbackStack = prev;
43
+ }
44
+ }
45
+ /**
46
+ * Get the current render context.
47
+ * Returns null if not inside a render.
48
+ */
49
+ function getRenderContext() {
50
+ if (asyncLocalStorage) return asyncLocalStorage.getStore() ?? null;
51
+ return fallbackStack;
52
+ }
53
+ /**
54
+ * Centralized SSR enforcement helper — throws a consistent error when async
55
+ * data is encountered during synchronous SSR.
56
+ */
57
+ function throwSSRDataMissing() {
58
+ throw new SSRDataMissingError();
59
+ }
60
+ //#endregion
61
+ export { createRenderContext, getRenderContext, throwSSRDataMissing, withRenderContext };
62
+
63
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * SSR Context Management\n *\n * Provides concurrency-safe context for server-side rendering.\n * In Node.js, uses AsyncLocalStorage for isolation between concurrent requests.\n * Falls back to stack-based approach in non-Node environments.\n */\n\nimport { SSRDataMissingError } from './errors';\n\nexport type { SSRData } from '../common/ssr';\nimport type { SSRData } from '../common/ssr';\nimport type { Route, RouteAuthOptions } from '../common/router';\n\n// Unified per-render context combining SSRContext and RenderContext\nexport interface RenderContext {\n url: string;\n seed: number;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n // Per-render key state (moved from render-keys.ts globals)\n keyCounter: number;\n renderData: Record<string, unknown> | null;\n}\n\n// Legacy alias for compatibility\nexport type SSRContext = RenderContext;\n\n// AsyncLocalStorage for Node.js concurrency safety\ntype AsyncLocalStorageType<T> = {\n getStore(): T | undefined;\n run<R>(store: T, fn: () => R): R;\n};\n\nlet asyncLocalStorage: AsyncLocalStorageType<RenderContext> | null = null;\n\n// Try to load AsyncLocalStorage at module init (Node.js only)\ntry {\n // Dynamic require to avoid bundler issues in browser builds\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const asyncHooks = require('async_hooks');\n if (asyncHooks?.AsyncLocalStorage) {\n asyncLocalStorage =\n new asyncHooks.AsyncLocalStorage() as AsyncLocalStorageType<RenderContext>;\n }\n} catch {\n // Not in Node.js or async_hooks unavailable - use fallback\n}\n\n// Fallback stack for non-Node environments\nlet fallbackStack: RenderContext | null = null;\n\nexport function createRenderContext(\n seed = 12345,\n opts: {\n url?: string;\n data?: SSRData;\n params?: Record<string, string>;\n routes?: readonly Route[];\n routeAuth?: RouteAuthOptions;\n signal?: AbortSignal;\n } = {}\n): RenderContext {\n return {\n url: opts.url ?? '',\n seed,\n data: opts.data,\n params: opts.params,\n routes: opts.routes,\n routeAuth: opts.routeAuth,\n signal: opts.signal,\n keyCounter: 0,\n renderData: null,\n };\n}\n\n/**\n * Run a function with the given render context.\n * Concurrency-safe in Node.js via AsyncLocalStorage.\n */\nexport function withRenderContext<T>(ctx: RenderContext, fn: () => T): T {\n if (asyncLocalStorage) {\n return asyncLocalStorage.run(ctx, fn);\n }\n // Fallback: stack-based (not concurrency-safe)\n const prev = fallbackStack;\n fallbackStack = ctx;\n try {\n return fn();\n } finally {\n fallbackStack = prev;\n }\n}\n\n/**\n * Get the current render context.\n * Returns null if not inside a render.\n */\nexport function getRenderContext(): RenderContext | null {\n if (asyncLocalStorage) {\n return asyncLocalStorage.getStore() ?? null;\n }\n return fallbackStack;\n}\n\n// Legacy API aliases (deprecated, for backwards compatibility)\nexport const getSSRContext = getRenderContext;\nexport const withSSRContext = withRenderContext;\nexport const getCurrentSSRContext = getRenderContext;\n\nexport function runWithSSRContext<T>(ctx: RenderContext, fn: () => T): T {\n // This was a separate path for sync detection; now unified\n return withRenderContext(ctx, fn);\n}\n\n/**\n * Centralized SSR enforcement helper — throws a consistent error when async\n * data is encountered during synchronous SSR.\n */\nexport function throwSSRDataMissing(): never {\n throw new SSRDataMissingError();\n}\n\nexport { SSRDataMissingError };\n"],"mappings":";;;;;;;;;;;AAqCA,IAAI,oBAAiE;AAGrE,IAAI;CAGF,MAAM,aAAA,UAAqB,cAAc;AACzC,KAAI,YAAY,kBACd,qBACE,IAAI,WAAW,mBAAmB;QAEhC;AAKR,IAAI,gBAAsC;AAE1C,SAAgB,oBACd,OAAO,OACP,OAOI,EAAE,EACS;AACf,QAAO;EACL,KAAK,KAAK,OAAO;EACjB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,QAAQ,KAAK;EACb,YAAY;EACZ,YAAY;EACb;;;;;;AAOH,SAAgB,kBAAqB,KAAoB,IAAgB;AACvE,KAAI,kBACF,QAAO,kBAAkB,IAAI,KAAK,GAAG;CAGvC,MAAM,OAAO;AACb,iBAAgB;AAChB,KAAI;AACF,SAAO,IAAI;WACH;AACR,kBAAgB;;;;;;;AAQpB,SAAgB,mBAAyC;AACvD,KAAI,kBACF,QAAO,kBAAkB,UAAU,IAAI;AAEzC,QAAO;;;;;;AAiBT,SAAgB,sBAA6B;AAC3C,OAAM,IAAI,qBAAqB"}
@@ -1,6 +1,8 @@
1
- export { SSRDataMissingError } from '../common/ssr-errors';
2
- export declare class SSRInvariantError extends Error {
3
- readonly code = "SSR_INVARIANT_VIOLATION";
4
- constructor(message: string);
1
+ import { SSRDataMissingError } from "../common/ssr-errors.js";
2
+
3
+ //#region src/ssr/errors.d.ts
4
+ declare class SSRInvariantError extends Error {
5
+ readonly code = "SSR_INVARIANT_VIOLATION";
6
+ constructor(message: string);
5
7
  }
6
8
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/ssr/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,6BAA6B;gBAC9B,OAAO,EAAE,MAAM;CAK5B"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/ssr/errors.ts"],"mappings":";;;cAEa,iBAAA,SAA0B,KAAA;EAAA,SAC5B,IAAA;cACG,OAAA;AAAA"}
@@ -1 +1,4 @@
1
- import{SSRDataMissingError as s}from"../common/ssr-errors.js";class r extends Error{constructor(t){super(t),this.code="SSR_INVARIANT_VIOLATION",this.name="SSRInvariantError",Object.setPrototypeOf(this,r.prototype)}}export{s as SSRDataMissingError,r as SSRInvariantError};
1
+ import "../common/ssr-errors.js";
2
+ //#endregion
3
+
4
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/ssr/errors.ts"],"sourcesContent":["export { SSRDataMissingError } from '../common/ssr-errors';\n\nexport class SSRInvariantError extends Error {\n readonly code = 'SSR_INVARIANT_VIOLATION';\n constructor(message: string) {\n super(message);\n this.name = 'SSRInvariantError';\n Object.setPrototypeOf(this, SSRInvariantError.prototype);\n }\n}\n"],"mappings":""}
@@ -1 +1,153 @@
1
- const A=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=new Map,u=256;const f=/[&"'<>]/g,l=/[{}<>\\]/g,p=/(?:url|expression|javascript)\s*\(/i,a=new Map,E=512;const C=t=>{const e=t.charCodeAt(0);return e===38?"&amp;":e===34?"&quot;":e===39?"&#x27;":e===60?"&lt;":e===62?"&gt;":t};function _(t){const e=a.get(t);if(e!==void 0)return e;const r=t.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return a.size<E&&a.set(t,r),r}function d(){o.clear()}function g(t){for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r===38||r===60||r===62)return!0}return!1}function S(t){for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);if(r===38||r===34||r===39||r===60||r===62)return!0}return!1}function b(t){const e=t.length<=64;if(e){const n=o.get(t);if(n!==void 0)return n}if(!g(t))return e&&o.size<u&&o.set(t,t),t;let r=t;return r=r.replace(/&/g,"&amp;"),r=r.replace(/</g,"&lt;"),r=r.replace(/>/g,"&gt;"),e&&o.size<u&&o.set(t,r),r}function T(t){return t.replace(f,C)}function h(t){const e=String(t);let r=!1,n=-1;for(let c=0;c<e.length;c++){const s=e.charCodeAt(c);if(s===123||s===125||s===60||s===62||s===92){if(r=!0,n>=0)break}else if(s===40&&n<0&&(n=c,r))break}return!r&&n===-1?e:n!==-1&&p.test(e)?"":r?e.replace(l,""):e}function R(t){if(!t||typeof t!="object")return null;const e=t;let r="";for(const n in e){const c=e[n];if(c==null||c===!1)continue;const s=_(n),i=h(String(c));i&&(r+=`${s}:${i};`)}return r||null}export{A as VOID_ELEMENTS,d as clearEscapeCache,T as escapeAttr,b as escapeText,S as needsEscapeAttr,g as needsEscapeText,R as styleObjToCss};
1
+ //#region src/ssr/escape.ts
2
+ /**
3
+ * HTML escaping utilities for SSR
4
+ *
5
+ * Centralizes text and attribute escaping to avoid duplication
6
+ * between sync and streaming SSR renderers.
7
+ */
8
+ const VOID_ELEMENTS = new Set([
9
+ "area",
10
+ "base",
11
+ "br",
12
+ "col",
13
+ "embed",
14
+ "hr",
15
+ "img",
16
+ "input",
17
+ "link",
18
+ "meta",
19
+ "param",
20
+ "source",
21
+ "track",
22
+ "wbr"
23
+ ]);
24
+ const escapeCache = /* @__PURE__ */ new Map();
25
+ const MAX_CACHE_SIZE = 256;
26
+ const CSS_UNSAFE_RE = /[{}<>\\]/g;
27
+ const CSS_DANGEROUS_FN_RE = /(?:url|expression|javascript)\s*\(/i;
28
+ const STYLE_PROP_CACHE = /* @__PURE__ */ new Map();
29
+ const MAX_STYLE_PROP_CACHE_SIZE = 512;
30
+ function toKebabCached(prop) {
31
+ const cached = STYLE_PROP_CACHE.get(prop);
32
+ if (cached !== void 0) return cached;
33
+ const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
34
+ if (STYLE_PROP_CACHE.size < MAX_STYLE_PROP_CACHE_SIZE) STYLE_PROP_CACHE.set(prop, kebab);
35
+ return kebab;
36
+ }
37
+ /**
38
+ * Fast check if a string needs text escaping.
39
+ * Used to skip the full escape call when not needed.
40
+ */
41
+ function needsEscapeText(text) {
42
+ for (let i = 0; i < text.length; i++) {
43
+ const ch = text.charCodeAt(i);
44
+ if (ch === 38 || ch === 60 || ch === 62) return true;
45
+ }
46
+ return false;
47
+ }
48
+ /**
49
+ * Fast check if a string needs attribute escaping.
50
+ * Checks for & " ' < > characters.
51
+ */
52
+ function needsEscapeAttr(value) {
53
+ for (let i = 0; i < value.length; i++) {
54
+ const ch = value.charCodeAt(i);
55
+ if (ch === 38 || ch === 34 || ch === 39 || ch === 60 || ch === 62) return true;
56
+ }
57
+ return false;
58
+ }
59
+ /**
60
+ * Escape HTML special characters in text content
61
+ * Fast-path: cache first, then scan-then-escape for new strings
62
+ */
63
+ function escapeText(text) {
64
+ const useCache = text.length <= 64;
65
+ if (useCache) {
66
+ const cached = escapeCache.get(text);
67
+ if (cached !== void 0) return cached;
68
+ }
69
+ if (!needsEscapeText(text)) {
70
+ if (useCache && escapeCache.size < MAX_CACHE_SIZE) escapeCache.set(text, text);
71
+ return text;
72
+ }
73
+ let escaped = "";
74
+ let lastIndex = 0;
75
+ for (let i = 0; i < text.length; i++) {
76
+ const ch = text.charCodeAt(i);
77
+ let entity;
78
+ if (ch === 38) entity = "&amp;";
79
+ else if (ch === 60) entity = "&lt;";
80
+ else if (ch === 62) entity = "&gt;";
81
+ else continue;
82
+ escaped += text.slice(lastIndex, i) + entity;
83
+ lastIndex = i + 1;
84
+ }
85
+ const result = escaped + text.slice(lastIndex);
86
+ if (useCache && escapeCache.size < MAX_CACHE_SIZE) escapeCache.set(text, result);
87
+ return result;
88
+ }
89
+ /**
90
+ * Escape HTML special characters in attribute values.
91
+ * Single-pass scan: returns the original string unchanged when no special
92
+ * characters are found, so callers can drop separate needsEscapeAttr checks.
93
+ */
94
+ function escapeAttr(value) {
95
+ let escaped = "";
96
+ let lastIndex = 0;
97
+ for (let i = 0; i < value.length; i++) {
98
+ const ch = value.charCodeAt(i);
99
+ let entity;
100
+ if (ch === 38) entity = "&amp;";
101
+ else if (ch === 34) entity = "&quot;";
102
+ else if (ch === 39) entity = "&#x27;";
103
+ else if (ch === 60) entity = "&lt;";
104
+ else if (ch === 62) entity = "&gt;";
105
+ else continue;
106
+ escaped += value.slice(lastIndex, i) + entity;
107
+ lastIndex = i + 1;
108
+ }
109
+ return lastIndex === 0 ? value : escaped + value.slice(lastIndex);
110
+ }
111
+ /**
112
+ * Escape CSS value to prevent injection attacks.
113
+ * Removes characters that could break out of CSS context.
114
+ */
115
+ function escapeCssValue(value) {
116
+ const str = String(value);
117
+ let hasUnsafeChars = false;
118
+ let openParen = -1;
119
+ for (let i = 0; i < str.length; i++) {
120
+ const ch = str.charCodeAt(i);
121
+ if (ch === 123 || ch === 125 || ch === 60 || ch === 62 || ch === 92) {
122
+ hasUnsafeChars = true;
123
+ if (openParen >= 0) break;
124
+ } else if (ch === 40 && openParen < 0) {
125
+ openParen = i;
126
+ if (hasUnsafeChars) break;
127
+ }
128
+ }
129
+ if (!hasUnsafeChars && openParen === -1) return str;
130
+ if (openParen !== -1 && CSS_DANGEROUS_FN_RE.test(str)) return "";
131
+ return hasUnsafeChars ? str.replace(CSS_UNSAFE_RE, "") : str;
132
+ }
133
+ /**
134
+ * Convert style object to CSS string with value escaping
135
+ * Optimized to avoid Object.entries allocation
136
+ */
137
+ function styleObjToCss(value) {
138
+ if (!value || typeof value !== "object") return null;
139
+ const styleObj = value;
140
+ let result = "";
141
+ for (const k in styleObj) {
142
+ const v = styleObj[k];
143
+ if (v === null || v === void 0 || v === false) continue;
144
+ const prop = toKebabCached(k);
145
+ const safeValue = escapeCssValue(String(v));
146
+ if (safeValue) result += `${prop}:${safeValue};`;
147
+ }
148
+ return result || null;
149
+ }
150
+ //#endregion
151
+ export { VOID_ELEMENTS, escapeAttr, escapeText, needsEscapeAttr, styleObjToCss };
152
+
153
+ //# sourceMappingURL=escape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape.js","names":[],"sources":["../../src/ssr/escape.ts"],"sourcesContent":["/**\n * HTML escaping utilities for SSR\n *\n * Centralizes text and attribute escaping to avoid duplication\n * between sync and streaming SSR renderers.\n */\n\n// HTML5 void elements that don't have closing tags\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n// Escape cache for common values (bounded and clearable for long-running servers)\nconst escapeCache = new Map<string, string>();\nconst MAX_CACHE_SIZE = 256;\n\nconst _TEXT_ESCAPE_RE = /[&<>]/g;\n\nconst CSS_UNSAFE_RE = /[{}<>\\\\]/g;\nconst CSS_DANGEROUS_FN_RE = /(?:url|expression|javascript)\\s*\\(/i;\n\nconst STYLE_PROP_CACHE = new Map<string, string>();\nconst MAX_STYLE_PROP_CACHE_SIZE = 512;\n\n// Pre-compute escape map functions for faster replacement\nconst _textEscapeMap = (ch: string): string => {\n const code = ch.charCodeAt(0);\n if (code === 38) return '&amp;'; // &\n if (code === 60) return '&lt;'; // <\n if (code === 62) return '&gt;'; // >\n return ch;\n};\n\nfunction toKebabCached(prop: string): string {\n const cached = STYLE_PROP_CACHE.get(prop);\n if (cached !== undefined) return cached;\n const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n if (STYLE_PROP_CACHE.size < MAX_STYLE_PROP_CACHE_SIZE) {\n STYLE_PROP_CACHE.set(prop, kebab);\n }\n return kebab;\n}\n\n/**\n * Clear the escape cache. Call between SSR requests in long-running servers\n * to prevent memory buildup from unique strings.\n */\nexport function clearEscapeCache(): void {\n escapeCache.clear();\n}\n\n/**\n * Fast check if a string needs text escaping.\n * Used to skip the full escape call when not needed.\n */\nexport function needsEscapeText(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n if (ch === 38 || ch === 60 || ch === 62) return true;\n }\n return false;\n}\n\n/**\n * Fast check if a string needs attribute escaping.\n * Checks for & \" ' < > characters.\n */\nexport function needsEscapeAttr(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n // & \" ' < >\n if (ch === 38 || ch === 34 || ch === 39 || ch === 60 || ch === 62) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Escape HTML special characters in text content\n * Fast-path: cache first, then scan-then-escape for new strings\n */\nexport function escapeText(text: string): string {\n // Only use cache for short strings (likely to be repeated)\n const useCache = text.length <= 64;\n\n if (useCache) {\n const cached = escapeCache.get(text);\n if (cached !== undefined) return cached;\n }\n\n // Fast path: check if escaping needed\n if (!needsEscapeText(text)) {\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, text);\n }\n return text;\n }\n\n // Single-pass scan-and-build: avoids 3 separate regex passes\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < text.length; i++) {\n const ch = text.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += text.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n const result = escaped + text.slice(lastIndex);\n\n if (useCache && escapeCache.size < MAX_CACHE_SIZE) {\n escapeCache.set(text, result);\n }\n return result;\n}\n\n/**\n * Escape HTML special characters in attribute values.\n * Single-pass scan: returns the original string unchanged when no special\n * characters are found, so callers can drop separate needsEscapeAttr checks.\n */\nexport function escapeAttr(value: string): string {\n let escaped = '';\n let lastIndex = 0;\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n let entity: string;\n if (ch === 38) entity = '&amp;';\n else if (ch === 34) entity = '&quot;';\n else if (ch === 39) entity = '&#x27;';\n else if (ch === 60) entity = '&lt;';\n else if (ch === 62) entity = '&gt;';\n else continue;\n escaped += value.slice(lastIndex, i) + entity;\n lastIndex = i + 1;\n }\n // Return original reference when nothing needed escaping (no allocation)\n return lastIndex === 0 ? value : escaped + value.slice(lastIndex);\n}\n\n/**\n * Escape CSS value to prevent injection attacks.\n * Removes characters that could break out of CSS context.\n */\nfunction escapeCssValue(value: string): string {\n const str = String(value);\n\n let hasUnsafeChars = false;\n let openParen = -1;\n\n // Single pass to check for unsafe chars and find first paren\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n // Check for { } < > \\\n if (ch === 123 || ch === 125 || ch === 60 || ch === 62 || ch === 92) {\n hasUnsafeChars = true;\n if (openParen >= 0) break;\n } else if (ch === 40 && openParen < 0) {\n // (\n openParen = i;\n if (hasUnsafeChars) break;\n }\n }\n\n // Fast path: most CSS values are simple\n if (!hasUnsafeChars && openParen === -1) return str;\n\n // Block dangerous CSS functions\n if (openParen !== -1 && CSS_DANGEROUS_FN_RE.test(str)) {\n return '';\n }\n\n // Remove characters that could break out of CSS value context\n return hasUnsafeChars ? str.replace(CSS_UNSAFE_RE, '') : str;\n}\n\n/**\n * Convert style object to CSS string with value escaping\n * Optimized to avoid Object.entries allocation\n */\nexport function styleObjToCss(value: unknown): string | null {\n if (!value || typeof value !== 'object') return null;\n\n const styleObj = value as Record<string, unknown>;\n let result = '';\n\n for (const k in styleObj) {\n const v = styleObj[k];\n if (v === null || v === undefined || v === false) continue;\n\n const prop = toKebabCached(k);\n const safeValue = escapeCssValue(String(v));\n if (safeValue) {\n result += `${prop}:${safeValue};`;\n }\n }\n\n return result || null;\n}\n"],"mappings":";;;;;;;AAQA,MAAa,gBAAgB,IAAI,IAAI;C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