@pluv/client 0.9.2 → 0.10.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.
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +12 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +8 -8
- package/src/PluvRoom.ts +49 -47
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@0.
|
|
2
|
+
> @pluv/client@0.10.0 build /home/runner/work/pluv/pluv/packages/client
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v7.
|
|
7
|
+
[34mCLI[39m tsup v7.2.0
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m39.21 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 139ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m40.42 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 139ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4296ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m13.18 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.18 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f43f1cc: Change packages to all be versioned together for consistency.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [f43f1cc]
|
|
12
|
+
- @pluv/crdt-yjs@0.10.0
|
|
13
|
+
- @pluv/types@0.10.0
|
|
14
|
+
|
|
3
15
|
## 0.9.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -532,6 +532,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
532
532
|
});
|
|
533
533
|
yield this._storageStore.initialize();
|
|
534
534
|
yield this._applyStorageStore();
|
|
535
|
+
console.log(this._getWsEndpoint(this.id));
|
|
535
536
|
const url = new URL(this._getWsEndpoint(this.id));
|
|
536
537
|
let authToken = null;
|
|
537
538
|
let webSocket;
|
package/dist/index.mjs
CHANGED
|
@@ -506,6 +506,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
506
506
|
});
|
|
507
507
|
yield this._storageStore.initialize();
|
|
508
508
|
yield this._applyStorageStore();
|
|
509
|
+
console.log(this._getWsEndpoint(this.id));
|
|
509
510
|
const url = new URL(this._getWsEndpoint(this.id));
|
|
510
511
|
let authToken = null;
|
|
511
512
|
let webSocket;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "@pluv/io frontend client",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/react": "^18.2.
|
|
21
|
-
"wonka": "^6.3.
|
|
22
|
-
"@pluv/crdt-yjs": "^0.
|
|
23
|
-
"@pluv/types": "^0.
|
|
20
|
+
"@types/react": "^18.2.20",
|
|
21
|
+
"wonka": "^6.3.4",
|
|
22
|
+
"@pluv/crdt-yjs": "^0.10.0",
|
|
23
|
+
"@pluv/types": "^0.10.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"yjs": "^13.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"tsup": "^7.
|
|
29
|
+
"tsup": "^7.2.0",
|
|
30
30
|
"typescript": "^5.1.6",
|
|
31
31
|
"yjs": "^13.6.7",
|
|
32
|
-
"@pluv/tsconfig": "^0.
|
|
33
|
-
"eslint-config-pluv": "^0.
|
|
32
|
+
"@pluv/tsconfig": "^0.10.0",
|
|
33
|
+
"eslint-config-pluv": "^0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/PluvRoom.ts
CHANGED
|
@@ -49,9 +49,9 @@ const Y_ORIGIN_INITIALIZED = "$INITIALIZED";
|
|
|
49
49
|
export const DEFAULT_PLUV_CLIENT_ADDON = <
|
|
50
50
|
TIO extends IOLike = IOLike,
|
|
51
51
|
TPresence extends JsonObject = {},
|
|
52
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
52
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
53
53
|
>(
|
|
54
|
-
input: PluvRoomAddonInput<TIO, TPresence, TStorage
|
|
54
|
+
input: PluvRoomAddonInput<TIO, TPresence, TStorage>,
|
|
55
55
|
): PluvRoomAddonResult => ({
|
|
56
56
|
storage: new StorageStore(input.room.id),
|
|
57
57
|
});
|
|
@@ -106,15 +106,15 @@ interface InternalListeners {
|
|
|
106
106
|
export type PluvRoomAddon<
|
|
107
107
|
TIO extends IOLike = IOLike,
|
|
108
108
|
TPresence extends JsonObject = {},
|
|
109
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
109
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
110
110
|
> = (
|
|
111
|
-
input: PluvRoomAddonInput<TIO, TPresence, TStorage
|
|
111
|
+
input: PluvRoomAddonInput<TIO, TPresence, TStorage>,
|
|
112
112
|
) => Partial<PluvRoomAddonResult>;
|
|
113
113
|
|
|
114
114
|
export interface PluvRoomAddonInput<
|
|
115
115
|
TIO extends IOLike = IOLike,
|
|
116
116
|
TPresence extends JsonObject = {},
|
|
117
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
117
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
118
118
|
> {
|
|
119
119
|
room: PluvRoom<TIO, TPresence, TStorage>;
|
|
120
120
|
}
|
|
@@ -131,7 +131,7 @@ export type PluvRoomDebug<TIO extends IOLike> = Id<{
|
|
|
131
131
|
export type PluvRoomOptions<
|
|
132
132
|
TIO extends IOLike,
|
|
133
133
|
TPresence extends JsonObject = {},
|
|
134
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
134
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
135
135
|
> = {
|
|
136
136
|
addons?: readonly PluvRoomAddon<TIO, TPresence, TStorage>[];
|
|
137
137
|
debug?: boolean | PluvRoomDebug<TIO>;
|
|
@@ -142,13 +142,13 @@ export type PluvRoomOptions<
|
|
|
142
142
|
export type RoomConfig<
|
|
143
143
|
TIO extends IOLike,
|
|
144
144
|
TPresence extends JsonObject = {},
|
|
145
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
145
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
146
146
|
> = RoomEndpoints<TIO> & PluvRoomOptions<TIO, TPresence, TStorage>;
|
|
147
147
|
|
|
148
148
|
export class PluvRoom<
|
|
149
149
|
TIO extends IOLike,
|
|
150
150
|
TPresence extends JsonObject = {},
|
|
151
|
-
TStorage extends Record<string, AbstractType<any>> = {}
|
|
151
|
+
TStorage extends Record<string, AbstractType<any>> = {},
|
|
152
152
|
> extends AbstractRoom<TIO, TPresence, TStorage> {
|
|
153
153
|
readonly _endpoints: RoomEndpoints<TIO>;
|
|
154
154
|
|
|
@@ -218,7 +218,7 @@ export class PluvRoom<
|
|
|
218
218
|
this._clearTimeout(this._timeouts.reconnect);
|
|
219
219
|
this._timeouts.reconnect = setTimeout(
|
|
220
220
|
this._reconnect.bind(this),
|
|
221
|
-
RECONNECT_TIMEOUT_MS
|
|
221
|
+
RECONNECT_TIMEOUT_MS,
|
|
222
222
|
);
|
|
223
223
|
|
|
224
224
|
onAuthorizationFail?.(error);
|
|
@@ -239,7 +239,7 @@ export class PluvRoom<
|
|
|
239
239
|
|
|
240
240
|
public broadcast<TEvent extends keyof InferIOInput<TIO>>(
|
|
241
241
|
event: TEvent,
|
|
242
|
-
data: Id<InferIOInput<TIO>[TEvent]
|
|
242
|
+
data: Id<InferIOInput<TIO>[TEvent]>,
|
|
243
243
|
): void {
|
|
244
244
|
if (!this._state.webSocket) return;
|
|
245
245
|
if (this._state.connection.state !== ConnectionState.Open) return;
|
|
@@ -272,6 +272,8 @@ export class PluvRoom<
|
|
|
272
272
|
await this._storageStore.initialize();
|
|
273
273
|
await this._applyStorageStore();
|
|
274
274
|
|
|
275
|
+
console.log(this._getWsEndpoint(this.id));
|
|
276
|
+
|
|
275
277
|
const url = new URL(this._getWsEndpoint(this.id));
|
|
276
278
|
|
|
277
279
|
let authToken: string | null = null;
|
|
@@ -330,7 +332,7 @@ export class PluvRoom<
|
|
|
330
332
|
|
|
331
333
|
public event = <TEvent extends keyof InferIOOutput<TIO>>(
|
|
332
334
|
event: TEvent,
|
|
333
|
-
callback: EventNotifierSubscriptionCallback<TIO, TEvent
|
|
335
|
+
callback: EventNotifierSubscriptionCallback<TIO, TEvent>,
|
|
334
336
|
): (() => void) => {
|
|
335
337
|
return this._eventNotifier.subscribe(event, callback);
|
|
336
338
|
};
|
|
@@ -338,7 +340,7 @@ export class PluvRoom<
|
|
|
338
340
|
public getConnection(): WebSocketConnection {
|
|
339
341
|
// Create a read-only clone of the connection state
|
|
340
342
|
return Object.freeze(
|
|
341
|
-
JSON.parse(JSON.stringify(this._state.connection))
|
|
343
|
+
JSON.parse(JSON.stringify(this._state.connection)),
|
|
342
344
|
);
|
|
343
345
|
}
|
|
344
346
|
|
|
@@ -351,7 +353,7 @@ export class PluvRoom<
|
|
|
351
353
|
};
|
|
352
354
|
|
|
353
355
|
public getOther = (
|
|
354
|
-
connectionId: string
|
|
356
|
+
connectionId: string,
|
|
355
357
|
): Id<UserInfo<TIO, TPresence>> | null => {
|
|
356
358
|
return this._usersManager.getOther(connectionId);
|
|
357
359
|
};
|
|
@@ -361,30 +363,30 @@ export class PluvRoom<
|
|
|
361
363
|
};
|
|
362
364
|
|
|
363
365
|
public getStorage = <TKey extends keyof TStorage>(
|
|
364
|
-
key: TKey
|
|
366
|
+
key: TKey,
|
|
365
367
|
): TStorage[TKey] | null => {
|
|
366
368
|
return this._crdtManager?.get(key) ?? null;
|
|
367
369
|
};
|
|
368
370
|
|
|
369
371
|
public other = (
|
|
370
372
|
connectionId: string,
|
|
371
|
-
callback: OtherNotifierSubscriptionCallback<TIO
|
|
373
|
+
callback: OtherNotifierSubscriptionCallback<TIO>,
|
|
372
374
|
): (() => void) => {
|
|
373
375
|
return this._otherNotifier.subscribe(connectionId, callback);
|
|
374
376
|
};
|
|
375
377
|
|
|
376
378
|
public storage = <TKey extends keyof TStorage>(
|
|
377
379
|
key: TKey,
|
|
378
|
-
fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void
|
|
380
|
+
fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void,
|
|
379
381
|
): (() => void) => {
|
|
380
382
|
return this._crdtNotifier.subscribe(key, fn);
|
|
381
383
|
};
|
|
382
384
|
|
|
383
385
|
public subscribe = <
|
|
384
|
-
TSubject extends keyof StateNotifierSubjects<TIO, TPresence
|
|
386
|
+
TSubject extends keyof StateNotifierSubjects<TIO, TPresence>,
|
|
385
387
|
>(
|
|
386
388
|
name: TSubject,
|
|
387
|
-
callback: SubscriptionCallback<TIO, TPresence, TSubject
|
|
389
|
+
callback: SubscriptionCallback<TIO, TPresence, TSubject>,
|
|
388
390
|
): (() => void) => {
|
|
389
391
|
return this._stateNotifier.subscribe(name, callback);
|
|
390
392
|
};
|
|
@@ -400,7 +402,7 @@ export class PluvRoom<
|
|
|
400
402
|
|
|
401
403
|
this.broadcast(
|
|
402
404
|
"$UPDATE_PRESENCE" as keyof InferIOInput<TIO>,
|
|
403
|
-
{ presence } as any
|
|
405
|
+
{ presence } as any,
|
|
404
406
|
);
|
|
405
407
|
};
|
|
406
408
|
|
|
@@ -435,11 +437,11 @@ export class PluvRoom<
|
|
|
435
437
|
|
|
436
438
|
window.addEventListener(
|
|
437
439
|
"online",
|
|
438
|
-
this._windowListeners.onNavigatorOnline
|
|
440
|
+
this._windowListeners.onNavigatorOnline,
|
|
439
441
|
);
|
|
440
442
|
document.addEventListener(
|
|
441
443
|
"visibilitychange",
|
|
442
|
-
this._windowListeners.onVisibilityChange
|
|
444
|
+
this._windowListeners.onVisibilityChange,
|
|
443
445
|
);
|
|
444
446
|
}
|
|
445
447
|
|
|
@@ -455,19 +457,19 @@ export class PluvRoom<
|
|
|
455
457
|
|
|
456
458
|
this._state.webSocket.addEventListener(
|
|
457
459
|
"close",
|
|
458
|
-
this._wsListeners.onClose
|
|
460
|
+
this._wsListeners.onClose,
|
|
459
461
|
);
|
|
460
462
|
this._state.webSocket.addEventListener(
|
|
461
463
|
"error",
|
|
462
|
-
this._wsListeners.onError
|
|
464
|
+
this._wsListeners.onError,
|
|
463
465
|
);
|
|
464
466
|
this._state.webSocket.addEventListener(
|
|
465
467
|
"message",
|
|
466
|
-
this._wsListeners.onMessage
|
|
468
|
+
this._wsListeners.onMessage,
|
|
467
469
|
);
|
|
468
470
|
this._state.webSocket.addEventListener(
|
|
469
471
|
"open",
|
|
470
|
-
this._wsListeners.onOpen
|
|
472
|
+
this._wsListeners.onOpen,
|
|
471
473
|
);
|
|
472
474
|
}
|
|
473
475
|
|
|
@@ -495,7 +497,7 @@ export class PluvRoom<
|
|
|
495
497
|
this._usersManager.removeMyself();
|
|
496
498
|
|
|
497
499
|
const canClose = [WebSocket.CONNECTING, WebSocket.OPEN].some(
|
|
498
|
-
(readyState) => readyState === this._state.webSocket?.readyState
|
|
500
|
+
(readyState) => readyState === this._state.webSocket?.readyState,
|
|
499
501
|
);
|
|
500
502
|
|
|
501
503
|
if (canClose) this._state.webSocket.close();
|
|
@@ -510,11 +512,11 @@ export class PluvRoom<
|
|
|
510
512
|
|
|
511
513
|
window.removeEventListener(
|
|
512
514
|
"online",
|
|
513
|
-
this._windowListeners.onNavigatorOnline
|
|
515
|
+
this._windowListeners.onNavigatorOnline,
|
|
514
516
|
);
|
|
515
517
|
document.removeEventListener(
|
|
516
518
|
"visibilitychange",
|
|
517
|
-
this._windowListeners.onVisibilityChange
|
|
519
|
+
this._windowListeners.onVisibilityChange,
|
|
518
520
|
);
|
|
519
521
|
|
|
520
522
|
this._windowListeners = null;
|
|
@@ -525,19 +527,19 @@ export class PluvRoom<
|
|
|
525
527
|
|
|
526
528
|
this._state.webSocket.removeEventListener(
|
|
527
529
|
"close",
|
|
528
|
-
this._wsListeners.onClose
|
|
530
|
+
this._wsListeners.onClose,
|
|
529
531
|
);
|
|
530
532
|
this._state.webSocket.removeEventListener(
|
|
531
533
|
"error",
|
|
532
|
-
this._wsListeners.onError
|
|
534
|
+
this._wsListeners.onError,
|
|
533
535
|
);
|
|
534
536
|
this._state.webSocket.removeEventListener(
|
|
535
537
|
"message",
|
|
536
|
-
this._wsListeners.onMessage
|
|
538
|
+
this._wsListeners.onMessage,
|
|
537
539
|
);
|
|
538
540
|
this._state.webSocket.removeEventListener(
|
|
539
541
|
"open",
|
|
540
|
-
this._wsListeners.onOpen
|
|
542
|
+
this._wsListeners.onOpen,
|
|
541
543
|
);
|
|
542
544
|
|
|
543
545
|
this._wsListeners = null;
|
|
@@ -567,18 +569,18 @@ export class PluvRoom<
|
|
|
567
569
|
|
|
568
570
|
await this._storageStore.flatten(encodedState);
|
|
569
571
|
},
|
|
570
|
-
{ wait: ADD_TO_STORAGE_STATE_DEBOUNCE_MS }
|
|
572
|
+
{ wait: ADD_TO_STORAGE_STATE_DEBOUNCE_MS },
|
|
571
573
|
);
|
|
572
574
|
|
|
573
575
|
private _getAddon = (
|
|
574
|
-
addons: readonly PluvRoomAddon<TIO, TPresence, TStorage>[]
|
|
576
|
+
addons: readonly PluvRoomAddon<TIO, TPresence, TStorage>[],
|
|
575
577
|
): PluvRoomAddon<TIO, TPresence, TStorage> => {
|
|
576
578
|
return addons.reduce<PluvRoomAddon<TIO, TPresence, TStorage>>(
|
|
577
579
|
(acc, addon) => () => ({
|
|
578
580
|
...acc({ room: this }),
|
|
579
581
|
...addon({ room: this }),
|
|
580
582
|
}),
|
|
581
|
-
DEFAULT_PLUV_CLIENT_ADDON
|
|
583
|
+
DEFAULT_PLUV_CLIENT_ADDON,
|
|
582
584
|
);
|
|
583
585
|
};
|
|
584
586
|
|
|
@@ -623,7 +625,7 @@ export class PluvRoom<
|
|
|
623
625
|
return await res.text().then((text) => text.trim());
|
|
624
626
|
} catch (err) {
|
|
625
627
|
throw new Error(
|
|
626
|
-
err instanceof Error ? err.message : "Room is unauthorized"
|
|
628
|
+
err instanceof Error ? err.message : "Room is unauthorized",
|
|
627
629
|
);
|
|
628
630
|
}
|
|
629
631
|
}
|
|
@@ -668,7 +670,7 @@ export class PluvRoom<
|
|
|
668
670
|
|
|
669
671
|
this._usersManager.patchPresence(
|
|
670
672
|
connectionId,
|
|
671
|
-
data.presence as TPresence
|
|
673
|
+
data.presence as TPresence,
|
|
672
674
|
);
|
|
673
675
|
|
|
674
676
|
const myPresence = this._usersManager.myPresence;
|
|
@@ -709,7 +711,7 @@ export class PluvRoom<
|
|
|
709
711
|
!!presence &&
|
|
710
712
|
this._usersManager.patchPresence(
|
|
711
713
|
connectionId,
|
|
712
|
-
presence as TPresence
|
|
714
|
+
presence as TPresence,
|
|
713
715
|
);
|
|
714
716
|
|
|
715
717
|
this._otherNotifier.subject(connectionId).next(other);
|
|
@@ -737,7 +739,7 @@ export class PluvRoom<
|
|
|
737
739
|
|
|
738
740
|
this._usersManager.setMyself(
|
|
739
741
|
connectionId,
|
|
740
|
-
user as Id<InferIOAuthorizeUser<InferIOAuthorize<TIO
|
|
742
|
+
user as Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>,
|
|
741
743
|
);
|
|
742
744
|
|
|
743
745
|
const presence = this._usersManager.myPresence;
|
|
@@ -758,7 +760,7 @@ export class PluvRoom<
|
|
|
758
760
|
}
|
|
759
761
|
|
|
760
762
|
private async _handleStorageReceivedMessage(
|
|
761
|
-
message: IOEventMessage<TIO
|
|
763
|
+
message: IOEventMessage<TIO>,
|
|
762
764
|
): Promise<void> {
|
|
763
765
|
const { connectionId } = message;
|
|
764
766
|
|
|
@@ -839,7 +841,7 @@ export class PluvRoom<
|
|
|
839
841
|
this._usersManager.setUser(
|
|
840
842
|
connectionId,
|
|
841
843
|
data.user,
|
|
842
|
-
data.presence as TPresence
|
|
844
|
+
data.presence as TPresence,
|
|
843
845
|
);
|
|
844
846
|
|
|
845
847
|
const other = this._usersManager.getOther(connectionId);
|
|
@@ -853,7 +855,7 @@ export class PluvRoom<
|
|
|
853
855
|
this._clearTimeout(this._timeouts.pong);
|
|
854
856
|
this._timeouts.pong = setTimeout(
|
|
855
857
|
this._reconnect.bind(this),
|
|
856
|
-
PONG_TIMEOUT_MS
|
|
858
|
+
PONG_TIMEOUT_MS,
|
|
857
859
|
);
|
|
858
860
|
|
|
859
861
|
this._sendMessage({ type: "$PING", data: {} });
|
|
@@ -890,7 +892,7 @@ export class PluvRoom<
|
|
|
890
892
|
type: "$UPDATE_STORAGE",
|
|
891
893
|
data: { origin, update },
|
|
892
894
|
});
|
|
893
|
-
}
|
|
895
|
+
},
|
|
894
896
|
);
|
|
895
897
|
|
|
896
898
|
this._subscriptions.observeCrdt = unsubscribe;
|
|
@@ -1015,7 +1017,7 @@ export class PluvRoom<
|
|
|
1015
1017
|
this._clearInterval(this._intervals.heartbeat);
|
|
1016
1018
|
this._intervals.heartbeat = setInterval(
|
|
1017
1019
|
this._heartbeat.bind(this),
|
|
1018
|
-
HEARTBEAT_INTERVAL_MS
|
|
1020
|
+
HEARTBEAT_INTERVAL_MS,
|
|
1019
1021
|
);
|
|
1020
1022
|
}
|
|
1021
1023
|
|
|
@@ -1090,7 +1092,7 @@ export class PluvRoom<
|
|
|
1090
1092
|
}
|
|
1091
1093
|
|
|
1092
1094
|
private _sendMessage<
|
|
1093
|
-
TMessage extends EventMessage<string, any> = EventMessage<string, any
|
|
1095
|
+
TMessage extends EventMessage<string, any> = EventMessage<string, any>,
|
|
1094
1096
|
>(data: TMessage): void {
|
|
1095
1097
|
const webSocket = this._state.webSocket;
|
|
1096
1098
|
|
|
@@ -1109,13 +1111,13 @@ export class PluvRoom<
|
|
|
1109
1111
|
}
|
|
1110
1112
|
|
|
1111
1113
|
private _updateState(
|
|
1112
|
-
updater: (oldState: WebSocketState<TIO>) => WebSocketState<TIO
|
|
1114
|
+
updater: (oldState: WebSocketState<TIO>) => WebSocketState<TIO>,
|
|
1113
1115
|
): WebSocketState<TIO> {
|
|
1114
1116
|
let authorization: AuthorizationState<TIO>;
|
|
1115
1117
|
|
|
1116
1118
|
try {
|
|
1117
1119
|
authorization = JSON.parse(
|
|
1118
|
-
JSON.stringify(this._state.authorization)
|
|
1120
|
+
JSON.stringify(this._state.authorization),
|
|
1119
1121
|
);
|
|
1120
1122
|
} catch {
|
|
1121
1123
|
throw new Error("User is not JSON serializable");
|