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,167 +0,0 @@
1
- import { Option, Schema } from "effect";
2
- import * as Subscription from "foldkit/subscription";
3
- import { Bundle } from "foldkit-bundle";
4
- /**
5
- * Debounced input as a bundle factory: `Changed` restarts a timer, and the
6
- * latest value settles as an OutMessage the placement must handle with
7
- * `onOut`. Each `Changed` bumps a generation carried by the `Settled` fact
8
- * it schedules, so a superseded timer's fact emits nothing — the same guard
9
- * as Presence's exit timeout. Generic over the value Schema, like History.
10
- * The clock is Effect's, so tests drive it with TestClock.
11
- */
12
- export declare const debounce: <const Name extends string, Value>(config: {
13
- readonly name: Name;
14
- readonly value: Schema.Codec<Value, unknown>;
15
- }) => Bundle.Bundle<Name, {
16
- readonly delayMs: number;
17
- }, {
18
- readonly latest: Value | null;
19
- readonly generation: number;
20
- }, {
21
- readonly _tag: "Changed";
22
- readonly value: Value;
23
- } | {
24
- readonly _tag: "Settled";
25
- readonly value: Value;
26
- readonly generation: number;
27
- }, {
28
- readonly _tag: "Debounced";
29
- readonly value: Value;
30
- }, never, never, void, {}, {}> & {
31
- Message: import("foldkit/message").MessageUnion<{
32
- readonly Changed: {
33
- value: Schema.Codec<Value, unknown, never, never>;
34
- };
35
- readonly Settled: {
36
- value: Schema.Codec<Value, unknown, never, never>;
37
- generation: Schema.Number;
38
- };
39
- }>;
40
- Debounced: Schema.TaggedStruct<"Debounced", {
41
- readonly value: Schema.Codec<Value, unknown, never, never>;
42
- }>;
43
- };
44
- export declare const IntervalModel: Schema.Struct<{
45
- readonly running: Schema.Boolean;
46
- readonly lastAt: Schema.NullOr<Schema.Number>;
47
- }>;
48
- export type IntervalModel = typeof IntervalModel.Type;
49
- export declare const IntervalMessage: import("foldkit/message").MessageUnion<{
50
- readonly Started: {};
51
- readonly Stopped: {};
52
- readonly Ticked: {
53
- at: Schema.Number;
54
- };
55
- }>;
56
- export type IntervalMessage = typeof IntervalMessage.Type;
57
- /**
58
- * A wall-clock interval as a bundle: the last tick time in the Model,
59
- * advanced by a tick stream while running. Sibling of Timer (which counts
60
- * ticks); this one records *when* they happened, so views can render clocks
61
- * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
62
- * For a clock whose running or interval the parent's Model decides, use the
63
- * `ticks` entry instead.
64
- */
65
- export declare const Interval: Bundle.Bundle<"Interval", {
66
- readonly intervalMs: number;
67
- }, {
68
- readonly running: boolean;
69
- readonly lastAt: number | null;
70
- }, {
71
- readonly _tag: "Started";
72
- } | {
73
- readonly _tag: "Stopped";
74
- } | {
75
- readonly _tag: "Ticked";
76
- readonly at: number;
77
- }, never, never, never, void, {}, {}>;
78
- /**
79
- * Relative time as a pure function: picks the unit (seconds through years)
80
- * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come
81
- * from the platform, not a phrase table. `from` is the earlier moment;
82
- * swap the arguments for future phrasing ("in 3 days").
83
- */
84
- export declare const formatRelativeTime: (from: Date, to: Date, locale?: string) => string;
85
- export declare const ThrottleModel: Schema.Struct<{
86
- readonly lastAt: Schema.NullOr<Schema.Number>;
87
- }>;
88
- export type ThrottleModel = typeof ThrottleModel.Type;
89
- export declare const ThrottleMessage: import("foldkit/message").MessageUnion<{
90
- readonly Attempted: {};
91
- readonly Evaluated: {
92
- now: Schema.Number;
93
- };
94
- }>;
95
- export type ThrottleMessage = typeof ThrottleMessage.Type;
96
- export declare const Throttled: Schema.TaggedStruct<"Throttled", {
97
- readonly at: Schema.Number;
98
- }>;
99
- export type Throttled = typeof Throttled.Type;
100
- /**
101
- * Leading-edge throttle as a bundle: the first `Attempted` in an interval
102
- * surfaces a `Throttled` OutMessage, the rest are dropped. `Attempted`
103
- * reads the clock through a Command, so the check runs against Effect time
104
- * and tests drive it with TestClock. Trailing-edge needs are Debounce's:
105
- * pair the two rather than adding a second timer here.
106
- */
107
- export declare const Throttle: Bundle.Bundle<"Throttle", {
108
- readonly intervalMs: number;
109
- }, {
110
- readonly lastAt: number | null;
111
- }, {
112
- readonly _tag: "Attempted";
113
- } | {
114
- readonly _tag: "Evaluated";
115
- readonly now: number;
116
- }, {
117
- readonly _tag: "Throttled";
118
- readonly at: number;
119
- }, never, never, void, {}, {}>;
120
- declare const TickDependencies: {
121
- intervalMs: Schema.Option<Schema.Number>;
122
- };
123
- type TickDependencies = {
124
- readonly intervalMs: Option.Option<number>;
125
- };
126
- /**
127
- * Ticks while `intervalMs` answers `Some`, each tick one interval after the
128
- * last and the first one interval after starting. A changed interval applies
129
- * from the next tick, with no restart; other Model changes do nothing.
130
- */
131
- export declare const ticks: <Model, Message>(config: {
132
- /** The time between ticks for this Model, in milliseconds; `None` stops the clock. */
133
- readonly intervalMs: (model: Model) => Option.Option<number>;
134
- /** The Message a tick sends, given its time on Effect's clock. */
135
- readonly onTick: (at: number) => Message;
136
- }) => Subscription.Subscription<Model, Message, TickDependencies>;
137
- export declare const TimerModel: Schema.Struct<{
138
- readonly count: Schema.Number;
139
- readonly running: Schema.Boolean;
140
- }>;
141
- export type TimerModel = typeof TimerModel.Type;
142
- export declare const TimerMessage: import("foldkit/message").MessageUnion<{
143
- readonly Started: {};
144
- readonly Stopped: {};
145
- readonly Ticked: {};
146
- }>;
147
- export type TimerMessage = typeof TimerMessage.Type;
148
- /**
149
- * A timer as a bundle: a count in the Model, advanced by a tick stream while
150
- * running. The clock is Effect's, so tests drive it with TestClock instead of
151
- * waiting. For a clock whose running or interval the parent's Model decides,
152
- * use the `ticks` entry instead.
153
- */
154
- export declare const Timer: Bundle.Bundle<"Timer", {
155
- readonly intervalMs: number;
156
- }, {
157
- readonly count: number;
158
- readonly running: boolean;
159
- }, {
160
- readonly _tag: "Started";
161
- } | {
162
- readonly _tag: "Stopped";
163
- } | {
164
- readonly _tag: "Ticked";
165
- }, never, never, never, void, {}, {}>;
166
- export {};
167
- //# 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;;;YACV,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,236 +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
- // 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
- // src/time/ticks.ts
65
- /**
66
- * A clock the parent owns, as an entry: whether it ticks and how fast are
67
- * functions of the parent's Model, so nothing keeps a second running flag or
68
- * interval beside the state they derive from (a game's phase and score).
69
- * Timer and Interval are built on it, for a clock that owns its own flag.
70
- */
71
- const TickDependencies = { intervalMs: Schema.Option(Schema.Number) };
72
- const checked = (intervalMs) => {
73
- if (Option.isSome(intervalMs) && !(intervalMs.value > 0 && Number.isFinite(intervalMs.value))) throw new Error(`ticks: intervalMs must be positive and finite, got ${intervalMs.value}`);
74
- return intervalMs;
75
- };
76
- /**
77
- * Ticks while `intervalMs` answers `Some`, each tick one interval after the
78
- * last and the first one interval after starting. A changed interval applies
79
- * from the next tick, with no restart; other Model changes do nothing.
80
- */
81
- const ticks = (config) => Subscription.make()((entry) => ({ ticks: entry(TickDependencies, {
82
- modelToDependencies: (model) => ({ intervalMs: checked(config.intervalMs(model)) }),
83
- keepAliveEquivalence: (a, b) => Option.isSome(a.intervalMs) === Option.isSome(b.intervalMs),
84
- dependenciesToStream: ({ intervalMs }, readDependencies) => Option.match(intervalMs, {
85
- onNone: () => Stream.empty,
86
- onSome: (started) => Stream.fromEffectRepeat(Effect.suspend(() => Effect.sleep(Option.getOrElse(readDependencies().intervalMs, () => started))).pipe(Effect.andThen(Clock.currentTimeMillis), Effect.map(config.onTick)))
87
- })
88
- }) })).ticks;
89
- // src/time/interval.ts
90
- const IntervalModel = Schema.Struct({
91
- running: Schema.Boolean,
92
- lastAt: Schema.NullOr(Schema.Number)
93
- });
94
- const IntervalMessage = defineMessageUnion({
95
- Started: {},
96
- Stopped: {},
97
- Ticked: { at: Schema.Number }
98
- });
99
- /**
100
- * A wall-clock interval as a bundle: the last tick time in the Model,
101
- * advanced by a tick stream while running. Sibling of Timer (which counts
102
- * ticks); this one records *when* they happened, so views can render clocks
103
- * and elapsed times. The clock is Effect's, so tests drive it with TestClock.
104
- * For a clock whose running or interval the parent's Model decides, use the
105
- * `ticks` entry instead.
106
- */
107
- const Interval = Bundle.make("Interval", {
108
- Model: IntervalModel,
109
- Message: IntervalMessage,
110
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
111
- init: () => ({ model: {
112
- running: false,
113
- lastAt: null
114
- } }),
115
- update: (model, message) => IntervalMessage.match(message, {
116
- Started: () => model.running ? { model } : { model: {
117
- ...model,
118
- running: true
119
- } },
120
- Stopped: () => model.running ? { model: {
121
- ...model,
122
- running: false
123
- } } : { model },
124
- Ticked: ({ at }) => ({ model: {
125
- ...model,
126
- lastAt: at
127
- } })
128
- }),
129
- subscriptions: ({ intervalMs }) => ({ ticks: ticks({
130
- intervalMs: (model) => model.running ? Option.some(intervalMs) : Option.none(),
131
- onTick: (at) => IntervalMessage.Ticked({ at })
132
- }) })
133
- });
134
- // src/time/relative.ts
135
- /**
136
- * Relative time as a pure function: picks the unit (seconds through years)
137
- * and delegates the wording to `Intl.RelativeTimeFormat`, so locales come
138
- * from the platform, not a phrase table. `from` is the earlier moment;
139
- * swap the arguments for future phrasing ("in 3 days").
140
- */
141
- const formatRelativeTime = (from, to, locale = "en") => {
142
- const format = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
143
- const seconds = Math.round((to.getTime() - from.getTime()) / 1e3);
144
- const abs = Math.abs(seconds);
145
- if (abs < 60) return format.format(-seconds, "second");
146
- const minutes = Math.round(seconds / 60);
147
- if (abs < 3600) return format.format(-minutes, "minute");
148
- const hours = Math.round(seconds / 3600);
149
- if (abs < 86400) return format.format(-hours, "hour");
150
- const days = Math.round(seconds / 86400);
151
- if (abs < 604800) return format.format(-days, "day");
152
- const weeks = Math.round(seconds / 604800);
153
- if (abs < 2592e3) return format.format(-weeks, "week");
154
- const months = Math.round(seconds / 2592e3);
155
- if (abs < 31536e3) return format.format(-months, "month");
156
- return format.format(-Math.round(seconds / 31536e3), "year");
157
- };
158
- // src/time/throttle.ts
159
- const ThrottleModel = Schema.Struct({ lastAt: Schema.NullOr(Schema.Number) });
160
- const ThrottleMessage = defineMessageUnion({
161
- Attempted: {},
162
- Evaluated: { now: Schema.Number }
163
- });
164
- const Throttled = Schema.TaggedStruct("Throttled", { at: Schema.Number });
165
- /**
166
- * Leading-edge throttle as a bundle: the first `Attempted` in an interval
167
- * surfaces a `Throttled` OutMessage, the rest are dropped. `Attempted`
168
- * reads the clock through a Command, so the check runs against Effect time
169
- * and tests drive it with TestClock. Trailing-edge needs are Debounce's:
170
- * pair the two rather than adding a second timer here.
171
- */
172
- const Throttle = Bundle.make("Throttle", {
173
- Model: ThrottleModel,
174
- Message: ThrottleMessage,
175
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
176
- init: () => ({ model: { lastAt: null } }),
177
- update: (model, message, args) => ThrottleMessage.match(message, {
178
- Attempted: () => ({
179
- model,
180
- commands: [{
181
- name: "Throttle.evaluate",
182
- effect: Effect.map(Clock.currentTimeMillis, (now) => ThrottleMessage.Evaluated({ now }))
183
- }]
184
- }),
185
- Evaluated: ({ now }) => model.lastAt === null || now - model.lastAt >= args.intervalMs ? {
186
- model: { lastAt: now },
187
- outMessage: Throttled.make({ at: now })
188
- } : { model }
189
- })
190
- });
191
- // src/time/timer.ts
192
- const TimerModel = Schema.Struct({
193
- count: Schema.Number,
194
- running: Schema.Boolean
195
- });
196
- const TimerMessage = defineMessageUnion({
197
- Started: {},
198
- Stopped: {},
199
- Ticked: {}
200
- });
201
- /**
202
- * A timer as a bundle: a count in the Model, advanced by a tick stream while
203
- * running. The clock is Effect's, so tests drive it with TestClock instead of
204
- * waiting. For a clock whose running or interval the parent's Model decides,
205
- * use the `ticks` entry instead.
206
- */
207
- const Timer = Bundle.make("Timer", {
208
- Model: TimerModel,
209
- Message: TimerMessage,
210
- args: Schema.Struct({ intervalMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
211
- init: () => ({ model: {
212
- count: 0,
213
- running: false
214
- } }),
215
- update: (model, message) => TimerMessage.match(message, {
216
- Started: () => model.running ? { model } : { model: {
217
- ...model,
218
- running: true
219
- } },
220
- Stopped: () => model.running ? { model: {
221
- ...model,
222
- running: false
223
- } } : { model },
224
- Ticked: () => ({ model: {
225
- ...model,
226
- count: model.count + 1
227
- } })
228
- }),
229
- subscriptions: ({ intervalMs }) => ({ ticks: ticks({
230
- intervalMs: (model) => model.running ? Option.some(intervalMs) : Option.none(),
231
- onTick: () => TimerMessage.Ticked()
232
- }) })
233
- });
234
- export { Interval, IntervalMessage, IntervalModel, Throttle, ThrottleMessage, ThrottleModel, Throttled, Timer, TimerMessage, TimerModel, debounce, formatRelativeTime, ticks };
235
-
236
- //# 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,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,GAA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