@askrjs/askr 0.0.48 → 0.0.50

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 (401) hide show
  1. package/dist/benchmark.js +6 -6
  2. package/dist/benchmark.js.map +1 -1
  3. package/dist/boot/hydration.js +140 -0
  4. package/dist/boot/hydration.js.map +1 -0
  5. package/dist/boot/index.d.ts +3 -56
  6. package/dist/boot/index.d.ts.map +1 -1
  7. package/dist/boot/index.js +62 -410
  8. package/dist/boot/index.js.map +1 -1
  9. package/dist/boot/root-lifecycle.d.ts +15 -0
  10. package/dist/boot/root-lifecycle.d.ts.map +1 -0
  11. package/dist/boot/root-lifecycle.js +205 -0
  12. package/dist/boot/root-lifecycle.js.map +1 -0
  13. package/dist/boot/route-startup.js +45 -0
  14. package/dist/boot/route-startup.js.map +1 -0
  15. package/dist/boot/types.d.ts +62 -0
  16. package/dist/boot/types.d.ts.map +1 -0
  17. package/dist/common/component.d.ts +3 -1
  18. package/dist/common/component.d.ts.map +1 -1
  19. package/dist/common/jsx.d.ts +6 -2
  20. package/dist/common/jsx.d.ts.map +1 -1
  21. package/dist/common/jsx.js.map +1 -1
  22. package/dist/common/props.d.ts +1 -1
  23. package/dist/common/render-context.js +55 -0
  24. package/dist/common/render-context.js.map +1 -0
  25. package/dist/common/router.d.ts +5 -1
  26. package/dist/common/router.d.ts.map +1 -1
  27. package/dist/common/ssr.d.ts +1 -1
  28. package/dist/common/ssr.js.map +1 -1
  29. package/dist/common/vnode.d.ts +5 -4
  30. package/dist/common/vnode.d.ts.map +1 -1
  31. package/dist/common/vnode.js.map +1 -1
  32. package/dist/components/error-boundary.d.ts +1 -1
  33. package/dist/components/error-boundary.js +2 -1
  34. package/dist/components/error-boundary.js.map +1 -1
  35. package/dist/components/link.js.map +1 -1
  36. package/dist/control/for.js +2 -1
  37. package/dist/control/for.js.map +1 -1
  38. package/dist/data/data-runtime.d.ts +28 -0
  39. package/dist/data/data-runtime.d.ts.map +1 -0
  40. package/dist/data/data-runtime.js +114 -0
  41. package/dist/data/data-runtime.js.map +1 -0
  42. package/dist/data/index.d.ts +6 -142
  43. package/dist/data/index.js +5 -539
  44. package/dist/data/invalidation.d.ts +9 -0
  45. package/dist/data/invalidation.d.ts.map +1 -0
  46. package/dist/data/invalidation.js +27 -0
  47. package/dist/data/invalidation.js.map +1 -0
  48. package/dist/data/mutation-cell.d.ts +28 -0
  49. package/dist/data/mutation-cell.d.ts.map +1 -0
  50. package/dist/data/mutation-cell.js +132 -0
  51. package/dist/data/mutation-cell.js.map +1 -0
  52. package/dist/data/query-cell.d.ts +46 -0
  53. package/dist/data/query-cell.d.ts.map +1 -0
  54. package/dist/data/query-cell.js +290 -0
  55. package/dist/data/query-cell.js.map +1 -0
  56. package/dist/data/query-key.js +42 -0
  57. package/dist/data/query-key.js.map +1 -0
  58. package/dist/data/shared.js +20 -0
  59. package/dist/data/shared.js.map +1 -0
  60. package/dist/data/types.d.ts +161 -0
  61. package/dist/data/types.d.ts.map +1 -0
  62. package/dist/foundations/icon/icon.d.ts.map +1 -1
  63. package/dist/foundations/icon/icon.js.map +1 -1
  64. package/dist/foundations/structures/portal.d.ts +1 -1
  65. package/dist/foundations/structures/portal.d.ts.map +1 -1
  66. package/dist/foundations/structures/portal.js +2 -1
  67. package/dist/foundations/structures/portal.js.map +1 -1
  68. package/dist/fx/fx.d.ts +1 -1
  69. package/dist/fx/fx.js +5 -4
  70. package/dist/fx/fx.js.map +1 -1
  71. package/dist/fx/timing.d.ts.map +1 -1
  72. package/dist/fx/timing.js +10 -6
  73. package/dist/fx/timing.js.map +1 -1
  74. package/dist/index.d.ts +3 -2
  75. package/dist/index.js +4 -2
  76. package/dist/index.js.map +1 -1
  77. package/dist/jsx/index.d.ts +2 -1
  78. package/dist/jsx/index.js +3 -2
  79. package/dist/jsx/types.d.ts +3 -1
  80. package/dist/jsx/types.d.ts.map +1 -1
  81. package/dist/jsx/types.js +2 -1
  82. package/dist/jsx-dev-runtime.d.ts +2 -2
  83. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  84. package/dist/jsx-dev-runtime.js.map +1 -1
  85. package/dist/jsx-runtime.d.ts +2 -2
  86. package/dist/jsx-runtime.d.ts.map +1 -1
  87. package/dist/jsx-runtime.js.map +1 -1
  88. package/dist/jsx-runtime2.d.ts +3 -2
  89. package/dist/jsx-runtime2.js +3 -2
  90. package/dist/renderer/attributes.js +231 -0
  91. package/dist/renderer/attributes.js.map +1 -0
  92. package/dist/renderer/boundaries.js +266 -0
  93. package/dist/renderer/boundaries.js.map +1 -0
  94. package/dist/renderer/child-shape.js +85 -0
  95. package/dist/renderer/child-shape.js.map +1 -0
  96. package/dist/renderer/children.js +3 -2
  97. package/dist/renderer/children.js.map +1 -1
  98. package/dist/renderer/cleanup.js +2 -1
  99. package/dist/renderer/cleanup.js.map +1 -1
  100. package/dist/renderer/component-host-cleanup.js +68 -0
  101. package/dist/renderer/component-host-cleanup.js.map +1 -0
  102. package/dist/renderer/component-host-instances.js +65 -0
  103. package/dist/renderer/component-host-instances.js.map +1 -0
  104. package/dist/renderer/component-host.js +247 -0
  105. package/dist/renderer/component-host.js.map +1 -0
  106. package/dist/renderer/dom-host.js +13 -0
  107. package/dist/renderer/dom-host.js.map +1 -0
  108. package/dist/renderer/dom-internal.js +185 -0
  109. package/dist/renderer/dom-internal.js.map +1 -0
  110. package/dist/renderer/dom.js +9 -2356
  111. package/dist/renderer/element-children.js +279 -0
  112. package/dist/renderer/element-children.js.map +1 -0
  113. package/dist/renderer/env.js +2 -1
  114. package/dist/renderer/error-boundary-dom.js +29 -0
  115. package/dist/renderer/error-boundary-dom.js.map +1 -0
  116. package/dist/renderer/evaluate-dom-range.js +85 -0
  117. package/dist/renderer/evaluate-dom-range.js.map +1 -0
  118. package/dist/renderer/evaluate-reconcile.js +281 -0
  119. package/dist/renderer/evaluate-reconcile.js.map +1 -0
  120. package/dist/renderer/evaluate.js +13 -399
  121. package/dist/renderer/evaluate.js.map +1 -1
  122. package/dist/renderer/fastpath.js +6 -5
  123. package/dist/renderer/fastpath.js.map +1 -1
  124. package/dist/renderer/for-commit-dom-map.js +83 -0
  125. package/dist/renderer/for-commit-dom-map.js.map +1 -0
  126. package/dist/renderer/for-commit-removal.js +36 -0
  127. package/dist/renderer/for-commit-removal.js.map +1 -0
  128. package/dist/renderer/for-commit-reorder.js +89 -0
  129. package/dist/renderer/for-commit-reorder.js.map +1 -0
  130. package/dist/renderer/for-commit.js +6 -188
  131. package/dist/renderer/for-commit.js.map +1 -1
  132. package/dist/renderer/index.js +28 -16
  133. package/dist/renderer/index.js.map +1 -1
  134. package/dist/renderer/keyed-children.js +32 -0
  135. package/dist/renderer/keyed-children.js.map +1 -0
  136. package/dist/renderer/keyed.js +2 -15
  137. package/dist/renderer/keyed.js.map +1 -1
  138. package/dist/renderer/namespaces.js +23 -0
  139. package/dist/renderer/namespaces.js.map +1 -0
  140. package/dist/renderer/prop-bindings.js +280 -0
  141. package/dist/renderer/prop-bindings.js.map +1 -0
  142. package/dist/renderer/reactive-child-dom.js +133 -0
  143. package/dist/renderer/reactive-child-dom.js.map +1 -0
  144. package/dist/renderer/reactive-child-sources.js +184 -0
  145. package/dist/renderer/reactive-child-sources.js.map +1 -0
  146. package/dist/renderer/reactive-children.js +294 -0
  147. package/dist/renderer/reactive-children.js.map +1 -0
  148. package/dist/renderer/reconcile-commit.js +38 -0
  149. package/dist/renderer/reconcile-commit.js.map +1 -0
  150. package/dist/renderer/reconcile-fastpaths.js +106 -0
  151. package/dist/renderer/reconcile-fastpaths.js.map +1 -0
  152. package/dist/renderer/reconcile-resolution.js +187 -0
  153. package/dist/renderer/reconcile-resolution.js.map +1 -0
  154. package/dist/renderer/reconcile.js +9 -371
  155. package/dist/renderer/reconcile.js.map +1 -1
  156. package/dist/renderer/retained-element-rollback.js +276 -0
  157. package/dist/renderer/retained-element-rollback.js.map +1 -0
  158. package/dist/renderer/stable-patch.js +82 -0
  159. package/dist/renderer/stable-patch.js.map +1 -0
  160. package/dist/renderer/static-reuse.js +96 -0
  161. package/dist/renderer/static-reuse.js.map +1 -0
  162. package/dist/renderer/types.js +2 -1
  163. package/dist/renderer/utils.js +4 -4
  164. package/dist/renderer/utils.js.map +1 -1
  165. package/dist/resources/index.d.ts +3 -2
  166. package/dist/resources/index.js +5 -2
  167. package/dist/router/access.js +36 -0
  168. package/dist/router/access.js.map +1 -0
  169. package/dist/router/activity.d.ts +10 -0
  170. package/dist/router/activity.d.ts.map +1 -0
  171. package/dist/router/activity.js +89 -0
  172. package/dist/router/activity.js.map +1 -0
  173. package/dist/router/authoring.d.ts +22 -0
  174. package/dist/router/authoring.d.ts.map +1 -0
  175. package/dist/router/authoring.js +198 -0
  176. package/dist/router/authoring.js.map +1 -0
  177. package/dist/router/index.d.ts +12 -4
  178. package/dist/router/index.js +10 -3
  179. package/dist/router/internal-types.d.ts +31 -0
  180. package/dist/router/internal-types.d.ts.map +1 -0
  181. package/dist/router/lazy.d.ts +19 -0
  182. package/dist/router/lazy.d.ts.map +1 -0
  183. package/dist/router/lazy.js +52 -0
  184. package/dist/router/lazy.js.map +1 -0
  185. package/dist/router/manifest.d.ts +10 -0
  186. package/dist/router/manifest.d.ts.map +1 -0
  187. package/dist/router/manifest.js +49 -0
  188. package/dist/router/manifest.js.map +1 -0
  189. package/dist/router/navigate.d.ts +4 -51
  190. package/dist/router/navigate.d.ts.map +1 -1
  191. package/dist/router/navigate.js +16 -459
  192. package/dist/router/navigate.js.map +1 -1
  193. package/dist/router/navigation-registry.d.ts +32 -0
  194. package/dist/router/navigation-registry.d.ts.map +1 -0
  195. package/dist/router/navigation-registry.js +105 -0
  196. package/dist/router/navigation-registry.js.map +1 -0
  197. package/dist/router/navigation-scroll.d.ts +14 -0
  198. package/dist/router/navigation-scroll.d.ts.map +1 -0
  199. package/dist/router/navigation-scroll.js +93 -0
  200. package/dist/router/navigation-scroll.js.map +1 -0
  201. package/dist/router/navigation-targets.d.ts +31 -0
  202. package/dist/router/navigation-targets.d.ts.map +1 -0
  203. package/dist/router/navigation-targets.js +253 -0
  204. package/dist/router/navigation-targets.js.map +1 -0
  205. package/dist/router/policy.d.ts +7 -1
  206. package/dist/router/policy.d.ts.map +1 -1
  207. package/dist/router/policy.js +27 -9
  208. package/dist/router/policy.js.map +1 -1
  209. package/dist/router/rendering.d.ts +10 -0
  210. package/dist/router/rendering.d.ts.map +1 -0
  211. package/dist/router/rendering.js +45 -0
  212. package/dist/router/rendering.js.map +1 -0
  213. package/dist/router/resolution.d.ts +17 -0
  214. package/dist/router/resolution.d.ts.map +1 -0
  215. package/dist/router/resolution.js +253 -0
  216. package/dist/router/resolution.js.map +1 -0
  217. package/dist/router/route-query.d.ts +17 -0
  218. package/dist/router/route-query.d.ts.map +1 -0
  219. package/dist/router/route-query.js +47 -0
  220. package/dist/router/route-query.js.map +1 -0
  221. package/dist/router/route.d.ts +8 -149
  222. package/dist/router/route.js +8 -854
  223. package/dist/router/store.d.ts +50 -0
  224. package/dist/router/store.d.ts.map +1 -0
  225. package/dist/router/store.js +171 -0
  226. package/dist/router/store.js.map +1 -0
  227. package/dist/runtime/access.js +45 -0
  228. package/dist/runtime/access.js.map +1 -0
  229. package/dist/runtime/child-scope.d.ts +1 -1
  230. package/dist/runtime/child-scope.js +4 -1
  231. package/dist/runtime/child-scope.js.map +1 -1
  232. package/dist/runtime/component-cleanup.d.ts +16 -0
  233. package/dist/runtime/component-cleanup.d.ts.map +1 -0
  234. package/dist/runtime/component-cleanup.js +70 -0
  235. package/dist/runtime/component-cleanup.js.map +1 -0
  236. package/dist/runtime/component-commit.js +165 -0
  237. package/dist/runtime/component-commit.js.map +1 -0
  238. package/dist/runtime/component-contracts.js +5 -0
  239. package/dist/runtime/component-facade.d.ts +5 -0
  240. package/dist/runtime/component-facade.js +4 -0
  241. package/dist/runtime/component-internal.d.ts +100 -0
  242. package/dist/runtime/component-internal.d.ts.map +1 -0
  243. package/dist/runtime/component-internal.js +219 -0
  244. package/dist/runtime/component-internal.js.map +1 -0
  245. package/dist/runtime/component-lifecycle.d.ts +49 -0
  246. package/dist/runtime/component-lifecycle.d.ts.map +1 -0
  247. package/dist/runtime/component-lifecycle.js +176 -0
  248. package/dist/runtime/component-lifecycle.js.map +1 -0
  249. package/dist/runtime/component-scope.d.ts +55 -0
  250. package/dist/runtime/component-scope.d.ts.map +1 -0
  251. package/dist/runtime/component-scope.js +154 -0
  252. package/dist/runtime/component-scope.js.map +1 -0
  253. package/dist/runtime/component.d.ts +4 -152
  254. package/dist/runtime/component.js +4 -692
  255. package/dist/runtime/context.d.ts +1 -1
  256. package/dist/runtime/context.js +6 -4
  257. package/dist/runtime/context.js.map +1 -1
  258. package/dist/runtime/control.d.ts +3 -3
  259. package/dist/runtime/control.js +2 -1
  260. package/dist/runtime/control.js.map +1 -1
  261. package/dist/runtime/derive.d.ts.map +1 -1
  262. package/dist/runtime/derive.js +6 -5
  263. package/dist/runtime/derive.js.map +1 -1
  264. package/dist/runtime/effect.d.ts +1 -1
  265. package/dist/runtime/effect.d.ts.map +1 -1
  266. package/dist/runtime/effect.js +2 -2
  267. package/dist/runtime/effect.js.map +1 -1
  268. package/dist/runtime/events.js +3 -3
  269. package/dist/runtime/events.js.map +1 -1
  270. package/dist/runtime/fastlane.js +13 -27
  271. package/dist/runtime/fastlane.js.map +1 -1
  272. package/dist/runtime/for-bench.d.ts +1 -1
  273. package/dist/runtime/for-bench.js +1 -4
  274. package/dist/runtime/for-bench.js.map +1 -1
  275. package/dist/runtime/for-internal.d.ts +43 -0
  276. package/dist/runtime/for-internal.d.ts.map +1 -0
  277. package/dist/runtime/for-internal.js +98 -0
  278. package/dist/runtime/for-internal.js.map +1 -0
  279. package/dist/runtime/for-reconcile.d.ts +8 -0
  280. package/dist/runtime/for-reconcile.d.ts.map +1 -0
  281. package/dist/runtime/for-reconcile.js +389 -0
  282. package/dist/runtime/for-reconcile.js.map +1 -0
  283. package/dist/runtime/for-scopes.d.ts +26 -0
  284. package/dist/runtime/for-scopes.d.ts.map +1 -0
  285. package/dist/runtime/for-scopes.js +160 -0
  286. package/dist/runtime/for-scopes.js.map +1 -0
  287. package/dist/runtime/for-signals.d.ts +30 -0
  288. package/dist/runtime/for-signals.d.ts.map +1 -0
  289. package/dist/runtime/for-signals.js +139 -0
  290. package/dist/runtime/for-signals.js.map +1 -0
  291. package/dist/runtime/for.d.ts +4 -66
  292. package/dist/runtime/for.js +5 -773
  293. package/dist/runtime/lifecycle-operations.d.ts +31 -0
  294. package/dist/runtime/lifecycle-operations.d.ts.map +1 -0
  295. package/dist/runtime/lifecycle-operations.js +195 -0
  296. package/dist/runtime/lifecycle-operations.js.map +1 -0
  297. package/dist/runtime/operations.d.ts +3 -40
  298. package/dist/runtime/operations.js +2 -357
  299. package/dist/runtime/readable.d.ts +2 -3
  300. package/dist/runtime/readable.d.ts.map +1 -1
  301. package/dist/runtime/readable.js +6 -5
  302. package/dist/runtime/readable.js.map +1 -1
  303. package/dist/runtime/resource-cell.js +2 -2
  304. package/dist/runtime/resource-cell.js.map +1 -1
  305. package/dist/runtime/resource-operation.d.ts +13 -0
  306. package/dist/runtime/resource-operation.d.ts.map +1 -0
  307. package/dist/runtime/resource-operation.js +170 -0
  308. package/dist/runtime/resource-operation.js.map +1 -0
  309. package/dist/runtime/runtime.d.ts +42 -0
  310. package/dist/runtime/runtime.d.ts.map +1 -0
  311. package/dist/runtime/runtime.js +59 -0
  312. package/dist/runtime/runtime.js.map +1 -0
  313. package/dist/runtime/scheduler.d.ts +5 -1
  314. package/dist/runtime/scheduler.d.ts.map +1 -1
  315. package/dist/runtime/scheduler.js +17 -17
  316. package/dist/runtime/scheduler.js.map +1 -1
  317. package/dist/runtime/selector.js +4 -3
  318. package/dist/runtime/selector.js.map +1 -1
  319. package/dist/runtime/snapshot-source.d.ts +1 -1
  320. package/dist/runtime/snapshot-source.js +1 -1
  321. package/dist/runtime/state.js +2 -1
  322. package/dist/runtime/state.js.map +1 -1
  323. package/dist/ssg/batch-render.js +2 -1
  324. package/dist/ssg/batch-render.js.map +1 -1
  325. package/dist/ssg/create-static-gen.d.ts +9 -3
  326. package/dist/ssg/create-static-gen.d.ts.map +1 -1
  327. package/dist/ssg/create-static-gen.js +12 -99
  328. package/dist/ssg/create-static-gen.js.map +1 -1
  329. package/dist/ssg/generation-plan.js +70 -0
  330. package/dist/ssg/generation-plan.js.map +1 -0
  331. package/dist/ssg/incremental-manifest.js +1 -1
  332. package/dist/ssg/static-routes.js +101 -0
  333. package/dist/ssg/static-routes.js.map +1 -0
  334. package/dist/ssg/types.d.ts +15 -7
  335. package/dist/ssg/types.d.ts.map +1 -1
  336. package/dist/ssr/boundaries.js +113 -0
  337. package/dist/ssr/boundaries.js.map +1 -0
  338. package/dist/ssr/component-runtime.js +111 -0
  339. package/dist/ssr/component-runtime.js.map +1 -0
  340. package/dist/ssr/context.d.ts +3 -1
  341. package/dist/ssr/context.d.ts.map +1 -1
  342. package/dist/ssr/context.js +9 -2
  343. package/dist/ssr/context.js.map +1 -1
  344. package/dist/ssr/errors.d.ts +2 -0
  345. package/dist/ssr/errors.js +11 -1
  346. package/dist/ssr/errors.js.map +1 -1
  347. package/dist/ssr/escape.js +3 -3
  348. package/dist/ssr/escape.js.map +1 -1
  349. package/dist/ssr/hydration-data.js +10 -0
  350. package/dist/ssr/hydration-data.js.map +1 -0
  351. package/dist/ssr/hydration-verify.d.ts +12 -0
  352. package/dist/ssr/hydration-verify.d.ts.map +1 -0
  353. package/dist/ssr/hydration-verify.js +144 -0
  354. package/dist/ssr/hydration-verify.js.map +1 -0
  355. package/dist/ssr/index-internal.d.ts +15 -0
  356. package/dist/ssr/index-internal.d.ts.map +1 -0
  357. package/dist/ssr/index-internal.js +19 -0
  358. package/dist/ssr/index-internal.js.map +1 -0
  359. package/dist/ssr/index.d.ts +5 -57
  360. package/dist/ssr/index.js +3 -738
  361. package/dist/ssr/render-keys.js +9 -32
  362. package/dist/ssr/render-keys.js.map +1 -1
  363. package/dist/ssr/render-resolved.d.ts +1 -1
  364. package/dist/ssr/render-resolved.d.ts.map +1 -1
  365. package/dist/ssr/render-resolved.js +4 -2
  366. package/dist/ssr/render-resolved.js.map +1 -1
  367. package/dist/ssr/render-sync.d.ts +21 -0
  368. package/dist/ssr/render-sync.d.ts.map +1 -0
  369. package/dist/ssr/render-sync.js +275 -0
  370. package/dist/ssr/render-sync.js.map +1 -0
  371. package/dist/ssr/route-policy-resolution.js +77 -0
  372. package/dist/ssr/route-policy-resolution.js.map +1 -0
  373. package/dist/ssr/route-render.d.ts +77 -0
  374. package/dist/ssr/route-render.d.ts.map +1 -0
  375. package/dist/ssr/route-render.js +119 -0
  376. package/dist/ssr/route-render.js.map +1 -0
  377. package/dist/ssr/sink.d.ts +26 -0
  378. package/dist/ssr/sink.d.ts.map +1 -0
  379. package/dist/ssr/types.d.ts +1 -0
  380. package/dist/ssr/types.d.ts.map +1 -1
  381. package/dist/ssr/verify-hydration.js.map +1 -1
  382. package/dist/testing/index.d.ts +1 -2
  383. package/dist/testing/index.d.ts.map +1 -1
  384. package/dist/testing/index.js +2 -1
  385. package/dist/testing/index.js.map +1 -1
  386. package/package.json +4 -3
  387. package/dist/data/index.d.ts.map +0 -1
  388. package/dist/data/index.js.map +0 -1
  389. package/dist/renderer/dom.js.map +0 -1
  390. package/dist/router/route.d.ts.map +0 -1
  391. package/dist/router/route.js.map +0 -1
  392. package/dist/runtime/component.d.ts.map +0 -1
  393. package/dist/runtime/component.js.map +0 -1
  394. package/dist/runtime/for.d.ts.map +0 -1
  395. package/dist/runtime/for.js.map +0 -1
  396. package/dist/runtime/operations.d.ts.map +0 -1
  397. package/dist/runtime/operations.js.map +0 -1
  398. package/dist/runtime/ssr-bridge.js +0 -24
  399. package/dist/runtime/ssr-bridge.js.map +0 -1
  400. package/dist/ssr/index.d.ts.map +0 -1
  401. package/dist/ssr/index.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ import { LayoutScopeRecord, PageScopeRecord, Route, RouteAuthOptions, RouteDefinition, RoutePolicy } from "../common/router.js";
2
+ import { AccessScopeState, InternalRoute, InternalRouteRecord, RegistrationScope, RegistrationSession } from "./internal-types.js";
3
+
4
+ //#region src/router/store.d.ts
5
+ type RouteStateSnapshot = {
6
+ routes: InternalRoute[];
7
+ records: InternalRouteRecord[];
8
+ namespaces: string[];
9
+ registrationLocked: boolean;
10
+ defaultRouteAuthOptions: RouteAuthOptions | undefined;
11
+ activeClientRouteAuthOptions: RouteAuthOptions | undefined;
12
+ routesByDepth: Array<[number, Route[]]>;
13
+ registrationScopeStack: RegistrationScope[];
14
+ registrationSessionStack: RegistrationSession[];
15
+ };
16
+ declare function getRouteRecords(): readonly InternalRouteRecord[];
17
+ declare function isRouteStoreRoutes(routeList: readonly Route[]): boolean;
18
+ declare function insertRecordSorted(record: InternalRouteRecord): void;
19
+ declare function addRouteToStores(routeObj: InternalRoute): void;
20
+ declare function getActiveRoutes(): readonly Route[];
21
+ declare function getActiveRouteAuthOptions(override?: RouteAuthOptions): RouteAuthOptions | undefined;
22
+ declare function _setActiveRouteAuthOptions(auth: RouteAuthOptions | undefined): void;
23
+ declare function getDefaultRouteAuthOptions(): RouteAuthOptions | undefined;
24
+ declare function setDefaultRouteAuthOptions(auth: RouteAuthOptions | undefined): void;
25
+ declare function getCurrentRegistrationSession(): RegistrationSession;
26
+ declare function getCurrentAccessScopeState(): AccessScopeState;
27
+ declare function getCurrentLayoutChain(): LayoutScopeRecord[];
28
+ declare function getCurrentPageChain(): PageScopeRecord[];
29
+ declare function hasActivePageScope(): boolean;
30
+ declare function getCurrentPageScope(): RegistrationScope | null;
31
+ declare function getCurrentScopeKind(): RegistrationScope['kind'] | null;
32
+ declare function getCurrentPathPrefix(): string;
33
+ declare function getCurrentInheritedPolicies(): RoutePolicy[];
34
+ declare function pushRegistrationScope(scope: RegistrationScope, fn: RouteDefinition): void;
35
+ declare function pushRegistrationSession(session: RegistrationSession, fn: RouteDefinition): void;
36
+ declare function lockRouteRegistration(): void;
37
+ declare function _lockRouteRegistrationForTests(): void;
38
+ declare function _unlockRouteRegistrationForTests(): void;
39
+ declare function assertRouteRegistrationUnlocked(): void;
40
+ declare function getRoutes(): Route[];
41
+ declare function hasRegisteredRoutes(): boolean;
42
+ declare function getNamespaceRoutes(namespace: string): Route[];
43
+ declare function unloadNamespace(namespace: string): number;
44
+ declare function getLoadedNamespaces(): string[];
45
+ declare function clearRouteState(): void;
46
+ declare function snapshotRouteState(): RouteStateSnapshot;
47
+ declare function restoreRouteState(snapshot: RouteStateSnapshot): void;
48
+ //#endregion
49
+ export { getRoutes };
50
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","names":[],"sources":["../../src/router/store.ts"],"mappings":";;;;KA6BK,kBAAA;EACH,MAAA,EAAQ,aAAA;EACR,OAAA,EAAS,mBAAA;EACT,UAAA;EACA,kBAAA;EACA,uBAAA,EAAyB,gBAAA;EACzB,4BAAA,EAA8B,gBAAA;EAC9B,aAAA,EAAe,KAAA,UAAe,KAAA;EAC9B,sBAAA,EAAwB,iBAAA;EACxB,wBAAA,EAA0B,mBAAA;AAAA;AAAA,iBASZ,eAAA,aAA4B,mBAAmB;AAAA,iBAI/C,kBAAA,CAAmB,SAA2B,WAAP,KAAK;AAAA,iBAI5C,kBAAA,CAAmB,MAA2B,EAAnB,mBAAmB;AAAA,iBAW9C,gBAAA,CAAiB,QAAuB,EAAb,aAAa;AAAA,iBAgBxC,eAAA,aAA4B,KAAK;AAAA,iBAKjC,yBAAA,CACd,QAAA,GAAW,gBAAA,GACV,gBAAgB;AAAA,iBAaH,0BAAA,CACd,IAAkC,EAA5B,gBAAgB;AAAA,iBAKR,0BAAA,IAA8B,gBAAgB;AAAA,iBAI9C,0BAAA,CACd,IAAkC,EAA5B,gBAAgB;AAAA,iBAKR,6BAAA,IAAiC,mBAAmB;AAAA,iBAQpD,0BAAA,IAA8B,gBAAgB;AAAA,iBAS9C,qBAAA,IAAyB,iBAAiB;AAAA,iBAY1C,mBAAA,IAAuB,eAAe;AAAA,iBAYtC,kBAAA;AAAA,iBAIA,mBAAA,IAAuB,iBAAiB;AAAA,iBAWxC,mBAAA,IAAuB,iBAAiB;AAAA,iBAMxC,oBAAA;AAAA,iBAMA,2BAAA,IAA+B,WAAW;AAAA,iBAY1C,qBAAA,CACd,KAAA,EAAO,iBAAA,EACP,EAAA,EAAI,eAAe;AAAA,iBAUL,uBAAA,CACd,OAAA,EAAS,mBAAA,EACT,EAAA,EAAI,eAAe;AAAA,iBAUL,qBAAA;AAAA,iBAIA,8BAAA;AAAA,iBAIA,gCAAA;AAAA,iBAIA,+BAAA;AAAA,iBASA,SAAA,IAAa,KAAK;AAAA,iBAIlB,mBAAA;AAAA,iBAIA,kBAAA,CAAmB,SAAA,WAAoB,KAAK;AAAA,iBAI5C,eAAA,CAAgB,SAAiB;AAAA,iBA2BjC,mBAAA;AAAA,iBAIA,eAAA;AAAA,iBAYA,kBAAA,IAAsB,kBAAkB;AAAA,iBAiBxC,iBAAA,CAAkB,QAA4B,EAAlB,kBAAkB"}
@@ -0,0 +1,171 @@
1
+ import { getActiveRenderContext } from "../common/render-context.js";
2
+ //#region src/router/store.ts
3
+ const routes = [];
4
+ const records = [];
5
+ const namespaces = /* @__PURE__ */ new Set();
6
+ const routesByDepth = /* @__PURE__ */ new Map();
7
+ const registrationScopeStack = [];
8
+ const registrationSessionStack = [];
9
+ let registrationLocked = false;
10
+ let defaultRouteAuthOptions;
11
+ let activeClientRouteAuthOptions;
12
+ function getDepth(path) {
13
+ const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
14
+ return normalized === "/" ? 0 : normalized.split("/").filter(Boolean).length;
15
+ }
16
+ function getRouteRecords() {
17
+ return records;
18
+ }
19
+ function isRouteStoreRoutes(routeList) {
20
+ return routeList === routes;
21
+ }
22
+ function insertRecordSorted(record) {
23
+ let lo = 0;
24
+ let hi = records.length;
25
+ while (lo < hi) {
26
+ const mid = lo + hi >>> 1;
27
+ if (records[mid].rank >= record.rank) lo = mid + 1;
28
+ else hi = mid;
29
+ }
30
+ records.splice(lo, 0, record);
31
+ }
32
+ function addRouteToStores(routeObj) {
33
+ routes.push(routeObj);
34
+ const depth = getDepth(routeObj.path);
35
+ let depthRoutes = routesByDepth.get(depth);
36
+ if (!depthRoutes) {
37
+ depthRoutes = [];
38
+ routesByDepth.set(depth, depthRoutes);
39
+ }
40
+ depthRoutes.push(routeObj);
41
+ if (routeObj.namespace) namespaces.add(routeObj.namespace);
42
+ }
43
+ function getActiveRoutes() {
44
+ return getActiveRenderContext()?.routes ?? routes;
45
+ }
46
+ function getActiveRouteAuthOptions(override) {
47
+ if (override) return override;
48
+ return getActiveRenderContext()?.routeAuth ?? activeClientRouteAuthOptions ?? defaultRouteAuthOptions;
49
+ }
50
+ function _setActiveRouteAuthOptions(auth) {
51
+ activeClientRouteAuthOptions = auth;
52
+ }
53
+ function getDefaultRouteAuthOptions() {
54
+ return defaultRouteAuthOptions;
55
+ }
56
+ function setDefaultRouteAuthOptions(auth) {
57
+ defaultRouteAuthOptions = auth;
58
+ }
59
+ function getCurrentRegistrationSession() {
60
+ return registrationSessionStack[registrationSessionStack.length - 1] ?? { authConfigured: !!defaultRouteAuthOptions?.resolve };
61
+ }
62
+ function getCurrentAccessScopeState() {
63
+ return registrationScopeStack[registrationScopeStack.length - 1]?.state ?? {
64
+ guestOnly: false,
65
+ authenticated: false
66
+ };
67
+ }
68
+ function getCurrentLayoutChain() {
69
+ const layoutChain = [];
70
+ for (const scope of registrationScopeStack) if (scope.layout) layoutChain.push({ component: scope.layout });
71
+ return layoutChain;
72
+ }
73
+ function getCurrentPageChain() {
74
+ const pageChain = [];
75
+ for (const scope of registrationScopeStack) if (scope.page) pageChain.push({ component: scope.page });
76
+ return pageChain;
77
+ }
78
+ function hasActivePageScope() {
79
+ return registrationScopeStack.some((scope) => !!scope.page);
80
+ }
81
+ function getCurrentPageScope() {
82
+ for (let index = registrationScopeStack.length - 1; index >= 0; index -= 1) {
83
+ const scope = registrationScopeStack[index];
84
+ if (scope.kind === "page") return scope;
85
+ }
86
+ return null;
87
+ }
88
+ function getCurrentScopeKind() {
89
+ return registrationScopeStack[registrationScopeStack.length - 1]?.kind ?? null;
90
+ }
91
+ function getCurrentPathPrefix() {
92
+ return registrationScopeStack[registrationScopeStack.length - 1]?.pathPrefix ?? "";
93
+ }
94
+ function getCurrentInheritedPolicies() {
95
+ const policies = [];
96
+ for (const scope of registrationScopeStack) if (scope.policies.length > 0) policies.push(...scope.policies);
97
+ return policies;
98
+ }
99
+ function pushRegistrationScope(scope, fn) {
100
+ registrationScopeStack.push(scope);
101
+ try {
102
+ fn();
103
+ } finally {
104
+ registrationScopeStack.pop();
105
+ }
106
+ }
107
+ function pushRegistrationSession(session, fn) {
108
+ registrationSessionStack.push(session);
109
+ try {
110
+ fn();
111
+ } finally {
112
+ registrationSessionStack.pop();
113
+ }
114
+ }
115
+ function lockRouteRegistration() {
116
+ registrationLocked = true;
117
+ }
118
+ function assertRouteRegistrationUnlocked() {
119
+ if (registrationLocked) throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");
120
+ }
121
+ function getRoutes() {
122
+ return [...routes];
123
+ }
124
+ function hasRegisteredRoutes() {
125
+ return routes.length > 0 || records.length > 0;
126
+ }
127
+ function clearRouteState() {
128
+ routes.length = 0;
129
+ records.length = 0;
130
+ namespaces.clear();
131
+ routesByDepth.clear();
132
+ registrationScopeStack.length = 0;
133
+ registrationSessionStack.length = 0;
134
+ registrationLocked = false;
135
+ defaultRouteAuthOptions = void 0;
136
+ activeClientRouteAuthOptions = void 0;
137
+ }
138
+ function snapshotRouteState() {
139
+ return {
140
+ routes: [...routes],
141
+ records: [...records],
142
+ namespaces: [...namespaces],
143
+ registrationLocked,
144
+ defaultRouteAuthOptions,
145
+ activeClientRouteAuthOptions,
146
+ routesByDepth: [...routesByDepth.entries()].map(([depth, depthRoutes]) => [depth, [...depthRoutes]]),
147
+ registrationScopeStack: [...registrationScopeStack],
148
+ registrationSessionStack: [...registrationSessionStack]
149
+ };
150
+ }
151
+ function restoreRouteState(snapshot) {
152
+ routes.length = 0;
153
+ routes.push(...snapshot.routes);
154
+ records.length = 0;
155
+ records.push(...snapshot.records);
156
+ namespaces.clear();
157
+ for (const namespace of snapshot.namespaces) namespaces.add(namespace);
158
+ routesByDepth.clear();
159
+ for (const [depth, depthRoutes] of snapshot.routesByDepth) routesByDepth.set(depth, [...depthRoutes]);
160
+ registrationScopeStack.length = 0;
161
+ registrationScopeStack.push(...snapshot.registrationScopeStack);
162
+ registrationSessionStack.length = 0;
163
+ registrationSessionStack.push(...snapshot.registrationSessionStack);
164
+ registrationLocked = snapshot.registrationLocked;
165
+ defaultRouteAuthOptions = snapshot.defaultRouteAuthOptions;
166
+ activeClientRouteAuthOptions = snapshot.activeClientRouteAuthOptions;
167
+ }
168
+ //#endregion
169
+ export { _setActiveRouteAuthOptions, addRouteToStores, assertRouteRegistrationUnlocked, clearRouteState, getActiveRouteAuthOptions, getActiveRoutes, getCurrentAccessScopeState, getCurrentInheritedPolicies, getCurrentLayoutChain, getCurrentPageChain, getCurrentPageScope, getCurrentPathPrefix, getCurrentRegistrationSession, getCurrentScopeKind, getDefaultRouteAuthOptions, getRouteRecords, getRoutes, hasActivePageScope, hasRegisteredRoutes, insertRecordSorted, isRouteStoreRoutes, lockRouteRegistration, pushRegistrationScope, pushRegistrationSession, restoreRouteState, setDefaultRouteAuthOptions, snapshotRouteState };
170
+
171
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","names":[],"sources":["../../src/router/store.ts"],"sourcesContent":["import type {\n LayoutScopeRecord,\n PageScopeRecord,\n Route,\n RouteAuthOptions,\n RouteDefinition,\n RoutePolicy,\n} from '../common/router';\nimport { getActiveRenderContext } from '../common/render-context';\nimport type {\n AccessScopeState,\n InternalRoute,\n InternalRouteRecord,\n RegistrationScope,\n RegistrationSession,\n} from './internal-types';\n\nconst routes: InternalRoute[] = [];\nconst records: InternalRouteRecord[] = [];\nconst namespaces = new Set<string>();\nconst routesByDepth = new Map<number, Route[]>();\n\nconst registrationScopeStack: RegistrationScope[] = [];\nconst registrationSessionStack: RegistrationSession[] = [];\n\nlet registrationLocked = false;\nlet defaultRouteAuthOptions: RouteAuthOptions | undefined;\nlet activeClientRouteAuthOptions: RouteAuthOptions | undefined;\n\ntype RouteStateSnapshot = {\n routes: InternalRoute[];\n records: InternalRouteRecord[];\n namespaces: string[];\n registrationLocked: boolean;\n defaultRouteAuthOptions: RouteAuthOptions | undefined;\n activeClientRouteAuthOptions: RouteAuthOptions | undefined;\n routesByDepth: Array<[number, Route[]]>;\n registrationScopeStack: RegistrationScope[];\n registrationSessionStack: RegistrationSession[];\n};\n\nfunction getDepth(path: string): number {\n const normalized =\n path.endsWith('/') && path !== '/' ? path.slice(0, -1) : path;\n return normalized === '/' ? 0 : normalized.split('/').filter(Boolean).length;\n}\n\nexport function getRouteRecords(): readonly InternalRouteRecord[] {\n return records;\n}\n\nexport function isRouteStoreRoutes(routeList: readonly Route[]): boolean {\n return routeList === routes;\n}\n\nexport function insertRecordSorted(record: InternalRouteRecord): void {\n let lo = 0;\n let hi = records.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (records[mid].rank >= record.rank) lo = mid + 1;\n else hi = mid;\n }\n records.splice(lo, 0, record);\n}\n\nexport function addRouteToStores(routeObj: InternalRoute): void {\n routes.push(routeObj);\n\n const depth = getDepth(routeObj.path);\n let depthRoutes = routesByDepth.get(depth);\n if (!depthRoutes) {\n depthRoutes = [];\n routesByDepth.set(depth, depthRoutes);\n }\n depthRoutes.push(routeObj);\n\n if (routeObj.namespace) {\n namespaces.add(routeObj.namespace);\n }\n}\n\nexport function getActiveRoutes(): readonly Route[] {\n const renderContext = getActiveRenderContext();\n return renderContext?.routes ?? routes;\n}\n\nexport function getActiveRouteAuthOptions(\n override?: RouteAuthOptions\n): RouteAuthOptions | undefined {\n if (override) {\n return override;\n }\n\n const renderContext = getActiveRenderContext();\n return (\n renderContext?.routeAuth ??\n activeClientRouteAuthOptions ??\n defaultRouteAuthOptions\n );\n}\n\nexport function _setActiveRouteAuthOptions(\n auth: RouteAuthOptions | undefined\n): void {\n activeClientRouteAuthOptions = auth;\n}\n\nexport function getDefaultRouteAuthOptions(): RouteAuthOptions | undefined {\n return defaultRouteAuthOptions;\n}\n\nexport function setDefaultRouteAuthOptions(\n auth: RouteAuthOptions | undefined\n): void {\n defaultRouteAuthOptions = auth;\n}\n\nexport function getCurrentRegistrationSession(): RegistrationSession {\n return (\n registrationSessionStack[registrationSessionStack.length - 1] ?? {\n authConfigured: !!defaultRouteAuthOptions?.resolve,\n }\n );\n}\n\nexport function getCurrentAccessScopeState(): AccessScopeState {\n return (\n registrationScopeStack[registrationScopeStack.length - 1]?.state ?? {\n guestOnly: false,\n authenticated: false,\n }\n );\n}\n\nexport function getCurrentLayoutChain(): LayoutScopeRecord[] {\n const layoutChain: LayoutScopeRecord[] = [];\n\n for (const scope of registrationScopeStack) {\n if (scope.layout) {\n layoutChain.push({ component: scope.layout });\n }\n }\n\n return layoutChain;\n}\n\nexport function getCurrentPageChain(): PageScopeRecord[] {\n const pageChain: PageScopeRecord[] = [];\n\n for (const scope of registrationScopeStack) {\n if (scope.page) {\n pageChain.push({ component: scope.page });\n }\n }\n\n return pageChain;\n}\n\nexport function hasActivePageScope(): boolean {\n return registrationScopeStack.some((scope) => !!scope.page);\n}\n\nexport function getCurrentPageScope(): RegistrationScope | null {\n for (let index = registrationScopeStack.length - 1; index >= 0; index -= 1) {\n const scope = registrationScopeStack[index];\n if (scope.kind === 'page') {\n return scope;\n }\n }\n\n return null;\n}\n\nexport function getCurrentScopeKind(): RegistrationScope['kind'] | null {\n return (\n registrationScopeStack[registrationScopeStack.length - 1]?.kind ?? null\n );\n}\n\nexport function getCurrentPathPrefix(): string {\n return (\n registrationScopeStack[registrationScopeStack.length - 1]?.pathPrefix ?? ''\n );\n}\n\nexport function getCurrentInheritedPolicies(): RoutePolicy[] {\n const policies: RoutePolicy[] = [];\n\n for (const scope of registrationScopeStack) {\n if (scope.policies.length > 0) {\n policies.push(...scope.policies);\n }\n }\n\n return policies;\n}\n\nexport function pushRegistrationScope(\n scope: RegistrationScope,\n fn: RouteDefinition\n): void {\n registrationScopeStack.push(scope);\n try {\n fn();\n } finally {\n registrationScopeStack.pop();\n }\n}\n\nexport function pushRegistrationSession(\n session: RegistrationSession,\n fn: RouteDefinition\n): void {\n registrationSessionStack.push(session);\n try {\n fn();\n } finally {\n registrationSessionStack.pop();\n }\n}\n\nexport function lockRouteRegistration(): void {\n registrationLocked = true;\n}\n\nexport function _lockRouteRegistrationForTests(): void {\n registrationLocked = true;\n}\n\nexport function _unlockRouteRegistrationForTests(): void {\n registrationLocked = false;\n}\n\nexport function assertRouteRegistrationUnlocked(): void {\n if (registrationLocked) {\n throw new Error(\n 'Route registration is locked after app startup. ' +\n 'Register routes at module load time before calling createSPA or createSSR.'\n );\n }\n}\n\nexport function getRoutes(): Route[] {\n return [...routes];\n}\n\nexport function hasRegisteredRoutes(): boolean {\n return routes.length > 0 || records.length > 0;\n}\n\nexport function getNamespaceRoutes(namespace: string): Route[] {\n return routes.filter((route) => route.namespace === namespace);\n}\n\nexport function unloadNamespace(namespace: string): number {\n const before = routes.length;\n\n for (let i = routes.length - 1; i >= 0; i--) {\n if (routes[i].namespace === namespace) {\n const removed = routes[i];\n routes.splice(i, 1);\n\n const depth = getDepth(removed.path);\n const depthRoutes = routesByDepth.get(depth);\n if (depthRoutes) {\n const idx = depthRoutes.indexOf(removed);\n if (idx >= 0) depthRoutes.splice(idx, 1);\n }\n }\n }\n\n for (let i = records.length - 1; i >= 0; i--) {\n if (records[i].options.namespace === namespace) {\n records.splice(i, 1);\n }\n }\n\n namespaces.delete(namespace);\n return before - routes.length;\n}\n\nexport function getLoadedNamespaces(): string[] {\n return Array.from(namespaces);\n}\n\nexport function clearRouteState(): void {\n routes.length = 0;\n records.length = 0;\n namespaces.clear();\n routesByDepth.clear();\n registrationScopeStack.length = 0;\n registrationSessionStack.length = 0;\n registrationLocked = false;\n defaultRouteAuthOptions = undefined;\n activeClientRouteAuthOptions = undefined;\n}\n\nexport function snapshotRouteState(): RouteStateSnapshot {\n return {\n routes: [...routes],\n records: [...records],\n namespaces: [...namespaces],\n registrationLocked,\n defaultRouteAuthOptions,\n activeClientRouteAuthOptions,\n routesByDepth: [...routesByDepth.entries()].map(([depth, depthRoutes]) => [\n depth,\n [...depthRoutes],\n ]),\n registrationScopeStack: [...registrationScopeStack],\n registrationSessionStack: [...registrationSessionStack],\n };\n}\n\nexport function restoreRouteState(snapshot: RouteStateSnapshot): void {\n routes.length = 0;\n routes.push(...snapshot.routes);\n\n records.length = 0;\n records.push(...snapshot.records);\n\n namespaces.clear();\n for (const namespace of snapshot.namespaces) {\n namespaces.add(namespace);\n }\n\n routesByDepth.clear();\n for (const [depth, depthRoutes] of snapshot.routesByDepth) {\n routesByDepth.set(depth, [...depthRoutes]);\n }\n\n registrationScopeStack.length = 0;\n registrationScopeStack.push(...snapshot.registrationScopeStack);\n\n registrationSessionStack.length = 0;\n registrationSessionStack.push(...snapshot.registrationSessionStack);\n\n registrationLocked = snapshot.registrationLocked;\n defaultRouteAuthOptions = snapshot.defaultRouteAuthOptions;\n activeClientRouteAuthOptions = snapshot.activeClientRouteAuthOptions;\n}\n"],"mappings":";;AAiBA,MAAM,SAA0B,CAAC;AACjC,MAAM,UAAiC,CAAC;AACxC,MAAM,6BAAa,IAAI,IAAY;AACnC,MAAM,gCAAgB,IAAI,IAAqB;AAE/C,MAAM,yBAA8C,CAAC;AACrD,MAAM,2BAAkD,CAAC;AAEzD,IAAI,qBAAqB;AACzB,IAAI;AACJ,IAAI;AAcJ,SAAS,SAAS,MAAsB;CACtC,MAAM,aACJ,KAAK,SAAS,GAAG,KAAK,SAAS,MAAM,KAAK,MAAM,GAAG,EAAE,IAAI;CAC3D,OAAO,eAAe,MAAM,IAAI,WAAW,MAAM,GAAG,CAAC,CAAC,OAAO,OA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() {
4
+ return getDefaultRuntime().scheduler;
5
+ }
6
+ function getDefaultRuntimeInstance() {
7
+ return getDefaultRuntime();
8
+ }
9
+ function getRuntimeRenderer() {
10
+ return getDefaultRuntime().renderer;
11
+ }
12
+ function enqueueRuntimeTask(task) {
13
+ getRuntimeScheduler().enqueue(task);
14
+ }
15
+ function enqueueRuntimeLane(lane, task) {
16
+ getRuntimeScheduler().enqueueInLane(lane, task);
17
+ }
18
+ function runRuntimeHandlerScope(fn, flushMode = "defer") {
19
+ return getRuntimeScheduler().runInHandlerScope(fn, flushMode);
20
+ }
21
+ function runRuntimeWithSyncProgress(fn) {
22
+ return getRuntimeScheduler().runWithSyncProgress(fn);
23
+ }
24
+ function getRuntimeSchedulerState() {
25
+ return getRuntimeScheduler().getState();
26
+ }
27
+ function isRuntimeSchedulerExecuting() {
28
+ return getRuntimeScheduler().isExecuting();
29
+ }
30
+ function getRuntimeFlushVersion() {
31
+ return getRuntimeScheduler().getFlushVersion();
32
+ }
33
+ function flushRuntimeScheduler() {
34
+ getRuntimeScheduler().flush();
35
+ }
36
+ function setRuntimeBulkCommitProbe(probe) {
37
+ getRuntimeScheduler().setBulkCommitProbe(probe);
38
+ }
39
+ function markRuntimeReactivePropsDirtySource(source) {
40
+ getRuntimeRenderer().markReactivePropsDirtySource(source);
41
+ }
42
+ //#endregion
43
+ export { enqueueRuntimeLane, enqueueRuntimeTask, flushRuntimeScheduler, getDefaultRuntimeInstance, getRuntimeFlushVersion, getRuntimeRenderer, getRuntimeScheduler, getRuntimeSchedulerState, isRuntimeSchedulerExecuting, markRuntimeReactivePropsDirtySource, runRuntimeHandlerScope, runRuntimeWithSyncProgress, setRuntimeBulkCommitProbe };
44
+
45
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","names":[],"sources":["../../src/runtime/access.ts"],"sourcesContent":["import type { ReadableSource } from './readable';\nimport {\n getDefaultRuntime,\n type AskrRuntime,\n type RuntimeRendererHost,\n} from './runtime';\nimport type { Scheduler, SchedulerLane } from './scheduler';\n\ntype RuntimeTask = () => void;\n\nexport function getRuntimeScheduler(): Scheduler {\n return getDefaultRuntime().scheduler;\n}\n\nexport function getDefaultRuntimeInstance(): AskrRuntime {\n return getDefaultRuntime();\n}\n\nexport function getRuntimeRenderer(): RuntimeRendererHost {\n return getDefaultRuntime().renderer;\n}\n\nexport function enqueueRuntimeTask(task: RuntimeTask): void {\n getRuntimeScheduler().enqueue(task);\n}\n\nexport function enqueueRuntimeLane(\n lane: SchedulerLane,\n task: RuntimeTask\n): void {\n getRuntimeScheduler().enqueueInLane(lane, task);\n}\n\nexport function runRuntimeHandlerScope<T>(\n fn: () => T,\n flushMode: 'defer' | 'sync' = 'defer'\n): T {\n return getRuntimeScheduler().runInHandlerScope(fn, flushMode);\n}\n\nexport function runRuntimeWithSyncProgress<T>(fn: () => T): T {\n return getRuntimeScheduler().runWithSyncProgress(fn);\n}\n\nexport function getRuntimeSchedulerState(): ReturnType<Scheduler['getState']> {\n return getRuntimeScheduler().getState();\n}\n\nexport function isRuntimeSchedulerExecuting(): boolean {\n return getRuntimeScheduler().isExecuting();\n}\n\nexport function getRuntimeFlushVersion(): number {\n return getRuntimeScheduler().getFlushVersion();\n}\n\nexport function flushRuntimeScheduler(): void {\n getRuntimeScheduler().flush();\n}\n\nexport function setRuntimeBulkCommitProbe(probe: () => boolean): void {\n getRuntimeScheduler().setBulkCommitProbe(probe);\n}\n\nexport function markRuntimeReactivePropsDirtySource(\n source: ReadableSource<unknown>\n): void {\n getRuntimeRenderer().markReactivePropsDirtySource(source);\n}\n"],"mappings":";;AAUA,SAAgB,sBAAiC;CAC/C,OAAO,kBAAkB,CAAC,CAAC;AAC7B;AAEA,SAAgB,4BAAyC;CACvD,OAAO,kBAAkB;AAC3B;AAEA,SAAgB,qBAA0C;CACxD,OAAO,kBAAkB,CAAC,CAAC;AAC7B;AAEA,SAAgB,mBAAmB,MAAyB;CAC1D,oBAAoB,CAAC,CAAC,QAAQ,IAAI;AACpC;AAEA,SAAgB,mBACd,MACA,MACM;CACN,oBAAoB,CAAC,CAAC,cAAc,MAAM,IAAI;AAChD;AAEA,SAAgB,uBACd,IACA,YAA8B,SAC3B;CACH,OAAO,oBAAoB,CAAC,CAAC,kBAAkB,IAAI,SAAS;AAC9D;AAEA,SAAgB,2BAA8B,IAAgB;CAC5D,OAAO,oBAAoB,CAAC,CAAC,oBAAoB,EAAE;AACrD;AAEA,SAAgB,2BAA8D;CAC5E,OAAO,oBAAoB,CAAC,CAAC,SAAS;AACxC;AAEA,SAAgB,8BAAuC;CACrD,OAAO,oBAAoB,CAAC,CAAC,YAAY;AAC3C;AAEA,SAAgB,yBAAiC;CAC/C,OAAO,oBAAoB,CAAC,CAAC,gBAAgB;AAC/C;AAEA,SAAgB,wBAA8B;CAC5C,oBAAoB,CAAC,CAAC,MAAM;AAC9B;AAEA,SAAgB,0BAA0B,OAA4B;CACpE,oBAAoB,CAAC,CAAC,mBAAmB,KAAK;AAChD;AAEA,SAAgB,oCACd,QACM;CACN,mBAAmB,CAAC,CAAC,6BAA6B,MAAM;AAC1D"}
@@ -1,4 +1,4 @@
1
- import { ComponentInstance } from "./component.js";
1
+ import { ComponentInstance } from "./component-internal.js";
2
2
  import { VNode } from "../common/vnode.js";
3
3
 
4
4
  //#region src/runtime/child-scope.d.ts
@@ -1,6 +1,9 @@
1
1
  import { _isDOMElement } from "../common/vnode.js";
2
2
  import { isDevelopmentEnvironment } from "../common/env.js";
3
- import { cleanupComponent, createComponentInstance, finalizeReadSubscriptions, getCurrentStateIndex, registerOwnedChildScope, renderScopedComponent, unregisterOwnedChildScope } from "./component.js";
3
+ import { getCurrentStateIndex } from "./component-scope.js";
4
+ import { cleanupComponent, registerOwnedChildScope, unregisterOwnedChildScope } from "./component-cleanup.js";
5
+ import { createComponentInstance, finalizeReadSubscriptions, renderScopedComponent } from "./component-internal.js";
6
+ import "./component.js";
4
7
  //#region src/runtime/child-scope.ts
5
8
  function renderScope(scope) {
6
9
  if (scope._disposed) {
@@ -1 +1 @@
1
- {"version":3,"file":"child-scope.js","names":[],"sources":["../../src/runtime/child-scope.ts"],"sourcesContent":["import type { VNode } from '../common/vnode';\nimport { _isDOMElement } from '../common/vnode';\nimport {\n cleanupComponent,\n createComponentInstance,\n finalizeReadSubscriptions,\n getCurrentStateIndex,\n registerOwnedChildScope,\n renderScopedComponent,\n unregisterOwnedChildScope,\n type ComponentInstance,\n} from './component';\nimport { isDevelopmentEnvironment } from '../common/env';\n\nexport interface ChildScope {\n key: string | number;\n componentInstance: ComponentInstance;\n previousVnode: VNode | undefined;\n vnode: VNode | undefined;\n dom?: Node;\n needsDomUpdate: boolean;\n hydrationPending: boolean;\n render(renderFn: () => VNode): VNode;\n markDirty(): void;\n dispose(): void;\n}\n\ninterface MutableChildScope extends ChildScope {\n _startStateIndex: number;\n _renderFn?: (() => VNode) | undefined;\n _onDirty?: (() => void) | undefined;\n _parent?: ComponentInstance | null;\n _disposed: boolean;\n}\n\nfunction renderScope(scope: MutableChildScope): VNode | undefined {\n if (scope._disposed) {\n if (isDevelopmentEnvironment()) {\n throw new Error(\n `[askr] Attempted to render disposed child scope ${String(scope.key)}.`\n );\n }\n return scope.vnode;\n }\n\n if (!scope._renderFn) {\n return scope.vnode;\n }\n\n const { componentInstance } = scope;\n const previousVNode = scope.vnode;\n\n try {\n const nextVNode = renderScopedComponent(\n componentInstance,\n scope._startStateIndex,\n scope._renderFn\n );\n if (\n previousVNode &&\n nextVNode &&\n _isDOMElement(previousVNode) &&\n _isDOMElement(nextVNode) &&\n typeof previousVNode.type === 'function' &&\n previousVNode.type === nextVNode.type &&\n '__instance' in previousVNode &&\n !('__instance' in nextVNode)\n ) {\n (\n nextVNode as VNode & {\n __instance?: ComponentInstance;\n }\n ).__instance = (\n previousVNode as VNode & {\n __instance?: ComponentInstance;\n }\n ).__instance;\n }\n scope.previousVnode = previousVNode;\n scope.vnode = nextVNode;\n scope.markDirty();\n finalizeReadSubscriptions(componentInstance);\n return scope.vnode;\n } catch (error) {\n componentInstance.hasPendingUpdate = false;\n throw error;\n }\n}\n\nexport function rerenderChildScope(scope: ChildScope): VNode | undefined {\n return renderScope(scope as MutableChildScope);\n}\n\nexport function disposeChildScope(scope: ChildScope): void {\n scope.dispose();\n}\n\nexport function createChildScope(\n parent: ComponentInstance | null,\n key: string | number,\n onDirty?: () => void\n): ChildScope {\n const scope = {} as MutableChildScope;\n\n const componentInstance = createComponentInstance(\n `child-scope-${String(key)}`,\n () => scope._renderFn?.() ?? null,\n {},\n null\n );\n\n if (parent) {\n componentInstance.parentInstance = parent;\n componentInstance.ownerFrame = parent.ownerFrame;\n componentInstance.portalScope = parent.portalScope;\n }\n\n scope.key = key;\n scope.componentInstance = componentInstance;\n scope.previousVnode = undefined;\n scope.vnode = undefined;\n scope.dom = undefined;\n scope.needsDomUpdate = true;\n scope.hydrationPending = true;\n scope._startStateIndex = getCurrentStateIndex();\n scope._renderFn = undefined;\n scope._onDirty = onDirty;\n scope._parent = parent;\n scope._disposed = false;\n scope.markDirty = () => {\n scope.needsDomUpdate = true;\n };\n scope.render = (renderFn: () => VNode) => {\n scope._renderFn = renderFn;\n return renderScope(scope) as VNode;\n };\n scope.dispose = () => {\n if (scope._disposed) {\n return;\n }\n scope._disposed = true;\n if (scope._parent) {\n unregisterOwnedChildScope(scope._parent, scope);\n }\n cleanupComponent(componentInstance);\n scope._renderFn = undefined;\n scope.previousVnode = undefined;\n scope.vnode = undefined;\n scope.dom = undefined;\n scope.needsDomUpdate = false;\n scope.hydrationPending = false;\n componentInstance.hasPendingUpdate = false;\n };\n\n componentInstance._pendingFlushTask = () => {\n componentInstance.hasPendingUpdate = false;\n if (componentInstance.notifyUpdate === null || scope._disposed) {\n return;\n }\n renderScope(scope);\n scope._onDirty?.();\n };\n\n if (parent) {\n registerOwnedChildScope(parent, scope);\n }\n\n return scope;\n}\n"],"mappings":";;;;AAmCA,SAAS,YAAY,OAA6C;CAChE,IAAI,MAAM,WAAW;EACnB,IA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CACA,MAAM,UAAU,aAA0B;EACxC,MAAM,YAAY;EAClB,OAAO,YAAY,KAAK;CAC1B;CACA,MAAM,gBAAgB;EACpB,IAAI,MAAM,WACR;EAEF,MAAM,YAAY;EAClB,IAAI,MAAM,SACR,0BAA0B,MAAM,SAAS,KAAK;EAEhD,iBAAiB,iBAAiB;EAClC,MAAM,YAAY;EAClB,MAAM,gBAAgB;EACtB,MAAM,QAAQ;EACd,MAAM,MAAM;EACZ,MAAM,iBAAiB;EACvB,MAAM,mBAAmB;EACzB,kBAAkB,mBAAmB;CACvC;CAEA,kBAAkB,0BAA0B;EAC1C,kBAAkB,mBAAmB;EACrC,IAAI,kBAAkB,iBAAiB,QAAQ,MAAM,WACnD;EAEF,YAAY,KAAK;EACjB,MAAM,WAAW;CACnB;CAEA,IAAI,QACF,wBAAwB,QAAQ,KAAK;CAGvC,OAAO;AACT"}
1
+ {"version":3,"file":"child-scope.js","names":[],"sources":["../../src/runtime/child-scope.ts"],"sourcesContent":["import type { VNode } from '../common/vnode';\nimport { _isDOMElement } from '../common/vnode';\nimport {\n cleanupComponent,\n createComponentInstance,\n finalizeReadSubscriptions,\n getCurrentStateIndex,\n registerOwnedChildScope,\n renderScopedComponent,\n unregisterOwnedChildScope,\n type ComponentInstance,\n} from './component';\nimport { isDevelopmentEnvironment } from '../common/env';\n\nexport interface ChildScope {\n key: string | number;\n componentInstance: ComponentInstance;\n previousVnode: VNode | undefined;\n vnode: VNode | undefined;\n dom?: Node;\n needsDomUpdate: boolean;\n hydrationPending: boolean;\n render(renderFn: () => VNode): VNode;\n markDirty(): void;\n dispose(): void;\n}\n\ninterface MutableChildScope extends ChildScope {\n _startStateIndex: number;\n _renderFn?: (() => VNode) | undefined;\n _onDirty?: (() => void) | undefined;\n _parent?: ComponentInstance | null;\n _disposed: boolean;\n}\n\nfunction renderScope(scope: MutableChildScope): VNode | undefined {\n if (scope._disposed) {\n if (isDevelopmentEnvironment()) {\n throw new Error(\n `[askr] Attempted to render disposed child scope ${String(scope.key)}.`\n );\n }\n return scope.vnode;\n }\n\n if (!scope._renderFn) {\n return scope.vnode;\n }\n\n const { componentInstance } = scope;\n const previousVNode = scope.vnode;\n\n try {\n const nextVNode = renderScopedComponent(\n componentInstance,\n scope._startStateIndex,\n scope._renderFn\n );\n if (\n previousVNode &&\n nextVNode &&\n _isDOMElement(previousVNode) &&\n _isDOMElement(nextVNode) &&\n typeof previousVNode.type === 'function' &&\n previousVNode.type === nextVNode.type &&\n '__instance' in previousVNode &&\n !('__instance' in nextVNode)\n ) {\n (\n nextVNode as VNode & {\n __instance?: ComponentInstance;\n }\n ).__instance = (\n previousVNode as VNode & {\n __instance?: ComponentInstance;\n }\n ).__instance;\n }\n scope.previousVnode = previousVNode;\n scope.vnode = nextVNode;\n scope.markDirty();\n finalizeReadSubscriptions(componentInstance);\n return scope.vnode;\n } catch (error) {\n componentInstance.hasPendingUpdate = false;\n throw error;\n }\n}\n\nexport function rerenderChildScope(scope: ChildScope): VNode | undefined {\n return renderScope(scope as MutableChildScope);\n}\n\nexport function disposeChildScope(scope: ChildScope): void {\n scope.dispose();\n}\n\nexport function createChildScope(\n parent: ComponentInstance | null,\n key: string | number,\n onDirty?: () => void\n): ChildScope {\n const scope = {} as MutableChildScope;\n\n const componentInstance = createComponentInstance(\n `child-scope-${String(key)}`,\n () => scope._renderFn?.() ?? null,\n {},\n null\n );\n\n if (parent) {\n componentInstance.parentInstance = parent;\n componentInstance.ownerFrame = parent.ownerFrame;\n componentInstance.portalScope = parent.portalScope;\n }\n\n scope.key = key;\n scope.componentInstance = componentInstance;\n scope.previousVnode = undefined;\n scope.vnode = undefined;\n scope.dom = undefined;\n scope.needsDomUpdate = true;\n scope.hydrationPending = true;\n scope._startStateIndex = getCurrentStateIndex();\n scope._renderFn = undefined;\n scope._onDirty = onDirty;\n scope._parent = parent;\n scope._disposed = false;\n scope.markDirty = () => {\n scope.needsDomUpdate = true;\n };\n scope.render = (renderFn: () => VNode) => {\n scope._renderFn = renderFn;\n return renderScope(scope) as VNode;\n };\n scope.dispose = () => {\n if (scope._disposed) {\n return;\n }\n scope._disposed = true;\n if (scope._parent) {\n unregisterOwnedChildScope(scope._parent, scope);\n }\n cleanupComponent(componentInstance);\n scope._renderFn = undefined;\n scope.previousVnode = undefined;\n scope.vnode = undefined;\n scope.dom = undefined;\n scope.needsDomUpdate = false;\n scope.hydrationPending = false;\n componentInstance.hasPendingUpdate = false;\n };\n\n componentInstance._pendingFlushTask = () => {\n componentInstance.hasPendingUpdate = false;\n if (componentInstance.notifyUpdate === null || scope._disposed) {\n return;\n }\n renderScope(scope);\n scope._onDirty?.();\n };\n\n if (parent) {\n registerOwnedChildScope(parent, scope);\n }\n\n return scope;\n}\n"],"mappings":";;;;;;;AAmCA,SAAS,YAAY,OAA6C;CAChE,IAAI,MAAM,WAAW;EACnB,IAAI,yBAAyB,GAC3B,MAAM,IAAI,MACR,mDAAmD,OAAO,MAAM,GAAG,EAAE,EACvE;EAEF,OAAO,MAAM;CACf;CAEA,IAAI,CAAC,MAAM,WACT,OAAO,MAAM;CAGf,MAAM,EAAE,sBAAsB;CAC9B,MAAM,gBAAgB,MAAM;CAE5B,IAAI;EACF,MAAM,YAAY,sBAChB,mBACA,MAAM,kBACN,MAAM,SACR;EACA,IACE,iBACA,aACA,cAAc,aAAa,KAC3B,cAAc,SAAS,KACvB,OAAO,cAAc,SAAS,cAC9B,cAAc,SAAS,UAAU,QACjC,gBAAgB,iBAChB,EAAE,gBAAgB,YAElB,UAIE,aACA,cAGA;EAEJ,MAAM,gBAAgB;EACtB,MAAM,QAAQ;EACd,MAAM,UAAU;EAChB,0BAA0B,iBAAiB;EAC3C,OAAO,MAAM;CACf,SAAS,OAAO;EACd,kBAAkB,mBAAmB;EACrC,MAAM;CACR;AACF;AAEA,SAAgB,mBAAmB,OAAsC;CACvE,OAAO,YAAY,KAA0B;AAC/C;AAEA,SAAgB,kBAAkB,OAAyB;CACzD,MAAM,QAAQ;AAChB;AAEA,SAAgB,iBACd,QACA,KACA,SACY;CACZ,MAAM,QAAQ,CAAC;CAEf,MAAM,oBAAoB,wBACxB,eAAe,OAAO,GAAG,WACnB,MAAM,YAAY,KAAK,MAC7B,CAAC,GACD,IACF;CAEA,IAAI,QAAQ;EACV,kBAAkB,iBAAiB;EACnC,kBAAkB,aAAa,OAAO;EACtC,kBAAkB,cAAc,OAAO;CACzC;CAEA,MAAM,MAAM;CACZ,MAAM,oBAAoB;CAC1B,MAAM,gBAAgB;CACtB,MAAM,QAAQ;CACd,MAAM,MAAM;CACZ,MAAM,iBAAiB;CACvB,MAAM,mBAAmB;CACzB,MAAM,mBAAmB,qBAAqB;CAC9C,MAAM,YAAY;CAClB,MAAM,WAAW;CACjB,MAAM,UAAU;CAChB,MAAM,YAAY;CAClB,MAAM,kBAAkB;EACtB,MAAM,iBAAiB;CACzB;CACA,MAAM,UAAU,aAA0B;EACxC,MAAM,YAAY;EAClB,OAAO,YAAY,KAAK;CAC1B;CACA,MAAM,gBAAgB;EACpB,IAAI,MAAM,WACR;EAEF,MAAM,YAAY;EAClB,IAAI,MAAM,SACR,0BAA0B,MAAM,SAAS,KAAK;EAEhD,iBAAiB,iBAAiB;EAClC,MAAM,YAAY;EAClB,MAAM,gBAAgB;EACtB,MAAM,QAAQ;EACd,MAAM,MAAM;EACZ,MAAM,iBAAiB;EACvB,MAAM,mBAAmB;EACzB,kBAAkB,mBAAmB;CACvC;CAEA,kBAAkB,0BAA0B;EAC1C,kBAAkB,mBAAmB;EACrC,IAAI,kBAAkB,iBAAiB,QAAQ,MAAM,WACnD;EAEF,YAAY,KAAK;EACjB,MAAM,WAAW;CACnB;CAEA,IAAI,QACF,wBAAwB,QAAQ,KAAK;CAGvC,OAAO;AACT"}
@@ -0,0 +1,16 @@
1
+ import { ComponentInstance } from "./component-internal.js";
2
+
3
+ //#region src/runtime/component-cleanup.d.ts
4
+ type OwnedChildScope = {
5
+ key: string | number;
6
+ dispose(): void;
7
+ };
8
+ /**
9
+ * Clean up component resources on unmount or route changes.
10
+ */
11
+ declare function cleanupComponent(instance: ComponentInstance): void;
12
+ declare function registerOwnedChildScope(instance: ComponentInstance, scope: OwnedChildScope): void;
13
+ declare function unregisterOwnedChildScope(instance: ComponentInstance, scope: OwnedChildScope): void;
14
+ //#endregion
15
+ export { OwnedChildScope, cleanupComponent, registerOwnedChildScope, unregisterOwnedChildScope };
16
+ //# sourceMappingURL=component-cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-cleanup.d.ts","names":[],"sources":["../../src/runtime/component-cleanup.ts"],"mappings":";;;KAaY,eAAA;EACV,GAAA;EACA,OAAO;AAAA;AAMT;;;AAAA,iBAAgB,gBAAA,CAAiB,QAA2B,EAAjB,iBAAiB;AAAA,iBA0E5C,uBAAA,CACd,QAAA,EAAU,iBAAA,EACV,KAAA,EAAO,eAAe;AAAA,iBAMR,yBAAA,CACd,QAAA,EAAU,iBAAA,EACV,KAAA,EAAO,eAAe"}
@@ -0,0 +1,70 @@
1
+ import { isDevelopmentEnvironment } from "../common/env.js";
2
+ import { logger } from "../dev/logger.js";
3
+ import { cleanupReadableSubscriptions } from "./readable.js";
4
+ import { clearCurrentComponentScope, restoreCurrentComponentScope } from "./component-scope.js";
5
+ //#region src/runtime/component-cleanup.ts
6
+ /**
7
+ * Component cleanup and owned child-scope bookkeeping.
8
+ */
9
+ /**
10
+ * Clean up component resources on unmount or route changes.
11
+ */
12
+ function cleanupComponent(instance) {
13
+ const savedScope = clearCurrentComponentScope();
14
+ try {
15
+ const cleanupErrors = [];
16
+ const recordCleanupError = (message, err) => {
17
+ if (instance.cleanupStrict) cleanupErrors.push(err);
18
+ else if (isDevelopmentEnvironment()) logger.warn(message, err);
19
+ };
20
+ const ownedChildScopes = instance._ownedChildScopes;
21
+ if (ownedChildScopes && ownedChildScopes.size > 0) {
22
+ instance._ownedChildScopes = /* @__PURE__ */ new Set();
23
+ for (const scope of ownedChildScopes) try {
24
+ scope.dispose();
25
+ } catch (err) {
26
+ recordCleanupError("[Askr] child scope cleanup threw:", err);
27
+ }
28
+ }
29
+ const cleanupFns = instance.cleanupFns;
30
+ instance.cleanupFns = [];
31
+ for (const cleanup of cleanupFns) try {
32
+ cleanup();
33
+ } catch (err) {
34
+ recordCleanupError("[Askr] cleanup function threw:", err);
35
+ }
36
+ try {
37
+ cleanupReadableSubscriptions(instance);
38
+ } catch (err) {
39
+ recordCleanupError("[Askr] readable subscription cleanup threw:", err);
40
+ }
41
+ try {
42
+ if (instance.abortController && !instance.abortController.signal.aborted) instance.abortController.abort();
43
+ } catch (err) {
44
+ recordCleanupError("[Askr] abort controller cleanup threw:", err);
45
+ }
46
+ instance.abortController = null;
47
+ instance.lifecycleGeneration++;
48
+ instance.evaluationGeneration++;
49
+ instance.mountOperations = [];
50
+ instance.commitOperations = [];
51
+ instance.lifecycleSlots = [];
52
+ instance.hasPendingUpdate = false;
53
+ instance.notifyUpdate = null;
54
+ instance._placeholder = void 0;
55
+ instance.mounted = false;
56
+ if (cleanupErrors.length > 0) throw new AggregateError(cleanupErrors, `Cleanup failed for component ${instance.id}`);
57
+ } finally {
58
+ restoreCurrentComponentScope(savedScope);
59
+ }
60
+ }
61
+ function registerOwnedChildScope(instance, scope) {
62
+ (instance._ownedChildScopes ??= /* @__PURE__ */ new Set()).add(scope);
63
+ }
64
+ function unregisterOwnedChildScope(instance, scope) {
65
+ instance._ownedChildScopes?.delete(scope);
66
+ }
67
+ //#endregion
68
+ export { cleanupComponent, registerOwnedChildScope, unregisterOwnedChildScope };
69
+
70
+ //# sourceMappingURL=component-cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-cleanup.js","names":[],"sources":["../../src/runtime/component-cleanup.ts"],"sourcesContent":["/**\n * Component cleanup and owned child-scope bookkeeping.\n */\n\nimport { isDevelopmentEnvironment } from '../common/env';\nimport { logger } from '../dev/logger';\nimport type { ComponentInstance } from './component-internal';\nimport {\n clearCurrentComponentScope,\n restoreCurrentComponentScope,\n} from './component-scope';\nimport { cleanupReadableSubscriptions } from './readable';\n\nexport type OwnedChildScope = {\n key: string | number;\n dispose(): void;\n};\n\n/**\n * Clean up component resources on unmount or route changes.\n */\nexport function cleanupComponent(instance: ComponentInstance): void {\n const savedScope = clearCurrentComponentScope();\n\n try {\n const cleanupErrors: unknown[] = [];\n const recordCleanupError = (message: string, err: unknown): void => {\n if (instance.cleanupStrict) {\n cleanupErrors.push(err);\n } else if (isDevelopmentEnvironment()) {\n logger.warn(message, err);\n }\n };\n\n const ownedChildScopes = instance._ownedChildScopes;\n if (ownedChildScopes && ownedChildScopes.size > 0) {\n instance._ownedChildScopes = new Set();\n for (const scope of ownedChildScopes) {\n try {\n scope.dispose();\n } catch (err) {\n recordCleanupError('[Askr] child scope cleanup threw:', err);\n }\n }\n }\n\n const cleanupFns = instance.cleanupFns;\n instance.cleanupFns = [];\n for (const cleanup of cleanupFns) {\n try {\n cleanup();\n } catch (err) {\n recordCleanupError('[Askr] cleanup function threw:', err);\n }\n }\n\n try {\n cleanupReadableSubscriptions(instance);\n } catch (err) {\n recordCleanupError('[Askr] readable subscription cleanup threw:', err);\n }\n\n try {\n if (\n instance.abortController &&\n !instance.abortController.signal.aborted\n ) {\n instance.abortController.abort();\n }\n } catch (err) {\n recordCleanupError('[Askr] abort controller cleanup threw:', err);\n }\n instance.abortController = null;\n\n instance.lifecycleGeneration++;\n instance.evaluationGeneration++;\n instance.mountOperations = [];\n instance.commitOperations = [];\n instance.lifecycleSlots = [];\n instance.hasPendingUpdate = false;\n instance.notifyUpdate = null;\n instance._placeholder = undefined;\n instance.mounted = false;\n\n if (cleanupErrors.length > 0) {\n throw new AggregateError(\n cleanupErrors,\n `Cleanup failed for component ${instance.id}`\n );\n }\n } finally {\n restoreCurrentComponentScope(savedScope);\n }\n}\n\nexport function registerOwnedChildScope(\n instance: ComponentInstance,\n scope: OwnedChildScope\n): void {\n const scopes = (instance._ownedChildScopes ??= new Set());\n scopes.add(scope);\n}\n\nexport function unregisterOwnedChildScope(\n instance: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SAAgB,wBACd,UACA,OACM;CAEN,CADgB,SAAS,sCAAsB,IAAI,IAAI,EACvD,CAAO,IAAI,KAAK;AAClB;AAEA,SAAgB,0BACd,UACA,OACM;CACN,SAAS,mBAAmB,OAAO,KAAK;AAC1C"}
@@ -0,0 +1,165 @@
1
+ import { isDevelopmentEnvironment } from "../common/env.js";
2
+ import { logger } from "../dev/logger.js";
3
+ import { enqueueRuntimeTask, getRuntimeRenderer } from "./access.js";
4
+ import { withContext } from "./context.js";
5
+ import { incDevCounter, setDevValue } from "./dev-namespace.js";
6
+ import { beginRenderTracking, enterDomCommitScope, restoreDomCommitScope } from "./component-scope.js";
7
+ import { isPromiseLike } from "../common/promise.js";
8
+ import { tryRuntimeFastLaneSync } from "./fastlane.js";
9
+ import { beginLifecycleCommitBatch, discardCommitOperations, discardLifecycleCommitBatch, executeCommittedLifecycleOperations, flushLifecycleCommitBatch } from "./component-lifecycle.js";
10
+ //#region src/runtime/component-commit.ts
11
+ function runScheduledComponent(instance, host) {
12
+ instance.notifyUpdate = instance._enqueueRun;
13
+ beginRenderTracking(instance);
14
+ const domSnapshot = instance.target ? instance.target.innerHTML : "";
15
+ let result;
16
+ try {
17
+ result = host.execute(instance);
18
+ } catch (err) {
19
+ discardCommitOperations(instance);
20
+ throw err;
21
+ }
22
+ if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must be synchronous.");
23
+ try {
24
+ if (tryRuntimeFastLaneSync(instance, result)) {
25
+ host.warnUnusedStateReads(instance);
26
+ return;
27
+ }
28
+ } catch (err) {
29
+ if (isDevelopmentEnvironment()) throw err;
30
+ }
31
+ enqueueRuntimeTask(() => {
32
+ if (!instance.target && instance._placeholder) {
33
+ commitPlaceholderReplacement(instance, result, host);
34
+ return;
35
+ }
36
+ if (instance.target) commitToTarget(instance, result, domSnapshot, host);
37
+ });
38
+ }
39
+ function commitPlaceholderReplacement(instance, result, host) {
40
+ if (result === null || result === void 0) {
41
+ host.finalizeReadSubscriptions(instance);
42
+ host.warnUnusedStateReads(instance);
43
+ host.commitRenderedComponent(instance);
44
+ return;
45
+ }
46
+ const placeholder = instance._placeholder;
47
+ const parent = placeholder.parentNode;
48
+ if (!parent) {
49
+ logger.warn("[Askr] placeholder no longer in DOM, cannot render component");
50
+ return;
51
+ }
52
+ const renderer = getRuntimeRenderer();
53
+ const hostElement = document.createElement("div");
54
+ const executionFrame = {
55
+ parent: instance.ownerFrame,
56
+ values: null
57
+ };
58
+ const oldInstance = enterDomCommitScope(instance);
59
+ const lifecycleBatch = beginLifecycleCommitBatch();
60
+ try {
61
+ try {
62
+ withContext(executionFrame, () => {
63
+ renderer.evaluate(result, hostElement);
64
+ });
65
+ parent.replaceChild(hostElement, placeholder);
66
+ } catch (err) {
67
+ discardLifecycleCommitBatch(lifecycleBatch);
68
+ throw err;
69
+ }
70
+ instance.target = hostElement;
71
+ instance._placeholder = void 0;
72
+ hostElement.__ASKR_INSTANCE = instance;
73
+ flushLifecycleCommitBatch(lifecycleBatch);
74
+ host.finalizeReadSubscriptions(instance);
75
+ host.warnUnusedStateReads(instance);
76
+ host.commitRenderedComponent(instance);
77
+ } finally {
78
+ restoreDomCommitScope(oldInstance);
79
+ }
80
+ }
81
+ function commitToTarget(instance, result, domSnapshot, host) {
82
+ const renderer = getRuntimeRenderer();
83
+ const target = instance.target;
84
+ let oldChildren = [];
85
+ let restoredOldChildren = false;
86
+ try {
87
+ const wasFirstMount = !instance.mounted;
88
+ const oldInstance = enterDomCommitScope(instance);
89
+ const executionFrame = {
90
+ parent: instance.ownerFrame,
91
+ values: null
92
+ };
93
+ oldChildren = Array.from(target.childNodes);
94
+ const lifecycleBatch = beginLifecycleCommitBatch();
95
+ try {
96
+ try {
97
+ withContext(executionFrame, () => {
98
+ renderer.evaluate(result, target, void 0, instance);
99
+ });
100
+ } catch (err) {
101
+ discardLifecycleCommitBatch(lifecycleBatch);
102
+ throw err;
103
+ }
104
+ } catch (err) {
105
+ cleanupFailedCommitChildren(renderer, target, oldChildren);
106
+ try {
107
+ incDevCounter("__DOM_REPLACE_COUNT");
108
+ setDevValue("__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE", (/* @__PURE__ */ new Error()).stack);
109
+ } catch (devErr) {}
110
+ target.replaceChildren(...oldChildren);
111
+ restoredOldChildren = true;
112
+ throw err;
113
+ } finally {
114
+ restoreDomCommitScope(oldInstance);
115
+ }
116
+ flushLifecycleCommitBatch(lifecycleBatch);
117
+ host.finalizeReadSubscriptions(instance);
118
+ host.warnUnusedStateReads(instance);
119
+ instance.mounted = true;
120
+ executeCommittedLifecycleOperations(instance, wasFirstMount);
121
+ } catch (renderError) {
122
+ discardCommitOperations(instance);
123
+ cleanupRollbackChildren(renderer, target, oldChildren, restoredOldChildren);
124
+ try {
125
+ incDevCounter("__DOM_REPLACE_COUNT");
126
+ setDevValue("__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK", (/* @__PURE__ */ new Error()).stack);
127
+ target.replaceChildren(...oldChildren);
128
+ } catch {
129
+ target.innerHTML = domSnapshot;
130
+ }
131
+ throw renderError;
132
+ }
133
+ }
134
+ function cleanupFailedCommitChildren(renderer, target, oldChildren) {
135
+ try {
136
+ const newChildren = Array.from(target.childNodes);
137
+ const preservedChildren = new Set(oldChildren);
138
+ for (const node of newChildren) {
139
+ if (preservedChildren.has(node)) continue;
140
+ try {
141
+ renderer.cleanupInstancesUnder(node);
142
+ } catch (err) {
143
+ logger.warn("[Askr] error cleaning up failed commit children:", err);
144
+ }
145
+ }
146
+ } catch (err) {}
147
+ }
148
+ function cleanupRollbackChildren(renderer, target, oldChildren, restoredOldChildren) {
149
+ try {
150
+ const currentChildren = Array.from(target.childNodes);
151
+ const preservedChildren = restoredOldChildren ? new Set(oldChildren) : null;
152
+ for (const node of currentChildren) {
153
+ if (preservedChildren?.has(node)) continue;
154
+ try {
155
+ renderer.cleanupInstancesUnder(node);
156
+ } catch (err) {
157
+ logger.warn("[Askr] error cleaning up partial children during rollback:", err);
158
+ }
159
+ }
160
+ } catch (err) {}
161
+ }
162
+ //#endregion
163
+ export { runScheduledComponent };
164
+
165
+ //# sourceMappingURL=component-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-commit.js","names":[],"sources":["../../src/runtime/component-commit.ts"],"sourcesContent":["import { isDevelopmentEnvironment } from '../common/env';\nimport { isPromiseLike } from '../common/promise';\nimport { logger } from '../dev/logger';\nimport { enqueueRuntimeTask, getRuntimeRenderer } from './access';\nimport {\n beginLifecycleCommitBatch,\n discardCommitOperations,\n discardLifecycleCommitBatch,\n executeCommittedLifecycleOperations,\n flushLifecycleCommitBatch,\n} from './component-lifecycle';\nimport {\n beginRenderTracking,\n enterDomCommitScope,\n restoreDomCommitScope,\n} from './component-scope';\nimport type { ContextFrame } from './context';\nimport { withContext } from './context';\nimport { incDevCounter, setDevValue } from './dev-namespace';\nimport { tryRuntimeFastLaneSync } from './fastlane';\nimport type { ComponentInstance } from './component-internal';\n\nexport interface ScheduledComponentCommitHost {\n execute(instance: ComponentInstance): unknown | Promise<unknown>;\n finalizeReadSubscriptions(instance: ComponentInstance): void;\n warnUnusedStateReads(instance: ComponentInstance): void;\n commitRenderedComponent(instance: ComponentInstance): void;\n}\n\nexport function runScheduledComponent(\n instance: ComponentInstance,\n host: ScheduledComponentCommitHost\n): void {\n instance.notifyUpdate = instance._enqueueRun!;\n beginRenderTracking(instance);\n const domSnapshot = instance.target ? instance.target.innerHTML : '';\n\n let result: unknown | Promise<unknown>;\n try {\n result = host.execute(instance);\n } catch (err) {\n discardCommitOperations(instance);\n throw err;\n }\n\n if (isPromiseLike(result)) {\n throw new Error(\n 'Async components are not supported. Components must be synchronous.'\n );\n }\n\n try {\n const used = tryRuntimeFastLaneSync(instance, result);\n if (used) {\n host.warnUnusedStateReads(instance);\n return;\n }\n } catch (err) {\n if (isDevelopmentEnvironment()) throw err;\n }\n\n enqueueRuntimeTask(() => {\n if (!instance.target && instance._placeholder) {\n commitPlaceholderReplacement(instance, result, host);\n return;\n }\n\n if (instance.target) {\n commitToTarget(instance, result, domSnapshot, host);\n }\n });\n}\n\nfunction commitPlaceholderReplacement(\n instance: ComponentInstance,\n result: unknown,\n host: ScheduledComponentCommitHost\n): void {\n if (result === null || result === undefined) {\n host.finalizeReadSubscriptions(instance);\n host.warnUnusedStateReads(instance);\n host.commitRenderedComponent(instance);\n return;\n }\n\n const placeholder = instance._placeholder!;\n const parent = placeholder.parentNode;\n if (!parent) {\n logger.warn('[Askr] placeholder no longer in DOM, cannot render component');\n return;\n }\n\n const renderer = getRuntimeRenderer();\n const hostElement = document.createElement('div');\n const executionFrame: ContextFrame = {\n parent: instance.ownerFrame,\n values: null,\n };\n\n const oldInstance = enterDomCommitScope(instance);\n const lifecycleBatch = beginLifecycleCommitBatch();\n try {\n try {\n withContext(executionFrame, () => {\n renderer.evaluate(result, hostElement);\n });\n parent.replaceChild(hostElement, placeholder);\n } catch (err) {\n discardLifecycleCommitBatch(lifecycleBatch);\n throw err;\n }\n\n instance.target = hostElement;\n instance._placeholder = undefined;\n (\n hostElement as Element & {\n __ASKR_INSTANCE?: ComponentInstance;\n }\n ).__ASKR_INSTANCE = instance;\n\n flushLifecycleCommitBatch(lifecycleBatch);\n host.finalizeReadSubscriptions(instance);\n host.warnUnusedStateReads(instance);\n host.commitRenderedComponent(instance);\n } finally {\n restoreDomCommitScope(oldInstance);\n }\n}\n\nfunction commitToTarget(\n instance: ComponentInstance,\n result: unknown,\n domSnapshot: string,\n host: ScheduledComponentCommitHost\n): void {\n const renderer = getRuntimeRenderer();\n const target = instance.target!;\n let oldChildren: Node[] = [];\n let restoredOldChildren = false;\n\n try {\n const wasFirstMount = !instance.mounted;\n const oldInstance = enterDomCommitScope(instance);\n const executionFrame: ContextFrame = {\n parent: instance.ownerFrame,\n values: null,\n };\n oldChildren = Array.from(target.childNodes);\n\n const lifecycleBatch = beginLifecycleCommitBatch();\n try {\n try {\n withContext(executionFrame, () => {\n renderer.evaluate(result, target, undefined, instance);\n });\n } catch (err) {\n discardLifecycleCommitBatch(lifecycleBatch);\n throw err;\n }\n } catch (err) {\n cleanupFailedCommitChildren(renderer, target, oldChildren);\n try {\n incDevCounter('__DOM_REPLACE_COUNT');\n setDevValue(\n '__LAST_DOM_REPLACE_STACK_COMPONENT_RESTORE',\n new Error().stack\n );\n } catch (devErr) {\n void devErr;\n }\n target.replaceChildren(...oldChildren);\n restoredOldChildren = true;\n throw err;\n } finally {\n restoreDomCommitScope(oldInstance);\n }\n\n flushLifecycleCommitBatch(lifecycleBatch);\n host.finalizeReadSubscriptions(instance);\n host.warnUnusedStateReads(instance);\n instance.mounted = true;\n executeCommittedLifecycleOperations(instance, wasFirstMount);\n } catch (renderError) {\n discardCommitOperations(instance);\n cleanupRollbackChildren(renderer, target, oldChildren, restoredOldChildren);\n\n try {\n incDevCounter('__DOM_REPLACE_COUNT');\n setDevValue(\n '__LAST_DOM_REPLACE_STACK_COMPONENT_ROLLBACK',\n new Error().stack\n );\n target.replaceChildren(...oldChildren);\n } catch {\n target.innerHTML = domSnapshot;\n }\n\n throw renderError;\n }\n}\n\nfunction cleanupFailedCommitChildren(\n renderer: ReturnType<typeof getRuntimeRenderer>,\n target: Element,\n oldChildren: Node[]\n): void {\n try {\n const newChildren = Array.from(target.childNodes);\n const preservedChildren = new Set(oldChildren);\n for (const node of newChildren) {\n if (preservedChildren.has(node)) {\n continue;\n }\n try {\n renderer.cleanupInstancesUnder(node);\n } catch (err) {\n logger.warn('[Askr] error cleaning up failed commit children:', err);\n }\n }\n } catch (err) {\n void err;\n }\n}\n\nfunction cleanupRollbackChildren(\n renderer: ReturnType<typeof getRuntimeRenderer>,\n target: Element,\n oldChildren: Node[],\n restoredOldChildren: boolean\n): void {\n try {\n const currentChildren = Array.from(target.childNodes);\n const preservedChildren = restoredOldChildren ? new Set(oldChildren) : null;\n for (const node of currentChildren) {\n if (preservedChildren?.has(node)) {\n continue;\n }\n try {\n renderer.cleanupInstancesUnder(node);\n } catch (err) {\n logger.warn(\n '[Askr] error cleaning up partial children during r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