@tdacorp/hyle-sdk 0.17.0 → 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 +155 -28
  2. package/dist/check-routes-bin.js +38 -13
  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 +728 -275
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +409 -326
  20. package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
  21. package/dist/{embed-BmdwA2G9.d.cts → embed-BUFRQboD.d.ts} +2 -2
  22. package/dist/{embed-DNTZ2UXv.d.ts → embed-CYt-q13P.d.cts} +2 -2
  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-nmukKYgL.d.ts → labels-CrA-iqTN.d.cts} +9 -0
  36. package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.ts} +9 -0
  37. package/dist/mermaid-diagram.cjs +401 -125
  38. package/dist/mermaid-diagram.d.cts +23 -7
  39. package/dist/mermaid-diagram.d.ts +23 -7
  40. package/dist/mermaid-diagram.js +204 -51
  41. package/dist/mermaid-image.cjs +134 -60
  42. package/dist/mermaid-image.d.cts +4 -3
  43. package/dist/mermaid-image.d.ts +4 -3
  44. package/dist/mermaid-image.js +27 -28
  45. package/dist/next.cjs +627 -264
  46. package/dist/next.d.cts +11 -8
  47. package/dist/next.d.ts +11 -8
  48. package/dist/next.js +39 -12
  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 +556 -226
  54. package/dist/react.d.cts +136 -29
  55. package/dist/react.d.ts +136 -29
  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-Ae7UFjsQ.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-euZ4-aC9.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 +96 -25
  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-Czt887Iv.d.cts → types-3F0wqD-o.d.cts} +26 -2
  73. package/dist/{types-Czt887Iv.d.ts → types-3F0wqD-o.d.ts} +26 -2
  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-DMK4XQLU.js +0 -1556
  84. package/dist/chunk-PJMJMP66.js +0 -63
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
package/dist/react.d.cts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as react from 'react';
2
- import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-BmdwA2G9.cjs';
4
- export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-BmdwA2G9.cjs';
5
- import { Root } from 'hast';
6
- import { h as ResolvedArticle, L as ListItem, j as ResolvedList, c as EngageListing } from './types-Czt887Iv.cjs';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-CYt-q13P.cjs';
4
+ export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-CYt-q13P.cjs';
5
+ export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-ijiWjEm9.cjs';
6
+ import { j as ResolvedArticle, L as ListItem, T as TocEntry, l as ResolvedList, c as EngageListing } from './types-3F0wqD-o.cjs';
7
+ import 'hast';
7
8
 
8
9
  interface HastContentProps {
9
10
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -16,7 +17,7 @@ interface HastContentProps {
16
17
  locale?: string;
17
18
  }
18
19
  /** Renders the `hast` content format as React elements. Never uses dangerouslySetInnerHTML; every node passes the allowlist first. */
19
- declare function HastContent({ tree, title, description, components, locale }: HastContentProps): ReactElement;
20
+ declare function HastContent(props: HastContentProps): ReactElement;
20
21
  /**
21
22
  * The one escape hatch: renders `content.format === "html"` as raw HTML. Use it ONLY with HTML that came from hyle's
22
23
  * resolve endpoint over your server-side connection, which sanitizes it before serializing. It is not sanitized again
@@ -26,6 +27,16 @@ declare function TrustedServerHtml({ html }: {
26
27
  html: string;
27
28
  }): ReactElement;
28
29
 
30
+ interface HyleBodyProps extends HastContentProps {
31
+ /** The body element's id, which the copy-button island looks up. Generated when omitted. */
32
+ id?: string | undefined;
33
+ }
34
+ /**
35
+ * An article body inside a page the host owns: the host keeps its title, metadata, JSON-LD, sitemap and feeds. The element
36
+ * carries `hyle` itself, so the stylesheet's tokens apply without a wrapper.
37
+ */
38
+ declare function HyleBody(props: HyleBodyProps): ReactElement;
39
+
29
40
  /**
30
41
  * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
31
42
  * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
@@ -60,12 +71,22 @@ interface ViewerLabels {
60
71
  outgoing: string;
61
72
  tracing: string;
62
73
  map: string;
74
+ largeTitle: string;
75
+ largeBody: string;
76
+ drawLarge: string;
77
+ drawing: string;
78
+ drawingBody: string;
79
+ drawAgain: string;
80
+ showSource: string;
81
+ hideSource: string;
82
+ printPreparing: string;
63
83
  }
84
+ declare const VIEWER_LABELS_EN: ViewerLabels;
64
85
 
65
86
  /**
66
- * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
67
- * base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that have a diagram,
68
- * from the host's own origin.
87
+ * Draws one diagram and opens it in the viewer on click. It receives the diagram text and presentational strings and nothing else:
88
+ * never a token, base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that draw a
89
+ * diagram, from the host's own origin; the viewer is another, fetched by the first click.
69
90
  */
70
91
  interface MermaidDiagramProps {
71
92
  source: string;
@@ -75,30 +96,42 @@ interface MermaidDiagramProps {
75
96
  errorText: string;
76
97
  /** Accessible name of the loader shown while the diagram renders (English when omitted). */
77
98
  loadingText?: string;
78
- /** Strings of the diagram viewer (English when omitted). */
99
+ /** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
79
100
  labels?: ViewerLabels;
80
101
  }
81
- declare function MermaidDiagram({ source, title, errorText, loadingText, labels }: MermaidDiagramProps): react.JSX.Element;
102
+ declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
82
103
 
104
+ declare const isClampedSource: (source: string) => boolean;
83
105
  /**
84
- * Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
85
- * so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
86
- * rebuilds the tree from scratch: only listed tags, only listed properties with an accepted value shape, and nothing
87
- * else is copied. Unknown tags are unwrapped (children kept); script and style are dropped with their text.
106
+ * The diagram text without per-diagram configuration. `%%{init: ...}%%` directives and a leading YAML frontmatter block can set
107
+ * `themeCSS` (arbitrary CSS in the page: `url()` fetches, `position: fixed` overlays), `themeVariables` and `fontFamily`, and Mermaid's
108
+ * sanitizer only checks brace balance. Plain `%% comment` lines stay. Repeats until stable, since removing one can join the text around it,
109
+ * at most MAX_STRIP_ROUNDS times; a source that still changes then is refused (returns "", which draws nothing) rather than passed on.
88
110
  */
89
- /** Thrown when a tree exceeds the node or size caps; `HastContent` renders a safe notice instead of the content. */
90
- declare class HastLimitError extends Error {
91
- constructor(message: string);
92
- }
93
- declare const scopeId: (id: string) => string;
94
- /** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
95
- declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
111
+ declare function stripMermaidConfig(source: string): string;
96
112
  /**
97
- * @param title when the body opens with an h1 that repeats the page title, that h1 is dropped (the page renders the title itself).
98
- * @param description when the first paragraph after that h1 starts with it, the paragraph is dropped (the page renders the description itself; hyle derives it, capped, from that paragraph).
99
- * @throws HastLimitError when the tree has more than 20,000 nodes or 512 KiB of text (hyle's own renderer caps).
113
+ * True when drawing `source` would freeze the page long enough that the reader should ask for it. Mermaid lays a diagram out in one
114
+ * uninterrupted task, so this is the only defence, and it must not be easy to slip under with ordinary syntax. It is true when `edgeBound`
115
+ * exceeds the edge limit, so for every diagram whose relations have a link token Mermaid draws no more than that when it is false.
116
+ * Sankey flows, requirement `<-` relations and C4 `Rel()` have none: only the statement, word and character limits bound those (0.2 s for
117
+ * 135 requirement relations and for 249 sankey flows, in Chromium at 1x). The price is that a label which only looks like a link counts as one, and ` & ` operands cost
118
+ * quadratically wherever they sit, so some 17 of them gate a diagram of any size: that is the safe direction. Its own cost is bounded:
119
+ * above AUTO_RENDER_CHARS it answers before reading anything (it runs on the server for every fence), and below that every pass is linear.
100
120
  */
101
- declare function sanitizeHast(tree: unknown, title?: string, description?: string | null): Root;
121
+ declare function isLargeDiagram(source: string): boolean;
122
+
123
+ /** `loaded` must settle (never reject) once every diagram it mounts has registered; a failed load settles it too. */
124
+ declare function holdPrintUntil(loaded: Promise<unknown>): void;
125
+ /**
126
+ * Ctrl/Cmd+P while a diagram is not drawn yet: hold the browser's print, draw every diagram, then call `window.print()`.
127
+ * Otherwise the key is left alone. Escape during the wait cancels the print.
128
+ * File > Print cannot be intercepted and still prints the source.
129
+ * Every MermaidDiagram installs it. One document listener serves every caller: it goes with the last cleanup, which
130
+ * also cancels a wait in progress.
131
+ * shortcut: the budgets and Escape are only served between tasks. Mermaid lays a diagram out in one synchronous task, so a diagram that
132
+ * is one huge layout holds the press until that layout ends, timers and Escape included; upgrade by not drawing such diagrams at all.
133
+ */
134
+ declare function installPrintShortcut(): () => void;
102
135
 
103
136
  /**
104
137
  * Chrome strings of the Comments component (en, fr, es). The fr and es copy is a draft and has not been reviewed by a native
@@ -137,6 +170,7 @@ interface CommentStrings {
137
170
  readonly removed: string;
138
171
  readonly removedByModerator: string;
139
172
  readonly removedByAuthor: string;
173
+ readonly unrenderable: string;
140
174
  readonly depthEnd: string;
141
175
  readonly held: string;
142
176
  readonly heldBanner: string;
@@ -165,6 +199,37 @@ interface CommentStrings {
165
199
  readonly more: string;
166
200
  readonly truncated: string;
167
201
  readonly justNow: string;
202
+ readonly react: string;
203
+ readonly reactions: string;
204
+ readonly reactionLike: string;
205
+ readonly reactionLove: string;
206
+ readonly reactionInsightful: string;
207
+ readonly reactionCelebrate: string;
208
+ readonly reactionSignIn: string;
209
+ readonly reactionAddedLive: string;
210
+ readonly reactionRemovedLive: string;
211
+ readonly reactionsLoading: string;
212
+ readonly reactionsError: string;
213
+ readonly votesOn: string;
214
+ readonly score: string;
215
+ readonly upvote: string;
216
+ readonly downvote: string;
217
+ readonly upvoteSignIn: string;
218
+ readonly downvoteSignIn: string;
219
+ readonly upvotedLive: string;
220
+ readonly downvotedLive: string;
221
+ readonly voteRemovedLive: string;
222
+ readonly voteRefused: string;
223
+ readonly slowDown: string;
224
+ readonly sort: string;
225
+ readonly sortNewest: string;
226
+ readonly sortTop: string;
227
+ readonly sortedNewestLive: string;
228
+ readonly sortedTopLive: string;
229
+ readonly sortError: string;
230
+ readonly newerLater: string;
231
+ readonly moreError: string;
232
+ readonly loadedLive: string;
168
233
  }
169
234
 
170
235
  /**
@@ -187,6 +252,14 @@ declare const en: {
187
252
  warning: string;
188
253
  tip: string;
189
254
  caution: string;
255
+ important: string;
256
+ copyCode: string;
257
+ copied: string;
258
+ copyBlocked: string;
259
+ done: string;
260
+ notDone: string;
261
+ playVideo: string;
262
+ videoFrame: string;
190
263
  diagram: string;
191
264
  diagramError: string;
192
265
  diagramLoading: string;
@@ -228,6 +301,17 @@ type Strings = typeof en;
228
301
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
229
302
  declare function stringsFor(locale: string | undefined): Strings;
230
303
 
304
+ interface HyleTocProps {
305
+ /** `toc` from an article result; only h2 and h3 entries are listed. */
306
+ toc: readonly TocEntry[];
307
+ /** "rail": a sticky aside with scroll-spy, for the host's side column. "inline": a collapsed `<details>` to put above the body. */
308
+ variant: "rail" | "inline";
309
+ /** Rail only: shown under the list. */
310
+ aside?: ReactNode;
311
+ locale?: string | undefined;
312
+ }
313
+ /** The contents list for a page the host owns. Which variant shows at which width is the host's layout decision. */
314
+ declare function HyleToc({ toc, variant, aside, locale }: HyleTocProps): ReactElement | null;
231
315
  interface ArticlePageProps extends PageBaseProps {
232
316
  article: ResolvedArticle;
233
317
  /**
@@ -288,7 +372,7 @@ interface RedirectingProps extends PageBaseProps {
288
372
  declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
289
373
 
290
374
  /**
291
- * The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
375
+ * The comments, votes and reactions section of an article (ADR 0017, 0021). It is fetched in the browser, uncached, after the cached article
292
376
  * has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
293
377
  * credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
294
378
  * into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
@@ -309,9 +393,32 @@ interface CommentsProps {
309
393
  readonly initial?: EngageListing | undefined;
310
394
  /** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
311
395
  readonly initialAt?: number | undefined;
396
+ /**
397
+ * Fetch nothing until the section is about to scroll into view (within 600px), so a statically cached page costs no request for
398
+ * readers who never get there. Without IntersectionObserver it loads at once. Default false.
399
+ */
400
+ readonly lazy?: boolean | undefined;
401
+ /** The article's own reactions above the thread. Set false when the page already has `HyleReactions`. Default true. */
402
+ readonly articleReactions?: boolean | undefined;
312
403
  }
313
- declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
404
+ declare function Comments(props: CommentsProps): ReactElement;
405
+
406
+ interface HyleReactionsProps {
407
+ /** The article's canonical site path (`publication.canonical_path`). */
408
+ readonly path: string;
409
+ /** The same object `ArticlePage` takes: `endpoint` (default "/api/hyle/engage") and `signInHref`. */
410
+ readonly engagement: EngagementConfig;
411
+ /** BCP 47. English, French and Spanish strings ship; anything else is English. Default "en". */
412
+ readonly locale?: string | undefined;
413
+ }
414
+ /**
415
+ * The article's reactions, on their own (for example under the title). Fetched in the browser through the host's
416
+ * `createEngagementRoute`, like `Comments`; renders nothing when engagement is off or the article is unknown.
417
+ * hyle has no counts-only endpoint, so it reads the first page `Comments` reads (the two share the request when they load
418
+ * together) and uses its article fields. It reads on mount even beside a `lazy` `Comments`.
419
+ */
420
+ declare function HyleReactions(props: HyleReactionsProps): ReactElement;
314
421
 
315
422
  declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
316
423
 
317
- export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HastLimitError, HyleComponents, JsonLdConfig, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
424
+ export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HyleBody, type HyleBodyProps, HyleComponents, HyleReactions, type HyleReactionsProps, HyleToc, type HyleTocProps, JsonLdConfig, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, VIEWER_LABELS_EN, type ViewerLabels, holdPrintUntil, installPrintShortcut, isClampedSource, isLargeDiagram, stringsFor, stripMermaidConfig };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as react from 'react';
2
- import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-DNTZ2UXv.js';
4
- export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-DNTZ2UXv.js';
5
- import { Root } from 'hast';
6
- import { h as ResolvedArticle, L as ListItem, j as ResolvedList, c as EngageListing } from './types-Czt887Iv.js';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-BUFRQboD.js';
4
+ export { A as ArticleRef, C as CalloutKind, d as CalloutProps, e as CodeBlockProps, b as EmbedHeading, f as HyleArticleView, g as HyleArticleViewProps, h as HyleListView, i as HyleListViewProps, a as HyleSlots, I as ImageProps, L as LinkProps, j as ListItemProps, M as MermaidProps, O as OgImage } from './embed-BUFRQboD.js';
5
+ export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-ijiWjEm9.js';
6
+ import { j as ResolvedArticle, L as ListItem, T as TocEntry, l as ResolvedList, c as EngageListing } from './types-3F0wqD-o.js';
7
+ import 'hast';
7
8
 
8
9
  interface HastContentProps {
9
10
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -16,7 +17,7 @@ interface HastContentProps {
16
17
  locale?: string;
17
18
  }
18
19
  /** Renders the `hast` content format as React elements. Never uses dangerouslySetInnerHTML; every node passes the allowlist first. */
19
- declare function HastContent({ tree, title, description, components, locale }: HastContentProps): ReactElement;
20
+ declare function HastContent(props: HastContentProps): ReactElement;
20
21
  /**
21
22
  * The one escape hatch: renders `content.format === "html"` as raw HTML. Use it ONLY with HTML that came from hyle's
22
23
  * resolve endpoint over your server-side connection, which sanitizes it before serializing. It is not sanitized again
@@ -26,6 +27,16 @@ declare function TrustedServerHtml({ html }: {
26
27
  html: string;
27
28
  }): ReactElement;
28
29
 
30
+ interface HyleBodyProps extends HastContentProps {
31
+ /** The body element's id, which the copy-button island looks up. Generated when omitted. */
32
+ id?: string | undefined;
33
+ }
34
+ /**
35
+ * An article body inside a page the host owns: the host keeps its title, metadata, JSON-LD, sitemap and feeds. The element
36
+ * carries `hyle` itself, so the stylesheet's tokens apply without a wrapper.
37
+ */
38
+ declare function HyleBody(props: HyleBodyProps): ReactElement;
39
+
29
40
  /**
30
41
  * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
31
42
  * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
@@ -60,12 +71,22 @@ interface ViewerLabels {
60
71
  outgoing: string;
61
72
  tracing: string;
62
73
  map: string;
74
+ largeTitle: string;
75
+ largeBody: string;
76
+ drawLarge: string;
77
+ drawing: string;
78
+ drawingBody: string;
79
+ drawAgain: string;
80
+ showSource: string;
81
+ hideSource: string;
82
+ printPreparing: string;
63
83
  }
84
+ declare const VIEWER_LABELS_EN: ViewerLabels;
64
85
 
65
86
  /**
66
- * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
67
- * base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that have a diagram,
68
- * from the host's own origin.
87
+ * Draws one diagram and opens it in the viewer on click. It receives the diagram text and presentational strings and nothing else:
88
+ * never a token, base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that draw a
89
+ * diagram, from the host's own origin; the viewer is another, fetched by the first click.
69
90
  */
70
91
  interface MermaidDiagramProps {
71
92
  source: string;
@@ -75,30 +96,42 @@ interface MermaidDiagramProps {
75
96
  errorText: string;
76
97
  /** Accessible name of the loader shown while the diagram renders (English when omitted). */
77
98
  loadingText?: string;
78
- /** Strings of the diagram viewer (English when omitted). */
99
+ /** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
79
100
  labels?: ViewerLabels;
80
101
  }
81
- declare function MermaidDiagram({ source, title, errorText, loadingText, labels }: MermaidDiagramProps): react.JSX.Element;
102
+ declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
82
103
 
104
+ declare const isClampedSource: (source: string) => boolean;
83
105
  /**
84
- * Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
85
- * so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
86
- * rebuilds the tree from scratch: only listed tags, only listed properties with an accepted value shape, and nothing
87
- * else is copied. Unknown tags are unwrapped (children kept); script and style are dropped with their text.
106
+ * The diagram text without per-diagram configuration. `%%{init: ...}%%` directives and a leading YAML frontmatter block can set
107
+ * `themeCSS` (arbitrary CSS in the page: `url()` fetches, `position: fixed` overlays), `themeVariables` and `fontFamily`, and Mermaid's
108
+ * sanitizer only checks brace balance. Plain `%% comment` lines stay. Repeats until stable, since removing one can join the text around it,
109
+ * at most MAX_STRIP_ROUNDS times; a source that still changes then is refused (returns "", which draws nothing) rather than passed on.
88
110
  */
89
- /** Thrown when a tree exceeds the node or size caps; `HastContent` renders a safe notice instead of the content. */
90
- declare class HastLimitError extends Error {
91
- constructor(message: string);
92
- }
93
- declare const scopeId: (id: string) => string;
94
- /** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
95
- declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
111
+ declare function stripMermaidConfig(source: string): string;
96
112
  /**
97
- * @param title when the body opens with an h1 that repeats the page title, that h1 is dropped (the page renders the title itself).
98
- * @param description when the first paragraph after that h1 starts with it, the paragraph is dropped (the page renders the description itself; hyle derives it, capped, from that paragraph).
99
- * @throws HastLimitError when the tree has more than 20,000 nodes or 512 KiB of text (hyle's own renderer caps).
113
+ * True when drawing `source` would freeze the page long enough that the reader should ask for it. Mermaid lays a diagram out in one
114
+ * uninterrupted task, so this is the only defence, and it must not be easy to slip under with ordinary syntax. It is true when `edgeBound`
115
+ * exceeds the edge limit, so for every diagram whose relations have a link token Mermaid draws no more than that when it is false.
116
+ * Sankey flows, requirement `<-` relations and C4 `Rel()` have none: only the statement, word and character limits bound those (0.2 s for
117
+ * 135 requirement relations and for 249 sankey flows, in Chromium at 1x). The price is that a label which only looks like a link counts as one, and ` & ` operands cost
118
+ * quadratically wherever they sit, so some 17 of them gate a diagram of any size: that is the safe direction. Its own cost is bounded:
119
+ * above AUTO_RENDER_CHARS it answers before reading anything (it runs on the server for every fence), and below that every pass is linear.
100
120
  */
101
- declare function sanitizeHast(tree: unknown, title?: string, description?: string | null): Root;
121
+ declare function isLargeDiagram(source: string): boolean;
122
+
123
+ /** `loaded` must settle (never reject) once every diagram it mounts has registered; a failed load settles it too. */
124
+ declare function holdPrintUntil(loaded: Promise<unknown>): void;
125
+ /**
126
+ * Ctrl/Cmd+P while a diagram is not drawn yet: hold the browser's print, draw every diagram, then call `window.print()`.
127
+ * Otherwise the key is left alone. Escape during the wait cancels the print.
128
+ * File > Print cannot be intercepted and still prints the source.
129
+ * Every MermaidDiagram installs it. One document listener serves every caller: it goes with the last cleanup, which
130
+ * also cancels a wait in progress.
131
+ * shortcut: the budgets and Escape are only served between tasks. Mermaid lays a diagram out in one synchronous task, so a diagram that
132
+ * is one huge layout holds the press until that layout ends, timers and Escape included; upgrade by not drawing such diagrams at all.
133
+ */
134
+ declare function installPrintShortcut(): () => void;
102
135
 
103
136
  /**
104
137
  * Chrome strings of the Comments component (en, fr, es). The fr and es copy is a draft and has not been reviewed by a native
@@ -137,6 +170,7 @@ interface CommentStrings {
137
170
  readonly removed: string;
138
171
  readonly removedByModerator: string;
139
172
  readonly removedByAuthor: string;
173
+ readonly unrenderable: string;
140
174
  readonly depthEnd: string;
141
175
  readonly held: string;
142
176
  readonly heldBanner: string;
@@ -165,6 +199,37 @@ interface CommentStrings {
165
199
  readonly more: string;
166
200
  readonly truncated: string;
167
201
  readonly justNow: string;
202
+ readonly react: string;
203
+ readonly reactions: string;
204
+ readonly reactionLike: string;
205
+ readonly reactionLove: string;
206
+ readonly reactionInsightful: string;
207
+ readonly reactionCelebrate: string;
208
+ readonly reactionSignIn: string;
209
+ readonly reactionAddedLive: string;
210
+ readonly reactionRemovedLive: string;
211
+ readonly reactionsLoading: string;
212
+ readonly reactionsError: string;
213
+ readonly votesOn: string;
214
+ readonly score: string;
215
+ readonly upvote: string;
216
+ readonly downvote: string;
217
+ readonly upvoteSignIn: string;
218
+ readonly downvoteSignIn: string;
219
+ readonly upvotedLive: string;
220
+ readonly downvotedLive: string;
221
+ readonly voteRemovedLive: string;
222
+ readonly voteRefused: string;
223
+ readonly slowDown: string;
224
+ readonly sort: string;
225
+ readonly sortNewest: string;
226
+ readonly sortTop: string;
227
+ readonly sortedNewestLive: string;
228
+ readonly sortedTopLive: string;
229
+ readonly sortError: string;
230
+ readonly newerLater: string;
231
+ readonly moreError: string;
232
+ readonly loadedLive: string;
168
233
  }
169
234
 
170
235
  /**
@@ -187,6 +252,14 @@ declare const en: {
187
252
  warning: string;
188
253
  tip: string;
189
254
  caution: string;
255
+ important: string;
256
+ copyCode: string;
257
+ copied: string;
258
+ copyBlocked: string;
259
+ done: string;
260
+ notDone: string;
261
+ playVideo: string;
262
+ videoFrame: string;
190
263
  diagram: string;
191
264
  diagramError: string;
192
265
  diagramLoading: string;
@@ -228,6 +301,17 @@ type Strings = typeof en;
228
301
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
229
302
  declare function stringsFor(locale: string | undefined): Strings;
230
303
 
304
+ interface HyleTocProps {
305
+ /** `toc` from an article result; only h2 and h3 entries are listed. */
306
+ toc: readonly TocEntry[];
307
+ /** "rail": a sticky aside with scroll-spy, for the host's side column. "inline": a collapsed `<details>` to put above the body. */
308
+ variant: "rail" | "inline";
309
+ /** Rail only: shown under the list. */
310
+ aside?: ReactNode;
311
+ locale?: string | undefined;
312
+ }
313
+ /** The contents list for a page the host owns. Which variant shows at which width is the host's layout decision. */
314
+ declare function HyleToc({ toc, variant, aside, locale }: HyleTocProps): ReactElement | null;
231
315
  interface ArticlePageProps extends PageBaseProps {
232
316
  article: ResolvedArticle;
233
317
  /**
@@ -288,7 +372,7 @@ interface RedirectingProps extends PageBaseProps {
288
372
  declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
289
373
 
290
374
  /**
291
- * The comments and likes section of an article (ADR 0017). It is fetched in the browser, uncached, after the cached article
375
+ * The comments, votes and reactions section of an article (ADR 0017, 0021). It is fetched in the browser, uncached, after the cached article
292
376
  * has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
293
377
  * credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
294
378
  * into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
@@ -309,9 +393,32 @@ interface CommentsProps {
309
393
  readonly initial?: EngageListing | undefined;
310
394
  /** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
311
395
  readonly initialAt?: number | undefined;
396
+ /**
397
+ * Fetch nothing until the section is about to scroll into view (within 600px), so a statically cached page costs no request for
398
+ * readers who never get there. Without IntersectionObserver it loads at once. Default false.
399
+ */
400
+ readonly lazy?: boolean | undefined;
401
+ /** The article's own reactions above the thread. Set false when the page already has `HyleReactions`. Default true. */
402
+ readonly articleReactions?: boolean | undefined;
312
403
  }
313
- declare function Comments({ path, endpoint, signInHref, locale, labels: s, initial, initialAt }: CommentsProps): ReactElement | null;
404
+ declare function Comments(props: CommentsProps): ReactElement;
405
+
406
+ interface HyleReactionsProps {
407
+ /** The article's canonical site path (`publication.canonical_path`). */
408
+ readonly path: string;
409
+ /** The same object `ArticlePage` takes: `endpoint` (default "/api/hyle/engage") and `signInHref`. */
410
+ readonly engagement: EngagementConfig;
411
+ /** BCP 47. English, French and Spanish strings ship; anything else is English. Default "en". */
412
+ readonly locale?: string | undefined;
413
+ }
414
+ /**
415
+ * The article's reactions, on their own (for example under the title). Fetched in the browser through the host's
416
+ * `createEngagementRoute`, like `Comments`; renders nothing when engagement is off or the article is unknown.
417
+ * hyle has no counts-only endpoint, so it reads the first page `Comments` reads (the two share the request when they load
418
+ * together) and uses its article fields. It reads on mount even beside a `lazy` `Comments`.
419
+ */
420
+ declare function HyleReactions(props: HyleReactionsProps): ReactElement;
314
421
 
315
422
  declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
316
423
 
317
- export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HastLimitError, HyleComponents, JsonLdConfig, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
424
+ export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HyleBody, type HyleBodyProps, HyleComponents, HyleReactions, type HyleReactionsProps, HyleToc, type HyleTocProps, JsonLdConfig, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, VIEWER_LABELS_EN, type ViewerLabels, holdPrintUntil, installPrintShortcut, isClampedSource, isLargeDiagram, stringsFor, stripMermaidConfig };
package/dist/react.js CHANGED
@@ -3,20 +3,31 @@ import {
3
3
  Comments,
4
4
  DocsPage,
5
5
  HastContent,
6
- HastLimitError,
7
6
  HyleArticleView,
7
+ HyleBody,
8
8
  HyleListView,
9
+ HyleReactions,
10
+ HyleToc,
9
11
  ListPage,
10
12
  MermaidDiagram,
11
13
  NotFound,
12
14
  Redirecting,
13
15
  TrustedServerHtml,
14
16
  Unavailable,
17
+ holdPrintUntil,
18
+ installPrintShortcut,
19
+ isClampedSource,
20
+ isLargeDiagram,
21
+ stripMermaidConfig
22
+ } from "./chunk-HJX57NLI.js";
23
+ import {
24
+ HastLimitError,
25
+ VIEWER_LABELS_EN,
15
26
  isSafeUrl,
16
27
  sanitizeHast,
17
28
  scopeId,
18
29
  stringsFor
19
- } from "./chunk-DMK4XQLU.js";
30
+ } from "./chunk-56Y24XBV.js";
20
31
  import "./chunk-67IOIAVW.js";
21
32
  export {
22
33
  ArticlePage,
@@ -25,15 +36,24 @@ export {
25
36
  HastContent,
26
37
  HastLimitError,
27
38
  HyleArticleView,
39
+ HyleBody,
28
40
  HyleListView,
41
+ HyleReactions,
42
+ HyleToc,
29
43
  ListPage,
30
44
  MermaidDiagram,
31
45
  NotFound,
32
46
  Redirecting,
33
47
  TrustedServerHtml,
34
48
  Unavailable,
49
+ VIEWER_LABELS_EN,
50
+ holdPrintUntil,
51
+ installPrintShortcut,
52
+ isClampedSource,
53
+ isLargeDiagram,
35
54
  isSafeUrl,
36
55
  sanitizeHast,
37
56
  scopeId,
38
- stringsFor
57
+ stringsFor,
58
+ stripMermaidConfig
39
59
  };