@affectively/aeon 1.0.0 → 1.2.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/README.md +10 -0
- package/dist/compression/index.cjs +580 -0
- package/dist/compression/index.cjs.map +1 -0
- package/dist/compression/index.d.cts +189 -0
- package/dist/compression/index.d.ts +189 -0
- package/dist/compression/index.js +573 -0
- package/dist/compression/index.js.map +1 -0
- package/dist/core/index.d.cts +70 -5
- package/dist/core/index.d.ts +70 -5
- package/dist/crypto/index.cjs +100 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +407 -0
- package/dist/crypto/index.d.ts +407 -0
- package/dist/crypto/index.js +96 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/distributed/index.cjs +420 -23
- package/dist/distributed/index.cjs.map +1 -1
- package/dist/distributed/index.d.cts +901 -2
- package/dist/distributed/index.d.ts +901 -2
- package/dist/distributed/index.js +420 -23
- package/dist/distributed/index.js.map +1 -1
- package/dist/index.cjs +1222 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -811
- package/dist/index.d.ts +11 -811
- package/dist/index.js +1221 -56
- package/dist/index.js.map +1 -1
- package/dist/offline/index.cjs +419 -0
- package/dist/offline/index.cjs.map +1 -0
- package/dist/offline/index.d.cts +148 -0
- package/dist/offline/index.d.ts +148 -0
- package/dist/offline/index.js +415 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/optimization/index.cjs +797 -0
- package/dist/optimization/index.cjs.map +1 -0
- package/dist/optimization/index.d.cts +347 -0
- package/dist/optimization/index.d.ts +347 -0
- package/dist/optimization/index.js +787 -0
- package/dist/optimization/index.js.map +1 -0
- package/dist/persistence/index.cjs +145 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +63 -0
- package/dist/persistence/index.d.ts +63 -0
- package/dist/persistence/index.js +142 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/presence/index.cjs +489 -0
- package/dist/presence/index.cjs.map +1 -0
- package/dist/presence/index.d.cts +283 -0
- package/dist/presence/index.d.ts +283 -0
- package/dist/presence/index.js +485 -0
- package/dist/presence/index.js.map +1 -0
- package/dist/types-CMxO7QF0.d.cts +33 -0
- package/dist/types-CMxO7QF0.d.ts +33 -0
- package/dist/versioning/index.cjs +296 -14
- package/dist/versioning/index.cjs.map +1 -1
- package/dist/versioning/index.d.cts +66 -1
- package/dist/versioning/index.d.ts +66 -1
- package/dist/versioning/index.js +296 -14
- package/dist/versioning/index.js.map +1 -1
- package/package.json +51 -1
- package/dist/index-C_4CMV5c.d.cts +0 -1207
- package/dist/index-C_4CMV5c.d.ts +0 -1207
|
@@ -0,0 +1,347 @@
|
|
|
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 };
|