{"version":3,"file":"session.mjs","names":[],"sources":["../../src/types/session.ts"],"sourcesContent":["/** One newline-delimited JSON frame, kept opaque so Pi can evolve its protocol. */\nexport type SessionFrame = Record<string, unknown>;\n\n/** Handshake vocabulary published by the Po core server. */\nexport const ATTACH_TYPE = 'attach';\nexport const ATTACHED_TYPE = 'attached';\nexport const ATTACH_ERROR_TYPE = 'attach_error';\nexport const REPLAY_TYPE = 'replay';\n\n/**\n * What the browser is told about the socket behind it.\n *\n * The token never reaches the browser, so the page cannot infer attachment from\n * the handshake itself; the bridge reports it instead.\n */\nexport type BridgeState = 'connecting' | 'attached' | 'refused' | 'detached' | 'closed';\n\nexport const BRIDGE_STATUS_TYPE = 'bridge_status';\n\nexport interface BridgeStatusFrame {\n  type: typeof BRIDGE_STATUS_TYPE;\n  state: BridgeState;\n  /** Human-readable cause, present when the state is refused or closed. */\n  reason?: string;\n  /** Frames the session buffered while nothing was attached. */\n  replayed?: number;\n  /** Frames the bounded backlog had to discard. */\n  dropped?: number;\n}\n\nexport function bridgeStatus(\n  state: BridgeState,\n  extra: Omit<BridgeStatusFrame, 'type' | 'state'> = {},\n): BridgeStatusFrame {\n  return { type: BRIDGE_STATUS_TYPE, state, ...extra };\n}\n"],"mappings":";;AAIA,MAAa,cAAc;AAC3B,MAAa,gBAAgB;AAC7B,MAAa,oBAAoB;AACjC,MAAa,cAAc;AAU3B,MAAa,qBAAqB;AAalC,SAAgB,aACd,OACA,QAAmD,CAAC,GACjC;CACnB,OAAO;EAAE,MAAM;EAAoB;EAAO,GAAG;CAAM;AACrD"}