@tdacorp/hyle-sdk 0.5.0 → 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/dist/next.js CHANGED
@@ -2,18 +2,22 @@ import {
2
2
  ArticlePage,
3
3
  DocsPage,
4
4
  ListPage
5
- } from "./chunk-SO6H2UGL.js";
5
+ } from "./chunk-6LW33475.js";
6
6
  import {
7
7
  DEFAULT_REVALIDATE,
8
8
  fetchResolver,
9
9
  workspaceTags
10
- } from "./chunk-OW6S7IZX.js";
10
+ } from "./chunk-XKR74Y5G.js";
11
11
  import {
12
12
  Cp1ClientError,
13
13
  createHyleClient,
14
14
  createRevalidationCallbackRoute,
15
15
  listPublicationPaths
16
- } from "./chunk-4OB77ZOD.js";
16
+ } from "./chunk-54JF4E53.js";
17
+ import {
18
+ ASSET_CONTENT_TYPES,
19
+ ASSET_FILE
20
+ } from "./chunk-67IOIAVW.js";
17
21
 
18
22
  // src/next/page.tsx
19
23
  import { notFound, permanentRedirect, redirect } from "next/navigation";
@@ -83,7 +87,7 @@ function hylePage(options) {
83
87
  if (path === void 0) notFound();
84
88
  try {
85
89
  const cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
86
- const result = await resolve(path, locale, options.listLimit, cursor);
90
+ const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
87
91
  switch (result.kind) {
88
92
  case "article": {
89
93
  const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
@@ -153,7 +157,7 @@ function hyleMetadata(options) {
153
157
  const { path, locale, toHref } = routeContext(options, await params ?? {});
154
158
  if (path === void 0) return {};
155
159
  try {
156
- const result = await resolve(path, locale, options.listLimit);
160
+ const result = await resolve(path, locale, options.listLimit, void 0, options.layout === "docs" ? "tree" : void 0);
157
161
  if (result.kind === "list") {
158
162
  const title = options.list?.title || result.section.title;
159
163
  const description2 = options.list?.description;
@@ -326,8 +330,83 @@ async function hyleRootSitemap(options, sitemap) {
326
330
  }
327
331
  return [...entries.values()];
328
332
  }
333
+
334
+ // src/next/asset.ts
335
+ var DEFAULT_MAX_BYTES = 16 * 1024 * 1024;
336
+ var DEFAULT_TIMEOUT_MS = 3e4;
337
+ var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400";
338
+ var PARTIAL_CACHE_CONTROL = "no-store";
339
+ var SAFE_HEADERS = { "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" };
340
+ var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
341
+ var isSwitchedOff2 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
342
+ function capped(body, max) {
343
+ let seen = 0;
344
+ return body.pipeThrough(
345
+ new TransformStream({
346
+ transform(chunk, controller) {
347
+ seen += chunk.byteLength;
348
+ if (seen > max) return controller.error(new Error("asset too large"));
349
+ controller.enqueue(chunk);
350
+ }
351
+ })
352
+ );
353
+ }
354
+ function createAssetRoute(options) {
355
+ let client;
356
+ const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
357
+ async function serve(req, ctx, head) {
358
+ if (isSwitchedOff2((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return empty(404);
359
+ const file = (await ctx.params).file;
360
+ if (typeof file !== "string" || !ASSET_FILE.test(file)) return empty(404);
361
+ try {
362
+ client ??= createHyleClient({ baseUrl: options.baseUrl?.trim() ?? "", token: options.token?.trim() ?? "", ...options.fetch ? { fetch: options.fetch } : {} });
363
+ } catch {
364
+ return empty(404);
365
+ }
366
+ let upstream;
367
+ try {
368
+ upstream = await client.asset(file, {
369
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
370
+ headers: { range: req.headers.get("range"), "if-range": req.headers.get("if-range"), "if-none-match": req.headers.get("if-none-match") }
371
+ });
372
+ } catch {
373
+ return empty(502);
374
+ }
375
+ const drop = () => void upstream.body?.cancel().catch(() => {
376
+ });
377
+ const etag = upstream.headers.get("etag");
378
+ if (upstream.status === 304) {
379
+ drop();
380
+ return new Response(null, { status: 304, headers: { "Cache-Control": CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS, ...etag ? { ETag: etag } : {} } });
381
+ }
382
+ if (upstream.status === 404 || upstream.status === 416) {
383
+ drop();
384
+ const range = upstream.status === 416 ? upstream.headers.get("content-range") : null;
385
+ return empty(upstream.status, range ? { "Content-Range": range } : {});
386
+ }
387
+ const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
388
+ const length = Number(upstream.headers.get("content-length"));
389
+ const expectedStatus = upstream.status === 200 || upstream.status === 206;
390
+ if (!expectedStatus || !upstream.body || !type || !ASSET_CONTENT_TYPES.has(type) || Number.isFinite(length) && length > maxBytes) {
391
+ drop();
392
+ return empty(502);
393
+ }
394
+ const headers = new Headers({ "Content-Type": type, "Accept-Ranges": "bytes", "Cache-Control": upstream.status === 206 ? PARTIAL_CACHE_CONTROL : CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS });
395
+ if (etag) headers.set("ETag", etag);
396
+ const contentRange = upstream.headers.get("content-range");
397
+ if (upstream.status === 206 && contentRange) headers.set("Content-Range", contentRange);
398
+ if (!upstream.headers.get("content-encoding") && upstream.headers.get("content-length")) headers.set("Content-Length", String(length));
399
+ if (head) {
400
+ drop();
401
+ return new Response(null, { status: upstream.status, headers });
402
+ }
403
+ return new Response(capped(upstream.body, maxBytes), { status: upstream.status, headers });
404
+ }
405
+ return { GET: (req, ctx) => serve(req, ctx, false), HEAD: (req, ctx) => serve(req, ctx, true) };
406
+ }
329
407
  export {
330
408
  MOUNTS_MAX_STALE_MS,
409
+ createAssetRoute,
331
410
  createRevalidateRoute,
332
411
  fetchResolver,
333
412
  hyleMetadata,
package/dist/react.cjs CHANGED
@@ -42,6 +42,20 @@ var import_hast_util_to_jsx_runtime = require("hast-util-to-jsx-runtime");
42
42
  var import_react = require("react");
43
43
  var import_jsx_runtime2 = require("react/jsx-runtime");
44
44
 
45
+ // src/asset-path.ts
46
+ var ASSET_ROUTE_PREFIX = "/api/hyle/assets";
47
+ var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
48
+ var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg";
49
+ var ASSET_FILE = new RegExp(`^${UUID}(?:\\.(?:${EXTENSIONS}))?$`);
50
+ var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)$`, "i");
51
+ function hostAssetSrc(src) {
52
+ const file = HYLE_ASSET_URL.exec(src)?.[1];
53
+ return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}` : src;
54
+ }
55
+ function hostAssetHtml(html) {
56
+ return html.replace(new RegExp(`(\\ssrc=")(/assets/${UUID}(?:\\.(?:${EXTENSIONS}))?)(")`, "gi"), (_m, open, url, close) => `${open}${hostAssetSrc(url)}${close}`);
57
+ }
58
+
45
59
  // src/react/icons.tsx
46
60
  var import_jsx_runtime = require("react/jsx-runtime");
47
61
  var SHAPES = {
@@ -72,7 +86,8 @@ var SHAPES = {
72
86
  ] }),
73
87
  chev: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 3.5 4.5 4.5L6 12.5" }),
74
88
  "chev-down": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.5 6 4.5 4.5L12.5 6" }),
75
- "chev-left": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 3.5 5.5 8 10 12.5" })
89
+ "chev-left": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 3.5 5.5 8 10 12.5" }),
90
+ x: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m4 4 8 8M12 4l-8 8" })
76
91
  };
77
92
  function Icon({ name, className }) {
78
93
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
@@ -233,6 +248,7 @@ function clean(node, depth, ctx2, budget) {
233
248
  if (Object.hasOwn(rules, key) && rules[key](value, inner)) properties[key] = value;
234
249
  }
235
250
  }
251
+ if ((tag === "img" || tag === "video" || tag === "audio") && typeof properties.src === "string") properties.src = hostAssetSrc(properties.src);
236
252
  if (tag === "iframe") {
237
253
  if (properties.sandbox === void 0 || properties.srcdoc === void 0) return [];
238
254
  properties.sandbox = "allow-scripts";
@@ -379,6 +395,8 @@ var en = {
379
395
  emptyBody: "Documents published to this section will appear here, newest first.",
380
396
  docs: "Documentation",
381
397
  menu: "Menu",
398
+ closeMenu: "Close menu",
399
+ updated: "Last updated",
382
400
  nfKind: "404 \xB7 Not found",
383
401
  nfTitle: "This page does not exist",
384
402
  nfBody: "The address may be mistyped, or the document may have been unpublished or moved.",
@@ -420,6 +438,8 @@ var fr = {
420
438
  emptyBody: "Les documents publi\xE9s dans cette section appara\xEEtront ici, du plus r\xE9cent au plus ancien.",
421
439
  docs: "Documentation",
422
440
  menu: "Menu",
441
+ closeMenu: "Fermer le menu",
442
+ updated: "Derni\xE8re mise \xE0 jour",
423
443
  nfKind: "404 \xB7 Introuvable",
424
444
  nfTitle: "Cette page n'existe pas",
425
445
  nfBody: "L'adresse est peut-\xEAtre mal saisie, ou le document a \xE9t\xE9 d\xE9publi\xE9 ou d\xE9plac\xE9.",
@@ -461,6 +481,8 @@ var es = {
461
481
  emptyBody: "Los documentos publicados en esta secci\xF3n aparecer\xE1n aqu\xED, del m\xE1s reciente al m\xE1s antiguo.",
462
482
  docs: "Documentaci\xF3n",
463
483
  menu: "Men\xFA",
484
+ closeMenu: "Cerrar el men\xFA",
485
+ updated: "\xDAltima actualizaci\xF3n",
464
486
  nfKind: "404 \xB7 No encontrada",
465
487
  nfTitle: "Esta p\xE1gina no existe",
466
488
  nfBody: "Puede que la direcci\xF3n est\xE9 mal escrita, o que el documento se haya despublicado o movido.",
@@ -580,7 +602,7 @@ function HastContent({ tree, title, components = {}, locale }) {
580
602
  });
581
603
  }
582
604
  function TrustedServerHtml({ html }) {
583
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { dangerouslySetInnerHTML: { __html: html } });
605
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { dangerouslySetInnerHTML: { __html: hostAssetHtml(html) } });
584
606
  }
585
607
 
586
608
  // src/react/index.ts
@@ -763,69 +785,6 @@ function ListPage({ list, olderHref, description, ...base }) {
763
785
  ] }) : null
764
786
  ] }) });
765
787
  }
766
- function DocsTree({ article, c }) {
767
- const { Link, s } = c;
768
- const current = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
769
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { href: c.href(article.publication.canonical_path), "aria-current": "page", children: article.publication.title }),
770
- article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { children: article.children.map((ch) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { href: c.href(ch.canonical_path), children: ch.title }) }, ch.canonical_path)) }) : null
771
- ] });
772
- const nested = article.ancestors.reduceRight(
773
- (inner, a) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
774
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { href: c.href(a.canonical_path), children: a.title }),
775
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { children: inner })
776
- ] }, a.canonical_path),
777
- current
778
- );
779
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { children: nested }) });
780
- }
781
- function DocsPage({ article, ...base }) {
782
- const { publication: pub } = article;
783
- const c = ctx(base, pub.locale);
784
- const { Link, s } = c;
785
- const toc = Toc({ toc: article.toc, c });
786
- const siteName = article.breadcrumbs[0]?.title ?? "";
787
- const version = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" });
788
- const side = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
789
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "hyle-side-head", children: [
790
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { children: siteName }),
791
- version
792
- ] }),
793
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
794
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DocsTree, { article, c }),
795
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
796
- ] });
797
- const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
798
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "hyle-docs", lang: c.locale, children: [
799
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { className: "hyle-nav-m", children: [
800
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("summary", { children: [
801
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "file" }),
802
- s.menu,
803
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "cur", children: pub.title }),
804
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
805
- ] }),
806
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: side })
807
- ] }),
808
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("aside", { className: "hyle-nav-d", "aria-label": s.docs, children: side }),
809
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
810
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
811
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "alert" }),
812
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
813
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { children: notTranslated }),
814
- " ",
815
- s.fallbackBody
816
- ] })
817
- ] }) : null,
818
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
819
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { className: "hyle-title", children: pub.title }),
820
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
821
- toc.narrow,
822
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Body, { article, components: base.components, locale: c.locale }),
823
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Pager, { prev: article.prev, next: article.next, c }),
824
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" })
825
- ] }),
826
- toc.wide
827
- ] }) });
828
- }
829
788
  function NotFound({ path, homeHref = "/", ...base }) {
830
789
  const c = ctx(base, "en");
831
790
  const { Link, s } = c;
@@ -874,6 +833,100 @@ function Redirecting({ from, to, ...base }) {
874
833
  extra ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { "data-slot": "redirecting.body", className: "fine", children: extra }) : null
875
834
  ] }) });
876
835
  }
836
+
837
+ // src/react/docs.tsx
838
+ var import_docs_enhance = require("./docs-enhance.cjs");
839
+ var import_jsx_runtime5 = require("react/jsx-runtime");
840
+ var ROOT_ID = "hyle-docs";
841
+ var NAV_ID = "hyle-docs-nav";
842
+ function navTreeOf(article) {
843
+ if (article.nav && !article.nav.truncated && article.nav.items.length > 0) return article.nav.items;
844
+ const { publication: pub } = article;
845
+ const here = {
846
+ slug: pub.slug,
847
+ title: pub.title,
848
+ canonical_path: pub.canonical_path,
849
+ children: article.children.map((child) => ({ ...child, children: [] }))
850
+ };
851
+ return [article.ancestors.reduceRight((inner, a) => ({ ...a, children: [inner] }), here)];
852
+ }
853
+ function pathTo(nodes, path) {
854
+ for (const node of nodes) {
855
+ if (node.canonical_path === path) return [node.canonical_path];
856
+ const below = pathTo(node.children, path);
857
+ if (below.length > 0) return [node.canonical_path, ...below];
858
+ }
859
+ return [];
860
+ }
861
+ function Branch({ nodes, current, onPath, c }) {
862
+ const { Link } = c;
863
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: nodes.map((node) => {
864
+ const link = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
865
+ if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: link }, node.canonical_path);
866
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
867
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("summary", { children: [
868
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "chev" }),
869
+ link
870
+ ] }),
871
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Branch, { nodes: node.children, current, onPath, c })
872
+ ] }) }, node.canonical_path);
873
+ }) });
874
+ }
875
+ function DocsPage({ article, ...base }) {
876
+ const { publication: pub } = article;
877
+ const c = ctx(base, pub.locale);
878
+ const { Link, s } = c;
879
+ const toc = Toc({ toc: article.toc, c });
880
+ const tree = navTreeOf(article);
881
+ const onPath = new Set(pathTo(tree, pub.canonical_path));
882
+ const siteName = article.breadcrumbs[0]?.title ?? "";
883
+ const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
884
+ const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
885
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
887
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
888
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "file" }),
889
+ s.menu,
890
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cur", children: pub.title }),
891
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
892
+ ] }),
893
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
894
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hyle-side-head", children: [
895
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("b", { children: siteName }),
896
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
897
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "x" }) })
898
+ ] }),
899
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
900
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
901
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
902
+ ] }),
903
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
904
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
905
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "alert" }),
906
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
907
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("b", { children: notTranslated }),
908
+ " ",
909
+ s.fallbackBody
910
+ ] })
911
+ ] }) : null,
912
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
913
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", { className: "hyle-title", children: pub.title }),
914
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
915
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "hyle-updated", children: [
916
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, { name: "calendar" }),
917
+ s.updated,
918
+ " ",
919
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
920
+ ] }),
921
+ toc.narrow,
922
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Body, { article, components: base.components, locale: c.locale }),
923
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Pager, { prev: article.prev, next: article.next, c }),
924
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
925
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
926
+ ] }),
927
+ toc.wide
928
+ ] }) });
929
+ }
877
930
  // Annotate the CommonJS export names for ESM import in node:
878
931
  0 && (module.exports = {
879
932
  ArticlePage,
package/dist/react.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps } from './types-DnPzhrFx.cjs';
4
- export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-DnPzhrFx.cjs';
3
+ import { H as HyleComponents, P as PageBaseProps } from './types-BPPZrYOZ.cjs';
4
+ export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-BPPZrYOZ.cjs';
5
5
  import { Root } from 'hast';
6
- import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.cjs';
6
+ import { f as ResolvedArticle, h as ResolvedList } from './types-CHxH5E0S.cjs';
7
7
 
8
8
  interface HastContentProps {
9
9
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -95,35 +95,6 @@ declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
95
95
  */
96
96
  declare function sanitizeHast(tree: unknown, title?: string): Root;
97
97
 
98
- interface ArticlePageProps extends PageBaseProps {
99
- article: ResolvedArticle;
100
- }
101
- declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
102
- interface ListPageProps extends PageBaseProps {
103
- list: ResolvedList;
104
- /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
105
- olderHref?: string;
106
- /** Page description under the title. */
107
- description?: string;
108
- }
109
- declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
110
- declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
111
- interface NotFoundProps extends PageBaseProps {
112
- /** The path that was not found, shown to the visitor. */
113
- path?: string;
114
- /** Where "Go to home" goes. */
115
- homeHref?: string;
116
- }
117
- declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
118
- /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
119
- declare function Unavailable(base: PageBaseProps): ReactElement;
120
- interface RedirectingProps extends PageBaseProps {
121
- from?: string;
122
- to: string;
123
- }
124
- /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
125
- declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
126
-
127
98
  /**
128
99
  * Chrome strings for en, fr and es. The fr and es copy is a draft carried over from the design kit and has not been
129
100
  * reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
@@ -154,6 +125,8 @@ declare const en: {
154
125
  emptyBody: string;
155
126
  docs: string;
156
127
  menu: string;
128
+ closeMenu: string;
129
+ updated: string;
157
130
  nfKind: string;
158
131
  nfTitle: string;
159
132
  nfBody: string;
@@ -174,4 +147,34 @@ type Strings = typeof en;
174
147
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
175
148
  declare function stringsFor(locale: string | undefined): Strings;
176
149
 
150
+ interface ArticlePageProps extends PageBaseProps {
151
+ article: ResolvedArticle;
152
+ }
153
+ declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
154
+ interface ListPageProps extends PageBaseProps {
155
+ list: ResolvedList;
156
+ /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
157
+ olderHref?: string;
158
+ /** Page description under the title. */
159
+ description?: string;
160
+ }
161
+ declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
162
+ interface NotFoundProps extends PageBaseProps {
163
+ /** The path that was not found, shown to the visitor. */
164
+ path?: string;
165
+ /** Where "Go to home" goes. */
166
+ homeHref?: string;
167
+ }
168
+ declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
169
+ /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
170
+ declare function Unavailable(base: PageBaseProps): ReactElement;
171
+ interface RedirectingProps extends PageBaseProps {
172
+ from?: string;
173
+ to: string;
174
+ }
175
+ /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
176
+ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
177
+
178
+ declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
179
+
177
180
  export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps } from './types-BoyBWF2F.js';
4
- export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-BoyBWF2F.js';
3
+ import { H as HyleComponents, P as PageBaseProps } from './types-C1eCQ2As.js';
4
+ export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-C1eCQ2As.js';
5
5
  import { Root } from 'hast';
6
- import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.js';
6
+ import { f as ResolvedArticle, h as ResolvedList } from './types-CHxH5E0S.js';
7
7
 
8
8
  interface HastContentProps {
9
9
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -95,35 +95,6 @@ declare function isSafeUrl(value: unknown, kind: "href" | "src"): boolean;
95
95
  */
96
96
  declare function sanitizeHast(tree: unknown, title?: string): Root;
97
97
 
98
- interface ArticlePageProps extends PageBaseProps {
99
- article: ResolvedArticle;
100
- }
101
- declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
102
- interface ListPageProps extends PageBaseProps {
103
- list: ResolvedList;
104
- /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
105
- olderHref?: string;
106
- /** Page description under the title. */
107
- description?: string;
108
- }
109
- declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
110
- declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
111
- interface NotFoundProps extends PageBaseProps {
112
- /** The path that was not found, shown to the visitor. */
113
- path?: string;
114
- /** Where "Go to home" goes. */
115
- homeHref?: string;
116
- }
117
- declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
118
- /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
119
- declare function Unavailable(base: PageBaseProps): ReactElement;
120
- interface RedirectingProps extends PageBaseProps {
121
- from?: string;
122
- to: string;
123
- }
124
- /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
125
- declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
126
-
127
98
  /**
128
99
  * Chrome strings for en, fr and es. The fr and es copy is a draft carried over from the design kit and has not been
129
100
  * reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
@@ -154,6 +125,8 @@ declare const en: {
154
125
  emptyBody: string;
155
126
  docs: string;
156
127
  menu: string;
128
+ closeMenu: string;
129
+ updated: string;
157
130
  nfKind: string;
158
131
  nfTitle: string;
159
132
  nfBody: string;
@@ -174,4 +147,34 @@ type Strings = typeof en;
174
147
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
175
148
  declare function stringsFor(locale: string | undefined): Strings;
176
149
 
150
+ interface ArticlePageProps extends PageBaseProps {
151
+ article: ResolvedArticle;
152
+ }
153
+ declare function ArticlePage({ article, ...base }: ArticlePageProps): ReactElement;
154
+ interface ListPageProps extends PageBaseProps {
155
+ list: ResolvedList;
156
+ /** Where "Older posts" goes; omit to hide it. The list endpoint is cursor based, so a host builds this from `list.next_cursor`. */
157
+ olderHref?: string;
158
+ /** Page description under the title. */
159
+ description?: string;
160
+ }
161
+ declare function ListPage({ list, olderHref, description, ...base }: ListPageProps): ReactElement;
162
+ interface NotFoundProps extends PageBaseProps {
163
+ /** The path that was not found, shown to the visitor. */
164
+ path?: string;
165
+ /** Where "Go to home" goes. */
166
+ homeHref?: string;
167
+ }
168
+ declare function NotFound({ path, homeHref, ...base }: NotFoundProps): ReactElement;
169
+ /** The fail-safe state `hylePage` renders when hyle cannot be reached. It takes no error: nothing internal can reach the markup. */
170
+ declare function Unavailable(base: PageBaseProps): ReactElement;
171
+ interface RedirectingProps extends PageBaseProps {
172
+ from?: string;
173
+ to: string;
174
+ }
175
+ /** For a client-side explanation of a move. The Next adapter redirects on the server and never renders this. */
176
+ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElement;
177
+
178
+ declare function DocsPage({ article, ...base }: ArticlePageProps): ReactElement;
179
+
177
180
  export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
package/dist/react.js CHANGED
@@ -13,7 +13,8 @@ import {
13
13
  sanitizeHast,
14
14
  scopeId,
15
15
  stringsFor
16
- } from "./chunk-SO6H2UGL.js";
16
+ } from "./chunk-6LW33475.js";
17
+ import "./chunk-67IOIAVW.js";
17
18
  export {
18
19
  ArticlePage,
19
20
  DocsPage,
@@ -1,7 +1,7 @@
1
- import { R as Resolved } from './types-CwBCPh6K.js';
1
+ import { R as Resolved } from './types-CHxH5E0S.cjs';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
- type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
4
+ type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree") => Promise<Resolved>;
5
5
  interface FetchResolverOptions {
6
6
  readonly baseUrl: string;
7
7
  readonly token: string;
@@ -1,7 +1,7 @@
1
- import { R as Resolved } from './types-CwBCPh6K.cjs';
1
+ import { R as Resolved } from './types-CHxH5E0S.js';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
- type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
4
+ type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string, nav?: "tree") => Promise<Resolved>;
5
5
  interface FetchResolverOptions {
6
6
  readonly baseUrl: string;
7
7
  readonly token: string;