@littlepartytime/dev-kit 1.15.0 → 1.15.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.
@@ -19,6 +19,8 @@ export default function Play() {
19
19
 
20
20
  const isAutoMode = useMemo(() => new URLSearchParams(window.location.search).get('auto') === 'true', []);
21
21
  const [myPlayerId, setMyPlayerId] = useState<string | null>(null);
22
+ // Ref survives React Fast Refresh (HMR) but not new tabs — perfect for reconnect identity
23
+ const assignedNicknameRef = useRef<string | null>(null);
22
24
 
23
25
  // Load renderer
24
26
  useEffect(() => {
@@ -28,10 +30,15 @@ export default function Play() {
28
30
  }, []);
29
31
 
30
32
  // Auto-join: connect immediately with server-assigned name
33
+ // assignedNicknameRef persists across HMR (React Refresh keeps refs) but resets per new tab
31
34
  useEffect(() => {
32
35
  if (!isAutoMode) return;
33
36
 
34
- const sock = io('http://localhost:4001', { query: { auto: 'true' } });
37
+ const query = assignedNicknameRef.current
38
+ ? { nickname: assignedNicknameRef.current }
39
+ : { auto: 'true' };
40
+
41
+ const sock = io('http://localhost:4001', { query });
35
42
 
36
43
  sock.on('connect', () => {
37
44
  setMyId(sock.id);
@@ -41,6 +48,7 @@ export default function Play() {
41
48
  sock.on('player:assigned', ({ id, nickname: assignedName }: { id: string; nickname: string }) => {
42
49
  setMyPlayerId(id);
43
50
  setNickname(assignedName);
51
+ assignedNicknameRef.current = assignedName;
44
52
  });
45
53
 
46
54
  sock.on('room:update', (r: any) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "description": "Development toolkit CLI for Little Party Time game developers",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",