@tradecanvas/core 1.11.0 → 1.12.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 (65) hide show
  1. package/README.md +2 -4
  2. package/dist/{WebGLSeriesRenderer-DVJBHdfm.js → WebGLSeriesRenderer-CLVnGxIS.js} +174 -134
  3. package/dist/{WebGLSeriesRenderer-DVJBHdfm.js.map → WebGLSeriesRenderer-CLVnGxIS.js.map} +1 -1
  4. package/dist/{WebGLSeriesRenderer-DjkYvHPQ.cjs → WebGLSeriesRenderer-rB3-CqXS.cjs} +12 -12
  5. package/dist/{WebGLSeriesRenderer-DjkYvHPQ.cjs.map → WebGLSeriesRenderer-rB3-CqXS.cjs.map} +1 -1
  6. package/dist/charts/BaselineRenderer.d.ts.map +1 -1
  7. package/dist/charts/KagiRenderer.d.ts.map +1 -1
  8. package/dist/charts/PointAndFigureRenderer.d.ts.map +1 -1
  9. package/dist/engine/RenderEngine.d.ts +5 -0
  10. package/dist/engine/RenderEngine.d.ts.map +1 -1
  11. package/dist/engine/gpu.d.ts +3 -1
  12. package/dist/engine/gpu.d.ts.map +1 -1
  13. package/dist/engine/gpuContexts.d.ts +23 -0
  14. package/dist/engine/gpuContexts.d.ts.map +1 -0
  15. package/dist/engine/index.d.ts +3 -1
  16. package/dist/engine/index.d.ts.map +1 -1
  17. package/dist/engine/loadWebGL.d.ts +15 -2
  18. package/dist/engine/loadWebGL.d.ts.map +1 -1
  19. package/dist/{gridLines-CBmfrSCE.cjs → gridLines-CVQJ3gzb.cjs} +2 -2
  20. package/dist/gridLines-CVQJ3gzb.cjs.map +1 -0
  21. package/dist/{gridLines-BJLaM2d7.js → gridLines-ovHZBvAe.js} +38 -5
  22. package/dist/gridLines-ovHZBvAe.js.map +1 -0
  23. package/dist/index.cjs +6 -6
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3242 -2484
  26. package/dist/index.js.map +1 -1
  27. package/dist/indicators/index.d.ts +13 -1
  28. package/dist/indicators/index.d.ts.map +1 -1
  29. package/dist/indicators/math.d.ts +2 -0
  30. package/dist/indicators/math.d.ts.map +1 -1
  31. package/dist/indicators/overlay/HammingMA.d.ts +19 -0
  32. package/dist/indicators/overlay/HammingMA.d.ts.map +1 -0
  33. package/dist/indicators/overlay/MAChannel.d.ts +13 -0
  34. package/dist/indicators/overlay/MAChannel.d.ts.map +1 -0
  35. package/dist/indicators/overlay/MACross.d.ts.map +1 -1
  36. package/dist/indicators/overlay/MovingAverageSets.d.ts +20 -0
  37. package/dist/indicators/overlay/MovingAverageSets.d.ts.map +1 -0
  38. package/dist/indicators/overlay/PivotPoints.d.ts +5 -0
  39. package/dist/indicators/overlay/PivotPoints.d.ts.map +1 -1
  40. package/dist/indicators/overlay/PriceAverages.d.ts +25 -0
  41. package/dist/indicators/overlay/PriceAverages.d.ts.map +1 -0
  42. package/dist/indicators/overlay/VolatilityIndex.d.ts +13 -0
  43. package/dist/indicators/overlay/VolatilityIndex.d.ts.map +1 -0
  44. package/dist/indicators/panel/AccumulativeSwingIndex.d.ts +13 -0
  45. package/dist/indicators/panel/AccumulativeSwingIndex.d.ts.map +1 -0
  46. package/dist/indicators/panel/AdvanceDecline.d.ts +18 -0
  47. package/dist/indicators/panel/AdvanceDecline.d.ts.map +1 -0
  48. package/dist/indicators/panel/ChopZone.d.ts +17 -0
  49. package/dist/indicators/panel/ChopZone.d.ts.map +1 -0
  50. package/dist/indicators/panel/MajorityRule.d.ts +15 -0
  51. package/dist/indicators/panel/MajorityRule.d.ts.map +1 -0
  52. package/dist/indicators/panel/PriceOscillator.d.ts +8 -0
  53. package/dist/indicators/panel/PriceOscillator.d.ts.map +1 -0
  54. package/dist/indicators/panel/SMIErgodic.d.ts +12 -0
  55. package/dist/indicators/panel/SMIErgodic.d.ts.map +1 -0
  56. package/dist/indicators/panel/VolatilityEstimators.d.ts +29 -0
  57. package/dist/indicators/panel/VolatilityEstimators.d.ts.map +1 -0
  58. package/dist/indicators/registry.d.ts.map +1 -1
  59. package/dist/indicators/symbols/symbolIndicators.d.ts +27 -0
  60. package/dist/indicators/symbols/symbolIndicators.d.ts.map +1 -1
  61. package/dist/webgl/WebGLSeriesRenderer.d.ts +30 -12
  62. package/dist/webgl/WebGLSeriesRenderer.d.ts.map +1 -1
  63. package/package.json +2 -2
  64. package/dist/gridLines-BJLaM2d7.js.map +0 -1
  65. package/dist/gridLines-CBmfrSCE.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BaselineRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/BaselineRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,sBAAsB;IAC7D,OAAO,CAAC,aAAa,CAAuB;IAE5C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IA4FpG,OAAO,CAAC,eAAe;CASxB"}
1
+ {"version":3,"file":"BaselineRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/BaselineRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,sBAAsB;IAC7D,OAAO,CAAC,aAAa,CAAuB;IAE5C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIhC,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAkGpG,OAAO,CAAC,eAAe;CASxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"KagiRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/KagiRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,qBAAa,YAAa,YAAW,sBAAsB;IACzD,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CAkDrG"}
1
+ {"version":3,"file":"KagiRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/KagiRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,qBAAa,YAAa,YAAW,sBAAsB;IACzD,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CAgDrG"}
@@ -1 +1 @@
1
- {"version":3,"file":"PointAndFigureRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/PointAndFigureRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IACnE,OAAO,CAAC,OAAO,CAAK;IAEpB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CA2DrG"}
1
+ {"version":3,"file":"PointAndFigureRenderer.d.ts","sourceRoot":"","sources":["../../src/charts/PointAndFigureRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IACnE,OAAO,CAAC,OAAO,CAAK;IAEpB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;CAiErG"}
@@ -101,8 +101,12 @@ export declare class RenderEngine {
101
101
  private topLayer;
102
102
  /** The GPU renderer under the scene. */
103
103
  private gpu;
104
+ /** A GPU whose context was lost, kept for when it comes back. */
105
+ private lostGpu;
104
106
  /** Called when the GPU context is lost and the engine has gone back to Canvas 2D. */
105
107
  onGpuLost: (() => void) | null;
108
+ /** Called when the lost context came back and the engine draws with the GPU again. */
109
+ onGpuRestored: (() => void) | null;
106
110
  /**
107
111
  * Optional hook fired AFTER the canvas layers have been resized in
108
112
  * response to a container resize. The Chart class uses this to push the
@@ -116,6 +120,7 @@ export declare class RenderEngine {
116
120
  setRenderContext(ctx: RenderContext): void;
117
121
  /** Draw bars and volume with `gpu`, on its canvas under the scene. */
118
122
  attachGpu(gpu: GpuRenderer): void;
123
+ private placeGpu;
119
124
  /** Back to Canvas 2D for everything. */
120
125
  detachGpu(): void;
121
126
  /** Draw every layer now, synchronously (a screenshot reads the GPU canvas before the browser clears it). */
@@ -1 +1 @@
1
- {"version":3,"file":"RenderEngine.d.ts","sourceRoot":"","sources":["../../src/engine/RenderEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIzF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAwC,WAAW,EAAE,MAAM,UAAU,CAAC;AAGlF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAA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aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI;IAQtC,OAAO,CAAC,MAAM;IAmBd,yEAAyE;IACzE,OAAO,CAAC,WAAW;IAiFnB;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;IA4CjB,uHAAuH;IACvH,OAAO,CAAC,UAAU;IAYlB,gHAAgH;IAChH,OAAO,CAAC,gBAAgB;IAQxB,mEAAmE;IACnE,OAAO,CAAC,gBAAgB;IAQxB,2CAA2C;IAC3C,OAAO,CAAC,MAAM;IASd;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAqBjB,oFAAoF;IACpF,OAAO,CAAC,SAAS;IA6BjB,sGAAsG;IACtG,OAAO,CAAC,YAAY;IA6CpB,0GAA0G;IAC1G,OAAO,CAAC,aAAa;IAWrB,4FAA4F;IAC5F,OAAO,CAAC,gBAAgB;IAUxB,mEAAmE;IACnE,OAAO,CAAC,qBAAqB;IAe7B,0GAA0G;IAC1G,OAAO,CAAC,YAAY;IAkBpB,uDAAuD;IACvD,OAAO,CAAC,eAAe;IA+DvB,yDAAyD;IACzD,OAAO,CAAC,oBAAoB;IAsC5B,+FAA+F;IAC/F,OAAO,CAAC,sBAAsB;IA4D9B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,IAAI,IAAI;CAMhB"}
@@ -89,8 +89,10 @@ export interface GpuRenderer {
89
89
  * draws nothing. Without one, everything past the bars is Canvas 2D.
90
90
  */
91
91
  recorder?(dpr: number, measure: CanvasRenderingContext2D | null): GpuRecorder;
92
- /** Called once if the GPU context is lost (the engine then draws with Canvas 2D). */
92
+ /** Called each time the GPU context is lost (the engine then draws with Canvas 2D). */
93
93
  onLost(callback: () => void): void;
94
+ /** Called each time the context comes back after a loss, ready to draw again. */
95
+ onRestored?(callback: () => void): void;
94
96
  destroy(): void;
95
97
  }
96
98
  //# sourceMappingURL=gpu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gpu.d.ts","s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AG,IAAI,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B;AAED,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,IAAI,GAAG,WAAW,CAAC;IAC9E,uFAAuF;IACvF,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACnC,iFAAiF;IACjF,UAAU,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACxC,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The WebGL contexts the charts on a page hold at once. Chrome and Safari
3
+ * keep about 16 a page and, past that, drop the oldest, whoever's it is (a
4
+ * live chart's, a map's), never to hand it back. The charts stop short of
5
+ * that and leave the rest to the page; a chart asked for WebGL past the limit
6
+ * draws with Canvas 2D until a context is let go. The count is per copy of
7
+ * the library loaded on the page.
8
+ */
9
+ /** How many charts draw with WebGL at once, unless set otherwise. */
10
+ export declare const DEFAULT_MAX_WEBGL_CHARTS = 8;
11
+ /**
12
+ * At most `count` charts on the page draw with WebGL at once (default 8;
13
+ * `Infinity` for no limit). Charts that draw with WebGL already keep it when
14
+ * the limit drops below them; it holds for those asking from then on.
15
+ */
16
+ export declare function setMaxWebGLCharts(count: number): void;
17
+ /** How many more charts may draw with WebGL now. */
18
+ export declare function gpuContextsLeft(): number;
19
+ /** A context of the charts' share, or null when they hold all of it: the function given back lets it go (once). */
20
+ export declare function claimGpuContext(): (() => void) | null;
21
+ /** `callback`, once, the next time a context may be had; the function given back stops waiting. */
22
+ export declare function whenGpuContextFree(callback: () => void): () => void;
23
+ //# sourceMappingURL=gpuContexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpuContexts.d.ts","sourceRoot":"","sources":["../../src/engine/gpuContexts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAM1C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED,oDAAoD;AACpD,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,mHAAmH;AACnH,wBAAgB,eAAe,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAUrD;AAED,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKnE"}
@@ -4,6 +4,8 @@ export { RenderLoop } from './RenderLoop.js';
4
4
  export { DPRManager } from './DPRManager.js';
5
5
  export { RenderEngine } from './RenderEngine.js';
6
6
  export type { RenderContext, PanelRenderInfo } from './RenderEngine.js';
7
- export { loadWebGLRenderer } from './loadWebGL.js';
7
+ export { loadWebGL, loadWebGLRenderer } from './loadWebGL.js';
8
+ export type { WebGLLoad } from './loadWebGL.js';
9
+ export { DEFAULT_MAX_WEBGL_CHARTS, setMaxWebGLCharts, gpuContextsLeft, claimGpuContext, whenGpuContextFree } from './gpuContexts.js';
8
10
  export type { GpuRenderer, GpuFrame, GpuDrawn, GpuBackground, GpuRect, GpuRecorder, GpuRegion, RendererMode } from './gpu.js';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrI,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
@@ -1,9 +1,22 @@
1
1
  import { GpuRenderer } from './gpu.js';
2
+ /** What `loadWebGL` got: a renderer, or why not. */
3
+ export type WebGLLoad = {
4
+ gpu: GpuRenderer;
5
+ reason?: undefined;
6
+ } | {
7
+ gpu: null;
8
+ reason: 'unsupported' | 'limit';
9
+ };
2
10
  /**
3
11
  * The WebGL renderer, loaded on first use so it stays out of the main bundle.
4
- * Null where WebGL 2 can't be had (with 'auto': nor where it only runs in
5
- * software, slower than Canvas 2D). A failure to load (offline, a blocked
12
+ * It holds one of the WebGL contexts the charts on the page may have
13
+ * (`setMaxWebGLCharts`), claimed before anything is loaded so two charts can't
14
+ * both take the last one. None when the charts hold all of them ('limit'), nor
15
+ * where WebGL 2 can't be had, or with 'auto' only runs in software, slower
16
+ * than Canvas 2D ('unsupported'). A failure to load (offline, a blocked
6
17
  * script) is logged as a warning, not thrown: the chart draws on with Canvas 2D.
7
18
  */
19
+ export declare function loadWebGL(mode: 'webgl' | 'auto'): Promise<WebGLLoad>;
20
+ /** The renderer `loadWebGL` gets, or null. */
8
21
  export declare function loadWebGLRenderer(mode: 'webgl' | 'auto'): Promise<GpuRenderer | null>;
9
22
  //# sourceMappingURL=loadWebGL.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadWebGL.d.ts","sourceRoot":"","sources":["../../src/engine/loadWebGL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAS3F"}
1
+ {"version":3,"file":"loadWebGL.d.ts","sourceRoot":"","sources":["../../src/engine/loadWebGL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,oDAAoD;AACpD,MAAM,MAAM,SAAS,GACjB;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GACxC;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAA;CAAE,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAiB1E;AAED,8CAA8C;AAC9C,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAE3F"}
@@ -1,2 +1,2 @@
1
- let e=require(`@tradecanvas/commons`);function t(e,t){return e*(t.barWidth+t.barSpacing)-t.offset+t.chartRect.x+t.barWidth/2}function n(e,t){let{min:n,max:r}=t.priceRange,{y:i,height:a}=t.chartRect,o;if(t.logScale&&n>0&&r>0){let t=Math.log(n),s=Math.log(r)-t;if(s===0)return i+a/2;o=(Math.log(Math.max(e,2**-52))-t)/s}else{let t=r-n;if(t===0)return i+a/2;o=(e-n)/t}return i+a*(t.invertScale?o:1-o)}function r(e){let{min:t,max:n}=e.priceRange,{y:r,height:i}=e.chartRect,a=e.invertScale===!0;if(e.logScale&&t>0&&n>0){let e=Math.log(t),o=Math.log(n)-e;if(o===0)return()=>r+i/2;let s=i/o,c=r+i;return a?t=>r+(Math.log(Math.max(t,2**-52))-e)*s:t=>c-(Math.log(Math.max(t,2**-52))-e)*s}let o=n-t;if(o===0)return()=>r+i/2;let s=i/o;return a?e=>r+(e-t)*s:e=>r+(n-e)*s}function i(e,t,n,r){let{min:i,max:a}=n.priceRange,o=(a-i)/t,s=r(i+e*o),c=r(i+(e+1)*o);return{top:Math.min(s,c),height:Math.abs(s-c),mid:(s+c)/2}}function a(e,t){let n=t.barWidth+t.barSpacing;return Math.round((e-t.chartRect.x-t.barWidth/2+t.offset)/n)}function o(e,t){let{min:n,max:r}=t.priceRange,i=(e-t.chartRect.y)/t.chartRect.height,a=t.invertScale?i:1-i;if(t.logScale&&n>0&&r>0){let e=Math.log(n);return Math.exp(e+(Math.log(r)-e)*a)}return n+(r-n)*a}var s=new WeakMap;function c(e){let t=e.length;if(t<2)return 0;let n=s.get(e);if(n&&n.length===t)return n.step;let r=[];for(let n=Math.max(1,t-20);n<t;n++)r.push(e[n].time-e[n-1].time);r.sort((e,t)=>e-t);let i=Math.max(0,r[r.length>>1]);return s.set(e,{length:t,step:i}),i}function l(e){let t=c(e);return(e.length>0?e[e.length-1].time:0)>0xe8d4a51000?t:t*1e3}function u(e,t){let n=t.length;if(n===0)return e;let r=n-1;if(e>r)return t[r].time+(e-r)*c(t);if(e<0)return t[0].time+e*c(t);let i=Math.floor(e);return i===e||i>=r?t[i].time:t[i].time+(e-i)*(t[i+1].time-t[i].time)}function d(e,t){if(t.length===0)return-1;let n=t[0].time,r=t.length-1,i=t[r].time;if(e<=n||e>=i){if(e===n)return 0;if(e===i)return r;let a=c(t);return a<=0?e<n?0:r:e<n?(e-n)/a:r+(e-i)/a}let a=0,o=t.length-1;for(;a<=o;){let n=a+o>>>1;if(t[n].time===e)return n;t[n].time<e?a=n+1:o=n-1}if(a>=t.length)return t.length-1;if(o<0)return 0;let s=t[o].time,l=t[a].time,u=l===s?0:(e-s)/(l-s);return o+u}function f(e,t){let n=t.data;return n&&n.length>0?d(e,n):e}function p(e,n){return t(f(e,n),n)}function m(e,t){let n=a(e,t),r=t.data;return r&&r.length>0?u(n,r):n}var h=.5037;function g(e){return Math.floor(e+h)}function _(e){let t=typeof e.getTransform==`function`?e.getTransform():void 0;return{a:t&&Number.isFinite(t.a)&&t.a>0?t.a:1,d:t&&Number.isFinite(t.d)&&t.d>0?t.d:1,e:t&&Number.isFinite(t.e)?t.e:0,f:t&&Number.isFinite(t.f)?t.f:0}}function v(e,t){let{a:n,d:r,e:i,f:a}=_(e);e.save(),e.setTransform(1,0,0,1,0,0);try{return t({ratio:n,x:e=>g(e*n+i),y:e=>g(e*r+a),left:(e,t)=>g(e*n+i-t/2)})}finally{e.restore()}}function y(e,t){let n=Math.max(1,Math.floor(t)),r=Math.max(n,Math.round(e*t));return(r-n)%2!=0&&--r,{body:Math.max(r,n),wick:n}}function b(e,t,n,r){let i=Math.max(1,Math.round(t*n)),a=i%2?.5:0;return{at:(g(e*n+r-a)+a-r)/n,width:i/n}}function x(e,t,n){let r=_(e),i=b(t,n,r.d,r.f);return{y:i.at,width:i.width}}function S(e,t,n){let r=_(e),i=b(t,n,r.a,r.e);return{x:i.at,width:i.width}}var C=1;function w(e){return e.barWidth<1}function T(e,t,n,r,i){let a=Math.min(n,e.length-1);if(t>a)return;let o={x:0,open:0,high:0,low:0,close:0,volume:0},s=!1;for(let n=Math.max(0,t);n<=a;n++){let t=e[n],a=Math.floor(r(n));s&&a!==o.x&&(i(o),s=!1),s?(t.high>o.high&&(o.high=t.high),t.low<o.low&&(o.low=t.low),t.volume>o.volume&&(o.volume=t.volume)):(o.x=a,o.open=t.open,o.high=t.high,o.low=t.low,o.volume=t.volume,s=!0),o.close=t.close}s&&i(o)}function E(e,t,n,i,a){let{from:o,to:s}=n.visibleRange,c=n.barWidth+n.barSpacing,l=-n.offset+n.chartRect.x+n.barWidth/2,u=r(n);v(e,n=>{let r=new Path2D,d=new Path2D;T(t,o,s,e=>e*c+l,e=>{let t=n.y(u(e.high)),i=n.y(u(e.low)),a=n.x(e.x),o=Math.max(1,n.x(e.x+1)-a);(e.close>=e.open?r:d).rect(a,Math.min(t,i),o,Math.max(Math.abs(i-t),1))}),e.fillStyle=i,e.fill(r),e.fillStyle=a,e.fill(d)})}var D=80;function O(t){let{chartRect:n,priceRange:i}=t;if(i.max-i.min<=0)return{horizontal:[],vertical:[]};let a=r(t),o=[],s=(0,e.computeTickStep)(i.min,i.max,8),c=Math.ceil(i.min/s)*s;for(let e=c;e<=i.max;e+=s)o.push(Math.round(a(e))+.5);let l=[],u=t.barWidth+t.barSpacing,d=Math.max(1,Math.ceil(D/u)),f=-t.offset+n.x+t.barWidth/2,p=Math.floor(t.offset/u),m=Math.ceil((t.offset+n.width)/u);for(let e=p;e<=m;e++)e%d===0&&l.push(Math.round(e*u+f)+.5);return{horizontal:o,vertical:l}}Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return p}});
2
- //# sourceMappingURL=gridLines-CBmfrSCE.cjs.map
1
+ let e=require(`@tradecanvas/commons`);function t(e,t){return e*(t.barWidth+t.barSpacing)-t.offset+t.chartRect.x+t.barWidth/2}function n(e,t){let{min:n,max:r}=t.priceRange,{y:i,height:a}=t.chartRect,o;if(t.logScale&&n>0&&r>0){let t=Math.log(n),s=Math.log(r)-t;if(s===0)return i+a/2;o=(Math.log(Math.max(e,2**-52))-t)/s}else{let t=r-n;if(t===0)return i+a/2;o=(e-n)/t}return i+a*(t.invertScale?o:1-o)}function r(e){let{min:t,max:n}=e.priceRange,{y:r,height:i}=e.chartRect,a=e.invertScale===!0;if(e.logScale&&t>0&&n>0){let e=Math.log(t),o=Math.log(n)-e;if(o===0)return()=>r+i/2;let s=i/o,c=r+i;return a?t=>r+(Math.log(Math.max(t,2**-52))-e)*s:t=>c-(Math.log(Math.max(t,2**-52))-e)*s}let o=n-t;if(o===0)return()=>r+i/2;let s=i/o;return a?e=>r+(e-t)*s:e=>r+(n-e)*s}function i(e,t,n,r){let{min:i,max:a}=n.priceRange,o=(a-i)/t,s=r(i+e*o),c=r(i+(e+1)*o);return{top:Math.min(s,c),height:Math.abs(s-c),mid:(s+c)/2}}function a(e,t){let n=t.barWidth+t.barSpacing;return Math.round((e-t.chartRect.x-t.barWidth/2+t.offset)/n)}function o(e,t){let{min:n,max:r}=t.priceRange,i=(e-t.chartRect.y)/t.chartRect.height,a=t.invertScale?i:1-i;if(t.logScale&&n>0&&r>0){let e=Math.log(n);return Math.exp(e+(Math.log(r)-e)*a)}return n+(r-n)*a}var s=new WeakMap;function c(e){let t=e.length;if(t<2)return 0;let n=s.get(e);if(n&&n.length===t)return n.step;let r=[];for(let n=Math.max(1,t-20);n<t;n++)r.push(e[n].time-e[n-1].time);r.sort((e,t)=>e-t);let i=Math.max(0,r[r.length>>1]);return s.set(e,{length:t,step:i}),i}function l(e){let t=c(e);return(e.length>0?e[e.length-1].time:0)>0xe8d4a51000?t:t*1e3}function u(e,t){let n=t.length;if(n===0)return e;let r=n-1;if(e>r)return t[r].time+(e-r)*c(t);if(e<0)return t[0].time+e*c(t);let i=Math.floor(e);return i===e||i>=r?t[i].time:t[i].time+(e-i)*(t[i+1].time-t[i].time)}function d(e,t){if(t.length===0)return-1;let n=t[0].time,r=t.length-1,i=t[r].time;if(e<=n||e>=i){if(e===n)return 0;if(e===i)return r;let a=c(t);return a<=0?e<n?0:r:e<n?(e-n)/a:r+(e-i)/a}let a=0,o=t.length-1;for(;a<=o;){let n=a+o>>>1;if(t[n].time===e)return n;t[n].time<e?a=n+1:o=n-1}if(a>=t.length)return t.length-1;if(o<0)return 0;let s=t[o].time,l=t[a].time,u=l===s?0:(e-s)/(l-s);return o+u}function f(e,t){let n=t.data;return n&&n.length>0?d(e,n):e}function p(e,n){return t(f(e,n),n)}function m(e,t){let n=a(e,t),r=t.data;return r&&r.length>0?u(n,r):n}var h=.5037;function g(e){return Math.floor(e+h)}function _(e){let t=typeof e.getTransform==`function`?e.getTransform():void 0;return{a:t&&Number.isFinite(t.a)&&t.a>0?t.a:1,d:t&&Number.isFinite(t.d)&&t.d>0?t.d:1,e:t&&Number.isFinite(t.e)?t.e:0,f:t&&Number.isFinite(t.f)?t.f:0}}function v(e,t){let{a:n,d:r,e:i,f:a}=_(e);e.save(),e.setTransform(1,0,0,1,0,0);try{return t({ratio:n,x:e=>g(e*n+i),y:e=>g(e*r+a),left:(e,t)=>g(e*n+i-t/2)})}finally{e.restore()}}function y(e,t){let n=Math.max(1,Math.floor(t)),r=Math.max(n,Math.round(e*t));return(r-n)%2!=0&&--r,{body:Math.max(r,n),wick:n}}function b(e,t,n,r){let i=Math.max(1,Math.round(t*n)),a=i%2?.5:0;return{at:(g(e*n+r-a)+a-r)/n,width:i/n}}function x(e,t,n){let r=_(e),i=b(t,n,r.d,r.f);return{y:i.at,width:i.width}}function S(e,t,n){let r=_(e),i=b(t,n,r.a,r.e);return{x:i.at,width:i.width}}var C=1;function w(e){return e.barWidth<1}function T(e,t,n,r,i){let a=Math.min(n,e.length-1);if(t>a)return;let o={x:0,open:0,high:0,low:0,close:0,volume:0},s=!1;for(let n=Math.max(0,t);n<=a;n++){let t=e[n],a=Math.floor(r(n));s&&a!==o.x&&(i(o),s=!1),s?(t.high>o.high&&(o.high=t.high),t.low<o.low&&(o.low=t.low),t.volume>o.volume&&(o.volume=t.volume)):(o.x=a,o.open=t.open,o.high=t.high,o.low=t.low,o.volume=t.volume,s=!0),o.close=t.close}s&&i(o)}function E(e,t,n,i,a){let{from:o,to:s}=n.visibleRange,c=n.barWidth+n.barSpacing,l=-n.offset+n.chartRect.x+n.barWidth/2,u=r(n);v(e,n=>{let r=new Path2D,d=new Path2D;T(t,o,s,e=>e*c+l,e=>{let t=n.y(u(e.high)),i=n.y(u(e.low)),a=n.x(e.x),o=Math.max(1,n.x(e.x+1)-a);(e.close>=e.open?r:d).rect(a,Math.min(t,i),o,Math.max(Math.abs(i-t),1))}),e.fillStyle=i,e.fill(r),e.fillStyle=a,e.fill(d)})}var D=8,O=8,k=0,A=new Set;function j(e){O=Number.isNaN(e)?8:Math.max(0,Math.floor(e)),M()>0&&F()}function M(){return Math.max(0,O-k)}function N(){if(k>=O)return null;k++;let e=!1;return()=>{e||(e=!0,k--,F())}}function P(e){return A.add(e),()=>{A.delete(e)}}function F(){let e=[...A];A.clear();for(let t of e)try{t()}catch(e){queueMicrotask(()=>{throw e})}}var I=80;function L(t){let{chartRect:n,priceRange:i}=t;if(i.max-i.min<=0)return{horizontal:[],vertical:[]};let a=r(t),o=[],s=(0,e.computeTickStep)(i.min,i.max,8),c=Math.ceil(i.min/s)*s;for(let e=c;e<=i.max;e+=s)o.push(Math.round(a(e))+.5);let l=[],u=t.barWidth+t.barSpacing,d=Math.max(1,Math.ceil(I/u)),f=-t.offset+n.x+t.barWidth/2,p=Math.floor(t.offset/u),m=Math.ceil((t.offset+n.width)/u);for(let e=p;e<=m;e++)e%d===0&&l.push(Math.round(e*u+f)+.5);return{horizontal:o,vertical:l}}Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return l}});
2
+ //# sourceMappingURL=gridLines-CVQJ3gzb.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gridLines-CVQJ3gzb.cjs","names":[],"sources":["../src/viewport/ScaleMapping.ts","../src/charts/pixelGrid.ts","../src/charts/denseBars.ts","../src/engine/gpuContexts.ts","../src/axis/gridLines.ts"],"sourcesContent":["import type { ViewportState } 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/**\n * `barTimeStep` in milliseconds whatever unit the series uses: bar times\n * below 1e12 are seconds (the same rule as `normalizeBarTime`).\n */\nexport function barTimeStepMs(data: TimedSeries): number {\n const step = barTimeStep(data);\n const last = data.length > 0 ? data[data.length - 1].time : 0;\n return last > 1e12 ? step : step * 1000;\n}\n\n/**\n * Time at bar index `index`, extrapolated by `barTimeStep` past either end of\n * the data — e.g. the future area right of the newest bar.\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 * barTimeStep(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 (by `barTimeStep`) 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 = 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","/**\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","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/** 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): 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 const priceStep = computeTickStep(priceRange.min, priceRange.max, 8);\n const firstPrice = Math.ceil(priceRange.min / priceStep) * priceStep;\n for (let price = firstPrice; price <= priceRange.max; price += priceStep) {\n horizontal.push(Math.round(toY(price)) + 0.5);\n }\n\n const vertical: number[] = [];\n const barUnit = viewport.barWidth + viewport.barSpacing;\n const barsPerGrid = Math.max(1, Math.ceil(MIN_COLUMN_SPACING / barUnit));\n const offsetX = -viewport.offset + chartRect.x + viewport.barWidth / 2;\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"],"mappings":"sCAEA,SAAgB,EAAY,EAAe,EAAiC,CAE1E,OAAO,GADS,EAAS,SAAW,EAAS,YACpB,EAAS,OAAS,EAAS,UAAU,EAAI,EAAS,SAAW,EAGxF,SAAgB,EAAS,EAAe,EAAiC,CACvE,GAAM,CAAE,MAAK,OAAQ,EAAS,WACxB,CAAE,EAAG,EAAK,UAAW,EAAS,UAChC,EACJ,GAAI,EAAS,UAAY,EAAM,GAAK,EAAM,EAAG,CAC3C,IAAM,EAAS,KAAK,IAAI,EAAI,CACtB,EAAW,KAAK,IAAI,EAAI,CAAG,EACjC,GAAI,IAAa,EAAG,OAAO,EAAM,EAAS,EAC1C,GAAS,KAAK,IAAI,KAAK,IAAI,SAAsB,CAAC,CAAG,GAAU,MAC1D,CACL,IAAM,EAAQ,EAAM,EACpB,GAAI,IAAU,EAAG,OAAO,EAAM,EAAS,EACvC,GAAS,EAAQ,GAAO,EAE1B,OAAO,EAAM,GAAU,EAAS,YAAc,EAAQ,EAAI,GAO5D,SAAgB,EAAe,EAAoD,CACjF,GAAM,CAAE,MAAK,OAAQ,EAAS,WACxB,CAAE,EAAG,EAAK,UAAW,EAAS,UAC9B,EAAS,EAAS,cAAgB,GACxC,GAAI,EAAS,UAAY,EAAM,GAAK,EAAM,EAAG,CAC3C,IAAM,EAAS,KAAK,IAAI,EAAI,CACtB,EAAW,KAAK,IAAI,EAAI,CAAG,EACjC,GAAI,IAAa,EAAG,UAAa,EAAM,EAAS,EAChD,IAAM,EAAI,EAAS,EACb,EAAS,EAAM,EACrB,OAAO,EACF,GAAU,GAAO,KAAK,IAAI,KAAK,IAAI,SAAsB,CAAC,CAAG,GAAU,EACvE,GAAU,GAAU,KAAK,IAAI,KA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,EAAuB,EAAE,CACzB,GAAA,EAAA,EAAA,iBAA4B,EAAW,IAAK,EAAW,IAAK,EAAE,CAC9D,EAAa,KAAK,KAAK,EAAW,IAAM,EAAU,CAAG,EAC3D,IAAK,IAAI,EAAQ,EAAY,GAAS,EAAW,IAAK,GAAS,EAC7D,EAAW,KAAK,KAAK,MAAM,EAAI,EAAM,CAAC,CAAG,GAAI,CAG/C,IAAM,EAAqB,EAAE,CACvB,EAAU,EAAS,SAAW,EAAS,WACvC,EAAc,KAAK,IAAI,EAAG,KAAK,KAAK,EAAqB,EAAQ,CAAC,CAClE,EAAU,CAAC,EAAS,OAAS,EAAU,EAAI,EAAS,SAAW,EAG/D,EAAO,KAAK,MAAM,EAAS,OAAS,EAAQ,CAC5C,EAAK,KAAK,MAAM,EAAS,OAAS,EAAU,OAAS,EAAQ,CACnE,IAAK,IAAI,EAAI,EAAM,GAAK,EAAI,IACtB,EAAI,IAAgB,GACxB,EAAS,KAAK,KAAK,MAAM,EAAI,EAAU,EAAQ,CAAG,GAAI,CAExD,MAAO,CAAE,aAAY,WAAU"}
@@ -199,9 +199,42 @@ function E(e, t, n, i, a) {
199
199
  });
200
200
  }
201
201
  //#endregion
202
+ //#region src/engine/gpuContexts.ts
203
+ var D = 8, O = 8, k = 0, A = /* @__PURE__ */ new Set();
204
+ function j(e) {
205
+ O = Number.isNaN(e) ? 8 : Math.max(0, Math.floor(e)), M() > 0 && F();
206
+ }
207
+ function M() {
208
+ return Math.max(0, O - k);
209
+ }
210
+ function N() {
211
+ if (k >= O) return null;
212
+ k++;
213
+ let e = !1;
214
+ return () => {
215
+ e || (e = !0, k--, F());
216
+ };
217
+ }
218
+ function P(e) {
219
+ return A.add(e), () => {
220
+ A.delete(e);
221
+ };
222
+ }
223
+ function F() {
224
+ let e = [...A];
225
+ A.clear();
226
+ for (let t of e) try {
227
+ t();
228
+ } catch (e) {
229
+ queueMicrotask(() => {
230
+ throw e;
231
+ });
232
+ }
233
+ }
234
+ //#endregion
202
235
  //#region src/axis/gridLines.ts
203
- var D = 80;
204
- function O(t) {
236
+ var I = 80;
237
+ function L(t) {
205
238
  let { chartRect: n, priceRange: i } = t;
206
239
  if (i.max - i.min <= 0) return {
207
240
  horizontal: [],
@@ -209,7 +242,7 @@ function O(t) {
209
242
  };
210
243
  let a = r(t), o = [], s = e(i.min, i.max, 8), c = Math.ceil(i.min / s) * s;
211
244
  for (let e = c; e <= i.max; e += s) o.push(Math.round(a(e)) + .5);
212
- let l = [], u = t.barWidth + t.barSpacing, d = Math.max(1, Math.ceil(D / u)), f = -t.offset + n.x + t.barWidth / 2, p = Math.floor(t.offset / u), m = Math.ceil((t.offset + n.width) / u);
245
+ let l = [], u = t.barWidth + t.barSpacing, d = Math.max(1, Math.ceil(I / u)), f = -t.offset + n.x + t.barWidth / 2, p = Math.floor(t.offset / u), m = Math.ceil((t.offset + n.width) / u);
213
246
  for (let e = p; e <= m; e++) e % d === 0 && l.push(Math.round(e * u + f) + .5);
214
247
  return {
215
248
  horizontal: o,
@@ -217,6 +250,6 @@ function O(t) {
217
250
  };
218
251
  }
219
252
  //#endregion
220
- export { o as C, m as S, r as _, E as a, d as b, S as c, u as d, t as f, n as g, i as h, w as i, x as l, l as m, C as n, h as o, c as p, T as r, y as s, O as t, v as u, f as v, a as x, p as y };
253
+ export { f as C, m as D, a as E, o as O, r as S, d as T, t as _, j as a, i as b, T as c, h as d, y as f, u as g, v as h, M as i, w as l, x as m, D as n, P as o, S as p, N as r, C as s, L as t, E as u, c as v, p as w, n as x, l as y };
221
254
 
222
- //# sourceMappingURL=gridLines-BJLaM2d7.js.map
255
+ //# sourceMappingURL=gridLines-ovHZBvAe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gridLines-ovHZBvAe.js","names":[],"sources":["../src/viewport/ScaleMapping.ts","../src/charts/pixelGrid.ts","../src/charts/denseBars.ts","../src/engine/gpuContexts.ts","../src/axis/gridLines.ts"],"sourcesContent":["import type { ViewportState } 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/**\n * `barTimeStep` in milliseconds whatever unit the series uses: bar times\n * below 1e12 are seconds (the same rule as `normalizeBarTime`).\n */\nexport function barTimeStepMs(data: TimedSeries): number {\n const step = barTimeStep(data);\n const last = data.length > 0 ? data[data.length - 1].time : 0;\n return last > 1e12 ? step : step * 1000;\n}\n\n/**\n * Time at bar index `index`, extrapolated by `barTimeStep` past either end of\n * the data — e.g. the future area right of the newest bar.\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 * barTimeStep(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 (by `barTimeStep`) 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 = 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","/**\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","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/** 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): 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 const priceStep = computeTickStep(priceRange.min, priceRange.max, 8);\n const firstPrice = Math.ceil(priceRange.min / priceStep) * priceStep;\n for (let price = firstPrice; price <= priceRange.max; price += priceStep) {\n horizontal.push(Math.round(toY(price)) + 0.5);\n }\n\n const vertical: number[] = [];\n const barUnit = viewport.barWidth + viewport.barSpacing;\n const barsPerGrid = Math.max(1, Math.ceil(MIN_COLUMN_SPACING / barUnit));\n const offsetX = -viewport.offset + chartRect.x + viewport.barWidth / 2;\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"],"mappings":";;AAEA,SAAgB,EAAY,GAAe,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