foldkit-primitives 0.15.4 → 0.16.0

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 (422) hide show
  1. package/dist/device/fullscreen.d.ts +28 -0
  2. package/dist/device/fullscreen.d.ts.map +1 -0
  3. package/dist/device/fullscreen.js +69 -0
  4. package/dist/device/fullscreen.js.map +1 -0
  5. package/dist/device/geolocation.d.ts +56 -0
  6. package/dist/device/geolocation.d.ts.map +1 -0
  7. package/dist/device/geolocation.js +87 -0
  8. package/dist/device/geolocation.js.map +1 -0
  9. package/dist/device/index.d.ts +5 -0
  10. package/dist/device/index.js +6 -0
  11. package/dist/device/media-devices.d.ts +88 -0
  12. package/dist/device/media-devices.d.ts.map +1 -0
  13. package/dist/device/media-devices.js +117 -0
  14. package/dist/device/media-devices.js.map +1 -0
  15. package/dist/device/media-stream.d.ts +93 -0
  16. package/dist/device/media-stream.d.ts.map +1 -0
  17. package/dist/device/media-stream.js +106 -0
  18. package/dist/device/media-stream.js.map +1 -0
  19. package/dist/device/permissions.d.ts +106 -0
  20. package/dist/device/permissions.d.ts.map +1 -0
  21. package/dist/device/permissions.js +143 -0
  22. package/dist/device/permissions.js.map +1 -0
  23. package/dist/dom/autofocus.d.ts +15 -0
  24. package/dist/dom/autofocus.d.ts.map +1 -0
  25. package/dist/dom/autofocus.js +22 -0
  26. package/dist/dom/autofocus.js.map +1 -0
  27. package/dist/dom/clipboard.d.ts +30 -0
  28. package/dist/dom/clipboard.d.ts.map +1 -0
  29. package/dist/dom/clipboard.js +50 -0
  30. package/dist/dom/clipboard.js.map +1 -0
  31. package/dist/dom/editable-text.d.ts +72 -0
  32. package/dist/dom/editable-text.d.ts.map +1 -0
  33. package/dist/dom/editable-text.js +232 -0
  34. package/dist/dom/editable-text.js.map +1 -0
  35. package/dist/dom/fluid-hover.d.ts +93 -0
  36. package/dist/dom/fluid-hover.d.ts.map +1 -0
  37. package/dist/dom/fluid-hover.js +294 -0
  38. package/dist/dom/fluid-hover.js.map +1 -0
  39. package/dist/dom/focus-scope.d.ts +21 -0
  40. package/dist/dom/focus-scope.d.ts.map +1 -0
  41. package/dist/dom/focus-scope.js +93 -0
  42. package/dist/dom/focus-scope.js.map +1 -0
  43. package/dist/dom/follow-tab-stop.d.ts +11 -0
  44. package/dist/dom/follow-tab-stop.d.ts.map +1 -0
  45. package/dist/dom/follow-tab-stop.js +54 -0
  46. package/dist/dom/follow-tab-stop.js.map +1 -0
  47. package/dist/dom/image-decode.d.ts +27 -0
  48. package/dist/dom/image-decode.d.ts.map +1 -0
  49. package/dist/dom/image-decode.js +50 -0
  50. package/dist/dom/image-decode.js.map +1 -0
  51. package/dist/dom/index.d.ts +24 -0
  52. package/dist/dom/index.js +25 -0
  53. package/dist/dom/input-mask.d.ts +35 -0
  54. package/dist/dom/input-mask.d.ts.map +1 -0
  55. package/dist/dom/input-mask.js +90 -0
  56. package/dist/dom/input-mask.js.map +1 -0
  57. package/dist/dom/keep-in-view.d.ts +16 -0
  58. package/dist/dom/keep-in-view.d.ts.map +1 -0
  59. package/dist/dom/keep-in-view.js +38 -0
  60. package/dist/dom/keep-in-view.js.map +1 -0
  61. package/dist/dom/keyboard-inset.d.ts +29 -0
  62. package/dist/dom/keyboard-inset.d.ts.map +1 -0
  63. package/dist/dom/keyboard-inset.js +45 -0
  64. package/dist/dom/keyboard-inset.js.map +1 -0
  65. package/dist/dom/layers.d.ts +6 -0
  66. package/dist/dom/layers.d.ts.map +1 -0
  67. package/dist/dom/layers.js +35 -0
  68. package/dist/dom/layers.js.map +1 -0
  69. package/dist/dom/measure.d.ts +42 -0
  70. package/dist/dom/measure.d.ts.map +1 -0
  71. package/dist/dom/measure.js +123 -0
  72. package/dist/dom/measure.js.map +1 -0
  73. package/dist/dom/move.d.ts +45 -0
  74. package/dist/dom/move.d.ts.map +1 -0
  75. package/dist/dom/move.js +96 -0
  76. package/dist/dom/move.js.map +1 -0
  77. package/dist/dom/pointed-links.d.ts +13 -0
  78. package/dist/dom/pointed-links.d.ts.map +1 -0
  79. package/dist/dom/pointed-links.js +59 -0
  80. package/dist/dom/pointed-links.js.map +1 -0
  81. package/dist/dom/pointer-drag.d.ts +132 -0
  82. package/dist/dom/pointer-drag.d.ts.map +1 -0
  83. package/dist/dom/pointer-drag.js +307 -0
  84. package/dist/dom/pointer-drag.js.map +1 -0
  85. package/dist/dom/pointer-position.d.ts +133 -0
  86. package/dist/dom/pointer-position.d.ts.map +1 -0
  87. package/dist/dom/pointer-position.js +173 -0
  88. package/dist/dom/pointer-position.js.map +1 -0
  89. package/dist/dom/script-loader.d.ts +12 -0
  90. package/dist/dom/script-loader.d.ts.map +1 -0
  91. package/dist/dom/script-loader.js +54 -0
  92. package/dist/dom/script-loader.js.map +1 -0
  93. package/dist/dom/scroll-bars.d.ts +52 -0
  94. package/dist/dom/scroll-bars.d.ts.map +1 -0
  95. package/dist/dom/scroll-bars.js +259 -0
  96. package/dist/dom/scroll-bars.js.map +1 -0
  97. package/dist/dom/scroll-settle.d.ts +33 -0
  98. package/dist/dom/scroll-settle.d.ts.map +1 -0
  99. package/dist/dom/scroll-settle.js +84 -0
  100. package/dist/dom/scroll-settle.js.map +1 -0
  101. package/dist/dom/scroll.d.ts +21 -0
  102. package/dist/dom/scroll.d.ts.map +1 -0
  103. package/dist/dom/scroll.js +141 -0
  104. package/dist/dom/scroll.js.map +1 -0
  105. package/dist/dom/share.d.ts +19 -0
  106. package/dist/dom/share.d.ts.map +1 -0
  107. package/dist/dom/share.js +41 -0
  108. package/dist/dom/share.js.map +1 -0
  109. package/dist/dom/swipe.d.ts +121 -0
  110. package/dist/dom/swipe.d.ts.map +1 -0
  111. package/dist/dom/swipe.js +291 -0
  112. package/dist/dom/swipe.js.map +1 -0
  113. package/dist/dom/targets.d.ts +45 -0
  114. package/dist/dom/targets.d.ts.map +1 -0
  115. package/dist/dom/targets.js +70 -0
  116. package/dist/dom/targets.js.map +1 -0
  117. package/dist/dom/track-box.d.ts +61 -0
  118. package/dist/dom/track-box.d.ts.map +1 -0
  119. package/dist/dom/track-box.js +131 -0
  120. package/dist/dom/track-box.js.map +1 -0
  121. package/dist/events/active-element.d.ts +15 -0
  122. package/dist/events/active-element.d.ts.map +1 -0
  123. package/dist/events/active-element.js +33 -0
  124. package/dist/events/active-element.js.map +1 -0
  125. package/dist/events/hotkeys.d.ts +22 -0
  126. package/dist/events/hotkeys.d.ts.map +1 -0
  127. package/dist/events/hotkeys.js +56 -0
  128. package/dist/events/hotkeys.js.map +1 -0
  129. package/dist/events/idle.d.ts +29 -0
  130. package/dist/events/idle.d.ts.map +1 -0
  131. package/dist/events/idle.js +51 -0
  132. package/dist/events/idle.js.map +1 -0
  133. package/dist/events/index.d.ts +9 -0
  134. package/dist/events/index.js +10 -0
  135. package/dist/{input-modality-l7InESYh.d.mts → events/input-modality.d.ts} +9 -10
  136. package/dist/events/input-modality.d.ts.map +1 -0
  137. package/dist/{input-modality-XwQOFLip.mjs → events/input-modality.js} +2 -2
  138. package/dist/events/input-modality.js.map +1 -0
  139. package/dist/events/keyboard.d.ts +30 -0
  140. package/dist/events/keyboard.d.ts.map +1 -0
  141. package/dist/events/keyboard.js +55 -0
  142. package/dist/events/keyboard.js.map +1 -0
  143. package/dist/events/pointer.d.ts +15 -0
  144. package/dist/events/pointer.d.ts.map +1 -0
  145. package/dist/events/pointer.js +28 -0
  146. package/dist/events/pointer.js.map +1 -0
  147. package/dist/events/scroll.d.ts +16 -0
  148. package/dist/events/scroll.d.ts.map +1 -0
  149. package/dist/events/scroll.js +29 -0
  150. package/dist/events/scroll.js.map +1 -0
  151. package/dist/events/visibility.d.ts +25 -0
  152. package/dist/events/visibility.d.ts.map +1 -0
  153. package/dist/events/visibility.js +28 -0
  154. package/dist/events/visibility.js.map +1 -0
  155. package/dist/events/window-size.d.ts +30 -0
  156. package/dist/events/window-size.d.ts.map +1 -0
  157. package/dist/events/window-size.js +63 -0
  158. package/dist/events/window-size.js.map +1 -0
  159. package/dist/index.d.ts +9 -0
  160. package/dist/index.js +10 -0
  161. package/dist/interaction/bundle-behavior.d.ts +37 -0
  162. package/dist/interaction/bundle-behavior.d.ts.map +1 -0
  163. package/dist/interaction/bundle-behavior.js +34 -0
  164. package/dist/interaction/bundle-behavior.js.map +1 -0
  165. package/dist/interaction/dismiss-layer.d.ts +100 -0
  166. package/dist/interaction/dismiss-layer.d.ts.map +1 -0
  167. package/dist/interaction/dismiss-layer.js +140 -0
  168. package/dist/interaction/dismiss-layer.js.map +1 -0
  169. package/dist/interaction/editable-text.d.ts +13 -0
  170. package/dist/interaction/editable-text.d.ts.map +1 -0
  171. package/dist/interaction/editable-text.js +17 -0
  172. package/dist/interaction/editable-text.js.map +1 -0
  173. package/dist/interaction/focus-scope.d.ts +21 -0
  174. package/dist/interaction/focus-scope.d.ts.map +1 -0
  175. package/dist/interaction/focus-scope.js +25 -0
  176. package/dist/interaction/focus-scope.js.map +1 -0
  177. package/dist/interaction/focus-visible.d.ts +9 -0
  178. package/dist/interaction/focus-visible.d.ts.map +1 -0
  179. package/dist/interaction/focus-visible.js +10 -0
  180. package/dist/interaction/focus-visible.js.map +1 -0
  181. package/dist/interaction/grid-navigation.d.ts +73 -0
  182. package/dist/interaction/grid-navigation.d.ts.map +1 -0
  183. package/dist/interaction/grid-navigation.js +137 -0
  184. package/dist/interaction/grid-navigation.js.map +1 -0
  185. package/dist/interaction/index.d.ts +21 -0
  186. package/dist/interaction/index.js +21 -0
  187. package/dist/interaction/layers.d.ts +12 -0
  188. package/dist/interaction/layers.d.ts.map +1 -0
  189. package/dist/interaction/layers.js +14 -0
  190. package/dist/interaction/layers.js.map +1 -0
  191. package/dist/interaction/list-navigation.d.ts +105 -0
  192. package/dist/interaction/list-navigation.d.ts.map +1 -0
  193. package/dist/interaction/list-navigation.js +168 -0
  194. package/dist/interaction/list-navigation.js.map +1 -0
  195. package/dist/interaction/live-announce.d.ts +70 -0
  196. package/dist/interaction/live-announce.d.ts.map +1 -0
  197. package/dist/interaction/live-announce.js +115 -0
  198. package/dist/interaction/live-announce.js.map +1 -0
  199. package/dist/interaction/long-press.d.ts +102 -0
  200. package/dist/interaction/long-press.d.ts.map +1 -0
  201. package/dist/interaction/long-press.js +115 -0
  202. package/dist/interaction/long-press.js.map +1 -0
  203. package/dist/interaction/move.d.ts +10 -0
  204. package/dist/interaction/move.d.ts.map +1 -0
  205. package/dist/interaction/move.js +17 -0
  206. package/dist/interaction/move.js.map +1 -0
  207. package/dist/interaction/overlay.d.ts +45 -0
  208. package/dist/interaction/overlay.d.ts.map +1 -0
  209. package/dist/interaction/overlay.js +57 -0
  210. package/dist/interaction/overlay.js.map +1 -0
  211. package/dist/interaction/placing.d.ts +86 -0
  212. package/dist/interaction/placing.d.ts.map +1 -0
  213. package/dist/interaction/placing.js +239 -0
  214. package/dist/interaction/placing.js.map +1 -0
  215. package/dist/interaction/pointer-drag.d.ts +23 -0
  216. package/dist/interaction/pointer-drag.d.ts.map +1 -0
  217. package/dist/interaction/pointer-drag.js +21 -0
  218. package/dist/interaction/pointer-drag.js.map +1 -0
  219. package/dist/interaction/press.d.ts +152 -0
  220. package/dist/interaction/press.d.ts.map +1 -0
  221. package/dist/interaction/press.js +229 -0
  222. package/dist/interaction/press.js.map +1 -0
  223. package/dist/interaction/roving-tabindex.d.ts +85 -0
  224. package/dist/interaction/roving-tabindex.d.ts.map +1 -0
  225. package/dist/interaction/roving-tabindex.js +142 -0
  226. package/dist/interaction/roving-tabindex.js.map +1 -0
  227. package/dist/interaction/selection.d.ts +72 -0
  228. package/dist/interaction/selection.d.ts.map +1 -0
  229. package/dist/interaction/selection.js +129 -0
  230. package/dist/interaction/selection.js.map +1 -0
  231. package/dist/interaction/targets.d.ts +15 -0
  232. package/dist/interaction/targets.d.ts.map +1 -0
  233. package/dist/interaction/targets.js +20 -0
  234. package/dist/interaction/targets.js.map +1 -0
  235. package/dist/interaction/tree-navigation.d.ts +111 -0
  236. package/dist/interaction/tree-navigation.d.ts.map +1 -0
  237. package/dist/interaction/tree-navigation.js +207 -0
  238. package/dist/interaction/tree-navigation.js.map +1 -0
  239. package/dist/interaction/typeahead.d.ts +73 -0
  240. package/dist/interaction/typeahead.d.ts.map +1 -0
  241. package/dist/interaction/typeahead.js +113 -0
  242. package/dist/interaction/typeahead.js.map +1 -0
  243. package/dist/internal.d.ts +16 -0
  244. package/dist/internal.d.ts.map +1 -0
  245. package/dist/{internal-C4gHodLc.mjs → internal.js} +7 -5
  246. package/dist/internal.js.map +1 -0
  247. package/dist/media/breakpoints.d.ts +37 -0
  248. package/dist/media/breakpoints.d.ts.map +1 -0
  249. package/dist/media/breakpoints.js +64 -0
  250. package/dist/media/breakpoints.js.map +1 -0
  251. package/dist/media/index.d.ts +3 -0
  252. package/dist/media/index.js +4 -0
  253. package/dist/media/mediaquery.d.ts +40 -0
  254. package/dist/media/mediaquery.d.ts.map +1 -0
  255. package/dist/media/mediaquery.js +42 -0
  256. package/dist/media/mediaquery.js.map +1 -0
  257. package/dist/media/platform.d.ts +30 -0
  258. package/dist/media/platform.d.ts.map +1 -0
  259. package/dist/media/platform.js +50 -0
  260. package/dist/media/platform.js.map +1 -0
  261. package/dist/motion/index.d.ts +5 -0
  262. package/dist/motion/index.js +5 -0
  263. package/dist/motion/motion.d.ts +16 -0
  264. package/dist/motion/motion.d.ts.map +1 -0
  265. package/dist/motion/motion.js +25 -0
  266. package/dist/motion/motion.js.map +1 -0
  267. package/dist/motion/presence.d.ts +37 -0
  268. package/dist/motion/presence.d.ts.map +1 -0
  269. package/dist/motion/presence.js +65 -0
  270. package/dist/motion/presence.js.map +1 -0
  271. package/dist/motion/spring.d.ts +50 -0
  272. package/dist/motion/spring.d.ts.map +1 -0
  273. package/dist/motion/spring.js +92 -0
  274. package/dist/motion/spring.js.map +1 -0
  275. package/dist/motion/tween.d.ts +44 -0
  276. package/dist/motion/tween.d.ts.map +1 -0
  277. package/dist/motion/tween.js +65 -0
  278. package/dist/motion/tween.js.map +1 -0
  279. package/dist/net/broadcast.d.ts +39 -0
  280. package/dist/net/broadcast.d.ts.map +1 -0
  281. package/dist/net/broadcast.js +73 -0
  282. package/dist/net/broadcast.js.map +1 -0
  283. package/dist/net/index.d.ts +5 -0
  284. package/dist/net/index.js +6 -0
  285. package/dist/net/online.d.ts +24 -0
  286. package/dist/net/online.d.ts.map +1 -0
  287. package/dist/net/online.js +26 -0
  288. package/dist/net/online.js.map +1 -0
  289. package/dist/net/sharedHost.d.ts +64 -0
  290. package/dist/net/sharedHost.d.ts.map +1 -0
  291. package/dist/net/sharedHost.js +124 -0
  292. package/dist/net/sharedHost.js.map +1 -0
  293. package/dist/net/sse.d.ts +115 -0
  294. package/dist/net/sse.d.ts.map +1 -0
  295. package/dist/net/sse.js +138 -0
  296. package/dist/net/sse.js.map +1 -0
  297. package/dist/net/websocket.d.ts +172 -0
  298. package/dist/net/websocket.d.ts.map +1 -0
  299. package/dist/net/websocket.js +199 -0
  300. package/dist/net/websocket.js.map +1 -0
  301. package/dist/observers/bounds.d.ts +24 -0
  302. package/dist/observers/bounds.d.ts.map +1 -0
  303. package/dist/observers/bounds.js +51 -0
  304. package/dist/observers/bounds.js.map +1 -0
  305. package/dist/observers/index.d.ts +4 -0
  306. package/dist/observers/index.js +5 -0
  307. package/dist/observers/intersection.d.ts +18 -0
  308. package/dist/observers/intersection.d.ts.map +1 -0
  309. package/dist/observers/intersection.js +33 -0
  310. package/dist/observers/intersection.js.map +1 -0
  311. package/dist/observers/mutation.d.ts +25 -0
  312. package/dist/observers/mutation.d.ts.map +1 -0
  313. package/dist/observers/mutation.js +53 -0
  314. package/dist/observers/mutation.js.map +1 -0
  315. package/dist/observers/resize.d.ts +18 -0
  316. package/dist/observers/resize.d.ts.map +1 -0
  317. package/dist/observers/resize.js +33 -0
  318. package/dist/observers/resize.js.map +1 -0
  319. package/dist/state/history.d.ts +115 -0
  320. package/dist/state/history.d.ts.map +1 -0
  321. package/dist/state/history.js +167 -0
  322. package/dist/state/history.js.map +1 -0
  323. package/dist/state/index.d.ts +6 -0
  324. package/dist/state/index.js +7 -0
  325. package/dist/state/locale.d.ts +27 -0
  326. package/dist/state/locale.d.ts.map +1 -0
  327. package/dist/state/locale.js +25 -0
  328. package/dist/state/locale.js.map +1 -0
  329. package/dist/state/pagination.d.ts +53 -0
  330. package/dist/state/pagination.d.ts.map +1 -0
  331. package/dist/state/pagination.js +72 -0
  332. package/dist/state/pagination.js.map +1 -0
  333. package/dist/state/range.d.ts +9 -0
  334. package/dist/state/range.d.ts.map +1 -0
  335. package/dist/state/range.js +18 -0
  336. package/dist/state/range.js.map +1 -0
  337. package/dist/state/selection.d.ts +47 -0
  338. package/dist/state/selection.d.ts.map +1 -0
  339. package/dist/state/selection.js +39 -0
  340. package/dist/state/selection.js.map +1 -0
  341. package/dist/state/virtual.d.ts +201 -0
  342. package/dist/state/virtual.d.ts.map +1 -0
  343. package/dist/state/{index.mjs → virtual.js} +10 -306
  344. package/dist/state/virtual.js.map +1 -0
  345. package/dist/time/debounce.d.ts +43 -0
  346. package/dist/time/debounce.d.ts.map +1 -0
  347. package/dist/time/debounce.js +65 -0
  348. package/dist/time/debounce.js.map +1 -0
  349. package/dist/time/index.d.ts +6 -0
  350. package/dist/time/index.js +7 -0
  351. package/dist/time/interval.d.ts +37 -0
  352. package/dist/time/interval.d.ts.map +1 -0
  353. package/dist/time/interval.js +52 -0
  354. package/dist/time/interval.js.map +1 -0
  355. package/dist/time/relative.d.ts +8 -0
  356. package/dist/time/relative.d.ts.map +1 -0
  357. package/dist/time/relative.js +27 -0
  358. package/dist/time/relative.js.map +1 -0
  359. package/dist/time/throttle.d.ts +38 -0
  360. package/dist/time/throttle.d.ts.map +1 -0
  361. package/dist/time/throttle.js +39 -0
  362. package/dist/time/throttle.js.map +1 -0
  363. package/dist/time/ticks.d.ts +21 -0
  364. package/dist/time/ticks.d.ts.map +1 -0
  365. package/dist/time/ticks.js +30 -0
  366. package/dist/time/ticks.js.map +1 -0
  367. package/dist/time/timer.d.ts +32 -0
  368. package/dist/time/timer.d.ts.map +1 -0
  369. package/dist/time/timer.js +50 -0
  370. package/dist/time/timer.js.map +1 -0
  371. package/package.json +31 -31
  372. package/dist/device/index.d.mts +0 -335
  373. package/dist/device/index.d.mts.map +0 -1
  374. package/dist/device/index.mjs +0 -493
  375. package/dist/device/index.mjs.map +0 -1
  376. package/dist/dom/index.d.mts +0 -714
  377. package/dist/dom/index.d.mts.map +0 -1
  378. package/dist/dom/index.mjs +0 -1840
  379. package/dist/dom/index.mjs.map +0 -1
  380. package/dist/editable-text-Bg7vil7h.d.mts +0 -307
  381. package/dist/editable-text-Bg7vil7h.d.mts.map +0 -1
  382. package/dist/events/index.d.mts +0 -168
  383. package/dist/events/index.d.mts.map +0 -1
  384. package/dist/events/index.mjs +0 -307
  385. package/dist/events/index.mjs.map +0 -1
  386. package/dist/follow-tab-stop-DM5EI4Ci.mjs +0 -856
  387. package/dist/follow-tab-stop-DM5EI4Ci.mjs.map +0 -1
  388. package/dist/index-Bomdwb7e.d.mts +0 -142
  389. package/dist/index-Bomdwb7e.d.mts.map +0 -1
  390. package/dist/index.d.mts +0 -12
  391. package/dist/index.mjs +0 -12
  392. package/dist/input-modality-XwQOFLip.mjs.map +0 -1
  393. package/dist/input-modality-l7InESYh.d.mts.map +0 -1
  394. package/dist/interaction/index.d.mts +0 -1193
  395. package/dist/interaction/index.d.mts.map +0 -1
  396. package/dist/interaction/index.mjs +0 -1992
  397. package/dist/interaction/index.mjs.map +0 -1
  398. package/dist/internal-C4gHodLc.mjs.map +0 -1
  399. package/dist/media/index.d.mts +0 -103
  400. package/dist/media/index.d.mts.map +0 -1
  401. package/dist/media/index.mjs +0 -146
  402. package/dist/media/index.mjs.map +0 -1
  403. package/dist/motion/index.d.mts +0 -2
  404. package/dist/motion/index.mjs +0 -1
  405. package/dist/motion-BmlJCjn6.mjs +0 -236
  406. package/dist/motion-BmlJCjn6.mjs.map +0 -1
  407. package/dist/net/index.d.mts +0 -338
  408. package/dist/net/index.d.mts.map +0 -1
  409. package/dist/net/index.mjs +0 -530
  410. package/dist/net/index.mjs.map +0 -1
  411. package/dist/observers/index.d.mts +0 -76
  412. package/dist/observers/index.d.mts.map +0 -1
  413. package/dist/observers/index.mjs +0 -155
  414. package/dist/observers/index.mjs.map +0 -1
  415. package/dist/rolldown-runtime-D8jQpDG7.mjs +0 -12
  416. package/dist/state/index.d.mts +0 -432
  417. package/dist/state/index.d.mts.map +0 -1
  418. package/dist/state/index.mjs.map +0 -1
  419. package/dist/time/index.d.mts +0 -167
  420. package/dist/time/index.d.mts.map +0 -1
  421. package/dist/time/index.mjs +0 -236
  422. package/dist/time/index.mjs.map +0 -1
@@ -1,300 +1,7 @@
1
- import { i as unlessSame, r as sameIds } from "../internal-C4gHodLc.mjs";
2
1
  import { Effect, Queue, Schema, Stream } from "effect";
3
- import * as Mount from "foldkit/mount";
4
2
  import { defineMessageUnion } from "foldkit/message";
5
3
  import { Bundle } from "foldkit-bundle";
6
- // src/state/history.ts
7
- const HistoryModel = (value) => Schema.Struct({
8
- past: Schema.Array(value),
9
- present: value,
10
- future: Schema.Array(value),
11
- /** The group of the last push, so the next push of the same group joins it; `null` for none. */
12
- group: Schema.NullOr(Schema.String)
13
- });
14
- const start = (present) => ({
15
- past: [],
16
- present,
17
- future: [],
18
- group: null
19
- });
20
- /**
21
- * No redo steps, keeping an already empty future: a view that reads the
22
- * future compares it by identity, so a push per keystroke or stroke cell
23
- * must not hand it a new empty array each time.
24
- */
25
- const noFuture = (model) => model.future.length === 0 ? model.future : [];
26
- const push = (model, value, options) => {
27
- const group = options.group ?? null;
28
- if (group !== null && group === model.group && model.past.length > 0) return {
29
- ...model,
30
- present: value,
31
- future: noFuture(model)
32
- };
33
- return {
34
- past: options.capacity === 0 ? [] : [...model.past, model.present].slice(-options.capacity),
35
- present: value,
36
- future: noFuture(model),
37
- group
38
- };
39
- };
40
- const undo = (model) => {
41
- const previous = model.past[model.past.length - 1];
42
- if (previous === void 0) return model;
43
- return {
44
- past: model.past.slice(0, -1),
45
- present: previous,
46
- future: [model.present, ...model.future],
47
- group: null
48
- };
49
- };
50
- const redo = (model) => {
51
- const next = model.future[0];
52
- if (next === void 0) return model;
53
- return {
54
- past: [...model.past, model.present],
55
- present: next,
56
- future: model.future.slice(1),
57
- group: null
58
- };
59
- };
60
- const goTo = (model, step) => {
61
- const steps = [
62
- ...model.past,
63
- model.present,
64
- ...model.future
65
- ];
66
- if (!Number.isInteger(step) || step < 0 || step >= steps.length || step === model.past.length) return model;
67
- return {
68
- past: steps.slice(0, step),
69
- present: steps[step],
70
- future: steps.slice(step + 1),
71
- group: null
72
- };
73
- };
74
- const clear = (model) => model.past.length === 0 && model.future.length === 0 && model.group === null ? model : start(model.present);
75
- const close = (model) => model.group === null ? model : {
76
- ...model,
77
- group: null
78
- };
79
- const revert = (model, group) => model.group === group ? {
80
- ...undo(model),
81
- future: [],
82
- group: null
83
- } : model;
84
- const checkCapacity = (name, capacity) => {
85
- if (!Number.isInteger(capacity) || capacity < 0) throw new Error(`History "${name}": capacity must be a non-negative integer`);
86
- return capacity;
87
- };
88
- /** Whether Undo would move: the past is non-empty. */
89
- const canUndo = (model) => model.past.length > 0;
90
- /** Whether Redo would move: the future is non-empty. */
91
- const canRedo = (model) => model.future.length > 0;
92
- /** The steps of a history as pure functions of its Model. */
93
- const History = {
94
- /** A history whose present is `value`, with nothing to undo. */
95
- start,
96
- /** Records `value` as the present; the same `group` as the last push joins its step. */
97
- push,
98
- /** One step back, or the Model as it was when there is none. */
99
- undo,
100
- /** One step forward, or the Model as it was when there is none. */
101
- redo,
102
- /**
103
- * The value at `step` made the present, counting every kept value from the
104
- * oldest (0), so the present is at `past.length`: what a click on a step's
105
- * thumbnail does. The Model as it was for the present or a step not kept.
106
- */
107
- goTo,
108
- /** Nothing to undo or redo, the present kept. */
109
- clear,
110
- /** The next push starts a step of its own, whatever its group: a group ends here. */
111
- close,
112
- /**
113
- * The step `group` is making taken back, and not redoable: what a cancelled
114
- * edit, or one that ended where it began, leaves. The Model as it was when
115
- * the last push was not of `group`. What the group's first push dropped
116
- * stays dropped: the redo future it cleared, and an entry capacity evicted;
117
- * with a capacity of 0 nothing was kept, so the present stays and only the
118
- * group ends.
119
- */
120
- revert,
121
- canUndo,
122
- canRedo
123
- };
124
- /**
125
- * Undo/redo as a bundle factory: the past, present, and future of one value
126
- * live in the Model, so every step replays. Pushing records, even an unchanged
127
- * value; skipping duplicates is the application's policy, not the stack's.
128
- *
129
- * A push may name a `group`. Consecutive pushes of the same group are one step:
130
- * the present moves and nothing new is recorded, so typing a word undoes as a
131
- * whole. Grouping needs no clock; the application names what belongs together.
132
- *
133
- * The steps are also pure functions (`History.push`, `undo`, `redo`, `goTo`, `clear`),
134
- * for a parent that records an edit in the same transition that makes it
135
- * rather than dispatching a Message to a placed bundle.
136
- */
137
- const history = (config) => {
138
- const capacity = checkCapacity(config.name, config.capacity ?? 100);
139
- const Model = HistoryModel(config.value);
140
- const Message = defineMessageUnion({
141
- Push: {
142
- value: config.value,
143
- group: Schema.optional(Schema.String)
144
- },
145
- Undo: {},
146
- Redo: {},
147
- GoTo: { step: Schema.Number },
148
- Clear: {}
149
- });
150
- return Object.assign(Bundle.make(config.name, {
151
- Model,
152
- Message,
153
- args: Schema.Struct({ initial: config.value }),
154
- init: (args) => ({ model: start(args.initial) }),
155
- update: (model, message) => Message.match(message, {
156
- Push: ({ value, group }) => ({ model: push(model, value, {
157
- capacity,
158
- group
159
- }) }),
160
- Undo: () => ({ model: undo(model) }),
161
- Redo: () => ({ model: redo(model) }),
162
- GoTo: ({ step }) => ({ model: goTo(model, step) }),
163
- Clear: () => ({ model: clear(model) })
164
- })
165
- }), { Message });
166
- };
167
- // src/state/locale.ts
168
- const LocaleModel = Schema.Struct({ locale: Schema.String });
169
- const LocaleMessage = defineMessageUnion({ SetLocale: { locale: Schema.String } });
170
- /**
171
- * Locale as a bundle: the current locale string in the Model. Starts from
172
- * `navigator.language` where available, falling back to the configured
173
- * default; changes arrive as Messages. No subscriptions: language changes
174
- * take effect on reload.
175
- */
176
- const Locale = Bundle.make("Locale", {
177
- Model: LocaleModel,
178
- Message: LocaleMessage,
179
- args: Schema.Struct({ default: Schema.String }),
180
- init: (args) => ({ model: { locale: typeof navigator !== "undefined" && typeof navigator.language === "string" ? navigator.language : args.default } }),
181
- update: (model, message) => LocaleMessage.match(message, { SetLocale: ({ locale }) => locale === model.locale ? { model } : { model: {
182
- ...model,
183
- locale
184
- } } })
185
- });
186
- // src/state/pagination.ts
187
- const PaginationModel = Schema.Struct({
188
- page: Schema.Number,
189
- perPage: Schema.Number,
190
- total: Schema.NullOr(Schema.Number)
191
- });
192
- const PaginationMessage = defineMessageUnion({
193
- GoToPage: { page: Schema.Number },
194
- NextPage: {},
195
- PrevPage: {},
196
- SetPerPage: { perPage: Schema.Number },
197
- SetTotal: { total: Schema.NullOr(Schema.Number) }
198
- });
199
- const clampPage = (page, perPage, total) => {
200
- if (!Number.isInteger(page)) return 1;
201
- if (page < 1) return 1;
202
- if (total === null) return page;
203
- return Math.min(page, Math.max(1, Math.ceil(total / perPage)));
204
- };
205
- /** The number of pages, or null while the total is unknown. */
206
- const pageCount = (model) => model.total === null ? null : Math.max(1, Math.ceil(model.total / model.perPage));
207
- /** The offset of the first item on the page, for a slice or a query. */
208
- const offset = (model) => (model.page - 1) * model.perPage;
209
- /**
210
- * Pagination as a bundle: the page, page size, and total live in the Model,
211
- * so page changes replay and every transition clamps into range. Pure logic,
212
- * no streams: data loading stays the application's job.
213
- */
214
- const Pagination = Bundle.make("Pagination", {
215
- Model: PaginationModel,
216
- Message: PaginationMessage,
217
- args: Schema.Struct({
218
- perPage: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())),
219
- total: Schema.optional(Schema.NullOr(Schema.Number.pipe(Schema.check(Schema.isFinite()))))
220
- }),
221
- init: (args) => ({ model: {
222
- page: 1,
223
- perPage: args.perPage,
224
- total: args.total ?? null
225
- } }),
226
- update: (model, message) => PaginationMessage.match(message, {
227
- GoToPage: ({ page }) => ({ model: unlessSame(model, {
228
- ...model,
229
- page: clampPage(page, model.perPage, model.total)
230
- }) }),
231
- NextPage: () => ({ model: unlessSame(model, {
232
- ...model,
233
- page: clampPage(model.page + 1, model.perPage, model.total)
234
- }) }),
235
- PrevPage: () => ({ model: unlessSame(model, {
236
- ...model,
237
- page: clampPage(model.page - 1, model.perPage, model.total)
238
- }) }),
239
- SetPerPage: ({ perPage }) => perPage > 0 ? { model: unlessSame(model, {
240
- ...model,
241
- perPage,
242
- page: clampPage(model.page, perPage, model.total)
243
- }) } : { model },
244
- SetTotal: ({ total }) => total === null || total >= 0 ? { model: unlessSame(model, {
245
- ...model,
246
- total,
247
- page: clampPage(model.page, model.perPage, total)
248
- }) } : { model }
249
- })
250
- });
251
- // src/state/range.ts
252
- /**
253
- * A numeric range as an array: `range(1, 4)` is `[1, 2, 3]`, inclusive of
254
- * the start and exclusive of the end, like `Array.from` length math. The
255
- * pagination companion: `range(1, (pageCount(model) ?? 0) + 1)` is the page
256
- * list. A zero or non-finite step would loop forever, so it throws, naming
257
- * the caller — like History's capacity check.
258
- */
259
- const range = (start, end, step = 1) => {
260
- if (!Number.isFinite(step) || step === 0) throw new Error(`range: step must be a non-zero finite number, got ${step}`);
261
- const values = [];
262
- if (step > 0) for (let value = start; value < end; value += step) values.push(value);
263
- else for (let value = start; value > end; value += step) values.push(value);
264
- return values;
265
- };
266
- // src/state/selection.ts
267
- const SelectionSetModel = Schema.Struct({ selected: Schema.Array(Schema.String) });
268
- const SelectionSetMessage = defineMessageUnion({
269
- Select: { id: Schema.String },
270
- Deselect: { id: Schema.String },
271
- Toggle: { id: Schema.String },
272
- ReplaceAll: { ids: Schema.Array(Schema.String) },
273
- Clear: {}
274
- });
275
- const without = (selected, id) => selected.filter((other) => other !== id);
276
- /** Whether the id is currently selected. */
277
- const isSelected = (model, id) => model.selected.includes(id);
278
- /**
279
- * A selection set as a bundle: the selected ids in the Model, changed one at
280
- * a time or replaced whole. Order follows first selection; toggling moves a
281
- * reselected id to the end. Pure logic, no streams.
282
- */
283
- const SelectionSet = Bundle.make("SelectionSet", {
284
- Model: SelectionSetModel,
285
- Message: SelectionSetMessage,
286
- init: () => ({ model: { selected: [] } }),
287
- update: (model, message) => SelectionSetMessage.match(message, {
288
- Select: ({ id }) => isSelected(model, id) ? { model } : { model: { selected: [...model.selected, id] } },
289
- Deselect: ({ id }) => isSelected(model, id) ? { model: { selected: without(model.selected, id) } } : { model },
290
- Toggle: ({ id }) => isSelected(model, id) ? { model: { selected: without(model.selected, id) } } : { model: { selected: [...model.selected, id] } },
291
- ReplaceAll: ({ ids }) => {
292
- const selected = [...new Set(ids)];
293
- return sameIds(selected, model.selected) ? { model } : { model: { selected } };
294
- },
295
- Clear: () => model.selected.length === 0 ? { model } : { model: { selected: [] } }
296
- })
297
- });
4
+ import * as Mount from "foldkit/mount";
298
5
  // src/state/virtual.ts
299
6
  const saneHeight = (height, estimatedHeight) => Number.isFinite(height) && height >= 0 ? height : estimatedHeight;
300
7
  const heightAt = (index, heights, keys, layout) => {
@@ -451,11 +158,10 @@ const Virtual = Bundle.make("Virtual", {
451
158
  initialHeights: Schema.optional(Schema.Record(Schema.String, Schema.Number))
452
159
  }),
453
160
  init: (args) => {
454
- const heights = {};
455
- for (const [key, height] of Object.entries(args.initialHeights ?? {})) {
161
+ const heights = Object.fromEntries(Object.entries(args.initialHeights ?? {}).flatMap(([key, height]) => {
456
162
  const sane = saneMeasured(height);
457
- if (sane !== null) heights[key] = sane;
458
- }
163
+ return sane === null ? [] : [[key, sane]];
164
+ }));
459
165
  return { model: {
460
166
  scrollTop: args.initialScrollTop ?? 0,
461
167
  heights,
@@ -499,13 +205,11 @@ const Virtual = Bundle.make("Virtual", {
499
205
  },
500
206
  Prune: ({ keys }) => {
501
207
  const kept = new Set(keys);
502
- const heights = {};
503
- let dropped = false;
504
- for (const [key, height] of Object.entries(model.heights)) if (kept.has(key)) heights[key] = height;
505
- else dropped = true;
506
- return dropped ? { model: {
208
+ const entries = Object.entries(model.heights);
209
+ const held = entries.filter(([key]) => kept.has(key));
210
+ return held.length < entries.length ? { model: {
507
211
  ...model,
508
- heights
212
+ heights: Object.fromEntries(held)
509
213
  } } : { model };
510
214
  },
511
215
  Settled: ({ generation }) => generation === model.generation ? { model: {
@@ -608,6 +312,6 @@ const masonry = (keys, heights, options) => {
608
312
  totalHeight: placements.length === 0 ? 0 : Math.max(...columnHeights) - options.gap
609
313
  };
610
314
  };
611
- export { History, HistoryModel, Locale, LocaleMessage, LocaleModel, MeasureRow, Pagination, PaginationMessage, PaginationModel, RowMeasured, SelectionSet, SelectionSetMessage, SelectionSetModel, Viewport, ViewportScrolled, Virtual, VirtualMessage, VirtualModel, canRedo, canUndo, distanceToEnd, history, isAtEnd, isSelected, masonry, offset, offsetFor, pageCount, range, stickyHeader, totalHeight, visibleRange, windowFor };
315
+ export { MeasureRow, RowMeasured, Viewport, ViewportScrolled, Virtual, VirtualMessage, VirtualModel, distanceToEnd, isAtEnd, masonry, offsetFor, stickyHeader, totalHeight, visibleRange, windowFor };
612
316
 
613
- //# sourceMappingURL=index.mjs.map
317
+ //# sourceMappingURL=virtual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual.js","names":[],"sources":["../../src/state/virtual.ts"],"sourcesContent":["import { Effect, Queue, Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Mount from 'foldkit/mount'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\n\n/** The rows to draw: a half-open range of indexes. */\nexport interface VirtualWindow {\n /** First visible row index, inclusive. */\n readonly start: number\n /** End row index, exclusive. */\n readonly end: number\n}\n\n/** Layout constants: per-row estimate, inter-row gap, and end padding. */\nexport interface VirtualLayout {\n readonly estimatedHeight: number\n readonly gap: number\n readonly paddingStart: number\n readonly paddingEnd: number\n}\n\nconst saneHeight = (height: number, estimatedHeight: number): number =>\n Number.isFinite(height) && height >= 0 ? height : estimatedHeight\n\nconst heightAt = (\n index: number,\n heights: Readonly<Record<string, number>>,\n keys: ReadonlyArray<string>,\n layout: VirtualLayout,\n): number => {\n const key = keys[index]\n if (key === undefined) return layout.estimatedHeight\n return saneHeight(heights[key] ?? layout.estimatedHeight, layout.estimatedHeight)\n}\n\ninterface Offsets {\n readonly heights: Readonly<Record<string, number>>\n readonly layout: VirtualLayout\n /** `tops[i]` is row i's top edge; `tops[count]` is past the last row's gap. */\n readonly tops: Float64Array\n}\n\n// One entry per keys array, replaced when the heights or the layout change: a\n// view that keeps its keys array between renders pays O(n) once per change of\n// heights, not once per call. Keys and heights are compared by identity, so an\n// array or record changed in place reads stale offsets; the Model never is.\nconst offsetsCache = new WeakMap<ReadonlyArray<string>, Offsets>()\n\nconst sameLayout = (a: VirtualLayout, b: VirtualLayout): boolean =>\n a.estimatedHeight === b.estimatedHeight &&\n a.gap === b.gap &&\n a.paddingStart === b.paddingStart &&\n a.paddingEnd === b.paddingEnd\n\nconst topsFor = (\n keys: ReadonlyArray<string>,\n heights: Readonly<Record<string, number>>,\n layout: VirtualLayout,\n): Float64Array => {\n const cached = offsetsCache.get(keys)\n if (cached !== undefined && cached.heights === heights && sameLayout(cached.layout, layout)) {\n return cached.tops\n }\n const tops = new Float64Array(keys.length + 1)\n tops[0] = layout.paddingStart\n for (let index = 0; index < keys.length; index++) {\n tops[index + 1] = tops[index]! + heightAt(index, heights, keys, layout) + layout.gap\n }\n offsetsCache.set(keys, { heights, layout: { ...layout }, tops })\n return tops\n}\n\n/** The first index in `[from, to)` whose value passes `test`, or `to`; `test` must be monotonic. */\nconst firstIndex = (from: number, to: number, test: (index: number) => boolean): number => {\n let low = from\n let high = to\n while (low < high) {\n const middle = (low + high) >>> 1\n if (test(middle)) high = middle\n else low = middle + 1\n }\n return low\n}\n\n/** Total scrollable height: padding, measured rows, estimates, and gaps. */\nexport const totalHeight = (\n keys: ReadonlyArray<string>,\n heights: Readonly<Record<string, number>>,\n layout: VirtualLayout,\n): number => {\n const last = keys.length - 1\n if (last === -1) return layout.paddingStart + layout.paddingEnd\n // The last row's bottom edge, not `tops[count]` less a gap: subtracting a\n // fractional gap back out need not land where the row ends.\n return (\n topsFor(keys, heights, layout)[last]! +\n heightAt(last, heights, keys, layout) +\n layout.paddingEnd\n )\n}\n\n/** Pixel offset of a row's top edge: padding plus the prefix before it. */\nexport const offsetFor = (\n index: number,\n keys: ReadonlyArray<string>,\n heights: Readonly<Record<string, number>>,\n layout: VirtualLayout,\n): number => topsFor(keys, heights, layout)[Math.max(0, Math.min(index, keys.length))]!\n\n/**\n * Which rows to render for a scroll position: the rows intersecting\n * `[scrollTop, scrollTop + viewportHeight)`, widened by `overscan` on both\n * sides and clamped to `[0, count]`. Gaps and padding are dead space — no\n * row — so boxes are tested, not cumulative coverage. An overscan of zero\n * renders exactly the visible rows.\n */\nexport const visibleRange = (\n keys: ReadonlyArray<string>,\n heights: Readonly<Record<string, number>>,\n layout: VirtualLayout,\n scrollTop: number,\n viewportHeight: number,\n overscan: number,\n): VirtualWindow => {\n const count = keys.length\n if (count === 0 || viewportHeight <= 0) return { start: 0, end: 0 }\n const tops = topsFor(keys, heights, layout)\n const top = Math.max(0, scrollTop)\n const bottom = top + viewportHeight\n // Row bottoms and tops only grow with the index, so both edges are searches.\n const start = firstIndex(\n 0,\n count,\n index => tops[index]! + heightAt(index, heights, keys, layout) > top,\n )\n const end = firstIndex(start, count, index => tops[index]! >= bottom)\n return {\n start: Math.max(0, start - Math.max(0, overscan)),\n end: Math.min(count, end + Math.max(0, overscan)),\n }\n}\n\nexport const VirtualModel = Schema.Struct({\n scrollTop: Schema.Number,\n heights: Schema.Record(Schema.String, Schema.Number),\n scrolling: Schema.Boolean,\n generation: Schema.Number,\n estimatedHeight: Schema.Number,\n overscan: Schema.Number,\n gap: Schema.Number,\n paddingStart: Schema.Number,\n paddingEnd: Schema.Number,\n})\nexport type VirtualModel = typeof VirtualModel.Type\n\nexport const VirtualMessage = defineMessageUnion({\n Scrolled: { top: Schema.Number },\n Measured: { key: Schema.String, height: Schema.Number },\n /** Drops heights for keys no longer listed: the bundle never sees the key\n order, so the application tells it what left. */\n Prune: { keys: Schema.Array(Schema.String) },\n /** Fires when scrolling has been silent for `settleMs`: only the latest\n generation counts, so a fling's intermediate timers emit nothing. */\n Settled: { generation: Schema.Number },\n})\nexport type VirtualMessage = typeof VirtualMessage.Type\n\nconst layoutOf = (model: VirtualModel): VirtualLayout => ({\n estimatedHeight: model.estimatedHeight,\n gap: model.gap,\n paddingStart: model.paddingStart,\n paddingEnd: model.paddingEnd,\n})\n\n/**\n * The rows to render plus the spacer height, from the Model, the key order,\n * and the viewport height. Layout and overscan come from the Model, so the\n * call cannot disagree with the placement. Keys stay the application's:\n * render each row keyed, and per-row placements keep identity.\n */\nexport const windowFor = (\n model: VirtualModel,\n keys: ReadonlyArray<string>,\n viewportHeight: number,\n): VirtualWindow & { readonly totalHeight: number } => {\n const layout = layoutOf(model)\n const window = visibleRange(\n keys,\n model.heights,\n layout,\n model.scrollTop,\n viewportHeight,\n model.overscan,\n )\n return { ...window, totalHeight: totalHeight(keys, model.heights, layout) }\n}\n\n/**\n * Pixels from the viewport's bottom edge to the content's end: negative\n * past it, zero exactly there. Prefetch thresholds want this number (\"load\n * when within 500px\"), not just the boolean below.\n */\nexport const distanceToEnd = (\n model: VirtualModel,\n keys: ReadonlyArray<string>,\n viewportHeight: number,\n): number => {\n const total = totalHeight(keys, model.heights, layoutOf(model))\n return total - (model.scrollTop + viewportHeight)\n}\n\n/**\n * Whether the viewport rests at (or past) the end, within `threshold`\n * pixels: the infinite-scroll check. An empty list counts as ended — there\n * is nothing to scroll, so more should load. Thresholds below zero clamp\n * to zero.\n */\nexport const isAtEnd = (\n model: VirtualModel,\n keys: ReadonlyArray<string>,\n viewportHeight: number,\n threshold = 0,\n): boolean => {\n const total = totalHeight(keys, model.heights, layoutOf(model))\n if (total <= 0) return true\n return total - (model.scrollTop + viewportHeight) <= Math.max(0, threshold)\n}\n\nconst saneTop = (top: number): number | null => (Number.isFinite(top) ? Math.max(0, top) : null)\n\nconst saneMeasured = (height: number): number | null =>\n Number.isFinite(height) && height >= 0 ? height : null\n\n/**\n * Windowing math for virtualized lists as pure functions: which rows to\n * render, how tall the scrollable area is, and where each row starts. Row\n * heights come from measured values with a per-row estimate fallback, so\n * unmeasured rows still occupy space and measuring later only corrects.\n * Keys are strings; heights are non-negative, and non-finite measurements\n * fall back to the estimate instead of poisoning the sums.\n *\n * The `Virtual` bundle below owns the scroll position and the measured\n * heights; `Viewport` reports container scrolls and `MeasureRow` reports\n * row heights, both as Mounts on the elements they observe. The application\n * renders `windowFor(...)` rows with its own views (keyed, so `each`\n * placements keep identity) inside a spacer of `totalHeight(...)`.\n */\nexport const Virtual = Bundle.make('Virtual', {\n Model: VirtualModel,\n Message: VirtualMessage,\n args: Schema.Struct({\n estimatedHeight: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThan(0)),\n Schema.check(Schema.isFinite()),\n ),\n overscan: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),\n gap: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThanOrEqualTo(0)),\n Schema.check(Schema.isFinite()),\n ),\n paddingStart: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThanOrEqualTo(0)),\n Schema.check(Schema.isFinite()),\n ),\n paddingEnd: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThanOrEqualTo(0)),\n Schema.check(Schema.isFinite()),\n ),\n settleMs: Schema.optional(\n Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())),\n ),\n initialScrollTop: Schema.optional(\n Schema.Number.pipe(\n Schema.check(Schema.isGreaterThanOrEqualTo(0)),\n Schema.check(Schema.isFinite()),\n ),\n ),\n initialHeights: Schema.optional(Schema.Record(Schema.String, Schema.Number)),\n }),\n init: args => {\n // Restored measurements pass through the same sanitation as live ones,\n // so a poisoned cache cannot wedge the sums. Built from entries, since\n // assigning a row keyed `__proto__` sets the prototype.\n const heights: Record<string, number> = Object.fromEntries(\n Object.entries(args.initialHeights ?? {}).flatMap(([key, height]) => {\n const sane = saneMeasured(height)\n return sane === null ? [] : [[key, sane] as const]\n }),\n )\n return {\n model: {\n scrollTop: args.initialScrollTop ?? 0,\n heights,\n scrolling: false,\n generation: 0,\n estimatedHeight: args.estimatedHeight,\n overscan: args.overscan,\n gap: args.gap,\n paddingStart: args.paddingStart,\n paddingEnd: args.paddingEnd,\n },\n }\n },\n update: (model, message, args) =>\n VirtualMessage.match<Update.ReturnWithOutMessage<VirtualModel, VirtualMessage, never>>(\n message,\n {\n Scrolled: ({ top }) => {\n const sane = saneTop(top)\n // The Viewport reports the position it mounts at, and a horizontal\n // scroll reports an unchanged top. The raw top is compared, so an\n // overscroll past zero still counts as scrolling.\n if (sane === null || top === model.scrollTop) return { model }\n const generation = model.generation + 1\n return {\n model: { ...model, scrollTop: sane, scrolling: true, generation },\n commands: [\n {\n name: 'Virtual.settle',\n args: { generation },\n effect: Effect.as(\n Effect.sleep(args.settleMs ?? 150),\n VirtualMessage.Settled({ generation }),\n ),\n },\n ],\n }\n },\n Measured: ({ key, height }) => {\n const sane = saneMeasured(height)\n // A remounted row, or a width-only resize, reports the height held.\n return sane === null || (Object.hasOwn(model.heights, key) && model.heights[key] === sane)\n ? { model }\n : { model: { ...model, heights: { ...model.heights, [key]: sane } } }\n },\n Prune: ({ keys }) => {\n const kept = new Set(keys)\n const entries = Object.entries(model.heights)\n const held = entries.filter(([key]) => kept.has(key))\n return held.length < entries.length\n ? { model: { ...model, heights: Object.fromEntries(held) } }\n : { model }\n },\n // A superseded silence timer carries an old generation: ignore it.\n Settled: ({ generation }) =>\n generation === model.generation ? { model: { ...model, scrolling: false } } : { model },\n },\n ),\n})\n\nexport const ViewportScrolled = Schema.TaggedStruct('ViewportScrolled', { top: Schema.Number })\nexport type ViewportScrolled = typeof ViewportScrolled.Type\n\n/**\n * The scroll container's position, reported on its own scrolls starting\n * with the current one. Attach to the scrolling element — viewport scrolls\n * arrive through the window-level scroll entry instead.\n */\nexport const Viewport = Mount.defineStream('Viewport', {\n messages: [ViewportScrolled],\n execute: ({ element }) => {\n // The mount needs only a scroll position, not a full Element.\n const read = (): ViewportScrolled => {\n const scroller = element as unknown as { readonly scrollTop: number }\n return ViewportScrolled.make({ top: scroller.scrollTop })\n }\n return Stream.concat(\n Stream.make(read()),\n Stream.fromEventListener(element, 'scroll').pipe(Stream.map(read)),\n )\n },\n})\n\nexport const RowMeasured = Schema.TaggedStruct('RowMeasured', {\n key: Schema.String,\n height: Schema.Number,\n})\nexport type RowMeasured = typeof RowMeasured.Type\n\ntype RowObserverCtor = new (callback: ResizeObserverCallback) => ResizeObserver\n\n/**\n * One row's height, reported on every resize starting with the current\n * one. The key is the application's row identity, echoed back so the\n * parent files the height without tracking which Mount sent what.\n */\nexport const MeasureRow = Mount.defineStream('MeasureRow', {\n messages: [RowMeasured],\n args: { key: Schema.String },\n execute: ({ element, key }) =>\n Stream.callback<typeof RowMeasured.Type>(queue =>\n Effect.gen(function* () {\n const Observed = (globalThis as { ResizeObserver?: RowObserverCtor }).ResizeObserver\n if (Observed === undefined) return\n yield* Effect.acquireRelease(\n Effect.sync(() => {\n const observer = new Observed(entries => {\n const rect = entries[0]?.contentRect\n if (rect !== undefined) {\n Queue.offerUnsafe(queue, RowMeasured.make({ key, height: rect.height }))\n }\n })\n observer.observe(element)\n return observer\n }),\n observer => Effect.sync(() => observer.disconnect()),\n )\n }),\n ),\n})\n\n/**\n * Which section header sticks for a window: the last section starting at\n * or before the first rendered row, or null above the first section. Order\n * independent — the scan takes the maximum, so unsorted input still\n * answers. CSS `position: sticky` does the sticking; this answers *what*\n * sticks, for styling and callbacks.\n */\nexport const stickyHeader = (\n sections: ReadonlyArray<{ readonly key: string; readonly index: number }>,\n startIndex: number,\n): string | null => {\n let current: string | null = null\n let currentIndex = -1\n for (const section of sections) {\n if (section.index <= startIndex && section.index > currentIndex) {\n current = section.key\n currentIndex = section.index\n }\n }\n return current\n}\n\n/** Where `masonry` puts one item: its column and its box, in pixels. */\nexport interface MasonryPlacement {\n readonly key: string\n readonly column: number\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\n/**\n * Masonry layout as a pure function: fixed column count and width, each\n * item packed into the currently shortest column. Unmeasured items use the\n * estimate; poisoned heights fall back the same way. This is layout only,\n * not windowing — every placed item renders, so it fits hundreds of images,\n * not hundred-thousands. Needing a windowed grid is a different algorithm.\n */\nexport const masonry = (\n keys: ReadonlyArray<string>,\n heights: Readonly<Record<string, number>>,\n options: {\n readonly columns: number\n readonly columnWidth: number\n readonly gap: number\n readonly estimatedHeight: number\n },\n): { readonly placements: ReadonlyArray<MasonryPlacement>; readonly totalHeight: number } => {\n if (!Number.isInteger(options.columns) || options.columns < 1) {\n throw new Error(`masonry: columns must be a positive integer, got ${options.columns}`)\n }\n if (!(options.columnWidth > 0) || !Number.isFinite(options.columnWidth)) {\n throw new Error(\n `masonry: columnWidth must be a positive finite number, got ${options.columnWidth}`,\n )\n }\n if (options.gap < 0 || !Number.isFinite(options.gap)) {\n throw new Error(`masonry: gap must be a non-negative finite number, got ${options.gap}`)\n }\n if (options.estimatedHeight < 0 || !Number.isFinite(options.estimatedHeight)) {\n throw new Error(\n `masonry: estimatedHeight must be a non-negative finite number, got ${options.estimatedHeight}`,\n )\n }\n const columnHeights: Array<number> = new Array(options.columns).fill(0)\n const placements: Array<MasonryPlacement> = []\n for (const key of keys) {\n const raw = heights[key] ?? options.estimatedHeight\n const height = Number.isFinite(raw) && raw >= 0 ? raw : options.estimatedHeight\n let column = 0\n for (let c = 1; c < columnHeights.length; c++) {\n if (columnHeights[c]! < columnHeights[column]!) column = c\n }\n placements.push({\n key,\n column,\n x: column * (options.columnWidth + options.gap),\n y: columnHeights[column]!,\n width: options.columnWidth,\n height,\n })\n columnHeights[column] = columnHeights[column]! + height + options.gap\n }\n return {\n placements,\n totalHeight: placements.length === 0 ? 0 : Math.max(...columnHeights) - options.gap,\n }\n}\n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MAAM,IAAI,MAAM,0DAA0D,QAAQ,KAAK;CAEzF,IAAI,QAAQ,kBAAkB,KAAK,CAAC,OAAO,SAAS,QAAQ,eAAe,GACzE,MAAM,IAAI,MACR,sEAAsE,QAAQ,iBAChF;CAEF,MAAM,gBAA+B,IAAI,MAAM,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC;CACtE,MAAM,aAAsC,CAAC;CAC7C,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,MAAM,QAAQ,QAAQ,QAAQ;EACpC,MAAM,SAAS,OAAO,SAAS,GAAG,KAAK,OAAO,IAAI,MAAM,QAAQ;EAChE,IAAI,SAAS;EACb,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,cAAc,KAAM,cAAc,SAAU,SAAS;EAE3D,WAAW,KAAK;GACd;GACA;GACA,GAAG,UAAU,QAAQ,cAAc,QAAQ;GAC3C,GAAG,cAAc;GACjB,OAAO,QAAQ;GACf;EACF,CAAC;EACD,cAAc,UAAU,cAAc,UAAW,SAAS,QAAQ;CACpE;CACA,OAAO;EACL;EACA,aAAa,WAAW,WAAW,IAAI,IAAI,KAAK,IAAI,GAAG,aAAa,IAAI,QAAQ;CAClF;AACF"}
@@ -0,0 +1,43 @@
1
+ import { Schema } from "effect";
2
+ import { Bundle } from "foldkit-bundle";
3
+ /**
4
+ * Debounced input as a bundle factory: `Changed` restarts a timer, and the
5
+ * latest value settles as an OutMessage the placement must handle with
6
+ * `onOut`. Each `Changed` bumps a generation carried by the `Settled` fact
7
+ * it schedules, so a superseded timer's fact emits nothing — the same guard
8
+ * as Presence's exit timeout. Generic over the value Schema, like History.
9
+ * The clock is Effect's, so tests drive it with TestClock.
10
+ */
11
+ export declare const debounce: <const Name extends string, Value>(config: {
12
+ readonly name: Name;
13
+ readonly value: Schema.Codec<Value, unknown>;
14
+ }) => Bundle.Bundle<Name, {
15
+ readonly delayMs: number;
16
+ }, {
17
+ readonly latest: Value | null;
18
+ readonly generation: number;
19
+ }, {
20
+ readonly _tag: "Changed";
21
+ readonly value: Value;
22
+ } | {
23
+ readonly _tag: "Settled";
24
+ readonly value: Value;
25
+ readonly generation: number;
26
+ }, {
27
+ readonly _tag: "Debounced";
28
+ readonly value: Value;
29
+ }, never, never, void, {}, {}> & {
30
+ Message: import("foldkit/message").MessageUnion<{
31
+ readonly Changed: {
32
+ value: Schema.Codec<Value, unknown, never, never>;
33
+ };
34
+ readonly Settled: {
35
+ value: Schema.Codec<Value, unknown, never, never>;
36
+ generation: Schema.Number;
37
+ };
38
+ }>;
39
+ Debounced: Schema.TaggedStruct<"Debounced", {
40
+ readonly value: Schema.Codec<Value, unknown, never, never>;
41
+ }>;
42
+ };
43
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","names":[],"sources":["../../src/time/debounce.ts"],"mappings":";;;;;;;;;;qBAaa,iBAAkB,qBAAqB,OAAK;WAC9C,MAAM;WACN,OAAO,OAAO,MAAM;MAC9B,OAAA,OAAA;;;;;;;;;;;;;;;;;;MAQc,OAAK,OAAA,MAAA;;;MACL,OAAK,OAAA,MAAA;MAAgB,YAAU,OAAA"}
@@ -0,0 +1,65 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { defineMessageUnion } from "foldkit/message";
3
+ import { Bundle } from "foldkit-bundle";
4
+ // src/time/debounce.ts
5
+ /**
6
+ * Debounced input as a bundle factory: `Changed` restarts a timer, and the
7
+ * latest value settles as an OutMessage the placement must handle with
8
+ * `onOut`. Each `Changed` bumps a generation carried by the `Settled` fact
9
+ * it schedules, so a superseded timer's fact emits nothing — the same guard
10
+ * as Presence's exit timeout. Generic over the value Schema, like History.
11
+ * The clock is Effect's, so tests drive it with TestClock.
12
+ */
13
+ const debounce = (config) => {
14
+ const Model = Schema.Struct({
15
+ latest: Schema.NullOr(config.value),
16
+ generation: Schema.Number
17
+ });
18
+ const Message = defineMessageUnion({
19
+ Changed: { value: config.value },
20
+ Settled: {
21
+ value: config.value,
22
+ generation: Schema.Number
23
+ }
24
+ });
25
+ const Debounced = Schema.TaggedStruct("Debounced", { value: config.value });
26
+ const bundle = Bundle.make(config.name, {
27
+ Model,
28
+ Message,
29
+ args: Schema.Struct({ delayMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
30
+ init: () => ({ model: {
31
+ latest: null,
32
+ generation: 0
33
+ } }),
34
+ update: (model, message, args) => Message.match(message, {
35
+ Changed: ({ value }) => {
36
+ const generation = model.generation + 1;
37
+ return {
38
+ model: {
39
+ latest: value,
40
+ generation
41
+ },
42
+ commands: [{
43
+ name: `${config.name}.settle`,
44
+ args: { generation },
45
+ effect: Effect.as(Effect.sleep(args.delayMs), Message.Settled({
46
+ value,
47
+ generation
48
+ }))
49
+ }]
50
+ };
51
+ },
52
+ Settled: ({ generation, value }) => generation === model.generation ? {
53
+ model,
54
+ outMessage: Debounced.make({ value })
55
+ } : { model }
56
+ })
57
+ });
58
+ return Object.assign(bundle, {
59
+ Message,
60
+ Debounced
61
+ });
62
+ };
63
+ export { debounce };
64
+
65
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","names":[],"sources":["../../src/time/debounce.ts"],"sourcesContent":["import { Effect, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\n\n/**\n * Debounced input as a bundle factory: `Changed` restarts a timer, and the\n * latest value settles as an OutMessage the placement must handle with\n * `onOut`. Each `Changed` bumps a generation carried by the `Settled` fact\n * it schedules, so a superseded timer's fact emits nothing — the same guard\n * as Presence's exit timeout. Generic over the value Schema, like History.\n * The clock is Effect's, so tests drive it with TestClock.\n */\nexport const debounce = <const Name extends string, Value>(config: {\n readonly name: Name\n readonly value: Schema.Codec<Value, unknown>\n}) => {\n const Model = Schema.Struct({\n latest: Schema.NullOr(config.value),\n generation: Schema.Number,\n })\n type Model = typeof Model.Type\n\n const Message = defineMessageUnion({\n Changed: { value: config.value },\n Settled: { value: config.value, generation: Schema.Number },\n })\n type Message = typeof Message.Type\n\n const Debounced = Schema.TaggedStruct('Debounced', { value: config.value })\n type Debounced = typeof Debounced.Type\n\n const bundle = Bundle.make(config.name, {\n Model,\n Message,\n args: Schema.Struct({\n delayMs: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThan(0)),\n Schema.check(Schema.isFinite()),\n ),\n }),\n init: () => ({ model: { latest: null, generation: 0 } }),\n update: (model, message, args) =>\n Message.match<Update.ReturnWithOutMessage<Model, Message, Debounced>>(message, {\n Changed: ({ value }) => {\n const generation = model.generation + 1\n return {\n model: { latest: value, generation },\n commands: [\n {\n name: `${config.name}.settle`,\n args: { generation },\n effect: Effect.as(\n Effect.sleep(args.delayMs),\n Message.Settled({ value, generation }),\n ),\n },\n ],\n }\n },\n // A superseded timer's fact arrives with an old generation: no\n // OutMessage, so the placement never sees it.\n Settled: ({ generation, value }) =>\n generation === model.generation\n ? { model, outMessage: Debounced.make({ value }) }\n : { model },\n }),\n })\n\n return Object.assign(bundle, { Message, Debounced })\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,YAA8C,WAGrD;CACJ,MAAM,QAAQ,OAAO,OAAO;EAC1B,QAAQ,OAAO,OAAO,OAAO,KAAK;EAClC,YAAY,OAAO;CACrB,CAAC;CAGD,MAAM,UAAU,mBAAmB;EACjC,SAAS,EAAE,OAAO,OAAO,MAAM;EAC/B,SAAS;GAAE,OAAO,OAAO;GAAO,YAAY,OAAO;EAAO;CAC5D,CAAC;CAGD,MAAM,YAAY,OAAO,aAAa,aAAa,EAAE,OAAO,OAAO,MAAM,CAAC;CAG1E,MAAM,SAAS,OAAO,KAAK,OAAO,MAAM;EACtC;EACA;EACA,MAAM,OAAO,OAAO,EAClB,SAAS,OAAO,OAAO,KACrB,OAAO,MAAM,OAAO,cAAc,CAAC,CAAC,GACpC,OAAO,MAAM,OAAO,SAAS,CAAC,CAChC,EACF,CAAC;EACD,aAAa,EAAE,OAAO;GAAE,QAAQ;GAAM,YAAY;EAAE,EAAE;EACtD,SAAS,OAAO,SAAS,SACvB,QAAQ,MAA8D,SAAS;GAC7E,UAAU,EAAE,YAAY;IACtB,MAAM,aAAa,MAAM,aAAa;IACtC,OAAO;KACL,OAAO;MAAE,QAAQ;MAAO;KAAW;KACnC,UAAU,CACR;MACE,MAAM,GAAG,OAAO,KAAK;MACrB,MAAM,EAAE,WAAW;MACnB,QAAQ,OAAO,GACb,OAAO,MAAM,KAAK,OAAO,GACzB,QAAQ,QAAQ;OAAE;OAAO;MAAW,CAAC,CACvC;KACF,CACF;IACF;GACF;GAGA,UAAU,EAAE,YAAY,YACtB,eAAe,MAAM,aACjB;IAAE;IAAO,YAAY,UAAU,KAAK,EAAE,MAAM,CAAC;GAAE,IAC/C,EAAE,MAAM;EAChB,CAAC;CACL,CAAC;CAED,OAAO,OAAO,OAAO,QAAQ;EAAE;EAAS;CAAU,CAAC;AACrD"}
@@ -0,0 +1,6 @@
1
+ export * from "./debounce.js";
2
+ export * from "./interval.js";
3
+ export * from "./relative.js";
4
+ export * from "./throttle.js";
5
+ export * from "./ticks.js";
6
+ export * from "./timer.js";
@@ -0,0 +1,7 @@
1
+ export * from "./debounce.js";
2
+ export * from "./interval.js";
3
+ export * from "./relative.js";
4
+ export * from "./throttle.js";
5
+ export * from "./ticks.js";
6
+ export * from "./timer.js";
7
+ export {};
@@ -0,0 +1,37 @@
1
+ import { Schema } from "effect";
2
+ import { Bundle } from "foldkit-bundle";
3
+ export declare const IntervalModel: Schema.Struct<{
4
+ readonly running: Schema.Boolean;
5
+ readonly lastAt: Schema.NullOr<Schema.Number>;
6
+ }>;
7
+ export type IntervalModel = typeof IntervalModel.Type;
8
+ export declare const IntervalMessage: import("foldkit/message").MessageUnion<{
9
+ readonly Started: {};
10
+ readonly Stopped: {};
11
+ readonly Ticked: {
12
+ at: Schema.Number;
13
+ };
14
+ }>;
15
+ export type IntervalMessage = typeof IntervalMessage.Type;
16
+ /**
17
+ * A wall-clock interval as a bundle: the last tick time in the Model,
18
+ * advanced by a tick stream while running. Sibling of Timer (which counts
19
+ * ticks); this one records *when* they happened, so views can render clocks
20
+ * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
21
+ * For a clock whose running or interval the parent's Model decides, use the
22
+ * `ticks` entry instead.
23
+ */
24
+ export declare const Interval: Bundle.Bundle<"Interval", {
25
+ readonly intervalMs: number;
26
+ }, {
27
+ readonly running: boolean;
28
+ readonly lastAt: number | null;
29
+ }, {
30
+ readonly _tag: "Started";
31
+ } | {
32
+ readonly _tag: "Stopped";
33
+ } | {
34
+ readonly _tag: "Ticked";
35
+ readonly at: number;
36
+ }, never, never, never, void, {}, {}>;
37
+ //# sourceMappingURL=interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interval.d.ts","names":[],"sources":["../../src/time/interval.ts"],"mappings":";;qBAMa,eAAa,OAAA;;;;YAId,uBAAuB,cAAc;qBAEpC,2CAAe;;;;IAGhB,IAAE,OAAA;;;YAEF,yBAAyB,gBAAgB;;;;;;;;;qBAUxC,UAAQ,OAAA"}
@@ -0,0 +1,52 @@
1
+ import { Option, Schema } from "effect";
2
+ import { defineMessageUnion } from "foldkit/message";
3
+ import { Bundle } from "foldkit-bundle";
4
+ import { ticks } from "./ticks.js";
5
+ // src/time/interval.ts
6
+ const IntervalModel = Schema.Struct({
7
+ running: Schema.Boolean,
8
+ lastAt: Schema.NullOr(Schema.Number)
9
+ });
10
+ const IntervalMessage = defineMessageUnion({
11
+ Started: {},
12
+ Stopped: {},
13
+ Ticked: { at: Schema.Number }
14
+ });
15
+ /**
16
+ * A wall-clock interval as a bundle: the last tick time in the Model,
17
+ * advanced by a tick stream while running. Sibling of Timer (which counts
18
+ * ticks); this one records *when* they happened, so views can render clocks
19
+ * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
20
+ * For a clock whose running or interval the parent's Model decides, use the
21
+ * `ticks` entry instead.
22
+ */
23
+ const Interval = Bundle.make("Interval", {
24
+ Model: IntervalModel,
25
+ Message: IntervalMessage,
26
+ args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
27
+ init: () => ({ model: {
28
+ running: false,
29
+ lastAt: null
30
+ } }),
31
+ update: (model, message) => IntervalMessage.match(message, {
32
+ Started: () => model.running ? { model } : { model: {
33
+ ...model,
34
+ running: true
35
+ } },
36
+ Stopped: () => model.running ? { model: {
37
+ ...model,
38
+ running: false
39
+ } } : { model },
40
+ Ticked: ({ at }) => ({ model: {
41
+ ...model,
42
+ lastAt: at
43
+ } })
44
+ }),
45
+ subscriptions: ({ intervalMs }) => ({ ticks: ticks({
46
+ intervalMs: (model) => model.running ? Option.some(intervalMs) : Option.none(),
47
+ onTick: (at) => IntervalMessage.Ticked({ at })
48
+ }) })
49
+ });
50
+ export { Interval, IntervalMessage, IntervalModel };
51
+
52
+ //# sourceMappingURL=interval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interval.js","names":[],"sources":["../../src/time/interval.ts"],"sourcesContent":["import { Option, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\nimport { ticks } from './ticks.js'\n\nexport const IntervalModel = Schema.Struct({\n running: Schema.Boolean,\n lastAt: Schema.NullOr(Schema.Number),\n})\nexport type IntervalModel = typeof IntervalModel.Type\n\nexport const IntervalMessage = defineMessageUnion({\n Started: {},\n Stopped: {},\n Ticked: { at: Schema.Number },\n})\nexport type IntervalMessage = typeof IntervalMessage.Type\n\n/**\n * A wall-clock interval as a bundle: the last tick time in the Model,\n * advanced by a tick stream while running. Sibling of Timer (which counts\n * ticks); this one records *when* they happened, so views can render clocks\n * and elapsed times. The clock is Effect's, so tests drive it with TestClock.\n * For a clock whose running or interval the parent's Model decides, use the\n * `ticks` entry instead.\n */\nexport const Interval = Bundle.make('Interval', {\n Model: IntervalModel,\n Message: IntervalMessage,\n args: Schema.Struct({\n intervalMs: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThan(0)),\n Schema.check(Schema.isFinite()),\n ),\n }),\n init: () => ({ model: { running: false, lastAt: null } }),\n update: (model, message) =>\n IntervalMessage.match<Update.ReturnWithOutMessage<IntervalModel, IntervalMessage, never>>(\n message,\n {\n Started: () => (model.running ? { model } : { model: { ...model, running: true } }),\n Stopped: () => (model.running ? { model: { ...model, running: false } } : { model }),\n Ticked: ({ at }) => ({ model: { ...model, lastAt: at } }),\n },\n ),\n subscriptions: ({ intervalMs }) => ({\n ticks: ticks<IntervalModel, IntervalMessage>({\n intervalMs: model => (model.running ? Option.some(intervalMs) : Option.none()),\n onTick: at => IntervalMessage.Ticked({ at }),\n }),\n }),\n})\n"],"mappings":";;;;;AAMA,MAAa,gBAAgB,OAAO,OAAO;CACzC,SAAS,OAAO;CAChB,QAAQ,OAAO,OAAO,OAAO,MAAM;AACrC,CAAC;AAGD,MAAa,kBAAkB,mBAAmB;CAChD,SAAS,CAAC;CACV,SAAS,CAAC;CACV,QAAQ,EAAE,IAAI,OAAO,OAAO;AAC9B,CAAC;;;;;;;;;AAWD,MAAa,WAAW,OAAO,KAAK,YAAY;CAC9C,OAAO;CACP,SAAS;CACT,MAAM,OAAO,OAAO,EAClB,YAAY,OAAO,OAAO,KACxB,OAAO,MAAM,OAAO,cAAc,CAAC,CAAC,GACpC,OAAO,MAAM,OAAO,SAAS,CAAC,CAChC,EACF,CAAC;CACD,aAAa,EAAE,OAAO;EAAE,SAAS;EAAO,QAAQ;CAAK,EAAE;CACvD,SAAS,OAAO,YACd,gBAAgB,MACd,SACA;EACE,eAAgB,MAAM,UAAU,EAAE,MAAM,IAAI,EAAE,OAAO;GAAE,GAAG;GAAO,SAAS;EAAK,EAAE;EACjF,eAAgB,MAAM,UAAU,EAAE,OAAO;GAAE,GAAG;GAAO,SAAS;EAAM,EAAE,IAAI,EAAE,MAAM;EAClF,SAAS,EAAE,UAAU,EAAE,OAAO;GAAE,GAAG;GAAO,QAAQ;EAAG,EAAE;CACzD,CACF;CACF,gBAAgB,EAAE,kBAAkB,EAClC,OAAO,MAAsC;EAC3C,aAAY,UAAU,MAAM,UAAU,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK;EAC5E,SAAQ,OAAM,gBAAgB,OAAO,EAAE,GAAG,CAAC;CAC7C,CAAC,EACH;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Relative time as a pure function: picks the unit (seconds through years)
3
+ * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come
4
+ * from the platform, not a phrase table. `from` is the earlier moment;
5
+ * swap the arguments for future phrasing ("in 3 days").
6
+ */
7
+ export declare const formatRelativeTime: (from: Date, to: Date, locale?: string) => string;
8
+ //# sourceMappingURL=relative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative.d.ts","names":[],"sources":["../../src/time/relative.ts"],"mappings":";;;;;;qBAMa,qBAAkB,MAAU,MAAI,IAAM,MAAI"}