@inditextech/weave-store-azure-web-pubsub 5.2.0 → 5.2.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/client.d.ts CHANGED
@@ -1,105 +1,814 @@
1
+ /// <reference types="node" />
1
2
  import { WeaveStore } from "@inditextech/weave-sdk";
2
3
  import { DeepPartial, WeaveStoreOptions } from "@inditextech/weave-types";
3
4
  import ReconnectingWebSocket from "reconnecting-websocket";
5
+ import * as Y from "yjs";
4
6
  import { Doc } from "yjs";
5
- import Emittery from "emittery";
6
- import * as awarenessProtocol from "y-protocols/awareness";
7
7
  import { WebSocket } from "ws";
8
8
  import { TokenCredential } from "@azure/identity";
9
- import { Encoder } from "lib0/encoding";
10
- import { Decoder } from "lib0/decoding";
9
+ import "@azure/web-pubsub";
10
+ import "events";
11
+ import "http";
12
+ //#region ../../node_modules/emittery/index.d.ts
13
+ /**
14
+ Emittery accepts strings, symbols, and numbers as event names.
11
15
 
12
- //#region src/server/event-handler/cloud-events-protocols.d.ts
16
+ Symbol event names are preferred given that they can be used to avoid name collisions when your classes are extended, especially for internal events.
17
+ */
18
+ type EventName = PropertyKey;
19
+ // Helper type for turning the passed `EventData` type map into a list of string keys that don't require data alongside the event name when emitting. Uses the same trick that `Omit` does internally to filter keys by building a map of keys to keys we want to keep, and then accessing all the keys to return just the list of keys we want to keep.
20
+ type DatalessEventNames<EventData> = { [Key in keyof EventData]: EventData[Key] extends undefined ? Key : never; }[keyof EventData];
21
+ declare const listenerAdded: unique symbol;
22
+ declare const listenerRemoved: unique symbol;
23
+ type OmnipresentEventData = {
24
+ [listenerAdded]: ListenerChangedData;
25
+ [listenerRemoved]: ListenerChangedData;
26
+ };
13
27
  /**
14
- * The protocol of Web PubSub Client.
28
+ Emittery can collect and log debug information.
29
+
30
+ To enable this feature set the `DEBUG` environment variable to `emittery` or `*`. Additionally, you can set the static `isDebugEnabled` variable to true on the Emittery class, or `myEmitter.debug.enabled` on an instance of it for debugging a single instance.
31
+
32
+ See API for more information on how debugging works.
15
33
  */
34
+ type DebugLogger<EventData, Name extends keyof EventData> = (type: string, debugName: string, eventName?: Name, eventData?: EventData[Name]) => void;
35
+ /**
36
+ Configure debug options of an instance.
37
+ */
38
+ type DebugOptions<EventData> = {
39
+ /**
40
+ Define a name for the instance of Emittery to use when outputting debug data.
41
+
42
+ @default undefined
43
+
44
+ @example
45
+ ```
46
+ import Emittery from 'emittery';
47
+
48
+ Emittery.isDebugEnabled = true;
49
+
50
+ const emitter = new Emittery({debug: {name: 'myEmitter'}});
51
+
52
+ emitter.on('test', data => {
53
+ // …
54
+ });
55
+
56
+ emitter.emit('test');
57
+ //=> [16:43:20.417][emittery:subscribe][myEmitter] Event Name: test
58
+ // data: undefined
59
+ ```
60
+ */
61
+ readonly name: string;
62
+ /**
63
+ Toggle debug logging just for this instance.
64
+
65
+ @default false
66
+
67
+ @example
68
+ ```
69
+ import Emittery from 'emittery';
70
+
71
+ const emitter1 = new Emittery({debug: {name: 'emitter1', enabled: true}});
72
+ const emitter2 = new Emittery({debug: {name: 'emitter2'}});
73
+
74
+ emitter1.on('test', data => {
75
+ // …
76
+ });
77
+
78
+ emitter2.on('test', data => {
79
+ // …
80
+ });
81
+
82
+ emitter1.emit('test');
83
+ //=> [16:43:20.417][emittery:subscribe][emitter1] Event Name: test
84
+ // data: undefined
85
+
86
+ emitter2.emit('test');
87
+ ```
88
+ */
89
+ readonly enabled?: boolean;
90
+ /**
91
+ Function that handles debug data.
92
+
93
+ @default
94
+ ```
95
+ (type, debugName, eventName, eventData) => {
96
+ eventData = JSON.stringify(eventData);
16
97
 
98
+ if (typeof eventName === 'symbol' || typeof eventName === 'number') {
99
+ eventName = eventName.toString();
100
+ }
101
+
102
+ const currentTime = new Date();
103
+ const logTime = `${currentTime.getHours()}:${currentTime.getMinutes()}:${currentTime.getSeconds()}.${currentTime.getMilliseconds()}`;
104
+ console.log(`[${logTime}][emittery:${type}][${debugName}] Event Name: ${eventName}\n\tdata: ${eventData}`);
105
+ }
106
+ ```
107
+
108
+ @example
109
+ ```
110
+ import Emittery from 'emittery';
111
+
112
+ const myLogger = (type, debugName, eventName, eventData) => {
113
+ console.log(`[${type}]: ${eventName}`);
114
+ };
115
+
116
+ const emitter = new Emittery({
117
+ debug: {
118
+ name: 'myEmitter',
119
+ enabled: true,
120
+ logger: myLogger
121
+ }
122
+ });
123
+
124
+ emitter.on('test', data => {
125
+ // …
126
+ });
127
+
128
+ emitter.emit('test');
129
+ //=> [subscribe]: test
130
+ ```
131
+ */
132
+ readonly logger?: DebugLogger<EventData, keyof EventData>;
133
+ };
17
134
  /**
18
- * The protocol of Web PubSub Client.
135
+ Configuration options for Emittery.
19
136
  */
20
- type WebPubSubClientProtocol = "default" | "mqtt";
137
+ type Options<EventData> = {
138
+ readonly debug?: DebugOptions<EventData>;
139
+ };
140
+ /**
141
+ A promise returned from `emittery.once` with an extra `off` method to cancel your subscription.
142
+ */
143
+ type EmitteryOncePromise<T> = {
144
+ off(): void;
145
+ } & Promise<T>;
146
+ /**
147
+ Removes an event subscription.
148
+ */
149
+ type UnsubscribeFunction = () => void;
21
150
  /**
22
- * The connection context representing the client WebSocket connection.
151
+ The data provided as `eventData` when listening for `Emittery.listenerAdded` or `Emittery.listenerRemoved`.
23
152
  */
153
+ type ListenerChangedData = {
154
+ /**
155
+ The listener that was added or removed.
156
+ */
157
+ listener: (eventData?: unknown) => (void | Promise<void>);
158
+ /**
159
+ The name of the event that was added or removed if `.on()` or `.off()` was used, or `undefined` if `.onAny()` or `.offAny()` was used.
160
+ */
161
+ eventName?: EventName;
162
+ };
163
+ /**
164
+ Emittery is a strictly typed, fully async EventEmitter implementation. Event listeners can be registered with `on` or `once`, and events can be emitted with `emit`.
165
+
166
+ `Emittery` has a generic `EventData` type that can be provided by users to strongly type the list of events and the data passed to the listeners for those events. Pass an interface of {[eventName]: undefined | <eventArg>}, with all the event names as the keys and the values as the type of the argument passed to listeners if there is one, or `undefined` if there isn't.
167
+
168
+ @example
169
+ ```
170
+ import Emittery from 'emittery';
171
+
172
+ const emitter = new Emittery<
173
+ // Pass `{[eventName: <string | symbol | number>]: undefined | <eventArg>}` as the first type argument for events that pass data to their listeners.
174
+ // A value of `undefined` in this map means the event listeners should expect no data, and a type other than `undefined` means the listeners will receive one argument of that type.
175
+ {
176
+ open: string,
177
+ close: undefined
178
+ }
179
+ >();
180
+
181
+ // Typechecks just fine because the data type for the `open` event is `string`.
182
+ emitter.emit('open', 'foo\n');
183
+
184
+ // Typechecks just fine because `close` is present but points to undefined in the event data type map.
185
+ emitter.emit('close');
186
+
187
+ // TS compilation error because `1` isn't assignable to `string`.
188
+ emitter.emit('open', 1);
189
+
190
+ // TS compilation error because `other` isn't defined in the event data type map.
191
+ emitter.emit('other');
192
+ ```
193
+ */
194
+ declare class Emittery<EventData = Record<EventName, any> // TODO: Use `unknown` instead of `any`.
195
+ , AllEventData = EventData & OmnipresentEventData, DatalessEvents = DatalessEventNames<EventData>> {
196
+ /**
197
+ Toggle debug mode for all instances.
198
+
199
+ Default: `true` if the `DEBUG` environment variable is set to `emittery` or `*`, otherwise `false`.
200
+
201
+ @example
202
+ ```
203
+ import Emittery from 'emittery';
204
+
205
+ Emittery.isDebugEnabled = true;
206
+
207
+ const emitter1 = new Emittery({debug: {name: 'myEmitter1'}});
208
+ const emitter2 = new Emittery({debug: {name: 'myEmitter2'}});
209
+
210
+ emitter1.on('test', data => {
211
+ // …
212
+ });
213
+
214
+ emitter2.on('otherTest', data => {
215
+ // …
216
+ });
217
+
218
+ emitter1.emit('test');
219
+ //=> [16:43:20.417][emittery:subscribe][myEmitter1] Event Name: test
220
+ // data: undefined
221
+
222
+ emitter2.emit('otherTest');
223
+ //=> [16:43:20.417][emittery:subscribe][myEmitter2] Event Name: otherTest
224
+ // data: undefined
225
+ ```
226
+ */
227
+ static isDebugEnabled: boolean;
228
+ /**
229
+ Fires when an event listener was added.
230
+
231
+ An object with `listener` and `eventName` (if `on` or `off` was used) is provided as event data.
232
+
233
+ @example
234
+ ```
235
+ import Emittery from 'emittery';
236
+
237
+ const emitter = new Emittery();
238
+
239
+ emitter.on(Emittery.listenerAdded, ({listener, eventName}) => {
240
+ console.log(listener);
241
+ //=> data => {}
242
+
243
+ console.log(eventName);
244
+ //=> '🦄'
245
+ });
246
+
247
+ emitter.on('🦄', data => {
248
+ // Handle data
249
+ });
250
+ ```
251
+ */
252
+ static readonly listenerAdded: typeof listenerAdded;
253
+ /**
254
+ Fires when an event listener was removed.
255
+
256
+ An object with `listener` and `eventName` (if `on` or `off` was used) is provided as event data.
257
+
258
+ @example
259
+ ```
260
+ import Emittery from 'emittery';
261
+
262
+ const emitter = new Emittery();
263
+
264
+ const off = emitter.on('🦄', data => {
265
+ // Handle data
266
+ });
267
+
268
+ emitter.on(Emittery.listenerRemoved, ({listener, eventName}) => {
269
+ console.log(listener);
270
+ //=> data => {}
271
+
272
+ console.log(eventName);
273
+ //=> '🦄'
274
+ });
275
+
276
+ off();
277
+ ```
278
+ */
279
+ static readonly listenerRemoved: typeof listenerRemoved;
280
+ /**
281
+ In TypeScript, it returns a decorator which mixins `Emittery` as property `emitteryPropertyName` and `methodNames`, or all `Emittery` methods if `methodNames` is not defined, into the target class.
282
+
283
+ @example
284
+ ```
285
+ import Emittery from 'emittery';
286
+
287
+ @Emittery.mixin('emittery')
288
+ class MyClass {}
289
+
290
+ const instance = new MyClass();
291
+
292
+ instance.emit('event');
293
+ ```
294
+ */
295
+ static mixin(emitteryPropertyName: string | symbol, methodNames?: readonly string[]): <T extends {
296
+ new (...arguments_: readonly any[]): any;
297
+ }>(klass: T) => T; // eslint-disable-line @typescript-eslint/prefer-function-type
298
+ /**
299
+ Debugging options for the current instance.
300
+ */
301
+ debug: DebugOptions<EventData>;
302
+ /**
303
+ Create a new Emittery instance with the specified options.
304
+
305
+ @returns An instance of Emittery that you can use to listen for and emit events.
306
+ */
307
+ constructor(options?: Options<EventData>);
308
+ /**
309
+ Subscribe to one or more events.
310
+
311
+ Using the same listener multiple times for the same event will result in only one method call per emitted event.
312
+
313
+ @returns An unsubscribe method.
314
+
315
+ @example
316
+ ```
317
+ import Emittery from 'emittery';
318
+
319
+ const emitter = new Emittery();
320
+
321
+ emitter.on('🦄', data => {
322
+ console.log(data);
323
+ });
324
+
325
+ emitter.on(['🦄', '🐶'], data => {
326
+ console.log(data);
327
+ });
328
+
329
+ emitter.emit('🦄', '🌈'); // log => '🌈' x2
330
+ emitter.emit('🐶', '🍖'); // log => '🍖'
331
+ ```
332
+ */
333
+ on<Name extends keyof AllEventData>(eventName: Name | readonly Name[], listener: (eventData: AllEventData[Name]) => void | Promise<void>, options?: {
334
+ signal?: AbortSignal;
335
+ }): UnsubscribeFunction;
336
+ /**
337
+ Get an async iterator which buffers data each time an event is emitted.
338
+
339
+ Call `return()` on the iterator to remove the subscription.
340
+
341
+ @example
342
+ ```
343
+ import Emittery from 'emittery';
344
+
345
+ const emitter = new Emittery();
346
+ const iterator = emitter.events('🦄');
347
+
348
+ emitter.emit('🦄', '🌈1'); // Buffered
349
+ emitter.emit('🦄', '🌈2'); // Buffered
350
+
351
+ iterator
352
+ .next()
353
+ .then(({value, done}) => {
354
+ // done === false
355
+ // value === '🌈1'
356
+ return iterator.next();
357
+ })
358
+ .then(({value, done}) => {
359
+ // done === false
360
+ // value === '🌈2'
361
+ // Revoke subscription
362
+ return iterator.return();
363
+ })
364
+ .then(({done}) => {
365
+ // done === true
366
+ });
367
+ ```
368
+
369
+ In practice you would usually consume the events using the [for await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) statement. In that case, to revoke the subscription simply break the loop.
370
+
371
+ @example
372
+ ```
373
+ import Emittery from 'emittery';
374
+
375
+ const emitter = new Emittery();
376
+ const iterator = emitter.events('🦄');
377
+
378
+ emitter.emit('🦄', '🌈1'); // Buffered
379
+ emitter.emit('🦄', '🌈2'); // Buffered
380
+
381
+ // In an async context.
382
+ for await (const data of iterator) {
383
+ if (data === '🌈2') {
384
+ break; // Revoke the subscription when we see the value `🌈2`.
385
+ }
386
+ }
387
+ ```
388
+
389
+ It accepts multiple event names.
390
+
391
+ @example
392
+ ```
393
+ import Emittery from 'emittery';
394
+
395
+ const emitter = new Emittery();
396
+ const iterator = emitter.events(['🦄', '🦊']);
397
+
398
+ emitter.emit('🦄', '🌈1'); // Buffered
399
+ emitter.emit('🦊', '🌈2'); // Buffered
400
+
401
+ iterator
402
+ .next()
403
+ .then(({value, done}) => {
404
+ // done === false
405
+ // value === '🌈1'
406
+ return iterator.next();
407
+ })
408
+ .then(({value, done}) => {
409
+ // done === false
410
+ // value === '🌈2'
411
+ // Revoke subscription
412
+ return iterator.return();
413
+ })
414
+ .then(({done}) => {
415
+ // done === true
416
+ });
417
+ ```
418
+ */
419
+ events<Name extends keyof EventData>(eventName: Name | readonly Name[]): AsyncIterableIterator<EventData[Name]>;
420
+ /**
421
+ Remove one or more event subscriptions.
422
+
423
+ @example
424
+ ```
425
+ import Emittery from 'emittery';
426
+
427
+ const emitter = new Emittery();
428
+
429
+ const listener = data => {
430
+ console.log(data);
431
+ };
432
+
433
+ emitter.on(['🦄', '🐶', '🦊'], listener);
434
+ await emitter.emit('🦄', 'a');
435
+ await emitter.emit('🐶', 'b');
436
+ await emitter.emit('🦊', 'c');
437
+ emitter.off('🦄', listener);
438
+ emitter.off(['🐶', '🦊'], listener);
439
+ await emitter.emit('🦄', 'a'); // nothing happens
440
+ await emitter.emit('🐶', 'b'); // nothing happens
441
+ await emitter.emit('🦊', 'c'); // nothing happens
442
+ ```
443
+ */
444
+ off<Name extends keyof AllEventData>(eventName: Name | readonly Name[], listener: (eventData: AllEventData[Name]) => void | Promise<void>): void;
445
+ /**
446
+ Subscribe to one or more events only once. It will be unsubscribed after the first
447
+ event.
448
+
449
+ @returns The promise of event data when `eventName` is emitted. This promise is extended with an `off` method.
450
+
451
+ @example
452
+ ```
453
+ import Emittery from 'emittery';
454
+
455
+ const emitter = new Emittery();
456
+
457
+ emitter.once('🦄').then(data => {
458
+ console.log(data);
459
+ //=> '🌈'
460
+ });
461
+
462
+ emitter.once(['🦄', '🐶']).then(data => {
463
+ console.log(data);
464
+ });
465
+
466
+ emitter.emit('🦄', '🌈'); // Logs `🌈` twice
467
+ emitter.emit('🐶', '🍖'); // Nothing happens
468
+ ```
469
+ */
470
+ once<Name extends keyof AllEventData>(eventName: Name | readonly Name[]): EmitteryOncePromise<AllEventData[Name]>;
471
+ /**
472
+ Trigger an event asynchronously, optionally with some data. Listeners are called in the order they were added, but executed concurrently.
473
+
474
+ @returns A promise that resolves when all the event listeners are done. *Done* meaning executed if synchronous or resolved when an async/promise-returning function. You usually wouldn't want to wait for this, but you could for example catch possible errors. If any of the listeners throw/reject, the returned promise will be rejected with the error, but the other listeners will not be affected.
475
+ */
476
+ emit<Name extends DatalessEvents>(eventName: Name): Promise<void>;
477
+ emit<Name extends keyof EventData>(eventName: Name, eventData: EventData[Name]): Promise<void>;
478
+ /**
479
+ Same as `emit()`, but it waits for each listener to resolve before triggering the next one. This can be useful if your events depend on each other. Although ideally they should not. Prefer `emit()` whenever possible.
480
+
481
+ If any of the listeners throw/reject, the returned promise will be rejected with the error and the remaining listeners will *not* be called.
482
+
483
+ @returns A promise that resolves when all the event listeners are done.
484
+ */
485
+ emitSerial<Name extends DatalessEvents>(eventName: Name): Promise<void>;
486
+ emitSerial<Name extends keyof EventData>(eventName: Name, eventData: EventData[Name]): Promise<void>;
487
+ /**
488
+ Subscribe to be notified about any event.
489
+
490
+ @returns A method to unsubscribe.
491
+ */
492
+ onAny(listener: (eventName: keyof EventData, eventData: EventData[keyof EventData]) => void | Promise<void>, options?: {
493
+ signal?: AbortSignal;
494
+ }): UnsubscribeFunction;
495
+ /**
496
+ Get an async iterator which buffers a tuple of an event name and data each time an event is emitted.
497
+
498
+ Call `return()` on the iterator to remove the subscription.
499
+
500
+ In the same way as for `events`, you can subscribe by using the `for await` statement.
501
+
502
+ @example
503
+ ```
504
+ import Emittery from 'emittery';
505
+
506
+ const emitter = new Emittery();
507
+ const iterator = emitter.anyEvent();
508
+
509
+ emitter.emit('🦄', '🌈1'); // Buffered
510
+ emitter.emit('🌟', '🌈2'); // Buffered
511
+
512
+ iterator.next()
513
+ .then(({value, done}) => {
514
+ // done is false
515
+ // value is ['🦄', '🌈1']
516
+ return iterator.next();
517
+ })
518
+ .then(({value, done}) => {
519
+ // done is false
520
+ // value is ['🌟', '🌈2']
521
+ // revoke subscription
522
+ return iterator.return();
523
+ })
524
+ .then(({done}) => {
525
+ // done is true
526
+ });
527
+ ```
528
+ */
529
+ anyEvent(): AsyncIterableIterator<[keyof EventData, EventData[keyof EventData]]>;
530
+ /**
531
+ Remove an `onAny` subscription.
532
+ */
533
+ offAny(listener: (eventName: keyof EventData, eventData: EventData[keyof EventData]) => void | Promise<void>): void;
534
+ /**
535
+ Clear all event listeners on the instance.
536
+
537
+ If `eventName` is given, only the listeners for that event are cleared.
538
+ */
539
+ clearListeners<Name extends keyof EventData>(eventName?: Name | readonly Name[]): void;
540
+ /**
541
+ The number of listeners for the `eventName` or all events if not specified.
542
+ */
543
+ listenerCount<Name extends keyof EventData>(eventName?: Name | readonly Name[]): number;
544
+ /**
545
+ Bind the given `methodNames`, or all `Emittery` methods if `methodNames` is not defined, into the `target` object.
546
+
547
+ @example
548
+ ```
549
+ import Emittery from 'emittery';
550
+
551
+ const object = {};
552
+
553
+ new Emittery().bindMethods(object);
554
+
555
+ object.emit('event');
556
+ ```
557
+ */
558
+ bindMethods(target: Record<string, unknown>, methodNames?: readonly string[]): void;
559
+ }
560
+ //#endregion
561
+ //#region ../../node_modules/lib0/observable.d.ts
562
+ /**
563
+ * Handles named events.
564
+ *
565
+ * @deprecated
566
+ * @template N
567
+ */
568
+ declare class Observable<N> {
569
+ /**
570
+ * Some desc.
571
+ * @type {Map<N, any>}
572
+ */
573
+ _observers: Map<N, any>;
574
+ /**
575
+ * @param {N} name
576
+ * @param {function} f
577
+ */
578
+ on(name: N, f: Function): void;
579
+ /**
580
+ * @param {N} name
581
+ * @param {function} f
582
+ */
583
+ once(name: N, f: Function): void;
584
+ /**
585
+ * @param {N} name
586
+ * @param {function} f
587
+ */
588
+ off(name: N, f: Function): void;
589
+ /**
590
+ * Emit a named event. All registered event listeners that listen to the
591
+ * specified name will receive the event.
592
+ *
593
+ * @todo This should catch exceptions
594
+ *
595
+ * @param {N} name The event name.
596
+ * @param {Array<any>} args The arguments that are applied to the event listener.
597
+ */
598
+ emit(name: N, args: Array<any>): void;
599
+ destroy(): void;
600
+ }
601
+ //#endregion
602
+ //#region ../../node_modules/y-protocols/awareness.d.ts
603
+ /**
604
+ * @typedef {Object} MetaClientState
605
+ * @property {number} MetaClientState.clock
606
+ * @property {number} MetaClientState.lastUpdated unix timestamp
607
+ */
608
+ /**
609
+ * The Awareness class implements a simple shared state protocol that can be used for non-persistent data like awareness information
610
+ * (cursor, username, status, ..). Each client can update its own local state and listen to state changes of
611
+ * remote clients. Every client may set a state of a remote peer to `null` to mark the client as offline.
612
+ *
613
+ * Each client is identified by a unique client id (something we borrow from `doc.clientID`). A client can override
614
+ * its own state by propagating a message with an increasing timestamp (`clock`). If such a message is received, it is
615
+ * applied if the known state of that client is older than the new state (`clock < newClock`). If a client thinks that
616
+ * a remote client is offline, it may propagate a message with
617
+ * `{ clock: currentClientClock, state: null, client: remoteClient }`. If such a
618
+ * message is received, and the known clock of that client equals the received clock, it will override the state with `null`.
619
+ *
620
+ * Before a client disconnects, it should propagate a `null` state with an updated clock.
621
+ *
622
+ * Awareness states must be updated every 30 seconds. Otherwise the Awareness instance will delete the client state.
623
+ *
624
+ * @extends {Observable<string>}
625
+ */
626
+ declare class Awareness extends Observable<string> {
627
+ /**
628
+ * @param {Y.Doc} doc
629
+ */
630
+ constructor(doc: Y.Doc);
631
+ doc: Y.Doc;
632
+ /**
633
+ * @type {number}
634
+ */
635
+ clientID: number;
636
+ /**
637
+ * Maps from client id to client state
638
+ * @type {Map<number, Object<string, any>>}
639
+ */
640
+ states: Map<number, {
641
+ [x: string]: any;
642
+ }>;
643
+ /**
644
+ * @type {Map<number, MetaClientState>}
645
+ */
646
+ meta: Map<number, MetaClientState>;
647
+ _checkInterval: any;
648
+ /**
649
+ * @return {Object<string,any>|null}
650
+ */
651
+ getLocalState(): {
652
+ [x: string]: any;
653
+ } | null;
654
+ /**
655
+ * @param {Object<string,any>|null} state
656
+ */
657
+ setLocalState(state: {
658
+ [x: string]: any;
659
+ } | null): void;
660
+ /**
661
+ * @param {string} field
662
+ * @param {any} value
663
+ */
664
+ setLocalStateField(field: string, value: any): void;
665
+ /**
666
+ * @return {Map<number,Object<string,any>>}
667
+ */
668
+ getStates(): Map<number, {
669
+ [x: string]: any;
670
+ }>;
671
+ }
672
+ type MetaClientState = {
673
+ clock: number;
674
+ /**
675
+ * unix timestamp
676
+ */
677
+ lastUpdated: number;
678
+ };
679
+ //#endregion
680
+ //#region ../../node_modules/@types/express-serve-static-core/index.d.ts
681
+ declare global {
682
+ namespace Express {
683
+ // These open interfaces may be extended in an application-specific manner via declaration merging.
684
+ // See for example method-override.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/method-override/index.d.ts)
685
+ interface Request {}
686
+ interface Response {}
687
+ interface Locals {}
688
+ interface Application {}
689
+ }
690
+ }
691
+ //#endregion
692
+ //#region src/server/event-handler/cloud-events-protocols.d.ts
693
+ /**
694
+ * The protocol of Web PubSub Client.
695
+ */
696
+ type WebPubSubClientProtocol = "default" | "mqtt";
697
+ /**
698
+ * The connection context representing the client WebSocket connection.
699
+ */
24
700
  interface ConnectionContext {
25
701
  /**
26
- * The unique identifier generated by the service of the network connection.
27
- */
702
+ * The unique identifier generated by the service of the network connection.
703
+ */
28
704
  signature: string;
29
705
  /**
30
- * The hub the connection belongs to.
31
- */
706
+ * The hub the connection belongs to.
707
+ */
32
708
  hub: string;
33
709
  /**
34
- * The Id of the connection.
35
- */
710
+ * The Id of the connection.
711
+ */
36
712
  connectionId: string;
37
713
  /**
38
- * The event name of this CloudEvents request.
39
- */
714
+ * The event name of this CloudEvents request.
715
+ */
40
716
  eventName: string;
41
717
  /**
42
- * The origin this CloudEvents request comes from.
43
- */
718
+ * The origin this CloudEvents request comes from.
719
+ */
44
720
  origin: string;
45
721
  /**
46
- * The user id of the connection.
47
- */
722
+ * The user id of the connection.
723
+ */
48
724
  userId?: string;
49
725
  /**
50
- * The subprotocol of this connection.
51
- */
726
+ * The subprotocol of this connection.
727
+ */
52
728
  subprotocol?: string;
53
729
  /**
54
- * Get the additional states for the connection, such states are perserved throughout the lifetime of the connection.
55
- */
730
+ * Get the additional states for the connection, such states are perserved throughout the lifetime of the connection.
731
+ */
56
732
  states: Record<string, any>;
57
733
  /**
58
- * The type of client protocol.
59
- */
734
+ * The type of client protocol.
735
+ */
60
736
  clientProtocol: WebPubSubClientProtocol;
61
737
  /**
62
- * The MQTT properties that the client WebSocket connection has when it connects (For MQTT connection only).
63
- */
738
+ * The MQTT properties that the client WebSocket connection has when it connects (For MQTT connection only).
739
+ */
64
740
  mqtt?: MqttConnectionContextProperties;
65
741
  }
66
742
  /**
67
- * The connection context properties representing the MQTT client WebSocket connection.
68
- */
743
+ * The connection context properties representing the MQTT client WebSocket connection.
744
+ */
69
745
  interface MqttConnectionContextProperties {
70
746
  /**
71
- * The unique identifier generated by the service of the network connection.
72
- */
747
+ * The unique identifier generated by the service of the network connection.
748
+ */
73
749
  physicalConnectionId: string;
74
750
  /**
75
- * The unique identifier generated by the service of the MQTT session.
76
- */
751
+ * The unique identifier generated by the service of the MQTT session.
752
+ */
77
753
  sessionId?: string;
78
- } //#endregion
754
+ }
755
+ //#endregion
79
756
  //#region src/constants.d.ts
80
-
81
- /**
82
- * Request for the connect event.
83
- */
84
757
  declare const WEAVE_STORE_AZURE_WEB_PUBSUB = "store-azure-web-pubsub";
85
758
  declare const WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS: {
86
- "CONNECTING": string;
87
- "CONNECTED": string;
88
- "DISCONNECTED": string;
89
- "ERROR": string;
759
+ CONNECTING: string;
760
+ CONNECTED: string;
761
+ DISCONNECTED: string;
762
+ ERROR: string;
90
763
  };
91
764
  declare const WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE: {
92
- "PUB": string;
93
- "SUB": string;
765
+ PUB: string;
766
+ SUB: string;
94
767
  };
95
768
  declare const WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS: {
96
- "NOT_FOUND": string;
97
- "NOT_CONNECTED": string;
98
- "DESTROYED": string;
769
+ NOT_FOUND: string;
770
+ NOT_CONNECTED: string;
771
+ DESTROYED: string;
99
772
  };
100
773
  declare const WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS: WeaveStoreAzureWebPubSubSyncClientOptions;
101
774
  declare const WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS: WeaveStoreAzureWebPubsubSyncHostOptions;
102
-
775
+ //#endregion
776
+ //#region ../../node_modules/lib0/encoding.d.ts
777
+ /**
778
+ * A BinaryEncoder handles the encoding to an Uint8Array.
779
+ */
780
+ declare class Encoder {
781
+ cpos: number;
782
+ cbuf: Uint8Array<ArrayBuffer>;
783
+ /**
784
+ * @type {Array<Uint8Array>}
785
+ */
786
+ bufs: Array<Uint8Array>;
787
+ }
788
+ //#endregion
789
+ //#region ../../node_modules/lib0/decoding.d.ts
790
+ /**
791
+ * A Decoder handles the decoding of an Uint8Array.
792
+ * @template {ArrayBufferLike} [Buf=ArrayBufferLike]
793
+ */
794
+ declare class Decoder<Buf extends ArrayBufferLike = ArrayBufferLike> {
795
+ /**
796
+ * @param {Uint8Array<Buf>} uint8Array Binary data to decode
797
+ */
798
+ constructor(uint8Array: Uint8Array<Buf>);
799
+ /**
800
+ * Decoding target.
801
+ *
802
+ * @type {Uint8Array<Buf>}
803
+ */
804
+ arr: Uint8Array<Buf>;
805
+ /**
806
+ * Current decoding position.
807
+ *
808
+ * @type {number}
809
+ */
810
+ pos: number;
811
+ }
103
812
  //#endregion
104
813
  //#region src/types.d.ts
105
814
  type WeaveStoreAzureWebPubsubConfig = {
@@ -124,9 +833,9 @@ type IndexedDbOptions = {
124
833
  /** Enable IndexedDB offline persistence for faster initial load. Default: false. */
125
834
  enabled: boolean;
126
835
  /**
127
- * IndexedDB database name. Defaults to the roomId when omitted.
128
- * Override to namespace databases in multi-tenant applications.
129
- */
836
+ * IndexedDB database name. Defaults to the roomId when omitted.
837
+ * Override to namespace databases in multi-tenant applications.
838
+ */
130
839
  dbName?: string;
131
840
  };
132
841
  type WeaveStoreAzureWebPubsubOptions = {
@@ -199,12 +908,12 @@ type WeaveStoreAzureWebPubSubSyncClientConnectionStatus = (typeof WEAVE_STORE_AZ
199
908
  declare enum MessageType {
200
909
  System = "system",
201
910
  JoinGroup = "joinGroup",
202
- SendToGroup = "sendToGroup",
911
+ SendToGroup = "sendToGroup"
203
912
  }
204
913
  declare enum MessageDataType {
205
914
  Init = "init",
206
915
  Sync = "sync",
207
- Awareness = "awareness",
916
+ Awareness = "awareness"
208
917
  }
209
918
  interface MessageData {
210
919
  payloadId?: string;
@@ -243,7 +952,8 @@ type WeaveStoreAzureWebPubsubSyncHostOptions = {
243
952
  checkIntervalMs: number;
244
953
  attemptsLimit: number;
245
954
  };
246
- }; //#endregion
955
+ };
956
+ //#endregion
247
957
  //#region src/client.d.ts
248
958
  declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
249
959
  doc: Doc;
@@ -267,14 +977,14 @@ declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
267
977
  private _updateHandler;
268
978
  private _awarenessUpdateHandler;
269
979
  /**
270
- * @param {string} url
271
- * @param {string} topic
272
- * @param {Doc} doc
273
- * @param {number} [options.resyncInterval] Request server state every `resyncInterval` milliseconds.
274
- * @param {number} [options.tokenProvider] token generator for negotiation.
275
- */
980
+ * @param {string} url
981
+ * @param {string} topic
982
+ * @param {Doc} doc
983
+ * @param {number} [options.resyncInterval] Request server state every `resyncInterval` milliseconds.
984
+ * @param {number} [options.tokenProvider] token generator for negotiation.
985
+ */
276
986
  constructor(instance: WeaveStoreAzureWebPubsub, url: string, topic: string, doc: Doc, options?: DeepPartial<WeaveStoreAzureWebPubSubSyncClientOptions>);
277
- get awareness(): awarenessProtocol.Awareness;
987
+ get awareness(): Awareness;
278
988
  get synced(): boolean;
279
989
  set synced(state: boolean);
280
990
  get ws(): ReconnectingWebSocket | null;
@@ -291,7 +1001,6 @@ declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
291
1001
  private destroyCheckHeartbeat;
292
1002
  connect(connectionUrlExtraParams?: Record<string, string>): Promise<void>;
293
1003
  }
294
-
295
1004
  //#endregion
296
1005
  //#region src/store-azure-web-pubsub.d.ts
297
1006
  declare class WeaveStoreAzureWebPubsub extends WeaveStore {
@@ -322,6 +1031,5 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
322
1031
  handleAwarenessChange(emit?: boolean): void;
323
1032
  setAwarenessInfo<T>(field: string, value: T): void;
324
1033
  }
325
-
326
1034
  //#endregion
327
1035
  export { FetchClient, FetchInitialState, FetchRoom, IndexedDbOptions, Message, MessageData, MessageDataType, MessageHandler, MessageType, PersistRoom, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS, WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE, WeaveAzureWebPubsubSyncHandlerOptions, WeaveRoomData, WeaveStoreAzureWebPubSubSyncClientConnectionStatus, WeaveStoreAzureWebPubSubSyncClientConnectionStatusKeys, WeaveStoreAzureWebPubSubSyncClientOptions, WeaveStoreAzureWebPubSubSyncHostClientConnectOptions, WeaveStoreAzureWebPubsub, WeaveStoreAzureWebPubsubConfig, WeaveStoreAzureWebPubsubEvents, WeaveStoreAzureWebPubsubOnConnectEvent, WeaveStoreAzureWebPubsubOnConnectedEvent, WeaveStoreAzureWebPubsubOnDisconnectedEvent, WeaveStoreAzureWebPubsubOnStoreFetchConnectionUrlEvent, WeaveStoreAzureWebPubsubOnWebsocketCloseEvent, WeaveStoreAzureWebPubsubOnWebsocketErrorEvent, WeaveStoreAzureWebPubsubOnWebsocketJoinGroupEvent, WeaveStoreAzureWebPubsubOnWebsocketMessageEvent, WeaveStoreAzureWebPubsubOnWebsocketOpenEvent, WeaveStoreAzureWebPubsubOnWebsocketReconnectEvent, WeaveStoreAzureWebPubsubOptions, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatus, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatusKeys, WeaveStoreAzureWebPubsubSyncHostOptions };