@tdacorp/hyle-sdk 0.8.1 → 0.9.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 +2 -2
- package/dist/check-routes-bin.js +1 -0
- package/dist/{chunk-EBNIKRQH.js → chunk-54JF4E53.js} +1 -0
- package/dist/{chunk-LGW2KP4X.js → chunk-6LW33475.js} +103 -65
- package/dist/{chunk-N4QYPO7S.js → chunk-XKR74Y5G.js} +3 -2
- package/dist/docs-enhance.cjs +97 -0
- package/dist/docs-enhance.d.cts +16 -0
- package/dist/docs-enhance.d.ts +16 -0
- package/dist/docs-enhance.js +73 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/next.cjs +91 -51
- package/dist/next.d.cts +4 -4
- package/dist/next.d.ts +4 -4
- package/dist/next.js +5 -5
- package/dist/react.cjs +102 -64
- package/dist/react.d.cts +35 -32
- package/dist/react.d.ts +35 -32
- package/dist/react.js +1 -1
- package/dist/{resolve-1rQntRBh.d.ts → resolve-D2rnnho9.d.cts} +2 -2
- package/dist/{resolve-36-Ng1H0.d.cts → resolve-Dpb6Orsj.d.ts} +2 -2
- package/dist/styles.css +32 -21
- package/dist/{types-DnPzhrFx.d.cts → types-BPPZrYOZ.d.cts} +1 -1
- package/dist/{types-BoyBWF2F.d.ts → types-C1eCQ2As.d.ts} +1 -1
- package/dist/{types-CwBCPh6K.d.cts → types-CHxH5E0S.d.cts} +15 -1
- package/dist/{types-CwBCPh6K.d.ts → types-CHxH5E0S.d.ts} +15 -1
- package/dist/use-cache.cjs +4 -3
- package/dist/use-cache.d.cts +2 -2
- package/dist/use-cache.d.ts +2 -2
- package/dist/use-cache.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -291,7 +291,7 @@ The 52 variables are listed in the token block at the top of `styles.css`. Layou
|
|
|
291
291
|
|
|
292
292
|
- Component slots: `Link` (every internal link, breadcrumb and in-page link: pass your router's Link), `Image`, `CodeBlock` (receives `code`, `language`, and the default `children`; the stock block has no copy button because that needs client JavaScript), `Mermaid` (receives hyle's sandboxed `srcDoc` and the extracted `source`; the default renders the diagram in the page, see "Mermaid diagrams"), `Callout` (GFM alerts such as `> [!NOTE]`). The raw element overrides `a`, `img`, `code`, `pre`, `table`, `blockquote` and `h1` to `h6` also work.
|
|
293
293
|
- Visual slots: `article.before`, `article.meta`, `article.aside`, `article.after`, `list.header`, `list.item` (a component that receives the item), `list.empty`, `docs.sidebar-header`, `docs.version`, `docs.sidebar-footer`, `docs.after`, `notfound.body`, `notfound.actions`, `redirecting.body`. An unfilled slot renders nothing.
|
|
294
|
-
- Layout: `layout: "docs"` renders articles as `DocsPage
|
|
294
|
+
- Layout: `layout: "docs"` renders articles as `DocsPage`, with no host code. The sidebar is the whole section (hyle sends it when the request carries `nav=tree`, which the layout adds; hidden pages are excluded and their children promoted, one locale): collapsible groups (`<details>`, so it works without JavaScript), the path to the current page open and the page marked `aria-current="page"`. Also a breadcrumb, previous and next links, an on-page contents list with scroll-spy (`aria-current="location"`, an IntersectionObserver, no dependency, no inline script), "Last updated" from the document's `updated_at`, and on a narrow mount (container width under 760px) a Menu button that opens the sidebar as a drawer (the native `popover` attribute: Escape and an outside click close it, focus returns to the button). A section above 2,000 pages in one locale is sent without the tree, and so is an older hyle: the sidebar then shows only the path to the page and its children. Restyle with the `--hyle-*` variables (`--hyle-nav-width`, `--hyle-toc-width`, `--hyle-sticky-top` for a sticky host header) and the slots above. A version badge is only what you put in `docs.version`: hyle has no docs-version data.
|
|
295
295
|
|
|
296
296
|
Chrome strings exist for en, fr and es (fr and es are unreviewed drafts). The page title is the only `h1`: a body `h1` becomes `h2`, and a leading body `h1` that repeats the title is dropped.
|
|
297
297
|
|
|
@@ -306,7 +306,7 @@ Chrome strings exist for en, fr and es (fr and es are unreviewed drafts). The pa
|
|
|
306
306
|
|
|
307
307
|
## Not included
|
|
308
308
|
|
|
309
|
-
Docs versions, reading time,
|
|
309
|
+
Docs versions, reading time, "closest matches" on the 404 page and a copy-code button: hyle does not provide that data or the page would need client JavaScript. Image URLs in content such as `/assets/<id>` are no longer passed through unchanged: see "Media".
|
|
310
310
|
|
|
311
311
|
## Contract
|
|
312
312
|
|
package/dist/check-routes-bin.js
CHANGED
|
@@ -96,6 +96,7 @@ function createHyleClient(options) {
|
|
|
96
96
|
const query = new URLSearchParams({ path: opts.path });
|
|
97
97
|
if (opts.locale !== void 0) query.set("locale", opts.locale);
|
|
98
98
|
if (opts.format !== void 0) query.set("format", opts.format);
|
|
99
|
+
if (opts.nav !== void 0) query.set("nav", opts.nav);
|
|
99
100
|
if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
|
|
100
101
|
if (opts.limit !== void 0) query.set("limit", String(opts.limit));
|
|
101
102
|
const reply = await get("/cp1/read/resolve", query, opts.init);
|
|
@@ -90,6 +90,7 @@ function createHyleClient(options) {
|
|
|
90
90
|
const query = new URLSearchParams({ path: opts.path });
|
|
91
91
|
if (opts.locale !== void 0) query.set("locale", opts.locale);
|
|
92
92
|
if (opts.format !== void 0) query.set("format", opts.format);
|
|
93
|
+
if (opts.nav !== void 0) query.set("nav", opts.nav);
|
|
93
94
|
if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
|
|
94
95
|
if (opts.limit !== void 0) query.set("limit", String(opts.limit));
|
|
95
96
|
const reply = await get("/cp1/read/resolve", query, opts.init);
|
|
@@ -38,7 +38,8 @@ var SHAPES = {
|
|
|
38
38
|
] }),
|
|
39
39
|
chev: /* @__PURE__ */ jsx("path", { d: "m6 3.5 4.5 4.5L6 12.5" }),
|
|
40
40
|
"chev-down": /* @__PURE__ */ jsx("path", { d: "m3.5 6 4.5 4.5L12.5 6" }),
|
|
41
|
-
"chev-left": /* @__PURE__ */ jsx("path", { d: "M10 3.5 5.5 8 10 12.5" })
|
|
41
|
+
"chev-left": /* @__PURE__ */ jsx("path", { d: "M10 3.5 5.5 8 10 12.5" }),
|
|
42
|
+
x: /* @__PURE__ */ jsx("path", { d: "m4 4 8 8M12 4l-8 8" })
|
|
42
43
|
};
|
|
43
44
|
function Icon({ name, className }) {
|
|
44
45
|
return /* @__PURE__ */ jsx("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
|
|
@@ -346,6 +347,8 @@ var en = {
|
|
|
346
347
|
emptyBody: "Documents published to this section will appear here, newest first.",
|
|
347
348
|
docs: "Documentation",
|
|
348
349
|
menu: "Menu",
|
|
350
|
+
closeMenu: "Close menu",
|
|
351
|
+
updated: "Last updated",
|
|
349
352
|
nfKind: "404 \xB7 Not found",
|
|
350
353
|
nfTitle: "This page does not exist",
|
|
351
354
|
nfBody: "The address may be mistyped, or the document may have been unpublished or moved.",
|
|
@@ -387,6 +390,8 @@ var fr = {
|
|
|
387
390
|
emptyBody: "Les documents publi\xE9s dans cette section appara\xEEtront ici, du plus r\xE9cent au plus ancien.",
|
|
388
391
|
docs: "Documentation",
|
|
389
392
|
menu: "Menu",
|
|
393
|
+
closeMenu: "Fermer le menu",
|
|
394
|
+
updated: "Derni\xE8re mise \xE0 jour",
|
|
390
395
|
nfKind: "404 \xB7 Introuvable",
|
|
391
396
|
nfTitle: "Cette page n'existe pas",
|
|
392
397
|
nfBody: "L'adresse est peut-\xEAtre mal saisie, ou le document a \xE9t\xE9 d\xE9publi\xE9 ou d\xE9plac\xE9.",
|
|
@@ -428,6 +433,8 @@ var es = {
|
|
|
428
433
|
emptyBody: "Los documentos publicados en esta secci\xF3n aparecer\xE1n aqu\xED, del m\xE1s reciente al m\xE1s antiguo.",
|
|
429
434
|
docs: "Documentaci\xF3n",
|
|
430
435
|
menu: "Men\xFA",
|
|
436
|
+
closeMenu: "Cerrar el men\xFA",
|
|
437
|
+
updated: "\xDAltima actualizaci\xF3n",
|
|
431
438
|
nfKind: "404 \xB7 No encontrada",
|
|
432
439
|
nfTitle: "Esta p\xE1gina no existe",
|
|
433
440
|
nfBody: "Puede que la direcci\xF3n est\xE9 mal escrita, o que el documento se haya despublicado o movido.",
|
|
@@ -730,69 +737,6 @@ function ListPage({ list, olderHref, description, ...base }) {
|
|
|
730
737
|
] }) : null
|
|
731
738
|
] }) });
|
|
732
739
|
}
|
|
733
|
-
function DocsTree({ article, c }) {
|
|
734
|
-
const { Link, s } = c;
|
|
735
|
-
const current = /* @__PURE__ */ jsxs4("li", { children: [
|
|
736
|
-
/* @__PURE__ */ jsx4(Link, { href: c.href(article.publication.canonical_path), "aria-current": "page", children: article.publication.title }),
|
|
737
|
-
article.children.length > 0 ? /* @__PURE__ */ jsx4("ul", { children: article.children.map((ch) => /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(Link, { href: c.href(ch.canonical_path), children: ch.title }) }, ch.canonical_path)) }) : null
|
|
738
|
-
] });
|
|
739
|
-
const nested = article.ancestors.reduceRight(
|
|
740
|
-
(inner, a) => /* @__PURE__ */ jsxs4("li", { children: [
|
|
741
|
-
/* @__PURE__ */ jsx4(Link, { href: c.href(a.canonical_path), children: a.title }),
|
|
742
|
-
/* @__PURE__ */ jsx4("ul", { children: inner })
|
|
743
|
-
] }, a.canonical_path),
|
|
744
|
-
current
|
|
745
|
-
);
|
|
746
|
-
return /* @__PURE__ */ jsx4("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ jsx4("ul", { children: nested }) });
|
|
747
|
-
}
|
|
748
|
-
function DocsPage({ article, ...base }) {
|
|
749
|
-
const { publication: pub } = article;
|
|
750
|
-
const c = ctx(base, pub.locale);
|
|
751
|
-
const { Link, s } = c;
|
|
752
|
-
const toc = Toc({ toc: article.toc, c });
|
|
753
|
-
const siteName = article.breadcrumbs[0]?.title ?? "";
|
|
754
|
-
const version = /* @__PURE__ */ jsx4(Slot, { name: "docs.version", slots: base.slots, tag: "span" });
|
|
755
|
-
const side = /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
756
|
-
/* @__PURE__ */ jsxs4("div", { className: "hyle-side-head", children: [
|
|
757
|
-
/* @__PURE__ */ jsx4("b", { children: siteName }),
|
|
758
|
-
version
|
|
759
|
-
] }),
|
|
760
|
-
/* @__PURE__ */ jsx4(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
|
|
761
|
-
/* @__PURE__ */ jsx4(DocsTree, { article, c }),
|
|
762
|
-
/* @__PURE__ */ jsx4(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
|
|
763
|
-
] });
|
|
764
|
-
const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
|
|
765
|
-
return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("div", { className: "hyle-docs", lang: c.locale, children: [
|
|
766
|
-
/* @__PURE__ */ jsxs4("details", { className: "hyle-nav-m", children: [
|
|
767
|
-
/* @__PURE__ */ jsxs4("summary", { children: [
|
|
768
|
-
/* @__PURE__ */ jsx4(Icon, { name: "file" }),
|
|
769
|
-
s.menu,
|
|
770
|
-
/* @__PURE__ */ jsx4("span", { className: "cur", children: pub.title }),
|
|
771
|
-
/* @__PURE__ */ jsx4(Icon, { name: "chev-down", className: "hyle-chev" })
|
|
772
|
-
] }),
|
|
773
|
-
/* @__PURE__ */ jsx4("div", { children: side })
|
|
774
|
-
] }),
|
|
775
|
-
/* @__PURE__ */ jsx4("aside", { className: "hyle-nav-d", "aria-label": s.docs, children: side }),
|
|
776
|
-
/* @__PURE__ */ jsxs4("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
|
|
777
|
-
notTranslated ? /* @__PURE__ */ jsxs4("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
|
|
778
|
-
/* @__PURE__ */ jsx4(Icon, { name: "alert" }),
|
|
779
|
-
/* @__PURE__ */ jsxs4("div", { children: [
|
|
780
|
-
/* @__PURE__ */ jsx4("b", { children: notTranslated }),
|
|
781
|
-
" ",
|
|
782
|
-
s.fallbackBody
|
|
783
|
-
] })
|
|
784
|
-
] }) : null,
|
|
785
|
-
/* @__PURE__ */ jsx4("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ jsx4("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ jsx4("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ jsx4(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
|
|
786
|
-
/* @__PURE__ */ jsx4("h1", { className: "hyle-title", children: pub.title }),
|
|
787
|
-
pub.description ? /* @__PURE__ */ jsx4("p", { className: "hyle-desc", children: pub.description }) : null,
|
|
788
|
-
toc.narrow,
|
|
789
|
-
/* @__PURE__ */ jsx4(Body, { article, components: base.components, locale: c.locale }),
|
|
790
|
-
/* @__PURE__ */ jsx4(Pager, { prev: article.prev, next: article.next, c }),
|
|
791
|
-
/* @__PURE__ */ jsx4(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" })
|
|
792
|
-
] }),
|
|
793
|
-
toc.wide
|
|
794
|
-
] }) });
|
|
795
|
-
}
|
|
796
740
|
function NotFound({ path, homeHref = "/", ...base }) {
|
|
797
741
|
const c = ctx(base, "en");
|
|
798
742
|
const { Link, s } = c;
|
|
@@ -842,6 +786,100 @@ function Redirecting({ from, to, ...base }) {
|
|
|
842
786
|
] }) });
|
|
843
787
|
}
|
|
844
788
|
|
|
789
|
+
// src/react/docs.tsx
|
|
790
|
+
import { DocsEnhance } from "./docs-enhance.js";
|
|
791
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
792
|
+
var ROOT_ID = "hyle-docs";
|
|
793
|
+
var NAV_ID = "hyle-docs-nav";
|
|
794
|
+
function navTreeOf(article) {
|
|
795
|
+
if (article.nav && !article.nav.truncated && article.nav.items.length > 0) return article.nav.items;
|
|
796
|
+
const { publication: pub } = article;
|
|
797
|
+
const here = {
|
|
798
|
+
slug: pub.slug,
|
|
799
|
+
title: pub.title,
|
|
800
|
+
canonical_path: pub.canonical_path,
|
|
801
|
+
children: article.children.map((child) => ({ ...child, children: [] }))
|
|
802
|
+
};
|
|
803
|
+
return [article.ancestors.reduceRight((inner, a) => ({ ...a, children: [inner] }), here)];
|
|
804
|
+
}
|
|
805
|
+
function pathTo(nodes, path) {
|
|
806
|
+
for (const node of nodes) {
|
|
807
|
+
if (node.canonical_path === path) return [node.canonical_path];
|
|
808
|
+
const below = pathTo(node.children, path);
|
|
809
|
+
if (below.length > 0) return [node.canonical_path, ...below];
|
|
810
|
+
}
|
|
811
|
+
return [];
|
|
812
|
+
}
|
|
813
|
+
function Branch({ nodes, current, onPath, c }) {
|
|
814
|
+
const { Link } = c;
|
|
815
|
+
return /* @__PURE__ */ jsx5("ul", { children: nodes.map((node) => {
|
|
816
|
+
const link = /* @__PURE__ */ jsx5(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
|
|
817
|
+
if (node.children.length === 0) return /* @__PURE__ */ jsx5("li", { children: link }, node.canonical_path);
|
|
818
|
+
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs5("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
|
|
819
|
+
/* @__PURE__ */ jsxs5("summary", { children: [
|
|
820
|
+
/* @__PURE__ */ jsx5(Icon, { name: "chev" }),
|
|
821
|
+
link
|
|
822
|
+
] }),
|
|
823
|
+
/* @__PURE__ */ jsx5(Branch, { nodes: node.children, current, onPath, c })
|
|
824
|
+
] }) }, node.canonical_path);
|
|
825
|
+
}) });
|
|
826
|
+
}
|
|
827
|
+
function DocsPage({ article, ...base }) {
|
|
828
|
+
const { publication: pub } = article;
|
|
829
|
+
const c = ctx(base, pub.locale);
|
|
830
|
+
const { Link, s } = c;
|
|
831
|
+
const toc = Toc({ toc: article.toc, c });
|
|
832
|
+
const tree = navTreeOf(article);
|
|
833
|
+
const onPath = new Set(pathTo(tree, pub.canonical_path));
|
|
834
|
+
const siteName = article.breadcrumbs[0]?.title ?? "";
|
|
835
|
+
const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
|
|
836
|
+
const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
|
|
837
|
+
return /* @__PURE__ */ jsx5(Shell, { children: /* @__PURE__ */ jsxs5("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
|
|
838
|
+
/* @__PURE__ */ jsx5(DocsEnhance, { headingIds, rootId: ROOT_ID }),
|
|
839
|
+
/* @__PURE__ */ jsxs5("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
|
|
840
|
+
/* @__PURE__ */ jsx5(Icon, { name: "file" }),
|
|
841
|
+
s.menu,
|
|
842
|
+
/* @__PURE__ */ jsx5("span", { className: "cur", children: pub.title }),
|
|
843
|
+
/* @__PURE__ */ jsx5(Icon, { name: "chev-down", className: "hyle-chev" })
|
|
844
|
+
] }),
|
|
845
|
+
/* @__PURE__ */ jsxs5("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
|
|
846
|
+
/* @__PURE__ */ jsxs5("div", { className: "hyle-side-head", children: [
|
|
847
|
+
/* @__PURE__ */ jsx5("b", { children: siteName }),
|
|
848
|
+
/* @__PURE__ */ jsx5(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
|
|
849
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ jsx5(Icon, { name: "x" }) })
|
|
850
|
+
] }),
|
|
851
|
+
/* @__PURE__ */ jsx5(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
|
|
852
|
+
/* @__PURE__ */ jsx5("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ jsx5(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
|
|
853
|
+
/* @__PURE__ */ jsx5(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
|
|
854
|
+
] }),
|
|
855
|
+
/* @__PURE__ */ jsxs5("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
|
|
856
|
+
notTranslated ? /* @__PURE__ */ jsxs5("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
|
|
857
|
+
/* @__PURE__ */ jsx5(Icon, { name: "alert" }),
|
|
858
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
859
|
+
/* @__PURE__ */ jsx5("b", { children: notTranslated }),
|
|
860
|
+
" ",
|
|
861
|
+
s.fallbackBody
|
|
862
|
+
] })
|
|
863
|
+
] }) : null,
|
|
864
|
+
/* @__PURE__ */ jsx5("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ jsx5("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ jsx5("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ jsx5(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
|
|
865
|
+
/* @__PURE__ */ jsx5("h1", { className: "hyle-title", children: pub.title }),
|
|
866
|
+
pub.description ? /* @__PURE__ */ jsx5("p", { className: "hyle-desc", children: pub.description }) : null,
|
|
867
|
+
/* @__PURE__ */ jsxs5("p", { className: "hyle-updated", children: [
|
|
868
|
+
/* @__PURE__ */ jsx5(Icon, { name: "calendar" }),
|
|
869
|
+
s.updated,
|
|
870
|
+
" ",
|
|
871
|
+
/* @__PURE__ */ jsx5("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
|
|
872
|
+
] }),
|
|
873
|
+
toc.narrow,
|
|
874
|
+
/* @__PURE__ */ jsx5(Body, { article, components: base.components, locale: c.locale }),
|
|
875
|
+
/* @__PURE__ */ jsx5(Pager, { prev: article.prev, next: article.next, c }),
|
|
876
|
+
/* @__PURE__ */ jsx5(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
|
|
877
|
+
/* @__PURE__ */ jsx5("span", { className: "hyle-docs-end", "aria-hidden": "true" })
|
|
878
|
+
] }),
|
|
879
|
+
toc.wide
|
|
880
|
+
] }) });
|
|
881
|
+
}
|
|
882
|
+
|
|
845
883
|
export {
|
|
846
884
|
HastLimitError,
|
|
847
885
|
scopeId,
|
|
@@ -852,9 +890,9 @@ export {
|
|
|
852
890
|
TrustedServerHtml,
|
|
853
891
|
ArticlePage,
|
|
854
892
|
ListPage,
|
|
855
|
-
DocsPage,
|
|
856
893
|
NotFound,
|
|
857
894
|
Unavailable,
|
|
858
895
|
Redirecting,
|
|
896
|
+
DocsPage,
|
|
859
897
|
MermaidDiagram2 as MermaidDiagram
|
|
860
898
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHyleClient,
|
|
3
3
|
isValidCacheTag
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-54JF4E53.js";
|
|
5
5
|
|
|
6
6
|
// src/next/resolve.ts
|
|
7
7
|
var DEFAULT_REVALIDATE = 300;
|
|
@@ -19,8 +19,9 @@ function fetchResolver(options) {
|
|
|
19
19
|
const client = createHyleClient({ baseUrl: options.baseUrl, token: options.token });
|
|
20
20
|
const revalidate = options.revalidate ?? DEFAULT_REVALIDATE;
|
|
21
21
|
const tags = workspaceTags(options.workspaceId, options.sections);
|
|
22
|
-
return (path, locale, limit, cursor) => client.resolve({
|
|
22
|
+
return (path, locale, limit, cursor, nav) => client.resolve({
|
|
23
23
|
path,
|
|
24
|
+
...nav !== void 0 ? { nav } : {},
|
|
24
25
|
...locale !== void 0 ? { locale } : {},
|
|
25
26
|
...limit !== void 0 ? { limit } : {},
|
|
26
27
|
...cursor !== void 0 ? { cursor } : {},
|
|
@@ -0,0 +1,97 @@
|
|
|
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/docs-enhance.tsx
|
|
22
|
+
var docs_enhance_exports = {};
|
|
23
|
+
__export(docs_enhance_exports, {
|
|
24
|
+
DocsEnhance: () => DocsEnhance
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(docs_enhance_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var REACHED_SLACK = 24 + 8;
|
|
29
|
+
function stickyTop(root) {
|
|
30
|
+
return Number.parseFloat(getComputedStyle(root).getPropertyValue("--h-sticky-top")) || 0;
|
|
31
|
+
}
|
|
32
|
+
function setCurrent(root, id) {
|
|
33
|
+
for (const link of Array.from(root.querySelectorAll(".hyle-toc-list a[href^='#']"))) {
|
|
34
|
+
if (id !== void 0 && link.getAttribute("href") === `#${id}`) link.setAttribute("aria-current", "location");
|
|
35
|
+
else link.removeAttribute("aria-current");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function revealCurrent(nav) {
|
|
39
|
+
const row = nav.querySelector("[aria-current='page']");
|
|
40
|
+
if (!row || nav.scrollHeight <= nav.clientHeight) return;
|
|
41
|
+
const a = row.getBoundingClientRect();
|
|
42
|
+
const b = nav.getBoundingClientRect();
|
|
43
|
+
if (a.top < b.top || a.bottom > b.bottom) nav.scrollTop += a.top - b.top - b.height / 3;
|
|
44
|
+
}
|
|
45
|
+
function DocsEnhance({ headingIds, rootId }) {
|
|
46
|
+
const key = headingIds.join("\n");
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
const root = document.getElementById(rootId);
|
|
49
|
+
if (!root) return;
|
|
50
|
+
const nav = root.querySelector(".hyle-nav-d");
|
|
51
|
+
const cleanups = [];
|
|
52
|
+
if (nav) {
|
|
53
|
+
revealCurrent(nav);
|
|
54
|
+
const onToggle = (e) => {
|
|
55
|
+
if (e.newState !== "open") return;
|
|
56
|
+
revealCurrent(nav);
|
|
57
|
+
nav.querySelector(".hyle-nav-x")?.focus();
|
|
58
|
+
};
|
|
59
|
+
const onClick = (e) => {
|
|
60
|
+
if (!(e.target instanceof Element) || !e.target.closest("a")) return;
|
|
61
|
+
try {
|
|
62
|
+
if (nav.matches(":popover-open")) nav.hidePopover();
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
nav.addEventListener("toggle", onToggle);
|
|
67
|
+
nav.addEventListener("click", onClick);
|
|
68
|
+
cleanups.push(() => (nav.removeEventListener("toggle", onToggle), nav.removeEventListener("click", onClick)));
|
|
69
|
+
}
|
|
70
|
+
const headings = headingIds.map((id) => document.getElementById(id)).filter((h) => h !== null);
|
|
71
|
+
const end = root.querySelector(".hyle-docs-end");
|
|
72
|
+
if (headings.length > 0 && typeof IntersectionObserver === "function") {
|
|
73
|
+
let endVisible = false;
|
|
74
|
+
const update = () => {
|
|
75
|
+
const line = stickyTop(root) + REACHED_SLACK;
|
|
76
|
+
let active = headings[0];
|
|
77
|
+
for (const h of headings) if (h.getBoundingClientRect().top <= line) active = h;
|
|
78
|
+
if (endVisible && window.scrollY > 0) active = headings.at(-1);
|
|
79
|
+
setCurrent(root, active?.id);
|
|
80
|
+
};
|
|
81
|
+
const io = new IntersectionObserver((entries) => {
|
|
82
|
+
for (const entry of entries) if (entry.target === end) endVisible = entry.isIntersecting;
|
|
83
|
+
update();
|
|
84
|
+
});
|
|
85
|
+
for (const h of headings) io.observe(h);
|
|
86
|
+
if (end) io.observe(end);
|
|
87
|
+
update();
|
|
88
|
+
cleanups.push(() => (io.disconnect(), setCurrent(root, void 0)));
|
|
89
|
+
}
|
|
90
|
+
return () => cleanups.forEach((fn) => fn());
|
|
91
|
+
}, [key, rootId]);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
DocsEnhance
|
|
97
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progressive enhancement for DocsPage. It renders nothing and receives only the heading ids and the root element's id: the
|
|
3
|
+
* page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
|
+
* scroll-spy for the on-page TOC (IntersectionObserver on the headings plus one on the end of the article, `aria-current="location"`
|
|
5
|
+
* set on the DOM links so it never re-renders), the current page scrolled into view in the sidebar, and the drawer closing
|
|
6
|
+
* when a link in it is followed (a client-side navigation does not reload the page, so the popover would stay open).
|
|
7
|
+
*/
|
|
8
|
+
interface DocsEnhanceProps {
|
|
9
|
+
/** The `id` of the heading elements to follow, in document order (already scoped, as in the TOC hrefs). */
|
|
10
|
+
headingIds: readonly string[];
|
|
11
|
+
/** The `id` of `.hyle-docs`. */
|
|
12
|
+
rootId: string;
|
|
13
|
+
}
|
|
14
|
+
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps): null;
|
|
15
|
+
|
|
16
|
+
export { DocsEnhance, type DocsEnhanceProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progressive enhancement for DocsPage. It renders nothing and receives only the heading ids and the root element's id: the
|
|
3
|
+
* page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
|
+
* scroll-spy for the on-page TOC (IntersectionObserver on the headings plus one on the end of the article, `aria-current="location"`
|
|
5
|
+
* set on the DOM links so it never re-renders), the current page scrolled into view in the sidebar, and the drawer closing
|
|
6
|
+
* when a link in it is followed (a client-side navigation does not reload the page, so the popover would stay open).
|
|
7
|
+
*/
|
|
8
|
+
interface DocsEnhanceProps {
|
|
9
|
+
/** The `id` of the heading elements to follow, in document order (already scoped, as in the TOC hrefs). */
|
|
10
|
+
headingIds: readonly string[];
|
|
11
|
+
/** The `id` of `.hyle-docs`. */
|
|
12
|
+
rootId: string;
|
|
13
|
+
}
|
|
14
|
+
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps): null;
|
|
15
|
+
|
|
16
|
+
export { DocsEnhance, type DocsEnhanceProps };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/react/docs-enhance.tsx
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
var REACHED_SLACK = 24 + 8;
|
|
6
|
+
function stickyTop(root) {
|
|
7
|
+
return Number.parseFloat(getComputedStyle(root).getPropertyValue("--h-sticky-top")) || 0;
|
|
8
|
+
}
|
|
9
|
+
function setCurrent(root, id) {
|
|
10
|
+
for (const link of Array.from(root.querySelectorAll(".hyle-toc-list a[href^='#']"))) {
|
|
11
|
+
if (id !== void 0 && link.getAttribute("href") === `#${id}`) link.setAttribute("aria-current", "location");
|
|
12
|
+
else link.removeAttribute("aria-current");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function revealCurrent(nav) {
|
|
16
|
+
const row = nav.querySelector("[aria-current='page']");
|
|
17
|
+
if (!row || nav.scrollHeight <= nav.clientHeight) return;
|
|
18
|
+
const a = row.getBoundingClientRect();
|
|
19
|
+
const b = nav.getBoundingClientRect();
|
|
20
|
+
if (a.top < b.top || a.bottom > b.bottom) nav.scrollTop += a.top - b.top - b.height / 3;
|
|
21
|
+
}
|
|
22
|
+
function DocsEnhance({ headingIds, rootId }) {
|
|
23
|
+
const key = headingIds.join("\n");
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const root = document.getElementById(rootId);
|
|
26
|
+
if (!root) return;
|
|
27
|
+
const nav = root.querySelector(".hyle-nav-d");
|
|
28
|
+
const cleanups = [];
|
|
29
|
+
if (nav) {
|
|
30
|
+
revealCurrent(nav);
|
|
31
|
+
const onToggle = (e) => {
|
|
32
|
+
if (e.newState !== "open") return;
|
|
33
|
+
revealCurrent(nav);
|
|
34
|
+
nav.querySelector(".hyle-nav-x")?.focus();
|
|
35
|
+
};
|
|
36
|
+
const onClick = (e) => {
|
|
37
|
+
if (!(e.target instanceof Element) || !e.target.closest("a")) return;
|
|
38
|
+
try {
|
|
39
|
+
if (nav.matches(":popover-open")) nav.hidePopover();
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
nav.addEventListener("toggle", onToggle);
|
|
44
|
+
nav.addEventListener("click", onClick);
|
|
45
|
+
cleanups.push(() => (nav.removeEventListener("toggle", onToggle), nav.removeEventListener("click", onClick)));
|
|
46
|
+
}
|
|
47
|
+
const headings = headingIds.map((id) => document.getElementById(id)).filter((h) => h !== null);
|
|
48
|
+
const end = root.querySelector(".hyle-docs-end");
|
|
49
|
+
if (headings.length > 0 && typeof IntersectionObserver === "function") {
|
|
50
|
+
let endVisible = false;
|
|
51
|
+
const update = () => {
|
|
52
|
+
const line = stickyTop(root) + REACHED_SLACK;
|
|
53
|
+
let active = headings[0];
|
|
54
|
+
for (const h of headings) if (h.getBoundingClientRect().top <= line) active = h;
|
|
55
|
+
if (endVisible && window.scrollY > 0) active = headings.at(-1);
|
|
56
|
+
setCurrent(root, active?.id);
|
|
57
|
+
};
|
|
58
|
+
const io = new IntersectionObserver((entries) => {
|
|
59
|
+
for (const entry of entries) if (entry.target === end) endVisible = entry.isIntersecting;
|
|
60
|
+
update();
|
|
61
|
+
});
|
|
62
|
+
for (const h of headings) io.observe(h);
|
|
63
|
+
if (end) io.observe(end);
|
|
64
|
+
update();
|
|
65
|
+
cleanups.push(() => (io.disconnect(), setCurrent(root, void 0)));
|
|
66
|
+
}
|
|
67
|
+
return () => cleanups.forEach((fn) => fn());
|
|
68
|
+
}, [key, rootId]);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
DocsEnhance
|
|
73
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -134,6 +134,7 @@ function createHyleClient(options) {
|
|
|
134
134
|
const query = new URLSearchParams({ path: opts.path });
|
|
135
135
|
if (opts.locale !== void 0) query.set("locale", opts.locale);
|
|
136
136
|
if (opts.format !== void 0) query.set("format", opts.format);
|
|
137
|
+
if (opts.nav !== void 0) query.set("nav", opts.nav);
|
|
137
138
|
if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
|
|
138
139
|
if (opts.limit !== void 0) query.set("limit", String(opts.limit));
|
|
139
140
|
const reply = await get("/cp1/read/resolve", query, opts.init);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, M as MountsResult } from './types-
|
|
2
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as
|
|
1
|
+
import { R as Resolved, M as MountsResult } from './types-CHxH5E0S.cjs';
|
|
2
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as NavNode, e as NavTree, f as ResolvedArticle, g as ResolvedDisabled, h as ResolvedList, i as ResolvedNotFound, j as ResolvedRedirect, T as TocEntry } from './types-CHxH5E0S.cjs';
|
|
3
3
|
export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.cjs';
|
|
4
4
|
|
|
5
5
|
/** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
|
|
@@ -28,6 +28,8 @@ interface ResolveOptions {
|
|
|
28
28
|
readonly path: string;
|
|
29
29
|
readonly locale?: string;
|
|
30
30
|
readonly format?: "hast" | "html";
|
|
31
|
+
/** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
|
|
32
|
+
readonly nav?: "tree";
|
|
31
33
|
readonly cursor?: string;
|
|
32
34
|
readonly limit?: number;
|
|
33
35
|
/** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, M as MountsResult } from './types-
|
|
2
|
-
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as
|
|
1
|
+
import { R as Resolved, M as MountsResult } from './types-CHxH5E0S.js';
|
|
2
|
+
export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, F as Fallback, L as ListItem, b as Mount, c as Mounts, N as NavItem, d as NavNode, e as NavTree, f as ResolvedArticle, g as ResolvedDisabled, h as ResolvedList, i as ResolvedNotFound, j as ResolvedRedirect, T as TocEntry } from './types-CHxH5E0S.js';
|
|
3
3
|
export { R as RevalidationCallbackOptions, a as RevalidationCallbackRoute, b as RevalidationPayload, c as createRevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
|
|
4
4
|
|
|
5
5
|
/** `next` is a Next.js fetch extension with no lib.dom type; typed structurally so this module needs no Next import. */
|
|
@@ -28,6 +28,8 @@ interface ResolveOptions {
|
|
|
28
28
|
readonly path: string;
|
|
29
29
|
readonly locale?: string;
|
|
30
30
|
readonly format?: "hast" | "html";
|
|
31
|
+
/** "tree" adds the whole section's navigation (`article.nav`); the docs layout asks for it. An older hyle ignores it. */
|
|
32
|
+
readonly nav?: "tree";
|
|
31
33
|
readonly cursor?: string;
|
|
32
34
|
readonly limit?: number;
|
|
33
35
|
/** Extra fetch options (for example Next's `next: { tags, revalidate }`). Method, body and the auth header cannot be overridden. */
|