@tradecanvas/core 1.24.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{WebGLSeriesRenderer-BNrnoMHq.js → WebGLSeriesRenderer-BXFfVudh.js} +3 -3
  2. package/dist/{WebGLSeriesRenderer-BNrnoMHq.js.map → WebGLSeriesRenderer-BXFfVudh.js.map} +1 -1
  3. package/dist/{WebGLSeriesRenderer-Bclv4lzZ.cjs → WebGLSeriesRenderer-DaTDdW4O.cjs} +3 -3
  4. package/dist/{WebGLSeriesRenderer-Bclv4lzZ.cjs.map → WebGLSeriesRenderer-DaTDdW4O.cjs.map} +1 -1
  5. package/dist/axis/GridRenderer.d.ts +3 -1
  6. package/dist/axis/GridRenderer.d.ts.map +1 -1
  7. package/dist/axis/PriceAxis.d.ts +28 -0
  8. package/dist/axis/PriceAxis.d.ts.map +1 -1
  9. package/dist/axis/TimeAxis.d.ts +16 -0
  10. package/dist/axis/TimeAxis.d.ts.map +1 -1
  11. package/dist/axis/gridLines.d.ts +11 -1
  12. package/dist/axis/gridLines.d.ts.map +1 -1
  13. package/dist/axis/timeMarks.d.ts +75 -0
  14. package/dist/axis/timeMarks.d.ts.map +1 -0
  15. package/dist/charts/CompareRenderer.d.ts.map +1 -1
  16. package/dist/drawings/DrawingManager.d.ts +5 -4
  17. package/dist/drawings/DrawingManager.d.ts.map +1 -1
  18. package/dist/engine/RenderEngine.d.ts.map +1 -1
  19. package/dist/engine/gpu.d.ts +3 -0
  20. package/dist/engine/gpu.d.ts.map +1 -1
  21. package/dist/features/DataExporter.d.ts.map +1 -1
  22. package/dist/features/MeasureOverlay.d.ts.map +1 -1
  23. package/dist/gpuContexts-BN9YuYEa.cjs +2 -0
  24. package/dist/gpuContexts-BN9YuYEa.cjs.map +1 -0
  25. package/dist/{gpuContexts-Bn58hj7u.js → gpuContexts-BXj2qguo.js} +132 -107
  26. package/dist/gpuContexts-BXj2qguo.js.map +1 -0
  27. package/dist/index.cjs +5 -5
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +3300 -3063
  30. package/dist/index.js.map +1 -1
  31. package/dist/indicators/symbols/SymbolSeriesStore.d.ts +4 -3
  32. package/dist/indicators/symbols/SymbolSeriesStore.d.ts.map +1 -1
  33. package/dist/indicators/symbols/symbolIndicators.d.ts.map +1 -1
  34. package/dist/interaction/CrosshairHandler.d.ts +8 -0
  35. package/dist/interaction/CrosshairHandler.d.ts.map +1 -1
  36. package/dist/interaction/CrosshairTooltip.d.ts +4 -2
  37. package/dist/interaction/CrosshairTooltip.d.ts.map +1 -1
  38. package/dist/interaction/PinnedTooltip.d.ts +3 -2
  39. package/dist/interaction/PinnedTooltip.d.ts.map +1 -1
  40. package/dist/trading/fillMarks.d.ts.map +1 -1
  41. package/dist/ui/BarCountdown.d.ts.map +1 -1
  42. package/dist/ui/ChartLegend.d.ts +4 -1
  43. package/dist/ui/ChartLegend.d.ts.map +1 -1
  44. package/dist/ui/SessionBreaks.d.ts +2 -1
  45. package/dist/ui/SessionBreaks.d.ts.map +1 -1
  46. package/dist/viewport/ScaleMapping.d.ts +11 -5
  47. package/dist/viewport/ScaleMapping.d.ts.map +1 -1
  48. package/dist/viewport/Viewport.d.ts.map +1 -1
  49. package/dist/viewport/index.d.ts +1 -1
  50. package/dist/viewport/index.d.ts.map +1 -1
  51. package/package.json +2 -2
  52. package/dist/gpuContexts-Bn58hj7u.js.map +0 -1
  53. package/dist/gpuContexts-DYrOp3uo.cjs +0 -2
  54. package/dist/gpuContexts-DYrOp3uo.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
- import { computeTickStep as e, lineDash as t } from "@tradecanvas/commons";
1
+ import { barTimeUnit as e, computeTickStep as t, lineDash as n } from "@tradecanvas/commons";
2
2
  //#region src/viewport/ScaleMapping.ts
3
- function n(e, t) {
3
+ function r(e, t) {
4
4
  return e * (t.barWidth + t.barSpacing) - t.offset + t.chartRect.x + t.barWidth / 2;
5
5
  }
6
- function r(e, t) {
6
+ function i(e, t) {
7
7
  let { min: n, max: r } = t.priceRange, { y: i, height: a } = t.chartRect, o;
8
8
  if (t.logScale && n > 0 && r > 0) {
9
9
  let t = Math.log(n), s = Math.log(r) - t;
@@ -16,7 +16,7 @@ function r(e, t) {
16
16
  }
17
17
  return i + a * (t.invertScale ? o : 1 - o);
18
18
  }
19
- function i(e) {
19
+ function a(e) {
20
20
  let { min: t, max: n } = e.priceRange, { y: r, height: i } = e.chartRect, a = e.invertScale === !0;
21
21
  if (e.logScale && t > 0 && n > 0) {
22
22
  let e = Math.log(t), o = Math.log(n) - e;
@@ -29,7 +29,7 @@ function i(e) {
29
29
  let s = i / o;
30
30
  return a ? (e) => r + (e - t) * s : (e) => r + (n - e) * s;
31
31
  }
32
- function a(e, t, n, r) {
32
+ function o(e, t, n, r) {
33
33
  let { min: i, max: a } = n.priceRange, o = (a - i) / t, s = r(i + e * o), c = r(i + (e + 1) * o);
34
34
  return {
35
35
  top: Math.min(s, c),
@@ -37,11 +37,11 @@ function a(e, t, n, r) {
37
37
  mid: (s + c) / 2
38
38
  };
39
39
  }
40
- function o(e, t) {
40
+ function s(e, t) {
41
41
  let n = t.barWidth + t.barSpacing;
42
42
  return Math.round((e - t.chartRect.x - t.barWidth / 2 + t.offset) / n);
43
43
  }
44
- function s(e, t) {
44
+ function c(e, t) {
45
45
  let { min: n, max: r } = t.priceRange, i = (e - t.chartRect.y) / t.chartRect.height, a = t.invertScale ? i : 1 - i;
46
46
  if (t.logScale && n > 0 && r > 0) {
47
47
  let e = Math.log(n);
@@ -49,41 +49,54 @@ function s(e, t) {
49
49
  }
50
50
  return n + (r - n) * a;
51
51
  }
52
- var c = /* @__PURE__ */ new WeakMap();
53
- function l(e) {
52
+ var l = /* @__PURE__ */ new WeakMap();
53
+ function u(e) {
54
54
  let t = e.length;
55
55
  if (t < 2) return 0;
56
- let n = c.get(e);
56
+ let n = l.get(e);
57
57
  if (n && n.length === t) return n.step;
58
58
  let r = [];
59
59
  for (let n = Math.max(1, t - 20); n < t; n++) r.push(e[n].time - e[n - 1].time);
60
60
  r.sort((e, t) => e - t);
61
61
  let i = Math.max(0, r[r.length >> 1]);
62
- return c.set(e, {
62
+ return l.set(e, {
63
63
  length: t,
64
64
  step: i
65
65
  }), i;
66
66
  }
67
- function u(e) {
68
- let t = l(e);
69
- return (e.length > 0 ? e[e.length - 1].time : 0) > 0xe8d4a51000 ? t : t * 1e3;
67
+ var d = 100, f = /* @__PURE__ */ new WeakMap();
68
+ function p(e) {
69
+ let t = e.length;
70
+ if (t < 2) return 0;
71
+ let n = Math.min(t - 1, d), r = f.get(e);
72
+ if (r && r.length === t && r.first === e[0].time && r.end === e[n].time) return r.step;
73
+ let i = (e[n].time - e[0].time) / n, a = i > 0 ? i : u(e);
74
+ return f.set(e, {
75
+ length: t,
76
+ first: e[0].time,
77
+ end: e[n].time,
78
+ step: a
79
+ }), a;
80
+ }
81
+ function m(t) {
82
+ return u(t) * e(t);
70
83
  }
71
- function d(e, t) {
84
+ function h(e, t) {
72
85
  let n = t.length;
73
86
  if (n === 0) return e;
74
87
  let r = n - 1;
75
- if (e > r) return t[r].time + (e - r) * l(t);
76
- if (e < 0) return t[0].time + e * l(t);
88
+ if (e > r) return t[r].time + (e - r) * u(t);
89
+ if (e < 0) return t[0].time + e * p(t);
77
90
  let i = Math.floor(e);
78
91
  return i === e || i >= r ? t[i].time : t[i].time + (e - i) * (t[i + 1].time - t[i].time);
79
92
  }
80
- function f(e, t) {
93
+ function g(e, t) {
81
94
  if (t.length === 0) return -1;
82
95
  let n = t[0].time, r = t.length - 1, i = t[r].time;
83
96
  if (e <= n || e >= i) {
84
97
  if (e === n) return 0;
85
98
  if (e === i) return r;
86
- let a = l(t);
99
+ let a = e < n ? p(t) : u(t);
87
100
  return a <= 0 ? e < n ? 0 : r : e < n ? (e - n) / a : r + (e - i) / a;
88
101
  }
89
102
  let a = 0, o = t.length - 1;
@@ -94,27 +107,27 @@ function f(e, t) {
94
107
  }
95
108
  if (a >= t.length) return t.length - 1;
96
109
  if (o < 0) return 0;
97
- let s = t[o].time, c = t[a].time, u = c === s ? 0 : (e - s) / (c - s);
98
- return o + u;
110
+ let s = t[o].time, c = t[a].time, l = c === s ? 0 : (e - s) / (c - s);
111
+ return o + l;
99
112
  }
100
- function p(e, t) {
113
+ function _(e, t) {
101
114
  let n = t.data;
102
- return n && n.length > 0 ? f(e, n) : e;
115
+ return n && n.length > 0 ? g(e, n) : e;
103
116
  }
104
- function m(e, t) {
105
- return n(p(e, t), t);
117
+ function v(e, t) {
118
+ return r(_(e, t), t);
106
119
  }
107
- function h(e, t) {
108
- let n = o(e, t), r = t.data;
109
- return r && r.length > 0 ? d(n, r) : n;
120
+ function y(e, t) {
121
+ let n = s(e, t), r = t.data;
122
+ return r && r.length > 0 ? h(n, r) : n;
110
123
  }
111
124
  //#endregion
112
125
  //#region src/charts/pixelGrid.ts
113
- var g = .5037;
114
- function _(e) {
115
- return Math.floor(e + g);
126
+ var b = .5037;
127
+ function x(e) {
128
+ return Math.floor(e + b);
116
129
  }
117
- function v(e) {
130
+ function S(e) {
118
131
  let t = typeof e.getTransform == "function" ? e.getTransform() : void 0;
119
132
  return {
120
133
  a: t && Number.isFinite(t.a) && t.a > 0 ? t.a : 1,
@@ -123,43 +136,43 @@ function v(e) {
123
136
  f: t && Number.isFinite(t.f) ? t.f : 0
124
137
  };
125
138
  }
126
- function y(e, t) {
127
- let { a: n, d: r, e: i, f: a } = v(e);
139
+ function C(e, t) {
140
+ let { a: n, d: r, e: i, f: a } = S(e);
128
141
  e.save(), e.setTransform(1, 0, 0, 1, 0, 0);
129
142
  try {
130
143
  return t({
131
144
  ratio: n,
132
- x: (e) => _(e * n + i),
133
- y: (e) => _(e * r + a),
134
- left: (e, t) => _(e * n + i - t / 2)
145
+ x: (e) => x(e * n + i),
146
+ y: (e) => x(e * r + a),
147
+ left: (e, t) => x(e * n + i - t / 2)
135
148
  });
136
149
  } finally {
137
150
  e.restore();
138
151
  }
139
152
  }
140
- function b(e, t) {
153
+ function w(e, t) {
141
154
  let n = Math.max(1, Math.floor(t)), r = Math.max(n, Math.round(e * t));
142
155
  return (r - n) % 2 != 0 && --r, {
143
156
  body: Math.max(r, n),
144
157
  wick: n
145
158
  };
146
159
  }
147
- function x(e, t, n, r) {
160
+ function T(e, t, n, r) {
148
161
  let i = Math.max(1, Math.round(t * n)), a = i % 2 ? .5 : 0;
149
162
  return {
150
- at: (_(e * n + r - a) + a - r) / n,
163
+ at: (x(e * n + r - a) + a - r) / n,
151
164
  width: i / n
152
165
  };
153
166
  }
154
- function S(e, t, n) {
155
- let r = v(e), i = x(t, n, r.d, r.f);
167
+ function E(e, t, n) {
168
+ let r = S(e), i = T(t, n, r.d, r.f);
156
169
  return {
157
170
  y: i.at,
158
171
  width: i.width
159
172
  };
160
173
  }
161
- function C(e, t, n) {
162
- let r = v(e), i = x(t, n, r.a, r.e);
174
+ function D(e, t, n) {
175
+ let r = S(e), i = T(t, n, r.a, r.e);
163
176
  return {
164
177
  x: i.at,
165
178
  width: i.width
@@ -167,11 +180,11 @@ function C(e, t, n) {
167
180
  }
168
181
  //#endregion
169
182
  //#region src/charts/denseBars.ts
170
- var w = 1;
171
- function T(e) {
183
+ var O = 1;
184
+ function k(e) {
172
185
  return e.barWidth < 1;
173
186
  }
174
- function E(e, t, n, r, i) {
187
+ function A(e, t, n, r, i) {
175
188
  let a = Math.min(n, e.length - 1);
176
189
  if (t > a) return;
177
190
  let o = {
@@ -188,37 +201,49 @@ function E(e, t, n, r, i) {
188
201
  }
189
202
  s && i(o);
190
203
  }
191
- function D(e, t, n, r, a) {
192
- let { from: o, to: s } = n.visibleRange, c = n.barWidth + n.barSpacing, l = -n.offset + n.chartRect.x + n.barWidth / 2, u = i(n);
193
- y(e, (n) => {
194
- let i = new Path2D(), d = new Path2D();
195
- E(t, o, s, (e) => e * c + l, (e) => {
196
- let t = n.y(u(e.high)), r = n.y(u(e.low)), a = n.x(e.x), o = Math.max(1, n.x(e.x + 1) - a);
197
- (e.close >= e.open ? i : d).rect(a, Math.min(t, r), o, Math.max(Math.abs(r - t), 1));
198
- }), e.fillStyle = r, e.fill(i), e.fillStyle = a, e.fill(d);
204
+ function j(e, t, n, r, i) {
205
+ let { from: o, to: s } = n.visibleRange, c = n.barWidth + n.barSpacing, l = -n.offset + n.chartRect.x + n.barWidth / 2, u = a(n);
206
+ C(e, (n) => {
207
+ let a = new Path2D(), d = new Path2D();
208
+ A(t, o, s, (e) => e * c + l, (e) => {
209
+ let t = n.y(u(e.high)), r = n.y(u(e.low)), i = n.x(e.x), o = Math.max(1, n.x(e.x + 1) - i);
210
+ (e.close >= e.open ? a : d).rect(i, Math.min(t, r), o, Math.max(Math.abs(r - t), 1));
211
+ }), e.fillStyle = r, e.fill(a), e.fillStyle = i, e.fill(d);
199
212
  });
200
213
  }
201
214
  //#endregion
202
215
  //#region src/axis/gridLines.ts
203
- var O = 80;
204
- function k(t) {
205
- let { chartRect: n, priceRange: r } = t;
206
- if (r.max - r.min <= 0) return {
216
+ var M = 80;
217
+ function N(e, n = {}) {
218
+ let { chartRect: r, priceRange: i } = e;
219
+ if (i.max - i.min <= 0) return {
207
220
  horizontal: [],
208
221
  vertical: []
209
222
  };
210
- let a = i(t), o = [], s = e(r.min, r.max, 8), c = Math.ceil(r.min / s) * s;
211
- for (let e = c; e <= r.max; e += s) o.push(Math.round(a(e)) + .5);
212
- let l = [], u = t.barWidth + t.barSpacing, d = Math.max(1, Math.ceil(O / u)), f = -t.offset + n.x + t.barWidth / 2, p = Math.floor(t.offset / u), m = Math.ceil((t.offset + n.width) / u);
213
- for (let e = p; e <= m; e++) e % d === 0 && l.push(Math.round(e * u + f) + .5);
223
+ let o = a(e), s = [];
224
+ if (n.prices) for (let e of n.prices) s.push(Math.round(o(e)) + .5);
225
+ else {
226
+ let e = t(i.min, i.max, 8), n = Math.ceil(i.min / e) * e;
227
+ for (let t = 0; n + t * e <= i.max; t++) s.push(Math.round(o(n + t * e)) + .5);
228
+ }
229
+ let c = [], l = e.barWidth + e.barSpacing, u = -e.offset + r.x + e.barWidth / 2;
230
+ if (n.slots) {
231
+ for (let e of n.slots) c.push(Math.round(e * l + u) + .5);
232
+ return {
233
+ horizontal: s,
234
+ vertical: c
235
+ };
236
+ }
237
+ let d = Math.max(1, Math.ceil(M / l)), f = Math.floor(e.offset / l), p = Math.ceil((e.offset + r.width) / l);
238
+ for (let e = f; e <= p; e++) e % d === 0 && c.push(Math.round(e * l + u) + .5);
214
239
  return {
215
- horizontal: o,
216
- vertical: l
240
+ horizontal: s,
241
+ vertical: c
217
242
  };
218
243
  }
219
244
  //#endregion
220
245
  //#region src/axis/GridRenderer.ts
221
- var A = [4, 4], j = class {
246
+ var P = [4, 4], F = class {
222
247
  visible = !0;
223
248
  setVisible(e) {
224
249
  this.visible = e;
@@ -226,36 +251,36 @@ var A = [4, 4], j = class {
226
251
  isVisible() {
227
252
  return this.visible;
228
253
  }
229
- render(e, t, n) {
254
+ render(e, t, n, r) {
230
255
  if (!this.visible) return;
231
- let { chartRect: r } = t, { horizontal: i, vertical: a } = k(t), o = M(n), s = o.horizontal, c = o.vertical;
232
- if (s.visible && c.visible && s.color === c.color && s.style === c.style && s.width === c.width) {
233
- P(e, s, () => {
234
- for (let t of i) {
235
- let n = F(t, s.width);
236
- e.moveTo(r.x, n), e.lineTo(r.x + r.width, n);
237
- }
256
+ let { chartRect: i } = t, { horizontal: a, vertical: o } = N(t, r), s = I(n), c = s.horizontal, l = s.vertical;
257
+ if (c.visible && l.visible && c.color === l.color && c.style === l.style && c.width === l.width) {
258
+ R(e, c, () => {
238
259
  for (let t of a) {
239
- let n = F(t, c.width);
240
- e.moveTo(n, r.y), e.lineTo(n, r.y + r.height);
260
+ let n = z(t, c.width);
261
+ e.moveTo(i.x, n), e.lineTo(i.x + i.width, n);
262
+ }
263
+ for (let t of o) {
264
+ let n = z(t, l.width);
265
+ e.moveTo(n, i.y), e.lineTo(n, i.y + i.height);
241
266
  }
242
267
  }), e.setLineDash([]);
243
268
  return;
244
269
  }
245
- o.horizontal.visible && i.length > 0 && P(e, o.horizontal, () => {
246
- for (let t of i) {
247
- let n = F(t, o.horizontal.width);
248
- e.moveTo(r.x, n), e.lineTo(r.x + r.width, n);
249
- }
250
- }), o.vertical.visible && a.length > 0 && P(e, o.vertical, () => {
270
+ s.horizontal.visible && a.length > 0 && R(e, s.horizontal, () => {
251
271
  for (let t of a) {
252
- let n = F(t, o.vertical.width);
253
- e.moveTo(n, r.y), e.lineTo(n, r.y + r.height);
272
+ let n = z(t, s.horizontal.width);
273
+ e.moveTo(i.x, n), e.lineTo(i.x + i.width, n);
274
+ }
275
+ }), s.vertical.visible && o.length > 0 && R(e, s.vertical, () => {
276
+ for (let t of o) {
277
+ let n = z(t, s.vertical.width);
278
+ e.moveTo(n, i.y), e.lineTo(n, i.y + i.height);
254
279
  }
255
280
  }), e.setLineDash([]);
256
281
  }
257
282
  };
258
- function M(e) {
283
+ function I(e) {
259
284
  let t = {
260
285
  visible: !0,
261
286
  color: e.grid,
@@ -267,41 +292,41 @@ function M(e) {
267
292
  vertical: t
268
293
  };
269
294
  }
270
- function N(e) {
271
- let { horizontal: t, vertical: n } = M(e), r = [t, n].filter((e) => e.visible);
295
+ function L(e) {
296
+ let { horizontal: t, vertical: n } = I(e), r = [t, n].filter((e) => e.visible);
272
297
  return r.every((e) => e.style === "solid" && e.width === 1 && e.color === r[0].color);
273
298
  }
274
- function P(e, n, r) {
275
- e.strokeStyle = n.color, e.lineWidth = n.width, e.setLineDash(t(n.style, A, n.width)), e.beginPath(), r(), e.stroke();
299
+ function R(e, t, r) {
300
+ e.strokeStyle = t.color, e.lineWidth = t.width, e.setLineDash(n(t.style, P, t.width)), e.beginPath(), r(), e.stroke();
276
301
  }
277
- function F(e, t) {
302
+ function z(e, t) {
278
303
  return t % 2 == 0 ? Math.round(e) : e;
279
304
  }
280
305
  //#endregion
281
306
  //#region src/engine/gpuContexts.ts
282
- var I = 8, L = 8, R = 0, z = /* @__PURE__ */ new Set();
283
- function B(e) {
284
- L = Number.isNaN(e) ? 8 : Math.max(0, Math.floor(e)), V() > 0 && W();
307
+ var B = 8, V = 8, H = 0, U = /* @__PURE__ */ new Set();
308
+ function W(e) {
309
+ V = Number.isNaN(e) ? 8 : Math.max(0, Math.floor(e)), G() > 0 && J();
285
310
  }
286
- function V() {
287
- return Math.max(0, L - R);
311
+ function G() {
312
+ return Math.max(0, V - H);
288
313
  }
289
- function H() {
290
- if (R >= L) return null;
291
- R++;
314
+ function K() {
315
+ if (H >= V) return null;
316
+ H++;
292
317
  let e = !1;
293
318
  return () => {
294
- e || (e = !0, R--, W());
319
+ e || (e = !0, H--, J());
295
320
  };
296
321
  }
297
- function U(e) {
298
- return z.add(e), () => {
299
- z.delete(e);
322
+ function q(e) {
323
+ return U.add(e), () => {
324
+ U.delete(e);
300
325
  };
301
326
  }
302
- function W() {
303
- let e = [...z];
304
- z.clear();
327
+ function J() {
328
+ let e = [...U];
329
+ U.clear();
305
330
  for (let t of e) try {
306
331
  t();
307
332
  } catch (e) {
@@ -311,6 +336,6 @@ function W() {
311
336
  }
312
337
  }
313
338
  //#endregion
314
- export { h as A, a as C, m as D, p as E, f as O, u as S, i as T, S as _, U as a, n as b, M as c, E as d, T as f, C as g, b as h, B as i, s as j, o as k, k as l, g as m, H as n, j as o, D as p, V as r, N as s, I as t, w as u, y as v, r as w, l as x, d as y };
339
+ export { s as A, p as C, _ as D, a as E, c as M, v as O, m as S, i as T, E as _, q as a, r as b, I as c, A as d, k as f, D as g, w as h, W as i, y as j, g as k, N as l, b as m, K as n, F as o, j as p, G as r, L as s, B as t, O as u, C as v, o as w, u as x, h as y };
315
340
 
316
- //# sourceMappingURL=gpuContexts-Bn58hj7u.js.map
341
+ //# sourceMappingURL=gpuContexts-BXj2qguo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpuContexts-BXj2qguo.js","names":[],"sources":["../src/viewport/ScaleMapping.ts","../src/charts/pixelGrid.ts","../src/charts/denseBars.ts","../src/axis/gridLines.ts","../src/axis/GridRenderer.ts","../src/engine/gpuContexts.ts"],"sourcesContent":["import type { ViewportState } from '@tradecanvas/commons';\nimport { barTimeUnit } from '@tradecanvas/commons';\n\nexport function barIndexToX(index: number, viewport: ViewportState): number {\n const barUnit = viewport.barWidth + viewport.barSpacing;\n return index * barUnit - viewport.offset + viewport.chartRect.x + viewport.barWidth / 2;\n}\n\nexport function priceToY(price: number, viewport: ViewportState): number {\n const { min, max } = viewport.priceRange;\n const { y: top, height } = viewport.chartRect;\n let ratio: number;\n if (viewport.logScale && min > 0 && max > 0) {\n const logMin = Math.log(min);\n const logRange = Math.log(max) - logMin;\n if (logRange === 0) return top + height / 2;\n ratio = (Math.log(Math.max(price, Number.EPSILON)) - logMin) / logRange;\n } else {\n const range = max - min;\n if (range === 0) return top + height / 2;\n ratio = (price - min) / range;\n }\n return top + height * (viewport.invertScale ? ratio : 1 - ratio);\n}\n\n/**\n * `priceToY` for one frame, with the per-call work hoisted out: for renderers\n * that map every visible bar. Follows the log scale and the inverted scale.\n */\nexport function priceToYMapper(viewport: ViewportState): (price: number) => number {\n const { min, max } = viewport.priceRange;\n const { y: top, height } = viewport.chartRect;\n const invert = viewport.invertScale === true;\n if (viewport.logScale && min > 0 && max > 0) {\n const logMin = Math.log(min);\n const logRange = Math.log(max) - logMin;\n if (logRange === 0) return () => top + height / 2;\n const k = height / logRange;\n const bottom = top + height;\n return invert\n ? (price) => top + (Math.log(Math.max(price, Number.EPSILON)) - logMin) * k\n : (price) => bottom - (Math.log(Math.max(price, Number.EPSILON)) - logMin) * k;\n }\n const range = max - min;\n if (range === 0) return () => top + height / 2;\n const k = height / range;\n return invert ? (price) => top + (price - min) * k : (price) => top + (max - price) * k;\n}\n\n/**\n * Where bucket `b` of `count` equal price buckets across the price range sits\n * on screen (bucket 0 holds the lowest prices), on any scale. `toY` is the\n * frame's `priceToYMapper`.\n */\nexport function priceBucketRow(\n b: number,\n count: number,\n viewport: ViewportState,\n toY: (price: number) => number,\n): { top: number; height: number; mid: number } {\n const { min, max } = viewport.priceRange;\n const step = (max - min) / count;\n const yLow = toY(min + b * step);\n const yHigh = toY(min + (b + 1) * step);\n return { top: Math.min(yLow, yHigh), height: Math.abs(yLow - yHigh), mid: (yLow + yHigh) / 2 };\n}\n\nexport function xToBarIndex(x: number, viewport: ViewportState): number {\n const barUnit = viewport.barWidth + viewport.barSpacing;\n return Math.round((x - viewport.chartRect.x - viewport.barWidth / 2 + viewport.offset) / barUnit);\n}\n\nexport function yToPrice(y: number, viewport: ViewportState): number {\n const { min, max } = viewport.priceRange;\n const fromTop = (y - viewport.chartRect.y) / viewport.chartRect.height;\n const ratio = viewport.invertScale ? fromTop : 1 - fromTop;\n if (viewport.logScale && min > 0 && max > 0) {\n const logMin = Math.log(min);\n const logMax = Math.log(max);\n return Math.exp(logMin + (logMax - logMin) * ratio);\n }\n return min + (max - min) * ratio;\n}\n\ntype TimedSeries = ReadonlyArray<{ time: number }>;\n\nconst stepCache = new WeakMap<TimedSeries, { length: number; step: number }>();\n\n/**\n * Typical spacing between bar times — the median of the last ~20 intervals,\n * so a weekend or halt gap doesn't skew it. Used to place times beyond either\n * end of the data (the empty future the chart can be panned into). Cached per\n * series and length; 0 when there are fewer than two bars.\n */\nexport function barTimeStep(data: TimedSeries): number {\n const n = data.length;\n if (n < 2) return 0;\n const cached = stepCache.get(data);\n if (cached && cached.length === n) return cached.step;\n const diffs: number[] = [];\n for (let i = Math.max(1, n - 20); i < n; i++) diffs.push(data[i].time - data[i - 1].time);\n diffs.sort((a, b) => a - b);\n const step = Math.max(0, diffs[diffs.length >> 1]);\n stepCache.set(data, { length: n, step });\n return step;\n}\n\n/** Bars the spacing before the oldest bar is averaged over. */\nconst PAST_STEP_SAMPLE = 100;\n\nconst pastStepCache = new WeakMap<TimedSeries, { length: number; first: number; end: number; step: number }>();\n\n/**\n * The average spacing of the first bars, weekends, nights and halts\n * included: how far back in time a slot before the oldest bar goes, so an\n * extrapolated date lands about where the bars, once loaded, would put it.\n * Cached per series; `barTimeStep` when the first bars share one time, 0\n * when there are fewer than two bars.\n */\nexport function pastTimeStep(data: TimedSeries): number {\n const n = data.length;\n if (n < 2) return 0;\n const k = Math.min(n - 1, PAST_STEP_SAMPLE);\n const cached = pastStepCache.get(data);\n if (cached && cached.length === n && cached.first === data[0].time && cached.end === data[k].time) return cached.step;\n const average = (data[k].time - data[0].time) / k;\n const step = average > 0 ? average : barTimeStep(data);\n pastStepCache.set(data, { length: n, first: data[0].time, end: data[k].time, step });\n return step;\n}\n\n/** `barTimeStep` in milliseconds whatever unit the series uses (`barTimeUnit`). */\nexport function barTimeStepMs(data: TimedSeries): number {\n return barTimeStep(data) * barTimeUnit(data);\n}\n\n/**\n * Time at bar index `index`, extrapolated past either end of the data: by\n * `barTimeStep` into the future right of the newest bar, by `pastTimeStep`\n * before the oldest.\n */\nexport function barIndexToTime(index: number, data: TimedSeries): number {\n const n = data.length;\n if (n === 0) return index;\n const last = n - 1;\n if (index > last) return data[last].time + (index - last) * barTimeStep(data);\n if (index < 0) return data[0].time + index * pastTimeStep(data);\n const lo = Math.floor(index);\n if (lo === index || lo >= last) return data[lo].time;\n return data[lo].time + (index - lo) * (data[lo + 1].time - data[lo].time);\n}\n\n/**\n * Convert a bar timestamp to its data-array index via binary search.\n * Falls back to fractional interpolation when the timestamp falls between bars,\n * and extrapolates (as `barIndexToTime` does) for times beyond either end — so a drawing\n * anchored in the future keeps its place instead of collapsing onto the last bar.\n * Returns -1 if data is empty.\n */\nexport function timestampToBarIndex(timestamp: number, data: TimedSeries): number {\n if (data.length === 0) return -1;\n const first = data[0].time;\n const lastIdx = data.length - 1;\n const lastTime = data[lastIdx].time;\n if (timestamp <= first || timestamp >= lastTime) {\n if (timestamp === first) return 0;\n if (timestamp === lastTime) return lastIdx;\n const step = timestamp < first ? pastTimeStep(data) : barTimeStep(data);\n if (step <= 0) return timestamp < first ? 0 : lastIdx;\n return timestamp < first ? (timestamp - first) / step : lastIdx + (timestamp - lastTime) / step;\n }\n // Binary search\n let lo = 0, hi = data.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >>> 1;\n if (data[mid].time === timestamp) return mid;\n if (data[mid].time < timestamp) lo = mid + 1;\n else hi = mid - 1;\n }\n // lo is the insertion point; interpolate between hi and lo\n if (lo >= data.length) return data.length - 1;\n if (hi < 0) return 0;\n const tLo = data[hi].time, tHi = data[lo].time;\n const frac = tHi !== tLo ? (timestamp - tLo) / (tHi - tLo) : 0;\n return hi + frac;\n}\n\n/**\n * Resolve an anchor `time` value to a (possibly fractional) bar index in the\n * current series. When `viewport.data` is set, `time` is interpreted as a real\n * timestamp and converted via `timestampToBarIndex`. Otherwise `time` is\n * already a bar index and is returned unchanged.\n */\nexport function resolveBarIndex(time: number, viewport: ViewportState): number {\n const data = viewport.data;\n if (data && data.length > 0) {\n return timestampToBarIndex(time, data);\n }\n return time;\n}\n\n/**\n * Map an anchor `time` value to its pixel x. Works whether `time` is a\n * timestamp (when `viewport.data` is set) or a bar index (legacy callers).\n */\nexport function timeToX(time: number, viewport: ViewportState): number {\n return barIndexToX(resolveBarIndex(time, viewport), viewport);\n}\n\n/**\n * Map a pixel x back to an anchor `time` value. Returns a real timestamp when\n * `viewport.data` is set (so the value survives timeframe switches), otherwise\n * returns a bar index for legacy callers.\n */\nexport function xToTime(x: number, viewport: ViewportState): number {\n const idx = xToBarIndex(x, viewport);\n const data = viewport.data;\n if (data && data.length > 0) {\n // Past either end (the empty future, or before the oldest bar) the time\n // is extrapolated, so drawings can be placed there.\n return barIndexToTime(idx, data);\n }\n return idx;\n}\n","/**\n * Drawing on whole device pixels. The chart draws in CSS pixels under the\n * device-pixel-ratio transform, so a 1 px line at a fractional position\n * spreads over two device pixels at half strength and looks soft and thick.\n * Bars drawn here go back to the canvas's own pixels and round to them: a\n * wick is one sharp column, a body has hard edges, at any ratio (1, 1.25, 2…).\n */\n\n/**\n * Rounding to a device pixel turns up from a hair under the half. Bar steps\n * are often round numbers (5.1 px, say) that put bars exactly on half a\n * pixel, where 64-bit arithmetic here and 32-bit on the GPU would round some\n * of them apart; a hair under, both land on the same side. The shaders use\n * the same constant.\n */\nexport const PIXEL_ROUNDING = 0.5037;\n\n/** The device pixel a device-pixel position rounds to. */\nexport function toPixel(v: number): number {\n return Math.floor(v + PIXEL_ROUNDING);\n}\n\nfunction transformOf(ctx: CanvasRenderingContext2D): { a: number; d: number; e: number; f: number } {\n const m = typeof ctx.getTransform === 'function' ? ctx.getTransform() : undefined;\n return {\n a: m && Number.isFinite(m.a) && m.a > 0 ? m.a : 1,\n d: m && Number.isFinite(m.d) && m.d > 0 ? m.d : 1,\n e: m && Number.isFinite(m.e) ? m.e : 0,\n f: m && Number.isFinite(m.f) ? m.f : 0,\n };\n}\n\n/** CSS to device-pixel mapping, rounded to whole pixels. */\nexport interface PixelGrid {\n /** Device pixels per CSS pixel. */\n ratio: number;\n /** The device pixel a CSS x falls on. */\n x(cssX: number): number;\n /** The device pixel a CSS y falls on. */\n y(cssY: number): number;\n /**\n * Left edge (device px) of a column `width` device pixels wide centred on\n * CSS x `cssCenter`: the same column `crispX` strokes for a line there.\n */\n left(cssCenter: number, width: number): number;\n}\n\n/**\n * Run `draw` with the transform reset to device pixels, then put it back.\n * A context without a readable transform (a test stand-in) is taken as 1:1.\n */\nexport function inDevicePixels<T>(ctx: CanvasRenderingContext2D, draw: (grid: PixelGrid) => T): T {\n const { a, d, e, f } = transformOf(ctx);\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n try {\n return draw({\n ratio: a,\n x: (v) => toPixel(v * a + e),\n y: (v) => toPixel(v * d + f),\n left: (v, width) => toPixel(v * a + e - width / 2),\n });\n } finally {\n ctx.restore();\n }\n}\n\n/**\n * A bar's columns in device pixels: the wick one CSS pixel wide (at least one\n * device pixel), the body about the bar's width, with an even difference so\n * the wick sits exactly in the middle.\n */\nexport function barColumns(barWidth: number, ratio: number): { body: number; wick: number } {\n const wick = Math.max(1, Math.floor(ratio));\n let body = Math.max(wick, Math.round(barWidth * ratio));\n if ((body - wick) % 2 !== 0) body -= 1;\n return { body: Math.max(body, wick), wick };\n}\n\n/** Snap a line's centre (in CSS px) so a `width`-wide stroke covers whole device pixels. */\nfunction snap(v: number, width: number, scale: number, shift: number): { at: number; width: number } {\n const w = Math.max(1, Math.round(width * scale));\n const half = w % 2 ? 0.5 : 0;\n return { at: (toPixel(v * scale + shift - half) + half - shift) / scale, width: w / scale };\n}\n\n/**\n * A horizontal line's y and width, snapped so the stroke covers whole device\n * pixels: one sharp row instead of a soft two-pixel smear.\n */\nexport function crispY(ctx: CanvasRenderingContext2D, y: number, width: number): { y: number; width: number } {\n const t = transformOf(ctx);\n const s = snap(y, width, t.d, t.f);\n return { y: s.at, width: s.width };\n}\n\n/** A vertical line's x and width, snapped like `crispY`. */\nexport function crispX(ctx: CanvasRenderingContext2D, x: number, width: number): { x: number; width: number } {\n const t = transformOf(ctx);\n const s = snap(x, width, t.a, t.e);\n return { x: s.at, width: s.width };\n}\n","import type { DataSeries, ViewportState } from '@tradecanvas/commons';\nimport { priceToYMapper } from '../viewport/ScaleMapping.js';\nimport { inDevicePixels } from './pixelGrid.js';\n\n/**\n * Below this bar width (CSS px) bar-shaped charts draw one column per pixel\n * instead of one shape per bar: thousands of sub-pixel candles would blur\n * into each other and cost a path segment each.\n */\nexport const DENSE_BAR_WIDTH = 1;\n\nexport function isDense(viewport: Pick<ViewportState, 'barWidth'>): boolean {\n return viewport.barWidth < DENSE_BAR_WIDTH;\n}\n\n/** The bars on one pixel column merged into one: first open, last close, extremes, largest volume. */\nexport interface PixelColumn {\n x: number;\n open: number;\n high: number;\n low: number;\n close: number;\n volume: number;\n}\n\n/**\n * Walk bars `from`..`to` merged per pixel column (`Math.floor` of their x).\n * The column object is reused between calls: copy it to keep it.\n */\nexport function forEachPixelColumn(\n data: DataSeries,\n from: number,\n to: number,\n toX: (index: number) => number,\n visit: (column: Readonly<PixelColumn>) => void,\n): void {\n const last = Math.min(to, data.length - 1);\n if (from > last) return;\n const col: PixelColumn = { x: 0, open: 0, high: 0, low: 0, close: 0, volume: 0 };\n let open = false;\n for (let i = Math.max(0, from); i <= last; i++) {\n const bar = data[i];\n const x = Math.floor(toX(i));\n if (open && x !== col.x) {\n visit(col);\n open = false;\n }\n if (!open) {\n col.x = x;\n col.open = bar.open;\n col.high = bar.high;\n col.low = bar.low;\n col.volume = bar.volume;\n open = true;\n } else {\n if (bar.high > col.high) col.high = bar.high;\n if (bar.low < col.low) col.low = bar.low;\n if (bar.volume > col.volume) col.volume = bar.volume;\n }\n col.close = bar.close;\n }\n if (open) visit(col);\n}\n\n/**\n * Draw a dense price series as one high–low line per pixel column, coloured by\n * the column's direction (its last close against its first open).\n */\nexport function renderDenseBars(\n ctx: CanvasRenderingContext2D,\n data: DataSeries,\n viewport: ViewportState,\n upColor: string,\n downColor: string,\n): void {\n const { from, to } = viewport.visibleRange;\n const barUnit = viewport.barWidth + viewport.barSpacing;\n const offsetX = -viewport.offset + viewport.chartRect.x + viewport.barWidth / 2;\n const toY = priceToYMapper(viewport);\n inDevicePixels(ctx, (px) => {\n const up = new Path2D();\n const down = new Path2D();\n forEachPixelColumn(data, from, to, (i) => i * barUnit + offsetX, (c) => {\n const top = px.y(toY(c.high));\n const bottom = px.y(toY(c.low));\n // A flat column still gets a pixel, like a doji's body.\n // Each column reaches the next with no gap: at 125% a CSS pixel is 1 or 2 device pixels.\n const left = px.x(c.x);\n const width = Math.max(1, px.x(c.x + 1) - left);\n (c.close >= c.open ? up : down).rect(left, Math.min(top, bottom), width, Math.max(Math.abs(bottom - top), 1));\n });\n ctx.fillStyle = upColor;\n ctx.fill(up);\n ctx.fillStyle = downColor;\n ctx.fill(down);\n });\n}\n","import type { ViewportState } from '@tradecanvas/commons';\nimport { computeTickStep } from '@tradecanvas/commons';\nimport { priceToYMapper } from '../viewport/ScaleMapping.js';\n\n/** The grid's lines as CSS-pixel centres: one across per price step, one down every few slots. */\nexport interface GridLines {\n horizontal: number[];\n vertical: number[];\n}\n\n/**\n * Where the axes put their labels: the grid draws its lines there, so lines\n * and labels agree. Either can be left out for the grid's own even spacing.\n */\nexport interface GridMarks {\n /** Prices the price axis labels. */\n prices?: readonly number[];\n /** Slots the time axis labels. */\n slots?: readonly number[];\n}\n\n/** Bars between vertical lines: at least this many pixels apart. */\nconst MIN_COLUMN_SPACING = 80;\n\n/** Where the grid lines go, for the 2D grid and the GPU alike. */\nexport function gridLines(viewport: ViewportState, marks: GridMarks = {}): GridLines {\n const { chartRect, priceRange } = viewport;\n if (priceRange.max - priceRange.min <= 0) return { horizontal: [], vertical: [] };\n const toY = priceToYMapper(viewport);\n\n const horizontal: number[] = [];\n if (marks.prices) {\n for (const price of marks.prices) horizontal.push(Math.round(toY(price)) + 0.5);\n } else {\n const priceStep = computeTickStep(priceRange.min, priceRange.max, 8);\n const firstPrice = Math.ceil(priceRange.min / priceStep) * priceStep;\n for (let i = 0; firstPrice + i * priceStep <= priceRange.max; i++) {\n horizontal.push(Math.round(toY(firstPrice + i * priceStep)) + 0.5);\n }\n }\n\n const vertical: number[] = [];\n const barUnit = viewport.barWidth + viewport.barSpacing;\n const offsetX = -viewport.offset + chartRect.x + viewport.barWidth / 2;\n if (marks.slots) {\n for (const slot of marks.slots) vertical.push(Math.round(slot * barUnit + offsetX) + 0.5);\n return { horizontal, vertical };\n }\n const barsPerGrid = Math.max(1, Math.ceil(MIN_COLUMN_SPACING / barUnit));\n // Every slot on screen — the empty space past either end of the data\n // (where the chart can be panned) keeps its grid too.\n const from = Math.floor(viewport.offset / barUnit);\n const to = Math.ceil((viewport.offset + chartRect.width) / barUnit);\n for (let i = from; i <= to; i++) {\n if (i % barsPerGrid !== 0) continue;\n vertical.push(Math.round(i * barUnit + offsetX) + 0.5);\n }\n return { horizontal, vertical };\n}\n","import type { ViewportState, Theme, ResolvedLineLook } from '@tradecanvas/commons';\nimport { lineDash } from '@tradecanvas/commons';\nimport { gridLines, type GridMarks } from './gridLines.js';\n\n/** The grid's dashes, as its lines are drawn when `dashed`. */\nconst GRID_DASH = [4, 4];\n\nexport class GridRenderer {\n private visible = true;\n\n setVisible(v: boolean): void { this.visible = v; }\n isVisible(): boolean { return this.visible; }\n\n /** `marks`: where the axes put their labels, for the lines to agree with them. */\n render(ctx: CanvasRenderingContext2D, viewport: ViewportState, theme: Theme, marks?: GridMarks): void {\n if (!this.visible) return;\n const { chartRect } = viewport;\n const { horizontal, vertical } = gridLines(viewport, marks);\n const looks = gridLooks(theme);\n const h = looks.horizontal;\n const v = looks.vertical;\n // Both ways alike: one path, so a see-through colour isn't laid twice where they cross.\n if (h.visible && v.visible && h.color === v.color && h.style === v.style && h.width === v.width) {\n stroke(ctx, h, () => {\n for (const y of horizontal) {\n const at = onPixel(y, h.width);\n ctx.moveTo(chartRect.x, at);\n ctx.lineTo(chartRect.x + chartRect.width, at);\n }\n for (const x of vertical) {\n const at = onPixel(x, v.width);\n ctx.moveTo(at, chartRect.y);\n ctx.lineTo(at, chartRect.y + chartRect.height);\n }\n });\n ctx.setLineDash([]);\n return;\n }\n if (looks.horizontal.visible && horizontal.length > 0) {\n stroke(ctx, looks.horizontal, () => {\n for (const y of horizontal) {\n const at = onPixel(y, looks.horizontal.width);\n ctx.moveTo(chartRect.x, at);\n ctx.lineTo(chartRect.x + chartRect.width, at);\n }\n });\n }\n if (looks.vertical.visible && vertical.length > 0) {\n stroke(ctx, looks.vertical, () => {\n for (const x of vertical) {\n const at = onPixel(x, looks.vertical.width);\n ctx.moveTo(at, chartRect.y);\n ctx.lineTo(at, chartRect.y + chartRect.height);\n }\n });\n }\n ctx.setLineDash([]);\n }\n}\n\n/** The grid's looks each way: the resolved style's, or the theme's grid colour, solid, 1 px. */\nexport function gridLooks(theme: Theme): { horizontal: ResolvedLineLook; vertical: ResolvedLineLook } {\n const plain: ResolvedLineLook = { visible: true, color: theme.grid, style: 'solid', width: 1 };\n return theme.style?.grid ?? { horizontal: plain, vertical: plain };\n}\n\n/**\n * Whether the GPU can draw the grid as it looks: every way shown is solid,\n * 1 px, and they share a colour. Otherwise the grid goes on Canvas 2D.\n */\nexport function gridFitsGpu(theme: Theme): boolean {\n const { horizontal, vertical } = gridLooks(theme);\n const shown = [horizontal, vertical].filter((look) => look.visible);\n return shown.every((look) => look.style === 'solid' && look.width === 1 && look.color === shown[0].color);\n}\n\n/** One path per way: a single stroke call for all its lines. */\nfunction stroke(ctx: CanvasRenderingContext2D, look: ResolvedLineLook, path: () => void): void {\n ctx.strokeStyle = look.color;\n ctx.lineWidth = look.width;\n ctx.setLineDash(lineDash(look.style, GRID_DASH, look.width));\n ctx.beginPath();\n path();\n ctx.stroke();\n}\n\n/** Grid lines come on the half pixel (crisp at 1 px); an even width is crisp on the whole pixel. */\nfunction onPixel(at: number, width: number): number {\n return width % 2 === 0 ? Math.round(at) : at;\n}\n","/**\n * The WebGL contexts the charts on a page hold at once. Chrome and Safari\n * keep about 16 a page and, past that, drop the oldest, whoever's it is (a\n * live chart's, a map's), never to hand it back. The charts stop short of\n * that and leave the rest to the page; a chart asked for WebGL past the limit\n * draws with Canvas 2D until a context is let go. The count is per copy of\n * the library loaded on the page.\n */\n\n/** How many charts draw with WebGL at once, unless set otherwise. */\nexport const DEFAULT_MAX_WEBGL_CHARTS = 8;\n\nlet limit = DEFAULT_MAX_WEBGL_CHARTS;\nlet held = 0;\nconst waiting = new Set<() => void>();\n\n/**\n * At most `count` charts on the page draw with WebGL at once (default 8;\n * `Infinity` for no limit). Charts that draw with WebGL already keep it when\n * the limit drops below them; it holds for those asking from then on.\n */\nexport function setMaxWebGLCharts(count: number): void {\n limit = Number.isNaN(count) ? DEFAULT_MAX_WEBGL_CHARTS : Math.max(0, Math.floor(count));\n if (gpuContextsLeft() > 0) wakeWaiting();\n}\n\n/** How many more charts may draw with WebGL now. */\nexport function gpuContextsLeft(): number {\n return Math.max(0, limit - held);\n}\n\n/** A context of the charts' share, or null when they hold all of it: the function given back lets it go (once). */\nexport function claimGpuContext(): (() => void) | null {\n if (held >= limit) return null;\n held++;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n held--;\n wakeWaiting();\n };\n}\n\n/** `callback`, once, the next time a context may be had; the function given back stops waiting. */\nexport function whenGpuContextFree(callback: () => void): () => void {\n waiting.add(callback);\n return () => {\n waiting.delete(callback);\n };\n}\n\nfunction wakeWaiting(): void {\n const callbacks = [...waiting];\n waiting.clear();\n for (const callback of callbacks) {\n try {\n callback();\n } catch (err) {\n // One that throws stops none of the others; its error still shows.\n queueMicrotask(() => {\n throw err;\n });\n }\n }\n}\n"],"mappings":";;AAGA,SAAgB,EAAY,GAAe,GAAiC;AAE1E,QAAO,KADS,EAAS,WAAW,EAAS,cACpB,EAAS,SAAS,EAAS,UAAU,IAAI,EAAS,WAAW;;AAGxF,SAAgB,EAAS,GAAe,GAAiC;CACvE,IAAM,EAAE,QAAK,WAAQ,EAAS,YACxB,EAAE,GAAG,GAAK,cAAW,EAAS,WAChC;AACJ,KAAI,EAAS,YAAY,IAAM,KAAK,IAAM,GAAG;EAC3C,IAAM,IAAS,KAAK,IAAI,EAAI,EACtB,IAAW,KAAK,IAAI,EAAI,GAAG;AACjC,MAAI,MAAa,EAAG,QAAO,IAAM,IAAS;AAC1C,OAAS,KAAK,IAAI,KAAK,IAAI,YAAsB,CAAC,GAAG,KAAU;QAC1D;EACL,IAAM,IAAQ,IAAM;AACpB,MAAI,MAAU,EAAG,QAAO,IAAM,IAAS;AACvC,OAAS,IAAQ,KAAO;;AAE1B,QAAO,IAAM,KAAU,EAAS,cAAc,IAAQ,IAAI;;AAO5D,SAAgB,EAAe,GAAoD;CACjF,IAAM,EAAE,QAAK,WAAQ,EAAS,YACxB,EAAE,GAAG,GAAK,cAAW,EAAS,WAC9B,IAAS,EAAS,gBAAgB;AACxC,KAAI,EAAS,YAAY,IAAM,KAAK,IAAM,GAAG;EAC3C,IAAM,IAAS,KAAK,IAAI,EAAI,EACtB,IAAW,KAAK,IAAI,EAAI,GAAG;AACjC,MAAI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