@mondaydotcomorg/z2h-cli 0.12.0 → 0.13.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -38,9 +38,9 @@ When a request needs data, follow `z2h:coding-standards-mf` §0: write a `runQue
38
38
  - This folder is **standalone** — not part of any monorepo, no git initialized.
39
39
  - `src/index.tsx` default-exports the React component the host MF loads.
40
40
  - `package.json` wires the `z2h-cli` for `build` / `start` / `deploy`.
41
- - `.zth/` is an auto-generated shadow workspace — never edit it by hand; `npx z2h-cli clean` wipes it.
42
- - Local dev: `npx z2h-cli dev` → opens at `https://bigbrain.me/bigbrain-vibe/<app>?zth_local=<port>`.
43
- - Production: `npx z2h-cli deploy` → live at `https://bigbrain.me/bigbrain-vibe/<app>`.
41
+ - `.zth/` is an auto-generated shadow workspace — never edit it by hand; `z2h-cli clean` wipes it.
42
+ - Local dev: `z2h-cli dev` → opens at `https://bigbrain.me/bigbrain-vibe/<app>?zth_local=<port>`.
43
+ - Production: `z2h-cli deploy` → live at `https://bigbrain.me/bigbrain-vibe/<app>`.
44
44
  - There is no git, no PR, no CI. The gate is: lint pass → typecheck pass → user previews and approves.
45
45
 
46
46
  ---
@@ -54,8 +54,8 @@ Apps are **private by default** — only you can view them. After the first depl
54
54
  To change visibility at any time:
55
55
 
56
56
  ```
57
- npx z2h-cli grant --public # open to all monday.com employees
58
- npx z2h-cli revoke --public # back to private
57
+ z2h-cli grant --public # open to all monday.com employees
58
+ z2h-cli revoke --public # back to private
59
59
  ```
60
60
 
61
61
  ---
@@ -1,18 +1,30 @@
1
- // HTML-embed entrypoint. Renders src/page.html in an iframe, with the file
2
- // imported via Vite's `?url` suffix so Vite's dev server hosts it at
3
- // /src/page.html (and copies it to /assets/ at build time). Same-origin
4
- // (the URL lives under whatever host is rendering the app), so the page's
5
- // fetch() calls carry bigbrain.me auth cookies normally.
6
- //
7
- // The iframe gives the page its own document — scripts execute natively,
8
- // CSS/JS is fully isolated from the host React app, no script reinjection
9
- // logic needed.
10
- import React from 'react';
1
+ import React, { useRef, useEffect } from 'react';
2
+ import { getBigBrainAPI } from '@mondaydotcomorg/trident-runtime';
11
3
  import pageUrl from './page.html?url';
12
4
 
5
+ const BACKEND_SUBDOMAIN = 'bigbrain-zth';
6
+
7
+ function getBackendBaseUrl(): string | null {
8
+ const base = getBigBrainAPI()?.contextService?.bigbrainBaseUrl;
9
+ return base ? base.replace('//', `//${BACKEND_SUBDOMAIN}.`) : null;
10
+ }
11
+
13
12
  export default function __APP_COMPONENT__() {
13
+ const iframeRef = useRef<HTMLIFrameElement>(null);
14
+ useEffect(() => {
15
+ const handleMessage = (event: MessageEvent) => {
16
+ if (!iframeRef.current || event.source !== iframeRef.current.contentWindow) return;
17
+ if (event.data?.type !== 'z2h:getConfig') return;
18
+ const baseUrl = getBackendBaseUrl();
19
+ if (!baseUrl) return;
20
+ (event.source as Window).postMessage({ type: 'z2h:config', baseUrl }, event.origin);
21
+ };
22
+ window.addEventListener('message', handleMessage);
23
+ return () => window.removeEventListener('message', handleMessage);
24
+ }, []);
14
25
  return (
15
26
  <iframe
27
+ ref={iframeRef}
16
28
  src={pageUrl}
17
29
  title="App"
18
30
  style={{ width: '100vw', height: '100vh', border: 'none', display: 'block' }}