{"version":3,"sources":["../src/debug.ts"],"sourcesContent":["import type { HTTPMethod, HTTPHeaders } from './index'\nimport type { RuntimeDebugContext } from '@vobs/runtime'\n\nexport type HTTPDebugStatus = 'loading' | 'retrying' | 'success' | 'error' | 'cancelled'\n\nexport type HTTPDebugCacheStatus = 'hit' | 'miss' | 'revalidated'\n\nexport interface HTTPDebugContext extends RuntimeDebugContext {\n  readonly cacheStatus?: HTTPDebugCacheStatus\n  /** Marks a request created from the DevTools request tester. */\n  readonly test?: boolean\n}\n\nexport interface HTTPDebugRequest {\n  readonly id: number\n  readonly phase: 'start' | 'retry' | 'end'\n  readonly status: HTTPDebugStatus\n  readonly url: string\n  readonly method: HTTPMethod\n  readonly headers: HTTPHeaders\n  readonly requestBody?: unknown\n  readonly startedAt: number\n  readonly endedAt?: number\n  readonly duration?: number\n  readonly attempt: number\n  readonly retries: number\n  readonly responseStatus?: number\n  readonly responseBody?: unknown\n  readonly error?: { readonly name: string; readonly message: string }\n  readonly context?: HTTPDebugContext\n}\n\nexport interface HTTPDebugHooks {\n  request?(event: HTTPDebugRequest): void\n}\n\nlet activeHTTPDebugHooks: HTTPDebugHooks | null = null\nconst httpDebugListeners = new Set<NonNullable<HTTPDebugHooks['request']>>()\n\nexport function setHTTPDebugHooks(hooks: HTTPDebugHooks | null): HTTPDebugHooks | null {\n  const previous = activeHTTPDebugHooks\n  activeHTTPDebugHooks = hooks\n  return previous\n}\n\nexport function getHTTPDebugHooks(): HTTPDebugHooks | null {\n  return activeHTTPDebugHooks\n}\n\nexport function subscribeHTTPDebug(listener: NonNullable<HTTPDebugHooks['request']>): () => void {\n  httpDebugListeners.add(listener)\n  return () => httpDebugListeners.delete(listener)\n}\n\nexport function emitHTTPDebug(event: HTTPDebugRequest): void {\n  try {\n    activeHTTPDebugHooks?.request?.(event)\n  } catch {\n    // Debug tooling must never change request behavior.\n  }\n  for (const listener of [...httpDebugListeners]) {\n    try { listener(event) } catch { /* Debug tooling must never change request behavior. */ }\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCA,IAAI,uBAA8C;AAClD,IAAM,qBAAqB,oBAAI,IAA4C;AAEpE,SAAS,kBAAkB,OAAqD;AACrF,QAAM,WAAW;AACjB,yBAAuB;AACvB,SAAO;AACT;AAJgB;AAMT,SAAS,oBAA2C;AACzD,SAAO;AACT;AAFgB;AAIT,SAAS,mBAAmB,UAA8D;AAC/F,qBAAmB,IAAI,QAAQ;AAC/B,SAAO,MAAM,mBAAmB,OAAO,QAAQ;AACjD;AAHgB;AAKT,SAAS,cAAc,OAA+B;AAC3D,MAAI;AACF,0BAAsB,UAAU,KAAK;AAAA,EACvC,QAAQ;AAAA,EAER;AACA,aAAW,YAAY,CAAC,GAAG,kBAAkB,GAAG;AAC9C,QAAI;AAAE,eAAS,KAAK;AAAA,IAAE,QAAQ;AAAA,IAA0D;AAAA,EAC1F;AACF;AATgB;","names":[]}