@base44-preview/vite-plugin 1.0.24-pr.93.c15f29a → 1.0.24-pr.93.fd9637f

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,19 +1,24 @@
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.
1
+ /// <reference types="vite/client" />
2
+ // The on-screen keyboard shrinks the builder's (top-level) visual viewport but not
3
+ // the preview iframe's, so an app inside the iframe can't reflow above the keyboard
4
+ // and leaves a blank gap (the published, top-level app is unaffected). The builder
5
+ // posts the visible height here — { type: "keyboard-viewport", height } — and while
6
+ // the keyboard is open (height > 0) we cap the document / #root / full-height wrappers
7
+ // to it so the layout fits above the keyboard; height 0 releases the cap.
8
+ // Inert until the parent posts; only runs inside the preview iframe.
5
9
  if (window.self !== window.top) {
10
+ const MESSAGE_TYPE = "keyboard-viewport";
6
11
  const HEIGHT_VAR = "--base44-keyboard-viewport-height";
7
12
  const STYLE_ID = "base44-keyboard-viewport-style";
8
- function ensureStyle() {
13
+ const ensureStyle = () => {
9
14
  if (document.getElementById(STYLE_ID))
10
15
  return;
11
16
  const style = document.createElement("style");
12
17
  style.id = STYLE_ID;
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.
18
+ // Active only while HEIGHT_VAR is set on <html> (keyboard open). code_generator
19
+ // gives app roots `min-h-screen`/`h-screen`, so capping those (plus 100vh/100dvh
20
+ // inline styles), the mount node and the document makes the layout fit the
21
+ // visible area and reflow bottom-anchored inputs above the keyboard.
17
22
  style.textContent = [
18
23
  `html[style*="${HEIGHT_VAR}"], html[style*="${HEIGHT_VAR}"] body {`,
19
24
  ` height: var(${HEIGHT_VAR}) !important;`,
@@ -32,19 +37,20 @@ if (window.self !== window.top) {
32
37
  `}`,
33
38
  ].join("\n");
34
39
  document.head.appendChild(style);
35
- }
36
- function apply(height) {
40
+ };
41
+ const apply = (height) => {
42
+ const root = document.documentElement;
37
43
  if (height > 0) {
38
44
  ensureStyle();
39
- document.documentElement.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
45
+ root.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
40
46
  }
41
47
  else {
42
- document.documentElement.style.removeProperty(HEIGHT_VAR);
48
+ root.style.removeProperty(HEIGHT_VAR);
43
49
  }
44
- }
50
+ };
45
51
  window.addEventListener("message", (event) => {
46
52
  const data = event.data;
47
- if (!data || data.type !== "keyboard-viewport" || typeof data.height !== "number")
53
+ if (!data || data.type !== MESSAGE_TYPE || typeof data.height !== "number")
48
54
  return;
49
55
  apply(data.height);
50
56
  });
@@ -1 +1 @@
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,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,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAmB,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAiD,CAAC;QACrE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;YAAE,OAAO;QACnF,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/vite-plugin",
3
- "version": "1.0.24-pr.93.c15f29a",
3
+ "version": "1.0.24-pr.93.fd9637f",
4
4
  "description": "The Vite plugin for base44 based applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,19 +1,25 @@
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.
1
+ /// <reference types="vite/client" />
2
+ // The on-screen keyboard shrinks the builder's (top-level) visual viewport but not
3
+ // the preview iframe's, so an app inside the iframe can't reflow above the keyboard
4
+ // and leaves a blank gap (the published, top-level app is unaffected). The builder
5
+ // posts the visible height here — { type: "keyboard-viewport", height } — and while
6
+ // the keyboard is open (height > 0) we cap the document / #root / full-height wrappers
7
+ // to it so the layout fits above the keyboard; height 0 releases the cap.
8
+ // Inert until the parent posts; only runs inside the preview iframe.
9
+
5
10
  if (window.self !== window.top) {
11
+ const MESSAGE_TYPE = "keyboard-viewport";
6
12
  const HEIGHT_VAR = "--base44-keyboard-viewport-height";
7
13
  const STYLE_ID = "base44-keyboard-viewport-style";
8
14
 
9
- function ensureStyle() {
15
+ const ensureStyle = (): void => {
10
16
  if (document.getElementById(STYLE_ID)) return;
11
17
  const style = document.createElement("style");
12
18
  style.id = STYLE_ID;
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.
19
+ // Active only while HEIGHT_VAR is set on <html> (keyboard open). code_generator
20
+ // gives app roots `min-h-screen`/`h-screen`, so capping those (plus 100vh/100dvh
21
+ // inline styles), the mount node and the document makes the layout fit the
22
+ // visible area and reflow bottom-anchored inputs above the keyboard.
17
23
  style.textContent = [
18
24
  `html[style*="${HEIGHT_VAR}"], html[style*="${HEIGHT_VAR}"] body {`,
19
25
  ` height: var(${HEIGHT_VAR}) !important;`,
@@ -32,20 +38,21 @@ if (window.self !== window.top) {
32
38
  `}`,
33
39
  ].join("\n");
34
40
  document.head.appendChild(style);
35
- }
41
+ };
36
42
 
37
- function apply(height: number) {
43
+ const apply = (height: number): void => {
44
+ const root = document.documentElement;
38
45
  if (height > 0) {
39
46
  ensureStyle();
40
- document.documentElement.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
47
+ root.style.setProperty(HEIGHT_VAR, `${Math.round(height)}px`);
41
48
  } else {
42
- document.documentElement.style.removeProperty(HEIGHT_VAR);
49
+ root.style.removeProperty(HEIGHT_VAR);
43
50
  }
44
- }
51
+ };
45
52
 
46
53
  window.addEventListener("message", (event: MessageEvent) => {
47
- const data = event.data;
48
- if (!data || data.type !== "keyboard-viewport" || typeof data.height !== "number") return;
54
+ const data = event.data as { type?: string; height?: number } | null;
55
+ if (!data || data.type !== MESSAGE_TYPE || typeof data.height !== "number") return;
49
56
  apply(data.height);
50
57
  });
51
58
  }