@tdacorp/hyle-sdk 0.2.1 → 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.
- package/README.md +105 -4
- package/bin/hyle-sdk-check-routes.mjs +3 -0
- package/dist/check-routes-bin.js +389 -0
- package/dist/chunk-4OB77ZOD.js +455 -0
- package/dist/chunk-BUJFMR3M.js +38 -0
- package/dist/{chunk-7VCMJUPC.js → chunk-OW6S7IZX.js} +1 -1
- package/dist/{chunk-MHVWHSKC.js → chunk-SO6H2UGL.js} +124 -6
- package/dist/diagram-viewer-DYX6R63Y.js +1132 -0
- package/dist/index.cjs +191 -20
- package/dist/index.d.cts +95 -3
- package/dist/index.d.ts +95 -3
- package/dist/index.js +13 -1
- package/dist/mermaid-diagram.cjs +1395 -0
- package/dist/mermaid-diagram.d.cts +55 -0
- package/dist/mermaid-diagram.d.ts +55 -0
- package/dist/mermaid-diagram.js +140 -0
- package/dist/next.cjs +286 -27
- package/dist/next.d.cts +51 -5
- package/dist/next.d.ts +51 -5
- package/dist/next.js +131 -5
- package/dist/react.cjs +124 -5
- package/dist/react.d.cts +60 -4
- package/dist/react.d.ts +60 -4
- package/dist/react.js +3 -1
- package/dist/{resolve-fMx2W8RR.d.ts → resolve-1rQntRBh.d.ts} +1 -1
- package/dist/{resolve-B_p0p4Zn.d.cts → resolve-36-Ng1H0.d.cts} +1 -1
- package/dist/styles.css +82 -1
- package/dist/{types-BNaGecO7.d.ts → types-BoyBWF2F.d.ts} +3 -1
- package/dist/{types-DjXf6iPo.d.cts → types-CwBCPh6K.d.cts} +20 -1
- package/dist/{types-DjXf6iPo.d.ts → types-CwBCPh6K.d.ts} +20 -1
- package/dist/{types-DLWvqanV.d.cts → types-DnPzhrFx.d.cts} +3 -1
- package/dist/use-cache.cjs +34 -20
- package/dist/use-cache.d.cts +2 -2
- package/dist/use-cache.d.ts +2 -2
- package/dist/use-cache.js +2 -2
- package/package.json +8 -3
- package/dist/chunk-HFUJRNFP.js +0 -290
package/dist/next.js
CHANGED
|
@@ -2,16 +2,18 @@ import {
|
|
|
2
2
|
ArticlePage,
|
|
3
3
|
DocsPage,
|
|
4
4
|
ListPage
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SO6H2UGL.js";
|
|
6
6
|
import {
|
|
7
|
+
DEFAULT_REVALIDATE,
|
|
7
8
|
fetchResolver,
|
|
8
9
|
workspaceTags
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OW6S7IZX.js";
|
|
10
11
|
import {
|
|
11
12
|
Cp1ClientError,
|
|
13
|
+
createHyleClient,
|
|
12
14
|
createRevalidationCallbackRoute,
|
|
13
15
|
listPublicationPaths
|
|
14
|
-
} from "./chunk-
|
|
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
|
|
26
|
+
const raw = basePath ?? "";
|
|
27
|
+
const value = raw === "/" ? "" : raw.replace(/\/$/, "");
|
|
25
28
|
if (value === "") return "";
|
|
26
|
-
if (!/^\/[^\s?#\\]+$/.test(value) ||
|
|
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
|
@@ -25,6 +25,7 @@ __export(react_exports, {
|
|
|
25
25
|
HastContent: () => HastContent,
|
|
26
26
|
HastLimitError: () => HastLimitError,
|
|
27
27
|
ListPage: () => ListPage,
|
|
28
|
+
MermaidDiagram: () => import_mermaid_diagram2.MermaidDiagram,
|
|
28
29
|
NotFound: () => NotFound,
|
|
29
30
|
Redirecting: () => Redirecting,
|
|
30
31
|
TrustedServerHtml: () => TrustedServerHtml,
|
|
@@ -77,6 +78,12 @@ function Icon({ name, className }) {
|
|
|
77
78
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
// src/react/content.tsx
|
|
82
|
+
var import_mermaid_diagram = require("./mermaid-diagram.cjs");
|
|
83
|
+
|
|
84
|
+
// src/react/mermaid-config.ts
|
|
85
|
+
var MAX_MERMAID_SOURCE = 2e4;
|
|
86
|
+
|
|
80
87
|
// src/react/sanitize.ts
|
|
81
88
|
var HastLimitError = class extends Error {
|
|
82
89
|
constructor(message) {
|
|
@@ -135,9 +142,14 @@ var isHref = (v) => isSafeUrl(v, "href") && (typeof v !== "string" || !v.trim().
|
|
|
135
142
|
var isSrc = (v) => isSafeUrl(v, "src");
|
|
136
143
|
var MERMAID_SCRIPT_URL = "https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.9.0/mermaid.min.js";
|
|
137
144
|
var MERMAID_SRCDOC = new RegExp(
|
|
138
|
-
`^<!doctype html><html><head><meta charset="utf-8"></head><body><div class="mermaid">[^<]
|
|
145
|
+
`^<!doctype html><html><head><meta charset="utf-8"></head><body><div class="mermaid">([^<]*)</div><script src="${MERMAID_SCRIPT_URL.replace(/[.]/g, "\\.")}"></script><script>mermaid\\.initialize\\(\\{ startOnLoad: true, securityLevel: "strict" \\}\\);</script></body></html>$`
|
|
139
146
|
);
|
|
140
147
|
var isMermaidSrcdoc = (v) => typeof v === "string" && v.length <= MAX_SRCDOC && MERMAID_SRCDOC.test(v);
|
|
148
|
+
var ENTITIES = { "<": "<", "&": "&", "<": "<", ">": ">", "&": "&", """: '"', "'": "'" };
|
|
149
|
+
function mermaidSource(srcDoc) {
|
|
150
|
+
const text = MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
|
|
151
|
+
return text === void 0 || text.length > MAX_MERMAID_SOURCE ? void 0 : text;
|
|
152
|
+
}
|
|
141
153
|
var MERMAID_FRAME_CSP = `default-src 'none'; script-src ${MERMAID_SCRIPT_URL} 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:`;
|
|
142
154
|
var heading = { id: isIdValue, className: isClass };
|
|
143
155
|
var ATTRS = new Map(
|
|
@@ -246,6 +258,101 @@ function sanitizeHast(tree, title) {
|
|
|
246
258
|
return { type: "root", children: raw.filter((n) => n !== skip).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
|
|
247
259
|
}
|
|
248
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
|
+
|
|
249
356
|
// src/react/strings.ts
|
|
250
357
|
var en = {
|
|
251
358
|
toc: "On this page",
|
|
@@ -263,6 +370,7 @@ var en = {
|
|
|
263
370
|
tip: "Tip",
|
|
264
371
|
caution: "Caution",
|
|
265
372
|
diagram: "Diagram",
|
|
373
|
+
diagramError: "This diagram could not be rendered.",
|
|
266
374
|
contentError: "This content cannot be displayed.",
|
|
267
375
|
fallbackTitle: "Not translated into {language} yet.",
|
|
268
376
|
fallbackBody: "You are reading the original.",
|
|
@@ -284,7 +392,8 @@ var en = {
|
|
|
284
392
|
rdFallback: "If nothing happens, go to the new address.",
|
|
285
393
|
unKind: "Unavailable",
|
|
286
394
|
unTitle: "This page is temporarily unavailable",
|
|
287
|
-
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
|
|
288
397
|
};
|
|
289
398
|
var fr = {
|
|
290
399
|
toc: "Sur cette page",
|
|
@@ -302,6 +411,7 @@ var fr = {
|
|
|
302
411
|
tip: "Astuce",
|
|
303
412
|
caution: "Danger",
|
|
304
413
|
diagram: "Sch\xE9ma",
|
|
414
|
+
diagramError: "Ce sch\xE9ma n'a pas pu \xEAtre affich\xE9.",
|
|
305
415
|
contentError: "Ce contenu ne peut pas \xEAtre affich\xE9.",
|
|
306
416
|
fallbackTitle: "Pas encore traduit en {language}.",
|
|
307
417
|
fallbackBody: "Vous lisez l'original.",
|
|
@@ -323,7 +433,8 @@ var fr = {
|
|
|
323
433
|
rdFallback: "Si rien ne se passe, allez \xE0 la nouvelle adresse.",
|
|
324
434
|
unKind: "Indisponible",
|
|
325
435
|
unTitle: "Cette page est momentan\xE9ment indisponible",
|
|
326
|
-
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
|
|
327
438
|
};
|
|
328
439
|
var es = {
|
|
329
440
|
toc: "En esta p\xE1gina",
|
|
@@ -341,6 +452,7 @@ var es = {
|
|
|
341
452
|
tip: "Consejo",
|
|
342
453
|
caution: "Peligro",
|
|
343
454
|
diagram: "Diagrama",
|
|
455
|
+
diagramError: "No se pudo mostrar este diagrama.",
|
|
344
456
|
contentError: "No se puede mostrar este contenido.",
|
|
345
457
|
fallbackTitle: "A\xFAn no est\xE1 traducida al {language}.",
|
|
346
458
|
fallbackBody: "Est\xE1s leyendo el original.",
|
|
@@ -362,7 +474,8 @@ var es = {
|
|
|
362
474
|
rdFallback: "Si no pasa nada, ve a la nueva direcci\xF3n.",
|
|
363
475
|
unKind: "No disponible",
|
|
364
476
|
unTitle: "Esta p\xE1gina no est\xE1 disponible por el momento",
|
|
365
|
-
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
|
|
366
479
|
};
|
|
367
480
|
var TABLE = { en, fr, es };
|
|
368
481
|
function stringsFor(locale) {
|
|
@@ -428,7 +541,9 @@ function buildComponents(c, s) {
|
|
|
428
541
|
};
|
|
429
542
|
const Frame = ({ srcDoc, sandbox }) => {
|
|
430
543
|
if (typeof srcDoc !== "string") return null;
|
|
431
|
-
|
|
544
|
+
const source = mermaidSource(srcDoc);
|
|
545
|
+
if (c.Mermaid) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.Mermaid, { srcDoc, source, title: s.diagram });
|
|
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 });
|
|
432
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 } }) });
|
|
433
548
|
};
|
|
434
549
|
const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
|
|
@@ -468,6 +583,9 @@ function TrustedServerHtml({ html }) {
|
|
|
468
583
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { dangerouslySetInnerHTML: { __html: html } });
|
|
469
584
|
}
|
|
470
585
|
|
|
586
|
+
// src/react/index.ts
|
|
587
|
+
var import_mermaid_diagram2 = require("./mermaid-diagram.cjs");
|
|
588
|
+
|
|
471
589
|
// src/react/pages.tsx
|
|
472
590
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
473
591
|
function Slot({ name, slots, tag: Tag = "div", className }) {
|
|
@@ -763,6 +881,7 @@ function Redirecting({ from, to, ...base }) {
|
|
|
763
881
|
HastContent,
|
|
764
882
|
HastLimitError,
|
|
765
883
|
ListPage,
|
|
884
|
+
MermaidDiagram,
|
|
766
885
|
NotFound,
|
|
767
886
|
Redirecting,
|
|
768
887
|
TrustedServerHtml,
|
package/dist/react.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
1
2
|
import { ReactElement } from 'react';
|
|
2
|
-
import { H as HyleComponents, P as PageBaseProps } from './types-
|
|
3
|
-
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-
|
|
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';
|
|
4
5
|
import { Root } from 'hast';
|
|
5
|
-
import {
|
|
6
|
+
import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.cjs';
|
|
6
7
|
|
|
7
8
|
interface HastContentProps {
|
|
8
9
|
/** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
|
|
@@ -23,6 +24,58 @@ declare function TrustedServerHtml({ html }: {
|
|
|
23
24
|
html: string;
|
|
24
25
|
}): ReactElement;
|
|
25
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
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
|
|
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,
|
|
66
|
+
* from the host's own origin.
|
|
67
|
+
*/
|
|
68
|
+
interface MermaidDiagramProps {
|
|
69
|
+
source: string;
|
|
70
|
+
/** Accessible name of the diagram. */
|
|
71
|
+
title: string;
|
|
72
|
+
/** Shown when Mermaid cannot render the source. */
|
|
73
|
+
errorText: string;
|
|
74
|
+
/** Strings of the diagram viewer (English when omitted). */
|
|
75
|
+
labels?: ViewerLabels;
|
|
76
|
+
}
|
|
77
|
+
declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
|
|
78
|
+
|
|
26
79
|
/**
|
|
27
80
|
* Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
|
|
28
81
|
* so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
|
|
@@ -75,6 +128,7 @@ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElem
|
|
|
75
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
|
|
76
129
|
* reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
|
|
77
130
|
*/
|
|
131
|
+
|
|
78
132
|
declare const en: {
|
|
79
133
|
toc: string;
|
|
80
134
|
prev: string;
|
|
@@ -91,6 +145,7 @@ declare const en: {
|
|
|
91
145
|
tip: string;
|
|
92
146
|
caution: string;
|
|
93
147
|
diagram: string;
|
|
148
|
+
diagramError: string;
|
|
94
149
|
contentError: string;
|
|
95
150
|
fallbackTitle: string;
|
|
96
151
|
fallbackBody: string;
|
|
@@ -113,9 +168,10 @@ declare const en: {
|
|
|
113
168
|
unKind: string;
|
|
114
169
|
unTitle: string;
|
|
115
170
|
unBody: string;
|
|
171
|
+
viewer: ViewerLabels;
|
|
116
172
|
};
|
|
117
173
|
type Strings = typeof en;
|
|
118
174
|
/** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
|
|
119
175
|
declare function stringsFor(locale: string | undefined): Strings;
|
|
120
176
|
|
|
121
|
-
export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
|
|
177
|
+
export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
1
2
|
import { ReactElement } from 'react';
|
|
2
|
-
import { H as HyleComponents, P as PageBaseProps } from './types-
|
|
3
|
-
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-
|
|
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';
|
|
4
5
|
import { Root } from 'hast';
|
|
5
|
-
import {
|
|
6
|
+
import { d as ResolvedArticle, f as ResolvedList } from './types-CwBCPh6K.js';
|
|
6
7
|
|
|
7
8
|
interface HastContentProps {
|
|
8
9
|
/** `content.tree` from an article result. Anything that is not a hast root renders nothing. */
|
|
@@ -23,6 +24,58 @@ declare function TrustedServerHtml({ html }: {
|
|
|
23
24
|
html: string;
|
|
24
25
|
}): ReactElement;
|
|
25
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
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The SDK's only client component. It receives the diagram text and presentational strings and nothing else: never a token,
|
|
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,
|
|
66
|
+
* from the host's own origin.
|
|
67
|
+
*/
|
|
68
|
+
interface MermaidDiagramProps {
|
|
69
|
+
source: string;
|
|
70
|
+
/** Accessible name of the diagram. */
|
|
71
|
+
title: string;
|
|
72
|
+
/** Shown when Mermaid cannot render the source. */
|
|
73
|
+
errorText: string;
|
|
74
|
+
/** Strings of the diagram viewer (English when omitted). */
|
|
75
|
+
labels?: ViewerLabels;
|
|
76
|
+
}
|
|
77
|
+
declare function MermaidDiagram({ source, title, errorText, labels }: MermaidDiagramProps): react.JSX.Element;
|
|
78
|
+
|
|
26
79
|
/**
|
|
27
80
|
* Defense in depth. hyle sanitizes server-side (packages/renderer/src/render.ts); this guard repeats the same allowlist
|
|
28
81
|
* so a compromised or buggy response still cannot put script, event handlers or `javascript:` URLs on the page. It
|
|
@@ -75,6 +128,7 @@ declare function Redirecting({ from, to, ...base }: RedirectingProps): ReactElem
|
|
|
75
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
|
|
76
129
|
* reviewed by a native speaker. Content itself is never translated here; it comes from hyle.
|
|
77
130
|
*/
|
|
131
|
+
|
|
78
132
|
declare const en: {
|
|
79
133
|
toc: string;
|
|
80
134
|
prev: string;
|
|
@@ -91,6 +145,7 @@ declare const en: {
|
|
|
91
145
|
tip: string;
|
|
92
146
|
caution: string;
|
|
93
147
|
diagram: string;
|
|
148
|
+
diagramError: string;
|
|
94
149
|
contentError: string;
|
|
95
150
|
fallbackTitle: string;
|
|
96
151
|
fallbackBody: string;
|
|
@@ -113,9 +168,10 @@ declare const en: {
|
|
|
113
168
|
unKind: string;
|
|
114
169
|
unTitle: string;
|
|
115
170
|
unBody: string;
|
|
171
|
+
viewer: ViewerLabels;
|
|
116
172
|
};
|
|
117
173
|
type Strings = typeof en;
|
|
118
174
|
/** Strings for a BCP 47 tag; the primary subtag decides, anything unknown falls back to English. */
|
|
119
175
|
declare function stringsFor(locale: string | undefined): Strings;
|
|
120
176
|
|
|
121
|
-
export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
|
|
177
|
+
export { ArticlePage, type ArticlePageProps, DocsPage, HastContent, type HastContentProps, HastLimitError, HyleComponents, ListPage, type ListPageProps, MermaidDiagram, type MermaidDiagramProps, NotFound, type NotFoundProps, PageBaseProps, Redirecting, type RedirectingProps, type Strings, TrustedServerHtml, Unavailable, isSafeUrl, sanitizeHast, scopeId, stringsFor };
|
package/dist/react.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
HastContent,
|
|
5
5
|
HastLimitError,
|
|
6
6
|
ListPage,
|
|
7
|
+
MermaidDiagram,
|
|
7
8
|
NotFound,
|
|
8
9
|
Redirecting,
|
|
9
10
|
TrustedServerHtml,
|
|
@@ -12,13 +13,14 @@ import {
|
|
|
12
13
|
sanitizeHast,
|
|
13
14
|
scopeId,
|
|
14
15
|
stringsFor
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SO6H2UGL.js";
|
|
16
17
|
export {
|
|
17
18
|
ArticlePage,
|
|
18
19
|
DocsPage,
|
|
19
20
|
HastContent,
|
|
20
21
|
HastLimitError,
|
|
21
22
|
ListPage,
|
|
23
|
+
MermaidDiagram,
|
|
22
24
|
NotFound,
|
|
23
25
|
Redirecting,
|
|
24
26
|
TrustedServerHtml,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Resolved } from './types-
|
|
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-
|
|
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>;
|