@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.
- package/README.md +171 -32
- package/dist/check-routes-bin.js +48 -21
- package/dist/chunk-56Y24XBV.js +840 -0
- package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
- package/dist/chunk-HJX57NLI.js +1105 -0
- package/dist/chunk-K5VDLROQ.js +145 -0
- package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
- package/dist/chunk-U74B7AUG.js +398 -0
- package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
- package/dist/client-41fU6OY2.d.cts +201 -0
- package/dist/client-LwzHwqpM.d.ts +201 -0
- package/dist/code-copy.cjs +72 -0
- package/dist/code-copy.d.cts +15 -0
- package/dist/code-copy.d.ts +15 -0
- package/dist/code-copy.js +48 -0
- package/dist/comments.cjs +733 -278
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +414 -330
- package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-XY3CG75U.js} +107 -46
- package/dist/{embed-B76zRRPa.d.cts → embed-BUFRQboD.d.ts} +10 -5
- package/dist/{embed-SqOBGI-E.d.ts → embed-CYt-q13P.d.cts} +10 -5
- 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 +881 -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 +181 -14
- package/dist/index.d.cts +14 -62
- package/dist/index.d.ts +14 -62
- package/dist/index.js +11 -1
- package/dist/labels-CrA-iqTN.d.cts +46 -0
- package/dist/labels-CrA-iqTN.d.ts +46 -0
- package/dist/mermaid-diagram.cjs +453 -148
- package/dist/mermaid-diagram.d.cts +25 -42
- package/dist/mermaid-diagram.d.ts +25 -42
- package/dist/mermaid-diagram.js +205 -50
- package/dist/mermaid-image.cjs +1456 -0
- package/dist/mermaid-image.d.cts +30 -0
- package/dist/mermaid-image.d.ts +30 -0
- package/dist/mermaid-image.js +93 -0
- package/dist/next.cjs +1709 -1134
- package/dist/next.d.cts +67 -14
- package/dist/next.d.ts +67 -14
- package/dist/next.js +950 -794
- 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 +677 -264
- package/dist/react.d.cts +161 -31
- package/dist/react.d.ts +161 -31
- package/dist/react.js +23 -3
- 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-DC2ccfwA.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
- package/dist/{resolve-DKLVftk_.d.cts → resolve-eI1muCKL.d.cts} +2 -2
- package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
- package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
- package/dist/sanitize-ijiWjEm9.d.cts +23 -0
- package/dist/sanitize-ijiWjEm9.d.ts +23 -0
- package/dist/styles.css +107 -47
- package/dist/toc-spy.cjs +59 -0
- package/dist/toc-spy.d.cts +15 -0
- package/dist/toc-spy.d.ts +15 -0
- package/dist/toc-spy.js +35 -0
- package/dist/{types-ByodIyEv.d.cts → types-3F0wqD-o.d.cts} +44 -4
- package/dist/{types-ByodIyEv.d.ts → types-3F0wqD-o.d.ts} +44 -4
- package/dist/use-cache.cjs +37 -11
- package/dist/use-cache.d.cts +12 -5
- package/dist/use-cache.d.ts +12 -5
- package/dist/use-cache.js +7 -7
- 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-4V4VKB3O.js +0 -1471
- package/dist/chunk-R5EMI4HQ.js +0 -61
- 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,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-
|
|
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-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(
|
|
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;
|
|
@@ -73,30 +94,44 @@ interface MermaidDiagramProps {
|
|
|
73
94
|
title: string;
|
|
74
95
|
/** Shown when Mermaid cannot render the source. */
|
|
75
96
|
errorText: string;
|
|
76
|
-
/**
|
|
97
|
+
/** Accessible name of the loader shown while the diagram renders (English when omitted). */
|
|
98
|
+
loadingText?: string;
|
|
99
|
+
/** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
|
|
77
100
|
labels?: ViewerLabels;
|
|
78
101
|
}
|
|
79
|
-
declare function MermaidDiagram(
|
|
102
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
80
103
|
|
|
104
|
+
declare const isClampedSource: (source: string) => boolean;
|
|
81
105
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
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.
|
|
86
110
|
*/
|
|
87
|
-
|
|
88
|
-
declare class HastLimitError extends Error {
|
|
89
|
-
constructor(message: string);
|
|
90
|
-
}
|
|
91
|
-
declare const scopeId: (id: string) => string;
|
|
92
|
-
/** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
|
|
93
|
-
declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
|
|
111
|
+
declare function stripMermaidConfig(source: string): string;
|
|
94
112
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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.
|
|
98
120
|
*/
|
|
99
|
-
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;
|
|
100
135
|
|
|
101
136
|
/**
|
|
102
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
|
|
@@ -135,6 +170,7 @@ interface CommentStrings {
|
|
|
135
170
|
readonly removed: string;
|
|
136
171
|
readonly removedByModerator: string;
|
|
137
172
|
readonly removedByAuthor: string;
|
|
173
|
+
readonly unrenderable: string;
|
|
138
174
|
readonly depthEnd: string;
|
|
139
175
|
readonly held: string;
|
|
140
176
|
readonly heldBanner: string;
|
|
@@ -163,6 +199,37 @@ interface CommentStrings {
|
|
|
163
199
|
readonly more: string;
|
|
164
200
|
readonly truncated: string;
|
|
165
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;
|
|
166
233
|
}
|
|
167
234
|
|
|
168
235
|
/**
|
|
@@ -185,13 +252,27 @@ declare const en: {
|
|
|
185
252
|
warning: string;
|
|
186
253
|
tip: string;
|
|
187
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;
|
|
188
263
|
diagram: string;
|
|
189
264
|
diagramError: string;
|
|
265
|
+
diagramLoading: string;
|
|
266
|
+
diagramSource: string;
|
|
190
267
|
contentError: string;
|
|
191
268
|
fallbackTitle: string;
|
|
192
269
|
fallbackBody: string;
|
|
270
|
+
readingTime: string;
|
|
271
|
+
readingTimeLabel: string;
|
|
193
272
|
older: string;
|
|
194
273
|
viewAll: string;
|
|
274
|
+
moreInSection: string;
|
|
275
|
+
subPages: string;
|
|
195
276
|
readAtSource: string;
|
|
196
277
|
emptyTitle: string;
|
|
197
278
|
emptyBody: string;
|
|
@@ -220,6 +301,17 @@ type Strings = typeof en;
|
|
|
220
301
|
/** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
|
|
221
302
|
declare function stringsFor(locale: string | undefined): Strings;
|
|
222
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;
|
|
223
315
|
interface ArticlePageProps extends PageBaseProps {
|
|
224
316
|
article: ResolvedArticle;
|
|
225
317
|
/**
|
|
@@ -233,9 +325,20 @@ interface ArticlePageProps extends PageBaseProps {
|
|
|
233
325
|
jsonLd?: JsonLdConfig | undefined;
|
|
234
326
|
/** The validated og:image URL, put in the BlogPosting `image`. */
|
|
235
327
|
imageUrl?: string | undefined;
|
|
328
|
+
/** The image's size when known, so the BlogPosting `image` becomes an ImageObject. */
|
|
329
|
+
imageWidth?: number | undefined;
|
|
330
|
+
imageHeight?: number | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* "More in this section" (`items`, the host's choice of siblings) and the article's own `children`, rendered after the pager with
|
|
333
|
+
* `HyleListView`. `hylePage` fills it from the `related` option. A list with no items renders nothing.
|
|
334
|
+
*/
|
|
335
|
+
related?: {
|
|
336
|
+
title?: string | undefined;
|
|
337
|
+
items: readonly ListItem[];
|
|
338
|
+
} | undefined;
|
|
236
339
|
}
|
|
237
340
|
|
|
238
|
-
declare function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, ...base }: ArticlePageProps): ReactElement;
|
|
341
|
+
declare function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }: ArticlePageProps): ReactElement;
|
|
239
342
|
interface ListPageProps extends PageBaseProps {
|
|
240
343
|
list: ResolvedList;
|
|
241
344
|
/** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
|
|
@@ -246,8 +349,12 @@ interface ListPageProps extends PageBaseProps {
|
|
|
246
349
|
origin?: string | undefined;
|
|
247
350
|
/** The list's own site path (what `hylePage` resolved). */
|
|
248
351
|
path?: string | undefined;
|
|
352
|
+
/** With `origin` and `path`, joins the CollectionPage to the host's WebSite and Organization graph (see `JsonLdConfig`). */
|
|
353
|
+
jsonLd?: JsonLdConfig | undefined;
|
|
354
|
+
/** The page's `?cursor=`, put in the JSON-LD url and @id. */
|
|
355
|
+
cursor?: string | undefined;
|
|
249
356
|
}
|
|
250
|
-
declare function ListPage({ list, olderHref, description, origin, path, ...base }: ListPageProps): ReactElement;
|
|
357
|
+
declare function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }: ListPageProps): ReactElement;
|
|
251
358
|
interface NotFoundProps extends PageBaseProps {
|
|
252
359
|
/** The path that was not found, shown to the visitor. */
|
|
253
360
|
path?: string;
|
|
@@ -265,7 +372,7 @@ interface RedirectingProps extends PageBaseProps {
|
|
|
265
372
|
declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
|
|
266
373
|
|
|
267
374
|
/**
|
|
268
|
-
* 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
|
|
269
376
|
* has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
|
|
270
377
|
* credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
|
|
271
378
|
* into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
|
|
@@ -286,9 +393,32 @@ interface CommentsProps {
|
|
|
286
393
|
readonly initial?: EngageListing | undefined;
|
|
287
394
|
/** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
|
|
288
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;
|
|
289
413
|
}
|
|
290
|
-
|
|
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;
|
|
291
421
|
|
|
292
422
|
declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
|
|
293
423
|
|
|
294
|
-
export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps,
|
|
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-
|
|
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-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(
|
|
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;
|
|
@@ -73,30 +94,44 @@ interface MermaidDiagramProps {
|
|
|
73
94
|
title: string;
|
|
74
95
|
/** Shown when Mermaid cannot render the source. */
|
|
75
96
|
errorText: string;
|
|
76
|
-
/**
|
|
97
|
+
/** Accessible name of the loader shown while the diagram renders (English when omitted). */
|
|
98
|
+
loadingText?: string;
|
|
99
|
+
/** Strings of the large-diagram notice, the print note and the diagram viewer (English when omitted). */
|
|
77
100
|
labels?: ViewerLabels;
|
|
78
101
|
}
|
|
79
|
-
declare function MermaidDiagram(
|
|
102
|
+
declare function MermaidDiagram(props: MermaidDiagramProps): react.JSX.Element;
|
|
80
103
|
|
|
104
|
+
declare const isClampedSource: (source: string) => boolean;
|
|
81
105
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
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.
|
|
86
110
|
*/
|
|
87
|
-
|
|
88
|
-
declare class HastLimitError extends Error {
|
|
89
|
-
constructor(message: string);
|
|
90
|
-
}
|
|
91
|
-
declare const scopeId: (id: string) => string;
|
|
92
|
-
/** Accepts a site-relative path, a fragment (href only), or an absolute http(s) URL (mailto for href only). */
|
|
93
|
-
declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
|
|
111
|
+
declare function stripMermaidConfig(source: string): string;
|
|
94
112
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
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.
|
|
98
120
|
*/
|
|
99
|
-
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;
|
|
100
135
|
|
|
101
136
|
/**
|
|
102
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
|
|
@@ -135,6 +170,7 @@ interface CommentStrings {
|
|
|
135
170
|
readonly removed: string;
|
|
136
171
|
readonly removedByModerator: string;
|
|
137
172
|
readonly removedByAuthor: string;
|
|
173
|
+
readonly unrenderable: string;
|
|
138
174
|
readonly depthEnd: string;
|
|
139
175
|
readonly held: string;
|
|
140
176
|
readonly heldBanner: string;
|
|
@@ -163,6 +199,37 @@ interface CommentStrings {
|
|
|
163
199
|
readonly more: string;
|
|
164
200
|
readonly truncated: string;
|
|
165
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;
|
|
166
233
|
}
|
|
167
234
|
|
|
168
235
|
/**
|
|
@@ -185,13 +252,27 @@ declare const en: {
|
|
|
185
252
|
warning: string;
|
|
186
253
|
tip: string;
|
|
187
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;
|
|
188
263
|
diagram: string;
|
|
189
264
|
diagramError: string;
|
|
265
|
+
diagramLoading: string;
|
|
266
|
+
diagramSource: string;
|
|
190
267
|
contentError: string;
|
|
191
268
|
fallbackTitle: string;
|
|
192
269
|
fallbackBody: string;
|
|
270
|
+
readingTime: string;
|
|
271
|
+
readingTimeLabel: string;
|
|
193
272
|
older: string;
|
|
194
273
|
viewAll: string;
|
|
274
|
+
moreInSection: string;
|
|
275
|
+
subPages: string;
|
|
195
276
|
readAtSource: string;
|
|
196
277
|
emptyTitle: string;
|
|
197
278
|
emptyBody: string;
|
|
@@ -220,6 +301,17 @@ type Strings = typeof en;
|
|
|
220
301
|
/** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
|
|
221
302
|
declare function stringsFor(locale: string | undefined): Strings;
|
|
222
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;
|
|
223
315
|
interface ArticlePageProps extends PageBaseProps {
|
|
224
316
|
article: ResolvedArticle;
|
|
225
317
|
/**
|
|
@@ -233,9 +325,20 @@ interface ArticlePageProps extends PageBaseProps {
|
|
|
233
325
|
jsonLd?: JsonLdConfig | undefined;
|
|
234
326
|
/** The validated og:image URL, put in the BlogPosting `image`. */
|
|
235
327
|
imageUrl?: string | undefined;
|
|
328
|
+
/** The image's size when known, so the BlogPosting `image` becomes an ImageObject. */
|
|
329
|
+
imageWidth?: number | undefined;
|
|
330
|
+
imageHeight?: number | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* "More in this section" (`items`, the host's choice of siblings) and the article's own `children`, rendered after the pager with
|
|
333
|
+
* `HyleListView`. `hylePage` fills it from the `related` option. A list with no items renders nothing.
|
|
334
|
+
*/
|
|
335
|
+
related?: {
|
|
336
|
+
title?: string | undefined;
|
|
337
|
+
items: readonly ListItem[];
|
|
338
|
+
} | undefined;
|
|
236
339
|
}
|
|
237
340
|
|
|
238
|
-
declare function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, ...base }: ArticlePageProps): ReactElement;
|
|
341
|
+
declare function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }: ArticlePageProps): ReactElement;
|
|
239
342
|
interface ListPageProps extends PageBaseProps {
|
|
240
343
|
list: ResolvedList;
|
|
241
344
|
/** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
|
|
@@ -246,8 +349,12 @@ interface ListPageProps extends PageBaseProps {
|
|
|
246
349
|
origin?: string | undefined;
|
|
247
350
|
/** The list's own site path (what `hylePage` resolved). */
|
|
248
351
|
path?: string | undefined;
|
|
352
|
+
/** With `origin` and `path`, joins the CollectionPage to the host's WebSite and Organization graph (see `JsonLdConfig`). */
|
|
353
|
+
jsonLd?: JsonLdConfig | undefined;
|
|
354
|
+
/** The page's `?cursor=`, put in the JSON-LD url and @id. */
|
|
355
|
+
cursor?: string | undefined;
|
|
249
356
|
}
|
|
250
|
-
declare function ListPage({ list, olderHref, description, origin, path, ...base }: ListPageProps): ReactElement;
|
|
357
|
+
declare function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }: ListPageProps): ReactElement;
|
|
251
358
|
interface NotFoundProps extends PageBaseProps {
|
|
252
359
|
/** The path that was not found, shown to the visitor. */
|
|
253
360
|
path?: string;
|
|
@@ -265,7 +372,7 @@ interface RedirectingProps extends PageBaseProps {
|
|
|
265
372
|
declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
|
|
266
373
|
|
|
267
374
|
/**
|
|
268
|
-
* 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
|
|
269
376
|
* has rendered, so a like never purges a page. It talks only to the host's own `createEngagementRoute` (same origin): no
|
|
270
377
|
* credential, no hyle URL and no markup built from text ever reaches this file. Comment bodies are server-rendered hast, turned
|
|
271
378
|
* into React elements by `CommentBody`; the reader's own unapproved comment is shown as plain text.
|
|
@@ -286,9 +393,32 @@ interface CommentsProps {
|
|
|
286
393
|
readonly initial?: EngageListing | undefined;
|
|
287
394
|
/** Epoch milliseconds `initial` was fetched at: the first render's clock, so relative times hydrate identically. The real clock takes over on mount. */
|
|
288
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;
|
|
289
413
|
}
|
|
290
|
-
|
|
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;
|
|
291
421
|
|
|
292
422
|
declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
|
|
293
423
|
|
|
294
|
-
export { ArticlePage, type ArticlePageProps, Comments, type CommentsProps, DocsPage, EngagementConfig, HastContent, type HastContentProps,
|
|
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 };
|