@crysound/crychart 1.0.6 → 1.0.8
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 +24 -2
- package/README.zh-CN.md +24 -2
- package/dist/crychart.cjs +883 -328
- package/dist/crychart.global.js +883 -328
- package/dist/crychart.js +883 -328
- package/dist/types/adapters/opentest.d.ts +3 -1
- package/dist/types/axis-canvas.d.ts +12 -1
- package/dist/types/chart.d.ts +9 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/render-heatmap.d.ts +2 -0
- package/dist/types/render-line-coverage.d.ts +4 -0
- package/dist/types/render-line-strip.d.ts +1 -0
- package/dist/types/render.d.ts +4 -0
- package/dist/types/series.d.ts +1 -0
- package/dist/types/shared-webgl-context.d.ts +86 -0
- package/docs/npm-usage.md +1 -1
- package/package.json +1 -1
package/dist/crychart.cjs
CHANGED
|
@@ -104,6 +104,7 @@ __export(index_exports, {
|
|
|
104
104
|
SegmentFigure: () => SegmentFigure,
|
|
105
105
|
SegmentSeries: () => SegmentSeries,
|
|
106
106
|
Series3DBase: () => Series3DBase,
|
|
107
|
+
SharedWebGLContext: () => SharedWebGLContext,
|
|
107
108
|
SimpleShadingStyle: () => SimpleShadingStyle,
|
|
108
109
|
SlicedHierarchyChart: () => SlicedHierarchyChart,
|
|
109
110
|
SolidFill: () => SolidFill,
|
|
@@ -1028,6 +1029,262 @@ function readPagedValue(view, absoluteIndex) {
|
|
|
1028
1029
|
return page[absoluteIndex - pageIndex * view.pageSize];
|
|
1029
1030
|
}
|
|
1030
1031
|
|
|
1032
|
+
// src/data-order.ts
|
|
1033
|
+
var caches = /* @__PURE__ */ new WeakMap();
|
|
1034
|
+
function resetContent(state) {
|
|
1035
|
+
state.epoch = -1;
|
|
1036
|
+
state.first = 0;
|
|
1037
|
+
state.next = 0;
|
|
1038
|
+
state.lastIndex = -1;
|
|
1039
|
+
state.lastValue = NaN;
|
|
1040
|
+
state.invalid = -1;
|
|
1041
|
+
state.decrease = -1;
|
|
1042
|
+
state.nonIncrease = -1;
|
|
1043
|
+
state.lastScanned = 0;
|
|
1044
|
+
state.lastFast = 0;
|
|
1045
|
+
state.lastEndpoints = 0;
|
|
1046
|
+
}
|
|
1047
|
+
function createState() {
|
|
1048
|
+
return {
|
|
1049
|
+
epoch: -1,
|
|
1050
|
+
first: 0,
|
|
1051
|
+
next: 0,
|
|
1052
|
+
lastIndex: -1,
|
|
1053
|
+
lastValue: NaN,
|
|
1054
|
+
invalid: -1,
|
|
1055
|
+
decrease: -1,
|
|
1056
|
+
nonIncrease: -1,
|
|
1057
|
+
scanned: 0,
|
|
1058
|
+
lastScanned: 0,
|
|
1059
|
+
fast: 0,
|
|
1060
|
+
lastFast: 0,
|
|
1061
|
+
endpoints: 0,
|
|
1062
|
+
lastEndpoints: 0,
|
|
1063
|
+
cacheHits: 0,
|
|
1064
|
+
rebuilds: 0
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
function cacheFor(dataSet) {
|
|
1068
|
+
let cache = caches.get(dataSet);
|
|
1069
|
+
if (!cache) {
|
|
1070
|
+
cache = { epoch: dataSet.getContentEpoch(), columns: /* @__PURE__ */ new Map() };
|
|
1071
|
+
caches.set(dataSet, cache);
|
|
1072
|
+
const owned2 = cache;
|
|
1073
|
+
dataSet.onChange((current) => {
|
|
1074
|
+
if (current.isDisposed()) {
|
|
1075
|
+
owned2.columns.clear();
|
|
1076
|
+
caches.delete(current);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
const epoch = current.getContentEpoch();
|
|
1080
|
+
if (owned2.epoch !== epoch) {
|
|
1081
|
+
for (const state of owned2.columns.values()) resetContent(state);
|
|
1082
|
+
owned2.epoch = epoch;
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
return cache;
|
|
1087
|
+
}
|
|
1088
|
+
function accept(state, index, value, first) {
|
|
1089
|
+
if (!Number.isFinite(value)) state.invalid = index;
|
|
1090
|
+
if (index > first && state.lastIndex === index - 1) {
|
|
1091
|
+
if (value < state.lastValue) state.decrease = index;
|
|
1092
|
+
if (value <= state.lastValue) state.nonIncrease = index;
|
|
1093
|
+
}
|
|
1094
|
+
state.lastValue = value;
|
|
1095
|
+
state.lastIndex = index;
|
|
1096
|
+
}
|
|
1097
|
+
function certifiedIncreasing(run, firstOffset, lastOffset, a, b) {
|
|
1098
|
+
if (!(run.step > 0) || !Number.isFinite(run.step) || !Number.isFinite(run.start) || !Number.isFinite(a) || !Number.isFinite(b) || !(b > a)) return false;
|
|
1099
|
+
const magnitude = Math.max(Math.abs(run.start), Math.abs(firstOffset * run.step), Math.abs(lastOffset * run.step), Math.abs(a), Math.abs(b));
|
|
1100
|
+
const separation = magnitude * Number.EPSILON * 8 + Number.MIN_VALUE * 8;
|
|
1101
|
+
return run.step > separation;
|
|
1102
|
+
}
|
|
1103
|
+
function scanAffine(state, view, from, next) {
|
|
1104
|
+
let low = view.runStart, high = view.runs.length;
|
|
1105
|
+
while (low < high) {
|
|
1106
|
+
const middle = low + Math.floor((high - low) / 2), run = view.runs[middle];
|
|
1107
|
+
if (run.firstIndex + run.count <= from) low = middle + 1;
|
|
1108
|
+
else high = middle;
|
|
1109
|
+
}
|
|
1110
|
+
for (let r = low; r < view.runs.length; r++) {
|
|
1111
|
+
const run = view.runs[r], first = Math.max(from, run.firstIndex), end = Math.min(next, run.firstIndex + run.count);
|
|
1112
|
+
if (first >= end) continue;
|
|
1113
|
+
if (end - first > 1) {
|
|
1114
|
+
const firstOffset = first - run.firstIndex, lastOffset = end - 1 - run.firstIndex;
|
|
1115
|
+
const a = run.start + firstOffset * run.step, b = run.start + lastOffset * run.step;
|
|
1116
|
+
state.endpoints += 2;
|
|
1117
|
+
state.lastEndpoints += 2;
|
|
1118
|
+
if (certifiedIncreasing(run, firstOffset, lastOffset, a, b)) {
|
|
1119
|
+
accept(state, first, a, view.firstIndex);
|
|
1120
|
+
state.lastIndex = end - 1;
|
|
1121
|
+
state.lastValue = b;
|
|
1122
|
+
state.fast += end - first;
|
|
1123
|
+
state.lastFast += end - first;
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
for (let index = first; index < end; index++) accept(state, index, run.start + (index - run.firstIndex) * run.step, view.firstIndex);
|
|
1128
|
+
state.scanned += end - first;
|
|
1129
|
+
state.lastScanned += end - first;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
function result(state, first, next, epoch) {
|
|
1133
|
+
const finite2 = state.invalid < first;
|
|
1134
|
+
return {
|
|
1135
|
+
finite: finite2,
|
|
1136
|
+
monotonic: finite2 && state.decrease <= first,
|
|
1137
|
+
strict: finite2 && state.nonIncrease <= first,
|
|
1138
|
+
sampleCount: next - first,
|
|
1139
|
+
firstIndex: first,
|
|
1140
|
+
nextIndex: next,
|
|
1141
|
+
contentEpoch: epoch,
|
|
1142
|
+
lastInvalidPointIndex: state.invalid,
|
|
1143
|
+
lastDecreaseEdgeIndex: state.decrease,
|
|
1144
|
+
lastNonIncreaseEdgeIndex: state.nonIncrease,
|
|
1145
|
+
scannedSamples: state.scanned,
|
|
1146
|
+
lastScannedSamples: state.lastScanned,
|
|
1147
|
+
affineFastSamples: state.fast,
|
|
1148
|
+
lastAffineFastSamples: state.lastFast,
|
|
1149
|
+
affineEndpointEvaluations: state.endpoints,
|
|
1150
|
+
lastAffineEndpointEvaluations: state.lastEndpoints,
|
|
1151
|
+
cacheHits: state.cacheHits,
|
|
1152
|
+
rebuilds: state.rebuilds
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
function getColumnOrder(dataSet, name) {
|
|
1156
|
+
if (!(dataSet.hasColumn?.(name) ?? Object.prototype.hasOwnProperty.call(dataSet.schema, name))) throw new RangeError(`Unknown data column: ${name}`);
|
|
1157
|
+
const epoch = dataSet.getContentEpoch(), next = dataSet.getNextSampleIndex(), first = next - dataSet.getSampleCount();
|
|
1158
|
+
if (dataSet.isDisposed()) return result(createState(), first, next, epoch);
|
|
1159
|
+
const cache = cacheFor(dataSet);
|
|
1160
|
+
let state = cache.columns.get(name);
|
|
1161
|
+
if (!state) {
|
|
1162
|
+
state = createState();
|
|
1163
|
+
cache.columns.set(name, state);
|
|
1164
|
+
}
|
|
1165
|
+
state.lastScanned = 0;
|
|
1166
|
+
state.lastFast = 0;
|
|
1167
|
+
state.lastEndpoints = 0;
|
|
1168
|
+
if (state.epoch === epoch && state.first === first && state.next === next) {
|
|
1169
|
+
state.cacheHits++;
|
|
1170
|
+
return result(state, first, next, epoch);
|
|
1171
|
+
}
|
|
1172
|
+
if (state.epoch !== epoch || next < state.next || first < state.first) {
|
|
1173
|
+
resetContent(state);
|
|
1174
|
+
state.rebuilds++;
|
|
1175
|
+
}
|
|
1176
|
+
const from = Math.max(first, state.next);
|
|
1177
|
+
if (from < next) {
|
|
1178
|
+
const view = dataSet.getColumnRuns(name);
|
|
1179
|
+
if (view.kind === "affine") scanAffine(state, view, from, next);
|
|
1180
|
+
else if (view.kind === "paged") {
|
|
1181
|
+
const cursor = new PagedColumnCursor(view, from);
|
|
1182
|
+
while (cursor.values) {
|
|
1183
|
+
const values = cursor.values, base = cursor.absoluteIndex - cursor.offset;
|
|
1184
|
+
for (let i = cursor.offset, end = i + cursor.length; i < end; i++) accept(state, base + i, values[i], first);
|
|
1185
|
+
cursor.next();
|
|
1186
|
+
}
|
|
1187
|
+
state.scanned += next - from;
|
|
1188
|
+
state.lastScanned += next - from;
|
|
1189
|
+
} else {
|
|
1190
|
+
let absolute = view.firstIndex;
|
|
1191
|
+
for (const values of view.slices) {
|
|
1192
|
+
const start = Math.max(0, from - absolute);
|
|
1193
|
+
for (let i = start; i < values.length; i++) accept(state, absolute + i, values[i], first);
|
|
1194
|
+
absolute += values.length;
|
|
1195
|
+
}
|
|
1196
|
+
state.scanned += next - from;
|
|
1197
|
+
state.lastScanned += next - from;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
state.epoch = epoch;
|
|
1201
|
+
state.first = first;
|
|
1202
|
+
state.next = next;
|
|
1203
|
+
return result(state, first, next, epoch);
|
|
1204
|
+
}
|
|
1205
|
+
var finiteCaches = /* @__PURE__ */ new WeakMap();
|
|
1206
|
+
function getColumnFinite(dataSet, name) {
|
|
1207
|
+
if (!(dataSet.hasColumn?.(name) ?? Object.prototype.hasOwnProperty.call(dataSet.schema, name))) throw new RangeError(`Unknown data column: ${name}`);
|
|
1208
|
+
const epoch = dataSet.getContentEpoch(), next = dataSet.getNextSampleIndex(), first = next - dataSet.getSampleCount();
|
|
1209
|
+
const expected2 = { revision: dataSet.revision, epoch, first, next };
|
|
1210
|
+
let columns = finiteCaches.get(dataSet);
|
|
1211
|
+
if (!columns && !dataSet.isDisposed()) {
|
|
1212
|
+
columns = /* @__PURE__ */ new Map();
|
|
1213
|
+
finiteCaches.set(dataSet, columns);
|
|
1214
|
+
const owned2 = columns;
|
|
1215
|
+
dataSet.onChange((current) => {
|
|
1216
|
+
if (current.isDisposed()) {
|
|
1217
|
+
owned2.clear();
|
|
1218
|
+
finiteCaches.delete(current);
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
let state = columns?.get(name);
|
|
1223
|
+
if (!state) {
|
|
1224
|
+
state = { invalid: -1, scanned: 0, fullScans: 0, incrementalScans: 0, cacheHits: 0 };
|
|
1225
|
+
columns?.set(name, state);
|
|
1226
|
+
}
|
|
1227
|
+
const before = readSourceCertificate(dataSet, expected2);
|
|
1228
|
+
const delta = !before?.tainted && state.certificate ? certifySourceDelta(dataSet, state.certificate, expected2).delta : void 0;
|
|
1229
|
+
state.certificate = void 0;
|
|
1230
|
+
let from = first, scanned = 0;
|
|
1231
|
+
if (delta) {
|
|
1232
|
+
from = Math.max(first, delta.previous.next);
|
|
1233
|
+
if (delta.kind === "unchanged") state.cacheHits++;
|
|
1234
|
+
else state.incrementalScans++;
|
|
1235
|
+
} else {
|
|
1236
|
+
state.invalid = -1;
|
|
1237
|
+
state.fullScans++;
|
|
1238
|
+
}
|
|
1239
|
+
if (from < next && !dataSet.isDisposed()) {
|
|
1240
|
+
const view = dataSet.getColumnRuns(name);
|
|
1241
|
+
if (view.firstIndex !== first || view.count !== next - first) throw new RangeError("Finite source does not cover the retained window");
|
|
1242
|
+
if (view.kind === "dense") {
|
|
1243
|
+
let absolute = first;
|
|
1244
|
+
for (const values of view.slices) {
|
|
1245
|
+
const start = Math.max(0, from - absolute), end = Math.min(values.length, next - absolute);
|
|
1246
|
+
for (let i = start; i < end; i++) if (!Number.isFinite(values[i])) state.invalid = absolute + i;
|
|
1247
|
+
scanned += Math.max(0, end - start);
|
|
1248
|
+
absolute += values.length;
|
|
1249
|
+
}
|
|
1250
|
+
} else if (view.kind === "paged") {
|
|
1251
|
+
for (let index = from; index < next; ) {
|
|
1252
|
+
const pageIndex = Math.floor(index / view.pageSize), base = pageIndex * view.pageSize;
|
|
1253
|
+
const values = view.getPage(pageIndex), end = Math.min(next, base + view.pageSize);
|
|
1254
|
+
for (; index < end; index++) {
|
|
1255
|
+
if (!Number.isFinite(values?.[index - base])) state.invalid = index;
|
|
1256
|
+
scanned++;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
} else {
|
|
1260
|
+
for (let r = view.runStart; r < view.runs.length; r++) {
|
|
1261
|
+
const run = view.runs[r], begin = Math.max(from, run.firstIndex), end = Math.min(next, run.firstIndex + run.count);
|
|
1262
|
+
for (let index = begin; index < end; index++) if (!Number.isFinite(run.start + (index - run.firstIndex) * run.step)) state.invalid = index;
|
|
1263
|
+
scanned += Math.max(0, end - begin);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (scanned !== next - from) throw new RangeError("Finite source omitted retained values");
|
|
1267
|
+
}
|
|
1268
|
+
state.scanned += scanned;
|
|
1269
|
+
const after = readSourceCertificate(dataSet, expected2);
|
|
1270
|
+
const verifiedCurrent = dataSet.revision === expected2.revision && dataSet.getContentEpoch() === epoch && dataSet.getNextSampleIndex() === next && dataSet.getSampleCount() === next - first && before === after;
|
|
1271
|
+
state.certificate = verifiedCurrent && after && !after.tainted ? after : void 0;
|
|
1272
|
+
return {
|
|
1273
|
+
finite: verifiedCurrent && state.invalid < first,
|
|
1274
|
+
verifiedCurrent,
|
|
1275
|
+
sampleCount: next - first,
|
|
1276
|
+
firstIndex: first,
|
|
1277
|
+
nextIndex: next,
|
|
1278
|
+
contentEpoch: epoch,
|
|
1279
|
+
lastInvalidPointIndex: state.invalid,
|
|
1280
|
+
scannedSamples: state.scanned,
|
|
1281
|
+
lastScannedSamples: scanned,
|
|
1282
|
+
fullScans: state.fullScans,
|
|
1283
|
+
incrementalScans: state.incrementalScans,
|
|
1284
|
+
cacheHits: state.cacheHits
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1031
1288
|
// src/core/data.ts
|
|
1032
1289
|
function positiveInteger(value, name) {
|
|
1033
1290
|
if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(`${name} must be a positive safe integer`);
|
|
@@ -1516,7 +1773,7 @@ var DataSetXY = class _DataSetXY {
|
|
|
1516
1773
|
const name = range.key === void 0 ? [...this.columns].find(([, c]) => c.schema.pattern === "progressive" || c.schema.pattern === "regressive")?.[0] ?? (this.columns.has("xValues") ? "xValues" : "x") : String(range.key);
|
|
1517
1774
|
const column = this.columns.get(name);
|
|
1518
1775
|
if (!column) throw new RangeError(`Unknown data column: ${name}`);
|
|
1519
|
-
[from, to] = this.findRange(column, Math.min(range.start, range.end), Math.max(range.start, range.end));
|
|
1776
|
+
[from, to] = this.findRange(name, column, Math.min(range.start, range.end), Math.max(range.start, range.end));
|
|
1520
1777
|
}
|
|
1521
1778
|
const data = {};
|
|
1522
1779
|
const allocated = this.pagedOptions ? /* @__PURE__ */ new Set() : void 0;
|
|
@@ -1761,11 +2018,34 @@ var DataSetXY = class _DataSetXY {
|
|
|
1761
2018
|
column.runStart = 0;
|
|
1762
2019
|
invalidateSourceCertificate(this, this.deltaSourceHeader(), "column-materialized");
|
|
1763
2020
|
}
|
|
1764
|
-
findRange(column, min, max) {
|
|
2021
|
+
findRange(name, column, min, max) {
|
|
1765
2022
|
let from = this.count, to = this.count;
|
|
1766
|
-
if (Number.isNaN(min) || Number.isNaN(max)) return [from, to];
|
|
2023
|
+
if (this.count === 0 || Number.isNaN(min) || Number.isNaN(max)) return [from, to];
|
|
2024
|
+
const monotonic = getColumnOrder(this, name).monotonic;
|
|
1767
2025
|
if (column.paged !== void 0) {
|
|
1768
2026
|
const view = this.paged.getColumnView(column.paged), firstIndex = view.firstIndex, endIndex = firstIndex + view.count;
|
|
2027
|
+
if (monotonic) {
|
|
2028
|
+
const pageSize = view.pageSize;
|
|
2029
|
+
const valueAt = (index) => {
|
|
2030
|
+
const pageIndex = Math.floor(index / pageSize), page = view.getPage(pageIndex);
|
|
2031
|
+
if (!page) throw new Error("Missing retained page");
|
|
2032
|
+
return page[index - pageIndex * pageSize];
|
|
2033
|
+
};
|
|
2034
|
+
let low = firstIndex, high = endIndex;
|
|
2035
|
+
while (low < high) {
|
|
2036
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
2037
|
+
if (valueAt(middle) < min) low = middle + 1;
|
|
2038
|
+
else high = middle;
|
|
2039
|
+
}
|
|
2040
|
+
const matchStart = low;
|
|
2041
|
+
high = endIndex;
|
|
2042
|
+
while (low < high) {
|
|
2043
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
2044
|
+
if (valueAt(middle) <= max) low = middle + 1;
|
|
2045
|
+
else high = middle;
|
|
2046
|
+
}
|
|
2047
|
+
return matchStart < low ? [matchStart - firstIndex, low - firstIndex] : [this.count, this.count];
|
|
2048
|
+
}
|
|
1769
2049
|
for (let index = firstIndex; index < endIndex; ) {
|
|
1770
2050
|
const pageIndex = Math.floor(index / view.pageSize), page = view.getPage(pageIndex);
|
|
1771
2051
|
if (!page) throw new Error("Missing retained page");
|
|
@@ -1780,6 +2060,47 @@ var DataSetXY = class _DataSetXY {
|
|
|
1780
2060
|
}
|
|
1781
2061
|
} else if (column.runs) {
|
|
1782
2062
|
const firstIndex = this.nextIndex - this.count;
|
|
2063
|
+
if (monotonic) {
|
|
2064
|
+
let rFirst = this.findRun(column, firstIndex);
|
|
2065
|
+
const rEnd = column.runs.length;
|
|
2066
|
+
const runBounds = (r) => {
|
|
2067
|
+
const run = column.runs[r];
|
|
2068
|
+
const start = Math.max(firstIndex, run.firstIndex), end = Math.min(this.nextIndex, run.firstIndex + run.count);
|
|
2069
|
+
return { run, start, end, firstVal: run.start + (start - run.firstIndex) * run.step, lastVal: run.start + (end - 1 - run.firstIndex) * run.step };
|
|
2070
|
+
};
|
|
2071
|
+
let low = rFirst, high = rEnd;
|
|
2072
|
+
while (low < high) {
|
|
2073
|
+
const mid = low + Math.floor((high - low) / 2);
|
|
2074
|
+
if (runBounds(mid).lastVal < min) low = mid + 1;
|
|
2075
|
+
else high = mid;
|
|
2076
|
+
}
|
|
2077
|
+
const startRunIndex = low;
|
|
2078
|
+
if (startRunIndex >= rEnd) return [this.count, this.count];
|
|
2079
|
+
low = startRunIndex;
|
|
2080
|
+
high = rEnd;
|
|
2081
|
+
while (low < high) {
|
|
2082
|
+
const mid = low + Math.floor((high - low) / 2);
|
|
2083
|
+
if (runBounds(mid).firstVal <= max) low = mid + 1;
|
|
2084
|
+
else high = mid;
|
|
2085
|
+
}
|
|
2086
|
+
const endRunIndex = low - 1;
|
|
2087
|
+
if (endRunIndex < startRunIndex) return [this.count, this.count];
|
|
2088
|
+
const firstB = runBounds(startRunIndex);
|
|
2089
|
+
let sLow = firstB.start, sHigh = firstB.end;
|
|
2090
|
+
while (sLow < sHigh) {
|
|
2091
|
+
const mid = sLow + Math.floor((sHigh - sLow) / 2);
|
|
2092
|
+
if (firstB.run.start + (mid - firstB.run.firstIndex) * firstB.run.step < min) sLow = mid + 1;
|
|
2093
|
+
else sHigh = mid;
|
|
2094
|
+
}
|
|
2095
|
+
const lastB = runBounds(endRunIndex);
|
|
2096
|
+
let eLow = startRunIndex === endRunIndex ? sLow : lastB.start, eHigh = lastB.end;
|
|
2097
|
+
while (eLow < eHigh) {
|
|
2098
|
+
const mid = eLow + Math.floor((eHigh - eLow) / 2);
|
|
2099
|
+
if (lastB.run.start + (mid - lastB.run.firstIndex) * lastB.run.step <= max) eLow = mid + 1;
|
|
2100
|
+
else eHigh = mid;
|
|
2101
|
+
}
|
|
2102
|
+
return sLow < eLow ? [sLow - firstIndex, eLow - firstIndex] : [this.count, this.count];
|
|
2103
|
+
}
|
|
1783
2104
|
for (let r = column.runStart; r < column.runs.length; r++) {
|
|
1784
2105
|
const run = column.runs[r];
|
|
1785
2106
|
const start = Math.max(firstIndex, run.firstIndex), end = Math.min(this.nextIndex, run.firstIndex + run.count);
|
|
@@ -1814,6 +2135,23 @@ var DataSetXY = class _DataSetXY {
|
|
|
1814
2135
|
}
|
|
1815
2136
|
} else {
|
|
1816
2137
|
const first = Math.min(this.count, this.allocation - this.head);
|
|
2138
|
+
if (monotonic) {
|
|
2139
|
+
const denseAt = (i) => column.values[i < first ? this.head + i : i - first];
|
|
2140
|
+
let low = 0, high = this.count;
|
|
2141
|
+
while (low < high) {
|
|
2142
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
2143
|
+
if (denseAt(middle) < min) low = middle + 1;
|
|
2144
|
+
else high = middle;
|
|
2145
|
+
}
|
|
2146
|
+
const matchStart = low;
|
|
2147
|
+
high = this.count;
|
|
2148
|
+
while (low < high) {
|
|
2149
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
2150
|
+
if (denseAt(middle) <= max) low = middle + 1;
|
|
2151
|
+
else high = middle;
|
|
2152
|
+
}
|
|
2153
|
+
return matchStart < low ? [matchStart, low] : [this.count, this.count];
|
|
2154
|
+
}
|
|
1817
2155
|
for (let i = 0; i < first; i++) {
|
|
1818
2156
|
const value = column.values[this.head + i];
|
|
1819
2157
|
if (value >= min && value <= max) {
|
|
@@ -4594,296 +4932,40 @@ var PolarAxisRadial = class extends Axis {
|
|
|
4594
4932
|
const offset = strategy.getFormattingOffset(), degrees = offset === void 0 ? value : value + offset;
|
|
4595
4933
|
return Number.isFinite(degrees) ? degrees.toFixed(0) : String(degrees);
|
|
4596
4934
|
}
|
|
4597
|
-
setNorth(degrees) {
|
|
4598
|
-
if (!Number.isFinite(degrees)) throw new RangeError("North angle must be finite");
|
|
4599
|
-
this.polarChart.setAngleOrigin(90 - (this.polarChart.getClockwise() ? -degrees : degrees));
|
|
4600
|
-
return this;
|
|
4601
|
-
}
|
|
4602
|
-
getNorth(_unused) {
|
|
4603
|
-
const angle = (90 - this.polarChart.getAngleOrigin()) * (this.polarChart.getClockwise() ? -1 : 1);
|
|
4604
|
-
return angle === 0 ? 0 : angle;
|
|
4605
|
-
}
|
|
4606
|
-
setClockwise(value) {
|
|
4607
|
-
const north = this.getNorth();
|
|
4608
|
-
this.polarChart.setClockwise(value);
|
|
4609
|
-
return this.setNorth(north);
|
|
4610
|
-
}
|
|
4611
|
-
getClockwise() {
|
|
4612
|
-
return this.polarChart.getClockwise();
|
|
4613
|
-
}
|
|
4614
|
-
setTickStyle(value) {
|
|
4615
|
-
this.tickStrategy.setMajorTickStyle(value);
|
|
4616
|
-
return this;
|
|
4617
|
-
}
|
|
4618
|
-
getTickStyle() {
|
|
4619
|
-
return this.tickStrategy.getMajorTickStyle();
|
|
4620
|
-
}
|
|
4621
|
-
setTickFormattingFunction(value) {
|
|
4622
|
-
if (typeof value !== "function") throw new TypeError("Polar tick formatter must be a function");
|
|
4623
|
-
this.tickFormattingFunction = value;
|
|
4624
|
-
this.chart.invalidate();
|
|
4625
|
-
return this;
|
|
4626
|
-
}
|
|
4627
|
-
getTickFormattingFunction() {
|
|
4628
|
-
return this.tickFormattingFunction;
|
|
4629
|
-
}
|
|
4630
|
-
};
|
|
4631
|
-
|
|
4632
|
-
// src/data-order.ts
|
|
4633
|
-
var caches = /* @__PURE__ */ new WeakMap();
|
|
4634
|
-
function resetContent(state) {
|
|
4635
|
-
state.epoch = -1;
|
|
4636
|
-
state.first = 0;
|
|
4637
|
-
state.next = 0;
|
|
4638
|
-
state.lastIndex = -1;
|
|
4639
|
-
state.lastValue = NaN;
|
|
4640
|
-
state.invalid = -1;
|
|
4641
|
-
state.decrease = -1;
|
|
4642
|
-
state.nonIncrease = -1;
|
|
4643
|
-
state.lastScanned = 0;
|
|
4644
|
-
state.lastFast = 0;
|
|
4645
|
-
state.lastEndpoints = 0;
|
|
4646
|
-
}
|
|
4647
|
-
function createState() {
|
|
4648
|
-
return {
|
|
4649
|
-
epoch: -1,
|
|
4650
|
-
first: 0,
|
|
4651
|
-
next: 0,
|
|
4652
|
-
lastIndex: -1,
|
|
4653
|
-
lastValue: NaN,
|
|
4654
|
-
invalid: -1,
|
|
4655
|
-
decrease: -1,
|
|
4656
|
-
nonIncrease: -1,
|
|
4657
|
-
scanned: 0,
|
|
4658
|
-
lastScanned: 0,
|
|
4659
|
-
fast: 0,
|
|
4660
|
-
lastFast: 0,
|
|
4661
|
-
endpoints: 0,
|
|
4662
|
-
lastEndpoints: 0,
|
|
4663
|
-
cacheHits: 0,
|
|
4664
|
-
rebuilds: 0
|
|
4665
|
-
};
|
|
4666
|
-
}
|
|
4667
|
-
function cacheFor(dataSet) {
|
|
4668
|
-
let cache = caches.get(dataSet);
|
|
4669
|
-
if (!cache) {
|
|
4670
|
-
cache = { epoch: dataSet.getContentEpoch(), columns: /* @__PURE__ */ new Map() };
|
|
4671
|
-
caches.set(dataSet, cache);
|
|
4672
|
-
const owned2 = cache;
|
|
4673
|
-
dataSet.onChange((current) => {
|
|
4674
|
-
if (current.isDisposed()) {
|
|
4675
|
-
owned2.columns.clear();
|
|
4676
|
-
caches.delete(current);
|
|
4677
|
-
return;
|
|
4678
|
-
}
|
|
4679
|
-
const epoch = current.getContentEpoch();
|
|
4680
|
-
if (owned2.epoch !== epoch) {
|
|
4681
|
-
for (const state of owned2.columns.values()) resetContent(state);
|
|
4682
|
-
owned2.epoch = epoch;
|
|
4683
|
-
}
|
|
4684
|
-
});
|
|
4685
|
-
}
|
|
4686
|
-
return cache;
|
|
4687
|
-
}
|
|
4688
|
-
function accept(state, index, value, first) {
|
|
4689
|
-
if (!Number.isFinite(value)) state.invalid = index;
|
|
4690
|
-
if (index > first && state.lastIndex === index - 1) {
|
|
4691
|
-
if (value < state.lastValue) state.decrease = index;
|
|
4692
|
-
if (value <= state.lastValue) state.nonIncrease = index;
|
|
4693
|
-
}
|
|
4694
|
-
state.lastValue = value;
|
|
4695
|
-
state.lastIndex = index;
|
|
4696
|
-
}
|
|
4697
|
-
function certifiedIncreasing(run, firstOffset, lastOffset, a, b) {
|
|
4698
|
-
if (!(run.step > 0) || !Number.isFinite(run.step) || !Number.isFinite(run.start) || !Number.isFinite(a) || !Number.isFinite(b) || !(b > a)) return false;
|
|
4699
|
-
const magnitude = Math.max(Math.abs(run.start), Math.abs(firstOffset * run.step), Math.abs(lastOffset * run.step), Math.abs(a), Math.abs(b));
|
|
4700
|
-
const separation = magnitude * Number.EPSILON * 8 + Number.MIN_VALUE * 8;
|
|
4701
|
-
return run.step > separation;
|
|
4702
|
-
}
|
|
4703
|
-
function scanAffine(state, view, from, next) {
|
|
4704
|
-
let low = view.runStart, high = view.runs.length;
|
|
4705
|
-
while (low < high) {
|
|
4706
|
-
const middle = low + Math.floor((high - low) / 2), run = view.runs[middle];
|
|
4707
|
-
if (run.firstIndex + run.count <= from) low = middle + 1;
|
|
4708
|
-
else high = middle;
|
|
4709
|
-
}
|
|
4710
|
-
for (let r = low; r < view.runs.length; r++) {
|
|
4711
|
-
const run = view.runs[r], first = Math.max(from, run.firstIndex), end = Math.min(next, run.firstIndex + run.count);
|
|
4712
|
-
if (first >= end) continue;
|
|
4713
|
-
if (end - first > 1) {
|
|
4714
|
-
const firstOffset = first - run.firstIndex, lastOffset = end - 1 - run.firstIndex;
|
|
4715
|
-
const a = run.start + firstOffset * run.step, b = run.start + lastOffset * run.step;
|
|
4716
|
-
state.endpoints += 2;
|
|
4717
|
-
state.lastEndpoints += 2;
|
|
4718
|
-
if (certifiedIncreasing(run, firstOffset, lastOffset, a, b)) {
|
|
4719
|
-
accept(state, first, a, view.firstIndex);
|
|
4720
|
-
state.lastIndex = end - 1;
|
|
4721
|
-
state.lastValue = b;
|
|
4722
|
-
state.fast += end - first;
|
|
4723
|
-
state.lastFast += end - first;
|
|
4724
|
-
continue;
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
for (let index = first; index < end; index++) accept(state, index, run.start + (index - run.firstIndex) * run.step, view.firstIndex);
|
|
4728
|
-
state.scanned += end - first;
|
|
4729
|
-
state.lastScanned += end - first;
|
|
4730
|
-
}
|
|
4731
|
-
}
|
|
4732
|
-
function result(state, first, next, epoch) {
|
|
4733
|
-
const finite2 = state.invalid < first;
|
|
4734
|
-
return {
|
|
4735
|
-
finite: finite2,
|
|
4736
|
-
monotonic: finite2 && state.decrease <= first,
|
|
4737
|
-
strict: finite2 && state.nonIncrease <= first,
|
|
4738
|
-
sampleCount: next - first,
|
|
4739
|
-
firstIndex: first,
|
|
4740
|
-
nextIndex: next,
|
|
4741
|
-
contentEpoch: epoch,
|
|
4742
|
-
lastInvalidPointIndex: state.invalid,
|
|
4743
|
-
lastDecreaseEdgeIndex: state.decrease,
|
|
4744
|
-
lastNonIncreaseEdgeIndex: state.nonIncrease,
|
|
4745
|
-
scannedSamples: state.scanned,
|
|
4746
|
-
lastScannedSamples: state.lastScanned,
|
|
4747
|
-
affineFastSamples: state.fast,
|
|
4748
|
-
lastAffineFastSamples: state.lastFast,
|
|
4749
|
-
affineEndpointEvaluations: state.endpoints,
|
|
4750
|
-
lastAffineEndpointEvaluations: state.lastEndpoints,
|
|
4751
|
-
cacheHits: state.cacheHits,
|
|
4752
|
-
rebuilds: state.rebuilds
|
|
4753
|
-
};
|
|
4754
|
-
}
|
|
4755
|
-
function getColumnOrder(dataSet, name) {
|
|
4756
|
-
if (!(dataSet.hasColumn?.(name) ?? Object.prototype.hasOwnProperty.call(dataSet.schema, name))) throw new RangeError(`Unknown data column: ${name}`);
|
|
4757
|
-
const epoch = dataSet.getContentEpoch(), next = dataSet.getNextSampleIndex(), first = next - dataSet.getSampleCount();
|
|
4758
|
-
if (dataSet.isDisposed()) return result(createState(), first, next, epoch);
|
|
4759
|
-
const cache = cacheFor(dataSet);
|
|
4760
|
-
let state = cache.columns.get(name);
|
|
4761
|
-
if (!state) {
|
|
4762
|
-
state = createState();
|
|
4763
|
-
cache.columns.set(name, state);
|
|
4764
|
-
}
|
|
4765
|
-
state.lastScanned = 0;
|
|
4766
|
-
state.lastFast = 0;
|
|
4767
|
-
state.lastEndpoints = 0;
|
|
4768
|
-
if (state.epoch === epoch && state.first === first && state.next === next) {
|
|
4769
|
-
state.cacheHits++;
|
|
4770
|
-
return result(state, first, next, epoch);
|
|
4771
|
-
}
|
|
4772
|
-
if (state.epoch !== epoch || next < state.next || first < state.first) {
|
|
4773
|
-
resetContent(state);
|
|
4774
|
-
state.rebuilds++;
|
|
4775
|
-
}
|
|
4776
|
-
const from = Math.max(first, state.next);
|
|
4777
|
-
if (from < next) {
|
|
4778
|
-
const view = dataSet.getColumnRuns(name);
|
|
4779
|
-
if (view.kind === "affine") scanAffine(state, view, from, next);
|
|
4780
|
-
else if (view.kind === "paged") {
|
|
4781
|
-
const cursor = new PagedColumnCursor(view, from);
|
|
4782
|
-
while (cursor.values) {
|
|
4783
|
-
const values = cursor.values, base = cursor.absoluteIndex - cursor.offset;
|
|
4784
|
-
for (let i = cursor.offset, end = i + cursor.length; i < end; i++) accept(state, base + i, values[i], first);
|
|
4785
|
-
cursor.next();
|
|
4786
|
-
}
|
|
4787
|
-
state.scanned += next - from;
|
|
4788
|
-
state.lastScanned += next - from;
|
|
4789
|
-
} else {
|
|
4790
|
-
let absolute = view.firstIndex;
|
|
4791
|
-
for (const values of view.slices) {
|
|
4792
|
-
const start = Math.max(0, from - absolute);
|
|
4793
|
-
for (let i = start; i < values.length; i++) accept(state, absolute + i, values[i], first);
|
|
4794
|
-
absolute += values.length;
|
|
4795
|
-
}
|
|
4796
|
-
state.scanned += next - from;
|
|
4797
|
-
state.lastScanned += next - from;
|
|
4798
|
-
}
|
|
4935
|
+
setNorth(degrees) {
|
|
4936
|
+
if (!Number.isFinite(degrees)) throw new RangeError("North angle must be finite");
|
|
4937
|
+
this.polarChart.setAngleOrigin(90 - (this.polarChart.getClockwise() ? -degrees : degrees));
|
|
4938
|
+
return this;
|
|
4799
4939
|
}
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
return result(state, first, next, epoch);
|
|
4804
|
-
}
|
|
4805
|
-
var finiteCaches = /* @__PURE__ */ new WeakMap();
|
|
4806
|
-
function getColumnFinite(dataSet, name) {
|
|
4807
|
-
if (!(dataSet.hasColumn?.(name) ?? Object.prototype.hasOwnProperty.call(dataSet.schema, name))) throw new RangeError(`Unknown data column: ${name}`);
|
|
4808
|
-
const epoch = dataSet.getContentEpoch(), next = dataSet.getNextSampleIndex(), first = next - dataSet.getSampleCount();
|
|
4809
|
-
const expected2 = { revision: dataSet.revision, epoch, first, next };
|
|
4810
|
-
let columns = finiteCaches.get(dataSet);
|
|
4811
|
-
if (!columns && !dataSet.isDisposed()) {
|
|
4812
|
-
columns = /* @__PURE__ */ new Map();
|
|
4813
|
-
finiteCaches.set(dataSet, columns);
|
|
4814
|
-
const owned2 = columns;
|
|
4815
|
-
dataSet.onChange((current) => {
|
|
4816
|
-
if (current.isDisposed()) {
|
|
4817
|
-
owned2.clear();
|
|
4818
|
-
finiteCaches.delete(current);
|
|
4819
|
-
}
|
|
4820
|
-
});
|
|
4940
|
+
getNorth(_unused) {
|
|
4941
|
+
const angle = (90 - this.polarChart.getAngleOrigin()) * (this.polarChart.getClockwise() ? -1 : 1);
|
|
4942
|
+
return angle === 0 ? 0 : angle;
|
|
4821
4943
|
}
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4944
|
+
setClockwise(value) {
|
|
4945
|
+
const north = this.getNorth();
|
|
4946
|
+
this.polarChart.setClockwise(value);
|
|
4947
|
+
return this.setNorth(north);
|
|
4826
4948
|
}
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
state.certificate = void 0;
|
|
4830
|
-
let from = first, scanned = 0;
|
|
4831
|
-
if (delta) {
|
|
4832
|
-
from = Math.max(first, delta.previous.next);
|
|
4833
|
-
if (delta.kind === "unchanged") state.cacheHits++;
|
|
4834
|
-
else state.incrementalScans++;
|
|
4835
|
-
} else {
|
|
4836
|
-
state.invalid = -1;
|
|
4837
|
-
state.fullScans++;
|
|
4949
|
+
getClockwise() {
|
|
4950
|
+
return this.polarChart.getClockwise();
|
|
4838
4951
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
if (view.kind === "dense") {
|
|
4843
|
-
let absolute = first;
|
|
4844
|
-
for (const values of view.slices) {
|
|
4845
|
-
const start = Math.max(0, from - absolute), end = Math.min(values.length, next - absolute);
|
|
4846
|
-
for (let i = start; i < end; i++) if (!Number.isFinite(values[i])) state.invalid = absolute + i;
|
|
4847
|
-
scanned += Math.max(0, end - start);
|
|
4848
|
-
absolute += values.length;
|
|
4849
|
-
}
|
|
4850
|
-
} else if (view.kind === "paged") {
|
|
4851
|
-
for (let index = from; index < next; ) {
|
|
4852
|
-
const pageIndex = Math.floor(index / view.pageSize), base = pageIndex * view.pageSize;
|
|
4853
|
-
const values = view.getPage(pageIndex), end = Math.min(next, base + view.pageSize);
|
|
4854
|
-
for (; index < end; index++) {
|
|
4855
|
-
if (!Number.isFinite(values?.[index - base])) state.invalid = index;
|
|
4856
|
-
scanned++;
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
} else {
|
|
4860
|
-
for (let r = view.runStart; r < view.runs.length; r++) {
|
|
4861
|
-
const run = view.runs[r], begin = Math.max(from, run.firstIndex), end = Math.min(next, run.firstIndex + run.count);
|
|
4862
|
-
for (let index = begin; index < end; index++) if (!Number.isFinite(run.start + (index - run.firstIndex) * run.step)) state.invalid = index;
|
|
4863
|
-
scanned += Math.max(0, end - begin);
|
|
4864
|
-
}
|
|
4865
|
-
}
|
|
4866
|
-
if (scanned !== next - from) throw new RangeError("Finite source omitted retained values");
|
|
4952
|
+
setTickStyle(value) {
|
|
4953
|
+
this.tickStrategy.setMajorTickStyle(value);
|
|
4954
|
+
return this;
|
|
4867
4955
|
}
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
lastScannedSamples: scanned,
|
|
4882
|
-
fullScans: state.fullScans,
|
|
4883
|
-
incrementalScans: state.incrementalScans,
|
|
4884
|
-
cacheHits: state.cacheHits
|
|
4885
|
-
};
|
|
4886
|
-
}
|
|
4956
|
+
getTickStyle() {
|
|
4957
|
+
return this.tickStrategy.getMajorTickStyle();
|
|
4958
|
+
}
|
|
4959
|
+
setTickFormattingFunction(value) {
|
|
4960
|
+
if (typeof value !== "function") throw new TypeError("Polar tick formatter must be a function");
|
|
4961
|
+
this.tickFormattingFunction = value;
|
|
4962
|
+
this.chart.invalidate();
|
|
4963
|
+
return this;
|
|
4964
|
+
}
|
|
4965
|
+
getTickFormattingFunction() {
|
|
4966
|
+
return this.tickFormattingFunction;
|
|
4967
|
+
}
|
|
4968
|
+
};
|
|
4887
4969
|
|
|
4888
4970
|
// src/line-extrema-pair-proof.ts
|
|
4889
4971
|
var issued2 = /* @__PURE__ */ new WeakSet();
|
|
@@ -7871,7 +7953,8 @@ var PointLineAreaSeries = class _PointLineAreaSeries {
|
|
|
7871
7953
|
yValues: { storage: Float64Array },
|
|
7872
7954
|
...this.axisZ ? { zValues: { storage: Float64Array } } : {}
|
|
7873
7955
|
},
|
|
7874
|
-
includesNaN: options.includesNaN
|
|
7956
|
+
includesNaN: options.includesNaN,
|
|
7957
|
+
columnStorage: options.columnStorage
|
|
7875
7958
|
});
|
|
7876
7959
|
const keys = Object.keys(this.dataSet.schema);
|
|
7877
7960
|
const implicitX = keys.length === 1 && !this.axisZ && keys[0] !== "x" && keys[0] !== "xValues";
|
|
@@ -15680,6 +15763,38 @@ var LineCoverageRenderer = class {
|
|
|
15680
15763
|
this.frameState = this.saveState();
|
|
15681
15764
|
this.capturedFrameActive = true;
|
|
15682
15765
|
}
|
|
15766
|
+
/** Shared-context all-coverage batch after SharedWebGLContext established its
|
|
15767
|
+
* exact clean default-target baseline: avoids 28 synchronous GL state queries
|
|
15768
|
+
* while preserving identical restoreState semantics for both draw and frame scopes. */
|
|
15769
|
+
beginKnownCapturedFrame(program, viewport) {
|
|
15770
|
+
if (this.disposed || this.frameState) throw new Error("Captured coverage frame requires a fresh frame");
|
|
15771
|
+
const gl = this.gl;
|
|
15772
|
+
this.frameState = {
|
|
15773
|
+
drawFramebuffer: null,
|
|
15774
|
+
readFramebuffer: null,
|
|
15775
|
+
viewport: Int32Array.from(viewport),
|
|
15776
|
+
scissor: Int32Array.from(viewport),
|
|
15777
|
+
clearColor: new Float32Array(4),
|
|
15778
|
+
colorMask: [true, true, true, true],
|
|
15779
|
+
program,
|
|
15780
|
+
vao: null,
|
|
15781
|
+
arrayBuffer: null,
|
|
15782
|
+
activeTexture: gl.TEXTURE0,
|
|
15783
|
+
texture0: null,
|
|
15784
|
+
sampler0: null,
|
|
15785
|
+
enabled: [[gl.SCISSOR_TEST, true], [gl.BLEND, true], [gl.DEPTH_TEST, false], [gl.STENCIL_TEST, false], [gl.CULL_FACE, false], [gl.RASTERIZER_DISCARD, false], [gl.SAMPLE_ALPHA_TO_COVERAGE, false], [gl.SAMPLE_COVERAGE, false], [gl.DITHER, true]],
|
|
15786
|
+
blendSourceRGB: gl.SRC_ALPHA,
|
|
15787
|
+
blendSourceAlpha: gl.ONE,
|
|
15788
|
+
blendDestinationRGB: gl.ONE_MINUS_SRC_ALPHA,
|
|
15789
|
+
blendDestinationAlpha: gl.ONE_MINUS_SRC_ALPHA,
|
|
15790
|
+
blendEquationRGB: gl.FUNC_ADD,
|
|
15791
|
+
blendEquationAlpha: gl.FUNC_ADD
|
|
15792
|
+
};
|
|
15793
|
+
this.capturedFrameActive = true;
|
|
15794
|
+
this.ownedMaskStateReady = false;
|
|
15795
|
+
this.knownFrameActive = true;
|
|
15796
|
+
this.stats.knownFrameBaselines++;
|
|
15797
|
+
}
|
|
15683
15798
|
/** Internal capability, only after DataRenderer established this exact private
|
|
15684
15799
|
* default-target baseline. Standalone draw()/frame users keep full capture.
|
|
15685
15800
|
* This record is ephemeral and cleared by every flush/end/context/dispose. */
|
|
@@ -16187,6 +16302,10 @@ var LineStripRenderer = class {
|
|
|
16187
16302
|
if (!this.coverage) throw new Error("Captured frame requires coverage rendering");
|
|
16188
16303
|
this.coverage.beginCapturedFrame();
|
|
16189
16304
|
}
|
|
16305
|
+
beginKnownCapturedCoverageFrame(program, viewport) {
|
|
16306
|
+
if (!this.coverage) throw new Error("Captured frame requires coverage rendering");
|
|
16307
|
+
this.coverage.beginKnownCapturedFrame(program, viewport);
|
|
16308
|
+
}
|
|
16190
16309
|
canDraw(packet) {
|
|
16191
16310
|
if (this.coverage) return this.coverage.canDraw(packet);
|
|
16192
16311
|
return !this.disposed && packet.strictlyMonotonicX === true && packet.mode === "line" && packet.dimensions === 2 && packet.count >= 2 && packet.thickness > 0 && !packet.colors && !packet.dashPattern?.length && packet.positions.length >= packet.count * 2;
|
|
@@ -16393,6 +16512,307 @@ var LineStripRenderer = class {
|
|
|
16393
16512
|
}
|
|
16394
16513
|
};
|
|
16395
16514
|
|
|
16515
|
+
// src/shared-webgl-context.ts
|
|
16516
|
+
var cores = /* @__PURE__ */ new WeakMap();
|
|
16517
|
+
var claimedCanvases = /* @__PURE__ */ new WeakMap();
|
|
16518
|
+
function sharedContextCore(context) {
|
|
16519
|
+
const core = cores.get(context);
|
|
16520
|
+
if (!core) throw new TypeError("Expected a valid SharedWebGLContext");
|
|
16521
|
+
return core;
|
|
16522
|
+
}
|
|
16523
|
+
function resetSharedBaseline(gl, width, height, maxVertexAttribs) {
|
|
16524
|
+
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
|
|
16525
|
+
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
|
|
16526
|
+
gl.drawBuffers([gl.BACK]);
|
|
16527
|
+
gl.readBuffer(gl.BACK);
|
|
16528
|
+
gl.bindVertexArray(null);
|
|
16529
|
+
for (let i = 0; i < maxVertexAttribs; i++) {
|
|
16530
|
+
gl.disableVertexAttribArray(i);
|
|
16531
|
+
gl.vertexAttribDivisor(i, 0);
|
|
16532
|
+
}
|
|
16533
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
16534
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
16535
|
+
gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null);
|
|
16536
|
+
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
|
|
16537
|
+
gl.bindBuffer(gl.COPY_READ_BUFFER, null);
|
|
16538
|
+
gl.bindBuffer(gl.COPY_WRITE_BUFFER, null);
|
|
16539
|
+
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
16540
|
+
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
|
|
16541
|
+
for (let unit = 2; unit >= 0; unit--) {
|
|
16542
|
+
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
16543
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
16544
|
+
gl.bindSampler(unit, null);
|
|
16545
|
+
}
|
|
16546
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
|
16547
|
+
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
|
|
16548
|
+
gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
|
|
16549
|
+
gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
|
|
16550
|
+
gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
|
|
16551
|
+
gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
|
|
16552
|
+
gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
|
|
16553
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
16554
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
16555
|
+
gl.useProgram(null);
|
|
16556
|
+
gl.colorMask(true, true, true, true);
|
|
16557
|
+
gl.depthMask(true);
|
|
16558
|
+
gl.stencilMask(255);
|
|
16559
|
+
for (const capability of [
|
|
16560
|
+
gl.DEPTH_TEST,
|
|
16561
|
+
gl.STENCIL_TEST,
|
|
16562
|
+
gl.CULL_FACE,
|
|
16563
|
+
gl.RASTERIZER_DISCARD,
|
|
16564
|
+
gl.SAMPLE_ALPHA_TO_COVERAGE,
|
|
16565
|
+
gl.SAMPLE_COVERAGE,
|
|
16566
|
+
gl.SCISSOR_TEST,
|
|
16567
|
+
gl.POLYGON_OFFSET_FILL
|
|
16568
|
+
]) {
|
|
16569
|
+
gl.disable(capability);
|
|
16570
|
+
}
|
|
16571
|
+
gl.enable(gl.BLEND);
|
|
16572
|
+
gl.enable(gl.DITHER);
|
|
16573
|
+
gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);
|
|
16574
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
16575
|
+
gl.viewport(0, 0, width, height);
|
|
16576
|
+
gl.scissor(0, 0, width, height);
|
|
16577
|
+
}
|
|
16578
|
+
var SharedContextCore = class {
|
|
16579
|
+
canvas;
|
|
16580
|
+
cullOffscreen;
|
|
16581
|
+
antialias;
|
|
16582
|
+
ownsCanvas;
|
|
16583
|
+
clients = /* @__PURE__ */ new Set();
|
|
16584
|
+
observer;
|
|
16585
|
+
observedRoots = /* @__PURE__ */ new Map();
|
|
16586
|
+
offscreenClients = /* @__PURE__ */ new Set();
|
|
16587
|
+
gl = null;
|
|
16588
|
+
attempted = false;
|
|
16589
|
+
disposed = false;
|
|
16590
|
+
maxVertexAttribs = 0;
|
|
16591
|
+
pendingPresent;
|
|
16592
|
+
baselineClean = false;
|
|
16593
|
+
chartDraws = 0;
|
|
16594
|
+
blits = 0;
|
|
16595
|
+
backingResizes = 0;
|
|
16596
|
+
contextLosses = 0;
|
|
16597
|
+
contextRestores = 0;
|
|
16598
|
+
onLost = (event) => {
|
|
16599
|
+
event.preventDefault();
|
|
16600
|
+
this.baselineClean = false;
|
|
16601
|
+
this.contextLosses++;
|
|
16602
|
+
};
|
|
16603
|
+
onRestore = () => {
|
|
16604
|
+
this.baselineClean = false;
|
|
16605
|
+
this.contextRestores++;
|
|
16606
|
+
};
|
|
16607
|
+
constructor(options) {
|
|
16608
|
+
if (options !== void 0 && (typeof options !== "object" || options === null)) {
|
|
16609
|
+
throw new TypeError("SharedWebGLContext options must be an object");
|
|
16610
|
+
}
|
|
16611
|
+
if (options?.canvas !== void 0) {
|
|
16612
|
+
if (typeof options.canvas !== "object" || options.canvas === null || typeof options.canvas.getContext !== "function") {
|
|
16613
|
+
throw new TypeError("SharedWebGLContext canvas must provide getContext");
|
|
16614
|
+
}
|
|
16615
|
+
if (claimedCanvases.has(options.canvas)) {
|
|
16616
|
+
throw new Error("Canvas is already bound to an active SharedWebGLContext");
|
|
16617
|
+
}
|
|
16618
|
+
this.canvas = options.canvas;
|
|
16619
|
+
this.ownsCanvas = false;
|
|
16620
|
+
claimedCanvases.set(options.canvas, this);
|
|
16621
|
+
} else if (typeof document !== "undefined") {
|
|
16622
|
+
this.canvas = document.createElement("canvas");
|
|
16623
|
+
this.ownsCanvas = true;
|
|
16624
|
+
} else {
|
|
16625
|
+
this.canvas = void 0;
|
|
16626
|
+
this.ownsCanvas = false;
|
|
16627
|
+
}
|
|
16628
|
+
this.antialias = options?.antialias === true;
|
|
16629
|
+
this.cullOffscreen = options?.cullOffscreen !== false;
|
|
16630
|
+
}
|
|
16631
|
+
acquire() {
|
|
16632
|
+
this.baselineClean = false;
|
|
16633
|
+
if (this.disposed) return null;
|
|
16634
|
+
if (this.attempted) return this.gl;
|
|
16635
|
+
this.attempted = true;
|
|
16636
|
+
if (!this.canvas) return null;
|
|
16637
|
+
let gl = null;
|
|
16638
|
+
try {
|
|
16639
|
+
gl = this.canvas.getContext("webgl2", {
|
|
16640
|
+
alpha: true,
|
|
16641
|
+
antialias: this.antialias,
|
|
16642
|
+
depth: false,
|
|
16643
|
+
stencil: false,
|
|
16644
|
+
premultipliedAlpha: true,
|
|
16645
|
+
preserveDrawingBuffer: false
|
|
16646
|
+
});
|
|
16647
|
+
} catch {
|
|
16648
|
+
gl = null;
|
|
16649
|
+
}
|
|
16650
|
+
if (gl) {
|
|
16651
|
+
this.gl = gl;
|
|
16652
|
+
const maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
|
|
16653
|
+
this.maxVertexAttribs = typeof maxAttribs === "number" && maxAttribs > 0 ? maxAttribs : 0;
|
|
16654
|
+
this.canvas.addEventListener("webglcontextlost", this.onLost);
|
|
16655
|
+
this.canvas.addEventListener("webglcontextrestored", this.onRestore);
|
|
16656
|
+
}
|
|
16657
|
+
return this.gl;
|
|
16658
|
+
}
|
|
16659
|
+
isAvailable() {
|
|
16660
|
+
const gl = this.acquire();
|
|
16661
|
+
return gl !== null && !this.disposed && !gl.isContextLost();
|
|
16662
|
+
}
|
|
16663
|
+
isDisposed() {
|
|
16664
|
+
return this.disposed;
|
|
16665
|
+
}
|
|
16666
|
+
getChartCount() {
|
|
16667
|
+
return this.clients.size;
|
|
16668
|
+
}
|
|
16669
|
+
getStats() {
|
|
16670
|
+
const active2 = this.gl !== null && !this.disposed;
|
|
16671
|
+
return {
|
|
16672
|
+
available: active2 && !this.gl.isContextLost(),
|
|
16673
|
+
disposed: this.disposed,
|
|
16674
|
+
registeredCharts: this.clients.size,
|
|
16675
|
+
offscreenCharts: this.offscreenClients.size,
|
|
16676
|
+
backingWidth: active2 && this.canvas ? this.canvas.width : 0,
|
|
16677
|
+
backingHeight: active2 && this.canvas ? this.canvas.height : 0,
|
|
16678
|
+
chartDraws: this.chartDraws,
|
|
16679
|
+
blits: this.blits,
|
|
16680
|
+
backingResizes: this.backingResizes,
|
|
16681
|
+
contextLosses: this.contextLosses,
|
|
16682
|
+
contextRestores: this.contextRestores
|
|
16683
|
+
};
|
|
16684
|
+
}
|
|
16685
|
+
register(client) {
|
|
16686
|
+
if (this.disposed) throw new Error("SharedWebGLContext has been disposed");
|
|
16687
|
+
if (this.clients.has(client)) return;
|
|
16688
|
+
this.clients.add(client);
|
|
16689
|
+
if (this.cullOffscreen && typeof IntersectionObserver === "function") {
|
|
16690
|
+
if (!this.observer) {
|
|
16691
|
+
this.observer = new IntersectionObserver(
|
|
16692
|
+
(entries) => {
|
|
16693
|
+
for (const entry of entries) {
|
|
16694
|
+
const targetClient = this.observedRoots.get(entry.target);
|
|
16695
|
+
if (!targetClient) continue;
|
|
16696
|
+
const offscreen = !entry.isIntersecting;
|
|
16697
|
+
if (offscreen) this.offscreenClients.add(targetClient);
|
|
16698
|
+
else this.offscreenClients.delete(targetClient);
|
|
16699
|
+
targetClient.setOffscreen?.(offscreen);
|
|
16700
|
+
}
|
|
16701
|
+
},
|
|
16702
|
+
{ threshold: 0 }
|
|
16703
|
+
);
|
|
16704
|
+
}
|
|
16705
|
+
this.observedRoots.set(client.root, client);
|
|
16706
|
+
this.observer.observe(client.root);
|
|
16707
|
+
}
|
|
16708
|
+
}
|
|
16709
|
+
unregister(client) {
|
|
16710
|
+
this.clients.delete(client);
|
|
16711
|
+
this.offscreenClients.delete(client);
|
|
16712
|
+
if (this.observedRoots.delete(client.root)) {
|
|
16713
|
+
this.observer?.unobserve(client.root);
|
|
16714
|
+
}
|
|
16715
|
+
}
|
|
16716
|
+
beginChartDraw(pixelWidth, pixelHeight) {
|
|
16717
|
+
this.pendingPresent = void 0;
|
|
16718
|
+
const gl = this.acquire();
|
|
16719
|
+
if (!gl || this.disposed || gl.isContextLost()) return false;
|
|
16720
|
+
const canvas = this.canvas;
|
|
16721
|
+
const width = Math.max(1, Math.round(pixelWidth));
|
|
16722
|
+
const height = Math.max(1, Math.round(pixelHeight));
|
|
16723
|
+
let resized = false;
|
|
16724
|
+
if (canvas.width !== width) {
|
|
16725
|
+
canvas.width = width;
|
|
16726
|
+
resized = true;
|
|
16727
|
+
}
|
|
16728
|
+
if (canvas.height !== height) {
|
|
16729
|
+
canvas.height = height;
|
|
16730
|
+
resized = true;
|
|
16731
|
+
}
|
|
16732
|
+
if (resized) this.backingResizes++;
|
|
16733
|
+
resetSharedBaseline(gl, width, height, this.maxVertexAttribs);
|
|
16734
|
+
gl.disable(gl.SCISSOR_TEST);
|
|
16735
|
+
gl.clearColor(0, 0, 0, 0);
|
|
16736
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
16737
|
+
this.pendingPresent = { width, height };
|
|
16738
|
+
this.baselineClean = true;
|
|
16739
|
+
this.chartDraws++;
|
|
16740
|
+
return true;
|
|
16741
|
+
}
|
|
16742
|
+
/** Consume the clean baseline established by beginChartDraw() for the first drawGPU() in this chart frame. */
|
|
16743
|
+
consumeCleanBaseline() {
|
|
16744
|
+
if (!this.baselineClean || this.disposed || !this.pendingPresent) return false;
|
|
16745
|
+
this.baselineClean = false;
|
|
16746
|
+
return true;
|
|
16747
|
+
}
|
|
16748
|
+
present(target, pixelWidth, pixelHeight) {
|
|
16749
|
+
const pending = this.pendingPresent;
|
|
16750
|
+
this.pendingPresent = void 0;
|
|
16751
|
+
this.baselineClean = false;
|
|
16752
|
+
const width = Math.max(1, Math.round(pixelWidth));
|
|
16753
|
+
const height = Math.max(1, Math.round(pixelHeight));
|
|
16754
|
+
if (!pending || !target || !this.canvas || pending.width !== width || pending.height !== height) {
|
|
16755
|
+
return;
|
|
16756
|
+
}
|
|
16757
|
+
target.save();
|
|
16758
|
+
target.setTransform(1, 0, 0, 1, 0, 0);
|
|
16759
|
+
target.globalAlpha = 1;
|
|
16760
|
+
target.globalCompositeOperation = "copy";
|
|
16761
|
+
target.imageSmoothingEnabled = false;
|
|
16762
|
+
target.drawImage(this.canvas, 0, 0);
|
|
16763
|
+
target.restore();
|
|
16764
|
+
this.blits++;
|
|
16765
|
+
}
|
|
16766
|
+
dispose() {
|
|
16767
|
+
if (this.disposed) return;
|
|
16768
|
+
this.disposed = true;
|
|
16769
|
+
this.pendingPresent = void 0;
|
|
16770
|
+
this.baselineClean = false;
|
|
16771
|
+
this.observer?.disconnect();
|
|
16772
|
+
this.observer = void 0;
|
|
16773
|
+
this.observedRoots.clear();
|
|
16774
|
+
this.offscreenClients.clear();
|
|
16775
|
+
this.clients.clear();
|
|
16776
|
+
if (this.canvas) {
|
|
16777
|
+
if (this.gl) {
|
|
16778
|
+
this.canvas.removeEventListener("webglcontextlost", this.onLost);
|
|
16779
|
+
this.canvas.removeEventListener("webglcontextrestored", this.onRestore);
|
|
16780
|
+
}
|
|
16781
|
+
if (this.ownsCanvas) {
|
|
16782
|
+
this.gl?.getExtension("WEBGL_lose_context")?.loseContext();
|
|
16783
|
+
this.canvas.width = 1;
|
|
16784
|
+
this.canvas.height = 1;
|
|
16785
|
+
} else {
|
|
16786
|
+
claimedCanvases.delete(this.canvas);
|
|
16787
|
+
}
|
|
16788
|
+
}
|
|
16789
|
+
this.gl = null;
|
|
16790
|
+
}
|
|
16791
|
+
};
|
|
16792
|
+
var SharedWebGLContext = class {
|
|
16793
|
+
constructor(options) {
|
|
16794
|
+
cores.set(this, new SharedContextCore(options));
|
|
16795
|
+
}
|
|
16796
|
+
/** Lazily acquires the shared WebGL2 context on first call and caches the result without retrying. */
|
|
16797
|
+
isAvailable() {
|
|
16798
|
+
return sharedContextCore(this).isAvailable();
|
|
16799
|
+
}
|
|
16800
|
+
isDisposed() {
|
|
16801
|
+
return sharedContextCore(this).isDisposed();
|
|
16802
|
+
}
|
|
16803
|
+
/** Number of charts currently registered with this shared context. */
|
|
16804
|
+
getChartCount() {
|
|
16805
|
+
return sharedContextCore(this).getChartCount();
|
|
16806
|
+
}
|
|
16807
|
+
getStats() {
|
|
16808
|
+
return sharedContextCore(this).getStats();
|
|
16809
|
+
}
|
|
16810
|
+
/** Idempotently disposes the shared context. Dispose all registered charts first. */
|
|
16811
|
+
dispose() {
|
|
16812
|
+
sharedContextCore(this).dispose();
|
|
16813
|
+
}
|
|
16814
|
+
};
|
|
16815
|
+
|
|
16396
16816
|
// src/render.ts
|
|
16397
16817
|
var iconVertex = `#version 300 es
|
|
16398
16818
|
precision highp float;
|
|
@@ -16538,7 +16958,15 @@ var DataRenderer = class {
|
|
|
16538
16958
|
this.ownedCoverageFrame = options.ownedCoverageFrame === true;
|
|
16539
16959
|
this.gpuClipPolicy = options.gpuClipPolicy ?? "legacy";
|
|
16540
16960
|
let gl = null;
|
|
16541
|
-
|
|
16961
|
+
let contextEvents = canvas;
|
|
16962
|
+
if (options.renderer !== "canvas2d" && options.sharedContext) {
|
|
16963
|
+
const core = sharedContextCore(options.sharedContext);
|
|
16964
|
+
gl = core.acquire();
|
|
16965
|
+
if (gl && core.canvas) {
|
|
16966
|
+
this.sharedContext = options.sharedContext;
|
|
16967
|
+
contextEvents = core.canvas;
|
|
16968
|
+
}
|
|
16969
|
+
} else try {
|
|
16542
16970
|
if (options.renderer !== "canvas2d") gl = canvas.getContext("webgl2", {
|
|
16543
16971
|
alpha: true,
|
|
16544
16972
|
antialias: options.antialias ?? false,
|
|
@@ -16549,11 +16977,12 @@ var DataRenderer = class {
|
|
|
16549
16977
|
}
|
|
16550
16978
|
if (options.renderer === "webgl2" && !gl) throw new Error("CRYChart WebGL2 renderer is unavailable");
|
|
16551
16979
|
this.gl = gl;
|
|
16980
|
+
this.contextEvents = contextEvents;
|
|
16552
16981
|
this.backend = gl ? "webgl2" : "canvas2d";
|
|
16553
16982
|
if (gl) {
|
|
16554
16983
|
this.init(gl);
|
|
16555
|
-
|
|
16556
|
-
|
|
16984
|
+
this.contextEvents.addEventListener("webglcontextlost", this.onLost);
|
|
16985
|
+
this.contextEvents.addEventListener("webglcontextrestored", this.onRestore);
|
|
16557
16986
|
} else
|
|
16558
16987
|
try {
|
|
16559
16988
|
this.ctx = canvas.getContext("2d");
|
|
@@ -16585,6 +17014,8 @@ var DataRenderer = class {
|
|
|
16585
17014
|
lost = false;
|
|
16586
17015
|
iconPipeline;
|
|
16587
17016
|
iconTextures = /* @__PURE__ */ new Map();
|
|
17017
|
+
sharedContext;
|
|
17018
|
+
contextEvents;
|
|
16588
17019
|
stats = {
|
|
16589
17020
|
frames: 0,
|
|
16590
17021
|
uploads: 0,
|
|
@@ -16869,8 +17300,12 @@ var DataRenderer = class {
|
|
|
16869
17300
|
const gl = this.gl;
|
|
16870
17301
|
const owned2 = this.canUseKnownOwnedFrame(packets, clear, this.gpuClipPolicy === "contained" && rasterTarget?.framebuffer !== null);
|
|
16871
17302
|
if (owned2 && !this.lineStrip) this.lineStrip = new LineStripRenderer(gl, { coverageUnion: true, coverageStateScope: "frame", clipPolicy: this.gpuClipPolicy });
|
|
16872
|
-
const
|
|
16873
|
-
|
|
17303
|
+
const sharedBaselineWasClean = this.sharedContext !== void 0 ? sharedContextCore(this.sharedContext).consumeCleanBaseline() : false;
|
|
17304
|
+
const sharedCleanBaseline = !owned2 && !rasterTarget && clear && sharedBaselineWasClean;
|
|
17305
|
+
const compatibleCoveragePackets = !owned2 && !rasterTarget && packets.length > 0 && packets.every((p) => p.strictlyMonotonicX === true && p.mode === "line" && p.dimensions === 2 && Number.isSafeInteger(p.count) && p.count >= 2 && p.positions.length >= p.count * 2 && Number.isFinite(p.thickness) && p.thickness > 0 && !p.colors && !p.dashPattern?.length && !p.pointSizes && !p.pointRotations);
|
|
17306
|
+
const sharedKnownCoverageBatch = sharedCleanBaseline && compatibleCoveragePackets;
|
|
17307
|
+
const coverageBatch = !sharedKnownCoverageBatch && compatibleCoveragePackets && gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING) === null;
|
|
17308
|
+
if ((sharedKnownCoverageBatch || coverageBatch) && !this.lineStrip) this.lineStrip = new LineStripRenderer(gl, { coverageUnion: this.lineCoverageUnion, coverageStateScope: this.lineCoverageStateScope, clipPolicy: this.gpuClipPolicy });
|
|
16874
17309
|
const stripBefore = { uploads: this.lineStrip?.stats.uploads ?? 0, bytes: this.lineStrip?.stats.uploadedBytes ?? 0 };
|
|
16875
17310
|
this.lineStrip?.beginFrame();
|
|
16876
17311
|
let frameEnded = false;
|
|
@@ -16898,6 +17333,10 @@ var DataRenderer = class {
|
|
|
16898
17333
|
gl.uniform2f(this.uniforms.plotOrigin, x, y);
|
|
16899
17334
|
gl.uniform1f(this.uniforms.dpr, dpr);
|
|
16900
17335
|
if (owned2) this.lineStrip.beginKnownOwnedFrame(this.program, [x, y, w, h]);
|
|
17336
|
+
else if (sharedKnownCoverageBatch) {
|
|
17337
|
+
this.lineStrip.beginKnownCapturedCoverageFrame(this.program, [x, y, w, h]);
|
|
17338
|
+
capturedCoverageBatch = true;
|
|
17339
|
+
}
|
|
16901
17340
|
let clipX = x, clipY = y, clipW = w, clipH = h;
|
|
16902
17341
|
const live = /* @__PURE__ */ new Set();
|
|
16903
17342
|
const liveAttributes = /* @__PURE__ */ new Set();
|
|
@@ -17309,8 +17748,8 @@ var DataRenderer = class {
|
|
|
17309
17748
|
this.attributeBuffers.clear();
|
|
17310
17749
|
if (this.program) this.gl.deleteProgram(this.program);
|
|
17311
17750
|
}
|
|
17312
|
-
this.
|
|
17313
|
-
this.
|
|
17751
|
+
this.contextEvents.removeEventListener("webglcontextlost", this.onLost);
|
|
17752
|
+
this.contextEvents.removeEventListener("webglcontextrestored", this.onRestore);
|
|
17314
17753
|
}
|
|
17315
17754
|
};
|
|
17316
17755
|
function appendPointPath(ctx, x, y, size, shape, rotation) {
|
|
@@ -18188,8 +18627,9 @@ var DataRendererHeatmap = class {
|
|
|
18188
18627
|
this.canvas = canvas;
|
|
18189
18628
|
this.options = options;
|
|
18190
18629
|
this.initialize();
|
|
18191
|
-
|
|
18192
|
-
|
|
18630
|
+
const events = this.options.contextEvents ?? this.canvas;
|
|
18631
|
+
events.addEventListener("webglcontextlost", this.contextLost);
|
|
18632
|
+
events.addEventListener("webglcontextrestored", this.contextRestored);
|
|
18193
18633
|
}
|
|
18194
18634
|
stats = { frames: 0, uploads: 0, textureUploads: 0, paletteUploads: 0, uploadedBytes: 0, drawCalls: 0, cells: 0, renderTimeMs: 0, cachedTextures: 0, cacheBytes: 0, contextRestores: 0 };
|
|
18195
18635
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -18480,8 +18920,9 @@ var DataRendererHeatmap = class {
|
|
|
18480
18920
|
this.program = void 0;
|
|
18481
18921
|
this.stats.cachedTextures = 0;
|
|
18482
18922
|
this.stats.cacheBytes = 0;
|
|
18483
|
-
this.
|
|
18484
|
-
|
|
18923
|
+
const events = this.options.contextEvents ?? this.canvas;
|
|
18924
|
+
events.removeEventListener("webglcontextlost", this.contextLost);
|
|
18925
|
+
events.removeEventListener("webglcontextrestored", this.contextRestored);
|
|
18485
18926
|
}
|
|
18486
18927
|
};
|
|
18487
18928
|
|
|
@@ -20004,30 +20445,73 @@ function fitEllipsoid3D(input, options = {}) {
|
|
|
20004
20445
|
// src/axis-canvas.ts
|
|
20005
20446
|
var color = (fill, fallback) => fill?.kind === "empty" ? ColorRGBA(0, 0, 0, 0) : fill?.getColor?.() ?? fallback;
|
|
20006
20447
|
var validFont = (font2) => font2.toCSS?.() ?? `${font2.getSize()}px sans-serif`;
|
|
20448
|
+
var TEXT_METRICS_CACHE_MAX = 1024;
|
|
20449
|
+
var fontCacheEpoch = 0;
|
|
20450
|
+
var fontCacheListening = false;
|
|
20451
|
+
var persistentTextCaches = /* @__PURE__ */ new WeakMap();
|
|
20452
|
+
function ensureFontCacheListener() {
|
|
20453
|
+
if (fontCacheListening) return;
|
|
20454
|
+
try {
|
|
20455
|
+
const fonts = globalThis.document?.fonts;
|
|
20456
|
+
if (typeof fonts?.addEventListener === "function") {
|
|
20457
|
+
fonts.addEventListener("loadingdone", () => {
|
|
20458
|
+
fontCacheEpoch++;
|
|
20459
|
+
});
|
|
20460
|
+
fontCacheListening = true;
|
|
20461
|
+
}
|
|
20462
|
+
} catch {
|
|
20463
|
+
}
|
|
20464
|
+
}
|
|
20465
|
+
function getAxisTextMetricsCache(ctx) {
|
|
20466
|
+
if (!ctx) return void 0;
|
|
20467
|
+
ensureFontCacheListener();
|
|
20468
|
+
let entry = persistentTextCaches.get(ctx);
|
|
20469
|
+
if (!entry || entry.epoch !== fontCacheEpoch) {
|
|
20470
|
+
entry = { epoch: fontCacheEpoch, map: /* @__PURE__ */ new Map() };
|
|
20471
|
+
persistentTextCaches.set(ctx, entry);
|
|
20472
|
+
} else if (entry.map.size >= TEXT_METRICS_CACHE_MAX) {
|
|
20473
|
+
entry.map.clear();
|
|
20474
|
+
}
|
|
20475
|
+
return entry.map;
|
|
20476
|
+
}
|
|
20007
20477
|
var lineBoxHeight = (font2) => font2.getSize() * 0.8;
|
|
20008
20478
|
function lineBoxBaseline(metrics2, font2) {
|
|
20009
20479
|
const size = font2.getSize();
|
|
20010
20480
|
return ((metrics2?.fontBoundingBoxAscent ?? size * 0.8) - (metrics2?.fontBoundingBoxDescent ?? size * 0.2)) / 2;
|
|
20011
20481
|
}
|
|
20012
|
-
function textMetrics(ctx, text, font2, cache) {
|
|
20013
|
-
const
|
|
20482
|
+
function textMetrics(ctx, text, font2, cache, align) {
|
|
20483
|
+
const fontCss = validFont(font2);
|
|
20484
|
+
const key = fontCss + "\0" + (align ?? "") + "\0" + text, cached = cache?.get(key);
|
|
20014
20485
|
if (cached) return cached;
|
|
20015
|
-
const previous = ctx?.font, previousBaseline = ctx?.textBaseline;
|
|
20016
|
-
if (ctx) {
|
|
20017
|
-
ctx.font = validFont(font2);
|
|
20018
|
-
ctx.textBaseline = "alphabetic";
|
|
20019
|
-
}
|
|
20486
|
+
const previous = ctx?.font, previousBaseline = ctx?.textBaseline, previousAlign = ctx?.textAlign;
|
|
20020
20487
|
let measured;
|
|
20021
20488
|
try {
|
|
20489
|
+
if (ctx) {
|
|
20490
|
+
ctx.font = fontCss;
|
|
20491
|
+
ctx.textBaseline = "alphabetic";
|
|
20492
|
+
if (align !== void 0) ctx.textAlign = align;
|
|
20493
|
+
}
|
|
20022
20494
|
measured = ctx?.measureText?.(text);
|
|
20023
20495
|
} finally {
|
|
20024
20496
|
if (ctx) {
|
|
20025
20497
|
if (previous !== void 0) ctx.font = previous;
|
|
20026
20498
|
if (previousBaseline !== void 0) ctx.textBaseline = previousBaseline;
|
|
20499
|
+
if (align !== void 0 && previousAlign !== void 0) ctx.textAlign = previousAlign;
|
|
20027
20500
|
}
|
|
20028
20501
|
}
|
|
20029
|
-
const result2 = {
|
|
20030
|
-
|
|
20502
|
+
const result2 = {
|
|
20503
|
+
width: measured?.width ?? text.length * font2.getSize() * 0.6,
|
|
20504
|
+
ascent: measured?.actualBoundingBoxAscent ?? font2.getSize() * 0.75,
|
|
20505
|
+
descent: measured?.actualBoundingBoxDescent ?? font2.getSize() * 0.25,
|
|
20506
|
+
baseline: lineBoxBaseline(measured, font2),
|
|
20507
|
+
actualBoundingBoxAscent: measured?.actualBoundingBoxAscent,
|
|
20508
|
+
actualBoundingBoxDescent: measured?.actualBoundingBoxDescent,
|
|
20509
|
+
...align !== void 0 ? { actualBoundingBoxLeft: measured?.actualBoundingBoxLeft, actualBoundingBoxRight: measured?.actualBoundingBoxRight } : {}
|
|
20510
|
+
};
|
|
20511
|
+
if (cache) {
|
|
20512
|
+
if (cache.size >= TEXT_METRICS_CACHE_MAX) cache.clear();
|
|
20513
|
+
cache.set(key, result2);
|
|
20514
|
+
}
|
|
20031
20515
|
return result2;
|
|
20032
20516
|
}
|
|
20033
20517
|
function measureChartTitleContent(ctx, text, font2, dpr = 1) {
|
|
@@ -20111,9 +20595,9 @@ function metrics(axis, ctx, cache, theme, resolveFont) {
|
|
|
20111
20595
|
const laneSize = extent > 0 ? Math.ceil(extent + (horizontal ? 2 : 4)) : 0;
|
|
20112
20596
|
return { measured: true, labelFont, titleFont, lane: 0, laneOffset: 0, laneSize, labelOffset, titleOffset, tickLength, labelWidth, labelAscent, labelDescent, titleWidth: title.width, titleAscent: title.ascent, titleDescent: title.descent, rotation };
|
|
20113
20597
|
}
|
|
20114
|
-
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont) {
|
|
20598
|
+
function measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont, persistentCache) {
|
|
20115
20599
|
const result2 = { contentMargins: { left: 0, right: 0, top: 0, bottom: 0 }, extraMargins: { left: 0, right: 0, top: 0, bottom: 0 }, axes: /* @__PURE__ */ new Map() };
|
|
20116
|
-
const textCache = /* @__PURE__ */ new Map();
|
|
20600
|
+
const textCache = persistentCache ?? /* @__PURE__ */ new Map();
|
|
20117
20601
|
for (const [horizontal, list] of [[true, axesX], [false, axesY]]) for (const opposite of [false, true]) {
|
|
20118
20602
|
const groups = /* @__PURE__ */ new Map();
|
|
20119
20603
|
for (const axis of list) if (axis.visible && !axis.disposed && axis.opposite === opposite) {
|
|
@@ -20188,14 +20672,15 @@ function paintAxisLabels(ctx, labels, axisLength, selectedTimeMinor = false) {
|
|
|
20188
20672
|
}
|
|
20189
20673
|
}
|
|
20190
20674
|
function drawAxisCanvas(ctx, options) {
|
|
20191
|
-
const
|
|
20675
|
+
const textCache = getAxisTextMetricsCache(ctx);
|
|
20676
|
+
const { plot: r, axesX, axesY, light = false, theme, resolveFont } = options, layout = options.layout ?? measureAxisCanvasLayout(ctx, axesX, axesY, theme, resolveFont, textCache);
|
|
20192
20677
|
const baselines = [];
|
|
20193
20678
|
ctx.save();
|
|
20194
20679
|
try {
|
|
20195
20680
|
ctx.textBaseline = "alphabetic";
|
|
20196
20681
|
for (const axis of [...axesX, ...axesY]) {
|
|
20197
20682
|
if (!axis.visible || axis.disposed) continue;
|
|
20198
|
-
const m = layout.axes.get(axis) ?? metrics(axis, ctx,
|
|
20683
|
+
const m = layout.axes.get(axis) ?? metrics(axis, ctx, textCache, theme, resolveFont), horizontal = axis.direction === "x", outward = axis.opposite ? horizontal ? -1 : 1 : horizontal ? 1 : -1;
|
|
20199
20684
|
const linePosition = horizontal ? axis.opposite ? r.top - m.laneOffset : r.top + r.height + m.laneOffset : axis.opposite ? r.left + r.width + m.laneOffset : r.left - m.laneOffset;
|
|
20200
20685
|
const range = axis.getScreenRange(), axisLength = Math.abs(range.end - range.start) * (horizontal ? r.width : r.height), strategy = axis.tickStrategy;
|
|
20201
20686
|
const lineFrom = horizontal ? { x: r.left + range.start * r.width, y: linePosition } : { x: linePosition, y: r.top + (1 - range.start) * r.height };
|
|
@@ -20210,7 +20695,7 @@ function drawAxisCanvas(ctx, options) {
|
|
|
20210
20695
|
if (options.paintFrame) {
|
|
20211
20696
|
if (axis.stroke?.getThickness?.() > 0) baselines.push({ stroke: axis.stroke, from: lineFrom, to: lineTo });
|
|
20212
20697
|
} else paintStroke(ctx, axis.stroke, lineFrom, lineTo);
|
|
20213
|
-
const ticks = measuredTickLayout(axis, ctx, axisLength,
|
|
20698
|
+
const ticks = measuredTickLayout(axis, ctx, axisLength, textCache, theme, resolveFont), labels = [], interval = axis.getInterval();
|
|
20214
20699
|
for (const level of ["minor", "major", "great"]) {
|
|
20215
20700
|
const style = tickStyle(strategy, level);
|
|
20216
20701
|
if (!style) continue;
|
|
@@ -20225,17 +20710,18 @@ function drawAxisCanvas(ctx, options) {
|
|
|
20225
20710
|
const labelFill = resolvedTickFill(axis, level, style, theme, true);
|
|
20226
20711
|
const labelColor = labelFill !== void 0 ? color(labelFill, ColorRGBA(0, 0, 0, 0)) : light ? ColorRGBA(82, 97, 118) : color(style.getLabelFillStyle(), ColorRGBA(150, 164, 185));
|
|
20227
20712
|
if (labelColor.a > 0 && tick.label.length) {
|
|
20713
|
+
const align = horizontal ? level === "great" ? "left" : "center" : axis.opposite ? "left" : "right";
|
|
20228
20714
|
ctx.font = validFont(labelFont);
|
|
20229
20715
|
ctx.fillStyle = labelColor.toCSS();
|
|
20230
|
-
ctx.textAlign =
|
|
20231
|
-
const measured = ctx
|
|
20716
|
+
ctx.textAlign = align;
|
|
20717
|
+
const measured = textMetrics(ctx, tick.label, labelFont, textCache, align), width = Number.isFinite(measured.width) ? measured.width : 0;
|
|
20232
20718
|
const anchor = level === "great" && "anchor" in tick ? axis.valueToScreenFraction(tick.anchor) : fraction2;
|
|
20233
20719
|
const anchorX = horizontal ? r.left + anchor * r.width + (level === "great" ? 2 : 0) : x;
|
|
20234
20720
|
const anchorY = horizontal ? y : r.top + r.height - anchor * r.height;
|
|
20235
20721
|
const labelX = horizontal ? boundAxisLabelX(ctx, tick.label, anchorX, lineFrom.x, lineTo.x, measured) : x + outward * m.labelOffset;
|
|
20236
20722
|
let labelY = anchorY + (horizontal ? outward * m.labelOffset : 4);
|
|
20237
20723
|
if (m.lineBoxTitleBaseline !== void 0) {
|
|
20238
|
-
const baseline =
|
|
20724
|
+
const baseline = measured.baseline, halfLine = lineBoxHeight(labelFont) / 2;
|
|
20239
20725
|
labelY = anchorY + baseline + (horizontal ? outward * (m.labelOffset + halfLine) : 0);
|
|
20240
20726
|
if (!horizontal) {
|
|
20241
20727
|
const first = Math.min(lineFrom.y, lineTo.y) + Math.max(halfLine + baseline, measured.actualBoundingBoxAscent ?? labelFont.getSize() * 0.75);
|
|
@@ -20791,6 +21277,11 @@ var ChartXY = class {
|
|
|
20791
21277
|
observer;
|
|
20792
21278
|
overlayContext;
|
|
20793
21279
|
underlayContext;
|
|
21280
|
+
sharedCore;
|
|
21281
|
+
sharedPresent = null;
|
|
21282
|
+
sharedClient;
|
|
21283
|
+
sharedOffscreen = false;
|
|
21284
|
+
sharedDeferred = false;
|
|
20794
21285
|
heatmapRenderer;
|
|
20795
21286
|
heatmapPalettes = /* @__PURE__ */ new Map();
|
|
20796
21287
|
heatCache = /* @__PURE__ */ new Map();
|
|
@@ -20877,7 +21368,7 @@ var ChartXY = class {
|
|
|
20877
21368
|
this.underlay = underlay;
|
|
20878
21369
|
this.overlay = overlay;
|
|
20879
21370
|
try {
|
|
20880
|
-
this.renderer = new DataRenderer(data, { antialias: options.antialias, renderer: options.renderer, lineCoverageUnion: options.experimentalLineCoverage === true, ownedCoverageFrame: options.experimentalOwnedCoverageFrame === true, gpuClipPolicy: this.gpuClipPolicy });
|
|
21371
|
+
this.renderer = new DataRenderer(data, { antialias: options.antialias, renderer: options.renderer, lineCoverageUnion: options.experimentalLineCoverage === true, ownedCoverageFrame: options.experimentalOwnedCoverageFrame === true, gpuClipPolicy: this.gpuClipPolicy, sharedContext: options.sharedContext ?? void 0 });
|
|
20881
21372
|
} catch (error) {
|
|
20882
21373
|
this.cssTextFonts?.dispose();
|
|
20883
21374
|
root.remove();
|
|
@@ -20897,6 +21388,18 @@ var ChartXY = class {
|
|
|
20897
21388
|
});
|
|
20898
21389
|
this.observer.observe(container);
|
|
20899
21390
|
}
|
|
21391
|
+
if (this.renderer?.sharedContext) {
|
|
21392
|
+
const sharedCore = sharedContextCore(this.renderer.sharedContext);
|
|
21393
|
+
this.sharedCore = sharedCore;
|
|
21394
|
+
this.sharedPresent = data.getContext("2d");
|
|
21395
|
+
const client = {
|
|
21396
|
+
root,
|
|
21397
|
+
setOffscreen: (offscreen) => this.setSharedOffscreen(offscreen)
|
|
21398
|
+
};
|
|
21399
|
+
this.sharedClient = client;
|
|
21400
|
+
sharedCore.register(client);
|
|
21401
|
+
this.cleanups.push(() => sharedCore.unregister(client));
|
|
21402
|
+
}
|
|
20900
21403
|
}
|
|
20901
21404
|
this.engine = {
|
|
20902
21405
|
container: this.root ?? this.container,
|
|
@@ -21496,7 +21999,7 @@ var ChartXY = class {
|
|
|
21496
21999
|
this.prepareCustomTickPlacementLengths(axesX, axesY);
|
|
21497
22000
|
const layoutAxesX = axesX.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21498
22001
|
const layoutAxesY = axesY.filter((axis) => this.hasAxisLaneContent(axis));
|
|
21499
|
-
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont) : void 0;
|
|
22002
|
+
this.axisCanvasLayout = this.kind === "xy" ? measureAxisCanvasLayout(this.overlayContext ?? void 0, layoutAxesX, layoutAxesY, this.theme, this.resolveTextFont, getAxisTextMetricsCache(this.overlayContext ?? void 0)) : void 0;
|
|
21500
22003
|
const axisExtra = this.axisCanvasLayout?.extraMargins ?? { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21501
22004
|
const legendMargin = this.overlayContext ? this.legend.getLayout(this.overlayContext, this.legendArea()).margin : { left: 0, right: 0, top: 0, bottom: 0 };
|
|
21502
22005
|
if (this.kind === "polar") {
|
|
@@ -21642,8 +22145,26 @@ var ChartXY = class {
|
|
|
21642
22145
|
this.cancelAxisScrollAnimations();
|
|
21643
22146
|
for (const series of this.series) series.cancelHighlightAnimation?.();
|
|
21644
22147
|
}
|
|
22148
|
+
setSharedOffscreen(offscreen) {
|
|
22149
|
+
if (offscreen === this.sharedOffscreen || this.disposed) return;
|
|
22150
|
+
this.sharedOffscreen = offscreen;
|
|
22151
|
+
if (offscreen) {
|
|
22152
|
+
if (this.frame && typeof cancelAnimationFrame === "function") {
|
|
22153
|
+
cancelAnimationFrame(this.frame);
|
|
22154
|
+
this.frame = 0;
|
|
22155
|
+
this.sharedDeferred = true;
|
|
22156
|
+
}
|
|
22157
|
+
} else if (this.sharedDeferred) {
|
|
22158
|
+
this.sharedDeferred = false;
|
|
22159
|
+
this.invalidate();
|
|
22160
|
+
}
|
|
22161
|
+
}
|
|
21645
22162
|
invalidate() {
|
|
21646
22163
|
if (this.disposed || this.frame || this.rendering || !this.root) return;
|
|
22164
|
+
if (this.sharedOffscreen) {
|
|
22165
|
+
this.sharedDeferred = true;
|
|
22166
|
+
return;
|
|
22167
|
+
}
|
|
21647
22168
|
if (typeof requestAnimationFrame === "function")
|
|
21648
22169
|
this.frame = requestAnimationFrame((timestamp) => {
|
|
21649
22170
|
this.frame = 0;
|
|
@@ -22097,6 +22618,8 @@ var ChartXY = class {
|
|
|
22097
22618
|
ctx.drawImage(cache.canvas, r.left, r.top, r.width, r.height);
|
|
22098
22619
|
}
|
|
22099
22620
|
renderData(packets) {
|
|
22621
|
+
const shared = this.sharedCore;
|
|
22622
|
+
if (shared && !shared.beginChartDraw(this.canvas.width, this.canvas.height)) return;
|
|
22100
22623
|
const grids = [];
|
|
22101
22624
|
for (const s of this.series) {
|
|
22102
22625
|
if (!(s instanceof HeatmapSeries) || !s.visible || s.disposed || !this.gpuHeatmap(s))
|
|
@@ -22167,7 +22690,7 @@ var ChartXY = class {
|
|
|
22167
22690
|
this.heatmapRenderer = new DataRendererHeatmap(
|
|
22168
22691
|
this.renderer.gl,
|
|
22169
22692
|
this.canvas,
|
|
22170
|
-
{ clipPolicy: this.gpuClipPolicy }
|
|
22693
|
+
{ clipPolicy: this.gpuClipPolicy, contextEvents: this.renderer.contextEvents }
|
|
22171
22694
|
);
|
|
22172
22695
|
const gl = this.renderer?.gl;
|
|
22173
22696
|
const rasterTarget = this.gpuClipPolicy === "contained" && gl ? rasterTargetForRect(null, gl.drawingBufferWidth, gl.drawingBufferHeight, this.plot, this.dpr) : void 0;
|
|
@@ -22184,6 +22707,7 @@ var ChartXY = class {
|
|
|
22184
22707
|
clear: grids.length === 0,
|
|
22185
22708
|
rasterTarget
|
|
22186
22709
|
});
|
|
22710
|
+
if (shared) shared.present(this.sharedPresent, this.canvas.width, this.canvas.height);
|
|
22187
22711
|
}
|
|
22188
22712
|
gpuHeatmap(s) {
|
|
22189
22713
|
return !!this.renderer?.gl && s.axisX.type !== "logarithmic" && s.axisY.type !== "logarithmic";
|
|
@@ -23443,7 +23967,8 @@ var Chart3D = class extends ChartXY {
|
|
|
23443
23967
|
gpuPackets = /* @__PURE__ */ new Map();
|
|
23444
23968
|
gpuRevision = 0;
|
|
23445
23969
|
constructor(options = {}) {
|
|
23446
|
-
|
|
23970
|
+
if (options.sharedContext) throw new UnsupportedFeatureError("shared WebGL contexts for Chart3D");
|
|
23971
|
+
super({ ...options, sharedContext: null, antialias: options.antialias ?? true });
|
|
23447
23972
|
this.cameraModel = options.experimental3DCameraModel === "legacy" ? "legacy" : "world";
|
|
23448
23973
|
this.axesZ.push(new Axis(this, "z", options.defaultAxisZ));
|
|
23449
23974
|
this.coordsAxis.z = this.axesZ[0];
|
|
@@ -25018,7 +25543,8 @@ function createCRYChartAdapter(container, options = {}) {
|
|
|
25018
25543
|
const chart = new ChartXY({
|
|
25019
25544
|
container,
|
|
25020
25545
|
legend: { visible: false },
|
|
25021
|
-
...options.xScale === "logarithmic" ? { defaultAxisX: { type: "logarithmic", base: 10 } } : {}
|
|
25546
|
+
...options.xScale === "logarithmic" ? { defaultAxisX: { type: "logarithmic", base: 10 } } : {},
|
|
25547
|
+
...options.sharedContext ? { sharedContext: options.sharedContext } : {}
|
|
25022
25548
|
});
|
|
25023
25549
|
const entries = /* @__PURE__ */ new Map();
|
|
25024
25550
|
let disposed = false;
|
|
@@ -25194,12 +25720,27 @@ function createCRYChartAdapter(container, options = {}) {
|
|
|
25194
25720
|
}
|
|
25195
25721
|
|
|
25196
25722
|
// src/index.ts
|
|
25197
|
-
function cryChart(
|
|
25723
|
+
function cryChart(options = {}) {
|
|
25724
|
+
if (options.sharedContext !== void 0 && options.sharedContextOptions !== void 0) {
|
|
25725
|
+
throw new TypeError(
|
|
25726
|
+
"Pass either sharedContext or sharedContextOptions, not both"
|
|
25727
|
+
);
|
|
25728
|
+
}
|
|
25729
|
+
if (options.sharedContext !== void 0 && !(options.sharedContext instanceof SharedWebGLContext)) {
|
|
25730
|
+
throw new TypeError("sharedContext must be a SharedWebGLContext");
|
|
25731
|
+
}
|
|
25732
|
+
if (options.sharedContext?.isDisposed()) {
|
|
25733
|
+
throw new Error("sharedContext has been disposed");
|
|
25734
|
+
}
|
|
25735
|
+
const shared = options.sharedContext ?? (options.sharedContextOptions ? new SharedWebGLContext(options.sharedContextOptions) : void 0);
|
|
25736
|
+
const ownsShared = !options.sharedContext && shared !== void 0;
|
|
25198
25737
|
const owned2 = /* @__PURE__ */ new Set();
|
|
25199
25738
|
let disposed = false;
|
|
25200
|
-
const create = (ctor,
|
|
25739
|
+
const create = (ctor, opts = {}) => {
|
|
25201
25740
|
if (disposed) throw new Error("Chart context has been disposed");
|
|
25202
|
-
const
|
|
25741
|
+
const injects = shared !== void 0 && (ctor === ChartXY || ctor === Polar || ctor === Dashboard) && !("sharedContext" in opts);
|
|
25742
|
+
const finalOptions = injects ? { ...opts, sharedContext: shared } : opts;
|
|
25743
|
+
const chart = new ctor(finalOptions);
|
|
25203
25744
|
owned2.add(chart);
|
|
25204
25745
|
chart.onDispose(() => owned2.delete(chart));
|
|
25205
25746
|
return chart;
|
|
@@ -25230,17 +25771,25 @@ function cryChart(_options = {}) {
|
|
|
25230
25771
|
} catch (error) {
|
|
25231
25772
|
errors.push(error);
|
|
25232
25773
|
}
|
|
25774
|
+
if (ownsShared) try {
|
|
25775
|
+
shared.dispose();
|
|
25776
|
+
} catch (error) {
|
|
25777
|
+
errors.push(error);
|
|
25778
|
+
}
|
|
25233
25779
|
if (errors.length) throw new AggregateError(errors, "Some chart disposal callbacks failed");
|
|
25234
25780
|
}
|
|
25235
25781
|
},
|
|
25236
25782
|
isDisposed: () => disposed,
|
|
25237
25783
|
/** Live charts owned by this context; disposed charts are released immediately. */
|
|
25238
|
-
getChartCount: () => owned2.size
|
|
25784
|
+
getChartCount: () => owned2.size,
|
|
25785
|
+
/** Shared WebGL2 context used by this context; undefined when not enabled. */
|
|
25786
|
+
getSharedContext: () => shared
|
|
25239
25787
|
};
|
|
25240
25788
|
}
|
|
25241
|
-
var version = "1.0.
|
|
25789
|
+
var version = "1.0.8";
|
|
25242
25790
|
var Dashboard = class {
|
|
25243
25791
|
root;
|
|
25792
|
+
sharedContext;
|
|
25244
25793
|
cells = /* @__PURE__ */ new Map();
|
|
25245
25794
|
children = /* @__PURE__ */ new Set();
|
|
25246
25795
|
events = new EventHub();
|
|
@@ -25252,6 +25801,7 @@ var Dashboard = class {
|
|
|
25252
25801
|
throw new Error("Dashboard requires a DOM");
|
|
25253
25802
|
const container = typeof options.container === "string" ? document.getElementById(options.container) : options.container ?? document.body;
|
|
25254
25803
|
if (!container) throw new Error("Dashboard container was not found");
|
|
25804
|
+
this.sharedContext = options.sharedContext;
|
|
25255
25805
|
this.root = document.createElement("div");
|
|
25256
25806
|
this.columns = options.numberOfColumns ?? 2;
|
|
25257
25807
|
this.rows = options.numberOfRows ?? 2;
|
|
@@ -25264,8 +25814,13 @@ var Dashboard = class {
|
|
|
25264
25814
|
cell.style.cssText = `min-height:0;min-width:0;grid-column:${(options.columnIndex ?? 0) + 1}/span ${options.columnSpan ?? 1};grid-row:${(options.rowIndex ?? 0) + 1}/span ${options.rowSpan ?? 1}`;
|
|
25265
25815
|
this.root.append(cell);
|
|
25266
25816
|
let chart;
|
|
25817
|
+
const inject = this.sharedContext && (Ctor === ChartXY || Ctor === Polar) && !("sharedContext" in options);
|
|
25267
25818
|
try {
|
|
25268
|
-
chart = new Ctor({
|
|
25819
|
+
chart = new Ctor({
|
|
25820
|
+
...options,
|
|
25821
|
+
...inject ? { sharedContext: this.sharedContext } : {},
|
|
25822
|
+
container: cell
|
|
25823
|
+
});
|
|
25269
25824
|
} catch (error) {
|
|
25270
25825
|
cell.remove();
|
|
25271
25826
|
throw error;
|