@affectively/aeon 1.3.0 → 5.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.
Files changed (57) hide show
  1. package/LICENSE +5 -11
  2. package/README.md +90 -10
  3. package/dist/compression/index.cjs +20 -3
  4. package/dist/compression/index.cjs.map +1 -1
  5. package/dist/compression/index.js +20 -3
  6. package/dist/compression/index.js.map +1 -1
  7. package/dist/crypto/index.cjs +30 -0
  8. package/dist/crypto/index.cjs.map +1 -1
  9. package/dist/crypto/index.js +29 -1
  10. package/dist/crypto/index.js.map +1 -1
  11. package/dist/distributed/index.cjs +15 -8
  12. package/dist/distributed/index.cjs.map +1 -1
  13. package/dist/distributed/index.js +15 -8
  14. package/dist/distributed/index.js.map +1 -1
  15. package/dist/index.cjs +2923 -46
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +2879 -47
  18. package/dist/index.js.map +1 -1
  19. package/dist/optimization/index.cjs +6 -3
  20. package/dist/optimization/index.cjs.map +1 -1
  21. package/dist/optimization/index.js +6 -3
  22. package/dist/optimization/index.js.map +1 -1
  23. package/dist/persistence/index.cjs +91 -29
  24. package/dist/persistence/index.cjs.map +1 -1
  25. package/dist/persistence/index.js +91 -29
  26. package/dist/persistence/index.js.map +1 -1
  27. package/dist/presence/index.cjs.map +1 -1
  28. package/dist/presence/index.js.map +1 -1
  29. package/dist/versioning/index.cjs +4 -3
  30. package/dist/versioning/index.cjs.map +1 -1
  31. package/dist/versioning/index.js +4 -3
  32. package/dist/versioning/index.js.map +1 -1
  33. package/package.json +7 -8
  34. package/dist/compression/index.d.cts +0 -189
  35. package/dist/compression/index.d.ts +0 -189
  36. package/dist/core/index.d.cts +0 -216
  37. package/dist/core/index.d.ts +0 -216
  38. package/dist/crypto/index.d.cts +0 -446
  39. package/dist/crypto/index.d.ts +0 -446
  40. package/dist/distributed/index.d.cts +0 -1016
  41. package/dist/distributed/index.d.ts +0 -1016
  42. package/dist/index.d.cts +0 -12
  43. package/dist/index.d.ts +0 -12
  44. package/dist/offline/index.d.cts +0 -154
  45. package/dist/offline/index.d.ts +0 -154
  46. package/dist/optimization/index.d.cts +0 -347
  47. package/dist/optimization/index.d.ts +0 -347
  48. package/dist/persistence/index.d.cts +0 -63
  49. package/dist/persistence/index.d.ts +0 -63
  50. package/dist/presence/index.d.cts +0 -283
  51. package/dist/presence/index.d.ts +0 -283
  52. package/dist/types-B7gCpNX9.d.cts +0 -33
  53. package/dist/types-B7gCpNX9.d.ts +0 -33
  54. package/dist/utils/index.d.cts +0 -38
  55. package/dist/utils/index.d.ts +0 -38
  56. package/dist/versioning/index.d.cts +0 -537
  57. package/dist/versioning/index.d.ts +0 -537
@@ -1,347 +0,0 @@
1
- import { Operation } from '../core/index.js';
2
-
3
- /**
4
- * Prefetching Engine (Phase 13)
5
- *
6
- * Predictively pre-compresses batches based on detected operation patterns.
7
- * Analyzes historical data to predict which operations are most likely to occur.
8
- */
9
-
10
- /**
11
- * Pattern in operation sequence
12
- */
13
- interface OperationPattern {
14
- sequence: string[];
15
- frequency: number;
16
- probability: number;
17
- lastOccurred: number;
18
- avgIntervalMs: number;
19
- }
20
- /**
21
- * Prediction for next operations
22
- */
23
- interface OperationPrediction {
24
- operationType: string;
25
- probability: number;
26
- reason: string;
27
- shouldPrefetch: boolean;
28
- estimatedTimeMs: number;
29
- }
30
- /**
31
- * Prefetched batch
32
- */
33
- interface PrefetchedBatch {
34
- id: string;
35
- operationType: string;
36
- compressed: Uint8Array;
37
- compressedSize: number;
38
- originalSize: number;
39
- compressionRatio: number;
40
- compressed_at: number;
41
- created_at: number;
42
- ttl: number;
43
- expiresAt: number;
44
- hitCount: number;
45
- missCount: number;
46
- }
47
- /**
48
- * Prefetching statistics
49
- */
50
- interface PrefetchingStats {
51
- totalPrefetched: number;
52
- totalHits: number;
53
- totalMisses: number;
54
- totalOverwrites: number;
55
- hitRatio: number;
56
- bandwidthSaved: number;
57
- patternsDetected: number;
58
- predictionAccuracy: number;
59
- }
60
- declare class PrefetchingEngine {
61
- private operationHistory;
62
- private patterns;
63
- private prefetchCache;
64
- private maxHistoryEntries;
65
- private maxCachePerType;
66
- private prefetchTTL;
67
- private predictionThreshold;
68
- private stats;
69
- private lastPredictionTime;
70
- private predictionInterval;
71
- constructor();
72
- /**
73
- * Record operation for pattern analysis
74
- */
75
- recordOperation(operationType: string, size: number): void;
76
- /**
77
- * Analyze patterns in operation history
78
- */
79
- private analyzePatterns;
80
- /**
81
- * Predict next operations
82
- */
83
- predictNextOperations(recentOperations: Operation[]): OperationPrediction[];
84
- /**
85
- * Add prefetched batch
86
- */
87
- addPrefetchedBatch(operationType: string, compressed: Uint8Array, originalSize: number): PrefetchedBatch;
88
- /**
89
- * Try to use prefetched batch
90
- */
91
- getPrefetchedBatch(operationType: string): PrefetchedBatch | null;
92
- /**
93
- * Update prediction accuracy metric
94
- */
95
- private updatePredictionAccuracy;
96
- /**
97
- * Clean expired prefetches
98
- */
99
- private cleanExpiredPrefetches;
100
- /**
101
- * Get statistics
102
- */
103
- getStats(): PrefetchingStats;
104
- /**
105
- * Clear all caches
106
- */
107
- clear(): void;
108
- }
109
- declare function getPrefetchingEngine(): PrefetchingEngine;
110
- declare function resetPrefetchingEngine(): void;
111
-
112
- /**
113
- * Batch Timing Optimizer (Phase 13)
114
- *
115
- * Intelligently schedules batch transmission based on network conditions,
116
- * device resources, and user activity patterns.
117
- */
118
- /**
119
- * Network window quality assessment
120
- */
121
- interface NetworkWindow {
122
- startTime: number;
123
- endTime: number;
124
- expectedDurationMs: number;
125
- latencyMs: number;
126
- bandwidthMbps: number;
127
- quality: 'excellent' | 'good' | 'fair' | 'poor';
128
- isStable: boolean;
129
- congestionLevel: number;
130
- recommendedBatchSize: number;
131
- }
132
- /**
133
- * Activity pattern
134
- */
135
- interface ActivityPattern {
136
- type: 'user-active' | 'idle' | 'background' | 'sleep';
137
- startTime: number;
138
- duration: number;
139
- probability: number;
140
- }
141
- /**
142
- * Batch scheduling decision
143
- */
144
- interface SchedulingDecision {
145
- shouldSendNow: boolean;
146
- nextOptimalWindowMs: number;
147
- recommendedDelay: number;
148
- reason: string;
149
- priority: 'critical' | 'high' | 'normal' | 'low';
150
- estimatedDeliveryMs: number;
151
- }
152
- /**
153
- * Batch timing statistics
154
- */
155
- interface BatchTimingStats {
156
- totalBatches: number;
157
- immediateDeliveries: number;
158
- deferredBatches: number;
159
- averageWaitTimeMs: number;
160
- averageDeliveryTimeMs: number;
161
- networkWindowsUsed: number;
162
- congestionAvoided: number;
163
- userFocusedOptimizations: number;
164
- }
165
- declare class BatchTimingOptimizer {
166
- private networkHistory;
167
- private activityHistory;
168
- private stats;
169
- private lastActivityTime;
170
- private isUserActive;
171
- private congestionDetectionWindow;
172
- private optimalBatchSize;
173
- constructor();
174
- /**
175
- * Record network measurement
176
- */
177
- recordNetworkMeasurement(latencyMs: number, bandwidthMbps: number): void;
178
- /**
179
- * Assess network quality
180
- */
181
- private assessNetworkQuality;
182
- /**
183
- * Detect congestion in network
184
- */
185
- private detectCongestion;
186
- /**
187
- * Find next optimal network window
188
- */
189
- private findOptimalWindow;
190
- /**
191
- * Get scheduling decision for a batch
192
- */
193
- getSchedulingDecision(batchSize: number, batchPriority?: 'critical' | 'high' | 'normal' | 'low', isUserTriggered?: boolean): SchedulingDecision;
194
- /**
195
- * Apply scheduling and update stats
196
- */
197
- applyScheduling(batchSize: number, sendNow: boolean, actualDelay: number): void;
198
- /**
199
- * Get optimal batch size recommendation
200
- */
201
- getOptimalBatchSize(): number;
202
- /**
203
- * Get current network window
204
- */
205
- getCurrentNetworkWindow(): NetworkWindow;
206
- /**
207
- * Set user activity state
208
- */
209
- setUserActive(active: boolean): void;
210
- /**
211
- * Get statistics
212
- */
213
- getStats(): BatchTimingStats;
214
- /**
215
- * Clear history
216
- */
217
- clear(): void;
218
- }
219
- declare function getBatchTimingOptimizer(): BatchTimingOptimizer;
220
- declare function resetBatchTimingOptimizer(): void;
221
-
222
- /**
223
- * Adaptive Compression Optimizer (Phase 13)
224
- *
225
- * Automatically adjusts compression level based on network conditions,
226
- * device capabilities, and real-time performance metrics.
227
- */
228
- /**
229
- * Network conditions affecting compression
230
- */
231
- interface NetworkProfile {
232
- estimatedSpeedKbps: number;
233
- latencyMs: number;
234
- isOnline: boolean;
235
- isWifi: boolean;
236
- isFast: boolean;
237
- isSlow: boolean;
238
- isEmpty: boolean;
239
- }
240
- /**
241
- * Device capabilities for compression
242
- */
243
- interface DeviceProfile {
244
- cpuCores: number;
245
- cpuUtilization: number;
246
- memoryAvailableMB: number;
247
- memoryTotalMB: number;
248
- isConstrained: boolean;
249
- isPremium: boolean;
250
- supportsWebWorkers: boolean;
251
- supportsWebAssembly: boolean;
252
- }
253
- /**
254
- * Compression recommendation based on conditions
255
- */
256
- interface CompressionRecommendation {
257
- recommendedLevel: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
258
- reason: string;
259
- confidence: number;
260
- estimatedCompressionMs: number;
261
- estimatedRatio: number;
262
- networkFactor: number;
263
- deviceFactor: number;
264
- }
265
- /**
266
- * Adaptive compression statistics
267
- */
268
- interface AdaptiveStats {
269
- currentLevel: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
270
- averageCompressionMs: number;
271
- averageRatio: number;
272
- levelsUsed: Set<number>;
273
- adjustmentCount: number;
274
- totalBatches: number;
275
- networkCondition: 'fast' | 'normal' | 'slow' | 'offline';
276
- }
277
- declare class AdaptiveCompressionOptimizer {
278
- private currentLevel;
279
- private networkProfile;
280
- private deviceProfile;
281
- private compressionHistory;
282
- private stats;
283
- constructor();
284
- /**
285
- * Update network conditions
286
- */
287
- updateNetworkConditions(speedKbps: number, latencyMs?: number, isOnline?: boolean): void;
288
- /**
289
- * Update device resource usage
290
- */
291
- updateDeviceResources(cpuUtilization: number, memoryAvailableMB: number): void;
292
- /**
293
- * Record compression performance
294
- */
295
- recordCompressionPerformance(level: number, compressionMs: number, ratio: number): void;
296
- /**
297
- * Get compression recommendation based on conditions
298
- */
299
- getRecommendedLevel(): CompressionRecommendation;
300
- /**
301
- * Calculate network factor (0-1)
302
- */
303
- private calculateNetworkFactor;
304
- /**
305
- * Calculate device factor (0-1)
306
- */
307
- private calculateDeviceFactor;
308
- /**
309
- * Estimate compression time for a level (in ms)
310
- */
311
- private estimateCompressionTime;
312
- /**
313
- * Estimate compression ratio for a level
314
- */
315
- private estimateCompressionRatio;
316
- /**
317
- * Apply recommendation and get new level
318
- */
319
- applyRecommendation(): 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
320
- /**
321
- * Get current level
322
- */
323
- getCurrentLevel(): 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
324
- /**
325
- * Get statistics
326
- */
327
- getStats(): AdaptiveStats;
328
- /**
329
- * Get detailed analysis
330
- */
331
- getDetailedAnalysis(): {
332
- stats: AdaptiveStats;
333
- network: NetworkProfile;
334
- device: DeviceProfile;
335
- recommendation: CompressionRecommendation;
336
- history: {
337
- level: number;
338
- ratio: number;
339
- timeMs: number;
340
- timestamp: number;
341
- }[];
342
- };
343
- }
344
- declare function getAdaptiveCompressionOptimizer(): AdaptiveCompressionOptimizer;
345
- declare function resetAdaptiveCompressionOptimizer(): void;
346
-
347
- export { type ActivityPattern, AdaptiveCompressionOptimizer, type AdaptiveStats, BatchTimingOptimizer, type BatchTimingStats, type CompressionRecommendation, type DeviceProfile, type NetworkProfile, type NetworkWindow, type OperationPattern, type OperationPrediction, type PrefetchedBatch, PrefetchingEngine, type PrefetchingStats, type SchedulingDecision, getAdaptiveCompressionOptimizer, getBatchTimingOptimizer, getPrefetchingEngine, resetAdaptiveCompressionOptimizer, resetBatchTimingOptimizer, resetPrefetchingEngine };
@@ -1,63 +0,0 @@
1
- import { S as StorageAdapter } from '../types-B7gCpNX9.cjs';
2
- export { P as PersistedEnvelope, a as PersistenceDeserializer, b as PersistenceSerializer } from '../types-B7gCpNX9.cjs';
3
-
4
- interface DashStorageBackend {
5
- get(key: string): Promise<string | null> | string | null;
6
- set(key: string, value: string): Promise<void> | void;
7
- delete(key: string): Promise<void> | void;
8
- }
9
- interface DashStorageChange {
10
- key: string;
11
- operation: 'set' | 'delete';
12
- value?: string;
13
- timestamp: number;
14
- }
15
- interface DashSyncClient {
16
- syncChanges(changes: DashStorageChange[]): Promise<void>;
17
- }
18
- interface DashStorageAdapterOptions {
19
- syncClient?: DashSyncClient;
20
- syncDebounceMs?: number;
21
- maxPendingChanges?: number;
22
- onSyncError?: (error: Error, changes: DashStorageChange[]) => void;
23
- }
24
- /**
25
- * Storage adapter boundary for dash-backed persistence.
26
- *
27
- * Writes are local-first through the provided backend and optionally synced
28
- * to D1/R2 via a sync client using debounced change batches.
29
- */
30
- declare class DashStorageAdapter implements StorageAdapter {
31
- private readonly backend;
32
- private readonly syncClient;
33
- private readonly syncDebounceMs;
34
- private readonly maxPendingChanges;
35
- private readonly onSyncError;
36
- private readonly pendingChanges;
37
- private syncTimer;
38
- private syncInFlight;
39
- private syncPending;
40
- constructor(backend: DashStorageBackend, options?: DashStorageAdapterOptions);
41
- getItem(key: string): Promise<string | null>;
42
- setItem(key: string, value: string): Promise<void>;
43
- removeItem(key: string): Promise<void>;
44
- getPendingSyncCount(): number;
45
- flushSync(): Promise<void>;
46
- private trackChange;
47
- private enforcePendingLimit;
48
- private scheduleSync;
49
- private performSync;
50
- }
51
-
52
- /**
53
- * In-memory adapter for tests and ephemeral runtimes.
54
- */
55
- declare class InMemoryStorageAdapter implements StorageAdapter {
56
- private readonly store;
57
- getItem(key: string): string | null;
58
- setItem(key: string, value: string): void;
59
- removeItem(key: string): void;
60
- clear(): void;
61
- }
62
-
63
- export { DashStorageAdapter, type DashStorageAdapterOptions, type DashStorageBackend, type DashStorageChange, type DashSyncClient, InMemoryStorageAdapter, StorageAdapter };
@@ -1,63 +0,0 @@
1
- import { S as StorageAdapter } from '../types-B7gCpNX9.js';
2
- export { P as PersistedEnvelope, a as PersistenceDeserializer, b as PersistenceSerializer } from '../types-B7gCpNX9.js';
3
-
4
- interface DashStorageBackend {
5
- get(key: string): Promise<string | null> | string | null;
6
- set(key: string, value: string): Promise<void> | void;
7
- delete(key: string): Promise<void> | void;
8
- }
9
- interface DashStorageChange {
10
- key: string;
11
- operation: 'set' | 'delete';
12
- value?: string;
13
- timestamp: number;
14
- }
15
- interface DashSyncClient {
16
- syncChanges(changes: DashStorageChange[]): Promise<void>;
17
- }
18
- interface DashStorageAdapterOptions {
19
- syncClient?: DashSyncClient;
20
- syncDebounceMs?: number;
21
- maxPendingChanges?: number;
22
- onSyncError?: (error: Error, changes: DashStorageChange[]) => void;
23
- }
24
- /**
25
- * Storage adapter boundary for dash-backed persistence.
26
- *
27
- * Writes are local-first through the provided backend and optionally synced
28
- * to D1/R2 via a sync client using debounced change batches.
29
- */
30
- declare class DashStorageAdapter implements StorageAdapter {
31
- private readonly backend;
32
- private readonly syncClient;
33
- private readonly syncDebounceMs;
34
- private readonly maxPendingChanges;
35
- private readonly onSyncError;
36
- private readonly pendingChanges;
37
- private syncTimer;
38
- private syncInFlight;
39
- private syncPending;
40
- constructor(backend: DashStorageBackend, options?: DashStorageAdapterOptions);
41
- getItem(key: string): Promise<string | null>;
42
- setItem(key: string, value: string): Promise<void>;
43
- removeItem(key: string): Promise<void>;
44
- getPendingSyncCount(): number;
45
- flushSync(): Promise<void>;
46
- private trackChange;
47
- private enforcePendingLimit;
48
- private scheduleSync;
49
- private performSync;
50
- }
51
-
52
- /**
53
- * In-memory adapter for tests and ephemeral runtimes.
54
- */
55
- declare class InMemoryStorageAdapter implements StorageAdapter {
56
- private readonly store;
57
- getItem(key: string): string | null;
58
- setItem(key: string, value: string): void;
59
- removeItem(key: string): void;
60
- clear(): void;
61
- }
62
-
63
- export { DashStorageAdapter, type DashStorageAdapterOptions, type DashStorageBackend, type DashStorageChange, type DashSyncClient, InMemoryStorageAdapter, StorageAdapter };