@wardic/test 1.0.0-rc.9 → 1.0.1
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/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/input.ts +27 -1
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 = "1.0.
|
|
10
|
+
export declare const VERSION = "1.0.1";
|
|
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,UAAU,CAAA;AAE9B,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 = "1.0.
|
|
11
|
+
export const VERSION = "1.0.1";
|
|
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,OAAO,CAAA;AAE9B,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":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wardic/test",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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,9 +48,9 @@
|
|
|
48
48
|
"typecheck:tests": "../../node_modules/typescript-7/bin/tsc -p tsconfig.test.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@wardic/core": "1.0.
|
|
51
|
+
"@wardic/core": "1.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"effect": "^4.1.
|
|
54
|
+
"effect": "^4.1.4"
|
|
55
55
|
}
|
|
56
56
|
}
|
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 = "1.0.
|
|
11
|
+
export const VERSION = "1.0.1"
|
|
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
|