@luxalgo/vela 0.6.18 → 0.6.20

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/dist/widget.cjs CHANGED
@@ -17186,9 +17186,10 @@ async function resolveIndicators(config, fetchImpl = fetch) {
17186
17186
  return out;
17187
17187
  }
17188
17188
  var ledgerEntryName = (e) => typeof e === "string" ? e : e.name;
17189
+ var ledgerNativeType = (e) => typeof e === "string" ? e : e.type;
17189
17190
  function indicatorLedger(i) {
17190
17191
  const natives = [...i.present];
17191
- if (i.volumePending && !natives.includes("volume")) natives.push("volume");
17192
+ if (i.volumePending && !natives.some((e) => ledgerNativeType(e) === "volume")) natives.push("volume");
17192
17193
  return {
17193
17194
  manifest: i.manifestSettled ? [...i.instanceEntries] : [...i.pendingManifest ?? i.instanceEntries],
17194
17195
  natives
@@ -18143,18 +18144,28 @@ function sanitizeCell(raw) {
18143
18144
  if (c.drawings != null && typeof c.drawings === "object") out.drawings = c.drawings;
18144
18145
  const ind = c.indicators;
18145
18146
  if (ind != null && typeof ind === "object") {
18147
+ const bag = (v) => v != null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
18146
18148
  const manifest = Array.isArray(ind.manifest) ? ind.manifest.flatMap((n) => {
18147
18149
  if (typeof n === "string") return [n];
18148
18150
  if (n != null && typeof n === "object" && typeof n.name === "string") {
18149
18151
  const e = n;
18150
- const bag = (v) => v != null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
18151
18152
  const inputs = bag(e.inputs);
18152
18153
  const props = bag(e.props);
18153
- return [inputs || props ? { name: e.name, ...inputs ? { inputs } : {}, ...props ? { props } : {} } : e.name];
18154
+ const hidden = e.hidden === true;
18155
+ return [inputs || props || hidden ? { name: e.name, ...inputs ? { inputs } : {}, ...props ? { props } : {}, ...hidden ? { hidden } : {} } : e.name];
18156
+ }
18157
+ return [];
18158
+ }) : [];
18159
+ const natives = Array.isArray(ind.natives) ? ind.natives.flatMap((n) => {
18160
+ if (typeof n === "string") return [n];
18161
+ if (n != null && typeof n === "object" && typeof n.type === "string") {
18162
+ const e = n;
18163
+ const inputs = bag(e.inputs);
18164
+ const hidden = e.hidden === true;
18165
+ return [inputs || hidden ? { type: e.type, ...inputs ? { inputs } : {}, ...hidden ? { hidden } : {} } : e.type];
18154
18166
  }
18155
18167
  return [];
18156
18168
  }) : [];
18157
- const natives = Array.isArray(ind.natives) ? ind.natives.filter((n) => typeof n === "string") : [];
18158
18169
  out.indicators = { manifest, natives };
18159
18170
  }
18160
18171
  const ext = sanitizeExt(c.ext);
@@ -37849,6 +37860,8 @@ function toPoints(bars, values, colors) {
37849
37860
  var ClassicIndicator = class {
37850
37861
  constructor(spec) {
37851
37862
  this.spec = spec;
37863
+ /** Null until start() — a pre-start setInputs must record without computing. */
37864
+ this.ctx = null;
37852
37865
  this.inputs = {};
37853
37866
  }
37854
37867
  start(ctx, inputs) {
@@ -37863,6 +37876,7 @@ var ClassicIndicator = class {
37863
37876
  }
37864
37877
  setInputs(inputs) {
37865
37878
  this.inputs = inputs;
37879
+ if (!this.ctx) return;
37866
37880
  this.recompute();
37867
37881
  }
37868
37882
  /** Nothing to free — the compute reads the live bar accessor on demand. */
@@ -37874,6 +37888,7 @@ var ClassicIndicator = class {
37874
37888
  stop() {
37875
37889
  }
37876
37890
  recompute() {
37891
+ if (!this.ctx) return;
37877
37892
  const bars = this.ctx.bars();
37878
37893
  const out = this.spec.compute(bars, this.inputs);
37879
37894
  const instanceId = this.spec.type;
@@ -41804,6 +41819,11 @@ function cellDrawings(opt) {
41804
41819
  if (opt === true || opt == null) return { toolbar: false };
41805
41820
  return { ...opt, toolbar: false };
41806
41821
  }
41822
+ function nativeLedgerEntry(handle) {
41823
+ const inputs = inputDeltas(handle.inputs, handle.inputValues());
41824
+ const hidden = !handle.visible;
41825
+ return inputs || hidden ? { type: handle.nativeType, ...inputs ? { inputs } : {}, ...hidden ? { hidden: true } : {} } : handle.nativeType;
41826
+ }
41807
41827
  function instanceDeltas(handle) {
41808
41828
  if (!handle) return void 0;
41809
41829
  const inputs = inputDeltas(handle.inputs, handle.inputValues());
@@ -41926,10 +41946,13 @@ var ChartCell = class {
41926
41946
  if (seed.rendererConfig != null) this.inner.renderer.applyConfig(seed.rendererConfig);
41927
41947
  if (seed.drawings != null) this.inner.drawings.fromJSON(seed.drawings);
41928
41948
  if (seed.indicators) {
41929
- for (const type of seed.indicators.natives) this.inner.addNativeIndicator(type);
41949
+ for (const entry of seed.indicators.natives) {
41950
+ const handle = this.inner.addNativeIndicator(ledgerNativeType(entry));
41951
+ this.applyNativeLedgerEntry(handle, entry);
41952
+ }
41930
41953
  this.pendingManifestNames = [...seed.indicators.manifest];
41931
41954
  }
41932
- this.volumeIntent = seed.indicators ? seed.indicators.natives.includes("volume") : deps.volume;
41955
+ this.volumeIntent = seed.indicators ? seed.indicators.natives.some((e) => ledgerNativeType(e) === "volume") : deps.volume;
41933
41956
  this.extState = { ...seed.ext ?? {} };
41934
41957
  this.inner.on("load:end", () => {
41935
41958
  this.volumeMayBePending = false;
@@ -42001,6 +42024,7 @@ var ChartCell = class {
42001
42024
  this.refreshNativeCatalog();
42002
42025
  });
42003
42026
  this.inner.on("indicator:inputs", () => this.deps.onStateDirty());
42027
+ this.inner.on("indicator:visibility", () => this.deps.onStateDirty());
42004
42028
  this.inner.on("indicator:removed", ({ id: id2 }) => {
42005
42029
  if (this.destroyed) return;
42006
42030
  const idx = this.instances.findIndex((it) => it.handle?.id === id2);
@@ -42445,7 +42469,7 @@ var ChartCell = class {
42445
42469
  if (list.length === 0) return;
42446
42470
  for (const led of this.pendingManifestNames) {
42447
42471
  const entry = list.find((e) => e.name === ledgerEntryName(led));
42448
- if (entry) this.addManifestInstance(entry, { record: false, ...typeof led === "object" ? { inputs: led.inputs, props: led.props } : {} });
42472
+ if (entry) this.addManifestInstance(entry, { record: false, ...typeof led === "object" ? { inputs: led.inputs, props: led.props, hidden: led.hidden } : {} });
42449
42473
  }
42450
42474
  this.pendingManifestNames = null;
42451
42475
  return;
@@ -42464,23 +42488,35 @@ var ChartCell = class {
42464
42488
  applyIndicatorLedger(led) {
42465
42489
  const chart = this.inner;
42466
42490
  if (!chart) return;
42467
- this.volumeIntent = led.natives.includes("volume");
42491
+ this.volumeIntent = led.natives.some((e) => ledgerNativeType(e) === "volume");
42468
42492
  this.history.silently(() => {
42469
42493
  const owed = /* @__PURE__ */ new Map();
42470
- for (const type of led.natives) owed.set(type, (owed.get(type) ?? 0) + 1);
42494
+ for (const e of led.natives) {
42495
+ const type = ledgerNativeType(e);
42496
+ const queue = owed.get(type);
42497
+ if (queue) queue.push(e);
42498
+ else owed.set(type, [e]);
42499
+ }
42471
42500
  for (const h of this.nativeHandles()) {
42472
- const type = h.nativeType;
42473
- const n = owed.get(type) ?? 0;
42474
- if (n > 0) owed.set(type, n - 1);
42501
+ const entry = owed.get(h.nativeType)?.shift();
42502
+ if (entry !== void 0) this.applyNativeLedgerEntry(h, entry);
42475
42503
  else h.remove();
42476
42504
  }
42477
- for (const [type, n] of owed) for (let i = 0; i < n; i++) chart.addNativeIndicator(type);
42505
+ for (const queue of owed.values()) {
42506
+ for (const e of queue) {
42507
+ const h = chart.addNativeIndicator(ledgerNativeType(e));
42508
+ this.applyNativeLedgerEntry(h, e);
42509
+ }
42510
+ }
42478
42511
  for (const it of [...this.instances]) this.dropInstance(it);
42479
42512
  if (this.manifest.length > 0) {
42480
42513
  for (const item of led.manifest) {
42481
42514
  const entry = this.manifest.find((e) => e.name === ledgerEntryName(item));
42482
42515
  if (entry)
42483
- this.addManifestInstance(entry, { record: false, ...typeof item === "object" ? { inputs: item.inputs, props: item.props } : {} });
42516
+ this.addManifestInstance(entry, {
42517
+ record: false,
42518
+ ...typeof item === "object" ? { inputs: item.inputs, props: item.props, hidden: item.hidden } : {}
42519
+ });
42484
42520
  }
42485
42521
  this.pendingManifestNames = null;
42486
42522
  } else if (!this.deps.manifestSettled()) {
@@ -42539,7 +42575,7 @@ var ChartCell = class {
42539
42575
  addExternalIndicator(entry) {
42540
42576
  this.addManifestInstance(
42541
42577
  { ...entry, enabled: true },
42542
- { external: true, ...entry.inputs ? { inputs: entry.inputs } : {}, ...entry.props ? { props: entry.props } : {} }
42578
+ { external: true, ...entry.inputs ? { inputs: entry.inputs } : {}, ...entry.props ? { props: entry.props } : {}, ...entry.hidden ? { hidden: true } : {} }
42543
42579
  );
42544
42580
  }
42545
42581
  /** Add ONE instance of a manifest entry (repeatable — duplicates are legitimate). */
@@ -42547,6 +42583,7 @@ var ChartCell = class {
42547
42583
  if (this.destroyed) return;
42548
42584
  const values = opts.inputs || opts.props ? { inputs: opts.inputs, props: opts.props } : void 0;
42549
42585
  const it = { entry, handle: this.addToChart(entry, values), ...opts.external ? { external: true } : {}, ...values ? { values } : {} };
42586
+ if (opts.hidden) it.handle?.setVisible(false);
42550
42587
  this.instances.push(it);
42551
42588
  this.deps.onIndicatorsChanged(this.id);
42552
42589
  if (opts.record === false) return;
@@ -42590,6 +42627,29 @@ var ChartCell = class {
42590
42627
  /** Add a native indicator. A multi-instance type gets a fresh instance every time; a
42591
42628
  * single-instance type already on the chart hands back its existing one — nothing
42592
42629
  * changed, so nothing enters the undo timeline. */
42630
+ /**
42631
+ * Converge one native handle to a restored ledger entry: every schema key gets the
42632
+ * entry's value or its declaration default (the DOCUMENT is the truth — a live
42633
+ * tweak must not survive a restore that says otherwise), and visibility follows
42634
+ * the `hidden` flag. Skips the input write when nothing differs — `setInputs`
42635
+ * re-runs the indicator, and a no-op restore must not flicker every native.
42636
+ */
42637
+ applyNativeLedgerEntry(handle, entry) {
42638
+ const wanted = typeof entry === "string" ? void 0 : entry.inputs;
42639
+ if (handle.inputs.length > 0) {
42640
+ const current = handle.inputValues();
42641
+ const next = {};
42642
+ for (const schema of handle.inputs) {
42643
+ const target = wanted?.[schema.key] ?? schema.defval;
42644
+ if (JSON.stringify(current[schema.key]) !== JSON.stringify(target)) next[schema.key] = target;
42645
+ }
42646
+ if (Object.keys(next).length > 0) handle.setInputs(next);
42647
+ } else if (wanted) {
42648
+ handle.setInputs(wanted);
42649
+ }
42650
+ const visible = !(typeof entry === "object" && entry.hidden);
42651
+ if (handle.visible !== visible) handle.setVisible(visible);
42652
+ }
42593
42653
  addNative(type) {
42594
42654
  const chart = this.inner;
42595
42655
  if (!chart) return;
@@ -42753,10 +42813,13 @@ var ChartCell = class {
42753
42813
  // (`ctx.addIndicator`) stay out: their names would never resolve against the
42754
42814
  // manifest — their plugin persists them via the `ext` seam instead.
42755
42815
  indicators: indicatorLedger({
42756
- present: this.inner ? this.inner.presentNativeIndicators() : [],
42816
+ // Live handles carry what the registry read cannot: the input DELTAS and
42817
+ // the hidden flag, so native settings/visibility survive the round-trip.
42818
+ present: this.inner ? this.nativeHandles().map((h) => nativeLedgerEntry(h)) : [],
42757
42819
  instanceEntries: this.instances.filter((it) => !it.external).map((it) => {
42758
42820
  const d = it.handle ? instanceDeltas(it.handle) : it.values;
42759
- return d ? { name: it.entry.name, ...d } : it.entry.name;
42821
+ const hidden = it.handle ? !it.handle.visible : false;
42822
+ return d || hidden ? { name: it.entry.name, ...d ?? {}, ...hidden ? { hidden: true } : {} } : it.entry.name;
42760
42823
  }),
42761
42824
  pendingManifest: this.pendingManifestNames,
42762
42825
  manifestSettled: this.deps.manifestSettled(),
package/dist/widget.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { V as Vela, W as WidgetContext, K as SidePanelButton } from './contributions-DEPRtkmG.cjs';
2
- export { C as CellStateContext, az as DEFAULT_PANEL_ORDER, E as ExternalIndicatorEntry, O as OVERRIDABLE_TOPBAR_IDS, M as SidePanelDescriptor, Q as SidePanelHandle, U as StatePersistenceHandler, _ as SymbolRankingHook, a3 as WidgetActionDescriptor, a4 as WidgetActionTarget, a5 as WidgetAttachment, af as registerSidePanel, ag as registerStatePersistence, ah as registerSymbolRanking, ai as registerWidgetAction, aj as registerWidgetAttachment, al as sidePanels, am as statePersistenceHandlers, an as symbolRanking, ao as topbarActionOverride, at as unregisterSidePanel, au as unregisterStatePersistence, av as unregisterWidgetAction, aw as unregisterWidgetAttachment, ax as widgetActions, ay as widgetAttachments } from './contributions-DEPRtkmG.cjs';
1
+ import { V as Vela, W as WidgetContext, K as SidePanelButton } from './contributions-D8HdlKmp.cjs';
2
+ export { C as CellStateContext, az as DEFAULT_PANEL_ORDER, E as ExternalIndicatorEntry, O as OVERRIDABLE_TOPBAR_IDS, M as SidePanelDescriptor, Q as SidePanelHandle, U as StatePersistenceHandler, _ as SymbolRankingHook, a3 as WidgetActionDescriptor, a4 as WidgetActionTarget, a5 as WidgetAttachment, af as registerSidePanel, ag as registerStatePersistence, ah as registerSymbolRanking, ai as registerWidgetAction, aj as registerWidgetAttachment, al as sidePanels, am as statePersistenceHandlers, an as symbolRanking, ao as topbarActionOverride, at as unregisterSidePanel, au as unregisterStatePersistence, av as unregisterWidgetAction, aw as unregisterWidgetAttachment, ax as widgetActions, ay as widgetAttachments } from './contributions-D8HdlKmp.cjs';
3
3
  import { b as VelaOptions, d as MarketSession, T as ThemeName, c as VelaTheme, s as DataWindowReadout } from './options-BCRmYALw.cjs';
4
- import { c as VelaShellOptions, W as WidgetHistory, b as RangePreset, f as WorkspaceState, j as TopbarComposition, a as StatuslinePart, P as PanelsState } from './statusline-model-7ECSDtgt.cjs';
5
- export { B as Bottombar, k as BottombarOptions, C as CellState, g as ChartState, I as IndicatorLoader, l as IndicatorManifest, m as IndicatorManifestEntry, n as RANGE_PRESETS, R as ResolvedIndicator, o as ResolvedTopbarComposition, p as TOPBAR_BUILTIN_IDS, q as TOPBAR_DEFAULT_LEFT, r as TOPBAR_DEFAULT_RIGHT, V as VelaStorage, t as WidgetStorage, h as decodeState, i as encodeState, u as localStorageAdapter, v as pinnedTopbarActionIds, w as resolveIndicators, x as resolveTopbarComposition, s as sanitizeState, y as topbarHas } from './statusline-model-7ECSDtgt.cjs';
4
+ import { c as VelaShellOptions, W as WidgetHistory, b as RangePreset, f as WorkspaceState, j as TopbarComposition, a as StatuslinePart, P as PanelsState } from './statusline-model-E7CMw5pQ.cjs';
5
+ export { B as Bottombar, k as BottombarOptions, C as CellState, g as ChartState, I as IndicatorLoader, l as IndicatorManifest, m as IndicatorManifestEntry, n as RANGE_PRESETS, R as ResolvedIndicator, o as ResolvedTopbarComposition, p as TOPBAR_BUILTIN_IDS, q as TOPBAR_DEFAULT_LEFT, r as TOPBAR_DEFAULT_RIGHT, V as VelaStorage, t as WidgetStorage, h as decodeState, i as encodeState, u as localStorageAdapter, v as pinnedTopbarActionIds, w as resolveIndicators, x as resolveTopbarComposition, s as sanitizeState, y as topbarHas } from './statusline-model-E7CMw5pQ.cjs';
6
6
  import { K as KeymapManager } from './keymap-CGOz5F5f.cjs';
7
7
  import { a as SymbolDescriptor } from './DataProvider-UtWw2CgJ.cjs';
8
8
  import { d as SidePanel } from './side-panel-HF0IAzwf.cjs';
package/dist/widget.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { V as Vela, W as WidgetContext, K as SidePanelButton } from './contributions-5nz3PLRe.js';
2
- export { C as CellStateContext, az as DEFAULT_PANEL_ORDER, E as ExternalIndicatorEntry, O as OVERRIDABLE_TOPBAR_IDS, M as SidePanelDescriptor, Q as SidePanelHandle, U as StatePersistenceHandler, _ as SymbolRankingHook, a3 as WidgetActionDescriptor, a4 as WidgetActionTarget, a5 as WidgetAttachment, af as registerSidePanel, ag as registerStatePersistence, ah as registerSymbolRanking, ai as registerWidgetAction, aj as registerWidgetAttachment, al as sidePanels, am as statePersistenceHandlers, an as symbolRanking, ao as topbarActionOverride, at as unregisterSidePanel, au as unregisterStatePersistence, av as unregisterWidgetAction, aw as unregisterWidgetAttachment, ax as widgetActions, ay as widgetAttachments } from './contributions-5nz3PLRe.js';
1
+ import { V as Vela, W as WidgetContext, K as SidePanelButton } from './contributions-FqIWhN4p.js';
2
+ export { C as CellStateContext, az as DEFAULT_PANEL_ORDER, E as ExternalIndicatorEntry, O as OVERRIDABLE_TOPBAR_IDS, M as SidePanelDescriptor, Q as SidePanelHandle, U as StatePersistenceHandler, _ as SymbolRankingHook, a3 as WidgetActionDescriptor, a4 as WidgetActionTarget, a5 as WidgetAttachment, af as registerSidePanel, ag as registerStatePersistence, ah as registerSymbolRanking, ai as registerWidgetAction, aj as registerWidgetAttachment, al as sidePanels, am as statePersistenceHandlers, an as symbolRanking, ao as topbarActionOverride, at as unregisterSidePanel, au as unregisterStatePersistence, av as unregisterWidgetAction, aw as unregisterWidgetAttachment, ax as widgetActions, ay as widgetAttachments } from './contributions-FqIWhN4p.js';
3
3
  import { b as VelaOptions, d as MarketSession, T as ThemeName, c as VelaTheme, s as DataWindowReadout } from './options-BCRmYALw.js';
4
- import { c as VelaShellOptions, W as WidgetHistory, b as RangePreset, f as WorkspaceState, j as TopbarComposition, a as StatuslinePart, P as PanelsState } from './statusline-model-D1Fhs8Dk.js';
5
- export { B as Bottombar, k as BottombarOptions, C as CellState, g as ChartState, I as IndicatorLoader, l as IndicatorManifest, m as IndicatorManifestEntry, n as RANGE_PRESETS, R as ResolvedIndicator, o as ResolvedTopbarComposition, p as TOPBAR_BUILTIN_IDS, q as TOPBAR_DEFAULT_LEFT, r as TOPBAR_DEFAULT_RIGHT, V as VelaStorage, t as WidgetStorage, h as decodeState, i as encodeState, u as localStorageAdapter, v as pinnedTopbarActionIds, w as resolveIndicators, x as resolveTopbarComposition, s as sanitizeState, y as topbarHas } from './statusline-model-D1Fhs8Dk.js';
4
+ import { c as VelaShellOptions, W as WidgetHistory, b as RangePreset, f as WorkspaceState, j as TopbarComposition, a as StatuslinePart, P as PanelsState } from './statusline-model-CCP1zm_Z.js';
5
+ export { B as Bottombar, k as BottombarOptions, C as CellState, g as ChartState, I as IndicatorLoader, l as IndicatorManifest, m as IndicatorManifestEntry, n as RANGE_PRESETS, R as ResolvedIndicator, o as ResolvedTopbarComposition, p as TOPBAR_BUILTIN_IDS, q as TOPBAR_DEFAULT_LEFT, r as TOPBAR_DEFAULT_RIGHT, V as VelaStorage, t as WidgetStorage, h as decodeState, i as encodeState, u as localStorageAdapter, v as pinnedTopbarActionIds, w as resolveIndicators, x as resolveTopbarComposition, s as sanitizeState, y as topbarHas } from './statusline-model-CCP1zm_Z.js';
6
6
  import { K as KeymapManager } from './keymap-CGOz5F5f.js';
7
7
  import { a as SymbolDescriptor } from './DataProvider-Cb-2lC5O.js';
8
8
  import { d as SidePanel } from './side-panel-HF0IAzwf.js';
package/dist/widget.js CHANGED
@@ -1,6 +1,6 @@
1
- import { VelaWorkspace } from './chunk-BXF7VNNE.js';
2
- export { Bottombar, ChartContextMenu, DataWindow, IndicatorPicker, ObjectTree, PanelDock, RANGE_PRESETS, ShortcutsHelp, Statusline, SymbolPicker, TimeframeQuick, Topbar, Watermark, dataWindowSections, decimalsFor, decodeState, encodeState, filterSymbols, fmtChange, fmtPrice, localStorageAdapter, parseTimeframe, priceStyleLabel, resolveIndicators, sanitizeState, timeframeLabel, timeframeMs } from './chunk-BXF7VNNE.js';
3
- export { TIMEZONES, normalizeTimezone, tzButtonLabel, tzMenuLabel, tzOffset } from './chunk-22QJKGXX.js';
1
+ import { VelaWorkspace } from './chunk-M6T5A733.js';
2
+ export { Bottombar, ChartContextMenu, DataWindow, IndicatorPicker, ObjectTree, PanelDock, RANGE_PRESETS, ShortcutsHelp, Statusline, SymbolPicker, TimeframeQuick, Topbar, Watermark, dataWindowSections, decimalsFor, decodeState, encodeState, filterSymbols, fmtChange, fmtPrice, localStorageAdapter, parseTimeframe, priceStyleLabel, resolveIndicators, sanitizeState, timeframeLabel, timeframeMs } from './chunk-M6T5A733.js';
3
+ export { TIMEZONES, normalizeTimezone, tzButtonLabel, tzMenuLabel, tzOffset } from './chunk-4Q4B5AO3.js';
4
4
  export { DEFAULT_PANEL_MAX_WIDTH, DEFAULT_PANEL_MIN_WIDTH, DEFAULT_PANEL_ORDER, DEFAULT_PANEL_WIDTH, OVERRIDABLE_TOPBAR_IDS, SidePanel, TOPBAR_BUILTIN_IDS, TOPBAR_DEFAULT_LEFT, TOPBAR_DEFAULT_RIGHT, clampPanelWidth, pinnedTopbarActionIds, registerSidePanel, registerStatePersistence, registerSymbolRanking, registerWidgetAction, registerWidgetAttachment, resolveTopbarComposition, sidePanels, statePersistenceHandlers, symbolRanking, topbarActionOverride, topbarHas, unregisterSidePanel, unregisterStatePersistence, unregisterWidgetAction, unregisterWidgetAttachment, widgetActions, widgetAttachments } from './chunk-IFJJPXSV.js';
5
5
  import './chunk-XCBJU674.js';
6
6
  import './chunk-T5Z5YUCF.js';
@@ -17104,9 +17104,10 @@ async function resolveIndicators(config, fetchImpl = fetch) {
17104
17104
  return out;
17105
17105
  }
17106
17106
  var ledgerEntryName = (e) => typeof e === "string" ? e : e.name;
17107
+ var ledgerNativeType = (e) => typeof e === "string" ? e : e.type;
17107
17108
  function indicatorLedger(i) {
17108
17109
  const natives = [...i.present];
17109
- if (i.volumePending && !natives.includes("volume")) natives.push("volume");
17110
+ if (i.volumePending && !natives.some((e) => ledgerNativeType(e) === "volume")) natives.push("volume");
17110
17111
  return {
17111
17112
  manifest: i.manifestSettled ? [...i.instanceEntries] : [...i.pendingManifest ?? i.instanceEntries],
17112
17113
  natives
@@ -18061,18 +18062,28 @@ function sanitizeCell(raw) {
18061
18062
  if (c.drawings != null && typeof c.drawings === "object") out.drawings = c.drawings;
18062
18063
  const ind = c.indicators;
18063
18064
  if (ind != null && typeof ind === "object") {
18065
+ const bag = (v) => v != null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
18064
18066
  const manifest = Array.isArray(ind.manifest) ? ind.manifest.flatMap((n) => {
18065
18067
  if (typeof n === "string") return [n];
18066
18068
  if (n != null && typeof n === "object" && typeof n.name === "string") {
18067
18069
  const e = n;
18068
- const bag = (v) => v != null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
18069
18070
  const inputs = bag(e.inputs);
18070
18071
  const props = bag(e.props);
18071
- return [inputs || props ? { name: e.name, ...inputs ? { inputs } : {}, ...props ? { props } : {} } : e.name];
18072
+ const hidden = e.hidden === true;
18073
+ return [inputs || props || hidden ? { name: e.name, ...inputs ? { inputs } : {}, ...props ? { props } : {}, ...hidden ? { hidden } : {} } : e.name];
18074
+ }
18075
+ return [];
18076
+ }) : [];
18077
+ const natives = Array.isArray(ind.natives) ? ind.natives.flatMap((n) => {
18078
+ if (typeof n === "string") return [n];
18079
+ if (n != null && typeof n === "object" && typeof n.type === "string") {
18080
+ const e = n;
18081
+ const inputs = bag(e.inputs);
18082
+ const hidden = e.hidden === true;
18083
+ return [inputs || hidden ? { type: e.type, ...inputs ? { inputs } : {}, ...hidden ? { hidden } : {} } : e.type];
18072
18084
  }
18073
18085
  return [];
18074
18086
  }) : [];
18075
- const natives = Array.isArray(ind.natives) ? ind.natives.filter((n) => typeof n === "string") : [];
18076
18087
  out.indicators = { manifest, natives };
18077
18088
  }
18078
18089
  const ext = sanitizeExt(c.ext);
@@ -37781,6 +37792,8 @@ function toPoints(bars, values, colors) {
37781
37792
  var ClassicIndicator = class {
37782
37793
  constructor(spec) {
37783
37794
  this.spec = spec;
37795
+ /** Null until start() — a pre-start setInputs must record without computing. */
37796
+ this.ctx = null;
37784
37797
  this.inputs = {};
37785
37798
  }
37786
37799
  start(ctx, inputs) {
@@ -37795,6 +37808,7 @@ var ClassicIndicator = class {
37795
37808
  }
37796
37809
  setInputs(inputs) {
37797
37810
  this.inputs = inputs;
37811
+ if (!this.ctx) return;
37798
37812
  this.recompute();
37799
37813
  }
37800
37814
  /** Nothing to free — the compute reads the live bar accessor on demand. */
@@ -37806,6 +37820,7 @@ var ClassicIndicator = class {
37806
37820
  stop() {
37807
37821
  }
37808
37822
  recompute() {
37823
+ if (!this.ctx) return;
37809
37824
  const bars = this.ctx.bars();
37810
37825
  const out = this.spec.compute(bars, this.inputs);
37811
37826
  const instanceId = this.spec.type;
@@ -41736,6 +41751,11 @@ function cellDrawings(opt) {
41736
41751
  if (opt === true || opt == null) return { toolbar: false };
41737
41752
  return { ...opt, toolbar: false };
41738
41753
  }
41754
+ function nativeLedgerEntry(handle) {
41755
+ const inputs = inputDeltas(handle.inputs, handle.inputValues());
41756
+ const hidden = !handle.visible;
41757
+ return inputs || hidden ? { type: handle.nativeType, ...inputs ? { inputs } : {}, ...hidden ? { hidden: true } : {} } : handle.nativeType;
41758
+ }
41739
41759
  function instanceDeltas(handle) {
41740
41760
  if (!handle) return void 0;
41741
41761
  const inputs = inputDeltas(handle.inputs, handle.inputValues());
@@ -41858,10 +41878,13 @@ var ChartCell = class {
41858
41878
  if (seed.rendererConfig != null) this.inner.renderer.applyConfig(seed.rendererConfig);
41859
41879
  if (seed.drawings != null) this.inner.drawings.fromJSON(seed.drawings);
41860
41880
  if (seed.indicators) {
41861
- for (const type of seed.indicators.natives) this.inner.addNativeIndicator(type);
41881
+ for (const entry of seed.indicators.natives) {
41882
+ const handle = this.inner.addNativeIndicator(ledgerNativeType(entry));
41883
+ this.applyNativeLedgerEntry(handle, entry);
41884
+ }
41862
41885
  this.pendingManifestNames = [...seed.indicators.manifest];
41863
41886
  }
41864
- this.volumeIntent = seed.indicators ? seed.indicators.natives.includes("volume") : deps.volume;
41887
+ this.volumeIntent = seed.indicators ? seed.indicators.natives.some((e) => ledgerNativeType(e) === "volume") : deps.volume;
41865
41888
  this.extState = { ...seed.ext ?? {} };
41866
41889
  this.inner.on("load:end", () => {
41867
41890
  this.volumeMayBePending = false;
@@ -41933,6 +41956,7 @@ var ChartCell = class {
41933
41956
  this.refreshNativeCatalog();
41934
41957
  });
41935
41958
  this.inner.on("indicator:inputs", () => this.deps.onStateDirty());
41959
+ this.inner.on("indicator:visibility", () => this.deps.onStateDirty());
41936
41960
  this.inner.on("indicator:removed", ({ id: id2 }) => {
41937
41961
  if (this.destroyed) return;
41938
41962
  const idx = this.instances.findIndex((it) => it.handle?.id === id2);
@@ -42377,7 +42401,7 @@ var ChartCell = class {
42377
42401
  if (list.length === 0) return;
42378
42402
  for (const led of this.pendingManifestNames) {
42379
42403
  const entry = list.find((e) => e.name === ledgerEntryName(led));
42380
- if (entry) this.addManifestInstance(entry, { record: false, ...typeof led === "object" ? { inputs: led.inputs, props: led.props } : {} });
42404
+ if (entry) this.addManifestInstance(entry, { record: false, ...typeof led === "object" ? { inputs: led.inputs, props: led.props, hidden: led.hidden } : {} });
42381
42405
  }
42382
42406
  this.pendingManifestNames = null;
42383
42407
  return;
@@ -42396,23 +42420,35 @@ var ChartCell = class {
42396
42420
  applyIndicatorLedger(led) {
42397
42421
  const chart = this.inner;
42398
42422
  if (!chart) return;
42399
- this.volumeIntent = led.natives.includes("volume");
42423
+ this.volumeIntent = led.natives.some((e) => ledgerNativeType(e) === "volume");
42400
42424
  this.history.silently(() => {
42401
42425
  const owed = /* @__PURE__ */ new Map();
42402
- for (const type of led.natives) owed.set(type, (owed.get(type) ?? 0) + 1);
42426
+ for (const e of led.natives) {
42427
+ const type = ledgerNativeType(e);
42428
+ const queue = owed.get(type);
42429
+ if (queue) queue.push(e);
42430
+ else owed.set(type, [e]);
42431
+ }
42403
42432
  for (const h of this.nativeHandles()) {
42404
- const type = h.nativeType;
42405
- const n = owed.get(type) ?? 0;
42406
- if (n > 0) owed.set(type, n - 1);
42433
+ const entry = owed.get(h.nativeType)?.shift();
42434
+ if (entry !== void 0) this.applyNativeLedgerEntry(h, entry);
42407
42435
  else h.remove();
42408
42436
  }
42409
- for (const [type, n] of owed) for (let i = 0; i < n; i++) chart.addNativeIndicator(type);
42437
+ for (const queue of owed.values()) {
42438
+ for (const e of queue) {
42439
+ const h = chart.addNativeIndicator(ledgerNativeType(e));
42440
+ this.applyNativeLedgerEntry(h, e);
42441
+ }
42442
+ }
42410
42443
  for (const it of [...this.instances]) this.dropInstance(it);
42411
42444
  if (this.manifest.length > 0) {
42412
42445
  for (const item of led.manifest) {
42413
42446
  const entry = this.manifest.find((e) => e.name === ledgerEntryName(item));
42414
42447
  if (entry)
42415
- this.addManifestInstance(entry, { record: false, ...typeof item === "object" ? { inputs: item.inputs, props: item.props } : {} });
42448
+ this.addManifestInstance(entry, {
42449
+ record: false,
42450
+ ...typeof item === "object" ? { inputs: item.inputs, props: item.props, hidden: item.hidden } : {}
42451
+ });
42416
42452
  }
42417
42453
  this.pendingManifestNames = null;
42418
42454
  } else if (!this.deps.manifestSettled()) {
@@ -42471,7 +42507,7 @@ var ChartCell = class {
42471
42507
  addExternalIndicator(entry) {
42472
42508
  this.addManifestInstance(
42473
42509
  { ...entry, enabled: true },
42474
- { external: true, ...entry.inputs ? { inputs: entry.inputs } : {}, ...entry.props ? { props: entry.props } : {} }
42510
+ { external: true, ...entry.inputs ? { inputs: entry.inputs } : {}, ...entry.props ? { props: entry.props } : {}, ...entry.hidden ? { hidden: true } : {} }
42475
42511
  );
42476
42512
  }
42477
42513
  /** Add ONE instance of a manifest entry (repeatable — duplicates are legitimate). */
@@ -42479,6 +42515,7 @@ var ChartCell = class {
42479
42515
  if (this.destroyed) return;
42480
42516
  const values = opts.inputs || opts.props ? { inputs: opts.inputs, props: opts.props } : void 0;
42481
42517
  const it = { entry, handle: this.addToChart(entry, values), ...opts.external ? { external: true } : {}, ...values ? { values } : {} };
42518
+ if (opts.hidden) it.handle?.setVisible(false);
42482
42519
  this.instances.push(it);
42483
42520
  this.deps.onIndicatorsChanged(this.id);
42484
42521
  if (opts.record === false) return;
@@ -42522,6 +42559,29 @@ var ChartCell = class {
42522
42559
  /** Add a native indicator. A multi-instance type gets a fresh instance every time; a
42523
42560
  * single-instance type already on the chart hands back its existing one — nothing
42524
42561
  * changed, so nothing enters the undo timeline. */
42562
+ /**
42563
+ * Converge one native handle to a restored ledger entry: every schema key gets the
42564
+ * entry's value or its declaration default (the DOCUMENT is the truth — a live
42565
+ * tweak must not survive a restore that says otherwise), and visibility follows
42566
+ * the `hidden` flag. Skips the input write when nothing differs — `setInputs`
42567
+ * re-runs the indicator, and a no-op restore must not flicker every native.
42568
+ */
42569
+ applyNativeLedgerEntry(handle, entry) {
42570
+ const wanted = typeof entry === "string" ? void 0 : entry.inputs;
42571
+ if (handle.inputs.length > 0) {
42572
+ const current = handle.inputValues();
42573
+ const next = {};
42574
+ for (const schema of handle.inputs) {
42575
+ const target = wanted?.[schema.key] ?? schema.defval;
42576
+ if (JSON.stringify(current[schema.key]) !== JSON.stringify(target)) next[schema.key] = target;
42577
+ }
42578
+ if (Object.keys(next).length > 0) handle.setInputs(next);
42579
+ } else if (wanted) {
42580
+ handle.setInputs(wanted);
42581
+ }
42582
+ const visible = !(typeof entry === "object" && entry.hidden);
42583
+ if (handle.visible !== visible) handle.setVisible(visible);
42584
+ }
42525
42585
  addNative(type) {
42526
42586
  const chart = this.inner;
42527
42587
  if (!chart) return;
@@ -42685,10 +42745,13 @@ var ChartCell = class {
42685
42745
  // (`ctx.addIndicator`) stay out: their names would never resolve against the
42686
42746
  // manifest — their plugin persists them via the `ext` seam instead.
42687
42747
  indicators: indicatorLedger({
42688
- present: this.inner ? this.inner.presentNativeIndicators() : [],
42748
+ // Live handles carry what the registry read cannot: the input DELTAS and
42749
+ // the hidden flag, so native settings/visibility survive the round-trip.
42750
+ present: this.inner ? this.nativeHandles().map((h) => nativeLedgerEntry(h)) : [],
42689
42751
  instanceEntries: this.instances.filter((it) => !it.external).map((it) => {
42690
42752
  const d = it.handle ? instanceDeltas(it.handle) : it.values;
42691
- return d ? { name: it.entry.name, ...d } : it.entry.name;
42753
+ const hidden = it.handle ? !it.handle.visible : false;
42754
+ return d || hidden ? { name: it.entry.name, ...d ?? {}, ...hidden ? { hidden: true } : {} } : it.entry.name;
42692
42755
  }),
42693
42756
  pendingManifest: this.pendingManifestNames,
42694
42757
  manifestSettled: this.deps.manifestSettled(),
@@ -1,8 +1,8 @@
1
1
  import { O as OHLCV, V as VisibleRangePreset, a as VisibleRange, b as VelaOptions, I as InputValue, c as VelaTheme, N as NativeBackend, d as MarketSession } from './options-BCRmYALw.cjs';
2
- import { S as SyncSetting, V as VelaStorage, C as CellState, W as WidgetHistory, R as ResolvedIndicator, a as StatuslinePart, b as RangePreset, T as TrackSizes, c as VelaShellOptions, d as SyncOptions, e as SyncKind, f as WorkspaceState } from './statusline-model-7ECSDtgt.cjs';
3
- export { g as ChartState, P as PanelsState, h as decodeState, i as encodeState, s as sanitizeState } from './statusline-model-7ECSDtgt.cjs';
2
+ import { S as SyncSetting, V as VelaStorage, C as CellState, W as WidgetHistory, R as ResolvedIndicator, a as StatuslinePart, b as RangePreset, T as TrackSizes, c as VelaShellOptions, d as SyncOptions, e as SyncKind, f as WorkspaceState } from './statusline-model-E7CMw5pQ.cjs';
3
+ export { g as ChartState, P as PanelsState, h as decodeState, i as encodeState, s as sanitizeState } from './statusline-model-E7CMw5pQ.cjs';
4
4
  import { K as KeymapManager } from './keymap-CGOz5F5f.cjs';
5
- import { I as IndicatorHandle, S as ScriptingEngine, W as WidgetContext, V as Vela, E as ExternalIndicatorEntry, a as ScriptRun } from './contributions-DEPRtkmG.cjs';
5
+ import { I as IndicatorHandle, S as ScriptingEngine, W as WidgetContext, V as Vela, E as ExternalIndicatorEntry, a as ScriptRun } from './contributions-D8HdlKmp.cjs';
6
6
  import { M as MarketDataFeed } from './DataProvider-UtWw2CgJ.cjs';
7
7
 
8
8
  /** The cells that follow `originId` under `setting` — PURE (never includes the origin). */
@@ -360,12 +360,21 @@ declare class ChartCell {
360
360
  external?: boolean;
361
361
  inputs?: Record<string, InputValue>;
362
362
  props?: Record<string, InputValue>;
363
+ hidden?: boolean;
363
364
  }): void;
364
365
  private removeInstance;
365
366
  private dropInstance;
366
367
  /** Add a native indicator. A multi-instance type gets a fresh instance every time; a
367
368
  * single-instance type already on the chart hands back its existing one — nothing
368
369
  * changed, so nothing enters the undo timeline. */
370
+ /**
371
+ * Converge one native handle to a restored ledger entry: every schema key gets the
372
+ * entry's value or its declaration default (the DOCUMENT is the truth — a live
373
+ * tweak must not survive a restore that says otherwise), and visibility follows
374
+ * the `hidden` flag. Skips the input write when nothing differs — `setInputs`
375
+ * re-runs the indicator, and a no-op restore must not flicker every native.
376
+ */
377
+ private applyNativeLedgerEntry;
369
378
  addNative(type: string): void;
370
379
  private removeNative;
371
380
  /** The chart's native instances, insertion order — the picker's on-chart rows and
@@ -1,8 +1,8 @@
1
1
  import { O as OHLCV, V as VisibleRangePreset, a as VisibleRange, b as VelaOptions, I as InputValue, c as VelaTheme, N as NativeBackend, d as MarketSession } from './options-BCRmYALw.js';
2
- import { S as SyncSetting, V as VelaStorage, C as CellState, W as WidgetHistory, R as ResolvedIndicator, a as StatuslinePart, b as RangePreset, T as TrackSizes, c as VelaShellOptions, d as SyncOptions, e as SyncKind, f as WorkspaceState } from './statusline-model-D1Fhs8Dk.js';
3
- export { g as ChartState, P as PanelsState, h as decodeState, i as encodeState, s as sanitizeState } from './statusline-model-D1Fhs8Dk.js';
2
+ import { S as SyncSetting, V as VelaStorage, C as CellState, W as WidgetHistory, R as ResolvedIndicator, a as StatuslinePart, b as RangePreset, T as TrackSizes, c as VelaShellOptions, d as SyncOptions, e as SyncKind, f as WorkspaceState } from './statusline-model-CCP1zm_Z.js';
3
+ export { g as ChartState, P as PanelsState, h as decodeState, i as encodeState, s as sanitizeState } from './statusline-model-CCP1zm_Z.js';
4
4
  import { K as KeymapManager } from './keymap-CGOz5F5f.js';
5
- import { I as IndicatorHandle, S as ScriptingEngine, W as WidgetContext, V as Vela, E as ExternalIndicatorEntry, a as ScriptRun } from './contributions-5nz3PLRe.js';
5
+ import { I as IndicatorHandle, S as ScriptingEngine, W as WidgetContext, V as Vela, E as ExternalIndicatorEntry, a as ScriptRun } from './contributions-FqIWhN4p.js';
6
6
  import { M as MarketDataFeed } from './DataProvider-Cb-2lC5O.js';
7
7
 
8
8
  /** The cells that follow `originId` under `setting` — PURE (never includes the origin). */
@@ -360,12 +360,21 @@ declare class ChartCell {
360
360
  external?: boolean;
361
361
  inputs?: Record<string, InputValue>;
362
362
  props?: Record<string, InputValue>;
363
+ hidden?: boolean;
363
364
  }): void;
364
365
  private removeInstance;
365
366
  private dropInstance;
366
367
  /** Add a native indicator. A multi-instance type gets a fresh instance every time; a
367
368
  * single-instance type already on the chart hands back its existing one — nothing
368
369
  * changed, so nothing enters the undo timeline. */
370
+ /**
371
+ * Converge one native handle to a restored ledger entry: every schema key gets the
372
+ * entry's value or its declaration default (the DOCUMENT is the truth — a live
373
+ * tweak must not survive a restore that says otherwise), and visibility follows
374
+ * the `hidden` flag. Skips the input write when nothing differs — `setInputs`
375
+ * re-runs the indicator, and a no-op restore must not flicker every native.
376
+ */
377
+ private applyNativeLedgerEntry;
369
378
  addNative(type: string): void;
370
379
  private removeNative;
371
380
  /** The chart's native instances, insertion order — the picker's on-chart rows and
package/dist/workspace.js CHANGED
@@ -1,5 +1,5 @@
1
- export { ChartCell, GRID_PICKER_MAX, VelaWorkspace, activeAfterLayout, decodeState, encodeState, ensureLayout, evenTracks, gridStyles, layoutDefinition, layoutForGrid, layoutShape, layouts, memoryStorageAdapter, rangesWithin, registerBuiltinLayouts, registerLayout, resizeTracks, sanitizeState, syncTargets, trackOffsets, unregisterLayout } from './chunk-BXF7VNNE.js';
2
- import './chunk-22QJKGXX.js';
1
+ export { ChartCell, GRID_PICKER_MAX, VelaWorkspace, activeAfterLayout, decodeState, encodeState, ensureLayout, evenTracks, gridStyles, layoutDefinition, layoutForGrid, layoutShape, layouts, memoryStorageAdapter, rangesWithin, registerBuiltinLayouts, registerLayout, resizeTracks, sanitizeState, syncTargets, trackOffsets, unregisterLayout } from './chunk-M6T5A733.js';
2
+ import './chunk-4Q4B5AO3.js';
3
3
  import './chunk-IFJJPXSV.js';
4
4
  import './chunk-XCBJU674.js';
5
5
  import './chunk-T5Z5YUCF.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxalgo/vela",
3
- "version": "0.6.18",
3
+ "version": "0.6.20",
4
4
  "description": "Open-source charting library with a native high-performance renderer, drawing tools, pluggable chart types and pluggable scripting engines.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://luxalgo.com/vela",