@littlepartytime/dev-kit 1.22.2 → 1.22.4-debug.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.
@@ -21,23 +21,56 @@ const gameOuterStyle: React.CSSProperties = {
21
21
  };
22
22
 
23
23
  /**
24
- * Track actual visible height via VisualViewport API.
25
- * On iOS Safari, 100dvh does NOT shrink when the keyboard opens (unlike
26
- * PWA/Capacitor where the platform runs). VisualViewport.height gives
27
- * the real available space, achieving the same behavior: game content
28
- * compresses instead of the page being pushed off-screen.
24
+ * Diagnostic: track viewport values for debugging keyboard/layout issues.
25
+ * Shows a small overlay on screen with real-time values.
26
+ * TODO: Remove after debugging is complete.
29
27
  */
30
- function useViewportHeight(): string {
28
+ interface ViewportDebug {
29
+ height: string;
30
+ debug: {
31
+ vvHeight: number;
32
+ vvOffsetTop: number;
33
+ innerHeight: number;
34
+ documentHeight: number;
35
+ scrollY: number;
36
+ rootHeight: number;
37
+ };
38
+ }
39
+
40
+ function useViewportHeight(): ViewportDebug {
31
41
  const [height, setHeight] = useState('100dvh');
42
+ const [debug, setDebug] = useState({
43
+ vvHeight: 0, vvOffsetTop: 0, innerHeight: 0,
44
+ documentHeight: 0, scrollY: 0, rootHeight: 0,
45
+ });
46
+ const initialHeight = useRef(0);
32
47
 
33
48
  useEffect(() => {
34
49
  const vv = window.visualViewport;
35
50
  if (!vv) return;
36
51
 
52
+ initialHeight.current = vv.height;
53
+
54
+ const KEYBOARD_THRESHOLD = 100;
55
+
37
56
  const update = () => {
38
- // Pin to top: counteract Safari scrolling the page up
57
+ const root = document.getElementById('root');
58
+ setDebug({
59
+ vvHeight: Math.round(vv.height),
60
+ vvOffsetTop: Math.round(vv.offsetTop),
61
+ innerHeight: window.innerHeight,
62
+ documentHeight: document.documentElement.clientHeight,
63
+ scrollY: Math.round(window.scrollY),
64
+ rootHeight: root ? root.clientHeight : 0,
65
+ });
66
+
39
67
  window.scrollTo(0, 0);
40
- setHeight(`${vv.height}px`);
68
+ const shrunk = initialHeight.current - vv.height;
69
+ if (shrunk > KEYBOARD_THRESHOLD) {
70
+ setHeight(`${vv.height}px`);
71
+ } else {
72
+ setHeight('100dvh');
73
+ }
41
74
  };
42
75
 
43
76
  update();
@@ -49,11 +82,18 @@ function useViewportHeight(): string {
49
82
  };
50
83
  }, []);
51
84
 
52
- return height;
85
+ return { height, debug };
53
86
  }
54
87
 
88
+ const debugOverlayStyle: React.CSSProperties = {
89
+ position: 'fixed', bottom: 0, left: 0, right: 0,
90
+ background: 'rgba(0,0,0,0.85)', color: '#0f0',
91
+ fontSize: 10, fontFamily: 'monospace', padding: 4,
92
+ zIndex: 99999, pointerEvents: 'none', lineHeight: 1.4,
93
+ };
94
+
55
95
  export default function Mobile() {
56
- const viewportHeight = useViewportHeight();
96
+ const { height: viewportHeight, debug } = useViewportHeight();
57
97
  const [socket, setSocket] = useState<Socket | null>(null);
58
98
  const [nickname, setNickname] = useState('');
59
99
  const [joined, setJoined] = useState(false);
@@ -205,10 +245,7 @@ export default function Mobile() {
205
245
  );
206
246
  }
207
247
 
208
- // Game — mirrors platform container structure:
209
- // div.h-[100dvh].flex.flex-col.overflow-hidden (root)
210
- // div.flex-1.min-h-0.overflow-y-auto (game outer)
211
- // div.game-sandbox (safe area padding)
248
+ // Game — mirrors platform container structure
212
249
  return (
213
250
  <div style={{ ...baseStyle, height: viewportHeight }}>
214
251
  <div style={gameOuterStyle}>
@@ -226,6 +263,10 @@ export default function Mobile() {
226
263
  )}
227
264
  </div>
228
265
  </div>
266
+ {/* DEBUG: viewport diagnostic overlay — remove after fixing */}
267
+ <div style={debugOverlayStyle}>
268
+ container: {viewportHeight} | vv: {debug.vvHeight} | vvOff: {debug.vvOffsetTop} | inner: {debug.innerHeight} | doc: {debug.documentHeight} | scrollY: {debug.scrollY} | root: {debug.rootHeight}
269
+ </div>
229
270
  </div>
230
271
  );
231
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.22.2",
3
+ "version": "1.22.4-debug.0",
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",