<Self, S extends Spec, R>(
tag: HyperlinkTag<Self, S>,
built: Driver<S, R>
): ImplOf<S>export const const grantLocal: <
Self,
S extends Spec,
R
>(
tag: HyperlinkTag<Self, S>,
built: Driver<S, R>
) => ImplOf<S>
grantLocal = <function (type parameter) Self in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>Self, function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>S extends Spec, function (type parameter) R in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>R>(
tag: HyperlinkTag<Self, S>(parameter) tag: {
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 DefaultMethod<infer F> ? F : S[K] extends …;
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 DefaultMethod<infer F> ? F : S[K] extends { readonly _…;
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 DefaultMethod<infer F> ? F : S[K] extends { rea…;
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 DefaultMethod<infer F> ? F : S[K] extends { rea…;
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 DefaultMethod<...> ? F : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a HyperService tag carrying spec S — what
Hyperlink.Tag
produces
(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: Driver<S, R>): ImplOf<S>Self, function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>S>,
built: Driver<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built: interface Driver<S extends Spec, R>A HyperService 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
WorkPool
,
Gate
, and
Daemon
(any toolkit HyperService 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.
Driver<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>S, function (type parameter) R in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>R>,
): type ImplOf<S extends Spec> = {
readonly [K in keyof S as S[K] extends AnyDefaultMethod
? never
: K]: 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 Effect<A, E> resolved once at acquire — that differs from how
it surfaces in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not
ServiceOf. A
ref
's impl is the
Subscribable
(not the consumer shape alone).
default
members are Tag-baked — omitted from the impl. A nested group that is only
default members still appears as {} (pass an empty object). Piped
defaults
keys may
be overridden via
ImplWithDefaultOverrides
.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<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: Driver<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built.Driver<S, R>.impl: WithRequirement<ImplOf<S>, R>impl, tag: HyperlinkTag<Self, S>(parameter) tag: {
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 DefaultMethod<infer F> ? F : S[K] extends …;
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 DefaultMethod<infer F> ? F : S[K] extends { readonly _…;
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 DefaultMethod<infer F> ? F : S[K] extends { rea…;
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 DefaultMethod<infer F> ? F : S[K] extends { rea…;
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: Driver<S, R>(parameter) built: {
impl: WithRequirement<ImplOf<S>, R>;
workerContext: Context.Context<R>;
}
built.Driver<S, R>.workerContext: Context.Context<R>(property) Driver<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 as S[K] extends AnyDefaultMethod
? never
: K]: 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 Effect<A, E> resolved once at acquire — that differs from how
it surfaces in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not
ServiceOf. A
ref
's impl is the
Subscribable
(not the consumer shape alone).
default
members are Tag-baked — omitted from the impl. A nested group that is only
default members still appears as {} (pass an empty object). Piped
defaults
keys may
be overridden via
ImplWithDefaultOverrides
.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, built: Driver<S, R>): ImplOf<S>S>;