@tdacorp/hyle-sdk 0.17.0 → 0.22.2
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 +261 -42
- package/dist/check-routes-bin.js +190 -53
- package/dist/{chunk-6VOHFFA5.js → chunk-7T5EEJHK.js} +2 -2
- package/dist/chunk-DUPT6XLB.js +57 -0
- package/dist/chunk-IW3TUD4G.js +841 -0
- package/dist/{chunk-MGSUQBDW.js → chunk-KU7LWK4E.js} +249 -24
- package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
- package/dist/chunk-SFFBZFEN.js +178 -0
- package/dist/chunk-U74B7AUG.js +398 -0
- package/dist/chunk-ZIW6FDU2.js +1126 -0
- package/dist/client-BGjmEWhN.d.cts +207 -0
- package/dist/client-D0LTpr3Y.d.ts +207 -0
- package/dist/code-copy.cjs +74 -0
- package/dist/code-copy.d.cts +18 -0
- package/dist/code-copy.d.ts +18 -0
- package/dist/code-copy.js +50 -0
- package/dist/comments.cjs +738 -280
- package/dist/comments.d.cts +66 -3
- package/dist/comments.d.ts +66 -3
- package/dist/comments.js +419 -331
- package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-DNTZ2UXv.d.ts → embed-CbtsbZs3.d.cts} +5 -3
- package/dist/{embed-BmdwA2G9.d.cts → embed-Cf_2ZR5x.d.ts} +5 -3
- package/dist/fragment-alias.cjs +51 -0
- package/dist/fragment-alias.d.cts +7 -0
- package/dist/fragment-alias.d.ts +7 -0
- package/dist/fragment-alias.js +27 -0
- package/dist/html.cjs +886 -0
- package/dist/html.d.cts +20 -0
- package/dist/html.d.ts +20 -0
- package/dist/html.js +45 -0
- package/dist/index.cjs +244 -24
- package/dist/index.d.cts +22 -68
- package/dist/index.d.ts +22 -68
- package/dist/index.js +12 -2
- package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.cts} +9 -0
- package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.ts} +9 -0
- package/dist/mermaid-diagram.cjs +441 -125
- package/dist/mermaid-diagram.d.cts +23 -7
- package/dist/mermaid-diagram.d.ts +23 -7
- package/dist/mermaid-diagram.js +213 -51
- package/dist/mermaid-image.cjs +137 -60
- package/dist/mermaid-image.d.cts +4 -3
- package/dist/mermaid-image.d.ts +4 -3
- package/dist/mermaid-image.js +27 -28
- package/dist/next.cjs +836 -304
- package/dist/next.d.cts +45 -20
- package/dist/next.d.ts +45 -20
- package/dist/next.js +151 -40
- package/dist/print-coordinator.cjs +157 -0
- package/dist/print-coordinator.d.cts +27 -0
- package/dist/print-coordinator.d.ts +27 -0
- package/dist/print-coordinator.js +83 -0
- package/dist/react.cjs +603 -240
- package/dist/react.d.cts +148 -30
- package/dist/react.d.ts +148 -30
- package/dist/react.js +26 -4
- package/dist/reactions.cjs +653 -0
- package/dist/reactions.d.cts +27 -0
- package/dist/reactions.d.ts +27 -0
- package/dist/reactions.js +364 -0
- package/dist/{resolve-euZ4-aC9.d.cts → resolve-BnIv7aB7.d.cts} +2 -2
- package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BysHtZ_i.d.ts} +2 -2
- package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
- package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
- package/dist/sanitize-BpY_AdZh.d.cts +23 -0
- package/dist/sanitize-BpY_AdZh.d.ts +23 -0
- package/dist/styles.css +100 -29
- package/dist/toc-spy.cjs +60 -0
- package/dist/toc-spy.d.cts +15 -0
- package/dist/toc-spy.d.ts +15 -0
- package/dist/toc-spy.js +36 -0
- package/dist/{types-Czt887Iv.d.cts → types-D09Z072G.d.cts} +57 -2
- package/dist/{types-Czt887Iv.d.ts → types-D09Z072G.d.ts} +57 -2
- package/dist/use-cache.cjs +89 -13
- package/dist/use-cache.d.cts +12 -5
- package/dist/use-cache.d.ts +12 -5
- package/dist/use-cache.js +8 -8
- package/dist/youtube-facade.cjs +50 -0
- package/dist/youtube-facade.d.cts +17 -0
- package/dist/youtube-facade.d.ts +17 -0
- package/dist/youtube-facade.js +26 -0
- package/package.json +16 -3
- package/dist/chunk-67IOIAVW.js +0 -35
- package/dist/chunk-DMK4XQLU.js +0 -1556
- package/dist/chunk-PJMJMP66.js +0 -63
- package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
- package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fill
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QVYQM5R2.js";
|
|
4
4
|
|
|
5
5
|
// src/react/viewer/diagram-viewer.tsx
|
|
6
6
|
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
@@ -70,7 +70,10 @@ function nearest(nodes, x, y) {
|
|
|
70
70
|
let d = GEOMETRY_SLACK;
|
|
71
71
|
for (const n of nodes) {
|
|
72
72
|
const nd = dist(n.box, x, y);
|
|
73
|
-
if (nd < d)
|
|
73
|
+
if (nd < d) {
|
|
74
|
+
d = nd;
|
|
75
|
+
best = n.key;
|
|
76
|
+
}
|
|
74
77
|
}
|
|
75
78
|
return best;
|
|
76
79
|
}
|
|
@@ -157,7 +160,10 @@ function walk(g, start, next, far) {
|
|
|
157
160
|
edges.add(i);
|
|
158
161
|
const other = far(g.edges[i]);
|
|
159
162
|
nodes.add(other);
|
|
160
|
-
if (!seen.has(other))
|
|
163
|
+
if (!seen.has(other)) {
|
|
164
|
+
seen.add(other);
|
|
165
|
+
queue.push(other);
|
|
166
|
+
}
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
return { nodes, edges };
|
|
@@ -170,7 +176,10 @@ function trace(g, key) {
|
|
|
170
176
|
function neighbourhood(g, key) {
|
|
171
177
|
const edges = /* @__PURE__ */ new Set([...g.out.get(key) ?? [], ...g.inn.get(key) ?? []]);
|
|
172
178
|
const nodes = /* @__PURE__ */ new Set([key]);
|
|
173
|
-
for (const i of edges)
|
|
179
|
+
for (const i of edges) {
|
|
180
|
+
nodes.add(g.edges[i].from);
|
|
181
|
+
nodes.add(g.edges[i].to);
|
|
182
|
+
}
|
|
174
183
|
return { nodes, edges };
|
|
175
184
|
}
|
|
176
185
|
var VEC = { up: [0, -1], down: [0, 1], left: [-1, 0], right: [1, 0] };
|
|
@@ -192,12 +201,18 @@ function pickNeighbour(g, key, dir) {
|
|
|
192
201
|
const across = Math.abs((x - cx) * vy - (y - cy) * vx);
|
|
193
202
|
if (along <= 0 || across > along * cone) continue;
|
|
194
203
|
const c = along + across * 2;
|
|
195
|
-
if (c < cost)
|
|
204
|
+
if (c < cost) {
|
|
205
|
+
cost = c;
|
|
206
|
+
pick = k;
|
|
207
|
+
}
|
|
196
208
|
}
|
|
197
209
|
return pick;
|
|
198
210
|
};
|
|
199
211
|
const adjacent = /* @__PURE__ */ new Set();
|
|
200
|
-
for (const i of [...g.out.get(key) ?? [], ...g.inn.get(key) ?? []])
|
|
212
|
+
for (const i of [...g.out.get(key) ?? [], ...g.inn.get(key) ?? []]) {
|
|
213
|
+
adjacent.add(g.edges[i].from);
|
|
214
|
+
adjacent.add(g.edges[i].to);
|
|
215
|
+
}
|
|
201
216
|
return best(adjacent, CONE) ?? best(adjacent, Infinity) ?? best(g.byKey.keys(), CONE);
|
|
202
217
|
}
|
|
203
218
|
function searchNodes(nodes, query) {
|
|
@@ -226,18 +241,25 @@ var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
226
241
|
var isTag = (segment) => !/^<style\b/i.test(segment);
|
|
227
242
|
function scopeSvg(svg, oldId, newId) {
|
|
228
243
|
if (!/^[\w-]+$/.test(oldId) || !/^[\w-]+$/.test(newId)) throw new Error("unsafe svg id");
|
|
244
|
+
const own = `${oldId}-`;
|
|
229
245
|
const token = new RegExp(`(?<![\\w-])${escapeRe(oldId)}(?![A-Za-z0-9-])`, "g");
|
|
230
246
|
const rooted = svg.replace(SEGMENT, (segment) => segment.replace(token, newId));
|
|
231
|
-
const
|
|
247
|
+
const ids = /* @__PURE__ */ new Set();
|
|
232
248
|
for (const segment of rooted.match(SEGMENT) ?? []) {
|
|
233
249
|
if (!isTag(segment)) continue;
|
|
234
|
-
for (const m of segment.matchAll(/\sid="([^"]*)"/g))
|
|
250
|
+
for (const m of segment.matchAll(/\sid="([^"]*)"/g)) ids.add(m[1]);
|
|
235
251
|
}
|
|
252
|
+
const stripped = (id) => id.startsWith(own) ? id.slice(own.length) : id;
|
|
253
|
+
const target = (id) => `${newId}_${stripped(id)}`;
|
|
254
|
+
const plain = [...ids].filter((id) => !id.startsWith(`${newId}_`) && id !== newId);
|
|
255
|
+
const claims = /* @__PURE__ */ new Map();
|
|
256
|
+
for (const id of plain) claims.set(target(id), (claims.get(target(id)) ?? 0) + 1);
|
|
257
|
+
const fresh = new Map(plain.map((id) => [id, ids.has(target(id)) || claims.get(target(id)) > 1 ? `${newId}_${id}` : target(id)]));
|
|
236
258
|
if (!fresh.size) return rooted;
|
|
237
259
|
const to = (id) => fresh.get(id) ?? id;
|
|
238
260
|
return rooted.replace(
|
|
239
261
|
SEGMENT,
|
|
240
|
-
(segment) => !isTag(segment) ? segment : segment.replace(/(\sid=")([^"]*)"/g, (_, a, id) => `${a}${to(id)}"`).replace(/url\(#([^)"'\s]+)\)/g, (_, id) => `url(#${to(id)})`).replace(/(\s(?:xlink:)?href=")#([^"]*)"/g, (_, a, id) => `${a}#${to(id)}"`).replace(/(\saria-(?:labelledby|describedby)=")([^"]*)"/g, (_, a,
|
|
262
|
+
(segment) => !isTag(segment) ? segment : segment.replace(/(\sid=")([^"]*)"/g, (_, a, id) => `${a}${to(id)}"`).replace(/url\(#([^)"'\s]+)\)/g, (_, id) => `url(#${to(id)})`).replace(/(\s(?:xlink:)?href=")#([^"]*)"/g, (_, a, id) => `${a}#${to(id)}"`).replace(/(\saria-(?:labelledby|describedby)=")([^"]*)"/g, (_, a, ids2) => `${a}${ids2.split(/\s+/).map(to).join(" ")}"`)
|
|
241
263
|
);
|
|
242
264
|
}
|
|
243
265
|
function svgSize(svg) {
|
|
@@ -497,7 +519,10 @@ var DiagramController = class {
|
|
|
497
519
|
n.el.setAttribute("aria-pressed", "false");
|
|
498
520
|
});
|
|
499
521
|
if (this.nodes[0]) this.roving = this.nodes[0].el;
|
|
500
|
-
for (const e of this.edges)
|
|
522
|
+
for (const e of this.edges) {
|
|
523
|
+
e.el.classList.add("hv-e");
|
|
524
|
+
e.labelEl?.classList.add("hv-e");
|
|
525
|
+
}
|
|
501
526
|
this.o.stage.classList.toggle("hv-plain", this.nodes.length > FADE_MAX_NODES);
|
|
502
527
|
}
|
|
503
528
|
// ---- view ---------------------------------------------------------------------------------------------------------------------------
|
|
@@ -756,13 +781,22 @@ var DiagramController = class {
|
|
|
756
781
|
for (const k of t.down) mark(at(k)?.el, "hv-down");
|
|
757
782
|
mark(at(this.pinned)?.el, "hv-sel");
|
|
758
783
|
const flow = t.upEdges.size + t.downEdges.size <= FLOW_MAX_EDGES ? ["hv-flow"] : [];
|
|
759
|
-
for (const i of t.upEdges)
|
|
760
|
-
|
|
784
|
+
for (const i of t.upEdges) {
|
|
785
|
+
mark(this.edges[i]?.el, "hv-up", ...flow);
|
|
786
|
+
mark(this.edges[i]?.labelEl, "hv-up");
|
|
787
|
+
}
|
|
788
|
+
for (const i of t.downEdges) {
|
|
789
|
+
mark(this.edges[i]?.el, "hv-down", ...flow);
|
|
790
|
+
mark(this.edges[i]?.labelEl, "hv-down");
|
|
791
|
+
}
|
|
761
792
|
} else if (g && this.hot) {
|
|
762
793
|
active = true;
|
|
763
794
|
const n = neighbourhood(g, this.hot);
|
|
764
795
|
for (const k of n.nodes) mark(at(k)?.el, k === this.hot ? "hv-sel" : "hv-nb");
|
|
765
|
-
for (const i of n.edges)
|
|
796
|
+
for (const i of n.edges) {
|
|
797
|
+
mark(this.edges[i]?.el, "hv-nb");
|
|
798
|
+
mark(this.edges[i]?.labelEl, "hv-nb");
|
|
799
|
+
}
|
|
766
800
|
} else if (this.query && this.hitEls.length) {
|
|
767
801
|
active = true;
|
|
768
802
|
for (const el of this.hitEls) mark(el);
|
|
@@ -970,6 +1004,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
970
1004
|
var sequence = 0;
|
|
971
1005
|
var locks = 0;
|
|
972
1006
|
var LOCK_CLASS = "hyle-viewer-lock";
|
|
1007
|
+
var FULLSCREEN_CLASS = "hyle-viewer-fs";
|
|
973
1008
|
var SCALES = ["1", "2", "4"];
|
|
974
1009
|
var TOAST_MS = 4e3;
|
|
975
1010
|
var Glyph = ({ d }) => /* @__PURE__ */ jsx("svg", { className: "hv-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d }) });
|
|
@@ -977,7 +1012,7 @@ var ICONS = {
|
|
|
977
1012
|
close: "m4 4 8 8M12 4l-8 8",
|
|
978
1013
|
fit: "M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10",
|
|
979
1014
|
search: "M7 12.2A5.2 5.2 0 1 0 7 1.8a5.2 5.2 0 0 0 0 10.4zM11 11l3.2 3.2",
|
|
980
|
-
full: "
|
|
1015
|
+
full: "M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9",
|
|
981
1016
|
exit: "M6 2.5V6H2.5M13.5 6H10V2.5M10 13.5V10h3.5M2.5 10H6v3.5"
|
|
982
1017
|
};
|
|
983
1018
|
function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
|
|
@@ -990,8 +1025,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
|
|
|
990
1025
|
const finder = useRef(null);
|
|
991
1026
|
const ctl = useRef(null);
|
|
992
1027
|
const labelsRef = useRef(labels);
|
|
993
|
-
|
|
994
|
-
const ownId = useRef(`hyle-viewer-${++sequence}`);
|
|
1028
|
+
const [ownId] = useState(() => `hyleViewer-${++sequence}`);
|
|
995
1029
|
const helpId = useId();
|
|
996
1030
|
const toastTimer = useRef(void 0);
|
|
997
1031
|
const downOnBackdrop = useRef(false);
|
|
@@ -1001,12 +1035,15 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
|
|
|
1001
1035
|
const [query, setQuery] = useState("");
|
|
1002
1036
|
const [scale, setScale] = useState("2");
|
|
1003
1037
|
const [fullscreen, setFullscreen] = useState(false);
|
|
1004
|
-
const scoped = useMemo(() => scopeSvg(svg, svgId, ownId
|
|
1038
|
+
const scoped = useMemo(() => scopeSvg(svg, svgId, ownId), [svg, svgId, ownId]);
|
|
1005
1039
|
const say = (message) => {
|
|
1006
1040
|
clearTimeout(toastTimer.current);
|
|
1007
1041
|
setToast(message);
|
|
1008
1042
|
toastTimer.current = setTimeout(() => setToast(""), TOAST_MS);
|
|
1009
1043
|
};
|
|
1044
|
+
useLayoutEffect(() => {
|
|
1045
|
+
labelsRef.current = labels;
|
|
1046
|
+
}, [labels]);
|
|
1010
1047
|
useLayoutEffect(() => {
|
|
1011
1048
|
const c = new DiagramController({
|
|
1012
1049
|
viewport: viewport.current,
|
|
@@ -1023,18 +1060,22 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
|
|
|
1023
1060
|
ctl.current = null;
|
|
1024
1061
|
};
|
|
1025
1062
|
}, []);
|
|
1026
|
-
useLayoutEffect(() => ctl.current?.show(scoped, `${ownId
|
|
1063
|
+
useLayoutEffect(() => ctl.current?.show(scoped, `${ownId}_`), [scoped, ownId]);
|
|
1027
1064
|
useEffect(() => {
|
|
1028
1065
|
const d = dialog.current;
|
|
1029
1066
|
if (!d.open) d.showModal();
|
|
1030
1067
|
if (locks++ === 0) document.documentElement.classList.add(LOCK_CLASS);
|
|
1031
1068
|
viewport.current?.focus({ preventScroll: true });
|
|
1032
|
-
const sync = () =>
|
|
1069
|
+
const sync = () => {
|
|
1070
|
+
const full = document.fullscreenElement === shell.current;
|
|
1071
|
+
setFullscreen(full);
|
|
1072
|
+
document.documentElement.classList.toggle(FULLSCREEN_CLASS, full);
|
|
1073
|
+
};
|
|
1033
1074
|
document.addEventListener("fullscreenchange", sync);
|
|
1034
1075
|
return () => {
|
|
1035
1076
|
document.removeEventListener("fullscreenchange", sync);
|
|
1036
1077
|
clearTimeout(toastTimer.current);
|
|
1037
|
-
if (--locks === 0) document.documentElement.classList.remove(LOCK_CLASS);
|
|
1078
|
+
if (--locks === 0) document.documentElement.classList.remove(LOCK_CLASS, FULLSCREEN_CLASS);
|
|
1038
1079
|
if (document.fullscreenElement && d.contains(document.fullscreenElement)) void document.exitFullscreen().catch(() => {
|
|
1039
1080
|
});
|
|
1040
1081
|
};
|
|
@@ -1141,7 +1182,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
|
|
|
1141
1182
|
/* @__PURE__ */ jsx("li", { className: "hv-down", children: labels.legendDownstream })
|
|
1142
1183
|
] }) : null,
|
|
1143
1184
|
/* @__PURE__ */ jsx("p", { className: "hv-hint", id: helpId, children: labels.hint }),
|
|
1144
|
-
/* @__PURE__ */ jsx("output", { className: "hv-toast",
|
|
1185
|
+
/* @__PURE__ */ jsx("output", { className: "hv-toast", children: toast })
|
|
1145
1186
|
] })
|
|
1146
1187
|
] })
|
|
1147
1188
|
}
|
package/dist/docs-enhance.cjs
CHANGED
|
@@ -25,6 +25,7 @@ __export(docs_enhance_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(docs_enhance_exports);
|
|
27
27
|
var import_react = require("react");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
29
|
var REACHED_SLACK = 24 + 8;
|
|
29
30
|
function stickyTop(root) {
|
|
30
31
|
return Number.parseFloat(getComputedStyle(root).getPropertyValue("--h-sticky-top")) || 0;
|
|
@@ -43,10 +44,12 @@ function revealCurrent(nav) {
|
|
|
43
44
|
if (a.top < b.top || a.bottom > b.bottom) nav.scrollTop += a.top - b.top - b.height / 3;
|
|
44
45
|
}
|
|
45
46
|
function DocsEnhance({ headingIds, rootId }) {
|
|
47
|
+
const marker = (0, import_react.useRef)(null);
|
|
46
48
|
const key = headingIds.join("\n");
|
|
47
49
|
(0, import_react.useEffect)(() => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
+
const tree = marker.current?.getRootNode();
|
|
51
|
+
const root = tree?.getElementById(rootId);
|
|
52
|
+
if (!tree || !root) return;
|
|
50
53
|
const nav = root.querySelector(".hyle-nav-d");
|
|
51
54
|
const cleanups = [];
|
|
52
55
|
if (nav) {
|
|
@@ -67,7 +70,7 @@ function DocsEnhance({ headingIds, rootId }) {
|
|
|
67
70
|
nav.addEventListener("click", onClick);
|
|
68
71
|
cleanups.push(() => (nav.removeEventListener("toggle", onToggle), nav.removeEventListener("click", onClick)));
|
|
69
72
|
}
|
|
70
|
-
const headings = headingIds.map((id) =>
|
|
73
|
+
const headings = headingIds.map((id) => tree.getElementById(id)).filter((h) => h !== null);
|
|
71
74
|
const end = root.querySelector(".hyle-docs-end");
|
|
72
75
|
if (headings.length > 0 && typeof IntersectionObserver === "function") {
|
|
73
76
|
let endVisible = false;
|
|
@@ -89,7 +92,7 @@ function DocsEnhance({ headingIds, rootId }) {
|
|
|
89
92
|
}
|
|
90
93
|
return () => cleanups.forEach((fn) => fn());
|
|
91
94
|
}, [key, rootId]);
|
|
92
|
-
return
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: marker, hidden: true });
|
|
93
96
|
}
|
|
94
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
98
|
0 && (module.exports = {
|
package/dist/docs-enhance.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Progressive enhancement for DocsPage. It renders
|
|
3
|
-
* page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
|
+
* Progressive enhancement for DocsPage. It renders only a hidden marker (whose tree, the document or a shadow root, is where
|
|
5
|
+
* the ids are looked up) and receives only the heading ids and the root element's id: the page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
6
|
* scroll-spy for the on-page TOC (IntersectionObserver on the headings plus one on the end of the article, `aria-current="location"`
|
|
5
7
|
* set on the DOM links so it never re-renders), the current page scrolled into view in the sidebar, and the drawer closing
|
|
6
8
|
* when a link in it is followed (a client-side navigation does not reload the page, so the popover would stay open).
|
|
@@ -11,6 +13,6 @@ interface DocsEnhanceProps {
|
|
|
11
13
|
/** The `id` of `.hyle-docs`. */
|
|
12
14
|
rootId: string;
|
|
13
15
|
}
|
|
14
|
-
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps):
|
|
16
|
+
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps): ReactElement;
|
|
15
17
|
|
|
16
18
|
export { DocsEnhance, type DocsEnhanceProps };
|
package/dist/docs-enhance.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Progressive enhancement for DocsPage. It renders
|
|
3
|
-
* page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
|
+
* Progressive enhancement for DocsPage. It renders only a hidden marker (whose tree, the document or a shadow root, is where
|
|
5
|
+
* the ids are looked up) and receives only the heading ids and the root element's id: the page works without it (the tree is `<details>`, the drawer is a `popover`), and this adds three things, with no dependency:
|
|
4
6
|
* scroll-spy for the on-page TOC (IntersectionObserver on the headings plus one on the end of the article, `aria-current="location"`
|
|
5
7
|
* set on the DOM links so it never re-renders), the current page scrolled into view in the sidebar, and the drawer closing
|
|
6
8
|
* when a link in it is followed (a client-side navigation does not reload the page, so the popover would stay open).
|
|
@@ -11,6 +13,6 @@ interface DocsEnhanceProps {
|
|
|
11
13
|
/** The `id` of `.hyle-docs`. */
|
|
12
14
|
rootId: string;
|
|
13
15
|
}
|
|
14
|
-
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps):
|
|
16
|
+
declare function DocsEnhance({ headingIds, rootId }: DocsEnhanceProps): ReactElement;
|
|
15
17
|
|
|
16
18
|
export { DocsEnhance, type DocsEnhanceProps };
|
package/dist/docs-enhance.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/react/docs-enhance.tsx
|
|
4
|
-
import { useEffect } from "react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
var REACHED_SLACK = 24 + 8;
|
|
6
7
|
function stickyTop(root) {
|
|
7
8
|
return Number.parseFloat(getComputedStyle(root).getPropertyValue("--h-sticky-top")) || 0;
|
|
@@ -20,10 +21,12 @@ function revealCurrent(nav) {
|
|
|
20
21
|
if (a.top < b.top || a.bottom > b.bottom) nav.scrollTop += a.top - b.top - b.height / 3;
|
|
21
22
|
}
|
|
22
23
|
function DocsEnhance({ headingIds, rootId }) {
|
|
24
|
+
const marker = useRef(null);
|
|
23
25
|
const key = headingIds.join("\n");
|
|
24
26
|
useEffect(() => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
+
const tree = marker.current?.getRootNode();
|
|
28
|
+
const root = tree?.getElementById(rootId);
|
|
29
|
+
if (!tree || !root) return;
|
|
27
30
|
const nav = root.querySelector(".hyle-nav-d");
|
|
28
31
|
const cleanups = [];
|
|
29
32
|
if (nav) {
|
|
@@ -44,7 +47,7 @@ function DocsEnhance({ headingIds, rootId }) {
|
|
|
44
47
|
nav.addEventListener("click", onClick);
|
|
45
48
|
cleanups.push(() => (nav.removeEventListener("toggle", onToggle), nav.removeEventListener("click", onClick)));
|
|
46
49
|
}
|
|
47
|
-
const headings = headingIds.map((id) =>
|
|
50
|
+
const headings = headingIds.map((id) => tree.getElementById(id)).filter((h) => h !== null);
|
|
48
51
|
const end = root.querySelector(".hyle-docs-end");
|
|
49
52
|
if (headings.length > 0 && typeof IntersectionObserver === "function") {
|
|
50
53
|
let endVisible = false;
|
|
@@ -66,7 +69,7 @@ function DocsEnhance({ headingIds, rootId }) {
|
|
|
66
69
|
}
|
|
67
70
|
return () => cleanups.forEach((fn) => fn());
|
|
68
71
|
}, [key, rootId]);
|
|
69
|
-
return
|
|
72
|
+
return /* @__PURE__ */ jsx("span", { ref: marker, hidden: true });
|
|
70
73
|
}
|
|
71
74
|
export {
|
|
72
75
|
DocsEnhance
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { j as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-D09Z072G.cjs';
|
|
3
3
|
|
|
4
|
-
type CalloutKind = "note" | "tip" | "warning" | "caution";
|
|
4
|
+
type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
6
6
|
href: string;
|
|
7
7
|
children?: ReactNode;
|
|
@@ -160,9 +160,11 @@ interface HyleListViewProps extends PageBaseProps {
|
|
|
160
160
|
readonly moreHref?: string | undefined;
|
|
161
161
|
/** Where "Older posts" goes (built from the list's `next_cursor`); omit to hide it. */
|
|
162
162
|
readonly olderHref?: string | undefined;
|
|
163
|
+
/** The list answer's `theme`, so an embedded list is styled like the workspace's pages. */
|
|
164
|
+
readonly theme?: ThemeRef | undefined;
|
|
163
165
|
}
|
|
164
166
|
/** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping. Pagination is only the optional `olderHref` link. */
|
|
165
|
-
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, ...base }: HyleListViewProps): ReactElement | null;
|
|
167
|
+
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, theme, ...base }: HyleListViewProps): ReactElement | null;
|
|
166
168
|
interface HyleArticleViewProps extends PageBaseProps {
|
|
167
169
|
readonly article: ResolvedArticle;
|
|
168
170
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { j as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-D09Z072G.js';
|
|
3
3
|
|
|
4
|
-
type CalloutKind = "note" | "tip" | "warning" | "caution";
|
|
4
|
+
type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
6
6
|
href: string;
|
|
7
7
|
children?: ReactNode;
|
|
@@ -160,9 +160,11 @@ interface HyleListViewProps extends PageBaseProps {
|
|
|
160
160
|
readonly moreHref?: string | undefined;
|
|
161
161
|
/** Where "Older posts" goes (built from the list's `next_cursor`); omit to hide it. */
|
|
162
162
|
readonly olderHref?: string | undefined;
|
|
163
|
+
/** The list answer's `theme`, so an embedded list is styled like the workspace's pages. */
|
|
164
|
+
readonly theme?: ThemeRef | undefined;
|
|
163
165
|
}
|
|
164
166
|
/** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping. Pagination is only the optional `olderHref` link. */
|
|
165
|
-
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, ...base }: HyleListViewProps): ReactElement | null;
|
|
167
|
+
declare function HyleListView({ items, layout, title, headingLevel, moreHref, olderHref, theme, ...base }: HyleListViewProps): ReactElement | null;
|
|
166
168
|
interface HyleArticleViewProps extends PageBaseProps {
|
|
167
169
|
readonly article: ResolvedArticle;
|
|
168
170
|
/**
|
|
@@ -0,0 +1,51 @@
|
|
|
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/fragment-alias.tsx
|
|
22
|
+
var fragment_alias_exports = {};
|
|
23
|
+
__export(fragment_alias_exports, {
|
|
24
|
+
FragmentAlias: () => FragmentAlias
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(fragment_alias_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var PREFIX = "user-content-";
|
|
29
|
+
function FragmentAlias() {
|
|
30
|
+
(0, import_react.useEffect)(() => {
|
|
31
|
+
const redirect = () => {
|
|
32
|
+
const [page, hash] = [location.href.slice(0, location.href.length - location.hash.length), location.hash.slice(1)];
|
|
33
|
+
let ids;
|
|
34
|
+
try {
|
|
35
|
+
ids = [hash, decodeURIComponent(hash)];
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const found = (prefix) => ids.some((id) => document.getElementById(prefix + id) !== null);
|
|
40
|
+
if (hash && !found("") && found(PREFIX)) location.replace(`${page}#${PREFIX}${hash}`);
|
|
41
|
+
};
|
|
42
|
+
redirect();
|
|
43
|
+
window.addEventListener("hashchange", redirect);
|
|
44
|
+
return () => window.removeEventListener("hashchange", redirect);
|
|
45
|
+
}, []);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
FragmentAlias
|
|
51
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every id hyle emits is prefixed `user-content-`, but links shared before that (or typed by hand) say `#x`. When `#x` matches
|
|
3
|
+
* nothing and `#user-content-x` exists, the history entry is replaced with the latter, on load and on every hash change.
|
|
4
|
+
*/
|
|
5
|
+
declare function FragmentAlias(): null;
|
|
6
|
+
|
|
7
|
+
export { FragmentAlias };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every id hyle emits is prefixed `user-content-`, but links shared before that (or typed by hand) say `#x`. When `#x` matches
|
|
3
|
+
* nothing and `#user-content-x` exists, the history entry is replaced with the latter, on load and on every hash change.
|
|
4
|
+
*/
|
|
5
|
+
declare function FragmentAlias(): null;
|
|
6
|
+
|
|
7
|
+
export { FragmentAlias };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/react/fragment-alias.tsx
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
var PREFIX = "user-content-";
|
|
6
|
+
function FragmentAlias() {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const redirect = () => {
|
|
9
|
+
const [page, hash] = [location.href.slice(0, location.href.length - location.hash.length), location.hash.slice(1)];
|
|
10
|
+
let ids;
|
|
11
|
+
try {
|
|
12
|
+
ids = [hash, decodeURIComponent(hash)];
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const found = (prefix) => ids.some((id) => document.getElementById(prefix + id) !== null);
|
|
17
|
+
if (hash && !found("") && found(PREFIX)) location.replace(`${page}#${PREFIX}${hash}`);
|
|
18
|
+
};
|
|
19
|
+
redirect();
|
|
20
|
+
window.addEventListener("hashchange", redirect);
|
|
21
|
+
return () => window.removeEventListener("hashchange", redirect);
|
|
22
|
+
}, []);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
FragmentAlias
|
|
27
|
+
};
|