@intentius/behold 0.29.27 → 0.29.28

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/dist/cli.js CHANGED
@@ -18492,9 +18492,9 @@ function cardFaces(ir, boxes, opts = {}) {
18492
18492
  ])
18493
18493
  )
18494
18494
  };
18495
- const restore = (svg) => back.size === 0 ? svg : svg.replace(new RegExp(`(${ID_ATTRS.join("|")})="([^"]*)"`, "g"), (whole, attr, value) => {
18495
+ const restore = (svg) => back.size === 0 ? svg : svg.replace(new RegExp(`(${ID_ATTRS.join("|")})="([^"]*)"`, "g"), (whole, attr2, value) => {
18496
18496
  const real = back.get(value);
18497
- return real === void 0 ? whole : `${attr}="${real}"`;
18497
+ return real === void 0 ? whole : `${attr2}="${real}"`;
18498
18498
  }).replaceAll(INVISIBLE, "");
18499
18499
  return { ir: displayIr, overrides, display: minted, restore };
18500
18500
  }
@@ -25880,16 +25880,79 @@ function terragucciDemoRoute(app, source2, opts = {}) {
25880
25880
  return c.json(a, "error" in a ? 502 : 200, { "cache-control": "no-store" });
25881
25881
  });
25882
25882
  }
25883
- var disabledPage = `<!doctype html><meta charset=utf-8><title>behold kiosk</title><script type="module">import { initTheme } from "/theme.js"; initTheme();</script><body style="font:16px system-ui;background:var(--bg,#1e1e2e);color:var(--fg,#cdd6f4);padding:2rem"><h3>The kiosk follows a terragucci demo</h3><p style="color:var(--muted,#777a8c)">Start behold with <code>--terragucci &lt;reports source&gt;</code>; the kiosk reads <code>demo.json</code> there.</p></body>`;
25884
- function kioskRoute(app, webRoot2, enabled) {
25883
+ var disabledPage = `<!doctype html><meta charset=utf-8><title>behold \xB7 live demo</title><script type="module">import { initTheme } from "/theme.js"; initTheme();</script><body style="font:16px system-ui;background:var(--bg,#1e1e2e);color:var(--fg,#cdd6f4);padding:2rem"><h3>The kiosk follows a terragucci demo</h3><p style="color:var(--muted,#777a8c)">Start behold with <code>--terragucci &lt;reports source&gt;</code>; the kiosk reads <code>demo.json</code> there.</p></body>`;
25884
+ function kioskRoute(app, webRoot2, enabled, allowedHosts = []) {
25885
25885
  app.get("/kiosk", (c) => {
25886
25886
  if (!enabled) {
25887
25887
  return c.html(disabledPage, 404);
25888
25888
  }
25889
- return new Response(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25889
+ const html = sharePage(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), {
25890
+ title: "behold \xB7 live demo",
25891
+ description: "Watch one change go from pull request to apply across real Terraform states.",
25892
+ origin: shareOrigin(c.req.header("host"), c.req.header("x-forwarded-proto"), allowedHosts),
25893
+ path: "/kiosk"
25894
+ });
25895
+ return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25896
+ });
25897
+ }
25898
+ var SHARE_IMAGE = {
25899
+ path: "/share.png",
25900
+ width: 1200,
25901
+ height: 630,
25902
+ alt: "The pixel behold logo above the word BEHOLD and the line: a live infrastructure loop you can watch."
25903
+ };
25904
+ var SHARE_IMAGE_MAX_AGE_SECS = 86400;
25905
+ function shareOrigin(host, forwardedProto, allowedHosts) {
25906
+ if (!host) return void 0;
25907
+ const m = /^([a-z0-9.-]+)(:\d{1,5})?$/.exec(host.trim().toLowerCase());
25908
+ if (!m) return void 0;
25909
+ const name = m[1];
25910
+ if (!allowedHosts.some((h) => hostName(h) === name)) return void 0;
25911
+ const proto = (forwardedProto ?? "").split(",")[0].trim().toLowerCase() === "https" ? "https" : "http";
25912
+ return `${proto}://${name}${m[2] ?? ""}`;
25913
+ }
25914
+ var attr = (v) => v.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
25915
+ function sharePage(html, p) {
25916
+ const tags = [
25917
+ ["property", "og:type", "website"],
25918
+ ["property", "og:site_name", "behold"],
25919
+ ["property", "og:title", p.title],
25920
+ ["property", "og:description", p.description],
25921
+ ["name", "description", p.description],
25922
+ ["name", "twitter:card", "summary_large_image"],
25923
+ ["name", "twitter:title", p.title],
25924
+ ["name", "twitter:description", p.description]
25925
+ ];
25926
+ if (p.origin) {
25927
+ const image = `${p.origin}${SHARE_IMAGE.path}`;
25928
+ tags.push(
25929
+ ["property", "og:url", `${p.origin}${p.path}`],
25930
+ ["property", "og:image", image],
25931
+ ["property", "og:image:type", "image/png"],
25932
+ ["property", "og:image:width", String(SHARE_IMAGE.width)],
25933
+ ["property", "og:image:height", String(SHARE_IMAGE.height)],
25934
+ ["property", "og:image:alt", SHARE_IMAGE.alt],
25935
+ ["name", "twitter:image", image],
25936
+ ["name", "twitter:image:alt", SHARE_IMAGE.alt]
25937
+ );
25938
+ }
25939
+ const head = [`<title>${attr(p.title)}</title>`, ...tags.map(([k, n, v]) => `<meta ${k}="${n}" content="${attr(v)}" />`)].join("\n ");
25940
+ return html.replace(/<title>[^<]*<\/title>/, () => head);
25941
+ }
25942
+ function shareImageRoute(app, webRoot2) {
25943
+ app.get(SHARE_IMAGE.path, () => {
25944
+ const png = readFileSync32(join43(webRoot2, "share.png"));
25945
+ return new Response(new Uint8Array(png), { headers: { "content-type": "image/png", "cache-control": `public, max-age=${SHARE_IMAGE_MAX_AGE_SECS}` } });
25890
25946
  });
25891
25947
  }
25892
25948
  var VENDOR_TOOLS = ["terraform", "terragrunt", "cdk-terrain", "choudoufu", "chant"];
25949
+ var VENDOR_NAMES = {
25950
+ terraform: "Terraform",
25951
+ terragrunt: "Terragrunt",
25952
+ "cdk-terrain": "CDK Terrain",
25953
+ choudoufu: "choudoufu",
25954
+ chant: "chant"
25955
+ };
25893
25956
  var isVendorTool = (v) => VENDOR_TOOLS.includes(v);
25894
25957
  var cycleKey = (tool) => `cycles/${tool}/latest.json`;
25895
25958
  var CYCLE_READ_TTL_MS = 1e4;
@@ -25962,11 +26025,18 @@ function vendorPage(html, tool) {
25962
26025
  return html.replace(/<meta charset="utf-8" \/>/, `<meta charset="utf-8" />
25963
26026
  <meta name="kiosk-tool" content="${tool}" />`);
25964
26027
  }
25965
- function vendorRoutes(app, webRoot2, enabled) {
26028
+ function vendorRoutes(app, webRoot2, enabled, allowedHosts = []) {
25966
26029
  for (const tool of VENDOR_TOOLS) {
25967
26030
  app.get(`/${tool}`, (c) => {
25968
26031
  if (!enabled) return c.html(disabledPage, 404);
25969
- const html = vendorPage(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), tool);
26032
+ const name = VENDOR_NAMES[tool];
26033
+ const shared2 = sharePage(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), {
26034
+ title: `behold \xB7 ${name}`,
26035
+ description: `Watch ${name} carry one change from pull request to apply, live.`,
26036
+ origin: shareOrigin(c.req.header("host"), c.req.header("x-forwarded-proto"), allowedHosts),
26037
+ path: `/${tool}`
26038
+ });
26039
+ const html = vendorPage(shared2, tool);
25970
26040
  return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25971
26041
  });
25972
26042
  }
@@ -28417,10 +28487,11 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28417
28487
  };
28418
28488
  const estateSourceRoots = async (opts) => (await Promise.all((cfg.projectDirs ?? []).map(async (dir) => [await graphPath(dir, opts), dir]))).flat();
28419
28489
  app.get("/healthz", (c) => c.json({ ok: true, projectDir: cfg.projectDir, env: cfg.env ?? null, frames: frames.size }));
28420
- kioskRoute(app, webRoot, !!cfg.terragucci);
28490
+ kioskRoute(app, webRoot, !!cfg.terragucci, guard.allowedHosts);
28491
+ shareImageRoute(app, webRoot);
28421
28492
  const doraSource = cfg.terragucci && cfg.prometheus ? terragucciSource(cfg.terragucci.source, { ...cfg.terragucci.aws ? { aws: cfg.terragucci.aws } : {}, ...cfg.terragucci.fetch ? { fetch: cfg.terragucci.fetch } : {} }) : void 0;
28422
28493
  metricsRoute(app, { ...cfg.prometheus ? { prometheus: cfg.prometheus } : {}, ...doraSource ? { doraFile: () => doraSource.read("dora.json") } : {} });
28423
- vendorRoutes(app, webRoot, !!cfg.terragucci);
28494
+ vendorRoutes(app, webRoot, !!cfg.terragucci, guard.allowedHosts);
28424
28495
  app.get("/api/frames", (c) => c.json({ frames: frames.summaries() }));
28425
28496
  app.get("/lanes", (c) => {
28426
28497
  const all = frames.all();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.27",
3
+ "version": "0.29.28",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
package/web/kiosk.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>behold kiosk</title>
6
+ <title>behold · live demo</title>
7
7
  <link
8
8
  rel="icon"
9
9
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6' fill='none' stroke='%23a6adc8' stroke-width='1.6'/%3E%3Ccircle cx='8' cy='8' r='2.2' fill='%23a6adc8'/%3E%3C/svg%3E"
package/web/kiosk.js CHANGED
@@ -895,7 +895,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
895
895
  s.replay = null;
896
896
  s.repo = null;
897
897
  s.live = null;
898
- if (vendor && typeof document !== "undefined") document.title = `${vendor.name} · terragucci demo`;
898
+ if (vendor && typeof document !== "undefined") document.title = `behold · ${vendor.name}`;
899
899
  /** The time the page shows: the replay's, while it replays. */
900
900
  const shownNow = () => (s.mode === "replay" && s.replay && s.replay.at ? s.replay.at : now());
901
901
  /** behold#571: the frame and the plan's facts are the served repo's, so a tool's page shows them only for its own repo. */
package/web/share.png ADDED
Binary file