@littlepartytime/dev-kit 1.22.3 → 1.22.4-debug.1

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,39 +21,28 @@ const gameOuterStyle: React.CSSProperties = {
21
21
  };
22
22
 
23
23
  /**
24
- * Track actual visible height via VisualViewport API.
25
- *
26
- * On iOS Safari (non-PWA), 100dvh does NOT shrink when the keyboard opens.
27
- * We use visualViewport.height to detect the keyboard and override the
28
- * container height only while it's open. When the keyboard closes, we
29
- * revert to 100dvh so Safari toolbar/address bar changes don't leave
30
- * a dead zone at the bottom.
24
+ * Diagnostic hook TODO: remove after debugging.
25
+ * Uses VisualViewport to detect keyboard and switch between
26
+ * pixel height (keyboard open) and 100dvh (keyboard closed).
31
27
  */
32
- function useViewportHeight(): string {
28
+ function useViewportHeight() {
33
29
  const [height, setHeight] = useState('100dvh');
34
30
  const initialHeight = useRef(0);
35
31
 
36
32
  useEffect(() => {
37
33
  const vv = window.visualViewport;
38
34
  if (!vv) return;
39
-
40
- // Capture the full viewport height on first load (no keyboard)
41
35
  initialHeight.current = vv.height;
42
-
43
- const KEYBOARD_THRESHOLD = 100; // px — if viewport shrinks by more than this, keyboard is open
44
-
36
+ const KEYBOARD_THRESHOLD = 100;
45
37
  const update = () => {
46
38
  window.scrollTo(0, 0);
47
39
  const shrunk = initialHeight.current - vv.height;
48
40
  if (shrunk > KEYBOARD_THRESHOLD) {
49
- // Keyboard is open: use exact pixel height so content compresses
50
41
  setHeight(`${vv.height}px`);
51
42
  } else {
52
- // Keyboard is closed: use 100dvh to fill the screen fully
53
43
  setHeight('100dvh');
54
44
  }
55
45
  };
56
-
57
46
  vv.addEventListener('resize', update);
58
47
  vv.addEventListener('scroll', update);
59
48
  return () => {
@@ -65,8 +54,57 @@ function useViewportHeight(): string {
65
54
  return height;
66
55
  }
67
56
 
57
+ /**
58
+ * Debug overlay that measures each container layer on every render.
59
+ * Ref-based: reads computed sizes of actual DOM elements.
60
+ */
61
+ function DebugOverlay({ containerRef, outerRef, sandboxRef }: {
62
+ containerRef: React.RefObject<HTMLDivElement | null>;
63
+ outerRef: React.RefObject<HTMLDivElement | null>;
64
+ sandboxRef: React.RefObject<HTMLDivElement | null>;
65
+ }) {
66
+ const [info, setInfo] = useState('');
67
+
68
+ useEffect(() => {
69
+ const measure = () => {
70
+ const c = containerRef.current;
71
+ const o = outerRef.current;
72
+ const s = sandboxRef.current;
73
+ const gameEl = s?.firstElementChild as HTMLElement | null;
74
+ const vv = window.visualViewport;
75
+
76
+ const lines = [
77
+ `vv:${vv ? Math.round(vv.height) : '?'} inner:${window.innerHeight} scrollY:${Math.round(window.scrollY)}`,
78
+ `container:${c?.clientHeight ?? '?'} computedH:${c ? getComputedStyle(c).height : '?'}`,
79
+ `outer:${o?.clientHeight ?? '?'} scrollTop:${o?.scrollTop ?? '?'} scrollH:${o?.scrollHeight ?? '?'}`,
80
+ `sandbox:${s?.clientHeight ?? '?'} game1st:${gameEl?.clientHeight ?? '?'}`,
81
+ ];
82
+ setInfo(lines.join('\n'));
83
+ };
84
+
85
+ measure();
86
+ const id = setInterval(measure, 500);
87
+ return () => clearInterval(id);
88
+ }, [containerRef, outerRef, sandboxRef]);
89
+
90
+ return (
91
+ <div style={{
92
+ position: 'fixed', bottom: 0, left: 0, right: 0,
93
+ background: 'rgba(0,0,0,0.85)', color: '#0f0',
94
+ fontSize: 10, fontFamily: 'monospace', padding: 4,
95
+ zIndex: 99999, pointerEvents: 'none', lineHeight: 1.4,
96
+ whiteSpace: 'pre',
97
+ }}>
98
+ {info}
99
+ </div>
100
+ );
101
+ }
102
+
68
103
  export default function Mobile() {
69
104
  const viewportHeight = useViewportHeight();
105
+ const containerRef = useRef<HTMLDivElement>(null);
106
+ const outerRef = useRef<HTMLDivElement>(null);
107
+ const sandboxRef = useRef<HTMLDivElement>(null);
70
108
  const [socket, setSocket] = useState<Socket | null>(null);
71
109
  const [nickname, setNickname] = useState('');
72
110
  const [joined, setJoined] = useState(false);
@@ -218,14 +256,11 @@ export default function Mobile() {
218
256
  );
219
257
  }
220
258
 
221
- // Game — mirrors platform container structure:
222
- // div.h-[100dvh].flex.flex-col.overflow-hidden (root)
223
- // div.flex-1.min-h-0.overflow-y-auto (game outer)
224
- // div.game-sandbox (safe area padding)
259
+ // Game — mirrors platform container structure
225
260
  return (
226
- <div style={{ ...baseStyle, height: viewportHeight }}>
227
- <div style={gameOuterStyle}>
228
- <div className="game-sandbox">
261
+ <div ref={containerRef} style={{ ...baseStyle, height: viewportHeight }}>
262
+ <div ref={outerRef} style={gameOuterStyle}>
263
+ <div ref={sandboxRef} className="game-sandbox">
229
264
  {gameOver ? (
230
265
  <PlatformTakeover
231
266
  result={gameResult}
@@ -239,6 +274,7 @@ export default function Mobile() {
239
274
  )}
240
275
  </div>
241
276
  </div>
277
+ <DebugOverlay containerRef={containerRef} outerRef={outerRef} sandboxRef={sandboxRef} />
242
278
  </div>
243
279
  );
244
280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.22.3",
3
+ "version": "1.22.4-debug.1",
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",