@asyra/collaboration 0.5.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -0
  3. package/dist/awareness.d.ts +65 -0
  4. package/dist/awareness.d.ts.map +1 -0
  5. package/dist/awareness.js +289 -0
  6. package/dist/awareness.js.map +1 -0
  7. package/dist/cloning.d.ts +5 -0
  8. package/dist/cloning.d.ts.map +1 -0
  9. package/dist/cloning.js +5 -0
  10. package/dist/cloning.js.map +1 -0
  11. package/dist/composition.d.ts +21 -0
  12. package/dist/composition.d.ts.map +1 -0
  13. package/dist/composition.js +2 -0
  14. package/dist/composition.js.map +1 -0
  15. package/dist/deep-freeze.d.ts +2 -0
  16. package/dist/deep-freeze.d.ts.map +1 -0
  17. package/dist/deep-freeze.js +11 -0
  18. package/dist/deep-freeze.js.map +1 -0
  19. package/dist/index.d.ts +10 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +5 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/process.d.ts +73 -0
  24. package/dist/process.d.ts.map +1 -0
  25. package/dist/process.js +323 -0
  26. package/dist/process.js.map +1 -0
  27. package/dist/provider.d.ts +43 -0
  28. package/dist/provider.d.ts.map +1 -0
  29. package/dist/provider.js +31 -0
  30. package/dist/provider.js.map +1 -0
  31. package/dist/providers/memory/hub.d.ts +32 -0
  32. package/dist/providers/memory/hub.d.ts.map +1 -0
  33. package/dist/providers/memory/hub.js +182 -0
  34. package/dist/providers/memory/hub.js.map +1 -0
  35. package/dist/providers/memory/index.d.ts +4 -0
  36. package/dist/providers/memory/index.d.ts.map +1 -0
  37. package/dist/providers/memory/index.js +3 -0
  38. package/dist/providers/memory/index.js.map +1 -0
  39. package/dist/providers/memory/provider.d.ts +41 -0
  40. package/dist/providers/memory/provider.d.ts.map +1 -0
  41. package/dist/providers/memory/provider.js +251 -0
  42. package/dist/providers/memory/provider.js.map +1 -0
  43. package/package.json +46 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Asa Tsai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # `@asyra/collaboration`
2
+
3
+ Optional, provider-replaceable live transport for completed Asyra Factory
4
+ publications and ephemeral Awareness.
5
+
6
+ The package owns connection lifecycle and FIFO publication handoff only. Apps
7
+ remain responsible for payload validation, permissions, canonical remote apply,
8
+ conflict policy, persistence, snapshots, and recovery.
9
+
10
+ Every Provider implements one data method in each direction:
11
+ `sendPublication(publication)` and
12
+ `onPublication(async (publication) => ...)`. Collaboration hands each immutable
13
+ Factory-owned `SharedPublication` to `sendPublication` exactly once and in FIFO
14
+ order without cloning or rebuilding it. It does not advance to the next
15
+ publication until the current send settles. The receiving callback remains
16
+ pending until the app finishes canonical remote apply.
17
+
18
+ Concrete transports own bounded queues, wire framing, encoding, and any
19
+ internal grouping that does not alter publication identity or order. Generic
20
+ Collaboration owns none of those transport policies. If the Provider is not
21
+ connected when a Factory publication arrives, Collaboration reports it as
22
+ skipped and does not replay it after reconnect.
23
+
24
+ `MemoryHub` and `MemoryProvider` are non-durable development references. They
25
+ create one detached publication snapshot per receiving peer, retain no
26
+ publication history, and do not echo the sender. Their one-slot peer capacity
27
+ bounds pending app work without making the current sender Promise wait for peer
28
+ apply. Disconnected peers miss publications and reconnect receives only future
29
+ live publications. These in-process semantics are not wire serialization or a
30
+ disk/database acknowledgement. Product apps that promise durable collaboration
31
+ must supply an app-owned backend.
32
+
33
+ An app apply failure reports a Collaboration `process-failed` outcome and
34
+ rejects the Provider callback. It is not a `ProviderFailure`; that type remains
35
+ reserved for connection and transport failures.
36
+
37
+ ```ts
38
+ import {
39
+ createCollaboration,
40
+ MemoryHub,
41
+ MemoryProvider
42
+ } from '@asyra/collaboration'
43
+ ```
44
+
45
+ See the
46
+ [Collaboration package contract](https://github.com/karote00/asyra/blob/main/docs/ai/framework/packages/collaboration.md)
47
+ for complete composition, lifecycle, provider, and app-ownership details.
48
+
49
+ ## Release support
50
+
51
+ The `@asyra/collaboration` `0.2.5` ESM artifact supports Node.js 24.x. Use only
52
+ package-root exports. The package is opt-in and creates no provider or network
53
+ side effect until an app explicitly composes and connects it. See the
54
+ [Framework release support contract](../../docs/ai/framework/RELEASE_SUPPORT.md).
@@ -0,0 +1,65 @@
1
+ import type { ProviderAwarenessDisconnect, ProviderAwarenessMessage } from './provider.js';
2
+ export interface AwarenessRecord {
3
+ [key: string]: AwarenessValue;
4
+ }
5
+ export type AwarenessValue = null | string | number | boolean | AwarenessValue[] | AwarenessRecord;
6
+ export type AwarenessStateInput = Readonly<Record<string, AwarenessValue | undefined>> & {
7
+ readonly heartbeatAt?: never;
8
+ };
9
+ export type AwarenessState = Readonly<Record<string, AwarenessValue | undefined>> & {
10
+ readonly heartbeatAt?: number;
11
+ };
12
+ export interface RemoteAwarenessSnapshot {
13
+ readonly actorId: string;
14
+ readonly clock: number;
15
+ readonly state: Readonly<AwarenessState>;
16
+ readonly lastSeenAt: number;
17
+ }
18
+ export type AwarenessRemovalReason = 'disconnect' | 'leave' | 'timeout';
19
+ export interface AwarenessUpdatedObservation {
20
+ readonly type: 'updated';
21
+ readonly snapshot: RemoteAwarenessSnapshot;
22
+ }
23
+ export interface AwarenessRemovedObservation {
24
+ readonly type: 'removed';
25
+ readonly actorId: string;
26
+ readonly reason: AwarenessRemovalReason;
27
+ }
28
+ export type AwarenessObservation = AwarenessUpdatedObservation | AwarenessRemovedObservation;
29
+ export type AwarenessValidationErrorCode = 'invalid-actor' | 'invalid-clock' | 'reserved-field' | 'invalid-state' | 'disposed';
30
+ export declare class AwarenessValidationError extends Error {
31
+ readonly code: AwarenessValidationErrorCode;
32
+ constructor(code: AwarenessValidationErrorCode, message: string);
33
+ }
34
+ export interface AwarenessOptions {
35
+ readonly actorId?: string;
36
+ readonly timeoutMs?: number;
37
+ readonly now?: () => number;
38
+ }
39
+ export declare class Awareness {
40
+ readonly actorId: string;
41
+ private readonly timeoutMs;
42
+ private readonly now;
43
+ private clock;
44
+ private disposed;
45
+ private readonly remote;
46
+ private readonly remoteClocks;
47
+ private readonly subscribers;
48
+ constructor(options?: AwarenessOptions);
49
+ localClock(): number;
50
+ updateLocal(input: AwarenessStateInput): ProviderAwarenessMessage;
51
+ leaveLocal(): ProviderAwarenessMessage;
52
+ applyRemote(message: ProviderAwarenessMessage): boolean;
53
+ handleDisconnect(event: ProviderAwarenessDisconnect): boolean;
54
+ clearRemote(reason: 'disconnect'): readonly string[];
55
+ expire(): readonly string[];
56
+ observe(subscriber: (event: AwarenessObservation) => void): () => void;
57
+ getRemote(actorId: string): RemoteAwarenessSnapshot | undefined;
58
+ remoteActors(): readonly string[];
59
+ dispose(): void;
60
+ isDisposed(): boolean;
61
+ private remove;
62
+ private emit;
63
+ private requireUsable;
64
+ }
65
+ //# sourceMappingURL=awareness.d.ts.map
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CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,MAAM,IAAI;IAMtE,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;IAK/D,YAAY,IAAI,SAAS,MAAM,EAAE;IAIjC,OAAO,IAAI,IAAI;IAQf,UAAU,IAAI,OAAO;IAIrB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,IAAI;IAiBZ,OAAO,CAAC,aAAa;CAQtB"}
@@ -0,0 +1,289 @@
1
+ import { deepFreeze } from './deep-freeze.js';
2
+ export class AwarenessValidationError extends Error {
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.name = 'AwarenessValidationError';
6
+ this.code = code;
7
+ }
8
+ }
9
+ const inboundMessageFields = new Set(['actorId', 'clock', 'state']);
10
+ const inboundDisconnectFields = new Set(['actorId', 'reason']);
11
+ const readInboundDisconnect = (event) => {
12
+ if (!event || typeof event !== 'object' || Array.isArray(event)) {
13
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect must be a record');
14
+ }
15
+ const prototype = Object.getPrototypeOf(event);
16
+ if (prototype !== Object.prototype && prototype !== null) {
17
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect must be a plain record');
18
+ }
19
+ const candidate = event;
20
+ const descriptors = new Map();
21
+ for (const key of Reflect.ownKeys(candidate)) {
22
+ if (typeof key !== 'string' || !inboundDisconnectFields.has(key)) {
23
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect contains an unsupported field');
24
+ }
25
+ const descriptor = Object.getOwnPropertyDescriptor(candidate, key);
26
+ if (!descriptor?.enumerable || !('value' in descriptor)) {
27
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect accessors are not supported');
28
+ }
29
+ descriptors.set(key, descriptor);
30
+ }
31
+ if ([...inboundDisconnectFields].some((field) => !descriptors.has(field))) {
32
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect is missing a required field');
33
+ }
34
+ return Object.freeze({
35
+ actorId: descriptors.get('actorId')?.value,
36
+ reason: descriptors.get('reason')?.value
37
+ });
38
+ };
39
+ const readInboundMessage = (message) => {
40
+ if (!message || typeof message !== 'object' || Array.isArray(message)) {
41
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness message must be a record');
42
+ }
43
+ const prototype = Object.getPrototypeOf(message);
44
+ if (prototype !== Object.prototype && prototype !== null) {
45
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness message must be a plain record');
46
+ }
47
+ const candidate = message;
48
+ const descriptors = new Map();
49
+ for (const key of Reflect.ownKeys(candidate)) {
50
+ if (typeof key !== 'string' || !inboundMessageFields.has(key)) {
51
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness message contains an unsupported field');
52
+ }
53
+ const descriptor = Object.getOwnPropertyDescriptor(candidate, key);
54
+ if (!descriptor?.enumerable || !('value' in descriptor)) {
55
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness message accessors are not supported');
56
+ }
57
+ descriptors.set(key, descriptor);
58
+ }
59
+ if ([...inboundMessageFields].some((field) => !descriptors.has(field))) {
60
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness message is missing a required field');
61
+ }
62
+ return Object.freeze({
63
+ actorId: descriptors.get('actorId')?.value,
64
+ clock: descriptors.get('clock')?.value,
65
+ state: descriptors.get('state')?.value
66
+ });
67
+ };
68
+ const cloneAwarenessValue = (value, seen = new WeakSet()) => {
69
+ if (value === null ||
70
+ typeof value === 'string' ||
71
+ typeof value === 'boolean') {
72
+ return value;
73
+ }
74
+ if (typeof value === 'number') {
75
+ if (Number.isFinite(value))
76
+ return value;
77
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness numbers must be finite');
78
+ }
79
+ if (typeof value !== 'object') {
80
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness contains an unsupported value');
81
+ }
82
+ if (seen.has(value)) {
83
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness cannot contain circular values');
84
+ }
85
+ seen.add(value);
86
+ if (Array.isArray(value)) {
87
+ const result = [];
88
+ for (let index = 0; index < value.length; index += 1) {
89
+ const descriptor = Object.getOwnPropertyDescriptor(value, index);
90
+ if (!descriptor || !('value' in descriptor)) {
91
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness arrays must contain data values');
92
+ }
93
+ result.push(cloneAwarenessValue(descriptor.value, seen));
94
+ }
95
+ seen.delete(value);
96
+ return result;
97
+ }
98
+ const prototype = Object.getPrototypeOf(value);
99
+ if (prototype !== Object.prototype && prototype !== null) {
100
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness objects must be plain records');
101
+ }
102
+ const result = {};
103
+ for (const key of Reflect.ownKeys(value)) {
104
+ if (typeof key !== 'string') {
105
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness cannot contain symbol keys');
106
+ }
107
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
108
+ if (!descriptor?.enumerable)
109
+ continue;
110
+ if (!('value' in descriptor)) {
111
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness accessors are not supported');
112
+ }
113
+ Object.defineProperty(result, key, {
114
+ value: cloneAwarenessValue(descriptor.value, seen),
115
+ enumerable: true,
116
+ configurable: true,
117
+ writable: true
118
+ });
119
+ }
120
+ seen.delete(value);
121
+ return result;
122
+ };
123
+ const requireActor = (actorId) => {
124
+ if (typeof actorId !== 'string' || !actorId.trim()) {
125
+ throw new AwarenessValidationError('invalid-actor', '[collaboration] awareness actorId is required');
126
+ }
127
+ return actorId;
128
+ };
129
+ const cloneState = (input, allowHeartbeatAt) => {
130
+ if (!allowHeartbeatAt &&
131
+ Object.prototype.hasOwnProperty.call(input, 'heartbeatAt')) {
132
+ throw new AwarenessValidationError('reserved-field', '[collaboration] awareness heartbeatAt is runtime-owned');
133
+ }
134
+ return deepFreeze(cloneAwarenessValue(input));
135
+ };
136
+ const cloneSnapshot = (snapshot) => deepFreeze({
137
+ actorId: snapshot.actorId,
138
+ clock: snapshot.clock,
139
+ state: cloneState(snapshot.state, true),
140
+ lastSeenAt: snapshot.lastSeenAt
141
+ });
142
+ export class Awareness {
143
+ constructor(options = {}) {
144
+ this.clock = 0;
145
+ this.disposed = false;
146
+ this.remote = new Map();
147
+ this.remoteClocks = new Map();
148
+ this.subscribers = new Set();
149
+ this.actorId = options.actorId ?? '';
150
+ this.timeoutMs = options.timeoutMs ?? 30000;
151
+ this.now = options.now ?? Date.now;
152
+ if (!Number.isFinite(this.timeoutMs) || this.timeoutMs <= 0) {
153
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness timeoutMs must be positive');
154
+ }
155
+ }
156
+ localClock() {
157
+ return this.clock;
158
+ }
159
+ updateLocal(input) {
160
+ this.requireUsable();
161
+ requireActor(this.actorId);
162
+ const selectedState = cloneState(input, false);
163
+ const state = cloneState({ ...selectedState, heartbeatAt: this.now() }, true);
164
+ this.clock += 1;
165
+ return deepFreeze({ actorId: this.actorId, clock: this.clock, state });
166
+ }
167
+ leaveLocal() {
168
+ this.requireUsable();
169
+ requireActor(this.actorId);
170
+ this.clock += 1;
171
+ return Object.freeze({
172
+ actorId: this.actorId,
173
+ clock: this.clock,
174
+ state: null
175
+ });
176
+ }
177
+ applyRemote(message) {
178
+ this.requireUsable();
179
+ const candidate = readInboundMessage(message);
180
+ const actorId = requireActor(candidate.actorId);
181
+ if (typeof candidate.clock !== 'number' ||
182
+ !Number.isSafeInteger(candidate.clock) ||
183
+ candidate.clock < 0) {
184
+ throw new AwarenessValidationError('invalid-clock', '[collaboration] awareness clock must be a non-negative safe integer');
185
+ }
186
+ const clock = candidate.clock;
187
+ if (actorId === this.actorId)
188
+ return false;
189
+ if (clock <= (this.remoteClocks.get(actorId) ?? -1))
190
+ return false;
191
+ if (candidate.state === null) {
192
+ this.remoteClocks.set(actorId, clock);
193
+ this.remove(actorId, 'leave');
194
+ return true;
195
+ }
196
+ if (!candidate.state ||
197
+ typeof candidate.state !== 'object' ||
198
+ Array.isArray(candidate.state)) {
199
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness state must be a record or null');
200
+ }
201
+ const snapshot = deepFreeze({
202
+ actorId,
203
+ clock,
204
+ state: cloneState(candidate.state, true),
205
+ lastSeenAt: this.now()
206
+ });
207
+ this.remoteClocks.set(actorId, clock);
208
+ this.remote.set(actorId, snapshot);
209
+ this.emit({ type: 'updated', snapshot });
210
+ return true;
211
+ }
212
+ handleDisconnect(event) {
213
+ this.requireUsable();
214
+ const candidate = readInboundDisconnect(event);
215
+ const actorId = requireActor(candidate.actorId);
216
+ if (candidate.reason !== 'disconnect') {
217
+ throw new AwarenessValidationError('invalid-state', '[collaboration] awareness disconnect reason is invalid');
218
+ }
219
+ this.remoteClocks.delete(actorId);
220
+ return this.remove(actorId, 'disconnect');
221
+ }
222
+ clearRemote(reason) {
223
+ this.requireUsable();
224
+ const actorIds = [...this.remote.keys()];
225
+ this.remoteClocks.clear();
226
+ actorIds.forEach((actorId) => this.remove(actorId, reason));
227
+ return Object.freeze(actorIds);
228
+ }
229
+ expire() {
230
+ this.requireUsable();
231
+ const currentTime = this.now();
232
+ const expired = [...this.remote.values()]
233
+ .filter((snapshot) => currentTime - snapshot.lastSeenAt >= this.timeoutMs)
234
+ .map((snapshot) => snapshot.actorId);
235
+ expired.forEach((actorId) => this.remove(actorId, 'timeout'));
236
+ return Object.freeze(expired);
237
+ }
238
+ observe(subscriber) {
239
+ this.requireUsable();
240
+ this.subscribers.add(subscriber);
241
+ return () => this.subscribers.delete(subscriber);
242
+ }
243
+ getRemote(actorId) {
244
+ const snapshot = this.remote.get(actorId);
245
+ return snapshot ? cloneSnapshot(snapshot) : undefined;
246
+ }
247
+ remoteActors() {
248
+ return Object.freeze([...this.remote.keys()]);
249
+ }
250
+ dispose() {
251
+ if (this.disposed)
252
+ return;
253
+ this.disposed = true;
254
+ this.remote.clear();
255
+ this.remoteClocks.clear();
256
+ this.subscribers.clear();
257
+ }
258
+ isDisposed() {
259
+ return this.disposed;
260
+ }
261
+ remove(actorId, reason) {
262
+ if (!this.remote.delete(actorId))
263
+ return false;
264
+ this.emit({ type: 'removed', actorId, reason });
265
+ return true;
266
+ }
267
+ emit(event) {
268
+ ;
269
+ [...this.subscribers].forEach((subscriber) => {
270
+ try {
271
+ subscriber(event.type === 'updated'
272
+ ? deepFreeze({
273
+ type: 'updated',
274
+ snapshot: cloneSnapshot(event.snapshot)
275
+ })
276
+ : Object.freeze({ ...event }));
277
+ }
278
+ catch {
279
+ // Awareness observers cannot alter ephemeral ownership.
280
+ }
281
+ });
282
+ }
283
+ requireUsable() {
284
+ if (this.disposed) {
285
+ throw new AwarenessValidationError('disposed', '[collaboration] awareness is disposed');
286
+ }
287
+ }
288
+ }
289
+ //# sourceMappingURL=awareness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awareness.js","sourceRoot":"","sources":["../src/awareness.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAyD7C,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAGjD,YAAY,IAAkC,EAAE,OAAe;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAQD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACnE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;AAa9D,MAAM,qBAAqB,GAAG,CAAC,KAAc,EAA4B,EAAE;IACzE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,wBAAwB,CAChC,eAAe,EACf,uDAAuD,CACxD,CAAA;IACH,CAAC;IACD,MA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AAC;IACH,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import type { SharedPublication } from '@asyra/factory';
2
+ import type { ProviderAwarenessMessage } from './provider.js';
3
+ export declare const clonePublication: (publication: SharedPublication) => SharedPublication;
4
+ export declare const cloneAwareness: (value: ProviderAwarenessMessage) => ProviderAwarenessMessage;
5
+ //# sourceMappingURL=cloning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloning.d.ts","sourceRoot":"","sources":["../src/cloning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGvD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAK7D,eAAO,MAAM,gBAAgB,GAC3B,aAAa,iBAAiB,KAC7B,iBAGA,CAAA;AAEH,eAAO,MAAM,cAAc,GACzB,OAAO,wBAAwB,KAC9B,wBAC0E,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { measureBrowserDragPhase } from '@asyra/utils';
2
+ const measureClone = (phaseName, clone) => measureBrowserDragPhase(phaseName, clone);
3
+ export const clonePublication = (publication) => measureClone('collaboration:clone-publication', () => structuredClone(publication));
4
+ export const cloneAwareness = (value) => measureClone('collaboration:clone-awareness', () => structuredClone(value));
5
+ //# sourceMappingURL=cloning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloning.js","sourceRoot":"","sources":["../src/cloning.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAItD,MAAM,YAAY,GAAG,CAAI,SAAiB,EAAE,KAAc,EAAK,EAAE,CAC/D,uBAAuB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAA8B,EACX,EAAE,CACrB,YAAY,CAAC,iCAAiC,EAAE,GAAG,EAAE,CACnD,eAAe,CAAC,WAAW,CAAC,CAC7B,CAAA;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAA+B,EACL,EAAE,CAC5B,YAAY,CAAC,+BAA+B,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import type { Factory, SharedPublication } from '@asyra/factory';
2
+ import type { Awareness } from './awareness.js';
3
+ import type { Provider } from './provider.js';
4
+ export type CollaborationResourceOwnership = 'owned' | 'borrowed';
5
+ export interface CollaborationResourceOwnershipMap {
6
+ provider: CollaborationResourceOwnership;
7
+ awareness: CollaborationResourceOwnership;
8
+ }
9
+ export type CollaborationFactory = Pick<Factory, 'subscribeToSharedPublication'>;
10
+ export type ProcessRemotePublication = (publication: SharedPublication) => void | Promise<void>;
11
+ export interface CreateCollaborationInput {
12
+ documentId: string;
13
+ roomId: string;
14
+ actorId: string;
15
+ factory: CollaborationFactory;
16
+ processRemotePublication: ProcessRemotePublication;
17
+ provider?: Provider;
18
+ awareness?: Awareness;
19
+ resourceOwnership?: Partial<CollaborationResourceOwnershipMap>;
20
+ }
21
+ //# sourceMappingURL=composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,MAAM,8BAA8B,GAAG,OAAO,GAAG,UAAU,CAAA;AAEjE,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,8BAA8B,CAAA;IACxC,SAAS,EAAE,8BAA8B,CAAA;CAC1C;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAA;AAEhF,MAAM,MAAM,wBAAwB,GAAG,CACrC,WAAW,EAAE,iBAAiB,KAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEzB,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,oBAAoB,CAAA;IAC7B,wBAAwB,EAAE,wBAAwB,CAAA;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC,iCAAiC,CAAC,CAAA;CAC/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const deepFreeze: <T>(value: T, seen?: WeakSet<object>) => T;
2
+ //# sourceMappingURL=deep-freeze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-freeze.d.ts","sourceRoot":"","sources":["../src/deep-freeze.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,sBAA4B,KAAG,CAWtE,CAAA"}
@@ -0,0 +1,11 @@
1
+ export const deepFreeze = (value, seen = new WeakSet()) => {
2
+ if (value === null || typeof value !== 'object')
3
+ return value;
4
+ const object = value;
5
+ if (seen.has(object))
6
+ return value;
7
+ seen.add(object);
8
+ Reflect.ownKeys(object).forEach((key) => deepFreeze(Reflect.get(object, key), seen));
9
+ return Object.freeze(value);
10
+ };
11
+ //# sourceMappingURL=deep-freeze.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-freeze.js","sourceRoot":"","sources":["../src/deep-freeze.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAI,KAAQ,EAAE,OAAO,IAAI,OAAO,EAAU,EAAK,EAAE;IACzE,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAE7D,MAAM,MAAM,GAAG,KAAe,CAAA;IAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAA;IAElC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAChB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACtC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAC3C,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ export { Collaboration, DisposalError, createCollaboration } from './process.js';
2
+ export type { CollaborationPublicationOutcome } from './process.js';
3
+ export { Awareness, AwarenessValidationError } from './awareness.js';
4
+ export type { AwarenessObservation, AwarenessOptions, AwarenessRecord, AwarenessRemovedObservation, AwarenessRemovalReason, AwarenessState, AwarenessStateInput, AwarenessUpdatedObservation, AwarenessValidationErrorCode, AwarenessValue, RemoteAwarenessSnapshot } from './awareness.js';
5
+ export { PROVIDER_FAILURE_CODES, ProviderFailure, createProviderIdentitySnapshot, isProviderFailureCode } from './provider.js';
6
+ export type { Provider, ProviderAwarenessDisconnect, ProviderAwarenessMessage, ProviderFailureCode, ProviderIdentity, ProviderStatus } from './provider.js';
7
+ export { MemoryHub, MemoryProvider } from './providers/memory/index.js';
8
+ export type { MemoryHubOptions } from './providers/memory/index.js';
9
+ export type { CollaborationFactory, CollaborationResourceOwnership, CollaborationResourceOwnershipMap, CreateCollaborationInput, ProcessRemotePublication } from './composition.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAChF,YAAY,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAA;AAEnE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACpE,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,uBAAuB,EACxB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,8BAA8B,EAC9B,qBAAqB,EACtB,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,QAAQ,EACR,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,YAAY,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,iCAAiC,EACjC,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { Collaboration, DisposalError, createCollaboration } from './process.js';
2
+ export { Awareness, AwarenessValidationError } from './awareness.js';
3
+ export { PROVIDER_FAILURE_CODES, ProviderFailure, createProviderIdentitySnapshot, isProviderFailureCode } from './provider.js';
4
+ export { MemoryHub, MemoryProvider } from './providers/memory/index.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGhF,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAepE,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,8BAA8B,EAC9B,qBAAqB,EACtB,MAAM,eAAe,CAAA;AAUtB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA"}
@@ -0,0 +1,73 @@
1
+ import { Awareness, type AwarenessStateInput } from './awareness.js';
2
+ import type { CollaborationFactory, CreateCollaborationInput } from './composition.js';
3
+ import type { Provider, ProviderAwarenessMessage } from './provider.js';
4
+ export declare class DisposalError extends Error {
5
+ readonly failures: readonly unknown[];
6
+ constructor(failures: readonly unknown[]);
7
+ }
8
+ export type CollaborationPublicationOutcome = Readonly<{
9
+ direction: 'local';
10
+ status: 'sent' | 'skipped';
11
+ publicationId: string;
12
+ }> | Readonly<{
13
+ direction: 'local';
14
+ status: 'send-failed';
15
+ publicationId: string;
16
+ error: unknown;
17
+ }> | Readonly<{
18
+ direction: 'remote';
19
+ status: 'processed';
20
+ publicationId: string;
21
+ }> | Readonly<{
22
+ direction: 'remote';
23
+ status: 'process-failed';
24
+ publicationId: string;
25
+ error: unknown;
26
+ }>;
27
+ export declare class Collaboration {
28
+ readonly identity: Readonly<{
29
+ documentId: string;
30
+ roomId: string;
31
+ actorId: string;
32
+ }>;
33
+ readonly factory: CollaborationFactory;
34
+ readonly provider?: Provider;
35
+ readonly awareness: Awareness;
36
+ private readonly composition;
37
+ private readonly processRemotePublication;
38
+ private readonly disposers;
39
+ private readonly outcomeSubscribers;
40
+ private outboundQueue;
41
+ private inboundQueue;
42
+ private connectionGeneration;
43
+ private observersBound;
44
+ private started;
45
+ private disposed;
46
+ private startPromise;
47
+ private disposePromise;
48
+ constructor(input: CreateCollaborationInput);
49
+ start(): Promise<void>;
50
+ disconnect(): Promise<void>;
51
+ reconnect(): Promise<void>;
52
+ updateAwareness(state: AwarenessStateInput): Promise<ProviderAwarenessMessage>;
53
+ leaveAwareness(): Promise<ProviderAwarenessMessage>;
54
+ expireAwareness(): readonly string[];
55
+ observePublicationOutcomes(subscriber: (outcome: CollaborationPublicationOutcome) => void): () => void;
56
+ isStarted(): boolean;
57
+ isDisposed(): boolean;
58
+ whenIdle(): Promise<void>;
59
+ dispose(): Promise<void>;
60
+ private activate;
61
+ private bindObservers;
62
+ private addDisposer;
63
+ private scheduleOutbound;
64
+ private dispatchOutboundPublication;
65
+ private scheduleInbound;
66
+ private processInboundPublication;
67
+ private invalidateConnection;
68
+ private emitOutcome;
69
+ private disposeOwnedResources;
70
+ private requireUsable;
71
+ }
72
+ export declare const createCollaboration: (input: CreateCollaborationInput) => Collaboration;
73
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,EACV,oBAAoB,EAGpB,wBAAwB,EAEzB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAEvE,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;gBAEzB,QAAQ,EAAE,SAAS,OAAO,EAAE;CAKzC;AAaD,MAAM,MAAM,+BAA+B,GACvC,QAAQ,CAAC;IACP,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAA;CACtB,CAAC,GACF,QAAQ,CAAC;IACP,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,aAAa,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;CACf,CAAC,GACF,QAAQ,CAAC;IACP,SAAS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