Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

runtime.ts

61 lines1.8 KB

1import { Connection } from "@t3tools/client-runtime/connection";
2import { ShellSnapshotLoader } from "@t3tools/client-runtime/state/shell";
3import {
4 boundedThreadSnapshotLoaderLayer,
5 ThreadHistoryController,
6} from "@t3tools/client-runtime/state/threads";
7import { PullRequestDiffLoader } from "@t3tools/client-runtime/state/pull-requests";
8import * as Layer from "effect/Layer";
9import { Atom } from "effect/unstable/reactivity";
10​
11import { runtimeContextLayer } from "../lib/runtime";
12import {
13 backgroundActivityObserverLayer,
14 backgroundActivityReporterLayer,
15} from "../lib/backgroundActivityReporter";
16import { connectionPlatformLayer } from "./platform";
17​
18const providedConnectionPlatformLayer = connectionPlatformLayer.pipe(
19 Layer.provide(runtimeContextLayer),
20);
21​
22const snapshotLoaderLayer = Layer.mergeAll(
23 boundedThreadSnapshotLoaderLayer,
24 ShellSnapshotLoader.layer,
25 ThreadHistoryController.layer,
26 PullRequestDiffLoader.layer,
27);
28​
29type ConnectionLayerSource =
30 | typeof Connection.layer
31 | typeof snapshotLoaderLayer
32 | typeof runtimeContextLayer
33 | typeof connectionPlatformLayer
34 | typeof backgroundActivityObserverLayer
35 | typeof backgroundActivityReporterLayer;
36​
37const providedClientConnectionLayer = snapshotLoaderLayer.pipe(
38 Layer.provideMerge(
39 Connection.layerWithOptions({
40 environmentThemes: true,
41 usageLimitSources: true,
42 usageLimitsCommand: true,
43 }),
44 ),
45 Layer.provideMerge(
46 Layer.mergeAll(
47 runtimeContextLayer,
48 providedConnectionPlatformLayer,
49 backgroundActivityObserverLayer,
50 ),
51 ),
52);
53​
54const connectionLayer = backgroundActivityReporterLayer.pipe(
55 Layer.provideMerge(providedClientConnectionLayer),
56);
57​
58export const connectionAtomRuntime: Atom.AtomRuntime<
59 Layer.Success<ConnectionLayerSource>,
60 Layer.Error<ConnectionLayerSource>
61> = Atom.runtime(connectionLayer);