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
package/dist/events/index.mjs
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { i as unlessSame } from "../internal-DP-xLKbT.mjs";
|
|
2
|
-
import { a as modalityOfKey, i as Modality, n as InputModalityMessage, r as InputModalityModel, t as InputModality } from "../input-modality-BXD383jg.mjs";
|
|
3
|
-
import { Effect, Queue, Schema, Stream } from "effect";
|
|
4
|
-
import { defineMessageUnion } from "foldkit/message";
|
|
5
|
-
import * as Subscription from "foldkit/subscription";
|
|
6
|
-
import { Bundle } from "foldkit-bundle";
|
|
7
|
-
//#region src/events/active-element.ts
|
|
8
|
-
/**
|
|
9
|
-
* Focused element as an entry — not a bundle, because elements are not
|
|
10
|
-
* Model facts: this reports the active element's tag and id (both
|
|
11
|
-
* serializable), and the parent stores what matters. Starts with the
|
|
12
|
-
* current answer, then follows `focusin`/`focusout`.
|
|
13
|
-
*/
|
|
14
|
-
const ActiveElementMessage = defineMessageUnion({ Changed: {
|
|
15
|
-
tag: Schema.String,
|
|
16
|
-
id: Schema.NullOr(Schema.String)
|
|
17
|
-
} });
|
|
18
|
-
/**
|
|
19
|
-
* Focus changes on the document. Without a document the stream is empty
|
|
20
|
-
* instead of throwing. Lift with `Subscription.persistentEntry`, mapping into
|
|
21
|
-
* the parent's Message.
|
|
22
|
-
*/
|
|
23
|
-
const activeElementEvents = () => {
|
|
24
|
-
if (typeof document === "undefined") return Stream.empty;
|
|
25
|
-
const read = () => {
|
|
26
|
-
const element = document.activeElement;
|
|
27
|
-
return ActiveElementMessage.Changed({
|
|
28
|
-
tag: element?.tagName ?? "",
|
|
29
|
-
id: element?.id !== void 0 && element.id !== "" ? element.id : null
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
const changes = Stream.mergeAll([Stream.fromEventListener(document, "focusin").pipe(Stream.map(read)), Stream.fromEventListener(document, "focusout").pipe(Stream.map(read))], { concurrency: "unbounded" });
|
|
33
|
-
return Stream.concat(Stream.make(read()), changes);
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/events/hotkeys.ts
|
|
37
|
-
const modifierOf = (part) => {
|
|
38
|
-
switch (part) {
|
|
39
|
-
case "ctrl":
|
|
40
|
-
case "control": return "ctrl";
|
|
41
|
-
case "shift": return "shift";
|
|
42
|
-
case "alt":
|
|
43
|
-
case "option": return "alt";
|
|
44
|
-
case "meta":
|
|
45
|
-
case "cmd":
|
|
46
|
-
case "command": return "meta";
|
|
47
|
-
default: return null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const keyNameOf = (part) => {
|
|
51
|
-
switch (part) {
|
|
52
|
-
case "spacebar":
|
|
53
|
-
case " ": return "space";
|
|
54
|
-
case "esc": return "escape";
|
|
55
|
-
default: return part;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Hotkey matching as a pure function over a `Pressed` payload: `matchHotkey`
|
|
60
|
-
* answers whether a press is the shortcut, so `update` stays a table of
|
|
61
|
-
* chords instead of a nest of modifier checks. Patterns read like
|
|
62
|
-
* `"ctrl+shift+k"`: modifiers first (any order), the key last,
|
|
63
|
-
* case-insensitive, with `cmd`/`command` and `option` as the Mac names for
|
|
64
|
-
* meta and alt. Matching is exact — unlisted modifiers must be up — and
|
|
65
|
-
* auto-repeat never matches, so holding a chord fires once. `space` (or a
|
|
66
|
-
* bare space) means the space key; `esc` means escape. A pattern with
|
|
67
|
-
* no key, or two keys, matches nothing: predicates return false, they do
|
|
68
|
-
* not throw on the hot path.
|
|
69
|
-
*/
|
|
70
|
-
const matchHotkey = (pattern, press) => {
|
|
71
|
-
if (press.repeat) return false;
|
|
72
|
-
const trimmed = pattern.split("+").map((part) => part.trim().toLowerCase()).filter((part) => part !== "");
|
|
73
|
-
const parts = trimmed.length === 0 && pattern.length > 0 ? ["space"] : trimmed;
|
|
74
|
-
const keys = parts.filter((part) => modifierOf(part) === null);
|
|
75
|
-
if (keys.length !== 1) return false;
|
|
76
|
-
if (keyNameOf(keys[0]) !== keyNameOf(press.key.toLowerCase())) return false;
|
|
77
|
-
const required = {
|
|
78
|
-
ctrl: false,
|
|
79
|
-
shift: false,
|
|
80
|
-
alt: false,
|
|
81
|
-
meta: false
|
|
82
|
-
};
|
|
83
|
-
for (const part of parts) {
|
|
84
|
-
const modifier = modifierOf(part);
|
|
85
|
-
if (modifier !== null) required[modifier] = true;
|
|
86
|
-
}
|
|
87
|
-
return required.ctrl === press.ctrl && required.shift === press.shift && required.alt === press.alt && required.meta === press.meta;
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/events/idle.ts
|
|
91
|
-
const IdleModel = Schema.Struct({ idle: Schema.Boolean });
|
|
92
|
-
const IdleMessage = defineMessageUnion({
|
|
93
|
-
BecameIdle: {},
|
|
94
|
-
BecameActive: {}
|
|
95
|
-
});
|
|
96
|
-
const activity = () => {
|
|
97
|
-
if (typeof window === "undefined") return Stream.empty;
|
|
98
|
-
const senses = [
|
|
99
|
-
Stream.fromEventListener(window, "mousemove"),
|
|
100
|
-
Stream.fromEventListener(window, "keydown"),
|
|
101
|
-
Stream.fromEventListener(window, "pointerdown"),
|
|
102
|
-
Stream.fromEventListener(window, "scroll")
|
|
103
|
-
];
|
|
104
|
-
return Stream.mergeAll(senses, { concurrency: "unbounded" });
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Idleness as a bundle: `idle` in the Model, flipped by activity and
|
|
108
|
-
* silence. While active, activity debounced past `timeoutMs` settles to
|
|
109
|
-
* `BecameIdle`; while idle, the first activity wakes to `BecameActive` and
|
|
110
|
-
* the dependency flip restarts the watch. Starts active — a lurker idles
|
|
111
|
-
* when the timeout elapses. The clock is Effect's, so tests drive it with
|
|
112
|
-
* TestClock.
|
|
113
|
-
*/
|
|
114
|
-
const Idle = Bundle.make("Idle", {
|
|
115
|
-
Model: IdleModel,
|
|
116
|
-
Message: IdleMessage,
|
|
117
|
-
args: Schema.Struct({ timeoutMs: Schema.Number.pipe(Schema.check(Schema.isGreaterThan(0)), Schema.check(Schema.isFinite())) }),
|
|
118
|
-
init: () => ({ model: { idle: false } }),
|
|
119
|
-
update: (model, message) => IdleMessage.match(message, {
|
|
120
|
-
BecameIdle: () => model.idle ? { model } : { model: {
|
|
121
|
-
...model,
|
|
122
|
-
idle: true
|
|
123
|
-
} },
|
|
124
|
-
BecameActive: () => model.idle ? { model: {
|
|
125
|
-
...model,
|
|
126
|
-
idle: false
|
|
127
|
-
} } : { model }
|
|
128
|
-
}),
|
|
129
|
-
subscriptions: ({ timeoutMs }) => Subscription.make()((entry) => ({ watch: entry({ idle: Schema.Boolean }, {
|
|
130
|
-
modelToDependencies: (model) => ({ idle: model.idle }),
|
|
131
|
-
dependenciesToStream: ({ idle }) => idle ? activity().pipe(Stream.take(1), Stream.map(() => IdleMessage.BecameActive())) : Stream.concat(Stream.make(null), activity()).pipe(Stream.debounce(timeoutMs), Stream.map(() => IdleMessage.BecameIdle()))
|
|
132
|
-
}) }))
|
|
133
|
-
});
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/events/keyboard.ts
|
|
136
|
-
/**
|
|
137
|
-
* Keyboard as an entry — not a bundle, because the parent owns whatever key
|
|
138
|
-
* state it keeps (a held-keys set, a shortcut map, a focused field): this
|
|
139
|
-
* reports presses and releases, including auto-repeat, and the parent
|
|
140
|
-
* stores what matters. Hotkey matching stays application policy.
|
|
141
|
-
*/
|
|
142
|
-
const KeyboardMessage = defineMessageUnion({
|
|
143
|
-
Pressed: {
|
|
144
|
-
key: Schema.String,
|
|
145
|
-
repeat: Schema.Boolean,
|
|
146
|
-
ctrl: Schema.Boolean,
|
|
147
|
-
shift: Schema.Boolean,
|
|
148
|
-
alt: Schema.Boolean,
|
|
149
|
-
meta: Schema.Boolean
|
|
150
|
-
},
|
|
151
|
-
Released: { key: Schema.String }
|
|
152
|
-
});
|
|
153
|
-
/**
|
|
154
|
-
* Key presses and releases on the window. Without a window the stream is
|
|
155
|
-
* empty instead of throwing. Lift with `Subscription.persistentEntry`, mapping
|
|
156
|
-
* into the parent's Message.
|
|
157
|
-
*/
|
|
158
|
-
const keyboardEvents = (options = {}) => {
|
|
159
|
-
if (typeof window === "undefined") return Stream.empty;
|
|
160
|
-
return Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => {
|
|
161
|
-
const down = (event) => {
|
|
162
|
-
const press = KeyboardMessage.Pressed({
|
|
163
|
-
key: event.key,
|
|
164
|
-
repeat: event.repeat,
|
|
165
|
-
ctrl: event.ctrlKey,
|
|
166
|
-
shift: event.shiftKey,
|
|
167
|
-
alt: event.altKey,
|
|
168
|
-
meta: event.metaKey
|
|
169
|
-
});
|
|
170
|
-
if (options.preventDefault?.(press) === true) event.preventDefault();
|
|
171
|
-
Queue.offerUnsafe(queue, press);
|
|
172
|
-
};
|
|
173
|
-
const up = (event) => Queue.offerUnsafe(queue, KeyboardMessage.Released({ key: event.key }));
|
|
174
|
-
window.addEventListener("keydown", down);
|
|
175
|
-
window.addEventListener("keyup", up);
|
|
176
|
-
return {
|
|
177
|
-
down,
|
|
178
|
-
up
|
|
179
|
-
};
|
|
180
|
-
}), ({ down, up }) => Effect.sync(() => {
|
|
181
|
-
window.removeEventListener("keydown", down);
|
|
182
|
-
window.removeEventListener("keyup", up);
|
|
183
|
-
})));
|
|
184
|
-
};
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/events/pointer.ts
|
|
187
|
-
/**
|
|
188
|
-
* Pointer position as an entry — not a bundle, because the parent owns what
|
|
189
|
-
* it keeps (a cursor, a drag anchor, hover state): this reports moves, and
|
|
190
|
-
* the parent stores what matters. Element-scoped pointer needs are Mounts,
|
|
191
|
-
* not this window-level entry.
|
|
192
|
-
*/
|
|
193
|
-
const PointerMessage = defineMessageUnion({ Moved: {
|
|
194
|
-
x: Schema.Number,
|
|
195
|
-
y: Schema.Number
|
|
196
|
-
} });
|
|
197
|
-
/**
|
|
198
|
-
* Pointer moves on the window. Without a window the stream is empty instead
|
|
199
|
-
* of throwing. Lift with `Subscription.persistentEntry`, mapping into the
|
|
200
|
-
* parent's Message.
|
|
201
|
-
*/
|
|
202
|
-
const pointerEvents = () => {
|
|
203
|
-
if (typeof window === "undefined") return Stream.empty;
|
|
204
|
-
return Stream.fromEventListener(window, "pointermove").pipe(Stream.map((event) => PointerMessage.Moved({
|
|
205
|
-
x: event.clientX,
|
|
206
|
-
y: event.clientY
|
|
207
|
-
})));
|
|
208
|
-
};
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/events/scroll.ts
|
|
211
|
-
/**
|
|
212
|
-
* Window scroll position as an entry — not a bundle, because the parent
|
|
213
|
-
* owns what it keeps (a stuck header, a back-to-top gate, restore-on-back):
|
|
214
|
-
* this reports positions, and the parent stores what matters.
|
|
215
|
-
* Element-scoped scrolling needs a Mount, not this window-level entry.
|
|
216
|
-
*/
|
|
217
|
-
const ScrollMessage = defineMessageUnion({ Scrolled: {
|
|
218
|
-
x: Schema.Number,
|
|
219
|
-
y: Schema.Number
|
|
220
|
-
} });
|
|
221
|
-
/**
|
|
222
|
-
* Scrolls on the window, in the capture phase so container scrolls (which
|
|
223
|
-
* do not bubble) report too. Without a window the stream is empty instead
|
|
224
|
-
* of throwing. Lift with `Subscription.persistentEntry`, mapping into the
|
|
225
|
-
* parent's Message.
|
|
226
|
-
*/
|
|
227
|
-
const scrollEvents = () => {
|
|
228
|
-
if (typeof window === "undefined") return Stream.empty;
|
|
229
|
-
return Stream.fromEventListener(window, "scroll", { capture: true }).pipe(Stream.map(() => ScrollMessage.Scrolled({
|
|
230
|
-
x: window.scrollX,
|
|
231
|
-
y: window.scrollY
|
|
232
|
-
})));
|
|
233
|
-
};
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/events/visibility.ts
|
|
236
|
-
const VisibilityModel = Schema.Struct({ visible: Schema.Boolean });
|
|
237
|
-
const VisibilityMessage = defineMessageUnion({ Changed: { visible: Schema.Boolean } });
|
|
238
|
-
const isVisible = () => typeof document === "undefined" || document.visibilityState !== "hidden";
|
|
239
|
-
const visibilityStream = () => {
|
|
240
|
-
if (typeof document === "undefined" || typeof document.addEventListener !== "function") return Stream.empty;
|
|
241
|
-
return Stream.concat(Stream.make(VisibilityMessage.Changed({ visible: isVisible() })), Stream.fromEventListener(document, "visibilitychange").pipe(Stream.map(() => VisibilityMessage.Changed({ visible: isVisible() }))));
|
|
242
|
-
};
|
|
243
|
-
/**
|
|
244
|
-
* Page visibility as a bundle: `visible` in the Model, read from the
|
|
245
|
-
* document at startup and kept current by `visibilitychange`. A hidden page
|
|
246
|
-
* is the application's cue to pause polling, animations, and realtime
|
|
247
|
-
* streams; the decision stays in application `update`, not here.
|
|
248
|
-
*/
|
|
249
|
-
const Visibility = Bundle.make("Visibility", {
|
|
250
|
-
Model: VisibilityModel,
|
|
251
|
-
Message: VisibilityMessage,
|
|
252
|
-
init: () => ({ model: { visible: isVisible() } }),
|
|
253
|
-
update: (model, message) => message.visible === model.visible ? { model } : { model: { visible: message.visible } },
|
|
254
|
-
subscriptions: () => Subscription.make()(() => ({ changes: Subscription.persistentEntry(visibilityStream()) }))
|
|
255
|
-
});
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/events/window-size.ts
|
|
258
|
-
const WindowSizeModel = Schema.Struct({
|
|
259
|
-
width: Schema.Number,
|
|
260
|
-
height: Schema.Number
|
|
261
|
-
});
|
|
262
|
-
const WindowSizeMessage = defineMessageUnion({ Changed: {
|
|
263
|
-
width: Schema.Number,
|
|
264
|
-
height: Schema.Number
|
|
265
|
-
} });
|
|
266
|
-
const readSize = () => ({
|
|
267
|
-
width: window.innerWidth,
|
|
268
|
-
height: window.innerHeight
|
|
269
|
-
});
|
|
270
|
-
const sizeStream = () => {
|
|
271
|
-
if (typeof window === "undefined" || typeof window.addEventListener !== "function") return Stream.empty;
|
|
272
|
-
return Stream.unwrap(Effect.gen(function* () {
|
|
273
|
-
const queue = yield* Queue.unbounded();
|
|
274
|
-
const onResize = () => {
|
|
275
|
-
const size = readSize();
|
|
276
|
-
Effect.runFork(Queue.offer(queue, WindowSizeMessage.Changed({
|
|
277
|
-
width: size.width,
|
|
278
|
-
height: size.height
|
|
279
|
-
})));
|
|
280
|
-
};
|
|
281
|
-
window.addEventListener("resize", onResize);
|
|
282
|
-
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
283
|
-
window.removeEventListener("resize", onResize);
|
|
284
|
-
}));
|
|
285
|
-
const size = readSize();
|
|
286
|
-
return Stream.concat(Stream.make(WindowSizeMessage.Changed({
|
|
287
|
-
width: size.width,
|
|
288
|
-
height: size.height
|
|
289
|
-
})), Stream.fromQueue(queue));
|
|
290
|
-
}));
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* Window size as a bundle: `{ width, height }` in the Model, read from the
|
|
294
|
-
* window at startup and kept current by one `resize` listener. Breakpoints
|
|
295
|
-
* owns its own listener and derives names; place this one when views need
|
|
296
|
-
* the raw pixels. Placing both doubles resize listeners — pick the one the
|
|
297
|
-
* view reads.
|
|
298
|
-
*/
|
|
299
|
-
const WindowSize = Bundle.make("WindowSize", {
|
|
300
|
-
Model: WindowSizeModel,
|
|
301
|
-
Message: WindowSizeMessage,
|
|
302
|
-
init: () => ({ model: {
|
|
303
|
-
width: 0,
|
|
304
|
-
height: 0
|
|
305
|
-
} }),
|
|
306
|
-
update: (model, message) => ({ model: unlessSame(model, {
|
|
307
|
-
width: message.width,
|
|
308
|
-
height: message.height
|
|
309
|
-
}) }),
|
|
310
|
-
subscriptions: () => Subscription.make()(() => ({ changes: Subscription.persistentEntry(sizeStream()) }))
|
|
311
|
-
});
|
|
312
|
-
//#endregion
|
|
313
|
-
export { ActiveElementMessage, Idle, IdleMessage, IdleModel, InputModality, InputModalityMessage, InputModalityModel, KeyboardMessage, Modality, PointerMessage, ScrollMessage, Visibility, VisibilityMessage, VisibilityModel, WindowSize, WindowSizeMessage, WindowSizeModel, activeElementEvents, keyboardEvents, matchHotkey, modalityOfKey, pointerEvents, scrollEvents };
|
|
314
|
-
|
|
315
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/events/active-element.ts","../../src/events/hotkeys.ts","../../src/events/idle.ts","../../src/events/keyboard.ts","../../src/events/pointer.ts","../../src/events/scroll.ts","../../src/events/visibility.ts","../../src/events/window-size.ts"],"sourcesContent":["/**\n * Focused element as an entry — not a bundle, because elements are not\n * Model facts: this reports the active element's tag and id (both\n * serializable), and the parent stores what matters. Starts with the\n * current answer, then follows `focusin`/`focusout`.\n */\nimport { Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\n\nexport const ActiveElementMessage = defineMessageUnion({\n Changed: { tag: Schema.String, id: Schema.NullOr(Schema.String) },\n})\nexport type ActiveElementMessage = typeof ActiveElementMessage.Type\n\n/**\n * Focus changes on the document. Without a document the stream is empty\n * instead of throwing. Lift with `Subscription.persistentEntry`, mapping into\n * the parent's Message.\n */\nexport const activeElementEvents = (): Stream.Stream<ActiveElementMessage> => {\n if (typeof document === 'undefined') return Stream.empty\n const read = (): ActiveElementMessage => {\n const element = document.activeElement as Element | null | undefined\n return ActiveElementMessage.Changed({\n tag: element?.tagName ?? '',\n id: element?.id !== undefined && element.id !== '' ? element.id : null,\n })\n }\n const changes: Stream.Stream<ActiveElementMessage> = Stream.mergeAll(\n [\n Stream.fromEventListener(document, 'focusin').pipe(Stream.map(read)),\n Stream.fromEventListener(document, 'focusout').pipe(Stream.map(read)),\n ],\n { concurrency: 'unbounded' },\n )\n return Stream.concat(Stream.make(read()), changes)\n}\n","export interface KeyPress {\n readonly key: string\n readonly repeat: boolean\n readonly ctrl: boolean\n readonly shift: boolean\n readonly alt: boolean\n readonly meta: boolean\n}\n\nconst modifierOf = (part: string): 'ctrl' | 'shift' | 'alt' | 'meta' | null => {\n switch (part) {\n case 'ctrl':\n case 'control':\n return 'ctrl'\n case 'shift':\n return 'shift'\n case 'alt':\n case 'option':\n return 'alt'\n case 'meta':\n case 'cmd':\n case 'command':\n return 'meta'\n default:\n return null\n }\n}\n\nconst keyNameOf = (part: string): string => {\n switch (part) {\n case 'spacebar':\n case ' ':\n return 'space'\n case 'esc':\n return 'escape'\n default:\n return part\n }\n}\n\n/**\n * Hotkey matching as a pure function over a `Pressed` payload: `matchHotkey`\n * answers whether a press is the shortcut, so `update` stays a table of\n * chords instead of a nest of modifier checks. Patterns read like\n * `\"ctrl+shift+k\"`: modifiers first (any order), the key last,\n * case-insensitive, with `cmd`/`command` and `option` as the Mac names for\n * meta and alt. Matching is exact — unlisted modifiers must be up — and\n * auto-repeat never matches, so holding a chord fires once. `space` (or a\n * bare space) means the space key; `esc` means escape. A pattern with\n * no key, or two keys, matches nothing: predicates return false, they do\n * not throw on the hot path.\n */\nexport const matchHotkey = (pattern: string, press: KeyPress): boolean => {\n if (press.repeat) return false\n const trimmed = pattern\n .split('+')\n .map(part => part.trim().toLowerCase())\n .filter(part => part !== '')\n // A bare whitespace pattern means the space key; an empty pattern is malformed.\n const parts = trimmed.length === 0 && pattern.length > 0 ? ['space'] : trimmed\n const keys = parts.filter(part => modifierOf(part) === null)\n if (keys.length !== 1) return false\n if (keyNameOf(keys[0]!) !== keyNameOf(press.key.toLowerCase())) return false\n const required: Record<'ctrl' | 'shift' | 'alt' | 'meta', boolean> = {\n ctrl: false,\n shift: false,\n alt: false,\n meta: false,\n }\n for (const part of parts) {\n const modifier = modifierOf(part)\n if (modifier !== null) required[modifier] = true\n }\n return (\n required.ctrl === press.ctrl &&\n required.shift === press.shift &&\n required.alt === press.alt &&\n required.meta === press.meta\n )\n}\n","import { Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Subscription from 'foldkit/subscription'\nimport type * as Update from 'foldkit/update'\nimport { Bundle } from 'foldkit-bundle'\n\nexport const IdleModel = Schema.Struct({ idle: Schema.Boolean })\nexport type IdleModel = typeof IdleModel.Type\n\nexport const IdleMessage = defineMessageUnion({ BecameIdle: {}, BecameActive: {} })\nexport type IdleMessage = typeof IdleMessage.Type\n\nconst activity = (): Stream.Stream<unknown> => {\n if (typeof window === 'undefined') return Stream.empty\n // One stream per sense; the merge fans into the debounce below.\n const senses: Array<Stream.Stream<unknown>> = [\n Stream.fromEventListener(window, 'mousemove'),\n Stream.fromEventListener(window, 'keydown'),\n Stream.fromEventListener(window, 'pointerdown'),\n Stream.fromEventListener(window, 'scroll'),\n ]\n return Stream.mergeAll(senses, { concurrency: 'unbounded' })\n}\n\n/**\n * Idleness as a bundle: `idle` in the Model, flipped by activity and\n * silence. While active, activity debounced past `timeoutMs` settles to\n * `BecameIdle`; while idle, the first activity wakes to `BecameActive` and\n * the dependency flip restarts the watch. Starts active — a lurker idles\n * when the timeout elapses. The clock is Effect's, so tests drive it with\n * TestClock.\n */\nexport const Idle = Bundle.make('Idle', {\n Model: IdleModel,\n Message: IdleMessage,\n args: Schema.Struct({\n timeoutMs: Schema.Number.pipe(\n Schema.check(Schema.isGreaterThan(0)),\n Schema.check(Schema.isFinite()),\n ),\n }),\n init: () => ({ model: { idle: false } }),\n update: (model, message) =>\n IdleMessage.match<Update.ReturnWithOutMessage<IdleModel, IdleMessage, never>>(message, {\n // One already in flight when the watch restarts can repeat the state.\n BecameIdle: () => (model.idle ? { model } : { model: { ...model, idle: true } }),\n BecameActive: () => (model.idle ? { model: { ...model, idle: false } } : { model }),\n }),\n subscriptions: ({ timeoutMs }): Subscription.Subscriptions<IdleModel, IdleMessage> =>\n Subscription.make<IdleModel, IdleMessage>()(entry => ({\n watch: entry(\n { idle: Schema.Boolean },\n {\n modelToDependencies: model => ({ idle: model.idle }),\n dependenciesToStream: ({ idle }) =>\n idle\n ? activity().pipe(\n Stream.take(1),\n Stream.map(() => IdleMessage.BecameActive()),\n )\n : // Seeded with subscribe time as last-known-alive: silence from\n // here still settles, so a lurker idles without moving first.\n Stream.concat(Stream.make(null), activity()).pipe(\n Stream.debounce(timeoutMs),\n Stream.map(() => IdleMessage.BecameIdle()),\n ),\n },\n ),\n })),\n})\n","/**\n * Keyboard as an entry — not a bundle, because the parent owns whatever key\n * state it keeps (a held-keys set, a shortcut map, a focused field): this\n * reports presses and releases, including auto-repeat, and the parent\n * stores what matters. Hotkey matching stays application policy.\n */\nimport { Effect, Queue, Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type { KeyPress } from './hotkeys.js'\n\nexport const KeyboardMessage = defineMessageUnion({\n Pressed: {\n key: Schema.String,\n repeat: Schema.Boolean,\n ctrl: Schema.Boolean,\n shift: Schema.Boolean,\n alt: Schema.Boolean,\n meta: Schema.Boolean,\n },\n Released: { key: Schema.String },\n})\nexport type KeyboardMessage = typeof KeyboardMessage.Type\n\n/**\n * Key presses and releases on the window. Without a window the stream is\n * empty instead of throwing. Lift with `Subscription.persistentEntry`, mapping\n * into the parent's Message.\n */\nexport const keyboardEvents = (\n options: {\n /**\n * Whether to cancel a press's default (the page scrolling under an arrow\n * key, the browser's own shortcut), decided in the listener, since a\n * default can only be cancelled before the event finishes dispatching.\n */\n readonly preventDefault?: (press: KeyPress) => boolean\n } = {},\n): Stream.Stream<KeyboardMessage> => {\n if (typeof window === 'undefined') return Stream.empty\n return Stream.callback<KeyboardMessage>(queue =>\n Effect.acquireRelease(\n Effect.sync(() => {\n const down = (event: KeyboardEvent) => {\n const press = KeyboardMessage.Pressed({\n key: event.key,\n repeat: event.repeat,\n ctrl: event.ctrlKey,\n shift: event.shiftKey,\n alt: event.altKey,\n meta: event.metaKey,\n })\n if (options.preventDefault?.(press) === true) event.preventDefault()\n Queue.offerUnsafe(queue, press)\n }\n const up = (event: KeyboardEvent) =>\n Queue.offerUnsafe(queue, KeyboardMessage.Released({ key: event.key }))\n window.addEventListener('keydown', down)\n window.addEventListener('keyup', up)\n return { down, up }\n }),\n ({ down, up }) =>\n Effect.sync(() => {\n window.removeEventListener('keydown', down)\n window.removeEventListener('keyup', up)\n }),\n ),\n )\n}\n","/**\n * Pointer position as an entry — not a bundle, because the parent owns what\n * it keeps (a cursor, a drag anchor, hover state): this reports moves, and\n * the parent stores what matters. Element-scoped pointer needs are Mounts,\n * not this window-level entry.\n */\nimport { Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\n\nexport const PointerMessage = defineMessageUnion({\n Moved: { x: Schema.Number, y: Schema.Number },\n})\nexport type PointerMessage = typeof PointerMessage.Type\n\n/**\n * Pointer moves on the window. Without a window the stream is empty instead\n * of throwing. Lift with `Subscription.persistentEntry`, mapping into the\n * parent's Message.\n */\nexport const pointerEvents = (): Stream.Stream<PointerMessage> => {\n if (typeof window === 'undefined') return Stream.empty\n return Stream.fromEventListener<PointerEvent>(window, 'pointermove').pipe(\n Stream.map(event => PointerMessage.Moved({ x: event.clientX, y: event.clientY })),\n )\n}\n","/**\n * Window scroll position as an entry — not a bundle, because the parent\n * owns what it keeps (a stuck header, a back-to-top gate, restore-on-back):\n * this reports positions, and the parent stores what matters.\n * Element-scoped scrolling needs a Mount, not this window-level entry.\n */\nimport { Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\n\nexport const ScrollMessage = defineMessageUnion({\n Scrolled: { x: Schema.Number, y: Schema.Number },\n})\nexport type ScrollMessage = typeof ScrollMessage.Type\n\n/**\n * Scrolls on the window, in the capture phase so container scrolls (which\n * do not bubble) report too. Without a window the stream is empty instead\n * of throwing. Lift with `Subscription.persistentEntry`, mapping into the\n * parent's Message.\n */\nexport const scrollEvents = (): Stream.Stream<ScrollMessage> => {\n if (typeof window === 'undefined') return Stream.empty\n return Stream.fromEventListener(window, 'scroll', { capture: true }).pipe(\n Stream.map(() => ScrollMessage.Scrolled({ x: window.scrollX, y: window.scrollY })),\n )\n}\n","import { Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Subscription from 'foldkit/subscription'\nimport { Bundle } from 'foldkit-bundle'\n\nexport const VisibilityModel = Schema.Struct({ visible: Schema.Boolean })\nexport type VisibilityModel = typeof VisibilityModel.Type\n\nexport const VisibilityMessage = defineMessageUnion({ Changed: { visible: Schema.Boolean } })\nexport type VisibilityMessage = typeof VisibilityMessage.Type\n\nconst isVisible = (): boolean =>\n typeof document === 'undefined' || document.visibilityState !== 'hidden'\n\nconst visibilityStream = (): Stream.Stream<VisibilityMessage> => {\n if (typeof document === 'undefined' || typeof document.addEventListener !== 'function') {\n return Stream.empty\n }\n return Stream.concat(\n Stream.make(VisibilityMessage.Changed({ visible: isVisible() })),\n Stream.fromEventListener(document, 'visibilitychange').pipe(\n Stream.map(() => VisibilityMessage.Changed({ visible: isVisible() })),\n ),\n )\n}\n\n/**\n * Page visibility as a bundle: `visible` in the Model, read from the\n * document at startup and kept current by `visibilitychange`. A hidden page\n * is the application's cue to pause polling, animations, and realtime\n * streams; the decision stays in application `update`, not here.\n */\nexport const Visibility = Bundle.make('Visibility', {\n Model: VisibilityModel,\n Message: VisibilityMessage,\n // No document (SSR): assume visible; the stream corrects on subscribe.\n init: () => ({ model: { visible: isVisible() } }),\n // The stream opens with the state `init` already read.\n update: (model, message) =>\n message.visible === model.visible ? { model } : { model: { visible: message.visible } },\n subscriptions: (): Subscription.Subscriptions<VisibilityModel, VisibilityMessage> =>\n Subscription.make<VisibilityModel, VisibilityMessage>()(() => ({\n changes: Subscription.persistentEntry(visibilityStream()),\n })),\n})\n","import { Effect, Queue, Schema, Stream } from 'effect'\nimport { defineMessageUnion } from 'foldkit/message'\nimport * as Subscription from 'foldkit/subscription'\nimport { Bundle } from 'foldkit-bundle'\nimport { unlessSame } from '../internal.js'\n\nexport const WindowSizeModel = Schema.Struct({ width: Schema.Number, height: Schema.Number })\nexport type WindowSizeModel = typeof WindowSizeModel.Type\n\nexport const WindowSizeMessage = defineMessageUnion({\n Changed: { width: Schema.Number, height: Schema.Number },\n})\nexport type WindowSizeMessage = typeof WindowSizeMessage.Type\n\nconst readSize = (): { readonly width: number; readonly height: number } => ({\n width: window.innerWidth,\n height: window.innerHeight,\n})\n\nconst sizeStream = (): Stream.Stream<WindowSizeMessage> => {\n if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') {\n return Stream.empty\n }\n return Stream.unwrap(\n Effect.gen(function* () {\n const queue = yield* Queue.unbounded<WindowSizeMessage>()\n const onResize = () => {\n const size = readSize()\n Effect.runFork(\n Queue.offer(queue, WindowSizeMessage.Changed({ width: size.width, height: size.height })),\n )\n }\n window.addEventListener('resize', onResize)\n yield* Effect.addFinalizer(() =>\n Effect.sync(() => {\n window.removeEventListener('resize', onResize)\n }),\n )\n const size = readSize()\n return Stream.concat(\n Stream.make(WindowSizeMessage.Changed({ width: size.width, height: size.height })),\n Stream.fromQueue(queue),\n )\n }),\n )\n}\n\n/**\n * Window size as a bundle: `{ width, height }` in the Model, read from the\n * window at startup and kept current by one `resize` listener. Breakpoints\n * owns its own listener and derives names; place this one when views need\n * the raw pixels. Placing both doubles resize listeners — pick the one the\n * view reads.\n */\nexport const WindowSize = Bundle.make('WindowSize', {\n Model: WindowSizeModel,\n Message: WindowSizeMessage,\n init: () => ({ model: { width: 0, height: 0 } }),\n update: (model, message) => ({\n model: unlessSame(model, { width: message.width, height: message.height }),\n }),\n subscriptions: (): Subscription.Subscriptions<WindowSizeModel, WindowSizeMessage> =>\n Subscription.make<WindowSizeModel, WindowSizeMessage>()(() => ({\n changes: Subscription.persistentEntry(sizeStream()),\n })),\n})\n"],"mappings":";;;;;;;;;;;;;AASA,MAAa,uBAAuB,mBAAmB,EACrD,SAAS;CAAE,KAAK,OAAO;CAAQ,IAAI,OAAO,OAAO,OAAO,MAAM;AAAE,EAClE,CAAC;;;;;;AAQD,MAAa,4BAAiE;CAC5E,IAAI,OAAO,aAAa,aAAa,OAAO,OAAO;CACnD,MAAM,aAAmC;EACvC,MAAM,UAAU,SAAS;EACzB,OAAO,qBAAqB,QAAQ;GAClC,KAAK,SAAS,WAAW;GACzB,IAAI,SAAS,OAAO,KAAA,KAAa,QAAQ,OAAO,KAAK,QAAQ,KAAK;EACpE,CAAC;CACH;CACA,MAAM,UAA+C,OAAO,SAC1D,CACE,OAAO,kBAAkB,UAAU,SAAS,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,GACnE,OAAO,kBAAkB,UAAU,UAAU,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,CACtE,GACA,EAAE,aAAa,YAAY,CAC7B;CACA,OAAO,OAAO,OAAO,OAAO,KAAK,KAAK,CAAC,GAAG,OAAO;AACnD;;;AC3BA,MAAM,cAAc,SAA2D;CAC7E,QAAQ,MAAR;EACE,KAAK;EACL,KAAK,WACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAM,aAAa,SAAyB;CAC1C,QAAQ,MAAR;EACE,KAAK;EACL,KAAK,KACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;;;;;;;;;AAcA,MAAa,eAAe,SAAiB,UAA6B;CACxE,IAAI,MAAM,QAAQ,OAAO;C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