foldkit 0.166.0 → 0.167.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/command/index.d.ts +4 -4
- package/dist/command/index.js +4 -4
- package/dist/dom/index.d.ts +6 -0
- package/dist/dom/index.d.ts.map +1 -1
- package/dist/dom/index.js +3 -0
- package/dist/dom/public.d.ts +2 -2
- package/dist/dom/public.d.ts.map +1 -1
- package/dist/dom/public.js +1 -1
- package/dist/{subscription/fromEvent.d.ts → dom/streamFromEvent.d.ts} +31 -31
- package/dist/dom/streamFromEvent.d.ts.map +1 -0
- package/dist/{subscription/fromEvent.js → dom/streamFromEvent.js} +20 -20
- package/dist/{subscription/keyBindings.d.ts → dom/streamFromKeyBindings.d.ts} +7 -7
- package/dist/dom/streamFromKeyBindings.d.ts.map +1 -0
- package/dist/{subscription/keyBindings.js → dom/streamFromKeyBindings.js} +62 -17
- package/dist/{subscription/fromMediaQuery.d.ts → dom/streamFromMediaQuery.d.ts} +7 -7
- package/dist/dom/streamFromMediaQuery.d.ts.map +1 -0
- package/dist/{subscription/fromMediaQuery.js → dom/streamFromMediaQuery.js} +4 -4
- package/dist/experimental/server/document.d.ts +43 -0
- package/dist/experimental/server/document.d.ts.map +1 -0
- package/dist/experimental/server/document.js +42 -0
- package/dist/experimental/server/entry.d.ts +14 -7
- package/dist/experimental/server/entry.d.ts.map +1 -1
- package/dist/experimental/server/entry.js +8 -6
- package/dist/experimental/server/fetch.d.ts +11 -8
- package/dist/experimental/server/fetch.d.ts.map +1 -1
- package/dist/experimental/server/fetch.js +16 -1
- package/dist/experimental/server/index.d.ts +1 -0
- package/dist/experimental/server/index.d.ts.map +1 -1
- package/dist/experimental/server/index.js +1 -0
- package/dist/experimental/server/public.d.ts +2 -2
- package/dist/experimental/server/public.d.ts.map +1 -1
- package/dist/experimental/server/public.js +1 -1
- package/dist/experimental/server/server.d.ts +1 -1
- package/dist/port/port.d.ts +8 -8
- package/dist/port/port.d.ts.map +1 -1
- package/dist/port/port.js +8 -8
- package/dist/port/public.d.ts +1 -1
- package/dist/port/public.d.ts.map +1 -1
- package/dist/port/public.js +1 -1
- package/dist/subscription/animationFrame.d.ts +4 -4
- package/dist/subscription/animationFrame.d.ts.map +1 -1
- package/dist/subscription/animationFrame.js +3 -3
- package/dist/subscription/public.d.ts +2 -8
- package/dist/subscription/public.d.ts.map +1 -1
- package/dist/subscription/public.js +2 -5
- package/dist/subscription/subscription.d.ts +9 -9
- package/dist/subscription/subscription.d.ts.map +1 -1
- package/dist/subscription/subscription.js +6 -6
- package/dist/update/public.d.ts +2 -2
- package/dist/update/public.d.ts.map +1 -1
- package/dist/update/public.js +1 -1
- package/dist/update/update.d.ts +109 -0
- package/dist/update/update.d.ts.map +1 -1
- package/dist/update/update.js +70 -0
- package/package.json +1 -1
- package/dist/subscription/fromEvent.d.ts.map +0 -1
- package/dist/subscription/fromMediaQuery.d.ts.map +0 -1
- package/dist/subscription/keyBindings.d.ts.map +0 -1
package/dist/command/index.d.ts
CHANGED
|
@@ -215,10 +215,10 @@ export declare const mapMessage: {
|
|
|
215
215
|
/** Lifts every Command in a list through `f`, transforming the result
|
|
216
216
|
* Message type from `FromMessage` to `ToMessage`. When `commands` is
|
|
217
217
|
* `undefined`, it returns an empty array. `Update.foldChild`,
|
|
218
|
-
* `Update.foldChildStep`, `Update.foldChildInit`,
|
|
219
|
-
* handle this mapping for application Submodels.
|
|
220
|
-
* standalone batch of Commands or when route-gated
|
|
221
|
-
* only the active child's Commands:
|
|
218
|
+
* `Update.foldChildStep`, `Update.foldChildInit`, `Update.foldChildInits`,
|
|
219
|
+
* and `Update.foldChildAt` handle this mapping for application Submodels.
|
|
220
|
+
* Use `mapMessages` for a standalone batch of Commands or when route-gated
|
|
221
|
+
* initialization includes only the active child's Commands:
|
|
222
222
|
*
|
|
223
223
|
* ```ts
|
|
224
224
|
* const commands = Command.mapMessages(
|
package/dist/command/index.js
CHANGED
|
@@ -133,10 +133,10 @@ export const mapMessage = Function.dual(2, (command, f) => {
|
|
|
133
133
|
/** Lifts every Command in a list through `f`, transforming the result
|
|
134
134
|
* Message type from `FromMessage` to `ToMessage`. When `commands` is
|
|
135
135
|
* `undefined`, it returns an empty array. `Update.foldChild`,
|
|
136
|
-
* `Update.foldChildStep`, `Update.foldChildInit`,
|
|
137
|
-
* handle this mapping for application Submodels.
|
|
138
|
-
* standalone batch of Commands or when route-gated
|
|
139
|
-
* only the active child's Commands:
|
|
136
|
+
* `Update.foldChildStep`, `Update.foldChildInit`, `Update.foldChildInits`,
|
|
137
|
+
* and `Update.foldChildAt` handle this mapping for application Submodels.
|
|
138
|
+
* Use `mapMessages` for a standalone batch of Commands or when route-gated
|
|
139
|
+
* initialization includes only the active child's Commands:
|
|
140
140
|
*
|
|
141
141
|
* ```ts
|
|
142
142
|
* const commands = Command.mapMessages(
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -4,5 +4,11 @@ export type { FocusDirection } from './dom.js';
|
|
|
4
4
|
export { detectElementMovement } from './elementMovement.js';
|
|
5
5
|
export { inertOthers, restoreInert } from './inert.js';
|
|
6
6
|
export { lockScroll, unlockScroll } from './scrollLock.js';
|
|
7
|
+
export { streamFromEvent, streamFromEventFilterMap, streamFromEventFilterMapPreventDefault, } from './streamFromEvent.js';
|
|
8
|
+
export type { StreamFromEventConfig, StreamFromEventFilterMapConfig, StreamFromEventFilterMapPreventDefaultConfig, TypedEventTarget, } from './streamFromEvent.js';
|
|
9
|
+
export { streamFromKeyBindings } from './streamFromKeyBindings.js';
|
|
10
|
+
export type { KeyBinding, KeySequence, StreamFromKeyBindingsConfig, WhileTyping, } from './streamFromKeyBindings.js';
|
|
11
|
+
export { streamFromMediaQuery } from './streamFromMediaQuery.js';
|
|
12
|
+
export type { StreamFromMediaQueryConfig } from './streamFromMediaQuery.js';
|
|
7
13
|
export { waitForAnimationSettled } from './waitForAnimation.js';
|
|
8
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dom/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,sBAAsB,EACtB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,UAAU,GACX,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,sBAAsB,EACtB,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,UAAU,GACX,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sCAAsC,GACvC,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,qBAAqB,EACrB,8BAA8B,EAC9B,4CAA4C,EAC5C,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,YAAY,EACV,UAAU,EACV,WAAW,EACX,2BAA2B,EAC3B,WAAW,GACZ,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/dom/index.js
CHANGED
|
@@ -3,4 +3,7 @@ export { advanceFocus, clickElement, closeDialog, focus, releaseDialogResources,
|
|
|
3
3
|
export { detectElementMovement } from './elementMovement.js';
|
|
4
4
|
export { inertOthers, restoreInert } from './inert.js';
|
|
5
5
|
export { lockScroll, unlockScroll } from './scrollLock.js';
|
|
6
|
+
export { streamFromEvent, streamFromEventFilterMap, streamFromEventFilterMapPreventDefault, } from './streamFromEvent.js';
|
|
7
|
+
export { streamFromKeyBindings } from './streamFromKeyBindings.js';
|
|
8
|
+
export { streamFromMediaQuery } from './streamFromMediaQuery.js';
|
|
6
9
|
export { waitForAnimationSettled } from './waitForAnimation.js';
|
package/dist/dom/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ElementNotFound, advanceFocus, clickElement, closeDialog, detectElementMovement, focus, inertOthers, lockScroll, releaseDialogResources, restoreInert, scrollIntoView, scrollIntoViewAfterPaint, scrollIntoViewIfNotVisible, showDialog, unlockScroll, waitForAnimationSettled, } from './index.js';
|
|
2
|
-
export type { FocusDirection } from './index.js';
|
|
1
|
+
export { ElementNotFound, advanceFocus, clickElement, closeDialog, detectElementMovement, focus, inertOthers, lockScroll, releaseDialogResources, restoreInert, scrollIntoView, scrollIntoViewAfterPaint, scrollIntoViewIfNotVisible, showDialog, streamFromEvent, streamFromEventFilterMap, streamFromEventFilterMapPreventDefault, streamFromKeyBindings, streamFromMediaQuery, unlockScroll, waitForAnimationSettled, } from './index.js';
|
|
2
|
+
export type { FocusDirection, KeyBinding, KeySequence, StreamFromEventConfig, StreamFromEventFilterMapConfig, StreamFromEventFilterMapPreventDefaultConfig, StreamFromKeyBindingsConfig, StreamFromMediaQueryConfig, TypedEventTarget, WhileTyping, } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
package/dist/dom/public.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/dom/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,KAAK,EACL,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,UAAU,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,YAAY,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/dom/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,KAAK,EACL,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,sCAAsC,EACtC,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,8BAA8B,EAC9B,4CAA4C,EAC5C,2BAA2B,EAC3B,0BAA0B,EAC1B,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAA"}
|
package/dist/dom/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ElementNotFound, advanceFocus, clickElement, closeDialog, detectElementMovement, focus, inertOthers, lockScroll, releaseDialogResources, restoreInert, scrollIntoView, scrollIntoViewAfterPaint, scrollIntoViewIfNotVisible, showDialog, unlockScroll, waitForAnimationSettled, } from './index.js';
|
|
1
|
+
export { ElementNotFound, advanceFocus, clickElement, closeDialog, detectElementMovement, focus, inertOthers, lockScroll, releaseDialogResources, restoreInert, scrollIntoView, scrollIntoViewAfterPaint, scrollIntoViewIfNotVisible, showDialog, streamFromEvent, streamFromEventFilterMap, streamFromEventFilterMapPreventDefault, streamFromKeyBindings, streamFromMediaQuery, unlockScroll, waitForAnimationSettled, } from './index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Option, Stream } from 'effect';
|
|
2
2
|
declare const EventMapMarker: unique symbol;
|
|
3
3
|
/**
|
|
4
|
-
* An `EventTarget` that declares the events it dispatches, so the `
|
|
4
|
+
* An `EventTarget` that declares the events it dispatches, so the `streamFromEvent`
|
|
5
5
|
* helpers can resolve an event name to its event type the way they do for
|
|
6
6
|
* `window`, `document`, and the DOM interfaces lib.dom declares event maps
|
|
7
7
|
* for.
|
|
@@ -15,7 +15,7 @@ declare const EventMapMarker: unique symbol;
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
|
-
* const slowWarningTarget:
|
|
18
|
+
* const slowWarningTarget: Dom.TypedEventTarget<{
|
|
19
19
|
* 'foldkit:slow-warning': CustomEvent<SlowWarningReport>
|
|
20
20
|
* }> = new EventTarget()
|
|
21
21
|
* ```
|
|
@@ -42,10 +42,10 @@ type PreventDefaultEventListenerOptions = Omit<AddEventListenerOptions, 'passive
|
|
|
42
42
|
passive?: false;
|
|
43
43
|
}>;
|
|
44
44
|
/**
|
|
45
|
-
* Configuration for the `
|
|
45
|
+
* Configuration for the `streamFromEvent` Stream helper.
|
|
46
46
|
*
|
|
47
47
|
* `target` is read inside the acquire Effect, never before it, so the
|
|
48
|
-
* resolved `EventTarget` is captured at the moment the
|
|
48
|
+
* resolved `EventTarget` is captured at the moment the Stream's scope
|
|
49
49
|
* opens. Pass a thunk when the target may not exist until the scope opens, or
|
|
50
50
|
* pass the `EventTarget` directly for always-present globals like `window` or
|
|
51
51
|
* `document`.
|
|
@@ -60,23 +60,23 @@ type PreventDefaultEventListenerOptions = Omit<AddEventListenerOptions, 'passive
|
|
|
60
60
|
* unless the listener is passive. Some browsers default wheel and touch
|
|
61
61
|
* listeners on global targets to passive, where `preventDefault()` is
|
|
62
62
|
* ignored. Pass `options: { passive: false }` explicitly when cancelling
|
|
63
|
-
* those events, or reach for `
|
|
63
|
+
* those events, or reach for `streamFromEventFilterMapPreventDefault`, which does
|
|
64
64
|
* so for you.
|
|
65
65
|
*
|
|
66
66
|
* The output type is inferred from the mapper; `Subscription.make` checks
|
|
67
67
|
* that the final Stream emits the application's Message type.
|
|
68
68
|
*/
|
|
69
|
-
export type
|
|
69
|
+
export type StreamFromEventConfig<Target extends EventTarget, Type extends EventTypeOf<Target>, Output> = Readonly<{
|
|
70
70
|
target: Target | (() => Target);
|
|
71
71
|
type: Type;
|
|
72
72
|
mapEvent: (event: EventOf<Target, Type>) => Output;
|
|
73
73
|
options?: AddEventListenerOptions;
|
|
74
74
|
}>;
|
|
75
75
|
/**
|
|
76
|
-
* Configuration for the `
|
|
76
|
+
* Configuration for the `streamFromEventFilterMap` Stream helper.
|
|
77
77
|
*
|
|
78
78
|
* `target` is read inside the acquire Effect, never before it, so the
|
|
79
|
-
* resolved `EventTarget` is captured at the moment the
|
|
79
|
+
* resolved `EventTarget` is captured at the moment the Stream's scope
|
|
80
80
|
* opens. Pass a thunk when the target may not exist until the scope opens, or
|
|
81
81
|
* pass the `EventTarget` directly for always-present globals like `window` or
|
|
82
82
|
* `document`.
|
|
@@ -92,22 +92,22 @@ export type FromEventConfig<Target extends EventTarget, Type extends EventTypeOf
|
|
|
92
92
|
* passive. Some browsers default wheel and touch listeners on global targets
|
|
93
93
|
* to passive, where `preventDefault()` is ignored. Pass
|
|
94
94
|
* `options: { passive: false }` explicitly when cancelling those events, or
|
|
95
|
-
* reach for `
|
|
95
|
+
* reach for `streamFromEventFilterMapPreventDefault`, which does so for you.
|
|
96
96
|
*
|
|
97
97
|
* The output type is inferred from the mapper; `Subscription.make` checks
|
|
98
98
|
* that the final Stream emits the application's Message type.
|
|
99
99
|
*/
|
|
100
|
-
export type
|
|
100
|
+
export type StreamFromEventFilterMapConfig<Target extends EventTarget, Type extends EventTypeOf<Target>, Output> = Readonly<{
|
|
101
101
|
target: Target | (() => Target);
|
|
102
102
|
type: Type;
|
|
103
103
|
filterMapEvent: (event: EventOf<Target, Type>) => Option.Option<Output>;
|
|
104
104
|
options?: AddEventListenerOptions;
|
|
105
105
|
}>;
|
|
106
106
|
/**
|
|
107
|
-
* Configuration for the `
|
|
107
|
+
* Configuration for the `streamFromEventFilterMapPreventDefault` Stream helper.
|
|
108
108
|
*
|
|
109
109
|
* `target` is read inside the acquire Effect, never before it, so the
|
|
110
|
-
* resolved `EventTarget` is captured at the moment the
|
|
110
|
+
* resolved `EventTarget` is captured at the moment the Stream's scope
|
|
111
111
|
* opens. Pass a thunk when the target may not exist until the scope opens, or
|
|
112
112
|
* pass the `EventTarget` directly for always-present globals like `window` or
|
|
113
113
|
* `document`.
|
|
@@ -130,7 +130,7 @@ export type FromEventFilterMapConfig<Target extends EventTarget, Type extends Ev
|
|
|
130
130
|
* The output type is inferred from the mapper; `Subscription.make` checks
|
|
131
131
|
* that the final Stream emits the application's Message type.
|
|
132
132
|
*/
|
|
133
|
-
export type
|
|
133
|
+
export type StreamFromEventFilterMapPreventDefaultConfig<Target extends EventTarget, Type extends EventTypeOf<Target>, Output> = Readonly<{
|
|
134
134
|
target: Target | (() => Target);
|
|
135
135
|
type: Type;
|
|
136
136
|
filterMapEvent: (event: EventOf<Target, Type>) => Option.Option<Output>;
|
|
@@ -141,7 +141,7 @@ export type FromEventFilterMapPreventDefaultConfig<Target extends EventTarget, T
|
|
|
141
141
|
* mapper chooses to keep, registering the listener when the Stream's scope
|
|
142
142
|
* opens and removing it when the scope closes.
|
|
143
143
|
*
|
|
144
|
-
* This is the filtered variant of `
|
|
144
|
+
* This is the filtered variant of `streamFromEvent`. Its `filterMapEvent` returns
|
|
145
145
|
* `Option.some(value)` to emit and `Option.none()` to ignore the event, so a
|
|
146
146
|
* single listener can react to some dispatches while passing on the rest. A
|
|
147
147
|
* mapper that never emits produces a `Stream<never>`.
|
|
@@ -154,7 +154,7 @@ export type FromEventFilterMapPreventDefaultConfig<Target extends EventTarget, T
|
|
|
154
154
|
* which ignores `preventDefault()`. Some browsers default wheel and touch
|
|
155
155
|
* listeners on global targets to passive. Pass
|
|
156
156
|
* `options: { passive: false }` explicitly when cancelling those events, or
|
|
157
|
-
* reach for `
|
|
157
|
+
* reach for `streamFromEventFilterMapPreventDefault`, which does so for you.
|
|
158
158
|
*
|
|
159
159
|
* The target, the event name, and the event the mapper receives are one fact:
|
|
160
160
|
* `type` is constrained to the names the target declares, and the mapper's
|
|
@@ -169,8 +169,8 @@ export type FromEventFilterMapPreventDefaultConfig<Target extends EventTarget, T
|
|
|
169
169
|
* listener never leaks on interruption.
|
|
170
170
|
*
|
|
171
171
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
172
|
-
* `Subscription.
|
|
173
|
-
*
|
|
172
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
173
|
+
* or plug it into a `Subscription.make` entry's
|
|
174
174
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
175
175
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
176
176
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
@@ -185,7 +185,7 @@ export type FromEventFilterMapPreventDefaultConfig<Target extends EventTarget, T
|
|
|
185
185
|
* modelToDependencies: model => ({ isListening: model.isListening }),
|
|
186
186
|
* dependenciesToStream: ({ isListening }) =>
|
|
187
187
|
* Stream.when(
|
|
188
|
-
*
|
|
188
|
+
* Dom.streamFromEventFilterMap({
|
|
189
189
|
* target: window,
|
|
190
190
|
* type: 'keydown',
|
|
191
191
|
* filterMapEvent: event =>
|
|
@@ -200,7 +200,7 @@ export type FromEventFilterMapPreventDefaultConfig<Target extends EventTarget, T
|
|
|
200
200
|
* }))
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
|
-
export declare const
|
|
203
|
+
export declare const streamFromEventFilterMap: <Target extends EventTarget, Type extends EventTypeOf<Target>, Output>(config: StreamFromEventFilterMapConfig<Target, Type, Output>) => Stream.Stream<Output>;
|
|
204
204
|
/**
|
|
205
205
|
* Build a Stream that emits a value for every dispatch of a DOM event,
|
|
206
206
|
* registering the listener when the Stream's scope opens and removing it when
|
|
@@ -219,17 +219,17 @@ export declare const fromEventFilterMap: <Target extends EventTarget, Type exten
|
|
|
219
219
|
* listener never leaks on interruption.
|
|
220
220
|
*
|
|
221
221
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
222
|
-
* `Subscription.
|
|
223
|
-
*
|
|
222
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
223
|
+
* or plug it into a `Subscription.make` entry's
|
|
224
224
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
225
225
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
226
226
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
227
227
|
* application's Message type.
|
|
228
228
|
*
|
|
229
229
|
* For a listener that reacts to only some events, reach for
|
|
230
|
-
* `
|
|
230
|
+
* `streamFromEventFilterMap`, whose mapper returns `Option<Output>`. For a
|
|
231
231
|
* listener that also cancels the default action of the events it handles,
|
|
232
|
-
* reach for `
|
|
232
|
+
* reach for `streamFromEventFilterMapPreventDefault`.
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
235
235
|
* ```typescript
|
|
@@ -240,7 +240,7 @@ export declare const fromEventFilterMap: <Target extends EventTarget, Type exten
|
|
|
240
240
|
* modelToDependencies: model => ({ isListening: model.isListening }),
|
|
241
241
|
* dependenciesToStream: ({ isListening }) =>
|
|
242
242
|
* Stream.when(
|
|
243
|
-
*
|
|
243
|
+
* Dom.streamFromEvent({
|
|
244
244
|
* target: window,
|
|
245
245
|
* type: 'keydown',
|
|
246
246
|
* mapEvent: event => Message.PressedKey({ key: event.key }),
|
|
@@ -252,14 +252,14 @@ export declare const fromEventFilterMap: <Target extends EventTarget, Type exten
|
|
|
252
252
|
* }))
|
|
253
253
|
* ```
|
|
254
254
|
*/
|
|
255
|
-
export declare const
|
|
255
|
+
export declare const streamFromEvent: <Target extends EventTarget, Type extends EventTypeOf<Target>, Output>(config: StreamFromEventConfig<Target, Type, Output>) => Stream.Stream<Output>;
|
|
256
256
|
/**
|
|
257
257
|
* Build a Stream that emits a value for the dispatches of a DOM event the
|
|
258
258
|
* mapper marks handled, calling `event.preventDefault()` on each of them,
|
|
259
259
|
* registering the listener when the Stream's scope opens and removing it when
|
|
260
260
|
* the scope closes.
|
|
261
261
|
*
|
|
262
|
-
* This is the cancelling variant of `
|
|
262
|
+
* This is the cancelling variant of `streamFromEventFilterMap`, mirroring
|
|
263
263
|
* `h.OnKeyDownPreventDefault` from `foldkit/html`. Its `filterMapEvent` returns
|
|
264
264
|
* `Option.some(value)` to mark a dispatch handled. The helper evaluates the
|
|
265
265
|
* mapper, calls `event.preventDefault()`, and queues the value before the
|
|
@@ -284,8 +284,8 @@ export declare const fromEvent: <Target extends EventTarget, Type extends EventT
|
|
|
284
284
|
* listener never leaks on interruption.
|
|
285
285
|
*
|
|
286
286
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
287
|
-
* `Subscription.
|
|
288
|
-
*
|
|
287
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
288
|
+
* or plug it into a `Subscription.make` entry's
|
|
289
289
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
290
290
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
291
291
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
@@ -300,7 +300,7 @@ export declare const fromEvent: <Target extends EventTarget, Type extends EventT
|
|
|
300
300
|
* modelToDependencies: model => ({ isModalOpen: model.isModalOpen }),
|
|
301
301
|
* dependenciesToStream: ({ isModalOpen }) =>
|
|
302
302
|
* Stream.when(
|
|
303
|
-
*
|
|
303
|
+
* Dom.streamFromEventFilterMapPreventDefault({
|
|
304
304
|
* target: window,
|
|
305
305
|
* type: 'wheel',
|
|
306
306
|
* filterMapEvent: () => Option.some(Message.SuppressedWheelScroll()),
|
|
@@ -312,6 +312,6 @@ export declare const fromEvent: <Target extends EventTarget, Type extends EventT
|
|
|
312
312
|
* }))
|
|
313
313
|
* ```
|
|
314
314
|
*/
|
|
315
|
-
export declare const
|
|
315
|
+
export declare const streamFromEventFilterMapPreventDefault: <Target extends EventTarget, Type extends EventTypeOf<Target>, Output>(config: StreamFromEventFilterMapPreventDefaultConfig<Target, Type, Output>) => Stream.Stream<Output>;
|
|
316
316
|
export {};
|
|
317
|
-
//# sourceMappingURL=
|
|
317
|
+
//# sourceMappingURL=streamFromEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamFromEvent.d.ts","sourceRoot":"","sources":["../../src/dom/streamFromEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEtD,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB,CAC/B,QAAQ,SAAS;IAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,QAAQ,GAAG,KAAK;CAAE,CAC7D,SAAQ,WAAW;IACnB,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAA;CACrC;AAED,KAAK,iBAAiB,GAAG,OAAO,cAAc,CAAA;AAI9C,KAAK,gBAAgB,CAAC,MAAM,IAAI,iBAAiB,SAAS,MAAM,MAA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K,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACvE,OAAO,CAAC,EAAE,kCAAkC,CAAA;CAC7C,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,SAAS,WAAW,EAC1B,IAAI,SAAS,WAAW,CAAC,MAAM,CAAC,EAChC,MAAM,UAEE,8BAA8B,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KAC3D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAkD,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,SAAS,WAAW,EAC1B,IAAI,SAAS,WAAW,CAAC,MAAM,CAAC,EAChC,MAAM,UAEE,qBAAqB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KAClD,MAAM,CAAC,MAAM,CAAC,MAAM,CAInB,CAAA;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,sCAAsC,GACjD,MAAM,SAAS,WAAW,EAC1B,IAAI,SAAS,WAAW,CAAC,MAAM,CAAC,EAChC,MAAM,UAEE,4CAA4C,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KACzE,MAAM,CAAC,MAAM,CAAC,MAAM,CA4BtB,CAAA"}
|
|
@@ -19,7 +19,7 @@ const listen = (config) => Stream.callback(queue => Effect.acquireRelease(Effect
|
|
|
19
19
|
* mapper chooses to keep, registering the listener when the Stream's scope
|
|
20
20
|
* opens and removing it when the scope closes.
|
|
21
21
|
*
|
|
22
|
-
* This is the filtered variant of `
|
|
22
|
+
* This is the filtered variant of `streamFromEvent`. Its `filterMapEvent` returns
|
|
23
23
|
* `Option.some(value)` to emit and `Option.none()` to ignore the event, so a
|
|
24
24
|
* single listener can react to some dispatches while passing on the rest. A
|
|
25
25
|
* mapper that never emits produces a `Stream<never>`.
|
|
@@ -32,7 +32,7 @@ const listen = (config) => Stream.callback(queue => Effect.acquireRelease(Effect
|
|
|
32
32
|
* which ignores `preventDefault()`. Some browsers default wheel and touch
|
|
33
33
|
* listeners on global targets to passive. Pass
|
|
34
34
|
* `options: { passive: false }` explicitly when cancelling those events, or
|
|
35
|
-
* reach for `
|
|
35
|
+
* reach for `streamFromEventFilterMapPreventDefault`, which does so for you.
|
|
36
36
|
*
|
|
37
37
|
* The target, the event name, and the event the mapper receives are one fact:
|
|
38
38
|
* `type` is constrained to the names the target declares, and the mapper's
|
|
@@ -47,8 +47,8 @@ const listen = (config) => Stream.callback(queue => Effect.acquireRelease(Effect
|
|
|
47
47
|
* listener never leaks on interruption.
|
|
48
48
|
*
|
|
49
49
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
50
|
-
* `Subscription.
|
|
51
|
-
*
|
|
50
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
51
|
+
* or plug it into a `Subscription.make` entry's
|
|
52
52
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
53
53
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
54
54
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
@@ -63,7 +63,7 @@ const listen = (config) => Stream.callback(queue => Effect.acquireRelease(Effect
|
|
|
63
63
|
* modelToDependencies: model => ({ isListening: model.isListening }),
|
|
64
64
|
* dependenciesToStream: ({ isListening }) =>
|
|
65
65
|
* Stream.when(
|
|
66
|
-
*
|
|
66
|
+
* Dom.streamFromEventFilterMap({
|
|
67
67
|
* target: window,
|
|
68
68
|
* type: 'keydown',
|
|
69
69
|
* filterMapEvent: event =>
|
|
@@ -78,7 +78,7 @@ const listen = (config) => Stream.callback(queue => Effect.acquireRelease(Effect
|
|
|
78
78
|
* }))
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
export const
|
|
81
|
+
export const streamFromEventFilterMap = (config) => listen(config);
|
|
82
82
|
/**
|
|
83
83
|
* Build a Stream that emits a value for every dispatch of a DOM event,
|
|
84
84
|
* registering the listener when the Stream's scope opens and removing it when
|
|
@@ -97,17 +97,17 @@ export const fromEventFilterMap = (config) => listen(config);
|
|
|
97
97
|
* listener never leaks on interruption.
|
|
98
98
|
*
|
|
99
99
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
100
|
-
* `Subscription.
|
|
101
|
-
*
|
|
100
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
101
|
+
* or plug it into a `Subscription.make` entry's
|
|
102
102
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
103
103
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
104
104
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
105
105
|
* application's Message type.
|
|
106
106
|
*
|
|
107
107
|
* For a listener that reacts to only some events, reach for
|
|
108
|
-
* `
|
|
108
|
+
* `streamFromEventFilterMap`, whose mapper returns `Option<Output>`. For a
|
|
109
109
|
* listener that also cancels the default action of the events it handles,
|
|
110
|
-
* reach for `
|
|
110
|
+
* reach for `streamFromEventFilterMapPreventDefault`.
|
|
111
111
|
*
|
|
112
112
|
* @example
|
|
113
113
|
* ```typescript
|
|
@@ -118,7 +118,7 @@ export const fromEventFilterMap = (config) => listen(config);
|
|
|
118
118
|
* modelToDependencies: model => ({ isListening: model.isListening }),
|
|
119
119
|
* dependenciesToStream: ({ isListening }) =>
|
|
120
120
|
* Stream.when(
|
|
121
|
-
*
|
|
121
|
+
* Dom.streamFromEvent({
|
|
122
122
|
* target: window,
|
|
123
123
|
* type: 'keydown',
|
|
124
124
|
* mapEvent: event => Message.PressedKey({ key: event.key }),
|
|
@@ -130,7 +130,7 @@ export const fromEventFilterMap = (config) => listen(config);
|
|
|
130
130
|
* }))
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
133
|
-
export const
|
|
133
|
+
export const streamFromEvent = (config) => listen({
|
|
134
134
|
...config,
|
|
135
135
|
filterMapEvent: event => Option.some(config.mapEvent(event)),
|
|
136
136
|
});
|
|
@@ -140,7 +140,7 @@ export const fromEvent = (config) => listen({
|
|
|
140
140
|
* registering the listener when the Stream's scope opens and removing it when
|
|
141
141
|
* the scope closes.
|
|
142
142
|
*
|
|
143
|
-
* This is the cancelling variant of `
|
|
143
|
+
* This is the cancelling variant of `streamFromEventFilterMap`, mirroring
|
|
144
144
|
* `h.OnKeyDownPreventDefault` from `foldkit/html`. Its `filterMapEvent` returns
|
|
145
145
|
* `Option.some(value)` to mark a dispatch handled. The helper evaluates the
|
|
146
146
|
* mapper, calls `event.preventDefault()`, and queues the value before the
|
|
@@ -165,8 +165,8 @@ export const fromEvent = (config) => listen({
|
|
|
165
165
|
* listener never leaks on interruption.
|
|
166
166
|
*
|
|
167
167
|
* This is a Stream, not a Subscription entry. Wrap it with
|
|
168
|
-
* `Subscription.
|
|
169
|
-
*
|
|
168
|
+
* `Subscription.persistentEntry` for a listener with no local Model dependencies,
|
|
169
|
+
* or plug it into a `Subscription.make` entry's
|
|
170
170
|
* `dependenciesToStream` (typically behind `Stream.when`) to gate it on a
|
|
171
171
|
* Model condition. The mapper's output type is inferred (even a raw Event is
|
|
172
172
|
* accepted here); `Subscription.make` checks the final Stream against the
|
|
@@ -181,7 +181,7 @@ export const fromEvent = (config) => listen({
|
|
|
181
181
|
* modelToDependencies: model => ({ isModalOpen: model.isModalOpen }),
|
|
182
182
|
* dependenciesToStream: ({ isModalOpen }) =>
|
|
183
183
|
* Stream.when(
|
|
184
|
-
*
|
|
184
|
+
* Dom.streamFromEventFilterMapPreventDefault({
|
|
185
185
|
* target: window,
|
|
186
186
|
* type: 'wheel',
|
|
187
187
|
* filterMapEvent: () => Option.some(Message.SuppressedWheelScroll()),
|
|
@@ -193,20 +193,20 @@ export const fromEvent = (config) => listen({
|
|
|
193
193
|
* }))
|
|
194
194
|
* ```
|
|
195
195
|
*/
|
|
196
|
-
export const
|
|
196
|
+
export const streamFromEventFilterMapPreventDefault = (config) => {
|
|
197
197
|
const options = config.options;
|
|
198
198
|
if (options?.passive === true) {
|
|
199
|
-
throw new Error(`Foldkit: \`
|
|
199
|
+
throw new Error(`Foldkit: \`Dom.streamFromEventFilterMapPreventDefault\` was passed ` +
|
|
200
200
|
`\`options: { passive: true }\` for a "${config.type}" listener. ` +
|
|
201
201
|
`The helper exists to call \`event.preventDefault()\` on every ` +
|
|
202
202
|
`dispatch the mapper marks handled, and a passive listener promises ` +
|
|
203
203
|
`the browser the exact opposite: \`preventDefault()\` inside it is ` +
|
|
204
204
|
`ignored and logs a console warning. Drop the \`passive\` option ` +
|
|
205
205
|
`(the helper registers the listener with \`passive: false\` for ` +
|
|
206
|
-
`you), or use \`
|
|
206
|
+
`you), or use \`Dom.streamFromEventFilterMap\` for a listener ` +
|
|
207
207
|
`that only observes.`);
|
|
208
208
|
}
|
|
209
|
-
return
|
|
209
|
+
return streamFromEventFilterMap({
|
|
210
210
|
...config,
|
|
211
211
|
options: { ...options, passive: false },
|
|
212
212
|
filterMapEvent: event => {
|
|
@@ -11,7 +11,7 @@ type BindingBase<Output> = Readonly<{
|
|
|
11
11
|
preventDefault?: boolean;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
|
-
* One entry in a {@link
|
|
14
|
+
* One entry in a {@link streamFromKeyBindings} binding table.
|
|
15
15
|
*
|
|
16
16
|
* A string describes one key press, such as `'/'`, `'Escape'`, or `'Mod+K'`.
|
|
17
17
|
* An array describes a sequence of at least two presses, such as
|
|
@@ -25,8 +25,8 @@ export type KeyBinding<Output> = BindingBase<Output> & (Readonly<{
|
|
|
25
25
|
whenRepeated?: never;
|
|
26
26
|
}>);
|
|
27
27
|
type ModKey = 'Control' | 'Meta';
|
|
28
|
-
/** Configuration for the {@link
|
|
29
|
-
export type
|
|
28
|
+
/** Configuration for the {@link streamFromKeyBindings} Stream helper. */
|
|
29
|
+
export type StreamFromKeyBindingsConfig<Output> = Readonly<{
|
|
30
30
|
bindings: ReadonlyArray<KeyBinding<Output>>;
|
|
31
31
|
target?: EventTarget | (() => EventTarget);
|
|
32
32
|
modKey?: ModKey;
|
|
@@ -63,7 +63,7 @@ export type KeyBindingsConfig<Output> = Readonly<{
|
|
|
63
63
|
* are rejected when the Stream is created.
|
|
64
64
|
*
|
|
65
65
|
* This helper returns a Stream, not a complete Subscription entry. Use
|
|
66
|
-
* `Subscription.
|
|
66
|
+
* `Subscription.persistentEntry` for a fixed table. When availability depends on
|
|
67
67
|
* the Model that owns the entry, build it inside `dependenciesToStream` and
|
|
68
68
|
* derive each binding's `isEnabled` from the dependency record. A dependency
|
|
69
69
|
* change opens a new Stream scope and resets any sequence in progress. If a
|
|
@@ -83,7 +83,7 @@ export type KeyBindingsConfig<Output> = Readonly<{
|
|
|
83
83
|
* isPaletteOpen: model.paletteState._tag === 'Open',
|
|
84
84
|
* }),
|
|
85
85
|
* dependenciesToStream: ({ isPaletteOpen }) =>
|
|
86
|
-
*
|
|
86
|
+
* Dom.streamFromKeyBindings<Message>({
|
|
87
87
|
* bindings: [
|
|
88
88
|
* {
|
|
89
89
|
* keys: 'Escape',
|
|
@@ -107,6 +107,6 @@ export type KeyBindingsConfig<Output> = Readonly<{
|
|
|
107
107
|
* }))
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
-
export declare const
|
|
110
|
+
export declare const streamFromKeyBindings: <Output>(config: StreamFromKeyBindingsConfig<Output>) => Stream.Stream<Output>;
|
|
111
111
|
export {};
|
|
112
|
-
//# sourceMappingURL=
|
|
112
|
+
//# sourceMappingURL=streamFromKeyBindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamFromKeyBindings.d.ts","sourceRoot":"","sources":["../../src/dom/streamFromKeyBindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAOR,MAAM,EAGP,MAAM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