@tdacorp/hyle-sdk 0.17.0 → 0.22.2
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/README.md +261 -42
- package/dist/check-routes-bin.js +190 -53
- package/dist/{chunk-6VOHFFA5.js → chunk-7T5EEJHK.js} +2 -2
- package/dist/chunk-DUPT6XLB.js +57 -0
- package/dist/chunk-IW3TUD4G.js +841 -0
- package/dist/{chunk-MGSUQBDW.js → chunk-KU7LWK4E.js} +249 -24
- package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
- package/dist/chunk-SFFBZFEN.js +178 -0
- package/dist/chunk-U74B7AUG.js +398 -0
- package/dist/chunk-ZIW6FDU2.js +1126 -0
- package/dist/client-BGjmEWhN.d.cts +207 -0
- package/dist/client-D0LTpr3Y.d.ts +207 -0
- package/dist/code-copy.cjs +74 -0
- package/dist/code-copy.d.cts +18 -0
- package/dist/code-copy.d.ts +18 -0
- package/dist/code-copy.js +50 -0
- package/dist/comments.cjs +738 -280
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +419 -331
- package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-DNTZ2UXv.d.ts → embed-CbtsbZs3.d.cts} +5 -3
- package/dist/{embed-BmdwA2G9.d.cts → embed-Cf_2ZR5x.d.ts} +5 -3
- package/dist/fragment-alias.cjs +51 -0
- package/dist/fragment-alias.d.cts +7 -0
- package/dist/fragment-alias.d.ts +7 -0
- package/dist/fragment-alias.js +27 -0
- package/dist/html.cjs +886 -0
- package/dist/html.d.cts +20 -0
- package/dist/html.d.ts +20 -0
- package/dist/html.js +45 -0
- package/dist/index.cjs +244 -24
- package/dist/index.d.cts +22 -68
- package/dist/index.d.ts +22 -68
- package/dist/index.js +12 -2
- package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.cts} +9 -0
- package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.ts} +9 -0
- package/dist/mermaid-diagram.cjs +441 -125
- package/dist/mermaid-diagram.d.cts +23 -7
- package/dist/mermaid-diagram.d.ts +23 -7
- package/dist/mermaid-diagram.js +213 -51
- package/dist/mermaid-image.cjs +137 -60
- package/dist/mermaid-image.d.cts +4 -3
- package/dist/mermaid-image.d.ts +4 -3
- package/dist/mermaid-image.js +27 -28
- package/dist/next.cjs +836 -304
- package/dist/next.d.cts +45 -20
- package/dist/next.d.ts +45 -20
- package/dist/next.js +151 -40
- package/dist/print-coordinator.cjs +157 -0
- package/dist/print-coordinator.d.cts +27 -0
- package/dist/print-coordinator.d.ts +27 -0
- package/dist/print-coordinator.js +83 -0
- package/dist/react.cjs +603 -240
- package/dist/react.d.cts +148 -30
- package/dist/react.d.ts +148 -30
- package/dist/react.js +26 -4
- package/dist/reactions.cjs +653 -0
- package/dist/reactions.d.cts +27 -0
- package/dist/reactions.d.ts +27 -0
- package/dist/reactions.js +364 -0
- package/dist/{resolve-euZ4-aC9.d.cts → resolve-BnIv7aB7.d.cts} +2 -2
- package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BysHtZ_i.d.ts} +2 -2
- package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
- package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
- package/dist/sanitize-BpY_AdZh.d.cts +23 -0
- package/dist/sanitize-BpY_AdZh.d.ts +23 -0
- package/dist/styles.css +100 -29
- package/dist/toc-spy.cjs +60 -0
- package/dist/toc-spy.d.cts +15 -0
- package/dist/toc-spy.d.ts +15 -0
- package/dist/toc-spy.js +36 -0
- package/dist/{types-Czt887Iv.d.cts → types-D09Z072G.d.cts} +57 -2
- package/dist/{types-Czt887Iv.d.ts → types-D09Z072G.d.ts} +57 -2
- package/dist/use-cache.cjs +89 -13
- package/dist/use-cache.d.cts +12 -5
- package/dist/use-cache.d.ts +12 -5
- package/dist/use-cache.js +8 -8
- package/dist/youtube-facade.cjs +50 -0
- package/dist/youtube-facade.d.cts +17 -0
- package/dist/youtube-facade.d.ts +17 -0
- package/dist/youtube-facade.js +26 -0
- package/package.json +16 -3
- package/dist/chunk-67IOIAVW.js +0 -35
- package/dist/chunk-DMK4XQLU.js +0 -1556
- package/dist/chunk-PJMJMP66.js +0 -63
- package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
- package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
package/dist/react.d.cts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
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-
|
|
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-
|
|
5
|
-
|
|
6
|
-
import {
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-CbtsbZs3.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-CbtsbZs3.cjs';
|
|
5
|
+
export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-BpY_AdZh.cjs';
|
|
6
|
+
import { j as ResolvedArticle, L as ListItem, o as TocEntry, l as ResolvedList, c as EngageListing, T as ThemeRef } from './types-D09Z072G.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. */
|
|
10
11
|
tree: unknown;
|
|
11
12
|
/** The page title; a leading body h1 that repeats it is dropped. */
|
|
12
13
|
title?: string;
|
|
13
|
-
/** The page description; a leading body paragraph that
|
|
14
|
+
/** The page description; a leading body paragraph that is exactly it is dropped. */
|
|
14
15
|
description?: string | null;
|
|
15
16
|
components?: HyleComponents;
|
|
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(
|
|
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
|
-
*
|
|
67
|
-
* base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that
|
|
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(
|
|
102
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
82
103
|
|
|
104
|
+
declare const isClampedSource: (source: string) => boolean;
|
|
83
105
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
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
|
|
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
|
|
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,43 @@ 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;
|
|
403
|
+
}
|
|
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;
|
|
312
413
|
}
|
|
313
|
-
|
|
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
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Links a themed workspace's stylesheet (hyle ADR 0036) from the host's own asset route (`createAssetRoute`), so a strict
|
|
426
|
+
* `style-src 'self'` and `font-src 'self'` CSP is enough. `precedence` makes React 19 put the link in the head and hold the
|
|
427
|
+
* paint until it has loaded, so there is no flash of the default theme. The URL is built from the scope and the hash alone,
|
|
428
|
+
* both checked as hex: nothing else hyle sends can become a stylesheet address. Renders nothing without a theme. The SDK's pages and embeds render it; a host
|
|
429
|
+
* that renders `HyleBody` itself passes the answer's `theme`.
|
|
430
|
+
*/
|
|
431
|
+
declare function HyleTheme({ theme }: {
|
|
432
|
+
theme?: ThemeRef | undefined;
|
|
433
|
+
}): ReactElement | null;
|
|
434
|
+
|
|
435
|
+
export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HyleBody, type HyleBodyProps, HyleComponents, HyleReactions, type HyleReactionsProps, HyleTheme, 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,22 +1,23 @@
|
|
|
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-
|
|
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-
|
|
5
|
-
|
|
6
|
-
import {
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { H as HyleComponents, P as PageBaseProps, E as EngagementConfig, J as JsonLdConfig } from './embed-Cf_2ZR5x.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-Cf_2ZR5x.js';
|
|
5
|
+
export { H as HastLimitError, i as isSafeUrl, s as sanitizeHast, a as scopeId } from './sanitize-BpY_AdZh.js';
|
|
6
|
+
import { j as ResolvedArticle, L as ListItem, o as TocEntry, l as ResolvedList, c as EngageListing, T as ThemeRef } from './types-D09Z072G.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. */
|
|
10
11
|
tree: unknown;
|
|
11
12
|
/** The page title; a leading body h1 that repeats it is dropped. */
|
|
12
13
|
title?: string;
|
|
13
|
-
/** The page description; a leading body paragraph that
|
|
14
|
+
/** The page description; a leading body paragraph that is exactly it is dropped. */
|
|
14
15
|
description?: string | null;
|
|
15
16
|
components?: HyleComponents;
|
|
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(
|
|
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
|
-
*
|
|
67
|
-
* base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that
|
|
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(
|
|
102
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
82
103
|
|
|
104
|
+
declare const isClampedSource: (source: string) => boolean;
|
|
83
105
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
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
|
|
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
|
|
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,43 @@ 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;
|
|
403
|
+
}
|
|
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;
|
|
312
413
|
}
|
|
313
|
-
|
|
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
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Links a themed workspace's stylesheet (hyle ADR 0036) from the host's own asset route (`createAssetRoute`), so a strict
|
|
426
|
+
* `style-src 'self'` and `font-src 'self'` CSP is enough. `precedence` makes React 19 put the link in the head and hold the
|
|
427
|
+
* paint until it has loaded, so there is no flash of the default theme. The URL is built from the scope and the hash alone,
|
|
428
|
+
* both checked as hex: nothing else hyle sends can become a stylesheet address. Renders nothing without a theme. The SDK's pages and embeds render it; a host
|
|
429
|
+
* that renders `HyleBody` itself passes the answer's `theme`.
|
|
430
|
+
*/
|
|
431
|
+
declare function HyleTheme({ theme }: {
|
|
432
|
+
theme?: ThemeRef | undefined;
|
|
433
|
+
}): ReactElement | null;
|
|
434
|
+
|
|
435
|
+
export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps, HyleBody, type HyleBodyProps, HyleComponents, HyleReactions, type HyleReactionsProps, HyleTheme, 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,21 +3,33 @@ import {
|
|
|
3
3
|
Comments,
|
|
4
4
|
DocsPage,
|
|
5
5
|
HastContent,
|
|
6
|
-
HastLimitError,
|
|
7
6
|
HyleArticleView,
|
|
7
|
+
HyleBody,
|
|
8
8
|
HyleListView,
|
|
9
|
+
HyleReactions,
|
|
10
|
+
HyleTheme,
|
|
11
|
+
HyleToc,
|
|
9
12
|
ListPage,
|
|
10
13
|
MermaidDiagram,
|
|
11
14
|
NotFound,
|
|
12
15
|
Redirecting,
|
|
13
16
|
TrustedServerHtml,
|
|
14
17
|
Unavailable,
|
|
18
|
+
holdPrintUntil,
|
|
19
|
+
installPrintShortcut,
|
|
20
|
+
isClampedSource,
|
|
21
|
+
isLargeDiagram,
|
|
22
|
+
stripMermaidConfig
|
|
23
|
+
} from "./chunk-ZIW6FDU2.js";
|
|
24
|
+
import {
|
|
25
|
+
HastLimitError,
|
|
26
|
+
VIEWER_LABELS_EN,
|
|
15
27
|
isSafeUrl,
|
|
16
28
|
sanitizeHast,
|
|
17
29
|
scopeId,
|
|
18
30
|
stringsFor
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
31
|
+
} from "./chunk-IW3TUD4G.js";
|
|
32
|
+
import "./chunk-DUPT6XLB.js";
|
|
21
33
|
export {
|
|
22
34
|
ArticlePage,
|
|
23
35
|
Comments,
|
|
@@ -25,15 +37,25 @@ export {
|
|
|
25
37
|
HastContent,
|
|
26
38
|
HastLimitError,
|
|
27
39
|
HyleArticleView,
|
|
40
|
+
HyleBody,
|
|
28
41
|
HyleListView,
|
|
42
|
+
HyleReactions,
|
|
43
|
+
HyleTheme,
|
|
44
|
+
HyleToc,
|
|
29
45
|
ListPage,
|
|
30
46
|
MermaidDiagram,
|
|
31
47
|
NotFound,
|
|
32
48
|
Redirecting,
|
|
33
49
|
TrustedServerHtml,
|
|
34
50
|
Unavailable,
|
|
51
|
+
VIEWER_LABELS_EN,
|
|
52
|
+
holdPrintUntil,
|
|
53
|
+
installPrintShortcut,
|
|
54
|
+
isClampedSource,
|
|
55
|
+
isLargeDiagram,
|
|
35
56
|
isSafeUrl,
|
|
36
57
|
sanitizeHast,
|
|
37
58
|
scopeId,
|
|
38
|
-
stringsFor
|
|
59
|
+
stringsFor,
|
|
60
|
+
stripMermaidConfig
|
|
39
61
|
};
|