@genome-spy/app 0.85.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.
- package/README.md +28 -0
- package/dist/{agentApi-Cz0hCnVp.js → agentApi-DgopQbMV.js} +5019 -6824
- package/dist/agentApi.es.js +2757 -2852
- package/dist/agentShared.es.js +15 -14
- package/dist/canvas2d-8uxuN_vx.js +619 -0
- package/dist/canvas2d-BtQC7Xr8.js +619 -0
- package/dist/{arrayUtils-LJpQOu-U.js → clipOptions-BQfNhxgP.js} +625 -561
- package/dist/{paramUtils-BYI4rwyL.js → clipOptions-taFzEljc.js} +192 -128
- package/dist/{debug-BvCZWumf.js → debug-Bzc3SoRg.js} +8 -8
- package/dist/{debug-CgDtmspT.js → debug-D_VtWQ6l.js} +8 -8
- package/dist/index.es.js +2992 -2915
- package/dist/index.js +2006 -2004
- package/dist/indexer-qiFctgR3.js +72 -0
- package/dist/indexer-qy_dq5l5.js +72 -0
- package/dist/layoutResult-D50MSHXR.js +97 -0
- package/dist/{nativeText-m5AUINMq.js → nativeText-DFV5XIx8.js} +247 -193
- package/dist/{nativeText-DMO8gLt7.js → nativeText-vT3AWE14.js} +244 -190
- package/dist/performanceProfiler-CPLEjApa.js +20 -0
- package/dist/rasterExport-B8pVoOsj.js +44 -0
- package/dist/rasterExport-C4r4xjQT.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-BQrRWp2Z.js +271 -0
- package/dist/renderCanvas2D-CHVNfIUz.js +271 -0
- package/dist/schema.json +71 -131
- package/dist/{svg-CCu8kYy2.js → svg-C-Sw6E6G.js} +286 -277
- package/dist/{svg-yFj875aX.js → svg-CKHwwKRt.js} +278 -269
- package/dist/svgRasterizer-BgD72AmG.js +40 -0
- package/dist/svgRasterizer-BgSNqI3L.js +40 -0
- package/dist/vega-scale-CK0_al6O.js +2700 -0
- package/dist/vega-scale-D46-iCaL.js +2700 -0
- package/dist/viewError-BiR9VCgL.js +29 -0
- package/dist/{viewIdentityRegistry-D3oPbN4O.js → viewIdentityRegistry-B-VGlez1.js} +1 -1
- package/dist/{viewIdentityRegistry-BUdkK9zT.js → viewIdentityRegistry-CDtVktJD.js} +1 -1
- package/dist/viewSelectors-CKfxF_LM.js +1817 -0
- package/dist/viewSelectors-D_imtq5Z.js +1817 -0
- package/dist/viewUtils-nCJ7AoaI.js +5782 -0
- package/dist/webgl-BaA3jSa2.js +4128 -0
- package/dist/webgl-FP-4EsBL.js +4128 -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/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
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"contributors": [],
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"homepage": "https://genomespy.app/",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.86.0",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"module": "dist/index.es.js",
|
|
14
14
|
"type": "module",
|
|
@@ -56,11 +56,12 @@
|
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"dev": "node dev-server.mjs",
|
|
59
|
-
"build": "rm -rf dist && mkdir -p dist && vite build && vite build --config vite.agent-subpaths.config.js && npm run build:schema",
|
|
59
|
+
"build": "rm -rf dist && mkdir -p dist && vite build && vite build --config vite.agent-subpaths.config.js && npm run build:schema && node scripts/verifyProductionBundle.mjs",
|
|
60
60
|
"build:schema": "mkdir -p dist && ts-json-schema-generator --path 'src/spec/*.d.ts' --type AppRootSpec > dist/schema.json",
|
|
61
61
|
"test:tsc": "npm run test:tsc:src && npm run test:tsc:tests",
|
|
62
62
|
"test:tsc:src": "tsc -p tsconfig.json --noEmit",
|
|
63
63
|
"test:tsc:tests": "tsc -p tsconfig.tests.json --noEmit",
|
|
64
|
+
"smoke:examples:webgpu": "node ../core/scripts/runWebGpuExamples.mjs --scope app --all --compare-webgl",
|
|
64
65
|
"storybook": "storybook dev -p 6006",
|
|
65
66
|
"build-storybook": "storybook build",
|
|
66
67
|
"prepublishOnly": "npm run build"
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
71
72
|
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
|
72
73
|
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
|
73
|
-
"@genome-spy/core": "^0.
|
|
74
|
+
"@genome-spy/core": "^0.86.0",
|
|
74
75
|
"@reduxjs/toolkit": "^2.11.0",
|
|
75
76
|
"d3-color": "^3.1.0",
|
|
76
77
|
"idb": "^7.1.1",
|
|
@@ -83,8 +84,8 @@
|
|
|
83
84
|
"zarrita": "^0.6.1"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
|
-
"@genome-spy/app-agent": "^0.
|
|
87
|
-
"@genome-spy/inspector": "^0.
|
|
87
|
+
"@genome-spy/app-agent": "^0.86.0",
|
|
88
|
+
"@genome-spy/inspector": "^0.86.0"
|
|
88
89
|
},
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "d90789e619350444c0cb12b611d09fb0a0587de1"
|
|
90
91
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
return {
|
|
21
|
-
measureWidth: p,
|
|
22
|
-
getCharByCode: i,
|
|
23
|
-
getChar: a,
|
|
24
|
-
xHeight: u,
|
|
25
|
-
capHeight: d,
|
|
26
|
-
descent: f,
|
|
27
|
-
common: e.common
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { e as t };
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { Vt as e } from "./paramUtils-BYI4rwyL.js";
|
|
2
|
-
import { a as t, o as n } from "./clipOptions-gqdb3fvW.js";
|
|
3
|
-
import { n as r, t as i } from "./warning-DRGdb6BF.js";
|
|
4
|
-
import { n as a, t as o } from "./viewRenderingContext-HtpqwS_x.js";
|
|
5
|
-
import { C as s, E as c, S as l, _ as u, a as d, b as f, c as p, d as m, f as h, g, h as _, i as v, l as y, m as b, n as x, o as S, p as C, r as w, s as T, t as E, u as D, w as O, x as k } from "./nativeText-DMO8gLt7.js";
|
|
6
|
-
//#region ../core/src/rendering/canvas2d/renderers/arrow.js
|
|
7
|
-
function A(e, t) {
|
|
8
|
-
let n = e, r = t.context, i = n.encoders, a = _(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 = k(i.fill(e.datum)), c = u(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 l = k(i.stroke(e.datum)), d = u(i.strokeOpacity, e.datum) * t.viewOpacity;
|
|
22
|
-
l != "none" && d > 0 && e.strokeWidth > 0 && (s != l && (r.strokeStyle = l, s = l), r.globalAlpha = d, r.lineWidth = e.strokeWidth, r.stroke());
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region ../core/src/rendering/canvas2d/renderers/link.js
|
|
27
|
-
function j(e, t) {
|
|
28
|
-
let n = e, r = t.context, i = n.encoders, a = f(n, n.properties.arcFadingDistance), o = C(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 s;
|
|
31
|
-
return b(n, o, t, (e) => {
|
|
32
|
-
let n = k(i.color(e.datum)), a = u(i.opacity, e.datum) * t.viewOpacity;
|
|
33
|
-
if (n == "none" || a <= 0 || e.strokeWidth <= 0) return;
|
|
34
|
-
s != n && (r.strokeStyle = n, s = n), r.globalAlpha = a, r.lineWidth = e.strokeWidth;
|
|
35
|
-
let [o, c, l, d] = e.points;
|
|
36
|
-
r.beginPath(), r.moveTo(o[0], o[1]), r.bezierCurveTo(c[0], c[1], l[0], l[1], d[0], d[1]), r.stroke();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region ../core/src/rendering/canvas2d/renderers/point.js
|
|
41
|
-
function M(e, t) {
|
|
42
|
-
let n = e;
|
|
43
|
-
f(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 = m(n), i = t.context, a = n.encoders, o, s;
|
|
45
|
-
return h(n, r, t, (e) => {
|
|
46
|
-
let n = e.datum, r = e.lineShape, c = k(a.fill(n)), l = u(a.fillOpacity, n) * t.viewOpacity, d = k(a.stroke(n)), f = u(a.strokeOpacity, n) * t.viewOpacity;
|
|
47
|
-
r && (d == "none" || f <= 0) && (d = c, f = l), 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 = D(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 && c != "none" && l > 0 && (o != c && (i.fillStyle = c, o = c), N(i, l), i.fill()), d != "none" && f > 0 && e.strokeWidth > 0 && (r && i.lineCap != "butt" && (i.lineCap = "butt"), s != d && (i.strokeStyle = d, s = d), N(i, f), P(i, e.strokeWidth), i.stroke());
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function N(e, t) {
|
|
60
|
-
e.globalAlpha != t && (e.globalAlpha = t);
|
|
61
|
-
}
|
|
62
|
-
function P(e, t) {
|
|
63
|
-
e.lineWidth != t && (e.lineWidth = t);
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region ../core/src/rendering/canvas2d/renderers/rect.js
|
|
67
|
-
function F(e, t) {
|
|
68
|
-
let n = e, r = p(n);
|
|
69
|
-
r.hatch != "none" && t.warn("Canvas2D ignored unsupported rect hatch."), r.shadow.opacity > 0 && t.warn("Canvas2D ignored unsupported rect shadow.");
|
|
70
|
-
let i = t.context, a = n.encoders, o, s, c = [
|
|
71
|
-
0,
|
|
72
|
-
0,
|
|
73
|
-
0,
|
|
74
|
-
0
|
|
75
|
-
];
|
|
76
|
-
return y(n, r, t, (e) => {
|
|
77
|
-
let n = e.opacityFactor, r = e.fill != "none" && e.fillOpacity > 0, l = k(a.stroke(e.datum)), d = u(a.strokeOpacity, e.datum) * t.viewOpacity * n, f = l != "none" && d > 0 && e.strokeWidth > 0, p = e.radii.topLeft != 0 || e.radii.topRight != 0 || e.radii.bottomRight != 0 || e.radii.bottomLeft != 0;
|
|
78
|
-
p && (r || f) && (c[0] = e.radii.topLeft, c[1] = e.radii.topRight, c[2] = e.radii.bottomRight, c[3] = e.radii.bottomLeft, i.beginPath(), i.roundRect(e.x, e.y, e.width, e.height, c)), r && (o != e.fill && (i.fillStyle = e.fill, o = e.fill), I(i, e.fillOpacity * n), p ? i.fill() : i.fillRect(e.x, e.y, e.width, e.height)), f && (s != l && (i.strokeStyle = l, s = l), I(i, d), L(i, e.strokeWidth), p ? i.stroke() : i.strokeRect(e.x, e.y, e.width, e.height));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function I(e, t) {
|
|
82
|
-
e.globalAlpha != t && (e.globalAlpha = t);
|
|
83
|
-
}
|
|
84
|
-
function L(e, t) {
|
|
85
|
-
e.lineWidth != t && (e.lineWidth = t);
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region ../core/src/rendering/canvas2d/renderers/rule.js
|
|
89
|
-
function R(e, t) {
|
|
90
|
-
let n = e, r = t.context, i = n.encoders;
|
|
91
|
-
r.lineCap = f(n, n.properties.strokeCap), r.setLineDash(f(n, n.properties.strokeDash) ?? []), r.lineDashOffset = f(n, n.properties.strokeDashOffset);
|
|
92
|
-
let a;
|
|
93
|
-
return T(n, S(n), t, (e) => {
|
|
94
|
-
let n = k(i.color(e.datum)), o = u(i.opacity, e.datum) * t.viewOpacity;
|
|
95
|
-
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());
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region ../core/src/rendering/canvas2d/renderers/text.js
|
|
100
|
-
function z(e, t) {
|
|
101
|
-
let n = e, r = n.properties, i = v(n), a = t.context, o = n.encoders, s = E(r.font), c = `${r.fontStyle ?? "normal"} ${w(r.fontWeight ?? "normal")} `, l = i.baseline == "baseline" ? "alphabetic" : i.baseline;
|
|
102
|
-
[
|
|
103
|
-
r.viewportEdgeFadeWidthTop,
|
|
104
|
-
r.viewportEdgeFadeWidthRight,
|
|
105
|
-
r.viewportEdgeFadeWidthBottom,
|
|
106
|
-
r.viewportEdgeFadeWidthLeft
|
|
107
|
-
].some((e) => f(n, e) > 0) && t.warn("Canvas2D ignored unsupported text viewport edge fading.");
|
|
108
|
-
let p, m;
|
|
109
|
-
return i.logoLetters || (a.textAlign = i.align, a.textBaseline = l), d(n, i, t, (e) => {
|
|
110
|
-
e.multiCharacterLogo && t.warn("Canvas2D stretches multi-character logo text as a single glyph cell.");
|
|
111
|
-
let n = k(o.color(e.datum)), r = u(o.opacity, e.datum) * t.viewOpacity * e.fadeOpacity;
|
|
112
|
-
if (!(n == "none" || r <= 0)) if (p != n && (a.fillStyle = n, p = n), a.globalAlpha = r, m != e.size && (a.font = `${c}${e.size}px ${s}`, m = e.size), e.logoScale) {
|
|
113
|
-
a.save(), a.translate(e.x, e.y), a.rotate(e.angle * Math.PI / 180), a.translate(e.dx, e.dy);
|
|
114
|
-
let t = a.measureText(e.text).width;
|
|
115
|
-
a.scale(e.logoScale.width / t, e.logoScale.heightScale), a.textAlign = "center", a.textBaseline = "alphabetic", a.fillText(e.text, 0, x("middle", 1)), a.restore();
|
|
116
|
-
} 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);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region ../core/src/rendering/canvas2d/renderers/index.js
|
|
121
|
-
function B(e, t) {
|
|
122
|
-
return e.getType() == "arrow" ? A(e, t) : e.getType() == "link" ? j(e, t) : e.getType() == "rect" ? F(e, t) : e.getType() == "point" ? M(e, t) : e.getType() == "rule" || e.getType() == "tick" ? R(e, t) : e.getType() == "text" ? z(e, t) : (t.warn(`Canvas2D rendering is not implemented for mark type "${e.getType()}".`), 0);
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region ../core/src/rendering/canvas2d/canvas2DViewRenderingContext.js
|
|
126
|
-
var V = class extends o {
|
|
127
|
-
#e = [];
|
|
128
|
-
#t = /* @__PURE__ */ new Set();
|
|
129
|
-
constructor(e, t) {
|
|
130
|
-
if (super(e), this.context = t.context, this.width = t.width, this.height = t.height, this.devicePixelRatio = t.devicePixelRatio, this.paint = t.paint, this.paint) {
|
|
131
|
-
let e = this.context;
|
|
132
|
-
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));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
getDevicePixelRatio() {
|
|
136
|
-
return this.devicePixelRatio;
|
|
137
|
-
}
|
|
138
|
-
pushView(e, t) {
|
|
139
|
-
this.paint && !this.#t.has(e) && (e.onBeforeRender(), this.#t.add(e)), this.#e.push({
|
|
140
|
-
view: e,
|
|
141
|
-
coords: t
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
popView(e) {
|
|
145
|
-
if (this.#e.pop()?.view !== e) throw Error("Unbalanced Canvas2D view rendering context stack.");
|
|
146
|
-
}
|
|
147
|
-
renderMark(e, r) {
|
|
148
|
-
if (!this.paint || e.unitView.getEffectiveOpacity() <= 0) return;
|
|
149
|
-
let a = this.currentCoords, o = t(r), u = n(o, e.properties.clip, a), d = s(this.width, this.height, u);
|
|
150
|
-
if (!O(d)) return;
|
|
151
|
-
let f = l(a, o, e.properties.cullByVisibleRange), p = this.context;
|
|
152
|
-
if (p.save(), u) {
|
|
153
|
-
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;
|
|
154
|
-
p.beginPath(), p.rect(t, n, r, i), p.clip();
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
c(e, r, a, (t, n) => B(e, {
|
|
158
|
-
context: p,
|
|
159
|
-
coords: t,
|
|
160
|
-
data: n,
|
|
161
|
-
visibleBounds: d,
|
|
162
|
-
anchorCullBounds: f,
|
|
163
|
-
viewOpacity: e.unitView.getEffectiveOpacity(),
|
|
164
|
-
warn: (t) => i(`${t} View: ${e.unitView.getPathString()}`)
|
|
165
|
-
}), (t) => i(`Canvas2D could not resolve sample facet index ${t}. View: ${e.unitView.getPathString()}`));
|
|
166
|
-
} finally {
|
|
167
|
-
p.restore();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
get currentCoords() {
|
|
171
|
-
let t = e(this.#e);
|
|
172
|
-
if (!t) throw Error("No current view in Canvas2D rendering context.");
|
|
173
|
-
return t.coords;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region ../core/src/rendering/canvas2d/renderCanvas2D.js
|
|
178
|
-
function H(e) {
|
|
179
|
-
let t = new V({ picking: !1 }, e);
|
|
180
|
-
e.viewRoot.render(t, a.create(0, 0, e.width, e.height), { firstFacet: !0 });
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region ../core/src/rendering/canvas2d/canvas2DRenderCoordinator.js
|
|
184
|
-
var U = class {
|
|
185
|
-
constructor(e) {
|
|
186
|
-
this.viewRoot = e.viewRoot, this.context = e.context, this.surface = e.surface, this.getBackground = e.getBackground, this.broadcast = e.broadcast, this.onLayoutComputed = e.onLayoutComputed;
|
|
187
|
-
}
|
|
188
|
-
computeLayout() {
|
|
189
|
-
this.broadcast("layout"), this.surface.invalidateSize();
|
|
190
|
-
let e = 5;
|
|
191
|
-
for (;;) {
|
|
192
|
-
if (this.#e(!1), !this.surface.invalidateSize()) {
|
|
193
|
-
this.onLayoutComputed(), this.broadcast("layoutComputed");
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (e--, e == 0) throw Error("Layout did not settle: canvas size kept changing.");
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
renderAll() {
|
|
200
|
-
this.#e(!0);
|
|
201
|
-
}
|
|
202
|
-
#e(e) {
|
|
203
|
-
let t = this.surface.getLogicalCanvasSize();
|
|
204
|
-
isNaN(t.width) || isNaN(t.height) || H({
|
|
205
|
-
viewRoot: this.viewRoot,
|
|
206
|
-
context: this.context,
|
|
207
|
-
width: t.width,
|
|
208
|
-
height: t.height,
|
|
209
|
-
devicePixelRatio: this.surface.getDevicePixelRatio(),
|
|
210
|
-
background: this.getBackground(),
|
|
211
|
-
paint: e
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}, W = class {
|
|
215
|
-
#e;
|
|
216
|
-
#t;
|
|
217
|
-
constructor(e) {
|
|
218
|
-
let t = document.createElement("canvas"), n = t.getContext("2d");
|
|
219
|
-
if (!n) throw Error("Unable to initialize a Canvas2D rendering context.");
|
|
220
|
-
this.canvas = t, this.context = n, e.container.appendChild(t);
|
|
221
|
-
try {
|
|
222
|
-
this.#e = new r(e.container, t, e.sizeSource, () => {
|
|
223
|
-
this.#n() && e.onCanvasResize();
|
|
224
|
-
}), this.#n();
|
|
225
|
-
} catch (e) {
|
|
226
|
-
throw this.#e?.finalize(), t.remove(), e;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
invalidateSize() {
|
|
230
|
-
return this.#e.invalidate(), this.#n();
|
|
231
|
-
}
|
|
232
|
-
#n() {
|
|
233
|
-
let e = this.getLogicalCanvasSize(), t = this.#e.getPhysicalCanvasSize(e);
|
|
234
|
-
return this.#t?.logicalWidth == e.width && this.#t.logicalHeight == e.height && this.#t.physicalWidth == t.width && this.#t.physicalHeight == t.height ? !1 : (this.canvas.style.width = `${e.width}px`, this.canvas.style.height = `${e.height}px`, this.canvas.width = t.width, this.canvas.height = t.height, this.#t = {
|
|
235
|
-
logicalWidth: e.width,
|
|
236
|
-
logicalHeight: e.height,
|
|
237
|
-
physicalWidth: t.width,
|
|
238
|
-
physicalHeight: t.height
|
|
239
|
-
}, !0);
|
|
240
|
-
}
|
|
241
|
-
getLogicalCanvasSize() {
|
|
242
|
-
return this.#e.getLogicalCanvasSize();
|
|
243
|
-
}
|
|
244
|
-
getDevicePixelRatio() {
|
|
245
|
-
return this.#e.getDevicePixelRatio();
|
|
246
|
-
}
|
|
247
|
-
finalize() {
|
|
248
|
-
this.#e.finalize(), this.canvas.remove();
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region ../core/src/rendering/canvas2d/rasterExport.js
|
|
253
|
-
async function G(e) {
|
|
254
|
-
let t = e.mimeType ?? "image/png";
|
|
255
|
-
if (t != "image/png") throw Error(`Unsupported raster export MIME type: ${t}`);
|
|
256
|
-
let n = q(e);
|
|
257
|
-
return new Promise((e, r) => {
|
|
258
|
-
n.toBlob((t) => {
|
|
259
|
-
t ? e(t) : r(/* @__PURE__ */ Error("Canvas2D could not encode the raster export."));
|
|
260
|
-
}, t);
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function K(e) {
|
|
264
|
-
return q({
|
|
265
|
-
...e,
|
|
266
|
-
pixelRatio: e.devicePixelRatio ?? e.pixelRatio
|
|
267
|
-
}).toDataURL("image/png");
|
|
268
|
-
}
|
|
269
|
-
function q(e) {
|
|
270
|
-
let t = e.logicalWidth ?? e.liveSize.width, n = e.logicalHeight ?? e.liveSize.height, r = e.pixelRatio ?? e.liveDevicePixelRatio, i = document.createElement("canvas");
|
|
271
|
-
i.width = Math.floor(t * r), i.height = Math.floor(n * r);
|
|
272
|
-
let a = i.getContext("2d");
|
|
273
|
-
if (!a) throw Error("Unable to initialize a Canvas2D export context.");
|
|
274
|
-
return H({
|
|
275
|
-
viewRoot: e.viewRoot,
|
|
276
|
-
context: a,
|
|
277
|
-
width: t,
|
|
278
|
-
height: n,
|
|
279
|
-
devicePixelRatio: r,
|
|
280
|
-
background: e.clearColor ?? null,
|
|
281
|
-
paint: !0
|
|
282
|
-
}), i;
|
|
283
|
-
}
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region ../core/src/rendering/canvas2d/index.js
|
|
286
|
-
function J(e) {
|
|
287
|
-
let t = new W(e);
|
|
288
|
-
return {
|
|
289
|
-
surface: t,
|
|
290
|
-
glHelper: void 0,
|
|
291
|
-
createRenderCoordinator: (e) => new U({
|
|
292
|
-
...e,
|
|
293
|
-
surface: t,
|
|
294
|
-
context: t.context
|
|
295
|
-
}),
|
|
296
|
-
exportCanvas: (e) => K({
|
|
297
|
-
...e,
|
|
298
|
-
liveSize: t.getLogicalCanvasSize(),
|
|
299
|
-
liveDevicePixelRatio: t.getDevicePixelRatio()
|
|
300
|
-
}),
|
|
301
|
-
exportRaster: (e) => G({
|
|
302
|
-
...e,
|
|
303
|
-
liveSize: t.getLogicalCanvasSize(),
|
|
304
|
-
liveDevicePixelRatio: t.getDevicePixelRatio()
|
|
305
|
-
})
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
//#endregion
|
|
309
|
-
export { J as createCanvas2DRenderingBackend };
|