@tradecanvas/svelte 1.0.10 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 TradeCanvas Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TradeCanvas Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,44 +1,44 @@
1
- # @tradecanvas/svelte
2
-
3
- Svelte 5 component for [`@tradecanvas/chart`](https://www.npmjs.com/package/@tradecanvas/chart) — reactive props, runes, zero boilerplate.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @tradecanvas/svelte @tradecanvas/chart
9
- ```
10
-
11
- `svelte` (>= 5) is a peer dependency.
12
-
13
- ## Usage
14
-
15
- ```svelte
16
- <script lang="ts">
17
- import { TradeCanvas } from '@tradecanvas/svelte'
18
- import type { Chart } from '@tradecanvas/chart'
19
-
20
- let chart = $state<Chart | null>(null)
21
- </script>
22
-
23
- <div style="height: 500px">
24
- <TradeCanvas
25
- symbol="BTCUSDT"
26
- timeframe="5m"
27
- theme="dark"
28
- indicators={['rsi', 'macd']}
29
- bind:chart
30
- />
31
- </div>
32
- ```
33
-
34
- Streams live Binance data by default. Pass `data={bars}` for static OHLC, or `adapter={...}` for any feed. `bind:chart` gives you the underlying `Chart` (or use `onReady`).
35
-
36
- ## Props
37
-
38
- `symbol`, `timeframe`, `theme`, `chartType`, `indicators`, `data`, `adapter`, `historyLimit`, `features`, `autoScale`, `signalMarkers`, `signalMarkerStyle`, `tradeZones`, `tradeZoneStyle`, `watermarkText`, `onReady`, and `bind:chart`.
39
-
40
- Reach the underlying `Chart` (drawings, trading, execution adapters, plugins, resizable panes) via `bind:chart` or `onReady`. See the [main docs](https://github.com/bonguynvan/tradecanvas).
41
-
42
- ## License
43
-
44
- MIT
1
+ # @tradecanvas/svelte
2
+
3
+ Svelte 5 component for [`@tradecanvas/chart`](https://www.npmjs.com/package/@tradecanvas/chart) — reactive props, runes, zero boilerplate.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @tradecanvas/svelte @tradecanvas/chart
9
+ ```
10
+
11
+ `svelte` (>= 5) is a peer dependency.
12
+
13
+ ## Usage
14
+
15
+ ```svelte
16
+ <script lang="ts">
17
+ import { TradeCanvas } from '@tradecanvas/svelte'
18
+ import type { Chart } from '@tradecanvas/chart'
19
+
20
+ let chart = $state<Chart | null>(null)
21
+ </script>
22
+
23
+ <div style="height: 500px">
24
+ <TradeCanvas
25
+ symbol="BTCUSDT"
26
+ timeframe="5m"
27
+ theme="dark"
28
+ indicators={['rsi', 'macd']}
29
+ bind:chart
30
+ />
31
+ </div>
32
+ ```
33
+
34
+ Streams live Binance data by default. Pass `data={bars}` for static OHLC, or `adapter={...}` for any feed. `bind:chart` gives you the underlying `Chart` (or use `onReady`).
35
+
36
+ ## Props
37
+
38
+ `symbol`, `timeframe`, `theme`, `chartType`, `indicators`, `data`, `adapter`, `historyLimit`, `features`, `autoScale`, `signalMarkers`, `signalMarkerStyle`, `tradeZones`, `tradeZoneStyle`, `watermarkText`, `onReady`, and `bind:chart`.
39
+
40
+ Reach the underlying `Chart` (drawings, trading, execution adapters, plugins, resizable panes) via `bind:chart` or `onReady`. See the [main docs](https://github.com/bonguynvan/tradecanvas).
41
+
42
+ ## License
43
+
44
+ MIT
@@ -1,164 +1,164 @@
1
- <script lang="ts">
2
- import { onMount, onDestroy } from 'svelte';
3
- import {
4
- Chart,
5
- BinanceAdapter,
6
- DARK_THEME,
7
- LIGHT_THEME,
8
- } from '@tradecanvas/chart';
9
- import type {
10
- ChartType,
11
- TimeFrame,
12
- FeaturesConfig,
13
- Theme,
14
- OHLCBar,
15
- SignalMarker,
16
- TradeZone,
17
- SignalMarkerStyle,
18
- TradeZoneStyle,
19
- DataAdapter,
20
- } from '@tradecanvas/chart';
21
-
22
- interface Props {
23
- symbol?: string;
24
- timeframe?: TimeFrame;
25
- theme?: 'dark' | 'light' | Theme;
26
- chartType?: ChartType;
27
- indicators?: string[];
28
- data?: OHLCBar[];
29
- adapter?: DataAdapter;
30
- historyLimit?: number;
31
- features?: FeaturesConfig;
32
- autoScale?: boolean;
33
- signalMarkers?: SignalMarker[];
34
- signalMarkerStyle?: SignalMarkerStyle;
35
- tradeZones?: TradeZone[];
36
- tradeZoneStyle?: TradeZoneStyle;
37
- watermarkText?: string;
38
- onReady?: (chart: Chart) => void;
39
- chart?: Chart | null;
40
- }
41
-
42
- let {
43
- symbol = 'BTCUSDT',
44
- timeframe = '5m' as TimeFrame,
45
- theme = 'dark' as 'dark' | 'light' | Theme,
46
- chartType = 'candlestick' as ChartType,
47
- indicators = [] as string[],
48
- data = undefined as OHLCBar[] | undefined,
49
- adapter = undefined as DataAdapter | undefined,
50
- historyLimit = 500,
51
- features = undefined as FeaturesConfig | undefined,
52
- autoScale = true,
53
- signalMarkers = undefined as SignalMarker[] | undefined,
54
- signalMarkerStyle = undefined as SignalMarkerStyle | undefined,
55
- tradeZones = undefined as TradeZone[] | undefined,
56
- tradeZoneStyle = undefined as TradeZoneStyle | undefined,
57
- watermarkText = undefined as string | undefined,
58
- onReady = undefined as ((chart: Chart) => void) | undefined,
59
- chart = $bindable(null) as Chart | null,
60
- }: Props = $props();
61
-
62
- function resolveTheme(t: 'dark' | 'light' | Theme): Theme {
63
- if (t === 'dark') return DARK_THEME;
64
- if (t === 'light') return LIGHT_THEME;
65
- return t as Theme;
66
- }
67
-
68
- let container: HTMLDivElement;
69
- let instance: Chart | null = null;
70
- const indicatorIds = new Map<string, string>();
71
- let prevSymbol = symbol;
72
- let prevTimeframe = timeframe;
73
-
74
- onMount(() => {
75
- instance = new Chart(container, {
76
- chartType,
77
- theme: resolveTheme(theme),
78
- autoScale,
79
- rightMargin: 5,
80
- crosshair: { mode: 'magnet' },
81
- watermark: watermarkText
82
- ? { text: watermarkText, fontSize: 48, color: 'rgba(255,255,255,0.03)' }
83
- : undefined,
84
- features: {
85
- drawings: true,
86
- drawingMagnet: true,
87
- drawingUndoRedo: true,
88
- indicators: true,
89
- trading: true,
90
- volume: true,
91
- legend: true,
92
- crosshair: true,
93
- keyboard: true,
94
- screenshot: true,
95
- alerts: true,
96
- barCountdown: true,
97
- logScale: true,
98
- watermark: true,
99
- ...features,
100
- },
101
- });
102
-
103
- chart = instance;
104
-
105
- if (data) {
106
- instance.setData(data);
107
- } else {
108
- const dataAdapter = adapter ?? new BinanceAdapter();
109
- instance.connect({ adapter: dataAdapter, symbol, timeframe, historyLimit });
110
- }
111
-
112
- onReady?.(instance);
113
- });
114
-
115
- onDestroy(() => {
116
- if (instance) {
117
- instance.disconnectStream();
118
- instance.destroy();
119
- instance = null;
120
- chart = null;
121
- }
122
- });
123
-
124
- $effect(() => {
125
- if (!instance || data) return;
126
- const _s = symbol;
127
- const _tf = timeframe;
128
- if (_s === prevSymbol && _tf === prevTimeframe) return;
129
- prevSymbol = _s;
130
- prevTimeframe = _tf;
131
- instance.disconnectStream();
132
- const dataAdapter = adapter ?? new BinanceAdapter();
133
- instance.connect({ adapter: dataAdapter, symbol: _s, timeframe: _tf, historyLimit });
134
- if (watermarkText) instance.setWatermark(watermarkText);
135
- });
136
-
137
- $effect(() => { instance?.setTheme(resolveTheme(theme)); });
138
- $effect(() => { instance?.setChartType(chartType); });
139
- $effect(() => { if (data) instance?.setData(data); });
140
-
141
- $effect(() => {
142
- if (!instance) return;
143
- const desired = new Set(indicators);
144
- for (const [name, instanceId] of indicatorIds) {
145
- if (!desired.has(name)) {
146
- instance.removeIndicator(instanceId);
147
- indicatorIds.delete(name);
148
- }
149
- }
150
- for (const name of indicators) {
151
- if (!indicatorIds.has(name)) {
152
- const instanceId = instance.addIndicator(name);
153
- if (instanceId) indicatorIds.set(name, instanceId);
154
- }
155
- }
156
- });
157
-
158
- $effect(() => { if (signalMarkers) instance?.setSignalMarkers(signalMarkers); });
159
- $effect(() => { if (signalMarkerStyle) instance?.setSignalMarkerStyle(signalMarkerStyle); });
160
- $effect(() => { if (tradeZones) instance?.setTradeZones(tradeZones); });
161
- $effect(() => { if (tradeZoneStyle) instance?.setTradeZoneStyle(tradeZoneStyle); });
162
- </script>
163
-
164
- <div bind:this={container} style="width:100%;height:100%"></div>
1
+ <script lang="ts">
2
+ import { onMount, onDestroy } from 'svelte';
3
+ import {
4
+ Chart,
5
+ BinanceAdapter,
6
+ DARK_THEME,
7
+ LIGHT_THEME,
8
+ } from '@tradecanvas/chart';
9
+ import type {
10
+ ChartType,
11
+ TimeFrame,
12
+ FeaturesConfig,
13
+ Theme,
14
+ OHLCBar,
15
+ SignalMarker,
16
+ TradeZone,
17
+ SignalMarkerStyle,
18
+ TradeZoneStyle,
19
+ DataAdapter,
20
+ } from '@tradecanvas/chart';
21
+
22
+ interface Props {
23
+ symbol?: string;
24
+ timeframe?: TimeFrame;
25
+ theme?: 'dark' | 'light' | Theme;
26
+ chartType?: ChartType;
27
+ indicators?: string[];
28
+ data?: OHLCBar[];
29
+ adapter?: DataAdapter;
30
+ historyLimit?: number;
31
+ features?: FeaturesConfig;
32
+ autoScale?: boolean;
33
+ signalMarkers?: SignalMarker[];
34
+ signalMarkerStyle?: SignalMarkerStyle;
35
+ tradeZones?: TradeZone[];
36
+ tradeZoneStyle?: TradeZoneStyle;
37
+ watermarkText?: string;
38
+ onReady?: (chart: Chart) => void;
39
+ chart?: Chart | null;
40
+ }
41
+
42
+ let {
43
+ symbol = 'BTCUSDT',
44
+ timeframe = '5m' as TimeFrame,
45
+ theme = 'dark' as 'dark' | 'light' | Theme,
46
+ chartType = 'candlestick' as ChartType,
47
+ indicators = [] as string[],
48
+ data = undefined as OHLCBar[] | undefined,
49
+ adapter = undefined as DataAdapter | undefined,
50
+ historyLimit = 500,
51
+ features = undefined as FeaturesConfig | undefined,
52
+ autoScale = true,
53
+ signalMarkers = undefined as SignalMarker[] | undefined,
54
+ signalMarkerStyle = undefined as SignalMarkerStyle | undefined,
55
+ tradeZones = undefined as TradeZone[] | undefined,
56
+ tradeZoneStyle = undefined as TradeZoneStyle | undefined,
57
+ watermarkText = undefined as string | undefined,
58
+ onReady = undefined as ((chart: Chart) => void) | undefined,
59
+ chart = $bindable(null) as Chart | null,
60
+ }: Props = $props();
61
+
62
+ function resolveTheme(t: 'dark' | 'light' | Theme): Theme {
63
+ if (t === 'dark') return DARK_THEME;
64
+ if (t === 'light') return LIGHT_THEME;
65
+ return t as Theme;
66
+ }
67
+
68
+ let container: HTMLDivElement;
69
+ let instance: Chart | null = null;
70
+ const indicatorIds = new Map<string, string>();
71
+ let prevSymbol = symbol;
72
+ let prevTimeframe = timeframe;
73
+
74
+ onMount(() => {
75
+ instance = new Chart(container, {
76
+ chartType,
77
+ theme: resolveTheme(theme),
78
+ autoScale,
79
+ rightMargin: 5,
80
+ crosshair: { mode: 'magnet' },
81
+ watermark: watermarkText
82
+ ? { text: watermarkText, fontSize: 48, color: 'rgba(255,255,255,0.03)' }
83
+ : undefined,
84
+ features: {
85
+ drawings: true,
86
+ drawingMagnet: true,
87
+ drawingUndoRedo: true,
88
+ indicators: true,
89
+ trading: true,
90
+ volume: true,
91
+ legend: true,
92
+ crosshair: true,
93
+ keyboard: true,
94
+ screenshot: true,
95
+ alerts: true,
96
+ barCountdown: true,
97
+ logScale: true,
98
+ watermark: true,
99
+ ...features,
100
+ },
101
+ });
102
+
103
+ chart = instance;
104
+
105
+ if (data) {
106
+ instance.setData(data);
107
+ } else {
108
+ const dataAdapter = adapter ?? new BinanceAdapter();
109
+ instance.connect({ adapter: dataAdapter, symbol, timeframe, historyLimit });
110
+ }
111
+
112
+ onReady?.(instance);
113
+ });
114
+
115
+ onDestroy(() => {
116
+ if (instance) {
117
+ instance.disconnectStream();
118
+ instance.destroy();
119
+ instance = null;
120
+ chart = null;
121
+ }
122
+ });
123
+
124
+ $effect(() => {
125
+ if (!instance || data) return;
126
+ const _s = symbol;
127
+ const _tf = timeframe;
128
+ if (_s === prevSymbol && _tf === prevTimeframe) return;
129
+ prevSymbol = _s;
130
+ prevTimeframe = _tf;
131
+ instance.disconnectStream();
132
+ const dataAdapter = adapter ?? new BinanceAdapter();
133
+ instance.connect({ adapter: dataAdapter, symbol: _s, timeframe: _tf, historyLimit });
134
+ if (watermarkText) instance.setWatermark(watermarkText);
135
+ });
136
+
137
+ $effect(() => { instance?.setTheme(resolveTheme(theme)); });
138
+ $effect(() => { instance?.setChartType(chartType); });
139
+ $effect(() => { if (data) instance?.setData(data); });
140
+
141
+ $effect(() => {
142
+ if (!instance) return;
143
+ const desired = new Set(indicators);
144
+ for (const [name, instanceId] of indicatorIds) {
145
+ if (!desired.has(name)) {
146
+ instance.removeIndicator(instanceId);
147
+ indicatorIds.delete(name);
148
+ }
149
+ }
150
+ for (const name of indicators) {
151
+ if (!indicatorIds.has(name)) {
152
+ const instanceId = instance.addIndicator(name);
153
+ if (instanceId) indicatorIds.set(name, instanceId);
154
+ }
155
+ }
156
+ });
157
+
158
+ $effect(() => { if (signalMarkers) instance?.setSignalMarkers(signalMarkers); });
159
+ $effect(() => { if (signalMarkerStyle) instance?.setSignalMarkerStyle(signalMarkerStyle); });
160
+ $effect(() => { if (tradeZones) instance?.setTradeZones(tradeZones); });
161
+ $effect(() => { if (tradeZoneStyle) instance?.setTradeZoneStyle(tradeZoneStyle); });
162
+ </script>
163
+
164
+ <div bind:this={container} style="width:100%;height:100%"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradecanvas/svelte",
3
- "version": "1.0.10",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "description": "Svelte 5 component for @tradecanvas/chart — reactive props, runes, zero boilerplate.",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "README.md"
36
36
  ],
37
37
  "dependencies": {
38
- "@tradecanvas/chart": "1.7.0"
38
+ "@tradecanvas/chart": "1.10.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "svelte": ">=5.0.0"