@tdacorp/hyle-sdk 0.24.1 → 0.26.1

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 (44) hide show
  1. package/README.md +2 -2
  2. package/dist/{embed-BaLQbE_n.d.ts → brand-CwXvdSkk.d.ts} +14 -2
  3. package/dist/{embed-BrrGgkgQ.d.cts → brand-IuZSB9UX.d.cts} +14 -2
  4. package/dist/{chunk-RCK4NCYC.js → chunk-3UQGU62T.js} +12 -0
  5. package/dist/{chunk-O4QWHXVH.js → chunk-IDBQSMWT.js} +1 -1
  6. package/dist/{chunk-5TKJH2XC.js → chunk-NUQQ6VHH.js} +267 -43
  7. package/dist/{chunk-Y3BACEWA.js → chunk-T4EZAQFU.js} +129 -3
  8. package/dist/chunk-VAR2B7S6.js +82 -0
  9. package/dist/{chunk-U74B7AUG.js → chunk-ZWKAEWEW.js} +22 -74
  10. package/dist/{client-DN38IP63.d.ts → client-B2zi_BGq.d.ts} +1 -1
  11. package/dist/{client-CI-3cHtc.d.cts → client-DBZTvcCh.d.cts} +1 -1
  12. package/dist/comments.cjs +25 -1
  13. package/dist/comments.js +4 -2
  14. package/dist/html.cjs +129 -3
  15. package/dist/html.js +1 -1
  16. package/dist/index.cjs +12 -0
  17. package/dist/index.d.cts +4 -4
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +1 -1
  20. package/dist/next.cjs +593 -177
  21. package/dist/next.d.cts +27 -11
  22. package/dist/next.d.ts +27 -11
  23. package/dist/next.js +188 -124
  24. package/dist/react.cjs +401 -46
  25. package/dist/react.d.cts +114 -4
  26. package/dist/react.d.ts +114 -4
  27. package/dist/react.js +14 -4
  28. package/dist/reactions.cjs +25 -1
  29. package/dist/reactions.js +4 -2
  30. package/dist/{resolve-Ce_yz8gC.d.cts → resolve-0nGnsIHo.d.cts} +1 -1
  31. package/dist/{resolve-DMHbYyTS.d.ts → resolve-CguSaZLa.d.ts} +1 -1
  32. package/dist/{revalidation-callback-BQl77tQR.d.cts → revalidation-callback-FT9ik1dh.d.cts} +11 -0
  33. package/dist/{revalidation-callback-BQl77tQR.d.ts → revalidation-callback-FT9ik1dh.d.ts} +11 -0
  34. package/dist/share-client.cjs +498 -0
  35. package/dist/share-client.d.cts +99 -0
  36. package/dist/share-client.d.ts +99 -0
  37. package/dist/share-client.js +390 -0
  38. package/dist/styles.css +176 -1
  39. package/dist/{types-CxE8kLeo.d.cts → types-CdaIzSjg.d.cts} +2 -0
  40. package/dist/{types-CxE8kLeo.d.ts → types-CdaIzSjg.d.ts} +2 -0
  41. package/dist/use-cache.d.cts +3 -3
  42. package/dist/use-cache.d.ts +3 -3
  43. package/dist/use-cache.js +2 -2
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -153,7 +153,7 @@ export default function Wrapper(props) { return <Suspense fallback={null}><Page
153
153
 
154
154
  The credential is never part of a cache key: entries are keyed by `baseUrl` plus `workspaceId` (pass both to `cachedResolver`), and the token stays in a module-level map. A switched-off read surface (`kind: "disabled"`) is cached for at most 30 s, so turning it back on is not delayed by the full window.
155
155
 
156
- The revalidate route expires tags immediately (`revalidateTag(tag, { expire: 0 })`), so no stale page is served after a purge. `HYLE_CONTENT_ENABLED=0` (or `false`) answers 404 from the route, the site-side rollback switch; nothing configured is also 404; partly configured is 503.
156
+ The revalidate route expires tags immediately (`revalidateTag(tag, { expire: 0 })`), so no stale page is served after a purge. With `indexNow: { origin, key }` (for example `{ origin: "https://www.example.com", key: process.env.HYLE_INDEXNOW_KEY }`) it also submits the addresses a publish changed to IndexNow (Bing, Yandex and others; Google does not take part) after the purge. It submits only in production (`VERCEL_ENV`, else `NODE_ENV`) and only with a key, and a failure is logged and never changes hyle's answer. Set `HYLE_INDEXNOW_KEY` in production only: off Vercel the gate is `NODE_ENV`, so a staging server built in production mode would submit too. Pass `localePrefix` as you pass it to `hylePage`, and serve the key at `/<key>.txt` from `public/`. `HYLE_CONTENT_ENABLED=0` (or `false`) answers 404 from the route, the site-side rollback switch; nothing configured is also 404; partly configured is 503.
157
157
 
158
158
  ### List pages
159
159
 
@@ -436,7 +436,7 @@ import { createProtectedUnlockRoute } from "@tdacorp/hyle-sdk/next";
436
436
  export const { POST } = createProtectedUnlockRoute();
437
437
  ```
438
438
 
439
- `hyleRootPage` checks the slugs hyle reports in `GET /cp1/read/mounts` (`protected`) together with the mounts, so the longest entry wins (and a path under a live slug makes no resolve call), but **`hyleRootPage` never draws a share: a path under a live slug is `notFound()` there**, because a share is read with the visitor's cookie and the catch-all may be ISR, where reading a cookie is a 500. The proxy rewrite below is what serves a share, on every host, so a host without it shows its shares as 404. The longest entry wins, a share beating a mount only when it is longer, or equally long and of the same workspace config: one workspace's share never hides another workspace's mount. **A share hides everything under its slug** (`/<slug>` and `/<slug>/<doc>`), so a slug must not be a path or the parent of a path your host serves itself (`/learn` would take your own `/learn/notes`). hyle refuses a slug at, above or under a reserved path (`reserved_paths`, and the routes `hyle-sdk-check-routes --sync` sends as `host_reserved_paths`); a host route that was never synced is yours to keep out of share slugs. Without a cookie the page shows a password form (labelled, `autocomplete="off"`, the error announced) under a generic "Password required" heading. hyle's gate reply carries no share name, so a slug reveals only that a share exists. The form posts `slug` and `password` to `/hyle-protected/unlock`. The unlock route checks that the POST is same-origin and that its form body is at most 1 KiB, stores the password in an `HttpOnly`, `Secure`, `SameSite=Lax` cookie for 12 hours, scoped to `Path=/<slug>` and, for the share's images, to `Path=/api/hyle/assets` (never `Path=/`, so no other request of your host carries it), and redirects to `/<slug>`. It never calls hyle, so one view is one open. The page then asks hyle with `client.protected(slug, password, docSlug?)`: a wrong or expired password shows the form again with "Wrong or expired password". A good one draws one document as an article, or several as the docs layout with a sidebar that highlights the current document. The cookie is named `hyle_p_` and 16 characters of a hash of the slug, so one visitor can hold a password for each share.
439
+ `hyleRootPage` checks the slugs hyle reports in `GET /cp1/read/mounts` (`protected`) together with the mounts, so the longest entry wins (and a path under a live slug makes no resolve call), but **`hyleRootPage` never draws a share: a path under a live slug is `notFound()` there**, because a share is read with the visitor's cookie and the catch-all may be ISR, where reading a cookie is a 500. The proxy rewrite below is what serves a share, on every host, so a host without it shows its shares as 404. The longest entry wins, a share beating a mount only when it is longer, or equally long and of the same workspace config: one workspace's share never hides another workspace's mount. **A share hides everything under its slug** (`/<slug>` and `/<slug>/<doc>`), so a slug must not be a path or the parent of a path your host serves itself (`/learn` would take your own `/learn/notes`). hyle refuses a slug at, above or under a reserved path (`reserved_paths`, and the routes `hyle-sdk-check-routes --sync` sends as `host_reserved_paths`); a host route that was never synced is yours to keep out of share slugs. Without a cookie the page shows a password form (labelled, `autocomplete="off"`, the error announced) under a generic "Password required" heading. hyle's gate reply carries no share name, so a slug reveals only that a share exists. The form posts `slug`, `password` and the optional `docSlug` to `/hyle-protected/unlock`; the route answers a document slug only when it is a slug, and appends it to the redirect. The unlock route checks that the POST is same-origin and that its form body is at most 1 KiB, stores the password in an `HttpOnly`, `Secure`, `SameSite=Lax` cookie for 12 hours, scoped to `Path=/<slug>` and, for the share's images, to `Path=/api/hyle/assets` (never `Path=/`, so no other request of your host carries it), and redirects to `/<slug>`. It never calls hyle, so one view is one open. The page then asks hyle with `client.protected(slug, password, docSlug?)`: a wrong or expired password shows the form again with "Wrong or expired password". A good one is drawn by `ShareChrome`, the same way for one document and for several: a bar (the share's name and the current document, search over the share's own titles and descriptions, a theme menu, the expiry and a Lock button), the document list (not drawn for one document), and the article with its contents. The Lock button posts `slug` and `lock=1` to the same unlock route: it clears the cookie on both paths and sends the visitor to the gate with `?locked=1`, which says "Locked" and shows no name. A share is not drawn with the article layout: its cover, author and `article.*` slots (`article.before`, `article.meta`, `article.aside`, `article.after`) are not drawn, while `components` and the `chrome.*` slots are. The cookie is named `hyle_p_` and 16 characters of a hash of the slug, so one visitor can hold a password for each share.
440
440
 
441
441
  The password must be 12 to 128 visible ASCII characters (no space, quote, comma, semicolon, percent sign or backslash), so it fits a cookie and a header unchanged. It is sent to hyle only in the `cp-protected` header, and a malformed slug or password is refused before anything is sent. The redirect target is built from the validated slug alone. Nothing is logged. Keep analytics off the protected paths: a page URL is shared with the person who holds the password.
442
442
 
@@ -1,5 +1,5 @@
1
1
  import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
- import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CxE8kLeo.js';
2
+ import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CdaIzSjg.js';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -80,6 +80,10 @@ interface HyleSlots {
80
80
  "notfound.body"?: ReactNode;
81
81
  "notfound.actions"?: ReactNode;
82
82
  "redirecting.body"?: ReactNode;
83
+ /** The protected share chrome (decision 109): the host's logo and name, in place of the `host` option. */
84
+ "chrome.brand"?: ReactNode;
85
+ /** The protected share chrome: an extra block under the document list's foot. */
86
+ "chrome.sidebar-footer"?: ReactNode;
83
87
  }
84
88
  /** Props every page shares. */
85
89
  interface PageBaseProps {
@@ -180,4 +184,12 @@ declare function HyleCommentsFallback({ locale }: {
180
184
  locale?: string | undefined;
181
185
  }): ReactElement;
182
186
 
183
- export { type ArticleRef as A, type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type JsonLdConfig as J, type LinkProps as L, type MermaidProps as M, type OgImage as O, 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 };
187
+ /** The host of a share page: its logo and name, the only part of the chrome the host contributes (decision 109). */
188
+ interface ShareHost {
189
+ readonly name: string;
190
+ readonly logo?: ReactNode;
191
+ /** Where the logo links; defaults to the host's root. */
192
+ readonly href?: string;
193
+ }
194
+
195
+ export { type ArticleRef as A, type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type JsonLdConfig as J, type LinkProps as L, type MermaidProps as M, type OgImage as O, type PageBaseProps as P, type ShareHost as S, 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
1
  import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
- import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CxE8kLeo.cjs';
2
+ import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CdaIzSjg.cjs';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
5
5
  interface LinkProps {
@@ -80,6 +80,10 @@ interface HyleSlots {
80
80
  "notfound.body"?: ReactNode;
81
81
  "notfound.actions"?: ReactNode;
82
82
  "redirecting.body"?: ReactNode;
83
+ /** The protected share chrome (decision 109): the host's logo and name, in place of the `host` option. */
84
+ "chrome.brand"?: ReactNode;
85
+ /** The protected share chrome: an extra block under the document list's foot. */
86
+ "chrome.sidebar-footer"?: ReactNode;
83
87
  }
84
88
  /** Props every page shares. */
85
89
  interface PageBaseProps {
@@ -180,4 +184,12 @@ declare function HyleCommentsFallback({ locale }: {
180
184
  locale?: string | undefined;
181
185
  }): ReactElement;
182
186
 
183
- export { type ArticleRef as A, type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type JsonLdConfig as J, type LinkProps as L, type MermaidProps as M, type OgImage as O, 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 };
187
+ /** The host of a share page: its logo and name, the only part of the chrome the host contributes (decision 109). */
188
+ interface ShareHost {
189
+ readonly name: string;
190
+ readonly logo?: ReactNode;
191
+ /** Where the logo links; defaults to the host's root. */
192
+ readonly href?: string;
193
+ }
194
+
195
+ export { type ArticleRef as A, type CalloutKind as C, type EngagementConfig as E, type HyleComponents as H, type ImageProps as I, type JsonLdConfig as J, type LinkProps as L, type MermaidProps as M, type OgImage as O, type PageBaseProps as P, type ShareHost as S, 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 };
@@ -386,6 +386,10 @@ async function runHook(hook, event) {
386
386
  clearTimeout(timer);
387
387
  }
388
388
  }
389
+ function parseIndexUrls(value) {
390
+ if (!Array.isArray(value)) return [];
391
+ return value.flatMap((item) => isRecord(item) && isEventPath(item.path) && isText(item.locale) ? [{ path: item.path, locale: item.locale }] : []);
392
+ }
389
393
  function createRevalidationCallbackRoute(options) {
390
394
  const dedupe = new DeliveryDedupe(options.dedupeCapacity);
391
395
  return {
@@ -438,6 +442,14 @@ function createRevalidationCallbackRoute(options) {
438
442
  const hook = options.onCommentEvent;
439
443
  const event = hook && parseCommentEvent(body);
440
444
  if (hook && event) await runHook(hook, event);
445
+ const indexUrls = parseIndexUrls(body.index_urls);
446
+ if (options.onIndexUrls && indexUrls.length > 0) {
447
+ try {
448
+ options.onIndexUrls(indexUrls);
449
+ } catch {
450
+ console.error("hyle: onIndexUrls failed");
451
+ }
452
+ }
441
453
  return okResponse(purged);
442
454
  }
443
455
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createHyleClient,
3
3
  isValidCacheTag
4
- } from "./chunk-RCK4NCYC.js";
4
+ } from "./chunk-3UQGU62T.js";
5
5
 
6
6
  // src/next/resolve.ts
7
7
  var DEFAULT_REVALIDATE = 86400;
@@ -9,7 +9,7 @@ import {
9
9
  scopeId,
10
10
  stringsFor,
11
11
  youtubeId
12
- } from "./chunk-Y3BACEWA.js";
12
+ } from "./chunk-T4EZAQFU.js";
13
13
  import {
14
14
  hostAssetHtml,
15
15
  themeFontHrefs,
@@ -70,7 +70,31 @@ var SHAPES = {
70
70
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
71
71
  /* @__PURE__ */ jsx("path", { d: "m3.8 12.2 8.4-8.4" })
72
72
  ] }),
73
- refresh: /* @__PURE__ */ jsx("path", { d: "M13 8a5 5 0 1 1-1.6-3.7M13 2.5v2.8h-2.8" })
73
+ refresh: /* @__PURE__ */ jsx("path", { d: "M13 8a5 5 0 1 1-1.6-3.7M13 2.5v2.8h-2.8" }),
74
+ lock: /* @__PURE__ */ jsxs(Fragment, { children: [
75
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "7", width: "10", height: "7", rx: "1.3" }),
76
+ /* @__PURE__ */ jsx("path", { d: "M5.2 7V5a2.8 2.8 0 0 1 5.6 0v2" })
77
+ ] }),
78
+ search: /* @__PURE__ */ jsxs(Fragment, { children: [
79
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5" }),
80
+ /* @__PURE__ */ jsx("path", { d: "m10.5 10.5 3.5 3.5" })
81
+ ] }),
82
+ sun: /* @__PURE__ */ jsxs(Fragment, { children: [
83
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "2.8" }),
84
+ /* @__PURE__ */ jsx("path", { d: "M8 1.5v1.8M8 12.7v1.8M1.5 8h1.8M12.7 8h1.8M3.4 3.4l1.3 1.3M11.3 11.3l1.3 1.3M3.4 12.6l1.3-1.3M11.3 4.7l1.3-1.3" })
85
+ ] }),
86
+ moon: /* @__PURE__ */ jsx("path", { d: "M13 9.4A5.6 5.6 0 0 1 6.6 3a5.6 5.6 0 1 0 6.4 6.4z" }),
87
+ monitor: /* @__PURE__ */ jsxs(Fragment, { children: [
88
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "12", height: "8", rx: "1.3" }),
89
+ /* @__PURE__ */ jsx("path", { d: "M6 14h4M8 11v3" })
90
+ ] }),
91
+ sidebar: /* @__PURE__ */ jsxs(Fragment, { children: [
92
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "12", height: "10", rx: "1.3" }),
93
+ /* @__PURE__ */ jsx("path", { d: "M6.5 3v10" })
94
+ ] }),
95
+ shield: /* @__PURE__ */ jsx("path", { d: "M8 1.5 2.5 3.6v4c0 3.2 2.3 5.4 5.5 6.9 3.2-1.5 5.5-3.7 5.5-6.9v-4z" }),
96
+ "arrow-left": /* @__PURE__ */ jsx("path", { d: "M13 8H3M7 4 3 8l4 4" }),
97
+ menu: /* @__PURE__ */ jsx("path", { d: "M2.5 4.5h11M2.5 8h11M2.5 11.5h11" })
74
98
  };
75
99
  function Icon({ name, className }) {
76
100
  return /* @__PURE__ */ jsx("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
@@ -995,7 +1019,30 @@ import { HyleReactions } from "./reactions.js";
995
1019
 
996
1020
  // src/react/docs.tsx
997
1021
  import { DocsEnhance } from "./docs-enhance.js";
998
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1022
+
1023
+ // src/react/docs-main.tsx
1024
+ import { Fragment as Fragment9, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
1025
+ function DocsMain({ article, c, components, narrowToc, prev, next, eyebrow }) {
1026
+ const { publication: pub } = article;
1027
+ const { s } = c;
1028
+ return /* @__PURE__ */ jsxs9(Fragment9, { children: [
1029
+ eyebrow,
1030
+ /* @__PURE__ */ jsx10("h1", { className: "hyle-title", children: pub.title }),
1031
+ pub.description ? /* @__PURE__ */ jsx10("p", { className: "hyle-desc", children: pub.description }) : null,
1032
+ /* @__PURE__ */ jsxs9("p", { className: "hyle-updated", children: [
1033
+ /* @__PURE__ */ jsx10(Icon, { name: "calendar" }),
1034
+ s.updated,
1035
+ " ",
1036
+ /* @__PURE__ */ jsx10("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
1037
+ ] }),
1038
+ narrowToc,
1039
+ /* @__PURE__ */ jsx10(Body, { article, components, locale: c.locale }),
1040
+ /* @__PURE__ */ jsx10(Pager, { prev, next, c })
1041
+ ] });
1042
+ }
1043
+
1044
+ // src/react/docs.tsx
1045
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
999
1046
  var ROOT_ID = "hyle-docs";
1000
1047
  var NAV_ID = "hyle-docs-nav";
1001
1048
  function navTreeOf(article) {
@@ -1019,15 +1066,15 @@ function pathTo(nodes, path) {
1019
1066
  }
1020
1067
  function Branch({ nodes, current, onPath, c }) {
1021
1068
  const { Link } = c;
1022
- return /* @__PURE__ */ jsx10("ul", { children: nodes.map((node) => {
1023
- const link = /* @__PURE__ */ jsx10(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
1024
- if (node.children.length === 0) return /* @__PURE__ */ jsx10("li", { children: link }, node.canonical_path);
1025
- return /* @__PURE__ */ jsx10("li", { children: /* @__PURE__ */ jsxs9("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
1026
- /* @__PURE__ */ jsxs9("summary", { children: [
1027
- /* @__PURE__ */ jsx10(Icon, { name: "chev" }),
1069
+ return /* @__PURE__ */ jsx11("ul", { children: nodes.map((node) => {
1070
+ const link = /* @__PURE__ */ jsx11(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
1071
+ if (node.children.length === 0) return /* @__PURE__ */ jsx11("li", { children: link }, node.canonical_path);
1072
+ return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsxs10("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
1073
+ /* @__PURE__ */ jsxs10("summary", { children: [
1074
+ /* @__PURE__ */ jsx11(Icon, { name: "chev" }),
1028
1075
  link
1029
1076
  ] }),
1030
- /* @__PURE__ */ jsx10(Branch, { nodes: node.children, current, onPath, c })
1077
+ /* @__PURE__ */ jsx11(Branch, { nodes: node.children, current, onPath, c })
1031
1078
  ] }) }, node.canonical_path);
1032
1079
  }) });
1033
1080
  }
@@ -1041,52 +1088,224 @@ function DocsPage({ article, ...base }) {
1041
1088
  const siteName = article.breadcrumbs[0]?.title ?? "";
1042
1089
  const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
1043
1090
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1044
- return /* @__PURE__ */ jsx10(Shell, { theme: article.theme, children: /* @__PURE__ */ jsxs9("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
1045
- /* @__PURE__ */ jsx10(DocsEnhance, { headingIds, rootId: ROOT_ID }),
1046
- /* @__PURE__ */ jsxs9("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
1047
- /* @__PURE__ */ jsx10(Icon, { name: "file" }),
1091
+ return /* @__PURE__ */ jsx11(Shell, { theme: article.theme, children: /* @__PURE__ */ jsxs10("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
1092
+ /* @__PURE__ */ jsx11(DocsEnhance, { headingIds, rootId: ROOT_ID }),
1093
+ /* @__PURE__ */ jsxs10("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
1094
+ /* @__PURE__ */ jsx11(Icon, { name: "file" }),
1048
1095
  s.menu,
1049
- /* @__PURE__ */ jsx10("span", { className: "cur", children: pub.title }),
1050
- /* @__PURE__ */ jsx10(Icon, { name: "chev-down", className: "hyle-chev" })
1096
+ /* @__PURE__ */ jsx11("span", { className: "cur", children: pub.title }),
1097
+ /* @__PURE__ */ jsx11(Icon, { name: "chev-down", className: "hyle-chev" })
1051
1098
  ] }),
1052
- /* @__PURE__ */ jsxs9("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
1053
- /* @__PURE__ */ jsxs9("div", { className: "hyle-side-head", children: [
1054
- /* @__PURE__ */ jsx10("b", { children: siteName }),
1055
- /* @__PURE__ */ jsx10(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
1056
- /* @__PURE__ */ jsx10("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ jsx10(Icon, { name: "x" }) })
1099
+ /* @__PURE__ */ jsxs10("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
1100
+ /* @__PURE__ */ jsxs10("div", { className: "hyle-side-head", children: [
1101
+ /* @__PURE__ */ jsx11("b", { children: siteName }),
1102
+ /* @__PURE__ */ jsx11(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
1103
+ /* @__PURE__ */ jsx11("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ jsx11(Icon, { name: "x" }) })
1057
1104
  ] }),
1058
- /* @__PURE__ */ jsx10(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
1059
- /* @__PURE__ */ jsx10("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ jsx10(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
1060
- /* @__PURE__ */ jsx10(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
1105
+ /* @__PURE__ */ jsx11(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
1106
+ /* @__PURE__ */ jsx11("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ jsx11(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
1107
+ /* @__PURE__ */ jsx11(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
1061
1108
  ] }),
1062
- /* @__PURE__ */ jsxs9("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
1063
- notTranslated ? /* @__PURE__ */ jsxs9("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1064
- /* @__PURE__ */ jsx10(Icon, { name: "alert" }),
1065
- /* @__PURE__ */ jsxs9("div", { children: [
1066
- /* @__PURE__ */ jsx10("b", { children: notTranslated }),
1109
+ /* @__PURE__ */ jsxs10("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
1110
+ notTranslated ? /* @__PURE__ */ jsxs10("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1111
+ /* @__PURE__ */ jsx11(Icon, { name: "alert" }),
1112
+ /* @__PURE__ */ jsxs10("div", { children: [
1113
+ /* @__PURE__ */ jsx11("b", { children: notTranslated }),
1067
1114
  " ",
1068
1115
  s.fallbackBody
1069
1116
  ] })
1070
1117
  ] }) : null,
1071
- /* @__PURE__ */ jsx10("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ jsx10("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ jsx10("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ jsx10(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
1072
- /* @__PURE__ */ jsx10("h1", { className: "hyle-title", children: pub.title }),
1073
- pub.description ? /* @__PURE__ */ jsx10("p", { className: "hyle-desc", children: pub.description }) : null,
1074
- /* @__PURE__ */ jsxs9("p", { className: "hyle-updated", children: [
1075
- /* @__PURE__ */ jsx10(Icon, { name: "calendar" }),
1076
- s.updated,
1077
- " ",
1078
- /* @__PURE__ */ jsx10("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
1079
- ] }),
1080
- toc.narrow,
1081
- /* @__PURE__ */ jsx10(Body, { article, components: base.components, locale: c.locale }),
1082
- /* @__PURE__ */ jsx10(Pager, { prev: article.prev, next: article.next, c }),
1083
- /* @__PURE__ */ jsx10(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
1084
- /* @__PURE__ */ jsx10("span", { className: "hyle-docs-end", "aria-hidden": "true" })
1118
+ /* @__PURE__ */ jsx11("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ jsx11("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ jsx11("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ jsx11(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
1119
+ /* @__PURE__ */ jsx11(DocsMain, { article, c, components: base.components, narrowToc: toc.narrow, prev: article.prev, next: article.next }),
1120
+ /* @__PURE__ */ jsx11(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
1121
+ /* @__PURE__ */ jsx11("span", { className: "hyle-docs-end", "aria-hidden": "true" })
1085
1122
  ] }),
1086
1123
  toc.wide
1087
1124
  ] }) });
1088
1125
  }
1089
1126
 
1127
+ // src/react/share/chrome.tsx
1128
+ import { ShareDrawerClose, ShareExpiryChip, ShareExpiryNotice, ShareFoldButton, ShareFrame, ShareMenuButton, ShareSearch, ShareThemeMenu } from "./share-client.js";
1129
+
1130
+ // src/react/share/model.ts
1131
+ var THEME_COOKIE = "hyle_theme";
1132
+ var SIDE_COOKIE = "hyle_share_side";
1133
+ var SOON_MS = 24 * 60 * 60 * 1e3;
1134
+ function expiryState(expiresAt, now) {
1135
+ if (expiresAt === null) return "none";
1136
+ const end = Date.parse(expiresAt);
1137
+ if (Number.isNaN(end) || now >= end) return "expired";
1138
+ return end - now <= SOON_MS ? "soon" : "ok";
1139
+ }
1140
+ function shareDate(iso, locale) {
1141
+ const date = new Date(iso);
1142
+ const text = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(date);
1143
+ return `${text} UTC`;
1144
+ }
1145
+ function themeFromCookie(value) {
1146
+ return value === "light" || value === "dark" ? value : "system";
1147
+ }
1148
+ function actFor(choice) {
1149
+ return choice === "system" ? void 0 : choice;
1150
+ }
1151
+
1152
+ // src/react/share/brand.tsx
1153
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1154
+ function brandFor(host, fill) {
1155
+ if (fill) return /* @__PURE__ */ jsx12("div", { className: "hyle-brand", "data-slot": "chrome.brand", children: fill });
1156
+ if (!host) return null;
1157
+ return /* @__PURE__ */ jsxs11("a", { className: "hyle-brand", href: host.href ?? "/", children: [
1158
+ host.logo,
1159
+ /* @__PURE__ */ jsx12("span", { className: "nm", children: host.name })
1160
+ ] });
1161
+ }
1162
+
1163
+ // src/react/share/chrome.tsx
1164
+ import { Fragment as Fragment10, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1165
+ function ShareChrome(props) {
1166
+ const { name, expiresAt, documents, article, docSlug, host, theme = "system", sidebarOpen = true, htmlTheme = false, hrefFor, lockAction, slug, now = Date.now(), ...base } = props;
1167
+ const { publication: pub } = article;
1168
+ const c = ctx(base, pub.locale);
1169
+ const s = c.s.share;
1170
+ const list = [...documents].sort((a, b) => a.position - b.position || (a.doc_slug < b.doc_slug ? -1 : 1));
1171
+ const index = list.findIndex((d) => d.doc_slug === docSlug);
1172
+ const single = list.length <= 1;
1173
+ const initial = expiryState(expiresAt, now);
1174
+ const labels = {
1175
+ protectedTag: s.protectedTag,
1176
+ noExpiry: s.noExpiry,
1177
+ expires: s.expires,
1178
+ expiresSoon: s.expiresSoon,
1179
+ expired: s.expired,
1180
+ soonNotice: s.soonNotice,
1181
+ endedNotice: s.endedNotice
1182
+ };
1183
+ const navItem = (d) => ({ slug: d.doc_slug, title: d.title, description: d.description ?? null, canonical_path: hrefFor(d.doc_slug) });
1184
+ const prev = index > 0 ? navItem(list[index - 1]) : null;
1185
+ const next = index >= 0 && index < list.length - 1 ? navItem(list[index + 1]) : null;
1186
+ const searchDocs = list.map((d) => ({ slug: d.doc_slug, title: d.title, description: d.description ?? null, href: hrefFor(d.doc_slug) }));
1187
+ const when = expiresAt === null ? s.noExpiry : s.expires.replace("{when}", shareDate(expiresAt, c.locale));
1188
+ const toc = Toc({ toc: article.toc, c });
1189
+ const side = single ? "none" : sidebarOpen ? "open" : "closed";
1190
+ const eyebrow = single || index < 0 ? void 0 : /* @__PURE__ */ jsx13("p", { className: "hyle-eyebrow", children: s.documentPosition.replace("{i}", String(index + 1)).replace("{n}", String(list.length)) });
1191
+ return /* @__PURE__ */ jsxs12(Fragment10, { children: [
1192
+ /* @__PURE__ */ jsx13(HyleTheme, { theme: article.theme }),
1193
+ /* @__PURE__ */ jsxs12(ShareFrame, { sidebarOpen, single, act: actFor(theme), lang: c.locale, children: [
1194
+ /* @__PURE__ */ jsx13("a", { className: "hyle-skip", href: "#hyle-main", children: s.skip }),
1195
+ /* @__PURE__ */ jsxs12("header", { className: "hyle-bar", children: [
1196
+ single ? null : /* @__PURE__ */ jsx13(ShareMenuButton, { label: s.showDocuments }),
1197
+ single ? null : /* @__PURE__ */ jsx13(ShareFoldButton, { show: s.showDocuments, hide: s.hideDocuments }),
1198
+ brandFor(host, base.slots?.["chrome.brand"]),
1199
+ /* @__PURE__ */ jsxs12("div", { className: "hyle-bar-title", children: [
1200
+ /* @__PURE__ */ jsx13("span", { className: "share", children: name }),
1201
+ /* @__PURE__ */ jsx13("span", { className: "sep", "aria-hidden": "true", children: "/" }),
1202
+ /* @__PURE__ */ jsx13("span", { className: "doc", children: pub.title })
1203
+ ] }),
1204
+ /* @__PURE__ */ jsx13("span", { className: "sp" }),
1205
+ /* @__PURE__ */ jsx13(ShareSearch, { docs: searchDocs, labels: { label: s.searchLabel, hint: s.searchHint, none: s.searchNone, scope: s.searchScope, count: s.searchCount, one: s.searchOne, close: s.close } }),
1206
+ /* @__PURE__ */ jsx13(ShareThemeMenu, { choice: theme, htmlTheme, labels: { label: s.theme, light: s.themeLight, dark: s.themeDark, system: s.themeSystem } }),
1207
+ /* @__PURE__ */ jsx13(ShareExpiryChip, { expiresAt, initial, locale: c.locale, labels }),
1208
+ /* @__PURE__ */ jsxs12("form", { className: "hyle-lock-form", method: "post", action: lockAction, children: [
1209
+ /* @__PURE__ */ jsx13("input", { type: "hidden", name: "slug", value: slug }),
1210
+ /* @__PURE__ */ jsx13("input", { type: "hidden", name: "lock", value: "1" }),
1211
+ /* @__PURE__ */ jsxs12("button", { className: "hyle-lock", type: "submit", "aria-label": s.lock, title: s.lockTitle, children: [
1212
+ /* @__PURE__ */ jsx13(Icon, { name: "lock" }),
1213
+ /* @__PURE__ */ jsx13("span", { children: s.lock })
1214
+ ] })
1215
+ ] })
1216
+ ] }),
1217
+ /* @__PURE__ */ jsx13(ShareExpiryNotice, { expiresAt, initial, labels }),
1218
+ /* @__PURE__ */ jsx13("div", { className: "hyle-statusrow", children: /* @__PURE__ */ jsx13(ShareExpiryChip, { expiresAt, initial, locale: c.locale, labels }) }),
1219
+ /* @__PURE__ */ jsxs12("div", { className: "hyle-share-body", "data-side": side, children: [
1220
+ single ? null : /* @__PURE__ */ jsx13(Fragment10, { children: /* @__PURE__ */ jsxs12("aside", { className: "hyle-side", id: "hyle-side", popover: "auto", "aria-label": s.documents, children: [
1221
+ /* @__PURE__ */ jsxs12("div", { className: "hyle-side-head", children: [
1222
+ /* @__PURE__ */ jsxs12("div", { children: [
1223
+ /* @__PURE__ */ jsx13("span", { className: "nm", children: name }),
1224
+ /* @__PURE__ */ jsx13("span", { className: "n", children: s.documentCount.replace("{n}", String(list.length)) })
1225
+ ] }),
1226
+ /* @__PURE__ */ jsx13(ShareDrawerClose, { label: s.closeDocuments })
1227
+ ] }),
1228
+ /* @__PURE__ */ jsx13("nav", { className: "hyle-side-list", "aria-label": s.documents, children: /* @__PURE__ */ jsx13("ol", { children: list.map((d) => /* @__PURE__ */ jsx13("li", { children: /* @__PURE__ */ jsx13(c.Link, { href: hrefFor(d.doc_slug), title: d.title, ...d.doc_slug === docSlug ? { "aria-current": "page" } : {}, children: /* @__PURE__ */ jsx13("span", { children: d.title }) }) }, d.doc_slug)) }) }),
1229
+ /* @__PURE__ */ jsxs12("div", { className: "hyle-side-foot", children: [
1230
+ /* @__PURE__ */ jsxs12("p", { children: [
1231
+ /* @__PURE__ */ jsx13(Icon, { name: "clock" }),
1232
+ /* @__PURE__ */ jsx13("span", { children: when })
1233
+ ] }),
1234
+ /* @__PURE__ */ jsxs12("p", { children: [
1235
+ /* @__PURE__ */ jsx13(Icon, { name: "lock" }),
1236
+ /* @__PURE__ */ jsx13("span", { children: s.privateCopy })
1237
+ ] }),
1238
+ /* @__PURE__ */ jsx13(Slot, { name: "chrome.sidebar-footer", slots: base.slots })
1239
+ ] })
1240
+ ] }) }),
1241
+ /* @__PURE__ */ jsxs12("main", { className: "hyle-share-main", id: "hyle-main", tabIndex: -1, children: [
1242
+ /* @__PURE__ */ jsx13("article", { className: "hyle-doc", "data-hyle-page": "docs", lang: pub.locale, children: /* @__PURE__ */ jsx13(DocsMain, { article, c, components: base.components, narrowToc: toc.narrow, prev, next, eyebrow }) }),
1243
+ toc.wide
1244
+ ] })
1245
+ ] })
1246
+ ] })
1247
+ ] });
1248
+ }
1249
+
1250
+ // src/react/share/gate.tsx
1251
+ import { ShareThemeMenu as ShareThemeMenu2 } from "./share-client.js";
1252
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1253
+ var PASSWORD_FIELD = "hyle-share-password";
1254
+ var ERROR_ID = "hyle-share-error";
1255
+ function ShareGate({ state, slug, unlockAction, docSlug, retryAfterSeconds = 0, host, theme = "system", htmlTheme = false, ...base }) {
1256
+ const c = ctx(base, "en");
1257
+ const s = c.s.share;
1258
+ const act = actFor(theme);
1259
+ const wrong = state === "wrong";
1260
+ return /* @__PURE__ */ jsxs13("div", { className: "hyle hyle-share", lang: c.locale, "data-hyle-chrome": "gate", ...act ? { "data-act": act } : {}, children: [
1261
+ /* @__PURE__ */ jsx14("a", { className: "hyle-skip", href: "#hyle-main", children: s.skip }),
1262
+ /* @__PURE__ */ jsxs13("header", { className: "hyle-bar", children: [
1263
+ brandFor(host, base.slots?.["chrome.brand"]),
1264
+ /* @__PURE__ */ jsx14("span", { className: "sp" }),
1265
+ /* @__PURE__ */ jsx14(ShareThemeMenu2, { choice: theme, htmlTheme, labels: { label: s.theme, light: s.themeLight, dark: s.themeDark, system: s.themeSystem } })
1266
+ ] }),
1267
+ /* @__PURE__ */ jsx14("main", { className: "hyle-gate", id: "hyle-main", tabIndex: -1, children: state === "attempts" ? /* @__PURE__ */ jsxs13("section", { className: "hyle-card", "data-kind": "warn", children: [
1268
+ /* @__PURE__ */ jsx14("span", { className: "glyph", children: /* @__PURE__ */ jsx14(Icon, { name: "clock" }) }),
1269
+ /* @__PURE__ */ jsx14("h1", { children: s.attemptsTitle }),
1270
+ /* @__PURE__ */ jsx14("p", { role: "alert", children: (retryAfterSeconds === 1 ? s.attemptsOne : s.attemptsBody).replace("{n}", String(retryAfterSeconds)) })
1271
+ ] }) : state === "unavailable" ? /* @__PURE__ */ jsxs13("section", { className: "hyle-card", children: [
1272
+ /* @__PURE__ */ jsx14("span", { className: "glyph", children: /* @__PURE__ */ jsx14(Icon, { name: "x-circle" }) }),
1273
+ /* @__PURE__ */ jsx14("h1", { children: s.unavailableTitle }),
1274
+ /* @__PURE__ */ jsx14("p", { children: s.unavailableBody })
1275
+ ] }) : /* @__PURE__ */ jsxs13("section", { className: "hyle-card", children: [
1276
+ /* @__PURE__ */ jsx14("span", { className: "glyph", children: /* @__PURE__ */ jsx14(Icon, { name: "lock" }) }),
1277
+ /* @__PURE__ */ jsx14("h1", { children: s.gateTitle }),
1278
+ /* @__PURE__ */ jsx14("p", { children: s.gateBody }),
1279
+ /* @__PURE__ */ jsxs13("form", { method: "post", action: unlockAction, autoComplete: "off", children: [
1280
+ /* @__PURE__ */ jsx14("input", { type: "hidden", name: "slug", value: slug }),
1281
+ docSlug !== void 0 && /* @__PURE__ */ jsx14("input", { type: "hidden", name: "docSlug", value: docSlug }),
1282
+ /* @__PURE__ */ jsx14("label", { htmlFor: PASSWORD_FIELD, children: s.gatePassword }),
1283
+ /* @__PURE__ */ jsx14(
1284
+ "input",
1285
+ {
1286
+ id: PASSWORD_FIELD,
1287
+ name: "password",
1288
+ type: "password",
1289
+ autoComplete: "off",
1290
+ spellCheck: false,
1291
+ required: true,
1292
+ minLength: 12,
1293
+ maxLength: 128,
1294
+ "aria-invalid": wrong || void 0,
1295
+ "aria-describedby": wrong ? ERROR_ID : void 0
1296
+ }
1297
+ ),
1298
+ wrong ? /* @__PURE__ */ jsx14("p", { className: "err", id: ERROR_ID, role: "alert", children: s.gateWrong }) : null,
1299
+ /* @__PURE__ */ jsx14("button", { className: "hyle-btn primary", type: "submit", children: s.gateOpen })
1300
+ ] })
1301
+ ] }) }),
1302
+ state === "locked" ? /* @__PURE__ */ jsxs13("div", { className: "hyle-toast", role: "status", children: [
1303
+ /* @__PURE__ */ jsx14(Icon, { name: "check-circle" }),
1304
+ s.locked
1305
+ ] }) : null
1306
+ ] });
1307
+ }
1308
+
1090
1309
  export {
1091
1310
  HastContent,
1092
1311
  TrustedServerHtml,
@@ -1118,6 +1337,11 @@ export {
1118
1337
  Unavailable,
1119
1338
  Redirecting,
1120
1339
  DocsPage,
1340
+ THEME_COOKIE,
1341
+ SIDE_COOKIE,
1342
+ themeFromCookie,
1343
+ ShareChrome,
1344
+ ShareGate,
1121
1345
  MermaidDiagram2 as MermaidDiagram,
1122
1346
  holdPrintUntil,
1123
1347
  installPrintShortcut,