@wardic/test 1.0.0-rc.1 → 1.0.0-rc.10
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +6 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +19 -1
- package/dist/input.js.map +1 -1
- package/dist/layer.d.ts +6 -5
- package/dist/layer.d.ts.map +1 -1
- package/dist/layer.js +3 -3
- package/dist/layer.js.map +1 -1
- package/dist/probe.d.ts +11 -9
- package/dist/probe.d.ts.map +1 -1
- package/dist/probe.js +14 -13
- package/dist/probe.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/input.ts +27 -1
- package/src/layer.ts +5 -3
- package/src/probe.ts +31 -24
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Nothing is drawn on a page: an app's components are tested with `DomLive`
|
|
8
8
|
* under the test runner's fake timers, as https://wardic.dev/guides/testing shows.
|
|
9
9
|
*/
|
|
10
|
-
export declare const VERSION = "
|
|
10
|
+
export declare const VERSION = "1.0.0-rc.10";
|
|
11
11
|
export * as TestClock from "./clock.ts";
|
|
12
12
|
export * as TestRenderer from "./renderer.ts";
|
|
13
13
|
export * as TestProbe from "./probe.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,OAAO,gBAAgB,CAAA;AAEpC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* under the test runner's fake timers, as https://wardic.dev/guides/testing shows.
|
|
9
9
|
*/
|
|
10
10
|
// The testing guide: #558.
|
|
11
|
-
export const VERSION = "
|
|
11
|
+
export const VERSION = "1.0.0-rc.10";
|
|
12
12
|
export * as TestClock from "./clock.js";
|
|
13
13
|
export * as TestRenderer from "./renderer.js";
|
|
14
14
|
export * as TestProbe from "./probe.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAA;AAEpC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/input.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ export declare const layer: (pointerEvents?: ReadonlyArray<InputSource.PointerLi
|
|
|
48
48
|
* `options.focusWithin` is the source's `focusWithin`, for a test of a **Keyboard press** that
|
|
49
49
|
* holds its keys only while focus is within its target. Without it the source says nothing of focus,
|
|
50
50
|
* and a press hears every key pushed.
|
|
51
|
+
*
|
|
52
|
+
* `pushTo(target, event)` and `pushFocusTo(target, event)` feed `pointerAmong` and `focusAmong`, the feeds
|
|
53
|
+
* over many targets: each subscriber hears the event with the target its `memberOf` names `target`, or
|
|
54
|
+
* nothing when it names none. `push` and `pushFocus` reach neither, nor these the per-target feeds.
|
|
51
55
|
*/
|
|
52
56
|
export declare const pushable: (options?: {
|
|
53
57
|
readonly focusWithin?: ((target: unknown) => boolean) | undefined;
|
|
@@ -56,5 +60,7 @@ export declare const pushable: (options?: {
|
|
|
56
60
|
readonly push: (event: InputSource.PointerLikeEvent) => Effect.Effect<void>;
|
|
57
61
|
readonly pushFocus: (event: InputSource.FocusLikeEvent) => Effect.Effect<void>;
|
|
58
62
|
readonly pushKey: (event: InputSource.KeyboardLikeEvent) => Effect.Effect<void>;
|
|
63
|
+
readonly pushTo: (target: unknown, event: InputSource.PointerLikeEvent) => Effect.Effect<void>;
|
|
64
|
+
readonly pushFocusTo: (target: unknown, event: InputSource.FocusLikeEvent) => Effect.Effect<void>;
|
|
59
65
|
}>;
|
|
60
66
|
//# sourceMappingURL=input.d.ts.map
|
package/dist/input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AAEvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAKrC;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,KAAK,mBACD,aAAa,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAC7C,aAAa,CAAC,WAAW,CAAC,cAAc,CAAC,cAC3C,aAAa,CAAC,WAAW,CAAC,iBAAiB,CAAC,KACtD,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAMlC,CAAA;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,eAAO,MAAM,QAAQ,aAAc;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,SAAS,CAAA;CAAE,KAAG,MAAM,CAAC,MAAM,CAAC;IACvH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;IACpD,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3E,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9E,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/E,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9F,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CAClG,CA8BG,CAAA"}
|
package/dist/input.js
CHANGED
|
@@ -59,12 +59,19 @@ export const layer = (pointerEvents = [], focusEvents = [], keyEvents = []) => L
|
|
|
59
59
|
* `options.focusWithin` is the source's `focusWithin`, for a test of a **Keyboard press** that
|
|
60
60
|
* holds its keys only while focus is within its target. Without it the source says nothing of focus,
|
|
61
61
|
* and a press hears every key pushed.
|
|
62
|
+
*
|
|
63
|
+
* `pushTo(target, event)` and `pushFocusTo(target, event)` feed `pointerAmong` and `focusAmong`, the feeds
|
|
64
|
+
* over many targets: each subscriber hears the event with the target its `memberOf` names `target`, or
|
|
65
|
+
* nothing when it names none. `push` and `pushFocus` reach neither, nor these the per-target feeds.
|
|
62
66
|
*/
|
|
63
|
-
// The hub: #318. No yield: ADR-0032. Keys: #427. adoptPointer: #431. focusWithin: #460.
|
|
67
|
+
// The hub: #318. No yield: ADR-0032. Keys: #427. adoptPointer: #431. focusWithin: #460. The feeds over
|
|
68
|
+
// many targets: #665's PR 5.
|
|
64
69
|
export const pushable = (options) => Effect.sync(() => {
|
|
65
70
|
const pointer = Feeds.hub();
|
|
66
71
|
const focus = Feeds.hub();
|
|
67
72
|
const keys = Feeds.hub();
|
|
73
|
+
const pointerAmong = Feeds.hub();
|
|
74
|
+
const focusAmong = Feeds.hub();
|
|
68
75
|
return {
|
|
69
76
|
layer: Layer.succeed(InputSource.InputSource, {
|
|
70
77
|
pointer: () => pointer.feed,
|
|
@@ -79,12 +86,23 @@ export const pushable = (options) => Effect.sync(() => {
|
|
|
79
86
|
}
|
|
80
87
|
return Option.none();
|
|
81
88
|
},
|
|
89
|
+
pointerAmong: among(pointerAmong),
|
|
90
|
+
focusAmong: among(focusAmong),
|
|
82
91
|
}),
|
|
83
92
|
push: pointer.push,
|
|
84
93
|
pushFocus: focus.push,
|
|
85
94
|
pushKey: keys.push,
|
|
95
|
+
pushTo: (target, event) => pointerAmong.push({ target, event }),
|
|
96
|
+
pushFocusTo: (target, event) => focusAmong.push({ target, event }),
|
|
86
97
|
};
|
|
87
98
|
});
|
|
99
|
+
/**
|
|
100
|
+
* A feed over many targets on `hub`, for a subscriber's `memberOf`: each pushed event with the target
|
|
101
|
+
* `memberOf` names its pushed one, none when it names none.
|
|
102
|
+
*/
|
|
103
|
+
const among = (hub) => (memberOf) => (emit, end) => hub.feed((pushed) => {
|
|
104
|
+
Option.map(memberOf(pushed.target), (target) => emit({ target, event: pushed.event }));
|
|
105
|
+
}, end);
|
|
88
106
|
/** Whether `raw` is a pointer event with a button pressed: one the pushable InputSource adopts (#431). */
|
|
89
107
|
const isPressedPointer = (raw) => Bool.and(Predicate.hasProperty(raw, "pointerId"), Predicate.hasProperty(raw, "pressed")) && raw.pressed;
|
|
90
108
|
//# sourceMappingURL=input.js.map
|
package/dist/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC;;;;;;;;;;GAUG;AACH,yCAAyC;AACzC,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,aAAa,GAAgD,EAAE,EAC/D,WAAW,GAA8C,EAAE,EAC3D,SAAS,GAAiD,EAAE,EACtB,EAAE,CACxC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE;IACrC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;IAC1C,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;IACvC,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;IACtC,YAAY,EAAE,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 -8,12 +8,13 @@ import type * as Probe from "@wardic/core/Probe";
|
|
|
8
8
|
import * as ReducedMotion from "@wardic/core/ReducedMotion";
|
|
9
9
|
import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
|
|
10
10
|
import type * as Renderer from "@wardic/core/Renderer";
|
|
11
|
+
import type * as ScrollSource from "@wardic/core/ScrollSource";
|
|
11
12
|
import * as Layer from "effect/Layer";
|
|
12
|
-
import
|
|
13
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
13
14
|
/**
|
|
14
15
|
* The full headless environment: deterministic Clock (driven by `frames`), a Refresh frame
|
|
15
|
-
* source that never calls back, recording Renderer, static Probe
|
|
16
|
-
* interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
16
|
+
* source that never calls back, recording Renderer, static Probe and ScrollSource, silent
|
|
17
|
+
* InputSource, core's real interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
17
18
|
* (`viewport`, `prefersReducedMotion`), and a fresh Drag activity, so one test's
|
|
18
19
|
* drag never blocks another's hover or press, and core's Frame loop over that
|
|
19
20
|
* Clock. Provide this in place of `DomLive` to test animation code without a
|
|
@@ -21,7 +22,7 @@ import { AtomRegistry } from "effect/reactivity";
|
|
|
21
22
|
* app's components are tested with `DomLive` under the test runner's fake timers instead
|
|
22
23
|
* (https://wardic.dev/guides/testing).
|
|
23
24
|
*/
|
|
24
|
-
export declare const testLayer: (frames?: ReadonlyArray<number>) => Layer.Layer<Clock.Clock | RefreshFrameSource.RefreshFrameSource | FrameLoop.FrameLoop | Renderer.Renderer | Probe.Probe | InputSource.InputSource | InterpolatorRegistry.InterpolatorRegistry | ReducedMotion.PositionalKeys | DefaultTransition.DefaultTransition | Announcer.Announcer | AtomRegistry.AtomRegistry>;
|
|
25
|
+
export declare const testLayer: (frames?: ReadonlyArray<number>) => Layer.Layer<Clock.Clock | RefreshFrameSource.RefreshFrameSource | FrameLoop.FrameLoop | Renderer.Renderer | Probe.Probe | ScrollSource.ScrollSource | InputSource.InputSource | InterpolatorRegistry.InterpolatorRegistry | ReducedMotion.PositionalKeys | DefaultTransition.DefaultTransition | Announcer.Announcer | AtomRegistry.AtomRegistry>;
|
|
25
26
|
/** `testLayer()` with an empty clock — for tests that drive their own frames. It never ticks on its own. */
|
|
26
|
-
export declare const TestLive: Layer.Layer<Announcer.Announcer | AtomRegistry.AtomRegistry | Clock.Clock | DefaultTransition.DefaultTransition | FrameLoop.FrameLoop | InputSource.InputSource | InterpolatorRegistry.InterpolatorRegistry | ReducedMotion.PositionalKeys | Probe.Probe | RefreshFrameSource.RefreshFrameSource | Renderer.Renderer, never, never>;
|
|
27
|
+
export declare const TestLive: Layer.Layer<Announcer.Announcer | AtomRegistry.AtomRegistry | Clock.Clock | DefaultTransition.DefaultTransition | FrameLoop.FrameLoop | InputSource.InputSource | InterpolatorRegistry.InterpolatorRegistry | ReducedMotion.PositionalKeys | Probe.Probe | RefreshFrameSource.RefreshFrameSource | Renderer.Renderer | ScrollSource.ScrollSource, never, never>;
|
|
27
28
|
//# sourceMappingURL=layer.d.ts.map
|
package/dist/layer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,iBAAiB,MAAM,gCAAgC,CAAA;AAEnE,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,KAAK,WAAW,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,oBAAoB,MAAM,mCAAmC,CAAA;AAEzE,OAAO,KAAK,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,kBAAkB,MAAM,iCAAiC,CAAA;AACrE,OAAO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ANGED
|
@@ -8,7 +8,7 @@ import * as ReducedMotion from "@wardic/core/ReducedMotion";
|
|
|
8
8
|
import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
|
|
9
9
|
import { constUndefined, constVoid } from "effect/Function";
|
|
10
10
|
import * as Layer from "effect/Layer";
|
|
11
|
-
import
|
|
11
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
12
12
|
import * as TestClock from "./clock.js";
|
|
13
13
|
import * as TestInput from "./input.js";
|
|
14
14
|
import * as TestProbe from "./probe.js";
|
|
@@ -21,8 +21,8 @@ import * as TestRenderer from "./renderer.js";
|
|
|
21
21
|
const stillFrames = { requestFrame: constUndefined, cancelFrame: constVoid };
|
|
22
22
|
/**
|
|
23
23
|
* The full headless environment: deterministic Clock (driven by `frames`), a Refresh frame
|
|
24
|
-
* source that never calls back, recording Renderer, static Probe
|
|
25
|
-
* interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
24
|
+
* source that never calls back, recording Renderer, static Probe and ScrollSource, silent
|
|
25
|
+
* InputSource, core's real interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
26
26
|
* (`viewport`, `prefersReducedMotion`), and a fresh Drag activity, so one test's
|
|
27
27
|
* drag never blocks another's hover or press, and core's Frame loop over that
|
|
28
28
|
* Clock. Provide this in place of `DomLive` to test animation code without a
|
package/dist/layer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer.js","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,iBAAiB,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,YAAY,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,oBAAoB,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAA;AAEvD,OA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C,YAAY,CAAC,KAAK,EAClB,SAAS,CAAC,KAAK,EAAE,EACjB,SAAS,CAAC,KAAK,EAAE,EACjB,oBAAoB,CAAC,KAAK;AAC1B,0EAA0E;AAC1E,aAAa,CAAC,cAAc;AAC5B,gFAAgF;AAChF,iBAAiB,CAAC,cAAc;AAChC,wDAAwD;AACxD,SAAS,CAAC,WAAW,EACrB,YAAY,CAAC,KAAK,EAClB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,EACxD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CACtD,CACF,CACF,CAAA;AAEH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,EAAE,CAAA"}
|
package/dist/probe.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Probe from "@wardic/core/Probe";
|
|
2
|
+
import * as ScrollSource from "@wardic/core/ScrollSource";
|
|
2
3
|
import * as Effect from "effect/Effect";
|
|
3
4
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import
|
|
5
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
5
6
|
/** Options for the static test Probe. */
|
|
6
7
|
export interface Options {
|
|
7
8
|
readonly bounds?: Probe.Bounds;
|
|
@@ -10,10 +11,10 @@ export interface Options {
|
|
|
10
11
|
readonly height: number;
|
|
11
12
|
};
|
|
12
13
|
readonly prefersReducedMotion?: boolean;
|
|
13
|
-
/** Whether the
|
|
14
|
-
readonly
|
|
15
|
-
/** Every container's scroll, as `
|
|
16
|
-
readonly scroll?:
|
|
14
|
+
/** Whether the Environment is shown: `true` when left out. */
|
|
15
|
+
readonly visible?: boolean;
|
|
16
|
+
/** Every container's scroll, as the `ScrollSource` gives it: a page that doesn't scroll when left out. */
|
|
17
|
+
readonly scroll?: ScrollSource.Scroll;
|
|
17
18
|
/**
|
|
18
19
|
* Script of intersection (in-view) booleans replayed by `observeIntersection`, an **Input feed**
|
|
19
20
|
* that ends after it. Mirrors the InputSource test harness: omitted (or empty) means it
|
|
@@ -24,9 +25,10 @@ export interface Options {
|
|
|
24
25
|
/**
|
|
25
26
|
* A static Probe: fixed bounds/viewport. `observeIntersection` replays the
|
|
26
27
|
* optional `intersection` script to each subscriber (empty by default, so it
|
|
27
|
-
* emits nothing); `observeResize` stays empty.
|
|
28
|
+
* emits nothing); `observeResize` stays empty. With it, a `ScrollSource`
|
|
29
|
+
* whose every container reads `scroll`, as the Probe's `scroll` did until #518.
|
|
28
30
|
*/
|
|
29
|
-
export declare const layer: (options?: Options) => Layer.Layer<Probe.Probe>;
|
|
31
|
+
export declare const layer: (options?: Options) => Layer.Layer<Probe.Probe | ScrollSource.ScrollSource>;
|
|
30
32
|
/**
|
|
31
33
|
* A push-based Probe for tests that need to interleave intersection
|
|
32
34
|
* (in-view/out-of-view) transitions with other effects on their own schedule —
|
|
@@ -39,8 +41,8 @@ export declare const layer: (options?: Options) => Layer.Layer<Probe.Probe>;
|
|
|
39
41
|
* measure/viewport/prefersReducedMotion/observeResize behave as in {@link layer}.
|
|
40
42
|
*/
|
|
41
43
|
export declare const pushable: (options?: Options) => Effect.Effect<{
|
|
42
|
-
readonly layer: Layer.Layer<Probe.Probe>;
|
|
44
|
+
readonly layer: Layer.Layer<Probe.Probe | ScrollSource.ScrollSource>;
|
|
43
45
|
readonly pushIntersection: (inView: boolean) => Effect.Effect<void>;
|
|
44
|
-
readonly pushScroll: (scroll:
|
|
46
|
+
readonly pushScroll: (scroll: ScrollSource.Scroll) => Effect.Effect<void, never, AtomRegistry.AtomRegistry>;
|
|
45
47
|
}>;
|
|
46
48
|
//# sourceMappingURL=probe.d.ts.map
|
package/dist/probe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM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,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACnE,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAAA;CAC5G,CAUG,CAAA"}
|
package/dist/probe.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as Probe from "@wardic/core/Probe";
|
|
2
|
+
import * as ScrollSource from "@wardic/core/ScrollSource";
|
|
2
3
|
import * as Arr from "effect/Array";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Layer from "effect/Layer";
|
|
5
6
|
import * as Stream from "effect/Stream";
|
|
6
|
-
import
|
|
7
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
8
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
7
9
|
import * as Feeds from "./feeds.js";
|
|
8
10
|
const ZERO_BOUNDS = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 };
|
|
9
11
|
const VIEWPORT = { width: 1024, height: 768 };
|
|
@@ -14,27 +16,26 @@ const toIntersection = (intersecting) => ({ intersecting });
|
|
|
14
16
|
/**
|
|
15
17
|
* A static Probe: fixed bounds/viewport. `observeIntersection` replays the
|
|
16
18
|
* optional `intersection` script to each subscriber (empty by default, so it
|
|
17
|
-
* emits nothing); `observeResize` stays empty.
|
|
19
|
+
* emits nothing); `observeResize` stays empty. With it, a `ScrollSource`
|
|
20
|
+
* whose every container reads `scroll`, as the Probe's `scroll` did until #518.
|
|
18
21
|
*/
|
|
19
22
|
export const layer = (options = {}) => {
|
|
20
23
|
const { intersection = [], scroll = STILL_SCROLL } = options;
|
|
21
|
-
return Layer.succeed(Probe.Probe, {
|
|
22
|
-
...fixed(options
|
|
24
|
+
return Layer.mergeAll(Layer.succeed(Probe.Probe, {
|
|
25
|
+
...fixed(options),
|
|
23
26
|
observeIntersection: () => Feeds.script(Arr.map(intersection, toIntersection)),
|
|
24
|
-
});
|
|
27
|
+
}), scrollLayer(Atom.make(scroll)));
|
|
25
28
|
};
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
* and one scroll Atom for every container, target and offset (#234).
|
|
29
|
-
*/
|
|
30
|
-
const fixed = ({ bounds = ZERO_BOUNDS, viewport = VIEWPORT, prefersReducedMotion = false, pageVisible = true }, scroll) => ({
|
|
29
|
+
/** Both Probes' fixed part: the bounds, the viewport, the preference and the page's visibility, each defaulted, and no resizes. */
|
|
30
|
+
const fixed = ({ bounds = ZERO_BOUNDS, viewport = VIEWPORT, prefersReducedMotion = false, visible = true }) => ({
|
|
31
31
|
measure: () => Effect.sync(() => bounds),
|
|
32
32
|
viewport: Atom.make(viewport),
|
|
33
33
|
prefersReducedMotion: Atom.make(prefersReducedMotion),
|
|
34
|
-
|
|
35
|
-
scroll: () => Effect.succeed(scroll),
|
|
34
|
+
visible: Atom.make(visible),
|
|
36
35
|
observeResize: () => Stream.empty,
|
|
37
36
|
});
|
|
37
|
+
/** One scroll Atom for every container, target and offset (#234). */
|
|
38
|
+
const scrollLayer = (scroll) => Layer.succeed(ScrollSource.ScrollSource, { scroll: () => Effect.succeed(scroll) });
|
|
38
39
|
/**
|
|
39
40
|
* A push-based Probe for tests that need to interleave intersection
|
|
40
41
|
* (in-view/out-of-view) transitions with other effects on their own schedule —
|
|
@@ -52,7 +53,7 @@ export const pushable = (options = {}) => Effect.sync(() => {
|
|
|
52
53
|
const { scroll = STILL_SCROLL } = options;
|
|
53
54
|
const scrollAtom = Atom.make(scroll);
|
|
54
55
|
return {
|
|
55
|
-
layer: Layer.succeed(Probe.Probe, { ...fixed(options
|
|
56
|
+
layer: Layer.mergeAll(Layer.succeed(Probe.Probe, { ...fixed(options), observeIntersection: () => intersections.feed }), scrollLayer(scrollAtom)),
|
|
56
57
|
pushIntersection: (inView) => intersections.push(toIntersection(inView)),
|
|
57
58
|
pushScroll: (next) => AtomRegistry.AtomRegistry.use((registry) => Effect.sync(() => registry.set(scrollAtom, next))),
|
|
58
59
|
};
|
package/dist/probe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,YAAY,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAA;AAC9C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,MAAM,WAAW,GAAiB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;AAC3G,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;AAC7C,mGAAmG;AACnG,MAAM,YA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AC1I,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wardic/test",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.10",
|
|
4
4
|
"description": "Headless testing Layers for Wardic: a clock that replays the frames you give it, a renderer that records what it's asked to draw, and input you push, so animation code runs without a browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animation",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typecheck:tests": "../../node_modules/typescript-7/bin/tsc -p tsconfig.test.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wardic/core": "1.0.0-rc.
|
|
51
|
+
"@wardic/core": "1.0.0-rc.10"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"effect": "^4.1.1"
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* under the test runner's fake timers, as https://wardic.dev/guides/testing shows.
|
|
9
9
|
*/
|
|
10
10
|
// The testing guide: #558.
|
|
11
|
-
export const VERSION = "
|
|
11
|
+
export const VERSION = "1.0.0-rc.10"
|
|
12
12
|
|
|
13
13
|
export * as TestClock from "./clock.ts"
|
|
14
14
|
export * as TestRenderer from "./renderer.ts"
|
package/src/input.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as InputFeed from "@wardic/core/InputFeed"
|
|
1
2
|
import * as InputSource from "@wardic/core/InputSource"
|
|
2
3
|
import * as Bool from "effect/Boolean"
|
|
3
4
|
import * as Effect from "effect/Effect"
|
|
@@ -66,18 +67,27 @@ export const layer = (
|
|
|
66
67
|
* `options.focusWithin` is the source's `focusWithin`, for a test of a **Keyboard press** that
|
|
67
68
|
* holds its keys only while focus is within its target. Without it the source says nothing of focus,
|
|
68
69
|
* and a press hears every key pushed.
|
|
70
|
+
*
|
|
71
|
+
* `pushTo(target, event)` and `pushFocusTo(target, event)` feed `pointerAmong` and `focusAmong`, the feeds
|
|
72
|
+
* over many targets: each subscriber hears the event with the target its `memberOf` names `target`, or
|
|
73
|
+
* nothing when it names none. `push` and `pushFocus` reach neither, nor these the per-target feeds.
|
|
69
74
|
*/
|
|
70
|
-
// The hub: #318. No yield: ADR-0032. Keys: #427. adoptPointer: #431. focusWithin: #460.
|
|
75
|
+
// The hub: #318. No yield: ADR-0032. Keys: #427. adoptPointer: #431. focusWithin: #460. The feeds over
|
|
76
|
+
// many targets: #665's PR 5.
|
|
71
77
|
export const pushable = (options?: { readonly focusWithin?: ((target: unknown) => boolean) | undefined }): Effect.Effect<{
|
|
72
78
|
readonly layer: Layer.Layer<InputSource.InputSource>
|
|
73
79
|
readonly push: (event: InputSource.PointerLikeEvent) => Effect.Effect<void>
|
|
74
80
|
readonly pushFocus: (event: InputSource.FocusLikeEvent) => Effect.Effect<void>
|
|
75
81
|
readonly pushKey: (event: InputSource.KeyboardLikeEvent) => Effect.Effect<void>
|
|
82
|
+
readonly pushTo: (target: unknown, event: InputSource.PointerLikeEvent) => Effect.Effect<void>
|
|
83
|
+
readonly pushFocusTo: (target: unknown, event: InputSource.FocusLikeEvent) => Effect.Effect<void>
|
|
76
84
|
}> =>
|
|
77
85
|
Effect.sync(() => {
|
|
78
86
|
const pointer = Feeds.hub<InputSource.PointerLikeEvent>()
|
|
79
87
|
const focus = Feeds.hub<InputSource.FocusLikeEvent>()
|
|
80
88
|
const keys = Feeds.hub<InputSource.KeyboardLikeEvent>()
|
|
89
|
+
const pointerAmong = Feeds.hub<InputSource.TargetEvent<InputSource.PointerLikeEvent>>()
|
|
90
|
+
const focusAmong = Feeds.hub<InputSource.TargetEvent<InputSource.FocusLikeEvent>>()
|
|
81
91
|
return {
|
|
82
92
|
layer: Layer.succeed(InputSource.InputSource, {
|
|
83
93
|
pointer: () => pointer.feed,
|
|
@@ -92,13 +102,29 @@ export const pushable = (options?: { readonly focusWithin?: ((target: unknown) =
|
|
|
92
102
|
}
|
|
93
103
|
return Option.none()
|
|
94
104
|
},
|
|
105
|
+
pointerAmong: among(pointerAmong),
|
|
106
|
+
focusAmong: among(focusAmong),
|
|
95
107
|
}),
|
|
96
108
|
push: pointer.push,
|
|
97
109
|
pushFocus: focus.push,
|
|
98
110
|
pushKey: keys.push,
|
|
111
|
+
pushTo: (target, event) => pointerAmong.push({ target, event }),
|
|
112
|
+
pushFocusTo: (target, event) => focusAmong.push({ target, event }),
|
|
99
113
|
}
|
|
100
114
|
})
|
|
101
115
|
|
|
116
|
+
/**
|
|
117
|
+
* A feed over many targets on `hub`, for a subscriber's `memberOf`: each pushed event with the target
|
|
118
|
+
* `memberOf` names its pushed one, none when it names none.
|
|
119
|
+
*/
|
|
120
|
+
const among =
|
|
121
|
+
<A>(hub: Feeds.Hub<InputSource.TargetEvent<A>>) =>
|
|
122
|
+
(memberOf: (node: unknown) => Option.Option<unknown>): InputFeed.InputFeed<InputSource.TargetEvent<A>> =>
|
|
123
|
+
(emit, end) =>
|
|
124
|
+
hub.feed((pushed) => {
|
|
125
|
+
Option.map(memberOf(pushed.target), (target) => emit({ target, event: pushed.event }))
|
|
126
|
+
}, end)
|
|
127
|
+
|
|
102
128
|
/** Whether `raw` is a pointer event with a button pressed: one the pushable InputSource adopts (#431). */
|
|
103
129
|
const isPressedPointer = (raw: unknown): raw is InputSource.PointerLikeEvent =>
|
|
104
130
|
Bool.and(Predicate.hasProperty(raw, "pointerId"), Predicate.hasProperty(raw, "pressed")) && (raw as InputSource.PointerLikeEvent).pressed
|
package/src/layer.ts
CHANGED
|
@@ -10,9 +10,10 @@ import type * as Probe from "@wardic/core/Probe"
|
|
|
10
10
|
import * as ReducedMotion from "@wardic/core/ReducedMotion"
|
|
11
11
|
import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource"
|
|
12
12
|
import type * as Renderer from "@wardic/core/Renderer"
|
|
13
|
+
import type * as ScrollSource from "@wardic/core/ScrollSource"
|
|
13
14
|
import { constUndefined, constVoid } from "effect/Function"
|
|
14
15
|
import * as Layer from "effect/Layer"
|
|
15
|
-
import
|
|
16
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry"
|
|
16
17
|
import * as TestClock from "./clock.ts"
|
|
17
18
|
import * as TestInput from "./input.ts"
|
|
18
19
|
import * as TestProbe from "./probe.ts"
|
|
@@ -27,8 +28,8 @@ const stillFrames: RefreshFrameSource.Shape = { requestFrame: constUndefined, ca
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* The full headless environment: deterministic Clock (driven by `frames`), a Refresh frame
|
|
30
|
-
* source that never calls back, recording Renderer, static Probe
|
|
31
|
-
* interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
31
|
+
* source that never calls back, recording Renderer, static Probe and ScrollSource, silent
|
|
32
|
+
* InputSource, core's real interpolator registry, a fresh AtomRegistry for reading Probe atoms
|
|
32
33
|
* (`viewport`, `prefersReducedMotion`), and a fresh Drag activity, so one test's
|
|
33
34
|
* drag never blocks another's hover or press, and core's Frame loop over that
|
|
34
35
|
* Clock. Provide this in place of `DomLive` to test animation code without a
|
|
@@ -45,6 +46,7 @@ export const testLayer = (
|
|
|
45
46
|
| FrameLoop.FrameLoop
|
|
46
47
|
| Renderer.Renderer
|
|
47
48
|
| Probe.Probe
|
|
49
|
+
| ScrollSource.ScrollSource
|
|
48
50
|
| InputSource.InputSource
|
|
49
51
|
| InterpolatorRegistry.InterpolatorRegistry
|
|
50
52
|
| ReducedMotion.PositionalKeys
|
package/src/probe.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import * as Probe from "@wardic/core/Probe"
|
|
2
|
+
import * as ScrollSource from "@wardic/core/ScrollSource"
|
|
2
3
|
import * as Arr from "effect/Array"
|
|
3
4
|
import * as Effect from "effect/Effect"
|
|
4
5
|
import * as Layer from "effect/Layer"
|
|
5
6
|
import * as Stream from "effect/Stream"
|
|
6
|
-
import
|
|
7
|
+
import * as Atom from "effect/reactivity/Atom"
|
|
8
|
+
import * as AtomRegistry from "effect/reactivity/AtomRegistry"
|
|
7
9
|
import * as Feeds from "./feeds.ts"
|
|
8
10
|
|
|
9
11
|
const ZERO_BOUNDS: Probe.Bounds = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 }
|
|
10
12
|
const VIEWPORT = { width: 1024, height: 768 }
|
|
11
13
|
/** A page that doesn't scroll: no range, and progress 1, as Motion reads a container with none. */
|
|
12
|
-
const STILL_SCROLL:
|
|
14
|
+
const STILL_SCROLL: ScrollSource.Scroll = { x: { current: 0, length: 0, progress: 1 }, y: { current: 0, length: 0, progress: 1 } }
|
|
13
15
|
|
|
14
16
|
/** A scripted in-view boolean as the Probe reports it, with no platform record. */
|
|
15
17
|
const toIntersection = (intersecting: boolean): Probe.Intersection => ({ intersecting })
|
|
16
18
|
|
|
17
19
|
/** Options for the static test Probe. */
|
|
18
|
-
//
|
|
20
|
+
// visible: #443 (`pageVisible` until #610). scroll: #234, a `ScrollSource` of its own since #518.
|
|
21
|
+
// intersection, an Input feed: #318.
|
|
19
22
|
export interface Options {
|
|
20
23
|
readonly bounds?: Probe.Bounds
|
|
21
24
|
readonly viewport?: { readonly width: number; readonly height: number }
|
|
22
25
|
readonly prefersReducedMotion?: boolean
|
|
23
|
-
/** Whether the
|
|
24
|
-
readonly
|
|
25
|
-
/** Every container's scroll, as `
|
|
26
|
-
readonly scroll?:
|
|
26
|
+
/** Whether the Environment is shown: `true` when left out. */
|
|
27
|
+
readonly visible?: boolean
|
|
28
|
+
/** Every container's scroll, as the `ScrollSource` gives it: a page that doesn't scroll when left out. */
|
|
29
|
+
readonly scroll?: ScrollSource.Scroll
|
|
27
30
|
/**
|
|
28
31
|
* Script of intersection (in-view) booleans replayed by `observeIntersection`, an **Input feed**
|
|
29
32
|
* that ends after it. Mirrors the InputSource test harness: omitted (or empty) means it
|
|
@@ -35,29 +38,33 @@ export interface Options {
|
|
|
35
38
|
/**
|
|
36
39
|
* A static Probe: fixed bounds/viewport. `observeIntersection` replays the
|
|
37
40
|
* optional `intersection` script to each subscriber (empty by default, so it
|
|
38
|
-
* emits nothing); `observeResize` stays empty.
|
|
41
|
+
* emits nothing); `observeResize` stays empty. With it, a `ScrollSource`
|
|
42
|
+
* whose every container reads `scroll`, as the Probe's `scroll` did until #518.
|
|
39
43
|
*/
|
|
40
|
-
export const layer = (options: Options = {}): Layer.Layer<Probe.Probe> => {
|
|
44
|
+
export const layer = (options: Options = {}): Layer.Layer<Probe.Probe | ScrollSource.ScrollSource> => {
|
|
41
45
|
const { intersection = [], scroll = STILL_SCROLL } = options
|
|
42
|
-
return Layer.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
return Layer.mergeAll(
|
|
47
|
+
Layer.succeed(Probe.Probe, {
|
|
48
|
+
...fixed(options),
|
|
49
|
+
observeIntersection: () => Feeds.script(Arr.map(intersection, toIntersection)),
|
|
50
|
+
}),
|
|
51
|
+
scrollLayer(Atom.make(scroll)),
|
|
52
|
+
)
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
* and one scroll Atom for every container, target and offset (#234).
|
|
51
|
-
*/
|
|
52
|
-
const fixed = ({ bounds = ZERO_BOUNDS, viewport = VIEWPORT, prefersReducedMotion = false, pageVisible = true }: Options, scroll: Atom.Atom<Probe.Scroll>) => ({
|
|
55
|
+
/** Both Probes' fixed part: the bounds, the viewport, the preference and the page's visibility, each defaulted, and no resizes. */
|
|
56
|
+
const fixed = ({ bounds = ZERO_BOUNDS, viewport = VIEWPORT, prefersReducedMotion = false, visible = true }: Options) => ({
|
|
53
57
|
measure: () => Effect.sync(() => bounds),
|
|
54
58
|
viewport: Atom.make(viewport),
|
|
55
59
|
prefersReducedMotion: Atom.make(prefersReducedMotion),
|
|
56
|
-
|
|
57
|
-
scroll: () => Effect.succeed(scroll),
|
|
60
|
+
visible: Atom.make(visible),
|
|
58
61
|
observeResize: () => Stream.empty,
|
|
59
62
|
})
|
|
60
63
|
|
|
64
|
+
/** One scroll Atom for every container, target and offset (#234). */
|
|
65
|
+
const scrollLayer = (scroll: Atom.Atom<ScrollSource.Scroll>): Layer.Layer<ScrollSource.ScrollSource> =>
|
|
66
|
+
Layer.succeed(ScrollSource.ScrollSource, { scroll: () => Effect.succeed(scroll) })
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* A push-based Probe for tests that need to interleave intersection
|
|
63
70
|
* (in-view/out-of-view) transitions with other effects on their own schedule —
|
|
@@ -71,17 +78,17 @@ const fixed = ({ bounds = ZERO_BOUNDS, viewport = VIEWPORT, prefersReducedMotion
|
|
|
71
78
|
*/
|
|
72
79
|
// The hub: #318. No yield: ADR-0032. Scroll: #234.
|
|
73
80
|
export const pushable = (options: Options = {}): Effect.Effect<{
|
|
74
|
-
readonly layer: Layer.Layer<Probe.Probe>
|
|
81
|
+
readonly layer: Layer.Layer<Probe.Probe | ScrollSource.ScrollSource>
|
|
75
82
|
readonly pushIntersection: (inView: boolean) => Effect.Effect<void>
|
|
76
|
-
readonly pushScroll: (scroll:
|
|
83
|
+
readonly pushScroll: (scroll: ScrollSource.Scroll) => Effect.Effect<void, never, AtomRegistry.AtomRegistry>
|
|
77
84
|
}> =>
|
|
78
85
|
Effect.sync(() => {
|
|
79
86
|
const intersections = Feeds.hub<Probe.Intersection>()
|
|
80
87
|
const { scroll = STILL_SCROLL } = options
|
|
81
88
|
const scrollAtom = Atom.make(scroll)
|
|
82
89
|
return {
|
|
83
|
-
layer: Layer.succeed(Probe.Probe, { ...fixed(options
|
|
90
|
+
layer: Layer.mergeAll(Layer.succeed(Probe.Probe, { ...fixed(options), observeIntersection: () => intersections.feed }), scrollLayer(scrollAtom)),
|
|
84
91
|
pushIntersection: (inView: boolean) => intersections.push(toIntersection(inView)),
|
|
85
|
-
pushScroll: (next:
|
|
92
|
+
pushScroll: (next: ScrollSource.Scroll) => AtomRegistry.AtomRegistry.use((registry) => Effect.sync(() => registry.set(scrollAtom, next))),
|
|
86
93
|
}
|
|
87
94
|
})
|