effect-browser 0.2.0-beta.9 → 0.3.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +849 -1161
- package/dist/Browser-S4kvpmqa.mjs +605 -0
- package/dist/Browser-S4kvpmqa.mjs.map +1 -0
- package/dist/Browser.d.mts +127 -3
- package/dist/Browser.mjs +2 -22
- package/dist/BrowserError-Coy7EW1N.d.mts +140 -0
- package/dist/BrowserError.d.mts +2 -0
- package/dist/BrowserError.mjs +211 -0
- package/dist/BrowserError.mjs.map +1 -0
- package/dist/BrowserEvent-BRu2juEz.d.mts +279 -0
- package/dist/BrowserEvent.d.mts +2 -0
- package/dist/BrowserEvent.mjs +297 -0
- package/dist/BrowserEvent.mjs.map +1 -0
- package/dist/Cdp.d.mts +32 -0
- package/dist/Cdp.mjs +61 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change-DNvztNLu.mjs +138 -0
- package/dist/Change-DNvztNLu.mjs.map +1 -0
- package/dist/Change-iMlcuzVD.d.mts +71 -0
- package/dist/Change.d.mts +2 -0
- package/dist/Change.mjs +2 -0
- package/dist/Chromium.d.mts +29 -81
- package/dist/Chromium.mjs +57 -392
- package/dist/Chromium.mjs.map +1 -1
- package/dist/Expect.d.mts +62 -0
- package/dist/Expect.mjs +114 -0
- package/dist/Expect.mjs.map +1 -0
- package/dist/Frame-BERmf_gM.d.mts +117 -0
- package/dist/Frame.d.mts +2 -0
- package/dist/Frame.mjs +123 -0
- package/dist/Frame.mjs.map +1 -0
- package/dist/Moment.d.mts +2 -0
- package/dist/Moment.mjs +288 -0
- package/dist/Moment.mjs.map +1 -0
- package/dist/Motion.d.mts +40 -0
- package/dist/Motion.mjs +122 -0
- package/dist/Motion.mjs.map +1 -0
- package/dist/Page-B5cjaUp5.mjs +618 -0
- package/dist/Page-B5cjaUp5.mjs.map +1 -0
- package/dist/Page-BlPjfibv.d.mts +595 -0
- package/dist/Page.d.mts +2 -0
- package/dist/Page.mjs +2 -0
- package/dist/Plan-BI8XGvDu.d.mts +209 -0
- package/dist/Plan-D1wrJVs8.mjs +508 -0
- package/dist/Plan-D1wrJVs8.mjs.map +1 -0
- package/dist/Plan.d.mts +2 -3
- package/dist/Plan.mjs +2 -2
- package/dist/Policy.d.mts +76 -0
- package/dist/Policy.mjs +237 -0
- package/dist/Policy.mjs.map +1 -0
- package/dist/Presentation.d.mts +48 -0
- package/dist/Presentation.mjs +117 -0
- package/dist/Presentation.mjs.map +1 -0
- package/dist/Snapshot-B34hZ4Jl.d.mts +68 -0
- package/dist/Snapshot.d.mts +2 -0
- package/dist/Snapshot.mjs +79 -0
- package/dist/Snapshot.mjs.map +1 -0
- package/dist/Stage.d.mts +64 -0
- package/dist/Stage.mjs +237 -0
- package/dist/Stage.mjs.map +1 -0
- package/dist/Supervisor-CYWFK3vM.d.mts +280 -0
- package/dist/Supervisor-TNKNOVzu.mjs +599 -0
- package/dist/Supervisor-TNKNOVzu.mjs.map +1 -0
- package/dist/Supervisor.d.mts +2 -0
- package/dist/Supervisor.mjs +2 -0
- package/dist/context-B6xr8nVi.mjs +261 -0
- package/dist/context-B6xr8nVi.mjs.map +1 -0
- package/dist/index.d.mts +17 -14
- package/dist/index.mjs +18 -13
- package/dist/match.inpage-xOe9LNO0.mjs +48 -0
- package/dist/match.inpage-xOe9LNO0.mjs.map +1 -0
- package/dist/page-B8tUQELg.mjs +5073 -0
- package/dist/page-B8tUQELg.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/url-Cd04Okid.mjs +264 -0
- package/dist/url-Cd04Okid.mjs.map +1 -0
- package/package.json +96 -61
- package/src/Browser.ts +666 -0
- package/src/BrowserError.ts +234 -0
- package/src/BrowserEvent.ts +296 -0
- package/src/Cdp.ts +101 -0
- package/src/Change.ts +88 -0
- package/src/Chromium.ts +102 -0
- package/src/Expect.ts +180 -0
- package/src/Frame.ts +130 -0
- package/src/Moment.ts +479 -0
- package/src/Motion.ts +166 -0
- package/src/Page.ts +522 -0
- package/src/Plan.ts +663 -0
- package/src/Policy.ts +325 -0
- package/src/Presentation.ts +195 -0
- package/src/Snapshot.ts +89 -0
- package/src/Stage.ts +467 -0
- package/src/Supervisor.ts +599 -0
- package/src/index.ts +20 -0
- package/src/internal/input/actions.ts +610 -0
- package/src/internal/input/dispatch.ts +161 -0
- package/src/internal/input/edit.inpage.ts +162 -0
- package/src/internal/input/evidence.inpage.ts +164 -0
- package/src/internal/input/gate.ts +224 -0
- package/src/internal/input/guard.inpage.ts +605 -0
- package/src/internal/input/guard.ts +184 -0
- package/src/internal/input/keyboard.ts +112 -0
- package/src/internal/input/keys.ts +127 -0
- package/src/internal/input/perform.ts +376 -0
- package/src/internal/input/pointer.ts +153 -0
- package/src/internal/input/replies.ts +195 -0
- package/src/internal/input/settle.ts +50 -0
- package/src/internal/input/style.ts +186 -0
- package/src/internal/input/targets.inpage.ts +293 -0
- package/src/internal/input/targets.ts +148 -0
- package/src/internal/page/bridge.ts +386 -0
- package/src/internal/page/context.ts +312 -0
- package/src/internal/page/lane.ts +311 -0
- package/src/internal/page/navigation.ts +183 -0
- package/src/internal/page/openings.ts +87 -0
- package/src/internal/page/page.ts +165 -0
- package/src/internal/page/url.ts +100 -0
- package/src/internal/page/viewport.ts +43 -0
- package/src/internal/pictures/capture.ts +776 -0
- package/src/internal/pictures/clock.ts +141 -0
- package/src/internal/pictures/counts.ts +92 -0
- package/src/internal/pictures/pictures.ts +520 -0
- package/src/internal/pictures/transport.ts +242 -0
- package/src/internal/reading/choose.ts +100 -0
- package/src/internal/reading/context.inpage.ts +201 -0
- package/src/internal/reading/controls.inpage.ts +158 -0
- package/src/internal/reading/expect.inpage.ts +70 -0
- package/src/internal/reading/match.inpage.ts +92 -0
- package/src/internal/reading/names.inpage.ts +306 -0
- package/src/internal/reading/outline.inpage.ts +260 -0
- package/src/internal/reading/reading.ts +223 -0
- package/src/internal/reading/ready.inpage.ts +164 -0
- package/src/internal/reading/ready.ts +111 -0
- package/src/internal/reading/subjects.inpage.ts +188 -0
- package/src/internal/reading/text.inpage.ts +135 -0
- package/src/internal/reading/walk.inpage.ts +220 -0
- package/src/internal/supervisor/lifecycle.ts +416 -0
- package/src/internal/timeline/changes.inpage.ts +216 -0
- package/src/internal/timeline/changes.ts +100 -0
- package/src/internal/timeline/events.ts +94 -0
- package/src/internal/timeline/fold.inpage.ts +123 -0
- package/src/internal/timeline/history.inpage.ts +229 -0
- package/src/internal/timeline/marks.inpage.ts +207 -0
- package/src/internal/timeline/record.inpage.ts +133 -0
- package/src/internal/timeline/sight.inpage.ts +122 -0
- package/src/internal/timeline/window.ts +96 -0
- package/src/internal/timeline/words.ts +65 -0
- package/dist/Bootstrap-B9UUXsvF.d.mts +0 -183
- package/dist/Bootstrap-CeQOWBy6.mjs +0 -189
- package/dist/Bootstrap-CeQOWBy6.mjs.map +0 -1
- package/dist/Bootstrap.d.mts +0 -3
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-BF9_sORP.d.mts +0 -388
- package/dist/Browser.mjs.map +0 -1
- package/dist/BrowserData-CPIIIHol.d.mts +0 -585
- package/dist/BrowserData.d.mts +0 -3
- package/dist/BrowserData.mjs +0 -695
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/BrowserRuntime-B6nT1G4X.d.mts +0 -148
- package/dist/BrowserRuntime-C1r2aSRK.mjs +0 -6820
- package/dist/BrowserRuntime-C1r2aSRK.mjs.map +0 -1
- package/dist/BrowserRuntime.d.mts +0 -3
- package/dist/BrowserRuntime.mjs +0 -3
- package/dist/Capture.d.mts +0 -56
- package/dist/Capture.mjs +0 -678
- package/dist/Capture.mjs.map +0 -1
- package/dist/CaptureData-CYriZHX1.mjs +0 -201
- package/dist/CaptureData-CYriZHX1.mjs.map +0 -1
- package/dist/CaptureData.d.mts +0 -219
- package/dist/CaptureData.mjs +0 -2
- package/dist/Errors.d.mts +0 -158
- package/dist/Errors.mjs +0 -207
- package/dist/Errors.mjs.map +0 -1
- package/dist/Images-yCG9BmRU.mjs +0 -76
- package/dist/Images-yCG9BmRU.mjs.map +0 -1
- package/dist/OperationOptions-DAeRS6O9.mjs +0 -55
- package/dist/OperationOptions-DAeRS6O9.mjs.map +0 -1
- package/dist/PageControl.d.mts +0 -15
- package/dist/PageControl.mjs +0 -34
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageRegistry-B3q9DS3g.mjs +0 -164
- package/dist/PageRegistry-B3q9DS3g.mjs.map +0 -1
- package/dist/Plan-Dyxu2q8C.mjs +0 -543
- package/dist/Plan-Dyxu2q8C.mjs.map +0 -1
- package/dist/PlanData-B668RxbQ.d.mts +0 -4831
- package/dist/PlanData.d.mts +0 -3
- package/dist/PlanData.mjs +0 -268
- package/dist/PlanData.mjs.map +0 -1
- package/dist/PlanInput-BJcPPncs.mjs +0 -75
- package/dist/PlanInput-BJcPPncs.mjs.map +0 -1
- package/dist/PublicSession-DCSMMqOj.mjs +0 -5602
- package/dist/PublicSession-DCSMMqOj.mjs.map +0 -1
- package/dist/Testing.d.mts +0 -479
- package/dist/Testing.mjs +0 -2147
- package/dist/Testing.mjs.map +0 -1
- package/dist/Timeline-fV22Xk-S.d.mts +0 -29
- package/dist/Timeline.d.mts +0 -4
- package/dist/Timeline.mjs +0 -20
- package/dist/Timeline.mjs.map +0 -1
- package/dist/TimelineData-BsOn-YGZ.d.mts +0 -3818
- package/dist/TimelineData.d.mts +0 -3
- package/dist/TimelineData.mjs +0 -482
- package/dist/TimelineData.mjs.map +0 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { c as DisconnectCause } from "./BrowserEvent-BRu2juEz.mjs";
|
|
2
|
+
import { Service, t as Browser_d_exports } from "./Browser.mjs";
|
|
3
|
+
import { Cause, Duration, Effect, Schedule, Schema, Scope, Stream } from "effect";
|
|
4
|
+
declare namespace lifecycle_d_exports {
|
|
5
|
+
export { Closed, Command, Down, Drain, Draining, GenerationState, Held, Input, Kept, Live, Lost, Open, Opening, Released, Reopening, Resolution, Settled, State, Step, Unconfirmed, lookup, resolve, start, transition };
|
|
6
|
+
}
|
|
7
|
+
declare const Settled_base: Schema.Class<Settled, Schema.TaggedStruct<"Settled", {}>, {}>;
|
|
8
|
+
/** The provider confirmed that the generation's browser ended. */
|
|
9
|
+
declare class Settled extends Settled_base {}
|
|
10
|
+
declare const Unconfirmed_base: Schema.Class<Unconfirmed, Schema.TaggedStruct<"Unconfirmed", {
|
|
11
|
+
readonly detail: Schema.String;
|
|
12
|
+
}>, {}>;
|
|
13
|
+
/** The provider could not confirm the end by its deadline, so the browser may still run, and bill. */
|
|
14
|
+
declare class Unconfirmed extends Unconfirmed_base {}
|
|
15
|
+
declare const Released: Schema.Union<readonly [typeof Settled, typeof Unconfirmed]>;
|
|
16
|
+
type Released = typeof Released.Type;
|
|
17
|
+
declare const Opening_base: Schema.Class<Opening, Schema.TaggedStruct<"Opening", {}>, {}>;
|
|
18
|
+
/** Opening, but not after a loss: the first generation, a rotation, or the one after `Down`. */
|
|
19
|
+
declare class Opening extends Opening_base {}
|
|
20
|
+
declare const Reopening_base: Schema.Class<Reopening, Schema.TaggedStruct<"Reopening", {}>, {}>;
|
|
21
|
+
/** Opening after the generation before it was lost. */
|
|
22
|
+
declare class Reopening extends Reopening_base {}
|
|
23
|
+
declare const Open_base: Schema.Class<Open, Schema.TaggedStruct<"Open", {}>, {}>;
|
|
24
|
+
/** Open: `browser` gives this generation until the next one opens. */
|
|
25
|
+
declare class Open extends Open_base {}
|
|
26
|
+
declare const Draining_base: Schema.Class<Draining, Schema.TaggedStruct<"Draining", {
|
|
27
|
+
readonly reason: Schema.Literals<readonly ["rotated", "lost", "retired"]>;
|
|
28
|
+
readonly revokeAt: Schema.Finite;
|
|
29
|
+
}>, {}>;
|
|
30
|
+
/** No longer serving; holds end at this host-monotonic deadline or when their owners let go. */
|
|
31
|
+
declare class Draining extends Draining_base {}
|
|
32
|
+
declare const Lost_base: Schema.Class<Lost, Schema.TaggedStruct<"Lost", {
|
|
33
|
+
readonly cause: Schema.Literals<readonly ["connection", "session", "released"]>;
|
|
34
|
+
}>, {}>;
|
|
35
|
+
/** Lost: its connection dropped, or its provider ended its session, as `cause` says. */
|
|
36
|
+
declare class Lost extends Lost_base {}
|
|
37
|
+
declare const Down_base: Schema.Class<Down, Schema.TaggedStruct<"Down", {
|
|
38
|
+
readonly detail: Schema.String;
|
|
39
|
+
readonly cause: Schema.Defect;
|
|
40
|
+
}>, {}>;
|
|
41
|
+
/**
|
|
42
|
+
* It never opened: its last try failed with `cause`, which the provider deems definite, or after
|
|
43
|
+
* which the reopen schedule gave up.
|
|
44
|
+
*/
|
|
45
|
+
declare class Down extends Down_base {}
|
|
46
|
+
declare const Closed_base: Schema.Class<Closed, Schema.TaggedStruct<"Closed", {
|
|
47
|
+
readonly released: Schema.optional<Schema.Union<readonly [typeof Settled, typeof Unconfirmed]>>;
|
|
48
|
+
}>, {}>;
|
|
49
|
+
/** It ended. `released` says how its release went; one retired while opening has none. */
|
|
50
|
+
declare class Closed extends Closed_base {}
|
|
51
|
+
declare const Kept_base: Schema.Class<Kept, Schema.TaggedStruct<"Kept", {}>, {}>;
|
|
52
|
+
/**
|
|
53
|
+
* It was serving as the supervisor's scope closed, and was left running, not released: its scope
|
|
54
|
+
* closed, and its provider runs it on, and bills, until something adopts and releases it.
|
|
55
|
+
*/
|
|
56
|
+
declare class Kept extends Kept_base {}
|
|
57
|
+
declare const GenerationState: Schema.Union<readonly [typeof Opening, typeof Reopening, typeof Open, typeof Draining, typeof Lost, typeof Down, typeof Closed, typeof Kept]>;
|
|
58
|
+
type GenerationState = typeof GenerationState.Type;
|
|
59
|
+
/** A generation that opened: its number, and what the runtime keeps to serve and end it. */
|
|
60
|
+
interface Live<A> {
|
|
61
|
+
readonly number: number;
|
|
62
|
+
readonly value: A;
|
|
63
|
+
}
|
|
64
|
+
interface Held<A, H> extends Live<A> {
|
|
65
|
+
readonly holds: ReadonlySet<H>;
|
|
66
|
+
}
|
|
67
|
+
/** Release ownership remains here until the provider and generation scope have finished. */
|
|
68
|
+
interface Drain<A, H> {
|
|
69
|
+
readonly _tag: "Draining" | "Releasing" | "Leaving";
|
|
70
|
+
readonly live: Held<A, H>;
|
|
71
|
+
readonly ending: Draining;
|
|
72
|
+
}
|
|
73
|
+
/** One serving generation, one shared acquisition, and prior generations still owned. */
|
|
74
|
+
type State<A, H = unknown> = ({
|
|
75
|
+
readonly _tag: "Opening";
|
|
76
|
+
readonly number: number;
|
|
77
|
+
readonly serving: Held<A, H> | undefined;
|
|
78
|
+
} | {
|
|
79
|
+
readonly _tag: "Open";
|
|
80
|
+
readonly serving: Held<A, H>;
|
|
81
|
+
} | {
|
|
82
|
+
readonly _tag: "Down";
|
|
83
|
+
readonly number: number;
|
|
84
|
+
readonly detail: string;
|
|
85
|
+
readonly cause: unknown;
|
|
86
|
+
readonly serving: Held<A, H> | undefined;
|
|
87
|
+
} | {
|
|
88
|
+
readonly _tag: "Retired";
|
|
89
|
+
}) & {
|
|
90
|
+
readonly draining: ReadonlyMap<number, Drain<A, H>>;
|
|
91
|
+
};
|
|
92
|
+
type Input<A, H = unknown> = {
|
|
93
|
+
readonly _tag: "Opened";
|
|
94
|
+
readonly live: Live<A>;
|
|
95
|
+
} | {
|
|
96
|
+
readonly _tag: "Failed";
|
|
97
|
+
readonly number: number;
|
|
98
|
+
readonly detail: string;
|
|
99
|
+
readonly cause: unknown;
|
|
100
|
+
} | {
|
|
101
|
+
readonly _tag: "Abandoned";
|
|
102
|
+
readonly number: number;
|
|
103
|
+
} | {
|
|
104
|
+
readonly _tag: "Lost";
|
|
105
|
+
readonly number: number;
|
|
106
|
+
readonly cause: DisconnectCause;
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: "Rotate";
|
|
109
|
+
readonly due?: number | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
readonly _tag: "Retire";
|
|
112
|
+
} | {
|
|
113
|
+
readonly _tag: "Keep";
|
|
114
|
+
} | {
|
|
115
|
+
readonly _tag: "Hold";
|
|
116
|
+
readonly number?: number | undefined;
|
|
117
|
+
readonly hold: H;
|
|
118
|
+
} | {
|
|
119
|
+
readonly _tag: "Let";
|
|
120
|
+
readonly number: number;
|
|
121
|
+
readonly hold: H;
|
|
122
|
+
} | {
|
|
123
|
+
readonly _tag: "Revoke";
|
|
124
|
+
readonly number: number;
|
|
125
|
+
} | {
|
|
126
|
+
readonly _tag: "Released";
|
|
127
|
+
readonly number: number;
|
|
128
|
+
readonly released?: Released | undefined;
|
|
129
|
+
};
|
|
130
|
+
type Command<A> = {
|
|
131
|
+
readonly _tag: "Open";
|
|
132
|
+
readonly number: number;
|
|
133
|
+
readonly after: number | undefined;
|
|
134
|
+
} | {
|
|
135
|
+
readonly _tag: "Watch";
|
|
136
|
+
readonly live: Live<A>;
|
|
137
|
+
} |
|
|
138
|
+
/** Signal ending and arrange revocation. Repeated only when loss/retirement accelerates it. */
|
|
139
|
+
{
|
|
140
|
+
readonly _tag: "Drain";
|
|
141
|
+
readonly live: Live<A>;
|
|
142
|
+
readonly ending: Draining;
|
|
143
|
+
} |
|
|
144
|
+
/** Revoke/close holds, await their Let inputs, release the provider, then close its scope. */
|
|
145
|
+
{
|
|
146
|
+
readonly _tag: "Release";
|
|
147
|
+
readonly live: Live<A>;
|
|
148
|
+
readonly ending: Draining;
|
|
149
|
+
} | {
|
|
150
|
+
readonly _tag: "Leave";
|
|
151
|
+
readonly live: Live<A>;
|
|
152
|
+
readonly ending: Draining;
|
|
153
|
+
};
|
|
154
|
+
interface Step<A, H = unknown> {
|
|
155
|
+
readonly state: State<A, H>;
|
|
156
|
+
readonly events: ReadonlyArray<readonly [number, GenerationState]>;
|
|
157
|
+
readonly commands: ReadonlyArray<Command<A>>;
|
|
158
|
+
readonly reply?: number | undefined;
|
|
159
|
+
readonly borrowed?: Live<A> | undefined;
|
|
160
|
+
}
|
|
161
|
+
declare const start: <A, H = unknown>() => Step<A, H>;
|
|
162
|
+
/** The holds still owned for a generation, including one whose release has begun. */
|
|
163
|
+
declare const lookup: <A, H>(state: State<A, H>, number: number) => Held<A, H> | undefined;
|
|
164
|
+
/** Pure admission and lifecycle changes. A rejected hold preserves state identity. */
|
|
165
|
+
declare const transition: <A, H = unknown>(state: State<A, H>, input: Input<A, H>, exclusive: boolean, now?: number, handover?: number) => Step<A, H>;
|
|
166
|
+
type Resolution<A> = {
|
|
167
|
+
readonly _tag: "Serve";
|
|
168
|
+
readonly live: Live<A>;
|
|
169
|
+
} | {
|
|
170
|
+
readonly _tag: "Unavailable";
|
|
171
|
+
readonly reason: "down" | "retired";
|
|
172
|
+
readonly detail: string;
|
|
173
|
+
readonly cause?: unknown;
|
|
174
|
+
};
|
|
175
|
+
/** An unheld browser resolution; use obtains its hold atomically through Hold instead. */
|
|
176
|
+
declare const resolve: <A, H>(state: State<A, H>, target: number | undefined) => Resolution<A> | undefined;
|
|
177
|
+
declare namespace Supervisor_d_exports {
|
|
178
|
+
export { Closed, Down, Draining, Generation, GenerationState, Kept, Lease, Lost, Open, Opened, Opening, Options, Released, Reopening, Settled, Superseded, Supervisor, Unavailable, Unconfirmed, UseOptions, make };
|
|
179
|
+
}
|
|
180
|
+
declare const Generation_base: Schema.Class<Generation, Schema.Struct<{
|
|
181
|
+
readonly number: Schema.Int;
|
|
182
|
+
readonly at: Schema.Finite;
|
|
183
|
+
readonly hostTime: Schema.Finite;
|
|
184
|
+
readonly state: Schema.Union<readonly [typeof Opening, typeof Reopening, typeof Open, typeof Draining, typeof Lost, typeof Down, typeof Closed, typeof Kept]>;
|
|
185
|
+
}>, {}>;
|
|
186
|
+
/** One change in a generation's life. `at` is wall-clock epoch milliseconds from the Effect `Clock`. */
|
|
187
|
+
declare class Generation extends Generation_base {}
|
|
188
|
+
declare const Unavailable_base: Schema.Class<Unavailable, Schema.TaggedStruct<"Unavailable", {
|
|
189
|
+
readonly reason: Schema.Literals<readonly ["opening", "down", "retired"]>;
|
|
190
|
+
readonly detail: Schema.String;
|
|
191
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
192
|
+
}>, Cause.YieldableError>;
|
|
193
|
+
/**
|
|
194
|
+
* No browser to give: none opened within `waitTimeout` (`opening`), the latest generation failed
|
|
195
|
+
* to open (`down`, with what it failed with as `cause`), or the supervisor was retired.
|
|
196
|
+
*/
|
|
197
|
+
declare class Unavailable extends Unavailable_base {
|
|
198
|
+
get message(): string;
|
|
199
|
+
}
|
|
200
|
+
/** One generation, as a provider opened it in the scope the supervisor gave it. */
|
|
201
|
+
interface Opened<A = void> {
|
|
202
|
+
readonly value: A;
|
|
203
|
+
readonly browser: Service;
|
|
204
|
+
/**
|
|
205
|
+
* End the generation, and say whether the provider confirmed its end. The supervisor asks it
|
|
206
|
+
* before it closes the generation's scope; without it, closing the scope ends the generation,
|
|
207
|
+
* which counts as `Settled`.
|
|
208
|
+
*/
|
|
209
|
+
readonly release?: Effect.Effect<Released> | undefined;
|
|
210
|
+
}
|
|
211
|
+
interface Options<E, R, A = void> {
|
|
212
|
+
/** Opens one generation in the scope it is given. */
|
|
213
|
+
readonly open: Effect.Effect<Opened<A>, E, R>;
|
|
214
|
+
/** When to try a failed open again. Defaults to exponential from 1 second, for 5 minutes. */
|
|
215
|
+
readonly reopen?: Schedule.Schedule<unknown, E> | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* Failures no new try mends, such as a refused key: an open that fails so is `Down` at once.
|
|
218
|
+
* Defaults to none.
|
|
219
|
+
*/
|
|
220
|
+
readonly definite?: ((error: E) => boolean) | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Rotate this long ahead of a generation's `expiresAt`, but no sooner than halfway through its
|
|
223
|
+
* life. Without it, a generation's end is a loss.
|
|
224
|
+
*/
|
|
225
|
+
readonly rotateBefore?: Duration.Input | undefined;
|
|
226
|
+
/** Generations must not overlap: a rotation releases the current one before it opens the next. */
|
|
227
|
+
readonly exclusive?: boolean | undefined;
|
|
228
|
+
/** Finite, nonnegative time outgoing holds may finish; defaults to 30 seconds. */
|
|
229
|
+
readonly handover?: Duration.Input | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Closing the scope leaves the serving generation running, `Kept`: it closes the generation's
|
|
232
|
+
* scope but never asks `release`. For providers whose scope only disconnects, such as
|
|
233
|
+
* `Browserbase.supervise` with `keep`. `retire` still releases it.
|
|
234
|
+
*/
|
|
235
|
+
readonly keep?: boolean | undefined;
|
|
236
|
+
/** How long `browser` and `rotate` wait for a generation to open. Defaults to 2 minutes. */
|
|
237
|
+
readonly waitTimeout?: Duration.Input | undefined;
|
|
238
|
+
}
|
|
239
|
+
declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
|
|
240
|
+
readonly generation: Schema.Int;
|
|
241
|
+
readonly reason: Schema.Literals<readonly ["rotated", "lost", "retired"]>;
|
|
242
|
+
readonly revokeAt: Schema.Finite;
|
|
243
|
+
}>, Cause.YieldableError>;
|
|
244
|
+
/** Work whose generation was revoked; input receipts still determine whether input reached a site. */
|
|
245
|
+
declare class Superseded extends Superseded_base {}
|
|
246
|
+
interface Lease<A> {
|
|
247
|
+
readonly generation: number;
|
|
248
|
+
readonly browser: Service;
|
|
249
|
+
readonly value: A;
|
|
250
|
+
/** First notice that serving ended; loss or retirement may revoke before its deadline. */
|
|
251
|
+
readonly ending: Effect.Effect<Superseded>;
|
|
252
|
+
/** An independent scope; its resources close before provider release. Fails once revoked. */
|
|
253
|
+
readonly retain: Effect.Effect<Scope.Closeable, Superseded>;
|
|
254
|
+
}
|
|
255
|
+
interface UseOptions {
|
|
256
|
+
/** Finite, nonnegative wait for a serving generation. Zero makes an immediate attempt. */
|
|
257
|
+
readonly wait?: Duration.Input | undefined;
|
|
258
|
+
}
|
|
259
|
+
interface Supervisor<A = void> {
|
|
260
|
+
/** Scoped work on the current generation. Revocation interrupts it and waits for its cleanup. */
|
|
261
|
+
readonly use: <B, E, R>(work: (lease: Lease<A>) => Effect.Effect<B, E, R>, options?: UseOptions) => Effect.Effect<B, E | Unavailable | Superseded, Exclude<R, Scope.Scope>>;
|
|
262
|
+
/** The current generation's browser, waiting up to `waitTimeout` while none is open. */
|
|
263
|
+
readonly browser: Effect.Effect<Service, Unavailable>;
|
|
264
|
+
/** Each generation's changes, in order. A new reader first gets the latest 64; ends on retiring. */
|
|
265
|
+
readonly states: Stream.Stream<Generation>;
|
|
266
|
+
/** Open the next generation now, or join the one opening, and wait for it. */
|
|
267
|
+
readonly rotate: Effect.Effect<Service, Unavailable>;
|
|
268
|
+
/** Stop opening at once, release every generation, and wait until each release has finished. */
|
|
269
|
+
readonly retire: Effect.Effect<void>;
|
|
270
|
+
}
|
|
271
|
+
type Provider = Omit<Opened, "value">;
|
|
272
|
+
type MakeOptions<E, R, A> = Omit<Options<E, R, A>, "open"> & {
|
|
273
|
+
readonly open: Effect.Effect<Opened<A> | Provider, E, R>;
|
|
274
|
+
};
|
|
275
|
+
/** Supervise scoped generation values. Browser-only providers retain their existing void value. */
|
|
276
|
+
declare function make<E, R, A = void>(options: Options<E, R, A>): Effect.Effect<Supervisor<A>, never, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
277
|
+
declare function make<E, R>(options: MakeOptions<E, R, never>): Effect.Effect<Supervisor<void>, never, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
278
|
+
//#endregion
|
|
279
|
+
export { Unconfirmed as S, Open as _, Superseded as a, Reopening as b, Unavailable as c, Closed as d, Down as f, Lost as g, Kept as h, Options as i, UseOptions as l, GenerationState as m, Lease as n, Supervisor as o, Draining as p, Opened as r, Supervisor_d_exports as s, Generation as t, make as u, Opening as v, Settled as x, Released as y };
|
|
280
|
+
//# sourceMappingURL=Supervisor-CYWFK3vM.d.mts.map
|