@pluv/client 0.44.1 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/client@0.44.1 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@1.0.0 build /home/runner/work/pluv/pluv/packages/client
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 56.50 KB
12
- ESM ⚡️ Build success in 128ms
13
- CJS dist/index.js 57.82 KB
14
- CJS ⚡️ Build success in 129ms
11
+ CJS dist/index.js 58.23 KB
12
+ CJS ⚡️ Build success in 110ms
13
+ ESM dist/index.mjs 56.91 KB
14
+ ESM ⚡️ Build success in 114ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3277ms
17
- DTS dist/index.d.mts 25.36 KB
18
- DTS dist/index.d.ts 25.36 KB
16
+ DTS ⚡️ Build success in 3353ms
17
+ DTS dist/index.d.mts 25.38 KB
18
+ DTS dist/index.d.ts 25.38 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - af94706: pluv.io is now stable and production ready!
8
+
9
+ With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
10
+
11
+ Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [af94706]
16
+ - @pluv/crdt@1.0.0
17
+ - @pluv/types@1.0.0
18
+
19
+ ## 0.44.2
20
+
21
+ ### Patch Changes
22
+
23
+ - 6cfd36f: Update `PluvRoom` to attempt to reconnect if currently disconnected when the window is re-focused.
24
+ - @pluv/crdt@0.44.2
25
+ - @pluv/types@0.44.2
26
+
3
27
  ## 0.44.1
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -228,6 +228,7 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
228
228
  private _onNavigatorOffline;
229
229
  private _onNavigatorOnline;
230
230
  private _onVisibilityChange;
231
+ private _onWindowFocus;
231
232
  private _parseMessage;
232
233
  private _pollReconnect;
233
234
  private _reconnect;
package/dist/index.d.ts CHANGED
@@ -228,6 +228,7 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
228
228
  private _onNavigatorOffline;
229
229
  private _onNavigatorOnline;
230
230
  private _onVisibilityChange;
231
+ private _onWindowFocus;
231
232
  private _parseMessage;
232
233
  private _pollReconnect;
233
234
  private _reconnect;
package/dist/index.js CHANGED
@@ -859,11 +859,13 @@ var PluvRoom = class extends AbstractRoom {
859
859
  this._windowListeners = this._windowListeners || {
860
860
  onNavigatorOffline: this._onNavigatorOffline.bind(this),
861
861
  onNavigatorOnline: this._onNavigatorOnline.bind(this),
862
- onVisibilityChange: this._onVisibilityChange.bind(this)
862
+ onVisibilityChange: this._onVisibilityChange.bind(this),
863
+ onWindowFocus: this._onWindowFocus.bind(this)
863
864
  };
864
865
  window.addEventListener("offline", this._windowListeners.onNavigatorOffline);
865
866
  window.addEventListener("online", this._windowListeners.onNavigatorOnline);
866
867
  document.addEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
868
+ window.addEventListener("focus", this._windowListeners.onWindowFocus);
867
869
  }
868
870
  _attachWsListeners() {
869
871
  if (!this._state.webSocket) return;
@@ -904,8 +906,10 @@ var PluvRoom = class extends AbstractRoom {
904
906
  if (!this._windowListeners) return;
905
907
  if (typeof window === "undefined") return;
906
908
  if (typeof document === "undefined") return;
909
+ window.removeEventListener("offline", this._windowListeners.onNavigatorOffline);
907
910
  window.removeEventListener("online", this._windowListeners.onNavigatorOnline);
908
911
  document.removeEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
912
+ window.removeEventListener("focus", this._windowListeners.onWindowFocus);
909
913
  this._windowListeners = null;
910
914
  }
911
915
  _detachWsListeners() {
@@ -1329,6 +1333,11 @@ var PluvRoom = class extends AbstractRoom {
1329
1333
  }
1330
1334
  });
1331
1335
  }
1336
+ _onWindowFocus() {
1337
+ return __async(this, null, function* () {
1338
+ return yield this._onVisibilityChange();
1339
+ });
1340
+ }
1332
1341
  _parseMessage(message) {
1333
1342
  if (typeof message.data !== "string") return null;
1334
1343
  try {
@@ -1392,8 +1401,8 @@ var PluvRoom = class extends AbstractRoom {
1392
1401
  webSocket: this._state.webSocket
1393
1402
  });
1394
1403
  const newState = updater(oldState);
1395
- this._logDebug("WebSocket new state: ", newState);
1396
1404
  this._state = newState;
1405
+ this._logDebug("WebSocket new state: ", newState);
1397
1406
  this._stateNotifier.subjects.connection.next(newState);
1398
1407
  return newState;
1399
1408
  }
package/dist/index.mjs CHANGED
@@ -828,11 +828,13 @@ var PluvRoom = class extends AbstractRoom {
828
828
  this._windowListeners = this._windowListeners || {
829
829
  onNavigatorOffline: this._onNavigatorOffline.bind(this),
830
830
  onNavigatorOnline: this._onNavigatorOnline.bind(this),
831
- onVisibilityChange: this._onVisibilityChange.bind(this)
831
+ onVisibilityChange: this._onVisibilityChange.bind(this),
832
+ onWindowFocus: this._onWindowFocus.bind(this)
832
833
  };
833
834
  window.addEventListener("offline", this._windowListeners.onNavigatorOffline);
834
835
  window.addEventListener("online", this._windowListeners.onNavigatorOnline);
835
836
  document.addEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
837
+ window.addEventListener("focus", this._windowListeners.onWindowFocus);
836
838
  }
837
839
  _attachWsListeners() {
838
840
  if (!this._state.webSocket) return;
@@ -873,8 +875,10 @@ var PluvRoom = class extends AbstractRoom {
873
875
  if (!this._windowListeners) return;
874
876
  if (typeof window === "undefined") return;
875
877
  if (typeof document === "undefined") return;
878
+ window.removeEventListener("offline", this._windowListeners.onNavigatorOffline);
876
879
  window.removeEventListener("online", this._windowListeners.onNavigatorOnline);
877
880
  document.removeEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
881
+ window.removeEventListener("focus", this._windowListeners.onWindowFocus);
878
882
  this._windowListeners = null;
879
883
  }
880
884
  _detachWsListeners() {
@@ -1298,6 +1302,11 @@ var PluvRoom = class extends AbstractRoom {
1298
1302
  }
1299
1303
  });
1300
1304
  }
1305
+ _onWindowFocus() {
1306
+ return __async(this, null, function* () {
1307
+ return yield this._onVisibilityChange();
1308
+ });
1309
+ }
1301
1310
  _parseMessage(message) {
1302
1311
  if (typeof message.data !== "string") return null;
1303
1312
  try {
@@ -1361,8 +1370,8 @@ var PluvRoom = class extends AbstractRoom {
1361
1370
  webSocket: this._state.webSocket
1362
1371
  });
1363
1372
  const newState = updater(oldState);
1364
- this._logDebug("WebSocket new state: ", newState);
1365
1373
  this._state = newState;
1374
+ this._logDebug("WebSocket new state: ", newState);
1366
1375
  this._stateNotifier.subjects.connection.next(newState);
1367
1376
  return newState;
1368
1377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.44.1",
3
+ "version": "1.0.0",
4
4
  "description": "@pluv/io frontend client",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "wonka": "^6.3.5",
21
- "@pluv/crdt": "^0.44.1",
22
- "@pluv/types": "^0.44.1"
21
+ "@pluv/crdt": "^1.0.0",
22
+ "@pluv/types": "^1.0.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^9.25.1",
26
26
  "tsup": "^8.4.0",
27
27
  "typescript": "^5.8.3",
28
- "@pluv/tsconfig": "^0.44.1",
29
- "eslint-config-pluv": "^0.44.1"
28
+ "@pluv/tsconfig": "^1.0.0",
29
+ "eslint-config-pluv": "^1.0.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/PluvRoom.ts CHANGED
@@ -82,6 +82,7 @@ interface WindowListeners {
82
82
  onNavigatorOffline: () => void;
83
83
  onNavigatorOnline: () => void;
84
84
  onVisibilityChange: () => void;
85
+ onWindowFocus: () => void;
85
86
  }
86
87
 
87
88
  interface WebSocketListeners {
@@ -619,11 +620,13 @@ export class PluvRoom<
619
620
  onNavigatorOffline: this._onNavigatorOffline.bind(this),
620
621
  onNavigatorOnline: this._onNavigatorOnline.bind(this),
621
622
  onVisibilityChange: this._onVisibilityChange.bind(this),
623
+ onWindowFocus: this._onWindowFocus.bind(this),
622
624
  };
623
625
 
624
626
  window.addEventListener("offline", this._windowListeners.onNavigatorOffline);
625
627
  window.addEventListener("online", this._windowListeners.onNavigatorOnline);
626
628
  document.addEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
629
+ window.addEventListener("focus", this._windowListeners.onWindowFocus);
627
630
  }
628
631
 
629
632
  private _attachWsListeners(): void {
@@ -675,8 +678,10 @@ export class PluvRoom<
675
678
  if (typeof window === "undefined") return;
676
679
  if (typeof document === "undefined") return;
677
680
 
681
+ window.removeEventListener("offline", this._windowListeners.onNavigatorOffline);
678
682
  window.removeEventListener("online", this._windowListeners.onNavigatorOnline);
679
683
  document.removeEventListener("visibilitychange", this._windowListeners.onVisibilityChange);
684
+ window.removeEventListener("focus", this._windowListeners.onWindowFocus);
680
685
 
681
686
  this._windowListeners = null;
682
687
  }
@@ -1288,6 +1293,10 @@ export class PluvRoom<
1288
1293
  }
1289
1294
  }
1290
1295
 
1296
+ private async _onWindowFocus(): Promise<void> {
1297
+ return await this._onVisibilityChange();
1298
+ }
1299
+
1291
1300
  private _parseMessage(message: { data: string | ArrayBuffer }): IOEventMessage<TIO> | null {
1292
1301
  /**
1293
1302
  * !HACK
@@ -1395,11 +1404,9 @@ export class PluvRoom<
1395
1404
  };
1396
1405
 
1397
1406
  const newState = updater(oldState);
1398
-
1399
- this._logDebug("WebSocket new state: ", newState);
1400
-
1401
1407
  this._state = newState;
1402
1408
 
1409
+ this._logDebug("WebSocket new state: ", newState);
1403
1410
  this._stateNotifier.subjects.connection.next(newState);
1404
1411
 
1405
1412
  return newState;