foldkit-primitives 0.15.3 → 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-BY-bSrEc.d.mts → events/input-modality.d.ts} +9 -12
  136. package/dist/events/input-modality.d.ts.map +1 -0
  137. package/dist/{input-modality-BXD383jg.mjs → events/input-modality.js} +3 -4
  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-DP-xLKbT.mjs → internal.js} +8 -7
  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} +11 -313
  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 -345
  373. package/dist/device/index.d.mts.map +0 -1
  374. package/dist/device/index.mjs +0 -498
  375. package/dist/device/index.mjs.map +0 -1
  376. package/dist/dom/index.d.mts +0 -750
  377. package/dist/dom/index.d.mts.map +0 -1
  378. package/dist/dom/index.mjs +0 -1857
  379. package/dist/dom/index.mjs.map +0 -1
  380. package/dist/editable-text-1D31qthY.d.mts +0 -319
  381. package/dist/editable-text-1D31qthY.d.mts.map +0 -1
  382. package/dist/events/index.d.mts +0 -184
  383. package/dist/events/index.d.mts.map +0 -1
  384. package/dist/events/index.mjs +0 -315
  385. package/dist/events/index.mjs.map +0 -1
  386. package/dist/follow-tab-stop-Caog2qg1.mjs +0 -863
  387. package/dist/follow-tab-stop-Caog2qg1.mjs.map +0 -1
  388. package/dist/index-CmmxqSEi.d.mts +0 -149
  389. package/dist/index-CmmxqSEi.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-BXD383jg.mjs.map +0 -1
  393. package/dist/input-modality-BY-bSrEc.d.mts.map +0 -1
  394. package/dist/interaction/index.d.mts +0 -1194
  395. package/dist/interaction/index.d.mts.map +0 -1
  396. package/dist/interaction/index.mjs +0 -2012
  397. package/dist/interaction/index.mjs.map +0 -1
  398. package/dist/internal-DP-xLKbT.mjs.map +0 -1
  399. package/dist/media/index.d.mts +0 -109
  400. package/dist/media/index.d.mts.map +0 -1
  401. package/dist/media/index.mjs +0 -149
  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-DmFDppRn.mjs +0 -240
  406. package/dist/motion-DmFDppRn.mjs.map +0 -1
  407. package/dist/net/index.d.mts +0 -348
  408. package/dist/net/index.d.mts.map +0 -1
  409. package/dist/net/index.mjs +0 -535
  410. package/dist/net/index.mjs.map +0 -1
  411. package/dist/observers/index.d.mts +0 -84
  412. package/dist/observers/index.d.mts.map +0 -1
  413. package/dist/observers/index.mjs +0 -159
  414. package/dist/observers/index.mjs.map +0 -1
  415. package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
  416. package/dist/state/index.d.mts +0 -444
  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 -179
  420. package/dist/time/index.d.mts.map +0 -1
  421. package/dist/time/index.mjs +0 -242
  422. package/dist/time/index.mjs.map +0 -1
@@ -1,179 +0,0 @@
1
- import { Option, Schema } from "effect";
2
- import * as Subscription from "foldkit/subscription";
3
- import { Bundle } from "foldkit-bundle";
4
- //#region src/time/debounce.d.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
- export declare const debounce: <const Name extends string, Value>(config: {
14
- readonly name: Name;
15
- readonly value: Schema.Codec<Value, unknown>;
16
- }) => Bundle.Bundle<Name, {
17
- readonly delayMs: number;
18
- }, {
19
- readonly latest: Value | null;
20
- readonly generation: number;
21
- }, {
22
- readonly _tag: "Changed";
23
- readonly value: Value;
24
- } | {
25
- readonly _tag: "Settled";
26
- readonly value: Value;
27
- readonly generation: number;
28
- }, {
29
- readonly _tag: "Debounced";
30
- readonly value: Value;
31
- }, never, never, void, {}, {}> & {
32
- Message: import("foldkit/message").MessageUnion<{
33
- readonly Changed: {
34
- value: Schema.Codec<Value, unknown, never, never>;
35
- };
36
- readonly Settled: {
37
- value: Schema.Codec<Value, unknown, never, never>;
38
- generation: Schema.Number;
39
- };
40
- }>;
41
- Debounced: Schema.TaggedStruct<"Debounced", {
42
- readonly value: Schema.Codec<Value, unknown, never, never>;
43
- }>;
44
- };
45
- //#endregion
46
- //#region src/time/interval.d.ts
47
- export declare const IntervalModel: Schema.Struct<{
48
- readonly running: Schema.Boolean;
49
- readonly lastAt: Schema.NullOr<Schema.Number>;
50
- }>;
51
- export type IntervalModel = typeof IntervalModel.Type;
52
- export declare const IntervalMessage: import("foldkit/message").MessageUnion<{
53
- readonly Started: {};
54
- readonly Stopped: {};
55
- readonly Ticked: {
56
- at: Schema.Number;
57
- };
58
- }>;
59
- export type IntervalMessage = typeof IntervalMessage.Type;
60
- /**
61
- * A wall-clock interval as a bundle: the last tick time in the Model,
62
- * advanced by a tick stream while running. Sibling of Timer (which counts
63
- * ticks); this one records *when* they happened, so views can render clocks
64
- * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
65
- * For a clock whose running or interval the parent's Model decides, use the
66
- * `ticks` entry instead.
67
- */
68
- export declare const Interval: Bundle.Bundle<"Interval", {
69
- readonly intervalMs: number;
70
- }, {
71
- readonly running: boolean;
72
- readonly lastAt: number | null;
73
- }, {
74
- readonly _tag: "Started";
75
- } | {
76
- readonly _tag: "Stopped";
77
- } | {
78
- readonly _tag: "Ticked";
79
- readonly at: number;
80
- }, never, never, never, void, {}, {}>;
81
- //#endregion
82
- //#region src/time/relative.d.ts
83
- /**
84
- * Relative time as a pure function: picks the unit (seconds through years)
85
- * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come
86
- * from the platform, not a phrase table. `from` is the earlier moment;
87
- * swap the arguments for future phrasing ("in 3 days").
88
- */
89
- export declare const formatRelativeTime: (from: Date, to: Date, locale?: string) => string;
90
- //#endregion
91
- //#region src/time/throttle.d.ts
92
- export declare const ThrottleModel: Schema.Struct<{
93
- readonly lastAt: Schema.NullOr<Schema.Number>;
94
- }>;
95
- export type ThrottleModel = typeof ThrottleModel.Type;
96
- export declare const ThrottleMessage: import("foldkit/message").MessageUnion<{
97
- readonly Attempted: {};
98
- readonly Evaluated: {
99
- now: Schema.Number;
100
- };
101
- }>;
102
- export type ThrottleMessage = typeof ThrottleMessage.Type;
103
- export declare const Throttled: Schema.TaggedStruct<"Throttled", {
104
- readonly at: Schema.Number;
105
- }>;
106
- export type Throttled = typeof Throttled.Type;
107
- /**
108
- * Leading-edge throttle as a bundle: the first `Attempted` in an interval
109
- * surfaces a `Throttled` OutMessage, the rest are dropped. `Attempted`
110
- * reads the clock through a Command, so the check runs against Effect time
111
- * and tests drive it with TestClock. Trailing-edge needs are Debounce's:
112
- * pair the two rather than adding a second timer here.
113
- */
114
- export declare const Throttle: Bundle.Bundle<"Throttle", {
115
- readonly intervalMs: number;
116
- }, {
117
- readonly lastAt: number | null;
118
- }, {
119
- readonly _tag: "Attempted";
120
- } | {
121
- readonly _tag: "Evaluated";
122
- readonly now: number;
123
- }, {
124
- readonly _tag: "Throttled";
125
- readonly at: number;
126
- }, never, never, void, {}, {}>;
127
- //#endregion
128
- //#region src/time/ticks.d.ts
129
- declare const TickDependencies: {
130
- intervalMs: Schema.Option<Schema.Number>;
131
- };
132
- type TickDependencies = {
133
- readonly intervalMs: Option.Option<number>;
134
- };
135
- /**
136
- * Ticks while `intervalMs` answers `Some`, each tick one interval after the
137
- * last and the first one interval after starting. A changed interval applies
138
- * from the next tick, with no restart; other Model changes do nothing.
139
- */
140
- export declare const ticks: <Model, Message>(config: {
141
- /** The time between ticks for this Model, in milliseconds; `None` stops the clock. */
142
- readonly intervalMs: (model: Model) => Option.Option<number>;
143
- /** The Message a tick sends, given its time on Effect's clock. */
144
- readonly onTick: (at: number) => Message;
145
- }) => Subscription.Subscription<Model, Message, TickDependencies>;
146
- //#endregion
147
- //#region src/time/timer.d.ts
148
- export declare const TimerModel: Schema.Struct<{
149
- readonly count: Schema.Number;
150
- readonly running: Schema.Boolean;
151
- }>;
152
- export type TimerModel = typeof TimerModel.Type;
153
- export declare const TimerMessage: import("foldkit/message").MessageUnion<{
154
- readonly Started: {};
155
- readonly Stopped: {};
156
- readonly Ticked: {};
157
- }>;
158
- export type TimerMessage = typeof TimerMessage.Type;
159
- /**
160
- * A timer as a bundle: a count in the Model, advanced by a tick stream while
161
- * running. The clock is Effect's, so tests drive it with TestClock instead of
162
- * waiting. For a clock whose running or interval the parent's Model decides,
163
- * use the `ticks` entry instead.
164
- */
165
- export declare const Timer: Bundle.Bundle<"Timer", {
166
- readonly intervalMs: number;
167
- }, {
168
- readonly count: number;
169
- readonly running: boolean;
170
- }, {
171
- readonly _tag: "Started";
172
- } | {
173
- readonly _tag: "Stopped";
174
- } | {
175
- readonly _tag: "Ticked";
176
- }, never, never, never, void, {}, {}>;
177
- //#endregion
178
- export {};
179
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/time/debounce.ts","../../src/time/interval.ts","../../src/time/relative.ts","../../src/time/throttle.ts","../../src/time/ticks.ts","../../src/time/timer.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;;;;;;;;;qBCnBjC,eAAa,OAAA;;;;YAId,uBAAuB,cAAc;qBAEpC,2CAAe;;;;IAGhB,IAAE,OAAA;;;YAEF,yBAAyB,gBAAgB;;;;;;;;;qBAUxC,UAAQ,OAAA;;;;;;;;;;;;;;;;;;;;;qBCrBR,qBAAkB,MAAU,MAAI,IAAM,MAAI;;;qBCD1C,eAAa,OAAA;;;YACd,uBAAuB,cAAc;qBAEpC,2CAAe;;;IAEb,KAAG,OAAA;;;YAEN,yBAAyB,gBAAgB;qBAExC,WAAS,OAAA;eAAT,OAAA;;YACD,mBAAmB,UAAU;;;;;;;;qBAS5B,UAAQ,OAAA;;;;;;;;;;;;;;;cCff;EAAqB,YAAU,OAAA,OAAA,OAAA;;KAChC;WAA8B,YAAY,OAAO;;;;;;;qBAezC,QAAS,OAAO,SAAO;;WAEzB,aAAa,OAAO,UAAU,OAAO;;WAErC,SAAS,eAAe;MAC/B,aAAa,aAAa,OAAO,SAAS;;;qBCzBjC,YAAU,OAAA;;;;YACX,oBAAoB,WAAW;qBAE9B,wCAAY;;;;;YAKb,sBAAsB,aAAa;;;;;;;qBAQlC,OAAK,OAAA"}
@@ -1,242 +0,0 @@
1
- import { Clock, Effect, Option, Schema, Stream } from "effect";
2
- import { defineMessageUnion } from "foldkit/message";
3
- import * as Subscription from "foldkit/subscription";
4
- import { Bundle } from "foldkit-bundle";
5
- //#region src/time/debounce.ts
6
- /**
7
- * Debounced input as a bundle factory: `Changed` restarts a timer, and the
8
- * latest value settles as an OutMessage the placement must handle with
9
- * `onOut`. Each `Changed` bumps a generation carried by the `Settled` fact
10
- * it schedules, so a superseded timer's fact emits nothing — the same guard
11
- * as Presence's exit timeout. Generic over the value Schema, like History.
12
- * The clock is Effect's, so tests drive it with TestClock.
13
- */
14
- const debounce = (config) => {
15
- const Model = Schema.Struct({
16
- latest: Schema.NullOr(config.value),
17
- generation: Schema.Number
18
- });
19
- const Message = defineMessageUnion({
20
- Changed: { value: config.value },
21
- Settled: {
22
- value: config.value,
23
- generation: Schema.Number
24
- }
25
- });
26
- const Debounced = Schema.TaggedStruct("Debounced", { value: config.value });
27
- const bundle = Bundle.make(config.name, {
28
- Model,
29
- Message,
30
- args: Schema.Struct({ delayMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
31
- init: () => ({ model: {
32
- latest: null,
33
- generation: 0
34
- } }),
35
- update: (model, message, args) => Message.match(message, {
36
- Changed: ({ value }) => {
37
- const generation = model.generation + 1;
38
- return {
39
- model: {
40
- latest: value,
41
- generation
42
- },
43
- commands: [{
44
- name: `${config.name}.settle`,
45
- args: { generation },
46
- effect: Effect.as(Effect.sleep(args.delayMs), Message.Settled({
47
- value,
48
- generation
49
- }))
50
- }]
51
- };
52
- },
53
- Settled: ({ generation, value }) => generation === model.generation ? {
54
- model,
55
- outMessage: Debounced.make({ value })
56
- } : { model }
57
- })
58
- });
59
- return Object.assign(bundle, {
60
- Message,
61
- Debounced
62
- });
63
- };
64
- //#endregion
65
- //#region src/time/ticks.ts
66
- /**
67
- * A clock the parent owns, as an entry: whether it ticks and how fast are
68
- * functions of the parent's Model, so nothing keeps a second running flag or
69
- * interval beside the state they derive from (a game's phase and score).
70
- * Timer and Interval are built on it, for a clock that owns its own flag.
71
- */
72
- const TickDependencies = { intervalMs: Schema.Option(Schema.Number) };
73
- const checked = (intervalMs) => {
74
- if (Option.isSome(intervalMs) && !(intervalMs.value > 0 && Number.isFinite(intervalMs.value))) throw new Error(`ticks: intervalMs must be positive and finite, got ${intervalMs.value}`);
75
- return intervalMs;
76
- };
77
- /**
78
- * Ticks while `intervalMs` answers `Some`, each tick one interval after the
79
- * last and the first one interval after starting. A changed interval applies
80
- * from the next tick, with no restart; other Model changes do nothing.
81
- */
82
- const ticks = (config) => Subscription.make()((entry) => ({ ticks: entry(TickDependencies, {
83
- modelToDependencies: (model) => ({ intervalMs: checked(config.intervalMs(model)) }),
84
- keepAliveEquivalence: (a, b) => Option.isSome(a.intervalMs) === Option.isSome(b.intervalMs),
85
- dependenciesToStream: ({ intervalMs }, readDependencies) => Option.match(intervalMs, {
86
- onNone: () => Stream.empty,
87
- onSome: (started) => Stream.fromEffectRepeat(Effect.suspend(() => Effect.sleep(Option.getOrElse(readDependencies().intervalMs, () => started))).pipe(Effect.andThen(Clock.currentTimeMillis), Effect.map(config.onTick)))
88
- })
89
- }) })).ticks;
90
- //#endregion
91
- //#region src/time/interval.ts
92
- const IntervalModel = Schema.Struct({
93
- running: Schema.Boolean,
94
- lastAt: Schema.NullOr(Schema.Number)
95
- });
96
- const IntervalMessage = defineMessageUnion({
97
- Started: {},
98
- Stopped: {},
99
- Ticked: { at: Schema.Number }
100
- });
101
- /**
102
- * A wall-clock interval as a bundle: the last tick time in the Model,
103
- * advanced by a tick stream while running. Sibling of Timer (which counts
104
- * ticks); this one records *when* they happened, so views can render clocks
105
- * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
106
- * For a clock whose running or interval the parent's Model decides, use the
107
- * `ticks` entry instead.
108
- */
109
- const Interval = Bundle.make("Interval", {
110
- Model: IntervalModel,
111
- Message: IntervalMessage,
112
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
113
- init: () => ({ model: {
114
- running: false,
115
- lastAt: null
116
- } }),
117
- update: (model, message) => IntervalMessage.match(message, {
118
- Started: () => model.running ? { model } : { model: {
119
- ...model,
120
- running: true
121
- } },
122
- Stopped: () => model.running ? { model: {
123
- ...model,
124
- running: false
125
- } } : { model },
126
- Ticked: ({ at }) => ({ model: {
127
- ...model,
128
- lastAt: at
129
- } })
130
- }),
131
- subscriptions: ({ intervalMs }) => ({ ticks: ticks({
132
- intervalMs: (model) => model.running ? Option.some(intervalMs) : Option.none(),
133
- onTick: (at) => IntervalMessage.Ticked({ at })
134
- }) })
135
- });
136
- //#endregion
137
- //#region src/time/relative.ts
138
- /**
139
- * Relative time as a pure function: picks the unit (seconds through years)
140
- * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come
141
- * from the platform, not a phrase table. `from` is the earlier moment;
142
- * swap the arguments for future phrasing ("in 3 days").
143
- */
144
- const formatRelativeTime = (from, to, locale = "en") => {
145
- const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
146
- const seconds = Math.round((to.getTime() - from.getTime()) / 1e3);
147
- const abs = Math.abs(seconds);
148
- if (abs < 60) return format.format(-seconds, "second");
149
- const minutes = Math.round(seconds / 60);
150
- if (abs < 3600) return format.format(-minutes, "minute");
151
- const hours = Math.round(seconds / 3600);
152
- if (abs < 86400) return format.format(-hours, "hour");
153
- const days = Math.round(seconds / 86400);
154
- if (abs < 604800) return format.format(-days, "day");
155
- const weeks = Math.round(seconds / 604800);
156
- if (abs < 2592e3) return format.format(-weeks, "week");
157
- const months = Math.round(seconds / 2592e3);
158
- if (abs < 31536e3) return format.format(-months, "month");
159
- return format.format(-Math.round(seconds / 31536e3), "year");
160
- };
161
- //#endregion
162
- //#region src/time/throttle.ts
163
- const ThrottleModel = Schema.Struct({ lastAt: Schema.NullOr(Schema.Number) });
164
- const ThrottleMessage = defineMessageUnion({
165
- Attempted: {},
166
- Evaluated: { now: Schema.Number }
167
- });
168
- const Throttled = Schema.TaggedStruct("Throttled", { at: Schema.Number });
169
- /**
170
- * Leading-edge throttle as a bundle: the first `Attempted` in an interval
171
- * surfaces a `Throttled` OutMessage, the rest are dropped. `Attempted`
172
- * reads the clock through a Command, so the check runs against Effect time
173
- * and tests drive it with TestClock. Trailing-edge needs are Debounce's:
174
- * pair the two rather than adding a second timer here.
175
- */
176
- const Throttle = Bundle.make("Throttle", {
177
- Model: ThrottleModel,
178
- Message: ThrottleMessage,
179
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
180
- init: () => ({ model: { lastAt: null } }),
181
- update: (model, message, args) => ThrottleMessage.match(message, {
182
- Attempted: () => ({
183
- model,
184
- commands: [{
185
- name: "Throttle.evaluate",
186
- effect: Effect.map(Clock.currentTimeMillis, (now) => ThrottleMessage.Evaluated({ now }))
187
- }]
188
- }),
189
- Evaluated: ({ now }) => model.lastAt === null || now - model.lastAt >= args.intervalMs ? {
190
- model: { lastAt: now },
191
- outMessage: Throttled.make({ at: now })
192
- } : { model }
193
- })
194
- });
195
- //#endregion
196
- //#region src/time/timer.ts
197
- const TimerModel = Schema.Struct({
198
- count: Schema.Number,
199
- running: Schema.Boolean
200
- });
201
- const TimerMessage = defineMessageUnion({
202
- Started: {},
203
- Stopped: {},
204
- Ticked: {}
205
- });
206
- /**
207
- * A timer as a bundle: a count in the Model, advanced by a tick stream while
208
- * running. The clock is Effect's, so tests drive it with TestClock instead of
209
- * waiting. For a clock whose running or interval the parent's Model decides,
210
- * use the `ticks` entry instead.
211
- */
212
- const Timer = Bundle.make("Timer", {
213
- Model: TimerModel,
214
- Message: TimerMessage,
215
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
216
- init: () => ({ model: {
217
- count: 0,
218
- running: false
219
- } }),
220
- update: (model, message) => TimerMessage.match(message, {
221
- Started: () => model.running ? { model } : { model: {
222
- ...model,
223
- running: true
224
- } },
225
- Stopped: () => model.running ? { model: {
226
- ...model,
227
- running: false
228
- } } : { model },
229
- Ticked: () => ({ model: {
230
- ...model,
231
- count: model.count + 1
232
- } })
233
- }),
234
- subscriptions: ({ intervalMs }) => ({ ticks: ticks({
235
- intervalMs: (model) => model.running ? Option.some(intervalMs) : Option.none(),
236
- onTick: () => TimerMessage.Ticked()
237
- }) })
238
- });
239
- //#endregion
240
- export { Interval, IntervalMessage, IntervalModel, Throttle, ThrottleMessage, ThrottleModel, Throttled, Timer, TimerMessage, TimerModel, debounce, formatRelativeTime, ticks };
241
-
242
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/time/debounce.ts","../../src/time/ticks.ts","../../src/time/interval.ts","../../src/time/relative.ts","../../src/time/throttle.ts","../../src/time/timer.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","/**\n * A clock the parent owns, as an entry: whether it ticks and how fast are\n * functions of the parent's Model, so nothing keeps a second running flag or\n * interval beside the state they derive from (a game's phase and score).\n * Timer and Interval are built on it, for a clock that owns its own flag.\n */\nimport { Clock, Effect, Option, Schema, Stream } from 'effect'\nimport * as Subscription from 'foldkit/subscription'\n\nconst TickDependencies = { intervalMs: Schema.Option(Schema.Number) }\ntype TickDependencies = { readonly intervalMs: Option.Option<number> }\n\nconst checked = (intervalMs: Option.Option<number>): Option.Option<number> => {\n // A zero, negative or non-finite interval would spin or never tick; the\n // runtime crashes on a defect here, which names the mistake where it is made.\n if (Option.isSome(intervalMs) && !(intervalMs.value > 0 && Number.isFinite(intervalMs.value)))\n throw new Error(`ticks: intervalMs must be positive and finite, got ${intervalMs.value}`)\n return intervalMs\n}\n\n/**\n * Ticks while `intervalMs` answers `Some`, each tick one interval after the\n * last and the first one interval after starting. A changed interval applies\n * from the next tick, with no restart; other Model changes do nothing.\n */\nexport const ticks = <Model, Message>(config: {\n /** The time between ticks for this Model, in milliseconds; `None` stops the clock. */\n readonly intervalMs: (model: Model) => Option.Option<number>\n /** The Message a tick sends, given its time on Effect's clock. */\n readonly onTick: (at: number) => Message\n}): Subscription.Subscription<Model, Message, TickDependencies> =>\n Subscription.make<Model, Message>()(entry => ({\n ticks: entry(TickDependencies, {\n modelToDependencies: model => ({ intervalMs: checked(config.intervalMs(model)) }),\n // Stopping and starting restart the stream; a new interval does not, so\n // a clock that speeds up keeps its phase instead of ticking at once.\n keepAliveEquivalence: (a, b) => Option.isSome(a.intervalMs) === Option.isSome(b.intervalMs),\n dependenciesToStream: ({ intervalMs }, readDependencies) =>\n Option.match(intervalMs, {\n onNone: () => Stream.empty,\n onSome: started =>\n Stream.fromEffectRepeat(\n Effect.suspend(() =>\n Effect.sleep(Option.getOrElse(readDependencies().intervalMs, () => started)),\n ).pipe(Effect.andThen(Clock.currentTimeMillis), Effect.map(config.onTick)),\n ),\n }),\n }),\n })).ticks\n","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","/**\n * Relative time as a pure function: picks the unit (seconds through years)\n * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come\n * from the platform, not a phrase table. `from` is the earlier moment;\n * swap the arguments for future phrasing (\"in 3 days\").\n */\nexport const formatRelativeTime = (from: Date, to: Date, locale = 'en'): string => {\n const format = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' })\n const seconds = Math.round((to.getTime() - from.getTime()) / 1000)\n const abs = Math.abs(seconds)\n if (abs < 60) return format.format(-seconds, 'second')\n const minutes = Math.round(seconds / 60)\n if (abs < 60 * 60) return format.format(-minutes, 'minute')\n const hours = Math.round(seconds / (60 * 60))\n if (abs < 24 * 60 * 60) return format.format(-hours, 'hour')\n const days = Math.round(seconds / (24 * 60 * 60))\n if (abs < 7 * 24 * 60 * 60) return format.format(-days, 'day')\n const weeks = Math.round(seconds / (7 * 24 * 60 * 60))\n if (abs < 30 * 24 * 60 * 60) return format.format(-weeks, 'week')\n const months = Math.round(seconds / (30 * 24 * 60 * 60))\n if (abs < 365 * 24 * 60 * 60) return format.format(-months, 'month')\n return format.format(-Math.round(seconds / (365 * 24 * 60 * 60)), 'year')\n}\n","import { Clock, Effect, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\n\nexport const ThrottleModel = Schema.Struct({ lastAt: Schema.NullOr(Schema.Number) })\nexport type ThrottleModel = typeof ThrottleModel.Type\n\nexport const ThrottleMessage = defineMessageUnion({\n Attempted: {},\n Evaluated: { now: Schema.Number },\n})\nexport type ThrottleMessage = typeof ThrottleMessage.Type\n\nexport const Throttled = Schema.TaggedStruct('Throttled', { at: Schema.Number })\nexport type Throttled = typeof Throttled.Type\n\n/**\n * Leading-edge throttle as a bundle: the first `Attempted` in an interval\n * surfaces a `Throttled` OutMessage, the rest are dropped. `Attempted`\n * reads the clock through a Command, so the check runs against Effect time\n * and tests drive it with TestClock. Trailing-edge needs are Debounce's:\n * pair the two rather than adding a second timer here.\n */\nexport const Throttle = Bundle.make('Throttle', {\n Model: ThrottleModel,\n Message: ThrottleMessage,\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: { lastAt: null } }),\n update: (model, message, args) =>\n ThrottleMessage.match<Update.ReturnWithOutMessage<ThrottleModel, ThrottleMessage, Throttled>>(\n message,\n {\n Attempted: () => ({\n model,\n commands: [\n {\n name: 'Throttle.evaluate',\n effect: Effect.map(Clock.currentTimeMillis, now =>\n ThrottleMessage.Evaluated({ now }),\n ),\n },\n ],\n }),\n // First attempt ever, or the interval has passed: fire and stamp.\n Evaluated: ({ now }) =>\n model.lastAt === null || now - model.lastAt >= args.intervalMs\n ? { model: { lastAt: now }, outMessage: Throttled.make({ at: now }) }\n : { model },\n },\n ),\n})\n","import { Option, Schema } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { Bundle } from 'foldkit-bundle'\nimport { ticks } from './ticks.js'\n\nexport const TimerModel = Schema.Struct({ count: Schema.Number, running: Schema.Boolean })\nexport type TimerModel = typeof TimerModel.Type\n\nexport const TimerMessage = defineMessageUnion({\n Started: {},\n Stopped: {},\n Ticked: {},\n})\nexport type TimerMessage = typeof TimerMessage.Type\n\n/**\n * A timer as a bundle: a count in the Model, advanced by a tick stream while\n * running. The clock is Effect's, so tests drive it with TestClock instead of\n * waiting. For a clock whose running or interval the parent's Model decides,\n * use the `ticks` entry instead.\n */\nexport const Timer = Bundle.make('Timer', {\n Model: TimerModel,\n Message: TimerMessage,\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: { count: 0, running: false } }),\n update: (model, message) =>\n TimerMessage.match(message, {\n Started: () => (model.running ? { model } : { model: { ...model, running: true } }),\n Stopped: () => (model.running ? { model: { ...model, running: false } } : { model }),\n Ticked: () => ({ model: { ...model, count: model.count + 1 } }),\n }),\n subscriptions: ({ intervalMs }) => ({\n ticks: ticks<TimerModel, TimerMessage>({\n intervalMs: model => (model.running ? Option.some(intervalMs) : Option.none()),\n onTick: () => TimerMessage.Ticked(),\n }),\n }),\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,GACp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