@base44-preview/vite-plugin 1.0.24-pr.93.2320a2c → 1.0.24-pr.93.c15f29a
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.
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// visible height
|
|
4
|
-
//
|
|
5
|
-
// The on-screen keyboard shrinks the builder's (top-level) visual viewport but
|
|
6
|
-
// NOT the preview iframe's, so the app rendered inside the iframe can't tell it
|
|
7
|
-
// has less room and leaves a blank gap above the keyboard (bottom-anchored
|
|
8
|
-
// inputs end up behind it). The published app doesn't hit this — it's the
|
|
9
|
-
// top-level document, so the browser reflows it for the keyboard.
|
|
10
|
-
//
|
|
11
|
-
// The builder is the only side that sees the keyboard, so it measures the
|
|
12
|
-
// visible height and posts { type: "keyboard-viewport", height }. Here we cap
|
|
13
|
-
// the app's full-height roots to that height while the keyboard is open, so a
|
|
14
|
-
// flex column reflows its content (and its bottom input) above the keyboard.
|
|
15
|
-
//
|
|
16
|
-
// Inert until the parent posts; only runs inside the preview iframe.
|
|
1
|
+
// The keyboard shrinks the builder's top-level visual viewport, not the preview
|
|
2
|
+
// iframe's, so the app inside can't reflow above it and leaves a blank gap. The
|
|
3
|
+
// builder posts the visible height here; while the keyboard is open (height > 0)
|
|
4
|
+
// we cap the app's full-height roots to it so the layout fits above it, 0 releases.
|
|
17
5
|
if (window.self !== window.top) {
|
|
18
|
-
const MESSAGE_TYPE = "keyboard-viewport";
|
|
19
6
|
const HEIGHT_VAR = "--base44-keyboard-viewport-height";
|
|
20
7
|
const STYLE_ID = "base44-keyboard-viewport-style";
|
|
21
|
-
|
|
22
|
-
// below the layout height — filters out no-op / rounding resizes.
|
|
23
|
-
const KEYBOARD_OPEN_MIN_DELTA_PX = 100;
|
|
24
|
-
const ensureStyle = () => {
|
|
8
|
+
function ensureStyle() {
|
|
25
9
|
if (document.getElementById(STYLE_ID))
|
|
26
10
|
return;
|
|
27
11
|
const style = document.createElement("style");
|
|
28
12
|
style.id = STYLE_ID;
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// inline styles) makes the layout fit above the keyboard.
|
|
13
|
+
// Applies only while HEIGHT_VAR is set on <html>. code_generator gives app roots
|
|
14
|
+
// min-h-screen/h-screen, so capping those (+ 100vh/100dvh, #root, the document).
|
|
15
|
+
// !important is required to override inline 100vh/100dvh styles and to win in
|
|
16
|
+
// apps that run Tailwind in important mode — we're overriding arbitrary user CSS.
|
|
34
17
|
style.textContent = [
|
|
35
18
|
`html[style*="${HEIGHT_VAR}"], html[style*="${HEIGHT_VAR}"] body {`,
|
|
36
19
|
` height: var(${HEIGHT_VAR}) !important;`,
|
|
@@ -49,24 +32,19 @@ if (window.self !== window.top) {
|
|
|
49
32
|
`}`,
|
|
50
33
|
].join("\n");
|
|
51
34
|
document.head.appendChild(style);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
height
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// returns to its natural full-height layout.
|
|
61
|
-
root.style.removeProperty(HEIGHT_VAR);
|
|
62
|
-
return;
|
|
35
|
+
}
|
|
36
|
+
function apply(height) {
|
|
37
|
+
if (height > 0) {
|
|
38
|
+
ensureStyle();
|
|
39
|
+
document.documentElement.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
document.documentElement.style.removeProperty(HEIGHT_VAR);
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
root.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
|
|
66
|
-
};
|
|
44
|
+
}
|
|
67
45
|
window.addEventListener("message", (event) => {
|
|
68
46
|
const data = event.data;
|
|
69
|
-
if (!data || data.type !==
|
|
47
|
+
if (!data || data.type !== "keyboard-viewport" || typeof data.height !== "number")
|
|
70
48
|
return;
|
|
71
49
|
apply(data.height);
|
|
72
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-viewport-bridge.js","sourceRoot":"","sources":["../../src/injections/keyboard-viewport-bridge.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"keyboard-viewport-bridge.js","sourceRoot":"","sources":["../../src/injections/keyboard-viewport-bridge.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,oFAAoF;AACpF,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;IAC/B,MAAM,UAAU,GAAG,mCAAmC,CAAC;IACvD,MAAM,QAAQ,GAAG,gCAAgC,CAAC;IAElD,SAAS,WAAW;QAClB,IAAI,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC;YAAE,OAAO;QAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,EAAE,GAAG,QAAQ,CAAC;QACpB,iFAAiF;QACjF,iFAAiF;QACjF,8EAA8E;QAC9E,kFAAkF;QAClF,KAAK,CAAC,WAAW,GAAG;YAClB,gBAAgB,UAAU,oBAAoB,UAAU,WAAW;YACnE,iBAAiB,UAAU,eAAe;YAC1C,qBAAqB,UAAU,eAAe;YAC9C,GAAG;YACH,gBAAgB,UAAU,YAAY;YACtC,iBAAiB,UAAU,eAAe;YAC1C,qBAAqB,UAAU,eAAe;YAC9C,qBAAqB;YACrB,GAAG;YACH,gBAAgB,UAAU,mCAAmC;YAC7D,gBAAgB,UAAU,sBAAsB;YAChD,gBAAgB,UAAU,wBAAwB;YAClD,iBAAiB,UAAU,eAAe;YAC1C,qBAAqB,UAAU,eAAe;YAC9C,GAAG;SACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,KAAK,CAAC,MAAc;QAC3B,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,WAAW,EAAE,CAAC;YACd,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpF,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAmB,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;YAAE,OAAO;QAC1F,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// visible height
|
|
4
|
-
//
|
|
5
|
-
// The on-screen keyboard shrinks the builder's (top-level) visual viewport but
|
|
6
|
-
// NOT the preview iframe's, so the app rendered inside the iframe can't tell it
|
|
7
|
-
// has less room and leaves a blank gap above the keyboard (bottom-anchored
|
|
8
|
-
// inputs end up behind it). The published app doesn't hit this — it's the
|
|
9
|
-
// top-level document, so the browser reflows it for the keyboard.
|
|
10
|
-
//
|
|
11
|
-
// The builder is the only side that sees the keyboard, so it measures the
|
|
12
|
-
// visible height and posts { type: "keyboard-viewport", height }. Here we cap
|
|
13
|
-
// the app's full-height roots to that height while the keyboard is open, so a
|
|
14
|
-
// flex column reflows its content (and its bottom input) above the keyboard.
|
|
15
|
-
//
|
|
16
|
-
// Inert until the parent posts; only runs inside the preview iframe.
|
|
17
|
-
|
|
1
|
+
// The keyboard shrinks the builder's top-level visual viewport, not the preview
|
|
2
|
+
// iframe's, so the app inside can't reflow above it and leaves a blank gap. The
|
|
3
|
+
// builder posts the visible height here; while the keyboard is open (height > 0)
|
|
4
|
+
// we cap the app's full-height roots to it so the layout fits above it, 0 releases.
|
|
18
5
|
if (window.self !== window.top) {
|
|
19
|
-
const MESSAGE_TYPE = "keyboard-viewport";
|
|
20
6
|
const HEIGHT_VAR = "--base44-keyboard-viewport-height";
|
|
21
7
|
const STYLE_ID = "base44-keyboard-viewport-style";
|
|
22
|
-
// Treat the keyboard as open only when the reported height is meaningfully
|
|
23
|
-
// below the layout height — filters out no-op / rounding resizes.
|
|
24
|
-
const KEYBOARD_OPEN_MIN_DELTA_PX = 100;
|
|
25
8
|
|
|
26
|
-
|
|
9
|
+
function ensureStyle() {
|
|
27
10
|
if (document.getElementById(STYLE_ID)) return;
|
|
28
11
|
const style = document.createElement("style");
|
|
29
12
|
style.id = STYLE_ID;
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// inline styles) makes the layout fit above the keyboard.
|
|
13
|
+
// Applies only while HEIGHT_VAR is set on <html>. code_generator gives app roots
|
|
14
|
+
// min-h-screen/h-screen, so capping those (+ 100vh/100dvh, #root, the document).
|
|
15
|
+
// !important is required to override inline 100vh/100dvh styles and to win in
|
|
16
|
+
// apps that run Tailwind in important mode — we're overriding arbitrary user CSS.
|
|
35
17
|
style.textContent = [
|
|
36
18
|
`html[style*="${HEIGHT_VAR}"], html[style*="${HEIGHT_VAR}"] body {`,
|
|
37
19
|
` height: var(${HEIGHT_VAR}) !important;`,
|
|
@@ -50,27 +32,20 @@ if (window.self !== window.top) {
|
|
|
50
32
|
`}`,
|
|
51
33
|
].join("\n");
|
|
52
34
|
document.head.appendChild(style);
|
|
53
|
-
}
|
|
35
|
+
}
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!keyboardOpen) {
|
|
62
|
-
// Keyboard closed (or negligible delta) — release the cap so the app
|
|
63
|
-
// returns to its natural full-height layout.
|
|
64
|
-
root.style.removeProperty(HEIGHT_VAR);
|
|
65
|
-
return;
|
|
37
|
+
function apply(height: number) {
|
|
38
|
+
if (height > 0) {
|
|
39
|
+
ensureStyle();
|
|
40
|
+
document.documentElement.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
|
|
41
|
+
} else {
|
|
42
|
+
document.documentElement.style.removeProperty(HEIGHT_VAR);
|
|
66
43
|
}
|
|
67
|
-
|
|
68
|
-
root.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
|
|
69
|
-
};
|
|
44
|
+
}
|
|
70
45
|
|
|
71
46
|
window.addEventListener("message", (event: MessageEvent) => {
|
|
72
|
-
const data = event.data
|
|
73
|
-
if (!data || data.type !==
|
|
47
|
+
const data = event.data;
|
|
48
|
+
if (!data || data.type !== "keyboard-viewport" || typeof data.height !== "number") return;
|
|
74
49
|
apply(data.height);
|
|
75
50
|
});
|
|
76
51
|
}
|