@genome-spy/app 0.84.0 → 0.86.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 (62) hide show
  1. package/README.md +28 -0
  2. package/dist/{agentApi-DHXYZVvQ.js → agentApi-DgopQbMV.js} +5804 -7009
  3. package/dist/agentApi.es.js +2823 -2594
  4. package/dist/agentShared.es.js +15 -14
  5. package/dist/canvas2d-8uxuN_vx.js +619 -0
  6. package/dist/canvas2d-BtQC7Xr8.js +619 -0
  7. package/dist/canvasSizeHelper-7h_8rOcx.js +56 -0
  8. package/dist/clipOptions-BQfNhxgP.js +2239 -0
  9. package/dist/clipOptions-taFzEljc.js +2259 -0
  10. package/dist/{debug-aHQsa6hU.js → debug-Bzc3SoRg.js} +8 -8
  11. package/dist/{debug-D6FqxKEj.js → debug-D_VtWQ6l.js} +8 -8
  12. package/dist/{esm-CGLz7idZ.js → esm-BA6yMcc-.js} +438 -434
  13. package/dist/{esm-D8vvQAP3.js → esm-CcDLRSvC.js} +33 -33
  14. package/dist/{esm-BeV56E_5.js → esm-CfYZhLHN.js} +33 -33
  15. package/dist/{esm-DQ3lJSQN.js → esm-JAiZmFIS.js} +1 -1
  16. package/dist/index.es.js +3067 -2987
  17. package/dist/index.js +2030 -2022
  18. package/dist/indexer-qiFctgR3.js +72 -0
  19. package/dist/indexer-qy_dq5l5.js +72 -0
  20. package/dist/layoutResult-D50MSHXR.js +97 -0
  21. package/dist/nativeText-DFV5XIx8.js +860 -0
  22. package/dist/nativeText-vT3AWE14.js +860 -0
  23. package/dist/performanceProfiler-CPLEjApa.js +20 -0
  24. package/dist/rasterExport-B8pVoOsj.js +44 -0
  25. package/dist/rasterExport-C4r4xjQT.js +44 -0
  26. package/dist/rasterImage-B4rPLaW9.js +18 -0
  27. package/dist/rasterization-CFogVB3B.js +50 -0
  28. package/dist/rectangle-DKnrAmKs.js +142 -0
  29. package/dist/renderCanvas2D-BQrRWp2Z.js +271 -0
  30. package/dist/renderCanvas2D-CHVNfIUz.js +271 -0
  31. package/dist/schema.json +1559 -219
  32. package/dist/style.css +1 -1
  33. package/dist/svg-C-Sw6E6G.js +1167 -0
  34. package/dist/svg-CKHwwKRt.js +1167 -0
  35. package/dist/{svgNumber-C6aRPc8Z.js → svgNumber-DNxESJQB.js} +1 -1
  36. package/dist/svgRasterizer-BgD72AmG.js +40 -0
  37. package/dist/svgRasterizer-BgSNqI3L.js +40 -0
  38. package/dist/vega-scale-CK0_al6O.js +2700 -0
  39. package/dist/vega-scale-D46-iCaL.js +2700 -0
  40. package/dist/viewError-BiR9VCgL.js +29 -0
  41. package/dist/{viewIdentityRegistry-Dl7rR4Ay.js → viewIdentityRegistry-B-VGlez1.js} +1 -1
  42. package/dist/{viewIdentityRegistry-AEQpJTDm.js → viewIdentityRegistry-CDtVktJD.js} +1 -1
  43. package/dist/viewSelectors-CKfxF_LM.js +1817 -0
  44. package/dist/viewSelectors-D_imtq5Z.js +1817 -0
  45. package/dist/viewUtils-nCJ7AoaI.js +5782 -0
  46. package/dist/warning-CpIIpk8e.js +7 -0
  47. package/dist/webgl-BaA3jSa2.js +4128 -0
  48. package/dist/webgl-FP-4EsBL.js +4128 -0
  49. package/package.json +7 -6
  50. package/dist/bmFontMetrics-CuNB-kNN.js +0 -31
  51. package/dist/clipOptions-Dqco1p8b.js +0 -377
  52. package/dist/framebufferReadback-Bje9lHb7.js +0 -1993
  53. package/dist/framebufferReadback-CC0D6Haw.js +0 -147
  54. package/dist/raster-9uKYMjHZ.js +0 -53
  55. package/dist/raster-BofBWXbe.js +0 -54
  56. package/dist/svg-CvsT1Y2V.js +0 -1793
  57. package/dist/svg-DRgWfcsL.js +0 -1793
  58. package/dist/twgl-full.module-BNEMlXRV.js +0 -1849
  59. package/dist/viewRenderingContext-HtpqwS_x.js +0 -120
  60. package/dist/viewSelectors-BhW4mTR1.js +0 -6386
  61. package/dist/viewSelectors-Bwzj10Qz.js +0 -6363
  62. package/dist/viewUtils-DMNiWslc.js +0 -7228
@@ -0,0 +1,20 @@
1
+ //#region ../core/src/debug/performanceProfiler.js
2
+ var e = Symbol.for("genome-spy.performance-profiler");
3
+ function t() {
4
+ return globalThis[e];
5
+ }
6
+ function n(e, n) {
7
+ let r = t();
8
+ if (!r?.enabled) return n();
9
+ let i = performance.now();
10
+ try {
11
+ return n();
12
+ } finally {
13
+ r.addPhase(e, performance.now() - i);
14
+ }
15
+ }
16
+ function r(e, n) {
17
+ t()?.addCount(e, n);
18
+ }
19
+ //#endregion
20
+ export { t as n, n as r, r as t };
@@ -0,0 +1,44 @@
1
+ import { t as e } from "./rasterization-CFogVB3B.js";
2
+ import { t } from "./rectangle-DKnrAmKs.js";
3
+ import { t as n } from "./layoutResult-D50MSHXR.js";
4
+ import { t as r } from "./renderCanvas2D-BQrRWp2Z.js";
5
+ //#region ../core/src/rendering/canvas2d/rasterExport.js
6
+ async function i(e) {
7
+ let t = e.mimeType ?? "image/png";
8
+ if (t != "image/png") throw Error(`Unsupported raster export MIME type: ${t}`);
9
+ let n = o(e);
10
+ return new Promise((e, r) => {
11
+ n.toBlob((t) => {
12
+ t ? e(t) : r(/* @__PURE__ */ Error("Canvas2D could not encode the raster export."));
13
+ }, t);
14
+ });
15
+ }
16
+ function a(e) {
17
+ return o({
18
+ ...e,
19
+ pixelRatio: e.devicePixelRatio ?? e.pixelRatio
20
+ }).toDataURL("image/png");
21
+ }
22
+ function o(i) {
23
+ let a = i.logicalWidth ?? i.liveSize.width, o = i.logicalHeight ?? i.liveSize.height, s = i.pixelRatio ?? i.liveDevicePixelRatio, c, l;
24
+ try {
25
+ c = document.createElement("canvas"), c.width = Math.floor(a * s), c.height = Math.floor(o * s), l = c.getContext("2d");
26
+ } catch (t) {
27
+ throw new e("Unable to initialize a Canvas2D export context.", { cause: t });
28
+ }
29
+ if (!l) throw new e("Unable to initialize a Canvas2D export context.");
30
+ return r({
31
+ layoutResult: n(i.viewRoot, t.create(0, 0, a, o), {
32
+ devicePixelRatio: s,
33
+ renderingOptions: { firstFacet: !0 }
34
+ }),
35
+ context: l,
36
+ width: a,
37
+ height: o,
38
+ devicePixelRatio: s,
39
+ background: i.clearColor ?? null,
40
+ paint: !0
41
+ }), c;
42
+ }
43
+ //#endregion
44
+ export { a as exportCanvas, i as exportRaster };
@@ -0,0 +1,44 @@
1
+ import { t as e } from "./rasterization-CFogVB3B.js";
2
+ import { t } from "./rectangle-DKnrAmKs.js";
3
+ import { t as n } from "./layoutResult-D50MSHXR.js";
4
+ import { t as r } from "./renderCanvas2D-CHVNfIUz.js";
5
+ //#region ../core/src/rendering/canvas2d/rasterExport.js
6
+ async function i(e) {
7
+ let t = e.mimeType ?? "image/png";
8
+ if (t != "image/png") throw Error(`Unsupported raster export MIME type: ${t}`);
9
+ let n = o(e);
10
+ return new Promise((e, r) => {
11
+ n.toBlob((t) => {
12
+ t ? e(t) : r(/* @__PURE__ */ Error("Canvas2D could not encode the raster export."));
13
+ }, t);
14
+ });
15
+ }
16
+ function a(e) {
17
+ return o({
18
+ ...e,
19
+ pixelRatio: e.devicePixelRatio ?? e.pixelRatio
20
+ }).toDataURL("image/png");
21
+ }
22
+ function o(i) {
23
+ let a = i.logicalWidth ?? i.liveSize.width, o = i.logicalHeight ?? i.liveSize.height, s = i.pixelRatio ?? i.liveDevicePixelRatio, c, l;
24
+ try {
25
+ c = document.createElement("canvas"), c.width = Math.floor(a * s), c.height = Math.floor(o * s), l = c.getContext("2d");
26
+ } catch (t) {
27
+ throw new e("Unable to initialize a Canvas2D export context.", { cause: t });
28
+ }
29
+ if (!l) throw new e("Unable to initialize a Canvas2D export context.");
30
+ return r({
31
+ layoutResult: n(i.viewRoot, t.create(0, 0, a, o), {
32
+ devicePixelRatio: s,
33
+ renderingOptions: { firstFacet: !0 }
34
+ }),
35
+ context: l,
36
+ width: a,
37
+ height: o,
38
+ devicePixelRatio: s,
39
+ background: i.clearColor ?? null,
40
+ paint: !0
41
+ }), c;
42
+ }
43
+ //#endregion
44
+ export { a as exportCanvas, i as exportRaster };
@@ -0,0 +1,18 @@
1
+ import { t as e } from "./svgNumber-DNxESJQB.js";
2
+ //#region ../core/src/rendering/svg/raster/rasterImage.js
3
+ function t(e, t, n, r) {
4
+ let i = Math.max(0, Math.floor(e.x1 * t)), a = Math.max(0, Math.floor(e.y1 * t)), o = Math.min(n, Math.ceil(e.x2 * t)), s = Math.min(r, Math.ceil(e.y2 * t));
5
+ return {
6
+ x: i,
7
+ y: a,
8
+ width: o - i,
9
+ height: s - a
10
+ };
11
+ }
12
+ function n(t, n, r, i) {
13
+ let a = t.image;
14
+ if (!a) throw Error("Raster run has no SVG image placeholder.");
15
+ a.setAttribute("x", "" + e(n.x / r)), a.setAttribute("y", "" + e(n.y / r)), a.setAttribute("width", "" + e(n.width / r)), a.setAttribute("height", "" + e(n.height / r)), a.setAttribute("href", i);
16
+ }
17
+ //#endregion
18
+ export { n, t };
@@ -0,0 +1,50 @@
1
+ //#region ../core/src/rendering/renderingModuleRegistry.js
2
+ var e = {}, t = class extends Error {
3
+ constructor(e, t) {
4
+ super(e, t), this.name = "RasterizationUnavailableError";
5
+ }
6
+ };
7
+ async function n(n, r) {
8
+ if (n.exportRaster) try {
9
+ return await n.exportRaster(r);
10
+ } catch (e) {
11
+ if (!(e instanceof t)) throw e;
12
+ }
13
+ if (!e.canvasRasterExport) throw i();
14
+ let a;
15
+ try {
16
+ a = await e.canvasRasterExport();
17
+ } catch (e) {
18
+ throw i(e);
19
+ }
20
+ try {
21
+ return await a.exportRaster({
22
+ ...r,
23
+ liveSize: n.surface.getLogicalCanvasSize(),
24
+ liveDevicePixelRatio: n.surface.getDevicePixelRatio()
25
+ });
26
+ } catch (e) {
27
+ throw e instanceof t ? i(e) : e;
28
+ }
29
+ }
30
+ async function r(n, r) {
31
+ if (n.rasterizeSvgRuns) try {
32
+ await n.rasterizeSvgRuns(r);
33
+ return;
34
+ } catch (e) {
35
+ if (!(e instanceof t)) throw e;
36
+ }
37
+ if (!e.canvasSvgRasterizer) throw new t("No raster backend supports selective SVG rasterization. Import \"@genome-spy/core/rendering/canvas.js\" to enable the Canvas2D fallback.");
38
+ let i;
39
+ try {
40
+ i = await e.canvasSvgRasterizer();
41
+ } catch (e) {
42
+ throw new t("No raster backend supports selective SVG rasterization.", { cause: e });
43
+ }
44
+ await i.createCanvas2DSvgRasterizer()(r);
45
+ }
46
+ function i(e) {
47
+ return new t("Raster export is unsupported because no raster rendering backend is available. Import \"@genome-spy/core/rendering/canvas.js\" to enable the Canvas2D fallback.", { cause: e });
48
+ }
49
+ //#endregion
50
+ export { e as i, n, r, t };
@@ -0,0 +1,142 @@
1
+ function e(e) {
2
+ let t = [];
3
+ for (let e = 0; e <= 127; e++) t.push(void 0);
4
+ let n = /* @__PURE__ */ new Map();
5
+ for (let r of e.chars) r.id <= 127 ? t[r.id] = r : n.set(r.id, r);
6
+ let r = 8722;
7
+ n.has(r) || n.set(r, t[45]);
8
+ function i(e) {
9
+ return (e <= 127 ? t[e] : n.get(e)) || t[63];
10
+ }
11
+ function a(e) {
12
+ return i(e.charCodeAt(0));
13
+ }
14
+ let o = e.common.base, s = a("x"), c = a("X"), l = a("q"), u = s.height - 10, d = c.height - 10, f = l.height - s.height + l.yoffset - s.yoffset;
15
+ function p(e, t = 1) {
16
+ let n = 0;
17
+ for (let t = 0; t < e.length; t++) n += i(e.charCodeAt(t)).xadvance;
18
+ return n / o * t;
19
+ }
20
+ let m = 0;
21
+ for (let t of e.chars) t.id > m && (m = t.id);
22
+ return {
23
+ measureWidth: p,
24
+ getCharByCode: i,
25
+ getChar: a,
26
+ chars: e.chars,
27
+ maxCharId: m,
28
+ xHeight: u,
29
+ capHeight: d,
30
+ descent: f,
31
+ common: e.common
32
+ };
33
+ }
34
+ //#endregion
35
+ //#region ../core/src/view/layout/rectangle.js
36
+ function t(e) {
37
+ return () => e;
38
+ }
39
+ var n = class e {
40
+ static create(n, r, i, a) {
41
+ return new e(t(n), t(r), t(i), t(a));
42
+ }
43
+ static ZERO = e.create(0, 0, 0, 0);
44
+ _offset(e, t) {
45
+ let n = this["_" + e];
46
+ if (t === 0) return n;
47
+ switch (typeof t) {
48
+ case "number": return () => n() + t;
49
+ case "function": return () => n() + t();
50
+ default: throw Error("Not a number of function");
51
+ }
52
+ }
53
+ _passThrough(e) {
54
+ return this._offset(e, 0);
55
+ }
56
+ constructor(e, t, n, r) {
57
+ this._x = e, this._y = t, this._width = n, this._height = r;
58
+ }
59
+ get x() {
60
+ return this._x();
61
+ }
62
+ get y() {
63
+ return this._y();
64
+ }
65
+ get width() {
66
+ return this._width();
67
+ }
68
+ get height() {
69
+ return this._height();
70
+ }
71
+ get x2() {
72
+ return this._x() + this._width();
73
+ }
74
+ get y2() {
75
+ return this._y() + this._height();
76
+ }
77
+ equals(e) {
78
+ return e ? this === e || this.x === e.x && this.y === e.y && this.width === e.width && this.height === e.height : !1;
79
+ }
80
+ modify(n) {
81
+ if (!Object.keys(n).length) return this;
82
+ let r = (e) => {
83
+ let r = n[e];
84
+ return typeof r == "number" ? t(r) : typeof r == "function" ? r : this._passThrough(e);
85
+ };
86
+ return new e(r("x"), r("y"), r("width"), r("height"));
87
+ }
88
+ translate(t, n) {
89
+ return t === 0 && n === 0 ? this : new e(this._offset("x", t), this._offset("y", n), this._passThrough("width"), this._passThrough("height"));
90
+ }
91
+ translateBy(e) {
92
+ return this.translate(e.x, e.y);
93
+ }
94
+ expand(t, n = 1) {
95
+ return t.left == 0 && t.top == 0 && t.right == 0 && t.bottom == 0 ? this : new e(t.left ? this._offset("x", -t.left * n) : this._passThrough("x"), t.top ? this._offset("y", -t.top * n) : this._passThrough("y"), t.width ? this._offset("width", t.width * n) : this._passThrough("width"), t.height ? this._offset("height", t.height * n) : this._passThrough("height"));
96
+ }
97
+ shrink(e) {
98
+ return this.expand(e, -1);
99
+ }
100
+ intersect(t) {
101
+ return this === t || t == null ? this : new e(() => Math.max(this.x, t.x), () => Math.max(this.y, t.y), () => Math.min(this.x2, t.x2) - Math.max(this.x, t.x), () => Math.min(this.y2, t.y2) - Math.max(this.y, t.y));
102
+ }
103
+ intersectX(t) {
104
+ return this === t || t == null ? this : new e(() => Math.max(this.x, t.x), this._passThrough("y"), () => Math.min(this.x2, t.x2) - Math.max(this.x, t.x), this._passThrough("height"));
105
+ }
106
+ intersectY(t) {
107
+ return this === t || t == null ? this : new e(this._passThrough("x"), () => Math.max(this.y, t.y), this._passThrough("width"), () => Math.min(this.y2, t.y2) - Math.max(this.y, t.y));
108
+ }
109
+ union(t) {
110
+ return this === t || t == null ? this : new e(() => Math.min(this.x, t.x), () => Math.min(this.y, t.y), () => Math.max(this.x2, t.x2) - Math.min(this.x, t.x), () => Math.max(this.y2, t.y2) - Math.min(this.y, t.y));
111
+ }
112
+ isDefined() {
113
+ return this.width >= 0 && this.height >= 0;
114
+ }
115
+ flatten() {
116
+ return new e(t(this.x), t(this.y), t(this.width), t(this.height));
117
+ }
118
+ containsPoint(e, t) {
119
+ return e >= this.x && e < this.x2 && t >= this.y && t < this.y2;
120
+ }
121
+ normalizePoint(e, t, n = !1) {
122
+ let r = {
123
+ x: (e - this.x) / this.width,
124
+ y: (t - this.y) / this.height
125
+ };
126
+ return n && (r.y = 1 - r.y), r;
127
+ }
128
+ denormalizePoint(e, t, n = !1) {
129
+ return n && (t = 1 - t), {
130
+ x: this.x + e * this.width,
131
+ y: this.y + t * this.height
132
+ };
133
+ }
134
+ toString() {
135
+ return `Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`;
136
+ }
137
+ toRoundedString() {
138
+ return `Rectangle: x: ${Math.round(this.x)}, y: ${Math.round(this.y)}, width: ${Math.round(this.width)}, height: ${Math.round(this.height)}`;
139
+ }
140
+ };
141
+ //#endregion
142
+ export { e as n, n as t };
@@ -0,0 +1,271 @@
1
+ import { a as e, o as t, s as n, u as r } from "./clipOptions-BQfNhxgP.js";
2
+ import { t as i } from "./warning-CpIIpk8e.js";
3
+ import { n as a } from "./layoutResult-D50MSHXR.js";
4
+ import { n as o } from "./performanceProfiler-CPLEjApa.js";
5
+ import { C as s, E as c, O as l, S as u, T as d, _ as f, a as p, c as m, d as h, f as g, h as _, i as v, k as y, l as b, m as x, n as S, o as C, p as w, r as T, s as E, t as D, u as O, w as k, y as A } from "./nativeText-DFV5XIx8.js";
6
+ //#region ../core/src/rendering/canvas2d/renderers/arrow.js
7
+ function j(e, t) {
8
+ let n = e, r = t.context, i = n.encoders, a = _(n);
9
+ r.lineJoin = "miter";
10
+ let o, c;
11
+ return f(n, a, t, (e) => {
12
+ e.headShapeFallback && t.warn(`Canvas2D rendered unsupported arrow headShape "${a.headShape}" as a triangle.`), r.beginPath();
13
+ for (let t of e.boundaryLoops) {
14
+ let e = t[0];
15
+ r.moveTo(e.x, e.y);
16
+ for (let e = 1; e < t.length; e++) r.lineTo(t[e].x, t[e].y);
17
+ r.closePath();
18
+ }
19
+ let n = s(i.fill(e.datum)), l = A(i.fillOpacity, e.datum) * t.viewOpacity;
20
+ n != "none" && l > 0 && (o != n && (r.fillStyle = n, o = n), r.globalAlpha = l, r.fill());
21
+ let u = s(i.stroke(e.datum)), d = A(i.strokeOpacity, e.datum) * t.viewOpacity;
22
+ u != "none" && d > 0 && e.strokeWidth > 0 && (c != u && (r.strokeStyle = u, c = u), r.globalAlpha = d, r.lineWidth = e.strokeWidth, r.stroke());
23
+ });
24
+ }
25
+ //#endregion
26
+ //#region ../core/src/rendering/canvas2d/renderers/link.js
27
+ function M(e, t) {
28
+ let n = e, r = t.context, i = n.encoders, a = u(n, n.properties.arcFadingDistance), o = w(n);
29
+ o.shape == "arc" && a !== !1 && a[0] > 0 && a[1] > 0 && t.warn("Canvas2D ignored unsupported link arc fading."), r.lineCap = "butt";
30
+ let c;
31
+ return x(n, o, t, (e) => {
32
+ let n = s(i.color(e.datum)), a = A(i.opacity, e.datum) * t.viewOpacity;
33
+ if (n == "none" || a <= 0 || e.strokeWidth <= 0) return;
34
+ c != n && (r.strokeStyle = n, c = n), r.globalAlpha = a, r.lineWidth = e.strokeWidth;
35
+ let [o, l, u, d] = e.points;
36
+ r.beginPath(), r.moveTo(o[0], o[1]), r.bezierCurveTo(l[0], l[1], u[0], u[1], d[0], d[1]), r.stroke();
37
+ });
38
+ }
39
+ //#endregion
40
+ //#region ../core/src/rendering/canvas2d/renderers/point.js
41
+ function N(e, t) {
42
+ let n = e;
43
+ u(n, n.properties.fillGradientStrength) && t.warn("Canvas2D ignored unsupported point property fillGradientStrength."), n.properties.geometricZoomBound && t.warn("Canvas2D ignored unsupported point property geometricZoomBound.");
44
+ let r = h(n), i = t.context, a = n.encoders, o, c;
45
+ return g(n, r, t, (e) => {
46
+ let n = e.datum, r = e.lineShape, l = s(a.fill(n)), u = A(a.fillOpacity, n) * t.viewOpacity, d = s(a.stroke(n)), f = A(a.strokeOpacity, n) * t.viewOpacity;
47
+ r && (d == "none" || f <= 0) && (d = l, f = u), i.beginPath();
48
+ let p = e.angle != 0 && e.shape != "circle";
49
+ p && (i.save(), i.translate(e.x, e.y), i.rotate(e.angle * Math.PI / 180));
50
+ let m = p ? 0 : e.x, h = p ? 0 : e.y, g = !0;
51
+ if (e.shape == "circle") i.arc(m, h, e.geometryRadius, 0, Math.PI * 2);
52
+ else if (e.shape == "square") {
53
+ let t = e.geometryRadius * 2;
54
+ i.rect(m - e.geometryRadius, h - e.geometryRadius, t, t);
55
+ } else g = O(e.shape, m, h, e.geometryRadius, i);
56
+ p && i.restore(), g || (t.warn(`Canvas2D rendered unsupported point shape "${e.shape}" as a circle.`), i.arc(e.x, e.y, e.geometryRadius, 0, Math.PI * 2)), !r && l != "none" && u > 0 && (o != l && (i.fillStyle = l, o = l), P(i, u), i.fill()), d != "none" && f > 0 && e.strokeWidth > 0 && (r && i.lineCap != "butt" && (i.lineCap = "butt"), c != d && (i.strokeStyle = d, c = d), P(i, f), F(i, e.strokeWidth), i.stroke());
57
+ });
58
+ }
59
+ function P(e, t) {
60
+ e.globalAlpha != t && (e.globalAlpha = t);
61
+ }
62
+ function F(e, t) {
63
+ e.lineWidth != t && (e.lineWidth = t);
64
+ }
65
+ //#endregion
66
+ //#region ../core/src/rendering/canvas2d/renderers/rect.js
67
+ function I(e, t) {
68
+ let n = e, r = m(n);
69
+ r.hatch != "none" && t.warn("Canvas2D ignored unsupported rect hatch.");
70
+ let i = t.start ?? 0;
71
+ if (i === (t.end ?? t.data.length)) return 0;
72
+ let a = t.context, o = n.encoders, c, l, u = [
73
+ 0,
74
+ 0,
75
+ 0,
76
+ 0
77
+ ], d = o.stroke.constant, f = o.strokeOpacity.constant, p = d ? s(o.stroke(t.data[i])) : "none", h = d && p == "none", g = !h && f ? A(o.strokeOpacity, t.data[i]) : 0;
78
+ return b(n, r, t, (e) => {
79
+ r.shadow.opacity > 0 && L(e, r.shadow, t, u);
80
+ let n = e.opacityFactor, i = e.fill != "none" && e.fillOpacity > 0, m = d ? p : s(o.stroke(e.datum)), _ = (f ? g : A(o.strokeOpacity, e.datum)) * t.viewOpacity * n, v = !h && m != "none" && _ > 0 && e.strokeWidth > 0, y = r.hasCornerRadii && (e.radii.topLeft != 0 || e.radii.topRight != 0 || e.radii.bottomRight != 0 || e.radii.bottomLeft != 0);
81
+ y && (i || v) && (u[0] = e.radii.topLeft, u[1] = e.radii.topRight, u[2] = e.radii.bottomRight, u[3] = e.radii.bottomLeft, a.beginPath(), a.roundRect(e.x, e.y, e.width, e.height, u)), i && (c != e.fill && (a.fillStyle = e.fill, c = e.fill), R(a, e.fillOpacity * n), y ? a.fill() : a.fillRect(e.x, e.y, e.width, e.height)), v && (l != m && (a.strokeStyle = m, l = m), R(a, _), z(a, e.strokeWidth), y ? a.stroke() : a.strokeRect(e.x, e.y, e.width, e.height));
82
+ });
83
+ }
84
+ function L(e, t, n, r) {
85
+ let { context: i, devicePixelRatio: a, visibleBounds: o } = n, s = e.strokeWidth / 2, c = e.x - s, l = e.y - s, u = e.width + s * 2, d = e.height + s * 2;
86
+ r[0] = e.radii.topLeft + s, r[1] = e.radii.topRight + s, r[2] = e.radii.bottomRight + s, r[3] = e.radii.bottomLeft + s, i.save();
87
+ try {
88
+ i.beginPath(), i.rect(o.x1, o.y1, o.x2 - o.x1, o.y2 - o.y1), i.roundRect(c, l, u, d, r), i.clip("evenodd"), i.shadowBlur = Math.max(t.blur / 2.5, .25) * 2 * a, i.shadowOffsetX = t.offsetX * a, i.shadowOffsetY = t.offsetY * a, i.shadowColor = t.color, i.globalAlpha = t.opacity * n.viewOpacity, i.fillStyle = "black", i.beginPath(), i.roundRect(c, l, u, d, r), i.fill();
89
+ } finally {
90
+ i.restore();
91
+ }
92
+ }
93
+ function R(e, t) {
94
+ e.globalAlpha != t && (e.globalAlpha = t);
95
+ }
96
+ function z(e, t) {
97
+ e.lineWidth != t && (e.lineWidth = t);
98
+ }
99
+ //#endregion
100
+ //#region ../core/src/rendering/canvas2d/renderers/rule.js
101
+ function B(e, t) {
102
+ let n = e, r = t.context, i = n.encoders;
103
+ r.lineCap = u(n, n.properties.strokeCap), r.setLineDash(u(n, n.properties.strokeDash) ?? []), r.lineDashOffset = u(n, n.properties.strokeDashOffset);
104
+ let a;
105
+ return E(n, C(n), t, (e) => {
106
+ let n = s(i.color(e.datum)), o = A(i.opacity, e.datum) * t.viewOpacity;
107
+ n == "none" || o <= 0 || e.strokeWidth <= 0 || (a != n && (r.strokeStyle = n, a = n), r.globalAlpha = o, r.lineWidth = e.strokeWidth, r.beginPath(), r.moveTo(e.x1, e.y1), r.lineTo(e.x2, e.y2), r.stroke());
108
+ });
109
+ }
110
+ //#endregion
111
+ //#region ../core/src/rendering/canvas2d/renderers/text.js
112
+ function V(e, t) {
113
+ let n = e, r = n.properties, i = v(n), a = t.context, o = n.encoders, c = D(r.font), l = `${r.fontStyle ?? "normal"} ${T(r.fontWeight ?? "normal")} `, d = i.baseline == "baseline" ? "alphabetic" : i.baseline;
114
+ [
115
+ r.viewportEdgeFadeWidthTop,
116
+ r.viewportEdgeFadeWidthRight,
117
+ r.viewportEdgeFadeWidthBottom,
118
+ r.viewportEdgeFadeWidthLeft
119
+ ].some((e) => u(n, e) > 0) && t.warn("Canvas2D ignored unsupported text viewport edge fading.");
120
+ let f, m;
121
+ return i.logoLetters || (a.textAlign = i.align, a.textBaseline = d), p(n, i, t, (e) => {
122
+ e.multiCharacterLogo && t.warn("Canvas2D stretches multi-character logo text as a single glyph cell.");
123
+ let n = s(o.color(e.datum)), r = A(o.opacity, e.datum) * t.viewOpacity * e.fadeOpacity;
124
+ if (!(n == "none" || r <= 0)) if (f != n && (a.fillStyle = n, f = n), a.globalAlpha = r, m != e.size && (a.font = `${l}${e.size}px ${c}`, m = e.size), e.logoScale) {
125
+ a.save(), a.translate(e.x, e.y), a.rotate(e.angle * Math.PI / 180), a.translate(e.dx, e.dy);
126
+ let t = a.measureText(e.text).width;
127
+ a.scale(e.logoScale.width / t, e.logoScale.heightScale), a.textAlign = "center", a.textBaseline = "alphabetic", a.fillText(e.text, 0, S("middle", 1)), a.restore();
128
+ } else e.angle ? (a.save(), a.translate(e.x, e.y), a.rotate(e.angle * Math.PI / 180), a.fillText(e.text, e.dx, e.dy, e.width), a.restore()) : a.fillText(e.text, e.x + e.dx, e.y + e.dy, e.width);
129
+ });
130
+ }
131
+ //#endregion
132
+ //#region ../core/src/rendering/canvas2d/renderers/index.js
133
+ function H(e, t) {
134
+ return e.getType() == "arrow" ? j(e, t) : e.getType() == "link" ? M(e, t) : e.getType() == "rect" ? I(e, t) : e.getType() == "point" ? N(e, t) : e.getType() == "rule" || e.getType() == "tick" ? B(e, t) : e.getType() == "text" ? V(e, t) : (t.warn(`Canvas2D rendering is not implemented for mark type "${e.getType()}".`), 0);
135
+ }
136
+ //#endregion
137
+ //#region ../core/src/rendering/sampleFacet.js
138
+ function U(e) {
139
+ let t = e.pixelToUnit, n = e.locSize.location * t, r = e.locSize.size * t;
140
+ return !(n > 1 || n + r < 0);
141
+ }
142
+ //#endregion
143
+ //#region ../core/src/rendering/canvas2d/canvas2DViewRenderingContext.js
144
+ var W = 8, G = 16777216, K = class extends a {
145
+ #e = [];
146
+ #t = /* @__PURE__ */ new WeakSet();
147
+ #n = /* @__PURE__ */ new WeakMap();
148
+ #r;
149
+ #i;
150
+ #a = new l();
151
+ #o;
152
+ #s = [0, 0];
153
+ #c;
154
+ #l;
155
+ #u = [];
156
+ constructor(e, t) {
157
+ if (super(e), this.context = t.context, this.width = t.width, this.height = t.height, this.devicePixelRatio = t.devicePixelRatio, this.paint = t.paint, this.#r = t.markPredicate ?? (() => !0), this.#i = o(), this.#o = t.xIndexManager, this.#l = t.opacityLayers ?? [], this.#c = {
158
+ x: 0,
159
+ y: 0,
160
+ width: this.context.canvas.width,
161
+ height: this.context.canvas.height
162
+ }, this.paint) {
163
+ let e = this.context;
164
+ e.resetTransform(), e.clearRect(0, 0, e.canvas.width, e.canvas.height), e.setTransform(this.devicePixelRatio, 0, 0, this.devicePixelRatio, 0, 0), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", t.background != null && (e.fillStyle = t.background, e.fillRect(0, 0, this.width, this.height));
165
+ }
166
+ }
167
+ getDevicePixelRatio() {
168
+ return this.devicePixelRatio;
169
+ }
170
+ pushView(t, n) {
171
+ this.paint && !this.#t.has(t) && (t.onBeforeRender(), this.#t.add(t));
172
+ let r = t.getOpacity();
173
+ if (this.paint && r > 0 && r !== 1) {
174
+ let r = e(t), i = q(n, this.devicePixelRatio, this.#c, r), a = J(this.#l, this.#u.length, i.width, i.height);
175
+ a.setTransform(this.devicePixelRatio, 0, 0, this.devicePixelRatio, -i.x, -i.y), this.#u.push({
176
+ context: this.context,
177
+ bounds: this.#c
178
+ }), this.context = a, this.#c = i;
179
+ }
180
+ this.#e.push({
181
+ view: t,
182
+ coords: n,
183
+ opacity: r
184
+ });
185
+ }
186
+ popView(e) {
187
+ let t = this.#e.pop();
188
+ if (t?.view !== e) throw Error("Unbalanced Canvas2D view rendering context stack.");
189
+ if (this.paint && t.opacity > 0 && t.opacity !== 1) {
190
+ let e = this.#u.pop();
191
+ if (!e) throw Error("Missing Canvas2D opacity parent target.");
192
+ let n = this.context.canvas, r = this.#c;
193
+ this.context = e.context, this.#c = e.bounds, this.context.save();
194
+ try {
195
+ this.context.globalAlpha = t.opacity, r.width && r.height && this.context.drawImage(n, r.x / this.devicePixelRatio, r.y / this.devicePixelRatio, r.width / this.devicePixelRatio, r.height / this.devicePixelRatio);
196
+ } finally {
197
+ this.context.restore();
198
+ }
199
+ }
200
+ }
201
+ renderMark(e, r) {
202
+ if (!this.paint || !this.#r(e)) return;
203
+ let a = this.#n.get(e.unitView);
204
+ if (a === void 0 && (a = e.unitView.getEffectiveOpacity(), this.#n.set(e.unitView, a)), a <= 0) return;
205
+ e.initializeRenderingRevisions([]);
206
+ let o = r.sampleFacetRenderingOptions;
207
+ if (o && !e.encoders.facetIndex && (this.#i?.addCount("canvasSampleFacetOccurrences"), !U(o))) {
208
+ this.#i?.addCount("canvasCulledSampleFacetOccurrences");
209
+ return;
210
+ }
211
+ let s = this.currentCoords, l = t(r), u = n(l, e.properties.clip, s), f = d(this.width, this.height, u);
212
+ if (!c(f)) return;
213
+ let p = k(s, l, e.properties.cullByVisibleRange), m = this.#o?.prepare(e) ?? !1, h = this.context;
214
+ if (h.save(), u) {
215
+ let e = u.rect.flatten(), t = u.clipX ? e.x : 0, n = u.clipY ? e.y : 0, r = u.clipX ? e.width : this.width, i = u.clipY ? e.height : this.height;
216
+ h.beginPath(), h.rect(t, n, r, i), h.clip();
217
+ }
218
+ try {
219
+ y(e, r, s, this.#a, (t, n) => {
220
+ let r = 0, a = n.length;
221
+ return m && this.#o.query(n, this.#s) && (r = this.#s[0], a = this.#s[1]), H(e, {
222
+ context: h,
223
+ devicePixelRatio: this.devicePixelRatio,
224
+ coords: t,
225
+ data: n,
226
+ start: r,
227
+ end: a,
228
+ visibleBounds: f,
229
+ anchorCullBounds: p,
230
+ viewOpacity: 1,
231
+ warn: (t) => i(`${t} View: ${e.unitView.getPathString()}`)
232
+ });
233
+ }, (t) => i(`Canvas2D could not resolve sample facet index ${t}. View: ${e.unitView.getPathString()}`));
234
+ } finally {
235
+ h.restore();
236
+ }
237
+ }
238
+ get currentCoords() {
239
+ let e = r(this.#e);
240
+ if (!e) throw Error("No current view in Canvas2D rendering context.");
241
+ return e.coords;
242
+ }
243
+ };
244
+ function q(e, t, n, r) {
245
+ let i = n.x + n.width, a = n.y + n.height, o = r.clipX ? Y(Math.floor(e.x * t), n.x, i) : n.x, s = r.clipY ? Y(Math.floor(e.y * t), n.y, a) : n.y, c = r.clipX ? Y(Math.ceil((e.x + e.width) * t), o, i) : i, l = r.clipY ? Y(Math.ceil((e.y + e.height) * t), s, a) : a;
246
+ return {
247
+ x: o,
248
+ y: s,
249
+ width: c - o,
250
+ height: l - s
251
+ };
252
+ }
253
+ function J(e, t, n, r) {
254
+ let i = n * r, a = e[t], o = e.reduce((e, n, r) => r === t ? e : e + n.canvas.width * n.canvas.height, 0), s = t < W && o + i <= G;
255
+ if (!a || !s) {
256
+ if (a = document.createElement("canvas").getContext("2d"), !a) throw Error("Unable to create a Canvas2D view group.");
257
+ s && (e[t] = a);
258
+ }
259
+ return a.canvas.width != n || a.canvas.height != r ? (a.canvas.width = n, a.canvas.height = r) : (a.resetTransform(), a.clearRect(0, 0, n, r)), a.globalAlpha = 1, a.globalCompositeOperation = "source-over", a;
260
+ }
261
+ function Y(e, t, n) {
262
+ return Math.min(n, Math.max(t, e));
263
+ }
264
+ //#endregion
265
+ //#region ../core/src/rendering/canvas2d/renderCanvas2D.js
266
+ function X(e) {
267
+ let t = new K({ picking: !1 }, e);
268
+ e.layoutResult.collectRenderCommands(t);
269
+ }
270
+ //#endregion
271
+ export { U as n, X as t };