@tdacorp/hyle-sdk 0.14.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +171 -32
  2. package/dist/check-routes-bin.js +48 -21
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +733 -278
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +414 -330
  20. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-XY3CG75U.js} +107 -46
  21. package/dist/{embed-B76zRRPa.d.cts → embed-BUFRQboD.d.ts} +10 -5
  22. package/dist/{embed-SqOBGI-E.d.ts → embed-CYt-q13P.d.cts} +10 -5
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/labels-CrA-iqTN.d.cts +46 -0
  36. package/dist/labels-CrA-iqTN.d.ts +46 -0
  37. package/dist/mermaid-diagram.cjs +453 -148
  38. package/dist/mermaid-diagram.d.cts +25 -42
  39. package/dist/mermaid-diagram.d.ts +25 -42
  40. package/dist/mermaid-diagram.js +205 -50
  41. package/dist/mermaid-image.cjs +1456 -0
  42. package/dist/mermaid-image.d.cts +30 -0
  43. package/dist/mermaid-image.d.ts +30 -0
  44. package/dist/mermaid-image.js +93 -0
  45. package/dist/next.cjs +1709 -1134
  46. package/dist/next.d.cts +67 -14
  47. package/dist/next.d.ts +67 -14
  48. package/dist/next.js +950 -794
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +677 -264
  54. package/dist/react.d.cts +161 -31
  55. package/dist/react.d.ts +161 -31
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-DC2ccfwA.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-DKLVftk_.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +107 -47
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-ByodIyEv.d.cts → types-3F0wqD-o.d.cts} +44 -4
  73. package/dist/{types-ByodIyEv.d.ts → types-3F0wqD-o.d.ts} +44 -4
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-4V4VKB3O.js +0 -1471
  84. package/dist/chunk-R5EMI4HQ.js +0 -61
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fill
3
- } from "./chunk-BUJFMR3M.js";
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) d = nd, best = n.key;
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)) seen.add(other), queue.push(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) nodes.add(g.edges[i].from), nodes.add(g.edges[i].to);
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) cost = c, pick = k;
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) ?? []]) adjacent.add(g.edges[i].from), adjacent.add(g.edges[i].to);
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 fresh = /* @__PURE__ */ new Map();
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)) if (!m[1].startsWith(`${newId}_`) && m[1] !== newId) fresh.set(m[1], `${newId}_${m[1]}`);
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, ids) => `${a}${ids.split(/\s+/).map(to).join(" ")}"`)
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) {
@@ -257,6 +279,31 @@ function standaloneSvg(svg) {
257
279
  return svg.replace(open, tagText);
258
280
  }
259
281
 
282
+ // src/react/viewer/svg-css.ts
283
+ var SVG_CSS = `
284
+ svg{display:block;position:static!important;width:100%;height:100%;max-width:none!important}
285
+ .hv-n{cursor:pointer;outline:none}
286
+ .hv-n,.hv-e{transition:opacity .15s}
287
+ @media (prefers-reduced-motion:reduce){.hv-n,.hv-e{transition:none}}
288
+ :host(.hv-plain) .hv-n,:host(.hv-plain) .hv-e{transition:none}
289
+ :host(.hv-active) .hv-n:not(.hv-on),:host(.hv-active) .hv-e:not(.hv-on){opacity:var(--hv-dim)}
290
+ .hv-n:focus-visible :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-focus)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
291
+ .hv-n.hv-nb :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(2px / var(--hv-k,1))!important}
292
+ .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}
293
+ .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}
294
+ .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}
295
+ .hv-n.hv-hit :is(rect,polygon,circle,ellipse,path){stroke:var(--hv-accent)!important;stroke-width:calc(3px / var(--hv-k,1))!important}
296
+ .hv-n.hv-cur :is(rect,polygon,circle,ellipse,path){stroke-width:calc(5px / var(--hv-k,1))!important}
297
+ text.hv-hit,text.hv-hit tspan{fill:var(--hv-accent)!important;font-weight:700}
298
+ text.hv-cur{text-decoration:underline}
299
+ path.hv-nb{stroke:var(--hv-accent)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
300
+ path.hv-up{stroke:var(--hv-up)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
301
+ path.hv-down{stroke:var(--hv-down)!important;stroke-width:calc(2.5px / var(--hv-k,1))!important}
302
+ path.hv-flow{stroke-dasharray:calc(7px / var(--hv-k,1)) calc(6px / var(--hv-k,1))!important;animation:hv-dash .9s linear infinite}
303
+ @keyframes hv-dash{to{stroke-dashoffset:calc(-26px / var(--hv-k,1))}}
304
+ @media (prefers-reduced-motion:reduce){path.hv-flow{animation:none}}
305
+ `;
306
+
260
307
  // src/react/viewer/view-math.ts
261
308
  var MIN_K = 0.2;
262
309
  var MAX_K = 10;
@@ -355,6 +402,7 @@ var DiagramController = class {
355
402
  constructor(o) {
356
403
  this.o = o;
357
404
  const { viewport: vp, stage, minimap } = o;
405
+ const root = this.root = stage.shadowRoot ?? stage.attachShadow({ mode: "open" });
358
406
  const on = (el, type, fn, opts) => {
359
407
  el.addEventListener(type, fn, opts);
360
408
  this.off.push(() => el.removeEventListener(type, fn, opts));
@@ -364,21 +412,16 @@ var DiagramController = class {
364
412
  on(vp, "pointermove", (e) => this.onMove(e));
365
413
  on(vp, "pointerup", (e) => this.onUp(e));
366
414
  on(vp, "pointercancel", (e) => this.onUp(e, true));
367
- on(stage, "pointerover", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.target)));
368
- on(stage, "pointerout", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.relatedTarget)));
369
- on(stage, "focusin", (e) => this.onFocusIn(e));
370
- on(stage, "focusout", () => this.focusLeft());
415
+ on(root, "pointerover", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.target)));
416
+ on(root, "pointerout", (e) => e.pointerType === "mouse" && !this.pointers.size && this.mouseOver(this.keyAt(e.relatedTarget)));
417
+ on(root, "focusin", (e) => this.onFocusIn(e));
418
+ on(root, "focusout", () => this.focusLeft());
371
419
  on(minimap, "pointerdown", (e) => this.onMiniDown(e));
372
420
  on(minimap, "pointermove", (e) => this.miniDrag && this.miniTo(e));
373
421
  on(minimap, "pointerup", () => this.miniDrag = false);
374
422
  on(minimap, "pointercancel", () => this.miniDrag = false);
375
423
  this.ro = new ResizeObserver(() => this.measure());
376
424
  this.ro.observe(vp);
377
- this.watcher = new MutationObserver(() => {
378
- const now = stage.querySelector("svg");
379
- if (now && now !== this.svg && this.source) this.mount(now, this.source.markup, this.source.idPrefix);
380
- });
381
- this.watcher.observe(stage, { childList: true });
382
425
  this.measure();
383
426
  }
384
427
  o;
@@ -416,8 +459,7 @@ var DiagramController = class {
416
459
  dragging = false;
417
460
  samples = [];
418
461
  ro;
419
- watcher;
420
- source;
462
+ root;
421
463
  miniDrag = false;
422
464
  miniColors = { node: "#888", edge: "#555", view: "#0af", bg: "transparent" };
423
465
  off = [];
@@ -425,16 +467,19 @@ var DiagramController = class {
425
467
  this.anim?.stop();
426
468
  cancelAnimationFrame(this.frame);
427
469
  this.ro?.disconnect();
428
- this.watcher?.disconnect();
429
470
  for (const f of this.off) f();
430
471
  }
431
472
  // ---- mounting -----------------------------------------------------------------------------------------------------------------------
432
- /** (Re)attaches to the SVG now in the stage. A re-mount (theme change) keeps the view and a still-valid pin. */
473
+ /** Shows `markup` in the stage's shadow root and attaches to its SVG. A new SVG (theme change) keeps the view and a still-valid pin. */
474
+ show(markup, idPrefix) {
475
+ this.root.innerHTML = `<style>${SVG_CSS}</style>${markup}`;
476
+ const svg = this.root.querySelector("svg");
477
+ if (svg) this.mount(svg, markup, idPrefix);
478
+ }
433
479
  mount(svg, markup, idPrefix) {
434
480
  const size = svgSize(markup) ?? { w: svg.getBoundingClientRect().width || 600, h: svg.getBoundingClientRect().height || 400 };
435
481
  const first = this.svg === void 0;
436
482
  this.svg = svg;
437
- this.source = { markup, idPrefix };
438
483
  this.content = { x: 0, y: 0, w: size.w, h: size.h };
439
484
  this.o.stage.style.width = `${size.w}px`;
440
485
  this.o.stage.style.height = `${size.h}px`;
@@ -474,7 +519,10 @@ var DiagramController = class {
474
519
  n.el.setAttribute("aria-pressed", "false");
475
520
  });
476
521
  if (this.nodes[0]) this.roving = this.nodes[0].el;
477
- for (const e of this.edges) e.el.classList.add("hv-e"), e.labelEl?.classList.add("hv-e");
522
+ for (const e of this.edges) {
523
+ e.el.classList.add("hv-e");
524
+ e.labelEl?.classList.add("hv-e");
525
+ }
478
526
  this.o.stage.classList.toggle("hv-plain", this.nodes.length > FADE_MAX_NODES);
479
527
  }
480
528
  // ---- view ---------------------------------------------------------------------------------------------------------------------------
@@ -568,8 +616,9 @@ var DiagramController = class {
568
616
  const at = this.local(e);
569
617
  this.pointers.set(e.pointerId, at);
570
618
  if (this.pointers.size === 1) {
571
- const key = this.keyAt(e.target);
572
- this.tap = { at, key, moved: false, link: Boolean(e.target.closest?.("a")), id: e.pointerId };
619
+ const target = e.composedPath()[0];
620
+ const key = this.keyAt(target);
621
+ this.tap = { at, key, moved: false, link: Boolean(target.closest?.("a")), id: e.pointerId };
573
622
  this.start = { view: this.view, at };
574
623
  this.dragging = false;
575
624
  this.samples = [{ t: e.timeStamp, ...at }];
@@ -701,7 +750,7 @@ var DiagramController = class {
701
750
  }
702
751
  focusLeft() {
703
752
  queueMicrotask(() => {
704
- if (this.o.stage.contains(document.activeElement)) return;
753
+ if (this.root.activeElement) return;
705
754
  this.focusKey = null;
706
755
  this.refreshHot();
707
756
  });
@@ -732,13 +781,22 @@ var DiagramController = class {
732
781
  for (const k of t.down) mark(at(k)?.el, "hv-down");
733
782
  mark(at(this.pinned)?.el, "hv-sel");
734
783
  const flow = t.upEdges.size + t.downEdges.size <= FLOW_MAX_EDGES ? ["hv-flow"] : [];
735
- for (const i of t.upEdges) mark(this.edges[i]?.el, "hv-up", ...flow), mark(this.edges[i]?.labelEl, "hv-up");
736
- for (const i of t.downEdges) mark(this.edges[i]?.el, "hv-down", ...flow), mark(this.edges[i]?.labelEl, "hv-down");
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
+ }
737
792
  } else if (g && this.hot) {
738
793
  active = true;
739
794
  const n = neighbourhood(g, this.hot);
740
795
  for (const k of n.nodes) mark(at(k)?.el, k === this.hot ? "hv-sel" : "hv-nb");
741
- for (const i of n.edges) mark(this.edges[i]?.el, "hv-nb"), mark(this.edges[i]?.labelEl, "hv-nb");
796
+ for (const i of n.edges) {
797
+ mark(this.edges[i]?.el, "hv-nb");
798
+ mark(this.edges[i]?.labelEl, "hv-nb");
799
+ }
742
800
  } else if (this.query && this.hitEls.length) {
743
801
  active = true;
744
802
  for (const el of this.hitEls) mark(el);
@@ -757,7 +815,7 @@ var DiagramController = class {
757
815
  }
758
816
  /** Arrow-key traversal from the focused node. Returns false when the key was not used. */
759
817
  traverse(dir) {
760
- const el = document.activeElement?.closest?.(".hv-n") ?? null;
818
+ const el = this.root.activeElement?.closest?.(".hv-n") ?? null;
761
819
  const key = el && this.stageHas(el) ? this.keyAt(el) : null;
762
820
  if (key === null || !this.graph) return false;
763
821
  const next = pickNeighbour(this.graph, key, dir);
@@ -769,7 +827,7 @@ var DiagramController = class {
769
827
  return true;
770
828
  }
771
829
  stageHas(el) {
772
- return this.o.stage.contains(el);
830
+ return this.root.contains(el);
773
831
  }
774
832
  /** Keyboard commands of the viewer. Returns true when the key was handled (the caller then prevents the default). */
775
833
  key(e) {
@@ -783,7 +841,7 @@ var DiagramController = class {
783
841
  this.set({ ...this.view, x: this.view.x + (dir === "left" ? step : dir === "right" ? -step : 0), y: this.view.y + (dir === "up" ? step : dir === "down" ? -step : 0) });
784
842
  return true;
785
843
  }
786
- const onNode = this.keyAt(document.activeElement);
844
+ const onNode = this.keyAt(this.root.activeElement);
787
845
  switch (e.key) {
788
846
  case "+":
789
847
  case "=":
@@ -946,6 +1004,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
946
1004
  var sequence = 0;
947
1005
  var locks = 0;
948
1006
  var LOCK_CLASS = "hyle-viewer-lock";
1007
+ var FULLSCREEN_CLASS = "hyle-viewer-fs";
949
1008
  var SCALES = ["1", "2", "4"];
950
1009
  var TOAST_MS = 4e3;
951
1010
  var Glyph = ({ d }) => /* @__PURE__ */ jsx("svg", { className: "hv-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d }) });
@@ -953,7 +1012,7 @@ var ICONS = {
953
1012
  close: "m4 4 8 8M12 4l-8 8",
954
1013
  fit: "M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10",
955
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",
956
- full: "M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10",
1015
+ full: "M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9",
957
1016
  exit: "M6 2.5V6H2.5M13.5 6H10V2.5M10 13.5V10h3.5M2.5 10H6v3.5"
958
1017
  };
959
1018
  function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
@@ -966,8 +1025,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
966
1025
  const finder = useRef(null);
967
1026
  const ctl = useRef(null);
968
1027
  const labelsRef = useRef(labels);
969
- labelsRef.current = labels;
970
- const ownId = useRef(`hyle-viewer-${++sequence}`);
1028
+ const [ownId] = useState(() => `hyleViewer-${++sequence}`);
971
1029
  const helpId = useId();
972
1030
  const toastTimer = useRef(void 0);
973
1031
  const downOnBackdrop = useRef(false);
@@ -977,13 +1035,15 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
977
1035
  const [query, setQuery] = useState("");
978
1036
  const [scale, setScale] = useState("2");
979
1037
  const [fullscreen, setFullscreen] = useState(false);
980
- const scoped = useMemo(() => scopeSvg(svg, svgId, ownId.current), [svg, svgId]);
981
- const html = useMemo(() => ({ __html: scoped }), [scoped]);
1038
+ const scoped = useMemo(() => scopeSvg(svg, svgId, ownId), [svg, svgId, ownId]);
982
1039
  const say = (message) => {
983
1040
  clearTimeout(toastTimer.current);
984
1041
  setToast(message);
985
1042
  toastTimer.current = setTimeout(() => setToast(""), TOAST_MS);
986
1043
  };
1044
+ useLayoutEffect(() => {
1045
+ labelsRef.current = labels;
1046
+ }, [labels]);
987
1047
  useLayoutEffect(() => {
988
1048
  const c = new DiagramController({
989
1049
  viewport: viewport.current,
@@ -1000,21 +1060,22 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1000
1060
  ctl.current = null;
1001
1061
  };
1002
1062
  }, []);
1003
- useLayoutEffect(() => {
1004
- const el = stage.current?.querySelector("svg");
1005
- if (el) ctl.current?.mount(el, scoped, `${ownId.current}_`);
1006
- }, [scoped]);
1063
+ useLayoutEffect(() => ctl.current?.show(scoped, `${ownId}_`), [scoped, ownId]);
1007
1064
  useEffect(() => {
1008
1065
  const d = dialog.current;
1009
1066
  if (!d.open) d.showModal();
1010
1067
  if (locks++ === 0) document.documentElement.classList.add(LOCK_CLASS);
1011
1068
  viewport.current?.focus({ preventScroll: true });
1012
- const sync = () => setFullscreen(document.fullscreenElement === shell.current);
1069
+ const sync = () => {
1070
+ const full = document.fullscreenElement === shell.current;
1071
+ setFullscreen(full);
1072
+ document.documentElement.classList.toggle(FULLSCREEN_CLASS, full);
1073
+ };
1013
1074
  document.addEventListener("fullscreenchange", sync);
1014
1075
  return () => {
1015
1076
  document.removeEventListener("fullscreenchange", sync);
1016
1077
  clearTimeout(toastTimer.current);
1017
- if (--locks === 0) document.documentElement.classList.remove(LOCK_CLASS);
1078
+ if (--locks === 0) document.documentElement.classList.remove(LOCK_CLASS, FULLSCREEN_CLASS);
1018
1079
  if (document.fullscreenElement && d.contains(document.fullscreenElement)) void document.exitFullscreen().catch(() => {
1019
1080
  });
1020
1081
  };
@@ -1112,7 +1173,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1112
1173
  /* @__PURE__ */ jsx("button", { type: "button", className: "hv-btn", "aria-label": labels.close, title: `${labels.close} (Esc)`, onClick: () => dialog.current?.close(), children: /* @__PURE__ */ jsx(Glyph, { d: ICONS.close }) })
1113
1174
  ] })
1114
1175
  ] }),
1115
- /* @__PURE__ */ jsx("div", { className: "hv-view", ref: viewport, tabIndex: -1, role: "group", "aria-label": title, "aria-describedby": helpId, children: /* @__PURE__ */ jsx("div", { className: "hv-stage", ref: stage, dangerouslySetInnerHTML: html }) }),
1176
+ /* @__PURE__ */ jsx("div", { className: "hv-view", ref: viewport, tabIndex: -1, role: "group", "aria-label": title, "aria-describedby": helpId, children: /* @__PURE__ */ jsx("div", { className: "hv-stage", ref: stage }) }),
1116
1177
  /* @__PURE__ */ jsx("canvas", { className: "hv-mini", ref: minimap, width: 176, height: 120, hidden: !ui.minimap, "aria-hidden": "true" }),
1117
1178
  /* @__PURE__ */ jsxs("div", { className: "hv-foot", children: [
1118
1179
  ui.pinned ? /* @__PURE__ */ jsxs("ul", { className: "hv-legend", "aria-hidden": "true", children: [
@@ -1121,7 +1182,7 @@ function DiagramViewer({ svg, svgId, source, title, labels, onClose }) {
1121
1182
  /* @__PURE__ */ jsx("li", { className: "hv-down", children: labels.legendDownstream })
1122
1183
  ] }) : null,
1123
1184
  /* @__PURE__ */ jsx("p", { className: "hv-hint", id: helpId, children: labels.hint }),
1124
- /* @__PURE__ */ jsx("output", { className: "hv-toast", role: "status", children: toast })
1185
+ /* @__PURE__ */ jsx("output", { className: "hv-toast", children: toast })
1125
1186
  ] })
1126
1187
  ] })
1127
1188
  }
@@ -1,7 +1,7 @@
1
1
  import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
- import { h as ResolvedArticle, L as ListItem } from './types-ByodIyEv.cjs';
2
+ import { j as ResolvedArticle, L as ListItem } from './types-3F0wqD-o.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;
@@ -11,6 +11,9 @@ interface LinkProps {
11
11
  interface ImageProps {
12
12
  src?: string;
13
13
  alt?: string;
14
+ /** Intrinsic pixel size when hyle knows it; pass both to the host image so the page reserves its box. */
15
+ width?: number;
16
+ height?: number;
14
17
  [prop: string]: unknown;
15
18
  }
16
19
  interface CodeBlockProps {
@@ -23,7 +26,7 @@ interface CodeBlockProps {
23
26
  interface MermaidProps {
24
27
  /** The sandboxed document hyle produced for the diagram. Render it only inside an iframe with `sandbox="allow-scripts"`. */
25
28
  srcDoc: string;
26
- /** The diagram text, extracted from `srcDoc` (at most 20,000 characters); undefined when it could not be extracted. */
29
+ /** The diagram text, extracted from `srcDoc`; undefined when it could not be extracted. */
27
30
  source: string | undefined;
28
31
  title: string;
29
32
  }
@@ -155,9 +158,11 @@ interface HyleListViewProps extends PageBaseProps {
155
158
  readonly headingLevel?: EmbedHeading | undefined;
156
159
  /** Where "View all" goes (a URL in the host's space); omit to hide it. */
157
160
  readonly moreHref?: string | undefined;
161
+ /** Where "Older posts" goes (built from the list's `next_cursor`); omit to hide it. */
162
+ readonly olderHref?: string | undefined;
158
163
  }
159
- /** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
160
- declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
164
+ /** 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;
161
166
  interface HyleArticleViewProps extends PageBaseProps {
162
167
  readonly article: ResolvedArticle;
163
168
  /**
@@ -1,7 +1,7 @@
1
1
  import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
2
- import { h as ResolvedArticle, L as ListItem } from './types-ByodIyEv.js';
2
+ import { j as ResolvedArticle, L as ListItem } from './types-3F0wqD-o.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;
@@ -11,6 +11,9 @@ interface LinkProps {
11
11
  interface ImageProps {
12
12
  src?: string;
13
13
  alt?: string;
14
+ /** Intrinsic pixel size when hyle knows it; pass both to the host image so the page reserves its box. */
15
+ width?: number;
16
+ height?: number;
14
17
  [prop: string]: unknown;
15
18
  }
16
19
  interface CodeBlockProps {
@@ -23,7 +26,7 @@ interface CodeBlockProps {
23
26
  interface MermaidProps {
24
27
  /** The sandboxed document hyle produced for the diagram. Render it only inside an iframe with `sandbox="allow-scripts"`. */
25
28
  srcDoc: string;
26
- /** The diagram text, extracted from `srcDoc` (at most 20,000 characters); undefined when it could not be extracted. */
29
+ /** The diagram text, extracted from `srcDoc`; undefined when it could not be extracted. */
27
30
  source: string | undefined;
28
31
  title: string;
29
32
  }
@@ -155,9 +158,11 @@ interface HyleListViewProps extends PageBaseProps {
155
158
  readonly headingLevel?: EmbedHeading | undefined;
156
159
  /** Where "View all" goes (a URL in the host's space); omit to hide it. */
157
160
  readonly moreHref?: string | undefined;
161
+ /** Where "Older posts" goes (built from the list's `next_cursor`); omit to hide it. */
162
+ readonly olderHref?: string | undefined;
158
163
  }
159
- /** Items link to `toHref(canonical_path)`: plain anchors in a flat list, newest first as hyle sent them, no grouping and no pagination. */
160
- declare function HyleListView({ items, layout, title, headingLevel, moreHref, ...base }: HyleListViewProps): ReactElement | null;
164
+ /** 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;
161
166
  interface HyleArticleViewProps extends PageBaseProps {
162
167
  readonly article: ResolvedArticle;
163
168
  /**
@@ -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
+ };