<Self, S extends Spec, R>(
tag: HyperlinkTag<Self, S>,
built: BuiltHyperlink<S, R>
): ImplOf<S>Discharge a BuiltHyperlink's captured worker context into every Effect method — yields the
R-free ImplOf shape for layer / the local grant in serve.
export const const grantLocal: <
Self,
S extends Spec,
R
>(
tag: HyperlinkTag<Self, S>,
built: BuiltHyperlink<S, R>
) => ImplOf<S>
Discharge a
BuiltHyperlink
's captured worker context into every Effect method — yields the
R-free
ImplOf
shape for
layer
/ the local grant in
serve
.
grantLocal = <function (type parameter) Self in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>Self, function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>S extends Spec, function (type parameter) R in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>R>(
tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag: interface HyperlinkTag<Self, S extends Spec, Svc = Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<...> : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a resource tag carrying spec S — what
Hyperlink.Tag
/ a
Hyperlink.tagFor
factory produce (and what you extend). Lets a consumer write
<S extends Spec>(tag: HyperlinkTag<Self, S>) and read the spec through named types
(
specOf
/
groupOf
) instead of a Parameters<typeof specOf> workaround.
HyperlinkTag<function (type parameter) Self in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>Self, function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>S>,
built: BuiltHyperlink<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built: interface BuiltHyperlink<S extends Spec, R>A resource impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
QueueHyperlink
,
RunHyperlink
, and
Process
(any toolkit resource that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
BuiltHyperlink<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>S, function (type parameter) R in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>R>,
): type ImplOf<S extends Spec> = {
readonly [K in keyof S]: S[K] extends FromLocalMethod<
infer M
>
? M
: S[K] extends LocalMethod<infer T>
? T
: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? ImplOf<S[K]>
: never
}
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A value field's impl is the Stream that feeds it (typically a SubscriptionRef's .changes),
and a constant's is the Effect<A> resolved once — both differ from how they surface in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not ServiceOf.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>S> =>
const provideContext: <
Impl,
S extends Spec,
Ctx
>(
impl: Impl,
spec: S,
context: Context.Context<Ctx>
) => ProvidedContext<Impl, Ctx>
Provide a
Context.Context
to every Effect method of an impl — the one-liner that replaces a
repetitive per-method Effect.provideContext(...) wrapping. One-liner over
mapEffects
; the
result subtracts the provided context Ctx from each method's requirement (see
ProvidedContext
) — R → Exclude<R, Ctx> — so a worker-R-carrying impl whose context fully
covers R becomes the R-free shape
ImplOf
expects, and a method needing more than Ctx
provides keeps a residual requirement (caught at the ImplOf assignment) rather than a false never.
Providing the context to a method that carries no R is a harmless no-op, so it applies uniformly.
Stream
and
Subscribable
members are left untouched.
const context = yield* Effect.context<R | RR>();
return Hyperlink.provideContext(impl, MyTag[Hyperlink.specSym], context);
provideContext(built: BuiltHyperlink<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built.BuiltHyperlink<S, R>.impl: WithRequirement<ImplOf<S>, R>impl, tag: HyperlinkTag<Self, S>(parameter) tag: {
groupId: string;
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag[const specSym: typeof specSymWhere the contract spec is stowed on a Tag (hidden from the value surface). Exported so
the public
HyperlinkTag
type is nameable across modules.
specSym], built: BuiltHyperlink<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built.BuiltHyperlink<S, R>.workerContext: Context.Context<R>(property) BuiltHyperlink<S, R>.workerContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
workerContext) as type ImplOf<S extends Spec> = {
readonly [K in keyof S]: S[K] extends FromLocalMethod<
infer M
>
? M
: S[K] extends LocalMethod<infer T>
? T
: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? ImplOf<S[K]>
: never
}
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A value field's impl is the Stream that feeds it (typically a SubscriptionRef's .changes),
and a constant's is the Effect<A> resolved once — both differ from how they surface in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not ServiceOf.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: BuiltHyperlink<S, R>): ImplOf<S>S>;