{"version":3,"file":"RoomRequest.mjs","sources":["../src/RoomRequest.ts"],"sourcesContent":["/** Decoded `Protocol.ROOM_RESPONSE` outcome handed to a pending round-trip's\n *  `onReply` callback: `ok` = resolved, else rejected; `faulted` distinguishes a\n *  server fault (handler threw / no handler) from a deliberate `ctx.reject`. @internal */\nexport type OnReply = (ok: boolean, payload: any, faulted: boolean) => void;\n\n/** Options for {@link Room.request}. */\nexport interface RequestOptions {\n    /** Reject the returned promise if no reply arrives within this many ms\n     *  (defaults to {@link Room.requestTimeout}). */\n    timeout?: number;\n    /** `\"unreliable\"` rides the unreliable channel (falls back to reliable when the\n     *  transport has none) and is sent once — a genuine drop is surfaced by the\n     *  `timeout`. Defaults to `\"reliable\"`. */\n    mode?: \"reliable\" | \"unreliable\";\n}\n\n/** Build the Error a rejected `request` throws. `faulted:false` → a deliberate\n *  `ctx.reject(reason)`: `name:\"rejected\"`, `.reason` = the raw typed reason.\n *  `faulted:true` → a server fault: an Error rebuilt from the sanitized\n *  `{ name, message, code }` payload. */\nexport function toRequestError(payload: any, faulted: boolean): Error {\n    if (!faulted) {\n        const error: any = new Error(\"request rejected\");\n        error.name = \"rejected\";\n        error.reason = payload;\n        return error;\n    }\n    const error: any = new Error(payload?.message ?? \"request failed\");\n    if (payload?.name) { error.name = payload.name; }\n    if (payload?.code !== undefined) { error.code = payload.code; }\n    return error;\n}\n"],"names":[],"mappings":";;;;;;AAgBA;;;AAGyC;AACnC,SAAU,cAAc,CAAC,OAAY,EAAE,OAAgB,EAAA;IACzD,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,KAAK,GAAQ,IAAI,KAAK,CAAC,kBAAkB,CAAC;AAChD,QAAA,KAAK,CAAC,IAAI,GAAG,UAAU;AACvB,QAAA,KAAK,CAAC,MAAM,GAAG,OAAO;AACtB,QAAA,OAAO,KAAK;IAChB;IACA,MAAM,KAAK,GAAQ,IAAI,KAAK,CAAC,OAAO,EAAE,OAAO,IAAI,gBAAgB,CAAC;AAClE,IAAA,IAAI,OAAO,EAAE,IAAI,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IAAE;AAChD,IAAA,IAAI,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE;AAAE,QAAA,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IAAE;AAC9D,IAAA,OAAO,KAAK;AAChB;;;;"}