@blueprint-chart/lib 1.8.1 → 1.8.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/dist/charts/number-parse.d.ts +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -101
- package/dist/lib/lib.iife.js +8 -8
- package/dist/node-backend/index.js +98 -90
- package/dist/{render-bpc-Bp2OTJmu.js → render-bpc-By-iMMKD.js} +144 -136
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
|
@@ -6696,14 +6696,22 @@ function Ro(e, t) {
|
|
|
6696
6696
|
};
|
|
6697
6697
|
}
|
|
6698
6698
|
//#endregion
|
|
6699
|
-
//#region src/charts/
|
|
6699
|
+
//#region src/charts/number-parse.ts
|
|
6700
6700
|
function zo(e) {
|
|
6701
|
-
|
|
6701
|
+
return e.replace(/(\d)\s+(?=\d)/g, "$1");
|
|
6702
|
+
}
|
|
6703
|
+
function Bo(e) {
|
|
6704
|
+
return zo(e.replace(/^"(.*)"$/, "$1")).replace(/%$/, "").trim();
|
|
6705
|
+
}
|
|
6706
|
+
function Vo(e) {
|
|
6707
|
+
let t = Bo(e?.trim() ?? "");
|
|
6702
6708
|
if (!t) return;
|
|
6703
|
-
let n = Number
|
|
6709
|
+
let n = Number(t);
|
|
6704
6710
|
return Number.isFinite(n) ? n : void 0;
|
|
6705
6711
|
}
|
|
6706
|
-
|
|
6712
|
+
//#endregion
|
|
6713
|
+
//#region src/charts/chart-helpers.ts
|
|
6714
|
+
function Ho(e) {
|
|
6707
6715
|
let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = [], r = [], i = t[0]?.match(/^series\s*=\s*(.+)$/);
|
|
6708
6716
|
if (i) {
|
|
6709
6717
|
let e = i[1].trim(), r = e.includes("\",\"") ? e.split(",").map((e) => e.trim().replace(/^"|"$/g, "")) : e.replace(/^"|"$/g, "").split(",").map((e) => e.trim()), a = r.map(() => []);
|
|
@@ -6712,7 +6720,7 @@ function Bo(e) {
|
|
|
6712
6720
|
if (o) {
|
|
6713
6721
|
n.push(o[1]);
|
|
6714
6722
|
let e = o[2].split(",");
|
|
6715
|
-
for (let t = 0; t < r.length; t++) a[t].push(
|
|
6723
|
+
for (let t = 0; t < r.length; t++) a[t].push(Vo(e[t]));
|
|
6716
6724
|
}
|
|
6717
6725
|
}
|
|
6718
6726
|
let o = r.map((e, t) => ({
|
|
@@ -6727,36 +6735,36 @@ function Bo(e) {
|
|
|
6727
6735
|
}
|
|
6728
6736
|
for (let e of t) {
|
|
6729
6737
|
let t = e.match(/^"([^"]+)"\s*=\s*(.+)$/);
|
|
6730
|
-
t && (n.push(t[1]), r.push(
|
|
6738
|
+
t && (n.push(t[1]), r.push(Vo(t[2])));
|
|
6731
6739
|
}
|
|
6732
6740
|
return {
|
|
6733
6741
|
labels: n,
|
|
6734
6742
|
values: r
|
|
6735
6743
|
};
|
|
6736
6744
|
}
|
|
6737
|
-
function
|
|
6745
|
+
function Uo(e, t) {
|
|
6738
6746
|
let n = {}, r = te(e.colorPalette);
|
|
6739
6747
|
return r ? n.colors = r : e.colors && e.colors.length > 0 && (n.colors = e.colors), e.autoContrast && t && n.colors && (n.colors = Ae(n.colors, t)), e.allowDarkMode !== void 0 && (n.allowDarkMode = e.allowDarkMode), n;
|
|
6740
6748
|
}
|
|
6741
|
-
function
|
|
6749
|
+
function Wo(e) {
|
|
6742
6750
|
let t = {};
|
|
6743
6751
|
return e.legend !== void 0 && (t.legend = e.legend), e.legendPosition !== void 0 && (t.legendPosition = e.legendPosition), e.legendAnchor !== void 0 && (t.legendAnchor = e.legendAnchor), e.directLabelling !== void 0 && (t.directLabelling = e.directLabelling), e.directLabelAnchor !== void 0 && (t.directLabelAnchor = e.directLabelAnchor), t;
|
|
6744
6752
|
}
|
|
6745
|
-
function
|
|
6753
|
+
function Go(e) {
|
|
6746
6754
|
if (!(e.showVerticalTicks !== void 0 || e.verticalGridStyle !== void 0 || e.verticalNumberFormat !== void 0 || e.showVerticalAxis !== void 0 || e.verticalAxisDirection !== void 0 || e.verticalScaleType !== void 0 || e.verticalLabelPosition !== void 0 || e.verticalRangeMin || e.verticalRangeMax)) return {};
|
|
6747
6755
|
let t = {};
|
|
6748
6756
|
e.showVerticalTicks !== void 0 && (t.showTicks = e.showVerticalTicks), e.verticalAxisDirection !== void 0 && (t.direction = e.verticalAxisDirection), e.verticalGridStyle !== void 0 && (t.gridStyle = e.verticalGridStyle), e.verticalNumberFormat !== void 0 && (t.numberFormat = e.verticalNumberFormat), e.showVerticalAxis !== void 0 && (t.showAxis = e.showVerticalAxis), e.verticalScaleType !== void 0 && (t.scaleType = e.verticalScaleType), e.verticalLabelPosition !== void 0 && (t.labelPosition = e.verticalLabelPosition);
|
|
6749
6757
|
let n = ce(e.verticalRangeMin ?? ""), r = ce(e.verticalRangeMax ?? "");
|
|
6750
6758
|
return (n !== void 0 || r !== void 0) && (t.range = {}, n !== void 0 && (t.range.min = n), r !== void 0 && (t.range.max = r)), { verticalAxis: t };
|
|
6751
6759
|
}
|
|
6752
|
-
function
|
|
6760
|
+
function Ko(e) {
|
|
6753
6761
|
if (!(e.showHorizontalTicks !== void 0 || e.horizontalGridStyle !== void 0 || e.horizontalNumberFormat !== void 0 || e.showHorizontalAxis !== void 0 || e.horizontalScaleType !== void 0 || e.horizontalLabelPosition !== void 0 || e.horizontalLabelRotation !== void 0 || e.horizontalRangeMin || e.horizontalRangeMax)) return {};
|
|
6754
6762
|
let t = {};
|
|
6755
6763
|
e.showHorizontalTicks !== void 0 && (t.showTicks = e.showHorizontalTicks), e.horizontalGridStyle !== void 0 && (t.gridStyle = e.horizontalGridStyle), e.horizontalNumberFormat !== void 0 && (t.numberFormat = e.horizontalNumberFormat), e.showHorizontalAxis !== void 0 && (t.showAxis = e.showHorizontalAxis), e.horizontalScaleType !== void 0 && (t.scaleType = e.horizontalScaleType), e.horizontalLabelPosition !== void 0 && (t.labelPosition = e.horizontalLabelPosition), e.horizontalLabelRotation !== void 0 && (t.labelRotation = e.horizontalLabelRotation);
|
|
6756
6764
|
let n = ce(e.horizontalRangeMin ?? ""), r = ce(e.horizontalRangeMax ?? "");
|
|
6757
6765
|
return (n !== void 0 || r !== void 0) && (t.range = {}, n !== void 0 && (t.range.min = n), r !== void 0 && (t.range.max = r)), { horizontalAxis: t };
|
|
6758
6766
|
}
|
|
6759
|
-
function
|
|
6767
|
+
function qo(e) {
|
|
6760
6768
|
return e.lineSymbols ? { lineSymbols: {
|
|
6761
6769
|
symbol: e.lineSymbolShape ?? R.Circle,
|
|
6762
6770
|
showOn: e.lineSymbolShowOn ?? z.FirstLast,
|
|
@@ -6765,13 +6773,13 @@ function Go(e) {
|
|
|
6765
6773
|
opacity: parseFloat(e.lineSymbolOpacity ?? "1") || 1
|
|
6766
6774
|
} } : {};
|
|
6767
6775
|
}
|
|
6768
|
-
function
|
|
6776
|
+
function Jo(e, t) {
|
|
6769
6777
|
let n = {
|
|
6770
|
-
...
|
|
6771
|
-
...Ho(e),
|
|
6772
|
-
...Uo(e),
|
|
6778
|
+
...Uo(e, t),
|
|
6773
6779
|
...Wo(e),
|
|
6774
|
-
...Go(e)
|
|
6780
|
+
...Go(e),
|
|
6781
|
+
...Ko(e),
|
|
6782
|
+
...qo(e)
|
|
6775
6783
|
};
|
|
6776
6784
|
e.interpolation !== void 0 && (n.interpolation = e.interpolation), e.valueLabels !== void 0 && (n.valueLabels = e.valueLabels), e.valueLabelPosition !== void 0 && (n.valueLabelPosition = e.valueLabelPosition), e.tooltips !== void 0 && (n.tooltips = e.tooltips), e.crosshair !== void 0 && (n.crosshair = e.crosshair), e.crosshairDirection && (n.crosshairDirection = e.crosshairDirection), e.crosshairStyle && (n.crosshairStyle = e.crosshairStyle), e.crosshairColor && (n.crosshairColor = e.crosshairColor), e.displayAsPercentage !== void 0 && (n.displayAsPercentage = e.displayAsPercentage), e.showTotal !== void 0 && (n.showTotal = e.showTotal), e.showLabels !== void 0 && (n.showLabels = e.showLabels), e.showValues !== void 0 && (n.showValues = e.showValues), e.swapLabelValue !== void 0 && (n.swapLabelValue = e.swapLabelValue);
|
|
6777
6785
|
let r = parseInt(e.sliceMax ?? "", 10);
|
|
@@ -6785,13 +6793,13 @@ function Ko(e, t) {
|
|
|
6785
6793
|
}
|
|
6786
6794
|
//#endregion
|
|
6787
6795
|
//#region src/render/resolve-scene.ts
|
|
6788
|
-
var
|
|
6789
|
-
function
|
|
6796
|
+
var Yo = /* @__PURE__ */ new Set();
|
|
6797
|
+
function Xo(e, t, n) {
|
|
6790
6798
|
let r = t;
|
|
6791
|
-
for (let t of e) t.transformType === "sort" ? r = H.Total :
|
|
6799
|
+
for (let t of e) t.transformType === "sort" ? r = H.Total : Yo.has(t.transformType) || (Yo.add(t.transformType), console.warn(`[blueprint-chart] Unknown transform "${t.transformType}" in ${n}; ignored.`));
|
|
6792
6800
|
return r;
|
|
6793
6801
|
}
|
|
6794
|
-
function
|
|
6802
|
+
function Zo() {
|
|
6795
6803
|
return {
|
|
6796
6804
|
properties: /* @__PURE__ */ new Map(),
|
|
6797
6805
|
chartTypeOptions: {},
|
|
@@ -6802,8 +6810,8 @@ function Yo() {
|
|
|
6802
6810
|
transforms: []
|
|
6803
6811
|
};
|
|
6804
6812
|
}
|
|
6805
|
-
function
|
|
6806
|
-
let r =
|
|
6813
|
+
function Qo(e, t, n) {
|
|
6814
|
+
let r = Zo();
|
|
6807
6815
|
for (let i = 0; i <= t; i++) {
|
|
6808
6816
|
let a = e[i], o = So(a.properties), s = o.get("type");
|
|
6809
6817
|
s && (r.chartType = s);
|
|
@@ -6818,10 +6826,10 @@ function Xo(e, t, n) {
|
|
|
6818
6826
|
}
|
|
6819
6827
|
return r;
|
|
6820
6828
|
}
|
|
6821
|
-
function
|
|
6829
|
+
function $o(e, t, n) {
|
|
6822
6830
|
return n < e ? !1 : t === "always" || n <= e + (typeof t == "number" ? t : 0);
|
|
6823
6831
|
}
|
|
6824
|
-
function
|
|
6832
|
+
function es(e, t) {
|
|
6825
6833
|
let n = e.options ?? (e.properties ? Ro(e.chartType, Co(e.chartType, e.properties)) : {}), r = {
|
|
6826
6834
|
chartType: e.chartType,
|
|
6827
6835
|
data: e.data,
|
|
@@ -6840,7 +6848,7 @@ function Qo(e, t) {
|
|
|
6840
6848
|
theme: e.theme
|
|
6841
6849
|
};
|
|
6842
6850
|
if (t == null || !e.scenes || t < 0 || t >= e.scenes.length) return r;
|
|
6843
|
-
let i =
|
|
6851
|
+
let i = Qo(e.scenes, t, e.chartType), a = i.chartType ?? e.chartType, o = i.data ? Ho(To(i.data)) : r.data, s = Object.keys(i.chartTypeOptions).length > 0 ? Ro(a, {
|
|
6844
6852
|
...n,
|
|
6845
6853
|
...i.chartTypeOptions
|
|
6846
6854
|
}) : n, c = i.colorizes.length > 0 ? Ao(i.colorizes) : i.data ? [] : r.colorizes, l = t == null ? r.highlights : jo(i.highlights), u = i.areaFills.length > 0 ? Mo(i.areaFills) : r.areaFills, d = (e.annotations ?? []).map((e, t) => ({
|
|
@@ -6855,10 +6863,10 @@ function Qo(e, t) {
|
|
|
6855
6863
|
config: e
|
|
6856
6864
|
});
|
|
6857
6865
|
});
|
|
6858
|
-
let f = d.filter(({ anchor: e, config: n }) =>
|
|
6866
|
+
let f = d.filter(({ anchor: e, config: n }) => $o(e, n.repeat, t)).map(({ key: e, config: t }) => ({
|
|
6859
6867
|
...t,
|
|
6860
6868
|
key: e
|
|
6861
|
-
})), p = i.seriesOverrides.length > 0 ? Fo(i.seriesOverrides) : r.seriesOverrides, m =
|
|
6869
|
+
})), p = i.seriesOverrides.length > 0 ? Fo(i.seriesOverrides) : r.seriesOverrides, m = Xo(i.transforms, r.sortMode, `scene ${t}`), h = [
|
|
6862
6870
|
"title",
|
|
6863
6871
|
"description",
|
|
6864
6872
|
"source",
|
|
@@ -6890,52 +6898,52 @@ function Qo(e, t) {
|
|
|
6890
6898
|
}
|
|
6891
6899
|
//#endregion
|
|
6892
6900
|
//#region src/render/layout-constraints.ts
|
|
6893
|
-
var
|
|
6894
|
-
function
|
|
6895
|
-
let t =
|
|
6901
|
+
var ts = /* @__PURE__ */ new WeakMap();
|
|
6902
|
+
function ns(e) {
|
|
6903
|
+
let t = ts.get(e);
|
|
6896
6904
|
if (!(!t || t.size === 0)) {
|
|
6897
6905
|
for (let n of t) e.style[n] = "";
|
|
6898
6906
|
t.clear();
|
|
6899
6907
|
}
|
|
6900
6908
|
}
|
|
6901
|
-
function
|
|
6902
|
-
let n =
|
|
6903
|
-
n || (n = /* @__PURE__ */ new Set(),
|
|
6909
|
+
function rs(e, t) {
|
|
6910
|
+
let n = ts.get(e);
|
|
6911
|
+
n || (n = /* @__PURE__ */ new Set(), ts.set(e, n)), n.add(t);
|
|
6904
6912
|
}
|
|
6905
|
-
function
|
|
6906
|
-
if (
|
|
6913
|
+
function is(e, t, n) {
|
|
6914
|
+
if (ns(e), n.ignoreLayout || !t) return { constrained: !1 };
|
|
6907
6915
|
let r = So(t), i = r.get("heightMode"), a = r.get("aspectRatio"), o = r.get("fixedHeight"), s = !1;
|
|
6908
6916
|
if (i === "aspect-ratio" && a) {
|
|
6909
6917
|
let t = String(a).split(":").map(Number);
|
|
6910
|
-
t.length === 2 && t[0] > 0 && t[1] > 0 && (e.style.aspectRatio = `${t[0]} / ${t[1]}`, e.style.height = "auto",
|
|
6911
|
-
} else i === "fixed" && o && (e.style.height = `${o}px`,
|
|
6912
|
-
return s && (e.style.display = "flex", e.style.flexDirection = "column", e.style.overflow = "hidden",
|
|
6918
|
+
t.length === 2 && t[0] > 0 && t[1] > 0 && (e.style.aspectRatio = `${t[0]} / ${t[1]}`, e.style.height = "auto", rs(e, "aspectRatio"), rs(e, "height"), s = !0);
|
|
6919
|
+
} else i === "fixed" && o && (e.style.height = `${o}px`, rs(e, "height"), s = !0);
|
|
6920
|
+
return s && (e.style.display = "flex", e.style.flexDirection = "column", e.style.overflow = "hidden", rs(e, "display"), rs(e, "flexDirection"), rs(e, "overflow")), { constrained: s };
|
|
6913
6921
|
}
|
|
6914
6922
|
//#endregion
|
|
6915
6923
|
//#region src/render/cross-type-fade.ts
|
|
6916
|
-
var
|
|
6917
|
-
function
|
|
6924
|
+
var as = /* @__PURE__ */ new WeakMap();
|
|
6925
|
+
function os(e) {
|
|
6918
6926
|
e.querySelectorAll("[data-bc-fade-overlay]").forEach((e) => {
|
|
6919
6927
|
typeof e.getAnimations == "function" && e.getAnimations().forEach((e) => e.cancel()), e.remove();
|
|
6920
6928
|
});
|
|
6921
6929
|
}
|
|
6922
|
-
function
|
|
6930
|
+
function ss(e, t, n) {
|
|
6923
6931
|
if (!n) return null;
|
|
6924
|
-
let r =
|
|
6925
|
-
return !r || r === t ? null : (
|
|
6932
|
+
let r = as.get(e);
|
|
6933
|
+
return !r || r === t ? null : (os(e), et(e));
|
|
6926
6934
|
}
|
|
6927
|
-
function
|
|
6928
|
-
if (
|
|
6935
|
+
function cs(e, t, n) {
|
|
6936
|
+
if (as.set(e, t), n) {
|
|
6929
6937
|
let t = e.querySelector(".bc-frame .bc-frame-body");
|
|
6930
6938
|
t && $e(t), tt(e, n);
|
|
6931
6939
|
}
|
|
6932
6940
|
}
|
|
6933
|
-
function
|
|
6934
|
-
|
|
6941
|
+
function ls(e) {
|
|
6942
|
+
as.delete(e), os(e);
|
|
6935
6943
|
}
|
|
6936
6944
|
//#endregion
|
|
6937
6945
|
//#region src/render/post-render.ts
|
|
6938
|
-
function
|
|
6946
|
+
function us(e, t, n) {
|
|
6939
6947
|
let r = e.querySelector(".bc-frame");
|
|
6940
6948
|
if (!r) return;
|
|
6941
6949
|
let i = [];
|
|
@@ -6947,9 +6955,9 @@ function cs(e, t, n) {
|
|
|
6947
6955
|
}
|
|
6948
6956
|
//#endregion
|
|
6949
6957
|
//#region src/render/render-chart.ts
|
|
6950
|
-
function
|
|
6951
|
-
if (n.transition || (Nn(e).interrupt(), e.replaceChildren(),
|
|
6952
|
-
n.transition && (Nn(e).interrupt(), e.replaceChildren(),
|
|
6958
|
+
function ds(e, t, n = {}) {
|
|
6959
|
+
if (n.transition || (Nn(e).interrupt(), e.replaceChildren(), ls(e)), t.data.labels.length === 0) {
|
|
6960
|
+
n.transition && (Nn(e).interrupt(), e.replaceChildren(), ls(e));
|
|
6953
6961
|
return;
|
|
6954
6962
|
}
|
|
6955
6963
|
let r = t;
|
|
@@ -6961,11 +6969,11 @@ function ls(e, t, n = {}) {
|
|
|
6961
6969
|
}
|
|
6962
6970
|
r = e;
|
|
6963
6971
|
}
|
|
6964
|
-
let i =
|
|
6972
|
+
let i = is(e, r.properties, n), a = es(r, n.sceneIndex), o = Ji(a.chartType);
|
|
6965
6973
|
if (!o) return;
|
|
6966
|
-
let s =
|
|
6974
|
+
let s = ss(e, a.chartType, !!n.transition);
|
|
6967
6975
|
s && e.replaceChildren();
|
|
6968
|
-
let c = Te(e), l =
|
|
6976
|
+
let c = Te(e), l = Jo(a.options, c), u;
|
|
6969
6977
|
if (n.thumbnail) u = null;
|
|
6970
6978
|
else {
|
|
6971
6979
|
let e = a.frame?.padding ?? n.padding ?? "16px";
|
|
@@ -6988,20 +6996,20 @@ function ls(e, t, n = {}) {
|
|
|
6988
6996
|
}, !!n.transition), n.transition && d.commit({
|
|
6989
6997
|
duration: Qe(),
|
|
6990
6998
|
mode: n.transitionMode
|
|
6991
|
-
}),
|
|
6999
|
+
}), us(e, { theme: n.theme ?? a.theme }, i), cs(e, a.chartType, s);
|
|
6992
7000
|
}
|
|
6993
7001
|
//#endregion
|
|
6994
7002
|
//#region src/render/backends/jsdom-env.ts
|
|
6995
|
-
function
|
|
7003
|
+
function fs() {
|
|
6996
7004
|
let e = new u();
|
|
6997
7005
|
return e.on("jsdomError", (e) => {
|
|
6998
7006
|
e.message && e.message.startsWith("Not implemented") || console.error(e);
|
|
6999
7007
|
}), e;
|
|
7000
7008
|
}
|
|
7001
|
-
function
|
|
7009
|
+
function ps(e) {
|
|
7002
7010
|
let t = new l(`<!DOCTYPE html><html><body><div id="root" style="width:${e.width}px;height:${e.height}px"></div></body></html>`, {
|
|
7003
7011
|
pretendToBeVisual: !0,
|
|
7004
|
-
virtualConsole:
|
|
7012
|
+
virtualConsole: fs()
|
|
7005
7013
|
}), n = t.window.document.getElementById("root");
|
|
7006
7014
|
return {
|
|
7007
7015
|
window: t.window,
|
|
@@ -7024,29 +7032,29 @@ function ds(e) {
|
|
|
7024
7032
|
}
|
|
7025
7033
|
//#endregion
|
|
7026
7034
|
//#region src/render/backends/text-shim.ts
|
|
7027
|
-
var
|
|
7028
|
-
d.registerFromPath(h(
|
|
7029
|
-
var
|
|
7030
|
-
function
|
|
7031
|
-
return
|
|
7035
|
+
var ms = h(m(p(import.meta.url)), "fonts");
|
|
7036
|
+
d.registerFromPath(h(ms, "DejaVuSans.ttf"), "sans-serif"), d.registerFromPath(h(ms, "DejaVuSans-Bold.ttf"), "sans-serif");
|
|
7037
|
+
var hs = f(1, 1).getContext("2d");
|
|
7038
|
+
function gs(e, t, n, r) {
|
|
7039
|
+
return hs.font = `${r} ${t}px ${n}`, hs.measureText(e);
|
|
7032
7040
|
}
|
|
7033
|
-
function
|
|
7041
|
+
function _s(e) {
|
|
7034
7042
|
return {
|
|
7035
7043
|
fontSize: parseFloat(e.getAttribute("font-size") ?? "12") || 12,
|
|
7036
7044
|
fontFamily: e.getAttribute("font-family") ?? "sans-serif",
|
|
7037
7045
|
fontWeight: e.getAttribute("font-weight") ?? "normal"
|
|
7038
7046
|
};
|
|
7039
7047
|
}
|
|
7040
|
-
function
|
|
7048
|
+
function vs(e) {
|
|
7041
7049
|
let t = e.SVGElement?.prototype, n = function() {
|
|
7042
|
-
let { fontSize: e, fontFamily: t, fontWeight: n } =
|
|
7043
|
-
return
|
|
7050
|
+
let { fontSize: e, fontFamily: t, fontWeight: n } = _s(this);
|
|
7051
|
+
return gs(this.textContent ?? "", e, t, n).width;
|
|
7044
7052
|
}, r = function(e, t) {
|
|
7045
|
-
let n = (this.textContent ?? "").substring(e, e + t), { fontSize: r, fontFamily: i, fontWeight: a } =
|
|
7046
|
-
return
|
|
7053
|
+
let n = (this.textContent ?? "").substring(e, e + t), { fontSize: r, fontFamily: i, fontWeight: a } = _s(this);
|
|
7054
|
+
return gs(n, r, i, a).width;
|
|
7047
7055
|
}, i = function() {
|
|
7048
7056
|
if (this.tagName === "text") {
|
|
7049
|
-
let { fontSize: e, fontFamily: t, fontWeight: n } =
|
|
7057
|
+
let { fontSize: e, fontFamily: t, fontWeight: n } = _s(this), r = gs(this.textContent ?? "", e, t, n);
|
|
7050
7058
|
return {
|
|
7051
7059
|
x: 0,
|
|
7052
7060
|
y: -e,
|
|
@@ -7069,8 +7077,8 @@ function gs(e) {
|
|
|
7069
7077
|
}
|
|
7070
7078
|
//#endregion
|
|
7071
7079
|
//#region src/render/backends/rasterize.ts
|
|
7072
|
-
var
|
|
7073
|
-
async function
|
|
7080
|
+
var ys = h(m(p(import.meta.url)), "fonts");
|
|
7081
|
+
async function bs(e, t = {}) {
|
|
7074
7082
|
let n = t.width ? {
|
|
7075
7083
|
mode: "width",
|
|
7076
7084
|
value: t.width
|
|
@@ -7080,7 +7088,7 @@ async function vs(e, t = {}) {
|
|
|
7080
7088
|
} : { mode: "original" }, r = new g(e, {
|
|
7081
7089
|
fitTo: n,
|
|
7082
7090
|
font: {
|
|
7083
|
-
fontDirs: [
|
|
7091
|
+
fontDirs: [ys],
|
|
7084
7092
|
loadSystemFonts: !1,
|
|
7085
7093
|
defaultFontFamily: "DejaVu Sans"
|
|
7086
7094
|
}
|
|
@@ -7089,23 +7097,23 @@ async function vs(e, t = {}) {
|
|
|
7089
7097
|
}
|
|
7090
7098
|
//#endregion
|
|
7091
7099
|
//#region src/render/backends/node-backend.ts
|
|
7092
|
-
var
|
|
7100
|
+
var xs = [
|
|
7093
7101
|
"window",
|
|
7094
7102
|
"document",
|
|
7095
7103
|
"Element",
|
|
7096
7104
|
"getComputedStyle",
|
|
7097
7105
|
"requestAnimationFrame"
|
|
7098
|
-
],
|
|
7099
|
-
function
|
|
7106
|
+
], Ss = /* @__PURE__ */ new WeakMap();
|
|
7107
|
+
function Cs(e) {
|
|
7100
7108
|
return e.includes("xmlns=\"http://www.w3.org/2000/svg\"") ? e : e.replace(/^<svg(?=\s|>)/, "<svg xmlns=\"http://www.w3.org/2000/svg\"");
|
|
7101
7109
|
}
|
|
7102
|
-
function
|
|
7110
|
+
function ws() {
|
|
7103
7111
|
return {
|
|
7104
7112
|
kind: "node",
|
|
7105
7113
|
createContainer(t, n) {
|
|
7106
7114
|
let r;
|
|
7107
7115
|
try {
|
|
7108
|
-
r =
|
|
7116
|
+
r = ps({
|
|
7109
7117
|
width: t,
|
|
7110
7118
|
height: n
|
|
7111
7119
|
});
|
|
@@ -7118,37 +7126,37 @@ function Ss() {
|
|
|
7118
7126
|
serializeFrame: r.serializeFrame,
|
|
7119
7127
|
cleanup: r.cleanup
|
|
7120
7128
|
};
|
|
7121
|
-
return
|
|
7129
|
+
return Ss.set(r.container, i), {
|
|
7122
7130
|
container: r.container,
|
|
7123
7131
|
cleanup: () => {
|
|
7124
|
-
|
|
7132
|
+
Ss.delete(r.container), r.cleanup();
|
|
7125
7133
|
}
|
|
7126
7134
|
};
|
|
7127
7135
|
},
|
|
7128
7136
|
renderToContainer(e, t, n) {
|
|
7129
|
-
let r =
|
|
7137
|
+
let r = Ss.get(e);
|
|
7130
7138
|
if (!r) throw Error("node-backend: container was not created by this backend");
|
|
7131
|
-
|
|
7139
|
+
vs(r.window);
|
|
7132
7140
|
let i = r.window, a = globalThis, o = {};
|
|
7133
|
-
for (let e of
|
|
7141
|
+
for (let e of xs) o[e] = a[e], a[e] = i[e];
|
|
7134
7142
|
try {
|
|
7135
|
-
|
|
7143
|
+
ds(e, t, {
|
|
7136
7144
|
sceneIndex: n.sceneIndex,
|
|
7137
7145
|
thumbnail: n.thumbnail ?? !1,
|
|
7138
7146
|
transition: !1,
|
|
7139
7147
|
theme: n.theme
|
|
7140
7148
|
});
|
|
7141
7149
|
} finally {
|
|
7142
|
-
for (let e of
|
|
7150
|
+
for (let e of xs) a[e] = o[e];
|
|
7143
7151
|
}
|
|
7144
7152
|
},
|
|
7145
7153
|
serializeSvg(e) {
|
|
7146
|
-
let t =
|
|
7154
|
+
let t = Ss.get(e), n = t ? t.serializeSvg() : e.querySelector("svg")?.outerHTML ?? "";
|
|
7147
7155
|
if (!n) throw Error("node-backend: renderToContainer produced no SVG");
|
|
7148
|
-
return
|
|
7156
|
+
return Cs(n);
|
|
7149
7157
|
},
|
|
7150
7158
|
serializeFrame(e) {
|
|
7151
|
-
let t =
|
|
7159
|
+
let t = Ss.get(e);
|
|
7152
7160
|
if (t) {
|
|
7153
7161
|
let n = t.serializeFrame();
|
|
7154
7162
|
return n === void 0 ? this.serializeSvg(e) : n;
|
|
@@ -7161,7 +7169,7 @@ function Ss() {
|
|
|
7161
7169
|
},
|
|
7162
7170
|
async rasterizePng(t, n) {
|
|
7163
7171
|
try {
|
|
7164
|
-
let e = await
|
|
7172
|
+
let e = await bs(Cs(t), n);
|
|
7165
7173
|
return new Uint8Array(e);
|
|
7166
7174
|
} catch (t) {
|
|
7167
7175
|
throw new e(`PNG rasterization requires @resvg/resvg-js. Install it: npm i @resvg/resvg-js. (${t instanceof Error ? t.message : String(t)})`);
|
|
@@ -7170,4 +7178,4 @@ function Ss() {
|
|
|
7170
7178
|
};
|
|
7171
7179
|
}
|
|
7172
7180
|
//#endregion
|
|
7173
|
-
export {
|
|
7181
|
+
export { ws as createNodeBackend };
|