@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.
- package/README.md +155 -28
- package/dist/check-routes-bin.js +38 -13
- 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 +728 -275
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +409 -326
- package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
- package/dist/{embed-BmdwA2G9.d.cts → embed-BUFRQboD.d.ts} +2 -2
- package/dist/{embed-DNTZ2UXv.d.ts → embed-CYt-q13P.d.cts} +2 -2
- 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-nmukKYgL.d.ts → labels-CrA-iqTN.d.cts} +9 -0
- package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.ts} +9 -0
- package/dist/mermaid-diagram.cjs +401 -125
- package/dist/mermaid-diagram.d.cts +23 -7
- package/dist/mermaid-diagram.d.ts +23 -7
- package/dist/mermaid-diagram.js +204 -51
- package/dist/mermaid-image.cjs +134 -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 +627 -264
- package/dist/next.d.cts +11 -8
- package/dist/next.d.ts +11 -8
- package/dist/next.js +39 -12
- 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 +556 -226
- package/dist/react.d.cts +136 -29
- package/dist/react.d.ts +136 -29
- 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-Ae7UFjsQ.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
- package/dist/{resolve-euZ4-aC9.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 +96 -25
- 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-Czt887Iv.d.cts → types-3F0wqD-o.d.cts} +26 -2
- package/dist/{types-Czt887Iv.d.ts → types-3F0wqD-o.d.ts} +26 -2
- 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-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/styles.css
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
/* END tokens */
|
|
67
67
|
|
|
68
68
|
.hyle{container:hyle/inline-size;display:block;color:var(--h-text);background:var(--h-bg);font-family:var(--h-font-sans);font-size:var(--h-font-size);line-height:var(--h-line-height);-webkit-font-smoothing:antialiased;text-size-adjust:100%}
|
|
69
|
-
.hyle
|
|
69
|
+
.hyle *:where(:not(.katex *)),.hyle *:where(:not(.katex *))::before,.hyle *:where(:not(.katex *))::after{box-sizing:border-box}
|
|
70
70
|
.hyle :where(h1,h2,h3,h4,p,ul,ol,li,figure,blockquote,pre,dl,dd,table){margin:0;padding:0}
|
|
71
71
|
.hyle :where(ul,ol){list-style:none}
|
|
72
72
|
.hyle :where(a){color:inherit}
|
|
@@ -140,6 +140,11 @@
|
|
|
140
140
|
.hyle-toc-list li{padding:0}
|
|
141
141
|
.hyle-toc-list ul ul{padding-left:12px}
|
|
142
142
|
.hyle-toc-list>ul{border-left:1px solid var(--h-hairline);padding-left:12px}
|
|
143
|
+
/* `HyleToc` on a host page: shown wherever the host puts it, and never a size container (a flex column could collapse it) */
|
|
144
|
+
.hyle.hyle-toc-solo{container-type:normal}
|
|
145
|
+
/* One class of specificity, so a host's own selector can still hide the rail at a breakpoint. */
|
|
146
|
+
.hyle-toc-d:where(.hyle-toc-solo){display:block}
|
|
147
|
+
.hyle-toc-solo .hyle-slot-wrap{margin-top:24px}
|
|
143
148
|
@container hyle (min-width:1040px){
|
|
144
149
|
.hyle-article{grid-template-columns:minmax(0,var(--h-measure)) var(--h-toc-width)}
|
|
145
150
|
.hyle-article>.hyle-toc-m{display:none}
|
|
@@ -261,6 +266,8 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
261
266
|
|
|
262
267
|
/* ---- prose layer: rendered markdown, plain semantic elements ---- */
|
|
263
268
|
.hyle-prose{overflow-wrap:break-word}
|
|
269
|
+
/* Nothing a writer positions (a formula's \raisebox, say) paints above or below the article, over the host's own page. */
|
|
270
|
+
@media screen{.hyle-prose{clip-path:inset(-8px -100vw)}}
|
|
264
271
|
.hyle-prose img{max-width:100%;height:auto}
|
|
265
272
|
.hyle-prose>*+*{margin-top:var(--h-paragraph-gap)}
|
|
266
273
|
.hyle-prose :where(h1,h2,h3,h4){font-family:var(--h-font-heading);font-weight:var(--h-heading-weight);letter-spacing:var(--h-heading-tracking);line-height:1.25;color:var(--h-text);scroll-margin-top:calc(var(--h-sticky-top) + 24px);text-wrap:balance;position:relative}
|
|
@@ -271,9 +278,10 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
271
278
|
.hyle-prose :where(h1,h2,h3,h4)+*{margin-top:12px}
|
|
272
279
|
.hyle-prose h2:first-child{margin-top:0;padding-top:0;border-top:0}
|
|
273
280
|
.hyle-anchor{position:absolute;left:-24px;top:0;width:24px;text-align:left;color:var(--h-text-faint);text-decoration:none;font-weight:400;opacity:0}
|
|
281
|
+
.hyle-anchor::before{content:"#"}
|
|
274
282
|
.hyle-prose :is(h2,h3,h4):hover .hyle-anchor,.hyle-anchor:focus-visible{opacity:1}
|
|
275
283
|
.hyle-prose h2 .hyle-anchor{top:var(--h-block-gap)}
|
|
276
|
-
.hyle-prose h2:first-child .hyle-anchor{top:0}
|
|
284
|
+
.hyle-prose h2:first-child .hyle-anchor,.hyle-prose section[data-footnotes] h2 .hyle-anchor{top:0}
|
|
277
285
|
.hyle-prose a:not(.hyle-anchor){color:var(--h-link);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px}
|
|
278
286
|
.hyle-prose a:not(.hyle-anchor):hover{text-decoration-thickness:2px}
|
|
279
287
|
.hyle-prose strong{font-weight:600}
|
|
@@ -325,6 +333,10 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
325
333
|
.hyle-codeblock pre{overflow-x:auto;padding:16px;font:400 var(--h-code-size)/1.65 var(--h-font-mono);tab-size:2;color:var(--h-text)}
|
|
326
334
|
.hyle-codeblock pre code{display:block;width:max-content;min-width:100%;font:inherit;background:none;border:0;padding:0}
|
|
327
335
|
.hyle-prose .hyle-codeblock pre,.hyle-prose .hyle-table table{margin:0}
|
|
336
|
+
.hyle-codeblock>header>button:first-child{margin-left:auto}
|
|
337
|
+
.hyle-codeblock>header>button .hyle-ic+.hyle-ic,.hyle-codeblock>header>button[data-state="copied"] .hyle-ic:first-child{display:none}
|
|
338
|
+
.hyle-codeblock>header>button[data-state="copied"] .hyle-ic+.hyle-ic{display:block;color:var(--h-ok)}
|
|
339
|
+
.hyle-codeblock>header>button[data-state="blocked"]{color:var(--h-bad)}
|
|
328
340
|
.hljs-keyword,.hljs-selector-tag,.hljs-tag,.hljs-doctag,.hljs-section{color:var(--h-syn-keyword)}
|
|
329
341
|
.hljs-string,.hljs-regexp,.hljs-template-variable,.hljs-addition{color:var(--h-syn-string)}
|
|
330
342
|
.hljs-number,.hljs-unit,.hljs-bullet{color:var(--h-syn-number)}
|
|
@@ -338,28 +350,30 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
338
350
|
.hljs-addition{background:color-mix(in srgb,var(--h-ok) 12%,transparent);display:inline-block;width:100%}
|
|
339
351
|
.hljs-deletion{background:color-mix(in srgb,var(--h-bad) 12%,transparent);display:inline-block;width:100%}
|
|
340
352
|
|
|
341
|
-
/* math: KaTeX
|
|
342
|
-
.katex{
|
|
343
|
-
.katex .mord.rm,.katex .mop,.katex .mbin,.katex .mrel,.katex .mopen,.katex .mclose,.katex .mpunct,.katex .num{font-style:normal}
|
|
344
|
-
.katex .mbin,.katex .mrel{margin:0 .28em}
|
|
345
|
-
.katex .msupsub{font-size:.7em;vertical-align:.5em;font-style:normal;line-height:0}
|
|
346
|
-
.katex .mfrac{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;margin:0 .12em;text-align:center}
|
|
347
|
-
.katex .mfrac>span:first-child{padding:0 .2em .1em;border-bottom:1px solid currentColor}
|
|
348
|
-
.katex .mfrac>span:last-child{padding:.1em .2em 0}
|
|
349
|
-
.katex .delim{font-size:2.2em;font-weight:200;font-style:normal;line-height:.8;vertical-align:middle;color:var(--h-text-muted)}
|
|
350
|
-
.katex .text{font-family:var(--h-font-sans);font-style:normal;font-size:.8em}
|
|
351
|
-
.katex-mathml{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
|
|
352
|
-
.katex-display{display:block;overflow-x:auto;text-align:center;padding:16px 0}
|
|
353
|
-
.katex-display .katex{font-size:1.3em}
|
|
353
|
+
/* math: KaTeX's own stylesheet (loaded by the host) draws it; a wide display equation only needs to scroll inside the column */
|
|
354
|
+
.hyle-prose .katex-display{overflow-x:auto;overflow-y:hidden;padding:4px 0}
|
|
354
355
|
|
|
355
356
|
/* figure */
|
|
356
357
|
.hyle-prose figure{margin-inline:0}
|
|
357
358
|
.hyle-prose figure img{display:block;width:100%;height:auto;border:var(--h-border-width) solid var(--h-border);border-radius:var(--h-radius);background:var(--h-surface)}
|
|
358
359
|
.hyle-prose figcaption{margin-top:8px;font-size:14px;line-height:1.5;color:var(--h-text-muted)}
|
|
359
360
|
|
|
361
|
+
/* YouTube: a thumbnail and play button until clicked, then the frame; the plain link stays under it */
|
|
362
|
+
.hyle-prose .hyle-youtube,.hyle-prose .hyle-youtube+*{margin-top:var(--h-block-gap)}
|
|
363
|
+
.hyle-youtube-stage{position:relative;aspect-ratio:16/9;overflow:hidden;border:var(--h-border-width) solid var(--h-border);border-radius:var(--h-radius);background:var(--h-surface-2)}
|
|
364
|
+
.hyle-youtube-stage>*{position:absolute;inset:0;width:100%;height:100%;border:0}
|
|
365
|
+
.hyle-youtube-stage>button{padding:0;background:transparent;cursor:pointer}
|
|
366
|
+
.hyle-youtube-stage>button:focus-visible{outline-offset:-4px}
|
|
367
|
+
.hyle-youtube .hyle-youtube-stage img{width:100%;height:100%;object-fit:cover}
|
|
368
|
+
.hyle-youtube-stage>button::before,.hyle-youtube-stage>button::after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
|
|
369
|
+
.hyle-youtube-stage>button::before{z-index:1;width:64px;height:44px;border-radius:var(--h-radius);background:var(--h-accent)}
|
|
370
|
+
.hyle-youtube-stage>button::after{z-index:2;border-block:9px solid transparent;border-left:15px solid var(--h-on-accent)}
|
|
371
|
+
.hyle-youtube>p{margin-top:8px;font-size:14px}
|
|
372
|
+
|
|
360
373
|
/* callout */
|
|
361
374
|
.hyle-callout{--k:var(--h-text-muted);display:grid;grid-template-columns:20px minmax(0,1fr);gap:12px;padding:16px;border:var(--h-border-width) solid color-mix(in srgb,var(--k) 30%,var(--h-border));border-radius:var(--h-radius);background:color-mix(in srgb,var(--k) 8%,var(--h-surface))}
|
|
362
375
|
.hyle-callout[data-kind="tip"]{--k:var(--h-ok)}
|
|
376
|
+
.hyle-callout[data-kind="important"]{--k:var(--h-link)}
|
|
363
377
|
.hyle-callout[data-kind="warning"]{--k:var(--h-warn)}
|
|
364
378
|
.hyle-callout[data-kind="caution"]{--k:var(--h-bad)}
|
|
365
379
|
.hyle-callout>.hyle-ic{width:20px;height:20px;margin-top:2px;color:var(--k)}
|
|
@@ -368,7 +382,7 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
368
382
|
.hyle-callout .bd{font-size:.9375em;line-height:1.6}
|
|
369
383
|
|
|
370
384
|
/* mermaid placeholder frame */
|
|
371
|
-
.hyle-mermaid{margin-inline:0;border:var(--h-border-width) dashed var(--h-border);border-radius:var(--h-radius);background:var(--h-surface);overflow-x:auto}
|
|
385
|
+
.hyle-mermaid{position:relative;margin-inline:0;border:var(--h-border-width) dashed var(--h-border);border-radius:var(--h-radius);background:var(--h-surface);overflow-x:auto}
|
|
372
386
|
.hyle-mermaid .hyle-stage{display:flex;align-items:center;justify-content:center;gap:0;padding:32px 16px;flex-wrap:wrap;row-gap:12px}
|
|
373
387
|
.hyle-mermaid .node{display:grid;place-items:center;min-width:104px;height:40px;padding:0 12px;border:var(--h-border-width) solid var(--h-border);border-radius:min(var(--h-radius),8px);background:var(--h-surface-2);font:500 13px/1 var(--h-font-mono);color:var(--h-text-muted)}
|
|
374
388
|
.hyle-mermaid .edge{width:32px;height:1px;background:var(--h-border);position:relative}
|
|
@@ -400,11 +414,8 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
400
414
|
.hyle-prose a[data-footnote-backref]{margin-left:4px;text-decoration:none;color:var(--h-link)}
|
|
401
415
|
|
|
402
416
|
@media (prefers-reduced-motion:no-preference){.hyle-btn,.hyle-chips a,.hyle-item,.hyle-pager a,.hyle-toc-list a,.hyle-tree li a{transition:background-color .12s,color .12s}}
|
|
403
|
-
@media print{.hyle-toc-d,.hyle-toc-m,.hyle-nav-d,.hyle-nav-m,.hyle-pager,.hyle-codeblock header button{display:none}.hyle-article,.hyle-docs{display:block}}
|
|
417
|
+
@media print{.hyle-toc-d,.hyle-toc-m,.hyle-nav-d,.hyle-nav-m,.hyle-pager,.hyle-youtube-stage,.hyle-codeblock header button{display:none}.hyle-article,.hyle-docs{display:block}}
|
|
404
418
|
|
|
405
|
-
.katex .mop.lim{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;line-height:1;margin:0 .2em;font-style:normal}
|
|
406
|
-
.katex .mop.lim .sym{font-size:1.6em}
|
|
407
|
-
.katex .mop.lim small{font-size:.65em}
|
|
408
419
|
.hyle-docs-main>.hyle-prose{margin-top:32px}
|
|
409
420
|
.hyle-state>div[data-slot="notfound.body"]{margin-top:16px;color:var(--h-text-muted)}
|
|
410
421
|
.hyle-state>div[data-slot="notfound.body"]>p{margin:0}
|
|
@@ -412,7 +423,8 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
412
423
|
.hyle-nav-m .hyle-side-head{margin:0;padding:12px 12px 0}
|
|
413
424
|
|
|
414
425
|
/* ---- additions not in the design kit (the kit mocks these; the real hast needs them) ---- */
|
|
415
|
-
|
|
426
|
+
/* Hidden text stays hidden in prose even when the host wraps `HastContent` in `.hyle-prose` only. */
|
|
427
|
+
.hyle .sr-only,.hyle-prose .sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
416
428
|
.hyle-mermaid>pre{padding:16px}
|
|
417
429
|
.hyle-mermaid[data-state=pending]{min-height:240px}
|
|
418
430
|
/* A stored render: the box is reserved by aspect-ratio before the image arrives, so nothing shifts. */
|
|
@@ -426,18 +438,62 @@ html:has(.hyle-nav-d:popover-open){overflow:hidden}
|
|
|
426
438
|
.hyle-mermaid-svg{display:flex;justify-content:center;padding:16px;contain:paint}
|
|
427
439
|
.hyle-mermaid-svg svg{position:static!important;max-width:100%;height:auto}
|
|
428
440
|
.hyle-mermaid-note{margin:0;padding:8px 16px;border-top:1px dashed var(--h-border);font-size:13px;color:var(--h-warn)}
|
|
441
|
+
/* inside the box: the clamp's mask and the frame both clip an outline drawn outside it */
|
|
442
|
+
.hyle-mermaid>pre:focus-visible,.hyle-mermaid-source>pre:focus-visible{outline-offset:-2px}
|
|
443
|
+
|
|
444
|
+
/* ---- a large diagram before it is drawn: a notice with the Draw button, then its source, clamped behind a toggle ---- */
|
|
445
|
+
.hyle-mermaid-gate{display:flex;flex-wrap:wrap;align-items:center;gap:12px 24px;padding:16px;border-bottom:var(--h-border-width,1px) dashed var(--h-border,GrayText)}
|
|
446
|
+
.hyle-mermaid-gate-text{flex:1 1 30ch;min-width:0;max-width:68ch}
|
|
447
|
+
.hyle-mermaid-gate-title{margin:0;font-size:15px;font-weight:600;line-height:1.5;color:var(--h-text)}
|
|
448
|
+
.hyle-mermaid-gate-body{margin:4px 0 0;font-size:14px;line-height:1.6;color:var(--h-text-muted)}
|
|
449
|
+
.hyle-mermaid-gate .hyle-mermaid-note{flex-basis:100%;padding:0;border:0}
|
|
450
|
+
.hyle-mermaid-draw{display:block;flex:none;margin:0;padding:6px 14px;border:var(--h-border-width,1px) solid var(--h-border,GrayText);border-radius:var(--h-radius,6px);background:var(--h-surface-2,Canvas);font-family:inherit;font-size:13px;font-weight:500;line-height:1.4;color:var(--h-text,CanvasText);cursor:pointer}
|
|
451
|
+
.hyle-mermaid-draw:hover{border-color:var(--h-accent,Highlight)}
|
|
452
|
+
.hyle-mermaid-draw[aria-disabled=true]{cursor:progress;color:var(--h-text-muted)}
|
|
453
|
+
.hyle-mermaid-draw[aria-disabled=true]:hover{border-color:var(--h-border,GrayText)}
|
|
454
|
+
div.hyle-mermaid-source{position:relative}
|
|
455
|
+
div.hyle-mermaid-source>pre{padding:16px}
|
|
456
|
+
div.hyle-mermaid-source[data-drawing]{display:none}
|
|
457
|
+
.hyle-mermaid-more{display:block;margin:4px 16px 16px;padding:4px 12px;border:var(--h-border-width,1px) solid var(--h-border,GrayText);border-radius:var(--h-radius,6px);background:var(--h-surface,Canvas);font-family:inherit;font-size:13px;font-weight:500;line-height:1.4;color:var(--h-text-muted);cursor:pointer}
|
|
458
|
+
.hyle-mermaid-more:hover{border-color:var(--h-accent,Highlight);color:var(--h-text)}
|
|
459
|
+
div.hyle-mermaid-source[data-clamped]>pre{max-height:15rem;overflow-y:auto;-webkit-mask-image:linear-gradient(#000 calc(100% - 4rem),transparent);mask-image:linear-gradient(#000 calc(100% - 4rem),transparent)}
|
|
460
|
+
/* The server's notice and toggle are inert stand-ins. They show, and a long source is clamped, only where scripting is enabled, so mounting
|
|
461
|
+
moves nothing; a reader without JavaScript keeps the whole source and no notice. */
|
|
462
|
+
.hyle-mermaid-gate[inert],.hyle-mermaid-more[inert]{display:none}
|
|
463
|
+
@media screen and (scripting:enabled){
|
|
464
|
+
.hyle-mermaid-gate[inert]{display:flex}
|
|
465
|
+
.hyle-mermaid-more[inert]{display:block}
|
|
466
|
+
.hyle-mermaid[data-clamp] div.hyle-mermaid-source>pre{max-height:15rem;overflow-y:auto;-webkit-mask-image:linear-gradient(#000 calc(100% - 4rem),transparent);mask-image:linear-gradient(#000 calc(100% - 4rem),transparent)}
|
|
467
|
+
}
|
|
468
|
+
/* While drawing: the spinner turns with transform only, so it runs on the compositor and keeps turning while Mermaid blocks the main thread. */
|
|
469
|
+
.hyle-mermaid-drawing{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;min-height:240px;padding:24px 16px;font-size:14px;line-height:1.6;color:var(--h-text-muted);text-align:center}
|
|
470
|
+
.hyle-mermaid-spinner{width:28px;height:28px;border:3px solid color-mix(in srgb,var(--h-accent,Highlight) 22%,transparent);border-top-color:var(--h-accent,Highlight);border-radius:50%;animation:hyle-mermaid-spin .9s linear infinite;will-change:transform}
|
|
471
|
+
@keyframes hyle-mermaid-spin{to{transform:rotate(1turn)}}
|
|
472
|
+
@media (prefers-reduced-motion:reduce){.hyle-mermaid-spinner{animation:none}}
|
|
473
|
+
|
|
474
|
+
/* ---- print: the whole source of anything not drawn; a diagram drawn in the dark theme goes dark-on-white ---- */
|
|
475
|
+
.hyle-print-status{position:fixed;inset:auto 16px 16px auto;z-index:100;max-width:calc(100vw - 32px);padding:8px 12px;border:1px solid GrayText;border-radius:6px;background:Canvas;color:CanvasText;font:500 13px/1.4 system-ui,sans-serif}
|
|
476
|
+
@media print{
|
|
477
|
+
.hyle-mermaid-gate-body,.hyle-mermaid-draw,.hyle-mermaid-more,.hyle-mermaid-drawing,.hyle-mermaid-hint,.hyle-print-status{display:none}
|
|
478
|
+
div.hyle-mermaid-source[data-drawing]{display:block}
|
|
479
|
+
div.hyle-mermaid-source[data-clamped]>pre{max-height:none;-webkit-mask-image:none;mask-image:none}
|
|
480
|
+
.hyle-mermaid>pre,.hyle-mermaid-source>pre{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
481
|
+
/* Trade-off: a classDef colour in the source is inverted too (hue kept). Redrawing in the light theme is what beforeprint cannot wait for. */
|
|
482
|
+
.hyle-mermaid[data-mermaid-theme=dark]{background:#fff}
|
|
483
|
+
.hyle-mermaid[data-mermaid-theme=dark] .hyle-mermaid-svg svg{filter:invert(1) hue-rotate(180deg)}
|
|
484
|
+
}
|
|
429
485
|
|
|
430
486
|
/* ---- diagram viewer (the click-to-expand trigger and its dialog, loaded on first click) ----
|
|
431
487
|
Public variables: --hyle-viewer-bg, --hyle-viewer-accent, --hyle-viewer-up, --hyle-viewer-down, --hyle-viewer-dim (opacity of dimmed
|
|
432
488
|
parts), --hyle-viewer-backdrop. All fall back to the --hyle-* surface, accent, warn and ok tokens above. */
|
|
433
489
|
.hyle-mermaid-open{position:relative;display:block;width:100%;margin:0;padding:0;border:0;border-radius:inherit;background:none;color:inherit;font:inherit;text-align:inherit;cursor:zoom-in}
|
|
434
|
-
.hyle-mermaid-
|
|
435
|
-
.hyle-mermaid-
|
|
436
|
-
.hyle-mermaid-open:hover .hyle-mermaid-hint,.hyle-mermaid-open:focus-visible .hyle-mermaid-hint{opacity:1}
|
|
490
|
+
.hyle-mermaid-hint{position:absolute;top:8px;right:8px;margin:0;padding:2px 10px;border:var(--h-border-width,1px) solid var(--h-border,GrayText);border-radius:var(--h-radius,6px);background:var(--h-surface-2,Canvas);font:500 12px/1.6 var(--h-font-sans,system-ui,sans-serif);color:var(--h-text-muted,CanvasText);opacity:0;transition:opacity .15s;cursor:zoom-in}
|
|
491
|
+
.hyle-mermaid-open:hover .hyle-mermaid-hint,.hyle-mermaid-hint:focus-visible{opacity:1}
|
|
437
492
|
@media (hover:none){.hyle-mermaid-hint{opacity:1}}
|
|
438
493
|
@media (prefers-reduced-motion:reduce){.hyle-mermaid-hint{transition:none}}
|
|
439
494
|
html.hyle-viewer-lock{overflow:hidden;scrollbar-gutter:stable}
|
|
440
|
-
|
|
495
|
+
/* plain classes set by the viewer, never :has(): each :has rule on <html> is re-checked on every DOM change, and a Mermaid draw makes ~1,500 */
|
|
496
|
+
html.hyle-viewer-lock.hyle-viewer-fs{scrollbar-gutter:auto}
|
|
441
497
|
|
|
442
498
|
.hyle-viewer{--hv-bg:var(--hyle-viewer-bg,var(--h-surface,Canvas));--hv-accent:var(--hyle-viewer-accent,var(--h-accent,#6f9bff));--hv-up:var(--hyle-viewer-up,var(--h-warn,#e0a030));--hv-down:var(--hyle-viewer-down,var(--h-ok,#3fb27f));--hv-dim:var(--hyle-viewer-dim,.16);
|
|
443
499
|
--hv-text:var(--h-text,CanvasText);--hv-muted:var(--h-text-muted,color-mix(in srgb,var(--hv-text) 65%,transparent));--hv-border:var(--h-border,color-mix(in srgb,var(--hv-text) 28%,transparent));--hv-raise:var(--h-surface-2,color-mix(in srgb,var(--hv-text) 8%,var(--hv-bg)));--hv-hairline:var(--h-hairline,color-mix(in srgb,var(--hv-text) 14%,transparent));--hv-focus:var(--h-focus,var(--hv-accent));
|
|
@@ -586,6 +642,21 @@ html.hyle-viewer-lock:has(.hv-shell:fullscreen){scrollbar-gutter:auto}
|
|
|
586
642
|
.hyle-banner{flex-wrap:wrap}
|
|
587
643
|
.hyle-cm[data-status="held"]>article{margin-inline:-8px;padding:8px}
|
|
588
644
|
}
|
|
645
|
+
/* reactions, votes and sort */
|
|
646
|
+
.hyle-reactions{--hc-like-on:var(--hyle-comments-like-on,var(--h-link))}
|
|
647
|
+
.hyle-reactions .hyle-react{margin-top:0;min-height:40px}
|
|
648
|
+
.hyle-react{flex-wrap:wrap}
|
|
649
|
+
.hyle-reaction-set{display:inline-flex;flex-wrap:wrap;align-items:center;gap:8px}
|
|
650
|
+
.hyle-cm-btn.chip[aria-pressed="true"]{color:var(--hc-like-on);font-weight:600}
|
|
651
|
+
.hyle-react .hyle-btn.chip[aria-pressed="true"]{border-color:var(--hc-like-on)}
|
|
652
|
+
.hyle-react .hyle-sk{width:96px;height:40px}
|
|
653
|
+
.hyle-cm-votes{display:inline-flex;align-items:center}
|
|
654
|
+
.hyle-cm-votes .hyle-cm-btn{justify-content:center;min-width:32px}
|
|
655
|
+
.hyle-cm-score{min-width:3ch;text-align:center;font:500 13px/1 var(--h-font-mono);font-variant-numeric:tabular-nums;color:var(--h-text)}
|
|
656
|
+
.hyle-cm-sort{display:inline-flex;gap:4px}
|
|
657
|
+
.hyle-cm-votes .hyle-cm-btn[aria-pressed="true"] .hyle-ic{fill:none;stroke:var(--hc-like-on,currentColor);stroke-width:2.2}
|
|
658
|
+
.hyle-cm-sort .hyle-cm-btn[aria-pressed="true"]{font-weight:600}
|
|
659
|
+
@container hyle (max-width:640px){.hyle-cm-votes .hyle-cm-btn{min-width:40px}}
|
|
589
660
|
.hyle-cm-note{margin-top:16px;font-size:13px;color:var(--h-text-muted)}
|
|
590
661
|
.hyle-cm-reply,.hyle-cm-main>.hyle-cm-compose{margin-top:12px}
|
|
591
662
|
|
package/dist/toc-spy.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/react/toc-spy.tsx
|
|
22
|
+
var toc_spy_exports = {};
|
|
23
|
+
__export(toc_spy_exports, {
|
|
24
|
+
TocSpy: () => TocSpy
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(toc_spy_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var LINE = 0.25;
|
|
30
|
+
var ABOVE_THE_LINE = "1000000px 0px -75% 0px";
|
|
31
|
+
function TocSpy({ ids }) {
|
|
32
|
+
const marker = (0, import_react.useRef)(null);
|
|
33
|
+
const key = ids.join("\n");
|
|
34
|
+
(0, import_react.useEffect)(() => {
|
|
35
|
+
const links = Array.from(marker.current?.parentElement?.querySelectorAll(".hyle-toc-list a[href^='#']") ?? []);
|
|
36
|
+
const headings = key.split("\n").map((id) => document.getElementById(id)).filter((h) => h !== null);
|
|
37
|
+
if (links.length === 0 || headings.length === 0 || typeof IntersectionObserver !== "function") return;
|
|
38
|
+
const update = () => {
|
|
39
|
+
let active = headings[0];
|
|
40
|
+
for (const heading of headings) if (heading.getBoundingClientRect().top <= window.innerHeight * LINE) active = heading;
|
|
41
|
+
for (const link of links) {
|
|
42
|
+
if (link.getAttribute("href") === `#${active.id}`) link.setAttribute("aria-current", "location");
|
|
43
|
+
else link.removeAttribute("aria-current");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const observer = new IntersectionObserver(update, { rootMargin: ABOVE_THE_LINE });
|
|
47
|
+
for (const heading of headings) observer.observe(heading);
|
|
48
|
+
update();
|
|
49
|
+
return () => {
|
|
50
|
+
observer.disconnect();
|
|
51
|
+
for (const link of links) link.removeAttribute("aria-current");
|
|
52
|
+
};
|
|
53
|
+
}, [key]);
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: marker, hidden: true });
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
TocSpy
|
|
59
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface TocSpyProps {
|
|
4
|
+
/** The `id`s of the headings to follow, in document order (already scoped, as in the TOC hrefs). */
|
|
5
|
+
ids: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Scroll-spy for the rail contents list: the link of the last heading reached carries `aria-current="location"`, the first one
|
|
9
|
+
* before that. It works on its parent element's links only, and the links themselves are server HTML. The one element it renders
|
|
10
|
+
* is a hidden marker that locates that parent.
|
|
11
|
+
* shortcut: a last section too short to reach the line never becomes current; add an end marker as `DocsEnhance` has if it matters.
|
|
12
|
+
*/
|
|
13
|
+
declare function TocSpy({ ids }: TocSpyProps): ReactElement;
|
|
14
|
+
|
|
15
|
+
export { TocSpy, type TocSpyProps };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface TocSpyProps {
|
|
4
|
+
/** The `id`s of the headings to follow, in document order (already scoped, as in the TOC hrefs). */
|
|
5
|
+
ids: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Scroll-spy for the rail contents list: the link of the last heading reached carries `aria-current="location"`, the first one
|
|
9
|
+
* before that. It works on its parent element's links only, and the links themselves are server HTML. The one element it renders
|
|
10
|
+
* is a hidden marker that locates that parent.
|
|
11
|
+
* shortcut: a last section too short to reach the line never becomes current; add an end marker as `DocsEnhance` has if it matters.
|
|
12
|
+
*/
|
|
13
|
+
declare function TocSpy({ ids }: TocSpyProps): ReactElement;
|
|
14
|
+
|
|
15
|
+
export { TocSpy, type TocSpyProps };
|
package/dist/toc-spy.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/react/toc-spy.tsx
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var LINE = 0.25;
|
|
7
|
+
var ABOVE_THE_LINE = "1000000px 0px -75% 0px";
|
|
8
|
+
function TocSpy({ ids }) {
|
|
9
|
+
const marker = useRef(null);
|
|
10
|
+
const key = ids.join("\n");
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const links = Array.from(marker.current?.parentElement?.querySelectorAll(".hyle-toc-list a[href^='#']") ?? []);
|
|
13
|
+
const headings = key.split("\n").map((id) => document.getElementById(id)).filter((h) => h !== null);
|
|
14
|
+
if (links.length === 0 || headings.length === 0 || typeof IntersectionObserver !== "function") return;
|
|
15
|
+
const update = () => {
|
|
16
|
+
let active = headings[0];
|
|
17
|
+
for (const heading of headings) if (heading.getBoundingClientRect().top <= window.innerHeight * LINE) active = heading;
|
|
18
|
+
for (const link of links) {
|
|
19
|
+
if (link.getAttribute("href") === `#${active.id}`) link.setAttribute("aria-current", "location");
|
|
20
|
+
else link.removeAttribute("aria-current");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const observer = new IntersectionObserver(update, { rootMargin: ABOVE_THE_LINE });
|
|
24
|
+
for (const heading of headings) observer.observe(heading);
|
|
25
|
+
update();
|
|
26
|
+
return () => {
|
|
27
|
+
observer.disconnect();
|
|
28
|
+
for (const link of links) link.removeAttribute("aria-current");
|
|
29
|
+
};
|
|
30
|
+
}, [key]);
|
|
31
|
+
return /* @__PURE__ */ jsx("span", { ref: marker, hidden: true });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
TocSpy
|
|
35
|
+
};
|
|
@@ -165,6 +165,12 @@ interface Mounts {
|
|
|
165
165
|
readonly cache: CacheInfo;
|
|
166
166
|
}
|
|
167
167
|
type MountsResult = Mounts | ResolvedDisabled;
|
|
168
|
+
/** The reaction kinds hyle accepts. A reader holds at most one of each kind on a subject. */
|
|
169
|
+
type ReactionKind = "like" | "love" | "insightful" | "celebrate";
|
|
170
|
+
/** Reactions on a subject by kind; a kind nobody used is absent. */
|
|
171
|
+
type ReactionCounts = Readonly<Partial<Record<ReactionKind, number>>>;
|
|
172
|
+
/** A comment vote: up or down. */
|
|
173
|
+
type VoteValue = 1 | -1;
|
|
168
174
|
/** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
|
|
169
175
|
interface EngageComment {
|
|
170
176
|
readonly id: string;
|
|
@@ -179,10 +185,16 @@ interface EngageComment {
|
|
|
179
185
|
readonly created_at: string;
|
|
180
186
|
readonly edited_at: string | null;
|
|
181
187
|
readonly like_count: number;
|
|
188
|
+
/** Sum of votes (may be negative; 0 on a tombstone). Absent from a hyle without votes. */
|
|
189
|
+
readonly score?: number;
|
|
190
|
+
/** Absent from a hyle without reaction kinds. */
|
|
191
|
+
readonly reaction_counts?: ReactionCounts;
|
|
182
192
|
/** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
|
|
183
193
|
readonly removed: boolean;
|
|
184
194
|
/** On a tombstone only: who removed it. Absent on a live comment. */
|
|
185
195
|
readonly removed_by?: "moderator" | "author";
|
|
196
|
+
/** A live comment hyle can no longer render: `body` is an empty tree. Absent otherwise, and from an older hyle. */
|
|
197
|
+
readonly unrenderable?: true;
|
|
186
198
|
readonly body: {
|
|
187
199
|
readonly format: "hast";
|
|
188
200
|
readonly tree: unknown;
|
|
@@ -190,8 +202,12 @@ interface EngageComment {
|
|
|
190
202
|
/** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
|
|
191
203
|
readonly mine?: boolean;
|
|
192
204
|
readonly liked_by_me?: boolean;
|
|
205
|
+
/** The reader's own reactions, every kind. Absent from a hyle that only says `liked_by_me`. */
|
|
206
|
+
readonly my_reactions?: readonly ReactionKind[];
|
|
193
207
|
/** ISO instant until which the reader may edit, or null. */
|
|
194
208
|
readonly can_edit_until?: string | null;
|
|
209
|
+
/** The reader's own vote, or null. Absent from a hyle without votes. */
|
|
210
|
+
readonly my_vote?: VoteValue | null;
|
|
195
211
|
}
|
|
196
212
|
/** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
|
|
197
213
|
interface EngageHeldComment {
|
|
@@ -202,6 +218,8 @@ interface EngageHeldComment {
|
|
|
202
218
|
readonly created_at: string;
|
|
203
219
|
readonly edited_at: string | null;
|
|
204
220
|
readonly can_edit_until: string | null;
|
|
221
|
+
/** As on `EngageComment`. */
|
|
222
|
+
readonly unrenderable?: true;
|
|
205
223
|
readonly body: {
|
|
206
224
|
readonly format: "hast";
|
|
207
225
|
readonly tree: unknown;
|
|
@@ -214,12 +232,18 @@ interface EngageListing {
|
|
|
214
232
|
readonly publication_id: string;
|
|
215
233
|
readonly comment_count: number;
|
|
216
234
|
readonly like_count: number;
|
|
217
|
-
/**
|
|
235
|
+
/** Reactions on the article by kind. Absent from a hyle without reaction kinds. */
|
|
236
|
+
readonly reaction_counts?: ReactionCounts;
|
|
237
|
+
/** More comments exist than this page lists. A hyle that pages every comment sets it exactly when `next_cursor` is set. */
|
|
218
238
|
readonly truncated: boolean;
|
|
239
|
+
/** Opaque cursor of the next page, valid with the same sort only. Null or absent when there is none. */
|
|
240
|
+
readonly next_cursor?: string | null;
|
|
219
241
|
readonly comments: readonly EngageComment[];
|
|
220
242
|
/** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
|
|
221
243
|
readonly liked_by_me?: boolean;
|
|
244
|
+
/** The reader's own reactions on the article. Absent from a hyle that only says `liked_by_me`. */
|
|
245
|
+
readonly my_reactions?: readonly ReactionKind[];
|
|
222
246
|
readonly mine_held?: readonly EngageHeldComment[];
|
|
223
247
|
}
|
|
224
248
|
|
|
225
|
-
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, ListItem as L,
|
|
249
|
+
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, TocEntry as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c, Mounts as d, MountsResult as e, NavNode as f, NavTree as g, ReactionKind as h, Resolved as i, ResolvedArticle as j, ResolvedDisabled as k, ResolvedList as l, ResolvedNotFound as m, ResolvedRedirect as n };
|
|
@@ -165,6 +165,12 @@ interface Mounts {
|
|
|
165
165
|
readonly cache: CacheInfo;
|
|
166
166
|
}
|
|
167
167
|
type MountsResult = Mounts | ResolvedDisabled;
|
|
168
|
+
/** The reaction kinds hyle accepts. A reader holds at most one of each kind on a subject. */
|
|
169
|
+
type ReactionKind = "like" | "love" | "insightful" | "celebrate";
|
|
170
|
+
/** Reactions on a subject by kind; a kind nobody used is absent. */
|
|
171
|
+
type ReactionCounts = Readonly<Partial<Record<ReactionKind, number>>>;
|
|
172
|
+
/** A comment vote: up or down. */
|
|
173
|
+
type VoteValue = 1 | -1;
|
|
168
174
|
/** One comment of `GET /cp1/engage/comments` (docs/cp1-spec.md section 3.11), in thread order. */
|
|
169
175
|
interface EngageComment {
|
|
170
176
|
readonly id: string;
|
|
@@ -179,10 +185,16 @@ interface EngageComment {
|
|
|
179
185
|
readonly created_at: string;
|
|
180
186
|
readonly edited_at: string | null;
|
|
181
187
|
readonly like_count: number;
|
|
188
|
+
/** Sum of votes (may be negative; 0 on a tombstone). Absent from a hyle without votes. */
|
|
189
|
+
readonly score?: number;
|
|
190
|
+
/** Absent from a hyle without reaction kinds. */
|
|
191
|
+
readonly reaction_counts?: ReactionCounts;
|
|
182
192
|
/** A hidden or deleted comment kept only because a visible reply hangs from it: no body, no author. */
|
|
183
193
|
readonly removed: boolean;
|
|
184
194
|
/** On a tombstone only: who removed it. Absent on a live comment. */
|
|
185
195
|
readonly removed_by?: "moderator" | "author";
|
|
196
|
+
/** A live comment hyle can no longer render: `body` is an empty tree. Absent otherwise, and from an older hyle. */
|
|
197
|
+
readonly unrenderable?: true;
|
|
186
198
|
readonly body: {
|
|
187
199
|
readonly format: "hast";
|
|
188
200
|
readonly tree: unknown;
|
|
@@ -190,8 +202,12 @@ interface EngageComment {
|
|
|
190
202
|
/** Viewer members: present on a live comment only when the listing was fetched for a known reader. */
|
|
191
203
|
readonly mine?: boolean;
|
|
192
204
|
readonly liked_by_me?: boolean;
|
|
205
|
+
/** The reader's own reactions, every kind. Absent from a hyle that only says `liked_by_me`. */
|
|
206
|
+
readonly my_reactions?: readonly ReactionKind[];
|
|
193
207
|
/** ISO instant until which the reader may edit, or null. */
|
|
194
208
|
readonly can_edit_until?: string | null;
|
|
209
|
+
/** The reader's own vote, or null. Absent from a hyle without votes. */
|
|
210
|
+
readonly my_vote?: VoteValue | null;
|
|
195
211
|
}
|
|
196
212
|
/** One of the reader's own held comments (`mine_held`): never part of `comments`, never counted. */
|
|
197
213
|
interface EngageHeldComment {
|
|
@@ -202,6 +218,8 @@ interface EngageHeldComment {
|
|
|
202
218
|
readonly created_at: string;
|
|
203
219
|
readonly edited_at: string | null;
|
|
204
220
|
readonly can_edit_until: string | null;
|
|
221
|
+
/** As on `EngageComment`. */
|
|
222
|
+
readonly unrenderable?: true;
|
|
205
223
|
readonly body: {
|
|
206
224
|
readonly format: "hast";
|
|
207
225
|
readonly tree: unknown;
|
|
@@ -214,12 +232,18 @@ interface EngageListing {
|
|
|
214
232
|
readonly publication_id: string;
|
|
215
233
|
readonly comment_count: number;
|
|
216
234
|
readonly like_count: number;
|
|
217
|
-
/**
|
|
235
|
+
/** Reactions on the article by kind. Absent from a hyle without reaction kinds. */
|
|
236
|
+
readonly reaction_counts?: ReactionCounts;
|
|
237
|
+
/** More comments exist than this page lists. A hyle that pages every comment sets it exactly when `next_cursor` is set. */
|
|
218
238
|
readonly truncated: boolean;
|
|
239
|
+
/** Opaque cursor of the next page, valid with the same sort only. Null or absent when there is none. */
|
|
240
|
+
readonly next_cursor?: string | null;
|
|
219
241
|
readonly comments: readonly EngageComment[];
|
|
220
242
|
/** Viewer members: absent from the public listing (anonymous, banned or unknown reader, or a rate-limited viewer read). */
|
|
221
243
|
readonly liked_by_me?: boolean;
|
|
244
|
+
/** The reader's own reactions on the article. Absent from a hyle that only says `liked_by_me`. */
|
|
245
|
+
readonly my_reactions?: readonly ReactionKind[];
|
|
222
246
|
readonly mine_held?: readonly EngageHeldComment[];
|
|
223
247
|
}
|
|
224
248
|
|
|
225
|
-
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, ListItem as L,
|
|
249
|
+
export type { Alternate as A, Breadcrumb as B, CacheInfo as C, DocumentMetaFields as D, EngageComment as E, Fallback as F, ListItem as L, Mount as M, NavItem as N, ReactionCounts as R, TocEntry as T, VoteValue as V, ArticleContent as a, EngageHeldComment as b, EngageListing as c, Mounts as d, MountsResult as e, NavNode as f, NavTree as g, ReactionKind as h, Resolved as i, ResolvedArticle as j, ResolvedDisabled as k, ResolvedList as l, ResolvedNotFound as m, ResolvedRedirect as n };
|
package/dist/use-cache.cjs
CHANGED
|
@@ -48,6 +48,18 @@ var Cp1ClientError = class extends Error {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// src/client.ts
|
|
51
|
+
var RENDERER_VERSION = "4";
|
|
52
|
+
function applyCredential(headers, credential, method, url) {
|
|
53
|
+
if (!credential.auth) {
|
|
54
|
+
headers.set("authorization", `Bearer ${credential.token}`);
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
const { workspaceId } = credential;
|
|
58
|
+
return credential.auth({ method, url }).then((extra) => {
|
|
59
|
+
for (const [name, value] of Object.entries(extra)) headers.set(name, value);
|
|
60
|
+
headers.set("cp-workspace", workspaceId);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
51
63
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
52
64
|
var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
53
65
|
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -89,14 +101,16 @@ function checkBaseUrl(baseUrl, allowInsecureHttp) {
|
|
|
89
101
|
}
|
|
90
102
|
function createHyleClient(options) {
|
|
91
103
|
checkBaseUrl(options.baseUrl, options.allowInsecureHttp);
|
|
92
|
-
if (!options.token) throw new TypeError("token is required");
|
|
104
|
+
if (!options.auth && !options.token) throw new TypeError("token is required");
|
|
93
105
|
const base = options.baseUrl.replace(/\/+$/, "");
|
|
94
106
|
const fetchImpl = options.fetch ?? fetch;
|
|
95
107
|
async function get(pathname, query, init) {
|
|
96
108
|
const url = new URL(`${base}${pathname}`);
|
|
97
109
|
url.search = query.toString();
|
|
98
110
|
const headers = new Headers(init?.headers);
|
|
99
|
-
headers.set("
|
|
111
|
+
headers.set("cp-renderer-version", RENDERER_VERSION);
|
|
112
|
+
const applied = applyCredential(headers, options, "GET", url.toString());
|
|
113
|
+
if (applied) await applied;
|
|
100
114
|
const timeout = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
101
115
|
const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
|
|
102
116
|
const res = await fetchImpl(url.toString(), { ...init, method: "GET", headers, redirect: "error", signal });
|
|
@@ -136,16 +150,28 @@ function createHyleClient(options) {
|
|
|
136
150
|
if (data?.cp === 1 && data.kind === "mounts" && isMounts(data)) return data;
|
|
137
151
|
throw failure(reply);
|
|
138
152
|
}
|
|
153
|
+
async function pushPosts(opts) {
|
|
154
|
+
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(opts.section)) throw new TypeError("section must be a section slug");
|
|
155
|
+
const query = new URLSearchParams();
|
|
156
|
+
if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
|
|
157
|
+
const reply = await get(`/cp1/read/sections/${opts.section}/posts`, query, opts.init);
|
|
158
|
+
const data = reply.parsed?.data;
|
|
159
|
+
if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
|
|
160
|
+
throw failure(reply);
|
|
161
|
+
}
|
|
139
162
|
async function asset(file, opts = {}) {
|
|
140
163
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
141
|
-
const
|
|
164
|
+
const url = `${base}/cp1/read/assets/${file}`;
|
|
165
|
+
const headers = new Headers();
|
|
166
|
+
const applied = applyCredential(headers, options, "GET", url);
|
|
167
|
+
if (applied) await applied;
|
|
142
168
|
for (const name of ["range", "if-range", "if-none-match"]) {
|
|
143
169
|
const value = opts.headers?.[name];
|
|
144
170
|
if (value) headers.set(name, value);
|
|
145
171
|
}
|
|
146
|
-
return fetchImpl(
|
|
172
|
+
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
147
173
|
}
|
|
148
|
-
return { resolve, mounts, asset };
|
|
174
|
+
return { resolve, mounts, pushPosts, asset };
|
|
149
175
|
}
|
|
150
176
|
|
|
151
177
|
// src/tag-validation.ts
|
|
@@ -155,24 +181,24 @@ function isValidCacheTag(tag) {
|
|
|
155
181
|
}
|
|
156
182
|
|
|
157
183
|
// src/next/resolve.ts
|
|
158
|
-
var DEFAULT_REVALIDATE =
|
|
184
|
+
var DEFAULT_REVALIDATE = 86400;
|
|
159
185
|
|
|
160
186
|
// src/next/use-cache.ts
|
|
161
187
|
var MAX_TAGS = 128;
|
|
162
188
|
var DISABLED_REVALIDATE = 30;
|
|
163
|
-
var
|
|
189
|
+
var credentials = /* @__PURE__ */ new Map();
|
|
164
190
|
var keyOf = (baseUrl, workspaceId) => `${baseUrl}\0${workspaceId}`;
|
|
165
191
|
async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, nav, revalidate) {
|
|
166
192
|
"use cache";
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
169
|
-
const result = await createHyleClient({ baseUrl,
|
|
193
|
+
const credential = credentials.get(keyOf(baseUrl, workspaceId));
|
|
194
|
+
if (!credential) throw new Error("hyle: unknown cache configuration");
|
|
195
|
+
const result = await createHyleClient({ baseUrl, ...credential }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {}, ...nav === "tree" ? { nav: "tree" } : {} });
|
|
170
196
|
if (result.kind !== "disabled") (0, import_cache.cacheTag)(...result.cache.tags.filter(isValidCacheTag).slice(0, MAX_TAGS));
|
|
171
197
|
(0, import_cache.cacheLife)({ stale: 30, revalidate: result.kind === "disabled" ? Math.min(revalidate, DISABLED_REVALIDATE) : revalidate });
|
|
172
198
|
return result;
|
|
173
199
|
}
|
|
174
200
|
function cachedResolver(options) {
|
|
175
|
-
|
|
201
|
+
credentials.set(keyOf(options.baseUrl, options.workspaceId), options.auth ? { auth: options.auth, workspaceId: options.workspaceId } : { token: options.token });
|
|
176
202
|
const revalidate = options.revalidate ?? DEFAULT_REVALIDATE;
|
|
177
203
|
return (path, locale, limit, cursor, nav) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", nav ?? "", revalidate);
|
|
178
204
|
}
|
package/dist/use-cache.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { H as
|
|
2
|
-
import './
|
|
1
|
+
import { H as HyleAuth } from './client-41fU6OY2.cjs';
|
|
2
|
+
import { H as HyleResolver } from './resolve-eI1muCKL.cjs';
|
|
3
|
+
import './types-3F0wqD-o.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
|
|
@@ -7,14 +8,20 @@ import './types-Czt887Iv.cjs';
|
|
|
7
8
|
* if the host enables `cacheComponents: true`; with it off, merely importing this file fails the build. That is why it is
|
|
8
9
|
* a separate entry (`@tdacorp/hyle-sdk/next/use-cache`) that a host imports only when it opts in.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
type CachedResolverOptions = {
|
|
11
12
|
readonly baseUrl: string;
|
|
12
13
|
/** The workspace id (HYLE_WORKSPACE_ID). With `baseUrl` it identifies the cache entries, so it must not be secret. */
|
|
13
14
|
readonly workspaceId: string;
|
|
14
|
-
|
|
15
|
+
/** `token` (a target credential) or `auth` (an identity machine token, `HyleAuth`); never part of a cache key. */
|
|
15
16
|
/** Seconds before a cached page is revalidated in the background. Webhooks purge sooner. Default 300. */
|
|
16
17
|
readonly revalidate?: number;
|
|
17
|
-
}
|
|
18
|
+
} & ({
|
|
19
|
+
readonly token: string;
|
|
20
|
+
readonly auth?: never;
|
|
21
|
+
} | {
|
|
22
|
+
readonly auth: HyleAuth;
|
|
23
|
+
readonly token?: never;
|
|
24
|
+
});
|
|
18
25
|
declare function cachedResolver(options: CachedResolverOptions): HyleResolver;
|
|
19
26
|
|
|
20
27
|
export { type CachedResolverOptions, cachedResolver };
|