velo-plot 3.0.0 → 3.1.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 (107) hide show
  1. package/README.md +22 -15
  2. package/dist/ChartCore-AnR_3Xkb.js +7338 -0
  3. package/dist/ChartCore-AnR_3Xkb.js.map +1 -0
  4. package/dist/GpuChartRenderer-Dxc0hrQA.js +75 -0
  5. package/dist/GpuChartRenderer-Dxc0hrQA.js.map +1 -0
  6. package/dist/{index.core-BmZe2jRQ.js → PluginRegistry-CzMHebYP.js} +19 -33
  7. package/dist/PluginRegistry-CzMHebYP.js.map +1 -0
  8. package/dist/angular-hooks.js +1 -1
  9. package/dist/angular.js +8 -8
  10. package/dist/{axisFormat-CzumxpCL.js → axisFormat-Sz4WIJfQ.js} +2 -2
  11. package/dist/{axisFormat-CzumxpCL.js.map → axisFormat-Sz4WIJfQ.js.map} +1 -1
  12. package/dist/{chartSyncBridge-DbWrwtyP.js → chartSyncBridge-D_rCtbFq.js} +12 -11
  13. package/dist/{chartSyncBridge-DbWrwtyP.js.map → chartSyncBridge-D_rCtbFq.js.map} +1 -1
  14. package/dist/core/ChartStatistics.d.ts +1 -1
  15. package/dist/core/chart/ChartCore.d.ts +12 -17
  16. package/dist/core/chart/ChartFeatureHooks.d.ts +7 -0
  17. package/dist/core/chart/chartExportPatch.d.ts +2 -0
  18. package/dist/core/chart/overlaySeriesRegistry.d.ts +7 -0
  19. package/dist/core/chart/series/SeriesActions.d.ts +1 -0
  20. package/dist/core/chart/series/SeriesBufferLite.d.ts +13 -0
  21. package/dist/core/chart/series/seriesOptionsRegistry.d.ts +8 -0
  22. package/dist/core/chart/series/seriesTypeRegistry.d.ts +5 -0
  23. package/dist/createStackedChart-DqcLCFGS.js +1338 -0
  24. package/dist/createStackedChart-DqcLCFGS.js.map +1 -0
  25. package/dist/{hooks-CYPCxoZx.js → hooks-DH-3bewj.js} +7 -7
  26. package/dist/{hooks-CYPCxoZx.js.map → hooks-DH-3bewj.js.map} +1 -1
  27. package/dist/{index-qunX30Xu.js → index-B7PTX94B.js} +2133 -2133
  28. package/dist/index-B7PTX94B.js.map +1 -0
  29. package/dist/{index-BMiZoKmm.js → index-BgrvqltV.js} +67 -67
  30. package/dist/index-BgrvqltV.js.map +1 -0
  31. package/dist/index-Cv6ZDLWf.js +521 -0
  32. package/dist/index-Cv6ZDLWf.js.map +1 -0
  33. package/dist/index-qhscKTDy.js.map +1 -1
  34. package/dist/index.core.d.ts +8 -6
  35. package/dist/index.d.ts +1 -14
  36. package/dist/plugins/3d.js +3 -1
  37. package/dist/plugins/3d.js.map +1 -1
  38. package/dist/plugins/analysis.js.map +1 -1
  39. package/dist/plugins/createPlugin.d.ts +8 -0
  40. package/dist/plugins/debug.js +32 -32
  41. package/dist/plugins/debug.js.map +1 -1
  42. package/dist/plugins/gpu.js +2033 -209
  43. package/dist/plugins/gpu.js.map +1 -1
  44. package/dist/plugins/i18n.js +286 -23
  45. package/dist/plugins/i18n.js.map +1 -1
  46. package/dist/plugins/latex.js +766 -207
  47. package/dist/plugins/latex.js.map +1 -1
  48. package/dist/plugins/loading/index.d.ts +1 -2
  49. package/dist/plugins/loading.js +3 -4
  50. package/dist/plugins/offscreen.js +11 -10
  51. package/dist/plugins/offscreen.js.map +1 -1
  52. package/dist/plugins/regression.js +254 -256
  53. package/dist/plugins/regression.js.map +1 -1
  54. package/dist/plugins/streaming.js +1 -1
  55. package/dist/plugins/tools.js +1 -1
  56. package/dist/react.js +55 -58
  57. package/dist/react.js.map +1 -1
  58. package/dist/renderer/NativeWebGLRenderer.d.ts +2 -1
  59. package/dist/renderer/native/NativeWebGLRenderer.d.ts +5 -1
  60. package/dist/renderer/native/draw.d.ts +2 -47
  61. package/dist/renderer/native/drawCore.d.ts +27 -0
  62. package/dist/renderer/native/drawExtended.d.ts +29 -0
  63. package/dist/renderer/native/frameRenderExtended.d.ts +1 -0
  64. package/dist/renderer/native/frameRenderRegistry.d.ts +27 -0
  65. package/dist/renderer/native/programFactoryCore.d.ts +6 -0
  66. package/dist/renderer/native/programFactoryExtended.d.ts +4 -0
  67. package/dist/renderer/native/utils.d.ts +3 -29
  68. package/dist/renderer/native/utilsCore.d.ts +14 -0
  69. package/dist/renderer/native/utilsExtended.d.ts +17 -0
  70. package/dist/renderer/overlaySeriesExtended.d.ts +1 -0
  71. package/dist/renderer/registerExtendedSeries.d.ts +1 -0
  72. package/dist/renderer/registerWebGPU.d.ts +2 -0
  73. package/dist/renderer/seriesBufferExtended.d.ts +4 -0
  74. package/dist/scientific/index.d.ts +1 -5
  75. package/dist/scientific/registerScientific.d.ts +1 -0
  76. package/dist/scientific.js +41 -41
  77. package/dist/solid.js +56 -59
  78. package/dist/solid.js.map +1 -1
  79. package/dist/svelte.js +26 -29
  80. package/dist/svelte.js.map +1 -1
  81. package/dist/trading/index.d.ts +1 -4
  82. package/dist/trading/registerTrading.d.ts +3 -0
  83. package/dist/trading.js +42 -42
  84. package/dist/types.d.ts +3 -3
  85. package/dist/velo-plot.full.js +2212 -1351
  86. package/dist/velo-plot.full.js.map +1 -1
  87. package/dist/velo-plot.js +33 -28
  88. package/dist/velo-plot.js.map +1 -1
  89. package/dist/vue/index.d.ts +2 -2
  90. package/dist/vue.js +17 -20
  91. package/dist/vue.js.map +1 -1
  92. package/package.json +9 -1
  93. package/dist/ChartCore-BpzRvN4Y.js +0 -8467
  94. package/dist/ChartCore-BpzRvN4Y.js.map +0 -1
  95. package/dist/createStackedChart-Dm-YqUT7.js +0 -756
  96. package/dist/createStackedChart-Dm-YqUT7.js.map +0 -1
  97. package/dist/gpuRenderer-BpaMYz-k.js +0 -1848
  98. package/dist/gpuRenderer-BpaMYz-k.js.map +0 -1
  99. package/dist/index-BMiZoKmm.js.map +0 -1
  100. package/dist/index-qunX30Xu.js.map +0 -1
  101. package/dist/index-x4stH3jD.js +0 -282
  102. package/dist/index-x4stH3jD.js.map +0 -1
  103. package/dist/index.core-BmZe2jRQ.js.map +0 -1
  104. package/dist/mockDatafeed-DHIDPcpX.js +0 -515
  105. package/dist/mockDatafeed-DHIDPcpX.js.map +0 -1
  106. package/dist/symbols-DT0eLlpW.js +0 -568
  107. package/dist/symbols-DT0eLlpW.js.map +0 -1
package/dist/solid.js CHANGED
@@ -1,47 +1,44 @@
1
- import { template as E, use as b, effect as P, setStyleProperty as g } from "solid-js/web";
1
+ import { template as I, use as b, effect as P, setStyleProperty as g } from "solid-js/web";
2
2
  import { createSignal as f, onCleanup as C, createEffect as y } from "solid-js";
3
- import { c as I, a as B, i as $, r as A, b as K } from "./chartSyncBridge-DbWrwtyP.js";
4
- import { p as w, o as V, s as L, d as M } from "./optionsSync-QUiN4Inw.js";
5
- import { c as z } from "./createStackedChart-Dm-YqUT7.js";
6
- import "./ChartCore-BpzRvN4Y.js";
7
- import "./index-x4stH3jD.js";
8
- import "./symbols-DT0eLlpW.js";
3
+ import { p as w, o as B, s as $, d as A } from "./optionsSync-QUiN4Inw.js";
4
+ import { c as K, a as V, i as p, r as L, b as M } from "./chartSyncBridge-D_rCtbFq.js";
5
+ import { c as z } from "./createStackedChart-DqcLCFGS.js";
9
6
  import { s as R, a as G, b as x } from "./stackedSync-tnrunZMt.js";
10
7
  function k(e = () => ({})) {
11
8
  const [t, l] = f(null), [n, a] = f(!1), [o, u] = f(null), [d, h] = f(null);
12
- let m, r = null, s = w(e());
9
+ let S, s = null, r = w(e());
13
10
  const v = (i) => {
14
- m = i, r == null || r();
15
- const c = I(i, e(), {
11
+ S = i, s == null || s();
12
+ const c = K(i, e(), {
16
13
  onBoundsChange: h,
17
14
  onError: u
18
15
  });
19
- l(c.chart), r = c.destroy, h(c.getBounds()), a(!0), s = w(e());
16
+ l(c.chart), s = c.destroy, h(c.getBounds()), a(!0), r = w(e());
20
17
  };
21
18
  return C(() => {
22
- r == null || r(), l(null), a(!1);
19
+ s == null || s(), l(null), a(!1);
23
20
  }), y(() => {
24
21
  const i = t(), c = e();
25
22
  if (!i) return;
26
- const S = w(c);
27
- V(s, S) && (L(i, s, S), s = S);
23
+ const m = w(c);
24
+ B(r, m) && ($(i, r, m), r = m);
28
25
  }), {
29
26
  setContainerRef: (i) => {
30
- i && i !== m && v(i);
27
+ i && i !== S && v(i);
31
28
  },
32
29
  chart: t,
33
30
  isReady: n,
34
31
  error: o,
35
32
  bounds: d,
36
33
  addSeries: (i) => {
37
- var S;
38
- (S = t()) == null || S.addSeries(i);
34
+ var m;
35
+ (m = t()) == null || m.addSeries(i);
39
36
  const c = t();
40
37
  c && h(c.getViewBounds());
41
38
  },
42
39
  updateSeries: (i, c) => {
43
- var S;
44
- return (S = t()) == null ? void 0 : S.updateSeries(i, c);
40
+ var m;
41
+ return (m = t()) == null ? void 0 : m.updateSeries(i, c);
45
42
  },
46
43
  removeSeries: (i) => {
47
44
  var c;
@@ -62,51 +59,51 @@ function k(e = () => ({})) {
62
59
  function N(e) {
63
60
  const [t, l] = f(null), [n, a] = f(!1);
64
61
  let o = null, u = "", d = /* @__PURE__ */ new Map();
65
- const h = (r) => {
62
+ const h = (s) => {
66
63
  o == null || o();
67
- const s = e(), v = z({ ...s, container: r });
68
- l(v), o = () => v.destroy(), u = R(s.panes), d = x(v, s.panes, /* @__PURE__ */ new Map()), v.whenReady().then(() => a(!0));
69
- }, m = (r) => {
70
- r && h(r);
64
+ const r = e(), v = z({ ...r, container: s });
65
+ l(v), o = () => v.destroy(), u = R(r.panes), d = x(v, r.panes, /* @__PURE__ */ new Map()), v.whenReady().then(() => a(!0));
66
+ }, S = (s) => {
67
+ s && h(s);
71
68
  };
72
69
  return C(() => {
73
70
  o == null || o(), l(null), a(!1);
74
71
  }), {
75
- setContainerRef: m,
72
+ setContainerRef: S,
76
73
  stack: t,
77
74
  isReady: n,
78
- fitAll: (r) => {
79
- var s;
80
- return (s = t()) == null ? void 0 : s.fitAll(r);
75
+ fitAll: (s) => {
76
+ var r;
77
+ return (r = t()) == null ? void 0 : r.fitAll(s);
81
78
  },
82
79
  resetAll: () => {
83
- var r;
84
- return (r = t()) == null ? void 0 : r.resetAll();
80
+ var s;
81
+ return (s = t()) == null ? void 0 : s.resetAll();
85
82
  },
86
83
  sync: () => {
87
- const r = t(), s = e();
88
- if (!r || !n()) return;
89
- if (R(s.panes) !== u) {
90
- h(r.container);
84
+ const s = t(), r = e();
85
+ if (!s || !n()) return;
86
+ if (R(r.panes) !== u) {
87
+ h(s.container);
91
88
  return;
92
89
  }
93
- G(r, s), d = x(r, s.panes, d);
90
+ G(s, r), d = x(s, r.panes, d);
94
91
  }
95
92
  };
96
93
  }
97
- var p = /* @__PURE__ */ E("<div role=img style=position:relative>");
94
+ var E = /* @__PURE__ */ I("<div role=img style=position:relative>");
98
95
  function O(e) {
99
96
  const t = k(() => e);
100
97
  let l = /* @__PURE__ */ new Map();
101
98
  return y(() => {
102
- !t.isReady() || !t.chart() || (l = M({
99
+ !t.isReady() || !t.chart() || (l = A({
103
100
  addSeries: t.addSeries,
104
101
  updateSeries: t.updateSeries,
105
102
  removeSeries: t.removeSeries,
106
103
  autoScale: () => t.chart().autoScale()
107
104
  }, e.series ?? [], l));
108
105
  }), (() => {
109
- var n = p();
106
+ var n = E();
110
107
  return b((a) => t.setContainerRef(a), n), P((a) => {
111
108
  var o = `velo-plot-container${e.class ? ` ${e.class}` : ""}`, u = typeof e.width == "number" ? `${e.width}px` : e.width ?? "100%", d = typeof e.height == "number" ? `${e.height}px` : e.height ?? "400px";
112
109
  return o !== a.e && (n.className = a.e = o), u !== a.t && g(n, "width", a.t = u), d !== a.a && g(n, "height", a.a = d), a;
@@ -117,10 +114,10 @@ function O(e) {
117
114
  }), n;
118
115
  })();
119
116
  }
120
- function W(e) {
117
+ function J(e) {
121
118
  const t = N(() => e);
122
119
  return y(() => t.sync()), (() => {
123
- var l = p();
120
+ var l = E();
124
121
  return b((n) => t.setContainerRef(n), l), P((n) => {
125
122
  var a = `velo-plot-stacked${e.class ? ` ${e.class}` : ""}`, o = typeof e.width == "number" ? `${e.width}px` : e.width ?? "100%", u = typeof e.height == "number" ? `${e.height}px` : e.height ?? "480px";
126
123
  return a !== n.e && (l.className = n.e = a), o !== n.t && g(l, "width", n.t = o), u !== n.a && g(l, "height", n.a = u), n;
@@ -131,20 +128,20 @@ function W(e) {
131
128
  }), l;
132
129
  })();
133
130
  }
134
- function X(e, t, l = {}) {
131
+ function Q(e, t, l = {}) {
135
132
  const [n, a] = f(null), [o, u] = f(!1), [d, h] = f(null);
136
133
  return y(() => {
137
- const m = e();
138
- if (!m) return;
139
- let r = !1;
140
- u(!0), B(m, t, l).then((s) => {
141
- r || (a(s), u(!1));
142
- }).catch((s) => {
143
- r || (h(s instanceof Error ? s : new Error(String(s))), u(!1));
134
+ const S = e();
135
+ if (!S) return;
136
+ let s = !1;
137
+ u(!0), V(S, t, l).then((r) => {
138
+ s || (a(r), u(!1));
139
+ }).catch((r) => {
140
+ s || (h(r instanceof Error ? r : new Error(String(r))), u(!1));
144
141
  }), C(() => {
145
- r = !0;
146
- const s = n();
147
- s && !$(m) && A(m, s.id);
142
+ s = !0;
143
+ const r = n();
144
+ r && !p(S) && L(S, r.id);
148
145
  });
149
146
  }), { result: n, isLoading: o, error: d };
150
147
  }
@@ -153,19 +150,19 @@ function Z(e, t) {
153
150
  return y(() => {
154
151
  const a = e();
155
152
  let o = null;
156
- a.length >= 2 ? (o = K(a, t), n(o.group)) : n(null), C(() => o == null ? void 0 : o.destroy());
153
+ a.length >= 2 ? (o = M(a, t), n(o.group)) : n(null), C(() => o == null ? void 0 : o.destroy());
157
154
  }), { group: l };
158
155
  }
159
- const Y = Z, _ = O, ee = k, te = k;
156
+ const U = Z, W = O, X = k, Y = k;
160
157
  export {
161
- _ as SciPlot,
162
- W as StackedPlot,
158
+ W as SciPlot,
159
+ J as StackedPlot,
163
160
  O as VeloPlot,
164
- Y as useChartGroup,
161
+ U as useChartGroup,
165
162
  Z as useChartSync,
166
- X as useIndicator,
167
- te as useSciChart,
168
- ee as useSciPlot,
163
+ Q as useIndicator,
164
+ Y as useSciChart,
165
+ X as useSciPlot,
169
166
  N as useStackedPlot,
170
167
  k as useVeloPlot
171
168
  };
package/dist/solid.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"solid.js","sources":["../src/solid/useVeloPlot.ts","../src/solid/useStackedPlot.ts","../src/solid/VeloPlot.tsx","../src/solid/useIndicator.ts","../src/solid/useChartSync.ts","../src/solid/index.ts"],"sourcesContent":["import { createSignal, onCleanup, createEffect } from \"solid-js\";\nimport type { Chart } from \"../core/Chart\";\nimport type { SeriesOptions, SeriesUpdateData, ZoomOptions, Bounds } from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport function useVeloPlot(options: () => UseVeloPlotOptions = () => ({})) {\n const [chart, setChart] = createSignal<Chart | null>(null);\n const [isReady, setIsReady] = createSignal(false);\n const [error, setError] = createSignal<Error | null>(null);\n const [bounds, setBounds] = createSignal<Bounds | null>(null);\n let container: HTMLDivElement | undefined;\n let destroy: (() => void) | null = null;\n let prevSync = pickSyncableOptions(options());\n\n const mount = (el: HTMLDivElement) => {\n container = el;\n destroy?.();\n const handle = createChartLifecycle(el, options(), {\n onBoundsChange: setBounds,\n onError: setError,\n });\n setChart(handle.chart);\n destroy = handle.destroy;\n setBounds(handle.getBounds());\n setIsReady(true);\n prevSync = pickSyncableOptions(options());\n };\n\n onCleanup(() => {\n destroy?.();\n setChart(null);\n setIsReady(false);\n });\n\n createEffect(() => {\n const c = chart();\n const opts = options();\n if (!c) return;\n const next = pickSyncableOptions(opts);\n if (optionsChanged(prevSync, next)) {\n syncChartOptions(c, prevSync, next);\n prevSync = next;\n }\n });\n\n return {\n setContainerRef: (el: HTMLDivElement | null | undefined) => {\n if (el && el !== container) mount(el);\n },\n chart,\n isReady,\n error,\n bounds,\n addSeries: (opts: SeriesOptions) => {\n chart()?.addSeries(opts);\n const c = chart();\n if (c) setBounds(c.getViewBounds());\n },\n updateSeries: (id: string, data: SeriesUpdateData) => chart()?.updateSeries(id, data),\n removeSeries: (id: string) => chart()?.removeSeries(id),\n zoom: (z: ZoomOptions) => chart()?.zoom(z),\n resetZoom: () => {\n chart()?.resetZoom();\n const c = chart();\n if (c) setBounds(c.getViewBounds());\n },\n };\n}\n","import { createSignal, onCleanup } from \"solid-js\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport { stackedStructureKey, syncStackedOptions, syncStackedPaneSeries } from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport function useStackedPlot(getOptions: () => Omit<StackedChartOptions, \"container\">) {\n const [stack, setStack] = createSignal<StackedChart | null>(null);\n const [isReady, setIsReady] = createSignal(false);\n let destroy: (() => void) | null = null;\n let structureKey = \"\";\n let paneSeries = new Map<string, Map<string, VeloPlotSeries>>();\n\n const mount = (el: HTMLDivElement) => {\n destroy?.();\n const opts = getOptions();\n const created = createStackedChart({ ...opts, container: el });\n setStack(created);\n destroy = () => created.destroy();\n structureKey = stackedStructureKey(opts.panes);\n paneSeries = syncStackedPaneSeries(created, opts.panes, new Map());\n created.whenReady().then(() => setIsReady(true));\n };\n\n const setContainerRef = (el: HTMLDivElement | null | undefined) => {\n if (el) mount(el);\n };\n\n onCleanup(() => {\n destroy?.();\n setStack(null);\n setIsReady(false);\n });\n\n return {\n setContainerRef,\n stack,\n isReady,\n fitAll: (opts?: { x?: Range; padding?: number }) => stack()?.fitAll(opts),\n resetAll: () => stack()?.resetAll(),\n sync: () => {\n const s = stack();\n const opts = getOptions();\n if (!s || !isReady()) return;\n const nextKey = stackedStructureKey(opts.panes);\n if (nextKey !== structureKey) {\n mount(s.container);\n return;\n }\n syncStackedOptions(s, opts);\n paneSeries = syncStackedPaneSeries(s, opts.panes, paneSeries);\n },\n };\n}\n","import { createEffect } from \"solid-js\";\nimport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nimport { useStackedPlot } from \"./useStackedPlot\";\nimport { diffSeries, type VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface VeloPlotProps extends UseVeloPlotOptions {\n series?: VeloPlotSeries[];\n width?: number | string;\n height?: number | string;\n class?: string;\n}\n\nexport function VeloPlot(props: VeloPlotProps) {\n const api = useVeloPlot(() => props);\n let previous = new Map<string, VeloPlotSeries>();\n\n createEffect(() => {\n if (!api.isReady() || !api.chart()) return;\n previous = diffSeries(\n {\n addSeries: api.addSeries,\n updateSeries: api.updateSeries,\n removeSeries: api.removeSeries,\n autoScale: () => api.chart()!.autoScale(),\n },\n props.series ?? [],\n previous,\n );\n });\n\n return (\n <div\n ref={(el) => api.setContainerRef(el)}\n className={`velo-plot-container${props.class ? ` ${props.class}` : \"\"}`}\n role=\"img\"\n style={{\n position: \"relative\",\n width: typeof props.width === \"number\" ? `${props.width}px` : props.width ?? \"100%\",\n height: typeof props.height === \"number\" ? `${props.height}px` : props.height ?? \"400px\",\n }}\n />\n );\n}\n\nexport function StackedPlot(\n props: {\n panes: import(\"../core/stacked\").StackedPaneConfig[];\n width?: number | string;\n height?: number | string;\n class?: string;\n } & Omit<import(\"../core/stacked\").StackedChartOptions, \"container\" | \"panes\">,\n) {\n const api = useStackedPlot(() => props);\n createEffect(() => api.sync());\n\n return (\n <div\n ref={(el) => api.setContainerRef(el)}\n className={`velo-plot-stacked${props.class ? ` ${props.class}` : \"\"}`}\n role=\"img\"\n style={{\n position: \"relative\",\n width: typeof props.width === \"number\" ? `${props.width}px` : props.width ?? \"100%\",\n height: typeof props.height === \"number\" ? `${props.height}px` : props.height ?? \"480px\",\n }}\n />\n );\n}\n","import { createSignal, createEffect, onCleanup } from \"solid-js\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { addIndicatorToHost, isStackedChart, removeIndicatorFromChart, type IndicatorHost } from \"../bindings/shared\";\nimport type { Chart } from \"../core/chart/types\";\n\nexport function useIndicator(\n host: () => IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n) {\n const [result, setResult] = createSignal<(AddIndicatorResult & { paneId?: string }) | null>(null);\n const [isLoading, setIsLoading] = createSignal(false);\n const [error, setError] = createSignal<Error | null>(null);\n\n createEffect(() => {\n const h = host();\n if (!h) return;\n let cancelled = false;\n setIsLoading(true);\n addIndicatorToHost(h, preset, options)\n .then((res) => {\n if (!cancelled) {\n setResult(res);\n setIsLoading(false);\n }\n })\n .catch((e) => {\n if (!cancelled) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setIsLoading(false);\n }\n });\n onCleanup(() => {\n cancelled = true;\n const res = result();\n if (res && !isStackedChart(h)) removeIndicatorFromChart(h as Chart, res.id);\n });\n });\n\n return { result, isLoading, error };\n}\n","import { createSignal, createEffect, onCleanup } from \"solid-js\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport function useChartSync(charts: () => ChartLike[], options?: SyncOptions) {\n const [group, setGroup] = createSignal<ChartGroup | null>(null);\n\n createEffect(() => {\n const list = charts();\n let handle: ReturnType<typeof createChartSync> | null = null;\n if (list.length >= 2) {\n handle = createChartSync(list, options);\n setGroup(handle.group);\n } else {\n setGroup(null);\n }\n onCleanup(() => handle?.destroy());\n });\n\n return { group };\n}\n\nexport const useChartGroup = useChartSync;\n","export { VeloPlot, StackedPlot } from \"./VeloPlot\";\nexport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nexport { useStackedPlot } from \"./useStackedPlot\";\nexport { useIndicator } from \"./useIndicator\";\nexport { useChartSync, useChartGroup } from \"./useChartSync\";\n\nimport { VeloPlot as VeloPlotImpl } from \"./VeloPlot\";\nimport { useVeloPlot as useVeloPlotImpl } from \"./useVeloPlot\";\n\n/** @deprecated Use `VeloPlot` instead. **Removed in v4.0.** */\nexport const SciPlot = VeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciPlot = useVeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciChart = useVeloPlotImpl;\n"],"names":["useVeloPlot","options","chart","setChart","createSignal","isReady","setIsReady","error","setError","bounds","setBounds","container","destroy","prevSync","pickSyncableOptions","mount","el","handle","createChartLifecycle","onCleanup","createEffect","c","opts","next","optionsChanged","syncChartOptions","_a","id","data","z","useStackedPlot","getOptions","stack","setStack","structureKey","paneSeries","created","createStackedChart","stackedStructureKey","syncStackedPaneSeries","setContainerRef","s","syncStackedOptions","VeloPlot","props","api","previous","Map","diffSeries","addSeries","updateSeries","removeSeries","autoScale","series","_el$","_tmpl$","_$use","_$effect","_p$","_v$","class","_v$2","width","_v$3","height","e","className","t","_$setStyleProperty","a","undefined","StackedPlot","sync","_el$2","_v$4","_v$5","_v$6","useIndicator","host","preset","result","setResult","isLoading","setIsLoading","h","cancelled","addIndicatorToHost","res","isStackedChart","removeIndicatorFromChart","useChartSync","charts","group","setGroup","list","createChartSync","useChartGroup","SciPlot","VeloPlotImpl","useSciPlot","useVeloPlotImpl","useSciChart"],"mappings":";;;;;;;;;AAaO,SAASA,EAAYC,IAAoC,OAAO,CAAA,IAAK;AAC1E,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAA2B,IAAI,GACnD,CAACC,GAASC,CAAU,IAAIF,EAAa,EAAK,GAC1C,CAACG,GAAOC,CAAQ,IAAIJ,EAA2B,IAAI,GACnD,CAACK,GAAQC,CAAS,IAAIN,EAA4B,IAAI;AAC5D,MAAIO,GACAC,IAA+B,MAC/BC,IAAWC,EAAoBb,GAAS;AAE5C,QAAMc,IAAQ,CAACC,MAAuB;AACpC,IAAAL,IAAYK,GACZJ,KAAA,QAAAA;AACA,UAAMK,IAASC,EAAqBF,GAAIf,EAAA,GAAW;AAAA,MACjD,gBAAgBS;AA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AACR,QAAIC,IAAY;AAChB,IAAAF,EAAa,EAAI,GACjBG,EAAmBF,GAAGL,GAAQ9E,CAAO,EAClC,KAAK,CAACsF,MAAQ;AACb,MAAKF,MACHJ,EAAUM,CAAG,GACbJ,EAAa,EAAK;AAAA,IAEtB,CAAC,EACA,MAAM,CAAClB,MAAM;AACZ,MAAKoB,MACH7E,EAASyD,aAAa,QAAQA,IAAI,IAAI,MAAM,OAAOA,CAAC,CAAC,CAAC,GACtDkB,EAAa,EAAK;AAAA,IAEtB,CAAC,GACHhE,EAAU,MAAM;AACd,MAAAkE,IAAY;AACZ,YAAME,IAAMP,EAAA;AACZ,MAAIO,KAAO,CAACC,EAAeJ,CAAC,KAAGK,EAAyBL,GAAYG,EAAI,EAAE;AAAA,IAC5E,CAAC;AAAA,EACH,CAAC,GAEM,EAAE,QAAAP,GAAQ,WAAAE,GAAW,OAAA3E,EAAA;AAC9B;ACpCO,SAASmF,EAAaC,GAA2B1F,GAAuB;AAC7E,QAAM,CAAC2F,GAAOC,CAAQ,IAAIzF,EAAgC,IAAI;AAE9D,SAAAgB,EAAa,MAAM;AACjB,UAAM0E,IAAOH,EAAA;AACb,QAAI1E,IAAoD;AACxD,IAAI6E,EAAK,UAAU,KACjB7E,IAAS8E,EAAgBD,GAAM7F,CAAO,GACtC4F,EAAS5E,EAAO,KAAK,KAErB4E,EAAS,IAAI,GAEf1E,EAAU,MAAMF,KAAA,gBAAAA,EAAQ,SAAS;AAAA,EACnC,CAAC,GAEM,EAAE,OAAA2E,EAAA;AACX;AAEO,MAAMI,IAAgBN,GCbhBO,IAAUC,GAEVC,KAAaC,GAEbC,KAAcD;"}
1
+ {"version":3,"file":"solid.js","sources":["../src/solid/useVeloPlot.ts","../src/solid/useStackedPlot.ts","../src/solid/VeloPlot.tsx","../src/solid/useIndicator.ts","../src/solid/useChartSync.ts","../src/solid/index.ts"],"sourcesContent":["import { createSignal, onCleanup, createEffect } from \"solid-js\";\nimport type { Chart } from \"../core/Chart\";\nimport type { SeriesOptions, SeriesUpdateData, ZoomOptions, Bounds } from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport function useVeloPlot(options: () => UseVeloPlotOptions = () => ({})) {\n const [chart, setChart] = createSignal<Chart | null>(null);\n const [isReady, setIsReady] = createSignal(false);\n const [error, setError] = createSignal<Error | null>(null);\n const [bounds, setBounds] = createSignal<Bounds | null>(null);\n let container: HTMLDivElement | undefined;\n let destroy: (() => void) | null = null;\n let prevSync = pickSyncableOptions(options());\n\n const mount = (el: HTMLDivElement) => {\n container = el;\n destroy?.();\n const handle = createChartLifecycle(el, options(), {\n onBoundsChange: setBounds,\n onError: setError,\n });\n setChart(handle.chart);\n destroy = handle.destroy;\n setBounds(handle.getBounds());\n setIsReady(true);\n prevSync = pickSyncableOptions(options());\n };\n\n onCleanup(() => {\n destroy?.();\n setChart(null);\n setIsReady(false);\n });\n\n createEffect(() => {\n const c = chart();\n const opts = options();\n if (!c) return;\n const next = pickSyncableOptions(opts);\n if (optionsChanged(prevSync, next)) {\n syncChartOptions(c, prevSync, next);\n prevSync = next;\n }\n });\n\n return {\n setContainerRef: (el: HTMLDivElement | null | undefined) => {\n if (el && el !== container) mount(el);\n },\n chart,\n isReady,\n error,\n bounds,\n addSeries: (opts: SeriesOptions) => {\n chart()?.addSeries(opts);\n const c = chart();\n if (c) setBounds(c.getViewBounds());\n },\n updateSeries: (id: string, data: SeriesUpdateData) => chart()?.updateSeries(id, data),\n removeSeries: (id: string) => chart()?.removeSeries(id),\n zoom: (z: ZoomOptions) => chart()?.zoom(z),\n resetZoom: () => {\n chart()?.resetZoom();\n const c = chart();\n if (c) setBounds(c.getViewBounds());\n },\n };\n}\n","import { createSignal, onCleanup } from \"solid-js\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport { stackedStructureKey, syncStackedOptions, syncStackedPaneSeries } from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport function useStackedPlot(getOptions: () => Omit<StackedChartOptions, \"container\">) {\n const [stack, setStack] = createSignal<StackedChart | null>(null);\n const [isReady, setIsReady] = createSignal(false);\n let destroy: (() => void) | null = null;\n let structureKey = \"\";\n let paneSeries = new Map<string, Map<string, VeloPlotSeries>>();\n\n const mount = (el: HTMLDivElement) => {\n destroy?.();\n const opts = getOptions();\n const created = createStackedChart({ ...opts, container: el });\n setStack(created);\n destroy = () => created.destroy();\n structureKey = stackedStructureKey(opts.panes);\n paneSeries = syncStackedPaneSeries(created, opts.panes, new Map());\n created.whenReady().then(() => setIsReady(true));\n };\n\n const setContainerRef = (el: HTMLDivElement | null | undefined) => {\n if (el) mount(el);\n };\n\n onCleanup(() => {\n destroy?.();\n setStack(null);\n setIsReady(false);\n });\n\n return {\n setContainerRef,\n stack,\n isReady,\n fitAll: (opts?: { x?: Range; padding?: number }) => stack()?.fitAll(opts),\n resetAll: () => stack()?.resetAll(),\n sync: () => {\n const s = stack();\n const opts = getOptions();\n if (!s || !isReady()) return;\n const nextKey = stackedStructureKey(opts.panes);\n if (nextKey !== structureKey) {\n mount(s.container);\n return;\n }\n syncStackedOptions(s, opts);\n paneSeries = syncStackedPaneSeries(s, opts.panes, paneSeries);\n },\n };\n}\n","import { createEffect } from \"solid-js\";\nimport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nimport { useStackedPlot } from \"./useStackedPlot\";\nimport { diffSeries, type VeloPlotSeries } from \"../bindings/shared\";\n\nexport interface VeloPlotProps extends UseVeloPlotOptions {\n series?: VeloPlotSeries[];\n width?: number | string;\n height?: number | string;\n class?: string;\n}\n\nexport function VeloPlot(props: VeloPlotProps) {\n const api = useVeloPlot(() => props);\n let previous = new Map<string, VeloPlotSeries>();\n\n createEffect(() => {\n if (!api.isReady() || !api.chart()) return;\n previous = diffSeries(\n {\n addSeries: api.addSeries,\n updateSeries: api.updateSeries,\n removeSeries: api.removeSeries,\n autoScale: () => api.chart()!.autoScale(),\n },\n props.series ?? [],\n previous,\n );\n });\n\n return (\n <div\n ref={(el) => api.setContainerRef(el)}\n className={`velo-plot-container${props.class ? ` ${props.class}` : \"\"}`}\n role=\"img\"\n style={{\n position: \"relative\",\n width: typeof props.width === \"number\" ? `${props.width}px` : props.width ?? \"100%\",\n height: typeof props.height === \"number\" ? `${props.height}px` : props.height ?? \"400px\",\n }}\n />\n );\n}\n\nexport function StackedPlot(\n props: {\n panes: import(\"../core/stacked\").StackedPaneConfig[];\n width?: number | string;\n height?: number | string;\n class?: string;\n } & Omit<import(\"../core/stacked\").StackedChartOptions, \"container\" | \"panes\">,\n) {\n const api = useStackedPlot(() => props);\n createEffect(() => api.sync());\n\n return (\n <div\n ref={(el) => api.setContainerRef(el)}\n className={`velo-plot-stacked${props.class ? ` ${props.class}` : \"\"}`}\n role=\"img\"\n style={{\n position: \"relative\",\n width: typeof props.width === \"number\" ? `${props.width}px` : props.width ?? \"100%\",\n height: typeof props.height === \"number\" ? `${props.height}px` : props.height ?? \"480px\",\n }}\n />\n );\n}\n","import { createSignal, createEffect, onCleanup } from \"solid-js\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { addIndicatorToHost, isStackedChart, removeIndicatorFromChart, type IndicatorHost } from \"../bindings/shared\";\nimport type { Chart } from \"../core/chart/types\";\n\nexport function useIndicator(\n host: () => IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n) {\n const [result, setResult] = createSignal<(AddIndicatorResult & { paneId?: string }) | null>(null);\n const [isLoading, setIsLoading] = createSignal(false);\n const [error, setError] = createSignal<Error | null>(null);\n\n createEffect(() => {\n const h = host();\n if (!h) return;\n let cancelled = false;\n setIsLoading(true);\n addIndicatorToHost(h, preset, options)\n .then((res) => {\n if (!cancelled) {\n setResult(res);\n setIsLoading(false);\n }\n })\n .catch((e) => {\n if (!cancelled) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setIsLoading(false);\n }\n });\n onCleanup(() => {\n cancelled = true;\n const res = result();\n if (res && !isStackedChart(h)) removeIndicatorFromChart(h as Chart, res.id);\n });\n });\n\n return { result, isLoading, error };\n}\n","import { createSignal, createEffect, onCleanup } from \"solid-js\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport function useChartSync(charts: () => ChartLike[], options?: SyncOptions) {\n const [group, setGroup] = createSignal<ChartGroup | null>(null);\n\n createEffect(() => {\n const list = charts();\n let handle: ReturnType<typeof createChartSync> | null = null;\n if (list.length >= 2) {\n handle = createChartSync(list, options);\n setGroup(handle.group);\n } else {\n setGroup(null);\n }\n onCleanup(() => handle?.destroy());\n });\n\n return { group };\n}\n\nexport const useChartGroup = useChartSync;\n","export { VeloPlot, StackedPlot } from \"./VeloPlot\";\nexport { useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nexport { useStackedPlot } from \"./useStackedPlot\";\nexport { useIndicator } from \"./useIndicator\";\nexport { useChartSync, useChartGroup } from \"./useChartSync\";\n\nimport { VeloPlot as VeloPlotImpl } from \"./VeloPlot\";\nimport { useVeloPlot as useVeloPlotImpl } from \"./useVeloPlot\";\n\n/** @deprecated Use `VeloPlot` instead. **Removed in v4.0.** */\nexport const SciPlot = VeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciPlot = useVeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciChart = useVeloPlotImpl;\n"],"names":["useVeloPlot","options","chart","setChart","createSignal","isReady","setIsReady","error","setError","bounds","setBounds","container","destroy","prevSync","pickSyncableOptions","mount","el","handle","createChartLifecycle","onCleanup","createEffect","c","opts","next","optionsChanged","syncChartOptions","_a","id","data","z","useStackedPlot","getOptions","stack","setStack","structureKey","paneSeries","created","createStackedChart","stackedStructureKey","syncStackedPaneSeries","setContainerRef","syncStackedOptions","VeloPlot","props","api","previous","Map","diffSeries","addSeries","updateSeries","removeSeries","autoScale","series","_el$","_tmpl$","_$use","_$effect","_p$","_v$","class","_v$2","width","_v$3","height","e","className","t","_$setStyleProperty","a","undefined","StackedPlot","sync","_el$2","_v$4","_v$5","_v$6","useIndicator","host","preset","result","setResult","isLoading","setIsLoading","h","cancelled","addIndicatorToHost","res","isStackedChart","removeIndicatorFromChart","useChartSync","charts","group","setGroup","list","createChartSync","useChartGroup","SciPlot","VeloPlotImpl","useSciPlot","useVeloPlotImpl","useSciChart"],"mappings":";;;;;;AAaO,SAASA,EAAYC,IAAoC,OAAO,CAAA,IAAK;AAC1E,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAA2B,IAAI,GACnD,CAACC,GAASC,CAAU,IAAIF,EAAa,EAAK,GAC1C,CAACG,GAAOC,CAAQ,IAAIJ,EAA2B,IAAI,GACnD,CAACK,GAAQC,CAAS,IAAIN,EAA4B,IAAI;AAC5D,MAAIO,GACAC,IAA+B,MAC/BC,IAAWC,EAAoBb,GAAS;AAE5C,QAAMc,IAAQ,CAACC,MAAuB;AACpC,IAAAL,IAAYK,GACZJ,KAAA,QAAAA;AACA,UAAMK,IAASC,EAAqBF,GAAIf,EAAA,GAAW;AAAA,MACjD,gBAAgBS;AAAA,MAChB,SAASF;AAAA,IAAA,CACV;AACD,IAAAL,EAASc,EAAO,KAAK,GACrBL,IAAUK,EAAO,SACjBP,EAAUO,EAAO,WAAW,GAC5BX,EAAW,EAAI,GACfO,IAAWC,EAAoBb,GAAS;AAAA,EAC1C;AAEA,SAAAkB,EAAU,MAAM;AACd,IAAAP,KAAA,QAAAA,KACAT,EAAS,IAAI,GACbG,EAAW,EAAK;AAAA,EAClB,CAAC,GAEDc,EAAa,MAAM;AACjB,UAAMC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AAA,IAEtB,CAAC,GACH/D,EAAU,MAAM;AACd,MAAAiE,IAAY;AACZ,YAAME,IAAMP,EAAA;AACZ,MAAIO,KAAO,CAACC,EAAeJ,CAAC,KAAGK,EAAyBL,GAAYG,EAAI,EAAE;AAAA,IAC5E,CAAC;AAAA,EACH,CAAC,GAEM,EAAE,QAAAP,GAAQ,WAAAE,GAAW,OAAA1E,EAAA;AAC9B;ACpCO,SAASkF,EAAaC,GAA2BzF,GAAuB;AAC7E,QAAM,CAAC0F,GAAOC,CAAQ,IAAIxF,EAAgC,IAAI;AAE9D,SAAAgB,EAAa,MAAM;AACjB,UAAMyE,IAAOH,EAAA;AACb,QAAIzE,IAAoD;AACxD,IAAI4E,EAAK,UAAU,KACjB5E,IAAS6E,EAAgBD,GAAM5F,CAAO,GACtC2F,EAAS3E,EAAO,KAAK,KAErB2E,EAAS,IAAI,GAEfzE,EAAU,MAAMF,KAAA,gBAAAA,EAAQ,SAAS;AAAA,EACnC,CAAC,GAEM,EAAE,OAAA0E,EAAA;AACX;AAEO,MAAMI,IAAgBN,GCbhBO,IAAUC,GAEVC,IAAaC,GAEbC,IAAcD;"}
package/dist/svelte.js CHANGED
@@ -1,13 +1,10 @@
1
- import { writable as p, get as i } from "svelte/store";
2
- import { c as g, i as k, r as b, a as w, b as P } from "./chartSyncBridge-DbWrwtyP.js";
3
- import { p as m, o as I, s as O } from "./optionsSync-QUiN4Inw.js";
4
- import { c as v } from "./createStackedChart-Dm-YqUT7.js";
5
- import "./ChartCore-BpzRvN4Y.js";
6
- import "./index-x4stH3jD.js";
7
- import "./symbols-DT0eLlpW.js";
1
+ import { writable as f, get as i } from "svelte/store";
2
+ import { p as m, o as g, s as k } from "./optionsSync-QUiN4Inw.js";
3
+ import { c as b, i as w, r as P, a as I, b as O } from "./chartSyncBridge-D_rCtbFq.js";
4
+ import { c as v } from "./createStackedChart-DqcLCFGS.js";
8
5
  import { s as S, a as A, b as C } from "./stackedSync-tnrunZMt.js";
9
6
  function y(u = {}) {
10
- const n = p(null), c = p(!1), s = p(null), a = p(null);
7
+ const n = f(null), c = f(!1), s = f(null), a = f(null);
11
8
  let r = null, d = m(u);
12
9
  return {
13
10
  chart: n,
@@ -16,7 +13,7 @@ function y(u = {}) {
16
13
  bounds: a,
17
14
  mount: (t) => {
18
15
  r == null || r();
19
- const e = g(t, u, {
16
+ const e = b(t, u, {
20
17
  onBoundsChange: (l) => a.set(l),
21
18
  onError: (l) => s.set(l)
22
19
  });
@@ -29,7 +26,7 @@ function y(u = {}) {
29
26
  const e = i(n);
30
27
  if (!e) return;
31
28
  const l = m(t);
32
- I(d, l) && (O(e, d, l), d = l);
29
+ g(d, l) && (k(e, d, l), d = l);
33
30
  },
34
31
  addSeries: (t) => {
35
32
  var l;
@@ -57,8 +54,8 @@ function y(u = {}) {
57
54
  }
58
55
  };
59
56
  }
60
- function x(u) {
61
- const n = p(null), c = p(!1);
57
+ function L(u) {
58
+ const n = f(null), c = f(!1);
62
59
  let s = null, a = S(u.panes), r = /* @__PURE__ */ new Map();
63
60
  const d = (o) => {
64
61
  s == null || s();
@@ -91,29 +88,29 @@ function x(u) {
91
88
  }
92
89
  };
93
90
  }
94
- function F(u, n, c = {}) {
95
- const s = p(null), a = p(!1), r = p(null);
91
+ function M(u, n, c = {}) {
92
+ const s = f(null), a = f(!1), r = f(null);
96
93
  return { result: s, isLoading: a, error: r, run: async () => {
97
- const f = u();
98
- if (f) {
94
+ const p = u();
95
+ if (p) {
99
96
  a.set(!0);
100
97
  try {
101
- const o = await w(f, n, c);
98
+ const o = await I(p, n, c);
102
99
  s.set(o), a.set(!1);
103
100
  } catch (o) {
104
101
  r.set(o instanceof Error ? o : new Error(String(o))), a.set(!1);
105
102
  }
106
103
  }
107
104
  }, cleanup: () => {
108
- const f = u();
105
+ const p = u();
109
106
  let o = null;
110
107
  s.subscribe((e) => {
111
108
  o = (e == null ? void 0 : e.id) ?? null;
112
- })(), o && f && !k(f) && b(f, o);
109
+ })(), o && p && !w(p) && P(p, o);
113
110
  } };
114
111
  }
115
112
  function B(u, n) {
116
- const c = p(null);
113
+ const c = f(null);
117
114
  let s = null;
118
115
  return { group: c, sync: () => {
119
116
  s == null || s.destroy();
@@ -122,22 +119,22 @@ function B(u, n) {
122
119
  c.set(null);
123
120
  return;
124
121
  }
125
- s = P(d, n), c.set(s.group);
122
+ s = O(d, n), c.set(s.group);
126
123
  }, destroy: () => {
127
124
  s == null || s.destroy(), c.set(null);
128
125
  } };
129
126
  }
130
- const G = B, T = y, j = y, q = y;
127
+ const Z = B, x = y, F = y, G = y;
131
128
  export {
132
- j as createSciPlot,
133
- x as createStackedPlot,
129
+ F as createSciPlot,
130
+ L as createStackedPlot,
134
131
  y as createVeloPlot,
135
- G as useChartGroup,
132
+ Z as useChartGroup,
136
133
  B as useChartSync,
137
- F as useIndicator,
138
- q as useSciChart,
139
- T as useSciPlot,
140
- x as useStackedPlot,
134
+ M as useIndicator,
135
+ G as useSciChart,
136
+ x as useSciPlot,
137
+ L as useStackedPlot,
141
138
  y as useVeloPlot
142
139
  };
143
140
  //# sourceMappingURL=svelte.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte.js","sources":["../src/svelte/useVeloPlot.ts","../src/svelte/useStackedPlot.ts","../src/svelte/useIndicator.ts","../src/svelte/useChartSync.ts","../src/svelte/index.ts"],"sourcesContent":["/**\n * Svelte composables for velo-plot (exported as functions).\n */\n\nimport { writable, get } from \"svelte/store\";\nimport type { Chart } from \"../core/Chart\";\nimport type { SeriesOptions, SeriesUpdateData, ZoomOptions, Bounds } from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport function createVeloPlot(options: UseVeloPlotOptions = {}) {\n const chart = writable<Chart | null>(null);\n const isReady = writable(false);\n const error = writable<Error | null>(null);\n const bounds = writable<Bounds | null>(null);\n\n let destroy: (() => void) | null = null;\n let prevSync = pickSyncableOptions(options);\n\n const mount = (container: HTMLDivElement) => {\n destroy?.();\n const handle = createChartLifecycle(container, options, {\n onBoundsChange: (b) => bounds.set(b),\n onError: (e) => error.set(e),\n });\n chart.set(handle.chart);\n destroy = handle.destroy;\n bounds.set(handle.getBounds());\n isReady.set(true);\n prevSync = pickSyncableOptions(options);\n };\n\n const updateOptions = (next: UseVeloPlotOptions) => {\n const c = get(chart);\n if (!c) return;\n const picked = pickSyncableOptions(next);\n if (optionsChanged(prevSync, picked)) {\n syncChartOptions(c, prevSync, picked);\n prevSync = picked;\n }\n };\n\n const unmount = () => {\n destroy?.();\n destroy = null;\n chart.set(null);\n isReady.set(false);\n };\n\n return {\n chart,\n isReady,\n error,\n bounds,\n mount,\n unmount,\n updateOptions,\n addSeries: (opts: SeriesOptions) => {\n get(chart)?.addSeries(opts);\n const c = get(chart);\n if (c) bounds.set(c.getViewBounds());\n },\n updateSeries: (id: string, data: SeriesUpdateData) => get(chart)?.updateSeries(id, data),\n removeSeries: (id: string) => get(chart)?.removeSeries(id),\n zoom: (z: ZoomOptions) => get(chart)?.zoom(z),\n resetZoom: () => {\n get(chart)?.resetZoom();\n const c = get(chart);\n if (c) bounds.set(c.getViewBounds());\n },\n };\n}\n\nexport { createVeloPlot as useVeloPlot };\n","import { writable, get } from \"svelte/store\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport { stackedStructureKey, syncStackedOptions, syncStackedPaneSeries } from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport function createStackedPlot(options: Omit<StackedChartOptions, \"container\">) {\n const stack = writable<StackedChart | null>(null);\n const isReady = writable(false);\n let destroy: (() => void) | null = null;\n let structureKey = stackedStructureKey(options.panes);\n let paneSeries = new Map<string, Map<string, VeloPlotSeries>>();\n\n const mount = (container: HTMLDivElement) => {\n destroy?.();\n const created = createStackedChart({ ...options, container });\n stack.set(created);\n destroy = () => created.destroy();\n structureKey = stackedStructureKey(options.panes);\n paneSeries = syncStackedPaneSeries(created, options.panes, new Map());\n created.whenReady().then(() => isReady.set(true));\n };\n\n const sync = (next: Omit<StackedChartOptions, \"container\">) => {\n const s = get(stack);\n if (!s || !get(isReady)) return;\n const nextKey = stackedStructureKey(next.panes);\n if (nextKey !== structureKey) {\n mount(s.container);\n return;\n }\n syncStackedOptions(s, next);\n paneSeries = syncStackedPaneSeries(s, next.panes, paneSeries);\n };\n\n const unmount = () => {\n destroy?.();\n stack.set(null);\n isReady.set(false);\n };\n\n return {\n stack,\n isReady,\n mount,\n unmount,\n sync,\n fitAll: (opts?: { x?: Range; padding?: number }) => get(stack)?.fitAll(opts),\n resetAll: () => get(stack)?.resetAll(),\n };\n}\n\nexport { createStackedPlot as useStackedPlot };\n","import { writable } from \"svelte/store\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { addIndicatorToHost, isStackedChart, removeIndicatorFromChart, type IndicatorHost } from \"../bindings/shared\";\nimport type { Chart } from \"../core/chart/types\";\n\nexport function useIndicator(\n getHost: () => IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n) {\n const result = writable<(AddIndicatorResult & { paneId?: string }) | null>(null);\n const isLoading = writable(false);\n const error = writable<Error | null>(null);\n\n const run = async () => {\n const host = getHost();\n if (!host) return;\n isLoading.set(true);\n try {\n const res = await addIndicatorToHost(host, preset, options);\n result.set(res);\n isLoading.set(false);\n } catch (e) {\n error.set(e instanceof Error ? e : new Error(String(e)));\n isLoading.set(false);\n }\n };\n\n const cleanupIndicator = () => {\n const host = getHost();\n let currentId: string | null = null;\n const unsub = result.subscribe((r) => {\n currentId = r?.id ?? null;\n });\n unsub();\n if (currentId && host && !isStackedChart(host)) {\n removeIndicatorFromChart(host as Chart, currentId);\n }\n };\n\n return { result, isLoading, error, run, cleanup: cleanupIndicator };\n}\n","import { writable } from \"svelte/store\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport function useChartSync(getCharts: () => ChartLike[], options?: SyncOptions) {\n const group = writable<ChartGroup | null>(null);\n let handle: ReturnType<typeof createChartSync> | null = null;\n\n const sync = () => {\n handle?.destroy();\n const charts = getCharts();\n if (charts.length < 2) {\n group.set(null);\n return;\n }\n handle = createChartSync(charts, options);\n group.set(handle.group);\n };\n\n const destroy = () => {\n handle?.destroy();\n group.set(null);\n };\n\n return { group, sync, destroy };\n}\n\nexport const useChartGroup = useChartSync;\n","export { createVeloPlot, useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nexport { createStackedPlot, useStackedPlot } from \"./useStackedPlot\";\nexport { useIndicator } from \"./useIndicator\";\nexport { useChartSync, useChartGroup } from \"./useChartSync\";\n\nimport { useVeloPlot as useVeloPlotImpl, createVeloPlot as createVeloPlotImpl } from \"./useVeloPlot\";\n\n/** @deprecated Use `useVeloPlot` / `createVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciPlot = useVeloPlotImpl;\n/** @deprecated Use `createVeloPlot` instead. **Removed in v4.0.** */\nexport const createSciPlot = createVeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciChart = useVeloPlotImpl;\n\n// Svelte components: import from 'velo-plot/svelte/VeloPlot.svelte' (shipped as source)\n"],"names":["createVeloPlot","options","chart","writable","isReady","error","bounds","destroy","prevSync","pickSyncableOptions","container","handle","createChartLifecycle","b","e","next","c","get","picked","optionsChanged","syncChartOptions","opts","_a","id","data","z","createStackedPlot","stack","structureKey","stackedStructureKey","paneSeries","mount","created","createStackedChart","syncStackedPaneSeries","s","syncStackedOptions","useIndicator","getHost","preset","result","isLoading","host","res","addIndicatorToHost","currentId","r","isStackedChart","removeIndicatorFromChart","useChartSync","getCharts","group","charts","createChartS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B,IAHcL,EAAO,UAAU,CAACM,MAAM;AACpC,MAAAD,KAAYC,KAAA,gBAAAA,EAAG,OAAM;AAAA,IACvB,CAAC,EACD,GACID,KAAaH,KAAQ,CAACK,EAAeL,CAAI,KAC3CM,EAAyBN,GAAeG,CAAS;AAAA,EAErD,EAEiD;AACnD;ACrCO,SAASI,EAAaC,GAA8BjD,GAAuB;AAChF,QAAMkD,IAAQhD,EAA4B,IAAI;AAC9C,MAAIQ,IAAoD;AAkBxD,SAAO,EAAE,OAAAwC,GAAO,MAhBH,MAAM;AACjB,IAAAxC,KAAA,QAAAA,EAAQ;AACR,UAAMyC,IAASF,EAAA;AACf,QAAIE,EAAO,SAAS,GAAG;AACrB,MAAAD,EAAM,IAAI,IAAI;AACd;AAAA,IACF;AACA,IAAAxC,IAAS0C,EAAgBD,GAAQnD,CAAO,GACxCkD,EAAM,IAAIxC,EAAO,KAAK;AAAA,EACxB,GAOsB,SALN,MAAM;AACpB,IAAAA,KAAA,QAAAA,EAAQ,WACRwC,EAAM,IAAI,IAAI;AAAA,EAChB,EAEsB;AACxB;AAEO,MAAMG,IAAgBL,GCpBhBM,IAAaC,GAEbC,IAAgBC,GAEhBC,IAAcH;"}
1
+ {"version":3,"file":"svelte.js","sources":["../src/svelte/useVeloPlot.ts","../src/svelte/useStackedPlot.ts","../src/svelte/useIndicator.ts","../src/svelte/useChartSync.ts","../src/svelte/index.ts"],"sourcesContent":["/**\n * Svelte composables for velo-plot (exported as functions).\n */\n\nimport { writable, get } from \"svelte/store\";\nimport type { Chart } from \"../core/Chart\";\nimport type { SeriesOptions, SeriesUpdateData, ZoomOptions, Bounds } from \"../types\";\nimport {\n createChartLifecycle,\n type ChartBindingOptions,\n optionsChanged,\n syncChartOptions,\n pickSyncableOptions,\n} from \"../bindings/shared\";\n\nexport interface UseVeloPlotOptions extends ChartBindingOptions {}\n\nexport function createVeloPlot(options: UseVeloPlotOptions = {}) {\n const chart = writable<Chart | null>(null);\n const isReady = writable(false);\n const error = writable<Error | null>(null);\n const bounds = writable<Bounds | null>(null);\n\n let destroy: (() => void) | null = null;\n let prevSync = pickSyncableOptions(options);\n\n const mount = (container: HTMLDivElement) => {\n destroy?.();\n const handle = createChartLifecycle(container, options, {\n onBoundsChange: (b) => bounds.set(b),\n onError: (e) => error.set(e),\n });\n chart.set(handle.chart);\n destroy = handle.destroy;\n bounds.set(handle.getBounds());\n isReady.set(true);\n prevSync = pickSyncableOptions(options);\n };\n\n const updateOptions = (next: UseVeloPlotOptions) => {\n const c = get(chart);\n if (!c) return;\n const picked = pickSyncableOptions(next);\n if (optionsChanged(prevSync, picked)) {\n syncChartOptions(c, prevSync, picked);\n prevSync = picked;\n }\n };\n\n const unmount = () => {\n destroy?.();\n destroy = null;\n chart.set(null);\n isReady.set(false);\n };\n\n return {\n chart,\n isReady,\n error,\n bounds,\n mount,\n unmount,\n updateOptions,\n addSeries: (opts: SeriesOptions) => {\n get(chart)?.addSeries(opts);\n const c = get(chart);\n if (c) bounds.set(c.getViewBounds());\n },\n updateSeries: (id: string, data: SeriesUpdateData) => get(chart)?.updateSeries(id, data),\n removeSeries: (id: string) => get(chart)?.removeSeries(id),\n zoom: (z: ZoomOptions) => get(chart)?.zoom(z),\n resetZoom: () => {\n get(chart)?.resetZoom();\n const c = get(chart);\n if (c) bounds.set(c.getViewBounds());\n },\n };\n}\n\nexport { createVeloPlot as useVeloPlot };\n","import { writable, get } from \"svelte/store\";\nimport { createStackedChart } from \"../core/stacked\";\nimport type { StackedChart, StackedChartOptions } from \"../core/stacked\";\nimport type { Range } from \"../types\";\nimport { stackedStructureKey, syncStackedOptions, syncStackedPaneSeries } from \"../bindings/shared\";\nimport type { VeloPlotSeries } from \"../bindings/shared\";\n\nexport function createStackedPlot(options: Omit<StackedChartOptions, \"container\">) {\n const stack = writable<StackedChart | null>(null);\n const isReady = writable(false);\n let destroy: (() => void) | null = null;\n let structureKey = stackedStructureKey(options.panes);\n let paneSeries = new Map<string, Map<string, VeloPlotSeries>>();\n\n const mount = (container: HTMLDivElement) => {\n destroy?.();\n const created = createStackedChart({ ...options, container });\n stack.set(created);\n destroy = () => created.destroy();\n structureKey = stackedStructureKey(options.panes);\n paneSeries = syncStackedPaneSeries(created, options.panes, new Map());\n created.whenReady().then(() => isReady.set(true));\n };\n\n const sync = (next: Omit<StackedChartOptions, \"container\">) => {\n const s = get(stack);\n if (!s || !get(isReady)) return;\n const nextKey = stackedStructureKey(next.panes);\n if (nextKey !== structureKey) {\n mount(s.container);\n return;\n }\n syncStackedOptions(s, next);\n paneSeries = syncStackedPaneSeries(s, next.panes, paneSeries);\n };\n\n const unmount = () => {\n destroy?.();\n stack.set(null);\n isReady.set(false);\n };\n\n return {\n stack,\n isReady,\n mount,\n unmount,\n sync,\n fitAll: (opts?: { x?: Range; padding?: number }) => get(stack)?.fitAll(opts),\n resetAll: () => get(stack)?.resetAll(),\n };\n}\n\nexport { createStackedPlot as useStackedPlot };\n","import { writable } from \"svelte/store\";\nimport type { AddIndicatorOptions, AddIndicatorResult } from \"../core/indicator/addIndicator\";\nimport type { IndicatorPresetName } from \"../core/indicator/indicatorPresets\";\nimport { addIndicatorToHost, isStackedChart, removeIndicatorFromChart, type IndicatorHost } from \"../bindings/shared\";\nimport type { Chart } from \"../core/chart/types\";\n\nexport function useIndicator(\n getHost: () => IndicatorHost,\n preset: IndicatorPresetName,\n options: AddIndicatorOptions = {},\n) {\n const result = writable<(AddIndicatorResult & { paneId?: string }) | null>(null);\n const isLoading = writable(false);\n const error = writable<Error | null>(null);\n\n const run = async () => {\n const host = getHost();\n if (!host) return;\n isLoading.set(true);\n try {\n const res = await addIndicatorToHost(host, preset, options);\n result.set(res);\n isLoading.set(false);\n } catch (e) {\n error.set(e instanceof Error ? e : new Error(String(e)));\n isLoading.set(false);\n }\n };\n\n const cleanupIndicator = () => {\n const host = getHost();\n let currentId: string | null = null;\n const unsub = result.subscribe((r) => {\n currentId = r?.id ?? null;\n });\n unsub();\n if (currentId && host && !isStackedChart(host)) {\n removeIndicatorFromChart(host as Chart, currentId);\n }\n };\n\n return { result, isLoading, error, run, cleanup: cleanupIndicator };\n}\n","import { writable } from \"svelte/store\";\nimport type { ChartLike, SyncOptions } from \"../core/sync\";\nimport { ChartGroup } from \"../core/sync\";\nimport { createChartSync } from \"../bindings/shared\";\n\nexport function useChartSync(getCharts: () => ChartLike[], options?: SyncOptions) {\n const group = writable<ChartGroup | null>(null);\n let handle: ReturnType<typeof createChartSync> | null = null;\n\n const sync = () => {\n handle?.destroy();\n const charts = getCharts();\n if (charts.length < 2) {\n group.set(null);\n return;\n }\n handle = createChartSync(charts, options);\n group.set(handle.group);\n };\n\n const destroy = () => {\n handle?.destroy();\n group.set(null);\n };\n\n return { group, sync, destroy };\n}\n\nexport const useChartGroup = useChartSync;\n","export { createVeloPlot, useVeloPlot, type UseVeloPlotOptions } from \"./useVeloPlot\";\nexport { createStackedPlot, useStackedPlot } from \"./useStackedPlot\";\nexport { useIndicator } from \"./useIndicator\";\nexport { useChartSync, useChartGroup } from \"./useChartSync\";\n\nimport { useVeloPlot as useVeloPlotImpl, createVeloPlot as createVeloPlotImpl } from \"./useVeloPlot\";\n\n/** @deprecated Use `useVeloPlot` / `createVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciPlot = useVeloPlotImpl;\n/** @deprecated Use `createVeloPlot` instead. **Removed in v4.0.** */\nexport const createSciPlot = createVeloPlotImpl;\n/** @deprecated Use `useVeloPlot` instead. **Removed in v4.0.** */\nexport const useSciChart = useVeloPlotImpl;\n\n// Svelte components: import from 'velo-plot/svelte/VeloPlot.svelte' (shipped as source)\n"],"names":["createVeloPlot","options","chart","writable","isReady","error","bounds","destroy","prevSync","pickSyncableOptions","container","handle","createChartLifecycle","b","e","next","c","get","picked","optionsChanged","syncChartOptions","opts","_a","id","data","z","createStackedPlot","stack","structureKey","stackedStructureKey","paneSeries","mount","created","createStackedChart","syncStackedPaneSeries","s","syncStackedOptions","useIndicator","getHost","preset","result","isLoading","host","res","addIndicatorToHost","currentId","r","isStackedChart","removeIndicatorFromChart","useChartSync","getCharts","group","charts","createChartSync","useChartGroup","useSciPlot","useVeloPlotImpl","createSciPlot","createVeloPlotImpl","useSciChart"],"mappings":";;;;;AAiBO,SAASA,EAAeC,IAA8B,IAAI;AAC/D,QAAMC,IAAQC,EAAuB,IAAI,GACnCC,IAAUD,EAAS,EAAK,GACxBE,IAAQF,EAAuB,IAAI,GACnCG,IAASH,EAAwB,IAAI;AAE3C,MAAII,IAA+B,MAC/BC,IAAWC,EAAoBR,CAAO;AAgC1C,SAAO;AAAA,IACL,OAAAC;AAAA,IACA,SAAAE;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,OAnCY,CAACI,MAA8B;AAC3C,MAAAH,KAAA,QAAAA;AACA,YAAMI,IAASC,EAAqBF,GAAWT,GAAS;AAAA,QACtD,gBAAgB,CAACY,MAAMP,EAAO,IAAIO,CAAC;AAAA,QACnC,SAAS,CAACC,MAAMT,EAAM,IAAIS,CAAC;AAAA,MAAA,CAC5B;AACD,MAAAZ,EAAM,IAAIS,EAAO,KAAK,GACtBJ,IAAUI,EAAO,SACjBL,EAAO,IAAIK,EAAO,WAAW,GAC7BP,EAAQ,IAAI,EAAI,GAChBI,IAAWC,EAAoBR,CAAO;AAAA,IACxC;AAAA,IAyBE,SAbc,MAAM;AACpB,MAAAM,KAAA,QAAAA,KACAA,IAAU,MACVL,EAAM,IAAI,IAAI,GACdE,EAAQ,IAAI,EAAK;AAAA,IACnB;AAAA,IASE,eAxBoB,CAACW,MAA6B;AAClD,YAAMC,IAAIC,EAAIf,CAAK;AACnB,UAAI,CAACc,EAAG;AACR,YAAME,IAAST,EAAoBM,CAAI;AACvC,MAAII,EAAeX,GAAUU,CAAM,MACjCE,EAAiBJ,GAAGR,GAAUU,CAAM,GACpCV,IAAWU;AAAA,IAEf;AAAA,IAiBE,WAAW,CAACG,MAAwB;;AAClC,OAAAC,IAAAL,EAAIf,CAAK,MAAT,QAAAoB,EAAY,UAAUD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B,UAAMC,IAAOJ,EAAA;AACb,QAAIO,IAA2B;AAI/B,IAHcL,EAAO,UAAU,CAACM,MAAM;AACpC,MAAAD,KAAYC,KAAA,gBAAAA,EAAG,OAAM;AAAA,IACvB,CAAC,EACD,GACID,KAAaH,KAAQ,CAACK,EAAeL,CAAI,KAC3CM,EAAyBN,GAAeG,CAAS;AAAA,EAErD,EAEiD;AACnD;ACrCO,SAASI,EAAaC,GAA8BjD,GAAuB;AAChF,QAAMkD,IAAQhD,EAA4B,IAAI;AAC9C,MAAIQ,IAAoD;AAkBxD,SAAO,EAAE,OAAAwC,GAAO,MAhBH,MAAM;AACjB,IAAAxC,KAAA,QAAAA,EAAQ;AACR,UAAMyC,IAASF,EAAA;AACf,QAAIE,EAAO,SAAS,GAAG;AACrB,MAAAD,EAAM,IAAI,IAAI;AACd;AAAA,IACF;AACA,IAAAxC,IAAS0C,EAAgBD,GAAQnD,CAAO,GACxCkD,EAAM,IAAIxC,EAAO,KAAK;AAAA,EACxB,GAOsB,SALN,MAAM;AACpB,IAAAA,KAAA,QAAAA,EAAQ,WACRwC,EAAM,IAAI,IAAI;AAAA,EAChB,EAEsB;AACxB;AAEO,MAAMG,IAAgBL,GCpBhBM,IAAaC,GAEbC,IAAgBC,GAEhBC,IAAcH;"}
@@ -1,7 +1,4 @@
1
- /**
2
- * velo-plot/trading — focused trading dashboard bundle (Stage 2).
3
- * Tree-shakes scientific/3D plugins; includes stacked charts, indicators, drawings, replay.
4
- */
1
+
5
2
  export { createChart } from '../core/Chart';
6
3
  export { createStackedChart } from '../core/stacked/createStackedChart';
7
4
  export type { Chart, ChartOptions } from '../core/Chart';
@@ -0,0 +1,3 @@
1
+ export declare function patchChartTradingMethods(): void;
2
+ /** Register trading extensions (call on `velo-plot/trading` import). */
3
+ export declare function registerTradingBundle(): void;
package/dist/trading.js CHANGED
@@ -1,13 +1,13 @@
1
- import { D as P, e as b, d as v, k as B, l as E, o as S, n as U, c as H } from "./ChartCore-BpzRvN4Y.js";
2
- import { c as k } from "./createStackedChart-Dm-YqUT7.js";
3
- import { c as L, b as R, f as G, i as K, a as j, m as X } from "./axisFormat-CzumxpCL.js";
1
+ import { a as P, f as b, g as v, c as B } from "./createStackedChart-DqcLCFGS.js";
2
+ import { c as S, b as U, f as H, i as I, a as k, m as _ } from "./axisFormat-Sz4WIJfQ.js";
3
+ import { P as R, a as G, b as K, c as j, d as X } from "./index-Cv6ZDLWf.js";
4
4
  import { PluginAnnotations as q } from "./plugins/annotations.js";
5
- import { P as J, a as N, b as O, c as Q } from "./mockDatafeed-DHIDPcpX.js";
6
- import { PluginKeyboard as W } from "./plugins/keyboard.js";
7
- import { P as $ } from "./index-BMiZoKmm.js";
8
- import { C as te } from "./index-CaXWSOTk.js";
5
+ import { PluginKeyboard as J } from "./plugins/keyboard.js";
6
+ import { P as O } from "./index-BgrvqltV.js";
7
+ import { C as V } from "./index-CaXWSOTk.js";
8
+ import { D as Z, e as $, d as ee, c as te } from "./ChartCore-AnR_3Xkb.js";
9
9
  const p = 864e5;
10
- function w(e) {
10
+ function g(e) {
11
11
  let a = e >>> 0;
12
12
  return () => {
13
13
  a = a + 1831565813 >>> 0;
@@ -16,7 +16,7 @@ function w(e) {
16
16
  };
17
17
  }
18
18
  function h(e) {
19
- return e !== void 0 ? w(e) : Math.random;
19
+ return e !== void 0 ? g(e) : Math.random;
20
20
  }
21
21
  function D(e, a, t = Date.UTC(2024, 0, 2)) {
22
22
  const l = typeof e == "object" ? e : { startMs: e, seed: a };
@@ -25,31 +25,31 @@ function D(e, a, t = Date.UTC(2024, 0, 2)) {
25
25
  seed: l.seed
26
26
  };
27
27
  }
28
- function x(e, a = Date.UTC(2024, 0, 2), t) {
29
- const { startMs: l, seed: d } = D(a, t), n = h(d), u = new Float64Array(e), c = new Float32Array(e), f = new Float32Array(e), m = new Float32Array(e), s = new Float32Array(e), y = new Float32Array(e);
28
+ function w(e, a = Date.UTC(2024, 0, 2), t) {
29
+ const { startMs: l, seed: y } = D(a, t), n = h(y), u = new Float64Array(e), c = new Float32Array(e), f = new Float32Array(e), d = new Float32Array(e), s = new Float32Array(e), m = new Float32Array(e);
30
30
  let i = l, r = 100;
31
31
  for (let o = 0; o < e; o++) {
32
32
  for (; new Date(i).getUTCDay() === 0 || new Date(i).getUTCDay() === 6; )
33
33
  i += p;
34
34
  u[o] = i, c[o] = r;
35
35
  const A = (n() - 0.48) * 3;
36
- s[o] = r + A, f[o] = Math.max(c[o], s[o]) + n() * 1.5, m[o] = Math.min(c[o], s[o]) - n() * 1.5, y[o] = 5e5 + n() * 2e6, r = s[o], i += p;
36
+ s[o] = r + A, f[o] = Math.max(c[o], s[o]) + n() * 1.5, d[o] = Math.min(c[o], s[o]) - n() * 1.5, m[o] = 5e5 + n() * 2e6, r = s[o], i += p;
37
37
  }
38
- return { x: u, open: c, high: f, low: m, close: s, volume: y };
38
+ return { x: u, open: c, high: f, low: d, close: s, volume: m };
39
39
  }
40
- function g(e, a = Date.UTC(2024, 0, 1), t) {
41
- const { startMs: l, seed: d } = D(
40
+ function x(e, a = Date.UTC(2024, 0, 1), t) {
41
+ const { startMs: l, seed: y } = D(
42
42
  a,
43
43
  t,
44
44
  Date.UTC(2024, 0, 1)
45
- ), n = h(d), u = new Float64Array(e), c = new Float32Array(e), f = new Float32Array(e), m = new Float32Array(e), s = new Float32Array(e), y = new Float32Array(e);
45
+ ), n = h(y), u = new Float64Array(e), c = new Float32Array(e), f = new Float32Array(e), d = new Float32Array(e), s = new Float32Array(e), m = new Float32Array(e);
46
46
  let i = 100;
47
47
  for (let r = 0; r < e; r++) {
48
48
  u[r] = l + r * p, c[r] = i;
49
49
  const o = (n() - 0.48) * 3;
50
- s[r] = i + o, f[r] = Math.max(c[r], s[r]) + n() * 1.5, m[r] = Math.min(c[r], s[r]) - n() * 1.5, y[r] = 5e5 + n() * 2e6, i = s[r];
50
+ s[r] = i + o, f[r] = Math.max(c[r], s[r]) + n() * 1.5, d[r] = Math.min(c[r], s[r]) - n() * 1.5, m[r] = 5e5 + n() * 2e6, i = s[r];
51
51
  }
52
- return { x: u, open: c, high: f, low: m, close: s, volume: y };
52
+ return { x: u, open: c, high: f, low: d, close: s, volume: m };
53
53
  }
54
54
  function M(e) {
55
55
  let a = 0;
@@ -64,32 +64,32 @@ function T(e) {
64
64
  return a;
65
65
  }
66
66
  export {
67
- te as ChartGroup,
68
- P as DARK_THEME,
69
- b as DEFAULT_THEME,
70
- v as LIGHT_THEME,
67
+ V as ChartGroup,
68
+ Z as DARK_THEME,
69
+ $ as DEFAULT_THEME,
70
+ ee as LIGHT_THEME,
71
71
  q as PluginAnnotations,
72
- J as PluginDrawingTools,
73
- W as PluginKeyboard,
74
- N as PluginReplay,
75
- $ as PluginStreaming,
76
- B as addIndicatorToChart,
77
- L as applyBusinessDayX,
78
- O as barsToOhlc,
79
- E as buildIndicatorPaneFromPreset,
80
- R as businessDaySpanMs,
81
- S as computeHeikinAshi,
82
- U as computeIndicatorFromSeries,
83
- H as createChart,
84
- Q as createMockDatafeed,
85
- k as createStackedChart,
72
+ R as PluginDrawingTools,
73
+ J as PluginKeyboard,
74
+ G as PluginReplay,
75
+ O as PluginStreaming,
76
+ P as addIndicatorToChart,
77
+ S as applyBusinessDayX,
78
+ K as barsToOhlc,
79
+ b as buildIndicatorPaneFromPreset,
80
+ U as businessDaySpanMs,
81
+ j as computeHeikinAshi,
82
+ v as computeIndicatorFromSeries,
83
+ te as createChart,
84
+ X as createMockDatafeed,
85
+ B as createStackedChart,
86
86
  T as findHighestBarIndex,
87
87
  M as findLowestBarIndex,
88
- G as formatBusinessDayTick,
89
- x as generateBusinessDayOhlcv,
90
- g as generateContinuousOhlcv,
91
- K as isBusinessDay,
92
- j as isBusinessDayScaleActive,
93
- X as mapToBusinessDayScale
88
+ H as formatBusinessDayTick,
89
+ w as generateBusinessDayOhlcv,
90
+ x as generateContinuousOhlcv,
91
+ I as isBusinessDay,
92
+ k as isBusinessDayScaleActive,
93
+ _ as mapToBusinessDayScale
94
94
  };
95
95
  //# sourceMappingURL=trading.js.map
package/dist/types.d.ts CHANGED
@@ -225,9 +225,9 @@ export interface SeriesUpdateData {
225
225
  /** New value for Gauge charts */
226
226
  value?: number;
227
227
  /** New nodes for Sankey diagrams */
228
- nodes?: any[];
228
+ nodes?: SankeyNode[] | string[];
229
229
  /** New links for Sankey diagrams */
230
- links?: any[];
230
+ links?: SankeyLink[];
231
231
  /** If true, append to existing data; if false, replace */
232
232
  append?: boolean;
233
233
  }
@@ -556,7 +556,7 @@ export interface ChartOptions {
556
556
  /** Responsive design configuration */
557
557
  responsive?: import('./core/responsive').ResponsiveConfig | boolean;
558
558
  /** Initial plugins to load */
559
- plugins?: any[];
559
+ plugins?: import('./plugins/types').ChartPlugin[];
560
560
  /** Loading indicator configuration */
561
561
  loading?: boolean | import('./plugins/loading').PluginLoadingConfig;
562
562
  /**