@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
@@ -1,161 +0,0 @@
1
- //#region src/renderer/dom-range.ts
2
- const RANGE_START_MARKER = "askr-range-start";
3
- const RANGE_END_MARKER = "askr-range-end";
4
- const rangesByOwner = /* @__PURE__ */ new WeakMap();
5
- const ownersByAnchor = /* @__PURE__ */ new WeakMap();
6
- function isRangeMarker(node) {
7
- return node.nodeType === 8;
8
- }
9
- function normalizeNodes(node) {
10
- if (!node) return [];
11
- return node instanceof DocumentFragment ? Array.from(node.childNodes) : [node];
12
- }
13
- function getRangeNodes(range) {
14
- if (range.single) return range.start.parentNode ? [range.start] : [];
15
- const nodes = [];
16
- let current = range.start.nextSibling;
17
- while (current && current !== range.end) {
18
- nodes.push(current);
19
- current = current.nextSibling;
20
- }
21
- return nodes;
22
- }
23
- function createDetachedRange(nodes, owner) {
24
- if (nodes && !(nodes instanceof DocumentFragment)) return {
25
- range: createSingleNodeRange(nodes, owner),
26
- fragment: null
27
- };
28
- const normalized = normalizeNodes(nodes);
29
- const ownerDocument = normalized[0]?.ownerDocument ?? (typeof document !== "undefined" ? document : null);
30
- if (!ownerDocument) throw new Error("[askr] Cannot create a DOM range without a document.");
31
- if (normalized.length === 1) {
32
- const single = normalized[0];
33
- return {
34
- range: createSingleNodeRange(single, owner),
35
- fragment: null
36
- };
37
- }
38
- const fragment = ownerDocument.createDocumentFragment();
39
- const start = ownerDocument.createComment(RANGE_START_MARKER);
40
- const end = ownerDocument.createComment(RANGE_END_MARKER);
41
- fragment.appendChild(start);
42
- for (const node of normalized) fragment.appendChild(node);
43
- fragment.appendChild(end);
44
- const range = {
45
- start,
46
- end,
47
- single: false
48
- };
49
- registerRange(range, owner);
50
- return {
51
- range,
52
- fragment
53
- };
54
- }
55
- /** @internal Create the common singleton range without a result wrapper. */
56
- function createSingleNodeRange(node, owner) {
57
- const range = {
58
- start: node,
59
- end: node,
60
- single: true
61
- };
62
- registerRange(range, owner);
63
- return range;
64
- }
65
- function createEmptyRange(ownerDocument = document, owner) {
66
- return createDetachedRange(ownerDocument.createDocumentFragment(), owner);
67
- }
68
- function registerRange(range, owner) {
69
- if (!owner) return;
70
- rangesByOwner.set(owner, range);
71
- ownersByAnchor.set(range.start, owner);
72
- if (range.end !== range.start) ownersByAnchor.set(range.end, owner);
73
- }
74
- function getOwnedRange(owner) {
75
- return rangesByOwner.get(owner);
76
- }
77
- function getRangeOwner(node) {
78
- return ownersByAnchor.get(node);
79
- }
80
- function clearRangeOwner(range, owner) {
81
- const startOwner = ownersByAnchor.get(range.start);
82
- const endOwner = ownersByAnchor.get(range.end);
83
- if (!owner || startOwner === owner) ownersByAnchor.delete(range.start);
84
- if (!owner || endOwner === owner) ownersByAnchor.delete(range.end);
85
- if (!owner || rangesByOwner.get(owner) === range) rangesByOwner.delete(owner ?? startOwner);
86
- }
87
- function appendRange(parent, range, before = null) {
88
- if (range.single) {
89
- parent.insertBefore(range.start, before);
90
- return;
91
- }
92
- const nodes = [
93
- range.start,
94
- ...getRangeNodes(range),
95
- range.end
96
- ];
97
- for (const node of nodes) parent.insertBefore(node, before);
98
- }
99
- function moveRange(parent, range, before = null) {
100
- if (before && rangeContains(range, before)) return;
101
- if (range.single) {
102
- parent.insertBefore(range.start, before);
103
- return;
104
- }
105
- const fragment = parent.ownerDocument.createDocumentFragment();
106
- const nodes = [
107
- range.start,
108
- ...getRangeNodes(range),
109
- range.end
110
- ];
111
- for (const node of nodes) fragment.appendChild(node);
112
- parent.insertBefore(fragment, before);
113
- }
114
- function insertRangeBefore(parent, range, before = null) {
115
- moveRange(parent, range, before);
116
- }
117
- function removeRange(range, removeNode = (node) => node.parentNode?.removeChild(node)) {
118
- if (range.single) {
119
- removeNode(range.start);
120
- clearRangeOwner(range);
121
- return;
122
- }
123
- const nodes = [
124
- range.start,
125
- ...getRangeNodes(range),
126
- range.end
127
- ];
128
- for (const node of nodes) removeNode(node);
129
- clearRangeOwner(range);
130
- }
131
- function rangeContains(range, node) {
132
- if (range.single) return range.start === node;
133
- if (range.start.parentNode !== node.parentNode) return false;
134
- let current = range.start;
135
- while (current) {
136
- if (current === node) return true;
137
- if (current === range.end) break;
138
- current = current.nextSibling;
139
- }
140
- return false;
141
- }
142
- function isRangeStart(node) {
143
- return isRangeMarker(node) && node.data === "askr-range-start";
144
- }
145
- function isRangeEnd(node) {
146
- return isRangeMarker(node) && node.data === "askr-range-end";
147
- }
148
- function findRangeEnd(start) {
149
- if (!isRangeStart(start)) return null;
150
- let depth = 0;
151
- for (let current = start; current; current = current.nextSibling) {
152
- if (isRangeStart(current)) depth++;
153
- if (isRangeEnd(current)) {
154
- depth--;
155
- if (depth === 0) return current;
156
- }
157
- }
158
- return null;
159
- }
160
- //#endregion
161
- export { RANGE_END_MARKER, RANGE_START_MARKER, appendRange, clearRangeOwner, createDetachedRange, createEmptyRange, createSingleNodeRange, findRangeEnd, getOwnedRange, getRangeNodes, getRangeOwner, insertRangeBefore, isRangeEnd, isRangeStart, moveRange, rangeContains, registerRange, removeRange };
@@ -1,11 +0,0 @@
1
- import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
2
- import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
3
- import { setStaticChildSlotsCacheEnabled } from "./static-reuse.js";
4
- import { updateElementChildren, updateUnkeyedChildren } from "./element-children.js";
5
- import { markReactivePropsDirtySource } from "./prop-bindings.js";
6
- import "./boundary-materialization.js";
7
- import "./boundaries.js";
8
- import { syncComponentElement } from "./component-host.js";
9
- import { tryPatchStableForDirtyItem } from "./stable-patch.js";
10
- import { IS_DOM_AVAILABLE, activateHydrationBoundary, createDOMNode, updateElementFromVnode } from "./dom-internal.js";
11
- export { IS_DOM_AVAILABLE, activateHydrationBoundary, createDOMNode, isBulkTextFastPathEligible, markReactivePropsDirtySource, performBulkPositionalKeyedTextUpdate, performBulkTextReplace, setStaticChildSlotsCacheEnabled, syncComponentElement, tryPatchStableForDirtyItem, updateElementChildren, updateElementFromVnode, updateUnkeyedChildren };
@@ -1,359 +0,0 @@
1
- import { __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
2
- import "./types.js";
3
- import { teardownNodeSubtree } from "./cleanup.js";
4
- import { extractKey, getMaterializedKey } from "./utils.js";
5
- import { keyedElements } from "./keyed.js";
6
- import { createDetachedRange, findRangeEnd, isRangeStart, moveRange, removeRange } from "./dom-range.js";
7
- import { getParentNamespace } from "./namespaces.js";
8
- import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
9
- import { getRendererDOMHost } from "./dom-host.js";
10
- import { reconcileKeyedChildren } from "./reconcile.js";
11
- import { isFragmentVNode, normalizeComponentChildren } from "./child-shape.js";
12
- import { trySyncScalarChildSequenceInPlace } from "./reactive-children.js";
13
- import { tagsEqualIgnoreCase } from "./static-reuse.js";
14
- import { syncControlBoundaryInMixedParent } from "./boundary-range-sync.js";
15
- import { evaluateControlBoundaryState, getControlBoundaryState, getDirectControlBoundaryVNode } from "./boundary-state.js";
16
- import { clearControlBoundaryCommitOwner, commitForBoundaryChildren, registerControlBoundaryCommitOwner, trySyncControlBoundaryChild } from "./boundaries.js";
17
- //#region src/renderer/element-children.ts
18
- const rendererReactiveChildDOMHost = {
19
- createDOMNode: (node, parentNamespace) => getRendererDOMHost().createDOMNode(node, parentNamespace),
20
- updateElementChildren: (el, children, forceUpdate) => updateElementChildren(el, children, forceUpdate)
21
- };
22
- function updateElementChildren(el, children, forceUpdate = false) {
23
- const directControlBoundary = getDirectControlBoundaryVNode(children);
24
- if (directControlBoundary) {
25
- const controlState = getControlBoundaryState(directControlBoundary);
26
- if (!controlState) throw new Error("[updateElementChildren] Control boundary missing internal state");
27
- registerControlBoundaryCommitOwner(el, controlState);
28
- commitForBoundaryChildren(el, controlState, evaluateControlBoundaryState(controlState));
29
- return;
30
- }
31
- clearControlBoundaryCommitOwner(el);
32
- if (children === null || children === void 0) {
33
- for (let n = el.firstChild; n;) {
34
- const next = n.nextSibling;
35
- teardownNodeSubtree(n);
36
- n = next;
37
- }
38
- el.textContent = "";
39
- return;
40
- }
41
- if (!Array.isArray(children) && isFragmentVNode(children)) {
42
- updateUnkeyedChildren(el, normalizeComponentChildren(children), forceUpdate);
43
- return;
44
- }
45
- if (!Array.isArray(children) && (typeof children === "string" || typeof children === "number")) {
46
- if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {
47
- const s = String(children);
48
- const t = el.firstChild;
49
- if (t.data !== s) t.data = s;
50
- } else {
51
- for (let n = el.firstChild; n;) {
52
- const next = n.nextSibling;
53
- teardownNodeSubtree(n);
54
- n = next;
55
- }
56
- el.textContent = String(children);
57
- }
58
- return;
59
- }
60
- if (Array.isArray(children)) {
61
- const normalizedChildren = normalizeComponentChildren(children);
62
- if (trySyncScalarChildSequenceInPlace(el, normalizedChildren, rendererReactiveChildDOMHost)) {
63
- keyedElements.delete(el);
64
- return;
65
- }
66
- if (normalizedChildren.some(isControlBoundaryVNode) && normalizedChildren.every((child) => {
67
- if (!isControlBoundaryVNode(child)) return true;
68
- return getControlBoundaryState(child)?.kind !== "for";
69
- })) {
70
- updateMixedControlChildren(el, normalizedChildren, forceUpdate);
71
- keyedElements.delete(el);
72
- return;
73
- }
74
- if (hasKeyedVNodeChildren(normalizedChildren)) {
75
- const newKeyMap = reconcileKeyedChildren(el, normalizedChildren, getOrBuildDomKeyMap(el));
76
- keyedElements.set(el, newKeyMap);
77
- return;
78
- }
79
- if (isBulkTextFastPathEligible(el, normalizedChildren)) {
80
- performBulkTextReplace(el, normalizedChildren);
81
- keyedElements.delete(el);
82
- return;
83
- }
84
- updateUnkeyedChildren(el, normalizedChildren, forceUpdate);
85
- return;
86
- }
87
- if (_isDOMElement(children)) {
88
- updateUnkeyedChildren(el, [children], forceUpdate);
89
- return;
90
- }
91
- for (let n = el.firstChild; n;) {
92
- const next = n.nextSibling;
93
- teardownNodeSubtree(n);
94
- n = next;
95
- }
96
- el.textContent = "";
97
- const dom = getRendererDOMHost().createDOMNode(children);
98
- if (dom) el.appendChild(dom);
99
- }
100
- function hasKeyedVNodeChildren(children) {
101
- for (let i = 0; i < children.length; i++) if (extractKey(children[i]) !== void 0) return true;
102
- return false;
103
- }
104
- function isControlBoundaryVNode(child) {
105
- return _isDOMElement(child) && child.type === __FOR_BOUNDARY__;
106
- }
107
- function removeRangeAtCursor(parent, cursor) {
108
- if (!isRangeStart(cursor)) return cursor;
109
- const end = findRangeEnd(cursor);
110
- if (!end) return cursor;
111
- const range = {
112
- start: cursor,
113
- end,
114
- single: false
115
- };
116
- const next = end.nextSibling;
117
- removeRange(range, (node) => {
118
- if (node === range.start || node === range.end) {
119
- node.parentNode?.removeChild(node);
120
- return;
121
- }
122
- teardownNodeSubtree(node);
123
- node.parentNode?.removeChild(node);
124
- });
125
- return next;
126
- }
127
- function updateMixedControlChildren(parent, children, forceUpdate) {
128
- const parentNamespace = getParentNamespace(parent);
129
- const domHost = getRendererDOMHost();
130
- let cursor = parent.firstChild;
131
- for (const child of children) {
132
- if (isControlBoundaryVNode(child)) {
133
- const controlState = getControlBoundaryState(child);
134
- if (!controlState) throw new Error("[updateElementChildren] Control boundary missing internal state");
135
- registerControlBoundaryCommitOwner(parent, controlState);
136
- const ranges = syncControlBoundaryInMixedParent(parent, controlState, evaluateControlBoundaryState(controlState), cursor);
137
- for (const range of ranges) if (range.start.parentNode !== parent) moveRange(parent, range, cursor?.parentNode === parent ? cursor : null);
138
- else if (cursor?.parentNode === parent) moveRange(parent, range, cursor);
139
- const last = ranges[ranges.length - 1];
140
- if (last) {
141
- const cursorWasReplaced = cursor && !ranges.some((range) => range.start === cursor);
142
- if (!cursor?.parentNode) cursor = last.end.nextSibling;
143
- else if (cursorWasReplaced && isRangeStart(cursor)) cursor = findRangeEnd(cursor)?.nextSibling ?? last.end.nextSibling;
144
- else if (isRangeStart(cursor)) cursor = findRangeEnd(cursor)?.nextSibling ?? last.end.nextSibling;
145
- else cursor = last.end.nextSibling;
146
- }
147
- continue;
148
- }
149
- if (cursor) cursor = removeRangeAtCursor(parent, cursor);
150
- if (cursor && (typeof child === "string" || typeof child === "number") && cursor.nodeType === 3) {
151
- cursor.data = String(child);
152
- cursor = cursor.nextSibling;
153
- continue;
154
- }
155
- if (cursor instanceof Element && _isDOMElement(child) && typeof child.type === "string" && tagsEqualIgnoreCase(cursor.tagName, child.type)) {
156
- domHost.updateElementFromVnode(cursor, child, true, forceUpdate);
157
- cursor = cursor.nextSibling;
158
- continue;
159
- }
160
- if (cursor instanceof Element && _isDOMElement(child) && typeof child.type === "function") {
161
- const synced = domHost.syncComponentElement(cursor, child, child.type, (child.props ?? {}) || {}, parentNamespace, forceUpdate);
162
- if (synced) {
163
- cursor = synced.nextSibling;
164
- continue;
165
- }
166
- }
167
- const created = domHost.createDOMNode(child, parentNamespace);
168
- if (!created) {
169
- cursor = cursor?.nextSibling ?? null;
170
- continue;
171
- }
172
- const materialized = createDetachedRange(created);
173
- const old = cursor;
174
- moveRange(parent, materialized.range, old);
175
- if (old) {
176
- teardownNodeSubtree(old);
177
- old.parentNode?.removeChild(old);
178
- }
179
- cursor = materialized.range.end.nextSibling;
180
- }
181
- while (cursor) {
182
- const next = removeRangeAtCursor(parent, cursor);
183
- cursor = next === cursor ? cursor.nextSibling : next;
184
- }
185
- }
186
- function isEmptyChild(child) {
187
- return child === null || child === void 0 || child === false;
188
- }
189
- function getOrBuildDomKeyMap(parent) {
190
- let keyMap = keyedElements.get(parent);
191
- if (!keyMap) {
192
- keyMap = /* @__PURE__ */ new Map();
193
- for (let child = parent.firstElementChild; child; child = child.nextElementSibling) {
194
- const key = getMaterializedKey(child);
195
- if (key !== void 0) keyMap.set(key, child);
196
- }
197
- if (keyMap.size > 0) keyedElements.set(parent, keyMap);
198
- }
199
- return keyMap.size > 0 ? keyMap : void 0;
200
- }
201
- function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
202
- const parentNamespace = getParentNamespace(parent);
203
- const domHost = getRendererDOMHost();
204
- const trySyncComponentChild = (currentDom, next) => {
205
- if (typeof next.type !== "function") return null;
206
- return domHost.syncComponentElement(currentDom, next, next.type, (next.props ?? {}) || {}, parentNamespace, forceUpdate);
207
- };
208
- const hasText = newChildren.some((c) => typeof c === "string" || typeof c === "number");
209
- const hasElements = newChildren.some((c) => _isDOMElement(c));
210
- const hasEmptyChildren = newChildren.some(isEmptyChild);
211
- const hasComponentChildren = newChildren.some((c) => _isDOMElement(c) && typeof c.type === "function");
212
- const hasNonElementDomChildren = parent.childNodes.length !== parent.children.length;
213
- if (!hasEmptyChildren && !hasText && !hasComponentChildren && !hasNonElementDomChildren && hasElements && parent.children.length === newChildren.length) {
214
- const c = parent.children;
215
- for (let i = 0; i < newChildren.length; i++) {
216
- const next = newChildren[i];
217
- const current = c[i];
218
- if (!current || next === void 0) continue;
219
- if (_isDOMElement(next) && typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) domHost.updateElementFromVnode(current, next, true, forceUpdate);
220
- else {
221
- const dom = domHost.createDOMNode(next, parentNamespace);
222
- if (dom) {
223
- teardownNodeSubtree(current);
224
- parent.replaceChild(dom, current);
225
- }
226
- }
227
- else if (_isDOMElement(next)) {
228
- if (trySyncControlBoundaryChild(parent, current, next)) continue;
229
- if (!trySyncComponentChild(current, next)) {
230
- const dom = domHost.createDOMNode(next, parentNamespace);
231
- if (dom) {
232
- teardownNodeSubtree(current);
233
- parent.replaceChild(dom, current);
234
- }
235
- }
236
- } else {
237
- const dom = domHost.createDOMNode(next, parentNamespace);
238
- if (dom) {
239
- teardownNodeSubtree(current);
240
- parent.replaceChild(dom, current);
241
- }
242
- }
243
- }
244
- return;
245
- }
246
- const existing = Array.from(parent.children);
247
- if (hasText || hasComponentChildren || hasEmptyChildren || hasNonElementDomChildren) {
248
- const allNodes = Array.from(parent.childNodes);
249
- const max = Math.max(allNodes.length, newChildren.length);
250
- for (let i = 0; i < max; i++) {
251
- const currentNode = allNodes[i];
252
- const next = newChildren[i];
253
- const nextIsEmpty = isEmptyChild(next);
254
- if (nextIsEmpty && currentNode) {
255
- teardownNodeSubtree(currentNode);
256
- currentNode.remove();
257
- continue;
258
- }
259
- if (!currentNode && !nextIsEmpty) {
260
- const dom = domHost.createDOMNode(next, parentNamespace);
261
- if (dom) parent.appendChild(dom);
262
- continue;
263
- }
264
- if (!currentNode || nextIsEmpty) continue;
265
- if (typeof next === "string" || typeof next === "number") if (currentNode.nodeType === 3) currentNode.data = String(next);
266
- else {
267
- const textNode = document.createTextNode(String(next));
268
- parent.replaceChild(textNode, currentNode);
269
- }
270
- else if (_isDOMElement(next)) if (currentNode.nodeType === 1) {
271
- const currentEl = currentNode;
272
- if (typeof next.type === "string") if (tagsEqualIgnoreCase(currentEl.tagName, next.type)) domHost.updateElementFromVnode(currentEl, next, true, forceUpdate);
273
- else {
274
- const dom = domHost.createDOMNode(next, parentNamespace);
275
- if (dom) {
276
- teardownNodeSubtree(currentEl);
277
- parent.replaceChild(dom, currentNode);
278
- }
279
- }
280
- else {
281
- if (trySyncControlBoundaryChild(parent, currentNode, next)) continue;
282
- if (!trySyncComponentChild(currentEl, next)) {
283
- const dom = domHost.createDOMNode(next, parentNamespace);
284
- if (dom) {
285
- teardownNodeSubtree(currentEl);
286
- parent.replaceChild(dom, currentNode);
287
- }
288
- }
289
- }
290
- } else {
291
- const dom = domHost.createDOMNode(next, parentNamespace);
292
- if (dom) parent.replaceChild(dom, currentNode);
293
- }
294
- }
295
- return;
296
- }
297
- if (newChildren.length === 1 && existing.length === 0 && parent.childNodes.length === 1) {
298
- const firstNewChild = newChildren[0];
299
- const firstExisting = parent.firstChild;
300
- if ((typeof firstNewChild === "string" || typeof firstNewChild === "number") && firstExisting?.nodeType === 3) {
301
- firstExisting.data = String(firstNewChild);
302
- return;
303
- }
304
- }
305
- if (existing.length === 0 && parent.childNodes.length > 0) {
306
- for (let n = parent.firstChild; n;) {
307
- const next = n.nextSibling;
308
- teardownNodeSubtree(n);
309
- n = next;
310
- }
311
- parent.textContent = "";
312
- }
313
- const max = Math.max(existing.length, newChildren.length);
314
- for (let i = 0; i < max; i++) {
315
- const current = existing[i];
316
- const next = newChildren[i];
317
- const nextIsEmpty = isEmptyChild(next);
318
- if (nextIsEmpty && current) {
319
- teardownNodeSubtree(current);
320
- current.remove();
321
- continue;
322
- }
323
- if (!current && !nextIsEmpty) {
324
- const dom = domHost.createDOMNode(next, parentNamespace);
325
- if (dom) parent.appendChild(dom);
326
- continue;
327
- }
328
- if (!current || nextIsEmpty) continue;
329
- if (typeof next === "string" || typeof next === "number") {
330
- const textNode = document.createTextNode(String(next));
331
- teardownNodeSubtree(current);
332
- parent.replaceChild(textNode, current);
333
- } else if (_isDOMElement(next)) {
334
- if (typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) domHost.updateElementFromVnode(current, next, true, forceUpdate);
335
- else {
336
- const dom = domHost.createDOMNode(next, parentNamespace);
337
- if (dom) {
338
- teardownNodeSubtree(current);
339
- parent.replaceChild(dom, current);
340
- }
341
- }
342
- else if (!trySyncComponentChild(current, next)) {
343
- const dom = domHost.createDOMNode(next, parentNamespace);
344
- if (dom) {
345
- teardownNodeSubtree(current);
346
- parent.replaceChild(dom, current);
347
- }
348
- }
349
- } else {
350
- const dom = domHost.createDOMNode(next);
351
- if (dom) {
352
- teardownNodeSubtree(current);
353
- parent.replaceChild(dom, current);
354
- }
355
- }
356
- }
357
- }
358
- //#endregion
359
- export { rendererReactiveChildDOMHost, updateElementChildren, updateUnkeyedChildren };
@@ -1,2 +0,0 @@
1
- import { getRuntimeEnv } from "../common/env.js";
2
- export { getRuntimeEnv };
@@ -1,86 +0,0 @@
1
- import { isDevelopmentEnvironment } from "../common/env.js";
2
- import { logger } from "../common/logger.js";
3
- import { beginLifecycleCommitBatch, discardLifecycleCommitBatch, flushLifecycleCommitBatch } from "../runtime/lifecycle-batch.js";
4
- import { createBoundaryReset, reportBoundaryError } from "../runtime/error-boundary.js";
5
- import "../runtime/index.js";
6
- import { getRendererDOMHost } from "./dom-host.js";
7
- //#region src/renderer/error-boundary-dom.ts
8
- function getBoundaryMessage(error) {
9
- if (error instanceof Error) return error.message || error.name || "Unknown error";
10
- if (typeof error === "string") return error;
11
- try {
12
- return JSON.stringify(error);
13
- } catch {
14
- return String(error);
15
- }
16
- }
17
- function createDefaultFallbackNode(error, reset) {
18
- const message = getBoundaryMessage(error);
19
- const wrapper = document.createElement("div");
20
- wrapper.setAttribute("role", "alert");
21
- wrapper.setAttribute("data-askr-error-boundary", "true");
22
- wrapper.style.boxSizing = "border-box";
23
- wrapper.style.padding = "1rem";
24
- wrapper.style.border = "1px solid currentColor";
25
- wrapper.style.borderRadius = "0.75rem";
26
- wrapper.style.display = "grid";
27
- wrapper.style.gap = "0.75rem";
28
- wrapper.style.maxWidth = "100%";
29
- const title = document.createElement("strong");
30
- title.textContent = "Something went wrong while rendering this view.";
31
- const summary = document.createElement("p");
32
- summary.textContent = "The app recovered into a visible fallback so the error is not hidden in the console.";
33
- summary.style.margin = "0";
34
- const details = document.createElement("details");
35
- details.open = isDevelopmentEnvironment();
36
- const detailsSummary = document.createElement("summary");
37
- detailsSummary.textContent = "Error details";
38
- const pre = document.createElement("pre");
39
- pre.textContent = message;
40
- pre.style.margin = "0";
41
- pre.style.whiteSpace = "pre-wrap";
42
- pre.style.wordBreak = "break-word";
43
- const button = document.createElement("button");
44
- button.type = "button";
45
- button.textContent = "Try again";
46
- button.addEventListener("click", () => reset());
47
- details.append(detailsSummary, pre);
48
- wrapper.append(title, summary, details, button);
49
- return wrapper;
50
- }
51
- function resolveErrorBoundaryFallback(fallback, error, reset) {
52
- if (typeof fallback === "function") return fallback(error, reset);
53
- return fallback ?? createDefaultFallbackNode(error, reset);
54
- }
55
- function runErrorBoundaryDOMAttempt(attempt) {
56
- const lifecycleBatch = beginLifecycleCommitBatch();
57
- try {
58
- const result = attempt();
59
- flushLifecycleCommitBatch(lifecycleBatch);
60
- return result;
61
- } catch (error) {
62
- discardLifecycleCommitBatch(lifecycleBatch);
63
- throw error;
64
- }
65
- }
66
- function materializeErrorBoundaryValue(value, parentNamespace) {
67
- if (value instanceof Node) return value;
68
- return getRendererDOMHost().createDOMNode(value, parentNamespace) ?? document.createComment("");
69
- }
70
- function createErrorBoundaryElement(node, props, parentNamespace) {
71
- const boundaryState = node.__instance?.errorBoundaryState ?? null;
72
- const reset = node.__instance ? createBoundaryReset(node.__instance) : () => {};
73
- const fallback = props.fallback;
74
- const children = props.children;
75
- const domHost = getRendererDOMHost();
76
- if (boundaryState?.error != null) return runErrorBoundaryDOMAttempt(() => materializeErrorBoundaryValue(resolveErrorBoundaryFallback(fallback, boundaryState.error, reset), parentNamespace));
77
- try {
78
- return runErrorBoundaryDOMAttempt(() => domHost.createDOMNode(children, parentNamespace) ?? document.createComment(""));
79
- } catch (error) {
80
- if (node.__instance) reportBoundaryError(node.__instance, error, props.onError);
81
- else logger.error("[Askr] ErrorBoundary caught render error:", error);
82
- return runErrorBoundaryDOMAttempt(() => materializeErrorBoundaryValue(resolveErrorBoundaryFallback(fallback, error, reset), parentNamespace));
83
- }
84
- }
85
- //#endregion
86
- export { createErrorBoundaryElement };