@tdacorp/hyle-sdk 0.3.0 → 0.5.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 (37) hide show
  1. package/README.md +92 -3
  2. package/bin/hyle-sdk-check-routes.mjs +3 -0
  3. package/dist/check-routes-bin.js +389 -0
  4. package/dist/chunk-4OB77ZOD.js +455 -0
  5. package/dist/chunk-BUJFMR3M.js +38 -0
  6. package/dist/{chunk-7VCMJUPC.js → chunk-OW6S7IZX.js} +1 -1
  7. package/dist/{chunk-EARQBSMF.js → chunk-SO6H2UGL.js} +102 -4
  8. package/dist/diagram-viewer-DYX6R63Y.js +1132 -0
  9. package/dist/index.cjs +191 -20
  10. package/dist/index.d.cts +95 -3
  11. package/dist/index.d.ts +95 -3
  12. package/dist/index.js +13 -1
  13. package/dist/mermaid-diagram.cjs +1267 -16
  14. package/dist/mermaid-diagram.d.cts +39 -1
  15. package/dist/mermaid-diagram.d.ts +39 -1
  16. package/dist/mermaid-diagram.js +35 -5
  17. package/dist/next.cjs +266 -26
  18. package/dist/next.d.cts +51 -5
  19. package/dist/next.d.ts +51 -5
  20. package/dist/next.js +131 -5
  21. package/dist/react.cjs +102 -4
  22. package/dist/react.d.cts +44 -4
  23. package/dist/react.d.ts +44 -4
  24. package/dist/react.js +1 -1
  25. package/dist/{resolve-fMx2W8RR.d.ts → resolve-1rQntRBh.d.ts} +1 -1
  26. package/dist/{resolve-B_p0p4Zn.d.cts → resolve-36-Ng1H0.d.cts} +1 -1
  27. package/dist/styles.css +76 -0
  28. package/dist/{types-CBvLhUPr.d.ts → types-BoyBWF2F.d.ts} +1 -1
  29. package/dist/{types-DjXf6iPo.d.cts → types-CwBCPh6K.d.cts} +20 -1
  30. package/dist/{types-DjXf6iPo.d.ts → types-CwBCPh6K.d.ts} +20 -1
  31. package/dist/{types-D0qoLh4E.d.cts → types-DnPzhrFx.d.cts} +1 -1
  32. package/dist/use-cache.cjs +34 -20
  33. package/dist/use-cache.d.cts +2 -2
  34. package/dist/use-cache.d.ts +2 -2
  35. package/dist/use-cache.js +2 -2
  36. package/package.json +5 -1
  37. package/dist/chunk-HFUJRNFP.js +0 -290
package/dist/next.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ReactElement } from 'react';
2
- import { H as HyleComponents, a as HyleSlots } from './types-CBvLhUPr.js';
3
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-fMx2W8RR.js';
4
- export { f as fetchResolver, w as workspaceTags } from './resolve-fMx2W8RR.js';
2
+ import { H as HyleComponents, a as HyleSlots } from './types-BoyBWF2F.js';
3
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-1rQntRBh.js';
4
+ export { f as fetchResolver, w as workspaceTags } from './resolve-1rQntRBh.js';
5
5
  import { MetadataRoute, Metadata } from 'next';
6
6
  import { a as RevalidationCallbackRoute } from './revalidation-callback-D7Ms_Puz.js';
7
- import './types-DjXf6iPo.js';
7
+ import './types-CwBCPh6K.js';
8
8
 
9
9
  type RouteParams = Record<string, string | string[] | undefined>;
10
10
  interface CommonOptions {
@@ -139,4 +139,50 @@ interface RevalidateRouteOptions {
139
139
  */
140
140
  declare function createRevalidateRoute(options: RevalidateRouteOptions): RevalidationCallbackRoute;
141
141
 
142
- export { FetchResolverOptions, type HyleNextOptions, HyleResolver, type HyleSitemapOptions, type PageProps, type RevalidateRouteOptions, type RouteParams, createRevalidateRoute, hyleMetadata, hylePage, hyleSitemap };
142
+ /**
143
+ * One workspace of a root catch-all: the options of `hylePage` without `basePath` (the mount prefix comes from hyle's mounts)
144
+ * and without `resolver` (the mounts are read through Next's fetch cache, so `baseUrl`, `token` and `workspaceId` are required).
145
+ * `revalidate` (default 300) also bounds the mounts fetch.
146
+ */
147
+ type HyleRootConfig = Omit<Extract<HyleNextOptions, {
148
+ resolver?: undefined;
149
+ }>, "basePath">;
150
+ type Configs = HyleRootConfig | readonly HyleRootConfig[];
151
+ /** How long a mounts copy that could not be refreshed may still be used. Past this a transient failure is rethrown. */
152
+ declare const MOUNTS_MAX_STALE_MS: number;
153
+ /**
154
+ * An async server component for the REQUIRED catch-all `app/.../[...hyle]/page.tsx`: `export default hyleRootPage({ ... })`,
155
+ * or an array of configs when one site serves several workspaces. It hands hyle every URL no other route of the host matched,
156
+ * but only the ones under a mount hyle reports (`GET /cp1/read/mounts`):
157
+ *
158
+ * - no mount matches (segment-boundary, case-sensitive, longest prefix wins) or the path is one of the workspace's `reserved`
159
+ * entries: `notFound()` with ZERO resolve calls, so junk URLs and bot probes never reach hyle;
160
+ * - otherwise the request is served by `hylePage` with `basePath` = the matched prefix (same locale, redirect and error rules).
161
+ *
162
+ * Failure of the mounts fetch: a 4xx or the kill switch means nothing is served (404). A transient failure (network, timeout,
163
+ * 5xx, 429, malformed body) uses the last mounts read successfully for up to 15 minutes, so a hyle outage keeps
164
+ * unmatched URLs a plain 404 and mounted pages on their last good render; with no such copy (a cold server) it is RETHROWN,
165
+ * because the URL might be a mounted page: Next keeps the last good ISR page, or a first render is an uncached 500. A host
166
+ * route never depends on this at all: Next matches it first. With a ROOT mount and no copy, every unmatched URL errors
167
+ * until hyle is back.
168
+ *
169
+ * The folder must be a required catch-all: an optional `[[...hyle]]` at the app root conflicts with a sibling `page.tsx` (the
170
+ * host's home page) at the same level.
171
+ */
172
+ declare function hyleRootPage(options: Configs): (props: PageProps) => Promise<ReactElement>;
173
+ /** `export const generateMetadata = hyleRootMetadata({ ... })` with the same options as `hyleRootPage`: no metadata for a path no mount serves. */
174
+ declare function hyleRootMetadata(options: Configs): (props: PageProps) => Promise<Metadata>;
175
+ interface HyleRootSitemapOptions {
176
+ /** The site's public origin, for example "https://tdacorp.in": https, no path, query or credentials. */
177
+ readonly origin: string;
178
+ /** See `hyleSitemap`. Applies to every mount. */
179
+ readonly onIncomplete?: "partial" | "throw";
180
+ }
181
+ /**
182
+ * Sitemap entries for every mount of every workspace, to spread into `app/sitemap.ts`: `[...hostEntries, ...(await hyleRootSitemap(configs, { origin }))]`.
183
+ * Each mount is listed with `hyleSitemap` (so `sections`, `locale`, `localePrefix` and `onIncomplete` behave as there). The mounts
184
+ * themselves must be readable: a failure with no last good copy throws, so a build never ships a sitemap without hyle's pages.
185
+ */
186
+ declare function hyleRootSitemap(options: Configs, sitemap: HyleRootSitemapOptions): Promise<MetadataRoute.Sitemap>;
187
+
188
+ export { FetchResolverOptions, type HyleNextOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, MOUNTS_MAX_STALE_MS, type PageProps, type RevalidateRouteOptions, type RouteParams, createRevalidateRoute, hyleMetadata, hylePage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap };
package/dist/next.js CHANGED
@@ -2,16 +2,18 @@ import {
2
2
  ArticlePage,
3
3
  DocsPage,
4
4
  ListPage
5
- } from "./chunk-EARQBSMF.js";
5
+ } from "./chunk-SO6H2UGL.js";
6
6
  import {
7
+ DEFAULT_REVALIDATE,
7
8
  fetchResolver,
8
9
  workspaceTags
9
- } from "./chunk-7VCMJUPC.js";
10
+ } from "./chunk-OW6S7IZX.js";
10
11
  import {
11
12
  Cp1ClientError,
13
+ createHyleClient,
12
14
  createRevalidationCallbackRoute,
13
15
  listPublicationPaths
14
- } from "./chunk-HFUJRNFP.js";
16
+ } from "./chunk-4OB77ZOD.js";
15
17
 
16
18
  // src/next/page.tsx
17
19
  import { notFound, permanentRedirect, redirect } from "next/navigation";
@@ -21,9 +23,10 @@ import { unstable_rethrow } from "next/navigation";
21
23
 
22
24
  // src/next/paths.ts
23
25
  function normalizeBasePath(basePath) {
24
- const value = (basePath ?? "").replace(/\/+$/, "");
26
+ const raw = basePath ?? "";
27
+ const value = raw === "/" ? "" : raw.replace(/\/$/, "");
25
28
  if (value === "") return "";
26
- if (!/^\/[^\s?#\\]+$/.test(value) || value.includes("//")) throw new TypeError(`basePath must look like "/learn", got "${basePath}"`);
29
+ if (!/^\/[^\s?#\\]+$/.test(value) || raw.includes("//")) throw new TypeError(`basePath must look like "/learn", got "${basePath}"`);
27
30
  return value;
28
31
  }
29
32
  var MAX_PATH_LENGTH = 1024;
@@ -204,11 +207,134 @@ function createRevalidateRoute(options) {
204
207
  }
205
208
  };
206
209
  }
210
+
211
+ // src/next/root.ts
212
+ import { notFound as notFound2 } from "next/navigation";
213
+
214
+ // src/next/mount-match.ts
215
+ function activeMounts(mounts) {
216
+ const out = [];
217
+ for (const { prefix, default_section } of mounts) {
218
+ try {
219
+ const normalized = normalizeBasePath(prefix);
220
+ out.push({ prefix: normalized, defaultSection: default_section, depth: normalized === "" ? 0 : normalized.split("/").length - 1 });
221
+ } catch (error) {
222
+ console.error(`hyle: ignoring a mount with an invalid prefix (${error instanceof Error ? error.name : "Error"})`);
223
+ }
224
+ }
225
+ return out;
226
+ }
227
+ var prefixMatches = (prefix, path) => prefix === "" || path === prefix || path.startsWith(`${prefix}/`);
228
+ function isReserved(path, reserved) {
229
+ return reserved.some((entry) => entry.endsWith("/*") ? prefixMatches(entry.slice(0, -2), path) : entry === path);
230
+ }
231
+
232
+ // src/next/root.ts
233
+ var MOUNTS_MAX_STALE_MS = 15 * 60 * 1e3;
234
+ var SECTION_SLUG = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
235
+ var NONE = { mounts: [], reserved: [] };
236
+ var lastKnownGood = /* @__PURE__ */ new Map();
237
+ function mountsLoader(config) {
238
+ if (!config.workspaceId) throw new TypeError("hyleRootPage: `workspaceId` is required for the fetch cache");
239
+ const client = createHyleClient({ baseUrl: config.baseUrl, token: config.token });
240
+ const init = { next: { revalidate: config.revalidate ?? DEFAULT_REVALIDATE, tags: workspaceTags(config.workspaceId).slice(0, 1) } };
241
+ const key = `${new URL(config.baseUrl).origin}|${config.workspaceId}`;
242
+ return async function load() {
243
+ try {
244
+ const result = await client.mounts({ init });
245
+ if (result.kind !== "mounts") {
246
+ lastKnownGood.delete(key);
247
+ return NONE;
248
+ }
249
+ const loaded = { mounts: activeMounts(result.mounts), reserved: result.reserved };
250
+ lastKnownGood.set(key, { loaded, at: Date.now() });
251
+ return loaded;
252
+ } catch (error) {
253
+ if (isRejectedRequest(error)) {
254
+ lastKnownGood.delete(key);
255
+ return NONE;
256
+ }
257
+ if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
258
+ lastKnownGood.delete(key);
259
+ throw error;
260
+ }
261
+ const kept = lastKnownGood.get(key);
262
+ if (kept && Date.now() - kept.at <= MOUNTS_MAX_STALE_MS) return kept.loaded;
263
+ throw error;
264
+ }
265
+ };
266
+ }
267
+ var asArray = (options) => Array.isArray(options) ? options : [options];
268
+ function setup(options) {
269
+ const configs = asArray(options);
270
+ if (configs.length === 0) throw new TypeError("hyleRootPage: pass at least one workspace config");
271
+ const param = configs[0].param ?? "hyle";
272
+ if (configs.some((c) => (c.param ?? "hyle") !== param)) throw new TypeError("hyleRootPage: every config must use the same `param`");
273
+ return { configs, param, loaders: configs.map(mountsLoader) };
274
+ }
275
+ function createRouter(options, make) {
276
+ const { configs, param, loaders } = setup(options);
277
+ const handlers = /* @__PURE__ */ new Map();
278
+ return async function route(params) {
279
+ const raw = params[param];
280
+ const segments = typeof raw === "string" ? [raw] : raw;
281
+ const path = sitePathFrom("", segments);
282
+ if (path === void 0 || path === "/" || !segments) return void 0;
283
+ const loaded = await Promise.all(loaders.map((load) => load()));
284
+ let best;
285
+ loaded.forEach(({ mounts, reserved }, index2) => {
286
+ if (isReserved(path, reserved)) return;
287
+ for (const mount2 of mounts) if (prefixMatches(mount2.prefix, path) && (!best || mount2.depth > best.mount.depth)) best = { index: index2, mount: mount2 };
288
+ });
289
+ if (!best) return void 0;
290
+ const { index, mount } = best;
291
+ const config = configs[index];
292
+ const id = `${index}|${mount.prefix}|${mount.defaultSection}`;
293
+ let handler = handlers.get(id);
294
+ if (!handler) {
295
+ const sections = [...config.sections ?? [], ...SECTION_SLUG.test(mount.defaultSection) ? [mount.defaultSection] : []];
296
+ handler = make({ ...config, basePath: mount.prefix, sections });
297
+ handlers.set(id, handler);
298
+ }
299
+ return { handler, params: { ...params, [param]: segments.slice(mount.depth) } };
300
+ };
301
+ }
302
+ function hyleRootPage(options) {
303
+ const route = createRouter(options, hylePage);
304
+ return async function HyleRootPage({ params, searchParams }) {
305
+ const hit = await route(await params ?? {});
306
+ if (!hit) notFound2();
307
+ return hit.handler({ params: Promise.resolve(hit.params), ...searchParams ? { searchParams } : {} });
308
+ };
309
+ }
310
+ function hyleRootMetadata(options) {
311
+ const route = createRouter(options, hyleMetadata);
312
+ return async function generateMetadata({ params }) {
313
+ const hit = await route(await params ?? {});
314
+ return hit ? hit.handler({ params: Promise.resolve(hit.params) }) : {};
315
+ };
316
+ }
317
+ async function hyleRootSitemap(options, sitemap) {
318
+ const { configs, loaders } = setup(options);
319
+ const entries = /* @__PURE__ */ new Map();
320
+ for (const [index, load] of loaders.entries()) {
321
+ const config = configs[index];
322
+ for (const mount of (await load()).mounts) {
323
+ const sections = [...config.sections ?? [], ...SECTION_SLUG.test(mount.defaultSection) ? [mount.defaultSection] : []];
324
+ for (const entry of await hyleSitemap({ ...config, basePath: mount.prefix, sections, ...sitemap })) entries.set(entry.url, entry);
325
+ }
326
+ }
327
+ return [...entries.values()];
328
+ }
207
329
  export {
330
+ MOUNTS_MAX_STALE_MS,
208
331
  createRevalidateRoute,
209
332
  fetchResolver,
210
333
  hyleMetadata,
211
334
  hylePage,
335
+ hyleRootMetadata,
336
+ hyleRootPage,
337
+ hyleRootSitemap,
212
338
  hyleSitemap,
213
339
  workspaceTags
214
340
  };
package/dist/react.cjs CHANGED
@@ -258,6 +258,101 @@ function sanitizeHast(tree, title) {
258
258
  return { type: "root", children: raw.filter((n) => n !== skip).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
259
259
  }
260
260
 
261
+ // src/react/viewer/labels.ts
262
+ var VIEWER_LABELS_EN = {
263
+ expand: "Expand diagram",
264
+ expandHint: "Expand",
265
+ viewer: "Diagram viewer",
266
+ close: "Close",
267
+ zoomIn: "Zoom in",
268
+ zoomOut: "Zoom out",
269
+ fit: "Fit to window",
270
+ actual: "Actual size",
271
+ search: "Find in diagram",
272
+ searchPlaceholder: "Find",
273
+ noMatch: "No match",
274
+ matchOf: "{n} of {total}",
275
+ copySource: "Copy diagram source",
276
+ downloadSvg: "Download SVG",
277
+ downloadPng: "Download PNG",
278
+ copyImage: "Copy as image",
279
+ pngScale: "PNG scale",
280
+ fullscreen: "Fullscreen",
281
+ exitFullscreen: "Exit fullscreen",
282
+ copied: "Copied",
283
+ saved: "Saved",
284
+ unavailable: "Not available here",
285
+ hint: "Scroll to zoom, drag to pan, click a node to trace its paths, press / to search",
286
+ legendSelected: "Selected",
287
+ legendUpstream: "Upstream",
288
+ legendDownstream: "Downstream",
289
+ outgoing: "outgoing",
290
+ tracing: "{label}: {up} upstream, {down} downstream",
291
+ map: "Overview map"
292
+ };
293
+ var VIEWER_LABELS_FR = {
294
+ expand: "Agrandir le sch\xE9ma",
295
+ expandHint: "Agrandir",
296
+ viewer: "Visionneuse de sch\xE9ma",
297
+ close: "Fermer",
298
+ zoomIn: "Zoom avant",
299
+ zoomOut: "Zoom arri\xE8re",
300
+ fit: "Ajuster \xE0 la fen\xEAtre",
301
+ actual: "Taille r\xE9elle",
302
+ search: "Rechercher dans le sch\xE9ma",
303
+ searchPlaceholder: "Rechercher",
304
+ noMatch: "Aucun r\xE9sultat",
305
+ matchOf: "{n} sur {total}",
306
+ copySource: "Copier la source du sch\xE9ma",
307
+ downloadSvg: "T\xE9l\xE9charger le SVG",
308
+ downloadPng: "T\xE9l\xE9charger le PNG",
309
+ copyImage: "Copier comme image",
310
+ pngScale: "\xC9chelle du PNG",
311
+ fullscreen: "Plein \xE9cran",
312
+ exitFullscreen: "Quitter le plein \xE9cran",
313
+ copied: "Copi\xE9",
314
+ saved: "Enregistr\xE9",
315
+ unavailable: "Indisponible ici",
316
+ hint: "Molette pour zoomer, glisser pour d\xE9placer, cliquer un n\u0153ud pour suivre ses chemins, / pour chercher",
317
+ legendSelected: "S\xE9lection",
318
+ legendUpstream: "En amont",
319
+ legendDownstream: "En aval",
320
+ outgoing: "sortants",
321
+ tracing: "{label} : {up} en amont, {down} en aval",
322
+ map: "Carte d'ensemble"
323
+ };
324
+ var VIEWER_LABELS_ES = {
325
+ expand: "Ampliar el diagrama",
326
+ expandHint: "Ampliar",
327
+ viewer: "Visor de diagramas",
328
+ close: "Cerrar",
329
+ zoomIn: "Acercar",
330
+ zoomOut: "Alejar",
331
+ fit: "Ajustar a la ventana",
332
+ actual: "Tama\xF1o real",
333
+ search: "Buscar en el diagrama",
334
+ searchPlaceholder: "Buscar",
335
+ noMatch: "Sin resultados",
336
+ matchOf: "{n} de {total}",
337
+ copySource: "Copiar el c\xF3digo del diagrama",
338
+ downloadSvg: "Descargar SVG",
339
+ downloadPng: "Descargar PNG",
340
+ copyImage: "Copiar como imagen",
341
+ pngScale: "Escala del PNG",
342
+ fullscreen: "Pantalla completa",
343
+ exitFullscreen: "Salir de pantalla completa",
344
+ copied: "Copiado",
345
+ saved: "Guardado",
346
+ unavailable: "No disponible aqu\xED",
347
+ hint: "Rueda para acercar, arrastra para mover, pulsa un nodo para seguir sus caminos, / para buscar",
348
+ legendSelected: "Seleccionado",
349
+ legendUpstream: "Aguas arriba",
350
+ legendDownstream: "Aguas abajo",
351
+ outgoing: "salientes",
352
+ tracing: "{label}: {up} aguas arriba, {down} aguas abajo",
353
+ map: "Mapa general"
354
+ };
355
+
261
356
  // src/react/strings.ts
262
357
  var en = {
263
358
  toc: "On this page",
@@ -297,7 +392,8 @@ var en = {
297
392
  rdFallback: "If nothing happens, go to the new address.",
298
393
  unKind: "Unavailable",
299
394
  unTitle: "This page is temporarily unavailable",
300
- unBody: "The content could not be loaded. Please try again in a moment."
395
+ unBody: "The content could not be loaded. Please try again in a moment.",
396
+ viewer: VIEWER_LABELS_EN
301
397
  };
302
398
  var fr = {
303
399
  toc: "Sur cette page",
@@ -337,7 +433,8 @@ var fr = {
337
433
  rdFallback: "Si rien ne se passe, allez \xE0 la nouvelle adresse.",
338
434
  unKind: "Indisponible",
339
435
  unTitle: "Cette page est momentan\xE9ment indisponible",
340
- unBody: "Le contenu n'a pas pu \xEAtre charg\xE9. R\xE9essayez dans un instant."
436
+ unBody: "Le contenu n'a pas pu \xEAtre charg\xE9. R\xE9essayez dans un instant.",
437
+ viewer: VIEWER_LABELS_FR
341
438
  };
342
439
  var es = {
343
440
  toc: "En esta p\xE1gina",
@@ -377,7 +474,8 @@ var es = {
377
474
  rdFallback: "Si no pasa nada, ve a la nueva direcci\xF3n.",
378
475
  unKind: "No disponible",
379
476
  unTitle: "Esta p\xE1gina no est\xE1 disponible por el momento",
380
- unBody: "No se pudo cargar el contenido. Int\xE9ntalo de nuevo en un momento."
477
+ unBody: "No se pudo cargar el contenido. Int\xE9ntalo de nuevo en un momento.",
478
+ viewer: VIEWER_LABELS_ES
381
479
  };
382
480
  var TABLE = { en, fr, es };
383
481
  function stringsFor(locale) {
@@ -445,7 +543,7 @@ function buildComponents(c, s) {
445
543
  if (typeof srcDoc !== "string") return null;
446
544
  const source = mermaidSource(srcDoc);
447
545
  if (c.Mermaid) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.Mermaid, { srcDoc, source, title: s.diagram });
448
- if (source !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mermaid_diagram.MermaidDiagram, { source, title: s.diagram, errorText: s.diagramError });
546
+ if (source !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mermaid_diagram.MermaidDiagram, { source, title: s.diagram, errorText: s.diagramError, labels: s.viewer });
449
547
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("figure", { className: "hyle-mermaid", "data-slot-component": "Mermaid", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("iframe", { srcDoc, sandbox: String(sandbox), title: s.diagram, loading: "lazy", referrerPolicy: "no-referrer", ...{ csp: MERMAID_FRAME_CSP } }) });
450
548
  };
451
549
  const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
package/dist/react.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps } from './types-D0qoLh4E.cjs';
4
- export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-D0qoLh4E.cjs';
3
+ import { H as HyleComponents, P as PageBaseProps } from './types-DnPzhrFx.cjs';
4
+ export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-DnPzhrFx.cjs';
5
5
  import { Root } from 'hast';
6
- import { b as ResolvedArticle, d as ResolvedList } from './types-DjXf6iPo.cjs';
6
+ import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.cjs';
7
7
 
8
8
  interface HastContentProps {
9
9
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -24,6 +24,42 @@ declare function TrustedServerHtml({ html }: {
24
24
  html: string;
25
25
  }): ReactElement;
26
26
 
27
+ /**
28
+ * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
29
+ * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
30
+ */
31
+ interface ViewerLabels {
32
+ expand: string;
33
+ expandHint: string;
34
+ viewer: string;
35
+ close: string;
36
+ zoomIn: string;
37
+ zoomOut: string;
38
+ fit: string;
39
+ actual: string;
40
+ search: string;
41
+ searchPlaceholder: string;
42
+ noMatch: string;
43
+ matchOf: string;
44
+ copySource: string;
45
+ downloadSvg: string;
46
+ downloadPng: string;
47
+ copyImage: string;
48
+ pngScale: string;
49
+ fullscreen: string;
50
+ exitFullscreen: string;
51
+ copied: string;
52
+ saved: string;
53
+ unavailable: string;
54
+ hint: string;
55
+ legendSelected: string;
56
+ legendUpstream: string;
57
+ legendDownstream: string;
58
+ outgoing: string;
59
+ tracing: string;
60
+ map: string;
61
+ }
62
+
27
63
  /**
28
64
  * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
29
65
  * base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that have a diagram,
@@ -35,8 +71,10 @@ interface MermaidDiagramProps {
35
71
  title: string;
36
72
  /** Shown when Mermaid cannot render the source. */
37
73
  errorText: string;
74
+ /** Strings of the diagram viewer (English when omitted). */
75
+ labels?: ViewerLabels;
38
76
  }
39
- declare function MermaidDiagram({ source, title, errorText }: MermaidDiagramProps): react.JSX.Element;
77
+ declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
40
78
 
41
79
  /**
42
80
  * Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
@@ -90,6 +128,7 @@ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElem
90
128
  * Chrome strings for en, fr and es. The fr and es copy is a draft carried over from the design kit and has not been
91
129
  * reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
92
130
  */
131
+
93
132
  declare const en: {
94
133
  toc: string;
95
134
  prev: string;
@@ -129,6 +168,7 @@ declare const en: {
129
168
  unKind: string;
130
169
  unTitle: string;
131
170
  unBody: string;
171
+ viewer: ViewerLabels;
132
172
  };
133
173
  type Strings = typeof en;
134
174
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
package/dist/react.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import { H as HyleComponents, P as PageBaseProps } from './types-CBvLhUPr.js';
4
- export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-CBvLhUPr.js';
3
+ import { H as HyleComponents, P as PageBaseProps } from './types-BoyBWF2F.js';
4
+ export { C as CalloutKind, b as CalloutProps, c as CodeBlockProps, a as HyleSlots, I as ImageProps, L as LinkProps, d as ListItemProps, M as MermaidProps } from './types-BoyBWF2F.js';
5
5
  import { Root } from 'hast';
6
- import { b as ResolvedArticle, d as ResolvedList } from './types-DjXf6iPo.js';
6
+ import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.js';
7
7
 
8
8
  interface HastContentProps {
9
9
  /** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
@@ -24,6 +24,42 @@ declare function TrustedServerHtml({ html }: {
24
24
  html: string;
25
25
  }): ReactElement;
26
26
 
27
+ /**
28
+ * Every string the diagram viewer shows. Pure data, so the client component can carry the English defaults without importing
29
+ * the viewer chunk, and the server passes the host's locale in (strings.ts holds fr and es, unreviewed drafts like the rest).
30
+ */
31
+ interface ViewerLabels {
32
+ expand: string;
33
+ expandHint: string;
34
+ viewer: string;
35
+ close: string;
36
+ zoomIn: string;
37
+ zoomOut: string;
38
+ fit: string;
39
+ actual: string;
40
+ search: string;
41
+ searchPlaceholder: string;
42
+ noMatch: string;
43
+ matchOf: string;
44
+ copySource: string;
45
+ downloadSvg: string;
46
+ downloadPng: string;
47
+ copyImage: string;
48
+ pngScale: string;
49
+ fullscreen: string;
50
+ exitFullscreen: string;
51
+ copied: string;
52
+ saved: string;
53
+ unavailable: string;
54
+ hint: string;
55
+ legendSelected: string;
56
+ legendUpstream: string;
57
+ legendDownstream: string;
58
+ outgoing: string;
59
+ tracing: string;
60
+ map: string;
61
+ }
62
+
27
63
  /**
28
64
  * The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
29
65
  * base URL or client (a test pins this). Mermaid is a dynamic import, so the chunk loads only on pages that have a diagram,
@@ -35,8 +71,10 @@ interface MermaidDiagramProps {
35
71
  title: string;
36
72
  /** Shown when Mermaid cannot render the source. */
37
73
  errorText: string;
74
+ /** Strings of the diagram viewer (English when omitted). */
75
+ labels?: ViewerLabels;
38
76
  }
39
- declare function MermaidDiagram({ source, title, errorText }: MermaidDiagramProps): react.JSX.Element;
77
+ declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
40
78
 
41
79
  /**
42
80
  * Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
@@ -90,6 +128,7 @@ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElem
90
128
  * Chrome strings for en, fr and es. The fr and es copy is a draft carried over from the design kit and has not been
91
129
  * reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
92
130
  */
131
+
93
132
  declare const en: {
94
133
  toc: string;
95
134
  prev: string;
@@ -129,6 +168,7 @@ declare const en: {
129
168
  unKind: string;
130
169
  unTitle: string;
131
170
  unBody: string;
171
+ viewer: ViewerLabels;
132
172
  };
133
173
  type Strings = typeof en;
134
174
  /** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
package/dist/react.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  sanitizeHast,
14
14
  scopeId,
15
15
  stringsFor
16
- } from "./chunk-EARQBSMF.js";
16
+ } from "./chunk-SO6H2UGL.js";
17
17
  export {
18
18
  ArticlePage,
19
19
  DocsPage,
@@ -1,4 +1,4 @@
1
- import { R as Resolved } from './types-DjXf6iPo.js';
1
+ import { R as Resolved } from './types-CwBCPh6K.js';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
4
  type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
@@ -1,4 +1,4 @@
1
- import { R as Resolved } from './types-DjXf6iPo.cjs';
1
+ import { R as Resolved } from './types-CwBCPh6K.cjs';
2
2
 
3
3
  /** Resolves a site path to a result. The two built-in strategies are `fetchResolver` (default) and `cachedResolver` (`@tdacorp/hyle-sdk/next/use-cache`). */
4
4
  type HyleResolver = (path: string, locale: string | undefined, limit?: number, cursor?: string) => Promise<Resolved>;
package/dist/styles.css CHANGED
@@ -406,3 +406,79 @@
406
406
  .hyle-mermaid-svg{display:flex;justify-content:center;padding:16px;contain:paint}
407
407
  .hyle-mermaid-svg svg{position:static!important;max-width:100%;height:auto}
408
408
  .hyle-mermaid-note{margin:0;padding:8px 16px;border-top:1px dashed var(--h-border);font-size:13px;color:var(--h-warn)}
409
+
410
+ /* ---- diagram viewer (the click-to-expand trigger and its dialog, loaded on first click) ----
411
+ Public variables: --hyle-viewer-bg, --hyle-viewer-accent, --hyle-viewer-up, --hyle-viewer-down, --hyle-viewer-dim (opacity of dimmed
412
+ parts), --hyle-viewer-backdrop. All fall back to the --hyle-* surface, accent, warn and ok tokens above. */
413
+ .hyle-mermaid-open{position:relative;display:block;width:100%;margin:0;padding:0;border:0;border-radius:inherit;background:none;color:inherit;font:inherit;text-align:inherit;cursor:zoom-in}
414
+ .hyle-mermaid-open:focus-visible{outline-offset:-2px}
415
+ .hyle-mermaid-hint{position:absolute;top:8px;right:8px;padding:2px 10px;border:var(--h-border-width,1px) solid var(--h-border,GrayText);border-radius:var(--h-radius,6px);background:var(--h-surface-2,Canvas);font:500 12px/1.6 var(--h-font-sans,system-ui,sans-serif);color:var(--h-text-muted,CanvasText);opacity:0;transition:opacity .15s;pointer-events:none}
416
+ .hyle-mermaid-open:hover .hyle-mermaid-hint,.hyle-mermaid-open:focus-visible .hyle-mermaid-hint{opacity:1}
417
+ @media (hover:none){.hyle-mermaid-hint{opacity:1}}
418
+ @media (prefers-reduced-motion:reduce){.hyle-mermaid-hint{transition:none}}
419
+ html.hyle-viewer-lock{overflow:hidden;scrollbar-gutter:stable}
420
+ html.hyle-viewer-lock:has(.hv-shell:fullscreen){scrollbar-gutter:auto}
421
+
422
+ .hyle-viewer{--hv-bg:var(--hyle-viewer-bg,var(--h-surface,Canvas));--hv-accent:var(--hyle-viewer-accent,var(--h-accent,#6f9bff));--hv-up:var(--hyle-viewer-up,var(--h-warn,#e0a030));--hv-down:var(--hyle-viewer-down,var(--h-ok,#3fb27f));--hv-dim:var(--hyle-viewer-dim,.16);
423
+ --hv-text:var(--h-text,CanvasText);--hv-muted:var(--h-text-muted,color-mix(in srgb,var(--hv-text) 65%,transparent));--hv-border:var(--h-border,color-mix(in srgb,var(--hv-text) 28%,transparent));--hv-raise:var(--h-surface-2,color-mix(in srgb,var(--hv-text) 8%,var(--hv-bg)));--hv-hairline:var(--h-hairline,color-mix(in srgb,var(--hv-text) 14%,transparent));--hv-focus:var(--h-focus,var(--hv-accent));
424
+
425
+ width:min(96vw,1680px);height:min(92vh,1100px);height:min(92dvh,1100px);max-width:none;max-height:none;margin:auto;padding:0;overflow:hidden;overscroll-behavior:contain;border:var(--h-border-width,1px) solid var(--hv-border);border-radius:var(--h-radius-lg,8px);background:var(--hv-bg);color:var(--hv-text);box-shadow:var(--h-shadow,0 12px 48px rgb(0 0 0/.4));font:400 14px/1.4 var(--h-font-sans,system-ui,sans-serif)}
426
+ .hv-shell{display:flex;flex-direction:column;width:100%;height:100%;background:var(--hv-bg);color:var(--hv-text)}
427
+ .hyle-viewer::backdrop{background:var(--hyle-viewer-backdrop,rgb(0 0 0/.6))}
428
+ @media (prefers-reduced-motion:no-preference){.hyle-viewer[open]{animation:hv-in .18s ease-out}@keyframes hv-in{from{opacity:0;transform:scale(.98)}}}
429
+ @media (max-width:640px){.hyle-viewer{width:100vw;width:100dvw;height:100vh;height:100dvh;border:0;border-radius:0}}
430
+ .hyle-viewer *{box-sizing:border-box}
431
+ .hv-bar{display:flex;flex:none;flex-wrap:wrap;align-items:center;gap:6px 12px;padding:8px 12px;border-bottom:1px solid var(--hv-border);font-weight:500;font-size:13px}
432
+ .hv-title{max-width:22ch;overflow:hidden;font-weight:600;text-overflow:ellipsis;white-space:nowrap}
433
+ .hv-zoom{min-width:5ch;font:400 13px/1 var(--h-font-mono,ui-monospace,monospace);font-variant-numeric:tabular-nums;color:var(--hv-muted)}
434
+ .hv-group{display:inline-flex;align-items:center;gap:4px}
435
+ .hv-end{margin-inline-start:auto}
436
+ .hv-btn,.hv-select,.hv-input{min-width:32px;min-height:32px;padding:0 8px;border:1px solid var(--hv-border);border-radius:var(--h-radius,6px);background:var(--hv-raise);color:var(--hv-text);font:inherit;line-height:1}
437
+ .hv-btn{display:inline-grid;place-items:center;cursor:pointer}
438
+ .hv-btn:hover,.hv-select:hover{border-color:var(--hv-accent)}
439
+ .hv-btn[aria-pressed=true]{border-color:var(--hv-accent);color:var(--hv-accent)}
440
+ .hv-txt{font:500 12px/1 var(--h-font-mono,ui-monospace,monospace)}
441
+ .hv-ic{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
442
+ .hv-input{width:14ch;cursor:text}
443
+ .hv-count{min-width:6ch;color:var(--hv-muted);font-size:12px}
444
+ @media (pointer:coarse){.hv-btn,.hv-select,.hv-input{min-width:44px;min-height:44px}}
445
+
446
+ .hv-view{position:relative;flex:1;min-height:0;overflow:hidden;contain:paint;touch-action:none;cursor:grab;outline:none;user-select:none;-webkit-user-select:none;background-image:radial-gradient(circle,var(--hv-hairline) 1px,transparent 1.5px);background-size:24px 24px}
447
+ .hv-view.hv-grabbing{cursor:grabbing}
448
+ /* --hv-k is the current zoom, written by the viewer while something is highlighted: strokes of highlights are divided by it so they keep their on-screen width. */
449
+ .hv-stage{--hv-k:1;position:absolute;top:0;left:0;transform-origin:0 0}
450
+ .hv-stage svg{display:block;position:static!important;width:100%;height:100%;max-width:none!important}
451
+ .hv-stage .hv-n{cursor:pointer;outline:none}
452
+ .hv-stage .hv-n,.hv-stage .hv-e{transition:opacity .15s}
453
+ @media (prefers-reduced-motion:reduce){.hv-stage .hv-n,.hv-stage .hv-e{transition:none}}
454
+ .hv-stage.hv-plain .hv-n,.hv-stage.hv-plain .hv-e{transition:none}
455
+ .hv-stage.hv-active .hv-n:not(.hv-on),.hv-stage.hv-active .hv-e:not(.hv-on){opacity:var(--hv-dim)}
456
+ .hv-stage .hv-n:focus-visible :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-focus)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
457
+ .hv-stage .hv-n.hv-nb :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(2px / var(--hv-k,1))!important}
458
+ .hv-stage .hv-n.hv-up :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-up)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
459
+ .hv-stage .hv-n.hv-down :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-down)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
460
+ .hv-stage .hv-n.hv-sel :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(3.5px / var(--hv-k,1))!important}
461
+ .hv-stage .hv-n.hv-hit :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
462
+ .hv-stage .hv-n.hv-cur :is(rect,polygon,circle,ellipse,path){stroke-width:calc(5px / var(--hv-k,1))!important}
463
+ .hv-stage text.hv-hit,.hv-stage text.hv-hit tspan{fill:var(--hv-accent)!important;font-weight:700}
464
+ .hv-stage text.hv-cur{text-decoration:underline}
465
+ .hv-stage path.hv-nb{stroke:var(--hv-accent)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
466
+ .hv-stage path.hv-up{stroke:var(--hv-up)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
467
+ .hv-stage path.hv-down{stroke:var(--hv-down)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
468
+ .hv-stage path.hv-flow{stroke-dasharray:calc(7px / var(--hv-k,1)) calc(6px / var(--hv-k,1))!important;animation:hv-dash .9s linear infinite}
469
+ @keyframes hv-dash{to{stroke-dashoffset:calc(-26px / var(--hv-k,1))}}
470
+ @media (prefers-reduced-motion:reduce){.hv-stage path.hv-flow{animation:none}}
471
+
472
+ .hv-mini{position:absolute;right:12px;bottom:44px;width:176px;height:120px;border:1px solid var(--hv-border);border-radius:var(--h-radius,6px);background:color-mix(in srgb,var(--hv-bg) 88%,transparent);color:var(--hv-muted);accent-color:var(--hv-accent);cursor:crosshair;touch-action:none}
473
+ @media (max-width:640px){.hv-mini{width:120px;height:82px}}
474
+ .hv-foot{display:flex;flex:none;flex-wrap:wrap;align-items:center;gap:4px 16px;min-height:32px;padding:6px 12px;border-top:1px solid var(--hv-border);font-size:12px;color:var(--hv-muted)}
475
+ .hv-hint{margin:0;flex:1 1 auto}
476
+ @media (max-width:640px){.hv-hint{display:none}}
477
+ .hv-toast{margin-inline-start:auto;color:var(--hv-text)}
478
+ .hv-toast:empty{display:none}
479
+ .hv-legend{display:flex;gap:14px;margin:0;padding:0;list-style:none}
480
+ .hv-legend li{display:inline-flex;align-items:center;gap:6px}
481
+ .hv-legend li::before{content:"";width:10px;height:10px;border-radius:2px;background:currentColor}
482
+ .hv-legend .hv-sel{color:var(--hv-accent)}
483
+ .hv-legend .hv-up{color:var(--hv-up)}
484
+ .hv-legend .hv-down{color:var(--hv-down)}
@@ -1,5 +1,5 @@
1
1
  import { ElementType, ReactNode, ComponentType } from 'react';
2
- import { L as ListItem } from './types-DjXf6iPo.js';
2
+ import { L as ListItem } from './types-CwBCPh6K.js';
3
3
 
4
4
  type CalloutKind = "note" | "tip" | "warning" | "caution";
5
5
  interface LinkProps {