@askrjs/askr 0.0.47 → 0.0.49

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 (394) 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 +1 -1
  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 +2 -0
  80. package/dist/jsx/types.js +2 -1
  81. package/dist/jsx-runtime2.d.ts +2 -1
  82. package/dist/jsx-runtime2.js +3 -2
  83. package/dist/renderer/attributes.js +231 -0
  84. package/dist/renderer/attributes.js.map +1 -0
  85. package/dist/renderer/boundaries.js +266 -0
  86. package/dist/renderer/boundaries.js.map +1 -0
  87. package/dist/renderer/child-shape.js +85 -0
  88. package/dist/renderer/child-shape.js.map +1 -0
  89. package/dist/renderer/children.js +3 -2
  90. package/dist/renderer/children.js.map +1 -1
  91. package/dist/renderer/cleanup.js +2 -1
  92. package/dist/renderer/cleanup.js.map +1 -1
  93. package/dist/renderer/component-host-cleanup.js +68 -0
  94. package/dist/renderer/component-host-cleanup.js.map +1 -0
  95. package/dist/renderer/component-host-instances.js +65 -0
  96. package/dist/renderer/component-host-instances.js.map +1 -0
  97. package/dist/renderer/component-host.js +247 -0
  98. package/dist/renderer/component-host.js.map +1 -0
  99. package/dist/renderer/dom-host.js +13 -0
  100. package/dist/renderer/dom-host.js.map +1 -0
  101. package/dist/renderer/dom-internal.js +185 -0
  102. package/dist/renderer/dom-internal.js.map +1 -0
  103. package/dist/renderer/dom.js +9 -2356
  104. package/dist/renderer/element-children.js +279 -0
  105. package/dist/renderer/element-children.js.map +1 -0
  106. package/dist/renderer/env.js +2 -1
  107. package/dist/renderer/error-boundary-dom.js +29 -0
  108. package/dist/renderer/error-boundary-dom.js.map +1 -0
  109. package/dist/renderer/evaluate-dom-range.js +85 -0
  110. package/dist/renderer/evaluate-dom-range.js.map +1 -0
  111. package/dist/renderer/evaluate-reconcile.js +281 -0
  112. package/dist/renderer/evaluate-reconcile.js.map +1 -0
  113. package/dist/renderer/evaluate.js +13 -399
  114. package/dist/renderer/evaluate.js.map +1 -1
  115. package/dist/renderer/fastpath.js +6 -5
  116. package/dist/renderer/fastpath.js.map +1 -1
  117. package/dist/renderer/for-commit-dom-map.js +83 -0
  118. package/dist/renderer/for-commit-dom-map.js.map +1 -0
  119. package/dist/renderer/for-commit-removal.js +36 -0
  120. package/dist/renderer/for-commit-removal.js.map +1 -0
  121. package/dist/renderer/for-commit-reorder.js +89 -0
  122. package/dist/renderer/for-commit-reorder.js.map +1 -0
  123. package/dist/renderer/for-commit.js +6 -188
  124. package/dist/renderer/for-commit.js.map +1 -1
  125. package/dist/renderer/index.js +28 -16
  126. package/dist/renderer/index.js.map +1 -1
  127. package/dist/renderer/keyed-children.js +32 -0
  128. package/dist/renderer/keyed-children.js.map +1 -0
  129. package/dist/renderer/keyed.js +2 -15
  130. package/dist/renderer/keyed.js.map +1 -1
  131. package/dist/renderer/namespaces.js +23 -0
  132. package/dist/renderer/namespaces.js.map +1 -0
  133. package/dist/renderer/prop-bindings.js +280 -0
  134. package/dist/renderer/prop-bindings.js.map +1 -0
  135. package/dist/renderer/reactive-child-dom.js +133 -0
  136. package/dist/renderer/reactive-child-dom.js.map +1 -0
  137. package/dist/renderer/reactive-child-sources.js +184 -0
  138. package/dist/renderer/reactive-child-sources.js.map +1 -0
  139. package/dist/renderer/reactive-children.js +294 -0
  140. package/dist/renderer/reactive-children.js.map +1 -0
  141. package/dist/renderer/reconcile-commit.js +38 -0
  142. package/dist/renderer/reconcile-commit.js.map +1 -0
  143. package/dist/renderer/reconcile-fastpaths.js +106 -0
  144. package/dist/renderer/reconcile-fastpaths.js.map +1 -0
  145. package/dist/renderer/reconcile-resolution.js +187 -0
  146. package/dist/renderer/reconcile-resolution.js.map +1 -0
  147. package/dist/renderer/reconcile.js +9 -371
  148. package/dist/renderer/reconcile.js.map +1 -1
  149. package/dist/renderer/retained-element-rollback.js +276 -0
  150. package/dist/renderer/retained-element-rollback.js.map +1 -0
  151. package/dist/renderer/stable-patch.js +82 -0
  152. package/dist/renderer/stable-patch.js.map +1 -0
  153. package/dist/renderer/static-reuse.js +96 -0
  154. package/dist/renderer/static-reuse.js.map +1 -0
  155. package/dist/renderer/types.js +2 -1
  156. package/dist/renderer/utils.js +4 -4
  157. package/dist/renderer/utils.js.map +1 -1
  158. package/dist/resources/index.d.ts +3 -2
  159. package/dist/resources/index.js +5 -2
  160. package/dist/router/access.js +36 -0
  161. package/dist/router/access.js.map +1 -0
  162. package/dist/router/activity.d.ts +10 -0
  163. package/dist/router/activity.d.ts.map +1 -0
  164. package/dist/router/activity.js +89 -0
  165. package/dist/router/activity.js.map +1 -0
  166. package/dist/router/authoring.d.ts +22 -0
  167. package/dist/router/authoring.d.ts.map +1 -0
  168. package/dist/router/authoring.js +198 -0
  169. package/dist/router/authoring.js.map +1 -0
  170. package/dist/router/index.d.ts +12 -4
  171. package/dist/router/index.js +9 -2
  172. package/dist/router/internal-types.d.ts +31 -0
  173. package/dist/router/internal-types.d.ts.map +1 -0
  174. package/dist/router/lazy.d.ts +19 -0
  175. package/dist/router/lazy.d.ts.map +1 -0
  176. package/dist/router/lazy.js +52 -0
  177. package/dist/router/lazy.js.map +1 -0
  178. package/dist/router/manifest.d.ts +10 -0
  179. package/dist/router/manifest.d.ts.map +1 -0
  180. package/dist/router/manifest.js +49 -0
  181. package/dist/router/manifest.js.map +1 -0
  182. package/dist/router/navigate.d.ts +4 -33
  183. package/dist/router/navigate.d.ts.map +1 -1
  184. package/dist/router/navigate.js +17 -414
  185. package/dist/router/navigate.js.map +1 -1
  186. package/dist/router/navigation-registry.d.ts +32 -0
  187. package/dist/router/navigation-registry.d.ts.map +1 -0
  188. package/dist/router/navigation-registry.js +105 -0
  189. package/dist/router/navigation-registry.js.map +1 -0
  190. package/dist/router/navigation-scroll.d.ts +14 -0
  191. package/dist/router/navigation-scroll.d.ts.map +1 -0
  192. package/dist/router/navigation-scroll.js +93 -0
  193. package/dist/router/navigation-scroll.js.map +1 -0
  194. package/dist/router/navigation-targets.d.ts +31 -0
  195. package/dist/router/navigation-targets.d.ts.map +1 -0
  196. package/dist/router/navigation-targets.js +253 -0
  197. package/dist/router/navigation-targets.js.map +1 -0
  198. package/dist/router/policy.d.ts +7 -1
  199. package/dist/router/policy.d.ts.map +1 -1
  200. package/dist/router/policy.js +27 -9
  201. package/dist/router/policy.js.map +1 -1
  202. package/dist/router/rendering.d.ts +10 -0
  203. package/dist/router/rendering.d.ts.map +1 -0
  204. package/dist/router/rendering.js +45 -0
  205. package/dist/router/rendering.js.map +1 -0
  206. package/dist/router/resolution.d.ts +17 -0
  207. package/dist/router/resolution.d.ts.map +1 -0
  208. package/dist/router/resolution.js +253 -0
  209. package/dist/router/resolution.js.map +1 -0
  210. package/dist/router/route-query.d.ts +17 -0
  211. package/dist/router/route-query.d.ts.map +1 -0
  212. package/dist/router/route-query.js +47 -0
  213. package/dist/router/route-query.js.map +1 -0
  214. package/dist/router/route.d.ts +8 -149
  215. package/dist/router/route.js +8 -854
  216. package/dist/router/store.d.ts +50 -0
  217. package/dist/router/store.d.ts.map +1 -0
  218. package/dist/router/store.js +171 -0
  219. package/dist/router/store.js.map +1 -0
  220. package/dist/runtime/access.js +45 -0
  221. package/dist/runtime/access.js.map +1 -0
  222. package/dist/runtime/child-scope.d.ts +1 -1
  223. package/dist/runtime/child-scope.js +4 -1
  224. package/dist/runtime/child-scope.js.map +1 -1
  225. package/dist/runtime/component-cleanup.d.ts +16 -0
  226. package/dist/runtime/component-cleanup.d.ts.map +1 -0
  227. package/dist/runtime/component-cleanup.js +70 -0
  228. package/dist/runtime/component-cleanup.js.map +1 -0
  229. package/dist/runtime/component-commit.js +165 -0
  230. package/dist/runtime/component-commit.js.map +1 -0
  231. package/dist/runtime/component-contracts.js +5 -0
  232. package/dist/runtime/component-facade.d.ts +5 -0
  233. package/dist/runtime/component-facade.js +4 -0
  234. package/dist/runtime/component-internal.d.ts +100 -0
  235. package/dist/runtime/component-internal.d.ts.map +1 -0
  236. package/dist/runtime/component-internal.js +219 -0
  237. package/dist/runtime/component-internal.js.map +1 -0
  238. package/dist/runtime/component-lifecycle.d.ts +49 -0
  239. package/dist/runtime/component-lifecycle.d.ts.map +1 -0
  240. package/dist/runtime/component-lifecycle.js +176 -0
  241. package/dist/runtime/component-lifecycle.js.map +1 -0
  242. package/dist/runtime/component-scope.d.ts +55 -0
  243. package/dist/runtime/component-scope.d.ts.map +1 -0
  244. package/dist/runtime/component-scope.js +154 -0
  245. package/dist/runtime/component-scope.js.map +1 -0
  246. package/dist/runtime/component.d.ts +4 -152
  247. package/dist/runtime/component.js +4 -692
  248. package/dist/runtime/context.d.ts +1 -1
  249. package/dist/runtime/context.js +6 -4
  250. package/dist/runtime/context.js.map +1 -1
  251. package/dist/runtime/control.d.ts +3 -3
  252. package/dist/runtime/control.js +2 -1
  253. package/dist/runtime/control.js.map +1 -1
  254. package/dist/runtime/derive.d.ts.map +1 -1
  255. package/dist/runtime/derive.js +6 -5
  256. package/dist/runtime/derive.js.map +1 -1
  257. package/dist/runtime/effect.d.ts +1 -1
  258. package/dist/runtime/effect.d.ts.map +1 -1
  259. package/dist/runtime/effect.js +2 -2
  260. package/dist/runtime/effect.js.map +1 -1
  261. package/dist/runtime/events.js +3 -3
  262. package/dist/runtime/events.js.map +1 -1
  263. package/dist/runtime/fastlane.js +13 -27
  264. package/dist/runtime/fastlane.js.map +1 -1
  265. package/dist/runtime/for-bench.d.ts +1 -1
  266. package/dist/runtime/for-bench.js +1 -4
  267. package/dist/runtime/for-bench.js.map +1 -1
  268. package/dist/runtime/for-internal.d.ts +43 -0
  269. package/dist/runtime/for-internal.d.ts.map +1 -0
  270. package/dist/runtime/for-internal.js +98 -0
  271. package/dist/runtime/for-internal.js.map +1 -0
  272. package/dist/runtime/for-reconcile.d.ts +8 -0
  273. package/dist/runtime/for-reconcile.d.ts.map +1 -0
  274. package/dist/runtime/for-reconcile.js +389 -0
  275. package/dist/runtime/for-reconcile.js.map +1 -0
  276. package/dist/runtime/for-scopes.d.ts +26 -0
  277. package/dist/runtime/for-scopes.d.ts.map +1 -0
  278. package/dist/runtime/for-scopes.js +160 -0
  279. package/dist/runtime/for-scopes.js.map +1 -0
  280. package/dist/runtime/for-signals.d.ts +30 -0
  281. package/dist/runtime/for-signals.d.ts.map +1 -0
  282. package/dist/runtime/for-signals.js +139 -0
  283. package/dist/runtime/for-signals.js.map +1 -0
  284. package/dist/runtime/for.d.ts +4 -66
  285. package/dist/runtime/for.js +5 -773
  286. package/dist/runtime/lifecycle-operations.d.ts +31 -0
  287. package/dist/runtime/lifecycle-operations.d.ts.map +1 -0
  288. package/dist/runtime/lifecycle-operations.js +195 -0
  289. package/dist/runtime/lifecycle-operations.js.map +1 -0
  290. package/dist/runtime/operations.d.ts +3 -40
  291. package/dist/runtime/operations.js +2 -357
  292. package/dist/runtime/readable.d.ts +2 -3
  293. package/dist/runtime/readable.d.ts.map +1 -1
  294. package/dist/runtime/readable.js +6 -5
  295. package/dist/runtime/readable.js.map +1 -1
  296. package/dist/runtime/resource-cell.js +2 -2
  297. package/dist/runtime/resource-cell.js.map +1 -1
  298. package/dist/runtime/resource-operation.d.ts +13 -0
  299. package/dist/runtime/resource-operation.d.ts.map +1 -0
  300. package/dist/runtime/resource-operation.js +170 -0
  301. package/dist/runtime/resource-operation.js.map +1 -0
  302. package/dist/runtime/runtime.d.ts +42 -0
  303. package/dist/runtime/runtime.d.ts.map +1 -0
  304. package/dist/runtime/runtime.js +59 -0
  305. package/dist/runtime/runtime.js.map +1 -0
  306. package/dist/runtime/scheduler.d.ts +5 -1
  307. package/dist/runtime/scheduler.d.ts.map +1 -1
  308. package/dist/runtime/scheduler.js +17 -17
  309. package/dist/runtime/scheduler.js.map +1 -1
  310. package/dist/runtime/selector.js +4 -3
  311. package/dist/runtime/selector.js.map +1 -1
  312. package/dist/runtime/snapshot-source.d.ts +1 -1
  313. package/dist/runtime/snapshot-source.js +1 -1
  314. package/dist/runtime/state.js +2 -1
  315. package/dist/runtime/state.js.map +1 -1
  316. package/dist/ssg/batch-render.js +2 -1
  317. package/dist/ssg/batch-render.js.map +1 -1
  318. package/dist/ssg/create-static-gen.d.ts +9 -3
  319. package/dist/ssg/create-static-gen.d.ts.map +1 -1
  320. package/dist/ssg/create-static-gen.js +12 -99
  321. package/dist/ssg/create-static-gen.js.map +1 -1
  322. package/dist/ssg/generation-plan.js +70 -0
  323. package/dist/ssg/generation-plan.js.map +1 -0
  324. package/dist/ssg/incremental-manifest.js +1 -1
  325. package/dist/ssg/static-routes.js +101 -0
  326. package/dist/ssg/static-routes.js.map +1 -0
  327. package/dist/ssg/types.d.ts +15 -7
  328. package/dist/ssg/types.d.ts.map +1 -1
  329. package/dist/ssr/boundaries.js +113 -0
  330. package/dist/ssr/boundaries.js.map +1 -0
  331. package/dist/ssr/component-runtime.js +111 -0
  332. package/dist/ssr/component-runtime.js.map +1 -0
  333. package/dist/ssr/context.d.ts +3 -1
  334. package/dist/ssr/context.d.ts.map +1 -1
  335. package/dist/ssr/context.js +9 -2
  336. package/dist/ssr/context.js.map +1 -1
  337. package/dist/ssr/errors.d.ts +2 -0
  338. package/dist/ssr/errors.js +11 -1
  339. package/dist/ssr/errors.js.map +1 -1
  340. package/dist/ssr/escape.js +3 -3
  341. package/dist/ssr/escape.js.map +1 -1
  342. package/dist/ssr/hydration-data.js +10 -0
  343. package/dist/ssr/hydration-data.js.map +1 -0
  344. package/dist/ssr/hydration-verify.d.ts +12 -0
  345. package/dist/ssr/hydration-verify.d.ts.map +1 -0
  346. package/dist/ssr/hydration-verify.js +144 -0
  347. package/dist/ssr/hydration-verify.js.map +1 -0
  348. package/dist/ssr/index-internal.d.ts +15 -0
  349. package/dist/ssr/index-internal.d.ts.map +1 -0
  350. package/dist/ssr/index-internal.js +19 -0
  351. package/dist/ssr/index-internal.js.map +1 -0
  352. package/dist/ssr/index.d.ts +5 -57
  353. package/dist/ssr/index.js +3 -738
  354. package/dist/ssr/render-keys.js +9 -32
  355. package/dist/ssr/render-keys.js.map +1 -1
  356. package/dist/ssr/render-resolved.d.ts +1 -1
  357. package/dist/ssr/render-resolved.d.ts.map +1 -1
  358. package/dist/ssr/render-resolved.js +4 -2
  359. package/dist/ssr/render-resolved.js.map +1 -1
  360. package/dist/ssr/render-sync.d.ts +21 -0
  361. package/dist/ssr/render-sync.d.ts.map +1 -0
  362. package/dist/ssr/render-sync.js +275 -0
  363. package/dist/ssr/render-sync.js.map +1 -0
  364. package/dist/ssr/route-policy-resolution.js +77 -0
  365. package/dist/ssr/route-policy-resolution.js.map +1 -0
  366. package/dist/ssr/route-render.d.ts +77 -0
  367. package/dist/ssr/route-render.d.ts.map +1 -0
  368. package/dist/ssr/route-render.js +119 -0
  369. package/dist/ssr/route-render.js.map +1 -0
  370. package/dist/ssr/sink.d.ts +26 -0
  371. package/dist/ssr/sink.d.ts.map +1 -0
  372. package/dist/ssr/types.d.ts +1 -0
  373. package/dist/ssr/types.d.ts.map +1 -1
  374. package/dist/ssr/verify-hydration.js.map +1 -1
  375. package/dist/testing/index.d.ts +1 -2
  376. package/dist/testing/index.d.ts.map +1 -1
  377. package/dist/testing/index.js +2 -1
  378. package/dist/testing/index.js.map +1 -1
  379. package/package.json +4 -3
  380. package/dist/data/index.d.ts.map +0 -1
  381. package/dist/data/index.js.map +0 -1
  382. package/dist/renderer/dom.js.map +0 -1
  383. package/dist/router/route.d.ts.map +0 -1
  384. package/dist/router/route.js.map +0 -1
  385. package/dist/runtime/component.d.ts.map +0 -1
  386. package/dist/runtime/component.js.map +0 -1
  387. package/dist/runtime/for.d.ts.map +0 -1
  388. package/dist/runtime/for.js.map +0 -1
  389. package/dist/runtime/operations.d.ts.map +0 -1
  390. package/dist/runtime/operations.js.map +0 -1
  391. package/dist/runtime/ssr-bridge.js +0 -24
  392. package/dist/runtime/ssr-bridge.js.map +0 -1
  393. package/dist/ssr/index.d.ts.map +0 -1
  394. package/dist/ssr/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_evaluate","_markReactivePropsDirtySource"],"sources":["../../src/renderer/index.ts"],"sourcesContent":["// Renderer barrel entrypoint.\n// Keep this file small: re-export the public surface and attach the runtime\n// fast-lane bridge on import.\n\nexport * from './types';\nexport * from './cleanup';\nexport {\n keyedElements,\n getKeyMapForElement,\n populateKeyMapForElement,\n _reconcilerRecordedParents,\n isKeyedReorderFastPathEligible,\n} from './keyed';\nexport * from './dom';\nexport { evaluate, clearDOMRange } from './evaluate';\n\nimport { evaluate as _evaluate } from './evaluate';\nimport { isKeyedReorderFastPathEligible, getKeyMapForElement } from './keyed';\nimport { markReactivePropsDirtySource as _markReactivePropsDirtySource } from './dom';\n\nexport function installRendererBridge(): true {\n if (typeof globalThis !== 'undefined') {\n const _g = globalThis as Record<string, unknown>;\n _g.__ASKR_RENDERER = {\n evaluate: _evaluate,\n isKeyedReorderFastPathEligible,\n getKeyMapForElement,\n markReactivePropsDirtySource: _markReactivePropsDirtySource,\n };\n }\n return true;\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,wBAA8B;CAC5C,IAAI,OAAO,eAAe,aAAa;EACrC,MAAM,KAAK;EACX,GAAG,kBAAkB;GACTA;GACV;GACA;GAC8BC;EAChC;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"index.js","names":["_evaluate","_markReactivePropsDirtySource"],"sources":["../../src/renderer/index.ts"],"sourcesContent":["// Renderer barrel entrypoint.\n// Keep this file small: re-export the public surface and provide the runtime\n// renderer host used by browser composition.\n\nexport * from './types';\nexport * from './cleanup';\nexport {\n keyedElements,\n getKeyMapForElement,\n populateKeyMapForElement,\n _reconcilerRecordedParents,\n isKeyedReorderFastPathEligible,\n} from './keyed';\nexport * from './dom';\nexport { evaluate, clearDOMRange } from './evaluate';\n\nimport { evaluate as _evaluate } from './evaluate';\nimport { cleanupInstancesUnder, teardownNodeSubtree } from './cleanup';\nimport { isKeyedReorderFastPathEligible, getKeyMapForElement } from './keyed';\nimport { populateKeyMapForElement } from './keyed';\nimport { markReactivePropsDirtySource as _markReactivePropsDirtySource } from './dom';\nimport { getDefaultRuntimeInstance } from '../runtime/access';\nimport {\n configureRuntimeRenderer,\n type AskrRuntime,\n type RuntimeRendererHost,\n} from '../runtime/runtime';\n\nexport function createRendererHost(): RuntimeRendererHost {\n return {\n evaluate: _evaluate,\n cleanupInstancesUnder,\n teardownNodeSubtree,\n populateKeyMapForElement,\n getKeyMapForElement,\n isKeyedReorderFastPathEligible,\n markReactivePropsDirtySource: _markReactivePropsDirtySource,\n };\n}\n\nexport function installRendererBridge(\n runtime: AskrRuntime = getDefaultRuntimeInstance()\n): true {\n configureRuntimeRenderer(createRendererHost(), runtime);\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,SAAgB,qBAA0C;CACxD,OAAO;EACKA;EACV;EACA;EACA;EACA;EACA;EAC8BC;CAChC;AACF;AAEA,SAAgB,sBACd,UAAuB,0BAA0B,GAC3C;CACN,yBAAyB,mBAAmB,GAAG,OAAO;CACtD,OAAO;AACT"}
@@ -0,0 +1,32 @@
1
+ import { extractKey } from "./utils.js";
2
+ //#region src/renderer/keyed-children.ts
3
+ function extractKeyedVnodes(newChildren) {
4
+ const keyedVnodes = [];
5
+ for (let i = 0; i < newChildren.length; i++) {
6
+ const child = newChildren[i];
7
+ const key = extractKey(child);
8
+ if (key !== void 0) keyedVnodes.push({
9
+ key,
10
+ vnode: child
11
+ });
12
+ }
13
+ return keyedVnodes;
14
+ }
15
+ function buildDOMKeyMap(parent) {
16
+ const keyMap = /* @__PURE__ */ new Map();
17
+ try {
18
+ for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
19
+ const k = el.getAttribute("data-key");
20
+ if (k !== null) {
21
+ keyMap.set(k, el);
22
+ const n = Number(k);
23
+ if (!Number.isNaN(n)) keyMap.set(n, el);
24
+ }
25
+ }
26
+ } catch {}
27
+ return keyMap;
28
+ }
29
+ //#endregion
30
+ export { buildDOMKeyMap, extractKeyedVnodes };
31
+
32
+ //# sourceMappingURL=keyed-children.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-children.js","names":[],"sources":["../../src/renderer/keyed-children.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { extractKey } from './utils';\n\nexport interface KeyedVnode {\n key: string | number;\n vnode: VNode;\n}\n\nexport function extractKeyedVnodes(newChildren: VNode[]): KeyedVnode[] {\n const keyedVnodes: KeyedVnode[] = [];\n\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const key = extractKey(child);\n if (key !== undefined) {\n keyedVnodes.push({ key, vnode: child });\n }\n }\n\n return keyedVnodes;\n}\n\nexport function buildDOMKeyMap(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, el);\n }\n }\n } catch {\n // Ignore DOM access failures; callers can fall back to reconciliation.\n }\n return keyMap;\n}\n"],"mappings":";;AAQA,SAAgB,mBAAmB,aAAoC;CACrE,MAAM,cAA4B,CAAC;CAEnC,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,QAAQ,YAAY;EAC1B,MAAM,MAAM,WAAW,KAAK;EAC5B,IAAI,QAAQ,QACV,YAAY,KAAK;GAAE;GAAK,OAAO;EAAM,CAAC;CAE1C;CAEA,OAAO;AACT;AAEA,SAAgB,eAAe,QAAgD;CAC7E,MAAM,yBAAS,IAAI,IAA8B;CACjD,IAAI;EACF,KAAK,IAAI,KAAK,OAAO,mBAAmB,IAAI,KAAK,GAAG,oBAAoB;GACtE,MAAM,IAAI,GAAG,aAAa,UAAU;GACpC,IAAI,MAAM,MAAM;IACd,OAAO,IAAI,GAAG,EAAE;IAChB,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,CAAC,OAAO,MAAM,CAAC,GAAG,OAAO,IAAI,GAAG,EAAE;GACxC;EACF;CACF,QAAQ,CAER;CACA,OAAO;AACT"}
@@ -1,4 +1,5 @@
1
- import { buildKeyMapFromChildren, extractKey, hasPropChanged, isIgnoredForPropChanges } from "./utils.js";
1
+ import { buildKeyMapFromChildren, hasPropChanged, isIgnoredForPropChanges } from "./utils.js";
2
+ import { extractKeyedVnodes } from "./keyed-children.js";
2
3
  //#region src/renderer/keyed.ts
3
4
  const keyedElements = /* @__PURE__ */ new WeakMap();
4
5
  /**
@@ -33,20 +34,6 @@ function populateKeyMapForElement(parent) {
33
34
  const _reconcilerRecordedParents = /* @__PURE__ */ new WeakSet();
34
35
  const LIS_THRESHOLD_MIN = 64;
35
36
  /**
36
- * Extract keyed vnodes from children array
37
- */
38
- function extractKeyedVnodes(newChildren) {
39
- const result = [];
40
- for (const child of newChildren) {
41
- const key = extractKey(child);
42
- if (key !== void 0) result.push({
43
- key,
44
- vnode: child
45
- });
46
- }
47
- return result;
48
- }
49
- /**
50
37
  * Compute LIS (Longest Increasing Subsequence) length for positions
51
38
  */
52
39
  function computeLISLength(positions) {
@@ -1 +1 @@
1
- {"version":3,"file":"keyed.js","names":[],"sources":["../../src/renderer/keyed.ts"],"sourcesContent":["import type { VNode } from './types';\nimport {\n extractKey,\n isIgnoredForPropChanges,\n hasPropChanged,\n buildKeyMapFromChildren,\n} from './utils';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Map Registry\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const keyedElements = new WeakMap<\n Element,\n Map<string | number, Element>\n>();\n\n/**\n * Retrieve existing keyed map for a parent element (runtime use)\n */\nexport function getKeyMapForElement(el: Element) {\n return keyedElements.get(el);\n}\n\n/**\n * Populate a keyed map for an element by scanning its immediate children\n * for `data-key` attributes. Proactive initialization for runtime layers.\n */\nexport function populateKeyMapForElement(parent: Element): void {\n try {\n if (keyedElements.has(parent)) return;\n\n let domMap = buildKeyMapFromChildren(parent);\n\n // Fallback: map by textContent when keys are not materialized as attrs\n if (domMap.size === 0) {\n domMap = new Map();\n const children = Array.from(parent.children);\n for (const ch of children) {\n const text = (ch.textContent || '').trim();\n if (text) {\n domMap.set(text, ch);\n const n = Number(text);\n if (!Number.isNaN(n)) domMap.set(n, ch);\n }\n }\n }\n\n if (domMap.size > 0) keyedElements.set(parent, domMap);\n } catch {\n // ignore\n }\n}\n\n// Track which parents had the reconciler record fast-path stats during the\n// current evaluation, so we can preserve diagnostics across additional\n// reconciliations within the same render pass without leaking between runs.\nexport const _reconcilerRecordedParents = new WeakSet<Element>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Fast-Path Eligibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Configuration: LIS fast-path thresholds\nconst LIS_THRESHOLD_MIN = 64; // Minimum list size for LIS optimization\n\nexport interface KeyedVnode {\n key: string | number;\n vnode: VNode;\n}\n\n/**\n * Extract keyed vnodes from children array\n */\nfunction extractKeyedVnodes(newChildren: VNode[]): KeyedVnode[] {\n const result: KeyedVnode[] = [];\n for (const child of newChildren) {\n const key = extractKey(child);\n if (key !== undefined) {\n result.push({ key, vnode: child });\n }\n }\n return result;\n}\n\n/**\n * Compute LIS (Longest Increasing Subsequence) length for positions\n */\nfunction computeLISLength(positions: number[]): number {\n const tails: number[] = [];\n for (const pos of positions) {\n if (pos === -1) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (tails[mid] < pos) lo = mid + 1;\n else hi = mid;\n }\n if (lo === tails.length) tails.push(pos);\n else tails[lo] = pos;\n }\n return tails.length;\n}\n\ninterface CurrentKeyOrderSnapshot {\n keyCount: number;\n currentKeys: string[];\n}\n\nfunction collectCurrentKeyOrder(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined\n): CurrentKeyOrderSnapshot {\n const currentKeys: string[] = [];\n\n if (oldKeyMap && oldKeyMap.size > 0) {\n let lastElement: Element | null = null;\n let keyCount = 0;\n\n for (const [key, el] of oldKeyMap) {\n if (el === lastElement) {\n continue;\n }\n\n lastElement = el;\n const normalizedKey = String(key);\n currentKeys.push(normalizedKey);\n\n keyCount++;\n }\n\n if (keyCount > 0) {\n return { keyCount, currentKeys };\n }\n }\n\n let keyCount = 0;\n\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const keyAttr = el.getAttribute('data-key');\n if (keyAttr === null) {\n continue;\n }\n\n currentKeys.push(keyAttr);\n keyCount++;\n }\n } catch {\n // ignore\n }\n\n return { keyCount, currentKeys };\n}\n\n/**\n * Check for prop changes between vnodes and existing elements\n */\nexport interface KeyedReorderDecision {\n useFastPath: boolean;\n totalKeyed: number;\n totalChildren: number;\n currentKeyCount: number;\n moveCount: number;\n lisLen: number;\n hasPropChanges: boolean;\n isWholeKeyedList: boolean;\n}\n\nfunction checkVnodePropChanges(\n keyedVnodes: KeyedVnode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): boolean {\n for (const { key, vnode } of keyedVnodes) {\n const el = oldKeyMap?.get(key);\n if (!el || typeof vnode !== 'object' || vnode === null) continue;\n const vnodeObj = vnode as unknown as { props?: Record<string, unknown> };\n const props = vnodeObj.props || {};\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Plan keyed reorder eligibility from one snapshot of keyed order and props.\n */\nexport function planKeyedReorderFastPath(\n parent: Element,\n keyedVnodes: KeyedVnode[],\n totalChildren: number,\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorderDecision {\n const totalKeyed = keyedVnodes.length;\n const isWholeKeyedList = totalKeyed === totalChildren;\n const shouldEvaluateShape =\n isWholeKeyedList && totalKeyed >= LIS_THRESHOLD_MIN;\n\n if (!shouldEvaluateShape) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);\n if (hasPropChanges) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges,\n isWholeKeyedList,\n };\n }\n\n const { keyCount: currentKeyCount, currentKeys } = collectCurrentKeyOrder(\n parent,\n oldKeyMap\n );\n\n let moveCount = 0;\n for (let i = 0; i < totalKeyed; i++) {\n if (currentKeys[i] !== String(keyedVnodes[i].key)) {\n moveCount++;\n }\n }\n\n const FAST_MOVE_THRESHOLD_ABS = 64;\n const FAST_MOVE_THRESHOLD_REL = 0.1;\n const cheapMoveTrigger =\n shouldEvaluateShape &&\n currentKeyCount > 0 &&\n moveCount >\n Math.max(\n FAST_MOVE_THRESHOLD_ABS,\n Math.floor(totalKeyed * FAST_MOVE_THRESHOLD_REL)\n );\n\n let lisTrigger = false;\n let lisLen = 0;\n if (shouldEvaluateShape && !cheapMoveTrigger) {\n const indexByKey = new Map<string, number>();\n for (let i = 0; i < currentKeys.length; i++) {\n indexByKey.set(currentKeys[i], i);\n }\n\n const positions: number[] = Array(totalKeyed).fill(-1);\n for (let i = 0; i < totalKeyed; i++) {\n positions[i] = indexByKey.get(String(keyedVnodes[i].key)) ?? -1;\n }\n lisLen = computeLISLength(positions);\n lisTrigger = lisLen < Math.floor(totalKeyed * 0.5);\n }\n\n if (!shouldEvaluateShape || !(cheapMoveTrigger || lisTrigger)) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n return {\n useFastPath: true,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n } as const;\n}\n\nexport function isKeyedReorderFastPathEligible(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorderDecision {\n return planKeyedReorderFastPath(\n parent,\n extractKeyedVnodes(newChildren),\n newChildren.length,\n oldKeyMap\n );\n}\n"],"mappings":";;AAYA,MAAa,gCAAgB,IAAI,QAG/B;;;;AAKF,SAAgB,oBAAoB,IAAa;CAC/C,OAAO,cAAc,IAAI,EAAE;AAC7B;;;;;AAMA,SAAgB,yBAAyB,QAAuB;CAC9D,IAAI;EACF,IAAI,cAAc,IAAI,MAAM,GAAG;EAE/B,IAAI,SAAS,wBAAwB,MAAM;EAG3C,IAAI,OAA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I,YAAY,OAAO,OAAO,YAAY,EAAE,CAAC,GAAG,GAC9C;CAMJ,MAAM,mBACJ,uBACA,kBAAkB,KAClB,YACE,KAAK,IACH,IACA,KAAK,MAAM,aAAa,EAAuB,CACjD;CAEJ,IAAI,aAAa;CACjB,IAAI,SAAS;CACb,IAAI,uBAAuB,CAAC,kBAAkB;EAC5C,MAAM,6BAAa,IAAI,IAAoB;EAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,WAAW,IAAI,YAAY,IAAI,CAAC;EAGlC,MAAM,YAAsB,MAAM,UAAU,CAAC,CAAC,KAAK,EAAE;EACrD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,UAAU,KAAK,WAAW,IAAI,OAAO,YAAY,EAAE,CAAC,GAAG,CAAC,KAAK;EAE/D,SAAS,iBAAiB,SAAS;EACnC,aAAa,SAAS,KAAK,MAAM,aAAa,EAAG;CACnD;CAEA,IAAI,CAAC,uBAAuB,EAAE,oBAAoB,aAChD,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;CACF;CAGF,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;CACF;AACF;AAEA,SAAgB,+BACd,QACA,aACA,WACsB;CACtB,OAAO,yBACL,QACA,mBAAmB,WAAW,GAC9B,YAAY,QACZ,SACF;AACF"}
1
+ {"version":3,"file":"keyed.js","names":[],"sources":["../../src/renderer/keyed.ts"],"sourcesContent":["import type { VNode } from './types';\nimport { extractKeyedVnodes, type KeyedVnode } from './keyed-children';\nimport {\n isIgnoredForPropChanges,\n hasPropChanged,\n buildKeyMapFromChildren,\n} from './utils';\n\nexport type { KeyedVnode } from './keyed-children';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Key Map Registry\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const keyedElements = new WeakMap<\n Element,\n Map<string | number, Element>\n>();\n\n/**\n * Retrieve existing keyed map for a parent element (runtime use)\n */\nexport function getKeyMapForElement(el: Element) {\n return keyedElements.get(el);\n}\n\n/**\n * Populate a keyed map for an element by scanning its immediate children\n * for `data-key` attributes. Proactive initialization for runtime layers.\n */\nexport function populateKeyMapForElement(parent: Element): void {\n try {\n if (keyedElements.has(parent)) return;\n\n let domMap = buildKeyMapFromChildren(parent);\n\n // Fallback: map by textContent when keys are not materialized as attrs\n if (domMap.size === 0) {\n domMap = new Map();\n const children = Array.from(parent.children);\n for (const ch of children) {\n const text = (ch.textContent || '').trim();\n if (text) {\n domMap.set(text, ch);\n const n = Number(text);\n if (!Number.isNaN(n)) domMap.set(n, ch);\n }\n }\n }\n\n if (domMap.size > 0) keyedElements.set(parent, domMap);\n } catch {\n // ignore\n }\n}\n\n// Track which parents had the reconciler record fast-path stats during the\n// current evaluation, so we can preserve diagnostics across additional\n// reconciliations within the same render pass without leaking between runs.\nexport const _reconcilerRecordedParents = new WeakSet<Element>();\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Fast-Path Eligibility\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Configuration: LIS fast-path thresholds\nconst LIS_THRESHOLD_MIN = 64; // Minimum list size for LIS optimization\n\n/**\n * Compute LIS (Longest Increasing Subsequence) length for positions\n */\nfunction computeLISLength(positions: number[]): number {\n const tails: number[] = [];\n for (const pos of positions) {\n if (pos === -1) continue;\n let lo = 0;\n let hi = tails.length;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (tails[mid] < pos) lo = mid + 1;\n else hi = mid;\n }\n if (lo === tails.length) tails.push(pos);\n else tails[lo] = pos;\n }\n return tails.length;\n}\n\ninterface CurrentKeyOrderSnapshot {\n keyCount: number;\n currentKeys: string[];\n}\n\nfunction collectCurrentKeyOrder(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined\n): CurrentKeyOrderSnapshot {\n const currentKeys: string[] = [];\n\n if (oldKeyMap && oldKeyMap.size > 0) {\n let lastElement: Element | null = null;\n let keyCount = 0;\n\n for (const [key, el] of oldKeyMap) {\n if (el === lastElement) {\n continue;\n }\n\n lastElement = el;\n const normalizedKey = String(key);\n currentKeys.push(normalizedKey);\n\n keyCount++;\n }\n\n if (keyCount > 0) {\n return { keyCount, currentKeys };\n }\n }\n\n let keyCount = 0;\n\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const keyAttr = el.getAttribute('data-key');\n if (keyAttr === null) {\n continue;\n }\n\n currentKeys.push(keyAttr);\n keyCount++;\n }\n } catch {\n // ignore\n }\n\n return { keyCount, currentKeys };\n}\n\n/**\n * Check for prop changes between vnodes and existing elements\n */\nexport interface KeyedReorderDecision {\n useFastPath: boolean;\n totalKeyed: number;\n totalChildren: number;\n currentKeyCount: number;\n moveCount: number;\n lisLen: number;\n hasPropChanges: boolean;\n isWholeKeyedList: boolean;\n}\n\nfunction checkVnodePropChanges(\n keyedVnodes: KeyedVnode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): boolean {\n for (const { key, vnode } of keyedVnodes) {\n const el = oldKeyMap?.get(key);\n if (!el || typeof vnode !== 'object' || vnode === null) continue;\n const vnodeObj = vnode as unknown as { props?: Record<string, unknown> };\n const props = vnodeObj.props || {};\n for (const k of Object.keys(props)) {\n if (isIgnoredForPropChanges(k)) continue;\n if (hasPropChanged(el, k, props[k])) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Plan keyed reorder eligibility from one snapshot of keyed order and props.\n */\nexport function planKeyedReorderFastPath(\n parent: Element,\n keyedVnodes: KeyedVnode[],\n totalChildren: number,\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorderDecision {\n const totalKeyed = keyedVnodes.length;\n const isWholeKeyedList = totalKeyed === totalChildren;\n const shouldEvaluateShape =\n isWholeKeyedList && totalKeyed >= LIS_THRESHOLD_MIN;\n\n if (!shouldEvaluateShape) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);\n if (hasPropChanges) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges,\n isWholeKeyedList,\n };\n }\n\n const { keyCount: currentKeyCount, currentKeys } = collectCurrentKeyOrder(\n parent,\n oldKeyMap\n );\n\n let moveCount = 0;\n for (let i = 0; i < totalKeyed; i++) {\n if (currentKeys[i] !== String(keyedVnodes[i].key)) {\n moveCount++;\n }\n }\n\n const FAST_MOVE_THRESHOLD_ABS = 64;\n const FAST_MOVE_THRESHOLD_REL = 0.1;\n const cheapMoveTrigger =\n shouldEvaluateShape &&\n currentKeyCount > 0 &&\n moveCount >\n Math.max(\n FAST_MOVE_THRESHOLD_ABS,\n Math.floor(totalKeyed * FAST_MOVE_THRESHOLD_REL)\n );\n\n let lisTrigger = false;\n let lisLen = 0;\n if (shouldEvaluateShape && !cheapMoveTrigger) {\n const indexByKey = new Map<string, number>();\n for (let i = 0; i < currentKeys.length; i++) {\n indexByKey.set(currentKeys[i], i);\n }\n\n const positions: number[] = Array(totalKeyed).fill(-1);\n for (let i = 0; i < totalKeyed; i++) {\n positions[i] = indexByKey.get(String(keyedVnodes[i].key)) ?? -1;\n }\n lisLen = computeLISLength(positions);\n lisTrigger = lisLen < Math.floor(totalKeyed * 0.5);\n }\n\n if (!shouldEvaluateShape || !(cheapMoveTrigger || lisTrigger)) {\n return {\n useFastPath: false,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n };\n }\n\n return {\n useFastPath: true,\n totalKeyed,\n totalChildren,\n currentKeyCount,\n moveCount,\n lisLen,\n hasPropChanges: false,\n isWholeKeyedList,\n } as const;\n}\n\nexport function isKeyedReorderFastPathEligible(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): KeyedReorder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AAM,EAAE,UAAU,iBAAiB,gBAAgB,uBACjD,QACA,SACF;CAEA,IAAI,YAAY;CAChB,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,IAAI,YAAY,OAAO,OAAO,YAAY,EAAE,CAAC,GAAG,GAC9C;CAMJ,MAAM,mBACJ,uBACA,kBAAkB,KAClB,YACE,KAAK,IACH,IACA,KAAK,MAAM,aAAa,EAAuB,CACjD;CAEJ,IAAI,aAAa;CACjB,IAAI,SAAS;CACb,IAAI,uBAAuB,CAAC,kBAAkB;EAC5C,MAAM,6BAAa,IAAI,IAAoB;EAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,WAAW,IAAI,YAAY,IAAI,CAAC;EAGlC,MAAM,YAAsB,MAAM,UAAU,CAAC,CAAC,KAAK,EAAE;EACrD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAC9B,UAAU,KAAK,WAAW,IAAI,OAAO,YAAY,EAAE,CAAC,GAAG,CAAC,KAAK;EAE/D,SAAS,iBAAiB,SAAS;EACnC,aAAa,SAAS,KAAK,MAAM,aAAa,EAAG;CACnD;CAEA,IAAI,CAAC,uBAAuB,EAAE,oBAAoB,aAChD,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;CACF;CAGF,OAAO;EACL,aAAa;EACb;EACA;EACA;EACA;EACA;EACA,gBAAgB;EAChB;CACF;AACF;AAEA,SAAgB,+BACd,QACA,aACA,WACsB;CACtB,OAAO,yBACL,QACA,mBAAmB,WAAW,GAC9B,YAAY,QACZ,SACF;AACF"}
@@ -0,0 +1,23 @@
1
+ import { tagNamesEqualIgnoreCase } from "./utils.js";
2
+ //#region src/renderer/namespaces.ts
3
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
4
+ function getParentNamespace(parent) {
5
+ return parent.namespaceURI === "http://www.w3.org/2000/svg" ? SVG_NAMESPACE : void 0;
6
+ }
7
+ function resolveChildNamespace(type, parentNamespace) {
8
+ if (type === "svg") return SVG_NAMESPACE;
9
+ if (parentNamespace === "http://www.w3.org/2000/svg" && type !== "foreignObject") return SVG_NAMESPACE;
10
+ }
11
+ function createElementForNamespace(type, parentNamespace, ownerDocument = document) {
12
+ const namespace = resolveChildNamespace(type, parentNamespace);
13
+ return namespace ? ownerDocument.createElementNS(namespace, type) : ownerDocument.createElement(type);
14
+ }
15
+ function canReuseIntrinsicElementInNamespace(existing, type, parentNamespace) {
16
+ if (!tagNamesEqualIgnoreCase(existing.tagName, type)) return false;
17
+ const expectedNamespace = resolveChildNamespace(type, parentNamespace);
18
+ return expectedNamespace === void 0 ? true : existing.namespaceURI === expectedNamespace;
19
+ }
20
+ //#endregion
21
+ export { SVG_NAMESPACE, canReuseIntrinsicElementInNamespace, createElementForNamespace, getParentNamespace, resolveChildNamespace };
22
+
23
+ //# sourceMappingURL=namespaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaces.js","names":[],"sources":["../../src/renderer/namespaces.ts"],"sourcesContent":["import { tagNamesEqualIgnoreCase } from './utils';\n\nexport const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\nexport function getParentNamespace(parent: Element): string | undefined {\n return parent.namespaceURI === SVG_NAMESPACE ? SVG_NAMESPACE : undefined;\n}\n\nexport function resolveChildNamespace(\n type: string,\n parentNamespace?: string\n): string | undefined {\n if (type === 'svg') return SVG_NAMESPACE;\n if (parentNamespace === SVG_NAMESPACE && type !== 'foreignObject') {\n return SVG_NAMESPACE;\n }\n return undefined;\n}\n\nexport function createElementForNamespace(\n type: string,\n parentNamespace?: string,\n ownerDocument: Document = document\n): Element {\n const namespace = resolveChildNamespace(type, parentNamespace);\n return namespace\n ? ownerDocument.createElementNS(namespace, type)\n : ownerDocument.createElement(type);\n}\n\nexport function canReuseIntrinsicElementInNamespace(\n existing: Element,\n type: string,\n parentNamespace: string | undefined\n): boolean {\n if (!tagNamesEqualIgnoreCase(existing.tagName, type)) {\n return false;\n }\n\n const expectedNamespace = resolveChildNamespace(type, parentNamespace);\n return expectedNamespace === undefined\n ? true\n : existing.namespaceURI === expectedNamespace;\n}\n"],"mappings":";;AAEA,MAAa,gBAAgB;AAE7B,SAAgB,mBAAmB,QAAqC;CACtE,OAAO,OAAO,iBAAA,+BAAiC,gBAAgB;AACjE;AAEA,SAAgB,sBACd,MACA,iBACoB;CACpB,IAAI,SAAS,OAAO,OAAO;CAC3B,IAAI,oBAAA,gCAAqC,SAAS,iBAChD,OAAO;AAGX;AAEA,SAAgB,0BACd,MACA,iBACA,gBAA0B,UACjB;CACT,MAAM,YAAY,sBAAsB,MAAM,eAAe;CAC7D,OAAO,YACH,cAAc,gBAAgB,WAAW,IAAI,IAC7C,cAAc,cAAc,IAAI;AACtC;AAEA,SAAgB,oCACd,UACA,MACA,iBACS;CACT,IAAI,CAAC,wBAAwB,SAAS,SAAS,IAAI,GACjD,OAAO;CAGT,MAAM,oBAAoB,sBAAsB,MAAM,eAAe;CACrE,OAAO,sBAAsB,SACzB,OACA,SAAS,iBAAiB;AAChC"}
@@ -0,0 +1,280 @@
1
+ import { getRuntimeEnv } from "../common/env.js";
2
+ import { logger } from "../dev/logger.js";
3
+ import { incrementPerfMetric } from "../runtime/perf-metrics.js";
4
+ import { incDevCounter } from "../runtime/dev-namespace.js";
5
+ import { addDelegatedListener, getDelegatedHandlerForElement, getDelegatedHandlersForElement, isDelegatedEvent, isEventDelegationEnabled, removeDelegatedListener, updateDelegatedListener } from "../runtime/events.js";
6
+ import { REACTIVE_CHILDREN_KEY, elementListeners, elementReactivePropsCleanup, updateElementRef } from "./cleanup.js";
7
+ import "./env.js";
8
+ import { createMutableWrappedHandler, getEventListenerKey, getEventListenerOptions, isSkippedProp, parseEventProp } from "./utils.js";
9
+ import { isBenchMetricScopeActive, recordBenchCounter } from "../runtime/for-bench.js";
10
+ import "../runtime/for.js";
11
+ import { applyScalarPropValue, removeStaleAttributes } from "./attributes.js";
12
+ import { createFineGrainedEffect, markFineGrainedEffectsDirtySource } from "../runtime/effect.js";
13
+ //#region src/renderer/prop-bindings.ts
14
+ const reactivePropRegistry = /* @__PURE__ */ new Set();
15
+ function addTrackedListener(el, eventName, handler, capture = false) {
16
+ const useDelegation = !capture && isEventDelegationEnabled() && isDelegatedEvent(eventName);
17
+ const listenerKey = getEventListenerKey(eventName, capture);
18
+ if (useDelegation) {
19
+ addDelegatedListener(el, eventName, handler, handler, void 0);
20
+ if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("listenerBindings");
21
+ return;
22
+ }
23
+ const options = getEventListenerOptions(eventName, capture);
24
+ const mutableHandler = createMutableWrappedHandler(handler, true);
25
+ const trackedHandler = mutableHandler.handler;
26
+ if (options !== void 0) el.addEventListener(eventName, trackedHandler, options);
27
+ else el.addEventListener(eventName, trackedHandler);
28
+ incDevCounter("listenerAdds");
29
+ if (!elementListeners.has(el)) elementListeners.set(el, /* @__PURE__ */ new Map());
30
+ elementListeners.get(el).set(listenerKey, {
31
+ handler: trackedHandler,
32
+ original: handler,
33
+ eventName,
34
+ options,
35
+ isDelegated: false,
36
+ updateHandler: mutableHandler?.updateHandler
37
+ });
38
+ if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("listenerBindings");
39
+ }
40
+ function markReactivePropsDirtySource(source) {
41
+ markFineGrainedEffectsDirtySource(source);
42
+ }
43
+ function setupReactiveProp(el, propName, propFn, tagName) {
44
+ const descriptor = {
45
+ el,
46
+ propName,
47
+ propFn,
48
+ tagName,
49
+ lastClassTokens: null
50
+ };
51
+ let effectHandle = null;
52
+ reactivePropRegistry.add(descriptor);
53
+ effectHandle = createFineGrainedEffect({
54
+ lane: "reactive",
55
+ compute: () => descriptor.propFn(),
56
+ commit: (value, previousValue) => {
57
+ incrementPerfMetric("reactivePropReevaluations");
58
+ applyScalarPropValue(el, propName, value, tagName, previousValue, descriptor);
59
+ },
60
+ equals: (previousValue, nextValue) => {
61
+ if (Object.is(previousValue, nextValue)) {
62
+ incrementPerfMetric("skippedDomPropWrites");
63
+ return true;
64
+ }
65
+ return false;
66
+ },
67
+ onError: (err) => {
68
+ if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive prop update failed:", err);
69
+ }
70
+ });
71
+ if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("reactivePropsMounted");
72
+ const cleanup = () => {
73
+ reactivePropRegistry.delete(descriptor);
74
+ effectHandle?.cleanup();
75
+ effectHandle = null;
76
+ };
77
+ const updateFn = (nextFn) => {
78
+ if (!effectHandle) return;
79
+ descriptor.propFn = nextFn;
80
+ try {
81
+ effectHandle.updateCompute(nextFn);
82
+ } catch (err) {
83
+ if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive prop update failed:", err);
84
+ }
85
+ };
86
+ return {
87
+ cleanup,
88
+ updateFn
89
+ };
90
+ }
91
+ function getOrCreateReactivePropsCleanupMap(el) {
92
+ let cleanupMap = elementReactivePropsCleanup.get(el);
93
+ if (!cleanupMap) {
94
+ cleanupMap = /* @__PURE__ */ new Map();
95
+ elementReactivePropsCleanup.set(el, cleanupMap);
96
+ }
97
+ return cleanupMap;
98
+ }
99
+ function createReactivePropCleanupEntry(el, propName, propFn, tagName) {
100
+ const reactive = setupReactiveProp(el, propName, propFn, tagName);
101
+ return {
102
+ cleanup: reactive.cleanup,
103
+ updateFn: (nextValue) => {
104
+ reactive.updateFn(nextValue);
105
+ },
106
+ restoreFn: (nextValue) => createReactivePropCleanupEntry(el, propName, nextValue, tagName),
107
+ fnRef: propFn
108
+ };
109
+ }
110
+ function hasTrackedElementPropBindings(el) {
111
+ const existingListeners = elementListeners.get(el);
112
+ const existingReactiveProps = elementReactivePropsCleanup.get(el);
113
+ return existingListeners !== void 0 && existingListeners.size > 0 || existingReactiveProps !== void 0 && existingReactiveProps.size > 0;
114
+ }
115
+ function applyPropsToElement(el, props, tagName, isHydrationSkipped) {
116
+ if (isHydrationSkipped(el)) return;
117
+ for (const key in props) {
118
+ const value = props[key];
119
+ if (key === "ref") {
120
+ updateElementRef(el, value);
121
+ continue;
122
+ }
123
+ if (isSkippedProp(key)) continue;
124
+ if (value === void 0 || value === null || value === false) continue;
125
+ const eventProp = parseEventProp(key);
126
+ if (eventProp) {
127
+ addTrackedListener(el, eventProp.eventName, value, eventProp.capture);
128
+ continue;
129
+ }
130
+ if (typeof value === "function" && key !== "ref") {
131
+ getOrCreateReactivePropsCleanupMap(el).set(key, createReactivePropCleanupEntry(el, key, value, tagName));
132
+ continue;
133
+ }
134
+ applyScalarPropValue(el, key, value, tagName);
135
+ }
136
+ }
137
+ function syncElementPropBindings(el, domVNode, props, usesReactiveChildren) {
138
+ const existingListeners = elementListeners.get(el);
139
+ const existingReactiveProps = elementReactivePropsCleanup.get(el);
140
+ let desiredListenerKeys = null;
141
+ let desiredDelegatedEventNames = null;
142
+ let desiredReactivePropNames = null;
143
+ if (usesReactiveChildren) (desiredReactivePropNames ??= /* @__PURE__ */ new Set()).add(REACTIVE_CHILDREN_KEY);
144
+ for (const key in props) {
145
+ const value = props[key];
146
+ if (key === "ref") continue;
147
+ if (isSkippedProp(key)) continue;
148
+ const eventProp = parseEventProp(key);
149
+ const eventName = eventProp?.eventName;
150
+ const eventCapture = eventProp?.capture ?? false;
151
+ const listenerKey = eventName === void 0 ? null : getEventListenerKey(eventName, eventCapture);
152
+ if (value === void 0 || value === null || value === false) {
153
+ if (listenerKey && existingListeners?.has(listenerKey)) {
154
+ const entry = existingListeners.get(listenerKey);
155
+ incDevCounter("listenerRemoves");
156
+ if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
157
+ else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
158
+ else el.removeEventListener(entry.eventName, entry.handler);
159
+ existingListeners.delete(listenerKey);
160
+ } else {
161
+ const entry = existingReactiveProps?.get(key);
162
+ if (entry) {
163
+ entry.cleanup();
164
+ existingReactiveProps?.delete(key);
165
+ } else applyScalarPropValue(el, key, value, domVNode.type);
166
+ }
167
+ continue;
168
+ }
169
+ if (typeof value === "function" && !eventProp && key !== "ref") {
170
+ const existingEntry = existingReactiveProps?.get(key);
171
+ if (existingReactiveProps && existingReactiveProps.size > 0) (desiredReactivePropNames ??= /* @__PURE__ */ new Set()).add(key);
172
+ if (existingEntry && existingEntry.fnRef === value) continue;
173
+ if (existingEntry?.updateFn) {
174
+ existingEntry.updateFn(value);
175
+ existingEntry.fnRef = value;
176
+ continue;
177
+ }
178
+ if (existingEntry) existingEntry.cleanup();
179
+ getOrCreateReactivePropsCleanupMap(el).set(key, createReactivePropCleanupEntry(el, key, value, domVNode.type));
180
+ continue;
181
+ }
182
+ const existingReactiveEntry = existingReactiveProps?.get(key);
183
+ if (existingReactiveEntry) {
184
+ existingReactiveEntry.cleanup();
185
+ existingReactiveProps?.delete(key);
186
+ }
187
+ if (eventProp && listenerKey) {
188
+ const eventName = eventProp.eventName;
189
+ const eventCapture = eventProp.capture;
190
+ const useDelegation = !eventCapture && isEventDelegationEnabled() && isDelegatedEvent(eventName);
191
+ if (useDelegation) (desiredDelegatedEventNames ??= /* @__PURE__ */ new Set()).add(eventName);
192
+ if (useDelegation) {
193
+ const existingDelegated = getDelegatedHandlerForElement(el, eventName);
194
+ if (existingDelegated?.original === value) continue;
195
+ if (existingDelegated && updateDelegatedListener(el, eventName, value, value, void 0)) continue;
196
+ addDelegatedListener(el, eventName, value, value, void 0);
197
+ continue;
198
+ }
199
+ (desiredListenerKeys ??= /* @__PURE__ */ new Set()).add(listenerKey);
200
+ const existing = existingListeners?.get(listenerKey);
201
+ if (existing && existing.original === value) continue;
202
+ if (existing) {
203
+ if (useDelegation && existing.isDelegated && updateDelegatedListener(el, eventName, value, value, void 0)) {
204
+ existing.handler = value;
205
+ existing.original = value;
206
+ existing.options = void 0;
207
+ continue;
208
+ }
209
+ if (!useDelegation && !existing.isDelegated && existing.updateHandler) {
210
+ existing.updateHandler(value);
211
+ existing.original = value;
212
+ continue;
213
+ }
214
+ if (existing.isDelegated) removeDelegatedListener(el, existing.eventName);
215
+ else if (existing.options !== void 0) el.removeEventListener(existing.eventName, existing.handler, existing.options);
216
+ else el.removeEventListener(existing.eventName, existing.handler);
217
+ }
218
+ const options = getEventListenerOptions(eventName, eventCapture);
219
+ const mutableHandler = createMutableWrappedHandler(value, true);
220
+ const trackedHandler = mutableHandler.handler;
221
+ if (options !== void 0) el.addEventListener(eventName, trackedHandler, options);
222
+ else el.addEventListener(eventName, trackedHandler);
223
+ incDevCounter("listenerAdds");
224
+ const listenerEntry = {
225
+ handler: trackedHandler,
226
+ original: value,
227
+ eventName,
228
+ options,
229
+ isDelegated: false,
230
+ updateHandler: mutableHandler?.updateHandler
231
+ };
232
+ if (!elementListeners.has(el)) elementListeners.set(el, /* @__PURE__ */ new Map());
233
+ elementListeners.get(el).set(listenerKey, listenerEntry);
234
+ } else applyScalarPropValue(el, key, value, domVNode.type);
235
+ }
236
+ removeStaleAttributes(el, domVNode, props);
237
+ if (existingListeners && existingListeners.size > 0) if (desiredListenerKeys === null) {
238
+ existingListeners.forEach((entry) => {
239
+ incDevCounter("listenerRemoves");
240
+ if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
241
+ else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
242
+ else el.removeEventListener(entry.eventName, entry.handler);
243
+ });
244
+ elementListeners.delete(el);
245
+ } else {
246
+ existingListeners.forEach((entry, listenerKey) => {
247
+ if (!desiredListenerKeys.has(listenerKey)) {
248
+ incDevCounter("listenerRemoves");
249
+ if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
250
+ else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
251
+ else el.removeEventListener(entry.eventName, entry.handler);
252
+ existingListeners.delete(listenerKey);
253
+ }
254
+ });
255
+ if (existingListeners.size === 0) elementListeners.delete(el);
256
+ }
257
+ const delegatedHandlers = getDelegatedHandlersForElement(el);
258
+ if (delegatedHandlers && delegatedHandlers.size > 0) {
259
+ if (desiredDelegatedEventNames === null) for (const eventName of delegatedHandlers.keys()) removeDelegatedListener(el, eventName);
260
+ else for (const eventName of delegatedHandlers.keys()) if (!desiredDelegatedEventNames.has(eventName)) removeDelegatedListener(el, eventName);
261
+ }
262
+ if (existingReactiveProps && existingReactiveProps.size > 0) if (desiredReactivePropNames === null) {
263
+ existingReactiveProps.forEach((entry) => {
264
+ entry.cleanup();
265
+ });
266
+ elementReactivePropsCleanup.delete(el);
267
+ } else {
268
+ existingReactiveProps.forEach((entry, key) => {
269
+ if (!desiredReactivePropNames.has(key)) {
270
+ entry.cleanup();
271
+ existingReactiveProps.delete(key);
272
+ }
273
+ });
274
+ if (existingReactiveProps.size === 0) elementReactivePropsCleanup.delete(el);
275
+ }
276
+ }
277
+ //#endregion
278
+ export { applyPropsToElement, hasTrackedElementPropBindings, markReactivePropsDirtySource, syncElementPropBindings };
279
+
280
+ //# sourceMappingURL=prop-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prop-bindings.js","names":[],"sources":["../../src/renderer/prop-bindings.ts"],"sourcesContent":["import { logger } from '../dev/logger';\nimport { incDevCounter } from '../runtime/dev-namespace';\nimport {\n createFineGrainedEffect,\n markFineGrainedEffectsDirtySource,\n type FineGrainedEffectHandle,\n} from '../runtime/effect';\nimport { isBenchMetricScopeActive, recordBenchCounter } from '../runtime/for';\nimport { incrementPerfMetric } from '../runtime/perf-metrics';\nimport type { ReadableSource } from '../runtime/readable';\nimport {\n isEventDelegationEnabled,\n addDelegatedListener,\n getDelegatedHandlerForElement,\n getDelegatedHandlersForElement,\n updateDelegatedListener,\n removeDelegatedListener,\n isDelegatedEvent,\n} from '../runtime/events';\nimport { applyScalarPropValue, removeStaleAttributes } from './attributes';\nimport {\n elementListeners,\n elementReactivePropsCleanup,\n REACTIVE_CHILDREN_KEY,\n type ReactivePropCleanupEntry,\n updateElementRef,\n} from './cleanup';\nimport { getRuntimeEnv } from './env';\nimport type { DOMElement } from './types';\nimport {\n createMutableWrappedHandler,\n getEventListenerKey,\n getEventListenerOptions,\n isSkippedProp,\n parseEventProp,\n} from './utils';\n\ninterface ReactivePropDescriptor {\n el: Element;\n propName: string;\n propFn: () => unknown;\n tagName: string;\n lastClassTokens: string[] | null;\n}\n\nconst reactivePropRegistry = new Set<ReactivePropDescriptor>();\n\nfunction addTrackedListener(\n el: Element,\n eventName: string,\n handler: EventListener,\n capture = false\n): void {\n const useDelegation =\n !capture && isEventDelegationEnabled() && isDelegatedEvent(eventName);\n const listenerKey = getEventListenerKey(eventName, capture);\n\n if (useDelegation) {\n addDelegatedListener(el, eventName, handler, handler, undefined);\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('listenerBindings');\n }\n return;\n }\n\n const options = getEventListenerOptions(eventName, capture);\n const mutableHandler = createMutableWrappedHandler(handler, true);\n const trackedHandler = mutableHandler.handler;\n\n if (options !== undefined) {\n el.addEventListener(eventName, trackedHandler, options);\n } else {\n el.addEventListener(eventName, trackedHandler);\n }\n incDevCounter('listenerAdds');\n\n if (!elementListeners.has(el)) {\n elementListeners.set(el, new Map());\n }\n elementListeners.get(el)!.set(listenerKey, {\n handler: trackedHandler,\n original: handler,\n eventName,\n options,\n isDelegated: false,\n updateHandler: mutableHandler?.updateHandler,\n });\n\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('listenerBindings');\n }\n}\n\nexport function markReactivePropsDirtySource(\n source: ReadableSource<unknown>\n): void {\n markFineGrainedEffectsDirtySource(source);\n}\n\nfunction setupReactiveProp(\n el: Element,\n propName: string,\n propFn: () => unknown,\n tagName: string\n): { cleanup: () => void; updateFn: (nextFn: () => unknown) => void } {\n const descriptor: ReactivePropDescriptor = {\n el,\n propName,\n propFn,\n tagName,\n lastClassTokens: null,\n };\n\n let effectHandle: FineGrainedEffectHandle<unknown> | null = null;\n\n reactivePropRegistry.add(descriptor);\n effectHandle = createFineGrainedEffect({\n lane: 'reactive',\n compute: () => descriptor.propFn(),\n commit: (value, previousValue) => {\n incrementPerfMetric('reactivePropReevaluations');\n applyScalarPropValue(\n el,\n propName,\n value,\n tagName,\n previousValue,\n descriptor\n );\n },\n equals: (previousValue, nextValue) => {\n if (Object.is(previousValue, nextValue)) {\n incrementPerfMetric('skippedDomPropWrites');\n return true;\n }\n return false;\n },\n onError: (err) => {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n logger.warn('[Askr] Reactive prop update failed:', err);\n }\n },\n });\n\n if (isBenchMetricScopeActive('coldCreate')) {\n recordBenchCounter('reactivePropsMounted');\n }\n\n const cleanup = () => {\n reactivePropRegistry.delete(descriptor);\n effectHandle?.cleanup();\n effectHandle = null;\n };\n\n const updateFn = (nextFn: () => unknown): void => {\n if (!effectHandle) {\n return;\n }\n\n descriptor.propFn = nextFn;\n\n try {\n effectHandle.updateCompute(nextFn);\n } catch (err) {\n if (getRuntimeEnv().NODE_ENV !== 'production') {\n logger.warn('[Askr] Reactive prop update failed:', err);\n }\n }\n };\n\n return {\n cleanup,\n updateFn,\n };\n}\n\nfunction getOrCreateReactivePropsCleanupMap(\n el: Element\n): Map<string, ReactivePropCleanupEntry> {\n let cleanupMap = elementReactivePropsCleanup.get(el);\n if (!cleanupMap) {\n cleanupMap = new Map();\n elementReactivePropsCleanup.set(el, cleanupMap);\n }\n return cleanupMap;\n}\n\nfunction createReactivePropCleanupEntry(\n el: Element,\n propName: string,\n propFn: () => unknown,\n tagName: string\n): ReactivePropCleanupEntry {\n const reactive = setupReactiveProp(el, propName, propFn, tagName);\n\n return {\n cleanup: reactive.cleanup,\n updateFn: (nextValue) => {\n reactive.updateFn(nextValue as () => unknown);\n },\n restoreFn: (nextValue) =>\n createReactivePropCleanupEntry(\n el,\n propName,\n nextValue as () => unknown,\n tagName\n ),\n fnRef: propFn,\n };\n}\n\nexport function hasTrackedElementPropBindings(el: Element): boolean {\n const existingListeners = elementListeners.get(el);\n const existingReactiveProps = elementReactivePropsCleanup.get(el);\n return (\n (existingListeners !== undefined && existingListeners.size > 0) ||\n (existingReactiveProps !== undefined && existingReactiveProps.size > 0)\n );\n}\n\nexport function applyPropsToElement(\n el: Element,\n props: Record<string, unknown>,\n tagName: string,\n isHydrationSkipped: (el: Element) => boolean\n): void {\n if (isHydrationSkipped(el)) {\n return;\n }\n\n for (const key in props) {\n const value = props[key];\n if (key === 'ref') {\n updateElementRef(el, value);\n continue;\n }\n if (isSkippedProp(key)) continue;\n if (value === undefined || value === null || value === false) continue;\n\n const eventProp = parseEventProp(key);\n if (eventProp) {\n addTrackedListener(\n el,\n eventProp.eventName,\n value as EventListener,\n eventProp.capture\n );\n continue;\n }\n\n if (typeof value === 'function' && key !== 'ref') {\n getOrCreateReactivePropsCleanupMap(el).set(\n key,\n createReactivePropCleanupEntry(el, key, value as () => unknown, tagName)\n );\n continue;\n }\n\n applyScalarPropValue(el, key, value, tagName);\n }\n}\n\nexport function syncElementPropBindings(\n el: Element,\n domVNode: DOMElement,\n props: Record<string, unknown>,\n usesReactiveChildren: boolean\n): void {\n const existingListeners = elementListeners.get(el);\n const existingReactiveProps = elementReactivePropsCleanup.get(el);\n\n let desiredListenerKeys: Set<string> | null = null;\n let desiredDelegatedEventNames: Set<string> | null = null;\n let desiredReactivePropNames: Set<string> | null = null;\n\n if (usesReactiveChildren) {\n (desiredReactivePropNames ??= new Set()).add(REACTIVE_CHILDREN_KEY);\n }\n\n for (const key in props) {\n const value = props[key];\n if (key === 'ref') continue;\n if (isSkippedProp(key)) continue;\n\n const eventProp = parseEventProp(key);\n const eventName = eventProp?.eventName;\n const eventCapture = eventProp?.capture ?? false;\n const listenerKey =\n eventName === undefined\n ? null\n : getEventListenerKey(eventName, eventCapture);\n\n if (value === undefined || value === null || value === false) {\n if (listenerKey && existingListeners?.has(listenerKey)) {\n const entry = existingListeners.get(listenerKey)!;\n incDevCounter('listenerRemoves');\n if (entry.isDelegated) {\n removeDelegatedListener(el, entry.eventName);\n } else {\n if (entry.options !== undefined) {\n el.removeEventListener(\n entry.eventName,\n entry.handler,\n entry.options\n );\n } else {\n el.removeEventListener(entry.eventName, entry.handler);\n }\n }\n existingListeners.delete(listenerKey);\n } else {\n const entry = existingReactiveProps?.get(key);\n if (entry) {\n entry.cleanup();\n existingReactiveProps?.delete(key);\n } else {\n applyScalarPropValue(el, key, value, domVNode.type as string);\n }\n }\n continue;\n }\n\n if (typeof value === 'function' && !eventProp && key !== 'ref') {\n const existingEntry = existingReactiveProps?.get(key);\n if (existingReactiveProps && existingReactiveProps.size > 0) {\n (desiredReactivePropNames ??= new Set()).add(key);\n }\n\n if (existingEntry && existingEntry.fnRef === value) {\n continue;\n }\n\n if (existingEntry?.updateFn) {\n existingEntry.updateFn(value as () => unknown);\n existingEntry.fnRef = value as () => unknown;\n continue;\n }\n\n if (existingEntry) {\n existingEntry.cleanup();\n }\n\n getOrCreateReactivePropsCleanupMap(el).set(\n key,\n createReactivePropCleanupEntry(\n el,\n key,\n value as () => unknown,\n domVNode.type as string\n )\n );\n continue;\n }\n\n const existingReactiveEntry = existingReactiveProps?.get(key);\n if (existingReactiveEntry) {\n existingReactiveEntry.cleanup();\n existingReactiveProps?.delete(key);\n }\n\n if (eventProp && listenerKey) {\n const eventName = eventProp.eventName;\n const eventCapture = eventProp.capture;\n const useDelegation =\n !eventCapture &&\n isEventDelegationEnabled() &&\n isDelegatedEvent(eventName);\n if (useDelegation) {\n (desiredDelegatedEventNames ??= new Set()).add(eventName);\n }\n\n if (useDelegation) {\n const existingDelegated = getDelegatedHandlerForElement(el, eventName);\n if (existingDelegated?.original === value) {\n continue;\n }\n\n if (\n existingDelegated &&\n updateDelegatedListener(\n el,\n eventName,\n value as EventListener,\n value as EventListener,\n undefined\n )\n ) {\n continue;\n }\n\n addDelegatedListener(\n el,\n eventName,\n value as EventListener,\n value as EventListener,\n undefined\n );\n continue;\n }\n\n (desiredListenerKeys ??= new Set()).add(listenerKey);\n\n const existing = existingListeners?.get(listenerKey);\n\n if (existing && existing.original === value) {\n continue;\n }\n\n if (existing) {\n if (\n useDelegation &&\n existing.isDelegated &&\n updateDelegatedListener(\n el,\n eventName,\n value as EventListener,\n value as EventListener,\n undefined\n )\n ) {\n existing.handler = value as EventListener;\n existing.original = value as EventListener;\n existing.options = undefined;\n continue;\n }\n\n if (!useDelegation && !existing.isDelegated && existing.updateHandler) {\n existing.updateHandler(value as EventListener);\n existing.original = value as EventListener;\n continue;\n }\n\n if (existing.isDelegated) {\n removeDelegatedListener(el, existing.eventName);\n } else {\n if (existing.options !== undefined) {\n el.removeEventListener(\n existing.eventName,\n existing.handler,\n existing.options\n );\n } else {\n el.removeEventListener(existing.eventName, existing.handler);\n }\n }\n }\n\n const options = getEventListenerOptions(eventName, eventCapture);\n const mutableHandler = createMutableWrappedHandler(\n value as EventListener,\n true\n );\n const trackedHandler = mutableHandler.handler;\n\n if (options !== undefined) {\n el.addEventListener(eventName, trackedHandler, options);\n } else {\n el.addEventListener(eventName, trackedHandler);\n }\n incDevCounter('listenerAdds');\n\n const listenerEntry = {\n handler: trackedHandler,\n original: value as EventListener,\n eventName,\n options,\n isDelegated: false,\n updateHandler: mutableHandler?.updateHandler,\n };\n if (!elementListeners.has(el)) {\n elementListeners.set(el, new Map());\n }\n elementListeners.get(el)!.set(listenerKey, listenerEntry);\n } else {\n applyScalarPropValue(el, key, value, domVNode.type as string);\n }\n }\n\n removeStaleAttributes(el, domVNode, props);\n\n if (existingListeners && existingListeners.size > 0) {\n if (desiredListenerKeys === null) {\n existingListeners.forEach((entry) => {\n incDevCounter('listenerRemoves');\n if (entry.isDelegated) {\n removeDelegatedListener(el, entry.eventName);\n } else {\n if (entry.options !== undefined) {\n el.removeEventListener(\n entry.eventName,\n entry.handler,\n entry.options\n );\n } else {\n el.removeEventListener(entry.eventName, entry.handler);\n }\n }\n });\n elementListeners.delete(el);\n } else {\n existingListeners.forEach((entry, listenerKey) => {\n if (!desiredListenerKeys.has(listenerKey)) {\n incDevCounter('listenerRemoves');\n if (entry.isDelegated) {\n removeDelegatedListener(el, entry.eventName);\n } else {\n if (entry.options !== undefined) {\n el.removeEventListener(\n entry.eventName,\n entry.handler,\n entry.options\n );\n } else {\n el.removeEventListener(entry.eventName, entry.handler);\n }\n }\n existingListeners.delete(listenerKey);\n }\n });\n if (existingListeners.size === 0) elementListeners.delete(el);\n }\n }\n\n const delegatedHandlers = getDelegatedHandlersForElement(el);\n if (delegatedHandlers && delegatedHandlers.size > 0) {\n if (desiredDelegatedEventNames === null) {\n for (const eventName of delegatedHandlers.keys()) {\n removeDelegatedListener(el, eventName);\n }\n } else {\n for (const eventName of delegatedHandlers.keys()) {\n if (!desiredDelegatedEventNames.has(eventName)) {\n removeDelegatedListener(el, eventName);\n }\n }\n }\n }\n\n if (existingReactiveProps && existingReactiveProps.size > 0) {\n if (desiredReactivePropNames === null) {\n existingReactiveProps.forEach((entry) => {\n entry.cleanup();\n });\n elementReactivePropsCleanup.delete(el);\n } else {\n existingReactiveProps.forEach((entry, key) => {\n if (!desiredReactivePropNames.has(key)) {\n entry.cleanup();\n existingReactiveProps.delete(key);\n }\n });\n if (existingReactiveProps.size === 0) {\n elementReactivePropsCleanup.delete(el);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6CA,MAAM,uCAAuB,IAAI,IAA4B;AAE7D,SAAS,mBACP,IACA,WACA,SACA,UAAU,OACJ;CACN,MAAM,gBACJ,CAAC,WAAW,yBAAyB,KAAK,iBAAiB,SAAS;CACtE,MAAM,cAAc,oBAAoB,WAAW,OAAO;CAE1D,IAAI,eAAe;EACjB,qBAAqB,IAAI,WAAW,SAAS,SAAS,MAAS;EAC/D,IAAI,yBAAyB,YAAY,GACvC,mBAAmB,kBAAkB;EAEvC;CACF;CAEA,MAAM,UAAU,wBAAwB,WAAW,OAAO;CAC1D,MAAM,iBAAiB,4BAA4B,SAAS,IAAI;CAChE,MAAM,iBAAiB,eAAe;CAEtC,IAAI,YAAY,QACd,GAAG,iBAAiB,WAAW,gBAAgB,OAAO;MAEtD,GAAG,iBAAiB,WAAW,cAAc;CAE/C,cAAc,cAAc;CAE5B,IAAI,CAAC,iBAAiB,IAAI,EA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3D,IAAI,qBAAqB,kBAAkB,OAAO,GAChD;MAAI,+BAA+B,MACjC,KAAK,MAAM,aAAa,kBAAkB,KAAK,GAC7C,wBAAwB,IAAI,SAAS;OAGvC,KAAK,MAAM,aAAa,kBAAkB,KAAK,GAC7C,IAAI,CAAC,2BAA2B,IAAI,SAAS,GAC3C,wBAAwB,IAAI,SAAS;CAG3C;CAGF,IAAI,yBAAyB,sBAAsB,OAAO,GACxD,IAAI,6BAA6B,MAAM;EACrC,sBAAsB,SAAS,UAAU;GACvC,MAAM,QAAQ;EAChB,CAAC;EACD,4BAA4B,OAAO,EAAE;CACvC,OAAO;EACL,sBAAsB,SAAS,OAAO,QAAQ;GAC5C,IAAI,CAAC,yBAAyB,IAAI,GAAG,GAAG;IACtC,MAAM,QAAQ;IACd,sBAAsB,OAAO,GAAG;GAClC;EACF,CAAC;EACD,IAAI,sBAAsB,SAAS,GACjC,4BAA4B,OAAO,EAAE;CAEzC;AAEJ"}
@@ -0,0 +1,133 @@
1
+ import { teardownNodeSubtree } from "./cleanup.js";
2
+ import { createElementForNamespace, getParentNamespace } from "./namespaces.js";
3
+ import { syncControlBoundaryScopeDom } from "./boundaries.js";
4
+ import { collectReactiveChildBoundaryVNodes, isSingleRootReactiveChildBoundaryValue } from "./reactive-child-sources.js";
5
+ //#region src/renderer/reactive-child-dom.ts
6
+ function materializeReactiveChildBoundaryNodes(value, parentNamespace, host) {
7
+ const nodes = [];
8
+ const dom = host.createDOMNode(value, parentNamespace);
9
+ if (!dom) return nodes;
10
+ if (dom instanceof DocumentFragment) {
11
+ for (let child = dom.firstChild; child; child = dom.firstChild) {
12
+ nodes.push(child);
13
+ dom.removeChild(child);
14
+ }
15
+ return nodes;
16
+ }
17
+ nodes.push(dom);
18
+ return nodes;
19
+ }
20
+ function createReactiveChildBoundaryHost(el) {
21
+ const ownerDocument = el.ownerDocument;
22
+ const parentNamespace = getParentNamespace(el);
23
+ return parentNamespace === "http://www.w3.org/2000/svg" ? createElementForNamespace("g", parentNamespace, ownerDocument) : createElementForNamespace("div", parentNamespace, ownerDocument);
24
+ }
25
+ function disposeReactiveChildBoundaryNodes(nodes) {
26
+ for (const node of nodes) {
27
+ if (node.parentNode) node.parentNode.removeChild(node);
28
+ teardownNodeSubtree(node);
29
+ }
30
+ }
31
+ function syncReactiveChildExpectedNodes(el, expectedNodes) {
32
+ const expectedNodeSet = new Set(expectedNodes);
33
+ for (let node = el.firstChild; node;) {
34
+ const next = node.nextSibling;
35
+ if (!expectedNodeSet.has(node)) {
36
+ teardownNodeSubtree(node);
37
+ el.removeChild(node);
38
+ }
39
+ node = next;
40
+ }
41
+ let anchor = el.firstChild;
42
+ for (const node of expectedNodes) {
43
+ if (node === anchor) {
44
+ anchor = anchor.nextSibling;
45
+ continue;
46
+ }
47
+ el.insertBefore(node, anchor);
48
+ anchor = node.nextSibling;
49
+ }
50
+ }
51
+ function commitReactiveChildBoundaryEntryNodes(el, entry, host) {
52
+ if (!entry.scope.needsDomUpdate) return entry.nodes;
53
+ if (entry.scope.vnode === null || entry.scope.vnode === void 0 || entry.scope.vnode === false) {
54
+ if (entry.nodes.length > 0) {
55
+ disposeReactiveChildBoundaryNodes(entry.nodes);
56
+ entry.nodes = [];
57
+ }
58
+ const dom = entry.scope.dom;
59
+ if (dom?.parentNode === el) {
60
+ teardownNodeSubtree(dom);
61
+ el.removeChild(dom);
62
+ }
63
+ entry.scope.dom = void 0;
64
+ entry.scope.needsDomUpdate = false;
65
+ return entry.nodes;
66
+ }
67
+ if (!isSingleRootReactiveChildBoundaryValue(entry.scope.vnode)) {
68
+ const nextChildren = [];
69
+ collectReactiveChildBoundaryVNodes(entry.scope.vnode, nextChildren);
70
+ const boundaryHost = createReactiveChildBoundaryHost(el);
71
+ for (const node of entry.nodes) boundaryHost.appendChild(node);
72
+ host.updateElementChildren(boundaryHost, nextChildren);
73
+ const nextNodes = Array.from(boundaryHost.childNodes);
74
+ entry.scope.dom = void 0;
75
+ entry.scope.needsDomUpdate = false;
76
+ entry.nodes = nextNodes;
77
+ return nextNodes;
78
+ }
79
+ if (entry.nodes.length > 1) {
80
+ disposeReactiveChildBoundaryNodes(entry.nodes);
81
+ entry.nodes = [];
82
+ entry.scope.dom = void 0;
83
+ }
84
+ const nextDom = syncControlBoundaryScopeDom(el, entry.scope, entry.scope.vnode ?? null);
85
+ if (!nextDom) {
86
+ entry.nodes = [];
87
+ entry.scope.needsDomUpdate = false;
88
+ return entry.nodes;
89
+ }
90
+ entry.nodes = [nextDom];
91
+ entry.scope.needsDomUpdate = false;
92
+ return entry.nodes;
93
+ }
94
+ function syncReactiveChildSequenceNodes(el, entries, host) {
95
+ const expectedNodes = [];
96
+ for (const entry of entries) {
97
+ if (entry.kind === "static") {
98
+ expectedNodes.push(...entry.nodes);
99
+ continue;
100
+ }
101
+ expectedNodes.push(...commitReactiveChildBoundaryEntryNodes(el, entry, host));
102
+ }
103
+ syncReactiveChildExpectedNodes(el, expectedNodes);
104
+ }
105
+ function syncReactiveScalarTextNodes(el, slotValues, values, host) {
106
+ const childNodes = el.childNodes;
107
+ if (childNodes.length === values.length) {
108
+ let allText = true;
109
+ for (let index = 0; index < childNodes.length; index += 1) if (childNodes[index]?.nodeType !== Node.TEXT_NODE) {
110
+ allText = false;
111
+ break;
112
+ }
113
+ if (allText) {
114
+ for (let index = 0; index < values.length; index += 1) {
115
+ const textNode = childNodes[index];
116
+ if (textNode.data !== values[index]) textNode.data = values[index];
117
+ }
118
+ return;
119
+ }
120
+ }
121
+ const boundaryHost = createReactiveChildBoundaryHost(el);
122
+ for (let node = el.firstChild; node;) {
123
+ const next = node.nextSibling;
124
+ boundaryHost.appendChild(node);
125
+ node = next;
126
+ }
127
+ host.updateElementChildren(boundaryHost, slotValues);
128
+ syncReactiveChildExpectedNodes(el, Array.from(boundaryHost.childNodes));
129
+ }
130
+ //#endregion
131
+ export { commitReactiveChildBoundaryEntryNodes, createReactiveChildBoundaryHost, disposeReactiveChildBoundaryNodes, materializeReactiveChildBoundaryNodes, syncReactiveChildExpectedNodes, syncReactiveChildSequenceNodes, syncReactiveScalarTextNodes };
132
+
133
+ //# sourceMappingURL=reactive-child-dom.js.map