@@ -1,4 +1,4 @@
|
||||
import { Context, Effect, Effectable, ExecutionStrategy, Function, Predicate, Runtime, Scope, String, Tracer, type Types, type Utils } from "effect"
|
||||
import { Context, Effect, Effectable, ExecutionStrategy, Function, Predicate, Runtime, Scope, Tracer, type Types, type Utils } from "effect"
|
||||
import * as React from "react"
|
||||
import { Hooks } from "./hooks/index.js"
|
||||
import * as Memo from "./Memo.js"
|
||||
@@ -331,13 +331,9 @@ export const make: (
|
||||
) => make.Gen & make.NonGen)
|
||||
) = (spanNameOrBody: Function | string, ...pipeables: any[]): any => {
|
||||
if (typeof spanNameOrBody !== "string") {
|
||||
const displayName = displayNameFromBody(spanNameOrBody)
|
||||
return Object.setPrototypeOf(
|
||||
Object.assign(function() {}, defaultOptions, {
|
||||
body: displayName
|
||||
? Effect.fn(displayName)(spanNameOrBody as any, ...pipeables as [])
|
||||
: Effect.fn(spanNameOrBody as any, ...pipeables),
|
||||
displayName,
|
||||
body: Effect.fn(spanNameOrBody as any, ...pipeables),
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
@@ -347,26 +343,34 @@ export const make: (
|
||||
return (body: any, ...pipeables: any[]) => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, defaultOptions, {
|
||||
body: Effect.fn(spanNameOrBody, spanOptions)(body, ...pipeables as []),
|
||||
displayName: displayNameFromBody(body) ?? spanNameOrBody,
|
||||
displayName: spanNameOrBody,
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const makeUntraced: make.Gen & make.NonGen = (
|
||||
body: Function,
|
||||
...pipeables: any[]
|
||||
) => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, defaultOptions, {
|
||||
body: Effect.fnUntraced(body as any, ...pipeables as []),
|
||||
displayName: displayNameFromBody(body),
|
||||
}),
|
||||
ComponentProto,
|
||||
export const makeUntraced: (
|
||||
& make.Gen
|
||||
& make.NonGen
|
||||
& ((name: string) => make.Gen & make.NonGen)
|
||||
) = (spanNameOrBody: Function | string, ...pipeables: any[]): any => (
|
||||
typeof spanNameOrBody !== "string"
|
||||
? Object.setPrototypeOf(
|
||||
Object.assign(function() {}, defaultOptions, {
|
||||
body: Effect.fnUntraced(spanNameOrBody as any, ...pipeables as []),
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
: (body: any, ...pipeables: any[]) => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, defaultOptions, {
|
||||
body: Effect.fnUntraced(body, ...pipeables as []),
|
||||
displayName: spanNameOrBody,
|
||||
}),
|
||||
ComponentProto,
|
||||
)
|
||||
)
|
||||
|
||||
const displayNameFromBody = (body: Function) => !String.isEmpty(body.name) ? body.name : undefined
|
||||
|
||||
export const withOptions: {
|
||||
<T extends Component<any, any, any, any>>(
|
||||
options: Partial<Component.Options>
|
||||
|
||||
Reference in New Issue
Block a user