@tdacorp/hyle-sdk 0.17.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +155 -28
  2. package/dist/check-routes-bin.js +38 -13
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +728 -275
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +409 -326
  20. package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
  21. package/dist/{embed-BmdwA2G9.d.cts → embed-BUFRQboD.d.ts} +2 -2
  22. package/dist/{embed-DNTZ2UXv.d.ts → embed-CYt-q13P.d.cts} +2 -2
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.cts} +9 -0
  36. package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.ts} +9 -0
  37. package/dist/mermaid-diagram.cjs +401 -125
  38. package/dist/mermaid-diagram.d.cts +23 -7
  39. package/dist/mermaid-diagram.d.ts +23 -7
  40. package/dist/mermaid-diagram.js +204 -51
  41. package/dist/mermaid-image.cjs +134 -60
  42. package/dist/mermaid-image.d.cts +4 -3
  43. package/dist/mermaid-image.d.ts +4 -3
  44. package/dist/mermaid-image.js +27 -28
  45. package/dist/next.cjs +627 -264
  46. package/dist/next.d.cts +11 -8
  47. package/dist/next.d.ts +11 -8
  48. package/dist/next.js +39 -12
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +556 -226
  54. package/dist/react.d.cts +136 -29
  55. package/dist/react.d.ts +136 -29
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-euZ4-aC9.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +96 -25
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-Czt887Iv.d.cts → types-3F0wqD-o.d.cts} +26 -2
  73. package/dist/{types-Czt887Iv.d.ts → types-3F0wqD-o.d.ts} +26 -2
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-DMK4XQLU.js +0 -1556
  84. package/dist/chunk-PJMJMP66.js +0 -63
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -1,5 +1,6 @@
1
- import { H as HyleResolver } from './resolve-Ae7UFjsQ.js';
2
- import './types-Czt887Iv.js';
1
+ import { H as HyleAuth } from './client-LwzHwqpM.js';
2
+ import { H as HyleResolver } from './resolve-BjAK0k_Y.js';
3
+ import './types-3F0wqD-o.js';
3
4
 
4
5
  /**
5
6
  * The exact caching strategy: a `'use cache'` function that fetches, then tags its own entry with the tags the response
@@ -7,14 +8,20 @@ import './types-Czt887Iv.js';
7
8
  * if the host enables `cacheComponents: true`; with it off, merely importing this file fails the build. That is why it is
8
9
  * a separate entry (`@tdacorp/hyle-sdk/next/use-cache`) that a host imports only when it opts in.
9
10
  */
10
- interface CachedResolverOptions {
11
+ type CachedResolverOptions = {
11
12
  readonly baseUrl: string;
12
13
  /** The workspace id (HYLE_WORKSPACE_ID). With `baseUrl` it identifies the cache entries, so it must not be secret. */
13
14
  readonly workspaceId: string;
14
- readonly token: string;
15
+ /** `token` (a target credential) or `auth` (an identity machine token, `HyleAuth`); never part of a cache key. */
15
16
  /** Seconds before a cached page is revalidated in the background. Webhooks purge sooner. Default 300. */
16
17
  readonly revalidate?: number;
17
- }
18
+ } & ({
19
+ readonly token: string;
20
+ readonly auth?: never;
21
+ } | {
22
+ readonly auth: HyleAuth;
23
+ readonly token?: never;
24
+ });
18
25
  declare function cachedResolver(options: CachedResolverOptions): HyleResolver;
19
26
 
20
27
  export { type CachedResolverOptions, cachedResolver };
package/dist/use-cache.js CHANGED
@@ -1,29 +1,29 @@
1
1
  import {
2
2
  DEFAULT_REVALIDATE
3
- } from "./chunk-6VOHFFA5.js";
3
+ } from "./chunk-X2TLYM7Y.js";
4
4
  import {
5
5
  createHyleClient,
6
6
  isValidCacheTag
7
- } from "./chunk-MGSUQBDW.js";
7
+ } from "./chunk-75JFLML4.js";
8
8
  import "./chunk-67IOIAVW.js";
9
9
 
10
10
  // src/next/use-cache.ts
11
11
  import { cacheLife, cacheTag } from "next/cache";
12
12
  var MAX_TAGS = 128;
13
13
  var DISABLED_REVALIDATE = 30;
14
- var tokens = /* @__PURE__ */ new Map();
14
+ var credentials = /* @__PURE__ */ new Map();
15
15
  var keyOf = (baseUrl, workspaceId) => `${baseUrl}\0${workspaceId}`;
16
16
  async function resolveCached(baseUrl, workspaceId, path, locale, limit, cursor, nav, revalidate) {
17
17
  "use cache";
18
- const token = tokens.get(keyOf(baseUrl, workspaceId));
19
- if (!token) throw new Error("hyle: unknown cache configuration");
20
- const result = await createHyleClient({ baseUrl, token }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {}, ...nav === "tree" ? { nav: "tree" } : {} });
18
+ const credential = credentials.get(keyOf(baseUrl, workspaceId));
19
+ if (!credential) throw new Error("hyle: unknown cache configuration");
20
+ const result = await createHyleClient({ baseUrl, ...credential }).resolve({ path, ...locale ? { locale } : {}, ...limit > 0 ? { limit } : {}, ...cursor ? { cursor } : {}, ...nav === "tree" ? { nav: "tree" } : {} });
21
21
  if (result.kind !== "disabled") cacheTag(...result.cache.tags.filter(isValidCacheTag).slice(0, MAX_TAGS));
22
22
  cacheLife({ stale: 30, revalidate: result.kind === "disabled" ? Math.min(revalidate, DISABLED_REVALIDATE) : revalidate });
23
23
  return result;
24
24
  }
25
25
  function cachedResolver(options) {
26
- tokens.set(keyOf(options.baseUrl, options.workspaceId), options.token);
26
+ credentials.set(keyOf(options.baseUrl, options.workspaceId), options.auth ? { auth: options.auth, workspaceId: options.workspaceId } : { token: options.token });
27
27
  const revalidate = options.revalidate ?? DEFAULT_REVALIDATE;
28
28
  return (path, locale, limit, cursor, nav) => resolveCached(options.baseUrl, options.workspaceId, path, locale ?? "", limit ?? 0, cursor ?? "", nav ?? "", revalidate);
29
29
  }
@@ -0,0 +1,50 @@
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/youtube-facade.tsx
22
+ var youtube_facade_exports = {};
23
+ __export(youtube_facade_exports, {
24
+ YouTubeFacade: () => YouTubeFacade
25
+ });
26
+ module.exports = __toCommonJS(youtube_facade_exports);
27
+ var import_react = require("react");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ function YouTubeFacade({ videoId, playLabel, frameTitle, children }) {
30
+ const [playing, setPlaying] = (0, import_react.useState)(false);
31
+ const id = encodeURIComponent(videoId);
32
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "hyle-youtube", "data-slot-component": "YouTube", children: [
33
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hyle-youtube-stage", children: playing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
34
+ "iframe",
35
+ {
36
+ ref: (frame) => frame?.focus(),
37
+ src: `https://www.youtube-nocookie.com/embed/${id}?autoplay=1`,
38
+ title: frameTitle,
39
+ sandbox: "allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox",
40
+ allow: "autoplay; encrypted-media; fullscreen; picture-in-picture",
41
+ referrerPolicy: "strict-origin-when-cross-origin"
42
+ }
43
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": playLabel, onClick: () => setPlaying(true), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: `https://i.ytimg.com/vi/${id}/hqdefault.jpg`, alt: "", loading: "lazy", decoding: "async", referrerPolicy: "no-referrer" }) }) }),
44
+ children
45
+ ] });
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ YouTubeFacade
50
+ });
@@ -0,0 +1,17 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+
3
+ interface YouTubeFacadeProps {
4
+ /** An 11 character video id the server already validated. */
5
+ videoId: string;
6
+ playLabel: string;
7
+ frameTitle: string;
8
+ /** The plain link to the video; it stays visible, with or without JavaScript. */
9
+ children?: ReactNode;
10
+ }
11
+ /**
12
+ * Click to load: until the click the only third-party request is the thumbnail from i.ytimg.com. The click swaps in a
13
+ * youtube-nocookie.com frame. `allow-same-origin` is safe here because the frame is another origin, never the host's.
14
+ */
15
+ declare function YouTubeFacade({ videoId, playLabel, frameTitle, children }: YouTubeFacadeProps): ReactElement;
16
+
17
+ export { YouTubeFacade, type YouTubeFacadeProps };
@@ -0,0 +1,17 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+
3
+ interface YouTubeFacadeProps {
4
+ /** An 11 character video id the server already validated. */
5
+ videoId: string;
6
+ playLabel: string;
7
+ frameTitle: string;
8
+ /** The plain link to the video; it stays visible, with or without JavaScript. */
9
+ children?: ReactNode;
10
+ }
11
+ /**
12
+ * Click to load: until the click the only third-party request is the thumbnail from i.ytimg.com. The click swaps in a
13
+ * youtube-nocookie.com frame. `allow-same-origin` is safe here because the frame is another origin, never the host's.
14
+ */
15
+ declare function YouTubeFacade({ videoId, playLabel, frameTitle, children }: YouTubeFacadeProps): ReactElement;
16
+
17
+ export { YouTubeFacade, type YouTubeFacadeProps };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+ // src/react/youtube-facade.tsx
4
+ import { useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ function YouTubeFacade({ videoId, playLabel, frameTitle, children }) {
7
+ const [playing, setPlaying] = useState(false);
8
+ const id = encodeURIComponent(videoId);
9
+ return /* @__PURE__ */ jsxs("div", { className: "hyle-youtube", "data-slot-component": "YouTube", children: [
10
+ /* @__PURE__ */ jsx("div", { className: "hyle-youtube-stage", children: playing ? /* @__PURE__ */ jsx(
11
+ "iframe",
12
+ {
13
+ ref: (frame) => frame?.focus(),
14
+ src: `https://www.youtube-nocookie.com/embed/${id}?autoplay=1`,
15
+ title: frameTitle,
16
+ sandbox: "allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox",
17
+ allow: "autoplay; encrypted-media; fullscreen; picture-in-picture",
18
+ referrerPolicy: "strict-origin-when-cross-origin"
19
+ }
20
+ ) : /* @__PURE__ */ jsx("button", { type: "button", "aria-label": playLabel, onClick: () => setPlaying(true), children: /* @__PURE__ */ jsx("img", { src: `https://i.ytimg.com/vi/${id}/hqdefault.jpg`, alt: "", loading: "lazy", decoding: "async", referrerPolicy: "no-referrer" }) }) }),
21
+ children
22
+ ] });
23
+ }
24
+ export {
25
+ YouTubeFacade
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdacorp/hyle-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.21.0",
4
4
  "description": "hyle SDK: a typed client for hyle's resolve endpoint, a hast renderer for React, and a Next.js catch-all page with tag-based revalidation.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,6 +40,16 @@
40
40
  "default": "./dist/react.cjs"
41
41
  }
42
42
  },
43
+ "./html": {
44
+ "import": {
45
+ "types": "./dist/html.d.ts",
46
+ "default": "./dist/html.js"
47
+ },
48
+ "require": {
49
+ "types": "./dist/html.d.cts",
50
+ "default": "./dist/html.cjs"
51
+ }
52
+ },
43
53
  "./next": {
44
54
  "import": {
45
55
  "types": "./dist/next.d.ts",
@@ -76,8 +86,9 @@
76
86
  "LICENSE"
77
87
  ],
78
88
  "dependencies": {
89
+ "hast-util-to-html": "^9.0.5",
79
90
  "hast-util-to-jsx-runtime": "^2.3.6",
80
- "mermaid": "~11.9.0"
91
+ "mermaid": "~11.16.0"
81
92
  },
82
93
  "peerDependencies": {
83
94
  "next": ">=16",
@@ -96,13 +107,15 @@
96
107
  "@types/node": "^24.10.2",
97
108
  "@types/react": "^19.2.18",
98
109
  "@types/react-dom": "^19.2.5",
110
+ "jsdom": "^26.1.0",
99
111
  "next": "^16.3.2",
100
112
  "react": "19.2.8",
101
113
  "react-dom": "19.2.8",
102
114
  "tsup": "^8.5.1",
103
115
  "typescript": "^5.9.3",
104
116
  "vitest": "^4.1.10",
105
- "@hyle/renderer": "0.3.0"
117
+ "@hyle/content": "0.6.1",
118
+ "@hyle/renderer": "0.5.0"
106
119
  },
107
120
  "keywords": [
108
121
  "hyle",