tinybase 5.0.2 → 5.0.4

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/@types/synchronizers/synchronizer-ws-server/index.d.cts +32 -27
  2. package/@types/synchronizers/synchronizer-ws-server/index.d.ts +32 -27
  3. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +32 -27
  4. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +32 -27
  5. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  6. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  7. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  8. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  9. package/cjs/es6/synchronizers/synchronizer-ws-server/index.cjs +4 -6
  10. package/cjs/es6/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -6
  11. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  12. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  13. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  14. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  15. package/cjs/synchronizers/synchronizer-ws-server/index.cjs +4 -4
  16. package/cjs/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -4
  17. package/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  18. package/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  19. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  20. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  21. package/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
  22. package/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
  23. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  24. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  25. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  26. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  27. package/package.json +4 -1
  28. package/readme.md +2 -2
  29. package/releases.md +1 -1
  30. package/synchronizers/synchronizer-ws-server/index.js +4 -4
  31. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -4
  32. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  33. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  34. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  35. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  36. package/umd/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
  37. package/umd/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
  38. package/umd/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  39. package/umd/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  40. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  41. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  42. package/umd/synchronizers/synchronizer-ws-server/index.js +4 -6
  43. package/umd/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {Id, IdOrNull, Ids} from '../../common/index.d.cts';
12
- import type {GetIdChanges} from '../../store/index.d.cts';
12
+ import type {IdAddedOrRemoved} from '../../store/index.d.cts';
13
13
  import type {WebSocketServer} from 'ws';
14
14
 
15
15
  /**
@@ -18,23 +18,24 @@ import type {WebSocketServer} from 'ws';
18
18
  *
19
19
  * A WsServer listens to any path, allowing an app to have the concept of
20
20
  * distinct 'rooms' that only certain clients are participating in. As soon as a
21
- * single client connects to a new path, this listener will be called with a
22
- * GetIdChanges callback that you can use to determine its Id.
21
+ * single client connects to a new path, this listener will be called with the
22
+ * Id of the new path and an `addedOrRemoved` value of `1`.
23
23
  *
24
- * When the final client disconnects from a path, it will be called again with a
25
- * GetIdChanges callback that you can again use to determine its Id.
24
+ * When the final client disconnects from a path, it will be called again with
25
+ * the Id of the deactivated path and an `addedOrRemoved` value of `-1`.
26
26
  *
27
27
  * A PathIdsListener is provided when using the addPathIdsListener method. See
28
28
  * that method for specific examples.
29
29
  * @param wsServer A reference to the WsServer.
30
- * @param getIdChanges A function that returns information about the path Id
31
- * change.
30
+ * @param pathId The Id of the path being added or removed.
31
+ * @param addedOrRemoved Whether the path was added (`1`) or removed (`-1`).
32
32
  * @category Listener
33
- * @since v5.0.0
33
+ * @since v5.0.3
34
34
  */
35
- export type PathIdsListener<> = (
35
+ export type PathIdsListener = (
36
36
  wsServer: WsServer,
37
- getIdChanges: GetIdChanges,
37
+ pathId: Id,
38
+ addedOrRemoved: IdAddedOrRemoved,
38
39
  ) => void;
39
40
 
40
41
  /**
@@ -43,25 +44,27 @@ export type PathIdsListener<> = (
43
44
  *
44
45
  * A WsServer listens to any path, allowing an app to have the concept of
45
46
  * distinct 'rooms' that only certain clients are participating in. As soon as a
46
- * new client connects to a path, this listener will be called with a
47
- * GetIdChanges callback that you can use to determine its Id.
47
+ * new client connects to a path, this listener will be called with the Id of
48
+ * the path, the Id of the new client, and an `addedOrRemoved` value of `1`.
48
49
  *
49
- * When the client disconnects from a path, it will be called again with a
50
- * GetIdChanges callback that you can again use to determine its Id.
50
+ * When the client disconnects from a path, it will be called again with the Id
51
+ * of the path, the Id of the leaving client, and an `addedOrRemoved` value of
52
+ * `-1`.
51
53
  *
52
54
  * A ClientIdsListener is provided when using the addClientIdsListener method.
53
55
  * See that method for specific examples.
54
56
  * @param wsServer A reference to the WsServer.
55
57
  * @param pathId The path that the client joined or left.
56
- * @param getIdChanges A function that returns information about the client Id
57
- * change.
58
+ * @param clientId The Id of the client being added or removed.
59
+ * @param addedOrRemoved Whether the client was added (`1`) or removed (`-1`).
58
60
  * @category Listener
59
- * @since v5.0.0
61
+ * @since v5.0.3
60
62
  */
61
- export type ClientIdsListener<> = (
63
+ export type ClientIdsListener = (
62
64
  wsServer: WsServer,
63
65
  pathId: Id,
64
- getIdChanges: GetIdChanges,
66
+ clientId: Id,
67
+ addedOrRemoved: IdAddedOrRemoved,
65
68
  ) => void;
66
69
 
67
70
  /**
@@ -240,33 +243,35 @@ export interface WsServer {
240
243
  * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
241
244
  *
242
245
  * const server = createWsServer(new WebSocketServer({port: 8047}));
243
- * const listenerId = server.addPathIdsListener((server, getIdChanges) => {
244
- * console.log(getIdChanges());
245
- * console.log(server.getPathIds());
246
- * });
246
+ * const listenerId = server.addPathIdsListener(
247
+ * (server, pathId, addedOrRemoved) => {
248
+ * console.log(pathId + (addedOrRemoved == 1 ? ' added' : ' removed'));
249
+ * console.log(server.getPathIds());
250
+ * },
251
+ * );
247
252
  *
248
253
  * const synchronizer1 = await createWsSynchronizer(
249
254
  * createMergeableStore(),
250
255
  * new WebSocket('ws://localhost:8047/roomA'),
251
256
  * );
252
- * // -> {'roomA': 1}
257
+ * // -> 'roomA added'
253
258
  * // -> ['roomA']
254
259
  *
255
260
  * const synchronizer2 = await createWsSynchronizer(
256
261
  * createMergeableStore(),
257
262
  * new WebSocket('ws://localhost:8047/roomB'),
258
263
  * );
259
- * // -> {'roomB': 1}
264
+ * // -> 'roomB added'
260
265
  * // -> ['roomA', 'roomB']
261
266
  *
262
267
  * synchronizer1.destroy();
263
268
  * // ...
264
- * // -> {'roomA': -1}
269
+ * // -> 'roomA removed'
265
270
  * // -> ['roomB']
266
271
  *
267
272
  * synchronizer2.destroy();
268
273
  * // ...
269
- * // -> {'roomB': -1}
274
+ * // -> 'roomB removed'
270
275
  * // -> []
271
276
  *
272
277
  * server.delListener(listenerId);
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {Id, IdOrNull, Ids} from '../../common/index.d.ts';
12
- import type {GetIdChanges} from '../../store/index.d.ts';
12
+ import type {IdAddedOrRemoved} from '../../store/index.d.ts';
13
13
  import type {WebSocketServer} from 'ws';
14
14
 
15
15
  /**
@@ -18,23 +18,24 @@ import type {WebSocketServer} from 'ws';
18
18
  *
19
19
  * A WsServer listens to any path, allowing an app to have the concept of
20
20
  * distinct 'rooms' that only certain clients are participating in. As soon as a
21
- * single client connects to a new path, this listener will be called with a
22
- * GetIdChanges callback that you can use to determine its Id.
21
+ * single client connects to a new path, this listener will be called with the
22
+ * Id of the new path and an `addedOrRemoved` value of `1`.
23
23
  *
24
- * When the final client disconnects from a path, it will be called again with a
25
- * GetIdChanges callback that you can again use to determine its Id.
24
+ * When the final client disconnects from a path, it will be called again with
25
+ * the Id of the deactivated path and an `addedOrRemoved` value of `-1`.
26
26
  *
27
27
  * A PathIdsListener is provided when using the addPathIdsListener method. See
28
28
  * that method for specific examples.
29
29
  * @param wsServer A reference to the WsServer.
30
- * @param getIdChanges A function that returns information about the path Id
31
- * change.
30
+ * @param pathId The Id of the path being added or removed.
31
+ * @param addedOrRemoved Whether the path was added (`1`) or removed (`-1`).
32
32
  * @category Listener
33
- * @since v5.0.0
33
+ * @since v5.0.3
34
34
  */
35
- export type PathIdsListener<> = (
35
+ export type PathIdsListener = (
36
36
  wsServer: WsServer,
37
- getIdChanges: GetIdChanges,
37
+ pathId: Id,
38
+ addedOrRemoved: IdAddedOrRemoved,
38
39
  ) => void;
39
40
 
40
41
  /**
@@ -43,25 +44,27 @@ export type PathIdsListener<> = (
43
44
  *
44
45
  * A WsServer listens to any path, allowing an app to have the concept of
45
46
  * distinct 'rooms' that only certain clients are participating in. As soon as a
46
- * new client connects to a path, this listener will be called with a
47
- * GetIdChanges callback that you can use to determine its Id.
47
+ * new client connects to a path, this listener will be called with the Id of
48
+ * the path, the Id of the new client, and an `addedOrRemoved` value of `1`.
48
49
  *
49
- * When the client disconnects from a path, it will be called again with a
50
- * GetIdChanges callback that you can again use to determine its Id.
50
+ * When the client disconnects from a path, it will be called again with the Id
51
+ * of the path, the Id of the leaving client, and an `addedOrRemoved` value of
52
+ * `-1`.
51
53
  *
52
54
  * A ClientIdsListener is provided when using the addClientIdsListener method.
53
55
  * See that method for specific examples.
54
56
  * @param wsServer A reference to the WsServer.
55
57
  * @param pathId The path that the client joined or left.
56
- * @param getIdChanges A function that returns information about the client Id
57
- * change.
58
+ * @param clientId The Id of the client being added or removed.
59
+ * @param addedOrRemoved Whether the client was added (`1`) or removed (`-1`).
58
60
  * @category Listener
59
- * @since v5.0.0
61
+ * @since v5.0.3
60
62
  */
61
- export type ClientIdsListener<> = (
63
+ export type ClientIdsListener = (
62
64
  wsServer: WsServer,
63
65
  pathId: Id,
64
- getIdChanges: GetIdChanges,
66
+ clientId: Id,
67
+ addedOrRemoved: IdAddedOrRemoved,
65
68
  ) => void;
66
69
 
67
70
  /**
@@ -240,33 +243,35 @@ export interface WsServer {
240
243
  * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
241
244
  *
242
245
  * const server = createWsServer(new WebSocketServer({port: 8047}));
243
- * const listenerId = server.addPathIdsListener((server, getIdChanges) => {
244
- * console.log(getIdChanges());
245
- * console.log(server.getPathIds());
246
- * });
246
+ * const listenerId = server.addPathIdsListener(
247
+ * (server, pathId, addedOrRemoved) => {
248
+ * console.log(pathId + (addedOrRemoved == 1 ? ' added' : ' removed'));
249
+ * console.log(server.getPathIds());
250
+ * },
251
+ * );
247
252
  *
248
253
  * const synchronizer1 = await createWsSynchronizer(
249
254
  * createMergeableStore(),
250
255
  * new WebSocket('ws://localhost:8047/roomA'),
251
256
  * );
252
- * // -> {'roomA': 1}
257
+ * // -> 'roomA added'
253
258
  * // -> ['roomA']
254
259
  *
255
260
  * const synchronizer2 = await createWsSynchronizer(
256
261
  * createMergeableStore(),
257
262
  * new WebSocket('ws://localhost:8047/roomB'),
258
263
  * );
259
- * // -> {'roomB': 1}
264
+ * // -> 'roomB added'
260
265
  * // -> ['roomA', 'roomB']
261
266
  *
262
267
  * synchronizer1.destroy();
263
268
  * // ...
264
- * // -> {'roomA': -1}
269
+ * // -> 'roomA removed'
265
270
  * // -> ['roomB']
266
271
  *
267
272
  * synchronizer2.destroy();
268
273
  * // ...
269
- * // -> {'roomB': -1}
274
+ * // -> 'roomB removed'
270
275
  * // -> []
271
276
  *
272
277
  * server.delListener(listenerId);
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {Id, IdOrNull, Ids} from '../../../common/with-schemas/index.d.cts';
12
- import type {GetIdChanges} from '../../../store/with-schemas/index.d.cts';
12
+ import type {IdAddedOrRemoved} from '../../../store/with-schemas/index.d.cts';
13
13
  import type {WebSocketServer} from 'ws';
14
14
 
15
15
  /**
@@ -18,23 +18,24 @@ import type {WebSocketServer} from 'ws';
18
18
  *
19
19
  * A WsServer listens to any path, allowing an app to have the concept of
20
20
  * distinct 'rooms' that only certain clients are participating in. As soon as a
21
- * single client connects to a new path, this listener will be called with a
22
- * GetIdChanges callback that you can use to determine its Id.
21
+ * single client connects to a new path, this listener will be called with the
22
+ * Id of the new path and an `addedOrRemoved` value of `1`.
23
23
  *
24
- * When the final client disconnects from a path, it will be called again with a
25
- * GetIdChanges callback that you can again use to determine its Id.
24
+ * When the final client disconnects from a path, it will be called again with
25
+ * the Id of the deactivated path and an `addedOrRemoved` value of `-1`.
26
26
  *
27
27
  * A PathIdsListener is provided when using the addPathIdsListener method. See
28
28
  * that method for specific examples.
29
29
  * @param wsServer A reference to the WsServer.
30
- * @param getIdChanges A function that returns information about the path Id
31
- * change.
30
+ * @param pathId The Id of the path being added or removed.
31
+ * @param addedOrRemoved Whether the path was added (`1`) or removed (`-1`).
32
32
  * @category Listener
33
- * @since v5.0.0
33
+ * @since v5.0.3
34
34
  */
35
- export type PathIdsListener<> = (
35
+ export type PathIdsListener = (
36
36
  wsServer: WsServer,
37
- getIdChanges: GetIdChanges<Id>,
37
+ pathId: Id,
38
+ addedOrRemoved: IdAddedOrRemoved,
38
39
  ) => void;
39
40
 
40
41
  /**
@@ -43,25 +44,27 @@ export type PathIdsListener<> = (
43
44
  *
44
45
  * A WsServer listens to any path, allowing an app to have the concept of
45
46
  * distinct 'rooms' that only certain clients are participating in. As soon as a
46
- * new client connects to a path, this listener will be called with a
47
- * GetIdChanges callback that you can use to determine its Id.
47
+ * new client connects to a path, this listener will be called with the Id of
48
+ * the path, the Id of the new client, and an `addedOrRemoved` value of `1`.
48
49
  *
49
- * When the client disconnects from a path, it will be called again with a
50
- * GetIdChanges callback that you can again use to determine its Id.
50
+ * When the client disconnects from a path, it will be called again with the Id
51
+ * of the path, the Id of the leaving client, and an `addedOrRemoved` value of
52
+ * `-1`.
51
53
  *
52
54
  * A ClientIdsListener is provided when using the addClientIdsListener method.
53
55
  * See that method for specific examples.
54
56
  * @param wsServer A reference to the WsServer.
55
57
  * @param pathId The path that the client joined or left.
56
- * @param getIdChanges A function that returns information about the client Id
57
- * change.
58
+ * @param clientId The Id of the client being added or removed.
59
+ * @param addedOrRemoved Whether the client was added (`1`) or removed (`-1`).
58
60
  * @category Listener
59
- * @since v5.0.0
61
+ * @since v5.0.3
60
62
  */
61
- export type ClientIdsListener<> = (
63
+ export type ClientIdsListener = (
62
64
  wsServer: WsServer,
63
65
  pathId: Id,
64
- getIdChanges: GetIdChanges<Id>,
66
+ clientId: Id,
67
+ addedOrRemoved: IdAddedOrRemoved,
65
68
  ) => void;
66
69
 
67
70
  /**
@@ -240,33 +243,35 @@ export interface WsServer {
240
243
  * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
241
244
  *
242
245
  * const server = createWsServer(new WebSocketServer({port: 8047}));
243
- * const listenerId = server.addPathIdsListener((server, getIdChanges) => {
244
- * console.log(getIdChanges());
245
- * console.log(server.getPathIds());
246
- * });
246
+ * const listenerId = server.addPathIdsListener(
247
+ * (server, pathId, addedOrRemoved) => {
248
+ * console.log(pathId + (addedOrRemoved == 1 ? ' added' : ' removed'));
249
+ * console.log(server.getPathIds());
250
+ * },
251
+ * );
247
252
  *
248
253
  * const synchronizer1 = await createWsSynchronizer(
249
254
  * createMergeableStore(),
250
255
  * new WebSocket('ws://localhost:8047/roomA'),
251
256
  * );
252
- * // -> {'roomA': 1}
257
+ * // -> 'roomA added'
253
258
  * // -> ['roomA']
254
259
  *
255
260
  * const synchronizer2 = await createWsSynchronizer(
256
261
  * createMergeableStore(),
257
262
  * new WebSocket('ws://localhost:8047/roomB'),
258
263
  * );
259
- * // -> {'roomB': 1}
264
+ * // -> 'roomB added'
260
265
  * // -> ['roomA', 'roomB']
261
266
  *
262
267
  * synchronizer1.destroy();
263
268
  * // ...
264
- * // -> {'roomA': -1}
269
+ * // -> 'roomA removed'
265
270
  * // -> ['roomB']
266
271
  *
267
272
  * synchronizer2.destroy();
268
273
  * // ...
269
- * // -> {'roomB': -1}
274
+ * // -> 'roomB removed'
270
275
  * // -> []
271
276
  *
272
277
  * server.delListener(listenerId);
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {Id, IdOrNull, Ids} from '../../../common/with-schemas/index.d.ts';
12
- import type {GetIdChanges} from '../../../store/with-schemas/index.d.ts';
12
+ import type {IdAddedOrRemoved} from '../../../store/with-schemas/index.d.ts';
13
13
  import type {WebSocketServer} from 'ws';
14
14
 
15
15
  /**
@@ -18,23 +18,24 @@ import type {WebSocketServer} from 'ws';
18
18
  *
19
19
  * A WsServer listens to any path, allowing an app to have the concept of
20
20
  * distinct 'rooms' that only certain clients are participating in. As soon as a
21
- * single client connects to a new path, this listener will be called with a
22
- * GetIdChanges callback that you can use to determine its Id.
21
+ * single client connects to a new path, this listener will be called with the
22
+ * Id of the new path and an `addedOrRemoved` value of `1`.
23
23
  *
24
- * When the final client disconnects from a path, it will be called again with a
25
- * GetIdChanges callback that you can again use to determine its Id.
24
+ * When the final client disconnects from a path, it will be called again with
25
+ * the Id of the deactivated path and an `addedOrRemoved` value of `-1`.
26
26
  *
27
27
  * A PathIdsListener is provided when using the addPathIdsListener method. See
28
28
  * that method for specific examples.
29
29
  * @param wsServer A reference to the WsServer.
30
- * @param getIdChanges A function that returns information about the path Id
31
- * change.
30
+ * @param pathId The Id of the path being added or removed.
31
+ * @param addedOrRemoved Whether the path was added (`1`) or removed (`-1`).
32
32
  * @category Listener
33
- * @since v5.0.0
33
+ * @since v5.0.3
34
34
  */
35
- export type PathIdsListener<> = (
35
+ export type PathIdsListener = (
36
36
  wsServer: WsServer,
37
- getIdChanges: GetIdChanges<Id>,
37
+ pathId: Id,
38
+ addedOrRemoved: IdAddedOrRemoved,
38
39
  ) => void;
39
40
 
40
41
  /**
@@ -43,25 +44,27 @@ export type PathIdsListener<> = (
43
44
  *
44
45
  * A WsServer listens to any path, allowing an app to have the concept of
45
46
  * distinct 'rooms' that only certain clients are participating in. As soon as a
46
- * new client connects to a path, this listener will be called with a
47
- * GetIdChanges callback that you can use to determine its Id.
47
+ * new client connects to a path, this listener will be called with the Id of
48
+ * the path, the Id of the new client, and an `addedOrRemoved` value of `1`.
48
49
  *
49
- * When the client disconnects from a path, it will be called again with a
50
- * GetIdChanges callback that you can again use to determine its Id.
50
+ * When the client disconnects from a path, it will be called again with the Id
51
+ * of the path, the Id of the leaving client, and an `addedOrRemoved` value of
52
+ * `-1`.
51
53
  *
52
54
  * A ClientIdsListener is provided when using the addClientIdsListener method.
53
55
  * See that method for specific examples.
54
56
  * @param wsServer A reference to the WsServer.
55
57
  * @param pathId The path that the client joined or left.
56
- * @param getIdChanges A function that returns information about the client Id
57
- * change.
58
+ * @param clientId The Id of the client being added or removed.
59
+ * @param addedOrRemoved Whether the client was added (`1`) or removed (`-1`).
58
60
  * @category Listener
59
- * @since v5.0.0
61
+ * @since v5.0.3
60
62
  */
61
- export type ClientIdsListener<> = (
63
+ export type ClientIdsListener = (
62
64
  wsServer: WsServer,
63
65
  pathId: Id,
64
- getIdChanges: GetIdChanges<Id>,
66
+ clientId: Id,
67
+ addedOrRemoved: IdAddedOrRemoved,
65
68
  ) => void;
66
69
 
67
70
  /**
@@ -240,33 +243,35 @@ export interface WsServer {
240
243
  * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
241
244
  *
242
245
  * const server = createWsServer(new WebSocketServer({port: 8047}));
243
- * const listenerId = server.addPathIdsListener((server, getIdChanges) => {
244
- * console.log(getIdChanges());
245
- * console.log(server.getPathIds());
246
- * });
246
+ * const listenerId = server.addPathIdsListener(
247
+ * (server, pathId, addedOrRemoved) => {
248
+ * console.log(pathId + (addedOrRemoved == 1 ? ' added' : ' removed'));
249
+ * console.log(server.getPathIds());
250
+ * },
251
+ * );
247
252
  *
248
253
  * const synchronizer1 = await createWsSynchronizer(
249
254
  * createMergeableStore(),
250
255
  * new WebSocket('ws://localhost:8047/roomA'),
251
256
  * );
252
- * // -> {'roomA': 1}
257
+ * // -> 'roomA added'
253
258
  * // -> ['roomA']
254
259
  *
255
260
  * const synchronizer2 = await createWsSynchronizer(
256
261
  * createMergeableStore(),
257
262
  * new WebSocket('ws://localhost:8047/roomB'),
258
263
  * );
259
- * // -> {'roomB': 1}
264
+ * // -> 'roomB added'
260
265
  * // -> ['roomA', 'roomB']
261
266
  *
262
267
  * synchronizer1.destroy();
263
268
  * // ...
264
- * // -> {'roomA': -1}
269
+ * // -> 'roomA removed'
265
270
  * // -> ['roomB']
266
271
  *
267
272
  * synchronizer2.destroy();
268
273
  * // ...
269
- * // -> {'roomB': -1}
274
+ * // -> 'roomB removed'
270
275
  * // -> []
271
276
  *
272
277
  * server.delListener(listenerId);
@@ -1 +1 @@
1
- "use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,(()=>({[r]:1}))),x(z,[r],(()=>({[e]:1}))),n.on("message",(n=>{var r;const s=n.toString("utf8"),u=s.indexOf("\n");if(-1!==u){const n=l(s,0,u),d=l(s,u+1);""===n?(o=(n,l)=>n!=e?l.send(e+"\n"+d):0,v(t,((n,e)=>o(e,n)))):null==(r=S(t,n))||r.send(e+"\n"+d)}var o})),n.on("close",(()=>{h(t,e),x(z,[r],(()=>({[e]:-1}))),c(t)&&(h(L,r),x(i,void 0,(()=>({[r]:-1}))))}))}))))}));const C={getWebSocketServer:()=>a,getPathIds:()=>g(L),getClientIds:n=>g(S(L,n)),addPathIdsListener:n=>m(n,i),addClientIdsListener:(n,e)=>m(e,z,[n]),delListener:n=>(A(n),C),getStats:()=>({paths:o(L),clients:d(L)}),destroy:()=>{a.close(),L.clear()}};return u(C)};
1
+ "use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,r,1),x(z,[r],e,1),n.on("message",(n=>{var r;const s=n.toString("utf8"),u=s.indexOf("\n");if(-1!==u){const n=l(s,0,u),d=l(s,u+1);""===n?(o=(n,l)=>n!=e?l.send(e+"\n"+d):0,v(t,((n,e)=>o(e,n)))):null==(r=S(t,n))||r.send(e+"\n"+d)}var o})),n.on("close",(()=>{h(t,e),x(z,[r],e,-1),c(t)&&(h(L,r),x(i,void 0,r,-1))}))}))))}));const C={getWebSocketServer:()=>a,getPathIds:()=>g(L),getClientIds:n=>g(S(L,n)),addPathIdsListener:n=>m(n,i),addClientIdsListener:(n,e)=>m(e,z,[n]),delListener:n=>(A(n),C),getStats:()=>({paths:o(L),clients:d(L)}),destroy:()=>{a.close(),L.clear()}};return u(C)};
@@ -1 +1 @@
1
- "use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,(()=>({[r]:1}))),x(z,[r],(()=>({[e]:1}))),n.on("message",(n=>{var r;const s=n.toString("utf8"),u=s.indexOf("\n");if(-1!==u){const n=l(s,0,u),d=l(s,u+1);""===n?(o=(n,l)=>n!=e?l.send(e+"\n"+d):0,v(t,((n,e)=>o(e,n)))):null==(r=S(t,n))||r.send(e+"\n"+d)}var o})),n.on("close",(()=>{h(t,e),x(z,[r],(()=>({[e]:-1}))),c(t)&&(h(L,r),x(i,void 0,(()=>({[r]:-1}))))}))}))))}));const C={getWebSocketServer:()=>a,getPathIds:()=>g(L),getClientIds:n=>g(S(L,n)),addPathIdsListener:n=>m(n,i),addClientIdsListener:(n,e)=>m(e,z,[n]),delListener:n=>(A(n),C),getStats:()=>({paths:o(L),clients:d(L)}),destroy:()=>{a.close(),L.clear()}};return u(C)};
1
+ "use strict";const n=n=>null==n,e=(e,l,t)=>n(e)?null==t?void 0:t():l(e),l=(n,e,l)=>n.slice(e,l),t=n=>n.length,r=(n,e)=>n.forEach(e),s=(n,...e)=>n.push(...e),u=Object.freeze,o=n=>{var e;return null!=(e=null==n?void 0:n.size)?e:0},d=(a=o,n=>{return e=(n,e)=>n+a(e),i(n).reduce(e,0);var e});var a;const c=e=>n(e)||0==o(e),i=n=>{var e;return[...null!=(e=null==n?void 0:n.values())?e:[]]},v=(n,e)=>null==n?void 0:n.forEach(e),h=(n,e)=>null==n?void 0:n.delete(e),f=n=>new Map(n),g=n=>{var e;return[...null!=(e=null==n?void 0:n.keys())?e:[]]},S=(n,e)=>null==n?void 0:n.get(e),y=(e,l,t)=>n(t)?(h(e,l),e):null==e?void 0:e.set(l,t),k=(n,e,l,t)=>{var r,s,u;return s=e,null!=(u=null==(r=n)?void 0:r.has(s))&&u?null==t||t(S(n,e)):y(n,e,l()),S(n,e)},p=(n,l,r,s,u=0)=>e((r?k:S)(n,l[u],u>t(l)-2?r:f),(e=>{if(u>t(l)-2)return(null==s?void 0:s(e))&&y(n,l[u]),e;const o=p(e,l,r,s,u+1);return c(e)&&y(n,l[u]),o})),I=e=>new Set(Array.isArray(e)||n(e)?e:[e]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=a=>{const i=f(),z=f(),L=f(),[m,x,A]=(l=>{let u;const[o,d]=(()=>{const n=[];let e=0;return[l=>{var t;return null!=(t=l?n.shift():null)?t:""+e++},e=>{b.test(e)&&t(n)<1e3&&s(n,e)}]})(),a=f();return[(n,e,l,t=[],r=(()=>[]))=>{null!=u||(u=C);const s=o(1);var d,c;return y(a,s,[n,e,l,t,r]),c=s,null==(d=p(e,null!=l?l:[""],I))||d.add(c),s},(n,e,...l)=>r(((n,e=[""])=>{const l=[],u=(n,o)=>o==t(e)?s(l,n):null===e[o]?v(n,(n=>u(n,o+1))):r([e[o],null],(e=>u(S(n,e),o+1)));return u(n,0),l})(n,e),(n=>v(n,(n=>S(a,n)[0](u,...null!=e?e:[],...l))))),n=>e(S(a,n),(([,e,l])=>(p(e,null!=l?l:[""],void 0,(e=>(h(e,n),c(e)?1:0))),y(a,n),d(n),l))),l=>e(S(a,l),(([e,,l=[],s,o])=>{const d=(...a)=>{var c,i;const v=t(a);v==t(l)?e(u,...a,...o(a)):n(l[v])?r(null!=(i=null==(c=s[v])?void 0:c.call(s,...a))?i:[],(n=>d(...a,n))):d(...a,l[v])};d()}))]})();a.on("connection",((n,t)=>{var r;return e(null==(r=t.url)?void 0:r.match(w),(([,r])=>e(t.headers["sec-websocket-key"],(e=>{const t=k(L,r,f);y(t,e,n),1==t.size&&x(i,void 0,r,1),x(z,[r],e,1),n.on("message",(n=>{var r;const s=n.toString("utf8"),u=s.indexOf("\n");if(-1!==u){const n=l(s,0,u),d=l(s,u+1);""===n?(o=(n,l)=>n!=e?l.send(e+"\n"+d):0,v(t,((n,e)=>o(e,n)))):null==(r=S(t,n))||r.send(e+"\n"+d)}var o})),n.on("close",(()=>{h(t,e),x(z,[r],e,-1),c(t)&&(h(L,r),x(i,void 0,r,-1))}))}))))}));const C={getWebSocketServer:()=>a,getPathIds:()=>g(L),getClientIds:n=>g(S(L,n)),addPathIdsListener:n=>m(n,i),addClientIdsListener:(n,e)=>m(e,z,[n]),delListener:n=>(A(n),C),getStats:()=>({paths:o(L),clients:d(L)}),destroy:()=>{a.close(),L.clear()}};return u(C)};
@@ -221,9 +221,9 @@ const createWsServer = (webSocketServer) => {
221
221
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
222
222
  mapSet(clients, clientId, webSocket);
223
223
  if (clients.size == 1) {
224
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
224
+ callListeners(pathIdListeners, void 0, pathId, 1);
225
225
  }
226
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
226
+ callListeners(clientIdListeners, [pathId], clientId, 1);
227
227
  webSocket.on('message', (data) => {
228
228
  var _a2;
229
229
  const payload = data.toString(UTF8);
@@ -246,12 +246,10 @@ const createWsServer = (webSocketServer) => {
246
246
  });
247
247
  webSocket.on('close', () => {
248
248
  collDel(clients, clientId);
249
- callListeners(clientIdListeners, [pathId], () => ({
250
- [clientId]: -1,
251
- }));
249
+ callListeners(clientIdListeners, [pathId], clientId, -1);
252
250
  if (collIsEmpty(clients)) {
253
251
  collDel(clientsByPath, pathId);
254
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
252
+ callListeners(pathIdListeners, void 0, pathId, -1);
255
253
  }
256
254
  });
257
255
  }),
@@ -221,9 +221,9 @@ const createWsServer = (webSocketServer) => {
221
221
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
222
222
  mapSet(clients, clientId, webSocket);
223
223
  if (clients.size == 1) {
224
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
224
+ callListeners(pathIdListeners, void 0, pathId, 1);
225
225
  }
226
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
226
+ callListeners(clientIdListeners, [pathId], clientId, 1);
227
227
  webSocket.on('message', (data) => {
228
228
  var _a2;
229
229
  const payload = data.toString(UTF8);
@@ -246,12 +246,10 @@ const createWsServer = (webSocketServer) => {
246
246
  });
247
247
  webSocket.on('close', () => {
248
248
  collDel(clients, clientId);
249
- callListeners(clientIdListeners, [pathId], () => ({
250
- [clientId]: -1,
251
- }));
249
+ callListeners(clientIdListeners, [pathId], clientId, -1);
252
250
  if (collIsEmpty(clients)) {
253
251
  collDel(clientsByPath, pathId);
254
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
252
+ callListeners(pathIdListeners, void 0, pathId, -1);
255
253
  }
256
254
  });
257
255
  }),
@@ -1 +1 @@
1
- "use strict";const e=e=>null==e,t=(t,n,s)=>e(t)?s?.():n(t),n=(e,t,n)=>e.slice(t,n),s=e=>e.length,r=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),o=Object.freeze,a=e=>e?.size??0,d=(l=a,e=>{return t=(e,t)=>e+l(t),u(e).reduce(t,0);var t});var l;const i=t=>e(t)||0==a(t),u=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),f=e=>new Map(e),g=e=>[...e?.keys()??[]],S=(e,t)=>e?.get(t),y=(t,n,s)=>e(s)?(v(t,n),t):t?.set(n,s),k=(e,t,n,s)=>{var r,c;return r=e,c=t,r?.has(c)?s?.(S(e,t)):y(e,t,n()),S(e,t)},p=(e,n,r,c,o=0)=>t((r?k:S)(e,n[o],o>s(n)-2?r:f),(t=>{if(o>s(n)-2)return c?.(t)&&y(e,n[o]),t;const a=p(t,n,r,c,o+1);return i(t)&&y(e,n[o]),a})),I=t=>new Set(Array.isArray(t)||e(t)?t:[t]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=l=>{const u=f(),z=f(),L=f(),[m,x,A]=(n=>{let o;const[a,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{b.test(t)&&s(e)<1e3&&c(e,t)}]})(),l=f();return[(e,t,n,s=[],r=(()=>[]))=>{o??=C;const c=a(1);var d,i;return y(l,c,[e,t,n,s,r]),d=p(t,n??[""],I),i=c,d?.add(i),c},(e,t,...n)=>r(((e,t=[""])=>{const n=[],o=(e,a)=>a==s(t)?c(n,e):null===t[a]?h(e,(e=>o(e,a+1))):r([t[a],null],(t=>o(S(e,t),a+1)));return o(e,0),n})(e,t),(e=>h(e,(e=>S(l,e)[0](o,...t??[],...n))))),e=>t(S(l,e),(([,t,n])=>(p(t,n??[""],void 0,(t=>(v(t,e),i(t)?1:0))),y(l,e),d(e),n))),n=>t(S(l,n),(([t,,n=[],c,a])=>{const d=(...l)=>{const i=s(l);i==s(n)?t(o,...l,...a(l)):e(n[i])?r(c[i]?.(...l)??[],(e=>d(...l,e))):d(...l,n[i])};d()}))]})();l.on("connection",((e,s)=>t(s.url?.match(w),(([,r])=>t(s.headers["sec-websocket-key"],(t=>{const s=k(L,r,f);y(s,t,e),1==s.size&&x(u,void 0,(()=>({[r]:1}))),x(z,[r],(()=>({[t]:1}))),e.on("message",(e=>{const r=e.toString("utf8"),c=r.indexOf("\n");if(-1!==c){const e=n(r,0,c),a=n(r,c+1);""===e?(o=(e,n)=>e!=t?n.send(t+"\n"+a):0,h(s,((e,t)=>o(t,e)))):S(s,e)?.send(t+"\n"+a)}var o})),e.on("close",(()=>{v(s,t),x(z,[r],(()=>({[t]:-1}))),i(s)&&(v(L,r),x(u,void 0,(()=>({[r]:-1}))))}))}))))));const C={getWebSocketServer:()=>l,getPathIds:()=>g(L),getClientIds:e=>g(S(L,e)),addPathIdsListener:e=>m(e,u),addClientIdsListener:(e,t)=>m(t,z,[e]),delListener:e=>(A(e),C),getStats:()=>({paths:a(L),clients:d(L)}),destroy:()=>{l.close(),L.clear()}};return o(C)};
1
+ "use strict";const e=e=>null==e,t=(t,n,s)=>e(t)?s?.():n(t),n=(e,t,n)=>e.slice(t,n),s=e=>e.length,r=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),o=Object.freeze,a=e=>e?.size??0,d=(l=a,e=>{return t=(e,t)=>e+l(t),u(e).reduce(t,0);var t});var l;const i=t=>e(t)||0==a(t),u=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),f=e=>new Map(e),g=e=>[...e?.keys()??[]],S=(e,t)=>e?.get(t),y=(t,n,s)=>e(s)?(v(t,n),t):t?.set(n,s),k=(e,t,n,s)=>{var r,c;return r=e,c=t,r?.has(c)?s?.(S(e,t)):y(e,t,n()),S(e,t)},p=(e,n,r,c,o=0)=>t((r?k:S)(e,n[o],o>s(n)-2?r:f),(t=>{if(o>s(n)-2)return c?.(t)&&y(e,n[o]),t;const a=p(t,n,r,c,o+1);return i(t)&&y(e,n[o]),a})),I=t=>new Set(Array.isArray(t)||e(t)?t:[t]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=l=>{const u=f(),z=f(),L=f(),[m,x,A]=(n=>{let o;const[a,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{b.test(t)&&s(e)<1e3&&c(e,t)}]})(),l=f();return[(e,t,n,s=[],r=(()=>[]))=>{o??=C;const c=a(1);var d,i;return y(l,c,[e,t,n,s,r]),d=p(t,n??[""],I),i=c,d?.add(i),c},(e,t,...n)=>r(((e,t=[""])=>{const n=[],o=(e,a)=>a==s(t)?c(n,e):null===t[a]?h(e,(e=>o(e,a+1))):r([t[a],null],(t=>o(S(e,t),a+1)));return o(e,0),n})(e,t),(e=>h(e,(e=>S(l,e)[0](o,...t??[],...n))))),e=>t(S(l,e),(([,t,n])=>(p(t,n??[""],void 0,(t=>(v(t,e),i(t)?1:0))),y(l,e),d(e),n))),n=>t(S(l,n),(([t,,n=[],c,a])=>{const d=(...l)=>{const i=s(l);i==s(n)?t(o,...l,...a(l)):e(n[i])?r(c[i]?.(...l)??[],(e=>d(...l,e))):d(...l,n[i])};d()}))]})();l.on("connection",((e,s)=>t(s.url?.match(w),(([,r])=>t(s.headers["sec-websocket-key"],(t=>{const s=k(L,r,f);y(s,t,e),1==s.size&&x(u,void 0,r,1),x(z,[r],t,1),e.on("message",(e=>{const r=e.toString("utf8"),c=r.indexOf("\n");if(-1!==c){const e=n(r,0,c),a=n(r,c+1);""===e?(o=(e,n)=>e!=t?n.send(t+"\n"+a):0,h(s,((e,t)=>o(t,e)))):S(s,e)?.send(t+"\n"+a)}var o})),e.on("close",(()=>{v(s,t),x(z,[r],t,-1),i(s)&&(v(L,r),x(u,void 0,r,-1))}))}))))));const C={getWebSocketServer:()=>l,getPathIds:()=>g(L),getClientIds:e=>g(S(L,e)),addPathIdsListener:e=>m(e,u),addClientIdsListener:(e,t)=>m(t,z,[e]),delListener:e=>(A(e),C),getStats:()=>({paths:a(L),clients:d(L)}),destroy:()=>{l.close(),L.clear()}};return o(C)};
@@ -1 +1 @@
1
- "use strict";const e=e=>null==e,t=(t,n,s)=>e(t)?s?.():n(t),n=(e,t,n)=>e.slice(t,n),s=e=>e.length,r=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),o=Object.freeze,a=e=>e?.size??0,d=(l=a,e=>{return t=(e,t)=>e+l(t),u(e).reduce(t,0);var t});var l;const i=t=>e(t)||0==a(t),u=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),f=e=>new Map(e),g=e=>[...e?.keys()??[]],S=(e,t)=>e?.get(t),y=(t,n,s)=>e(s)?(v(t,n),t):t?.set(n,s),k=(e,t,n,s)=>{var r,c;return r=e,c=t,r?.has(c)?s?.(S(e,t)):y(e,t,n()),S(e,t)},p=(e,n,r,c,o=0)=>t((r?k:S)(e,n[o],o>s(n)-2?r:f),(t=>{if(o>s(n)-2)return c?.(t)&&y(e,n[o]),t;const a=p(t,n,r,c,o+1);return i(t)&&y(e,n[o]),a})),I=t=>new Set(Array.isArray(t)||e(t)?t:[t]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=l=>{const u=f(),z=f(),L=f(),[m,x,A]=(n=>{let o;const[a,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{b.test(t)&&s(e)<1e3&&c(e,t)}]})(),l=f();return[(e,t,n,s=[],r=(()=>[]))=>{o??=C;const c=a(1);var d,i;return y(l,c,[e,t,n,s,r]),d=p(t,n??[""],I),i=c,d?.add(i),c},(e,t,...n)=>r(((e,t=[""])=>{const n=[],o=(e,a)=>a==s(t)?c(n,e):null===t[a]?h(e,(e=>o(e,a+1))):r([t[a],null],(t=>o(S(e,t),a+1)));return o(e,0),n})(e,t),(e=>h(e,(e=>S(l,e)[0](o,...t??[],...n))))),e=>t(S(l,e),(([,t,n])=>(p(t,n??[""],void 0,(t=>(v(t,e),i(t)?1:0))),y(l,e),d(e),n))),n=>t(S(l,n),(([t,,n=[],c,a])=>{const d=(...l)=>{const i=s(l);i==s(n)?t(o,...l,...a(l)):e(n[i])?r(c[i]?.(...l)??[],(e=>d(...l,e))):d(...l,n[i])};d()}))]})();l.on("connection",((e,s)=>t(s.url?.match(w),(([,r])=>t(s.headers["sec-websocket-key"],(t=>{const s=k(L,r,f);y(s,t,e),1==s.size&&x(u,void 0,(()=>({[r]:1}))),x(z,[r],(()=>({[t]:1}))),e.on("message",(e=>{const r=e.toString("utf8"),c=r.indexOf("\n");if(-1!==c){const e=n(r,0,c),a=n(r,c+1);""===e?(o=(e,n)=>e!=t?n.send(t+"\n"+a):0,h(s,((e,t)=>o(t,e)))):S(s,e)?.send(t+"\n"+a)}var o})),e.on("close",(()=>{v(s,t),x(z,[r],(()=>({[t]:-1}))),i(s)&&(v(L,r),x(u,void 0,(()=>({[r]:-1}))))}))}))))));const C={getWebSocketServer:()=>l,getPathIds:()=>g(L),getClientIds:e=>g(S(L,e)),addPathIdsListener:e=>m(e,u),addClientIdsListener:(e,t)=>m(t,z,[e]),delListener:e=>(A(e),C),getStats:()=>({paths:a(L),clients:d(L)}),destroy:()=>{l.close(),L.clear()}};return o(C)};
1
+ "use strict";const e=e=>null==e,t=(t,n,s)=>e(t)?s?.():n(t),n=(e,t,n)=>e.slice(t,n),s=e=>e.length,r=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),o=Object.freeze,a=e=>e?.size??0,d=(l=a,e=>{return t=(e,t)=>e+l(t),u(e).reduce(t,0);var t});var l;const i=t=>e(t)||0==a(t),u=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),f=e=>new Map(e),g=e=>[...e?.keys()??[]],S=(e,t)=>e?.get(t),y=(t,n,s)=>e(s)?(v(t,n),t):t?.set(n,s),k=(e,t,n,s)=>{var r,c;return r=e,c=t,r?.has(c)?s?.(S(e,t)):y(e,t,n()),S(e,t)},p=(e,n,r,c,o=0)=>t((r?k:S)(e,n[o],o>s(n)-2?r:f),(t=>{if(o>s(n)-2)return c?.(t)&&y(e,n[o]),t;const a=p(t,n,r,c,o+1);return i(t)&&y(e,n[o]),a})),I=t=>new Set(Array.isArray(t)||e(t)?t:[t]),b=/^\d+$/,w=/\/([^?]*)/;exports.createWsServer=l=>{const u=f(),z=f(),L=f(),[m,x,A]=(n=>{let o;const[a,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{b.test(t)&&s(e)<1e3&&c(e,t)}]})(),l=f();return[(e,t,n,s=[],r=(()=>[]))=>{o??=C;const c=a(1);var d,i;return y(l,c,[e,t,n,s,r]),d=p(t,n??[""],I),i=c,d?.add(i),c},(e,t,...n)=>r(((e,t=[""])=>{const n=[],o=(e,a)=>a==s(t)?c(n,e):null===t[a]?h(e,(e=>o(e,a+1))):r([t[a],null],(t=>o(S(e,t),a+1)));return o(e,0),n})(e,t),(e=>h(e,(e=>S(l,e)[0](o,...t??[],...n))))),e=>t(S(l,e),(([,t,n])=>(p(t,n??[""],void 0,(t=>(v(t,e),i(t)?1:0))),y(l,e),d(e),n))),n=>t(S(l,n),(([t,,n=[],c,a])=>{const d=(...l)=>{const i=s(l);i==s(n)?t(o,...l,...a(l)):e(n[i])?r(c[i]?.(...l)??[],(e=>d(...l,e))):d(...l,n[i])};d()}))]})();l.on("connection",((e,s)=>t(s.url?.match(w),(([,r])=>t(s.headers["sec-websocket-key"],(t=>{const s=k(L,r,f);y(s,t,e),1==s.size&&x(u,void 0,r,1),x(z,[r],t,1),e.on("message",(e=>{const r=e.toString("utf8"),c=r.indexOf("\n");if(-1!==c){const e=n(r,0,c),a=n(r,c+1);""===e?(o=(e,n)=>e!=t?n.send(t+"\n"+a):0,h(s,((e,t)=>o(t,e)))):S(s,e)?.send(t+"\n"+a)}var o})),e.on("close",(()=>{v(s,t),x(z,[r],t,-1),i(s)&&(v(L,r),x(u,void 0,r,-1))}))}))))));const C={getWebSocketServer:()=>l,getPathIds:()=>g(L),getClientIds:e=>g(S(L,e)),addPathIdsListener:e=>m(e,u),addClientIdsListener:(e,t)=>m(t,z,[e]),delListener:e=>(A(e),C),getStats:()=>({paths:a(L),clients:d(L)}),destroy:()=>{l.close(),L.clear()}};return o(C)};