@genome-spy/app 0.85.0 → 0.87.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.
- package/README.md +28 -0
- package/dist/{agentApi-Cz0hCnVp.js → agentApi-BZ1JCo1N.js} +7174 -8484
- package/dist/agentApi.es.js +3312 -3575
- package/dist/agentShared.es.js +14 -13
- package/dist/canvas2d-B_PnIof-.js +620 -0
- package/dist/canvas2d-Cafq5v-N.js +620 -0
- package/dist/{arrayUtils-LJpQOu-U.js → clipOptions-D6eh9T-_.js} +1060 -634
- package/dist/{paramUtils-BYI4rwyL.js → clipOptions-H68pJyEZ.js} +940 -514
- package/dist/{debug-CgDtmspT.js → debug-BGzgZmyk.js} +8 -8
- package/dist/{debug-BvCZWumf.js → debug-UYKZLNh4.js} +8 -8
- package/dist/index.es.js +2983 -2916
- package/dist/index.js +2006 -1997
- package/dist/indexer-Di57GyxX.js +72 -0
- package/dist/indexer-o6Hpg4nN.js +72 -0
- package/dist/layoutResult-D50MSHXR.js +97 -0
- package/dist/nativeText-D9SoxpaD.js +934 -0
- package/dist/nativeText-DAjvkrzc.js +934 -0
- package/dist/performanceProfiler-CPLEjApa.js +20 -0
- package/dist/rasterExport-DzldLv6E.js +44 -0
- package/dist/rasterExport-IAbJwi8F.js +44 -0
- package/dist/rasterImage-B4rPLaW9.js +18 -0
- package/dist/rasterization-CFogVB3B.js +50 -0
- package/dist/rectangle-DKnrAmKs.js +142 -0
- package/dist/renderCanvas2D-BJ93Ptqj.js +277 -0
- package/dist/renderCanvas2D-yJ1IrDcX.js +277 -0
- package/dist/schema.json +11685 -4428
- package/dist/{svg-yFj875aX.js → svg-BRpl2Xub.js} +412 -449
- package/dist/{svg-CCu8kYy2.js → svg-DJuqHIyc.js} +399 -436
- package/dist/svgRasterizer-CGZQ5njV.js +40 -0
- package/dist/svgRasterizer-PAoqLn1j.js +40 -0
- package/dist/vega-scale-BGC53c22.js +2403 -0
- package/dist/vega-scale-DdW2NzQ3.js +2403 -0
- package/dist/viewError-BiR9VCgL.js +29 -0
- package/dist/{viewIdentityRegistry-BUdkK9zT.js → viewIdentityRegistry-D4p067HU.js} +1 -1
- package/dist/{viewIdentityRegistry-D3oPbN4O.js → viewIdentityRegistry-Dc2hXYsO.js} +1 -1
- package/dist/viewSelectors-DNXnGwEW.js +2015 -0
- package/dist/viewSelectors-DYYlOt91.js +2015 -0
- package/dist/viewUtils-EdhZTPrJ.js +6448 -0
- package/dist/webgl-C53DwzVT.js +4127 -0
- package/dist/webgl-CdgNFlJk.js +4127 -0
- package/package.json +7 -6
- package/dist/bmFontMetrics-CuNB-kNN.js +0 -31
- package/dist/canvas2d-DoAXEiF9.js +0 -309
- package/dist/canvas2d-f5jl4A5D.js +0 -310
- package/dist/clipOptions-gqdb3fvW.js +0 -43
- package/dist/color-W5zffv-z.js +0 -335
- package/dist/framebufferReadback-CCLOjStu.js +0 -148
- package/dist/framebufferReadback-THWwFqs8.js +0 -1994
- package/dist/nativeText-DMO8gLt7.js +0 -806
- package/dist/nativeText-m5AUINMq.js +0 -806
- package/dist/twgl-full.module-DB2UdP1k.js +0 -1849
- package/dist/viewRenderingContext-HtpqwS_x.js +0 -120
- package/dist/viewSelectors-DGCspRN3.js +0 -4198
- package/dist/viewSelectors-U5oLCLHV.js +0 -4195
- package/dist/viewUtils-Dg4RA40Q.js +0 -7503
- package/dist/warning-DRGdb6BF.js +0 -59
- package/dist/webgl-Ci6ZhCCf.js +0 -54
- package/dist/webgl-Dpz8a3TI.js +0 -53
|
@@ -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-yJ1IrDcX.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-BJ93Ptqj.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,277 @@
|
|
|
1
|
+
import { a as e, an as t, m as n, o as r, s as i } from "./clipOptions-H68pJyEZ.js";
|
|
2
|
+
import { t as a } from "./warning-CpIIpk8e.js";
|
|
3
|
+
import { n as o } from "./performanceProfiler-CPLEjApa.js";
|
|
4
|
+
import { n as s } from "./layoutResult-D50MSHXR.js";
|
|
5
|
+
import { D as c, E as l, M as u, O as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as y, g as b, h as x, i as S, j as C, k as w, l as T, m as E, n as D, o as O, p as k, r as A, s as j, t as M, u as N, v as P } from "./nativeText-DAjvkrzc.js";
|
|
6
|
+
//#region ../core/src/rendering/canvas2d/renderers/arrow.js
|
|
7
|
+
function F(e, t) {
|
|
8
|
+
let n = e, r = t.context, i = n.encoders, a = P(n);
|
|
9
|
+
r.lineJoin = "miter";
|
|
10
|
+
let o, s;
|
|
11
|
+
return g(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 = l(i.fill(e.datum)), c = f(i.fillOpacity, e.datum) * t.viewOpacity;
|
|
20
|
+
n != "none" && c > 0 && (o != n && (r.fillStyle = n, o = n), r.globalAlpha = c, r.fill());
|
|
21
|
+
let u = l(i.stroke(e.datum)), d = f(i.strokeOpacity, e.datum) * t.viewOpacity;
|
|
22
|
+
u != "none" && d > 0 && e.strokeWidth > 0 && (s != u && (r.strokeStyle = u, s = 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 I(e, t) {
|
|
28
|
+
let r = e, i = t.context, a = r.encoders, o = k(r), s = b(r, o.shape);
|
|
29
|
+
i.lineCap = "butt";
|
|
30
|
+
let c;
|
|
31
|
+
return E(r, o, t, (e) => {
|
|
32
|
+
let r = l(a.color(e.datum)), o = f(a.opacity, e.datum) * t.viewOpacity;
|
|
33
|
+
if (r == "none" || o <= 0 || e.strokeWidth <= 0) return;
|
|
34
|
+
let u = s(e.datum), d = u && m(e.points[0], e.points[3], u);
|
|
35
|
+
if (d) {
|
|
36
|
+
let { normalX: e, normalY: t, offset: a, start: o, end: s } = d, l = i.createLinearGradient(e * (a - s), t * (a - s), e * (a + s), t * (a + s)), u = n(r), f = u.opacity;
|
|
37
|
+
for (let e of x(o, s)) u.opacity = f * e.opacity, l.addColorStop(e.offset, u.formatRgb());
|
|
38
|
+
i.strokeStyle = l, c = void 0;
|
|
39
|
+
} else c != r && (i.strokeStyle = r, c = r);
|
|
40
|
+
i.globalAlpha = o, i.lineWidth = e.strokeWidth;
|
|
41
|
+
let [p, h, g, _] = e.points;
|
|
42
|
+
i.beginPath(), i.moveTo(p[0], p[1]), i.bezierCurveTo(h[0], h[1], g[0], g[1], _[0], _[1]), i.stroke();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../core/src/rendering/canvas2d/renderers/point.js
|
|
47
|
+
function L(e, t) {
|
|
48
|
+
let n = e;
|
|
49
|
+
p(n, n.properties.fillGradientStrength) && t.warn("Canvas2D ignored unsupported point property fillGradientStrength."), n.properties.geometricZoomBound && t.warn("Canvas2D ignored unsupported point property geometricZoomBound.");
|
|
50
|
+
let r = v(n), i = t.context, a = n.encoders, o, s;
|
|
51
|
+
return y(n, r, t, (e) => {
|
|
52
|
+
let n = e.datum, r = e.lineShape, c = l(a.fill(n)), u = f(a.fillOpacity, n) * t.viewOpacity, d = l(a.stroke(n)), p = f(a.strokeOpacity, n) * t.viewOpacity;
|
|
53
|
+
r && (d == "none" || p <= 0) && (d = c, p = u), i.beginPath();
|
|
54
|
+
let m = e.angle != 0 && e.shape != "circle";
|
|
55
|
+
m && (i.save(), i.translate(e.x, e.y), i.rotate(e.angle * Math.PI / 180));
|
|
56
|
+
let h = m ? 0 : e.x, g = m ? 0 : e.y, _ = !0;
|
|
57
|
+
if (e.shape == "circle") i.arc(h, g, e.geometryRadius, 0, Math.PI * 2);
|
|
58
|
+
else if (e.shape == "square") {
|
|
59
|
+
let t = e.geometryRadius * 2;
|
|
60
|
+
i.rect(h - e.geometryRadius, g - e.geometryRadius, t, t);
|
|
61
|
+
} else _ = N(e.shape, h, g, e.geometryRadius, i);
|
|
62
|
+
m && i.restore(), _ || (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 && c != "none" && u > 0 && (o != c && (i.fillStyle = c, o = c), R(i, u), i.fill()), d != "none" && p > 0 && e.strokeWidth > 0 && (r && i.lineCap != "butt" && (i.lineCap = "butt"), s != d && (i.strokeStyle = d, s = d), R(i, p), z(i, e.strokeWidth), i.stroke());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function R(e, t) {
|
|
66
|
+
e.globalAlpha != t && (e.globalAlpha = t);
|
|
67
|
+
}
|
|
68
|
+
function z(e, t) {
|
|
69
|
+
e.lineWidth != t && (e.lineWidth = t);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../core/src/rendering/canvas2d/renderers/rect.js
|
|
73
|
+
function B(e, t) {
|
|
74
|
+
let n = e, r = _(n);
|
|
75
|
+
r.hatch != "none" && t.warn("Canvas2D ignored unsupported rect hatch.");
|
|
76
|
+
let i = t.start ?? 0;
|
|
77
|
+
if (i === (t.end ?? t.data.length)) return 0;
|
|
78
|
+
let a = t.context, o = n.encoders, s, c, u = [
|
|
79
|
+
0,
|
|
80
|
+
0,
|
|
81
|
+
0,
|
|
82
|
+
0
|
|
83
|
+
], d = o.stroke.constant, p = o.strokeOpacity.constant, m = d ? l(o.stroke(t.data[i])) : "none", h = d && m == "none", g = !h && p ? f(o.strokeOpacity, t.data[i]) : 0;
|
|
84
|
+
return T(n, r, t, (e) => {
|
|
85
|
+
r.shadow.opacity > 0 && V(e, r.shadow, t, u);
|
|
86
|
+
let n = e.opacityFactor, i = e.fill != "none" && e.fillOpacity > 0, _ = d ? m : l(o.stroke(e.datum)), v = (p ? g : f(o.strokeOpacity, e.datum)) * t.viewOpacity * n, y = !h && _ != "none" && v > 0 && e.strokeWidth > 0, b = r.hasCornerRadii && (e.radii.topLeft != 0 || e.radii.topRight != 0 || e.radii.bottomRight != 0 || e.radii.bottomLeft != 0);
|
|
87
|
+
b && (i || y) && (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 && (s != e.fill && (a.fillStyle = e.fill, s = e.fill), H(a, e.fillOpacity * n), b ? a.fill() : a.fillRect(e.x, e.y, e.width, e.height)), y && (c != _ && (a.strokeStyle = _, c = _), H(a, v), U(a, e.strokeWidth), b ? a.stroke() : a.strokeRect(e.x, e.y, e.width, e.height));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function V(e, t, n, r) {
|
|
91
|
+
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;
|
|
92
|
+
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();
|
|
93
|
+
try {
|
|
94
|
+
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();
|
|
95
|
+
} finally {
|
|
96
|
+
i.restore();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function H(e, t) {
|
|
100
|
+
e.globalAlpha != t && (e.globalAlpha = t);
|
|
101
|
+
}
|
|
102
|
+
function U(e, t) {
|
|
103
|
+
e.lineWidth != t && (e.lineWidth = t);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../core/src/rendering/canvas2d/renderers/rule.js
|
|
107
|
+
function W(e, t) {
|
|
108
|
+
let n = e, r = t.context, i = n.encoders;
|
|
109
|
+
r.lineCap = p(n, n.properties.strokeCap), r.setLineDash(p(n, n.properties.strokeDash) ?? []), r.lineDashOffset = p(n, n.properties.strokeDashOffset);
|
|
110
|
+
let a;
|
|
111
|
+
return j(n, O(n), t, (e) => {
|
|
112
|
+
let n = l(i.color(e.datum)), o = f(i.opacity, e.datum) * t.viewOpacity;
|
|
113
|
+
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());
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region ../core/src/rendering/canvas2d/renderers/text.js
|
|
118
|
+
function G(e, t) {
|
|
119
|
+
let n = e, r = n.properties, i = S(n), a = t.context, o = n.encoders, s = M(r.font), c = `${r.fontStyle ?? "normal"} ${A(r.fontWeight ?? "normal")} `, u = i.baseline == "baseline" ? "alphabetic" : i.baseline;
|
|
120
|
+
[
|
|
121
|
+
r.viewportEdgeFadeWidthTop,
|
|
122
|
+
r.viewportEdgeFadeWidthRight,
|
|
123
|
+
r.viewportEdgeFadeWidthBottom,
|
|
124
|
+
r.viewportEdgeFadeWidthLeft
|
|
125
|
+
].some((e) => p(n, e) > 0) && t.warn("Canvas2D ignored unsupported text viewport edge fading.");
|
|
126
|
+
let d, m;
|
|
127
|
+
return i.logoLetters || (a.textAlign = i.align, a.textBaseline = u), h(n, i, t, (e) => {
|
|
128
|
+
e.multiCharacterLogo && t.warn("Canvas2D stretches multi-character logo text as a single glyph cell.");
|
|
129
|
+
let n = l(o.color(e.datum)), r = f(o.opacity, e.datum) * t.viewOpacity * e.fadeOpacity;
|
|
130
|
+
if (!(n == "none" || r <= 0)) if (d != n && (a.fillStyle = n, d = n), a.globalAlpha = r, m != e.size && (a.font = `${c}${e.size}px ${s}`, m = e.size), e.logoScale) {
|
|
131
|
+
a.save(), a.translate(e.x, e.y), a.rotate(e.angle * Math.PI / 180), a.translate(e.dx, e.dy);
|
|
132
|
+
let t = a.measureText(e.text).width;
|
|
133
|
+
a.scale(e.logoScale.width / t, e.logoScale.heightScale), a.textAlign = "center", a.textBaseline = "alphabetic", a.fillText(e.text, 0, D("middle", 1)), a.restore();
|
|
134
|
+
} 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);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../core/src/rendering/canvas2d/renderers/index.js
|
|
139
|
+
function K(e, t) {
|
|
140
|
+
return e.getType() == "arrow" ? F(e, t) : e.getType() == "link" ? I(e, t) : e.getType() == "rect" ? B(e, t) : e.getType() == "point" ? L(e, t) : e.getType() == "rule" || e.getType() == "tick" ? W(e, t) : e.getType() == "text" ? G(e, t) : (t.warn(`Canvas2D rendering is not implemented for mark type "${e.getType()}".`), 0);
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region ../core/src/rendering/sampleFacet.js
|
|
144
|
+
function q(e) {
|
|
145
|
+
let t = e.pixelToUnit, n = e.locSize.location * t, r = e.locSize.size * t;
|
|
146
|
+
return !(n > 1 || n + r < 0);
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region ../core/src/rendering/canvas2d/canvas2DViewRenderingContext.js
|
|
150
|
+
var J = 8, Y = 16777216, X = class extends s {
|
|
151
|
+
#e = [];
|
|
152
|
+
#t = /* @__PURE__ */ new WeakSet();
|
|
153
|
+
#n = /* @__PURE__ */ new WeakMap();
|
|
154
|
+
#r;
|
|
155
|
+
#i;
|
|
156
|
+
#a = new C();
|
|
157
|
+
#o;
|
|
158
|
+
#s = [0, 0];
|
|
159
|
+
#c;
|
|
160
|
+
#l;
|
|
161
|
+
#u = [];
|
|
162
|
+
constructor(e, t) {
|
|
163
|
+
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 = {
|
|
164
|
+
x: 0,
|
|
165
|
+
y: 0,
|
|
166
|
+
width: this.context.canvas.width,
|
|
167
|
+
height: this.context.canvas.height
|
|
168
|
+
}, this.paint) {
|
|
169
|
+
let e = this.context;
|
|
170
|
+
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));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
getDevicePixelRatio() {
|
|
174
|
+
return this.devicePixelRatio;
|
|
175
|
+
}
|
|
176
|
+
pushView(t, n) {
|
|
177
|
+
this.paint && !this.#t.has(t) && (t.onBeforeRender(), this.#t.add(t));
|
|
178
|
+
let r = t.getOpacity();
|
|
179
|
+
if (this.paint && r > 0 && r !== 1) {
|
|
180
|
+
let r = e(t), i = Z(n, this.devicePixelRatio, this.#c, r), a = Q(this.#l, this.#u.length, i.width, i.height);
|
|
181
|
+
a.setTransform(this.devicePixelRatio, 0, 0, this.devicePixelRatio, -i.x, -i.y), this.#u.push({
|
|
182
|
+
context: this.context,
|
|
183
|
+
bounds: this.#c
|
|
184
|
+
}), this.context = a, this.#c = i;
|
|
185
|
+
}
|
|
186
|
+
this.#e.push({
|
|
187
|
+
view: t,
|
|
188
|
+
coords: n,
|
|
189
|
+
opacity: r
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
popView(e) {
|
|
193
|
+
let t = this.#e.pop();
|
|
194
|
+
if (t?.view !== e) throw Error("Unbalanced Canvas2D view rendering context stack.");
|
|
195
|
+
if (this.paint && t.opacity > 0 && t.opacity !== 1) {
|
|
196
|
+
let e = this.#u.pop();
|
|
197
|
+
if (!e) throw Error("Missing Canvas2D opacity parent target.");
|
|
198
|
+
let n = this.context.canvas, r = this.#c;
|
|
199
|
+
this.context = e.context, this.#c = e.bounds, this.context.save();
|
|
200
|
+
try {
|
|
201
|
+
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);
|
|
202
|
+
} finally {
|
|
203
|
+
this.context.restore();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
renderMark(e, t) {
|
|
208
|
+
if (!this.paint || !this.#r(e)) return;
|
|
209
|
+
let n = this.#n.get(e.unitView);
|
|
210
|
+
if (n === void 0 && (n = e.unitView.getEffectiveOpacity(), this.#n.set(e.unitView, n)), n <= 0) return;
|
|
211
|
+
e.initializeRenderingRevisions(Object.keys(e.properties));
|
|
212
|
+
let o = t.sampleFacetRenderingOptions;
|
|
213
|
+
if (o && !e.encoders.facetIndex && (this.#i?.addCount("canvasSampleFacetOccurrences"), !q(o))) {
|
|
214
|
+
this.#i?.addCount("canvasCulledSampleFacetOccurrences");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
let s = this.currentCoords, l = r(t), f = i(l, e.properties.clip, s), p = d(this.width, this.height, f);
|
|
218
|
+
if (!w(p)) return;
|
|
219
|
+
let m = c(s, l, e.properties.cullByVisibleRange), h = this.#o?.prepare(e) ?? !1, g = this.context;
|
|
220
|
+
if (g.save(), f) {
|
|
221
|
+
let e = f.rect.flatten(), t = f.clipX ? e.x : 0, n = f.clipY ? e.y : 0, r = f.clipX ? e.width : this.width, i = f.clipY ? e.height : this.height;
|
|
222
|
+
g.beginPath(), g.rect(t, n, r, i), g.clip();
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
u(e, t, s, this.#a, (t, n) => {
|
|
226
|
+
let r = 0, i = n.length;
|
|
227
|
+
return h && this.#o.query(n, this.#s) && (r = this.#s[0], i = this.#s[1]), K(e, {
|
|
228
|
+
context: g,
|
|
229
|
+
devicePixelRatio: this.devicePixelRatio,
|
|
230
|
+
coords: t,
|
|
231
|
+
data: n,
|
|
232
|
+
start: r,
|
|
233
|
+
end: i,
|
|
234
|
+
visibleBounds: p,
|
|
235
|
+
anchorCullBounds: m,
|
|
236
|
+
viewOpacity: 1,
|
|
237
|
+
warn: (t) => a(`${t} View: ${e.unitView.getPathString()}`)
|
|
238
|
+
});
|
|
239
|
+
}, (t) => a(`Canvas2D could not resolve sample facet index ${t}. View: ${e.unitView.getPathString()}`));
|
|
240
|
+
} finally {
|
|
241
|
+
g.restore();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
get currentCoords() {
|
|
245
|
+
let e = t(this.#e);
|
|
246
|
+
if (!e) throw Error("No current view in Canvas2D rendering context.");
|
|
247
|
+
return e.coords;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
function Z(e, t, n, r) {
|
|
251
|
+
let i = n.x + n.width, a = n.y + n.height, o = r.clipX ? $(Math.floor(e.x * t), n.x, i) : n.x, s = r.clipY ? $(Math.floor(e.y * t), n.y, a) : n.y, c = r.clipX ? $(Math.ceil((e.x + e.width) * t), o, i) : i, l = r.clipY ? $(Math.ceil((e.y + e.height) * t), s, a) : a;
|
|
252
|
+
return {
|
|
253
|
+
x: o,
|
|
254
|
+
y: s,
|
|
255
|
+
width: c - o,
|
|
256
|
+
height: l - s
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function Q(e, t, n, r) {
|
|
260
|
+
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 < J && o + i <= Y;
|
|
261
|
+
if (!a || !s) {
|
|
262
|
+
if (a = document.createElement("canvas").getContext("2d"), !a) throw Error("Unable to create a Canvas2D view group.");
|
|
263
|
+
s && (e[t] = a);
|
|
264
|
+
}
|
|
265
|
+
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;
|
|
266
|
+
}
|
|
267
|
+
function $(e, t, n) {
|
|
268
|
+
return Math.min(n, Math.max(t, e));
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region ../core/src/rendering/canvas2d/renderCanvas2D.js
|
|
272
|
+
function ee(e) {
|
|
273
|
+
let t = new X({ picking: !1 }, e);
|
|
274
|
+
e.layoutResult.collectRenderCommands(t);
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { q as n, ee as t };
|