Refactoring
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2025-07-16 12:53:37 +02:00
parent 591ec17e9f
commit da3b672441

View File

@@ -26,6 +26,151 @@ const nonReactiveTags = [Tracer.ParentSpan] as const
export namespace make {
export type Gen = {
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, P extends {} = {}>(
body: (props: P) => Generator<Eff, React.ReactNode, never>,
): Component<
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never,
P
>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => Effect.Effect<React.ReactNode, EOut, ROut>
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, G, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => G,
h: (_: G, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, G, H, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => G,
h: (_: G, props: NoInfer<P>) => H,
i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
}
export interface Options {
readonly untraced?: boolean
readonly finalizerExecutionMode?: "sync" | "fork"
@@ -33,150 +178,7 @@ export namespace make {
}
}
export const make: {
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, P extends {} = {}>(
body: (props: P) => Generator<Eff, React.ReactNode, never>,
): Component<
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never,
P
>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => Effect.Effect<React.ReactNode, EOut, ROut>
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, G, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => G,
h: (_: G, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
<Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>, AEff, A, B, C, D, E, F, G, H, EOut, ROut, P extends {} = {}>(
body: (props: P) => Generator<Eff, AEff, never>,
a: (
_: Effect.Effect<
AEff,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never
>,
props: NoInfer<P>,
) => A,
b: (_: A, props: NoInfer<P>) => B,
c: (_: B, props: NoInfer<P>) => C,
d: (_: C, props: NoInfer<P>) => D,
e: (_: D, props: NoInfer<P>) => E,
f: (_: E, props: NoInfer<P>) => F,
g: (_: F, props: NoInfer<P>) => G,
h: (_: G, props: NoInfer<P>) => H,
i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P>
} = (...pipeables: readonly [any]) => {
export const make: make.Gen = (...pipeables: readonly [any]) => {
const displayName: string = !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined
return Object.setPrototypeOf({
@@ -187,30 +189,10 @@ export const make: {
}, ComponentProto)
}
export const make_old = <
Eff extends Utils.YieldWrap<Effect.Effect<any, any, any>>,
P extends {} = {},
>(
body: (props: P) => Generator<Eff, React.ReactNode, never>,
options?: make.Options,
): Component<
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer E, infer _R>>] ? E : never,
[Eff] extends [never] ? never : [Eff] extends [Utils.YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R : never,
P
> => {
const displayName = !String.isEmpty(body.name) ? body.name : undefined
return Object.setPrototypeOf({
body: options?.untraced
? Effect.fnUntraced(body)
: displayName
? Effect.fn(displayName)(body)
: Effect.fn(body),
displayName,
finalizerExecutionMode: options?.finalizerExecutionMode ?? "sync",
finalizerExecutionStrategy: options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential,
}, ComponentProto)
}
export const makeUntraced: make.Gen = (...pipeables: readonly [any]) => Object.setPrototypeOf({
body: Effect.fnUntraced(...pipeables),
displayName: !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined,
}, ComponentProto)
export const withRuntime: {