@tdacorp/hyle-sdk 0.14.1 → 0.21.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.
Files changed (86) hide show
  1. package/README.md +171 -32
  2. package/dist/check-routes-bin.js +48 -21
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +733 -278
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +414 -330
  20. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-XY3CG75U.js} +107 -46
  21. package/dist/{embed-B76zRRPa.d.cts → embed-BUFRQboD.d.ts} +10 -5
  22. package/dist/{embed-SqOBGI-E.d.ts → embed-CYt-q13P.d.cts} +10 -5
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/labels-CrA-iqTN.d.cts +46 -0
  36. package/dist/labels-CrA-iqTN.d.ts +46 -0
  37. package/dist/mermaid-diagram.cjs +453 -148
  38. package/dist/mermaid-diagram.d.cts +25 -42
  39. package/dist/mermaid-diagram.d.ts +25 -42
  40. package/dist/mermaid-diagram.js +205 -50
  41. package/dist/mermaid-image.cjs +1456 -0
  42. package/dist/mermaid-image.d.cts +30 -0
  43. package/dist/mermaid-image.d.ts +30 -0
  44. package/dist/mermaid-image.js +93 -0
  45. package/dist/next.cjs +1709 -1134
  46. package/dist/next.d.cts +67 -14
  47. package/dist/next.d.ts +67 -14
  48. package/dist/next.js +950 -794
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +677 -264
  54. package/dist/react.d.cts +161 -31
  55. package/dist/react.d.ts +161 -31
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-DC2ccfwA.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-DKLVftk_.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +107 -47
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-ByodIyEv.d.cts → types-3F0wqD-o.d.cts} +44 -4
  73. package/dist/{types-ByodIyEv.d.ts → types-3F0wqD-o.d.ts} +44 -4
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-4V4VKB3O.js +0 -1471
  84. package/dist/chunk-R5EMI4HQ.js +0 -61
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -0,0 +1,30 @@
1
+ import * as react from 'react';
2
+ import { V as ViewerLabels } from './labels-CrA-iqTN.cjs';
3
+
4
+ /**
5
+ * A diagram hyle already rendered (in the author's browser, sanitized and stored, ADR 0024): the reader gets a sized `<img>` and
6
+ * no layout runs in any browser. The source stays in the markup inside `<details>`, so crawlers and no-JS readers have it. Like
7
+ * MermaidDiagram it receives presentational values only, never a token or client; the SVG it fetches on click comes from the
8
+ * host's own same-origin asset route. If the image fails to load it falls back to MermaidDiagram, which asks before drawing a large
9
+ * diagram; the stored image itself needs no such gate, since showing it runs no layout.
10
+ */
11
+ interface StoredRender {
12
+ src: string;
13
+ width: number;
14
+ height: number;
15
+ }
16
+ interface MermaidImageProps {
17
+ source: string;
18
+ title: string;
19
+ errorText: string;
20
+ loadingText: string;
21
+ sourceLabel: string;
22
+ light: StoredRender;
23
+ dark: StoredRender;
24
+ labels?: ViewerLabels;
25
+ }
26
+ /** True when a fetched stored SVG still looks like what the server stores; the viewer inlines only those. */
27
+ declare function isSafeStoredSvg(svg: string): boolean;
28
+ declare function MermaidImage(props: MermaidImageProps): react.JSX.Element;
29
+
30
+ export { MermaidImage, type MermaidImageProps, type StoredRender, isSafeStoredSvg };
@@ -0,0 +1,30 @@
1
+ import * as react from 'react';
2
+ import { V as ViewerLabels } from './labels-CrA-iqTN.js';
3
+
4
+ /**
5
+ * A diagram hyle already rendered (in the author's browser, sanitized and stored, ADR 0024): the reader gets a sized `<img>` and
6
+ * no layout runs in any browser. The source stays in the markup inside `<details>`, so crawlers and no-JS readers have it. Like
7
+ * MermaidDiagram it receives presentational values only, never a token or client; the SVG it fetches on click comes from the
8
+ * host's own same-origin asset route. If the image fails to load it falls back to MermaidDiagram, which asks before drawing a large
9
+ * diagram; the stored image itself needs no such gate, since showing it runs no layout.
10
+ */
11
+ interface StoredRender {
12
+ src: string;
13
+ width: number;
14
+ height: number;
15
+ }
16
+ interface MermaidImageProps {
17
+ source: string;
18
+ title: string;
19
+ errorText: string;
20
+ loadingText: string;
21
+ sourceLabel: string;
22
+ light: StoredRender;
23
+ dark: StoredRender;
24
+ labels?: ViewerLabels;
25
+ }
26
+ /** True when a fetched stored SVG still looks like what the server stores; the viewer inlines only those. */
27
+ declare function isSafeStoredSvg(svg: string): boolean;
28
+ declare function MermaidImage(props: MermaidImageProps): react.JSX.Element;
29
+
30
+ export { MermaidImage, type MermaidImageProps, type StoredRender, isSafeStoredSvg };
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import {
3
+ afterFullscreen,
4
+ watchPageTheme
5
+ } from "./chunk-K5VDLROQ.js";
6
+ import {
7
+ VIEWER_LABELS_EN
8
+ } from "./chunk-QVYQM5R2.js";
9
+
10
+ // src/react/mermaid-image.tsx
11
+ import { useEffect, useRef, useState } from "react";
12
+ import { DiagramBoundary, MermaidDiagram } from "./mermaid-diagram.js";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ var FORBIDDEN_IN_SVG = /<script|<foreignObject|\son\w+\s*=|javascript:/i;
15
+ var BAD_CSS = /\\|@(?!keyframes\b)|expression|-moz-binding|behavior|-webkit-image-set|(?:src|image|image-set|cross-fade|element|paint)\(|url\((?!\s*['"]?\s*#)/i;
16
+ function isSafeStoredSvg(svg) {
17
+ if (FORBIDDEN_IN_SVG.test(svg)) return false;
18
+ for (const m of svg.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>|\s[\w:-]+="([^"]*)"/g)) if (BAD_CSS.test(m[1] ?? m[2] ?? "")) return false;
19
+ return true;
20
+ }
21
+ function StoredDiagram({ source, title, errorText, loadingText, sourceLabel, light, dark, labels = VIEWER_LABELS_EN }) {
22
+ const figure = useRef(null);
23
+ const img = useRef(null);
24
+ const trigger = useRef(null);
25
+ const [theme, setTheme] = useState(null);
26
+ const [pending, setPending] = useState(false);
27
+ const [failed, setFailed] = useState(false);
28
+ const [view, setView] = useState(null);
29
+ const [viewerFailed, setViewerFailed] = useState(false);
30
+ const [Viewer, setViewer] = useState(null);
31
+ useEffect(() => figure.current ? watchPageTheme(figure.current, setTheme) : void 0, []);
32
+ useEffect(() => {
33
+ const el = img.current;
34
+ if (!el?.complete) setPending(true);
35
+ else if (el.naturalWidth === 0) setFailed(true);
36
+ }, []);
37
+ if (failed) return /* @__PURE__ */ jsx(MermaidDiagram, { source, title, errorText, loadingText, labels });
38
+ const active = theme === "dark" ? dark : light;
39
+ const expand = async (e) => {
40
+ if (e.target.closest("a")) return;
41
+ setViewerFailed(false);
42
+ try {
43
+ const response = await fetch(active.src);
44
+ const svg = response.ok ? await response.text() : "";
45
+ const id = /^\s*<svg\b[^>]*?\sid="([\w-]+)"/.exec(svg)?.[1];
46
+ if (!id || !isSafeStoredSvg(svg)) return setViewerFailed(true);
47
+ const { DiagramViewer } = await import("./diagram-viewer-XY3CG75U.js");
48
+ setViewer(() => DiagramViewer);
49
+ setView({ svg, id });
50
+ } catch {
51
+ setViewerFailed(true);
52
+ }
53
+ };
54
+ return /* @__PURE__ */ jsxs("figure", { ref: figure, className: "hyle-mermaid", "data-slot-component": "Mermaid", children: [
55
+ /* @__PURE__ */ jsxs("div", { className: "hyle-mermaid-open", role: "presentation", onClick: expand, children: [
56
+ /* @__PURE__ */ jsxs("span", { className: "hyle-mermaid-frame", style: { aspectRatio: `${active.width} / ${active.height}`, maxWidth: active.width }, children: [
57
+ pending ? /* @__PURE__ */ jsx("span", { className: "hyle-mermaid-loader", role: "status", "aria-busy": "true", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }) }) : null,
58
+ /* @__PURE__ */ jsxs("picture", { children: [
59
+ /* @__PURE__ */ jsx("source", { srcSet: dark.src, media: theme === null ? "(prefers-color-scheme: dark)" : theme === "dark" ? "all" : "not all" }),
60
+ /* @__PURE__ */ jsx("img", { ref: img, src: light.src, alt: title, width: light.width, height: light.height, decoding: "async", loading: "lazy", onLoad: () => setPending(false), onError: () => setFailed(true) })
61
+ ] })
62
+ ] }),
63
+ /* @__PURE__ */ jsx("button", { ref: trigger, type: "button", className: "hyle-mermaid-hint", "aria-label": labels.expand, "aria-haspopup": "dialog", children: labels.expandHint })
64
+ ] }),
65
+ /* @__PURE__ */ jsxs("details", { className: "hyle-mermaid-source", children: [
66
+ /* @__PURE__ */ jsx("summary", { children: sourceLabel }),
67
+ /* @__PURE__ */ jsx("pre", { tabIndex: 0, children: /* @__PURE__ */ jsx("code", { className: "language-mermaid", children: source }) })
68
+ ] }),
69
+ view && Viewer ? /* @__PURE__ */ jsx(
70
+ Viewer,
71
+ {
72
+ svg: view.svg,
73
+ svgId: view.id,
74
+ source,
75
+ title,
76
+ labels,
77
+ onClose: () => afterFullscreen(figure.current, () => {
78
+ setView(null);
79
+ trigger.current?.focus({ preventScroll: true });
80
+ })
81
+ }
82
+ ) : null,
83
+ viewerFailed ? /* @__PURE__ */ jsx("p", { className: "hyle-mermaid-note", role: "status", children: labels.unavailable }) : null,
84
+ /* @__PURE__ */ jsx("figcaption", { className: "sr-only", children: title })
85
+ ] });
86
+ }
87
+ function MermaidImage(props) {
88
+ return /* @__PURE__ */ jsx(DiagramBoundary, { source: props.source, children: /* @__PURE__ */ jsx(StoredDiagram, { ...props }) });
89
+ }
90
+ export {
91
+ MermaidImage,
92
+ isSafeStoredSvg
93
+ };