{"version":3,"file":"mutation-line.d.ts","sourceRoot":"","sources":["../../../src/harness/session/mutation-line.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,qBAAa,YAAY;IACxB,OAAO,CAAC,IAAI,CAAoC;IAChD,OAAO,CAAC,WAAW,CAAoB;IAEvC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAWlD;IAED,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhC;CACD","sourcesContent":["/** Serializes complete read-modify-write jobs for one Session. */\nexport class MutationLine {\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate sealedError: Error | undefined;\n\n\trun<T>(operation: () => T | Promise<T>): Promise<T> {\n\t\tif (this.sealedError !== undefined) return Promise.reject(this.sealedError);\n\t\tconst result = this.tail.then(() => {\n\t\t\tif (this.sealedError !== undefined) throw this.sealedError;\n\t\t\treturn operation();\n\t\t});\n\t\tthis.tail = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn result;\n\t}\n\n\tseal(error: Error): Promise<void> {\n\t\tthis.sealedError ??= error;\n\t\treturn this.tail;\n\t}\n}\n"]}