effect-start 0.20.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/Cookies.js +392 -0
- package/dist/FileSystem.js +131 -0
- package/dist/Socket.js +37 -0
- package/package.json +39 -40
- package/src/Commander.ts +73 -130
- package/src/ContentNegotiation.ts +68 -100
- package/src/Cookies.ts +408 -0
- package/src/Development.ts +48 -63
- package/src/Effectify.ts +222 -206
- package/src/Entity.ts +59 -86
- package/src/FilePathPattern.ts +5 -5
- package/src/FileRouter.ts +38 -63
- package/src/FileRouterCodegen.ts +64 -56
- package/src/FileSystem.ts +390 -0
- package/src/Http.ts +17 -50
- package/src/PathPattern.ts +33 -41
- package/src/PlatformError.ts +29 -50
- package/src/PlatformRuntime.ts +39 -47
- package/src/Route.ts +68 -187
- package/src/RouteBody.ts +45 -161
- package/src/RouteHook.ts +22 -45
- package/src/RouteHttp.ts +88 -142
- package/src/RouteHttpTracer.ts +25 -26
- package/src/RouteMount.ts +100 -238
- package/src/RouteSchema.ts +67 -201
- package/src/RouteSse.ts +28 -82
- package/src/RouteTree.ts +31 -79
- package/src/RouteTrie.ts +13 -32
- package/src/SchemaExtra.ts +3 -5
- package/src/Socket.ts +51 -0
- package/src/Start.ts +20 -21
- package/src/StreamExtra.ts +93 -96
- package/src/TuplePathPattern.ts +54 -43
- package/src/Unique.ts +9 -15
- package/src/Values.ts +26 -30
- package/src/bun/BunBundle.ts +27 -73
- package/src/bun/BunImportTrackerPlugin.ts +67 -65
- package/src/bun/BunRoute.ts +12 -31
- package/src/bun/BunRuntime.ts +3 -10
- package/src/bun/BunServer.ts +50 -60
- package/src/bun/BunVirtualFilesPlugin.ts +1 -4
- package/src/bun/_BunEnhancedResolve.ts +17 -42
- package/src/bun/_empty.html +0 -1
- package/src/bundler/Bundle.ts +20 -36
- package/src/bundler/BundleFiles.ts +36 -56
- package/src/client/Overlay.ts +1 -2
- package/src/client/ScrollState.ts +5 -9
- package/src/client/index.ts +10 -13
- package/src/datastar/actions/fetch.ts +29 -48
- package/src/datastar/actions/peek.ts +1 -5
- package/src/datastar/actions/setAll.ts +2 -2
- package/src/datastar/actions/toggleAll.ts +2 -2
- package/src/datastar/attributes/attr.ts +17 -18
- package/src/datastar/attributes/bind.ts +41 -61
- package/src/datastar/attributes/class.ts +2 -5
- package/src/datastar/attributes/computed.ts +2 -10
- package/src/datastar/attributes/effect.ts +1 -2
- package/src/datastar/attributes/indicator.ts +2 -8
- package/src/datastar/attributes/init.ts +2 -10
- package/src/datastar/attributes/jsonSignals.ts +1 -6
- package/src/datastar/attributes/on.ts +4 -13
- package/src/datastar/attributes/onIntersect.ts +10 -22
- package/src/datastar/attributes/onInterval.ts +2 -10
- package/src/datastar/attributes/onSignalPatch.ts +18 -28
- package/src/datastar/attributes/ref.ts +1 -2
- package/src/datastar/attributes/show.ts +1 -2
- package/src/datastar/attributes/signals.ts +1 -5
- package/src/datastar/attributes/style.ts +6 -12
- package/src/datastar/attributes/text.ts +1 -2
- package/src/datastar/engine.ts +102 -158
- package/src/datastar/index.ts +2 -2
- package/src/datastar/utils.ts +16 -51
- package/src/datastar/watchers/patchElements.ts +35 -93
- package/src/datastar/watchers/patchSignals.ts +1 -2
- package/src/experimental/EncryptedCookies.ts +81 -175
- package/src/experimental/index.ts +0 -1
- package/src/hyper/Hyper.ts +14 -33
- package/src/hyper/HyperHtml.ts +13 -10
- package/src/hyper/HyperNode.ts +2 -7
- package/src/hyper/HyperRoute.ts +2 -5
- package/src/hyper/jsx-runtime.ts +2 -10
- package/src/hyper/jsx.d.ts +171 -440
- package/src/lint/plugin.js +276 -0
- package/src/node/NodeFileSystem.ts +140 -202
- package/src/node/NodeUtils.ts +1 -3
- package/src/testing/TestLogger.ts +9 -22
- package/src/testing/index.ts +0 -1
- package/src/testing/utils.ts +30 -31
- package/src/x/cloudflare/CloudflareTunnel.ts +53 -65
- package/src/x/datastar/Datastar.ts +3 -10
- package/src/x/datastar/index.ts +1 -3
- package/src/x/datastar/jsx-datastar.d.ts +1 -4
- package/src/x/tailwind/TailwindPlugin.ts +119 -112
- package/src/x/tailwind/compile.ts +10 -33
- package/src/x/tailwind/plugin.ts +2 -2
- package/src/HttpAppExtra.ts +0 -478
- package/src/HttpUtils.ts +0 -17
- package/src/bun/BunPlatformHttpServer.ts +0 -88
- package/src/bun/BunServerRequest.ts +0 -396
- package/src/bundler/BundleHttp.ts +0 -259
- package/src/experimental/SseHttpResponse.ts +0 -55
- package/src/middlewares/BasicAuthMiddleware.ts +0 -36
- package/src/middlewares/index.ts +0 -1
- package/src/testing/TestHttpClient.ts +0 -148
package/src/Http.ts
CHANGED
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import * as Values from "./Values.ts"
|
|
2
2
|
|
|
3
|
-
export type Method =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
| "PUT"
|
|
7
|
-
| "DELETE"
|
|
8
|
-
| "PATCH"
|
|
9
|
-
| "HEAD"
|
|
10
|
-
| "OPTIONS"
|
|
11
|
-
|
|
12
|
-
type Respondable =
|
|
13
|
-
| Response
|
|
14
|
-
| Promise<Response>
|
|
3
|
+
export type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS"
|
|
4
|
+
|
|
5
|
+
type Respondable = Response | Promise<Response>
|
|
15
6
|
|
|
16
7
|
export type WebHandler = (request: Request) => Respondable
|
|
17
8
|
|
|
18
|
-
export type WebMiddleware = (
|
|
19
|
-
request: Request,
|
|
20
|
-
next: WebHandler,
|
|
21
|
-
) => Respondable
|
|
9
|
+
export type WebMiddleware = (request: Request, next: WebHandler) => Respondable
|
|
22
10
|
|
|
23
11
|
export function fetch(
|
|
24
12
|
handler: WebHandler,
|
|
25
|
-
init:
|
|
26
|
-
&
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
| { path: `/${string}` }
|
|
30
|
-
)
|
|
31
|
-
& { body?: RequestInit["body"] | Record<string, unknown> },
|
|
13
|
+
init: Omit<RequestInit, "body"> &
|
|
14
|
+
({ url: string } | { path: `/${string}` }) & {
|
|
15
|
+
body?: RequestInit["body"] | Record<string, unknown>
|
|
16
|
+
},
|
|
32
17
|
): Promise<Response> {
|
|
33
|
-
const url = "path" in init
|
|
34
|
-
? `http://localhost${init.path}`
|
|
35
|
-
: init.url
|
|
18
|
+
const url = "path" in init ? `http://localhost${init.path}` : init.url
|
|
36
19
|
|
|
37
20
|
const isPlain = Values.isPlainObject(init.body)
|
|
38
21
|
|
|
@@ -52,24 +35,15 @@ export function fetch(
|
|
|
52
35
|
}
|
|
53
36
|
|
|
54
37
|
export function createAbortableRequest(
|
|
55
|
-
init:
|
|
56
|
-
& Omit<RequestInit, "signal">
|
|
57
|
-
& (
|
|
58
|
-
| { url: string }
|
|
59
|
-
| { path: `/${string}` }
|
|
60
|
-
),
|
|
38
|
+
init: Omit<RequestInit, "signal"> & ({ url: string } | { path: `/${string}` }),
|
|
61
39
|
): { request: Request; abort: () => void } {
|
|
62
|
-
const url = "path" in init
|
|
63
|
-
? `http://localhost${init.path}`
|
|
64
|
-
: init.url
|
|
40
|
+
const url = "path" in init ? `http://localhost${init.path}` : init.url
|
|
65
41
|
const controller = new AbortController()
|
|
66
42
|
const request = new Request(url, { ...init, signal: controller.signal })
|
|
67
43
|
return { request, abort: () => controller.abort() }
|
|
68
44
|
}
|
|
69
45
|
|
|
70
|
-
export function mapHeaders(
|
|
71
|
-
headers: Headers,
|
|
72
|
-
): Record<string, string | undefined> {
|
|
46
|
+
export function mapHeaders(headers: Headers): Record<string, string | undefined> {
|
|
73
47
|
const result: Record<string, string | undefined> = {}
|
|
74
48
|
headers.forEach((value, key) => {
|
|
75
49
|
result[key.toLowerCase()] = value
|
|
@@ -77,9 +51,7 @@ export function mapHeaders(
|
|
|
77
51
|
return result
|
|
78
52
|
}
|
|
79
53
|
|
|
80
|
-
export function parseCookies(
|
|
81
|
-
cookieHeader: string | null,
|
|
82
|
-
): Record<string, string | undefined> {
|
|
54
|
+
export function parseCookies(cookieHeader: string | null): Record<string, string | undefined> {
|
|
83
55
|
if (!cookieHeader) return {}
|
|
84
56
|
const result: Record<string, string | undefined> = {}
|
|
85
57
|
for (const part of cookieHeader.split(";")) {
|
|
@@ -130,23 +102,18 @@ export type MultipartPart = FilePart | FieldPart
|
|
|
130
102
|
|
|
131
103
|
export async function parseFormData(
|
|
132
104
|
request: Request,
|
|
133
|
-
): Promise<
|
|
134
|
-
Record<string, ReadonlyArray<FilePart> | ReadonlyArray<string> | string>
|
|
135
|
-
> {
|
|
105
|
+
): Promise<Record<string, ReadonlyArray<FilePart> | ReadonlyArray<string> | string>> {
|
|
136
106
|
const formData = await request.formData()
|
|
137
|
-
const result: Record<
|
|
138
|
-
string,
|
|
139
|
-
ReadonlyArray<FilePart> | ReadonlyArray<string> | string
|
|
140
|
-
> = {}
|
|
107
|
+
const result: Record<string, ReadonlyArray<FilePart> | ReadonlyArray<string> | string> = {}
|
|
141
108
|
|
|
142
109
|
for (const key of new Set(formData.keys())) {
|
|
143
110
|
const values = formData.getAll(key)
|
|
144
111
|
const first = values[0]
|
|
145
112
|
|
|
146
113
|
if (typeof first === "string") {
|
|
147
|
-
result[key] = values.length === 1 ? first : (values as string
|
|
114
|
+
result[key] = values.length === 1 ? first : (values as Array<string>)
|
|
148
115
|
} else {
|
|
149
|
-
const files: FilePart
|
|
116
|
+
const files: Array<FilePart> = []
|
|
150
117
|
for (const value of values) {
|
|
151
118
|
if (typeof value !== "string") {
|
|
152
119
|
const content = new Uint8Array(await value.arrayBuffer())
|
package/src/PathPattern.ts
CHANGED
|
@@ -2,24 +2,29 @@ export type PathPattern = `/${string}`
|
|
|
2
2
|
|
|
3
3
|
export type Segments<Path extends string> = Path extends `/${infer Rest}`
|
|
4
4
|
? Segments<Rest>
|
|
5
|
-
: Path extends `${infer Head}/${infer Tail}`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
: Path extends `${infer Head}/${infer Tail}`
|
|
6
|
+
? [Head, ...Segments<Tail>]
|
|
7
|
+
: Path extends ""
|
|
8
|
+
? []
|
|
9
|
+
: [Path]
|
|
10
|
+
|
|
11
|
+
export type Params<T extends string> = string extends T
|
|
12
|
+
? Record<string, string>
|
|
10
13
|
: T extends `${infer _Start}:${infer Param}?/${infer Rest}`
|
|
11
14
|
? { [K in Param]?: string } & Params<`/${Rest}`>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
: T extends `${infer _Start}:${infer Param}/${infer Rest}`
|
|
16
|
+
? { [K in Param]: string } & Params<`/${Rest}`>
|
|
17
|
+
: T extends `${infer _Start}:${infer Param}+`
|
|
18
|
+
? { [K in Param]: string }
|
|
19
|
+
: T extends `${infer _Start}:${infer Param}*`
|
|
20
|
+
? { [K in Param]?: string }
|
|
21
|
+
: T extends `${infer _Start}:${infer Param}?`
|
|
22
|
+
? { [K in Param]?: string }
|
|
23
|
+
: T extends `${infer _Start}:${infer Param}`
|
|
24
|
+
? { [K in Param]: string }
|
|
25
|
+
: {}
|
|
26
|
+
|
|
27
|
+
export type ValidateResult = { ok: true; segments: Array<string> } | { ok: false; error: string }
|
|
23
28
|
|
|
24
29
|
function isValidSegment(segment: string): boolean {
|
|
25
30
|
if (segment.startsWith(":")) {
|
|
@@ -46,10 +51,7 @@ export function validate(path: string): ValidateResult {
|
|
|
46
51
|
return { ok: true, segments }
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
export function match(
|
|
50
|
-
pattern: string,
|
|
51
|
-
path: string,
|
|
52
|
-
): Record<string, string> | null {
|
|
54
|
+
export function match(pattern: string, path: string): Record<string, string> | null {
|
|
53
55
|
const patternSegments = pattern.split("/").filter(Boolean)
|
|
54
56
|
const pathSegments = path.split("/").filter(Boolean)
|
|
55
57
|
const params: Record<string, string> = {}
|
|
@@ -153,11 +155,9 @@ function getParamName(seg: string): string {
|
|
|
153
155
|
* - `:param+` → `/*param`
|
|
154
156
|
* - `:param*` → `/`, `/*param`
|
|
155
157
|
*/
|
|
156
|
-
export function toExpress(path: string): string
|
|
158
|
+
export function toExpress(path: string): Array<string> {
|
|
157
159
|
const segments = path.split("/").filter(Boolean)
|
|
158
|
-
const optionalWildcardIndex = segments.findIndex(
|
|
159
|
-
(s) => s.startsWith(":") && s.endsWith("*"),
|
|
160
|
-
)
|
|
160
|
+
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
161
161
|
|
|
162
162
|
if (optionalWildcardIndex !== -1) {
|
|
163
163
|
const before = segments.slice(0, optionalWildcardIndex)
|
|
@@ -207,7 +207,7 @@ export function toExpress(path: string): string[] {
|
|
|
207
207
|
* - `:param+` → `:param+`
|
|
208
208
|
* - `:param*` → `:param*`
|
|
209
209
|
*/
|
|
210
|
-
export function toURLPattern(path: string): string
|
|
210
|
+
export function toURLPattern(path: string): Array<string> {
|
|
211
211
|
const segments = path.split("/").filter(Boolean)
|
|
212
212
|
const joined = segments
|
|
213
213
|
.map((seg) => {
|
|
@@ -230,11 +230,9 @@ export function toURLPattern(path: string): string[] {
|
|
|
230
230
|
* - `:param+` → `*` (splat, required)
|
|
231
231
|
* - `:param*` → `/`, `/*` (splat, optional - two routes)
|
|
232
232
|
*/
|
|
233
|
-
export function toReactRouter(path: string): string
|
|
233
|
+
export function toReactRouter(path: string): Array<string> {
|
|
234
234
|
const segments = path.split("/").filter(Boolean)
|
|
235
|
-
const optionalWildcardIndex = segments.findIndex(
|
|
236
|
-
(s) => s.startsWith(":") && s.endsWith("*"),
|
|
237
|
-
)
|
|
235
|
+
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
238
236
|
|
|
239
237
|
if (optionalWildcardIndex !== -1) {
|
|
240
238
|
const before = segments.slice(0, optionalWildcardIndex)
|
|
@@ -361,11 +359,9 @@ export function toTanStack(path: string): string {
|
|
|
361
359
|
* - `:param+` → `*` (unnamed, required)
|
|
362
360
|
* - `:param*` → `/`, `/*` (unnamed, optional - two routes)
|
|
363
361
|
*/
|
|
364
|
-
export function toHono(path: string): string
|
|
362
|
+
export function toHono(path: string): Array<string> {
|
|
365
363
|
const segments = path.split("/").filter(Boolean)
|
|
366
|
-
const optionalWildcardIndex = segments.findIndex(
|
|
367
|
-
(s) => s.startsWith(":") && s.endsWith("*"),
|
|
368
|
-
)
|
|
364
|
+
const optionalWildcardIndex = segments.findIndex((s) => s.startsWith(":") && s.endsWith("*"))
|
|
369
365
|
|
|
370
366
|
if (optionalWildcardIndex !== -1) {
|
|
371
367
|
const before = segments.slice(0, optionalWildcardIndex)
|
|
@@ -413,7 +409,7 @@ export function toHono(path: string): string[] {
|
|
|
413
409
|
* - `:param+` → `*` (unnamed)
|
|
414
410
|
* - `:param*` → `/`, `/*` (two routes)
|
|
415
411
|
*/
|
|
416
|
-
export function toEffect(path: string): string
|
|
412
|
+
export function toEffect(path: string): Array<string> {
|
|
417
413
|
return toHono(path)
|
|
418
414
|
}
|
|
419
415
|
|
|
@@ -430,7 +426,7 @@ export function toEffect(path: string): string[] {
|
|
|
430
426
|
* - `:param+` → `/*`
|
|
431
427
|
* - `:param*` → `/`, `/*` (two routes)
|
|
432
428
|
*/
|
|
433
|
-
export function toBun(path: string): PathPattern
|
|
429
|
+
export function toBun(path: string): Array<PathPattern> {
|
|
434
430
|
const segments = path.split("/").filter(Boolean)
|
|
435
431
|
|
|
436
432
|
const optionalIndex = segments.findIndex(
|
|
@@ -472,14 +468,10 @@ export function toBun(path: string): PathPattern[] {
|
|
|
472
468
|
|
|
473
469
|
const optionalModifier = getModifier(optional)
|
|
474
470
|
const optionalName = getParamName(optional)
|
|
475
|
-
const requiredOptional = optionalModifier === "*"
|
|
476
|
-
? `:${optionalName}+`
|
|
477
|
-
: `:${optionalName}`
|
|
471
|
+
const requiredOptional = optionalModifier === "*" ? `:${optionalName}+` : `:${optionalName}`
|
|
478
472
|
|
|
479
473
|
const withOptionalSegments = [...before, requiredOptional, ...after]
|
|
480
|
-
const withOptionalPath: PathPattern = `/${
|
|
481
|
-
withOptionalSegments.map(formatSegment).join("/")
|
|
482
|
-
}`
|
|
474
|
+
const withOptionalPath: PathPattern = `/${withOptionalSegments.map(formatSegment).join("/")}`
|
|
483
475
|
|
|
484
476
|
return [...toBun(basePath), ...toBun(withOptionalPath)]
|
|
485
477
|
}
|
package/src/PlatformError.ts
CHANGED
|
@@ -7,29 +7,18 @@ import * as Predicate from "effect/Predicate"
|
|
|
7
7
|
import * as Schema from "effect/Schema"
|
|
8
8
|
import type * as Types from "effect/Types"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const TypeId: typeof TypeId_ = TypeId_
|
|
10
|
+
export const TypeId: unique symbol = Symbol.for("@effect/platform/Error/PlatformError")
|
|
13
11
|
|
|
14
12
|
export type TypeId = typeof TypeId
|
|
15
13
|
|
|
16
|
-
export const isPlatformError = (u: unknown): u is PlatformError =>
|
|
17
|
-
Predicate.hasProperty(u, TypeId)
|
|
14
|
+
export const isPlatformError = (u: unknown): u is PlatformError => Predicate.hasProperty(u, TypeId)
|
|
18
15
|
|
|
19
|
-
export const TypeIdError = <
|
|
20
|
-
const TypeId extends symbol,
|
|
21
|
-
const Tag extends string,
|
|
22
|
-
>(
|
|
16
|
+
export const TypeIdError = <const TypeId extends symbol, const Tag extends string>(
|
|
23
17
|
typeId: TypeId,
|
|
24
18
|
tag: Tag,
|
|
25
|
-
): new<A extends Record<string, any>>(
|
|
19
|
+
): (new <A extends Record<string, any>>(
|
|
26
20
|
args: Types.Simplify<A>,
|
|
27
|
-
) =>
|
|
28
|
-
& Cause.YieldableError
|
|
29
|
-
& Record<TypeId, TypeId>
|
|
30
|
-
& { readonly _tag: Tag }
|
|
31
|
-
& Readonly<A> =>
|
|
32
|
-
{
|
|
21
|
+
) => Cause.YieldableError & Record<TypeId, TypeId> & { readonly _tag: Tag } & Readonly<A>) => {
|
|
33
22
|
class Base extends Data.Error<{}> {
|
|
34
23
|
readonly _tag = tag
|
|
35
24
|
}
|
|
@@ -48,23 +37,18 @@ export const Module = Schema.Literal(
|
|
|
48
37
|
"Terminal",
|
|
49
38
|
)
|
|
50
39
|
|
|
51
|
-
export class BadArgument
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
)
|
|
61
|
-
{
|
|
40
|
+
export class BadArgument extends Schema.TaggedError<BadArgument>(
|
|
41
|
+
"@effect/platform/Error/BadArgument",
|
|
42
|
+
)("BadArgument", {
|
|
43
|
+
module: Module,
|
|
44
|
+
method: Schema.String,
|
|
45
|
+
description: Schema.optional(Schema.String),
|
|
46
|
+
cause: Schema.optional(Schema.Defect),
|
|
47
|
+
}) {
|
|
62
48
|
readonly [TypeId]: typeof TypeId = TypeId
|
|
63
49
|
|
|
64
50
|
get message(): string {
|
|
65
|
-
return `${this.module}.${this.method}${
|
|
66
|
-
this.description ? `: ${this.description}` : ""
|
|
67
|
-
}`
|
|
51
|
+
return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`
|
|
68
52
|
}
|
|
69
53
|
}
|
|
70
54
|
|
|
@@ -84,22 +68,17 @@ export const SystemErrorReason = Schema.Literal(
|
|
|
84
68
|
|
|
85
69
|
export type SystemErrorReason = typeof SystemErrorReason.Type
|
|
86
70
|
|
|
87
|
-
export class SystemError
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
),
|
|
99
|
-
cause: Schema.optional(Schema.Defect),
|
|
100
|
-
},
|
|
101
|
-
)
|
|
102
|
-
{
|
|
71
|
+
export class SystemError extends Schema.TaggedError<SystemError>(
|
|
72
|
+
"@effect/platform/Error/SystemError",
|
|
73
|
+
)("SystemError", {
|
|
74
|
+
reason: SystemErrorReason,
|
|
75
|
+
module: Module,
|
|
76
|
+
method: Schema.String,
|
|
77
|
+
description: Schema.optional(Schema.String),
|
|
78
|
+
syscall: Schema.optional(Schema.String),
|
|
79
|
+
pathOrDescriptor: Schema.optional(Schema.Union(Schema.String, Schema.Number)),
|
|
80
|
+
cause: Schema.optional(Schema.Defect),
|
|
81
|
+
}) {
|
|
103
82
|
readonly [TypeId]: typeof TypeId = TypeId
|
|
104
83
|
|
|
105
84
|
get message(): string {
|
|
@@ -111,7 +90,7 @@ export class SystemError
|
|
|
111
90
|
|
|
112
91
|
export type PlatformError = BadArgument | SystemError
|
|
113
92
|
|
|
114
|
-
export const PlatformError: Schema.Union<[
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
93
|
+
export const PlatformError: Schema.Union<[typeof BadArgument, typeof SystemError]> = Schema.Union(
|
|
94
|
+
BadArgument,
|
|
95
|
+
SystemError,
|
|
96
|
+
)
|
package/src/PlatformRuntime.ts
CHANGED
|
@@ -21,13 +21,11 @@ export const defaultTeardown: Teardown = <E, A>(
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface RunMain {
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
): <E, A>(effect: Effect.Effect<A, E>) => void
|
|
24
|
+
(options?: {
|
|
25
|
+
readonly disableErrorReporting?: boolean | undefined
|
|
26
|
+
readonly disablePrettyLogger?: boolean | undefined
|
|
27
|
+
readonly teardown?: Teardown | undefined
|
|
28
|
+
}): <E, A>(effect: Effect.Effect<A, E>) => void
|
|
31
29
|
<E, A>(
|
|
32
30
|
effect: Effect.Effect<A, E>,
|
|
33
31
|
options?: {
|
|
@@ -38,10 +36,7 @@ export interface RunMain {
|
|
|
38
36
|
): void
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
const addPrettyLogger = (
|
|
42
|
-
refs: FiberRefs.FiberRefs,
|
|
43
|
-
fiberId: FiberId.Runtime,
|
|
44
|
-
) => {
|
|
39
|
+
const addPrettyLogger = (refs: FiberRefs.FiberRefs, fiberId: FiberId.Runtime) => {
|
|
45
40
|
const loggers = FiberRefs.getOrDefault(refs, FiberRef.currentLoggers)
|
|
46
41
|
if (!HashSet.has(loggers, Logger.defaultLogger)) {
|
|
47
42
|
return refs
|
|
@@ -57,39 +52,37 @@ const addPrettyLogger = (
|
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
export const makeRunMain = (
|
|
60
|
-
f: <E, A>(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
) => void,
|
|
55
|
+
f: <E, A>(options: {
|
|
56
|
+
readonly fiber: Fiber.RuntimeFiber<A, E>
|
|
57
|
+
readonly teardown: Teardown
|
|
58
|
+
}) => void,
|
|
66
59
|
): RunMain =>
|
|
67
60
|
Function.dual(
|
|
68
61
|
(args) => Effect.isEffect(args[0]),
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
62
|
+
(
|
|
63
|
+
effect: Effect.Effect<any, any>,
|
|
64
|
+
options?: {
|
|
65
|
+
readonly disableErrorReporting?: boolean | undefined
|
|
66
|
+
readonly disablePrettyLogger?: boolean | undefined
|
|
67
|
+
readonly teardown?: Teardown | undefined
|
|
68
|
+
},
|
|
69
|
+
) => {
|
|
70
|
+
const fiber =
|
|
71
|
+
options?.disableErrorReporting === true
|
|
72
|
+
? Effect.runFork(effect, {
|
|
73
|
+
updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
|
|
74
|
+
})
|
|
75
|
+
: Effect.runFork(
|
|
76
|
+
Effect.tapErrorCause(effect, (cause) => {
|
|
77
|
+
if (Cause.isInterruptedOnly(cause)) {
|
|
78
|
+
return Effect.void
|
|
79
|
+
}
|
|
80
|
+
return Effect.logError(cause)
|
|
81
|
+
}),
|
|
82
|
+
{
|
|
83
|
+
updateRefs: options?.disablePrettyLogger === true ? undefined : addPrettyLogger,
|
|
84
|
+
},
|
|
85
|
+
)
|
|
93
86
|
const teardown = options?.teardown ?? defaultTeardown
|
|
94
87
|
return f({ fiber, teardown })
|
|
95
88
|
},
|
|
@@ -99,10 +92,9 @@ export const makeRunMain = (
|
|
|
99
92
|
* Are we running within an agent harness, like Claude Code?
|
|
100
93
|
*/
|
|
101
94
|
export function isAgentHarness() {
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
&&
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
95
|
+
return (
|
|
96
|
+
typeof process !== "undefined" &&
|
|
97
|
+
!process.stdout.isTTY &&
|
|
98
|
+
(process.env.CLAUDECODE || process.env.CURSOR_AGENT)
|
|
99
|
+
)
|
|
108
100
|
}
|