@blueprint-chart/lib 1.8.1 → 1.8.3
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/charts/plugins/annotations/position-helpers.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -101
- package/dist/lib/lib.iife.js +9 -8
- package/dist/node-backend/index.js +110 -97
- package/dist/{render-bpc-Bp2OTJmu.js → render-bpc-Bgb7rsgM.js} +156 -143
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
|
@@ -2092,12 +2092,17 @@ function $t(e, t, n, r, i = {}) {
|
|
|
2092
2092
|
} else s.text(t);
|
|
2093
2093
|
}
|
|
2094
2094
|
function en(e, t, n) {
|
|
2095
|
-
let r =
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2095
|
+
let r = 0, i = (t) => {
|
|
2096
|
+
e.append("tspan").attr("x", e.attr("x")).attr("dy", r === 0 ? "0" : "1.2em").text(t), r++;
|
|
2097
|
+
};
|
|
2098
|
+
for (let e of t.split("\n")) {
|
|
2099
|
+
let t = "";
|
|
2100
|
+
for (let r of e.split(/\s+/).filter(Boolean)) {
|
|
2101
|
+
let e = t ? `${t} ${r}` : r;
|
|
2102
|
+
t && e.length * 7 > n ? (i(t), t = r) : t = e;
|
|
2103
|
+
}
|
|
2104
|
+
i(t);
|
|
2099
2105
|
}
|
|
2100
|
-
i && e.append("tspan").attr("x", e.attr("x")).attr("dy", a === 0 ? "0" : "1.2em").text(i);
|
|
2101
2106
|
}
|
|
2102
2107
|
function tn(e, t, n = I.Center) {
|
|
2103
2108
|
if ("bandwidth" in t) {
|
|
@@ -2170,7 +2175,7 @@ function cn(e, t, n, r) {
|
|
|
2170
2175
|
let e = on(d - u.x);
|
|
2171
2176
|
$t(o, t.text, g, _ - 4, {
|
|
2172
2177
|
textColor: t.textColor,
|
|
2173
|
-
maxWidth: an(t.maxWidth, n.width),
|
|
2178
|
+
maxWidth: an(t.maxWidth, n.width) ?? n.width * .4,
|
|
2174
2179
|
textAnchor: e,
|
|
2175
2180
|
backgroundColor: n.backgroundColor,
|
|
2176
2181
|
textOutline: t.textOutline
|
|
@@ -2259,7 +2264,7 @@ function un(e, t, n, r) {
|
|
|
2259
2264
|
if (t.text) {
|
|
2260
2265
|
$t(i, t.text, o, s, {
|
|
2261
2266
|
textColor: t.textColor,
|
|
2262
|
-
maxWidth: an(t.maxWidth, n.width),
|
|
2267
|
+
maxWidth: an(t.maxWidth, n.width) ?? n.width * .4,
|
|
2263
2268
|
textAnchor: "middle",
|
|
2264
2269
|
backgroundColor: n.backgroundColor,
|
|
2265
2270
|
textOutline: t.textOutline
|
|
@@ -6696,14 +6701,22 @@ function Ro(e, t) {
|
|
|
6696
6701
|
};
|
|
6697
6702
|
}
|
|
6698
6703
|
//#endregion
|
|
6699
|
-
//#region src/charts/
|
|
6704
|
+
//#region src/charts/number-parse.ts
|
|
6700
6705
|
function zo(e) {
|
|
6701
|
-
|
|
6706
|
+
return e.replace(/(\d)\s+(?=\d)/g, "$1");
|
|
6707
|
+
}
|
|
6708
|
+
function Bo(e) {
|
|
6709
|
+
return zo(e.replace(/^"(.*)"$/, "$1")).replace(/%$/, "").trim();
|
|
6710
|
+
}
|
|
6711
|
+
function Vo(e) {
|
|
6712
|
+
let t = Bo(e?.trim() ?? "");
|
|
6702
6713
|
if (!t) return;
|
|
6703
|
-
let n = Number
|
|
6714
|
+
let n = Number(t);
|
|
6704
6715
|
return Number.isFinite(n) ? n : void 0;
|
|
6705
6716
|
}
|
|
6706
|
-
|
|
6717
|
+
//#endregion
|
|
6718
|
+
//#region src/charts/chart-helpers.ts
|
|
6719
|
+
function Ho(e) {
|
|
6707
6720
|
let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = [], r = [], i = t[0]?.match(/^series\s*=\s*(.+)$/);
|
|
6708
6721
|
if (i) {
|
|
6709
6722
|
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 +6725,7 @@ function Bo(e) {
|
|
|
6712
6725
|
if (o) {
|
|
6713
6726
|
n.push(o[1]);
|
|
6714
6727
|
let e = o[2].split(",");
|
|
6715
|
-
for (let t = 0; t < r.length; t++) a[t].push(
|
|
6728
|
+
for (let t = 0; t < r.length; t++) a[t].push(Vo(e[t]));
|
|
6716
6729
|
}
|
|
6717
6730
|
}
|
|
6718
6731
|
let o = r.map((e, t) => ({
|
|
@@ -6727,36 +6740,36 @@ function Bo(e) {
|
|
|
6727
6740
|
}
|
|
6728
6741
|
for (let e of t) {
|
|
6729
6742
|
let t = e.match(/^"([^"]+)"\s*=\s*(.+)$/);
|
|
6730
|
-
t && (n.push(t[1]), r.push(
|
|
6743
|
+
t && (n.push(t[1]), r.push(Vo(t[2])));
|
|
6731
6744
|
}
|
|
6732
6745
|
return {
|
|
6733
6746
|
labels: n,
|
|
6734
6747
|
values: r
|
|
6735
6748
|
};
|
|
6736
6749
|
}
|
|
6737
|
-
function
|
|
6750
|
+
function Uo(e, t) {
|
|
6738
6751
|
let n = {}, r = te(e.colorPalette);
|
|
6739
6752
|
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
6753
|
}
|
|
6741
|
-
function
|
|
6754
|
+
function Wo(e) {
|
|
6742
6755
|
let t = {};
|
|
6743
6756
|
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
6757
|
}
|
|
6745
|
-
function
|
|
6758
|
+
function Go(e) {
|
|
6746
6759
|
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
6760
|
let t = {};
|
|
6748
6761
|
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
6762
|
let n = ce(e.verticalRangeMin ?? ""), r = ce(e.verticalRangeMax ?? "");
|
|
6750
6763
|
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
6764
|
}
|
|
6752
|
-
function
|
|
6765
|
+
function Ko(e) {
|
|
6753
6766
|
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
6767
|
let t = {};
|
|
6755
6768
|
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
6769
|
let n = ce(e.horizontalRangeMin ?? ""), r = ce(e.horizontalRangeMax ?? "");
|
|
6757
6770
|
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
6771
|
}
|
|
6759
|
-
function
|
|
6772
|
+
function qo(e) {
|
|
6760
6773
|
return e.lineSymbols ? { lineSymbols: {
|
|
6761
6774
|
symbol: e.lineSymbolShape ?? R.Circle,
|
|
6762
6775
|
showOn: e.lineSymbolShowOn ?? z.FirstLast,
|
|
@@ -6765,13 +6778,13 @@ function Go(e) {
|
|
|
6765
6778
|
opacity: parseFloat(e.lineSymbolOpacity ?? "1") || 1
|
|
6766
6779
|
} } : {};
|
|
6767
6780
|
}
|
|
6768
|
-
function
|
|
6781
|
+
function Jo(e, t) {
|
|
6769
6782
|
let n = {
|
|
6770
|
-
...
|
|
6771
|
-
...Ho(e),
|
|
6772
|
-
...Uo(e),
|
|
6783
|
+
...Uo(e, t),
|
|
6773
6784
|
...Wo(e),
|
|
6774
|
-
...Go(e)
|
|
6785
|
+
...Go(e),
|
|
6786
|
+
...Ko(e),
|
|
6787
|
+
...qo(e)
|
|
6775
6788
|
};
|
|
6776
6789
|
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
6790
|
let r = parseInt(e.sliceMax ?? "", 10);
|
|
@@ -6785,13 +6798,13 @@ function Ko(e, t) {
|
|
|
6785
6798
|
}
|
|
6786
6799
|
//#endregion
|
|
6787
6800
|
//#region src/render/resolve-scene.ts
|
|
6788
|
-
var
|
|
6789
|
-
function
|
|
6801
|
+
var Yo = /* @__PURE__ */ new Set();
|
|
6802
|
+
function Xo(e, t, n) {
|
|
6790
6803
|
let r = t;
|
|
6791
|
-
for (let t of e) t.transformType === "sort" ? r = H.Total :
|
|
6804
|
+
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
6805
|
return r;
|
|
6793
6806
|
}
|
|
6794
|
-
function
|
|
6807
|
+
function Zo() {
|
|
6795
6808
|
return {
|
|
6796
6809
|
properties: /* @__PURE__ */ new Map(),
|
|
6797
6810
|
chartTypeOptions: {},
|
|
@@ -6802,8 +6815,8 @@ function Yo() {
|
|
|
6802
6815
|
transforms: []
|
|
6803
6816
|
};
|
|
6804
6817
|
}
|
|
6805
|
-
function
|
|
6806
|
-
let r =
|
|
6818
|
+
function Qo(e, t, n) {
|
|
6819
|
+
let r = Zo();
|
|
6807
6820
|
for (let i = 0; i <= t; i++) {
|
|
6808
6821
|
let a = e[i], o = So(a.properties), s = o.get("type");
|
|
6809
6822
|
s && (r.chartType = s);
|
|
@@ -6818,10 +6831,10 @@ function Xo(e, t, n) {
|
|
|
6818
6831
|
}
|
|
6819
6832
|
return r;
|
|
6820
6833
|
}
|
|
6821
|
-
function
|
|
6834
|
+
function $o(e, t, n) {
|
|
6822
6835
|
return n < e ? !1 : t === "always" || n <= e + (typeof t == "number" ? t : 0);
|
|
6823
6836
|
}
|
|
6824
|
-
function
|
|
6837
|
+
function es(e, t) {
|
|
6825
6838
|
let n = e.options ?? (e.properties ? Ro(e.chartType, Co(e.chartType, e.properties)) : {}), r = {
|
|
6826
6839
|
chartType: e.chartType,
|
|
6827
6840
|
data: e.data,
|
|
@@ -6840,7 +6853,7 @@ function Qo(e, t) {
|
|
|
6840
6853
|
theme: e.theme
|
|
6841
6854
|
};
|
|
6842
6855
|
if (t == null || !e.scenes || t < 0 || t >= e.scenes.length) return r;
|
|
6843
|
-
let i =
|
|
6856
|
+
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
6857
|
...n,
|
|
6845
6858
|
...i.chartTypeOptions
|
|
6846
6859
|
}) : 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 +6868,10 @@ function Qo(e, t) {
|
|
|
6855
6868
|
config: e
|
|
6856
6869
|
});
|
|
6857
6870
|
});
|
|
6858
|
-
let f = d.filter(({ anchor: e, config: n }) =>
|
|
6871
|
+
let f = d.filter(({ anchor: e, config: n }) => $o(e, n.repeat, t)).map(({ key: e, config: t }) => ({
|
|
6859
6872
|
...t,
|
|
6860
6873
|
key: e
|
|
6861
|
-
})), p = i.seriesOverrides.length > 0 ? Fo(i.seriesOverrides) : r.seriesOverrides, m =
|
|
6874
|
+
})), p = i.seriesOverrides.length > 0 ? Fo(i.seriesOverrides) : r.seriesOverrides, m = Xo(i.transforms, r.sortMode, `scene ${t}`), h = [
|
|
6862
6875
|
"title",
|
|
6863
6876
|
"description",
|
|
6864
6877
|
"source",
|
|
@@ -6890,52 +6903,52 @@ function Qo(e, t) {
|
|
|
6890
6903
|
}
|
|
6891
6904
|
//#endregion
|
|
6892
6905
|
//#region src/render/layout-constraints.ts
|
|
6893
|
-
var
|
|
6894
|
-
function
|
|
6895
|
-
let t =
|
|
6906
|
+
var ts = /* @__PURE__ */ new WeakMap();
|
|
6907
|
+
function ns(e) {
|
|
6908
|
+
let t = ts.get(e);
|
|
6896
6909
|
if (!(!t || t.size === 0)) {
|
|
6897
6910
|
for (let n of t) e.style[n] = "";
|
|
6898
6911
|
t.clear();
|
|
6899
6912
|
}
|
|
6900
6913
|
}
|
|
6901
|
-
function
|
|
6902
|
-
let n =
|
|
6903
|
-
n || (n = /* @__PURE__ */ new Set(),
|
|
6914
|
+
function rs(e, t) {
|
|
6915
|
+
let n = ts.get(e);
|
|
6916
|
+
n || (n = /* @__PURE__ */ new Set(), ts.set(e, n)), n.add(t);
|
|
6904
6917
|
}
|
|
6905
|
-
function
|
|
6906
|
-
if (
|
|
6918
|
+
function is(e, t, n) {
|
|
6919
|
+
if (ns(e), n.ignoreLayout || !t) return { constrained: !1 };
|
|
6907
6920
|
let r = So(t), i = r.get("heightMode"), a = r.get("aspectRatio"), o = r.get("fixedHeight"), s = !1;
|
|
6908
6921
|
if (i === "aspect-ratio" && a) {
|
|
6909
6922
|
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",
|
|
6923
|
+
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);
|
|
6924
|
+
} else i === "fixed" && o && (e.style.height = `${o}px`, rs(e, "height"), s = !0);
|
|
6925
|
+
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
6926
|
}
|
|
6914
6927
|
//#endregion
|
|
6915
6928
|
//#region src/render/cross-type-fade.ts
|
|
6916
|
-
var
|
|
6917
|
-
function
|
|
6929
|
+
var as = /* @__PURE__ */ new WeakMap();
|
|
6930
|
+
function os(e) {
|
|
6918
6931
|
e.querySelectorAll("[data-bc-fade-overlay]").forEach((e) => {
|
|
6919
6932
|
typeof e.getAnimations == "function" && e.getAnimations().forEach((e) => e.cancel()), e.remove();
|
|
6920
6933
|
});
|
|
6921
6934
|
}
|
|
6922
|
-
function
|
|
6935
|
+
function ss(e, t, n) {
|
|
6923
6936
|
if (!n) return null;
|
|
6924
|
-
let r =
|
|
6925
|
-
return !r || r === t ? null : (
|
|
6937
|
+
let r = as.get(e);
|
|
6938
|
+
return !r || r === t ? null : (os(e), et(e));
|
|
6926
6939
|
}
|
|
6927
|
-
function
|
|
6928
|
-
if (
|
|
6940
|
+
function cs(e, t, n) {
|
|
6941
|
+
if (as.set(e, t), n) {
|
|
6929
6942
|
let t = e.querySelector(".bc-frame .bc-frame-body");
|
|
6930
6943
|
t && $e(t), tt(e, n);
|
|
6931
6944
|
}
|
|
6932
6945
|
}
|
|
6933
|
-
function
|
|
6934
|
-
|
|
6946
|
+
function ls(e) {
|
|
6947
|
+
as.delete(e), os(e);
|
|
6935
6948
|
}
|
|
6936
6949
|
//#endregion
|
|
6937
6950
|
//#region src/render/post-render.ts
|
|
6938
|
-
function
|
|
6951
|
+
function us(e, t, n) {
|
|
6939
6952
|
let r = e.querySelector(".bc-frame");
|
|
6940
6953
|
if (!r) return;
|
|
6941
6954
|
let i = [];
|
|
@@ -6947,9 +6960,9 @@ function cs(e, t, n) {
|
|
|
6947
6960
|
}
|
|
6948
6961
|
//#endregion
|
|
6949
6962
|
//#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(),
|
|
6963
|
+
function ds(e, t, n = {}) {
|
|
6964
|
+
if (n.transition || (Nn(e).interrupt(), e.replaceChildren(), ls(e)), t.data.labels.length === 0) {
|
|
6965
|
+
n.transition && (Nn(e).interrupt(), e.replaceChildren(), ls(e));
|
|
6953
6966
|
return;
|
|
6954
6967
|
}
|
|
6955
6968
|
let r = t;
|
|
@@ -6961,11 +6974,11 @@ function ls(e, t, n = {}) {
|
|
|
6961
6974
|
}
|
|
6962
6975
|
r = e;
|
|
6963
6976
|
}
|
|
6964
|
-
let i =
|
|
6977
|
+
let i = is(e, r.properties, n), a = es(r, n.sceneIndex), o = Ji(a.chartType);
|
|
6965
6978
|
if (!o) return;
|
|
6966
|
-
let s =
|
|
6979
|
+
let s = ss(e, a.chartType, !!n.transition);
|
|
6967
6980
|
s && e.replaceChildren();
|
|
6968
|
-
let c = Te(e), l =
|
|
6981
|
+
let c = Te(e), l = Jo(a.options, c), u;
|
|
6969
6982
|
if (n.thumbnail) u = null;
|
|
6970
6983
|
else {
|
|
6971
6984
|
let e = a.frame?.padding ?? n.padding ?? "16px";
|
|
@@ -6988,20 +7001,20 @@ function ls(e, t, n = {}) {
|
|
|
6988
7001
|
}, !!n.transition), n.transition && d.commit({
|
|
6989
7002
|
duration: Qe(),
|
|
6990
7003
|
mode: n.transitionMode
|
|
6991
|
-
}),
|
|
7004
|
+
}), us(e, { theme: n.theme ?? a.theme }, i), cs(e, a.chartType, s);
|
|
6992
7005
|
}
|
|
6993
7006
|
//#endregion
|
|
6994
7007
|
//#region src/render/backends/jsdom-env.ts
|
|
6995
|
-
function
|
|
7008
|
+
function fs() {
|
|
6996
7009
|
let e = new u();
|
|
6997
7010
|
return e.on("jsdomError", (e) => {
|
|
6998
7011
|
e.message && e.message.startsWith("Not implemented") || console.error(e);
|
|
6999
7012
|
}), e;
|
|
7000
7013
|
}
|
|
7001
|
-
function
|
|
7014
|
+
function ps(e) {
|
|
7002
7015
|
let t = new l(`<!DOCTYPE html><html><body><div id="root" style="width:${e.width}px;height:${e.height}px"></div></body></html>`, {
|
|
7003
7016
|
pretendToBeVisual: !0,
|
|
7004
|
-
virtualConsole:
|
|
7017
|
+
virtualConsole: fs()
|
|
7005
7018
|
}), n = t.window.document.getElementById("root");
|
|
7006
7019
|
return {
|
|
7007
7020
|
window: t.window,
|
|
@@ -7024,29 +7037,29 @@ function ds(e) {
|
|
|
7024
7037
|
}
|
|
7025
7038
|
//#endregion
|
|
7026
7039
|
//#region src/render/backends/text-shim.ts
|
|
7027
|
-
var
|
|
7028
|
-
d.registerFromPath(h(
|
|
7029
|
-
var
|
|
7030
|
-
function
|
|
7031
|
-
return
|
|
7040
|
+
var ms = h(m(p(import.meta.url)), "fonts");
|
|
7041
|
+
d.registerFromPath(h(ms, "DejaVuSans.ttf"), "sans-serif"), d.registerFromPath(h(ms, "DejaVuSans-Bold.ttf"), "sans-serif");
|
|
7042
|
+
var hs = f(1, 1).getContext("2d");
|
|
7043
|
+
function gs(e, t, n, r) {
|
|
7044
|
+
return hs.font = `${r} ${t}px ${n}`, hs.measureText(e);
|
|
7032
7045
|
}
|
|
7033
|
-
function
|
|
7046
|
+
function _s(e) {
|
|
7034
7047
|
return {
|
|
7035
7048
|
fontSize: parseFloat(e.getAttribute("font-size") ?? "12") || 12,
|
|
7036
7049
|
fontFamily: e.getAttribute("font-family") ?? "sans-serif",
|
|
7037
7050
|
fontWeight: e.getAttribute("font-weight") ?? "normal"
|
|
7038
7051
|
};
|
|
7039
7052
|
}
|
|
7040
|
-
function
|
|
7053
|
+
function vs(e) {
|
|
7041
7054
|
let t = e.SVGElement?.prototype, n = function() {
|
|
7042
|
-
let { fontSize: e, fontFamily: t, fontWeight: n } =
|
|
7043
|
-
return
|
|
7055
|
+
let { fontSize: e, fontFamily: t, fontWeight: n } = _s(this);
|
|
7056
|
+
return gs(this.textContent ?? "", e, t, n).width;
|
|
7044
7057
|
}, r = function(e, t) {
|
|
7045
|
-
let n = (this.textContent ?? "").substring(e, e + t), { fontSize: r, fontFamily: i, fontWeight: a } =
|
|
7046
|
-
return
|
|
7058
|
+
let n = (this.textContent ?? "").substring(e, e + t), { fontSize: r, fontFamily: i, fontWeight: a } = _s(this);
|
|
7059
|
+
return gs(n, r, i, a).width;
|
|
7047
7060
|
}, i = function() {
|
|
7048
7061
|
if (this.tagName === "text") {
|
|
7049
|
-
let { fontSize: e, fontFamily: t, fontWeight: n } =
|
|
7062
|
+
let { fontSize: e, fontFamily: t, fontWeight: n } = _s(this), r = gs(this.textContent ?? "", e, t, n);
|
|
7050
7063
|
return {
|
|
7051
7064
|
x: 0,
|
|
7052
7065
|
y: -e,
|
|
@@ -7069,8 +7082,8 @@ function gs(e) {
|
|
|
7069
7082
|
}
|
|
7070
7083
|
//#endregion
|
|
7071
7084
|
//#region src/render/backends/rasterize.ts
|
|
7072
|
-
var
|
|
7073
|
-
async function
|
|
7085
|
+
var ys = h(m(p(import.meta.url)), "fonts");
|
|
7086
|
+
async function bs(e, t = {}) {
|
|
7074
7087
|
let n = t.width ? {
|
|
7075
7088
|
mode: "width",
|
|
7076
7089
|
value: t.width
|
|
@@ -7080,7 +7093,7 @@ async function vs(e, t = {}) {
|
|
|
7080
7093
|
} : { mode: "original" }, r = new g(e, {
|
|
7081
7094
|
fitTo: n,
|
|
7082
7095
|
font: {
|
|
7083
|
-
fontDirs: [
|
|
7096
|
+
fontDirs: [ys],
|
|
7084
7097
|
loadSystemFonts: !1,
|
|
7085
7098
|
defaultFontFamily: "DejaVu Sans"
|
|
7086
7099
|
}
|
|
@@ -7089,23 +7102,23 @@ async function vs(e, t = {}) {
|
|
|
7089
7102
|
}
|
|
7090
7103
|
//#endregion
|
|
7091
7104
|
//#region src/render/backends/node-backend.ts
|
|
7092
|
-
var
|
|
7105
|
+
var xs = [
|
|
7093
7106
|
"window",
|
|
7094
7107
|
"document",
|
|
7095
7108
|
"Element",
|
|
7096
7109
|
"getComputedStyle",
|
|
7097
7110
|
"requestAnimationFrame"
|
|
7098
|
-
],
|
|
7099
|
-
function
|
|
7111
|
+
], Ss = /* @__PURE__ */ new WeakMap();
|
|
7112
|
+
function Cs(e) {
|
|
7100
7113
|
return e.includes("xmlns=\"http://www.w3.org/2000/svg\"") ? e : e.replace(/^<svg(?=\s|>)/, "<svg xmlns=\"http://www.w3.org/2000/svg\"");
|
|
7101
7114
|
}
|
|
7102
|
-
function
|
|
7115
|
+
function ws() {
|
|
7103
7116
|
return {
|
|
7104
7117
|
kind: "node",
|
|
7105
7118
|
createContainer(t, n) {
|
|
7106
7119
|
let r;
|
|
7107
7120
|
try {
|
|
7108
|
-
r =
|
|
7121
|
+
r = ps({
|
|
7109
7122
|
width: t,
|
|
7110
7123
|
height: n
|
|
7111
7124
|
});
|
|
@@ -7118,37 +7131,37 @@ function Ss() {
|
|
|
7118
7131
|
serializeFrame: r.serializeFrame,
|
|
7119
7132
|
cleanup: r.cleanup
|
|
7120
7133
|
};
|
|
7121
|
-
return
|
|
7134
|
+
return Ss.set(r.container, i), {
|
|
7122
7135
|
container: r.container,
|
|
7123
7136
|
cleanup: () => {
|
|
7124
|
-
|
|
7137
|
+
Ss.delete(r.container), r.cleanup();
|
|
7125
7138
|
}
|
|
7126
7139
|
};
|
|
7127
7140
|
},
|
|
7128
7141
|
renderToContainer(e, t, n) {
|
|
7129
|
-
let r =
|
|
7142
|
+
let r = Ss.get(e);
|
|
7130
7143
|
if (!r) throw Error("node-backend: container was not created by this backend");
|
|
7131
|
-
|
|
7144
|
+
vs(r.window);
|
|
7132
7145
|
let i = r.window, a = globalThis, o = {};
|
|
7133
|
-
for (let e of
|
|
7146
|
+
for (let e of xs) o[e] = a[e], a[e] = i[e];
|
|
7134
7147
|
try {
|
|
7135
|
-
|
|
7148
|
+
ds(e, t, {
|
|
7136
7149
|
sceneIndex: n.sceneIndex,
|
|
7137
7150
|
thumbnail: n.thumbnail ?? !1,
|
|
7138
7151
|
transition: !1,
|
|
7139
7152
|
theme: n.theme
|
|
7140
7153
|
});
|
|
7141
7154
|
} finally {
|
|
7142
|
-
for (let e of
|
|
7155
|
+
for (let e of xs) a[e] = o[e];
|
|
7143
7156
|
}
|
|
7144
7157
|
},
|
|
7145
7158
|
serializeSvg(e) {
|
|
7146
|
-
let t =
|
|
7159
|
+
let t = Ss.get(e), n = t ? t.serializeSvg() : e.querySelector("svg")?.outerHTML ?? "";
|
|
7147
7160
|
if (!n) throw Error("node-backend: renderToContainer produced no SVG");
|
|
7148
|
-
return
|
|
7161
|
+
return Cs(n);
|
|
7149
7162
|
},
|
|
7150
7163
|
serializeFrame(e) {
|
|
7151
|
-
let t =
|
|
7164
|
+
let t = Ss.get(e);
|
|
7152
7165
|
if (t) {
|
|
7153
7166
|
let n = t.serializeFrame();
|
|
7154
7167
|
return n === void 0 ? this.serializeSvg(e) : n;
|
|
@@ -7161,7 +7174,7 @@ function Ss() {
|
|
|
7161
7174
|
},
|
|
7162
7175
|
async rasterizePng(t, n) {
|
|
7163
7176
|
try {
|
|
7164
|
-
let e = await
|
|
7177
|
+
let e = await bs(Cs(t), n);
|
|
7165
7178
|
return new Uint8Array(e);
|
|
7166
7179
|
} catch (t) {
|
|
7167
7180
|
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 +7183,4 @@ function Ss() {
|
|
|
7170
7183
|
};
|
|
7171
7184
|
}
|
|
7172
7185
|
//#endregion
|
|
7173
|
-
export {
|
|
7186
|
+
export { ws as createNodeBackend };
|