MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / buildWidgetSnippet

Function buildWidgetSnippet

scripts/hsr/widget-code-snippet.mjs:24–41  ·  view source on GitHub ↗
(banner)

Source from the content-addressed store, hash-verified

22}
23
24export function buildWidgetSnippet(banner) {
25 const safeBanner = sanitizeSelfEditBanner(typeof banner === "string" ? banner : FALLBACK_BANNER);
26 return [
27 'import { ui } from "@rezi-ui/core";',
28 "",
29 "// This export is read by scripts/hsr/widget-view.mjs during live HSR swaps.",
30 `export const SELF_EDIT_BANNER = ${JSON.stringify(safeBanner)};`,
31 "",
32 "export function renderHeroTitle() {",
33 " return ui.richText([",
34 ' { text: SELF_EDIT_BANNER, style: { fg: "amber", bold: true } },',
35 ' { text: " Hot State-Preserving Reload Widget Lab", style: { bold: true } },',
36 " ]);",
37 "}",
38 "",
39 "// Save from the demo with F6/Ctrl+O/Ctrl+S or Save button + Enter.",
40 ].join("\n");
41}
42
43export function extractBannerFromSnippet(snippet, fallback = FALLBACK_BANNER) {
44 const source = typeof snippet === "string" ? snippet : "";

Callers 3

widget-app.mjsFile · 0.90
saveBannerToWidgetFileFunction · 0.90

Calls 1

sanitizeSelfEditBannerFunction · 0.90

Tested by

no test coverage detected