@shivaedev/test-story 0.46.1 → 0.47.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +58 -4
  3. package/dist/server/LiveAnswerSignal.d.ts +8 -0
  4. package/dist/server/LiveAnswerSignal.d.ts.map +1 -0
  5. package/dist/server/LiveAnswerSignal.js +2 -0
  6. package/dist/server/LiveAnswerSignal.js.map +1 -0
  7. package/dist/server/adapters/isolatedGit.d.ts +9 -0
  8. package/dist/server/adapters/isolatedGit.d.ts.map +1 -0
  9. package/dist/server/adapters/isolatedGit.js +49 -0
  10. package/dist/server/adapters/isolatedGit.js.map +1 -0
  11. package/dist/server/adapters/trackedSockets.d.ts +6 -0
  12. package/dist/server/adapters/trackedSockets.d.ts.map +1 -0
  13. package/dist/server/adapters/trackedSockets.js +22 -0
  14. package/dist/server/adapters/trackedSockets.js.map +1 -0
  15. package/dist/server/nextLiveAnswer.d.ts +5 -0
  16. package/dist/server/nextLiveAnswer.d.ts.map +1 -0
  17. package/dist/server/nextLiveAnswer.js +19 -0
  18. package/dist/server/nextLiveAnswer.js.map +1 -0
  19. package/dist/server/rpcSocketHost.d.ts +16 -0
  20. package/dist/server/rpcSocketHost.d.ts.map +1 -0
  21. package/dist/server/rpcSocketHost.js +53 -0
  22. package/dist/server/rpcSocketHost.js.map +1 -0
  23. package/dist/server/screenDriver.d.ts +8 -16
  24. package/dist/server/screenDriver.d.ts.map +1 -1
  25. package/dist/server/screenDriver.js +8 -11
  26. package/dist/server/screenDriver.js.map +1 -1
  27. package/dist/server/screenSignal.d.ts +0 -1
  28. package/dist/server/screenSignal.d.ts.map +1 -1
  29. package/package.json +19 -19
  30. package/src/server/LiveAnswerSignal.ts +8 -0
  31. package/src/server/adapters/isolatedGit.ts +63 -0
  32. package/src/server/adapters/trackedSockets.ts +23 -0
  33. package/src/server/nextLiveAnswer.ts +24 -0
  34. package/src/server/rpcSocketHost.ts +65 -0
  35. package/src/server/screenDriver.ts +18 -25
  36. package/src/server/screenSignal.ts +0 -1
  37. package/dist/server/nextScreenHint.d.ts +0 -5
  38. package/dist/server/nextScreenHint.d.ts.map +0 -1
  39. package/dist/server/nextScreenHint.js +0 -14
  40. package/dist/server/nextScreenHint.js.map +0 -1
  41. package/src/server/nextScreenHint.ts +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.47.0 - 2026-11-11
4
+
5
+ ### Added
6
+
7
+ - `isolatedGit(cwd, args, handed?)` from `@shivaedev/test-story/server/adapters/isolatedGit.ts` runs git for a story kit without the developer's global or system git configuration and without the `GIT_DIR`, `GIT_INDEX_FILE`, `GIT_CONFIG_PARAMETERS`, author and committer variables that a git hook running the tests exports. Variables a kit hands it apply after the isolation. `isolatedGitCommand(command, handed?)` and `isolatedGitEnvironment(handed?)` give the same isolation to a program under test as an `env` command line or as environment variables.
8
+ - `rpcSocketHost(group, handlers)` from `server/rpcSocketHost.ts` serves an RPC group over a real WebSocket on loopback for live-update stories. A story can drop or pause the open sockets, hold or refuse the next handshakes and wait for each handshake that arrives.
9
+ - The screen driver's `withLiveAnswer(answers, action, { timeoutMs }?)` runs an action and returns once a named live query has answered after it, so a screen story can read a result that reaches the screen as a server push after the command has settled, or after another viewer's write. When no answer arrives, the verb fails with `SignalNotReceived`, which names the query.
10
+
11
+ ### Breaking
12
+
13
+ - The screen driver no longer has `nextLiveHint()`, and `MissingClientActivity` is gone. Replace a fork of `driver.nextLiveHint()` before an action and a join after it with `driver.withLiveAnswer(liveAnswers(view.registry, "the notes list", client.api.list.query()), action)`, naming the query that shows the change. `ScreenDriver` takes one type parameter: change `ScreenDriver<E, THintError>` to `ScreenDriver<E>`. `ScreenSignalState` no longer has `hints`.
14
+
3
15
  ## 0.46.1 - 2026-11-10
4
16
 
5
17
  ### Changed
package/README.md CHANGED
@@ -342,6 +342,27 @@ Point story requests at `proxy.url`. The proxy listens on IPv4 and IPv6 loopback
342
342
 
343
343
  Set `localAddress` to choose the source socket address of the proxy's connection to the host. The upstream must accept that address family; for a hostname, the proxy resolves the matching family. Use `127.0.0.1` or `::1` for portable loopback stories. An unavailable local address fails acquisition with a message naming it. The proxy returns 502 if it cannot connect to the host. Both listeners close with the story's Scope.
344
344
 
345
+ #### Dropping and pausing a live client's WebSocket
346
+
347
+ Stories about reconnects, resumes and live updates need a real WebSocket RPC server whose sockets the story controls. Use `rpcSocketHost` from `@shivaedev/test-story/server/rpcSocketHost.ts` in the kit's scoped `create` hook with the RPC group and a Layer of its handlers, plus any RPC middleware the group declares:
348
+
349
+ ```ts
350
+ import { rpcSocketHost } from "@shivaedev/test-story/server/rpcSocketHost.ts";
351
+
352
+ const host = yield* rpcSocketHost(Counter, Counter.toLayer(handlers));
353
+ const client = makeClient(Counter, { url: host.url });
354
+ ```
355
+
356
+ The host serves the group over WebSocket with NDJSON serialization at `host.url`, an allocated IPv4 loopback port with the `/rpc` path. State the handlers read, such as a stored title, stays in the kit. Its controls are Effects for verbs:
357
+
358
+ - `drop` destroys every open socket, as a lost connection does.
359
+ - `pause` stops reading from every open socket, so the client's frames, pings included, get no answer while the connection looks open. Sockets opened later are read normally.
360
+ - `hold` makes every later WebSocket handshake wait. `held` completes for each handshake that reaches the hold, in arrival order, so a verb can wait until the client tries to reconnect. `accept` releases held handshakes and answers later ones again.
361
+ - `refuse` answers later handshakes with 503 until `accept` or a later `hold`.
362
+ - `handshakes` reads how many handshakes reached the host, and `nextHandshake` completes for each handshake in arrival order, whether it was answered, held or refused.
363
+
364
+ `hold` followed by `drop` keeps a client reconnecting until the story accepts it, and `refuse` followed by `drop` shows the client an unreachable server. Closing the story's Scope destroys open sockets, which also ends handshakes still held, and closes the server.
365
+
345
366
  #### Reading OTLP exports
346
367
 
347
368
  Use `otlpReceiver` from `@shivaedev/test-story/server/otlpReceiver.ts` in a kit's scoped `create` hook. It listens on an allocated loopback port and closes with the story scope. Build the application's tracing layer with `receiver.tracerLayer(options?)`, providing native OTLP serialization and an HTTP client:
@@ -820,6 +841,32 @@ const abandoned = yield* service.untilAbandoned(
820
841
 
821
842
  All three adapters retain observations from acquisition, so a wait can start before or after its matching event. Each wait observes independently. They use `until` and its live-time deadline and `SignalNotReceived` diagnostics. Ending child output without a match fails immediately with the last line; a missing span or abandoned request fails at the deadline with the last observation. A silent source reports that no values arrived.
822
843
 
844
+ ### Running git in a temporary repository
845
+
846
+ A kit that runs git, in its own setup or through the program under test, must give the same result on every machine and from every caller. Without isolation, git reads the developer's global and system configuration, so a global hooks path, commit signing or a commit template changes the story, and when the tests run from a git hook, the `GIT_DIR`, `GIT_INDEX_FILE` and `GIT_CONFIG_PARAMETERS` that hook exports point git at the outer repository. Run every git command of a kit through `isolatedGit(cwd, args)` from `@shivaedev/test-story/server/adapters/isolatedGit.ts`. It returns `{ status, stdout, stderr }`; the kit decides what a failure means.
847
+
848
+ ```ts
849
+ import { isolatedGit } from "@shivaedev/test-story/server/adapters/isolatedGit.ts";
850
+
851
+ const run = isolatedGit(repository, [
852
+ "-c",
853
+ "user.name=Story",
854
+ "-c",
855
+ "user.email=story@example.com",
856
+ "commit",
857
+ "--quiet",
858
+ "--message",
859
+ "Add the README",
860
+ ]);
861
+ if (run.status !== 0) {
862
+ throw new Error(`git commit failed: ${run.stderr}`);
863
+ }
864
+ ```
865
+
866
+ The git process reads no global or system configuration and inherits none of the variables git clears when it enters another repository (`git rev-parse --local-env-vars`), nor the author and committer a hook exports; it keeps the rest of the test process's environment, such as `PATH` and `HOME`. Give the commits an identity with `-c user.name=… -c user.email=…` or the repository's own config.
867
+
868
+ To hand a configuration on purpose, pass it as the third argument: `isolatedGit(app, ["commit", "-m", "Initial app"], { GIT_CONFIG_GLOBAL: guardConfig })` runs with that global configuration, because handed variables apply after the isolation. For the program under test, `isolatedGitCommand(["pnpm", "install"], handed)` returns the same isolation as an `env` command line to spawn, and `isolatedGitEnvironment(handed)` returns it as variables, with `undefined` for each variable to remove, for a spawn's `env` or for stubbing the test process's own environment.
869
+
823
870
  ### When a story fails
824
871
 
825
872
  After the engine has been created, a failing story test adds the story to its first error, as in the examples above:
@@ -990,7 +1037,7 @@ const driver = screenDriver({ act, transport: page.pending, root: view.container
990
1037
 
991
1038
  Pass the page's native `pending` stream as the driver's `transport` option to wait for global fetches to resolve or reject, including requests sent by `useBrowserErrors`. After a page action, `yield* driver.settle()` waits for every outstanding fetch without sleeping. This counts fetch completion at response headers, not consumption of a streaming response body, and does not supply the document cookie jar; keep using `domFetch` for clients that need that document transport.
992
1039
 
993
- `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`. Supply at least one of `pending`, `activity` or `transport` for `settle()`. `nextLiveHint()` needs `activity` or a `ScreenSignal` in `pending`. DOM actions, lookups and synchronous readouts work without these signals. Without any completion signal, `settle()` fails immediately in its error channel with `MissingScreenPending`, exported from `server/screenDriver.ts`, even when the screen is idle.
1040
+ `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`. Supply at least one of `pending`, `activity` or `transport` for `settle()`. DOM actions, lookups and synchronous readouts work without these signals. Without any completion signal, `settle()` fails immediately in its error channel with `MissingScreenPending`, exported from `server/screenDriver.ts`, even when the screen is idle.
994
1041
 
995
1042
  To use `settle()`, supply a native `Stream<boolean>` as `pending`, emitting the current pending state on subscription and every subsequent change. For example, a package that tracks work in a native `SubscriptionRef<boolean>` supplies `pending: SubscriptionRef.changes(requests.pending)`. For a native boolean atom, use `AtomRegistry.toStream(view.registry, pendingAtom)` from `effect/reactivity/AtomRegistry`. Keep pending true until the resulting screen work is ready to render. Settlement keeps its `Effect<void>` type with no typed errors and waits until the stream emits false; DOM mutations also wake the driver, and repeated identical renders never count as completion. `find()` waits for pending work to finish and its target to appear, reacting to both signals and mutations.
996
1043
 
@@ -1008,7 +1055,7 @@ verbs: ({ view, requests }, story) =>
1008
1055
  });
1009
1056
  ```
1010
1057
 
1011
- A `ScreenSignal` from `server/screenSignal.ts` is a native `Stream<ScreenSignalState>` with a `current` Effect. Each state reports `pending` until screen work is ready to render and a monotonic `hints` count for received updates. Any engine can supply this shape; waits observe it without knowing which engine produced it.
1058
+ A `ScreenSignal` from `server/screenSignal.ts` is a native `Stream<ScreenSignalState>` with a `current` Effect. Each state reports `pending` until screen work is ready to render. Any engine can supply this shape; waits observe it without knowing which engine produced it.
1012
1059
 
1013
1060
  For a real contract client, project its native activity with `activityScreenSignal`. Combine it with application work and transport requests when a screen uses all three:
1014
1061
 
@@ -1029,9 +1076,13 @@ yield* screen.settle();
1029
1076
  expect(screen.text("output")).toBe("Saved title");
1030
1077
  ```
1031
1078
 
1032
- `settle()` waits until every supplied source is settled together, then flushes the renderer before returning. A source that becomes busy while another finishes keeps the wait open. `pending` and `transport` each accept the same sampler, boolean stream or `ScreenSignal` shape; `activity` accepts a `ScreenSignal`; contract owns the projection from native `ClientActivity`. It observes changes from all three without sleeps, quiet windows or polling. With `activityScreenSignal(clientActivity(client))`, the default is commands in flight and each mounted query's first result. A live query that has already delivered, including one awaiting a later refresh, is normal screen state and keeps no wait open. Contract uses its query/command declarations, so kits list no queries as settling exceptions. `find()` waits for settled activity and a matching target, including a target rendered by a later DOM mutation. To wait for a particular changed value, use `findText()` or an explicit live-change wait.
1079
+ `settle()` waits until every supplied source is settled together, then flushes the renderer before returning. A source that becomes busy while another finishes keeps the wait open. `pending` and `transport` each accept the same sampler, boolean stream or `ScreenSignal` shape; `activity` accepts a `ScreenSignal`; contract owns the projection from native `ClientActivity`. It observes changes from all three without sleeps, quiet windows or polling. With `activityScreenSignal(clientActivity(client))`, the default is commands in flight and each mounted query's first result. A live query that has already delivered, including one awaiting a later refresh, is normal screen state and keeps no wait open. Contract uses its query/command declarations, so kits list no queries as settling exceptions. `find()` waits for settled activity and a matching target, including a target rendered by a later DOM mutation. To wait for a particular changed value, use `findText()` or `withLiveAnswer`.
1080
+
1081
+ `withLiveAnswer(answers, action, { timeoutMs }?)` runs an action and returns its result once the live query named by `answers` has delivered a settled answer after the action began. It is the one wait for a live change, whether the story's own command or another viewer's write causes it: a contract command settles on its receipt, and the server's rerun reaches a live query later as a push that `settle()` does not wait for. Build `answers` with `liveAnswers(view.registry, "the notes list", api.list.query())` from `@shivaedev/contract/liveAnswers.ts`, or supply any `LiveAnswerSignal` from `server/LiveAnswerSignal.ts`. Any answer to that query counts, including one caused by another change or an unchanged rerun. A held server rerun leaves the current value visible and keeps the wait open. If no answer arrives within the driver's `timeoutMs`, or the answers end, the verb fails with `SignalNotReceived`, naming the query. Settle the screen after it; `activityScreenSignal(activity, isClientIdle)` from `@shivaedev/contract/clientActivity.ts` also waits for finite calls and pending query atoms. To assert which kind of update arrived, read the transport with `browserReads` below; the driver only waits.
1033
1082
 
1034
- `nextLiveHint()` waits for the next pushed subscription update received after the verb starts, including first results and server reconciliation results. Start the wait before another viewer writes, then settle the screen after the update arrives. Server coalescing is automatic, and the client makes no follow-up read. A held server rerun leaves the current value visible and does not block a command receipt's settlement. `activityScreenSignal(activity, isClientIdle)` also waits for finite calls and pending query atoms; both functions come from `@shivaedev/contract/clientActivity.ts`. If the client activity stream ends without an update, the wait fails with `SignalNotReceived` from `server/until.ts`. It needs `activity` or a `ScreenSignal` in `pending`; a callback-only driver fails with `MissingClientActivity`. Existing `pending: activityScreenSignal(clientActivity(client))` wiring remains supported.
1083
+ ```ts
1084
+ submitNote: () => screen.withLiveAnswer(liveAnswers(view.registry, "the notes list", client.api.list.query()), screen.submit()),
1085
+ ```
1035
1086
 
1036
1087
  For screens with runtime timers, acquire `const clock = yield* watchedClock` from `server/watchedClock.ts` during kit creation and pass `clock` to `screenDriver({ act, clock, pending, root, tell })`. Supply that same Clock to the application's atom runtime. While the supplied completion sources are busy, screen waits advance to the next registered sleep inside the supplied renderer `act`, then check completion again. Canceled sleeps are removed. A debounced search can therefore use `enter` followed by `settle` without a real wait or its debounce duration in a kit verb. Clock advancement is opt-in; the driver leaves time alone without `clock`. It advances the shared clock, including other scheduled work, so use explicit `clock.adjust(duration)` inside `act` when a story needs to observe a time boundary, such as holding a diary row for a long press.
1037
1088
 
@@ -1104,6 +1155,7 @@ Import each module with the prefix `@shivaedev/test-story/`; there is no root en
1104
1155
  | `server/adapters/seedCookies.ts` | `seedCookies(cookies, target?)`, `DomCookie` |
1105
1156
  | `server/routeOutbound.ts` | `routeOutbound(routes)` |
1106
1157
  | `server/screenDriver.ts` | `screenDriver(options)`, `ScreenDriverOptions`, `ScreenDriver`, `ScreenTarget`, `MissingScreenPending` |
1158
+ | `server/LiveAnswerSignal.ts` | `LiveAnswerSignal`, the answers of one query that `withLiveAnswer` waits for |
1107
1159
  | `server/adapters/memberScreens.ts` | `memberScreens(options)`, `MemberScreen` |
1108
1160
  | `server/adapters/domNavigate.ts` | `domNavigate(url?)` |
1109
1161
  | `server/genreTags.ts` | `genreTags(...kitNames)`, `GenreTag` |
@@ -1112,6 +1164,8 @@ Import each module with the prefix `@shivaedev/test-story/`; there is no root en
1112
1164
  | `server/httpVisitor.ts` | `httpVisitor(upstream, options?)`, `HttpVisitorOptions`, `VisitorRequest` |
1113
1165
  | `server/forwardingProxy.ts` | `forwardingProxy(upstream, options?)`, `ForwardingProxyOptions` |
1114
1166
  | `server/otlpReceiver.ts` | `otlpReceiver(options?)`, `OtlpSpan`, `OtlpExport`, `OtlpReceiverOptions`, `OtlpTracerOptions` |
1167
+ | `server/rpcSocketHost.ts` | `rpcSocketHost(group, handlers)` |
1168
+ | `server/adapters/isolatedGit.ts` | `isolatedGit(cwd, args, handed?)`, `isolatedGitCommand(command, handed?)`, `isolatedGitEnvironment(handed?)`, `GitRun` |
1115
1169
 
1116
1170
  ### Install and limits
1117
1171
 
@@ -0,0 +1,8 @@
1
+ import type * as Effect from "effect/Effect";
2
+ import type * as Stream from "effect/Stream";
3
+ export interface LiveAnswerSignal {
4
+ readonly answered: Stream.Stream<number>;
5
+ readonly current: Effect.Effect<number>;
6
+ readonly name: string;
7
+ }
8
+ //# sourceMappingURL=LiveAnswerSignal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveAnswerSignal.d.ts","sourceRoot":"","sources":["../../src/server/LiveAnswerSignal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LiveAnswerSignal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveAnswerSignal.js","sourceRoot":"","sources":["../../src/server/LiveAnswerSignal.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export interface GitRun {
2
+ readonly status: number | null;
3
+ readonly stderr: string;
4
+ readonly stdout: string;
5
+ }
6
+ export declare function isolatedGitEnvironment(handed?: Readonly<Record<string, string>>): Readonly<Record<string, string | undefined>>;
7
+ export declare function isolatedGitCommand(command: readonly [string, ...string[]], handed?: Readonly<Record<string, string>>): readonly [string, ...string[]];
8
+ export declare function isolatedGit(cwd: string, args: readonly string[], handed?: Readonly<Record<string, string>>): GitRun;
9
+ //# sourceMappingURL=isolatedGit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolatedGit.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/isolatedGit.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAYlI;AAED,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EACvC,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC3C,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAKhC;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAAG,MAAM,CAIvH"}
@@ -0,0 +1,49 @@
1
+ import { spawnSync } from "node:child_process";
2
+ // A git hook that runs the tests exports these for its own repository and commit, and git itself clears the first group
3
+ // (`git rev-parse --local-env-vars`) before it enters another repository.
4
+ const INHERITED = [
5
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
6
+ "GIT_CONFIG",
7
+ "GIT_CONFIG_PARAMETERS",
8
+ "GIT_OBJECT_DIRECTORY",
9
+ "GIT_DIR",
10
+ "GIT_WORK_TREE",
11
+ "GIT_IMPLICIT_WORK_TREE",
12
+ "GIT_GRAFT_FILE",
13
+ "GIT_INDEX_FILE",
14
+ "GIT_NO_REPLACE_OBJECTS",
15
+ "GIT_REPLACE_REF_BASE",
16
+ "GIT_PREFIX",
17
+ "GIT_SHALLOW_FILE",
18
+ "GIT_COMMON_DIR",
19
+ "GIT_AUTHOR_NAME",
20
+ "GIT_AUTHOR_EMAIL",
21
+ "GIT_AUTHOR_DATE",
22
+ "GIT_COMMITTER_NAME",
23
+ "GIT_COMMITTER_EMAIL",
24
+ "GIT_COMMITTER_DATE",
25
+ ];
26
+ // Detached auto maintenance outlives the git call and races the story's removal of its temporary repository.
27
+ export function isolatedGitEnvironment(handed = {}) {
28
+ return {
29
+ ...Object.fromEntries(INHERITED.map((name) => [name, undefined])),
30
+ "GIT_CONFIG_COUNT": "2",
31
+ "GIT_CONFIG_GLOBAL": "/dev/null",
32
+ "GIT_CONFIG_KEY_0": "gc.auto",
33
+ "GIT_CONFIG_KEY_1": "maintenance.auto",
34
+ "GIT_CONFIG_NOSYSTEM": "1",
35
+ "GIT_CONFIG_VALUE_0": "0",
36
+ "GIT_CONFIG_VALUE_1": "false",
37
+ ...handed,
38
+ };
39
+ }
40
+ export function isolatedGitCommand(command, handed = {}) {
41
+ const variables = Object.entries(isolatedGitEnvironment(handed)).flatMap(([name, value]) => value === undefined ? ["-u", name] : [`${name}=${value}`]);
42
+ return ["env", ...variables, ...command];
43
+ }
44
+ export function isolatedGit(cwd, args, handed = {}) {
45
+ const [command, ...rest] = isolatedGitCommand(["git", ...args], handed);
46
+ const { status, stderr, stdout } = spawnSync(command, rest, { cwd, encoding: "utf8" });
47
+ return { status, stderr, stdout };
48
+ }
49
+ //# sourceMappingURL=isolatedGit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolatedGit.js","sourceRoot":"","sources":["../../../src/server/adapters/isolatedGit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wHAAwH;AACxH,0EAA0E;AAC1E,MAAM,SAAS,GAAG;IACjB,kCAAkC;IAClC,YAAY;IACZ,uBAAuB;IACvB,sBAAsB;IACtB,SAAS;IACT,eAAe;IACf,wBAAwB;IACxB,gBAAgB;IAChB,gBAAgB;IAChB,wBAAwB;IACxB,sBAAsB;IACtB,YAAY;IACZ,kBAAkB;IAClB,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,iBAAi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I,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function trackedSockets(): {
2
+ destroy: () => void;
3
+ pause: () => void;
4
+ server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
5
+ };
6
+ //# sourceMappingURL=trackedSockets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackedSockets.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/trackedSockets.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc;;;;EAmB7B"}
@@ -0,0 +1,22 @@
1
+ import { createServer } from "node:http";
2
+ export function trackedSockets() {
3
+ const sockets = new Set();
4
+ const server = createServer().on("connection", (socket) => {
5
+ sockets.add(socket);
6
+ socket.on("close", () => sockets.delete(socket));
7
+ });
8
+ return {
9
+ destroy: () => {
10
+ for (const socket of sockets) {
11
+ socket.destroy();
12
+ }
13
+ },
14
+ pause: () => {
15
+ for (const socket of sockets) {
16
+ socket.pause();
17
+ }
18
+ },
19
+ server,
20
+ };
21
+ }
22
+ //# sourceMappingURL=trackedSockets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackedSockets.js","sourceRoot":"","sources":["../../../src/server/adapters/trackedSockets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,UAAU,cAAc;IAC7B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE;QACzD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,OAAO;QACN,OAAO,EAAE,GAAG,EAAE;YACb,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,CAAC;QACF,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACX,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC;QACF,CAAC;QACD,MAAM;KACN,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as Effect from "effect/Effect";
2
+ import type { LiveAnswerSignal } from "#server/LiveAnswerSignal.ts";
3
+ import { SignalNotReceived } from "#server/until.ts";
4
+ export declare const nextLiveAnswer: (answers: LiveAnswerSignal, before: number, timeoutMs: number) => Effect.Effect<void, SignalNotReceived, never>;
5
+ //# sourceMappingURL=nextLiveAnswer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextLiveAnswer.d.ts","sourceRoot":"","sources":["../../src/server/nextLiveAnswer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,cAAc,iHAiBzB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Option from "effect/Option";
3
+ import * as Stream from "effect/Stream";
4
+ import { SignalNotReceived } from "#server/until.ts";
5
+ export const nextLiveAnswer = Effect.fnUntraced(function* (answers, before, timeoutMs) {
6
+ function missing(reason) {
7
+ return new SignalNotReceived({
8
+ message: [
9
+ `Waited for a live answer to ${answers.name} after the action above, none arrived: ${reason}.`,
10
+ "help: the server pushed no result for this query after the action. Check that the action changes what the query",
11
+ " reads, or settle without this wait when the command's own reply updates the screen.",
12
+ ].join("\n"),
13
+ });
14
+ }
15
+ const answer = answers.answered.pipe(Stream.filter((completed) => completed > before), Stream.runHead, Effect.flatMap((found) => (Option.isSome(found) ? Effect.void : Effect.fail(missing("the query's answers ended")))));
16
+ const deadline = Effect.sleep(timeoutMs).pipe(Effect.andThen(Effect.fail(missing(`nothing came within ${timeoutMs}ms`))));
17
+ return yield* Effect.raceFirst(answer, deadline);
18
+ });
19
+ //# sourceMappingURL=nextLiveAnswer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextLiveAnswer.js","sourceRoot":"","sources":["../../src/server/nextLiveAnswer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAyB,EAAE,MAAc,EAAE,SAAiB;IACtH,SAAS,OAAO,CAAC,MAAc;QAC9B,OAAO,IAAI,iBAAiB,CAAC;YAC5B,OAAO,EAAE;gBACR,+BAA+B,OAAO,CAAC,IAAI,0CAA0C,MAAM,GAAG;gBAC9F,iHAAiH;gBACjH,2FAA2F;aAC3F,CAAC,IAAI,CAAC,IAAI,CAAC;SACZ,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CACnC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC,EAChD,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CACnH,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1H,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Context, Effect, Layer } from "effect";
2
+ import { HttpRouter, HttpServer } from "effect/http";
3
+ import type { Rpc, RpcGroup } from "effect/rpc";
4
+ import { RpcSerialization } from "effect/rpc";
5
+ export declare const rpcSocketHost: <TRpcs extends Rpc.Any, E, R>(group: RpcGroup.RpcGroup<TRpcs>, handlers: Layer.Layer<Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>, E, R>) => Effect.Effect<{
6
+ accept: Effect.Effect<void, never, never>;
7
+ drop: Effect.Effect<void, never, never>;
8
+ handshakes: Effect.Effect<number, never, never>;
9
+ held: Effect.Effect<void, never, never>;
10
+ hold: Effect.Effect<void, never, never>;
11
+ nextHandshake: Effect.Effect<void, never, never>;
12
+ pause: Effect.Effect<void, never, never>;
13
+ refuse: Effect.Effect<void, never, never>;
14
+ url: string;
15
+ }, [Effect.Effect<void, never, import("effect/Scope").Scope> | Effect.Effect<Context.Context<import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices>, import("effect/http/HttpServerError").ServeError | HttpRouter.Request.Without<E>, import("effect/Scope").Scope | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", R>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", R>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<R>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices>>] extends [Effect.Effect<infer _A, infer E_1, infer _R>] ? E_1 : never, [Effect.Effect<void, never, import("effect/Scope").Scope> | Effect.Effect<Context.Context<import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices>, import("effect/http/HttpServerError").ServeError | HttpRouter.Request.Without<E>, import("effect/Scope").Scope | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", R>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", R>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<R>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<HttpRouter.HttpRouter, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<RpcSerialization.RpcSerialization, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.Middleware<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.ServicesServer<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices> | Exclude<Exclude<HttpRouter.Request.Without<Exclude<Rpc.ToHandler<TRpcs>, RpcSerialization.RpcSerialization | Rpc.Middleware<TRpcs> | Rpc.ToHandler<TRpcs>>>, HttpRouter.HttpRouter>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | HttpServer.HttpServer | import("@effect/platform-node/NodeServices").NodeServices>>] extends [Effect.Effect<infer _A_1, infer _E, infer R_1>] ? R_1 : never>;
16
+ //# sourceMappingURL=rpcSocketHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpcSocketHost.d.ts","sourceRoot":"","sources":["../../src/server/rpcSocketHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAY,MAAM,EAAE,KAAK,EAAc,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAEzE,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAa,MAAM,YAAY,CAAC;AAGzD,eAAO,MAAM,aAAa,GAAgC,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;;;;;;;;;;g9bAwDnF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
2
+ import { Context, Deferred, Effect, Layer, Queue, Ref } from "effect";
3
+ import { HttpRouter, HttpServer, HttpServerResponse } from "effect/http";
4
+ import * as HttpStatus from "effect/http/HttpStatus";
5
+ import { RpcSerialization, RpcServer } from "effect/rpc";
6
+ import { trackedSockets } from "#server/adapters/trackedSockets.ts";
7
+ export const rpcSocketHost = Effect.fnUntraced(function* (group, handlers) {
8
+ const sockets = trackedSockets();
9
+ const holding = yield* Ref.make(undefined);
10
+ const refusing = yield* Ref.make(false);
11
+ const count = yield* Ref.make(0);
12
+ const arrived = yield* Queue.unbounded();
13
+ const held = yield* Queue.unbounded();
14
+ const accept = Effect.gen(function* () {
15
+ yield* Ref.set(refusing, false);
16
+ const release = yield* Ref.getAndSet(holding, undefined);
17
+ if (release !== undefined) {
18
+ yield* Deferred.succeed(release, undefined);
19
+ }
20
+ });
21
+ const gate = HttpRouter.middleware((request) => Effect.gen(function* () {
22
+ yield* Ref.update(count, (handshakes) => handshakes + 1);
23
+ yield* Queue.offer(arrived, undefined);
24
+ if (yield* Ref.get(refusing)) {
25
+ return HttpServerResponse.empty({ status: HttpStatus.fromLiteral("ServiceUnavailable") });
26
+ }
27
+ const release = yield* Ref.get(holding);
28
+ if (release !== undefined) {
29
+ yield* Queue.offer(held, undefined);
30
+ yield* Deferred.await(release);
31
+ }
32
+ return yield* request;
33
+ }));
34
+ const routes = RpcServer.layerHttp({ group, path: "/rpc", protocol: "websocket" }).pipe(Layer.provide([handlers, RpcSerialization.layerNdjson, gate.layer]));
35
+ const context = yield* Layer.build(HttpRouter.serve(routes, { disableLogger: true }).pipe(Layer.provideMerge(NodeHttpServer.layer(() => sockets.server, { host: "127.0.0.1", port: 0 }))));
36
+ yield* Effect.addFinalizer(() => Effect.sync(sockets.destroy));
37
+ return {
38
+ accept,
39
+ drop: Effect.sync(sockets.destroy),
40
+ handshakes: Ref.get(count),
41
+ held: Queue.take(held),
42
+ hold: Effect.gen(function* () {
43
+ const release = yield* Deferred.make();
44
+ yield* Ref.set(refusing, false);
45
+ yield* Ref.update(holding, (current) => current ?? release);
46
+ }),
47
+ nextHandshake: Queue.take(arrived),
48
+ pause: Effect.sync(sockets.pause),
49
+ refuse: accept.pipe(Effect.andThen(Ref.set(refusing, true))),
50
+ url: `${HttpServer.formatAddress(Context.get(context, HttpServer.HttpServer).address)}/rpc`,
51
+ };
52
+ });
53
+ //# sourceMappingURL=rpcSocketHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpcSocketHost.js","sourceRoot":"","sources":["../../src/server/rpcSocketHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;A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C,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,OAAO;QACN,MAAM;QACN,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAClC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACzB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAQ,CAAC;YAC7C,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAChC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC;QACF,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;QAClC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,GAAG,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,MAAM;KAC3F,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import type * as Stream from "effect/Stream";
3
3
  import { type ScreenAct } from "#server/adapters/screenAct.ts";
4
+ import type { LiveAnswerSignal } from "#server/LiveAnswerSignal.ts";
4
5
  import type { ScreenSignal } from "#server/screenSignal.ts";
5
- import type { SignalNotReceived } from "#server/until.ts";
6
6
  import type { ScreenClock } from "#server/watchedClock.ts";
7
7
  export type ScreenTarget = string | {
8
8
  readonly role: string;
@@ -25,27 +25,17 @@ declare const MissingScreenPending_base: new <A extends Record<string, any> = {}
25
25
  export declare class MissingScreenPending extends MissingScreenPending_base {
26
26
  readonly message = "Cannot settle the screen without a completion signal.\nhelp: Supply pending, activity or transport that stays busy until the resulting screen work is ready to render.";
27
27
  }
28
- 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 & {
29
- readonly _tag: "MissingClientActivity";
30
- } & Readonly<A>;
31
- export declare class MissingClientActivity extends MissingClientActivity_base {
32
- readonly message = "Cannot wait for a live hint without client activity.\nhelp: Supply activity or pending: a ScreenSignal with current pending work and a hint sequence.";
33
- }
34
- export type ScreenDriver<E = never, THintError = MissingClientActivity | SignalNotReceived> = Omit<ReturnType<typeof makeScreenActions>, "settle" | "nextLiveHint"> & {
35
- nextLiveHint: () => Effect.Effect<void, THintError>;
28
+ export type ScreenDriver<E = never> = Omit<ReturnType<typeof makeScreenActions>, "settle"> & {
36
29
  settle: (options?: {
37
30
  readonly timeoutMs?: number;
38
31
  }) => Effect.Effect<void, E>;
39
- dialog: (target: ScreenTarget) => ScreenDriver<E, THintError>;
40
- within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E, THintError>;
32
+ dialog: (target: ScreenTarget) => ScreenDriver<E>;
33
+ within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E>;
41
34
  };
42
35
  export declare function screenDriver(options: ScreenDriverOptions & ({
43
- readonly pending: ScreenSignal;
36
+ readonly pending: NonNullable<ScreenDriverOptions["pending"]>;
44
37
  } | {
45
38
  readonly activity: ScreenSignal;
46
- })): ScreenDriver<never, SignalNotReceived>;
47
- export declare function screenDriver(options: ScreenDriverOptions & ({
48
- readonly pending: (() => boolean) | Stream.Stream<boolean>;
49
39
  } | {
50
40
  readonly transport: NonNullable<ScreenDriverOptions["transport"]>;
51
41
  })): ScreenDriver;
@@ -84,12 +74,14 @@ declare function makeScreenActions(options: ScreenDriverOptions, dialogs: boolea
84
74
  }) => Effect.Effect<void, never, never>;
85
75
  click: (selector: ScreenTarget) => Effect.Effect<void, never, never>;
86
76
  enter: (selector: ScreenTarget, value: string) => Effect.Effect<void, never, never>;
87
- nextLiveHint: () => Effect.Effect<undefined, SignalNotReceived, never> | Effect.Effect<never, MissingClientActivity, never>;
88
77
  select: (selector: ScreenTarget, value: string) => Effect.Effect<void, never, never>;
89
78
  settle: (settings?: {
90
79
  readonly timeoutMs?: number;
91
80
  }) => Effect.Effect<void, never, never> | Effect.Effect<never, MissingScreenPending, never>;
92
81
  submit: (selector?: ScreenTarget) => Effect.Effect<void, never, never>;
82
+ withLiveAnswer: <A, E, R>(answers: LiveAnswerSignal, action: Effect.Effect<A, E, R>, settings?: {
83
+ readonly timeoutMs?: number;
84
+ }) => Effect.Effect<A, E | import("./until.ts").SignalNotReceived, R>;
93
85
  };
94
86
  export {};
95
87
  //# sourceMappingURL=screenDriver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenDriver.d.ts","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAmB,KAAK,SAAS,EAA4B,MAAM,+BAA+B,CAAC;AAK1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,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AS/H"}
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
3
3
  import { withLive } from "@shivaedev/test/withLive.ts";
4
4
  import { directScreenAct, screenAct, screenPerform } from "#server/adapters/screenAct.ts";
5
5
  import { screenElements } from "#server/adapters/screenElements.ts";
6
- import { nextScreenHint } from "#server/nextScreenHint.ts";
6
+ import { nextLiveAnswer } from "#server/nextLiveAnswer.ts";
7
7
  import { screenInteractions } from "#server/screenInteractions.ts";
8
8
  import { screenReadouts } from "#server/screenReadouts.ts";
9
9
  import { screenWaits } from "#server/screenWaits.ts";
@@ -11,9 +11,6 @@ import { targetName } from "#server/targetName.ts";
11
11
  export class MissingScreenPending extends Data.TaggedError("MissingScreenPending") {
12
12
  message = "Cannot settle the screen without a completion signal.\nhelp: Supply pending, activity or transport that stays busy until the resulting screen work is ready to render.";
13
13
  }
14
- export class MissingClientActivity extends Data.TaggedError("MissingClientActivity") {
15
- message = "Cannot wait for a live hint without client activity.\nhelp: Supply activity or pending: a ScreenSignal with current pending work and a hint sequence.";
16
- }
17
14
  export function screenDriver(options) {
18
15
  return makeDriver(options, true);
19
16
  }
@@ -58,16 +55,16 @@ function makeScreenActions(options, dialogs) {
58
55
  element.click();
59
56
  }),
60
57
  enter: (selector, value) => perform(`enter a value in ${targetName(selector)}`, () => elements.enter(selector, value)),
61
- nextLiveHint: () => {
62
- const signal = activity ?? pending;
63
- if (signal === undefined || typeof signal === "function" || !("current" in signal)) {
64
- return Effect.fail(new MissingClientActivity());
65
- }
66
- return withLive(Effect.sync(() => tell("wait for the next live hint")).pipe(Effect.andThen(screenAct(act, nextScreenHint(signal)))));
67
- },
68
58
  select: (selector, value) => perform(`select ${JSON.stringify(value)} in ${targetName(selector)}`, () => elements.select(selector, value)),
69
59
  settle: (settings) => pending === undefined && activity === undefined && transport === undefined ? Effect.fail(new MissingScreenPending()) : waits.settle(settings),
70
60
  submit: (selector = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
61
+ withLiveAnswer: (answers, action, settings = {}) => Effect.gen(function* () {
62
+ const before = yield* answers.current;
63
+ const result = yield* action;
64
+ tell(`wait for a live answer to ${answers.name}`);
65
+ yield* withLive(screenAct(act, nextLiveAnswer(answers, before, settings.timeoutMs ?? timeoutMs)));
66
+ return result;
67
+ }),
71
68
  };
72
69
  }
73
70
  //# sourceMappingURL=screenDriver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenDriver.js","sourceRoot":"","sources":["../../src/server/screenDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAkBnD,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC;IAC/D,OAAO,GACxB,wKAAwK,CAAC;CAC1K;AAED,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC;IACjE,OAAO,GACxB,uJAAuJ,CAAC;CACzJ;AAoBD,MAAM,UAAU,YAAY,CAAC,OAA4B;IACxD,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,OAA4B,EAAE,OAAgB,EAAE,WAA+B;IA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9I,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;QACrI,cAAc,EAAE,CAAU,OAAyB,EAAE,MAA8B,EAAE,QAAQ,GAAoC,EAAE,EAAE,EAAE,CACtI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YACtC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC;YAC7B,IAAI,CAAC,6BAA6B,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAClD,KAAK,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;YAClG,OAAO,MAAM,CAAC;QACf,CAAC,CAAC;KACH,CAAC;AACH,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import type * as Effect from "effect/Effect";
2
2
  import type * as Stream from "effect/Stream";
3
3
  export interface ScreenSignalState {
4
- readonly hints: number;
5
4
  readonly pending: boolean;
6
5
  }
7
6
  export type ScreenSignal = Stream.Stream<ScreenSignalState> & {
@@ -1 +1 @@
1
- {"version":3,"file":"screenSignal.d.ts","sourceRoot":"","sources":["../../src/server/screenSignal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"screenSignal.d.ts","sourceRoot":"","sources":["../../src/server/screenSignal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/test-story",
3
- "version": "0.46.1",
3
+ "version": "0.47.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,39 +42,39 @@
42
42
  "README.md"
43
43
  ],
44
44
  "dependencies": {
45
- "@shivaedev/contract": "0.43.5",
46
- "@shivaedev/test": "0.17.1",
47
- "@shivaedev/test-sql": "0.24.8",
45
+ "@shivaedev/contract": "0.44.0",
46
+ "@shivaedev/test": "0.17.2",
47
+ "@shivaedev/test-sql": "0.24.9",
48
48
  "dom-accessibility-api": "0.7.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@effect/atom-react": "4.1.1",
52
- "@effect/platform-node": "4.1.1",
53
- "@effect/sql-pg": "4.1.1",
54
- "@effect/vitest": "4.1.1",
55
- "@shivaedev/quality": "0.76.0",
56
- "@shivaedev/react": "0.47.1",
57
- "@shivaedev/server": "0.33.4",
51
+ "@effect/atom-react": "4.1.2",
52
+ "@effect/platform-node": "4.1.2",
53
+ "@effect/sql-pg": "4.1.2",
54
+ "@effect/vitest": "4.1.2",
55
+ "@shivaedev/quality": "0.77.0",
56
+ "@shivaedev/react": "0.47.2",
57
+ "@shivaedev/server": "0.34.0",
58
58
  "@types/node": "24.19.2",
59
59
  "@types/react": "19.3.0",
60
60
  "@types/react-dom": "19.3.0",
61
- "effect": "4.1.1",
61
+ "effect": "4.1.2",
62
62
  "happy-dom": "21.0.4",
63
63
  "react": "19.3.1",
64
64
  "react-dom": "19.3.1",
65
65
  "typescript": "7.0.2",
66
- "vitest": "5.0.5"
66
+ "vitest": "5.1.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@effect/atom-react": "4.1.1",
70
- "@effect/platform-node": "4.1.1",
71
- "@effect/sql-pg": "4.1.1",
72
- "@effect/vitest": "4.1.1",
73
- "effect": "4.1.1",
69
+ "@effect/atom-react": "4.1.2",
70
+ "@effect/platform-node": "4.1.2",
71
+ "@effect/sql-pg": "4.1.2",
72
+ "@effect/vitest": "4.1.2",
73
+ "effect": "4.1.2",
74
74
  "happy-dom": "21.0.4",
75
75
  "react": "19.3.1",
76
76
  "react-dom": "19.3.1",
77
- "vitest": "5.0.5"
77
+ "vitest": "5.1.0"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@effect/atom-react": {
@@ -0,0 +1,8 @@
1
+ import type * as Effect from "effect/Effect";
2
+ import type * as Stream from "effect/Stream";
3
+
4
+ export interface LiveAnswerSignal {
5
+ readonly answered: Stream.Stream<number>;
6
+ readonly current: Effect.Effect<number>;
7
+ readonly name: string;
8
+ }
@@ -0,0 +1,63 @@
1
+ import { spawnSync } from "node:child_process";
2
+
3
+ // A git hook that runs the tests exports these for its own repository and commit, and git itself clears the first group
4
+ // (`git rev-parse --local-env-vars`) before it enters another repository.
5
+ const INHERITED = [
6
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
7
+ "GIT_CONFIG",
8
+ "GIT_CONFIG_PARAMETERS",
9
+ "GIT_OBJECT_DIRECTORY",
10
+ "GIT_DIR",
11
+ "GIT_WORK_TREE",
12
+ "GIT_IMPLICIT_WORK_TREE",
13
+ "GIT_GRAFT_FILE",
14
+ "GIT_INDEX_FILE",
15
+ "GIT_NO_REPLACE_OBJECTS",
16
+ "GIT_REPLACE_REF_BASE",
17
+ "GIT_PREFIX",
18
+ "GIT_SHALLOW_FILE",
19
+ "GIT_COMMON_DIR",
20
+ "GIT_AUTHOR_NAME",
21
+ "GIT_AUTHOR_EMAIL",
22
+ "GIT_AUTHOR_DATE",
23
+ "GIT_COMMITTER_NAME",
24
+ "GIT_COMMITTER_EMAIL",
25
+ "GIT_COMMITTER_DATE",
26
+ ];
27
+
28
+ export interface GitRun {
29
+ readonly status: number | null;
30
+ readonly stderr: string;
31
+ readonly stdout: string;
32
+ }
33
+
34
+ // Detached auto maintenance outlives the git call and races the story's removal of its temporary repository.
35
+ export function isolatedGitEnvironment(handed: Readonly<Record<string, string>> = {}): Readonly<Record<string, string | undefined>> {
36
+ return {
37
+ ...Object.fromEntries(INHERITED.map((name) => [name, undefined])),
38
+ "GIT_CONFIG_COUNT": "2",
39
+ "GIT_CONFIG_GLOBAL": "/dev/null",
40
+ "GIT_CONFIG_KEY_0": "gc.auto",
41
+ "GIT_CONFIG_KEY_1": "maintenance.auto",
42
+ "GIT_CONFIG_NOSYSTEM": "1",
43
+ "GIT_CONFIG_VALUE_0": "0",
44
+ "GIT_CONFIG_VALUE_1": "false",
45
+ ...handed,
46
+ };
47
+ }
48
+
49
+ export function isolatedGitCommand(
50
+ command: readonly [string, ...string[]],
51
+ handed: Readonly<Record<string, string>> = {},
52
+ ): readonly [string, ...string[]] {
53
+ const variables = Object.entries(isolatedGitEnvironment(handed)).flatMap(([name, value]) =>
54
+ value === undefined ? ["-u", name] : [`${name}=${value}`],
55
+ );
56
+ return ["env", ...variables, ...command];
57
+ }
58
+
59
+ export function isolatedGit(cwd: string, args: readonly string[], handed: Readonly<Record<string, string>> = {}): GitRun {
60
+ const [command, ...rest] = isolatedGitCommand(["git", ...args], handed);
61
+ const { status, stderr, stdout } = spawnSync(command, rest, { cwd, encoding: "utf8" });
62
+ return { status, stderr, stdout };
63
+ }
@@ -0,0 +1,23 @@
1
+ import { createServer } from "node:http";
2
+ import type { Socket } from "node:net";
3
+
4
+ export function trackedSockets() {
5
+ const sockets = new Set<Socket>();
6
+ const server = createServer().on("connection", (socket) => {
7
+ sockets.add(socket);
8
+ socket.on("close", () => sockets.delete(socket));
9
+ });
10
+ return {
11
+ destroy: () => {
12
+ for (const socket of sockets) {
13
+ socket.destroy();
14
+ }
15
+ },
16
+ pause: () => {
17
+ for (const socket of sockets) {
18
+ socket.pause();
19
+ }
20
+ },
21
+ server,
22
+ };
23
+ }
@@ -0,0 +1,24 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Option from "effect/Option";
3
+ import * as Stream from "effect/Stream";
4
+ import type { LiveAnswerSignal } from "#server/LiveAnswerSignal.ts";
5
+ import { SignalNotReceived } from "#server/until.ts";
6
+
7
+ export const nextLiveAnswer = Effect.fnUntraced(function* (answers: LiveAnswerSignal, before: number, timeoutMs: number) {
8
+ function missing(reason: string) {
9
+ return new SignalNotReceived({
10
+ message: [
11
+ `Waited for a live answer to ${answers.name} after the action above, none arrived: ${reason}.`,
12
+ "help: the server pushed no result for this query after the action. Check that the action changes what the query",
13
+ " reads, or settle without this wait when the command's own reply updates the screen.",
14
+ ].join("\n"),
15
+ });
16
+ }
17
+ const answer = answers.answered.pipe(
18
+ Stream.filter((completed) => completed > before),
19
+ Stream.runHead,
20
+ Effect.flatMap((found) => (Option.isSome(found) ? Effect.void : Effect.fail(missing("the query's answers ended")))),
21
+ );
22
+ const deadline = Effect.sleep(timeoutMs).pipe(Effect.andThen(Effect.fail(missing(`nothing came within ${timeoutMs}ms`))));
23
+ return yield* Effect.raceFirst(answer, deadline);
24
+ });
@@ -0,0 +1,65 @@
1
+ import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
2
+ import { Context, Deferred, Effect, Layer, Queue, Ref } from "effect";
3
+ import { HttpRouter, HttpServer, HttpServerResponse } from "effect/http";
4
+ import * as HttpStatus from "effect/http/HttpStatus";
5
+ import type { Rpc, RpcGroup } from "effect/rpc";
6
+ import { RpcSerialization, RpcServer } from "effect/rpc";
7
+ import { trackedSockets } from "#server/adapters/trackedSockets.ts";
8
+
9
+ export const rpcSocketHost = Effect.fnUntraced(function* <TRpcs extends Rpc.Any, E, R>(
10
+ group: RpcGroup.RpcGroup<TRpcs>,
11
+ handlers: Layer.Layer<Rpc.ToHandler<TRpcs> | Rpc.Middleware<TRpcs>, E, R>,
12
+ ) {
13
+ const sockets = trackedSockets();
14
+ const holding = yield* Ref.make<Deferred.Deferred<void> | undefined>(undefined);
15
+ const refusing = yield* Ref.make(false);
16
+ const count = yield* Ref.make(0);
17
+ const arrived = yield* Queue.unbounded<void>();
18
+ const held = yield* Queue.unbounded<void>();
19
+ const accept = Effect.gen(function* () {
20
+ yield* Ref.set(refusing, false);
21
+ const release = yield* Ref.getAndSet(holding, undefined);
22
+ if (release !== undefined) {
23
+ yield* Deferred.succeed(release, undefined);
24
+ }
25
+ });
26
+ const gate = HttpRouter.middleware((request) =>
27
+ Effect.gen(function* () {
28
+ yield* Ref.update(count, (handshakes) => handshakes + 1);
29
+ yield* Queue.offer(arrived, undefined);
30
+ if (yield* Ref.get(refusing)) {
31
+ return HttpServerResponse.empty({ status: HttpStatus.fromLiteral("ServiceUnavailable") });
32
+ }
33
+ const release = yield* Ref.get(holding);
34
+ if (release !== undefined) {
35
+ yield* Queue.offer(held, undefined);
36
+ yield* Deferred.await(release);
37
+ }
38
+ return yield* request;
39
+ }),
40
+ );
41
+ const routes = RpcServer.layerHttp({ group, path: "/rpc", protocol: "websocket" }).pipe(
42
+ Layer.provide([handlers, RpcSerialization.layerNdjson, gate.layer]),
43
+ );
44
+ const context = yield* Layer.build(
45
+ HttpRouter.serve(routes, { disableLogger: true }).pipe(
46
+ Layer.provideMerge(NodeHttpServer.layer(() => sockets.server, { host: "127.0.0.1", port: 0 })),
47
+ ),
48
+ );
49
+ yield* Effect.addFinalizer(() => Effect.sync(sockets.destroy));
50
+ return {
51
+ accept,
52
+ drop: Effect.sync(sockets.destroy),
53
+ handshakes: Ref.get(count),
54
+ held: Queue.take(held),
55
+ hold: Effect.gen(function* () {
56
+ const release = yield* Deferred.make<void>();
57
+ yield* Ref.set(refusing, false);
58
+ yield* Ref.update(holding, (current) => current ?? release);
59
+ }),
60
+ nextHandshake: Queue.take(arrived),
61
+ pause: Effect.sync(sockets.pause),
62
+ refuse: accept.pipe(Effect.andThen(Ref.set(refusing, true))),
63
+ url: `${HttpServer.formatAddress(Context.get(context, HttpServer.HttpServer).address)}/rpc`,
64
+ };
65
+ });
@@ -4,13 +4,13 @@ import type * as Stream from "effect/Stream";
4
4
  import { withLive } from "@shivaedev/test/withLive.ts";
5
5
  import { directScreenAct, type ScreenAct, screenAct, screenPerform } from "#server/adapters/screenAct.ts";
6
6
  import { screenElements } from "#server/adapters/screenElements.ts";
7
- import { nextScreenHint } from "#server/nextScreenHint.ts";
7
+ import type { LiveAnswerSignal } from "#server/LiveAnswerSignal.ts";
8
+ import { nextLiveAnswer } from "#server/nextLiveAnswer.ts";
8
9
  import { screenInteractions } from "#server/screenInteractions.ts";
9
10
  import { screenReadouts } from "#server/screenReadouts.ts";
10
11
  import type { ScreenSignal } from "#server/screenSignal.ts";
11
12
  import { screenWaits } from "#server/screenWaits.ts";
12
13
  import { targetName } from "#server/targetName.ts";
13
- import type { SignalNotReceived } from "#server/until.ts";
14
14
  import type { ScreenClock } from "#server/watchedClock.ts";
15
15
 
16
16
  export type ScreenTarget = string | { readonly role: string; readonly name: string | RegExp };
@@ -32,27 +32,19 @@ export class MissingScreenPending extends Data.TaggedError("MissingScreenPending
32
32
  "Cannot settle the screen without a completion signal.\nhelp: Supply pending, activity or transport that stays busy until the resulting screen work is ready to render.";
33
33
  }
34
34
 
35
- export class MissingClientActivity extends Data.TaggedError("MissingClientActivity") {
36
- override readonly message =
37
- "Cannot wait for a live hint without client activity.\nhelp: Supply activity or pending: a ScreenSignal with current pending work and a hint sequence.";
38
- }
39
-
40
- export type ScreenDriver<E = never, THintError = MissingClientActivity | SignalNotReceived> = Omit<
41
- ReturnType<typeof makeScreenActions>,
42
- "settle" | "nextLiveHint"
43
- > & {
44
- nextLiveHint: () => Effect.Effect<void, THintError>;
35
+ export type ScreenDriver<E = never> = Omit<ReturnType<typeof makeScreenActions>, "settle"> & {
45
36
  settle: (options?: { readonly timeoutMs?: number }) => Effect.Effect<void, E>;
46
- dialog: (target: ScreenTarget) => ScreenDriver<E, THintError>;
47
- within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E, THintError>;
37
+ dialog: (target: ScreenTarget) => ScreenDriver<E>;
38
+ within: (container: ScreenTarget | HTMLElement) => ScreenDriver<E>;
48
39
  };
49
40
 
50
- export function screenDriver(
51
- options: ScreenDriverOptions & ({ readonly pending: ScreenSignal } | { readonly activity: ScreenSignal }),
52
- ): ScreenDriver<never, SignalNotReceived>;
53
41
  export function screenDriver(
54
42
  options: ScreenDriverOptions &
55
- ({ readonly pending: (() => boolean) | Stream.Stream<boolean> } | { readonly transport: NonNullable<ScreenDriverOptions["transport"]> }),
43
+ (
44
+ | { readonly pending: NonNullable<ScreenDriverOptions["pending"]> }
45
+ | { readonly activity: ScreenSignal }
46
+ | { readonly transport: NonNullable<ScreenDriverOptions["transport"]> }
47
+ ),
56
48
  ): ScreenDriver;
57
49
  export function screenDriver(options: ScreenDriverOptions): ScreenDriver<MissingScreenPending>;
58
50
  export function screenDriver(options: ScreenDriverOptions): ScreenDriver<MissingScreenPending> {
@@ -103,17 +95,18 @@ function makeScreenActions(options: ScreenDriverOptions, dialogs: boolean) {
103
95
  element.click();
104
96
  }),
105
97
  enter: (selector: ScreenTarget, value: string) => perform(`enter a value in ${targetName(selector)}`, () => elements.enter(selector, value)),
106
- nextLiveHint: () => {
107
- const signal = activity ?? pending;
108
- if (signal === undefined || typeof signal === "function" || !("current" in signal)) {
109
- return Effect.fail(new MissingClientActivity());
110
- }
111
- return withLive(Effect.sync(() => tell("wait for the next live hint")).pipe(Effect.andThen(screenAct(act, nextScreenHint(signal)))));
112
- },
113
98
  select: (selector: ScreenTarget, value: string) =>
114
99
  perform(`select ${JSON.stringify(value)} in ${targetName(selector)}`, () => elements.select(selector, value)),
115
100
  settle: (settings?: { readonly timeoutMs?: number }) =>
116
101
  pending === undefined && activity === undefined && transport === undefined ? Effect.fail(new MissingScreenPending()) : waits.settle(settings),
117
102
  submit: (selector: ScreenTarget = "form") => perform(`submit ${targetName(selector)}`, () => elements.form(selector).requestSubmit()),
103
+ withLiveAnswer: <A, E, R>(answers: LiveAnswerSignal, action: Effect.Effect<A, E, R>, settings: { readonly timeoutMs?: number } = {}) =>
104
+ Effect.gen(function* () {
105
+ const before = yield* answers.current;
106
+ const result = yield* action;
107
+ tell(`wait for a live answer to ${answers.name}`);
108
+ yield* withLive(screenAct(act, nextLiveAnswer(answers, before, settings.timeoutMs ?? timeoutMs)));
109
+ return result;
110
+ }),
118
111
  };
119
112
  }
@@ -2,7 +2,6 @@ import type * as Effect from "effect/Effect";
2
2
  import type * as Stream from "effect/Stream";
3
3
 
4
4
  export interface ScreenSignalState {
5
- readonly hints: number;
6
5
  readonly pending: boolean;
7
6
  }
8
7
 
@@ -1,5 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import type { ScreenSignal } from "#server/screenSignal.ts";
3
- import { SignalNotReceived } from "#server/until.ts";
4
- export declare const nextScreenHint: (signal: ScreenSignal) => Effect.Effect<undefined, SignalNotReceived, never>;
5
- //# sourceMappingURL=nextScreenHint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nextScreenHint.d.ts","sourceRoot":"","sources":["../../src/server/nextScreenHint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,cAAc,8EAczB,CAAC"}
@@ -1,14 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Option from "effect/Option";
3
- import * as Stream from "effect/Stream";
4
- import { SignalNotReceived } from "#server/until.ts";
5
- export const nextScreenHint = Effect.fnUntraced(function* (signal) {
6
- const before = (yield* signal.current).hints;
7
- const hint = yield* signal.pipe(Stream.filter((state) => state.hints > before), Stream.runHead);
8
- if (Option.isNone(hint)) {
9
- return yield* Effect.fail(new SignalNotReceived({
10
- message: 'Signal "next live hint" never arrived: the client activity stream ended.\nhelp: Keep the client activity stream open until the action delivers a live hint.',
11
- }));
12
- }
13
- });
14
- //# sourceMappingURL=nextScreenHint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nextScreenHint.js","sourceRoot":"","sources":["../../src/server/nextScreenHint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAoB;IAC9E,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,EAC9C,MAAM,CAAC,OAAO,CACd,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACxB,IAAI,iBAAiB,CAAC;YACrB,OAAO,EACN,6JAA6J;SAC9J,CAAC,CACF,CAAC;IACH,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -1,21 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Option from "effect/Option";
3
- import * as Stream from "effect/Stream";
4
- import type { ScreenSignal } from "#server/screenSignal.ts";
5
- import { SignalNotReceived } from "#server/until.ts";
6
-
7
- export const nextScreenHint = Effect.fnUntraced(function* (signal: ScreenSignal) {
8
- const before = (yield* signal.current).hints;
9
- const hint = yield* signal.pipe(
10
- Stream.filter((state) => state.hints > before),
11
- Stream.runHead,
12
- );
13
- if (Option.isNone(hint)) {
14
- return yield* Effect.fail(
15
- new SignalNotReceived({
16
- message:
17
- 'Signal "next live hint" never arrived: the client activity stream ended.\nhelp: Keep the client activity stream open until the action delivers a live hint.',
18
- }),
19
- );
20
- }
21
- });