{"version":3,"file":"sync-receipt.cjs","sources":["../../src/sync-receipt.ts"],"sourcesContent":["import type { SyncAppliedReceipt } from './types'\n\nconst ACCEPTED = Symbol(`tanstack-db.sync-receipt.accepted`)\n\ntype AcceptedReceipt = Promise<void> & { [ACCEPTED]?: SyncAppliedReceipt }\n\n/**\n * Attaches the moment a sync transaction was accepted to the receipt that\n * resolves when it is visible. A wrapping sync, such as persistence, accepts\n * after its durable step.\n *\n * @internal Adapter infrastructure, not an application API.\n */\nexport function withAcceptedReceipt(\n  visible: Promise<void>,\n  accepted: SyncAppliedReceipt,\n): Promise<void> {\n  ;(visible as AcceptedReceipt)[ACCEPTED] = accepted\n  return visible\n}\n\n/**\n * The moment a receipt's sync transaction was accepted. Handler-facing writes\n * and Collection readiness wait for this, not for visibility: a transaction held by a persisting\n * optimistic transaction becomes visible only when that transaction settles,\n * so a handler awaiting visibility would wait for itself. Core accepts at\n * `commit()`. A receipt that carries no acceptance moment is treated as\n * accepted only when it resolves.\n *\n * @internal Adapter infrastructure, not an application API.\n */\nexport function whenSyncAccepted(\n  receipt: SyncAppliedReceipt,\n): SyncAppliedReceipt {\n  return receipt === true\n    ? true\n    : ((receipt as AcceptedReceipt)[ACCEPTED] ?? receipt)\n}\n"],"names":[],"mappings":";;AAEA,MAAM,kCAAkB,mCAAmC;AAWpD,SAAS,oBACd,SACA,UACe;AACb,UAA4B,QAAQ,IAAI;AAC1C,SAAO;AACT;AAYO,SAAS,iBACd,SACoB;AACpB,SAAO,YAAY,OACf,OACE,QAA4B,QAAQ,KAAK;AACjD;;;"}