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