@pol-studios/powersync 1.0.0 → 1.0.2
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.
- package/dist/attachments/index.js +1 -1
- package/dist/{chunk-4FJVBR3X.js → chunk-3AYXHQ4W.js} +24 -13
- package/dist/chunk-3AYXHQ4W.js.map +1 -0
- package/dist/{chunk-BJ36QDFN.js → chunk-7EMDVIZX.js} +1 -1
- package/dist/chunk-7EMDVIZX.js.map +1 -0
- package/dist/chunk-C2RSTGDC.js +726 -0
- package/dist/chunk-C2RSTGDC.js.map +1 -0
- package/dist/{chunk-NPNBGCRC.js → chunk-EJ23MXPQ.js} +1 -1
- package/dist/{chunk-NPNBGCRC.js.map → chunk-EJ23MXPQ.js.map} +1 -1
- package/dist/{chunk-CHRTN5PF.js → chunk-FPTDATY5.js} +1 -1
- package/dist/chunk-FPTDATY5.js.map +1 -0
- package/dist/chunk-GMFDCVMZ.js +1285 -0
- package/dist/chunk-GMFDCVMZ.js.map +1 -0
- package/dist/chunk-OLHGI472.js +1 -0
- package/dist/{chunk-CFCK2LHI.js → chunk-OTJXIRWX.js} +45 -40
- package/dist/chunk-OTJXIRWX.js.map +1 -0
- package/dist/{chunk-GBGATW2S.js → chunk-V6LJ6MR2.js} +86 -95
- package/dist/chunk-V6LJ6MR2.js.map +1 -0
- package/dist/chunk-VJCL2SWD.js +1 -0
- package/dist/chunk-VJCL2SWD.js.map +1 -0
- package/dist/connector/index.d.ts +1 -2
- package/dist/connector/index.js +3 -6
- package/dist/core/index.js +2 -2
- package/dist/{supabase-connector-D14-kl5v.d.ts → index-Cb-NI0Ct.d.ts} +159 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +12 -13
- package/dist/index.native.d.ts +1 -2
- package/dist/index.native.js +13 -14
- package/dist/index.web.d.ts +1 -2
- package/dist/index.web.js +13 -14
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.js +1 -1
- package/dist/platform/index.web.js +1 -1
- package/dist/provider/index.d.ts +6 -1
- package/dist/provider/index.js +6 -6
- package/dist/sync/index.js +3 -3
- package/package.json +35 -10
- package/dist/chunk-4FJVBR3X.js.map +0 -1
- package/dist/chunk-7BPTGEVG.js +0 -1
- package/dist/chunk-BJ36QDFN.js.map +0 -1
- package/dist/chunk-CFCK2LHI.js.map +0 -1
- package/dist/chunk-CHRTN5PF.js.map +0 -1
- package/dist/chunk-FLHDT4TS.js +0 -327
- package/dist/chunk-FLHDT4TS.js.map +0 -1
- package/dist/chunk-GBGATW2S.js.map +0 -1
- package/dist/chunk-Q3LFFMRR.js +0 -925
- package/dist/chunk-Q3LFFMRR.js.map +0 -1
- package/dist/chunk-T225XEML.js +0 -298
- package/dist/chunk-T225XEML.js.map +0 -1
- package/dist/index-nae7nzib.d.ts +0 -147
- /package/dist/{chunk-7BPTGEVG.js.map → chunk-OLHGI472.js.map} +0 -0
|
@@ -1,7 +1,116 @@
|
|
|
1
|
-
import { C as CrudEntry, i as ClassifiedError, P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
|
|
2
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { C as CrudEntry, i as ClassifiedError, P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
|
|
3
3
|
import { LoggerAdapter } from './platform/index.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Conflict Types for @pol-studios/powersync
|
|
7
|
+
*
|
|
8
|
+
* Defines powersync-specific conflict types that mirror the types from @pol-studios/db.
|
|
9
|
+
* These are kept in sync with the db package to ensure type compatibility.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Represents a field-level conflict where both local and server changed the same field.
|
|
13
|
+
*/
|
|
14
|
+
interface FieldConflict {
|
|
15
|
+
/** The field name that has conflicting changes */
|
|
16
|
+
field: string;
|
|
17
|
+
/** The local (pending) value */
|
|
18
|
+
localValue: unknown;
|
|
19
|
+
/** The current server value */
|
|
20
|
+
serverValue: unknown;
|
|
21
|
+
/** User who made the server change (from AuditLog.changeBy) */
|
|
22
|
+
changedBy: string | null;
|
|
23
|
+
/** When the server change occurred (from AuditLog.changeAt) */
|
|
24
|
+
changedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of checking for conflicts between local changes and server state.
|
|
28
|
+
*/
|
|
29
|
+
interface ConflictCheckResult {
|
|
30
|
+
/** Whether any field conflicts were detected */
|
|
31
|
+
hasConflict: boolean;
|
|
32
|
+
/** List of field-level conflicts */
|
|
33
|
+
conflicts: FieldConflict[];
|
|
34
|
+
/** Fields that can safely sync (no server changes) */
|
|
35
|
+
nonConflictingChanges: string[];
|
|
36
|
+
/** The table name */
|
|
37
|
+
table: string;
|
|
38
|
+
/** The record ID */
|
|
39
|
+
recordId: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* User's resolution choice for a conflict.
|
|
43
|
+
*/
|
|
44
|
+
type ConflictResolution = {
|
|
45
|
+
action: 'overwrite';
|
|
46
|
+
} | {
|
|
47
|
+
action: 'keep-server';
|
|
48
|
+
} | {
|
|
49
|
+
action: 'partial';
|
|
50
|
+
fields: string[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Handler for conflict events in the connector.
|
|
54
|
+
*/
|
|
55
|
+
interface ConflictHandler {
|
|
56
|
+
/**
|
|
57
|
+
* Called when a conflict is detected during upload.
|
|
58
|
+
*
|
|
59
|
+
* @param result - The conflict check result
|
|
60
|
+
* @returns Resolution to apply, or null to queue for UI resolution
|
|
61
|
+
*/
|
|
62
|
+
onConflict: (result: ConflictCheckResult) => Promise<ConflictResolution | null>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Configuration for conflict detection behavior.
|
|
66
|
+
*/
|
|
67
|
+
interface ConflictDetectionConfig {
|
|
68
|
+
/** Tables to skip conflict detection (opt-out). Default: [] */
|
|
69
|
+
skipTables?: string[];
|
|
70
|
+
/** Fields to ignore in conflict detection. Default: ['updatedAt', 'createdAt'] */
|
|
71
|
+
ignoredFields?: string[];
|
|
72
|
+
/** Whether to enable conflict detection. Default: true */
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type ConflictListener = (conflict: ConflictCheckResult) => void;
|
|
77
|
+
type ResolutionListener = (table: string, recordId: string, resolution: ConflictResolution) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Event bus for decoupling conflict detection from UI resolution.
|
|
80
|
+
*
|
|
81
|
+
* Flow:
|
|
82
|
+
* 1. Connector detects conflict -> calls bus.emitConflict()
|
|
83
|
+
* 2. ConflictContext subscribes via bus.onConflict() -> shows UI
|
|
84
|
+
* 3. User resolves -> ConflictContext calls bus.emitResolution()
|
|
85
|
+
* 4. Connector subscribes via bus.onResolution() -> triggers re-upload
|
|
86
|
+
*/
|
|
87
|
+
declare class ConflictBus {
|
|
88
|
+
private conflictListeners;
|
|
89
|
+
private resolutionListeners;
|
|
90
|
+
/**
|
|
91
|
+
* Subscribe to conflict detection events.
|
|
92
|
+
* @returns Unsubscribe function
|
|
93
|
+
*/
|
|
94
|
+
onConflict(listener: ConflictListener): () => void;
|
|
95
|
+
/**
|
|
96
|
+
* Subscribe to resolution events.
|
|
97
|
+
* @returns Unsubscribe function
|
|
98
|
+
*/
|
|
99
|
+
onResolution(listener: ResolutionListener): () => void;
|
|
100
|
+
/**
|
|
101
|
+
* Emit a conflict detection event (called by connector).
|
|
102
|
+
*/
|
|
103
|
+
emitConflict(conflict: ConflictCheckResult): void;
|
|
104
|
+
/**
|
|
105
|
+
* Emit a resolution event (called by UI/ConflictContext).
|
|
106
|
+
*/
|
|
107
|
+
emitResolution(table: string, recordId: string, resolution: ConflictResolution): void;
|
|
108
|
+
/**
|
|
109
|
+
* Clear all listeners (for cleanup).
|
|
110
|
+
*/
|
|
111
|
+
destroy(): void;
|
|
112
|
+
}
|
|
113
|
+
|
|
5
114
|
/**
|
|
6
115
|
* Connector Types for @pol-studios/powersync
|
|
7
116
|
*
|
|
@@ -37,6 +146,21 @@ interface SupabaseConnectorOptions {
|
|
|
37
146
|
onTransactionComplete?: (entries: CrudEntry[]) => void;
|
|
38
147
|
/** Function to check if upload should proceed. Used for sync mode gating. */
|
|
39
148
|
shouldUpload?: () => boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Optional: Configuration for version-based conflict detection.
|
|
151
|
+
* When enabled, checks for conflicts before uploading changes.
|
|
152
|
+
*/
|
|
153
|
+
conflictDetection?: ConflictDetectionConfig;
|
|
154
|
+
/**
|
|
155
|
+
* Optional: Handler for conflict resolution.
|
|
156
|
+
* If not provided, conflicts are logged and upload proceeds.
|
|
157
|
+
*/
|
|
158
|
+
conflictHandler?: ConflictHandler;
|
|
159
|
+
/**
|
|
160
|
+
* Optional: Event bus for publishing conflict events.
|
|
161
|
+
* Use this to notify the UI layer about detected conflicts.
|
|
162
|
+
*/
|
|
163
|
+
conflictBus?: ConflictBus;
|
|
40
164
|
}
|
|
41
165
|
/**
|
|
42
166
|
* Configuration passed to PowerSyncProvider for connector setup
|
|
@@ -132,6 +256,7 @@ interface PowerSyncCredentials {
|
|
|
132
256
|
* - Uploading local changes back to Supabase
|
|
133
257
|
* - Schema routing for multi-schema databases
|
|
134
258
|
* - Custom CRUD handling for complex operations
|
|
259
|
+
* - Version-based conflict detection (when enabled)
|
|
135
260
|
*/
|
|
136
261
|
|
|
137
262
|
/**
|
|
@@ -191,8 +316,19 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
|
191
316
|
private readonly onTransactionFailure?;
|
|
192
317
|
private readonly onTransactionComplete?;
|
|
193
318
|
private readonly shouldUploadFn?;
|
|
319
|
+
private readonly conflictDetection?;
|
|
320
|
+
private readonly conflictHandler?;
|
|
321
|
+
private readonly conflictBus?;
|
|
322
|
+
private versionColumnCache;
|
|
194
323
|
private activeProjectIds;
|
|
324
|
+
private resolvedConflicts;
|
|
325
|
+
private unsubscribeResolution?;
|
|
195
326
|
constructor(options: SupabaseConnectorOptions);
|
|
327
|
+
/**
|
|
328
|
+
* Clean up resources (unsubscribe from event listeners).
|
|
329
|
+
* Call this when the connector is no longer needed.
|
|
330
|
+
*/
|
|
331
|
+
destroy(): void;
|
|
196
332
|
/**
|
|
197
333
|
* Set the active project IDs for scoped sync.
|
|
198
334
|
* Call this when user selects/opens projects.
|
|
@@ -213,8 +349,29 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
|
213
349
|
/**
|
|
214
350
|
* Upload local changes to Supabase.
|
|
215
351
|
* Called automatically by PowerSync when there are pending uploads.
|
|
352
|
+
*
|
|
353
|
+
* When conflict detection is enabled:
|
|
354
|
+
* 1. Checks if table has _version column (cached)
|
|
355
|
+
* 2. If yes, compares local vs server version
|
|
356
|
+
* 3. On version mismatch, queries AuditLog for field conflicts
|
|
357
|
+
* 4. If conflicts found, calls handler or publishes to conflict bus
|
|
358
|
+
* 5. Applies resolution or skips entry based on handler response
|
|
216
359
|
*/
|
|
217
360
|
uploadData(database: AbstractPowerSyncDatabase): Promise<void>;
|
|
361
|
+
/**
|
|
362
|
+
* Process a transaction without conflict detection.
|
|
363
|
+
* Used when conflict detection is disabled.
|
|
364
|
+
*/
|
|
365
|
+
private processTransaction;
|
|
366
|
+
/**
|
|
367
|
+
* Check if a table has a _version column (cached).
|
|
368
|
+
*/
|
|
369
|
+
private checkVersionColumn;
|
|
370
|
+
/**
|
|
371
|
+
* Filter opData to only include specified fields.
|
|
372
|
+
* Used for partial sync resolution.
|
|
373
|
+
*/
|
|
374
|
+
private filterFields;
|
|
218
375
|
/**
|
|
219
376
|
* Process a single CRUD operation.
|
|
220
377
|
*
|
|
@@ -229,4 +386,4 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
|
229
386
|
private processCrudEntry;
|
|
230
387
|
}
|
|
231
388
|
|
|
232
|
-
export { type ConnectorConfig as C, type PowerSyncCredentials as P, SupabaseConnector as S, type SupabaseConnectorOptions as a, type SchemaRouter as b, type CrudHandler as c, defaultSchemaRouter as d };
|
|
389
|
+
export { type ConnectorConfig as C, type FieldConflict as F, type PowerSyncCredentials as P, type ResolutionListener as R, SupabaseConnector as S, type SupabaseConnectorOptions as a, type SchemaRouter as b, type CrudHandler as c, defaultSchemaRouter as d, ConflictBus as e, type ConflictCheckResult as f, type ConflictResolution as g, type ConflictHandler as h, type ConflictDetectionConfig as i, type ConflictListener as j };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
|
|
2
2
|
export { k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-afHtE1U_.js';
|
|
3
3
|
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { C as ConflictAwareConnector, a as ConflictAwareConnectorOptions, d as ConflictHandler, c as ConflictResolution, F as FieldConflict } from './index-nae7nzib.js';
|
|
4
|
+
import { i as ConflictDetectionConfig, f as ConflictCheckResult } from './index-Cb-NI0Ct.js';
|
|
5
|
+
export { e as ConflictBus, h as ConflictHandler, j as ConflictListener, g as ConflictResolution, C as ConnectorConfig, c as CrudHandler, F as FieldConflict, P as PowerSyncCredentials, R as ResolutionListener, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './index-Cb-NI0Ct.js';
|
|
7
6
|
export { AttachmentQueue, AttachmentQueueConfig, AttachmentRecord, AttachmentSourceConfig, AttachmentState, AttachmentStatsRow, AttachmentStorageAdapter, AttachmentSyncStats, AttachmentSyncStatus, CacheConfig, CacheFileRow, CachedSizeRow, CompressionConfig, DEFAULT_CACHE_CONFIG, DEFAULT_COMPRESSION_CONFIG, DEFAULT_DOWNLOAD_CONFIG, DownloadConfig, DownloadPhase, DownloadStatus, EvictRow, IdRow } from './attachments/index.js';
|
|
8
7
|
export { e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe } from './types-Cd7RhNqf.js';
|
|
9
8
|
export { HealthMonitor, MetricsCollector, SyncStatusTracker } from './sync/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-OLHGI472.js";
|
|
2
2
|
import "./chunk-32OLICZO.js";
|
|
3
3
|
import {
|
|
4
4
|
AttachmentQueueContext,
|
|
5
|
+
ConflictBus,
|
|
5
6
|
ConnectionHealthContext,
|
|
6
7
|
PowerSyncContext,
|
|
7
8
|
PowerSyncProvider,
|
|
@@ -23,14 +24,14 @@ import {
|
|
|
23
24
|
useSyncMode,
|
|
24
25
|
useSyncStatus,
|
|
25
26
|
useUploadStatus
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GMFDCVMZ.js";
|
|
27
28
|
import {
|
|
28
29
|
AttachmentQueue,
|
|
29
30
|
AttachmentState,
|
|
30
31
|
DEFAULT_CACHE_CONFIG,
|
|
31
32
|
DEFAULT_COMPRESSION_CONFIG,
|
|
32
33
|
DEFAULT_DOWNLOAD_CONFIG
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-V6LJ6MR2.js";
|
|
34
35
|
import "./chunk-7JQZBZ5N.js";
|
|
35
36
|
import {
|
|
36
37
|
DEFAULT_CONNECTION_HEALTH,
|
|
@@ -40,7 +41,7 @@ import {
|
|
|
40
41
|
HealthMonitor,
|
|
41
42
|
MetricsCollector,
|
|
42
43
|
SyncStatusTracker
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-OTJXIRWX.js";
|
|
44
45
|
import "./chunk-W7HSR35B.js";
|
|
45
46
|
import {
|
|
46
47
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -73,18 +74,16 @@ import {
|
|
|
73
74
|
STORAGE_KEY_PREFIX,
|
|
74
75
|
STORAGE_KEY_SYNC_MODE,
|
|
75
76
|
STORAGE_WARNING_THRESHOLD
|
|
76
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-EJ23MXPQ.js";
|
|
78
|
+
import "./chunk-VJCL2SWD.js";
|
|
77
79
|
import {
|
|
78
|
-
|
|
80
|
+
SupabaseConnector,
|
|
81
|
+
defaultSchemaRouter,
|
|
79
82
|
detectConflicts,
|
|
80
83
|
fetchServerVersion,
|
|
81
84
|
getLocalVersion,
|
|
82
85
|
hasVersionColumn
|
|
83
|
-
} from "./chunk-
|
|
84
|
-
import {
|
|
85
|
-
SupabaseConnector,
|
|
86
|
-
defaultSchemaRouter
|
|
87
|
-
} from "./chunk-FLHDT4TS.js";
|
|
86
|
+
} from "./chunk-C2RSTGDC.js";
|
|
88
87
|
import {
|
|
89
88
|
AttachmentError,
|
|
90
89
|
ConfigurationError,
|
|
@@ -100,7 +99,7 @@ import {
|
|
|
100
99
|
extractTableNames,
|
|
101
100
|
generateFailureId,
|
|
102
101
|
toSyncOperationError
|
|
103
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-FPTDATY5.js";
|
|
104
103
|
export {
|
|
105
104
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
106
105
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -112,7 +111,7 @@ export {
|
|
|
112
111
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
113
112
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
114
113
|
ConfigurationError,
|
|
115
|
-
|
|
114
|
+
ConflictBus,
|
|
116
115
|
ConnectionHealthContext,
|
|
117
116
|
ConnectorError,
|
|
118
117
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
package/dist/index.native.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { A as AbstractPowerSyncDatabase, k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-afHtE1U_.js';
|
|
2
2
|
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
3
|
-
export { C as ConnectorConfig, c as CrudHandler, P as PowerSyncCredentials, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './
|
|
4
|
-
export { C as ConflictAwareConnector, a as ConflictAwareConnectorOptions, b as ConflictCheckResult, e as ConflictDetectionConfig, d as ConflictHandler, c as ConflictResolution, F as FieldConflict } from './index-nae7nzib.js';
|
|
3
|
+
export { e as ConflictBus, f as ConflictCheckResult, i as ConflictDetectionConfig, h as ConflictHandler, j as ConflictListener, g as ConflictResolution, C as ConnectorConfig, c as CrudHandler, F as FieldConflict, P as PowerSyncCredentials, R as ResolutionListener, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './index-Cb-NI0Ct.js';
|
|
5
4
|
export { AttachmentQueue, AttachmentQueueConfig, AttachmentRecord, AttachmentSourceConfig, AttachmentState, AttachmentStatsRow, AttachmentStorageAdapter, AttachmentSyncStats, AttachmentSyncStatus, CacheConfig, CacheFileRow, CachedSizeRow, CompressionConfig, DEFAULT_CACHE_CONFIG, DEFAULT_COMPRESSION_CONFIG, DEFAULT_DOWNLOAD_CONFIG, DownloadConfig, DownloadPhase, DownloadStatus, EvictRow, IdRow } from './attachments/index.js';
|
|
6
5
|
export { e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe } from './types-Cd7RhNqf.js';
|
|
7
6
|
export { HealthMonitor, MetricsCollector, SyncStatusTracker } from './sync/index.js';
|
package/dist/index.native.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-OLHGI472.js";
|
|
2
2
|
import "./chunk-32OLICZO.js";
|
|
3
3
|
import {
|
|
4
4
|
AttachmentQueueContext,
|
|
5
|
+
ConflictBus,
|
|
5
6
|
ConnectionHealthContext,
|
|
6
7
|
PowerSyncContext,
|
|
7
8
|
PowerSyncProvider,
|
|
@@ -23,14 +24,14 @@ import {
|
|
|
23
24
|
useSyncMode,
|
|
24
25
|
useSyncStatus,
|
|
25
26
|
useUploadStatus
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GMFDCVMZ.js";
|
|
27
28
|
import {
|
|
28
29
|
AttachmentQueue,
|
|
29
30
|
AttachmentState,
|
|
30
31
|
DEFAULT_CACHE_CONFIG,
|
|
31
32
|
DEFAULT_COMPRESSION_CONFIG,
|
|
32
33
|
DEFAULT_DOWNLOAD_CONFIG
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-V6LJ6MR2.js";
|
|
34
35
|
import "./chunk-7JQZBZ5N.js";
|
|
35
36
|
import {
|
|
36
37
|
DEFAULT_CONNECTION_HEALTH,
|
|
@@ -40,7 +41,7 @@ import {
|
|
|
40
41
|
HealthMonitor,
|
|
41
42
|
MetricsCollector,
|
|
42
43
|
SyncStatusTracker
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-OTJXIRWX.js";
|
|
44
45
|
import "./chunk-W7HSR35B.js";
|
|
45
46
|
import {
|
|
46
47
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -73,21 +74,19 @@ import {
|
|
|
73
74
|
STORAGE_KEY_PREFIX,
|
|
74
75
|
STORAGE_KEY_SYNC_MODE,
|
|
75
76
|
STORAGE_WARNING_THRESHOLD
|
|
76
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-EJ23MXPQ.js";
|
|
77
78
|
import {
|
|
78
79
|
createNativePlatformAdapter
|
|
79
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-3AYXHQ4W.js";
|
|
81
|
+
import "./chunk-VJCL2SWD.js";
|
|
80
82
|
import {
|
|
81
|
-
|
|
83
|
+
SupabaseConnector,
|
|
84
|
+
defaultSchemaRouter,
|
|
82
85
|
detectConflicts,
|
|
83
86
|
fetchServerVersion,
|
|
84
87
|
getLocalVersion,
|
|
85
88
|
hasVersionColumn
|
|
86
|
-
} from "./chunk-
|
|
87
|
-
import {
|
|
88
|
-
SupabaseConnector,
|
|
89
|
-
defaultSchemaRouter
|
|
90
|
-
} from "./chunk-FLHDT4TS.js";
|
|
89
|
+
} from "./chunk-C2RSTGDC.js";
|
|
91
90
|
import {
|
|
92
91
|
AttachmentError,
|
|
93
92
|
ConfigurationError,
|
|
@@ -103,7 +102,7 @@ import {
|
|
|
103
102
|
extractTableNames,
|
|
104
103
|
generateFailureId,
|
|
105
104
|
toSyncOperationError
|
|
106
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-FPTDATY5.js";
|
|
107
106
|
export {
|
|
108
107
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
109
108
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -115,7 +114,7 @@ export {
|
|
|
115
114
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
116
115
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
117
116
|
ConfigurationError,
|
|
118
|
-
|
|
117
|
+
ConflictBus,
|
|
119
118
|
ConnectionHealthContext,
|
|
120
119
|
ConnectorError,
|
|
121
120
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
package/dist/index.web.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { A as AbstractPowerSyncDatabase, k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-afHtE1U_.js';
|
|
2
2
|
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
3
|
-
export { C as ConnectorConfig, c as CrudHandler, P as PowerSyncCredentials, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './
|
|
4
|
-
export { C as ConflictAwareConnector, a as ConflictAwareConnectorOptions, b as ConflictCheckResult, e as ConflictDetectionConfig, d as ConflictHandler, c as ConflictResolution, F as FieldConflict } from './index-nae7nzib.js';
|
|
3
|
+
export { e as ConflictBus, f as ConflictCheckResult, i as ConflictDetectionConfig, h as ConflictHandler, j as ConflictListener, g as ConflictResolution, C as ConnectorConfig, c as CrudHandler, F as FieldConflict, P as PowerSyncCredentials, R as ResolutionListener, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './index-Cb-NI0Ct.js';
|
|
5
4
|
export { AttachmentQueue, AttachmentQueueConfig, AttachmentRecord, AttachmentSourceConfig, AttachmentState, AttachmentStatsRow, AttachmentStorageAdapter, AttachmentSyncStats, AttachmentSyncStatus, CacheConfig, CacheFileRow, CachedSizeRow, CompressionConfig, DEFAULT_CACHE_CONFIG, DEFAULT_COMPRESSION_CONFIG, DEFAULT_DOWNLOAD_CONFIG, DownloadConfig, DownloadPhase, DownloadStatus, EvictRow, IdRow } from './attachments/index.js';
|
|
6
5
|
export { e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe } from './types-Cd7RhNqf.js';
|
|
7
6
|
export { HealthMonitor, MetricsCollector, SyncStatusTracker } from './sync/index.js';
|
package/dist/index.web.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-OLHGI472.js";
|
|
2
2
|
import "./chunk-32OLICZO.js";
|
|
3
3
|
import {
|
|
4
4
|
AttachmentQueueContext,
|
|
5
|
+
ConflictBus,
|
|
5
6
|
ConnectionHealthContext,
|
|
6
7
|
PowerSyncContext,
|
|
7
8
|
PowerSyncProvider,
|
|
@@ -23,14 +24,14 @@ import {
|
|
|
23
24
|
useSyncMode,
|
|
24
25
|
useSyncStatus,
|
|
25
26
|
useUploadStatus
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GMFDCVMZ.js";
|
|
27
28
|
import {
|
|
28
29
|
AttachmentQueue,
|
|
29
30
|
AttachmentState,
|
|
30
31
|
DEFAULT_CACHE_CONFIG,
|
|
31
32
|
DEFAULT_COMPRESSION_CONFIG,
|
|
32
33
|
DEFAULT_DOWNLOAD_CONFIG
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-V6LJ6MR2.js";
|
|
34
35
|
import "./chunk-7JQZBZ5N.js";
|
|
35
36
|
import {
|
|
36
37
|
DEFAULT_CONNECTION_HEALTH,
|
|
@@ -40,7 +41,7 @@ import {
|
|
|
40
41
|
HealthMonitor,
|
|
41
42
|
MetricsCollector,
|
|
42
43
|
SyncStatusTracker
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-OTJXIRWX.js";
|
|
44
45
|
import "./chunk-W7HSR35B.js";
|
|
45
46
|
import {
|
|
46
47
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -73,21 +74,19 @@ import {
|
|
|
73
74
|
STORAGE_KEY_PREFIX,
|
|
74
75
|
STORAGE_KEY_SYNC_MODE,
|
|
75
76
|
STORAGE_WARNING_THRESHOLD
|
|
76
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-EJ23MXPQ.js";
|
|
77
78
|
import {
|
|
78
79
|
createWebPlatformAdapter
|
|
79
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-7EMDVIZX.js";
|
|
81
|
+
import "./chunk-VJCL2SWD.js";
|
|
80
82
|
import {
|
|
81
|
-
|
|
83
|
+
SupabaseConnector,
|
|
84
|
+
defaultSchemaRouter,
|
|
82
85
|
detectConflicts,
|
|
83
86
|
fetchServerVersion,
|
|
84
87
|
getLocalVersion,
|
|
85
88
|
hasVersionColumn
|
|
86
|
-
} from "./chunk-
|
|
87
|
-
import {
|
|
88
|
-
SupabaseConnector,
|
|
89
|
-
defaultSchemaRouter
|
|
90
|
-
} from "./chunk-FLHDT4TS.js";
|
|
89
|
+
} from "./chunk-C2RSTGDC.js";
|
|
91
90
|
import {
|
|
92
91
|
AttachmentError,
|
|
93
92
|
ConfigurationError,
|
|
@@ -103,7 +102,7 @@ import {
|
|
|
103
102
|
extractTableNames,
|
|
104
103
|
generateFailureId,
|
|
105
104
|
toSyncOperationError
|
|
106
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-FPTDATY5.js";
|
|
107
106
|
export {
|
|
108
107
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
109
108
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -115,7 +114,7 @@ export {
|
|
|
115
114
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
116
115
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
117
116
|
ConfigurationError,
|
|
118
|
-
|
|
117
|
+
ConflictBus,
|
|
119
118
|
ConnectionHealthContext,
|
|
120
119
|
ConnectorError,
|
|
121
120
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/platform/types.ts"],"sourcesContent":["/**\n * Platform Adapter Types for @pol-studios/powersync\n *\n * This module defines the interfaces that platform-specific adapters must implement.\n * Consumers provide an adapter for their platform (React Native or Web) that handles\n * platform-specific operations like file system access, async storage, and network status.\n */\n\nimport type { AbstractPowerSyncDatabase } from '../core/types';\n\n// ─── Database Factory Options ────────────────────────────────────────────────\n\n/**\n * Options for creating a PowerSync database instance\n */\nexport interface DatabaseOptions {\n /** Database file name (e.g., \"pol-offline.db\") */\n dbFilename: string;\n /** PowerSync schema definition */\n schema: unknown; // Schema type from @powersync/common\n /** Optional: Encryption key for SQLite */\n encryptionKey?: string;\n}\n\n// ─── File System Adapter ─────────────────────────────────────────────────────\n\n/**\n * Information about a file or directory\n */\nexport interface FileInfo {\n /** Whether the file/directory exists */\n exists: boolean;\n /** Size in bytes (0 for directories) */\n size: number;\n /** Last modification time */\n modificationTime?: Date;\n /** Whether this is a directory */\n isDirectory: boolean;\n}\n\n/**\n * File system operations interface.\n *\n * React Native: Implemented using expo-file-system\n * Web: Implemented using IndexedDB or Cache API\n */\nexport interface FileSystemAdapter {\n /**\n * Read a file's contents\n * @param uri - The file URI/path\n * @param encoding - How to encode the result ('base64' or 'utf8')\n */\n readFile(uri: string, encoding?: 'base64' | 'utf8'): Promise<string>;\n\n /**\n * Write data to a file (creates parent directories if needed)\n * @param uri - The file URI/path\n * @param data - The data to write\n * @param encoding - How the data is encoded ('base64' or 'utf8')\n */\n writeFile(uri: string, data: string, encoding?: 'base64' | 'utf8'): Promise<void>;\n\n /**\n * Delete a file\n * @param uri - The file URI/path\n */\n deleteFile(uri: string): Promise<void>;\n\n /**\n * Copy a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n copyFile(source: string, destination: string): Promise<void>;\n\n /**\n * Move a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n moveFile(source: string, destination: string): Promise<void>;\n\n /**\n * Get information about a file or directory\n * @param uri - The file URI/path\n * @returns File info or null if it doesn't exist\n */\n getFileInfo(uri: string): Promise<FileInfo | null>;\n\n /**\n * Create a directory\n * @param uri - The directory URI/path\n * @param options - Options for directory creation\n */\n makeDirectory(uri: string, options?: {
|
|
1
|
+
{"version":3,"sources":["../../src/platform/types.ts"],"sourcesContent":["/**\n * Platform Adapter Types for @pol-studios/powersync\n *\n * This module defines the interfaces that platform-specific adapters must implement.\n * Consumers provide an adapter for their platform (React Native or Web) that handles\n * platform-specific operations like file system access, async storage, and network status.\n */\n\nimport type { AbstractPowerSyncDatabase } from '../core/types';\n\n// ─── Database Factory Options ────────────────────────────────────────────────\n\n/**\n * Options for creating a PowerSync database instance\n */\nexport interface DatabaseOptions {\n /** Database file name (e.g., \"pol-offline.db\") */\n dbFilename: string;\n /** PowerSync schema definition */\n schema: unknown; // Schema type from @powersync/common\n /** Optional: Encryption key for SQLite */\n encryptionKey?: string;\n}\n\n// ─── File System Adapter ─────────────────────────────────────────────────────\n\n/**\n * Information about a file or directory\n */\nexport interface FileInfo {\n /** Whether the file/directory exists */\n exists: boolean;\n /** Size in bytes (0 for directories) */\n size: number;\n /** Last modification time */\n modificationTime?: Date;\n /** Whether this is a directory */\n isDirectory: boolean;\n}\n\n/**\n * File system operations interface.\n *\n * React Native: Implemented using expo-file-system\n * Web: Implemented using IndexedDB or Cache API\n */\nexport interface FileSystemAdapter {\n /**\n * Read a file's contents\n * @param uri - The file URI/path\n * @param encoding - How to encode the result ('base64' or 'utf8')\n */\n readFile(uri: string, encoding?: 'base64' | 'utf8'): Promise<string>;\n\n /**\n * Write data to a file (creates parent directories if needed)\n * @param uri - The file URI/path\n * @param data - The data to write\n * @param encoding - How the data is encoded ('base64' or 'utf8')\n */\n writeFile(uri: string, data: string, encoding?: 'base64' | 'utf8'): Promise<void>;\n\n /**\n * Delete a file\n * @param uri - The file URI/path\n */\n deleteFile(uri: string): Promise<void>;\n\n /**\n * Copy a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n copyFile(source: string, destination: string): Promise<void>;\n\n /**\n * Move a file from source to destination\n * @param source - Source file URI/path\n * @param destination - Destination file URI/path\n */\n moveFile(source: string, destination: string): Promise<void>;\n\n /**\n * Get information about a file or directory\n * @param uri - The file URI/path\n * @returns File info or null if it doesn't exist\n */\n getFileInfo(uri: string): Promise<FileInfo | null>;\n\n /**\n * Create a directory\n * @param uri - The directory URI/path\n * @param options - Options for directory creation\n */\n makeDirectory(uri: string, options?: {\n intermediates?: boolean;\n }): Promise<void>;\n\n /**\n * Get the documents directory path for this platform\n */\n getDocumentsDirectory(): string;\n\n /**\n * Get the cache directory path for this platform\n */\n getCacheDirectory(): string;\n\n /**\n * Get the free disk space in bytes\n */\n getFreeDiskSpace(): Promise<number>;\n}\n\n// ─── Async Storage Adapter ───────────────────────────────────────────────────\n\n/**\n * Key-value storage interface for persisting preferences and state.\n *\n * React Native: Implemented using @react-native-async-storage/async-storage\n * Web: Implemented using localStorage\n */\nexport interface AsyncStorageAdapter {\n /**\n * Get a value by key\n * @param key - The storage key\n * @returns The stored value or null if not found\n */\n getItem(key: string): Promise<string | null>;\n\n /**\n * Set a value by key\n * @param key - The storage key\n * @param value - The value to store\n */\n setItem(key: string, value: string): Promise<void>;\n\n /**\n * Remove a value by key\n * @param key - The storage key\n */\n removeItem(key: string): Promise<void>;\n\n /**\n * Get multiple values by keys\n * @param keys - Array of storage keys\n * @returns Array of [key, value] tuples\n */\n multiGet(keys: string[]): Promise<[string, string | null][]>;\n\n /**\n * Set multiple values\n * @param entries - Array of [key, value] tuples\n */\n multiSet(entries: [string, string][]): Promise<void>;\n}\n\n// ─── Network Adapter ─────────────────────────────────────────────────────────\n\n/** Network connection types */\nexport type ConnectionType = 'wifi' | 'cellular' | 'ethernet' | 'unknown' | 'none';\n\n/**\n * Network connectivity monitoring interface.\n *\n * React Native: Implemented using @react-native-community/netinfo\n * Web: Implemented using navigator.onLine + online/offline events\n */\nexport interface NetworkAdapter {\n /**\n * Check if the device is currently connected to the internet\n */\n isConnected(): Promise<boolean>;\n\n /**\n * Get the current connection type\n */\n getConnectionType(): Promise<ConnectionType>;\n\n /**\n * Add a listener for connection status changes\n * @param callback - Called when connection status changes\n * @returns Unsubscribe function\n */\n addConnectionListener(callback: (isConnected: boolean) => void): () => void;\n}\n\n// ─── Logger Adapter ──────────────────────────────────────────────────────────\n\n/**\n * Logging interface for debugging and monitoring.\n * Allows consumers to use their existing logging infrastructure.\n */\nexport interface LoggerAdapter {\n /**\n * Log a debug message (verbose, for development)\n */\n debug(message: string, ...args: unknown[]): void;\n\n /**\n * Log an info message (general information)\n */\n info(message: string, ...args: unknown[]): void;\n\n /**\n * Log a warning message (potential issues)\n */\n warn(message: string, ...args: unknown[]): void;\n\n /**\n * Log an error message (failures)\n */\n error(message: string, ...args: unknown[]): void;\n}\n\n// ─── Image Processor Adapter ─────────────────────────────────────────────────\n\n/**\n * Result of an image compression operation\n */\nexport interface CompressedImage {\n /** URI/path to the compressed image */\n uri: string;\n /** Width of the compressed image in pixels */\n width: number;\n /** Height of the compressed image in pixels */\n height: number;\n}\n\n/**\n * Options for image compression\n */\nexport interface CompressionOptions {\n /** Compression quality (0.0 to 1.0, where 1.0 is best quality) */\n quality: number;\n /** Maximum width in pixels (will scale down if larger) */\n maxWidth?: number;\n /** Maximum height in pixels (will scale down if larger) */\n maxHeight?: number;\n /** Output format */\n format?: 'jpeg' | 'png' | 'webp';\n}\n\n/**\n * Image processing interface for attachment compression.\n *\n * React Native: Implemented using expo-image-manipulator\n * Web: Implemented using canvas API\n *\n * This is optional - if not provided, attachments won't be compressed.\n */\nexport interface ImageProcessorAdapter {\n /**\n * Compress an image\n * @param uri - The source image URI/path\n * @param options - Compression options\n * @returns The compressed image result\n */\n compress(uri: string, options: CompressionOptions): Promise<CompressedImage>;\n}\n\n// ─── Main Platform Adapter Interface ─────────────────────────────────────────\n\n/**\n * Platform-specific adapter that consumers must provide.\n * This allows the package to work across React Native and Web.\n *\n * @example React Native\n * ```typescript\n * import { createNativePlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createNativePlatformAdapter(logger);\n * ```\n *\n * @example Web\n * ```typescript\n * import { createWebPlatformAdapter } from '@pol-studios/powersync/platform';\n *\n * const platform = createWebPlatformAdapter(logger);\n * ```\n */\nexport interface PlatformAdapter {\n /**\n * Create a PowerSync database instance for this platform.\n *\n * React Native: Uses PowerSyncDatabase from @powersync/react-native\n * Web: Uses PowerSyncDatabase from @powersync/web\n *\n * @param options - Database creation options\n * @returns Initialized PowerSync database\n */\n createDatabase(options: DatabaseOptions): Promise<AbstractPowerSyncDatabase>;\n\n /**\n * File system operations for attachment caching.\n */\n fileSystem: FileSystemAdapter;\n\n /**\n * Key-value storage for preferences and metrics persistence.\n */\n storage: AsyncStorageAdapter;\n\n /**\n * Network connectivity monitoring.\n */\n network: NetworkAdapter;\n\n /**\n * Logging interface.\n */\n logger: LoggerAdapter;\n\n /**\n * Optional: Image compression for attachment optimization.\n * If not provided, attachments won't be compressed.\n */\n imageProcessor?: ImageProcessorAdapter;\n}\n\n// ─── Platform Detection ──────────────────────────────────────────────────────\n\n/** Supported platform types */\nexport type PlatformType = 'react-native' | 'web' | 'unknown';\n\n/**\n * Detect the current platform based on environment\n */\nexport function detectPlatform(): PlatformType {\n // Check for React Native\n if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n return 'react-native';\n }\n\n // Check for browser environment\n if (typeof window !== 'undefined' && typeof document !== 'undefined') {\n return 'web';\n }\n return 'unknown';\n}"],"mappings":";AAwUO,SAAS,iBAA+B;AAE7C,MAAI,OAAO,cAAc,eAAe,UAAU,YAAY,eAAe;AAC3E,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { A as AbstractPowerSyncDatabase, a as SyncStatus, C as CrudEntry, S as SyncMode, F as FailedTransaction, h as CompletedTransaction, b as ConnectionHealth, e as SyncMetrics, D as DownloadProgress, E as EntitySyncState, f as SyncError } from '../types-afHtE1U_.js';
|
|
4
4
|
import { PlatformAdapter } from '../platform/index.js';
|
|
5
|
-
import { C as ConnectorConfig, S as SupabaseConnector } from '../
|
|
5
|
+
import { C as ConnectorConfig, S as SupabaseConnector, e as ConflictBus } from '../index-Cb-NI0Ct.js';
|
|
6
6
|
import { AttachmentQueueConfig, AttachmentQueue } from '../attachments/index.js';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default from 'react';
|
|
@@ -144,6 +144,11 @@ interface PowerSyncContextValue<TSchema = unknown> {
|
|
|
144
144
|
* The platform adapter instance.
|
|
145
145
|
*/
|
|
146
146
|
platform: PlatformAdapter;
|
|
147
|
+
/**
|
|
148
|
+
* The conflict bus for subscribing to conflict events.
|
|
149
|
+
* Use this to wire up conflict UI components.
|
|
150
|
+
*/
|
|
151
|
+
conflictBus: ConflictBus;
|
|
147
152
|
}
|
|
148
153
|
/**
|
|
149
154
|
* Value provided by SyncStatusContext.
|
package/dist/provider/index.js
CHANGED
|
@@ -21,17 +21,17 @@ import {
|
|
|
21
21
|
useSyncMode,
|
|
22
22
|
useSyncStatus,
|
|
23
23
|
useUploadStatus
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-GMFDCVMZ.js";
|
|
25
|
+
import "../chunk-V6LJ6MR2.js";
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_CONNECTION_HEALTH,
|
|
28
28
|
DEFAULT_SYNC_CONFIG,
|
|
29
29
|
DEFAULT_SYNC_METRICS,
|
|
30
30
|
DEFAULT_SYNC_STATUS
|
|
31
|
-
} from "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-
|
|
31
|
+
} from "../chunk-OTJXIRWX.js";
|
|
32
|
+
import "../chunk-EJ23MXPQ.js";
|
|
33
|
+
import "../chunk-C2RSTGDC.js";
|
|
34
|
+
import "../chunk-FPTDATY5.js";
|
|
35
35
|
export {
|
|
36
36
|
AttachmentQueueContext,
|
|
37
37
|
ConnectionHealthContext,
|
package/dist/sync/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
HealthMonitor,
|
|
4
4
|
MetricsCollector,
|
|
5
5
|
SyncStatusTracker
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-OTJXIRWX.js";
|
|
7
|
+
import "../chunk-EJ23MXPQ.js";
|
|
8
|
+
import "../chunk-FPTDATY5.js";
|
|
9
9
|
export {
|
|
10
10
|
HealthMonitor,
|
|
11
11
|
MetricsCollector,
|