@a0n/aeon 5.0.1 → 5.0.2
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/dist/AeonEventEmitter-B1DzaYFk.d.cts +23 -0
- package/dist/AeonEventEmitter-B1DzaYFk.d.ts +23 -0
- package/dist/compression/index.d.cts +1 -1
- package/dist/compression/index.d.ts +1 -1
- package/dist/core/index.cjs +89 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -212
- package/dist/core/index.d.ts +2 -212
- package/dist/core/index.js +88 -0
- package/dist/core/index.js.map +1 -1
- package/dist/distributed/index.cjs +88 -4
- package/dist/distributed/index.cjs.map +1 -1
- package/dist/distributed/index.d.cts +2 -2
- package/dist/distributed/index.d.ts +2 -2
- package/dist/distributed/index.js +88 -4
- package/dist/distributed/index.js.map +1 -1
- package/dist/index.cjs +98 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +98 -5
- package/dist/index.js.map +1 -1
- package/dist/offline/index.cjs +88 -4
- package/dist/offline/index.cjs.map +1 -1
- package/dist/offline/index.d.cts +3 -3
- package/dist/offline/index.d.ts +3 -3
- package/dist/offline/index.js +88 -4
- package/dist/offline/index.js.map +1 -1
- package/dist/optimization/index.d.cts +1 -1
- package/dist/optimization/index.d.ts +1 -1
- package/dist/presence/index.cjs +88 -4
- package/dist/presence/index.cjs.map +1 -1
- package/dist/presence/index.d.cts +2 -2
- package/dist/presence/index.d.ts +2 -2
- package/dist/presence/index.js +88 -4
- package/dist/presence/index.js.map +1 -1
- package/dist/types-Bj5EbkSK.d.cts +212 -0
- package/dist/types-Bj5EbkSK.d.ts +212 -0
- package/package.json +15 -17
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type EventListener = (...args: any[]) => void;
|
|
2
|
+
type AeonEventMap = Record<PropertyKey, EventListener>;
|
|
3
|
+
type EventShape = Record<string, EventListener>;
|
|
4
|
+
type EventKey<Events extends object> = keyof Events;
|
|
5
|
+
declare class AeonEventEmitter<Events extends {
|
|
6
|
+
[K in keyof Events]: EventListener;
|
|
7
|
+
} = EventShape> {
|
|
8
|
+
private readonly listenerMap;
|
|
9
|
+
on<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
10
|
+
addListener<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
11
|
+
once<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
12
|
+
off<K extends EventKey<Events>>(event: K, fn?: Events[K], context?: unknown, once?: boolean): this;
|
|
13
|
+
removeListener<K extends EventKey<Events>>(event: K, fn?: Events[K], context?: unknown, once?: boolean): this;
|
|
14
|
+
removeAllListeners<K extends EventKey<Events>>(event?: K): this;
|
|
15
|
+
emit<K extends EventKey<Events>>(event: K, ...args: Parameters<Events[K]>): boolean;
|
|
16
|
+
eventNames(): Array<EventKey<Events>>;
|
|
17
|
+
listeners<K extends EventKey<Events>>(event: K): Events[K][];
|
|
18
|
+
listenerCount<K extends EventKey<Events>>(event: K): number;
|
|
19
|
+
subscribe<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): () => void;
|
|
20
|
+
private registerListener;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { AeonEventEmitter as A, type AeonEventMap as a };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type EventListener = (...args: any[]) => void;
|
|
2
|
+
type AeonEventMap = Record<PropertyKey, EventListener>;
|
|
3
|
+
type EventShape = Record<string, EventListener>;
|
|
4
|
+
type EventKey<Events extends object> = keyof Events;
|
|
5
|
+
declare class AeonEventEmitter<Events extends {
|
|
6
|
+
[K in keyof Events]: EventListener;
|
|
7
|
+
} = EventShape> {
|
|
8
|
+
private readonly listenerMap;
|
|
9
|
+
on<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
10
|
+
addListener<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
11
|
+
once<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): this;
|
|
12
|
+
off<K extends EventKey<Events>>(event: K, fn?: Events[K], context?: unknown, once?: boolean): this;
|
|
13
|
+
removeListener<K extends EventKey<Events>>(event: K, fn?: Events[K], context?: unknown, once?: boolean): this;
|
|
14
|
+
removeAllListeners<K extends EventKey<Events>>(event?: K): this;
|
|
15
|
+
emit<K extends EventKey<Events>>(event: K, ...args: Parameters<Events[K]>): boolean;
|
|
16
|
+
eventNames(): Array<EventKey<Events>>;
|
|
17
|
+
listeners<K extends EventKey<Events>>(event: K): Events[K][];
|
|
18
|
+
listenerCount<K extends EventKey<Events>>(event: K): number;
|
|
19
|
+
subscribe<K extends EventKey<Events>>(event: K, fn: Events[K], context?: unknown): () => void;
|
|
20
|
+
private registerListener;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { AeonEventEmitter as A, type AeonEventMap as a };
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,4 +1,93 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/core/AeonEventEmitter.ts
|
|
4
|
+
var AeonEventEmitter = class {
|
|
5
|
+
listenerMap = /* @__PURE__ */ new Map();
|
|
6
|
+
on(event, fn, context) {
|
|
7
|
+
return this.registerListener(event, fn, context, false);
|
|
8
|
+
}
|
|
9
|
+
addListener(event, fn, context) {
|
|
10
|
+
return this.registerListener(event, fn, context, false);
|
|
11
|
+
}
|
|
12
|
+
once(event, fn, context) {
|
|
13
|
+
return this.registerListener(event, fn, context, true);
|
|
14
|
+
}
|
|
15
|
+
off(event, fn, context, once) {
|
|
16
|
+
return this.removeListener(event, fn, context, once);
|
|
17
|
+
}
|
|
18
|
+
removeListener(event, fn, context, once) {
|
|
19
|
+
const listeners = this.listenerMap.get(event);
|
|
20
|
+
if (!listeners) {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
if (!fn) {
|
|
24
|
+
this.listenerMap.delete(event);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
const retained = listeners.filter(
|
|
28
|
+
(listener) => listener.fn !== fn || once === true && listener.once !== true || context !== void 0 && listener.context !== context
|
|
29
|
+
);
|
|
30
|
+
if (retained.length === 0) {
|
|
31
|
+
this.listenerMap.delete(event);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
this.listenerMap.set(
|
|
35
|
+
event,
|
|
36
|
+
retained
|
|
37
|
+
);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
removeAllListeners(event) {
|
|
41
|
+
if (event === void 0) {
|
|
42
|
+
this.listenerMap.clear();
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
this.listenerMap.delete(event);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
emit(event, ...args) {
|
|
49
|
+
const listeners = this.listenerMap.get(event);
|
|
50
|
+
if (!listeners || listeners.length === 0) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
for (const listener of [...listeners]) {
|
|
54
|
+
if (listener.once) {
|
|
55
|
+
this.removeListener(event, listener.fn, listener.context, true);
|
|
56
|
+
}
|
|
57
|
+
listener.fn.apply(listener.context, args);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
eventNames() {
|
|
62
|
+
return Array.from(this.listenerMap.keys());
|
|
63
|
+
}
|
|
64
|
+
listeners(event) {
|
|
65
|
+
return this.listenerMap.get(event)?.map((listener) => listener.fn) ?? [];
|
|
66
|
+
}
|
|
67
|
+
listenerCount(event) {
|
|
68
|
+
return this.listenerMap.get(event)?.length ?? 0;
|
|
69
|
+
}
|
|
70
|
+
subscribe(event, fn, context) {
|
|
71
|
+
this.on(event, fn, context);
|
|
72
|
+
return () => {
|
|
73
|
+
this.off(event, fn, context);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
registerListener(event, fn, context, once) {
|
|
77
|
+
if (typeof fn !== "function") {
|
|
78
|
+
throw new TypeError("The listener must be a function");
|
|
79
|
+
}
|
|
80
|
+
const listeners = this.listenerMap.get(event) ?? [];
|
|
81
|
+
listeners.push({
|
|
82
|
+
fn,
|
|
83
|
+
context: context || this,
|
|
84
|
+
once
|
|
85
|
+
});
|
|
86
|
+
this.listenerMap.set(event, listeners);
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
exports.AeonEventEmitter = AeonEventEmitter;
|
|
3
92
|
//# sourceMappingURL=index.cjs.map
|
|
4
93
|
//# sourceMappingURL=index.cjs.map
|
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
1
|
+
{"version":3,"sources":["../../src/core/AeonEventEmitter.ts"],"names":[],"mappings":";;;AAqBO,IAAM,mBAAN,MAEL;AAAA,EACiB,WAAA,uBAAkB,GAAA,EAGjC;AAAA,EAEF,EAAA,CACE,KAAA,EACA,EAAA,EACA,OAAA,EACM;AACN,IAAA,OAAO,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAO,EAAA,EAAI,SAAS,KAAK,CAAA;AAAA,EACxD;AAAA,EAEA,WAAA,CACE,KAAA,EACA,EAAA,EACA,OAAA,EACM;AACN,IAAA,OAAO,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAO,EAAA,EAAI,SAAS,KAAK,CAAA;AAAA,EACxD;AAAA,EAEA,IAAA,CACE,KAAA,EACA,EAAA,EACA,OAAA,EACM;AACN,IAAA,OAAO,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAO,EAAA,EAAI,SAAS,IAAI,CAAA;AAAA,EACvD;AAAA,EAEA,GAAA,CACE,KAAA,EACA,EAAA,EACA,OAAA,EACA,IAAA,EACM;AACN,IAAA,OAAO,IAAA,CAAK,cAAA,CAAe,KAAA,EAAO,EAAA,EAAI,SAAS,IAAI,CAAA;AAAA,EACrD;AAAA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;AAEA,IAAA,MAAM,YACJ,IAAA,CAAK,WAAA,CAAY,GAAA,CAAI,KAAK,KACzB,EAAC;AAEJ,IAAA,SAAA,CAAU,IAAA,CAAK;AAAA,MACb,EAAA;AAAA,MACA,SAAS,OAAA,IAAW,IAAA;AAAA,MACpB;AAAA,KACD,CAAA;AAED,IAAA,IAAA,CAAK,WAAA,CAAY,GAAA,CAAI,KAAA,EAAO,SAAS,CAAA;AAErC,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["/**\n * Aeon Event Emitter\n *\n * Aeon's control-plane events are low-volume observation surfaces, not\n * throughput-critical data planes. This implementation favors a small, typed,\n * dependency-free API with deterministic snapshot delivery over micro-optimized\n * special cases.\n */\n\ntype EventListener = (...args: any[]) => void;\n\nexport type AeonEventMap = Record<PropertyKey, EventListener>;\n\ntype EventShape = Record<string, EventListener>;\ntype EventKey<Events extends object> = keyof Events;\ntype ListenerRecord<Fn extends EventListener> = {\n fn: Fn;\n context: unknown;\n once: boolean;\n};\n\nexport class AeonEventEmitter<\n Events extends { [K in keyof Events]: EventListener } = EventShape\n> {\n private readonly listenerMap = new Map<\n EventKey<Events>,\n Array<ListenerRecord<Events[EventKey<Events>]>>\n >();\n\n on<K extends EventKey<Events>>(\n event: K,\n fn: Events[K],\n context?: unknown\n ): this {\n return this.registerListener(event, fn, context, false);\n }\n\n addListener<K extends EventKey<Events>>(\n event: K,\n fn: Events[K],\n context?: unknown\n ): this {\n return this.registerListener(event, fn, context, false);\n }\n\n once<K extends EventKey<Events>>(\n event: K,\n fn: Events[K],\n context?: unknown\n ): this {\n return this.registerListener(event, fn, context, true);\n }\n\n off<K extends EventKey<Events>>(\n event: K,\n fn?: Events[K],\n context?: unknown,\n once?: boolean\n ): this {\n return this.removeListener(event, fn, context, once);\n }\n\n removeListener<K extends EventKey<Events>>(\n event: K,\n fn?: Events[K],\n context?: unknown,\n once?: boolean\n ): this {\n const listeners = this.listenerMap.get(event);\n if (!listeners) {\n return this;\n }\n\n if (!fn) {\n this.listenerMap.delete(event);\n return this;\n }\n\n const retained = listeners.filter(\n (listener) =>\n listener.fn !== fn ||\n (once === true && listener.once !== true) ||\n (context !== undefined && listener.context !== context)\n );\n\n if (retained.length === 0) {\n this.listenerMap.delete(event);\n return this;\n }\n\n this.listenerMap.set(\n event,\n retained as Array<ListenerRecord<Events[EventKey<Events>]>>\n );\n\n return this;\n }\n\n removeAllListeners<K extends EventKey<Events>>(event?: K): this {\n if (event === undefined) {\n this.listenerMap.clear();\n return this;\n }\n\n this.listenerMap.delete(event);\n return this;\n }\n\n emit<K extends EventKey<Events>>(\n event: K,\n ...args: Parameters<Events[K]>\n ): boolean {\n const listeners = this.listenerMap.get(event);\n if (!listeners || listeners.length === 0) {\n return false;\n }\n\n // Emit against a point-in-time snapshot so registration churn during\n // delivery affects only future folds.\n for (const listener of [...listeners]) {\n if (listener.once) {\n this.removeListener(event, listener.fn, listener.context, true);\n }\n\n listener.fn.apply(listener.context, args);\n }\n\n return true;\n }\n\n eventNames(): Array<EventKey<Events>> {\n return Array.from(this.listenerMap.keys());\n }\n\n listeners<K extends EventKey<Events>>(event: K): Events[K][] {\n return (\n this.listenerMap.get(event)?.map((listener) => listener.fn as Events[K]) ??\n []\n );\n }\n\n listenerCount<K extends EventKey<Events>>(event: K): number {\n return this.listenerMap.get(event)?.length ?? 0;\n }\n\n subscribe<K extends EventKey<Events>>(\n event: K,\n fn: Events[K],\n context?: unknown\n ): () => void {\n this.on(event, fn, context);\n\n return () => {\n this.off(event, fn, context);\n };\n }\n\n private registerListener<K extends EventKey<Events>>(\n event: K,\n fn: Events[K],\n context: unknown,\n once: boolean\n ): this {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n const listeners =\n this.listenerMap.get(event) ??\n ([] as Array<ListenerRecord<Events[EventKey<Events>]>>);\n\n listeners.push({\n fn,\n context: context || this,\n once,\n });\n\n this.listenerMap.set(event, listeners);\n\n return this;\n }\n}\n"]}
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,212 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Shared type definitions for the Aeon synchronization and versioning system.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Operation type - what action is being performed
|
|
8
|
-
*/
|
|
9
|
-
type OperationType = 'create' | 'update' | 'delete' | 'sync' | 'batch';
|
|
10
|
-
/**
|
|
11
|
-
* Operation priority for sync ordering
|
|
12
|
-
*/
|
|
13
|
-
type OperationPriority = 'high' | 'normal' | 'low';
|
|
14
|
-
/**
|
|
15
|
-
* Operation sync status
|
|
16
|
-
*/
|
|
17
|
-
type OperationStatus = 'pending' | 'syncing' | 'synced' | 'failed';
|
|
18
|
-
/**
|
|
19
|
-
* Queued operation for offline-first synchronization
|
|
20
|
-
*/
|
|
21
|
-
interface Operation {
|
|
22
|
-
id: string;
|
|
23
|
-
type: OperationType;
|
|
24
|
-
sessionId: string;
|
|
25
|
-
status: OperationStatus;
|
|
26
|
-
data: Record<string, unknown>;
|
|
27
|
-
priority?: OperationPriority;
|
|
28
|
-
createdAt?: number;
|
|
29
|
-
syncedAt?: number;
|
|
30
|
-
retryCount?: number;
|
|
31
|
-
maxRetries?: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Conflict detection result
|
|
35
|
-
*/
|
|
36
|
-
interface ConflictDetectionResult {
|
|
37
|
-
hasConflict: boolean;
|
|
38
|
-
type?: 'update_update' | 'delete_update' | 'update_delete' | 'concurrent';
|
|
39
|
-
severity?: 'low' | 'medium' | 'high';
|
|
40
|
-
similarity?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Conflict resolution strategy
|
|
44
|
-
*/
|
|
45
|
-
type ResolutionStrategy = 'local_wins' | 'remote_wins' | 'last_modified' | 'merge' | 'manual';
|
|
46
|
-
/**
|
|
47
|
-
* Sync batch for uploading multiple operations
|
|
48
|
-
*/
|
|
49
|
-
interface SyncBatch {
|
|
50
|
-
batchId: string;
|
|
51
|
-
operations: Operation[];
|
|
52
|
-
totalSize: number;
|
|
53
|
-
createdAt: number;
|
|
54
|
-
priority: OperationPriority;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sync result from server
|
|
58
|
-
*/
|
|
59
|
-
interface SyncResult {
|
|
60
|
-
success: boolean;
|
|
61
|
-
synced: string[];
|
|
62
|
-
failed: Array<{
|
|
63
|
-
operationId: string;
|
|
64
|
-
error: string;
|
|
65
|
-
}>;
|
|
66
|
-
conflicts: Array<{
|
|
67
|
-
operationId: string;
|
|
68
|
-
remoteVersion: Record<string, unknown>;
|
|
69
|
-
strategy: ResolutionStrategy;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Network state for adaptive sync
|
|
74
|
-
*/
|
|
75
|
-
type NetworkState = 'online' | 'offline' | 'poor' | 'unknown';
|
|
76
|
-
/**
|
|
77
|
-
* Bandwidth profile for sync adaptation
|
|
78
|
-
*/
|
|
79
|
-
interface BandwidthProfile {
|
|
80
|
-
bandwidth: number;
|
|
81
|
-
latency: number;
|
|
82
|
-
timestamp: number;
|
|
83
|
-
reliability: number;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Sync coordinator configuration
|
|
87
|
-
*/
|
|
88
|
-
interface SyncCoordinatorConfig {
|
|
89
|
-
maxBatchSize: number;
|
|
90
|
-
maxBatchBytes: number;
|
|
91
|
-
maxRetries: number;
|
|
92
|
-
retryDelayMs: number;
|
|
93
|
-
enableCompression: boolean;
|
|
94
|
-
enableDeltaSync: boolean;
|
|
95
|
-
adaptateBatchSize: boolean;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Vector clock for causality tracking
|
|
99
|
-
*/
|
|
100
|
-
interface VectorClock {
|
|
101
|
-
[nodeId: string]: number;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* CRDT operation for conflict-free updates
|
|
105
|
-
*/
|
|
106
|
-
interface CRDTOperation {
|
|
107
|
-
id: string;
|
|
108
|
-
type: 'insert' | 'delete' | 'update';
|
|
109
|
-
path: string[];
|
|
110
|
-
value?: unknown;
|
|
111
|
-
timestamp: number;
|
|
112
|
-
nodeId: string;
|
|
113
|
-
vectorClock: VectorClock;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Presence selection range
|
|
117
|
-
*/
|
|
118
|
-
interface PresenceSelection {
|
|
119
|
-
start: number;
|
|
120
|
-
end: number;
|
|
121
|
-
direction?: 'forward' | 'backward' | 'none';
|
|
122
|
-
path?: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Presence typing signal
|
|
126
|
-
*/
|
|
127
|
-
interface PresenceTyping {
|
|
128
|
-
isTyping: boolean;
|
|
129
|
-
field?: string;
|
|
130
|
-
isComposing?: boolean;
|
|
131
|
-
startedAt?: number;
|
|
132
|
-
stoppedAt?: number;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Presence scroll signal
|
|
136
|
-
*/
|
|
137
|
-
interface PresenceScroll {
|
|
138
|
-
depth: number;
|
|
139
|
-
y?: number;
|
|
140
|
-
viewportHeight?: number;
|
|
141
|
-
documentHeight?: number;
|
|
142
|
-
path?: string;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Presence viewport signal
|
|
146
|
-
*/
|
|
147
|
-
interface PresenceViewport {
|
|
148
|
-
width: number;
|
|
149
|
-
height: number;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Presence input signal
|
|
153
|
-
*/
|
|
154
|
-
interface PresenceInputState {
|
|
155
|
-
field: string;
|
|
156
|
-
hasFocus: boolean;
|
|
157
|
-
valueLength?: number;
|
|
158
|
-
selectionStart?: number;
|
|
159
|
-
selectionEnd?: number;
|
|
160
|
-
isComposing?: boolean;
|
|
161
|
-
inputMode?: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Presence emotional state signal
|
|
165
|
-
*/
|
|
166
|
-
interface PresenceEmotion {
|
|
167
|
-
primary?: string;
|
|
168
|
-
secondary?: string;
|
|
169
|
-
confidence?: number;
|
|
170
|
-
intensity?: number;
|
|
171
|
-
valence?: number;
|
|
172
|
-
arousal?: number;
|
|
173
|
-
dominance?: number;
|
|
174
|
-
source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
|
|
175
|
-
updatedAt?: number;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Presence information for real-time collaboration
|
|
179
|
-
*/
|
|
180
|
-
interface PresenceInfo {
|
|
181
|
-
userId: string;
|
|
182
|
-
nodeId: string;
|
|
183
|
-
cursor?: {
|
|
184
|
-
x: number;
|
|
185
|
-
y: number;
|
|
186
|
-
path?: string;
|
|
187
|
-
};
|
|
188
|
-
focusNode?: string;
|
|
189
|
-
selection?: PresenceSelection;
|
|
190
|
-
typing?: PresenceTyping;
|
|
191
|
-
scroll?: PresenceScroll;
|
|
192
|
-
viewport?: PresenceViewport;
|
|
193
|
-
inputState?: PresenceInputState;
|
|
194
|
-
emotion?: PresenceEmotion;
|
|
195
|
-
metadata?: Record<string, unknown>;
|
|
196
|
-
lastActivity: number;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Event emitter types
|
|
200
|
-
*/
|
|
201
|
-
type EventCallback<T = unknown> = (data: T) => void;
|
|
202
|
-
type EventUnsubscribe = () => void;
|
|
203
|
-
/**
|
|
204
|
-
* Generic event emitter interface
|
|
205
|
-
*/
|
|
206
|
-
interface IEventEmitter {
|
|
207
|
-
on<T = unknown>(event: string, callback: EventCallback<T>): EventUnsubscribe;
|
|
208
|
-
off(event: string, callback: EventCallback): void;
|
|
209
|
-
emit<T = unknown>(event: string, data?: T): void;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
|
1
|
+
export { B as BandwidthProfile, C as CRDTOperation, a as ConflictDetectionResult, E as EventCallback, b as EventUnsubscribe, I as IEventEmitter, N as NetworkState, O as Operation, c as OperationPriority, d as OperationStatus, e as OperationType, P as PresenceEmotion, f as PresenceInfo, g as PresenceInputState, h as PresenceScroll, i as PresenceSelection, j as PresenceTyping, k as PresenceViewport, R as ResolutionStrategy, S as SyncBatch, l as SyncCoordinatorConfig, m as SyncResult, V as VectorClock } from '../types-Bj5EbkSK.cjs';
|
|
2
|
+
export { A as AeonEventEmitter, a as AeonEventMap } from '../AeonEventEmitter-B1DzaYFk.cjs';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,212 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Shared type definitions for the Aeon synchronization and versioning system.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Operation type - what action is being performed
|
|
8
|
-
*/
|
|
9
|
-
type OperationType = 'create' | 'update' | 'delete' | 'sync' | 'batch';
|
|
10
|
-
/**
|
|
11
|
-
* Operation priority for sync ordering
|
|
12
|
-
*/
|
|
13
|
-
type OperationPriority = 'high' | 'normal' | 'low';
|
|
14
|
-
/**
|
|
15
|
-
* Operation sync status
|
|
16
|
-
*/
|
|
17
|
-
type OperationStatus = 'pending' | 'syncing' | 'synced' | 'failed';
|
|
18
|
-
/**
|
|
19
|
-
* Queued operation for offline-first synchronization
|
|
20
|
-
*/
|
|
21
|
-
interface Operation {
|
|
22
|
-
id: string;
|
|
23
|
-
type: OperationType;
|
|
24
|
-
sessionId: string;
|
|
25
|
-
status: OperationStatus;
|
|
26
|
-
data: Record<string, unknown>;
|
|
27
|
-
priority?: OperationPriority;
|
|
28
|
-
createdAt?: number;
|
|
29
|
-
syncedAt?: number;
|
|
30
|
-
retryCount?: number;
|
|
31
|
-
maxRetries?: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Conflict detection result
|
|
35
|
-
*/
|
|
36
|
-
interface ConflictDetectionResult {
|
|
37
|
-
hasConflict: boolean;
|
|
38
|
-
type?: 'update_update' | 'delete_update' | 'update_delete' | 'concurrent';
|
|
39
|
-
severity?: 'low' | 'medium' | 'high';
|
|
40
|
-
similarity?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Conflict resolution strategy
|
|
44
|
-
*/
|
|
45
|
-
type ResolutionStrategy = 'local_wins' | 'remote_wins' | 'last_modified' | 'merge' | 'manual';
|
|
46
|
-
/**
|
|
47
|
-
* Sync batch for uploading multiple operations
|
|
48
|
-
*/
|
|
49
|
-
interface SyncBatch {
|
|
50
|
-
batchId: string;
|
|
51
|
-
operations: Operation[];
|
|
52
|
-
totalSize: number;
|
|
53
|
-
createdAt: number;
|
|
54
|
-
priority: OperationPriority;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sync result from server
|
|
58
|
-
*/
|
|
59
|
-
interface SyncResult {
|
|
60
|
-
success: boolean;
|
|
61
|
-
synced: string[];
|
|
62
|
-
failed: Array<{
|
|
63
|
-
operationId: string;
|
|
64
|
-
error: string;
|
|
65
|
-
}>;
|
|
66
|
-
conflicts: Array<{
|
|
67
|
-
operationId: string;
|
|
68
|
-
remoteVersion: Record<string, unknown>;
|
|
69
|
-
strategy: ResolutionStrategy;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Network state for adaptive sync
|
|
74
|
-
*/
|
|
75
|
-
type NetworkState = 'online' | 'offline' | 'poor' | 'unknown';
|
|
76
|
-
/**
|
|
77
|
-
* Bandwidth profile for sync adaptation
|
|
78
|
-
*/
|
|
79
|
-
interface BandwidthProfile {
|
|
80
|
-
bandwidth: number;
|
|
81
|
-
latency: number;
|
|
82
|
-
timestamp: number;
|
|
83
|
-
reliability: number;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Sync coordinator configuration
|
|
87
|
-
*/
|
|
88
|
-
interface SyncCoordinatorConfig {
|
|
89
|
-
maxBatchSize: number;
|
|
90
|
-
maxBatchBytes: number;
|
|
91
|
-
maxRetries: number;
|
|
92
|
-
retryDelayMs: number;
|
|
93
|
-
enableCompression: boolean;
|
|
94
|
-
enableDeltaSync: boolean;
|
|
95
|
-
adaptateBatchSize: boolean;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Vector clock for causality tracking
|
|
99
|
-
*/
|
|
100
|
-
interface VectorClock {
|
|
101
|
-
[nodeId: string]: number;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* CRDT operation for conflict-free updates
|
|
105
|
-
*/
|
|
106
|
-
interface CRDTOperation {
|
|
107
|
-
id: string;
|
|
108
|
-
type: 'insert' | 'delete' | 'update';
|
|
109
|
-
path: string[];
|
|
110
|
-
value?: unknown;
|
|
111
|
-
timestamp: number;
|
|
112
|
-
nodeId: string;
|
|
113
|
-
vectorClock: VectorClock;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Presence selection range
|
|
117
|
-
*/
|
|
118
|
-
interface PresenceSelection {
|
|
119
|
-
start: number;
|
|
120
|
-
end: number;
|
|
121
|
-
direction?: 'forward' | 'backward' | 'none';
|
|
122
|
-
path?: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Presence typing signal
|
|
126
|
-
*/
|
|
127
|
-
interface PresenceTyping {
|
|
128
|
-
isTyping: boolean;
|
|
129
|
-
field?: string;
|
|
130
|
-
isComposing?: boolean;
|
|
131
|
-
startedAt?: number;
|
|
132
|
-
stoppedAt?: number;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Presence scroll signal
|
|
136
|
-
*/
|
|
137
|
-
interface PresenceScroll {
|
|
138
|
-
depth: number;
|
|
139
|
-
y?: number;
|
|
140
|
-
viewportHeight?: number;
|
|
141
|
-
documentHeight?: number;
|
|
142
|
-
path?: string;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Presence viewport signal
|
|
146
|
-
*/
|
|
147
|
-
interface PresenceViewport {
|
|
148
|
-
width: number;
|
|
149
|
-
height: number;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Presence input signal
|
|
153
|
-
*/
|
|
154
|
-
interface PresenceInputState {
|
|
155
|
-
field: string;
|
|
156
|
-
hasFocus: boolean;
|
|
157
|
-
valueLength?: number;
|
|
158
|
-
selectionStart?: number;
|
|
159
|
-
selectionEnd?: number;
|
|
160
|
-
isComposing?: boolean;
|
|
161
|
-
inputMode?: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Presence emotional state signal
|
|
165
|
-
*/
|
|
166
|
-
interface PresenceEmotion {
|
|
167
|
-
primary?: string;
|
|
168
|
-
secondary?: string;
|
|
169
|
-
confidence?: number;
|
|
170
|
-
intensity?: number;
|
|
171
|
-
valence?: number;
|
|
172
|
-
arousal?: number;
|
|
173
|
-
dominance?: number;
|
|
174
|
-
source?: 'self-report' | 'inferred' | 'sensor' | 'hybrid';
|
|
175
|
-
updatedAt?: number;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Presence information for real-time collaboration
|
|
179
|
-
*/
|
|
180
|
-
interface PresenceInfo {
|
|
181
|
-
userId: string;
|
|
182
|
-
nodeId: string;
|
|
183
|
-
cursor?: {
|
|
184
|
-
x: number;
|
|
185
|
-
y: number;
|
|
186
|
-
path?: string;
|
|
187
|
-
};
|
|
188
|
-
focusNode?: string;
|
|
189
|
-
selection?: PresenceSelection;
|
|
190
|
-
typing?: PresenceTyping;
|
|
191
|
-
scroll?: PresenceScroll;
|
|
192
|
-
viewport?: PresenceViewport;
|
|
193
|
-
inputState?: PresenceInputState;
|
|
194
|
-
emotion?: PresenceEmotion;
|
|
195
|
-
metadata?: Record<string, unknown>;
|
|
196
|
-
lastActivity: number;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Event emitter types
|
|
200
|
-
*/
|
|
201
|
-
type EventCallback<T = unknown> = (data: T) => void;
|
|
202
|
-
type EventUnsubscribe = () => void;
|
|
203
|
-
/**
|
|
204
|
-
* Generic event emitter interface
|
|
205
|
-
*/
|
|
206
|
-
interface IEventEmitter {
|
|
207
|
-
on<T = unknown>(event: string, callback: EventCallback<T>): EventUnsubscribe;
|
|
208
|
-
off(event: string, callback: EventCallback): void;
|
|
209
|
-
emit<T = unknown>(event: string, data?: T): void;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export type { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock };
|
|
1
|
+
export { B as BandwidthProfile, C as CRDTOperation, a as ConflictDetectionResult, E as EventCallback, b as EventUnsubscribe, I as IEventEmitter, N as NetworkState, O as Operation, c as OperationPriority, d as OperationStatus, e as OperationType, P as PresenceEmotion, f as PresenceInfo, g as PresenceInputState, h as PresenceScroll, i as PresenceSelection, j as PresenceTyping, k as PresenceViewport, R as ResolutionStrategy, S as SyncBatch, l as SyncCoordinatorConfig, m as SyncResult, V as VectorClock } from '../types-Bj5EbkSK.js';
|
|
2
|
+
export { A as AeonEventEmitter, a as AeonEventMap } from '../AeonEventEmitter-B1DzaYFk.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
+
// src/core/AeonEventEmitter.ts
|
|
2
|
+
var AeonEventEmitter = class {
|
|
3
|
+
listenerMap = /* @__PURE__ */ new Map();
|
|
4
|
+
on(event, fn, context) {
|
|
5
|
+
return this.registerListener(event, fn, context, false);
|
|
6
|
+
}
|
|
7
|
+
addListener(event, fn, context) {
|
|
8
|
+
return this.registerListener(event, fn, context, false);
|
|
9
|
+
}
|
|
10
|
+
once(event, fn, context) {
|
|
11
|
+
return this.registerListener(event, fn, context, true);
|
|
12
|
+
}
|
|
13
|
+
off(event, fn, context, once) {
|
|
14
|
+
return this.removeListener(event, fn, context, once);
|
|
15
|
+
}
|
|
16
|
+
removeListener(event, fn, context, once) {
|
|
17
|
+
const listeners = this.listenerMap.get(event);
|
|
18
|
+
if (!listeners) {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
if (!fn) {
|
|
22
|
+
this.listenerMap.delete(event);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
const retained = listeners.filter(
|
|
26
|
+
(listener) => listener.fn !== fn || once === true && listener.once !== true || context !== void 0 && listener.context !== context
|
|
27
|
+
);
|
|
28
|
+
if (retained.length === 0) {
|
|
29
|
+
this.listenerMap.delete(event);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
this.listenerMap.set(
|
|
33
|
+
event,
|
|
34
|
+
retained
|
|
35
|
+
);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
removeAllListeners(event) {
|
|
39
|
+
if (event === void 0) {
|
|
40
|
+
this.listenerMap.clear();
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
this.listenerMap.delete(event);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
emit(event, ...args) {
|
|
47
|
+
const listeners = this.listenerMap.get(event);
|
|
48
|
+
if (!listeners || listeners.length === 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
for (const listener of [...listeners]) {
|
|
52
|
+
if (listener.once) {
|
|
53
|
+
this.removeListener(event, listener.fn, listener.context, true);
|
|
54
|
+
}
|
|
55
|
+
listener.fn.apply(listener.context, args);
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
eventNames() {
|
|
60
|
+
return Array.from(this.listenerMap.keys());
|
|
61
|
+
}
|
|
62
|
+
listeners(event) {
|
|
63
|
+
return this.listenerMap.get(event)?.map((listener) => listener.fn) ?? [];
|
|
64
|
+
}
|
|
65
|
+
listenerCount(event) {
|
|
66
|
+
return this.listenerMap.get(event)?.length ?? 0;
|
|
67
|
+
}
|
|
68
|
+
subscribe(event, fn, context) {
|
|
69
|
+
this.on(event, fn, context);
|
|
70
|
+
return () => {
|
|
71
|
+
this.off(event, fn, context);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
registerListener(event, fn, context, once) {
|
|
75
|
+
if (typeof fn !== "function") {
|
|
76
|
+
throw new TypeError("The listener must be a function");
|
|
77
|
+
}
|
|
78
|
+
const listeners = this.listenerMap.get(event) ?? [];
|
|
79
|
+
listeners.push({
|
|
80
|
+
fn,
|
|
81
|
+
context: context || this,
|
|
82
|
+
once
|
|
83
|
+
});
|
|
84
|
+
this.listenerMap.set(event, listeners);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
1
88
|
|
|
89
|
+
export { AeonEventEmitter };
|
|
2
90
|
//# sourceMappingURL=index.js.map
|
|
3
91
|
//# sourceMappingURL=index.js.map
|