@pol-studios/powersync 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ // src/conflicts/conflict-bus.ts
2
+ var ConflictBus = class {
3
+ conflictListeners = /* @__PURE__ */ new Set();
4
+ resolutionListeners = /* @__PURE__ */ new Set();
5
+ /**
6
+ * Subscribe to conflict detection events.
7
+ * @returns Unsubscribe function
8
+ */
9
+ onConflict(listener) {
10
+ this.conflictListeners.add(listener);
11
+ return () => this.conflictListeners.delete(listener);
12
+ }
13
+ /**
14
+ * Subscribe to resolution events.
15
+ * @returns Unsubscribe function
16
+ */
17
+ onResolution(listener) {
18
+ this.resolutionListeners.add(listener);
19
+ return () => this.resolutionListeners.delete(listener);
20
+ }
21
+ /**
22
+ * Emit a conflict detection event (called by connector).
23
+ */
24
+ emitConflict(conflict) {
25
+ this.conflictListeners.forEach((listener) => listener(conflict));
26
+ }
27
+ /**
28
+ * Emit a resolution event (called by UI/ConflictContext).
29
+ */
30
+ emitResolution(recordId, resolution) {
31
+ this.resolutionListeners.forEach((listener) => listener(recordId, resolution));
32
+ }
33
+ /**
34
+ * Clear all listeners (for cleanup).
35
+ */
36
+ destroy() {
37
+ this.conflictListeners.clear();
38
+ this.resolutionListeners.clear();
39
+ }
40
+ };
41
+
42
+ export {
43
+ ConflictBus
44
+ };
45
+ //# sourceMappingURL=chunk-42IJ25Q4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/conflicts/conflict-bus.ts"],"sourcesContent":["import type { ConflictCheckResult, ConflictResolution } from './types';\n\nexport type ConflictListener = (conflict: ConflictCheckResult) => void;\nexport type ResolutionListener = (recordId: string, resolution: ConflictResolution) => void;\n\n/**\n * Event bus for decoupling conflict detection from UI resolution.\n *\n * Flow:\n * 1. Connector detects conflict -> calls bus.emitConflict()\n * 2. ConflictContext subscribes via bus.onConflict() -> shows UI\n * 3. User resolves -> ConflictContext calls bus.emitResolution()\n * 4. Connector subscribes via bus.onResolution() -> triggers re-upload\n */\nexport class ConflictBus {\n private conflictListeners = new Set<ConflictListener>();\n private resolutionListeners = new Set<ResolutionListener>();\n\n /**\n * Subscribe to conflict detection events.\n * @returns Unsubscribe function\n */\n onConflict(listener: ConflictListener): () => void {\n this.conflictListeners.add(listener);\n return () => this.conflictListeners.delete(listener);\n }\n\n /**\n * Subscribe to resolution events.\n * @returns Unsubscribe function\n */\n onResolution(listener: ResolutionListener): () => void {\n this.resolutionListeners.add(listener);\n return () => this.resolutionListeners.delete(listener);\n }\n\n /**\n * Emit a conflict detection event (called by connector).\n */\n emitConflict(conflict: ConflictCheckResult): void {\n this.conflictListeners.forEach((listener) => listener(conflict));\n }\n\n /**\n * Emit a resolution event (called by UI/ConflictContext).\n */\n emitResolution(recordId: string, resolution: ConflictResolution): void {\n this.resolutionListeners.forEach((listener) => listener(recordId, resolution));\n }\n\n /**\n * Clear all listeners (for cleanup).\n */\n destroy(): void {\n this.conflictListeners.clear();\n this.resolutionListeners.clear();\n }\n}\n"],"mappings":";AAcO,IAAM,cAAN,MAAkB;AAAA,EACf,oBAAoB,oBAAI,IAAsB;AAAA,EAC9C,sBAAsB,oBAAI,IAAwB;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1D,WAAW,UAAwC;AACjD,SAAK,kBAAkB,IAAI,QAAQ;AACnC,WAAO,MAAM,KAAK,kBAAkB,OAAO,QAAQ;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAa,UAA0C;AACrD,SAAK,oBAAoB,IAAI,QAAQ;AACrC,WAAO,MAAM,KAAK,oBAAoB,OAAO,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,UAAqC;AAChD,SAAK,kBAAkB,QAAQ,CAAC,aAAa,SAAS,QAAQ,CAAC;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,UAAkB,YAAsC;AACrE,SAAK,oBAAoB,QAAQ,CAAC,aAAa,SAAS,UAAU,UAAU,CAAC;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACd,SAAK,kBAAkB,MAAM;AAC7B,SAAK,oBAAoB,MAAM;AAAA,EACjC;AACF;","names":[]}
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-CFCK2LHI.js";
12
12
  import {
13
13
  SupabaseConnector
14
- } from "./chunk-FLHDT4TS.js";
14
+ } from "./chunk-MB2RC3NS.js";
15
15
  import {
16
16
  createSyncError,
17
17
  extractEntityIds,
@@ -922,4 +922,4 @@ export {
922
922
  useUploadStatus,
923
923
  useSyncActivity
924
924
  };
925
- //# sourceMappingURL=chunk-Q3LFFMRR.js.map
925
+ //# sourceMappingURL=chunk-H7HZMI4H.js.map