@littlepartytime/dev-kit 1.18.0 → 1.18.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.
@@ -10,6 +10,21 @@ const CAPTURE_H = 751; // 844 - 59 - 34
10
10
  *
11
11
  * Also exposed on window.__devkit__.captureScreen() for LLM/Playwright callers:
12
12
  * await page.evaluate(() => window.__devkit__.captureScreen())
13
+ *
14
+ * ## Why onclone?
15
+ * html2canvas clones the entire document before rendering. The PhoneFrame DOM
16
+ * has three CSS properties that break the capture:
17
+ *
18
+ * - `contain: paint` on Screen div and safe-area div — html2canvas uses
19
+ * getBoundingClientRect() to compute clip rects, which returns the *visual*
20
+ * (post-transform) size, clipping the output to ~half height.
21
+ * - `transform: scale(x)` on the phone body — same getBoundingClientRect
22
+ * mismatch; intrinsic size is 390×751 but visual rect is smaller.
23
+ * - `overflow: hidden` on ancestors — once transform is removed, the full-size
24
+ * phone body overflows its scaled wrapper and gets clipped.
25
+ *
26
+ * Fix: in the `onclone` callback, neutralise all three properties on ancestor
27
+ * elements of the *cloned* document. The original DOM is never touched.
13
28
  */
14
29
  export async function captureScreen(): Promise<string> {
15
30
  const el = document.getElementById('devkit-game-screen');
@@ -23,6 +38,18 @@ export async function captureScreen(): Promise<string> {
23
38
  backgroundColor: null,
24
39
  useCORS: true,
25
40
  allowTaint: true,
41
+ onclone: (clonedDoc: Document) => {
42
+ const clonedEl = clonedDoc.getElementById('devkit-game-screen');
43
+ if (!clonedEl) return;
44
+
45
+ let node: HTMLElement | null = clonedEl;
46
+ while (node && node !== clonedDoc.body) {
47
+ node.style.contain = '';
48
+ node.style.transform = 'none';
49
+ node.style.overflow = 'visible';
50
+ node = node.parentElement;
51
+ }
52
+ },
26
53
  });
27
54
 
28
55
  return canvas.toDataURL('image/png');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.18.0",
3
+ "version": "1.18.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",