@affectively/dash 5.3.1 → 5.4.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.
- package/README.md +193 -0
- package/dist/src/api/firebase/auth/index.d.ts +137 -0
- package/dist/src/api/firebase/auth/index.js +352 -0
- package/dist/src/api/firebase/auth/providers.d.ts +254 -0
- package/dist/src/api/firebase/auth/providers.js +518 -0
- package/dist/src/api/firebase/database/index.d.ts +108 -0
- package/dist/src/api/firebase/database/index.js +368 -0
- package/dist/src/api/firebase/errors.d.ts +15 -0
- package/dist/src/api/firebase/errors.js +215 -0
- package/dist/src/api/firebase/firestore/data-types.d.ts +116 -0
- package/dist/src/api/firebase/firestore/data-types.js +280 -0
- package/dist/src/api/firebase/firestore/index.d.ts +7 -0
- package/dist/src/api/firebase/firestore/index.js +13 -0
- package/dist/src/api/firebase/firestore/listeners.d.ts +20 -0
- package/dist/src/api/firebase/firestore/listeners.js +50 -0
- package/dist/src/api/firebase/firestore/operations.d.ts +123 -0
- package/dist/src/api/firebase/firestore/operations.js +490 -0
- package/dist/src/api/firebase/firestore/query.d.ts +118 -0
- package/dist/src/api/firebase/firestore/query.js +418 -0
- package/dist/src/api/firebase/index.d.ts +11 -0
- package/dist/src/api/firebase/index.js +17 -0
- package/dist/src/api/firebase/storage/index.d.ts +100 -0
- package/dist/src/api/firebase/storage/index.js +286 -0
- package/dist/src/api/firebase/types.d.ts +341 -0
- package/dist/src/api/firebase/types.js +4 -0
- package/dist/src/auth/manager.d.ts +182 -0
- package/dist/src/auth/manager.js +598 -0
- package/dist/src/engine/ai.d.ts +10 -0
- package/dist/src/engine/ai.js +76 -0
- package/dist/src/engine/sqlite.d.ts +353 -0
- package/dist/src/engine/sqlite.js +1328 -0
- package/dist/src/engine/vec_extension.d.ts +5 -0
- package/dist/src/engine/vec_extension.js +10 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +26 -0
- package/dist/src/mcp/server.d.ts +8 -0
- package/dist/src/mcp/server.js +87 -0
- package/dist/src/reactivity/signal.d.ts +3 -0
- package/dist/src/reactivity/signal.js +31 -0
- package/dist/src/schema/lens.d.ts +29 -0
- package/dist/src/schema/lens.js +122 -0
- package/dist/src/sync/AeonDurableSync.d.ts +27 -0
- package/dist/src/sync/AeonDurableSync.js +133 -0
- package/dist/src/sync/AutomergeProvider.d.ts +45 -0
- package/dist/src/sync/AutomergeProvider.js +153 -0
- package/dist/src/sync/aeon/config.d.ts +21 -0
- package/dist/src/sync/aeon/config.js +14 -0
- package/dist/src/sync/aeon/delta-adapter.d.ts +62 -0
- package/dist/src/sync/aeon/delta-adapter.js +98 -0
- package/dist/src/sync/aeon/index.d.ts +18 -0
- package/dist/src/sync/aeon/index.js +19 -0
- package/dist/src/sync/aeon/offline-adapter.d.ts +110 -0
- package/dist/src/sync/aeon/offline-adapter.js +227 -0
- package/dist/src/sync/aeon/presence-adapter.d.ts +114 -0
- package/dist/src/sync/aeon/presence-adapter.js +157 -0
- package/dist/src/sync/aeon/schema-adapter.d.ts +95 -0
- package/dist/src/sync/aeon/schema-adapter.js +163 -0
- package/dist/src/sync/backup.d.ts +12 -0
- package/dist/src/sync/backup.js +44 -0
- package/dist/src/sync/connection.d.ts +20 -0
- package/dist/src/sync/connection.js +50 -0
- package/dist/src/sync/d1-provider.d.ts +103 -0
- package/dist/src/sync/d1-provider.js +418 -0
- package/dist/src/sync/hybrid-provider.d.ts +307 -0
- package/dist/src/sync/hybrid-provider.js +1353 -0
- package/dist/src/sync/provider.d.ts +11 -0
- package/dist/src/sync/provider.js +67 -0
- package/dist/src/sync/types.d.ts +32 -0
- package/dist/src/sync/types.js +4 -0
- package/dist/src/sync/verify.d.ts +1 -0
- package/dist/src/sync/verify.js +23 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +77 -43
- package/dist/index.d.ts +0 -62
- package/dist/index.js +0 -31
- package/dist/sync/index.d.ts +0 -6
- package/dist/sync/index.js +0 -4
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { Observable } from 'lib0/observable';
|
|
3
|
+
import * as awarenessProtocol from 'y-protocols/awareness';
|
|
4
|
+
import { type AeonConfig } from './aeon/config.js';
|
|
5
|
+
import { DashDeltaAdapter } from './aeon/delta-adapter.js';
|
|
6
|
+
import { DashPresenceAdapter } from './aeon/presence-adapter.js';
|
|
7
|
+
import { DashOfflineAdapter } from './aeon/offline-adapter.js';
|
|
8
|
+
export declare class HybridProvider extends Observable<string> {
|
|
9
|
+
private doc;
|
|
10
|
+
private ws;
|
|
11
|
+
private wt;
|
|
12
|
+
private connected;
|
|
13
|
+
private url;
|
|
14
|
+
private activeRelayUrl;
|
|
15
|
+
private roomName;
|
|
16
|
+
awareness: awarenessProtocol.Awareness;
|
|
17
|
+
private writer;
|
|
18
|
+
private highFrequencyMode;
|
|
19
|
+
private connectionState;
|
|
20
|
+
private reconnectAttempts;
|
|
21
|
+
private readonly maxReconnectDelay;
|
|
22
|
+
private readonly baseReconnectDelay;
|
|
23
|
+
private reconnectTimeout;
|
|
24
|
+
private relayDiscovery;
|
|
25
|
+
private discoveredRelayUrls;
|
|
26
|
+
private relayDiscoveryCursor;
|
|
27
|
+
private lastRelayDiscoveryAt;
|
|
28
|
+
private relayHealth;
|
|
29
|
+
private relayPerformance;
|
|
30
|
+
private compressionEngine;
|
|
31
|
+
private adaptiveCompression;
|
|
32
|
+
private batchTiming;
|
|
33
|
+
private outboundQueue;
|
|
34
|
+
private outboundQueueBytes;
|
|
35
|
+
private batchFlushTimeout;
|
|
36
|
+
private flushingBatch;
|
|
37
|
+
private lastCompressionRatio;
|
|
38
|
+
private relayPrivacy;
|
|
39
|
+
private roomCryptoKey;
|
|
40
|
+
private roomCryptoKeyReady;
|
|
41
|
+
private localCapabilitiesBitmask;
|
|
42
|
+
private peerCapabilities;
|
|
43
|
+
private protocolVersion;
|
|
44
|
+
private lastCapabilityAdvertisedAt;
|
|
45
|
+
private aeonConfig;
|
|
46
|
+
private deltaAdapter;
|
|
47
|
+
private presenceAdapter;
|
|
48
|
+
private offlineAdapter;
|
|
49
|
+
constructor(url: string, roomName: string, doc: Y.Doc, { awareness, aeonConfig, relayDiscovery, relayPerformance, relayPrivacy, }?: {
|
|
50
|
+
awareness?: awarenessProtocol.Awareness;
|
|
51
|
+
aeonConfig?: AeonConfig;
|
|
52
|
+
relayDiscovery?: RelayDiscoveryConfig;
|
|
53
|
+
relayPerformance?: RelayPerformanceConfig;
|
|
54
|
+
relayPrivacy?: RelayPrivacyConfig;
|
|
55
|
+
});
|
|
56
|
+
private connect;
|
|
57
|
+
private connectWebSocket;
|
|
58
|
+
/**
|
|
59
|
+
* Schedule reconnection with exponential backoff + jitter
|
|
60
|
+
* Prevents thundering herd on network flapping
|
|
61
|
+
*/
|
|
62
|
+
private scheduleReconnect;
|
|
63
|
+
private seedAdaptiveNetworkProfile;
|
|
64
|
+
private initializeRoomCryptoKey;
|
|
65
|
+
private getRoomCryptoKey;
|
|
66
|
+
private computeLocalCapabilities;
|
|
67
|
+
private getKnownRemoteClientIds;
|
|
68
|
+
private isCapabilityEnabled;
|
|
69
|
+
private capabilityListFromBitmask;
|
|
70
|
+
private sendCapabilitiesAdvertisement;
|
|
71
|
+
private reconcilePeerCapabilities;
|
|
72
|
+
private getAuthToken;
|
|
73
|
+
private resolveRelayUrl;
|
|
74
|
+
private discoverRelayUrls;
|
|
75
|
+
private fetchRelayCandidates;
|
|
76
|
+
private rankRelayUrls;
|
|
77
|
+
private scoreRelay;
|
|
78
|
+
private recordRelaySuccess;
|
|
79
|
+
private recordRelayFailure;
|
|
80
|
+
enterHighFrequencyMode(): Promise<void>;
|
|
81
|
+
private sendSyncStep1;
|
|
82
|
+
/**
|
|
83
|
+
* Read loop for WebTransport with dynamic buffer sizing
|
|
84
|
+
* Handles payloads larger than initial buffer
|
|
85
|
+
*/
|
|
86
|
+
private readLoop;
|
|
87
|
+
/**
|
|
88
|
+
* Handle incoming message with protocol validation
|
|
89
|
+
* Never silently ignores malformed messages
|
|
90
|
+
*/
|
|
91
|
+
private handleMessage;
|
|
92
|
+
/**
|
|
93
|
+
* Send message with error handling and offline queue fallback
|
|
94
|
+
* Never fails silently - either sends, queues, or throws
|
|
95
|
+
*/
|
|
96
|
+
private send;
|
|
97
|
+
private enqueueOutbound;
|
|
98
|
+
private scheduleBatchFlush;
|
|
99
|
+
private flushOutboundQueue;
|
|
100
|
+
private encodeBatchFrame;
|
|
101
|
+
private applyOutboundPipeline;
|
|
102
|
+
private maybeCompressPayload;
|
|
103
|
+
private decompressPayload;
|
|
104
|
+
private maybeEncryptPayload;
|
|
105
|
+
private decryptPayload;
|
|
106
|
+
private sendSingleFrame;
|
|
107
|
+
/**
|
|
108
|
+
* Queue message for offline sync
|
|
109
|
+
*/
|
|
110
|
+
private queueForOffline;
|
|
111
|
+
private onDocUpdate;
|
|
112
|
+
private onAwarenessUpdate;
|
|
113
|
+
destroy(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Get the delta adapter for compression stats
|
|
116
|
+
*/
|
|
117
|
+
getDeltaAdapter(): DashDeltaAdapter | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get the presence adapter for rich presence features
|
|
120
|
+
*/
|
|
121
|
+
getPresenceAdapter(): DashPresenceAdapter | null;
|
|
122
|
+
/**
|
|
123
|
+
* Get the offline adapter for queue management
|
|
124
|
+
*/
|
|
125
|
+
getOfflineAdapter(): DashOfflineAdapter | null;
|
|
126
|
+
/**
|
|
127
|
+
* Get Aeon configuration
|
|
128
|
+
*/
|
|
129
|
+
getAeonConfig(): AeonConfig;
|
|
130
|
+
/**
|
|
131
|
+
* Process offline queue when back online
|
|
132
|
+
*/
|
|
133
|
+
processOfflineQueue(): Promise<{
|
|
134
|
+
synced: number;
|
|
135
|
+
failed: number;
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Get comprehensive connection status
|
|
139
|
+
*/
|
|
140
|
+
getConnectionStatus(): ConnectionStatus;
|
|
141
|
+
/**
|
|
142
|
+
* Force immediate reconnection (resets backoff)
|
|
143
|
+
* Use when user explicitly requests reconnect
|
|
144
|
+
*/
|
|
145
|
+
forceReconnect(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Get all awareness states from connected peers
|
|
148
|
+
*/
|
|
149
|
+
getAwarenessStates(): AwarenessState[];
|
|
150
|
+
/**
|
|
151
|
+
* Get the local client ID
|
|
152
|
+
*/
|
|
153
|
+
getLocalClientId(): number;
|
|
154
|
+
/**
|
|
155
|
+
* Get connected peer count (excluding local)
|
|
156
|
+
*/
|
|
157
|
+
getPeerCount(): number;
|
|
158
|
+
/**
|
|
159
|
+
* Get document state information
|
|
160
|
+
*/
|
|
161
|
+
getDocumentState(): DocumentState;
|
|
162
|
+
/**
|
|
163
|
+
* Get a snapshot of the Yjs document for inspection
|
|
164
|
+
*/
|
|
165
|
+
getDocumentSnapshot(): DocumentSnapshot;
|
|
166
|
+
/**
|
|
167
|
+
* Set local awareness state for introspection (admin view)
|
|
168
|
+
*/
|
|
169
|
+
setLocalAwareness(state: Record<string, unknown>): void;
|
|
170
|
+
/**
|
|
171
|
+
* Get full provider status for debugging
|
|
172
|
+
*/
|
|
173
|
+
getProviderStatus(): ProviderStatus;
|
|
174
|
+
/**
|
|
175
|
+
* Get Aeon-specific status
|
|
176
|
+
*/
|
|
177
|
+
getAeonStatus(): AeonStatus;
|
|
178
|
+
}
|
|
179
|
+
export interface ConnectionStatus {
|
|
180
|
+
connected: boolean;
|
|
181
|
+
connectionState: 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
182
|
+
roomName: string;
|
|
183
|
+
url: string;
|
|
184
|
+
reconnectAttempts: number;
|
|
185
|
+
websocket: {
|
|
186
|
+
state: 'connecting' | 'open' | 'closing' | 'closed';
|
|
187
|
+
connected: boolean;
|
|
188
|
+
bufferedAmount: number;
|
|
189
|
+
};
|
|
190
|
+
webTransport: {
|
|
191
|
+
connected: boolean;
|
|
192
|
+
highFrequencyMode: boolean;
|
|
193
|
+
};
|
|
194
|
+
discovery: {
|
|
195
|
+
enabled: boolean;
|
|
196
|
+
knownRelays: number;
|
|
197
|
+
lastDiscoveryAt: number | null;
|
|
198
|
+
targetPeerId: string;
|
|
199
|
+
};
|
|
200
|
+
performance: {
|
|
201
|
+
batching: boolean;
|
|
202
|
+
adaptiveCompression: boolean;
|
|
203
|
+
activeBatching: boolean;
|
|
204
|
+
activeCompression: boolean;
|
|
205
|
+
queuedFrames: number;
|
|
206
|
+
lastCompressionRatio: number | null;
|
|
207
|
+
};
|
|
208
|
+
privacy: {
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
keyLoaded: boolean;
|
|
211
|
+
activeEncryption: boolean;
|
|
212
|
+
};
|
|
213
|
+
protocol: {
|
|
214
|
+
version: number;
|
|
215
|
+
localCapabilities: string[];
|
|
216
|
+
knownPeers: number;
|
|
217
|
+
};
|
|
218
|
+
transport: 'WebSocket' | 'WebTransport';
|
|
219
|
+
}
|
|
220
|
+
export interface RelayDiscoveryConfig {
|
|
221
|
+
enabled?: boolean;
|
|
222
|
+
bootstrapUrls?: string[];
|
|
223
|
+
discoveryPath?: string;
|
|
224
|
+
refreshIntervalMs?: number;
|
|
225
|
+
requestTimeoutMs?: number;
|
|
226
|
+
maxCandidates?: number;
|
|
227
|
+
dhtQueryEnabled?: boolean;
|
|
228
|
+
targetPeerId?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface RelayPerformanceConfig {
|
|
231
|
+
enableAdaptiveCompression?: boolean;
|
|
232
|
+
enableBatching?: boolean;
|
|
233
|
+
compressionThresholdBytes?: number;
|
|
234
|
+
maxBatchDelayMs?: number;
|
|
235
|
+
maxBatchSizeBytes?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface RelayPrivacyConfig {
|
|
238
|
+
enabled?: boolean;
|
|
239
|
+
roomKey?: string | Uint8Array;
|
|
240
|
+
}
|
|
241
|
+
export interface AwarenessState {
|
|
242
|
+
clientId: number;
|
|
243
|
+
state: Record<string, unknown>;
|
|
244
|
+
isLocal: boolean;
|
|
245
|
+
}
|
|
246
|
+
export interface SharedTypeInfo {
|
|
247
|
+
name: string;
|
|
248
|
+
type: 'YMap' | 'YArray' | 'YText' | 'YXmlFragment' | 'unknown';
|
|
249
|
+
size: number;
|
|
250
|
+
}
|
|
251
|
+
export interface DocumentState {
|
|
252
|
+
clientId: number;
|
|
253
|
+
guid: string;
|
|
254
|
+
stateVectorSize: number;
|
|
255
|
+
updateSize: number;
|
|
256
|
+
sharedTypes: SharedTypeInfo[];
|
|
257
|
+
transactionCount: number;
|
|
258
|
+
gcEnabled: boolean;
|
|
259
|
+
}
|
|
260
|
+
export interface DocumentSnapshot {
|
|
261
|
+
timestamp: string;
|
|
262
|
+
roomName: string;
|
|
263
|
+
content: Record<string, unknown>;
|
|
264
|
+
}
|
|
265
|
+
export interface ProviderStatus {
|
|
266
|
+
connection: ConnectionStatus;
|
|
267
|
+
awareness: {
|
|
268
|
+
localClientId: number;
|
|
269
|
+
peerCount: number;
|
|
270
|
+
states: AwarenessState[];
|
|
271
|
+
};
|
|
272
|
+
document: DocumentState;
|
|
273
|
+
aeon: AeonStatus;
|
|
274
|
+
}
|
|
275
|
+
export interface AeonStatus {
|
|
276
|
+
enabled: {
|
|
277
|
+
deltaSync: boolean;
|
|
278
|
+
richPresence: boolean;
|
|
279
|
+
offlineQueue: boolean;
|
|
280
|
+
};
|
|
281
|
+
delta: {
|
|
282
|
+
totalOperations: number;
|
|
283
|
+
totalFull: number;
|
|
284
|
+
totalDelta: number;
|
|
285
|
+
totalOriginalSize: number;
|
|
286
|
+
totalDeltaSize: number;
|
|
287
|
+
averageReductionPercent: number;
|
|
288
|
+
} | null;
|
|
289
|
+
offline: {
|
|
290
|
+
pending: number;
|
|
291
|
+
syncing: number;
|
|
292
|
+
failed: number;
|
|
293
|
+
synced: number;
|
|
294
|
+
totalOperations: number;
|
|
295
|
+
} | null;
|
|
296
|
+
presence: {
|
|
297
|
+
total: number;
|
|
298
|
+
online: number;
|
|
299
|
+
away: number;
|
|
300
|
+
offline: number;
|
|
301
|
+
} | null;
|
|
302
|
+
compression: {
|
|
303
|
+
averageCompressionMs: number;
|
|
304
|
+
averageRatio: number;
|
|
305
|
+
networkCondition: 'fast' | 'normal' | 'slow' | 'offline';
|
|
306
|
+
} | null;
|
|
307
|
+
}
|