import * as ClientAgent from "./ClientAgent.js"; import * as Injector from "./Injector.js"; import * as JsFunction from "./JsFunction.js"; import * as JsObject from "./JsObject.js"; import * as Message from "./Message.js"; import * as Observable from "./Observable/index.js"; import * as Proxy from "./Proxy.js"; import * as ServerAgent from "./ServerAgent.js"; import * as Subprotocol from "./Subprotocol.js"; import * as Supervisor from "./Supervisor.js"; export { Session as t }; /** * An agent is either a client agent or a server agent. Agents look a lot like * actors. */ export type Agent = ClientAgent.t | ServerAgent.t; /** * All sessions are observed by the root supervisor. */ export declare const rootSupervisor: Supervisor.Supervisor>; /** * A session spawns and observes agents. A session may spawn multiple server or * client agents while active. Terminating a session will terminate all agents * spawned by the session that are still active. * * If all agents spawned by the session are terminated then the session is * automatically terminated. */ export declare abstract class Session extends Supervisor.t { #private; readonly protocol: Subprotocol; readonly injector?: Injector.t | undefined; readonly input: Required>>; readonly output: Observable.Observable>; constructor(protocol: Subprotocol, injector?: Injector.t | undefined); /** * Terminates the session, completing its input and output and terminating all * of its spawned agents. */ terminate(): void; /** * Spawns a new client agent. */ protected createClient(this: Session, serverAddress: string): ClientAgent.t; /** * Spawns a new server agent. */ protected createServer(this: Session, provide: unknown, address?: string): ServerAgent.t; } /** * Represents a client session. A proxy can be created from a client session for * calling remote functions. */ export declare class ClientSession extends Session { #private; readonly injector: Injector.t | undefined; readonly protocol: Subprotocol; constructor(injector: Injector.t | undefined, protocol: Subprotocol); createProxy(): Value extends object ? Proxy.t : JsObject.Empty; } /** * Represents a server session. */ export declare class ServerSession extends Session { readonly injector: Injector.t | undefined; readonly protocol: Subprotocol; readonly value: Value; constructor(injector: Injector.t | undefined, protocol: Subprotocol, value: Value); } export interface Resource { type: "Resource"; } /** * A container type for a remote resource. This exists as a workaround to the * absence of partial type inference in TypeScript. */ export declare const Resource: () => Resource; /** * The transporter protocol is type agnostic. Subprotocols are required for * type safety. */ type Subprotocol = Subprotocol.t>, JsFunction.Output>>; interface Options { injector?: Injector.t; protocol: Subprotocol; } export interface ClientOptions extends Options { resource: Resource; } /** * Creates a new `ClientSession`. */ export declare function client({ injector, protocol, resource }: ClientOptions): ClientSession; export interface ServerOptions extends Options { provide: Value; } /** * Creates a new `ServerSession`. */ export declare function server({ injector, protocol, provide: value }: ServerOptions): ServerSession; /** * Returns a union of function types from a type. If the type is an object then * functions will be extracted from the object recursively. */ type ExtractFunctions = T extends JsFunction.t ? T : T extends object ? Extract, JsFunction.t> : never; //# sourceMappingURL=Session.d.ts.map