@shivaedev/test-story 0.26.3 → 0.28.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/CHANGELOG.md +22 -0
- package/README.md +19 -3
- package/dist/server/browserReads.d.ts +21 -1
- package/dist/server/browserReads.d.ts.map +1 -1
- package/dist/server/browserReads.js +13 -45
- package/dist/server/browserReads.js.map +1 -1
- package/dist/server/internal/browserReadObserver.d.ts +73 -0
- package/dist/server/internal/browserReadObserver.d.ts.map +1 -0
- package/dist/server/internal/browserReadObserver.js +68 -0
- package/dist/server/internal/browserReadObserver.js.map +1 -0
- package/dist/server/internal/browserSubscriptions.d.ts +18 -0
- package/dist/server/internal/browserSubscriptions.d.ts.map +1 -0
- package/dist/server/internal/browserSubscriptions.js +39 -0
- package/dist/server/internal/browserSubscriptions.js.map +1 -0
- package/dist/server/internal/screenActivity.d.ts +5 -0
- package/dist/server/internal/screenActivity.d.ts.map +1 -0
- package/dist/server/internal/screenActivity.js +10 -0
- package/dist/server/internal/screenActivity.js.map +1 -0
- package/dist/server/internal/screenReadouts.d.ts +10 -0
- package/dist/server/internal/screenReadouts.d.ts.map +1 -0
- package/dist/server/internal/screenReadouts.js +27 -0
- package/dist/server/internal/screenReadouts.js.map +1 -0
- package/dist/server/screenDriver.d.ts +17 -5
- package/dist/server/screenDriver.d.ts.map +1 -1
- package/dist/server/screenDriver.js +28 -22
- package/dist/server/screenDriver.js.map +1 -1
- package/dist/server/storyKit.d.ts +1 -0
- package/dist/server/storyKit.d.ts.map +1 -1
- package/dist/server/storyKit.js.map +1 -1
- package/package.json +3 -3
- package/src/server/browserReads.ts +21 -56
- package/src/server/internal/browserReadObserver.ts +70 -0
- package/src/server/internal/browserSubscriptions.ts +43 -0
- package/src/server/internal/screenActivity.ts +15 -0
- package/src/server/internal/screenReadouts.ts +28 -0
- package/src/server/screenDriver.ts +43 -25
- package/src/server/storyKit.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.28.0 - 2026-10-31
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Contract clients expose `clientActivity(client)`, a native Effect `Stream` with a `current` Effect reporting finite RPC calls, queued live invalidations, refreshing query atoms and received live hints.
|
|
8
|
+
- Screen drivers accept that activity as `pending`, wait for idle activity with their renderer before screen assertions, and expose `nextLiveHint()` for the next client delivery. Stories keep live coalescing enabled.
|
|
9
|
+
|
|
10
|
+
## 0.27.0 - 2026-10-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Browser readouts expose each subscription opening's state and an Effect that waits for all openings to receive a first response or a tagged refusal, without polling.
|
|
15
|
+
- Contract clients accept a session identity protocol factory so custom transports can follow sign-in and sign-out.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Story kits with unmet creation service requirements report the missing service in TypeScript errors instead of an unrelated composition property error.
|
|
20
|
+
|
|
21
|
+
### Breaking
|
|
22
|
+
|
|
23
|
+
- `browserReads().protocol` is now a session identity protocol factory. Continue passing it directly to `makeClient`; native Layer consumers must call `observed.protocol(undefined)` for an anonymous client, or pass the session identity. The same readout counts traffic across session sockets.
|
|
24
|
+
|
|
3
25
|
## 0.26.3 - 2026-10-30
|
|
4
26
|
|
|
5
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -717,7 +717,7 @@ pnpm add --save-dev react react-dom @effect/atom-react @types/react @types/react
|
|
|
717
717
|
|
|
718
718
|
### Driving a screen
|
|
719
719
|
|
|
720
|
-
`screenDriver(options)` supplies DOM verbs and readouts for a kit's `verbs` hook. Give it the mounted `root` (or a getter for a root that navigation replaces) and the story's `tell`. The `pending` option is
|
|
720
|
+
`screenDriver(options)` supplies DOM verbs and readouts for a kit's `verbs` hook. Give it the mounted `root` (or a getter for a root that navigation replaces) and the story's `tell`. The `pending` option is required for `settle()`; `nextLiveHint()` requires client activity in that option. DOM actions, lookups and synchronous readouts work without it. Without `pending`, `settle()` fails immediately in its error channel with `MissingScreenPending`, exported from `server/screenDriver.ts`, even when the screen is idle.
|
|
721
721
|
|
|
722
722
|
To use `settle()`, supply a `pending()` function that reads the application's own request or atom state. Settlement then keeps its `Effect<void>` type with no typed errors and waits until that signal is false; repeated identical renders never count as completion. The application must keep the signal true until its resulting screen work is ready to render.
|
|
723
723
|
|
|
@@ -732,6 +732,20 @@ verbs: ({ view, requests }, story) =>
|
|
|
732
732
|
});
|
|
733
733
|
```
|
|
734
734
|
|
|
735
|
+
For a real contract client, use its activity instead of maintaining request counters or reading loading markup:
|
|
736
|
+
|
|
737
|
+
```ts
|
|
738
|
+
import { clientActivity } from "@shivaedev/contract/clientActivity.ts";
|
|
739
|
+
import { screenDriver } from "@shivaedev/test-story/server/screenDriver.ts";
|
|
740
|
+
|
|
741
|
+
const screen = screenDriver({ act, pending: clientActivity(client), root, tell });
|
|
742
|
+
yield* screen.click({ role: "button", name: "Save" });
|
|
743
|
+
yield* screen.settle();
|
|
744
|
+
expect(screen.text("output")).toBe("Saved title");
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
This form of `settle()` observes client activity changes and flushes the renderer before returning. Finite RPC calls, coalesced invalidations and refreshing query atoms all keep it waiting; subscription streams themselves do not. With client activity, `find()` settles before looking up its target once. Keep live coalescing enabled. `nextLiveHint()` waits for the next subscription update received after the verb starts, including initial or resync updates; it does not wait for a refresh. Start the wait before another viewer writes, then settle before reading the resulting screen. It needs client activity; a callback-only driver fails with `MissingClientActivity`.
|
|
748
|
+
|
|
735
749
|
`click(selector)`, `enter(selector, value)` and `submit(selector = "form")` return Effects. Selectors identify exactly one descendant of the root; missing or ambiguous controls fail. Hidden targets and targets inside hidden ancestors refuse actions and readouts. Text entry focuses an input or textarea and dispatches input and change events. Disabled controls refuse clicks and entry, inert ancestors also prevent form submission, and read-only fields refuse entry. Actions do not wait for settlement, so a story can release a held request before calling `settle()`.
|
|
736
750
|
|
|
737
751
|
`within(container)` returns the same driver scoped to that container, including nested `within` calls. Pass a selector, a role/name target or an `HTMLElement`. Selector and role containers must resolve to one rendered descendant and use the usual missing or ambiguous target diagnostics. For example, `within({ role: "region", name: "Billing" }).click({ role: "button", name: "Save" })` can address a Save button when Delivery has an identical button. Settlement keeps the original pending signal and error type.
|
|
@@ -752,7 +766,7 @@ Settlement has a live-time limit of 3 seconds, configurable with the driver's `t
|
|
|
752
766
|
|
|
753
767
|
### Counting a page's live reads
|
|
754
768
|
|
|
755
|
-
Acquire `browserReads` from `server/browserReads.ts` in the browser story kit's `create` hook. Give it the page's RPC URL and contracts, then pass its `protocol` to each `makeClient` used by that page. Those clients share one native WebSocket transport. In Node stories, pass `layerWebSocketConstructorWS` from `@effect/platform-node/NodeSocket`; the default uses the global browser constructor. Optional `headers` travel on the socket handshake.
|
|
769
|
+
Acquire `browserReads` from `server/browserReads.ts` in the browser story kit's `create` hook. Give it the page's RPC URL and contracts, then pass its `protocol` to each `makeClient` used by that page. Those clients share one native WebSocket transport per session identity. When the page signs in or out and updates the client's live identity, the client opens a socket for that session, and the same readout keeps counting across both sockets. `protocol` is a session identity factory; pass it directly to `makeClient`, or call `observed.protocol(identity)` when building a native Layer yourself. In Node stories, pass `layerWebSocketConstructorWS` from `@effect/platform-node/NodeSocket`; the default uses the global browser constructor. Optional `headers` travel on the socket handshake.
|
|
756
770
|
|
|
757
771
|
```ts
|
|
758
772
|
const observed = yield* browserReads({ contracts: [Notes], url });
|
|
@@ -761,6 +775,8 @@ const client = makeClient(Notes, { protocol: observed.protocol, url });
|
|
|
761
775
|
|
|
762
776
|
Expose `observed.readCount`, `observed.reads`, `observed.hints` and `observed.watchHints` through the kit's verbs. `readCount()` counts query requests and `$changes` subscription openings; `readCount("notes.list")` selects one tag. `reads()` returns their `tag`, encoded `payload` and `kind` (`"query"` or `"subscription"`), in send order. Commands and protocol acknowledgements do not count. `hints()` returns the `LiveHint` values received for those subscriptions, including `Resync`.
|
|
763
777
|
|
|
778
|
+
`observed.subscriptions()` returns each opening's `tag`, encoded `payload` and `state`: `"open"`, `"answered"` after its first streamed value, or `"refused"` with `refusalTag` from its failure Exit. A refusal is not a hint. Expose `observed.waitForSubscriptions` through the kit and `yield* waitForSubscriptions` after the page has opened its subscriptions. It waits on response signals until every opening has answered or been refused. It has no polling budget and resolves immediately when no opening is pending. It does not wait for future navigation to open subscriptions or for React to render.
|
|
779
|
+
|
|
764
780
|
A story calls `const hints = yield* watchHints()` before the write, then `yield* hints.next` to await its browser delivery. Each watcher buffers its own future deliveries until the calling Scope closes. The wait uses the transport's signal with no polling budget. A hint means the browser received it; wait on the application's query or screen signal separately before asserting its rendered result or refetch count. Give another page its own readout to keep its traffic separate.
|
|
765
781
|
|
|
766
782
|
### API by module
|
|
@@ -771,7 +787,7 @@ Import each module with the prefix `@shivaedev/test-story/`; there is no root en
|
|
|
771
787
|
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
772
788
|
| `server/storyKit.ts` | `storyKit`, `Trait`, `RunUntilOptions`, `Story`, `RunHooks`, `StoryKitDefinition`, `Told`, `StoryBody`, `StoryTest`, `StoryIt`, `StoryKit` |
|
|
773
789
|
| `server/outcomes.ts` | `outcomes(rows)` |
|
|
774
|
-
| `server/browserReads.ts` | `browserReads(options)`, `BrowserReadsOptions`, `BrowserRead`
|
|
790
|
+
| `server/browserReads.ts` | `browserReads(options)`, `BrowserReadsOptions`, `BrowserRead`, `BrowserSubscription` |
|
|
775
791
|
| `server/domFetch.ts` | `domFetch(baseUrl, target?)` |
|
|
776
792
|
| `server/seedCookies.ts` | `seedCookies(cookies, target?)`, `DomCookie` |
|
|
777
793
|
| `server/routeOutbound.ts` | `routeOutbound(routes)` |
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Effect, Layer } from "effect";
|
|
2
2
|
import { RpcClient } from "effect/rpc";
|
|
3
3
|
import * as Socket from "effect/socket/Socket";
|
|
4
|
+
export type BrowserSubscription = {
|
|
5
|
+
readonly payload: unknown;
|
|
6
|
+
readonly tag: string;
|
|
7
|
+
} & ({
|
|
8
|
+
readonly state: "open" | "answered";
|
|
9
|
+
} | {
|
|
10
|
+
readonly state: "refused";
|
|
11
|
+
readonly refusalTag: string;
|
|
12
|
+
});
|
|
4
13
|
export interface BrowserRead {
|
|
5
14
|
readonly kind: "query" | "subscription";
|
|
6
15
|
readonly payload: unknown;
|
|
@@ -39,9 +48,19 @@ export declare const browserReads: (options: BrowserReadsOptions) => Effect.Effe
|
|
|
39
48
|
} | {
|
|
40
49
|
readonly _tag: "Resync";
|
|
41
50
|
})[];
|
|
42
|
-
protocol: Layer.Layer<RpcClient.Protocol, never, never>;
|
|
43
51
|
readCount: (tag?: string) => number;
|
|
44
52
|
reads: () => BrowserRead[];
|
|
53
|
+
subscriptions: () => ({
|
|
54
|
+
payload: unknown;
|
|
55
|
+
tag: string;
|
|
56
|
+
state: "open" | "answered";
|
|
57
|
+
} | {
|
|
58
|
+
payload: unknown;
|
|
59
|
+
tag: string;
|
|
60
|
+
state: "refused";
|
|
61
|
+
refusalTag: string;
|
|
62
|
+
})[];
|
|
63
|
+
waitForSubscriptions: Effect.Effect<void, never, never>;
|
|
45
64
|
watchHints: () => Effect.Effect<{
|
|
46
65
|
next: Effect.Effect<{
|
|
47
66
|
readonly _tag: "Changed";
|
|
@@ -63,5 +82,6 @@ export declare const browserReads: (options: BrowserReadsOptions) => Effect.Effe
|
|
|
63
82
|
readonly _tag: "Resync";
|
|
64
83
|
}, never, never>;
|
|
65
84
|
}, never, import("effect/Scope").Scope>;
|
|
85
|
+
protocol: (arg: string | undefined) => Layer.Layer<RpcClient.Protocol, never, never>;
|
|
66
86
|
}, never, import("effect/Scope").Scope>;
|
|
67
87
|
//# sourceMappingURL=browserReads.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserReads.d.ts","source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,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;CACzE;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;iBAnBN,OAAO;aACX,MAAM;eACE,MAAM,GAAG,UAAU;;iBAFvB,OAAO;aACX,MAAM;eAC4C,SAAS;oBAAuB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;uCAyBrG,CAAC"}
|
|
@@ -1,51 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
2
3
|
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
3
4
|
import * as Socket from "effect/socket/Socket";
|
|
4
|
-
import {
|
|
5
|
+
import { browserReadObserver } from "#internal/browserReadObserver.ts";
|
|
5
6
|
export const browserReads = Effect.fn("BrowserStory.browserReads")(function* (options) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
yield* Effect.addFinalizer(() => PubSub.shutdown(deliveries));
|
|
12
|
-
const context = yield* Layer.build(RpcClient.layerProtocolSocket().pipe(Layer.provide(Socket.layerWebSocket(options.url.replace(/^http/u, "ws"), { headers: options.headers }).pipe(Layer.provide(options.webSocketConstructor ?? Socket.layerWebSocketConstructorGlobal))), Layer.provide(RpcSerialization.layerNdjson)));
|
|
13
|
-
const underlying = Context.get(context, RpcClient.Protocol);
|
|
14
|
-
const listening = new Set();
|
|
15
|
-
const protocol = Layer.succeed(RpcClient.Protocol, {
|
|
16
|
-
...underlying,
|
|
17
|
-
run: (clientId, receive) => underlying.run(clientId, (message) => Effect.gen(function* () {
|
|
18
|
-
if (message._tag === "Chunk" && listening.has(`${clientId}:${message.requestId}`)) {
|
|
19
|
-
for (const value of message.values) {
|
|
20
|
-
const hint = yield* Schema.decodeUnknownEffect(LiveHint)(value).pipe(Effect.orDie);
|
|
21
|
-
hints.push(hint);
|
|
22
|
-
yield* PubSub.publish(deliveries, hint);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else if (message._tag === "Exit") {
|
|
26
|
-
listening.delete(`${clientId}:${message.requestId}`);
|
|
27
|
-
}
|
|
28
|
-
yield* receive(message);
|
|
29
|
-
})),
|
|
30
|
-
send: (clientId, request, transferables) => Effect.gen(function* () {
|
|
31
|
-
if (request._tag === "Request") {
|
|
32
|
-
if (subscriptions.has(request.tag)) {
|
|
33
|
-
listening.add(`${clientId}:${request.id}`);
|
|
34
|
-
reads.push({ kind: "subscription", payload: request.payload, tag: request.tag });
|
|
35
|
-
}
|
|
36
|
-
else if (queries.has(request.tag)) {
|
|
37
|
-
reads.push({ kind: "query", payload: request.payload, tag: request.tag });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
yield* underlying.send(clientId, request, transferables);
|
|
41
|
-
}),
|
|
7
|
+
const { observeProtocol, ...observed } = yield* browserReadObserver(options.contracts);
|
|
8
|
+
const memoMap = yield* Layer.makeMemoMap;
|
|
9
|
+
const protocol = Atom.family((_identity) => {
|
|
10
|
+
const layer = Layer.effect(RpcClient.Protocol, observeProtocol).pipe(Layer.provide(socketProtocol(options)));
|
|
11
|
+
return Layer.effectContext(Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer, memoMap, scope)));
|
|
42
12
|
});
|
|
43
|
-
return {
|
|
44
|
-
hints: () => [...hints],
|
|
45
|
-
protocol,
|
|
46
|
-
readCount: (tag) => reads.filter((read) => tag === undefined || read.tag === tag).length,
|
|
47
|
-
reads: () => [...reads],
|
|
48
|
-
watchHints: () => Effect.map(PubSub.subscribe(deliveries), (queue) => ({ next: PubSub.take(queue) })),
|
|
49
|
-
};
|
|
13
|
+
return { ...observed, protocol };
|
|
50
14
|
});
|
|
15
|
+
function socketProtocol(options) {
|
|
16
|
+
const socket = Socket.layerWebSocket(options.url.replace(/^http/u, "ws"), { headers: options.headers }).pipe(Layer.provide(options.webSocketConstructor ?? Socket.layerWebSocketConstructorGlobal));
|
|
17
|
+
return RpcClient.layerProtocolSocket().pipe(Layer.provide(socket), Layer.provide(RpcSerialization.layerNdjson));
|
|
18
|
+
}
|
|
51
19
|
//# sourceMappingURL=browserReads.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserReads.js","sourceRoot":"","sources":["../../src/server/browserReads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"browserReads.js","sourceRoot":"","sources":["../../src/server/browserReads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAsBvE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,QAAQ,CAAC,EAAE,OAA4B;IACzG,MAAM,EAAE,eAAe,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,SAA6B,EAAE,EAAE;QAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC7G,OAAO,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACpH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,OAA4B;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAC3G,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,IAAI,MAAM,CAAC,+BAA+B,CAAC,CACrF,CAAC;IACF,OAAO,SAAS,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { RpcClient, type RpcMessage } from "effect/rpc";
|
|
3
|
+
import type { BrowserRead } from "#browserReads.ts";
|
|
4
|
+
export declare const browserReadObserver: (contracts: readonly {
|
|
5
|
+
readonly declaration: {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly queries: readonly {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
}[]) => Effect.Effect<{
|
|
12
|
+
hints: () => ({
|
|
13
|
+
readonly _tag: "Changed";
|
|
14
|
+
readonly keys: readonly ({
|
|
15
|
+
readonly _tag: "Bucket";
|
|
16
|
+
readonly collection: string;
|
|
17
|
+
readonly field: string;
|
|
18
|
+
readonly value: string | number;
|
|
19
|
+
} | {
|
|
20
|
+
readonly _tag: "List";
|
|
21
|
+
readonly collection: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly _tag: "Item";
|
|
24
|
+
readonly collection: string;
|
|
25
|
+
readonly id: string | number;
|
|
26
|
+
})[];
|
|
27
|
+
readonly queryIndexes?: readonly number[] | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
readonly _tag: "Resync";
|
|
30
|
+
})[];
|
|
31
|
+
observeProtocol: Effect.Effect<{
|
|
32
|
+
readonly run: (clientId: number, f: (data: RpcMessage.FromServerEncoded) => Effect.Effect<void>) => Effect.Effect<never>;
|
|
33
|
+
readonly send: (clientId: number, request: RpcMessage.FromClientEncoded, transferables?: ReadonlyArray<globalThis.Transferable>) => Effect.Effect<void, import("effect/rpc/RpcClientError").RpcClientError>;
|
|
34
|
+
readonly supportsAck: boolean;
|
|
35
|
+
readonly supportsTransferables: boolean;
|
|
36
|
+
readonly codecFor: import("effect/rpc/RpcSerialization").CodecFor;
|
|
37
|
+
}, never, RpcClient.Protocol>;
|
|
38
|
+
readCount: (tag?: string) => number;
|
|
39
|
+
reads: () => BrowserRead[];
|
|
40
|
+
subscriptions: () => ({
|
|
41
|
+
payload: unknown;
|
|
42
|
+
tag: string;
|
|
43
|
+
state: "open" | "answered";
|
|
44
|
+
} | {
|
|
45
|
+
payload: unknown;
|
|
46
|
+
tag: string;
|
|
47
|
+
state: "refused";
|
|
48
|
+
refusalTag: string;
|
|
49
|
+
})[];
|
|
50
|
+
waitForSubscriptions: Effect.Effect<void, never, never>;
|
|
51
|
+
watchHints: () => Effect.Effect<{
|
|
52
|
+
next: Effect.Effect<{
|
|
53
|
+
readonly _tag: "Changed";
|
|
54
|
+
readonly keys: readonly ({
|
|
55
|
+
readonly _tag: "Bucket";
|
|
56
|
+
readonly collection: string;
|
|
57
|
+
readonly field: string;
|
|
58
|
+
readonly value: string | number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly _tag: "List";
|
|
61
|
+
readonly collection: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly _tag: "Item";
|
|
64
|
+
readonly collection: string;
|
|
65
|
+
readonly id: string | number;
|
|
66
|
+
})[];
|
|
67
|
+
readonly queryIndexes?: readonly number[] | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
readonly _tag: "Resync";
|
|
70
|
+
}, never, never>;
|
|
71
|
+
}, never, import("effect/Scope").Scope>;
|
|
72
|
+
}, never, import("effect/Scope").Scope>;
|
|
73
|
+
//# sourceMappingURL=browserReadObserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserReadObserver.d.ts","sourceRoot":"","sources":["../../../src/server/internal/browserReadObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,kBAAkB,CAAC;AAGzE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAyDZ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAMxB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Effect, PubSub, Schema } from "effect";
|
|
2
|
+
import { RpcClient } from "effect/rpc";
|
|
3
|
+
import { LiveHint } from "@shivaedev/contract/live.ts";
|
|
4
|
+
import { browserSubscriptions } from "#internal/browserSubscriptions.ts";
|
|
5
|
+
export const browserReadObserver = Effect.fnUntraced(function* (contracts) {
|
|
6
|
+
const queries = new Set(contracts.flatMap(({ declaration }) => declaration.queries.map(({ name }) => `${declaration.name}.${name}`)));
|
|
7
|
+
const subscriptionTags = new Set(contracts.map(({ declaration }) => `${declaration.name}.$changes`));
|
|
8
|
+
const reads = [];
|
|
9
|
+
const hints = [];
|
|
10
|
+
const deliveries = yield* PubSub.unbounded();
|
|
11
|
+
yield* Effect.addFinalizer(() => PubSub.shutdown(deliveries));
|
|
12
|
+
const tracked = yield* browserSubscriptions;
|
|
13
|
+
const receive = Effect.fnUntraced(function* (index, message) {
|
|
14
|
+
if (index === undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
yield* tracked.receive(index, message);
|
|
18
|
+
if (message._tag !== "Chunk") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const value of message.values) {
|
|
22
|
+
if (Schema.is(LiveHint)(value)) {
|
|
23
|
+
hints.push(value);
|
|
24
|
+
yield* PubSub.publish(deliveries, value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
hints: () => [...hints],
|
|
30
|
+
observeProtocol: Effect.gen(function* () {
|
|
31
|
+
const underlying = yield* RpcClient.Protocol;
|
|
32
|
+
const listening = new Map();
|
|
33
|
+
function record(clientId, request) {
|
|
34
|
+
if (subscriptionTags.has(request.tag)) {
|
|
35
|
+
listening.set(`${clientId}:${request.id}`, tracked.open(request.payload, request.tag));
|
|
36
|
+
reads.push({ kind: "subscription", payload: request.payload, tag: request.tag });
|
|
37
|
+
}
|
|
38
|
+
else if (queries.has(request.tag)) {
|
|
39
|
+
reads.push({ kind: "query", payload: request.payload, tag: request.tag });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const observeMessage = Effect.fnUntraced(function* (clientId, message) {
|
|
43
|
+
const key = "requestId" in message ? `${clientId}:${message.requestId}` : undefined;
|
|
44
|
+
yield* receive(key === undefined ? undefined : listening.get(key), message);
|
|
45
|
+
if (message._tag === "Exit") {
|
|
46
|
+
listening.delete(`${clientId}:${message.requestId}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const protocol = {
|
|
50
|
+
...underlying,
|
|
51
|
+
run: (clientId, deliver) => underlying.run(clientId, (message) => observeMessage(clientId, message).pipe(Effect.andThen(() => deliver(message)))),
|
|
52
|
+
send: (clientId, request, transferables) => Effect.gen(function* () {
|
|
53
|
+
if (request._tag === "Request") {
|
|
54
|
+
record(clientId, request);
|
|
55
|
+
}
|
|
56
|
+
yield* underlying.send(clientId, request, transferables);
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
return protocol;
|
|
60
|
+
}),
|
|
61
|
+
readCount: (tag) => reads.filter((read) => tag === undefined || read.tag === tag).length,
|
|
62
|
+
reads: () => [...reads],
|
|
63
|
+
subscriptions: tracked.subscriptions,
|
|
64
|
+
waitForSubscriptions: tracked.waitForSubscriptions,
|
|
65
|
+
watchHints: () => Effect.map(PubSub.subscribe(deliveries), (queue) => ({ next: PubSub.take(queue) })),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=browserReadObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserReadObserver.js","sourceRoot":"","sources":["../../../src/server/internal/browserReadObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAmB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,SAA2C;IAC1G,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtI,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAA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C,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACrG,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { RpcMessage } from "effect/rpc";
|
|
3
|
+
export declare const browserSubscriptions: Effect.Effect<{
|
|
4
|
+
open: (payload: unknown, tag: string) => number;
|
|
5
|
+
receive: (index: number, message: RpcMessage.FromServerEncoded) => Effect.Effect<void, never, never>;
|
|
6
|
+
subscriptions: () => ({
|
|
7
|
+
payload: unknown;
|
|
8
|
+
tag: string;
|
|
9
|
+
state: "open" | "answered";
|
|
10
|
+
} | {
|
|
11
|
+
payload: unknown;
|
|
12
|
+
tag: string;
|
|
13
|
+
state: "refused";
|
|
14
|
+
refusalTag: string;
|
|
15
|
+
})[];
|
|
16
|
+
waitForSubscriptions: Effect.Effect<void, never, never>;
|
|
17
|
+
}, never, never>;
|
|
18
|
+
//# sourceMappingURL=browserSubscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserSubscriptions.d.ts","sourceRoot":"","sources":["../../../src/server/internal/browserSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAa,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,eAAO,MAAM,oBAAoB;oBAaf,OAAO,OAAO,MAAM;qBAInB,MAAM,WAAW,UAAU,CAAC,iBAAiB;;;;;;;;;;;;gBAqB9D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Deferred, Effect, Predicate } from "effect";
|
|
2
|
+
export const browserSubscriptions = Effect.sync(() => {
|
|
3
|
+
const openings = [];
|
|
4
|
+
let changed = Deferred.makeUnsafe();
|
|
5
|
+
function settle(index, state) {
|
|
6
|
+
openings[index] = state;
|
|
7
|
+
const signal = changed;
|
|
8
|
+
changed = Deferred.makeUnsafe();
|
|
9
|
+
return Deferred.succeed(signal, undefined);
|
|
10
|
+
}
|
|
11
|
+
const waitForSubscriptions = Effect.suspend(() => openings.every(({ state }) => state !== "open") ? Effect.void : Deferred.await(changed).pipe(Effect.andThen(waitForSubscriptions)));
|
|
12
|
+
return {
|
|
13
|
+
open: (payload, tag) => {
|
|
14
|
+
openings.push({ payload, state: "open", tag });
|
|
15
|
+
return openings.length - 1;
|
|
16
|
+
},
|
|
17
|
+
receive: (index, message) => {
|
|
18
|
+
const opening = openings[index];
|
|
19
|
+
if (opening === undefined || opening.state !== "open") {
|
|
20
|
+
return Effect.void;
|
|
21
|
+
}
|
|
22
|
+
if (message._tag === "Chunk" && message.values.length > 0) {
|
|
23
|
+
return settle(index, { ...opening, state: "answered" });
|
|
24
|
+
}
|
|
25
|
+
if (message._tag !== "Exit" || message.exit._tag !== "Failure") {
|
|
26
|
+
return Effect.void;
|
|
27
|
+
}
|
|
28
|
+
for (const cause of message.exit.cause) {
|
|
29
|
+
if (cause._tag === "Fail" && Predicate.hasProperty(cause.error, "_tag") && typeof cause.error._tag === "string") {
|
|
30
|
+
return settle(index, { ...opening, refusalTag: cause.error._tag, state: "refused" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return Effect.void;
|
|
34
|
+
},
|
|
35
|
+
subscriptions: () => openings.map((opening) => ({ ...opening })),
|
|
36
|
+
waitForSubscriptions,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=browserSubscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserSubscriptions.js","sourceRoot":"","sources":["../../../src/server/internal/browserSubscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;IACpD,MAAM,QAAQ,GAA0B,E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O,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACzD,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAChE,OAAO,MAAM,CAAC,IAAI,CAAC;YACpB,CAAC;YACD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACxC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACjH,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBACtF,CAAC;YACF,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC;QACpB,CAAC;QACD,aAAa,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QAChE,oBAAoB;KACpB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type ClientActivity } from "@shivaedev/contract/clientActivity.ts";
|
|
3
|
+
export declare function waitForClient(activity: ClientActivity): Effect.Effect<void, never, never>;
|
|
4
|
+
export declare const nextClientHint: (activity: ClientActivity) => Effect.Effect<void, never, never>;
|
|
5
|
+
//# sourceMappingURL=screenActivity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenActivity.d.ts","sourceRoot":"","sources":["../../../src/server/internal/screenActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,uCAAuC,CAAC;AAE1F,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,qCAErD;AAED,eAAO,MAAM,cAAc,iEAOzB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import { isClientIdle } from "@shivaedev/contract/clientActivity.ts";
|
|
3
|
+
export function waitForClient(activity) {
|
|
4
|
+
return activity.pipe(Stream.filter(isClientIdle), Stream.take(1), Stream.runDrain);
|
|
5
|
+
}
|
|
6
|
+
export const nextClientHint = Effect.fnUntraced(function* (activity) {
|
|
7
|
+
const before = (yield* activity.current).liveHints;
|
|
8
|
+
return yield* activity.pipe(Stream.filter((state) => state.liveHints > before), Stream.take(1), Stream.runDrain);
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=screenActivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenActivity.js","sourceRoot":"","sources":["../../../src/server/internal/screenActivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAuB,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAE1F,MAAM,UAAU,aAAa,CAAC,QAAwB;IACrD,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,QAAwB;IAClF,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;IACnD,OAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAC1B,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,EAClD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EACd,MAAM,CAAC,QAAQ,CACf,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScreenTarget } from "#screenDriver.ts";
|
|
2
|
+
export declare function screenReadouts(currentRoot: () => HTMLElement, tell: (line: string) => void): {
|
|
3
|
+
accessible: (selector: string | Element) => {
|
|
4
|
+
name: string;
|
|
5
|
+
role: string | null;
|
|
6
|
+
};
|
|
7
|
+
text: (selector?: ScreenTarget) => string;
|
|
8
|
+
value: (selector: ScreenTarget) => string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=screenReadouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenReadouts.d.ts","sourceRoot":"","sources":["../../../src/server/internal/screenReadouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,WAAW,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;IAGzF,UAAU,aAAa,MAAM,GAAG,OAAO;;;;IASvC,IAAI,cAAc,YAAY;IAK9B,KAAK,aAAa,YAAY;EAM/B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { accessibility, targetName } from "./screenAccessibility.js";
|
|
2
|
+
import { screenElements } from "./screenElements.js";
|
|
3
|
+
export function screenReadouts(currentRoot, tell) {
|
|
4
|
+
const elements = screenElements(currentRoot);
|
|
5
|
+
return {
|
|
6
|
+
accessible: (selector) => {
|
|
7
|
+
if (typeof selector !== "string") {
|
|
8
|
+
return accessibility(selector);
|
|
9
|
+
}
|
|
10
|
+
const element = elements.element(selector);
|
|
11
|
+
const accessible = accessibility(element);
|
|
12
|
+
tell(`read the accessibility of ${selector}: ${JSON.stringify(accessible)}`);
|
|
13
|
+
return accessible;
|
|
14
|
+
},
|
|
15
|
+
text: (selector) => {
|
|
16
|
+
const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
|
|
17
|
+
tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
|
|
18
|
+
return text;
|
|
19
|
+
},
|
|
20
|
+
value: (selector) => {
|
|
21
|
+
const value = elements.input(selector).value;
|
|
22
|
+
tell(`read the value in ${targetName(selector)}: ${JSON.stringify(value)}`);
|
|
23
|
+
return value;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=screenReadouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenReadouts.js","sourceRoot":"","sources":["../../../src/server/internal/screenReadouts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,UAAU,cAAc,CAAC,WAA8B,EAAE,IAA4B;IAC1F,MAAM,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,OAAO;QACN,UAAU,EAAE,CAAC,QAA0B,EAAE,EAAE;YAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAClC,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;YAC1C,IAAI,CAAC,6BAA6B,QAAQ,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAC7E,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,IAAI,EAAE,CAAC,QAAuB,EAAE,EAAE;YACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3H,IAAI,CAAC,QAAQ,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtG,OAAO,IAAI,CAAC;QACb,CAAC;QACD,KAAK,EAAE,CAAC,QAAsB,EAAE,EAAE;YACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;YAC7C,IAAI,CAAC,qBAAqB,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5E,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { type ClientActivity } from "@shivaedev/contract/clientActivity.ts";
|
|
2
3
|
export type ScreenTarget = string | {
|
|
3
4
|
readonly role: string;
|
|
4
5
|
readonly name: string | RegExp;
|
|
5
6
|
};
|
|
6
7
|
export interface ScreenDriverOptions {
|
|
7
8
|
readonly act?: (action: () => Promise<void>) => PromiseLike<void>;
|
|
8
|
-
readonly pending?: () => boolean;
|
|
9
|
+
readonly pending?: (() => boolean) | ClientActivity;
|
|
9
10
|
readonly root: HTMLElement | (() => HTMLElement);
|
|
10
11
|
readonly tell: (line: string) => void;
|
|
11
12
|
readonly timeoutMs?: number;
|
|
@@ -16,12 +17,22 @@ declare const MissingScreenPending_base: new <A extends Record<string, any> = {}
|
|
|
16
17
|
export declare class MissingScreenPending extends MissingScreenPending_base {
|
|
17
18
|
readonly message = "Cannot settle the screen without the pending option.\nhelp: Supply pending: () => boolean that reads the application's pending work and stays true until its resulting screen work is ready to render.";
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
declare const MissingClientActivity_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
21
|
+
readonly _tag: "MissingClientActivity";
|
|
22
|
+
} & Readonly<A>;
|
|
23
|
+
export declare class MissingClientActivity extends MissingClientActivity_base {
|
|
24
|
+
readonly message = "Cannot wait for a live hint without client activity.\nhelp: Supply pending: clientActivity(client) from @shivaedev/contract/clientActivity.ts.";
|
|
25
|
+
}
|
|
26
|
+
export type ScreenDriver<E = never, THintError = MissingClientActivity> = Omit<ReturnType<typeof makeScreenActions>, "settle" | "nextLiveHint"> & {
|
|
27
|
+
nextLiveHint: () => Effect.Effect<void, THintError>;
|
|
20
28
|
settle: (options?: {
|
|
21
29
|
readonly timeoutMs?: number;
|
|
22
30
|
}) => Effect.Effect<void, E>;
|
|
23
|
-
within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E>;
|
|
31
|
+
within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E, THintError>;
|
|
24
32
|
};
|
|
33
|
+
export declare function screenDriver(options: ScreenDriverOptions & {
|
|
34
|
+
readonly pending: ClientActivity;
|
|
35
|
+
}): ScreenDriver<never, never>;
|
|
25
36
|
export declare function screenDriver(options: ScreenDriverOptions & {
|
|
26
37
|
readonly pending: () => boolean;
|
|
27
38
|
}): ScreenDriver;
|
|
@@ -31,17 +42,18 @@ declare function makeScreenActions({ root, pending, tell, act, timeoutMs }: Scre
|
|
|
31
42
|
name: string;
|
|
32
43
|
role: string | null;
|
|
33
44
|
};
|
|
45
|
+
text: (selector?: ScreenTarget) => string;
|
|
46
|
+
value: (selector: ScreenTarget) => string;
|
|
34
47
|
click: (selector: ScreenTarget) => Effect.Effect<void, never, never>;
|
|
35
48
|
enter: (selector: ScreenTarget, value: string) => Effect.Effect<void, never, never>;
|
|
36
49
|
find: (target: ScreenTarget, options?: {
|
|
37
50
|
readonly timeout?: number;
|
|
38
51
|
}) => Effect.Effect<HTMLElement, import("effect/Cause").UnknownError, never>;
|
|
52
|
+
nextLiveHint: () => Effect.Effect<void, never, never> | Effect.Effect<never, MissingClientActivity, never>;
|
|
39
53
|
settle: (options?: {
|
|
40
54
|
readonly timeoutMs?: number;
|
|
41
55
|
}) => Effect.Effect<void, never, never> | Effect.Effect<never, MissingScreenPending, never>;
|
|
42
56
|
submit: (selector?: ScreenTarget) => Effect.Effect<void, never, never>;
|
|
43
|
-
text: (selector?: ScreenTarget) => string;
|
|
44
|
-
value: (selector: ScreenTarget) => string;
|
|
45
57
|
};
|
|
46
58
|
export {};
|
|
47
59
|
//# sourceMappingURL=screenDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenDriver.d.ts","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAY,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"screenDriver.d.ts","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAY,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,uCAAuC,CAAC;AAO1F,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9F,MAAM,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AC9H,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,GAAG,YAAY,CAAC;AAC/G,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;AAiB/F,iBAAS,iBAAiB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAA0B,EAAE,SAAgB,EAAE,EAAE,mBAAmB;;;;;;;sBAqEjG,YAAY;sBAOZ,YAAY,SAAS,MAAM;mBApCxB,YAAY,YAAW;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;;uBA/BjD;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;wBAgFpC,YAAY;EAEhC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { Data, Effect, Schedule } from "effect";
|
|
2
|
+
import { isClientIdle } from "@shivaedev/contract/clientActivity.ts";
|
|
2
3
|
import { withLive } from "@shivaedev/test/withLive.ts";
|
|
3
|
-
import {
|
|
4
|
+
import { targetName } from "#internal/screenAccessibility.ts";
|
|
5
|
+
import { nextClientHint, waitForClient } from "#internal/screenActivity.ts";
|
|
4
6
|
import { screenElements } from "#internal/screenElements.ts";
|
|
7
|
+
import { screenReadouts } from "#internal/screenReadouts.ts";
|
|
5
8
|
export class MissingScreenPending extends Data.TaggedError("MissingScreenPending") {
|
|
6
9
|
message = "Cannot settle the screen without the pending option.\nhelp: Supply pending: () => boolean that reads the application's pending work and stays true until its resulting screen work is ready to render.";
|
|
7
10
|
}
|
|
11
|
+
export class MissingClientActivity extends Data.TaggedError("MissingClientActivity") {
|
|
12
|
+
message = "Cannot wait for a live hint without client activity.\nhelp: Supply pending: clientActivity(client) from @shivaedev/contract/clientActivity.ts.";
|
|
13
|
+
}
|
|
8
14
|
export function screenDriver(options) {
|
|
9
15
|
const suppliedRoot = options.root;
|
|
10
16
|
const root = typeof suppliedRoot === "function" ? suppliedRoot : () => suppliedRoot;
|
|
@@ -33,16 +39,22 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
33
39
|
if (pending === undefined) {
|
|
34
40
|
return Effect.fail(new MissingScreenPending());
|
|
35
41
|
}
|
|
42
|
+
return settleWork(pending, options);
|
|
43
|
+
}
|
|
44
|
+
function settleWork(work, options) {
|
|
36
45
|
const limit = options.timeoutMs ?? timeoutMs;
|
|
46
|
+
const isIdle = typeof work === "function" ? Effect.sync(() => !work()) : Effect.map(work.current, isClientIdle);
|
|
37
47
|
const wait = Effect.gen(function* () {
|
|
38
48
|
tell("wait for the screen's pending work");
|
|
39
49
|
do {
|
|
40
50
|
yield* Effect.promise(() => act(async () => undefined));
|
|
41
|
-
if (
|
|
51
|
+
if (yield* isIdle) {
|
|
42
52
|
tell("the screen has no pending work");
|
|
43
53
|
return;
|
|
44
54
|
}
|
|
45
|
-
yield*
|
|
55
|
+
yield* typeof work === "function"
|
|
56
|
+
? Effect.promise(() => act(() => new Promise((resolve) => setTimeout(resolve, 10))))
|
|
57
|
+
: Effect.promise((signal) => act(() => Effect.runPromise(waitForClient(work), { signal })));
|
|
46
58
|
} while (true);
|
|
47
59
|
});
|
|
48
60
|
function timedOut() {
|
|
@@ -51,6 +63,12 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
51
63
|
return withLive(wait.pipe(Effect.timeoutOrElse({ duration: limit, orElse: timedOut })));
|
|
52
64
|
}
|
|
53
65
|
function find(target, options = {}) {
|
|
66
|
+
if (pending !== undefined && typeof pending !== "function") {
|
|
67
|
+
return settleWork(pending, { timeoutMs: options.timeout ?? timeoutMs }).pipe(Effect.andThen(Effect.sync(() => {
|
|
68
|
+
tell(`find ${targetName(target)}`);
|
|
69
|
+
return elements.element(target);
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
54
72
|
return withLive(Effect.gen(function* () {
|
|
55
73
|
tell(`find ${targetName(target)}`);
|
|
56
74
|
return yield* Effect.tryPromise(async () => {
|
|
@@ -63,15 +81,7 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
63
81
|
}));
|
|
64
82
|
}
|
|
65
83
|
return {
|
|
66
|
-
|
|
67
|
-
if (typeof selector !== "string") {
|
|
68
|
-
return accessibility(selector);
|
|
69
|
-
}
|
|
70
|
-
const element = elements.element(selector);
|
|
71
|
-
const accessible = accessibility(element);
|
|
72
|
-
tell(`read the accessibility of ${selector}: ${JSON.stringify(accessible)}`);
|
|
73
|
-
return accessible;
|
|
74
|
-
},
|
|
84
|
+
...screenReadouts(currentRoot, tell),
|
|
75
85
|
click: (selector) => perform(`click ${targetName(selector)}`, () => {
|
|
76
86
|
const element = elements.element(selector);
|
|
77
87
|
elements.enabled(element, selector);
|
|
@@ -80,18 +90,14 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
80
90
|
}),
|
|
81
91
|
enter: (selector, value) => perform(`enter a value in ${targetName(selector)}`, () => elements.enter(selector, value)),
|
|
82
92
|
find,
|
|
93
|
+
nextLiveHint: () => {
|
|
94
|
+
if (pending === undefined || typeof pending === "function") {
|
|
95
|
+
return Effect.fail(new MissingClientActivity());
|
|
96
|
+
}
|
|
97
|
+
return withLive(Effect.sync(() => tell("wait for the next live hint")).pipe(Effect.andThen(Effect.promise((signal) => act(() => Effect.runPromise(nextClientHint(pending), { signal }))))));
|
|
98
|
+
},
|
|
83
99
|
settle,
|
|
84
100
|
submit: (selector = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
|
|
85
|
-
text: (selector) => {
|
|
86
|
-
const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
|
|
87
|
-
tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
|
|
88
|
-
return text;
|
|
89
|
-
},
|
|
90
|
-
value: (selector) => {
|
|
91
|
-
const value = elements.input(selector).value;
|
|
92
|
-
tell(`read the value in ${targetName(selector)}: ${JSON.stringify(value)}`);
|
|
93
|
-
return value;
|
|
94
|
-
},
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
103
|
//# sourceMappingURL=screenDriver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenDriver.js","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"screenDriver.js","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAuB,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAY7D,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC;IAC/D,OAAO,GACxB,wMAAwM,CAAC;CAC1M;AAED,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC;IACjE,OAAO,GACxB,gJAAgJ,CAAC;CAClJ;AAWD,MAAM,UAAU,YAAY,CAAC,OAA4B;IACxD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAClC,MAAM,IAAI,GAAG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IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC,IAAI,CAC1D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAC7G,CACD,CAAC;QACH,CAAC;QACD,MAAM;QACN,MAAM,EAAE,CAAC,QAAQ,GAAiB,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;KACrI,CAAC;AACH,CAAC"}
|
|
@@ -65,5 +65,6 @@ export interface StoryKit<TEngine, TStage extends string, TVerbs, TRun extends A
|
|
|
65
65
|
}
|
|
66
66
|
export declare function storyKit<TCreate extends () => unknown, const TStage extends string = never, TVerbs extends object = object, TProvided = never, TAfter extends AfterResults<TStage> = Record<never, never>, TStep extends AnyEffect = never, TFailed extends AnyEffect = never, TDiagnose extends AnyEffect = never>(definition: InferredDefinition<TCreate, TStage, TVerbs, TProvided, TAfter, TStep, TFailed, TDiagnose>): StoryKit<HookValue<ReturnType<TCreate>>, TStage, TVerbs, TStep | TFailed | TDiagnose, TProvided>;
|
|
67
67
|
export declare function storyKit<const TKits extends KitList>(definition: Composition<TKits>): ComposedKit<TKits>;
|
|
68
|
+
export declare function storyKit<TCreate extends () => unknown, const TStage extends string = never, TVerbs extends object = object, TProvided = never, TAfter extends AfterResults<TStage> = Record<never, never>, TStep extends AnyEffect = never, TFailed extends AnyEffect = never, TDiagnose extends AnyEffect = never, const TKits extends KitList = KitList>(definition: InferredDefinition<TCreate, TStage, TVerbs, TProvided, TAfter, TStep, TFailed, TDiagnose> | Composition<TKits>): StoryKit<HookValue<ReturnType<TCreate>>, TStage, TVerbs, TStep | TFailed | TDiagnose, TProvided> | ComposedKit<TKits>;
|
|
68
69
|
export {};
|
|
69
70
|
//# sourceMappingURL=storyKit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyKit.d.ts","sourceRoot":"","sources":["../../src/server/storyKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpI,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAU,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxI,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAAE,KAAK,KAAK,EAAiB,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAEnI,KAAK,aAAa,CAAC,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,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AK,EAC/B,OAAO,SAAS,SAAS,GAAG,KAAK,EACjC,SAAS,SAAS,SAAS,GAAG,KAAK,EACnC,KAAK,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO,EAErC,UAAU,EAAE,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GACxH,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,EAAE,SAAS,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyKit.js","sourceRoot":"","sources":["../../src/server/storyKit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAwE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpI,OAAO,EAA4E,MAAM,EAAmB,MAAM,qBAAqB,CAAC;AAGxI,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAc,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"storyKit.js","sourceRoot":"","sources":["../../src/server/storyKit.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAwE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpI,OAAO,EAA4E,MAAM,EAAmB,MAAM,qBAAqB,CAAC;AAGxI,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAc,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA2HhE,MAAM,UAAU,QAAQ,CAAC,KAA6C;IACrE,MAAM,UAAU,GAAG,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnF,OAAO;QACN,CAAC,aAAa,CAAC,EAAE,UAAU;QAC3B,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC;QACvB,KAAK,EAAE,CAAC,KAAa,EAAE,IAAY,EAAE,KAAqD,EAAE,EAAE,CAC7F,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,MAAM;KACN,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/test-story",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Tests that read like stories over the real engine: a story kit per engine with its own it, traits per feature, and a failure that prints the story, where it stopped and the engine's state",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/test-story#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@shivaedev/contract": "0.
|
|
45
|
+
"@shivaedev/contract": "0.27.0",
|
|
46
46
|
"@shivaedev/test": "0.12.0",
|
|
47
47
|
"@shivaedev/test-sql": "0.15.0",
|
|
48
48
|
"dom-accessibility-api": "0.7.1"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@effect/atom-react": "4.0.6",
|
|
52
52
|
"@effect/platform-node": "4.0.6",
|
|
53
53
|
"@effect/vitest": "4.0.6",
|
|
54
|
-
"@shivaedev/quality": "0.48.
|
|
54
|
+
"@shivaedev/quality": "0.48.2",
|
|
55
55
|
"@types/node": "24.19.2",
|
|
56
56
|
"@types/react": "19.3.0",
|
|
57
57
|
"@types/react-dom": "19.3.0",
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import * as Atom from "effect/reactivity/Atom";
|
|
2
3
|
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
3
4
|
import * as Socket from "effect/socket/Socket";
|
|
4
|
-
import {
|
|
5
|
+
import { browserReadObserver } from "#internal/browserReadObserver.ts";
|
|
6
|
+
|
|
7
|
+
export type BrowserSubscription = {
|
|
8
|
+
readonly payload: unknown;
|
|
9
|
+
readonly tag: string;
|
|
10
|
+
} & ({ readonly state: "open" | "answered" } | { readonly state: "refused"; readonly refusalTag: string });
|
|
5
11
|
|
|
6
12
|
export interface BrowserRead {
|
|
7
13
|
readonly kind: "query" | "subscription";
|
|
@@ -19,59 +25,18 @@ export interface BrowserReadsOptions {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export const browserReads = Effect.fn("BrowserStory.browserReads")(function* (options: BrowserReadsOptions) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
yield* Effect.addFinalizer(() => PubSub.shutdown(deliveries));
|
|
28
|
-
const context = yield* Layer.build(
|
|
29
|
-
RpcClient.layerProtocolSocket().pipe(
|
|
30
|
-
Layer.provide(
|
|
31
|
-
Socket.layerWebSocket(options.url.replace(/^http/u, "ws"), { headers: options.headers }).pipe(
|
|
32
|
-
Layer.provide(options.webSocketConstructor ?? Socket.layerWebSocketConstructorGlobal),
|
|
33
|
-
),
|
|
34
|
-
),
|
|
35
|
-
Layer.provide(RpcSerialization.layerNdjson),
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
const underlying = Context.get(context, RpcClient.Protocol);
|
|
39
|
-
const listening = new Set<string>();
|
|
40
|
-
const protocol = Layer.succeed(RpcClient.Protocol, {
|
|
41
|
-
...underlying,
|
|
42
|
-
run: (clientId, receive) =>
|
|
43
|
-
underlying.run(clientId, (message) =>
|
|
44
|
-
Effect.gen(function* () {
|
|
45
|
-
if (message._tag === "Chunk" && listening.has(`${clientId}:${message.requestId}`)) {
|
|
46
|
-
for (const value of message.values) {
|
|
47
|
-
const hint = yield* Schema.decodeUnknownEffect(LiveHint)(value).pipe(Effect.orDie);
|
|
48
|
-
hints.push(hint);
|
|
49
|
-
yield* PubSub.publish(deliveries, hint);
|
|
50
|
-
}
|
|
51
|
-
} else if (message._tag === "Exit") {
|
|
52
|
-
listening.delete(`${clientId}:${message.requestId}`);
|
|
53
|
-
}
|
|
54
|
-
yield* receive(message);
|
|
55
|
-
}),
|
|
56
|
-
),
|
|
57
|
-
send: (clientId, request, transferables) =>
|
|
58
|
-
Effect.gen(function* () {
|
|
59
|
-
if (request._tag === "Request") {
|
|
60
|
-
if (subscriptions.has(request.tag)) {
|
|
61
|
-
listening.add(`${clientId}:${request.id}`);
|
|
62
|
-
reads.push({ kind: "subscription", payload: request.payload, tag: request.tag });
|
|
63
|
-
} else if (queries.has(request.tag)) {
|
|
64
|
-
reads.push({ kind: "query", payload: request.payload, tag: request.tag });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
yield* underlying.send(clientId, request, transferables);
|
|
68
|
-
}),
|
|
28
|
+
const { observeProtocol, ...observed } = yield* browserReadObserver(options.contracts);
|
|
29
|
+
const memoMap = yield* Layer.makeMemoMap;
|
|
30
|
+
const protocol = Atom.family((_identity: string | undefined) => {
|
|
31
|
+
const layer = Layer.effect(RpcClient.Protocol, observeProtocol).pipe(Layer.provide(socketProtocol(options)));
|
|
32
|
+
return Layer.effectContext(Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer, memoMap, scope)));
|
|
69
33
|
});
|
|
70
|
-
return {
|
|
71
|
-
hints: () => [...hints],
|
|
72
|
-
protocol,
|
|
73
|
-
readCount: (tag?: string) => reads.filter((read) => tag === undefined || read.tag === tag).length,
|
|
74
|
-
reads: () => [...reads],
|
|
75
|
-
watchHints: () => Effect.map(PubSub.subscribe(deliveries), (queue) => ({ next: PubSub.take(queue) })),
|
|
76
|
-
};
|
|
34
|
+
return { ...observed, protocol };
|
|
77
35
|
});
|
|
36
|
+
|
|
37
|
+
function socketProtocol(options: BrowserReadsOptions) {
|
|
38
|
+
const socket = Socket.layerWebSocket(options.url.replace(/^http/u, "ws"), { headers: options.headers }).pipe(
|
|
39
|
+
Layer.provide(options.webSocketConstructor ?? Socket.layerWebSocketConstructorGlobal),
|
|
40
|
+
);
|
|
41
|
+
return RpcClient.layerProtocolSocket().pipe(Layer.provide(socket), Layer.provide(RpcSerialization.layerNdjson));
|
|
42
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Effect, PubSub, Schema } from "effect";
|
|
2
|
+
import { RpcClient, type RpcMessage } from "effect/rpc";
|
|
3
|
+
import { LiveHint } from "@shivaedev/contract/live.ts";
|
|
4
|
+
import type { BrowserRead, BrowserReadsOptions } from "#browserReads.ts";
|
|
5
|
+
import { browserSubscriptions } from "#internal/browserSubscriptions.ts";
|
|
6
|
+
|
|
7
|
+
export const browserReadObserver = Effect.fnUntraced(function* (contracts: BrowserReadsOptions["contracts"]) {
|
|
8
|
+
const queries = new Set(contracts.flatMap(({ declaration }) => declaration.queries.map(({ name }) => `${declaration.name}.${name}`)));
|
|
9
|
+
const subscriptionTags = new Set(contracts.map(({ declaration }) => `${declaration.name}.$changes`));
|
|
10
|
+
const reads: BrowserRead[] = [];
|
|
11
|
+
const hints: LiveHint[] = [];
|
|
12
|
+
const deliveries = yield* PubSub.unbounded<LiveHint>();
|
|
13
|
+
yield* Effect.addFinalizer(() => PubSub.shutdown(deliveries));
|
|
14
|
+
const tracked = yield* browserSubscriptions;
|
|
15
|
+
const receive = Effect.fnUntraced(function* (index: number | undefined, message: RpcMessage.FromServerEncoded) {
|
|
16
|
+
if (index === undefined) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
yield* tracked.receive(index, message);
|
|
20
|
+
if (message._tag !== "Chunk") {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const value of message.values) {
|
|
24
|
+
if (Schema.is(LiveHint)(value)) {
|
|
25
|
+
hints.push(value);
|
|
26
|
+
yield* PubSub.publish(deliveries, value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
hints: () => [...hints],
|
|
32
|
+
observeProtocol: Effect.gen(function* () {
|
|
33
|
+
const underlying = yield* RpcClient.Protocol;
|
|
34
|
+
const listening = new Map<string, number>();
|
|
35
|
+
function record(clientId: number, request: RpcMessage.RequestEncoded) {
|
|
36
|
+
if (subscriptionTags.has(request.tag)) {
|
|
37
|
+
listening.set(`${clientId}:${request.id}`, tracked.open(request.payload, request.tag));
|
|
38
|
+
reads.push({ kind: "subscription", payload: request.payload, tag: request.tag });
|
|
39
|
+
} else if (queries.has(request.tag)) {
|
|
40
|
+
reads.push({ kind: "query", payload: request.payload, tag: request.tag });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const observeMessage = Effect.fnUntraced(function* (clientId: number, message: RpcMessage.FromServerEncoded) {
|
|
44
|
+
const key = "requestId" in message ? `${clientId}:${message.requestId}` : undefined;
|
|
45
|
+
yield* receive(key === undefined ? undefined : listening.get(key), message);
|
|
46
|
+
if (message._tag === "Exit") {
|
|
47
|
+
listening.delete(`${clientId}:${message.requestId}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const protocol: RpcClient.Protocol["Service"] = {
|
|
51
|
+
...underlying,
|
|
52
|
+
run: (clientId, deliver) =>
|
|
53
|
+
underlying.run(clientId, (message) => observeMessage(clientId, message).pipe(Effect.andThen(() => deliver(message)))),
|
|
54
|
+
send: (clientId, request, transferables) =>
|
|
55
|
+
Effect.gen(function* () {
|
|
56
|
+
if (request._tag === "Request") {
|
|
57
|
+
record(clientId, request);
|
|
58
|
+
}
|
|
59
|
+
yield* underlying.send(clientId, request, transferables);
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
return protocol;
|
|
63
|
+
}),
|
|
64
|
+
readCount: (tag?: string) => reads.filter((read) => tag === undefined || read.tag === tag).length,
|
|
65
|
+
reads: () => [...reads],
|
|
66
|
+
subscriptions: tracked.subscriptions,
|
|
67
|
+
waitForSubscriptions: tracked.waitForSubscriptions,
|
|
68
|
+
watchHints: () => Effect.map(PubSub.subscribe(deliveries), (queue) => ({ next: PubSub.take(queue) })),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Deferred, Effect, Predicate } from "effect";
|
|
2
|
+
import type { RpcMessage } from "effect/rpc";
|
|
3
|
+
import type { BrowserSubscription } from "#browserReads.ts";
|
|
4
|
+
|
|
5
|
+
export const browserSubscriptions = Effect.sync(() => {
|
|
6
|
+
const openings: BrowserSubscription[] = [];
|
|
7
|
+
let changed = Deferred.makeUnsafe<void>();
|
|
8
|
+
function settle(index: number, state: BrowserSubscription) {
|
|
9
|
+
openings[index] = state;
|
|
10
|
+
const signal = changed;
|
|
11
|
+
changed = Deferred.makeUnsafe<void>();
|
|
12
|
+
return Deferred.succeed(signal, undefined);
|
|
13
|
+
}
|
|
14
|
+
const waitForSubscriptions: Effect.Effect<void> = Effect.suspend(() =>
|
|
15
|
+
openings.every(({ state }) => state !== "open") ? Effect.void : Deferred.await(changed).pipe(Effect.andThen(waitForSubscriptions)),
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
open: (payload: unknown, tag: string) => {
|
|
19
|
+
openings.push({ payload, state: "open", tag });
|
|
20
|
+
return openings.length - 1;
|
|
21
|
+
},
|
|
22
|
+
receive: (index: number, message: RpcMessage.FromServerEncoded) => {
|
|
23
|
+
const opening = openings[index];
|
|
24
|
+
if (opening === undefined || opening.state !== "open") {
|
|
25
|
+
return Effect.void;
|
|
26
|
+
}
|
|
27
|
+
if (message._tag === "Chunk" && message.values.length > 0) {
|
|
28
|
+
return settle(index, { ...opening, state: "answered" });
|
|
29
|
+
}
|
|
30
|
+
if (message._tag !== "Exit" || message.exit._tag !== "Failure") {
|
|
31
|
+
return Effect.void;
|
|
32
|
+
}
|
|
33
|
+
for (const cause of message.exit.cause) {
|
|
34
|
+
if (cause._tag === "Fail" && Predicate.hasProperty(cause.error, "_tag") && typeof cause.error._tag === "string") {
|
|
35
|
+
return settle(index, { ...opening, refusalTag: cause.error._tag, state: "refused" });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Effect.void;
|
|
39
|
+
},
|
|
40
|
+
subscriptions: () => openings.map((opening) => ({ ...opening })),
|
|
41
|
+
waitForSubscriptions,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import { type ClientActivity, isClientIdle } from "@shivaedev/contract/clientActivity.ts";
|
|
3
|
+
|
|
4
|
+
export function waitForClient(activity: ClientActivity) {
|
|
5
|
+
return activity.pipe(Stream.filter(isClientIdle), Stream.take(1), Stream.runDrain);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const nextClientHint = Effect.fnUntraced(function* (activity: ClientActivity) {
|
|
9
|
+
const before = (yield* activity.current).liveHints;
|
|
10
|
+
return yield* activity.pipe(
|
|
11
|
+
Stream.filter((state) => state.liveHints > before),
|
|
12
|
+
Stream.take(1),
|
|
13
|
+
Stream.runDrain,
|
|
14
|
+
);
|
|
15
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ScreenTarget } from "#screenDriver.ts";
|
|
2
|
+
import { accessibility, targetName } from "./screenAccessibility.ts";
|
|
3
|
+
import { screenElements } from "./screenElements.ts";
|
|
4
|
+
|
|
5
|
+
export function screenReadouts(currentRoot: () => HTMLElement, tell: (line: string) => void) {
|
|
6
|
+
const elements = screenElements(currentRoot);
|
|
7
|
+
return {
|
|
8
|
+
accessible: (selector: string | Element) => {
|
|
9
|
+
if (typeof selector !== "string") {
|
|
10
|
+
return accessibility(selector);
|
|
11
|
+
}
|
|
12
|
+
const element = elements.element(selector);
|
|
13
|
+
const accessible = accessibility(element);
|
|
14
|
+
tell(`read the accessibility of ${selector}: ${JSON.stringify(accessible)}`);
|
|
15
|
+
return accessible;
|
|
16
|
+
},
|
|
17
|
+
text: (selector?: ScreenTarget) => {
|
|
18
|
+
const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
|
|
19
|
+
tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
|
|
20
|
+
return text;
|
|
21
|
+
},
|
|
22
|
+
value: (selector: ScreenTarget) => {
|
|
23
|
+
const value = elements.input(selector).value;
|
|
24
|
+
tell(`read the value in ${targetName(selector)}: ${JSON.stringify(value)}`);
|
|
25
|
+
return value;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Data, Effect, Schedule } from "effect";
|
|
2
|
+
import { type ClientActivity, isClientIdle } from "@shivaedev/contract/clientActivity.ts";
|
|
2
3
|
import { withLive } from "@shivaedev/test/withLive.ts";
|
|
3
|
-
import {
|
|
4
|
+
import { targetName } from "#internal/screenAccessibility.ts";
|
|
5
|
+
import { nextClientHint, waitForClient } from "#internal/screenActivity.ts";
|
|
4
6
|
import { screenElements } from "#internal/screenElements.ts";
|
|
7
|
+
import { screenReadouts } from "#internal/screenReadouts.ts";
|
|
5
8
|
|
|
6
9
|
export type ScreenTarget = string | { readonly role: string; readonly name: string | RegExp };
|
|
7
10
|
|
|
8
11
|
export interface ScreenDriverOptions {
|
|
9
12
|
readonly act?: (action: () => Promise<void>) => PromiseLike<void>;
|
|
10
|
-
readonly pending?: () => boolean;
|
|
13
|
+
readonly pending?: (() => boolean) | ClientActivity;
|
|
11
14
|
readonly root: HTMLElement | (() => HTMLElement);
|
|
12
15
|
readonly tell: (line: string) => void;
|
|
13
16
|
readonly timeoutMs?: number;
|
|
@@ -18,11 +21,18 @@ export class MissingScreenPending extends Data.TaggedError("MissingScreenPending
|
|
|
18
21
|
"Cannot settle the screen without the pending option.\nhelp: Supply pending: () => boolean that reads the application's pending work and stays true until its resulting screen work is ready to render.";
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
export
|
|
24
|
+
export class MissingClientActivity extends Data.TaggedError("MissingClientActivity") {
|
|
25
|
+
override readonly message =
|
|
26
|
+
"Cannot wait for a live hint without client activity.\nhelp: Supply pending: clientActivity(client) from @shivaedev/contract/clientActivity.ts.";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ScreenDriver<E = never, THintError = MissingClientActivity> = Omit<ReturnType<typeof makeScreenActions>, "settle" | "nextLiveHint"> & {
|
|
30
|
+
nextLiveHint: () => Effect.Effect<void, THintError>;
|
|
22
31
|
settle: (options?: { readonly timeoutMs?: number }) => Effect.Effect<void, E>;
|
|
23
|
-
within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E>;
|
|
32
|
+
within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E, THintError>;
|
|
24
33
|
};
|
|
25
34
|
|
|
35
|
+
export function screenDriver(options: ScreenDriverOptions & { readonly pending: ClientActivity }): ScreenDriver<never, never>;
|
|
26
36
|
export function screenDriver(options: ScreenDriverOptions & { readonly pending: () => boolean }): ScreenDriver;
|
|
27
37
|
export function screenDriver(options: ScreenDriverOptions): ScreenDriver<MissingScreenPending>;
|
|
28
38
|
export function screenDriver(options: ScreenDriverOptions): ScreenDriver<MissingScreenPending> {
|
|
@@ -54,16 +64,22 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
54
64
|
if (pending === undefined) {
|
|
55
65
|
return Effect.fail(new MissingScreenPending());
|
|
56
66
|
}
|
|
67
|
+
return settleWork(pending, options);
|
|
68
|
+
}
|
|
69
|
+
function settleWork(work: NonNullable<ScreenDriverOptions["pending"]>, options: { readonly timeoutMs?: number }) {
|
|
57
70
|
const limit = options.timeoutMs ?? timeoutMs;
|
|
71
|
+
const isIdle = typeof work === "function" ? Effect.sync(() => !work()) : Effect.map(work.current, isClientIdle);
|
|
58
72
|
const wait = Effect.gen(function* () {
|
|
59
73
|
tell("wait for the screen's pending work");
|
|
60
74
|
do {
|
|
61
75
|
yield* Effect.promise(() => act(async () => undefined));
|
|
62
|
-
if (
|
|
76
|
+
if (yield* isIdle) {
|
|
63
77
|
tell("the screen has no pending work");
|
|
64
78
|
return;
|
|
65
79
|
}
|
|
66
|
-
yield*
|
|
80
|
+
yield* typeof work === "function"
|
|
81
|
+
? Effect.promise(() => act(() => new Promise<void>((resolve) => setTimeout(resolve, 10))))
|
|
82
|
+
: Effect.promise((signal) => act(() => Effect.runPromise(waitForClient(work), { signal })));
|
|
67
83
|
} while (true);
|
|
68
84
|
});
|
|
69
85
|
function timedOut() {
|
|
@@ -76,6 +92,16 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
76
92
|
return withLive(wait.pipe(Effect.timeoutOrElse({ duration: limit, orElse: timedOut })));
|
|
77
93
|
}
|
|
78
94
|
function find(target: ScreenTarget, options: { readonly timeout?: number } = {}) {
|
|
95
|
+
if (pending !== undefined && typeof pending !== "function") {
|
|
96
|
+
return settleWork(pending, { timeoutMs: options.timeout ?? timeoutMs }).pipe(
|
|
97
|
+
Effect.andThen(
|
|
98
|
+
Effect.sync(() => {
|
|
99
|
+
tell(`find ${targetName(target)}`);
|
|
100
|
+
return elements.element(target);
|
|
101
|
+
}),
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
79
105
|
return withLive(
|
|
80
106
|
Effect.gen(function* () {
|
|
81
107
|
tell(`find ${targetName(target)}`);
|
|
@@ -93,15 +119,7 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
93
119
|
);
|
|
94
120
|
}
|
|
95
121
|
return {
|
|
96
|
-
|
|
97
|
-
if (typeof selector !== "string") {
|
|
98
|
-
return accessibility(selector);
|
|
99
|
-
}
|
|
100
|
-
const element = elements.element(selector);
|
|
101
|
-
const accessible = accessibility(element);
|
|
102
|
-
tell(`read the accessibility of ${selector}: ${JSON.stringify(accessible)}`);
|
|
103
|
-
return accessible;
|
|
104
|
-
},
|
|
122
|
+
...screenReadouts(currentRoot, tell),
|
|
105
123
|
click: (selector: ScreenTarget) =>
|
|
106
124
|
perform(`click ${targetName(selector)}`, () => {
|
|
107
125
|
const element = elements.element(selector);
|
|
@@ -111,17 +129,17 @@ function makeScreenActions({ root, pending, tell, act = (action) => action(), ti
|
|
|
111
129
|
}),
|
|
112
130
|
enter: (selector: ScreenTarget, value: string) => perform(`enter a value in ${targetName(selector)}`, () => elements.enter(selector, value)),
|
|
113
131
|
find,
|
|
132
|
+
nextLiveHint: () => {
|
|
133
|
+
if (pending === undefined || typeof pending === "function") {
|
|
134
|
+
return Effect.fail(new MissingClientActivity());
|
|
135
|
+
}
|
|
136
|
+
return withLive(
|
|
137
|
+
Effect.sync(() => tell("wait for the next live hint")).pipe(
|
|
138
|
+
Effect.andThen(Effect.promise((signal) => act(() => Effect.runPromise(nextClientHint(pending), { signal })))),
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
},
|
|
114
142
|
settle,
|
|
115
143
|
submit: (selector: ScreenTarget = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
|
|
116
|
-
text: (selector?: ScreenTarget) => {
|
|
117
|
-
const text = elements.text(selector === undefined ? elements.rendered(currentRoot(), "root") : elements.element(selector));
|
|
118
|
-
tell(`read ${selector === undefined ? "the screen" : targetName(selector)}: ${JSON.stringify(text)}`);
|
|
119
|
-
return text;
|
|
120
|
-
},
|
|
121
|
-
value: (selector: ScreenTarget) => {
|
|
122
|
-
const value = elements.input(selector).value;
|
|
123
|
-
tell(`read the value in ${targetName(selector)}: ${JSON.stringify(value)}`);
|
|
124
|
-
return value;
|
|
125
|
-
},
|
|
126
144
|
};
|
|
127
145
|
}
|
package/src/server/storyKit.ts
CHANGED
|
@@ -116,6 +116,20 @@ export function storyKit<
|
|
|
116
116
|
definition: InferredDefinition<TCreate, TStage, TVerbs, TProvided, TAfter, TStep, TFailed, TDiagnose>,
|
|
117
117
|
): StoryKit<HookValue<ReturnType<TCreate>>, TStage, TVerbs, TStep | TFailed | TDiagnose, TProvided>;
|
|
118
118
|
export function storyKit<const TKits extends KitList>(definition: Composition<TKits>): ComposedKit<TKits>;
|
|
119
|
+
// TypeScript reports the last overload's error, so it must check both definition shapes.
|
|
120
|
+
export function storyKit<
|
|
121
|
+
TCreate extends () => unknown,
|
|
122
|
+
const TStage extends string = never,
|
|
123
|
+
TVerbs extends object = object,
|
|
124
|
+
TProvided = never,
|
|
125
|
+
TAfter extends AfterResults<TStage> = Record<never, never>,
|
|
126
|
+
TStep extends AnyEffect = never,
|
|
127
|
+
TFailed extends AnyEffect = never,
|
|
128
|
+
TDiagnose extends AnyEffect = never,
|
|
129
|
+
const TKits extends KitList = KitList,
|
|
130
|
+
>(
|
|
131
|
+
definition: InferredDefinition<TCreate, TStage, TVerbs, TProvided, TAfter, TStep, TFailed, TDiagnose> | Composition<TKits>,
|
|
132
|
+
): StoryKit<HookValue<ReturnType<TCreate>>, TStage, TVerbs, TStep | TFailed | TDiagnose, TProvided> | ComposedKit<TKits>;
|
|
119
133
|
export function storyKit(input: LooseDefinition | Composition<KitList>): unknown {
|
|
120
134
|
const definition = "extends" in input ? compose(input.name, input.extends) : input;
|
|
121
135
|
return {
|