@luxalgo/vela 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/dist/{DataProvider-DrN7ZIou.d.cts → DataProvider-DDUYw2qP.d.cts} +1 -1
- package/dist/{DataProvider-BmHkcwvJ.d.ts → DataProvider-JJq7M2it.d.ts} +1 -1
- package/dist/{history-CvOtsjT5.d.ts → bottombar-COnL2Sk4.d.ts} +110 -127
- package/dist/{history-BmyjaVir.d.cts → bottombar-DeDXbF_K.d.cts} +110 -127
- package/dist/{chunk-6FA4TDUF.js → chunk-JQFO2WMU.js} +2666 -2333
- package/dist/{chunk-BEJ57HP4.js → chunk-OEUGUXL7.js} +14 -1
- package/dist/{chunk-3QX6QOCX.js → chunk-TMXK2SJR.js} +5852 -3340
- package/dist/{contributions-2bEmCF9S.d.cts → contributions-BqCIsbaP.d.ts} +108 -4
- package/dist/{contributions-DatoAzMx.d.ts → contributions-DNMqrAuw.d.cts} +108 -4
- package/dist/index.cjs +2681 -2332
- package/dist/index.d.cts +65 -14
- package/dist/index.d.ts +65 -14
- package/dist/index.js +2 -2
- package/dist/{options-YdiaaVjt.d.cts → options-BaVTMXaO.d.cts} +48 -2
- package/dist/{options-YdiaaVjt.d.ts → options-BaVTMXaO.d.ts} +48 -2
- package/dist/{plugin-CkiStRaI.d.cts → plugin-CN8U2__Q.d.cts} +11 -5
- package/dist/{plugin-BeCMF1VQ.d.ts → plugin-WnvNNJOp.d.ts} +11 -5
- package/dist/plugin.cjs +16 -0
- package/dist/plugin.d.cts +4 -4
- package/dist/plugin.d.ts +4 -4
- package/dist/plugin.js +1 -1
- package/dist/providers/binance.d.cts +2 -2
- package/dist/providers/binance.d.ts +2 -2
- package/dist/providers/coinbase.d.cts +2 -2
- package/dist/providers/coinbase.d.ts +2 -2
- package/dist/providers/hyperliquid.d.cts +2 -2
- package/dist/providers/hyperliquid.d.ts +2 -2
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/vela.global.js +2661 -2312
- package/dist/vela.global.min.js +48 -48
- package/dist/widget.cjs +35658 -34074
- package/dist/widget.d.cts +39 -271
- package/dist/widget.d.ts +39 -271
- package/dist/widget.js +60 -1313
- package/dist/workspace.cjs +1584 -960
- package/dist/workspace.d.cts +111 -15
- package/dist/workspace.d.ts +111 -15
- package/dist/workspace.js +6 -2281
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
# Vela
|
|
2
2
|
|
|
3
3
|
A fast, extensible financial charting library with its own native canvas renderer, a
|
|
4
|
-
headless core, a batteries-included
|
|
4
|
+
headless core, a batteries-included shell, and a plugin SDK for custom chart types and
|
|
5
5
|
renderer layers.
|
|
6
6
|
|
|
7
7
|
- **`vela`** — the headless chart: data model, engines, drawings, providers, native renderer.
|
|
8
|
-
- **`vela/
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
- **`vela/workspace`** — the full chart app: one chart (`layout: false`) or a grid of
|
|
9
|
+
them under one shared topbar (symbol / timeframe / style / indicators), status line,
|
|
10
|
+
watermark, bottom bar (ranges, clock, timezone), object tree, keyboard-first UX,
|
|
11
|
+
named cells, sync groups and one persisted state document.
|
|
12
|
+
- **`vela/ui`** — the component kit the shell is built on: design tokens, overlay chrome
|
|
11
13
|
([Zag.js](https://zagjs.com) menu/dialog/drawer/tooltip), form primitives (switch, select,
|
|
12
14
|
number, text, color, popover), and the `KeymapManager`.
|
|
13
15
|
- **`vela/plugin`** — the extension SDK: chart types, renderer layers, native indicators.
|
|
14
|
-
- **`vela/workspace`** — the multi-chart shell: a grid of full charts under one shared
|
|
15
|
-
topbar, with named cells, sync groups and one persisted state document.
|
|
16
16
|
- **`vela/providers/*`** — data providers (Binance, Coinbase, Hyperliquid).
|
|
17
17
|
|
|
18
18
|
## Quick start
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
|
-
import {
|
|
21
|
+
import { VelaWorkspace } from 'vela/workspace';
|
|
22
22
|
import { BinanceProvider } from 'vela/providers/binance';
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const chart = new VelaWorkspace('#chart', {
|
|
25
|
+
layout: false, // one chart; '2h' | '4' | '8' | … for a multi-chart grid
|
|
25
26
|
symbol: 'BTCUSDT', // bare = first declared provider listing it; 'binance:BTCUSDT' pins the venue
|
|
26
27
|
timeframe: '60',
|
|
27
28
|
live: true,
|
|
28
29
|
theme: 'dark',
|
|
29
30
|
providers: { binance: () => new BinanceProvider() },
|
|
30
|
-
persist: true,
|
|
31
|
-
|
|
32
|
-
urlState: true, // ?symbol=…&interval=… shareable links
|
|
31
|
+
persist: true, // restore the full state document — market, style, timezone, renderer
|
|
32
|
+
// config, drawings and indicators — from localStorage
|
|
33
33
|
});
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -67,11 +67,11 @@ value** — via `handle.context()` (read-only snapshots, worker-safe). See the
|
|
|
67
67
|
[API reference](docs/user/api-reference.md#reading-a-scripts-execution-context), and
|
|
68
68
|
[Scripting engines](docs/user/scripting-engines.md) for the addon and for writing your own.
|
|
69
69
|
|
|
70
|
-
The
|
|
70
|
+
The shell takes an **indicator manifest** — inline JSON, a URL returning it, or an async
|
|
71
71
|
loader (`() => Promise<manifest>`):
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
|
-
new
|
|
74
|
+
new VelaWorkspace('#chart', {
|
|
75
75
|
// …
|
|
76
76
|
engines: { pine: () => new PineEngine() },
|
|
77
77
|
indicators: '/indicators.json', // or an inline [{ name, script | url, language?, enabled? }]
|
|
@@ -82,7 +82,7 @@ new VelaWidget('#chart', {
|
|
|
82
82
|
|
|
83
83
|
Type a **letter** → symbol search. Type a **digit** → timeframe entry (`15`, `4h`, `D`, `3M`…).
|
|
84
84
|
`mod+alt+S` (Ctrl+Alt+S, ⌥⌘S on macOS) → screenshot. `?` → the shortcuts panel. Bindings are declarative
|
|
85
|
-
(`
|
|
85
|
+
(`chart.keymap.register({...})`) — plugins register theirs the same way.
|
|
86
86
|
|
|
87
87
|
## Extending (plugin SDK)
|
|
88
88
|
|
|
@@ -104,14 +104,14 @@ registerRendererLayer({
|
|
|
104
104
|
});
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
A registered chart type automatically appears in the
|
|
107
|
+
A registered chart type automatically appears in the shell's style dropdown; a chart
|
|
108
108
|
type's `dataEngine` pushes to its layer's channel with zero extra wiring. See
|
|
109
109
|
[docs/contributing/plugin-sdk.md](docs/contributing/plugin-sdk.md).
|
|
110
110
|
|
|
111
111
|
## Documentation
|
|
112
112
|
|
|
113
113
|
Full documentation lives in [docs/](docs/index.md) — user guides ([quickstart](docs/user/quickstart.md),
|
|
114
|
-
[the
|
|
114
|
+
[the workspace](docs/user/workspace.md), [options](docs/user/options.md), [API reference](docs/user/api-reference.md)),
|
|
115
115
|
[architecture](docs/architecture/overview.md), and [contributing](docs/contributing/setup.md) guides
|
|
116
116
|
including the [plugin SDK](docs/contributing/plugin-sdk.md).
|
|
117
117
|
|
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface RangePreset {
|
|
6
|
-
/** Button label. */
|
|
7
|
-
id: string;
|
|
8
|
-
/** Timeframe to switch to for this range. */
|
|
9
|
-
tf: string;
|
|
10
|
-
/** The core visible-range preset framed once the chart is ready. */
|
|
11
|
-
preset: VisibleRangePreset;
|
|
12
|
-
/**
|
|
13
|
-
* Bars the window needs AT `tf` — the fetch budget for the rebuild. Without it the
|
|
14
|
-
* chart loads its default depth and the framed window is clipped to whatever
|
|
15
|
-
* history happens to be loaded (a "1D" that only shows 16 hours). Includes a small
|
|
16
|
-
* margin; `ALL` asks for as much history as the provider will serve.
|
|
17
|
-
*/
|
|
18
|
-
bars: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Range chips — each pairs a timeframe, a visible window, and the fetch depth that
|
|
22
|
-
* window needs. Resolutions follow the reference: the shorter the range, the finer the
|
|
23
|
-
* bars (1 day of 1-minute bars … 5 years of weekly bars).
|
|
24
|
-
*/
|
|
25
|
-
declare const RANGE_PRESETS: readonly RangePreset[];
|
|
26
|
-
interface BottombarOptions {
|
|
27
|
-
timezone: string;
|
|
28
|
-
onRange: (preset: RangePreset) => void;
|
|
29
|
-
onTimezone: (zone: string) => void;
|
|
30
|
-
/** RTH/ETH toggled by the user. Fires only while the toggle is ENABLED (see {@link Bottombar.setSession}). */
|
|
31
|
-
onSession?: (session: 'regular' | 'extended') => void;
|
|
32
|
-
onSettingsClick?: () => void;
|
|
33
|
-
}
|
|
34
|
-
declare class Bottombar {
|
|
35
|
-
readonly el: HTMLElement;
|
|
36
|
-
private readonly clockEl;
|
|
37
|
-
private readonly tzLabelEl;
|
|
38
|
-
private readonly tzButton;
|
|
39
|
-
private readonly tzMenu;
|
|
40
|
-
private readonly settingsTip;
|
|
41
|
-
private readonly rangeButtons;
|
|
42
|
-
private readonly sessionButtons;
|
|
43
|
-
private sessionEl;
|
|
44
|
-
private timezone;
|
|
45
|
-
private timer;
|
|
46
|
-
constructor(host: HTMLElement, opts: BottombarOptions);
|
|
47
|
-
setTimezone(zone: string): void;
|
|
48
|
-
/** Highlight (or clear with null) the active range chip — cleared on manual tf changes. */
|
|
49
|
-
setActiveRange(id: string | null): void;
|
|
50
|
-
/**
|
|
51
|
-
* Reflect the ACTIVE chart's session posture. `enabled: false` (a continuous
|
|
52
|
-
* market, or metadata not landed yet) HIDES the toggle entirely — RTH/ETH is
|
|
53
|
-
* meaningless there. Enabled, the chips appear and the active one tracks the
|
|
54
|
-
* chart's current session.
|
|
55
|
-
*/
|
|
56
|
-
setSession(state: {
|
|
57
|
-
session: 'regular' | 'extended';
|
|
58
|
-
enabled: boolean;
|
|
59
|
-
}): void;
|
|
60
|
-
destroy(): void;
|
|
61
|
-
private tzItems;
|
|
62
|
-
private tick;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface IndicatorManifestEntry {
|
|
66
|
-
name: string;
|
|
67
|
-
/** Inline script source (one of script/url required). */
|
|
68
|
-
script?: string;
|
|
69
|
-
/** Fetch the source from here instead (resolved relative to the manifest URL). */
|
|
70
|
-
url?: string;
|
|
71
|
-
/** Engine language (default: the chart's default engine). */
|
|
72
|
-
language?: string;
|
|
73
|
-
/** Add to the chart at startup (default true). Disabled entries only appear in pickers. */
|
|
74
|
-
enabled?: boolean;
|
|
75
|
-
/** Picker grouping (default 'Indicators'). */
|
|
76
|
-
category?: string;
|
|
77
|
-
}
|
|
78
|
-
type IndicatorManifest = IndicatorManifestEntry[] | {
|
|
79
|
-
indicators: IndicatorManifestEntry[];
|
|
80
|
-
};
|
|
81
|
-
/** A manifest entry with its source resolved and ready for `chart.addIndicator`. */
|
|
82
|
-
interface ResolvedIndicator {
|
|
83
|
-
name: string;
|
|
84
|
-
script: string;
|
|
85
|
-
language?: string;
|
|
86
|
-
enabled: boolean;
|
|
87
|
-
category?: string;
|
|
88
|
-
}
|
|
89
|
-
/** An async manifest source — called once at resolution time. The escape hatch for
|
|
90
|
-
* manifests that a URL can't express: a filesystem read, an authenticated API, a
|
|
91
|
-
* bundler dynamic import. A rejection behaves like a failing manifest URL. */
|
|
92
|
-
type IndicatorLoader = () => Promise<IndicatorManifest>;
|
|
93
|
-
/** Load the indicator list: a manifest object, a URL string returning the manifest JSON,
|
|
94
|
-
* or an async loader function returning the manifest. Entries with `url` sources are
|
|
95
|
-
* fetched here too (relative to the manifest URL when there is one). Entries that fail
|
|
96
|
-
* to resolve are dropped with a console warning — one broken script must not take the
|
|
97
|
-
* chart down. */
|
|
98
|
-
declare function resolveIndicators(config: string | IndicatorManifest | IndicatorLoader, fetchImpl?: typeof fetch): Promise<ResolvedIndicator[]>;
|
|
1
|
+
import { D as DataProvider } from './DataProvider-JJq7M2it.js';
|
|
2
|
+
import { S as ScriptingEngine, V as Vela } from './contributions-BqCIsbaP.js';
|
|
3
|
+
import { V as VisibleRangePreset } from './options-BaVTMXaO.js';
|
|
99
4
|
|
|
100
5
|
/** The linkable dimensions. `crosshair` mirrors the pointer time onto same-group
|
|
101
6
|
* cells as GHOST crosshairs (renderers without the optional `setExternalCrosshair`
|
|
@@ -161,6 +66,12 @@ interface CellState {
|
|
|
161
66
|
manifest: string[];
|
|
162
67
|
natives: string[];
|
|
163
68
|
};
|
|
69
|
+
/** Third-party per-chart state, by namespaced key (`'vendor.feature'`) — written and
|
|
70
|
+
* read by registered state-persistence handlers (`registerStatePersistence`, scope
|
|
71
|
+
* `'cell'`). Values are OPAQUE here: the codec preserves entries verbatim — a key
|
|
72
|
+
* whose handler is absent this session still round-trips — and each handler
|
|
73
|
+
* validates its own payload at restore. JSON-serializable values only. */
|
|
74
|
+
ext?: Record<string, unknown>;
|
|
164
75
|
}
|
|
165
76
|
/** One entry of the document's `charts` array: a chart's state plus its cell IDENTITY. */
|
|
166
77
|
interface ChartState extends CellState {
|
|
@@ -191,6 +102,9 @@ interface WorkspaceState {
|
|
|
191
102
|
/** Per-chart state, one entry per SLOT (a single `c1` entry for the widget).
|
|
192
103
|
* Ids are unique — the codec drops id-less entries and keeps the LAST duplicate. */
|
|
193
104
|
charts: ChartState[];
|
|
105
|
+
/** Third-party document-level state, by namespaced key (`'vendor.feature'`) — the
|
|
106
|
+
* `scope: 'global'` counterpart of {@link CellState.ext}, same opacity contract. */
|
|
107
|
+
ext?: Record<string, unknown>;
|
|
194
108
|
}
|
|
195
109
|
declare function encodeState(state: WorkspaceState): string;
|
|
196
110
|
/** Parse + sanitize a persisted payload. Null on anything unusable (wrong version,
|
|
@@ -203,8 +117,43 @@ declare function decodeState(raw: string): WorkspaceState | null;
|
|
|
203
117
|
*/
|
|
204
118
|
declare function sanitizeState(doc: unknown): WorkspaceState | null;
|
|
205
119
|
|
|
206
|
-
|
|
207
|
-
|
|
120
|
+
interface IndicatorManifestEntry {
|
|
121
|
+
name: string;
|
|
122
|
+
/** Inline script source (one of script/url required). */
|
|
123
|
+
script?: string;
|
|
124
|
+
/** Fetch the source from here instead (resolved relative to the manifest URL). */
|
|
125
|
+
url?: string;
|
|
126
|
+
/** Engine language (default: the chart's default engine). */
|
|
127
|
+
language?: string;
|
|
128
|
+
/** Add to the chart at startup (default true). Disabled entries only appear in pickers. */
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
/** Picker grouping (default 'Indicators'). */
|
|
131
|
+
category?: string;
|
|
132
|
+
}
|
|
133
|
+
type IndicatorManifest = IndicatorManifestEntry[] | {
|
|
134
|
+
indicators: IndicatorManifestEntry[];
|
|
135
|
+
};
|
|
136
|
+
/** A manifest entry with its source resolved and ready for `chart.addIndicator`. */
|
|
137
|
+
interface ResolvedIndicator {
|
|
138
|
+
name: string;
|
|
139
|
+
script: string;
|
|
140
|
+
language?: string;
|
|
141
|
+
enabled: boolean;
|
|
142
|
+
category?: string;
|
|
143
|
+
}
|
|
144
|
+
/** An async manifest source — called once at resolution time. The escape hatch for
|
|
145
|
+
* manifests that a URL can't express: a filesystem read, an authenticated API, a
|
|
146
|
+
* bundler dynamic import. A rejection behaves like a failing manifest URL. */
|
|
147
|
+
type IndicatorLoader = () => Promise<IndicatorManifest>;
|
|
148
|
+
/** Load the indicator list: a manifest object, a URL string returning the manifest JSON,
|
|
149
|
+
* or an async loader function returning the manifest. Entries with `url` sources are
|
|
150
|
+
* fetched here too (relative to the manifest URL when there is one). Entries that fail
|
|
151
|
+
* to resolve are dropped with a console warning — one broken script must not take the
|
|
152
|
+
* chart down. */
|
|
153
|
+
declare function resolveIndicators(config: string | IndicatorManifest | IndicatorLoader, fetchImpl?: typeof fetch): Promise<ResolvedIndicator[]>;
|
|
154
|
+
|
|
155
|
+
/** The storage contract BOTH shells persist through (the widget wrapper and the
|
|
156
|
+
* workspace — one name, one shape). Methods may be synchronous or return promises. */
|
|
208
157
|
interface VelaStorage {
|
|
209
158
|
get(key: string): string | null | Promise<string | null>;
|
|
210
159
|
set(key: string, value: string): void | Promise<void>;
|
|
@@ -222,32 +171,6 @@ type WidgetStorage = VelaStorage;
|
|
|
222
171
|
* shell's own key is used as-is (the historical behavior).
|
|
223
172
|
*/
|
|
224
173
|
declare function localStorageAdapter(storageKey?: string): WidgetStorage;
|
|
225
|
-
interface PersistedState {
|
|
226
|
-
symbol?: string;
|
|
227
|
-
timeframe?: string;
|
|
228
|
-
priceStyle?: string;
|
|
229
|
-
timezone?: string;
|
|
230
|
-
bars?: string;
|
|
231
|
-
/** Trading session (`regular` | `extended`) — URL param `session`. */
|
|
232
|
-
session?: string;
|
|
233
|
-
watermark?: string;
|
|
234
|
-
/** Comma-joined favorite drawing-tool types. */
|
|
235
|
-
favorites?: string;
|
|
236
|
-
}
|
|
237
|
-
/** Parse a LEGACY prefs payload (never throws — junk yields `{}`). */
|
|
238
|
-
declare function parsePersisted(raw: string | null): PersistedState;
|
|
239
|
-
/** Load the persisted state — synchronous result for sync storages, else a promise. */
|
|
240
|
-
declare function loadPersisted(storage: WidgetStorage, storageKey: string): PersistedState | Promise<PersistedState>;
|
|
241
|
-
/** Save (fire-and-forget — async adapter failures are the adapter's concern). */
|
|
242
|
-
declare function savePersisted(storage: WidgetStorage, storageKey: string, state: PersistedState): void;
|
|
243
|
-
/**
|
|
244
|
-
* LEGACY migration — convert the widget's pre-unified three-key layout (prefs under
|
|
245
|
-
* the main key, renderer config under `<key>:config`, drawings under `<key>:drawings`)
|
|
246
|
-
* into ONE unified state document (the same format the workspace persists, with a
|
|
247
|
-
* single `c1` cell). Null when the payload holds no usable state. Pure — the caller
|
|
248
|
-
* reads the keys, then rewrites the main key and drops the legacy sub-keys.
|
|
249
|
-
*/
|
|
250
|
-
declare function legacyWidgetState(prefs: PersistedState, rawConfig: string | null, rawDrawings: string | null): WorkspaceState | null;
|
|
251
174
|
|
|
252
175
|
/** What a shell (widget or workspace) accepts BEYOND the chart options themselves. */
|
|
253
176
|
interface VelaShellOptions {
|
|
@@ -332,4 +255,64 @@ declare class WidgetHistory {
|
|
|
332
255
|
private notify;
|
|
333
256
|
}
|
|
334
257
|
|
|
335
|
-
|
|
258
|
+
interface RangePreset {
|
|
259
|
+
/** Button label. */
|
|
260
|
+
id: string;
|
|
261
|
+
/** Timeframe to switch to for this range. */
|
|
262
|
+
tf: string;
|
|
263
|
+
/** The core visible-range preset framed once the chart is ready. */
|
|
264
|
+
preset: VisibleRangePreset;
|
|
265
|
+
/**
|
|
266
|
+
* Bars the window needs AT `tf` — the fetch budget for the rebuild. Without it the
|
|
267
|
+
* chart loads its default depth and the framed window is clipped to whatever
|
|
268
|
+
* history happens to be loaded (a "1D" that only shows 16 hours). Includes a small
|
|
269
|
+
* margin; `ALL` asks for as much history as the provider will serve.
|
|
270
|
+
*/
|
|
271
|
+
bars: number;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Range chips — each pairs a timeframe, a visible window, and the fetch depth that
|
|
275
|
+
* window needs. Resolutions follow the reference: the shorter the range, the finer the
|
|
276
|
+
* bars (1 day of 1-minute bars … 5 years of weekly bars).
|
|
277
|
+
*/
|
|
278
|
+
declare const RANGE_PRESETS: readonly RangePreset[];
|
|
279
|
+
interface BottombarOptions {
|
|
280
|
+
timezone: string;
|
|
281
|
+
onRange: (preset: RangePreset) => void;
|
|
282
|
+
onTimezone: (zone: string) => void;
|
|
283
|
+
/** RTH/ETH toggled by the user. Fires only while the toggle is ENABLED (see {@link Bottombar.setSession}). */
|
|
284
|
+
onSession?: (session: 'regular' | 'extended') => void;
|
|
285
|
+
onSettingsClick?: () => void;
|
|
286
|
+
}
|
|
287
|
+
declare class Bottombar {
|
|
288
|
+
readonly el: HTMLElement;
|
|
289
|
+
private readonly clockEl;
|
|
290
|
+
private readonly tzLabelEl;
|
|
291
|
+
private readonly tzButton;
|
|
292
|
+
private readonly tzMenu;
|
|
293
|
+
private readonly settingsTip;
|
|
294
|
+
private readonly rangeButtons;
|
|
295
|
+
private readonly sessionButtons;
|
|
296
|
+
private sessionEl;
|
|
297
|
+
private timezone;
|
|
298
|
+
private timer;
|
|
299
|
+
constructor(host: HTMLElement, opts: BottombarOptions);
|
|
300
|
+
setTimezone(zone: string): void;
|
|
301
|
+
/** Highlight (or clear with null) the active range chip — cleared on manual tf changes. */
|
|
302
|
+
setActiveRange(id: string | null): void;
|
|
303
|
+
/**
|
|
304
|
+
* Reflect the ACTIVE chart's session posture. `enabled: false` (a continuous
|
|
305
|
+
* market, or metadata not landed yet) HIDES the toggle entirely — RTH/ETH is
|
|
306
|
+
* meaningless there. Enabled, the chips appear and the active one tracks the
|
|
307
|
+
* chart's current session.
|
|
308
|
+
*/
|
|
309
|
+
setSession(state: {
|
|
310
|
+
session: 'regular' | 'extended';
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
}): void;
|
|
313
|
+
destroy(): void;
|
|
314
|
+
private tzItems;
|
|
315
|
+
private tick;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export { Bottombar as B, type CellState as C, type IndicatorLoader as I, type PanelsState as P, type ResolvedIndicator as R, type SyncSetting as S, type TrackSizes as T, type VelaStorage as V, WidgetHistory as W, type RangePreset as a, type VelaShellOptions as b, type SyncOptions as c, type SyncKind as d, type WorkspaceState as e, type ChartState as f, decodeState as g, encodeState as h, type BottombarOptions as i, type IndicatorManifest as j, type IndicatorManifestEntry as k, RANGE_PRESETS as l, type WidgetStorage as m, localStorageAdapter as n, resolveIndicators as r, sanitizeState as s };
|
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface RangePreset {
|
|
6
|
-
/** Button label. */
|
|
7
|
-
id: string;
|
|
8
|
-
/** Timeframe to switch to for this range. */
|
|
9
|
-
tf: string;
|
|
10
|
-
/** The core visible-range preset framed once the chart is ready. */
|
|
11
|
-
preset: VisibleRangePreset;
|
|
12
|
-
/**
|
|
13
|
-
* Bars the window needs AT `tf` — the fetch budget for the rebuild. Without it the
|
|
14
|
-
* chart loads its default depth and the framed window is clipped to whatever
|
|
15
|
-
* history happens to be loaded (a "1D" that only shows 16 hours). Includes a small
|
|
16
|
-
* margin; `ALL` asks for as much history as the provider will serve.
|
|
17
|
-
*/
|
|
18
|
-
bars: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Range chips — each pairs a timeframe, a visible window, and the fetch depth that
|
|
22
|
-
* window needs. Resolutions follow the reference: the shorter the range, the finer the
|
|
23
|
-
* bars (1 day of 1-minute bars … 5 years of weekly bars).
|
|
24
|
-
*/
|
|
25
|
-
declare const RANGE_PRESETS: readonly RangePreset[];
|
|
26
|
-
interface BottombarOptions {
|
|
27
|
-
timezone: string;
|
|
28
|
-
onRange: (preset: RangePreset) => void;
|
|
29
|
-
onTimezone: (zone: string) => void;
|
|
30
|
-
/** RTH/ETH toggled by the user. Fires only while the toggle is ENABLED (see {@link Bottombar.setSession}). */
|
|
31
|
-
onSession?: (session: 'regular' | 'extended') => void;
|
|
32
|
-
onSettingsClick?: () => void;
|
|
33
|
-
}
|
|
34
|
-
declare class Bottombar {
|
|
35
|
-
readonly el: HTMLElement;
|
|
36
|
-
private readonly clockEl;
|
|
37
|
-
private readonly tzLabelEl;
|
|
38
|
-
private readonly tzButton;
|
|
39
|
-
private readonly tzMenu;
|
|
40
|
-
private readonly settingsTip;
|
|
41
|
-
private readonly rangeButtons;
|
|
42
|
-
private readonly sessionButtons;
|
|
43
|
-
private sessionEl;
|
|
44
|
-
private timezone;
|
|
45
|
-
private timer;
|
|
46
|
-
constructor(host: HTMLElement, opts: BottombarOptions);
|
|
47
|
-
setTimezone(zone: string): void;
|
|
48
|
-
/** Highlight (or clear with null) the active range chip — cleared on manual tf changes. */
|
|
49
|
-
setActiveRange(id: string | null): void;
|
|
50
|
-
/**
|
|
51
|
-
* Reflect the ACTIVE chart's session posture. `enabled: false` (a continuous
|
|
52
|
-
* market, or metadata not landed yet) HIDES the toggle entirely — RTH/ETH is
|
|
53
|
-
* meaningless there. Enabled, the chips appear and the active one tracks the
|
|
54
|
-
* chart's current session.
|
|
55
|
-
*/
|
|
56
|
-
setSession(state: {
|
|
57
|
-
session: 'regular' | 'extended';
|
|
58
|
-
enabled: boolean;
|
|
59
|
-
}): void;
|
|
60
|
-
destroy(): void;
|
|
61
|
-
private tzItems;
|
|
62
|
-
private tick;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface IndicatorManifestEntry {
|
|
66
|
-
name: string;
|
|
67
|
-
/** Inline script source (one of script/url required). */
|
|
68
|
-
script?: string;
|
|
69
|
-
/** Fetch the source from here instead (resolved relative to the manifest URL). */
|
|
70
|
-
url?: string;
|
|
71
|
-
/** Engine language (default: the chart's default engine). */
|
|
72
|
-
language?: string;
|
|
73
|
-
/** Add to the chart at startup (default true). Disabled entries only appear in pickers. */
|
|
74
|
-
enabled?: boolean;
|
|
75
|
-
/** Picker grouping (default 'Indicators'). */
|
|
76
|
-
category?: string;
|
|
77
|
-
}
|
|
78
|
-
type IndicatorManifest = IndicatorManifestEntry[] | {
|
|
79
|
-
indicators: IndicatorManifestEntry[];
|
|
80
|
-
};
|
|
81
|
-
/** A manifest entry with its source resolved and ready for `chart.addIndicator`. */
|
|
82
|
-
interface ResolvedIndicator {
|
|
83
|
-
name: string;
|
|
84
|
-
script: string;
|
|
85
|
-
language?: string;
|
|
86
|
-
enabled: boolean;
|
|
87
|
-
category?: string;
|
|
88
|
-
}
|
|
89
|
-
/** An async manifest source — called once at resolution time. The escape hatch for
|
|
90
|
-
* manifests that a URL can't express: a filesystem read, an authenticated API, a
|
|
91
|
-
* bundler dynamic import. A rejection behaves like a failing manifest URL. */
|
|
92
|
-
type IndicatorLoader = () => Promise<IndicatorManifest>;
|
|
93
|
-
/** Load the indicator list: a manifest object, a URL string returning the manifest JSON,
|
|
94
|
-
* or an async loader function returning the manifest. Entries with `url` sources are
|
|
95
|
-
* fetched here too (relative to the manifest URL when there is one). Entries that fail
|
|
96
|
-
* to resolve are dropped with a console warning — one broken script must not take the
|
|
97
|
-
* chart down. */
|
|
98
|
-
declare function resolveIndicators(config: string | IndicatorManifest | IndicatorLoader, fetchImpl?: typeof fetch): Promise<ResolvedIndicator[]>;
|
|
1
|
+
import { D as DataProvider } from './DataProvider-DDUYw2qP.cjs';
|
|
2
|
+
import { S as ScriptingEngine, V as Vela } from './contributions-DNMqrAuw.cjs';
|
|
3
|
+
import { V as VisibleRangePreset } from './options-BaVTMXaO.cjs';
|
|
99
4
|
|
|
100
5
|
/** The linkable dimensions. `crosshair` mirrors the pointer time onto same-group
|
|
101
6
|
* cells as GHOST crosshairs (renderers without the optional `setExternalCrosshair`
|
|
@@ -161,6 +66,12 @@ interface CellState {
|
|
|
161
66
|
manifest: string[];
|
|
162
67
|
natives: string[];
|
|
163
68
|
};
|
|
69
|
+
/** Third-party per-chart state, by namespaced key (`'vendor.feature'`) — written and
|
|
70
|
+
* read by registered state-persistence handlers (`registerStatePersistence`, scope
|
|
71
|
+
* `'cell'`). Values are OPAQUE here: the codec preserves entries verbatim — a key
|
|
72
|
+
* whose handler is absent this session still round-trips — and each handler
|
|
73
|
+
* validates its own payload at restore. JSON-serializable values only. */
|
|
74
|
+
ext?: Record<string, unknown>;
|
|
164
75
|
}
|
|
165
76
|
/** One entry of the document's `charts` array: a chart's state plus its cell IDENTITY. */
|
|
166
77
|
interface ChartState extends CellState {
|
|
@@ -191,6 +102,9 @@ interface WorkspaceState {
|
|
|
191
102
|
/** Per-chart state, one entry per SLOT (a single `c1` entry for the widget).
|
|
192
103
|
* Ids are unique — the codec drops id-less entries and keeps the LAST duplicate. */
|
|
193
104
|
charts: ChartState[];
|
|
105
|
+
/** Third-party document-level state, by namespaced key (`'vendor.feature'`) — the
|
|
106
|
+
* `scope: 'global'` counterpart of {@link CellState.ext}, same opacity contract. */
|
|
107
|
+
ext?: Record<string, unknown>;
|
|
194
108
|
}
|
|
195
109
|
declare function encodeState(state: WorkspaceState): string;
|
|
196
110
|
/** Parse + sanitize a persisted payload. Null on anything unusable (wrong version,
|
|
@@ -203,8 +117,43 @@ declare function decodeState(raw: string): WorkspaceState | null;
|
|
|
203
117
|
*/
|
|
204
118
|
declare function sanitizeState(doc: unknown): WorkspaceState | null;
|
|
205
119
|
|
|
206
|
-
|
|
207
|
-
|
|
120
|
+
interface IndicatorManifestEntry {
|
|
121
|
+
name: string;
|
|
122
|
+
/** Inline script source (one of script/url required). */
|
|
123
|
+
script?: string;
|
|
124
|
+
/** Fetch the source from here instead (resolved relative to the manifest URL). */
|
|
125
|
+
url?: string;
|
|
126
|
+
/** Engine language (default: the chart's default engine). */
|
|
127
|
+
language?: string;
|
|
128
|
+
/** Add to the chart at startup (default true). Disabled entries only appear in pickers. */
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
/** Picker grouping (default 'Indicators'). */
|
|
131
|
+
category?: string;
|
|
132
|
+
}
|
|
133
|
+
type IndicatorManifest = IndicatorManifestEntry[] | {
|
|
134
|
+
indicators: IndicatorManifestEntry[];
|
|
135
|
+
};
|
|
136
|
+
/** A manifest entry with its source resolved and ready for `chart.addIndicator`. */
|
|
137
|
+
interface ResolvedIndicator {
|
|
138
|
+
name: string;
|
|
139
|
+
script: string;
|
|
140
|
+
language?: string;
|
|
141
|
+
enabled: boolean;
|
|
142
|
+
category?: string;
|
|
143
|
+
}
|
|
144
|
+
/** An async manifest source — called once at resolution time. The escape hatch for
|
|
145
|
+
* manifests that a URL can't express: a filesystem read, an authenticated API, a
|
|
146
|
+
* bundler dynamic import. A rejection behaves like a failing manifest URL. */
|
|
147
|
+
type IndicatorLoader = () => Promise<IndicatorManifest>;
|
|
148
|
+
/** Load the indicator list: a manifest object, a URL string returning the manifest JSON,
|
|
149
|
+
* or an async loader function returning the manifest. Entries with `url` sources are
|
|
150
|
+
* fetched here too (relative to the manifest URL when there is one). Entries that fail
|
|
151
|
+
* to resolve are dropped with a console warning — one broken script must not take the
|
|
152
|
+
* chart down. */
|
|
153
|
+
declare function resolveIndicators(config: string | IndicatorManifest | IndicatorLoader, fetchImpl?: typeof fetch): Promise<ResolvedIndicator[]>;
|
|
154
|
+
|
|
155
|
+
/** The storage contract BOTH shells persist through (the widget wrapper and the
|
|
156
|
+
* workspace — one name, one shape). Methods may be synchronous or return promises. */
|
|
208
157
|
interface VelaStorage {
|
|
209
158
|
get(key: string): string | null | Promise<string | null>;
|
|
210
159
|
set(key: string, value: string): void | Promise<void>;
|
|
@@ -222,32 +171,6 @@ type WidgetStorage = VelaStorage;
|
|
|
222
171
|
* shell's own key is used as-is (the historical behavior).
|
|
223
172
|
*/
|
|
224
173
|
declare function localStorageAdapter(storageKey?: string): WidgetStorage;
|
|
225
|
-
interface PersistedState {
|
|
226
|
-
symbol?: string;
|
|
227
|
-
timeframe?: string;
|
|
228
|
-
priceStyle?: string;
|
|
229
|
-
timezone?: string;
|
|
230
|
-
bars?: string;
|
|
231
|
-
/** Trading session (`regular` | `extended`) — URL param `session`. */
|
|
232
|
-
session?: string;
|
|
233
|
-
watermark?: string;
|
|
234
|
-
/** Comma-joined favorite drawing-tool types. */
|
|
235
|
-
favorites?: string;
|
|
236
|
-
}
|
|
237
|
-
/** Parse a LEGACY prefs payload (never throws — junk yields `{}`). */
|
|
238
|
-
declare function parsePersisted(raw: string | null): PersistedState;
|
|
239
|
-
/** Load the persisted state — synchronous result for sync storages, else a promise. */
|
|
240
|
-
declare function loadPersisted(storage: WidgetStorage, storageKey: string): PersistedState | Promise<PersistedState>;
|
|
241
|
-
/** Save (fire-and-forget — async adapter failures are the adapter's concern). */
|
|
242
|
-
declare function savePersisted(storage: WidgetStorage, storageKey: string, state: PersistedState): void;
|
|
243
|
-
/**
|
|
244
|
-
* LEGACY migration — convert the widget's pre-unified three-key layout (prefs under
|
|
245
|
-
* the main key, renderer config under `<key>:config`, drawings under `<key>:drawings`)
|
|
246
|
-
* into ONE unified state document (the same format the workspace persists, with a
|
|
247
|
-
* single `c1` cell). Null when the payload holds no usable state. Pure — the caller
|
|
248
|
-
* reads the keys, then rewrites the main key and drops the legacy sub-keys.
|
|
249
|
-
*/
|
|
250
|
-
declare function legacyWidgetState(prefs: PersistedState, rawConfig: string | null, rawDrawings: string | null): WorkspaceState | null;
|
|
251
174
|
|
|
252
175
|
/** What a shell (widget or workspace) accepts BEYOND the chart options themselves. */
|
|
253
176
|
interface VelaShellOptions {
|
|
@@ -332,4 +255,64 @@ declare class WidgetHistory {
|
|
|
332
255
|
private notify;
|
|
333
256
|
}
|
|
334
257
|
|
|
335
|
-
|
|
258
|
+
interface RangePreset {
|
|
259
|
+
/** Button label. */
|
|
260
|
+
id: string;
|
|
261
|
+
/** Timeframe to switch to for this range. */
|
|
262
|
+
tf: string;
|
|
263
|
+
/** The core visible-range preset framed once the chart is ready. */
|
|
264
|
+
preset: VisibleRangePreset;
|
|
265
|
+
/**
|
|
266
|
+
* Bars the window needs AT `tf` — the fetch budget for the rebuild. Without it the
|
|
267
|
+
* chart loads its default depth and the framed window is clipped to whatever
|
|
268
|
+
* history happens to be loaded (a "1D" that only shows 16 hours). Includes a small
|
|
269
|
+
* margin; `ALL` asks for as much history as the provider will serve.
|
|
270
|
+
*/
|
|
271
|
+
bars: number;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Range chips — each pairs a timeframe, a visible window, and the fetch depth that
|
|
275
|
+
* window needs. Resolutions follow the reference: the shorter the range, the finer the
|
|
276
|
+
* bars (1 day of 1-minute bars … 5 years of weekly bars).
|
|
277
|
+
*/
|
|
278
|
+
declare const RANGE_PRESETS: readonly RangePreset[];
|
|
279
|
+
interface BottombarOptions {
|
|
280
|
+
timezone: string;
|
|
281
|
+
onRange: (preset: RangePreset) => void;
|
|
282
|
+
onTimezone: (zone: string) => void;
|
|
283
|
+
/** RTH/ETH toggled by the user. Fires only while the toggle is ENABLED (see {@link Bottombar.setSession}). */
|
|
284
|
+
onSession?: (session: 'regular' | 'extended') => void;
|
|
285
|
+
onSettingsClick?: () => void;
|
|
286
|
+
}
|
|
287
|
+
declare class Bottombar {
|
|
288
|
+
readonly el: HTMLElement;
|
|
289
|
+
private readonly clockEl;
|
|
290
|
+
private readonly tzLabelEl;
|
|
291
|
+
private readonly tzButton;
|
|
292
|
+
private readonly tzMenu;
|
|
293
|
+
private readonly settingsTip;
|
|
294
|
+
private readonly rangeButtons;
|
|
295
|
+
private readonly sessionButtons;
|
|
296
|
+
private sessionEl;
|
|
297
|
+
private timezone;
|
|
298
|
+
private timer;
|
|
299
|
+
constructor(host: HTMLElement, opts: BottombarOptions);
|
|
300
|
+
setTimezone(zone: string): void;
|
|
301
|
+
/** Highlight (or clear with null) the active range chip — cleared on manual tf changes. */
|
|
302
|
+
setActiveRange(id: string | null): void;
|
|
303
|
+
/**
|
|
304
|
+
* Reflect the ACTIVE chart's session posture. `enabled: false` (a continuous
|
|
305
|
+
* market, or metadata not landed yet) HIDES the toggle entirely — RTH/ETH is
|
|
306
|
+
* meaningless there. Enabled, the chips appear and the active one tracks the
|
|
307
|
+
* chart's current session.
|
|
308
|
+
*/
|
|
309
|
+
setSession(state: {
|
|
310
|
+
session: 'regular' | 'extended';
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
}): void;
|
|
313
|
+
destroy(): void;
|
|
314
|
+
private tzItems;
|
|
315
|
+
private tick;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export { Bottombar as B, type CellState as C, type IndicatorLoader as I, type PanelsState as P, type ResolvedIndicator as R, type SyncSetting as S, type TrackSizes as T, type VelaStorage as V, WidgetHistory as W, type RangePreset as a, type VelaShellOptions as b, type SyncOptions as c, type SyncKind as d, type WorkspaceState as e, type ChartState as f, decodeState as g, encodeState as h, type BottombarOptions as i, type IndicatorManifest as j, type IndicatorManifestEntry as k, RANGE_PRESETS as l, type WidgetStorage as m, localStorageAdapter as n, resolveIndicators as r, sanitizeState as s };
|