@littlepartytime/dev-kit 1.22.4-debug.0 → 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,49 +21,20 @@ const gameOuterStyle: React.CSSProperties = {
21
21
  };
22
22
 
23
23
  /**
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.
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).
27
27
  */
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 {
28
+ function useViewportHeight() {
41
29
  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
30
  const initialHeight = useRef(0);
47
31
 
48
32
  useEffect(() => {
49
33
  const vv = window.visualViewport;
50
34
  if (!vv) return;
51
-
52
35
  initialHeight.current = vv.height;
53
-
54
36
  const KEYBOARD_THRESHOLD = 100;
55
-
56
37
  const update = () => {
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
-
67
38
  window.scrollTo(0, 0);
68
39
  const shrunk = initialHeight.current - vv.height;
69
40
  if (shrunk > KEYBOARD_THRESHOLD) {
@@ -72,8 +43,6 @@ function useViewportHeight(): ViewportDebug {
72
43
  setHeight('100dvh');
73
44
  }
74
45
  };
75
-
76
- update();
77
46
  vv.addEventListener('resize', update);
78
47
  vv.addEventListener('scroll', update);
79
48
  return () => {
@@ -82,18 +51,60 @@ function useViewportHeight(): ViewportDebug {
82
51
  };
83
52
  }, []);
84
53
 
85
- return { height, debug };
54
+ return height;
86
55
  }
87
56
 
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
- };
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
+ }
94
102
 
95
103
  export default function Mobile() {
96
- const { height: viewportHeight, debug } = useViewportHeight();
104
+ const viewportHeight = useViewportHeight();
105
+ const containerRef = useRef<HTMLDivElement>(null);
106
+ const outerRef = useRef<HTMLDivElement>(null);
107
+ const sandboxRef = useRef<HTMLDivElement>(null);
97
108
  const [socket, setSocket] = useState<Socket | null>(null);
98
109
  const [nickname, setNickname] = useState('');
99
110
  const [joined, setJoined] = useState(false);
@@ -247,9 +258,9 @@ export default function Mobile() {
247
258
 
248
259
  // Game — mirrors platform container structure
249
260
  return (
250
- <div style={{ ...baseStyle, height: viewportHeight }}>
251
- <div style={gameOuterStyle}>
252
- <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">
253
264
  {gameOver ? (
254
265
  <PlatformTakeover
255
266
  result={gameResult}
@@ -263,10 +274,7 @@ export default function Mobile() {
263
274
  )}
264
275
  </div>
265
276
  </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>
277
+ <DebugOverlay containerRef={containerRef} outerRef={outerRef} sandboxRef={sandboxRef} />
270
278
  </div>
271
279
  );
272
280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.22.4-debug.0",
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",