@tenphi/renderer 0.26.0 → 0.28.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.
@@ -0,0 +1,16 @@
1
+ //#region src/client/preview-height.d.ts
2
+ /**
3
+ * The message a scripted preview frame and its page exchange. The frame's
4
+ * reporter (preview-document.ts) posts `{ type, height }` with its content
5
+ * height; the page posts `{ type }` to ask for the height again.
6
+ */
7
+ declare const PREVIEW_HEIGHT_MESSAGE = "cookbook:preview-height";
8
+ /**
9
+ * Size each preview frame to the height its document reports plus the frame's
10
+ * `data-buffer` length, a validated CSS length. The frame's `min-height` and
11
+ * `max-height` clamp the value, so this only sets `height`.
12
+ */
13
+ declare function initializePreviewHeight(): void;
14
+ //#endregion
15
+ export { PREVIEW_HEIGHT_MESSAGE, initializePreviewHeight };
16
+ //# sourceMappingURL=preview-height.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-height.d.ts","names":[],"sources":["../../src/client/preview-height.ts"],"mappings":";;;;;;cAKa;;;;;;iBAUG"}
@@ -0,0 +1,31 @@
1
+ //#region src/client/preview-height.ts
2
+ /**
3
+ * The message a scripted preview frame and its page exchange. The frame's
4
+ * reporter (preview-document.ts) posts `{ type, height }` with its content
5
+ * height; the page posts `{ type }` to ask for the height again.
6
+ */
7
+ const PREVIEW_HEIGHT_MESSAGE = "cookbook:preview-height";
8
+ const previewFrames = () => document.querySelectorAll("[data-element=Preview] iframe");
9
+ /**
10
+ * Size each preview frame to the height its document reports plus the frame's
11
+ * `data-buffer` length, a validated CSS length. The frame's `min-height` and
12
+ * `max-height` clamp the value, so this only sets `height`.
13
+ */
14
+ function initializePreviewHeight() {
15
+ addEventListener("message", resizePreviewFrame);
16
+ for (const frame of previewFrames()) frame.contentWindow?.postMessage({ type: PREVIEW_HEIGHT_MESSAGE }, "*");
17
+ }
18
+ function resizePreviewFrame({ data, source }) {
19
+ const height = data?.type === "cookbook:preview-height" && data.height;
20
+ if (typeof height !== "number" || !Number.isFinite(height) || height < 0) return;
21
+ for (const frame of previewFrames()) if (frame.contentWindow === source) {
22
+ const content = `${Math.ceil(height)}px`;
23
+ const { buffer } = frame.dataset;
24
+ frame.style.height = buffer ? `calc(${content} + ${buffer})` : content;
25
+ return;
26
+ }
27
+ }
28
+ //#endregion
29
+ export { PREVIEW_HEIGHT_MESSAGE, initializePreviewHeight };
30
+
31
+ //# sourceMappingURL=preview-height.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-height.js","names":[],"sources":["../../src/client/preview-height.ts"],"sourcesContent":["/**\n * The message a scripted preview frame and its page exchange. The frame's\n * reporter (preview-document.ts) posts `{ type, height }` with its content\n * height; the page posts `{ type }` to ask for the height again.\n */\nexport const PREVIEW_HEIGHT_MESSAGE = \"cookbook:preview-height\";\n\nconst previewFrames = () =>\n document.querySelectorAll<HTMLIFrameElement>(\"[data-element=Preview] iframe\");\n\n/**\n * Size each preview frame to the height its document reports plus the frame's\n * `data-buffer` length, a validated CSS length. The frame's `min-height` and\n * `max-height` clamp the value, so this only sets `height`.\n */\nexport function initializePreviewHeight(): void {\n addEventListener(\"message\", resizePreviewFrame);\n // Frames usually load and report before this deferred module runs.\n for (const frame of previewFrames())\n frame.contentWindow?.postMessage({ type: PREVIEW_HEIGHT_MESSAGE }, \"*\");\n}\n\nfunction resizePreviewFrame({ data, source }: MessageEvent): void {\n const height: unknown = data?.type === PREVIEW_HEIGHT_MESSAGE && data.height;\n if (typeof height !== \"number\" || !Number.isFinite(height) || height < 0)\n return;\n for (const frame of previewFrames())\n if (frame.contentWindow === source) {\n const content = `${Math.ceil(height)}px`;\n const { buffer } = frame.dataset;\n frame.style.height = buffer ? `calc(${content} + ${buffer})` : content;\n return;\n }\n}\n"],"mappings":";;;;;;AAKA,MAAa,yBAAyB;AAEtC,MAAM,sBACJ,SAAS,iBAAoC,+BAA+B;;;;;;AAO9E,SAAgB,0BAAgC;CAC9C,iBAAiB,WAAW,kBAAkB;CAE9C,KAAK,MAAM,SAAS,cAAc,GAChC,MAAM,eAAe,YAAY,EAAE,MAAM,uBAAuB,GAAG,GAAG;AAC1E;AAEA,SAAS,mBAAmB,EAAE,MAAM,UAA8B;CAChE,MAAM,SAAkB,MAAM,SAAA,6BAAmC,KAAK;CACtE,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,SAAS,MAAM,KAAK,SAAS,GACrE;CACF,KAAK,MAAM,SAAS,cAAc,GAChC,IAAI,MAAM,kBAAkB,QAAQ;EAClC,MAAM,UAAU,GAAG,KAAK,KAAK,MAAM,EAAE;EACrC,MAAM,EAAE,WAAW,MAAM;EACzB,MAAM,MAAM,SAAS,SAAS,QAAQ,QAAQ,KAAK,OAAO,KAAK;EAC/D;CACF;AACJ"}
@@ -2,7 +2,7 @@
2
2
  import { messages, requestLanguage } from "../localization.js";
3
3
  import { buildPreview } from "../preview-document.js";
4
4
  import { content } from "virtual:cookbook/config";
5
- import { PreviewRoot } from "./Preview.styles.js";
5
+ import { PreviewRoot, previewHeightStyles } from "./Preview.styles.js";
6
6
 
7
7
  import type { PreviewProps as Props } from "./props.js";
8
8
 
@@ -18,13 +18,19 @@ const ui = messages(
18
18
  );
19
19
  ---
20
20
 
21
- <PreviewRoot className="td-preview" data-not-content="" aria-label={title}>
21
+ <PreviewRoot
22
+ className="td-preview"
23
+ data-not-content=""
24
+ aria-label={title}
25
+ styles={preview.height && previewHeightStyles(preview.height)}
26
+ >
22
27
  <PreviewRoot.Caption><strong>{title}</strong></PreviewRoot.Caption>
23
28
  <PreviewRoot.Stage>
24
29
  <PreviewRoot.Frame
25
30
  title={title}
26
31
  sandbox={preview.sandbox}
27
32
  srcDoc={preview.document}
33
+ data-buffer={preview.buffer}
28
34
  />
29
35
  </PreviewRoot.Stage>
30
36
  <PreviewRoot.Code>
@@ -32,3 +38,9 @@ const ui = messages(
32
38
  <PreviewRoot.Pre><code>{preview.source}</code></PreviewRoot.Pre>
33
39
  </PreviewRoot.Code>
34
40
  </PreviewRoot>
41
+
42
+ <script>
43
+ import { initializePreviewHeight } from "../client/preview-height.js";
44
+
45
+ initializePreviewHeight();
46
+ </script>
@@ -38,7 +38,10 @@ export const PreviewRoot = defineComponent("Preview", {
38
38
  Frame: {
39
39
  display: "block",
40
40
  width: "100%",
41
- height: "min 10rem",
41
+ // A scripted preview grows to fit its content (client/preview-height.ts)
42
+ // between its minimum height and the window's height. The cap also stops
43
+ // content sized by the frame itself, such as `100vh`, growing forever.
44
+ height: "10rem 100vh",
42
45
  border: "0",
43
46
  fill: "#surface",
44
47
  },
@@ -78,3 +81,11 @@ export const PreviewRoot = defineComponent("Preview", {
78
81
  },
79
82
  elements: previewElements,
80
83
  });
84
+
85
+ /**
86
+ * Render-time styles for one preview's `height` prop, a validated CSS length.
87
+ * It replaces the minimum height and keeps the window-height cap.
88
+ */
89
+ export function previewHeightStyles(height) {
90
+ return { Frame: { height: `${height} 100vh` } };
91
+ }
@@ -15,6 +15,10 @@ interface PreviewProps {
15
15
  javascript?: string;
16
16
  /** Public-directory paths, such as `/demo/button.js`, inlined as classic scripts before `javascript`. */
17
17
  scripts?: string[];
18
+ /** The frame's minimum height as a CSS length, such as `18rem`; defaults to `10rem`. */
19
+ height?: string;
20
+ /** Room below the content of a preview that runs scripts, as a CSS length such as `12rem`, for overlays like a listbox; defaults to `0`. */
21
+ buffer?: string;
18
22
  }
19
23
  type StepsProps = Record<string, never>;
20
24
  interface TabsProps {
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","names":[],"sources":["../../src/components/props.ts"],"mappings":";UAAiB;EACf;EACA;;UAEe;EACf;EACA;EACA;;UAEe;EACf;EACA;EACA;EACA;;EAEA;;KAEU,aAAa;UACR;EACf;;UAEe;EACf;;UAEe;EACf;EACA;;UAEe;EACf;EACA,OAAO;IAAQ;IAAe;IAAc"}
1
+ {"version":3,"file":"props.d.ts","names":[],"sources":["../../src/components/props.ts"],"mappings":";UAAiB;EACf;EACA;;UAEe;EACf;EACA;EACA;;UAEe;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;KAEU,aAAa;UACR;EACf;;UAEe;EACf;;UAEe;EACf;EACA;;UAEe;EACf;EACA,OAAO;IAAQ;IAAe;IAAc"}
@@ -14,6 +14,10 @@ export interface PreviewProps {
14
14
  javascript?: string;
15
15
  /** Public-directory paths, such as `/demo/button.js`, inlined as classic scripts before `javascript`. */
16
16
  scripts?: string[];
17
+ /** The frame's minimum height as a CSS length, such as `18rem`; defaults to `10rem`. */
18
+ height?: string;
19
+ /** Room below the content of a preview that runs scripts, as a CSS length such as `12rem`, for overlays like a listbox; defaults to `0`. */
20
+ buffer?: string;
17
21
  }
18
22
  export type StepsProps = Record<string, never>;
19
23
  export interface TabsProps {
@@ -1,14 +1,29 @@
1
1
  import { PreviewProps } from "./components/props.js";
2
2
  //#region src/preview-document.d.ts
3
3
  /**
4
- * Build a Preview's frame document and its "View source" text. Public scripts
5
- * are inlined so they run in the opaque-origin sandbox without a request.
4
+ * Runs first in a preview frame that allows scripts, so it keeps `parent` even
5
+ * if authored code declares its own. It measures the root element's box rather
6
+ * than `scrollHeight`, which never drops below the frame's own height: the
7
+ * root's height follows the content, so the frame can shrink, and growing the
8
+ * frame doesn't change the measurement. A horizontal scrollbar, if any, is
9
+ * added so that it doesn't overflow the content vertically. The frame's origin
10
+ * is opaque, so the message is posted to any origin.
6
11
  */
7
- declare function buildPreview({ html, css, javascript, scripts }: Omit<PreviewProps, "title">, publicDir: string, page: string): Promise<{
12
+ declare const previewHeightReporter = "{\nconst root = document.documentElement;\nconst page = parent;\nconst report = () => page.postMessage({ type: \"cookbook:preview-height\", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, \"*\");\nnew ResizeObserver(report).observe(root);\naddEventListener(\"message\", (event) => { if (event.data?.type === \"cookbook:preview-height\") report(); });\n}";
13
+ /**
14
+ * Build a Preview's frame document, its "View source" text and the frame's
15
+ * settings. Public scripts are inlined so they run in the opaque-origin sandbox
16
+ * without a request. A frame that runs scripts also reports its content height
17
+ * so the page can size it, adding the buffer; a frame without scripts keeps its
18
+ * minimum height, and nothing measures its content to add a buffer to.
19
+ */
20
+ declare function buildPreview({ html, css, javascript, scripts, height, buffer }: Omit<PreviewProps, "title">, publicDir: string, page: string): Promise<{
8
21
  document: string;
9
22
  source: string;
10
23
  sandbox: string;
24
+ height: string | undefined;
25
+ buffer: string | undefined;
11
26
  }>;
12
27
  //#endregion
13
- export { buildPreview };
28
+ export { buildPreview, previewHeightReporter };
14
29
  //# sourceMappingURL=preview-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-document.d.ts","names":[],"sources":["../src/preview-document.ts"],"mappings":";;;;;;iBAQsB,eAElB,MACA,KACA,YACA,WACC,KAAK,wBACR,mBACA,eAAY"}
1
+ {"version":3,"file":"preview-document.d.ts","names":[],"sources":["../src/preview-document.ts"],"mappings":";;;;;;;;;;;cAmBa;;;;;;;;iBAeS,eAElB,MACA,KACA,YACA,SACA,QACA,UACC,KAAK,wBACR,mBACA,eAAY"}
@@ -1,18 +1,44 @@
1
+ import { PREVIEW_HEIGHT_MESSAGE } from "./client/preview-height.js";
1
2
  import { readFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  //#region src/preview-document.ts
5
+ const CSS_LENGTH = /^(?:\d+|\d*\.\d+)(?:px|r?em|ch|ex|r?lh|[dls]?v(?:h|w|min|max)|cm|mm|in|pt|pc)$/;
4
6
  /**
5
- * Build a Preview's frame document and its "View source" text. Public scripts
6
- * are inlined so they run in the opaque-origin sandbox without a request.
7
+ * Runs first in a preview frame that allows scripts, so it keeps `parent` even
8
+ * if authored code declares its own. It measures the root element's box rather
9
+ * than `scrollHeight`, which never drops below the frame's own height: the
10
+ * root's height follows the content, so the frame can shrink, and growing the
11
+ * frame doesn't change the measurement. A horizontal scrollbar, if any, is
12
+ * added so that it doesn't overflow the content vertically. The frame's origin
13
+ * is opaque, so the message is posted to any origin.
7
14
  */
8
- async function buildPreview({ html = "", css = "", javascript, scripts = [] }, publicDir, page) {
15
+ const previewHeightReporter = `{
16
+ const root = document.documentElement;
17
+ const page = parent;
18
+ const report = () => page.postMessage({ type: "${PREVIEW_HEIGHT_MESSAGE}", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, "*");
19
+ new ResizeObserver(report).observe(root);
20
+ addEventListener("message", (event) => { if (event.data?.type === "${PREVIEW_HEIGHT_MESSAGE}") report(); });
21
+ }`;
22
+ /**
23
+ * Build a Preview's frame document, its "View source" text and the frame's
24
+ * settings. Public scripts are inlined so they run in the opaque-origin sandbox
25
+ * without a request. A frame that runs scripts also reports its content height
26
+ * so the page can size it, adding the buffer; a frame without scripts keeps its
27
+ * minimum height, and nothing measures its content to add a buffer to.
28
+ */
29
+ async function buildPreview({ html = "", css = "", javascript, scripts = [], height, buffer }, publicDir, page) {
30
+ for (const [name, value] of [["height", height], ["buffer", buffer]]) if (value !== void 0 && !CSS_LENGTH.test(value)) throw Error(`Preview on ${page}: ${name} ${value} must be a CSS length, such as 18rem or 320px.`);
9
31
  const files = await Promise.all(scripts.map((src) => readPublicScript(src, publicDir, page)));
10
- const markup = `<!doctype html><meta charset="utf-8"><style>${css}</style>${html}`;
32
+ const head = "<!doctype html><meta charset=\"utf-8\">";
33
+ const body = `<style>${css}</style>${html}`;
11
34
  const authored = javascript ? inlineScript(javascript) : "";
35
+ const runsScripts = Boolean(scripts.length || javascript);
12
36
  return {
13
- document: markup + files.map(inlineScript).join("") + authored,
14
- source: markup + scripts.map((src) => `<script src="${src}"><\/script>`).join("") + authored,
15
- sandbox: scripts.length || javascript ? "allow-scripts" : ""
37
+ document: head + (runsScripts ? inlineScript(previewHeightReporter) : "") + body + files.map(inlineScript).join("") + authored,
38
+ source: head + body + scripts.map((src) => `<script src="${src}"><\/script>`).join("") + authored,
39
+ sandbox: runsScripts ? "allow-forms allow-scripts" : "allow-forms",
40
+ height,
41
+ buffer: runsScripts ? buffer : void 0
16
42
  };
17
43
  }
18
44
  function inlineScript(code) {
@@ -28,6 +54,6 @@ async function readPublicScript(src, publicDir, page) {
28
54
  }
29
55
  }
30
56
  //#endregion
31
- export { buildPreview };
57
+ export { buildPreview, previewHeightReporter };
32
58
 
33
59
  //# sourceMappingURL=preview-document.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-document.js","names":[],"sources":["../src/preview-document.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { PreviewProps } from \"./components/props.js\";\n\n/**\n * Build a Preview's frame document and its \"View source\" text. Public scripts\n * are inlined so they run in the opaque-origin sandbox without a request.\n */\nexport async function buildPreview(\n {\n html = \"\",\n css = \"\",\n javascript,\n scripts = [],\n }: Omit<PreviewProps, \"title\">,\n publicDir: string,\n page: string,\n) {\n const files = await Promise.all(\n scripts.map((src) => readPublicScript(src, publicDir, page)),\n );\n const markup = `<!doctype html><meta charset=\"utf-8\"><style>${css}</style>${html}`;\n const authored = javascript ? inlineScript(javascript) : \"\";\n return {\n document: markup + files.map(inlineScript).join(\"\") + authored,\n source:\n markup +\n scripts.map((src) => `<script src=\"${src}\"></script>`).join(\"\") +\n authored,\n sandbox: scripts.length || javascript ? \"allow-scripts\" : \"\",\n };\n}\n\n// The HTML parser ends a script at the first `</script`, even inside a string.\nfunction inlineScript(code: string) {\n return `<script>${code.replace(/<\\/(script)/gi, \"<\\\\/$1\")}</script>`;\n}\n\nasync function readPublicScript(src: string, publicDir: string, page: string) {\n const error = `Preview on ${page}: script ${src} must be a readable file in the site's public directory, such as /demo/button.js.`;\n if (!/^\\/(?!\\/)/.test(src) || src.split(/[\\\\/]/).includes(\"..\"))\n throw Error(error);\n try {\n return await readFile(join(publicDir, src), \"utf8\");\n } catch {\n throw Error(error);\n }\n}\n"],"mappings":";;;;;;;AAQA,eAAsB,aACpB,EACE,OAAO,IACP,MAAM,IACN,YACA,UAAU,CAAC,KAEb,WACA,MACA;CACA,MAAM,QAAQ,MAAM,QAAQ,IAC1B,QAAQ,KAAK,QAAQ,iBAAiB,KAAK,WAAW,IAAI,CAAC,CAC7D;CACA,MAAM,SAAS,+CAA+C,IAAI,UAAU;CAC5E,MAAM,WAAW,aAAa,aAAa,UAAU,IAAI;CACzD,OAAO;EACL,UAAU,SAAS,MAAM,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI;EACtD,QACE,SACA,QAAQ,KAAK,QAAQ,gBAAgB,IAAI,aAAY,CAAC,CAAC,KAAK,EAAE,IAC9D;EACF,SAAS,QAAQ,UAAU,aAAa,kBAAkB;CAC5D;AACF;AAGA,SAAS,aAAa,MAAc;CAClC,OAAO,WAAW,KAAK,QAAQ,iBAAiB,QAAQ,EAAE;AAC5D;AAEA,eAAe,iBAAiB,KAAa,WAAmB,MAAc;CAC5E,MAAM,QAAQ,cAAc,KAAK,WAAW,IAAI;CAChD,IAAI,CAAC,YAAY,KAAK,GAAG,KAAK,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAC5D,MAAM,MAAM,KAAK;CACnB,IAAI;EACF,OAAO,MAAM,SAAS,KAAK,WAAW,GAAG,GAAG,MAAM;CACpD,QAAQ;EACN,MAAM,MAAM,KAAK;CACnB;AACF"}
1
+ {"version":3,"file":"preview-document.js","names":[],"sources":["../src/preview-document.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { PREVIEW_HEIGHT_MESSAGE } from \"./client/preview-height.js\";\nimport type { PreviewProps } from \"./components/props.js\";\n\n// The frame's height and buffer become CSS, so accept only a plain length.\n// Percentages are rejected because the frame's container has no fixed height.\nconst CSS_LENGTH =\n /^(?:\\d+|\\d*\\.\\d+)(?:px|r?em|ch|ex|r?lh|[dls]?v(?:h|w|min|max)|cm|mm|in|pt|pc)$/;\n\n/**\n * Runs first in a preview frame that allows scripts, so it keeps `parent` even\n * if authored code declares its own. It measures the root element's box rather\n * than `scrollHeight`, which never drops below the frame's own height: the\n * root's height follows the content, so the frame can shrink, and growing the\n * frame doesn't change the measurement. A horizontal scrollbar, if any, is\n * added so that it doesn't overflow the content vertically. The frame's origin\n * is opaque, so the message is posted to any origin.\n */\nexport const previewHeightReporter = `{\nconst root = document.documentElement;\nconst page = parent;\nconst report = () => page.postMessage({ type: \"${PREVIEW_HEIGHT_MESSAGE}\", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, \"*\");\nnew ResizeObserver(report).observe(root);\naddEventListener(\"message\", (event) => { if (event.data?.type === \"${PREVIEW_HEIGHT_MESSAGE}\") report(); });\n}`;\n\n/**\n * Build a Preview's frame document, its \"View source\" text and the frame's\n * settings. Public scripts are inlined so they run in the opaque-origin sandbox\n * without a request. A frame that runs scripts also reports its content height\n * so the page can size it, adding the buffer; a frame without scripts keeps its\n * minimum height, and nothing measures its content to add a buffer to.\n */\nexport async function buildPreview(\n {\n html = \"\",\n css = \"\",\n javascript,\n scripts = [],\n height,\n buffer,\n }: Omit<PreviewProps, \"title\">,\n publicDir: string,\n page: string,\n) {\n for (const [name, value] of [\n [\"height\", height],\n [\"buffer\", buffer],\n ])\n if (value !== undefined && !CSS_LENGTH.test(value))\n throw Error(\n `Preview on ${page}: ${name} ${value} must be a CSS length, such as 18rem or 320px.`,\n );\n const files = await Promise.all(\n scripts.map((src) => readPublicScript(src, publicDir, page)),\n );\n const head = '<!doctype html><meta charset=\"utf-8\">';\n const body = `<style>${css}</style>${html}`;\n const authored = javascript ? inlineScript(javascript) : \"\";\n const runsScripts = Boolean(scripts.length || javascript);\n return {\n // The height reporter runs first, before authored code can shadow `parent`.\n document:\n head +\n (runsScripts ? inlineScript(previewHeightReporter) : \"\") +\n body +\n files.map(inlineScript).join(\"\") +\n authored,\n source:\n head +\n body +\n scripts.map((src) => `<script src=\"${src}\"></script>`).join(\"\") +\n authored,\n // A submitted form can navigate only the frame itself, as a link can.\n sandbox: runsScripts ? \"allow-forms allow-scripts\" : \"allow-forms\",\n height,\n buffer: runsScripts ? buffer : undefined,\n };\n}\n\n// The HTML parser ends a script at the first `</script`, even inside a string.\nfunction inlineScript(code: string) {\n return `<script>${code.replace(/<\\/(script)/gi, \"<\\\\/$1\")}</script>`;\n}\n\nasync function readPublicScript(src: string, publicDir: string, page: string) {\n const error = `Preview on ${page}: script ${src} must be a readable file in the site's public directory, such as /demo/button.js.`;\n if (!/^\\/(?!\\/)/.test(src) || src.split(/[\\\\/]/).includes(\"..\"))\n throw Error(error);\n try {\n return await readFile(join(publicDir, src), \"utf8\");\n } catch {\n throw Error(error);\n }\n}\n"],"mappings":";;;;AAOA,MAAM,aACJ;;;;;;;;;;AAWF,MAAa,wBAAwB;;;iDAGY,uBAAuB;;qEAEH,uBAAuB;;;;;;;;;AAU5F,eAAsB,aACpB,EACE,OAAO,IACP,MAAM,IACN,YACA,UAAU,CAAC,GACX,QACA,UAEF,WACA,MACA;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,CAC1B,CAAC,UAAU,MAAM,GACjB,CAAC,UAAU,MAAM,CACnB,GACE,IAAI,UAAU,KAAA,KAAa,CAAC,WAAW,KAAK,KAAK,GAC/C,MAAM,MACJ,cAAc,KAAK,IAAI,KAAK,GAAG,MAAM,+CACvC;CACJ,MAAM,QAAQ,MAAM,QAAQ,IAC1B,QAAQ,KAAK,QAAQ,iBAAiB,KAAK,WAAW,IAAI,CAAC,CAC7D;CACA,MAAM,OAAO;CACb,MAAM,OAAO,UAAU,IAAI,UAAU;CACrC,MAAM,WAAW,aAAa,aAAa,UAAU,IAAI;CACzD,MAAM,cAAc,QAAQ,QAAQ,UAAU,UAAU;CACxD,OAAO;EAEL,UACE,QACC,cAAc,aAAa,qBAAqB,IAAI,MACrD,OACA,MAAM,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAC/B;EACF,QACE,OACA,OACA,QAAQ,KAAK,QAAQ,gBAAgB,IAAI,aAAY,CAAC,CAAC,KAAK,EAAE,IAC9D;EAEF,SAAS,cAAc,8BAA8B;EACrD;EACA,QAAQ,cAAc,SAAS,KAAA;CACjC;AACF;AAGA,SAAS,aAAa,MAAc;CAClC,OAAO,WAAW,KAAK,QAAQ,iBAAiB,QAAQ,EAAE;AAC5D;AAEA,eAAe,iBAAiB,KAAa,WAAmB,MAAc;CAC5E,MAAM,QAAQ,cAAc,KAAK,WAAW,IAAI;CAChD,IAAI,CAAC,YAAY,KAAK,GAAG,KAAK,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAC5D,MAAM,MAAM,KAAK;CACnB,IAAI;EACF,OAAO,MAAM,SAAS,KAAK,WAAW,GAAG,GAAG,MAAM;CACpD,QAAQ;EACN,MAAM,MAAM,KAAK;CACnB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/renderer",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Astro renderer and Tasty theme for Cookbook",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -61,7 +61,7 @@
61
61
  "@fontsource-variable/jetbrains-mono": "^5.3.0",
62
62
  "@fontsource-variable/onest": "^5.3.0",
63
63
  "@pagefind/default-ui": "1.5.2",
64
- "@tenphi/docs": "0.26.0",
64
+ "@tenphi/docs": "0.28.0",
65
65
  "@tenphi/eslint-plugin-tasty": "1.6.0",
66
66
  "@tenphi/glaze": "2.0.1",
67
67
  "@tenphi/tasty": "3.9.10",