@affectively/aeon-pages 1.3.0
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/CHANGELOG.md +112 -0
- package/README.md +625 -0
- package/examples/basic/aeon.config.ts +39 -0
- package/examples/basic/components/Cursor.tsx +86 -0
- package/examples/basic/components/OfflineIndicator.tsx +103 -0
- package/examples/basic/components/PresenceBar.tsx +77 -0
- package/examples/basic/package.json +20 -0
- package/examples/basic/pages/index.tsx +80 -0
- package/package.json +101 -0
- package/packages/analytics/README.md +309 -0
- package/packages/analytics/build.ts +35 -0
- package/packages/analytics/package.json +50 -0
- package/packages/analytics/src/click-tracker.ts +368 -0
- package/packages/analytics/src/context-bridge.ts +319 -0
- package/packages/analytics/src/data-layer.ts +302 -0
- package/packages/analytics/src/gtm-loader.ts +239 -0
- package/packages/analytics/src/index.ts +230 -0
- package/packages/analytics/src/merkle-tree.ts +489 -0
- package/packages/analytics/src/provider.tsx +300 -0
- package/packages/analytics/src/types.ts +320 -0
- package/packages/analytics/src/use-analytics.ts +296 -0
- package/packages/analytics/tsconfig.json +19 -0
- package/packages/benchmarks/src/benchmark.test.ts +691 -0
- package/packages/cli/dist/index.js +61899 -0
- package/packages/cli/package.json +43 -0
- package/packages/cli/src/commands/build.test.ts +682 -0
- package/packages/cli/src/commands/build.ts +890 -0
- package/packages/cli/src/commands/dev.ts +473 -0
- package/packages/cli/src/commands/init.ts +409 -0
- package/packages/cli/src/commands/start.ts +297 -0
- package/packages/cli/src/index.ts +105 -0
- package/packages/directives/src/use-aeon.ts +272 -0
- package/packages/mcp-server/package.json +51 -0
- package/packages/mcp-server/src/index.ts +178 -0
- package/packages/mcp-server/src/resources.ts +346 -0
- package/packages/mcp-server/src/tools/index.ts +36 -0
- package/packages/mcp-server/src/tools/navigation.ts +545 -0
- package/packages/mcp-server/tsconfig.json +21 -0
- package/packages/react/package.json +40 -0
- package/packages/react/src/Link.tsx +388 -0
- package/packages/react/src/components/InstallPrompt.tsx +286 -0
- package/packages/react/src/components/OfflineDiagnostics.tsx +677 -0
- package/packages/react/src/components/PushNotifications.tsx +453 -0
- package/packages/react/src/hooks/useAeonNavigation.ts +219 -0
- package/packages/react/src/hooks/useConflicts.ts +277 -0
- package/packages/react/src/hooks/useNetworkState.ts +209 -0
- package/packages/react/src/hooks/usePilotNavigation.ts +254 -0
- package/packages/react/src/hooks/useServiceWorker.ts +278 -0
- package/packages/react/src/hooks.ts +195 -0
- package/packages/react/src/index.ts +151 -0
- package/packages/react/src/provider.tsx +467 -0
- package/packages/react/tsconfig.json +19 -0
- package/packages/runtime/README.md +399 -0
- package/packages/runtime/build.ts +48 -0
- package/packages/runtime/package.json +71 -0
- package/packages/runtime/schema.sql +40 -0
- package/packages/runtime/src/api-routes.ts +465 -0
- package/packages/runtime/src/benchmark.ts +171 -0
- package/packages/runtime/src/cache.ts +479 -0
- package/packages/runtime/src/durable-object.ts +1341 -0
- package/packages/runtime/src/index.ts +360 -0
- package/packages/runtime/src/navigation.test.ts +421 -0
- package/packages/runtime/src/navigation.ts +422 -0
- package/packages/runtime/src/nextjs-adapter.ts +272 -0
- package/packages/runtime/src/offline/encrypted-queue.test.ts +607 -0
- package/packages/runtime/src/offline/encrypted-queue.ts +478 -0
- package/packages/runtime/src/offline/encryption.test.ts +412 -0
- package/packages/runtime/src/offline/encryption.ts +397 -0
- package/packages/runtime/src/offline/types.ts +465 -0
- package/packages/runtime/src/predictor.ts +371 -0
- package/packages/runtime/src/registry.ts +351 -0
- package/packages/runtime/src/router/context-extractor.ts +661 -0
- package/packages/runtime/src/router/esi-control-react.tsx +2053 -0
- package/packages/runtime/src/router/esi-control.ts +541 -0
- package/packages/runtime/src/router/esi-cyrano.ts +779 -0
- package/packages/runtime/src/router/esi-format-react.tsx +1744 -0
- package/packages/runtime/src/router/esi-react.tsx +1065 -0
- package/packages/runtime/src/router/esi-translate-observer.ts +476 -0
- package/packages/runtime/src/router/esi-translate-react.tsx +556 -0
- package/packages/runtime/src/router/esi-translate.ts +503 -0
- package/packages/runtime/src/router/esi.ts +666 -0
- package/packages/runtime/src/router/heuristic-adapter.test.ts +295 -0
- package/packages/runtime/src/router/heuristic-adapter.ts +557 -0
- package/packages/runtime/src/router/index.ts +298 -0
- package/packages/runtime/src/router/merkle-capability.ts +473 -0
- package/packages/runtime/src/router/speculation.ts +451 -0
- package/packages/runtime/src/router/types.ts +630 -0
- package/packages/runtime/src/router.test.ts +470 -0
- package/packages/runtime/src/router.ts +302 -0
- package/packages/runtime/src/server.ts +481 -0
- package/packages/runtime/src/service-worker-push.ts +319 -0
- package/packages/runtime/src/service-worker.ts +553 -0
- package/packages/runtime/src/skeleton-hydrate.ts +237 -0
- package/packages/runtime/src/speculation.test.ts +389 -0
- package/packages/runtime/src/speculation.ts +486 -0
- package/packages/runtime/src/storage.test.ts +1297 -0
- package/packages/runtime/src/storage.ts +1048 -0
- package/packages/runtime/src/sync/conflict-resolver.test.ts +528 -0
- package/packages/runtime/src/sync/conflict-resolver.ts +565 -0
- package/packages/runtime/src/sync/coordinator.test.ts +608 -0
- package/packages/runtime/src/sync/coordinator.ts +596 -0
- package/packages/runtime/src/tree-compiler.ts +295 -0
- package/packages/runtime/src/types.ts +728 -0
- package/packages/runtime/src/worker.ts +327 -0
- package/packages/runtime/tsconfig.json +20 -0
- package/packages/runtime/wasm/aeon_pages_runtime.d.ts +504 -0
- package/packages/runtime/wasm/aeon_pages_runtime.js +1657 -0
- package/packages/runtime/wasm/aeon_pages_runtime_bg.wasm +0 -0
- package/packages/runtime/wasm/aeon_pages_runtime_bg.wasm.d.ts +196 -0
- package/packages/runtime/wasm/package.json +21 -0
- package/packages/runtime/wrangler.toml +41 -0
- package/packages/runtime-wasm/Cargo.lock +436 -0
- package/packages/runtime-wasm/Cargo.toml +29 -0
- package/packages/runtime-wasm/pkg/aeon_pages_runtime.d.ts +480 -0
- package/packages/runtime-wasm/pkg/aeon_pages_runtime.js +1568 -0
- package/packages/runtime-wasm/pkg/aeon_pages_runtime_bg.wasm +0 -0
- package/packages/runtime-wasm/pkg/aeon_pages_runtime_bg.wasm.d.ts +192 -0
- package/packages/runtime-wasm/pkg/package.json +21 -0
- package/packages/runtime-wasm/src/hydrate.rs +352 -0
- package/packages/runtime-wasm/src/lib.rs +191 -0
- package/packages/runtime-wasm/src/render.rs +629 -0
- package/packages/runtime-wasm/src/router.rs +298 -0
- package/packages/runtime-wasm/src/skeleton.rs +430 -0
- package/rfcs/RFC-001-ZERO-DEPENDENCY-RENDERING.md +1446 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aeon Pages Offline Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the offline-first operation queue system.
|
|
5
|
+
* Supports encrypted storage, priority queuing, and sync coordination.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Operation Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Operation type - what action is being performed
|
|
14
|
+
*/
|
|
15
|
+
export type OperationType =
|
|
16
|
+
| 'create'
|
|
17
|
+
| 'update'
|
|
18
|
+
| 'delete'
|
|
19
|
+
| 'session_update'
|
|
20
|
+
| 'tree_update'
|
|
21
|
+
| 'data_update'
|
|
22
|
+
| 'presence_update'
|
|
23
|
+
| string; // Allow custom types
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Operation priority for sync ordering
|
|
27
|
+
*/
|
|
28
|
+
export type OperationPriority = 'high' | 'normal' | 'low';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Operation sync status
|
|
32
|
+
*/
|
|
33
|
+
export type OperationStatus = 'pending' | 'syncing' | 'synced' | 'failed';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Queued operation for offline-first collaboration
|
|
37
|
+
*/
|
|
38
|
+
export interface OfflineOperation {
|
|
39
|
+
/** Unique operation identifier */
|
|
40
|
+
id: string;
|
|
41
|
+
|
|
42
|
+
/** Operation type */
|
|
43
|
+
type: OperationType;
|
|
44
|
+
|
|
45
|
+
/** Associated session ID */
|
|
46
|
+
sessionId: string;
|
|
47
|
+
|
|
48
|
+
/** Current sync status */
|
|
49
|
+
status: OperationStatus;
|
|
50
|
+
|
|
51
|
+
/** Operation payload (unencrypted in memory, encrypted at rest) */
|
|
52
|
+
data: Record<string, unknown>;
|
|
53
|
+
|
|
54
|
+
/** Priority for sync ordering */
|
|
55
|
+
priority: OperationPriority;
|
|
56
|
+
|
|
57
|
+
/** Encrypted data (when stored) */
|
|
58
|
+
encryptedData?: Uint8Array;
|
|
59
|
+
|
|
60
|
+
/** Encryption version */
|
|
61
|
+
encryptionVersion?: number;
|
|
62
|
+
|
|
63
|
+
/** Size in bytes */
|
|
64
|
+
bytesSize: number;
|
|
65
|
+
|
|
66
|
+
/** Creation timestamp */
|
|
67
|
+
createdAt: number;
|
|
68
|
+
|
|
69
|
+
/** Sync completion timestamp */
|
|
70
|
+
syncedAt?: number;
|
|
71
|
+
|
|
72
|
+
/** Number of failed attempts */
|
|
73
|
+
failedCount: number;
|
|
74
|
+
|
|
75
|
+
/** Last error message */
|
|
76
|
+
lastError?: string;
|
|
77
|
+
|
|
78
|
+
/** Current retry count */
|
|
79
|
+
retryCount: number;
|
|
80
|
+
|
|
81
|
+
/** Maximum allowed retries */
|
|
82
|
+
maxRetries: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Queue Configuration
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Encrypted queue configuration
|
|
91
|
+
*/
|
|
92
|
+
export interface EncryptedQueueConfig {
|
|
93
|
+
/** Maximum local storage capacity in bytes (default: 50MB) */
|
|
94
|
+
maxLocalCapacity: number;
|
|
95
|
+
|
|
96
|
+
/** Threshold (0-1) at which compaction is triggered (default: 0.8) */
|
|
97
|
+
compactionThreshold: number;
|
|
98
|
+
|
|
99
|
+
/** Interval for D1 sync in ms (default: 5 minutes) */
|
|
100
|
+
d1SyncInterval: number;
|
|
101
|
+
|
|
102
|
+
/** Age after which synced operations are cleaned up in ms (default: 1 hour) */
|
|
103
|
+
syncedCleanupAge: number;
|
|
104
|
+
|
|
105
|
+
/** Encryption configuration */
|
|
106
|
+
encryption: {
|
|
107
|
+
/** Whether encryption is enabled */
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
/** Key derivation method: 'ucan' for UCAN-derived keys, 'session' for session-based */
|
|
110
|
+
keyDerivation: 'ucan' | 'session';
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Queue statistics
|
|
116
|
+
*/
|
|
117
|
+
export interface QueueStats {
|
|
118
|
+
/** Total operations in queue */
|
|
119
|
+
total: number;
|
|
120
|
+
|
|
121
|
+
/** Operations pending sync */
|
|
122
|
+
pending: number;
|
|
123
|
+
|
|
124
|
+
/** Operations currently syncing */
|
|
125
|
+
syncing: number;
|
|
126
|
+
|
|
127
|
+
/** Successfully synced operations */
|
|
128
|
+
synced: number;
|
|
129
|
+
|
|
130
|
+
/** Failed operations */
|
|
131
|
+
failed: number;
|
|
132
|
+
|
|
133
|
+
/** Total bytes used */
|
|
134
|
+
totalBytes: number;
|
|
135
|
+
|
|
136
|
+
/** Whether compaction is needed */
|
|
137
|
+
compactionNeeded: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Encryption Types
|
|
142
|
+
// ============================================================================
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Encrypted payload structure
|
|
146
|
+
*/
|
|
147
|
+
export interface EncryptedPayload {
|
|
148
|
+
/** Encryption version */
|
|
149
|
+
version: number;
|
|
150
|
+
|
|
151
|
+
/** Nonce/IV (12 bytes for AES-GCM) */
|
|
152
|
+
nonce: Uint8Array;
|
|
153
|
+
|
|
154
|
+
/** Encrypted data with auth tag appended */
|
|
155
|
+
ciphertext: Uint8Array;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Encryption key material
|
|
160
|
+
*/
|
|
161
|
+
export interface EncryptionKeyMaterial {
|
|
162
|
+
/** Raw key bytes */
|
|
163
|
+
key: CryptoKey;
|
|
164
|
+
|
|
165
|
+
/** Key derivation context */
|
|
166
|
+
context: string;
|
|
167
|
+
|
|
168
|
+
/** User ID the key is bound to */
|
|
169
|
+
userId: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ============================================================================
|
|
173
|
+
// Sync Types
|
|
174
|
+
// ============================================================================
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Sync batch for uploading multiple operations
|
|
178
|
+
*/
|
|
179
|
+
export interface SyncBatch {
|
|
180
|
+
/** Unique batch identifier */
|
|
181
|
+
batchId: string;
|
|
182
|
+
|
|
183
|
+
/** Operations in this batch */
|
|
184
|
+
operations: OfflineOperation[];
|
|
185
|
+
|
|
186
|
+
/** Total size in bytes */
|
|
187
|
+
totalSize: number;
|
|
188
|
+
|
|
189
|
+
/** Batch creation timestamp */
|
|
190
|
+
createdAt: number;
|
|
191
|
+
|
|
192
|
+
/** Batch priority (highest priority of contained operations) */
|
|
193
|
+
priority: OperationPriority;
|
|
194
|
+
|
|
195
|
+
/** Whether batch is compressed */
|
|
196
|
+
compressed: boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Sync result from server
|
|
201
|
+
*/
|
|
202
|
+
export interface SyncResult {
|
|
203
|
+
/** Whether sync completed successfully */
|
|
204
|
+
success: boolean;
|
|
205
|
+
|
|
206
|
+
/** Successfully synced operation IDs */
|
|
207
|
+
synced: string[];
|
|
208
|
+
|
|
209
|
+
/** Failed operations with errors */
|
|
210
|
+
failed: Array<{
|
|
211
|
+
operationId: string;
|
|
212
|
+
error: string;
|
|
213
|
+
retryable: boolean;
|
|
214
|
+
}>;
|
|
215
|
+
|
|
216
|
+
/** Detected conflicts */
|
|
217
|
+
conflicts: Array<{
|
|
218
|
+
operationId: string;
|
|
219
|
+
remoteVersion: Record<string, unknown>;
|
|
220
|
+
strategy: ResolutionStrategy;
|
|
221
|
+
}>;
|
|
222
|
+
|
|
223
|
+
/** Server timestamp */
|
|
224
|
+
serverTimestamp: number;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// Conflict Types
|
|
229
|
+
// ============================================================================
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Conflict detection result
|
|
233
|
+
*/
|
|
234
|
+
export interface ConflictDetectionResult {
|
|
235
|
+
/** Whether a conflict was detected */
|
|
236
|
+
hasConflict: boolean;
|
|
237
|
+
|
|
238
|
+
/** Type of conflict */
|
|
239
|
+
type?: 'update_update' | 'delete_update' | 'update_delete' | 'concurrent';
|
|
240
|
+
|
|
241
|
+
/** Severity level */
|
|
242
|
+
severity?: 'low' | 'medium' | 'high';
|
|
243
|
+
|
|
244
|
+
/** Similarity score (0-1) for potential auto-merge */
|
|
245
|
+
similarity?: number;
|
|
246
|
+
|
|
247
|
+
/** Conflicting fields */
|
|
248
|
+
conflictingFields?: string[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Conflict resolution strategy
|
|
253
|
+
*/
|
|
254
|
+
export type ResolutionStrategy =
|
|
255
|
+
| 'local-wins'
|
|
256
|
+
| 'remote-wins'
|
|
257
|
+
| 'last-modified'
|
|
258
|
+
| 'merge'
|
|
259
|
+
| 'manual';
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Stored conflict for manual resolution
|
|
263
|
+
*/
|
|
264
|
+
export interface StoredConflict {
|
|
265
|
+
/** Unique conflict identifier */
|
|
266
|
+
id: string;
|
|
267
|
+
|
|
268
|
+
/** Associated operation ID */
|
|
269
|
+
operationId: string;
|
|
270
|
+
|
|
271
|
+
/** Session ID */
|
|
272
|
+
sessionId: string;
|
|
273
|
+
|
|
274
|
+
/** Local version of data */
|
|
275
|
+
localData: Record<string, unknown>;
|
|
276
|
+
|
|
277
|
+
/** Remote version of data */
|
|
278
|
+
remoteData: Record<string, unknown>;
|
|
279
|
+
|
|
280
|
+
/** Conflict type */
|
|
281
|
+
type: ConflictDetectionResult['type'];
|
|
282
|
+
|
|
283
|
+
/** Severity */
|
|
284
|
+
severity: ConflictDetectionResult['severity'];
|
|
285
|
+
|
|
286
|
+
/** Detection timestamp */
|
|
287
|
+
detectedAt: number;
|
|
288
|
+
|
|
289
|
+
/** Resolution (if resolved) */
|
|
290
|
+
resolution?: {
|
|
291
|
+
strategy: ResolutionStrategy;
|
|
292
|
+
resolvedData: Record<string, unknown>;
|
|
293
|
+
resolvedAt: number;
|
|
294
|
+
resolvedBy?: string;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ============================================================================
|
|
299
|
+
// Network Types
|
|
300
|
+
// ============================================================================
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Network state for adaptive sync
|
|
304
|
+
*/
|
|
305
|
+
export type NetworkState = 'online' | 'offline' | 'poor' | 'unknown';
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Bandwidth profile for sync adaptation
|
|
309
|
+
*/
|
|
310
|
+
export interface BandwidthProfile {
|
|
311
|
+
/** Estimated bandwidth in Kbps */
|
|
312
|
+
speedKbps: number;
|
|
313
|
+
|
|
314
|
+
/** Estimated latency in ms */
|
|
315
|
+
latencyMs: number;
|
|
316
|
+
|
|
317
|
+
/** Measurement timestamp */
|
|
318
|
+
timestamp: number;
|
|
319
|
+
|
|
320
|
+
/** Reliability score (0-1) */
|
|
321
|
+
reliability: number;
|
|
322
|
+
|
|
323
|
+
/** Effective connection type */
|
|
324
|
+
effectiveType?: '2g' | '3g' | '4g' | 'slow-2g' | 'unknown';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Network state event
|
|
329
|
+
*/
|
|
330
|
+
export interface NetworkStateEvent {
|
|
331
|
+
/** Previous state */
|
|
332
|
+
previousState: NetworkState;
|
|
333
|
+
|
|
334
|
+
/** New state */
|
|
335
|
+
newState: NetworkState;
|
|
336
|
+
|
|
337
|
+
/** Bandwidth profile (if available) */
|
|
338
|
+
bandwidth?: BandwidthProfile;
|
|
339
|
+
|
|
340
|
+
/** Timestamp */
|
|
341
|
+
timestamp: number;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ============================================================================
|
|
345
|
+
// Coordinator Types
|
|
346
|
+
// ============================================================================
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Sync coordinator configuration
|
|
350
|
+
*/
|
|
351
|
+
export interface SyncCoordinatorConfig {
|
|
352
|
+
/** Maximum operations per batch (default: 100) */
|
|
353
|
+
maxBatchSize: number;
|
|
354
|
+
|
|
355
|
+
/** Maximum bytes per batch (default: 5MB) */
|
|
356
|
+
maxBatchBytes: number;
|
|
357
|
+
|
|
358
|
+
/** Batch timeout in ms (default: 5000) */
|
|
359
|
+
batchTimeoutMs: number;
|
|
360
|
+
|
|
361
|
+
/** Maximum retry attempts (default: 5) */
|
|
362
|
+
maxRetries: number;
|
|
363
|
+
|
|
364
|
+
/** Base retry delay in ms (default: 1000) */
|
|
365
|
+
retryDelayMs: number;
|
|
366
|
+
|
|
367
|
+
/** Enable compression for batches (default: true) */
|
|
368
|
+
enableCompression: boolean;
|
|
369
|
+
|
|
370
|
+
/** Enable delta sync (default: true) */
|
|
371
|
+
enableDeltaSync: boolean;
|
|
372
|
+
|
|
373
|
+
/** Enable adaptive batch sizing based on network (default: true) */
|
|
374
|
+
adaptiveBatching: boolean;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Sync progress event
|
|
379
|
+
*/
|
|
380
|
+
export interface SyncProgressEvent {
|
|
381
|
+
/** Current batch being synced */
|
|
382
|
+
batchId: string;
|
|
383
|
+
|
|
384
|
+
/** Total operations in batch */
|
|
385
|
+
totalOperations: number;
|
|
386
|
+
|
|
387
|
+
/** Operations synced so far */
|
|
388
|
+
syncedOperations: number;
|
|
389
|
+
|
|
390
|
+
/** Bytes synced */
|
|
391
|
+
bytesSynced: number;
|
|
392
|
+
|
|
393
|
+
/** Total bytes */
|
|
394
|
+
totalBytes: number;
|
|
395
|
+
|
|
396
|
+
/** Estimated time remaining in ms */
|
|
397
|
+
estimatedTimeRemaining?: number;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ============================================================================
|
|
401
|
+
// Event Types
|
|
402
|
+
// ============================================================================
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Offline queue events
|
|
406
|
+
*/
|
|
407
|
+
export type OfflineQueueEvents = {
|
|
408
|
+
/** Queue initialized */
|
|
409
|
+
initialized: undefined;
|
|
410
|
+
|
|
411
|
+
/** Operation added to queue */
|
|
412
|
+
'operation:queued': { operationId: string; sessionId: string; size: number };
|
|
413
|
+
|
|
414
|
+
/** Operation started syncing */
|
|
415
|
+
'operation:syncing': { operationId: string };
|
|
416
|
+
|
|
417
|
+
/** Operation synced successfully */
|
|
418
|
+
'operation:synced': { operationId: string };
|
|
419
|
+
|
|
420
|
+
/** Operation failed (will retry) */
|
|
421
|
+
'operation:retry': { operationId: string; attempt: number };
|
|
422
|
+
|
|
423
|
+
/** Operation failed permanently */
|
|
424
|
+
'operation:failed_max_retries': { operationId: string; error: string };
|
|
425
|
+
|
|
426
|
+
/** Queue capacity error */
|
|
427
|
+
'queue:error': { operationId: string; error: string };
|
|
428
|
+
|
|
429
|
+
/** Queue compacted */
|
|
430
|
+
'queue:compacted': undefined;
|
|
431
|
+
|
|
432
|
+
/** D1 sync completed */
|
|
433
|
+
'd1:synced': QueueStats;
|
|
434
|
+
|
|
435
|
+
/** Queue shutdown */
|
|
436
|
+
shutdown: undefined;
|
|
437
|
+
|
|
438
|
+
[key: string]: unknown;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Sync coordinator events
|
|
443
|
+
*/
|
|
444
|
+
export interface SyncCoordinatorEvents {
|
|
445
|
+
/** Network state changed */
|
|
446
|
+
'network:changed': NetworkStateEvent;
|
|
447
|
+
|
|
448
|
+
/** Sync started */
|
|
449
|
+
'sync:started': { batchId: string };
|
|
450
|
+
|
|
451
|
+
/** Sync progress update */
|
|
452
|
+
'sync:progress': SyncProgressEvent;
|
|
453
|
+
|
|
454
|
+
/** Sync completed */
|
|
455
|
+
'sync:completed': SyncResult;
|
|
456
|
+
|
|
457
|
+
/** Sync failed */
|
|
458
|
+
'sync:failed': { batchId: string; error: string };
|
|
459
|
+
|
|
460
|
+
/** Conflict detected */
|
|
461
|
+
'conflict:detected': StoredConflict;
|
|
462
|
+
|
|
463
|
+
/** Conflict resolved */
|
|
464
|
+
'conflict:resolved': { conflictId: string; strategy: ResolutionStrategy };
|
|
465
|
+
}
|