@hadoku/rooms-client 0.45.66 → 0.45.67

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 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,UAAU,EAAuB,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAmBlI;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAyCpH"}
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,UAAU,EAAuB,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAmBlI;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAsDpH"}
package/dist/react.js CHANGED
@@ -45,13 +45,26 @@ export function useRoomList(target, deps) {
45
45
  };
46
46
  }
47
47
  const client = clientRef.current.client;
48
+ // Close on unmount FOR GOOD, never on the cleanup React runs between two
49
+ // mounts. StrictMode (every dev build) mounts, cleans up and mounts again
50
+ // with the SAME render result: closing here at once aborted the first fetch
51
+ // and left the remount holding a dead client, so the lobby sat on "Loading
52
+ // rooms…" forever in dev and in every local E2E (home.spec, ui.spec and the
53
+ // TV lobby, red on main from c58f9e77 to this fix). The close is deferred a
54
+ // task; a remount cancels it. A key change closes the old client in render,
55
+ // above, so nothing here depends on the timer for that.
56
+ const pendingClose = useRef(null);
48
57
  useEffect(() => {
49
- // The ref above may already have rebuilt the client between renders (a
50
- // key change during render); this effect's only job is to close whatever
51
- // is CURRENT when the component unmounts for good.
58
+ if (pendingClose.current !== null) {
59
+ clearTimeout(pendingClose.current);
60
+ pendingClose.current = null;
61
+ }
52
62
  return () => {
53
- if (clientRef.current?.client === client)
54
- client.close();
63
+ pendingClose.current = setTimeout(() => {
64
+ pendingClose.current = null;
65
+ if (clientRef.current?.client === client)
66
+ client.close();
67
+ }, 0);
55
68
  };
56
69
  }, [client]);
57
70
  const state = useSyncExternalStore(client ? client.subscribe : noopSubscribe, () => (client ? client.getState() : EMPTY_STATE));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/rooms-client",
3
- "version": "0.45.66",
4
- "gitHead": "3fe154b62d74336adcf289cc956f7ae10f74bc25",
3
+ "version": "0.45.67",
4
+ "gitHead": "399291480e0b456476e04926380dd3a5154ef7ed",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Browser-side room feed client: follow a room (or the room list) without polling for it.",
@@ -27,7 +27,7 @@
27
27
  "directory": "packages/rooms-client"
28
28
  },
29
29
  "dependencies": {
30
- "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@0.45.66"
30
+ "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@0.45.67"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18",