@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Millis, ae as InputSchema, ac as IndicatorMeta, P as PriceStyle, O as OHLCV, m as InputValue, k as IndicatorModel, j as MoveTarget,
|
|
2
|
-
import { S as SymbolInfo, B as BarRange, M as MarketDataFeed, D as DataProvider, P as ProviderInfo, a as SymbolDescriptor, b as ProviderCapabilities } from './DataProvider-
|
|
1
|
+
import { t as Millis, ae as InputSchema, ac as IndicatorMeta, P as PriceStyle, O as OHLCV, m as InputValue, k as IndicatorModel, j as MoveTarget, aq as PaneAxis, aD as SeriesSpec, aa as Fill, B as Background, av as PriceLine, a0 as DrawingLine, Y as DrawingBox, $ as DrawingLabel, a4 as DrawingPolyline, a1 as DrawingLinefill, a6 as DrawingTable, g as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, v as DrawingTypeKey, u as SnapMode, a2 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, o as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, r as DataWindowReadout, n as SymbolPickerFn, aR as PaneInfo, a9 as DrawingsOption, D as Drawing, b as VelaOptions, x as AddIndicatorOptions, ap as MarketSwitch, ao as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-BaVTMXaO.js';
|
|
2
|
+
import { S as SymbolInfo, B as BarRange, M as MarketDataFeed, D as DataProvider, P as ProviderInfo, a as SymbolDescriptor, b as ProviderCapabilities } from './DataProvider-JJq7M2it.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A strategy's broker state at ONE bar — the flat summary a host reads while a script
|
|
@@ -382,6 +382,13 @@ declare class DataControl {
|
|
|
382
382
|
* columns — instead pushes its payload through the dedicated renderer seam, `pushData`.)
|
|
383
383
|
*/
|
|
384
384
|
interface NativeIndicatorOutput {
|
|
385
|
+
/**
|
|
386
|
+
* Value-axis override for the pane this native OWNS (see `IndicatorModel.paneAxis`):
|
|
387
|
+
* `'none'` for content that is not value-mapped, or band labels for a categorical
|
|
388
|
+
* axis. Emitted per compute, so it can follow the inputs (e.g. row toggles relabel
|
|
389
|
+
* the axis). Absent ⇒ the pane derives a scale from its content as usual.
|
|
390
|
+
*/
|
|
391
|
+
paneAxis?: PaneAxis;
|
|
385
392
|
series?: SeriesSpec[];
|
|
386
393
|
fills?: Fill[];
|
|
387
394
|
backgrounds?: Background[];
|
|
@@ -753,7 +760,11 @@ interface VelaEventMap extends Record<string, unknown> {
|
|
|
753
760
|
oldestTime: number;
|
|
754
761
|
barsLoaded: number;
|
|
755
762
|
};
|
|
756
|
-
alert
|
|
763
|
+
/** An indicator's script raised an alert. `indicator` names the source — the
|
|
764
|
+
* indicator's display title (what its legend row shows). */
|
|
765
|
+
alert: EngineAlert & {
|
|
766
|
+
indicator?: string;
|
|
767
|
+
};
|
|
757
768
|
warning: EngineWarning;
|
|
758
769
|
}
|
|
759
770
|
|
|
@@ -928,7 +939,23 @@ declare class RendererControl {
|
|
|
928
939
|
setSettingsSections(sections: ReadonlyArray<{
|
|
929
940
|
title: string;
|
|
930
941
|
rows: readonly unknown[];
|
|
942
|
+
id?: string;
|
|
931
943
|
}>): this;
|
|
944
|
+
/**
|
|
945
|
+
* Set the settings-dialog visibility policy: `hidden` lists setting ids to hide —
|
|
946
|
+
* a tab (`'canvas'`), a group (`'canvas.grid'`), or a single row
|
|
947
|
+
* (`'canvas.grid.vertical'`); an id hides its whole subtree, and a tab with nothing
|
|
948
|
+
* left disappears from the rail. Presentation-only: hidden values keep being stored
|
|
949
|
+
* and applied (e.g. hide `'advanced'` while forcing the widget's `bars` option).
|
|
950
|
+
* Seeded from `VelaOptions.settings`; silent no-op without a settings dialog.
|
|
951
|
+
*/
|
|
952
|
+
setSettingsVisibility(policy: {
|
|
953
|
+
hidden?: readonly string[];
|
|
954
|
+
}): this;
|
|
955
|
+
/** Every addressable setting id of this chart (built-in tabs/groups/rows, chart-type
|
|
956
|
+
* sections, host sections) — enumerate these to build a `hidden` list instead of
|
|
957
|
+
* reading contributor source. Empty on a renderer without a settings dialog. */
|
|
958
|
+
listSettingsIds(): string[];
|
|
932
959
|
/** Tell the renderer's own chrome which size class the host shell is in —
|
|
933
960
|
* `'mobile'` switches its dialogs/toolbars to the touch-first presentation.
|
|
934
961
|
* Silent no-op on a renderer without adaptive chrome. */
|
|
@@ -1425,6 +1452,28 @@ interface WidgetContext {
|
|
|
1425
1452
|
host: HTMLElement;
|
|
1426
1453
|
/** The widget's feedback pill (bottom-center, auto-hides). */
|
|
1427
1454
|
toast(message: string, kind?: 'info' | 'success' | 'error'): void;
|
|
1455
|
+
/** Add a SCRIPT indicator to the active chart THROUGH THE SHELL — unlike the raw
|
|
1456
|
+
* `chart.addIndicator`, the addition enters the unified undo/redo timeline, the
|
|
1457
|
+
* topbar indicator count, and the shell's bookkeeping. The entry's source rides the
|
|
1458
|
+
* recorded action, so redo re-adds it even after the original handle died. The
|
|
1459
|
+
* shell does NOT persist these across reloads (they are not manifest entries) —
|
|
1460
|
+
* a plugin that wants them back owns that via {@link registerStatePersistence}. */
|
|
1461
|
+
addIndicator(entry: ExternalIndicatorEntry): void;
|
|
1462
|
+
/** Add a native (core-computed) indicator to the active chart through the shell —
|
|
1463
|
+
* recorded in the undo/redo timeline, unlike the raw `chart.addNativeIndicator`. */
|
|
1464
|
+
addNativeIndicator(type: string): void;
|
|
1465
|
+
/** Tell the shell some PERSISTABLE third-party state changed (a debounced
|
|
1466
|
+
* `state:changed` + storage write follows). Only needed for state with no shell
|
|
1467
|
+
* event of its own — indicator adds/removals already trigger the save cycle. */
|
|
1468
|
+
stateChanged(): void;
|
|
1469
|
+
}
|
|
1470
|
+
/** What {@link WidgetContext.addIndicator} takes: a named script, ready to run. */
|
|
1471
|
+
interface ExternalIndicatorEntry {
|
|
1472
|
+
name: string;
|
|
1473
|
+
/** The script source (the recorded undo/redo action re-adds from it). */
|
|
1474
|
+
script: string;
|
|
1475
|
+
/** Engine language (default: the chart's default engine). */
|
|
1476
|
+
language?: string;
|
|
1428
1477
|
}
|
|
1429
1478
|
/** Where an action is projected. */
|
|
1430
1479
|
type WidgetActionTarget = 'topbar' | 'context:body' | 'context:price-axis' | 'context:time-axis';
|
|
@@ -1565,6 +1614,61 @@ declare function registerLegendAction(desc: LegendActionDescriptor): () => void;
|
|
|
1565
1614
|
declare function unregisterLegendAction(id: string): void;
|
|
1566
1615
|
/** Every registered legend action, `order`-sorted (registration order breaks ties). */
|
|
1567
1616
|
declare function legendActions(): LegendActionDescriptor[];
|
|
1617
|
+
/**
|
|
1618
|
+
* The surface a `scope: 'cell'` persistence handler works against — bound to ONE cell
|
|
1619
|
+
* (never the active one by proxy), because serialize/restore run per cell, including
|
|
1620
|
+
* cells that are not active. `addIndicator`/`addNativeIndicator` target THIS cell and
|
|
1621
|
+
* are ALWAYS muted — unlike their {@link WidgetContext} namesakes they never enter the
|
|
1622
|
+
* undo timeline, even from an async `restore` continuation (fetch, then add): applying
|
|
1623
|
+
* a document is state application, not a user edit.
|
|
1624
|
+
*/
|
|
1625
|
+
interface CellStateContext {
|
|
1626
|
+
/** The cell's durable identity (`'c1'`, a declared name). */
|
|
1627
|
+
cellId: string;
|
|
1628
|
+
/** The cell's LIVE chart. */
|
|
1629
|
+
chart: Vela;
|
|
1630
|
+
/** Add a script indicator to THIS cell through the shell (see {@link WidgetContext.addIndicator}). */
|
|
1631
|
+
addIndicator(entry: ExternalIndicatorEntry): void;
|
|
1632
|
+
/** Add a native indicator to THIS cell through the shell. */
|
|
1633
|
+
addNativeIndicator(type: string): void;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* A third-party STATE PERSISTENCE handler — how a plugin puts its own state into the
|
|
1637
|
+
* shell's persisted document (the `ext` bag of `WorkspaceState` / per-chart state)
|
|
1638
|
+
* instead of running a parallel store. `key` is namespaced (`'vendor.feature'`) and
|
|
1639
|
+
* flat — one entry per handler. `serialize` runs on every shell snapshot (`getState`,
|
|
1640
|
+
* the persist write) and returns a JSON-serializable payload, or `undefined` for "no
|
|
1641
|
+
* entry". `restore` runs when a document carrying the key is applied (boot restore,
|
|
1642
|
+
* `applyState`) — AFTER the core state (chart alive, engines registered, indicator
|
|
1643
|
+
* ledger converged) and, for cell scope, inside the cell's history-mute, so nothing it
|
|
1644
|
+
* does enters undo/redo. The payload is UNTRUSTED (the codec passes `ext` through
|
|
1645
|
+
* opaquely): validate it. `restore` is only called for keys present in the document.
|
|
1646
|
+
*
|
|
1647
|
+
* Register at import time, before shells are constructed — the rule every contribution
|
|
1648
|
+
* registry shares. A key with no registered handler still round-trips verbatim, so a
|
|
1649
|
+
* session without the plugin never loses its state.
|
|
1650
|
+
*/
|
|
1651
|
+
type StatePersistenceHandler = {
|
|
1652
|
+
/** Namespaced entry key (`'velapro.indicators'`) — re-registering a key replaces it. */
|
|
1653
|
+
key: string;
|
|
1654
|
+
/** Where the entry lives: per chart (`charts[i].ext`) — follows the cell through pool/layout moves. */
|
|
1655
|
+
scope: 'cell';
|
|
1656
|
+
serialize(ctx: CellStateContext): unknown;
|
|
1657
|
+
restore(payload: unknown, ctx: CellStateContext): void;
|
|
1658
|
+
} | {
|
|
1659
|
+
key: string;
|
|
1660
|
+
/** Document root (`state.ext`) — one entry per document, whatever the grid. */
|
|
1661
|
+
scope: 'global';
|
|
1662
|
+
serialize(ctx: WidgetContext): unknown;
|
|
1663
|
+
restore(payload: unknown, ctx: WidgetContext): void;
|
|
1664
|
+
};
|
|
1665
|
+
/** Register (or replace) a state-persistence handler. Returns an unregister disposer. */
|
|
1666
|
+
declare function registerStatePersistence(handler: StatePersistenceHandler): () => void;
|
|
1667
|
+
declare function unregisterStatePersistence(key: string): void;
|
|
1668
|
+
/** The registered handlers of one scope (registration order). */
|
|
1669
|
+
declare function statePersistenceHandlers<S extends StatePersistenceHandler['scope']>(scope: S): Array<Extract<StatePersistenceHandler, {
|
|
1670
|
+
scope: S;
|
|
1671
|
+
}>>;
|
|
1568
1672
|
/** Makes ONE engine instance for ONE chart — engines hold per-chart sessions (and
|
|
1569
1673
|
* possibly a worker), so the shell calls the factory per chart build, never shares. */
|
|
1570
1674
|
type EngineFactory = () => ScriptingEngine;
|
|
@@ -1582,4 +1686,4 @@ declare function unregisterDefaultEngine(language: string): void;
|
|
|
1582
1686
|
* language. The shell layers (widget, workspace cell) register exactly this result. */
|
|
1583
1687
|
declare function resolveEngines(overrides?: Record<string, EngineFactory>): Record<string, EngineFactory>;
|
|
1584
1688
|
|
|
1585
|
-
export {
|
|
1689
|
+
export { type WidgetAttachment as $, type SidePanelButton as A, type BarsChangeReason as B, type CellStateContext as C, type DrawingsDocument as D, type ExternalIndicatorEntry as E, type FetchSeries as F, type SidePanelDescriptor as G, type SidePanelHandle as H, type IndicatorHandle as I, type SidePanelHeader as J, type StatePersistenceHandler as K, type LegendActionDescriptor as L, type StrategyFill as M, type NativeIndicator as N, type StrategyState as O, type ParsedSymbol as P, type StrategyTrade as Q, type Resolved as R, type ScriptingEngine as S, TypedEventBus as T, type VelaDeps as U, Vela as V, type WidgetContext as W, type VelaEventMap as X, type VisibleBarRange as Y, type WidgetActionDescriptor as Z, type WidgetActionTarget as _, type ScriptRun as a, getNativeIndicator as a0, legendActions as a1, nativeIndicatorDescriptors as a2, nativeIndicatorTypes as a3, registerDefaultEngine as a4, registerLegendAction as a5, registerNativeIndicator as a6, registerSidePanel as a7, registerStatePersistence as a8, registerWidgetAction as a9, registerWidgetAttachment as aa, resolveEngines as ab, sidePanels as ac, statePersistenceHandlers as ad, unregisterDefaultEngine as ae, unregisterLegendAction as af, unregisterNativeIndicator as ag, unregisterSidePanel as ah, unregisterStatePersistence as ai, unregisterWidgetAction as aj, unregisterWidgetAttachment as ak, widgetActions as al, widgetAttachments as am, DEFAULT_PANEL_ORDER as an, type ContextSelect as b, DataControl as c, DrawingsControl as d, type EngineAlert as e, type EngineCapabilities as f, type EngineContextSnapshot as g, type EngineFactory as h, type EngineWarning as i, type ExecutionHandlers as j, type ExecutionMarket as k, type ExecutionRequest as l, type ExecutionSession as m, type IndicatorEventMap as n, type IndicatorSummary as o, type LegendIndicatorInfo as p, type NativeIndicatorContext as q, type NativeIndicatorDescriptor as r, type NativeIndicatorInfo as s, type NativeIndicatorOutput as t, type PreparedScript as u, RendererControl as v, type RunIndicatorResult as w, type SceneInspection as x, type ScriptRunCause as y, type ScriptRunResult as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Millis, ae as InputSchema, ac as IndicatorMeta, P as PriceStyle, O as OHLCV, m as InputValue, k as IndicatorModel, j as MoveTarget,
|
|
2
|
-
import { S as SymbolInfo, B as BarRange, M as MarketDataFeed, D as DataProvider, P as ProviderInfo, a as SymbolDescriptor, b as ProviderCapabilities } from './DataProvider-
|
|
1
|
+
import { t as Millis, ae as InputSchema, ac as IndicatorMeta, P as PriceStyle, O as OHLCV, m as InputValue, k as IndicatorModel, j as MoveTarget, aq as PaneAxis, aD as SeriesSpec, aa as Fill, B as Background, av as PriceLine, a0 as DrawingLine, Y as DrawingBox, $ as DrawingLabel, a4 as DrawingPolyline, a1 as DrawingLinefill, a6 as DrawingTable, g as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, v as DrawingTypeKey, u as SnapMode, a2 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, o as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, r as DataWindowReadout, n as SymbolPickerFn, aR as PaneInfo, a9 as DrawingsOption, D as Drawing, b as VelaOptions, x as AddIndicatorOptions, ap as MarketSwitch, ao as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-BaVTMXaO.cjs';
|
|
2
|
+
import { S as SymbolInfo, B as BarRange, M as MarketDataFeed, D as DataProvider, P as ProviderInfo, a as SymbolDescriptor, b as ProviderCapabilities } from './DataProvider-DDUYw2qP.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A strategy's broker state at ONE bar — the flat summary a host reads while a script
|
|
@@ -382,6 +382,13 @@ declare class DataControl {
|
|
|
382
382
|
* columns — instead pushes its payload through the dedicated renderer seam, `pushData`.)
|
|
383
383
|
*/
|
|
384
384
|
interface NativeIndicatorOutput {
|
|
385
|
+
/**
|
|
386
|
+
* Value-axis override for the pane this native OWNS (see `IndicatorModel.paneAxis`):
|
|
387
|
+
* `'none'` for content that is not value-mapped, or band labels for a categorical
|
|
388
|
+
* axis. Emitted per compute, so it can follow the inputs (e.g. row toggles relabel
|
|
389
|
+
* the axis). Absent ⇒ the pane derives a scale from its content as usual.
|
|
390
|
+
*/
|
|
391
|
+
paneAxis?: PaneAxis;
|
|
385
392
|
series?: SeriesSpec[];
|
|
386
393
|
fills?: Fill[];
|
|
387
394
|
backgrounds?: Background[];
|
|
@@ -753,7 +760,11 @@ interface VelaEventMap extends Record<string, unknown> {
|
|
|
753
760
|
oldestTime: number;
|
|
754
761
|
barsLoaded: number;
|
|
755
762
|
};
|
|
756
|
-
alert
|
|
763
|
+
/** An indicator's script raised an alert. `indicator` names the source — the
|
|
764
|
+
* indicator's display title (what its legend row shows). */
|
|
765
|
+
alert: EngineAlert & {
|
|
766
|
+
indicator?: string;
|
|
767
|
+
};
|
|
757
768
|
warning: EngineWarning;
|
|
758
769
|
}
|
|
759
770
|
|
|
@@ -928,7 +939,23 @@ declare class RendererControl {
|
|
|
928
939
|
setSettingsSections(sections: ReadonlyArray<{
|
|
929
940
|
title: string;
|
|
930
941
|
rows: readonly unknown[];
|
|
942
|
+
id?: string;
|
|
931
943
|
}>): this;
|
|
944
|
+
/**
|
|
945
|
+
* Set the settings-dialog visibility policy: `hidden` lists setting ids to hide —
|
|
946
|
+
* a tab (`'canvas'`), a group (`'canvas.grid'`), or a single row
|
|
947
|
+
* (`'canvas.grid.vertical'`); an id hides its whole subtree, and a tab with nothing
|
|
948
|
+
* left disappears from the rail. Presentation-only: hidden values keep being stored
|
|
949
|
+
* and applied (e.g. hide `'advanced'` while forcing the widget's `bars` option).
|
|
950
|
+
* Seeded from `VelaOptions.settings`; silent no-op without a settings dialog.
|
|
951
|
+
*/
|
|
952
|
+
setSettingsVisibility(policy: {
|
|
953
|
+
hidden?: readonly string[];
|
|
954
|
+
}): this;
|
|
955
|
+
/** Every addressable setting id of this chart (built-in tabs/groups/rows, chart-type
|
|
956
|
+
* sections, host sections) — enumerate these to build a `hidden` list instead of
|
|
957
|
+
* reading contributor source. Empty on a renderer without a settings dialog. */
|
|
958
|
+
listSettingsIds(): string[];
|
|
932
959
|
/** Tell the renderer's own chrome which size class the host shell is in —
|
|
933
960
|
* `'mobile'` switches its dialogs/toolbars to the touch-first presentation.
|
|
934
961
|
* Silent no-op on a renderer without adaptive chrome. */
|
|
@@ -1425,6 +1452,28 @@ interface WidgetContext {
|
|
|
1425
1452
|
host: HTMLElement;
|
|
1426
1453
|
/** The widget's feedback pill (bottom-center, auto-hides). */
|
|
1427
1454
|
toast(message: string, kind?: 'info' | 'success' | 'error'): void;
|
|
1455
|
+
/** Add a SCRIPT indicator to the active chart THROUGH THE SHELL — unlike the raw
|
|
1456
|
+
* `chart.addIndicator`, the addition enters the unified undo/redo timeline, the
|
|
1457
|
+
* topbar indicator count, and the shell's bookkeeping. The entry's source rides the
|
|
1458
|
+
* recorded action, so redo re-adds it even after the original handle died. The
|
|
1459
|
+
* shell does NOT persist these across reloads (they are not manifest entries) —
|
|
1460
|
+
* a plugin that wants them back owns that via {@link registerStatePersistence}. */
|
|
1461
|
+
addIndicator(entry: ExternalIndicatorEntry): void;
|
|
1462
|
+
/** Add a native (core-computed) indicator to the active chart through the shell —
|
|
1463
|
+
* recorded in the undo/redo timeline, unlike the raw `chart.addNativeIndicator`. */
|
|
1464
|
+
addNativeIndicator(type: string): void;
|
|
1465
|
+
/** Tell the shell some PERSISTABLE third-party state changed (a debounced
|
|
1466
|
+
* `state:changed` + storage write follows). Only needed for state with no shell
|
|
1467
|
+
* event of its own — indicator adds/removals already trigger the save cycle. */
|
|
1468
|
+
stateChanged(): void;
|
|
1469
|
+
}
|
|
1470
|
+
/** What {@link WidgetContext.addIndicator} takes: a named script, ready to run. */
|
|
1471
|
+
interface ExternalIndicatorEntry {
|
|
1472
|
+
name: string;
|
|
1473
|
+
/** The script source (the recorded undo/redo action re-adds from it). */
|
|
1474
|
+
script: string;
|
|
1475
|
+
/** Engine language (default: the chart's default engine). */
|
|
1476
|
+
language?: string;
|
|
1428
1477
|
}
|
|
1429
1478
|
/** Where an action is projected. */
|
|
1430
1479
|
type WidgetActionTarget = 'topbar' | 'context:body' | 'context:price-axis' | 'context:time-axis';
|
|
@@ -1565,6 +1614,61 @@ declare function registerLegendAction(desc: LegendActionDescriptor): () => void;
|
|
|
1565
1614
|
declare function unregisterLegendAction(id: string): void;
|
|
1566
1615
|
/** Every registered legend action, `order`-sorted (registration order breaks ties). */
|
|
1567
1616
|
declare function legendActions(): LegendActionDescriptor[];
|
|
1617
|
+
/**
|
|
1618
|
+
* The surface a `scope: 'cell'` persistence handler works against — bound to ONE cell
|
|
1619
|
+
* (never the active one by proxy), because serialize/restore run per cell, including
|
|
1620
|
+
* cells that are not active. `addIndicator`/`addNativeIndicator` target THIS cell and
|
|
1621
|
+
* are ALWAYS muted — unlike their {@link WidgetContext} namesakes they never enter the
|
|
1622
|
+
* undo timeline, even from an async `restore` continuation (fetch, then add): applying
|
|
1623
|
+
* a document is state application, not a user edit.
|
|
1624
|
+
*/
|
|
1625
|
+
interface CellStateContext {
|
|
1626
|
+
/** The cell's durable identity (`'c1'`, a declared name). */
|
|
1627
|
+
cellId: string;
|
|
1628
|
+
/** The cell's LIVE chart. */
|
|
1629
|
+
chart: Vela;
|
|
1630
|
+
/** Add a script indicator to THIS cell through the shell (see {@link WidgetContext.addIndicator}). */
|
|
1631
|
+
addIndicator(entry: ExternalIndicatorEntry): void;
|
|
1632
|
+
/** Add a native indicator to THIS cell through the shell. */
|
|
1633
|
+
addNativeIndicator(type: string): void;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* A third-party STATE PERSISTENCE handler — how a plugin puts its own state into the
|
|
1637
|
+
* shell's persisted document (the `ext` bag of `WorkspaceState` / per-chart state)
|
|
1638
|
+
* instead of running a parallel store. `key` is namespaced (`'vendor.feature'`) and
|
|
1639
|
+
* flat — one entry per handler. `serialize` runs on every shell snapshot (`getState`,
|
|
1640
|
+
* the persist write) and returns a JSON-serializable payload, or `undefined` for "no
|
|
1641
|
+
* entry". `restore` runs when a document carrying the key is applied (boot restore,
|
|
1642
|
+
* `applyState`) — AFTER the core state (chart alive, engines registered, indicator
|
|
1643
|
+
* ledger converged) and, for cell scope, inside the cell's history-mute, so nothing it
|
|
1644
|
+
* does enters undo/redo. The payload is UNTRUSTED (the codec passes `ext` through
|
|
1645
|
+
* opaquely): validate it. `restore` is only called for keys present in the document.
|
|
1646
|
+
*
|
|
1647
|
+
* Register at import time, before shells are constructed — the rule every contribution
|
|
1648
|
+
* registry shares. A key with no registered handler still round-trips verbatim, so a
|
|
1649
|
+
* session without the plugin never loses its state.
|
|
1650
|
+
*/
|
|
1651
|
+
type StatePersistenceHandler = {
|
|
1652
|
+
/** Namespaced entry key (`'velapro.indicators'`) — re-registering a key replaces it. */
|
|
1653
|
+
key: string;
|
|
1654
|
+
/** Where the entry lives: per chart (`charts[i].ext`) — follows the cell through pool/layout moves. */
|
|
1655
|
+
scope: 'cell';
|
|
1656
|
+
serialize(ctx: CellStateContext): unknown;
|
|
1657
|
+
restore(payload: unknown, ctx: CellStateContext): void;
|
|
1658
|
+
} | {
|
|
1659
|
+
key: string;
|
|
1660
|
+
/** Document root (`state.ext`) — one entry per document, whatever the grid. */
|
|
1661
|
+
scope: 'global';
|
|
1662
|
+
serialize(ctx: WidgetContext): unknown;
|
|
1663
|
+
restore(payload: unknown, ctx: WidgetContext): void;
|
|
1664
|
+
};
|
|
1665
|
+
/** Register (or replace) a state-persistence handler. Returns an unregister disposer. */
|
|
1666
|
+
declare function registerStatePersistence(handler: StatePersistenceHandler): () => void;
|
|
1667
|
+
declare function unregisterStatePersistence(key: string): void;
|
|
1668
|
+
/** The registered handlers of one scope (registration order). */
|
|
1669
|
+
declare function statePersistenceHandlers<S extends StatePersistenceHandler['scope']>(scope: S): Array<Extract<StatePersistenceHandler, {
|
|
1670
|
+
scope: S;
|
|
1671
|
+
}>>;
|
|
1568
1672
|
/** Makes ONE engine instance for ONE chart — engines hold per-chart sessions (and
|
|
1569
1673
|
* possibly a worker), so the shell calls the factory per chart build, never shares. */
|
|
1570
1674
|
type EngineFactory = () => ScriptingEngine;
|
|
@@ -1582,4 +1686,4 @@ declare function unregisterDefaultEngine(language: string): void;
|
|
|
1582
1686
|
* language. The shell layers (widget, workspace cell) register exactly this result. */
|
|
1583
1687
|
declare function resolveEngines(overrides?: Record<string, EngineFactory>): Record<string, EngineFactory>;
|
|
1584
1688
|
|
|
1585
|
-
export {
|
|
1689
|
+
export { type WidgetAttachment as $, type SidePanelButton as A, type BarsChangeReason as B, type CellStateContext as C, type DrawingsDocument as D, type ExternalIndicatorEntry as E, type FetchSeries as F, type SidePanelDescriptor as G, type SidePanelHandle as H, type IndicatorHandle as I, type SidePanelHeader as J, type StatePersistenceHandler as K, type LegendActionDescriptor as L, type StrategyFill as M, type NativeIndicator as N, type StrategyState as O, type ParsedSymbol as P, type StrategyTrade as Q, type Resolved as R, type ScriptingEngine as S, TypedEventBus as T, type VelaDeps as U, Vela as V, type WidgetContext as W, type VelaEventMap as X, type VisibleBarRange as Y, type WidgetActionDescriptor as Z, type WidgetActionTarget as _, type ScriptRun as a, getNativeIndicator as a0, legendActions as a1, nativeIndicatorDescriptors as a2, nativeIndicatorTypes as a3, registerDefaultEngine as a4, registerLegendAction as a5, registerNativeIndicator as a6, registerSidePanel as a7, registerStatePersistence as a8, registerWidgetAction as a9, registerWidgetAttachment as aa, resolveEngines as ab, sidePanels as ac, statePersistenceHandlers as ad, unregisterDefaultEngine as ae, unregisterLegendAction as af, unregisterNativeIndicator as ag, unregisterSidePanel as ah, unregisterStatePersistence as ai, unregisterWidgetAction as aj, unregisterWidgetAttachment as ak, widgetActions as al, widgetAttachments as am, DEFAULT_PANEL_ORDER as an, type ContextSelect as b, DataControl as c, DrawingsControl as d, type EngineAlert as e, type EngineCapabilities as f, type EngineContextSnapshot as g, type EngineFactory as h, type EngineWarning as i, type ExecutionHandlers as j, type ExecutionMarket as k, type ExecutionRequest as l, type ExecutionSession as m, type IndicatorEventMap as n, type IndicatorSummary as o, type LegendIndicatorInfo as p, type NativeIndicatorContext as q, type NativeIndicatorDescriptor as r, type NativeIndicatorInfo as s, type NativeIndicatorOutput as t, type PreparedScript as u, RendererControl as v, type RunIndicatorResult as w, type SceneInspection as x, type ScriptRunCause as y, type ScriptRunResult as z };
|