@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,189 @@
|
|
|
1
|
+
import { Operation } from '../core/index.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compression Engine (Phase 12)
|
|
5
|
+
*
|
|
6
|
+
* Provides compression for delta operations using native CompressionStream API.
|
|
7
|
+
* Falls back gracefully when native compression is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
interface CompressedBatch {
|
|
10
|
+
id: string;
|
|
11
|
+
compressed: Uint8Array;
|
|
12
|
+
originalSize: number;
|
|
13
|
+
compressedSize: number;
|
|
14
|
+
compressionRatio: number;
|
|
15
|
+
algorithm: 'gzip' | 'deflate' | 'none';
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
interface CompressedChunk {
|
|
19
|
+
chunkId: string;
|
|
20
|
+
batchId: string;
|
|
21
|
+
data: Uint8Array;
|
|
22
|
+
index: number;
|
|
23
|
+
total: number;
|
|
24
|
+
checksum: string;
|
|
25
|
+
}
|
|
26
|
+
interface CompressionStats {
|
|
27
|
+
totalCompressed: number;
|
|
28
|
+
totalDecompressed: number;
|
|
29
|
+
totalOriginalBytes: number;
|
|
30
|
+
totalCompressedBytes: number;
|
|
31
|
+
averageCompressionRatio: number;
|
|
32
|
+
compressionTimeMs: number;
|
|
33
|
+
decompressionTimeMs: number;
|
|
34
|
+
}
|
|
35
|
+
declare class CompressionEngine {
|
|
36
|
+
private stats;
|
|
37
|
+
private preferredAlgorithm;
|
|
38
|
+
constructor(preferredAlgorithm?: 'gzip' | 'deflate');
|
|
39
|
+
/**
|
|
40
|
+
* Check if native compression is available
|
|
41
|
+
*/
|
|
42
|
+
supportsNativeCompression(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Compress data
|
|
45
|
+
*/
|
|
46
|
+
compress(data: Uint8Array | string): Promise<CompressedBatch>;
|
|
47
|
+
/**
|
|
48
|
+
* Decompress data
|
|
49
|
+
*/
|
|
50
|
+
decompress(batch: CompressedBatch): Promise<Uint8Array>;
|
|
51
|
+
/**
|
|
52
|
+
* Compress using native CompressionStream
|
|
53
|
+
*/
|
|
54
|
+
private compressNative;
|
|
55
|
+
/**
|
|
56
|
+
* Decompress using native DecompressionStream
|
|
57
|
+
*/
|
|
58
|
+
private decompressNative;
|
|
59
|
+
/**
|
|
60
|
+
* Split compressed batch into chunks for transmission
|
|
61
|
+
*/
|
|
62
|
+
splitIntoChunks(batch: CompressedBatch, chunkSize?: number): CompressedChunk[];
|
|
63
|
+
/**
|
|
64
|
+
* Reassemble chunks into compressed batch
|
|
65
|
+
*/
|
|
66
|
+
reassembleChunks(chunks: CompressedChunk[]): Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Simple checksum for chunk verification
|
|
69
|
+
*/
|
|
70
|
+
private simpleChecksum;
|
|
71
|
+
/**
|
|
72
|
+
* Update average compression ratio
|
|
73
|
+
*/
|
|
74
|
+
private updateAverageRatio;
|
|
75
|
+
/**
|
|
76
|
+
* Get statistics
|
|
77
|
+
*/
|
|
78
|
+
getStats(): CompressionStats;
|
|
79
|
+
/**
|
|
80
|
+
* Reset statistics
|
|
81
|
+
*/
|
|
82
|
+
resetStats(): void;
|
|
83
|
+
}
|
|
84
|
+
declare function getCompressionEngine(): CompressionEngine;
|
|
85
|
+
declare function resetCompressionEngine(): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Delta Sync Optimizer (Phase 12)
|
|
89
|
+
*
|
|
90
|
+
* Implements field-level change detection to reduce payload size.
|
|
91
|
+
* Computes delta between current and previous operation state.
|
|
92
|
+
*
|
|
93
|
+
* Performance Impact:
|
|
94
|
+
* - Delta sync alone: 70-80% payload reduction
|
|
95
|
+
* - Combined with compression: 80-90% total reduction
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Delta operation - represents only changed fields
|
|
100
|
+
*/
|
|
101
|
+
interface DeltaOperation {
|
|
102
|
+
id: string;
|
|
103
|
+
type: 'full' | 'delta';
|
|
104
|
+
operationId: string;
|
|
105
|
+
operationType: Operation['type'];
|
|
106
|
+
sessionId: string;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
changes?: Record<string, unknown>;
|
|
109
|
+
changeMask?: string[];
|
|
110
|
+
fullData?: Record<string, unknown>;
|
|
111
|
+
priority?: 'high' | 'normal' | 'low';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Batch of delta operations
|
|
115
|
+
*/
|
|
116
|
+
interface DeltaBatch {
|
|
117
|
+
batchId: string;
|
|
118
|
+
operations: DeltaOperation[];
|
|
119
|
+
timestamp: number;
|
|
120
|
+
totalOriginalSize: number;
|
|
121
|
+
totalDeltaSize: number;
|
|
122
|
+
reductionPercent: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Statistics about delta sync performance
|
|
126
|
+
*/
|
|
127
|
+
interface DeltaStats {
|
|
128
|
+
totalOperations: number;
|
|
129
|
+
totalFull: number;
|
|
130
|
+
totalDelta: number;
|
|
131
|
+
totalOriginalSize: number;
|
|
132
|
+
totalDeltaSize: number;
|
|
133
|
+
averageReductionPercent: number;
|
|
134
|
+
lastSyncTime: number;
|
|
135
|
+
fullOperationThreshold: number;
|
|
136
|
+
}
|
|
137
|
+
declare class DeltaSyncOptimizer {
|
|
138
|
+
private operationHistory;
|
|
139
|
+
private stats;
|
|
140
|
+
constructor(fullOperationThreshold?: number);
|
|
141
|
+
/**
|
|
142
|
+
* Compute delta for single operation
|
|
143
|
+
*/
|
|
144
|
+
computeDelta(operation: Operation): DeltaOperation;
|
|
145
|
+
/**
|
|
146
|
+
* Compute deltas for batch of operations
|
|
147
|
+
*/
|
|
148
|
+
computeBatchDeltas(operations: Operation[]): DeltaBatch;
|
|
149
|
+
/**
|
|
150
|
+
* Decompress delta operation back to full operation
|
|
151
|
+
*/
|
|
152
|
+
decompressDelta(delta: DeltaOperation): Operation;
|
|
153
|
+
/**
|
|
154
|
+
* Update history after successful sync
|
|
155
|
+
*/
|
|
156
|
+
updateHistory(operations: Operation[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Clear history for specific operations
|
|
159
|
+
*/
|
|
160
|
+
clearHistory(operationIds: string[]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Get current performance statistics
|
|
163
|
+
*/
|
|
164
|
+
getStats(): DeltaStats;
|
|
165
|
+
/**
|
|
166
|
+
* Reset statistics
|
|
167
|
+
*/
|
|
168
|
+
resetStats(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Set the full operation threshold
|
|
171
|
+
*/
|
|
172
|
+
setFullOperationThreshold(bytes: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Get history size for memory monitoring
|
|
175
|
+
*/
|
|
176
|
+
getHistorySize(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Get memory footprint estimate
|
|
179
|
+
*/
|
|
180
|
+
getMemoryEstimate(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Deep equality check for nested objects
|
|
183
|
+
*/
|
|
184
|
+
private deepEqual;
|
|
185
|
+
}
|
|
186
|
+
declare function getDeltaSyncOptimizer(threshold?: number): DeltaSyncOptimizer;
|
|
187
|
+
declare function resetDeltaSyncOptimizer(): void;
|
|
188
|
+
|
|
189
|
+
export { type CompressedBatch, type CompressedChunk, CompressionEngine, type CompressionStats, type DeltaBatch, type DeltaOperation, type DeltaStats, DeltaSyncOptimizer, getCompressionEngine, getDeltaSyncOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Operation } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compression Engine (Phase 12)
|
|
5
|
+
*
|
|
6
|
+
* Provides compression for delta operations using native CompressionStream API.
|
|
7
|
+
* Falls back gracefully when native compression is unavailable.
|
|
8
|
+
*/
|
|
9
|
+
interface CompressedBatch {
|
|
10
|
+
id: string;
|
|
11
|
+
compressed: Uint8Array;
|
|
12
|
+
originalSize: number;
|
|
13
|
+
compressedSize: number;
|
|
14
|
+
compressionRatio: number;
|
|
15
|
+
algorithm: 'gzip' | 'deflate' | 'none';
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
interface CompressedChunk {
|
|
19
|
+
chunkId: string;
|
|
20
|
+
batchId: string;
|
|
21
|
+
data: Uint8Array;
|
|
22
|
+
index: number;
|
|
23
|
+
total: number;
|
|
24
|
+
checksum: string;
|
|
25
|
+
}
|
|
26
|
+
interface CompressionStats {
|
|
27
|
+
totalCompressed: number;
|
|
28
|
+
totalDecompressed: number;
|
|
29
|
+
totalOriginalBytes: number;
|
|
30
|
+
totalCompressedBytes: number;
|
|
31
|
+
averageCompressionRatio: number;
|
|
32
|
+
compressionTimeMs: number;
|
|
33
|
+
decompressionTimeMs: number;
|
|
34
|
+
}
|
|
35
|
+
declare class CompressionEngine {
|
|
36
|
+
private stats;
|
|
37
|
+
private preferredAlgorithm;
|
|
38
|
+
constructor(preferredAlgorithm?: 'gzip' | 'deflate');
|
|
39
|
+
/**
|
|
40
|
+
* Check if native compression is available
|
|
41
|
+
*/
|
|
42
|
+
supportsNativeCompression(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Compress data
|
|
45
|
+
*/
|
|
46
|
+
compress(data: Uint8Array | string): Promise<CompressedBatch>;
|
|
47
|
+
/**
|
|
48
|
+
* Decompress data
|
|
49
|
+
*/
|
|
50
|
+
decompress(batch: CompressedBatch): Promise<Uint8Array>;
|
|
51
|
+
/**
|
|
52
|
+
* Compress using native CompressionStream
|
|
53
|
+
*/
|
|
54
|
+
private compressNative;
|
|
55
|
+
/**
|
|
56
|
+
* Decompress using native DecompressionStream
|
|
57
|
+
*/
|
|
58
|
+
private decompressNative;
|
|
59
|
+
/**
|
|
60
|
+
* Split compressed batch into chunks for transmission
|
|
61
|
+
*/
|
|
62
|
+
splitIntoChunks(batch: CompressedBatch, chunkSize?: number): CompressedChunk[];
|
|
63
|
+
/**
|
|
64
|
+
* Reassemble chunks into compressed batch
|
|
65
|
+
*/
|
|
66
|
+
reassembleChunks(chunks: CompressedChunk[]): Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Simple checksum for chunk verification
|
|
69
|
+
*/
|
|
70
|
+
private simpleChecksum;
|
|
71
|
+
/**
|
|
72
|
+
* Update average compression ratio
|
|
73
|
+
*/
|
|
74
|
+
private updateAverageRatio;
|
|
75
|
+
/**
|
|
76
|
+
* Get statistics
|
|
77
|
+
*/
|
|
78
|
+
getStats(): CompressionStats;
|
|
79
|
+
/**
|
|
80
|
+
* Reset statistics
|
|
81
|
+
*/
|
|
82
|
+
resetStats(): void;
|
|
83
|
+
}
|
|
84
|
+
declare function getCompressionEngine(): CompressionEngine;
|
|
85
|
+
declare function resetCompressionEngine(): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Delta Sync Optimizer (Phase 12)
|
|
89
|
+
*
|
|
90
|
+
* Implements field-level change detection to reduce payload size.
|
|
91
|
+
* Computes delta between current and previous operation state.
|
|
92
|
+
*
|
|
93
|
+
* Performance Impact:
|
|
94
|
+
* - Delta sync alone: 70-80% payload reduction
|
|
95
|
+
* - Combined with compression: 80-90% total reduction
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Delta operation - represents only changed fields
|
|
100
|
+
*/
|
|
101
|
+
interface DeltaOperation {
|
|
102
|
+
id: string;
|
|
103
|
+
type: 'full' | 'delta';
|
|
104
|
+
operationId: string;
|
|
105
|
+
operationType: Operation['type'];
|
|
106
|
+
sessionId: string;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
changes?: Record<string, unknown>;
|
|
109
|
+
changeMask?: string[];
|
|
110
|
+
fullData?: Record<string, unknown>;
|
|
111
|
+
priority?: 'high' | 'normal' | 'low';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Batch of delta operations
|
|
115
|
+
*/
|
|
116
|
+
interface DeltaBatch {
|
|
117
|
+
batchId: string;
|
|
118
|
+
operations: DeltaOperation[];
|
|
119
|
+
timestamp: number;
|
|
120
|
+
totalOriginalSize: number;
|
|
121
|
+
totalDeltaSize: number;
|
|
122
|
+
reductionPercent: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Statistics about delta sync performance
|
|
126
|
+
*/
|
|
127
|
+
interface DeltaStats {
|
|
128
|
+
totalOperations: number;
|
|
129
|
+
totalFull: number;
|
|
130
|
+
totalDelta: number;
|
|
131
|
+
totalOriginalSize: number;
|
|
132
|
+
totalDeltaSize: number;
|
|
133
|
+
averageReductionPercent: number;
|
|
134
|
+
lastSyncTime: number;
|
|
135
|
+
fullOperationThreshold: number;
|
|
136
|
+
}
|
|
137
|
+
declare class DeltaSyncOptimizer {
|
|
138
|
+
private operationHistory;
|
|
139
|
+
private stats;
|
|
140
|
+
constructor(fullOperationThreshold?: number);
|
|
141
|
+
/**
|
|
142
|
+
* Compute delta for single operation
|
|
143
|
+
*/
|
|
144
|
+
computeDelta(operation: Operation): DeltaOperation;
|
|
145
|
+
/**
|
|
146
|
+
* Compute deltas for batch of operations
|
|
147
|
+
*/
|
|
148
|
+
computeBatchDeltas(operations: Operation[]): DeltaBatch;
|
|
149
|
+
/**
|
|
150
|
+
* Decompress delta operation back to full operation
|
|
151
|
+
*/
|
|
152
|
+
decompressDelta(delta: DeltaOperation): Operation;
|
|
153
|
+
/**
|
|
154
|
+
* Update history after successful sync
|
|
155
|
+
*/
|
|
156
|
+
updateHistory(operations: Operation[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Clear history for specific operations
|
|
159
|
+
*/
|
|
160
|
+
clearHistory(operationIds: string[]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Get current performance statistics
|
|
163
|
+
*/
|
|
164
|
+
getStats(): DeltaStats;
|
|
165
|
+
/**
|
|
166
|
+
* Reset statistics
|
|
167
|
+
*/
|
|
168
|
+
resetStats(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Set the full operation threshold
|
|
171
|
+
*/
|
|
172
|
+
setFullOperationThreshold(bytes: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Get history size for memory monitoring
|
|
175
|
+
*/
|
|
176
|
+
getHistorySize(): number;
|
|
177
|
+
/**
|
|
178
|
+
* Get memory footprint estimate
|
|
179
|
+
*/
|
|
180
|
+
getMemoryEstimate(): number;
|
|
181
|
+
/**
|
|
182
|
+
* Deep equality check for nested objects
|
|
183
|
+
*/
|
|
184
|
+
private deepEqual;
|
|
185
|
+
}
|
|
186
|
+
declare function getDeltaSyncOptimizer(threshold?: number): DeltaSyncOptimizer;
|
|
187
|
+
declare function resetDeltaSyncOptimizer(): void;
|
|
188
|
+
|
|
189
|
+
export { type CompressedBatch, type CompressedChunk, CompressionEngine, type CompressionStats, type DeltaBatch, type DeltaOperation, type DeltaStats, DeltaSyncOptimizer, getCompressionEngine, getDeltaSyncOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer };
|