{"version":3,"sources":["../../../../src/core/experimental/frames/network-frame.ts"],"sourcesContent":["import { Emitter, type DefaultEventMap } from 'rettime'\nimport type { AnyHandler, HandlersController } from '../handlers-controller'\nimport type { UnhandledFrameHandle } from '../on-unhandled-frame'\n\nexport type AnyNetworkFrame = NetworkFrame<string, unknown, any>\n\nexport type ExtractFrameEvents<Frame> =\n  Frame extends NetworkFrame<any, any, infer Events> ? Events : never\n\nexport interface NetworkFrameResolutionContext {\n  baseUrl?: string | URL\n  quiet?: boolean\n}\n\n/**\n * The base for the network frames. Extend this abstract class\n * to implement custom network frames.\n */\nexport abstract class NetworkFrame<\n  Protocol extends string,\n  Data,\n  Events extends DefaultEventMap,\n> {\n  public events: Emitter<Events>\n\n  constructor(\n    public readonly protocol: Protocol,\n    public readonly data: Data,\n  ) {\n    this.events = new Emitter()\n  }\n\n  public abstract getHandlers(controller: HandlersController): Array<AnyHandler>\n\n  /**\n   * Resolve the current frame against the given list of handlers.\n   * Optionally, use a custom resolution context to control behaviors\n   * like `baseUrl`.\n   *\n   * Returns `true` if the frame was handled, `false` if it wasn't, and `null`\n   * if its handling was skipped (e.g. the frame was bypassed).\n   */\n  public abstract resolve(\n    handlers: Array<AnyHandler>,\n    onUnhandledFrame: UnhandledFrameHandle,\n    resolutionContext?: NetworkFrameResolutionContext,\n  ): Promise<boolean | null>\n\n  /**\n   * Perform this network frame as-is.\n   */\n  public abstract passthrough(): void\n\n  /**\n   * Error the underling network frame.\n   * @param reason The reason for the error.\n   */\n  public abstract errorWith(reason?: unknown): void\n\n  /**\n   * Get a message to be used when this frame is unhandled.\n   */\n  public abstract getUnhandledMessage(): Promise<string>\n}\n"],"mappings":"AAAA,SAAS,eAAqC;AAkBvC,MAAe,aAIpB;AAAA,EAGA,YACkB,UACA,MAChB;AAFgB;AACA;AAEhB,SAAK,SAAS,IAAI,QAAQ;AAAA,EAC5B;AAAA,EAPO;AAwCT;","names":[]}