@pi-outpost/embed 0.45.0 → 0.47.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.
@@ -16510,8 +16510,15 @@ function Ih(e, t, n = {}) {
16510
16510
  }));
16511
16511
  break;
16512
16512
  case "image": {
16513
+ if (Kh(i.url)) {
16514
+ r.push(new Os({
16515
+ children: [Fh(qh(i.url, i.alt), n)],
16516
+ link: i.url
16517
+ }));
16518
+ break;
16519
+ }
16513
16520
  let e = t.get(i);
16514
- e === void 0 ? r.push(Fh(i.alt ?? i.url, n)) : r.push(Yh(e, i.alt));
16521
+ e === void 0 ? r.push(Fh(i.alt ?? i.url, n)) : r.push(Zh(e, i.alt));
16515
16522
  break;
16516
16523
  }
16517
16524
  case "inlineMath":
@@ -16587,11 +16594,21 @@ async function Gh(e, t) {
16587
16594
  } catch {}
16588
16595
  return n;
16589
16596
  }
16590
- async function Kh(e, t) {
16597
+ function Kh(e) {
16598
+ return !/^[a-z][a-z0-9+.-]*:|^\/\//i.test(e) && /\.(drawio|dio)$/i.test(e.split(/[?#]/)[0]);
16599
+ }
16600
+ function qh(e, t) {
16601
+ let n = e.split(/[?#]/)[0].replace(/^\.\//, "");
16602
+ try {
16603
+ n = decodeURIComponent(n);
16604
+ } catch {}
16605
+ return t && t.trim() !== "" ? `${t.trim()} (draw.io diagram: ${n})` : `draw.io diagram: ${n}`;
16606
+ }
16607
+ async function Jh(e, t) {
16591
16608
  let n = /* @__PURE__ */ new Map(), { imageKey: r, loadImage: i } = t;
16592
16609
  if (r === void 0 || i === void 0) return n;
16593
16610
  let a = [], o = (e) => {
16594
- e.type === "image" && a.push(e);
16611
+ e.type === "image" && !Kh(e.url) && a.push(e);
16595
16612
  for (let t of e.children ?? []) o(t);
16596
16613
  };
16597
16614
  o(e);
@@ -16605,7 +16622,7 @@ async function Kh(e, t) {
16605
16622
  }
16606
16623
  return n;
16607
16624
  }
16608
- function qh(e) {
16625
+ function Yh(e) {
16609
16626
  return new Pa({
16610
16627
  type: "svg",
16611
16628
  data: new TextEncoder().encode(e.svg),
@@ -16616,28 +16633,28 @@ function qh(e) {
16616
16633
  transformation: Uh(e.width, e.height)
16617
16634
  });
16618
16635
  }
16619
- function Jh(e) {
16636
+ function Xh(e) {
16620
16637
  return new Q({
16621
16638
  alignment: un.CENTER,
16622
- children: [qh(e)]
16639
+ children: [Yh(e)]
16623
16640
  });
16624
16641
  }
16625
- function Yh(e, t) {
16626
- return e.kind === "vector" ? qh(e.image) : new Pa({
16642
+ function Zh(e, t) {
16643
+ return e.kind === "vector" ? Yh(e.image) : new Pa({
16627
16644
  type: e.type,
16628
16645
  data: e.bytes,
16629
16646
  transformation: Uh(e.width, e.height),
16630
- ...Xh(t)
16647
+ ...Qh(t)
16631
16648
  });
16632
16649
  }
16633
- function Xh(e) {
16650
+ function Qh(e) {
16634
16651
  let t = e?.trim() ?? "";
16635
16652
  return t === "" ? {} : { altText: {
16636
16653
  name: "Picture",
16637
16654
  description: t
16638
16655
  } };
16639
16656
  }
16640
- function Zh(e) {
16657
+ function $h(e) {
16641
16658
  return e === 0 ? {} : {
16642
16659
  indent: { left: Mh * e },
16643
16660
  border: { left: {
@@ -16648,22 +16665,22 @@ function Zh(e) {
16648
16665
  } }
16649
16666
  };
16650
16667
  }
16651
- function Qh(e, t, n = 0) {
16668
+ function eg(e, t, n = 0) {
16652
16669
  let r = e.ordered === !0, i = r ? t.instance++ : 0, a = [];
16653
16670
  for (let o of e.children) {
16654
16671
  let e = !0;
16655
- for (let s of o.children) s.type === "list" ? a.push(...Qh(s, t, n + 1)) : s.type === "paragraph" ? (a.push(new Q({
16672
+ for (let s of o.children) s.type === "list" ? a.push(...eg(s, t, n + 1)) : s.type === "paragraph" ? (a.push(new Q({
16656
16673
  children: Ih(s.children, t.images),
16657
16674
  ...e ? r ? { numbering: {
16658
16675
  reference: Nh,
16659
16676
  level: n,
16660
16677
  instance: i
16661
16678
  } } : { bullet: { level: n } } : { indent: { left: Mh * (n + 1) } }
16662
- })), e = !1) : a.push(...tg([s], t));
16679
+ })), e = !1) : a.push(...rg([s], t));
16663
16680
  }
16664
16681
  return a;
16665
16682
  }
16666
- function $h(e, t) {
16683
+ function tg(e, t) {
16667
16684
  return new tu({
16668
16685
  rows: e.children.map((e, n) => new eu({
16669
16686
  tableHeader: n === 0,
@@ -16675,7 +16692,7 @@ function $h(e, t) {
16675
16692
  }
16676
16693
  });
16677
16694
  }
16678
- function eg() {
16695
+ function ng() {
16679
16696
  return new Q({
16680
16697
  children: [],
16681
16698
  border: { bottom: {
@@ -16686,7 +16703,7 @@ function eg() {
16686
16703
  } }
16687
16704
  });
16688
16705
  }
16689
- function tg(e, t) {
16706
+ function rg(e, t) {
16690
16707
  let n = [];
16691
16708
  for (let r of e) switch (r.type) {
16692
16709
  case "heading":
@@ -16695,28 +16712,28 @@ function tg(e, t) {
16695
16712
  case "paragraph":
16696
16713
  n.push(new Q({
16697
16714
  children: Ih(r.children, t.images),
16698
- ...Zh(t.quoteDepth)
16715
+ ...$h(t.quoteDepth)
16699
16716
  }));
16700
16717
  break;
16701
16718
  case "list":
16702
- n.push(...Qh(r, t));
16719
+ n.push(...eg(r, t));
16703
16720
  break;
16704
16721
  case "table":
16705
- n.push($h(r, t.images));
16722
+ n.push(tg(r, t.images));
16706
16723
  break;
16707
16724
  case "code": {
16708
16725
  let e = t.diagrams.get(r);
16709
- e === void 0 ? n.push(...Vh(r)) : n.push(Jh(e));
16726
+ e === void 0 ? n.push(...Vh(r)) : n.push(Xh(e));
16710
16727
  break;
16711
16728
  }
16712
16729
  case "blockquote":
16713
- n.push(...tg(r.children, {
16730
+ n.push(...rg(r.children, {
16714
16731
  ...t,
16715
16732
  quoteDepth: t.quoteDepth + 1
16716
16733
  }));
16717
16734
  break;
16718
16735
  case "thematicBreak":
16719
- n.push(eg());
16736
+ n.push(ng());
16720
16737
  break;
16721
16738
  case "math":
16722
16739
  n.push(new Q({
@@ -16732,9 +16749,9 @@ function tg(e, t) {
16732
16749
  }
16733
16750
  return n;
16734
16751
  }
16735
- async function ng(e, t = {}) {
16736
- let n = Ph(e), r = await Gh(n, t.renderDiagram), i = await Kh(n, t);
16737
- return tg(n.children, {
16752
+ async function ig(e, t = {}) {
16753
+ let n = Ph(e), r = await Gh(n, t.renderDiagram), i = await Jh(n, t);
16754
+ return rg(n.children, {
16738
16755
  instance: 0,
16739
16756
  quoteDepth: 0,
16740
16757
  diagrams: r,
@@ -16743,14 +16760,14 @@ async function ng(e, t = {}) {
16743
16760
  }
16744
16761
  //#endregion
16745
16762
  //#region ../shared/src/docx/document.ts
16746
- function rg(e) {
16763
+ function ag(e) {
16747
16764
  return new vf({
16748
- styles: { default: ig() },
16749
- numbering: { config: [ag()] },
16765
+ styles: { default: og() },
16766
+ numbering: { config: [sg()] },
16750
16767
  sections: [{ children: e }]
16751
16768
  });
16752
16769
  }
16753
- function ig() {
16770
+ function og() {
16754
16771
  let e = (e) => ({ paragraph: { outlineLevel: e } });
16755
16772
  return {
16756
16773
  heading1: e(0),
@@ -16761,7 +16778,7 @@ function ig() {
16761
16778
  heading6: e(5)
16762
16779
  };
16763
16780
  }
16764
- function ag() {
16781
+ function sg() {
16765
16782
  return {
16766
16783
  reference: Nh,
16767
16784
  levels: [
@@ -16784,14 +16801,14 @@ function ag() {
16784
16801
  }
16785
16802
  //#endregion
16786
16803
  //#region ../shared/src/docx/svgSize.ts
16787
- function og(e) {
16804
+ function cg(e) {
16788
16805
  let t = /viewBox="\s*[\d.-]+[\s,]+[\d.-]+[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e), n = t ? Number(t[1]) : NaN, r = t ? Number(t[2]) : NaN;
16789
16806
  return !Number.isFinite(n) || !Number.isFinite(r) || n <= 0 || r <= 0 ? null : {
16790
16807
  width: n,
16791
16808
  height: r
16792
16809
  };
16793
16810
  }
16794
- function sg(e, t, n) {
16811
+ function lg(e, t, n) {
16795
16812
  let r = /^[\s\S]*?<svg\b[^>]*>/.exec(e);
16796
16813
  return r === null ? e : r[0].replace(/\swidth="[^"]*"/, "").replace(/\sheight="[^"]*"/, "").replace(/\sstyle="[^"]*"/, (e) => {
16797
16814
  let t = e.replace(/max-width:[^;"]*;?/, "");
@@ -16800,24 +16817,24 @@ function sg(e, t, n) {
16800
16817
  }
16801
16818
  //#endregion
16802
16819
  //#region ../ui/src/export/mermaidToImage.ts
16803
- var cg = /* @__PURE__ */ e({
16804
- DiagramError: () => lg,
16805
- inlineStyles: () => fg,
16806
- rasterise: () => hg,
16807
- renderDiagram: () => pg,
16808
- svgDimensions: () => ug,
16809
- withExplicitSize: () => sg
16810
- }), lg = class extends Error {
16820
+ var ug = /* @__PURE__ */ e({
16821
+ DiagramError: () => dg,
16822
+ inlineStyles: () => mg,
16823
+ rasterise: () => _g,
16824
+ renderDiagram: () => hg,
16825
+ svgDimensions: () => fg,
16826
+ withExplicitSize: () => lg
16827
+ }), dg = class extends Error {
16811
16828
  constructor(e) {
16812
16829
  super(e), this.name = "DiagramError";
16813
16830
  }
16814
16831
  };
16815
- function ug(e) {
16816
- let t = og(e);
16817
- if (t === null) throw new lg("diagram has no usable viewBox");
16832
+ function fg(e) {
16833
+ let t = cg(e);
16834
+ if (t === null) throw new dg("diagram has no usable viewBox");
16818
16835
  return t;
16819
16836
  }
16820
- var dg = [
16837
+ var pg = [
16821
16838
  "fill",
16822
16839
  "fill-opacity",
16823
16840
  "stroke",
@@ -16834,7 +16851,7 @@ var dg = [
16834
16851
  "text-anchor",
16835
16852
  "dominant-baseline"
16836
16853
  ];
16837
- function fg(e) {
16854
+ function mg(e) {
16838
16855
  let t = document.createElement("div");
16839
16856
  t.setAttribute("style", "position:absolute;left:-10000px;top:0;width:0;height:0;overflow:hidden"), t.innerHTML = e;
16840
16857
  let n = t.querySelector("svg");
@@ -16843,7 +16860,7 @@ function fg(e) {
16843
16860
  try {
16844
16861
  let e = [n, ...n.querySelectorAll("*")].filter((e) => e.tagName.toLowerCase() !== "style").map((e) => {
16845
16862
  let t = window.getComputedStyle(e), n = [];
16846
- for (let e of dg) {
16863
+ for (let e of pg) {
16847
16864
  let r = t.getPropertyValue(e);
16848
16865
  r !== "" && n.push([e, r]);
16849
16866
  }
@@ -16862,7 +16879,7 @@ function fg(e) {
16862
16879
  t.remove();
16863
16880
  }
16864
16881
  }
16865
- async function pg(e, t) {
16882
+ async function hg(e, t) {
16866
16883
  return r(async () => {
16867
16884
  let n = (await import("./mermaid.core-C8dp1dnD.js").then((e) => e.t)).default, r;
16868
16885
  try {
@@ -16876,7 +16893,7 @@ async function pg(e, t) {
16876
16893
  htmlLabels: !1
16877
16894
  }), {svg: r} = await n.render(t, e);
16878
16895
  } catch (e) {
16879
- throw new lg(`mermaid could not render the diagram: ${String(e)}`);
16896
+ throw new dg(`mermaid could not render the diagram: ${String(e)}`);
16880
16897
  } finally {
16881
16898
  n.initialize({
16882
16899
  startOnLoad: !1,
@@ -16885,39 +16902,39 @@ async function pg(e, t) {
16885
16902
  suppressErrorRendering: !0
16886
16903
  });
16887
16904
  }
16888
- let { width: i, height: a } = ug(r), o = sg(r, i, a), s = await hg(o, i, a);
16905
+ let { width: i, height: a } = fg(r), o = lg(r, i, a), s = await _g(o, i, a);
16889
16906
  return {
16890
- svg: fg(o),
16907
+ svg: mg(o),
16891
16908
  png: s,
16892
16909
  width: i,
16893
16910
  height: a
16894
16911
  };
16895
16912
  });
16896
16913
  }
16897
- var mg = 2;
16898
- async function hg(e, t, n) {
16914
+ var gg = 2;
16915
+ async function _g(e, t, n) {
16899
16916
  let r = document.createElement("canvas");
16900
- r.width = Math.max(1, Math.round(t * mg)), r.height = Math.max(1, Math.round(n * mg));
16917
+ r.width = Math.max(1, Math.round(t * gg)), r.height = Math.max(1, Math.round(n * gg));
16901
16918
  let i = r.getContext("2d");
16902
- if (i === null) throw new lg("no 2d canvas context for the fallback image");
16919
+ if (i === null) throw new dg("no 2d canvas context for the fallback image");
16903
16920
  let a = URL.createObjectURL(new Blob([e], { type: "image/svg+xml;charset=utf-8" }));
16904
16921
  try {
16905
- let e = await gg(a);
16906
- return i.fillStyle = "#ffffff", i.fillRect(0, 0, r.width, r.height), i.drawImage(e, 0, 0, r.width, r.height), await _g(r);
16922
+ let e = await vg(a);
16923
+ return i.fillStyle = "#ffffff", i.fillRect(0, 0, r.width, r.height), i.drawImage(e, 0, 0, r.width, r.height), await yg(r);
16907
16924
  } finally {
16908
16925
  URL.revokeObjectURL(a);
16909
16926
  }
16910
16927
  }
16911
- function gg(e) {
16928
+ function vg(e) {
16912
16929
  return new Promise((t, n) => {
16913
16930
  let r = new Image();
16914
- r.onload = () => t(r), r.onerror = () => n(new lg("the browser would not draw the diagram")), r.src = e;
16931
+ r.onload = () => t(r), r.onerror = () => n(new dg("the browser would not draw the diagram")), r.src = e;
16915
16932
  });
16916
16933
  }
16917
- async function _g(e) {
16934
+ async function yg(e) {
16918
16935
  let t = await new Promise((t) => e.toBlob(t, "image/png"));
16919
- if (t === null) throw new lg("the canvas produced no image");
16936
+ if (t === null) throw new dg("the canvas produced no image");
16920
16937
  return new Uint8Array(await t.arrayBuffer());
16921
16938
  }
16922
16939
  //#endregion
16923
- export { pg as a, rg as c, Vf as d, Q as f, hg as i, ng as l, fg as n, ug as o, wr as p, cg as r, sg as s, lg as t, Ah as u };
16940
+ export { hg as a, ag as c, ig as d, Ah as f, wr as h, _g as i, qh as l, Q as m, mg as n, fg as o, Vf as p, ug as r, lg as s, dg as t, Kh as u };