@tdacorp/hyle-sdk 0.8.1 → 0.11.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.
Files changed (41) hide show
  1. package/README.md +82 -4
  2. package/bin/hyle-sdk-engage-keygen.mjs +3 -0
  3. package/dist/check-routes-bin.js +6 -1
  4. package/dist/{chunk-EBNIKRQH.js → chunk-N7ZQUAGM.js} +46 -2
  5. package/dist/chunk-R5EMI4HQ.js +61 -0
  6. package/dist/{chunk-LGW2KP4X.js → chunk-S3LT6G4M.js} +601 -77
  7. package/dist/{chunk-N4QYPO7S.js → chunk-S7PCCEHP.js} +3 -2
  8. package/dist/comments.cjs +1048 -0
  9. package/dist/comments.d.cts +152 -0
  10. package/dist/comments.d.ts +152 -0
  11. package/dist/comments.js +1025 -0
  12. package/dist/docs-enhance.cjs +97 -0
  13. package/dist/docs-enhance.d.cts +16 -0
  14. package/dist/docs-enhance.d.ts +16 -0
  15. package/dist/docs-enhance.js +73 -0
  16. package/dist/{types-DnPzhrFx.d.cts → embed-BC8Tlc6A.d.cts} +44 -3
  17. package/dist/{types-BoyBWF2F.d.ts → embed-CwSzvBUO.d.ts} +44 -3
  18. package/dist/engage-keygen-bin.js +67 -0
  19. package/dist/index.cjs +27 -1
  20. package/dist/index.d.cts +13 -3
  21. package/dist/index.d.ts +13 -3
  22. package/dist/index.js +5 -1
  23. package/dist/mermaid-diagram.js +9 -54
  24. package/dist/next.cjs +988 -66
  25. package/dist/next.d.cts +149 -6
  26. package/dist/next.d.ts +149 -6
  27. package/dist/next.js +391 -12
  28. package/dist/react.cjs +403 -75
  29. package/dist/react.d.cts +141 -33
  30. package/dist/react.d.ts +141 -33
  31. package/dist/react.js +7 -1
  32. package/dist/{resolve-36-Ng1H0.d.cts → resolve-BYL8jMg0.d.ts} +2 -2
  33. package/dist/{resolve-1rQntRBh.d.ts → resolve-Ra8-y2U-.d.cts} +2 -2
  34. package/dist/styles.css +149 -21
  35. package/dist/{types-CwBCPh6K.d.cts → types-C72FwzOd.d.cts} +71 -1
  36. package/dist/{types-CwBCPh6K.d.ts → types-C72FwzOd.d.ts} +71 -1
  37. package/dist/use-cache.cjs +9 -4
  38. package/dist/use-cache.d.cts +2 -2
  39. package/dist/use-cache.d.ts +2 -2
  40. package/dist/use-cache.js +5 -5
  41. package/package.json +4 -3
@@ -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
+ };
@@ -1,5 +1,5 @@
1
- import { ElementType, ReactNode, ComponentType } from 'react';
2
- import { L as ListItem } from './types-CwBCPh6K.cjs';
1
+ import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
+ import { L as ListItem, h as ResolvedArticle } from './types-C72FwzOd.cjs';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -90,5 +90,46 @@ interface PageBaseProps {
90
90
  */
91
91
  toHref?: ((sitePath: string, locale: string) => string) | undefined;
92
92
  }
93
+ /** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
94
+ interface EngagementConfig {
95
+ /** The host route that answers the calls. Default "/api/hyle/engage". */
96
+ endpoint?: string | undefined;
97
+ /** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
98
+ signInHref?: string | undefined;
99
+ }
100
+
101
+ /**
102
+ * Embeds: parts of a hyle site inside a page the host owns. Pure markup, server safe, no "use client". Unlike the pages they have
103
+ * no frame, no `<title>`, no `<link>`, no `<meta>`, no JSON-LD, no table of contents and no pager: the host page keeps its own
104
+ * metadata, and every embed links back to the canonical URL on the mount.
105
+ */
106
+ type EmbedHeading = 2 | 3 | 4;
107
+ interface HyleListViewProps extends PageBaseProps {
108
+ readonly items: readonly ListItem[];
109
+ /** Default "list". "grid" lays the items out as cards. */
110
+ readonly layout?: "list" | "grid" | undefined;
111
+ /** An optional heading above the list. */
112
+ readonly title?: string | undefined;
113
+ /** The heading's level, so it nests under the host page's own headings. Default 2. */
114
+ readonly headingLevel?: EmbedHeading | undefined;
115
+ /** Where "View all" goes (a URL in the host's space); omit to hide it. */
116
+ readonly moreHref?: string | undefined;
117
+ }
118
+ /** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
119
+ declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
120
+ interface HyleArticleViewProps extends PageBaseProps {
121
+ readonly article: ResolvedArticle;
122
+ /**
123
+ * The title's level. Default 2: a host page normally has its own h1, and body headings are h2 and below, so nest the embed
124
+ * under a section heading of your own and raise this to match.
125
+ */
126
+ readonly headingLevel?: EmbedHeading | undefined;
127
+ }
128
+ /** The article's title, date, description and body, then a visible link to the canonical page. */
129
+ declare function HyleArticleView({ article, headingLevel, ...base }: HyleArticleViewProps): ReactElement;
130
+ /** The placeholder to give `<Suspense fallback>` around `HyleComments`: the labelled section and skeleton rows, no data. */
131
+ declare function HyleCommentsFallback({ locale }: {
132
+ locale?: string | undefined;
133
+ }): ReactElement;
93
134
 
94
- export type { CalloutKind as C, HyleComponents as H, ImageProps as I, LinkProps as L, MermaidProps as M, PageBaseProps as P, HyleSlots as a, CalloutProps as b, CodeBlockProps as c, ListItemProps as d };
135
+ export { type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type LinkProps as L, type MermaidProps as M, type PageBaseProps as P, type HyleSlots as a, type EmbedHeading as b, HyleCommentsFallback as c, type CalloutProps as d, type CodeBlockProps as e, HyleArticleView as f, type HyleArticleViewProps as g, HyleListView as h, type HyleListViewProps as i, type ListItemProps as j };
@@ -1,5 +1,5 @@
1
- import { ElementType, ReactNode, ComponentType } from 'react';
2
- import { L as ListItem } from './types-CwBCPh6K.js';
1
+ import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
+ import { L as ListItem, h as ResolvedArticle } from './types-C72FwzOd.js';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -90,5 +90,46 @@ interface PageBaseProps {
90
90
  */
91
91
  toHref?: ((sitePath: string, locale: string) => string) | undefined;
92
92
  }
93
+ /** Reader comments and likes under an article (ADR 0017). Pass it only when the workspace has engagement on and the host mounted `createEngagementRoute`. */
94
+ interface EngagementConfig {
95
+ /** The host route that answers the calls. Default "/api/hyle/engage". */
96
+ endpoint?: string | undefined;
97
+ /** Where the "Sign in" button goes (the host's own sign-in). Without it a signed-out visitor sees the prompt but no button. */
98
+ signInHref?: string | undefined;
99
+ }
100
+
101
+ /**
102
+ * Embeds: parts of a hyle site inside a page the host owns. Pure markup, server safe, no "use client". Unlike the pages they have
103
+ * no frame, no `<title>`, no `<link>`, no `<meta>`, no JSON-LD, no table of contents and no pager: the host page keeps its own
104
+ * metadata, and every embed links back to the canonical URL on the mount.
105
+ */
106
+ type EmbedHeading = 2 | 3 | 4;
107
+ interface HyleListViewProps extends PageBaseProps {
108
+ readonly items: readonly ListItem[];
109
+ /** Default "list". "grid" lays the items out as cards. */
110
+ readonly layout?: "list" | "grid" | undefined;
111
+ /** An optional heading above the list. */
112
+ readonly title?: string | undefined;
113
+ /** The heading's level, so it nests under the host page's own headings. Default 2. */
114
+ readonly headingLevel?: EmbedHeading | undefined;
115
+ /** Where "View all" goes (a URL in the host's space); omit to hide it. */
116
+ readonly moreHref?: string | undefined;
117
+ }
118
+ /** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
119
+ declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
120
+ interface HyleArticleViewProps extends PageBaseProps {
121
+ readonly article: ResolvedArticle;
122
+ /**
123
+ * The title's level. Default 2: a host page normally has its own h1, and body headings are h2 and below, so nest the embed
124
+ * under a section heading of your own and raise this to match.
125
+ */
126
+ readonly headingLevel?: EmbedHeading | undefined;
127
+ }
128
+ /** The article's title, date, description and body, then a visible link to the canonical page. */
129
+ declare function HyleArticleView({ article, headingLevel, ...base }: HyleArticleViewProps): ReactElement;
130
+ /** The placeholder to give `<Suspense fallback>` around `HyleComments`: the labelled section and skeleton rows, no data. */
131
+ declare function HyleCommentsFallback({ locale }: {
132
+ locale?: string | undefined;
133
+ }): ReactElement;
93
134
 
94
- export type { CalloutKind as C, HyleComponents as H, ImageProps as I, LinkProps as L, MermaidProps as M, PageBaseProps as P, HyleSlots as a, CalloutProps as b, CodeBlockProps as c, ListItemProps as d };
135
+ export { type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type LinkProps as L, type MermaidProps as M, type PageBaseProps as P, type HyleSlots as a, type EmbedHeading as b, HyleCommentsFallback as c, type CalloutProps as d, type CodeBlockProps as e, HyleArticleView as f, type HyleArticleViewProps as g, HyleListView as h, type HyleListViewProps as i, type ListItemProps as j };
@@ -0,0 +1,67 @@
1
+ // src/engage-keygen.ts
2
+ import { spawnSync } from "child_process";
3
+ import { closeSync, openSync, writeSync } from "fs";
4
+
5
+ // src/engage-keys.ts
6
+ import { createPrivateKey, createPublicKey, generateKeyPairSync, randomUUID, sign } from "crypto";
7
+ var PKCS8_ED25519 = Buffer.from("302e020100300506032b657004220420", "hex");
8
+ function generateEngagementKeyPair() {
9
+ const jwk = generateKeyPairSync("ed25519").privateKey.export({ format: "jwk" });
10
+ return { publicKey: String(jwk.x), privateKey: String(jwk.d) };
11
+ }
12
+
13
+ // src/engage-keygen.ts
14
+ var KEYGEN_USAGE = `usage:
15
+ hyle-sdk-engage-keygen --out <env-file> write HYLE_ENGAGE_SIGNING_KEY=<private key> to a new file (mode 0600), print only the public key
16
+ hyle-sdk-engage-keygen --stdout print both keys to the terminal (the private key lands in your scrollback)`;
17
+ var nodeIo = {
18
+ stdout: (t) => void console.log(t),
19
+ stderr: (t) => void console.error(t),
20
+ writeNew: (path, content) => {
21
+ const fd = openSync(path, "wx", 384);
22
+ try {
23
+ writeSync(fd, content);
24
+ } finally {
25
+ closeSync(fd);
26
+ }
27
+ },
28
+ gitIgnored: (path) => {
29
+ const r = spawnSync("git", ["check-ignore", "-q", "--", path], { stdio: "ignore" });
30
+ return r.status === 0 ? true : r.status === 1 ? false : void 0;
31
+ }
32
+ };
33
+ function keygen(argv, io = nodeIo) {
34
+ const outAt = argv.indexOf("--out");
35
+ const out = outAt >= 0 ? argv[outAt + 1] : void 0;
36
+ const toStdout = argv.length === 1 && argv[0] === "--stdout";
37
+ const toFile = argv.length === 2 && outAt === 0 && out !== void 0 && !out.startsWith("--");
38
+ if (!toStdout && !toFile) {
39
+ io.stderr(KEYGEN_USAGE);
40
+ return 2;
41
+ }
42
+ const { publicKey, privateKey } = generateEngagementKeyPair();
43
+ if (toStdout) {
44
+ io.stdout(`Public key (register it in hyle, workspace engagement settings):
45
+ ${publicKey}
46
+ `);
47
+ io.stdout(`Private key (set it as the HYLE_ENGAGE_SIGNING_KEY environment variable; never commit it, never share it):
48
+ ${privateKey}`);
49
+ return 0;
50
+ }
51
+ try {
52
+ io.writeNew(out, `HYLE_ENGAGE_SIGNING_KEY=${privateKey}
53
+ `);
54
+ } catch (error) {
55
+ io.stderr(`could not write ${out}: ${error.code ?? "error"} (no key was printed)`);
56
+ return 1;
57
+ }
58
+ io.stdout(`Public key (register it in hyle, workspace engagement settings):
59
+ ${publicKey}
60
+ `);
61
+ io.stdout(`Private key written to ${out} (mode 0600). Load it as HYLE_ENGAGE_SIGNING_KEY; never commit it.`);
62
+ if (io.gitIgnored(out) === false) io.stderr(`warning: ${out} is not ignored by git. Add it to .gitignore before you commit anything.`);
63
+ return 0;
64
+ }
65
+
66
+ // src/engage-keygen-bin.ts
67
+ process.exitCode = keygen(process.argv.slice(2));
package/dist/index.cjs CHANGED
@@ -27,7 +27,9 @@ __export(src_exports, {
27
27
  checkRoutes: () => checkRoutes,
28
28
  createHyleClient: () => createHyleClient,
29
29
  createRevalidationCallbackRoute: () => createRevalidationCallbackRoute,
30
+ engagementPublicKey: () => engagementPublicKey,
30
31
  formatReport: () => formatReport,
32
+ generateEngagementKeyPair: () => generateEngagementKeyPair,
31
33
  hostRoutesFromManifests: () => hostRoutesFromManifests,
32
34
  isValidCacheTag: () => isValidCacheTag,
33
35
  listPublicationPaths: () => listPublicationPaths,
@@ -134,11 +136,16 @@ function createHyleClient(options) {
134
136
  const query = new URLSearchParams({ path: opts.path });
135
137
  if (opts.locale !== void 0) query.set("locale", opts.locale);
136
138
  if (opts.format !== void 0) query.set("format", opts.format);
139
+ if (opts.nav !== void 0) query.set("nav", opts.nav);
137
140
  if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
138
141
  if (opts.limit !== void 0) query.set("limit", String(opts.limit));
139
142
  const reply = await get("/cp1/read/resolve", query, opts.init);
140
143
  const data = reply.parsed?.data;
141
- if (data && data.cp === 1 && typeof data.kind === "string" && KINDS.has(data.kind)) return data;
144
+ if (data && data.cp === 1 && typeof data.kind === "string" && KINDS.has(data.kind)) {
145
+ const resolved = data;
146
+ if (resolved.kind === "article" && resolved.content.format === "html" && opts.format !== "html") throw failure(reply);
147
+ return resolved;
148
+ }
142
149
  throw failure(reply);
143
150
  }
144
151
  async function mounts(opts = {}) {
@@ -558,6 +565,23 @@ var printable = (text) => {
558
565
  const clean = text.replace(/\u001b(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007\u001b]*(?:\u0007|\u001b\\)?|.)?/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
559
566
  return clean.length > MAX_PRINTED ? `${clean.slice(0, MAX_PRINTED)}...` : clean;
560
567
  };
568
+
569
+ // src/engage-keys.ts
570
+ var import_node_crypto2 = require("crypto");
571
+ var KEY_B64URL = /^[A-Za-z0-9_-]{43}$/;
572
+ var PKCS8_ED25519 = Buffer.from("302e020100300506032b657004220420", "hex");
573
+ function generateEngagementKeyPair() {
574
+ const jwk = (0, import_node_crypto2.generateKeyPairSync)("ed25519").privateKey.export({ format: "jwk" });
575
+ return { publicKey: String(jwk.x), privateKey: String(jwk.d) };
576
+ }
577
+ function engagementSigningKey(seed) {
578
+ const bytes = KEY_B64URL.test(seed) ? Buffer.from(seed, "base64url") : void 0;
579
+ if (bytes?.length !== 32) throw new TypeError("the engagement signing key must be a 32-byte Ed25519 seed, base64url (43 characters)");
580
+ return (0, import_node_crypto2.createPrivateKey)({ key: Buffer.concat([PKCS8_ED25519, bytes]), format: "der", type: "pkcs8" });
581
+ }
582
+ function engagementPublicKey(seed) {
583
+ return String((0, import_node_crypto2.createPublicKey)(engagementSigningKey(seed)).export({ format: "jwk" }).x);
584
+ }
561
585
  // Annotate the CommonJS export names for ESM import in node:
562
586
  0 && (module.exports = {
563
587
  CACHE_TAG_PATTERN,
@@ -567,7 +591,9 @@ var printable = (text) => {
567
591
  checkRoutes,
568
592
  createHyleClient,
569
593
  createRevalidationCallbackRoute,
594
+ engagementPublicKey,
570
595
  formatReport,
596
+ generateEngagementKeyPair,
571
597
  hostRoutesFromManifests,
572
598
  isValidCacheTag,
573
599
  listPublicationPaths,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-CwBCPh6K.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 ResolvedArticle, e as ResolvedDisabled, f as ResolvedList, g as ResolvedNotFound, h as ResolvedRedirect, T as TocEntry } from './types-CwBCPh6K.cjs';
1
+ import { R as Resolved, M as MountsResult } from './types-C72FwzOd.cjs';
2
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-C72FwzOd.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. */
@@ -272,4 +274,12 @@ declare function reservedFor(hostRoutes: readonly string[], options?: {
272
274
  /** The human report. */
273
275
  declare function formatReport(report: RouteCheckReport): string;
274
276
 
275
- export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
277
+ /** Fresh pair for `hyle-sdk-engage-keygen`. Nothing is logged here. */
278
+ declare function generateEngagementKeyPair(): {
279
+ readonly publicKey: string;
280
+ readonly privateKey: string;
281
+ };
282
+ /** The public half to register in hyle, from the private seed. */
283
+ declare function engagementPublicKey(seed: string): string;
284
+
285
+ export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, engagementPublicKey, formatReport, generateEngagementKeyPair, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Resolved, M as MountsResult } from './types-CwBCPh6K.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 ResolvedArticle, e as ResolvedDisabled, f as ResolvedList, g as ResolvedNotFound, h as ResolvedRedirect, T as TocEntry } from './types-CwBCPh6K.js';
1
+ import { R as Resolved, M as MountsResult } from './types-C72FwzOd.js';
2
+ export { A as Alternate, a as ArticleContent, B as Breadcrumb, C as CacheInfo, E as EngageComment, b as EngageHeldComment, c as EngageListing, F as Fallback, L as ListItem, d as Mount, e as Mounts, N as NavItem, f as NavNode, g as NavTree, h as ResolvedArticle, i as ResolvedDisabled, j as ResolvedList, k as ResolvedNotFound, l as ResolvedRedirect, T as TocEntry } from './types-C72FwzOd.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. */
@@ -272,4 +274,12 @@ declare function reservedFor(hostRoutes: readonly string[], options?: {
272
274
  /** The human report. */
273
275
  declare function formatReport(report: RouteCheckReport): string;
274
276
 
275
- export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, formatReport, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
277
+ /** Fresh pair for `hyle-sdk-engage-keygen`. Nothing is logged here. */
278
+ declare function generateEngagementKeyPair(): {
279
+ readonly publicKey: string;
280
+ readonly privateKey: string;
281
+ };
282
+ /** The public half to register in hyle, from the private seed. */
283
+ declare function engagementPublicKey(seed: string): string;
284
+
285
+ export { type AssetOptions, CACHE_TAG_PATTERN, Cp1ClientError, DeliveryDedupe, type DynamicOverlap, type HostSyncInput, type HostSyncResult, type HyleClient, type HyleClientOptions, type HyleRequestInit, type ListPublicationPathsOptions, type LocaleOptions, type LocalePrefix, type MountsOptions, MountsResult, type NextManifests, type ParsedSignatureHeader, type PublicationPath, type PublicationPaths, type ResolveOptions, Resolved, type RouteCheckInput, type RouteCheckReport, SDK_OWN_RESERVED, type VerifySignatureParams, checkRoutes, createHyleClient, engagementPublicKey, formatReport, generateEngagementKeyPair, hostRoutesFromManifests, isValidCacheTag, listPublicationPaths, normalizeRoute, parseSignatureHeader, reservedFor, routeMatches, syncHostReserved, verifyHyleSignature };
package/dist/index.js CHANGED
@@ -6,7 +6,9 @@ import {
6
6
  checkRoutes,
7
7
  createHyleClient,
8
8
  createRevalidationCallbackRoute,
9
+ engagementPublicKey,
9
10
  formatReport,
11
+ generateEngagementKeyPair,
10
12
  hostRoutesFromManifests,
11
13
  isValidCacheTag,
12
14
  listPublicationPaths,
@@ -16,7 +18,7 @@ import {
16
18
  routeMatches,
17
19
  syncHostReserved,
18
20
  verifyHyleSignature
19
- } from "./chunk-EBNIKRQH.js";
21
+ } from "./chunk-N7ZQUAGM.js";
20
22
  import "./chunk-67IOIAVW.js";
21
23
  export {
22
24
  CACHE_TAG_PATTERN,
@@ -26,7 +28,9 @@ export {
26
28
  checkRoutes,
27
29
  createHyleClient,
28
30
  createRevalidationCallbackRoute,
31
+ engagementPublicKey,
29
32
  formatReport,
33
+ generateEngagementKeyPair,
30
34
  hostRoutesFromManifests,
31
35
  isValidCacheTag,
32
36
  listPublicationPaths,
@@ -1,64 +1,19 @@
1
1
  "use client";
2
+ import {
3
+ MAX_MERMAID_SOURCE,
4
+ RENDER_TIMEOUT_MS,
5
+ nextMermaidId,
6
+ pickMermaidTheme,
7
+ stripMermaidConfig,
8
+ whenNearViewport,
9
+ withTimeout
10
+ } from "./chunk-R5EMI4HQ.js";
2
11
  import {
3
12
  VIEWER_LABELS_EN
4
13
  } from "./chunk-BUJFMR3M.js";
5
14
 
6
15
  // src/react/mermaid-diagram.tsx
7
16
  import { useEffect, useId, useMemo, useRef, useState } from "react";
8
-
9
- // src/react/mermaid-config.ts
10
- var MAX_MERMAID_SOURCE = 2e4;
11
- function luminance(css) {
12
- const m = /^(rgba?)\(([^)]*)\)$|^color\(srgb ([^)]*)\)$/.exec(css.trim());
13
- if (!m) return void 0;
14
- const parts = (m[2] ?? m[3] ?? "").split(/[\s,/]+/).filter(Boolean).map(Number);
15
- const [r, g, b] = parts.map((v) => m[3] ? v : v / 255);
16
- const alpha = parts[3] ?? 1;
17
- if (r === void 0 || g === void 0 || b === void 0 || [r, g, b, alpha].some(Number.isNaN) || alpha < 0.5) return void 0;
18
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
19
- }
20
- function pickMermaidTheme(background, prefersDark) {
21
- const l = luminance(background);
22
- return (l === void 0 ? prefersDark : l < 0.5) ? "dark" : "default";
23
- }
24
- var RENDER_TIMEOUT_MS = 1e4;
25
- var NEAR_VIEWPORT_MARGIN = "200px";
26
- var FRONTMATTER = /^\s*-{3}[^\S\n]*\n[\s\S]*?\n-{3}[^\S\n]*(?:\n|$)/;
27
- var DIRECTIVE = /%%\{(?:(?!\}%%)[\s\S])*(?:\}%%)?/g;
28
- function stripMermaidConfig(source) {
29
- let text = source.replace(/\r\n?/g, "\n");
30
- for (let previous = ""; previous !== text; ) {
31
- previous = text;
32
- text = text.replace(FRONTMATTER, "").replace(DIRECTIVE, "");
33
- }
34
- return text;
35
- }
36
- var counter = 0;
37
- var nextMermaidId = () => `hyle-mermaid-${++counter}`;
38
- function withTimeout(promise, ms) {
39
- let timer;
40
- const timeout = new Promise((_, reject) => {
41
- timer = setTimeout(() => reject(new Error("timeout")), ms);
42
- });
43
- return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
44
- }
45
- function whenNearViewport(el, onNear, Observer = globalThis.IntersectionObserver) {
46
- if (!Observer) {
47
- onNear();
48
- return () => {
49
- };
50
- }
51
- const observer = new Observer((entries) => {
52
- if (entries.some((e) => e.isIntersecting)) {
53
- observer.disconnect();
54
- onNear();
55
- }
56
- }, { rootMargin: NEAR_VIEWPORT_MARGIN });
57
- observer.observe(el);
58
- return () => observer.disconnect();
59
- }
60
-
61
- // src/react/mermaid-diagram.tsx
62
17
  import { jsx, jsxs } from "react/jsx-runtime";
63
18
  var queue = Promise.resolve();
64
19
  async function renderSvg(id, source, theme) {