@luxalgo/vela 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/{DataProvider-wbtJ3-Sa.d.cts → DataProvider-Bw58CjYy.d.cts} +1 -1
  2. package/dist/{DataProvider-oH78tYXL.d.ts → DataProvider-Byo8pEv0.d.ts} +1 -1
  3. package/dist/{chunk-KWI3YDBW.js → chunk-ALTGHKIM.js} +584 -25
  4. package/dist/{chunk-TO3GIK7Z.js → chunk-AUOB7A5Y.js} +2 -2
  5. package/dist/{chunk-VHGACEHO.js → chunk-I2U4NZD2.js} +7 -1
  6. package/dist/{chunk-2IPXYM4B.js → chunk-MOJ4T26N.js} +88 -5
  7. package/dist/{chunk-HMHA733L.js → chunk-UNUVPQFW.js} +1924 -734
  8. package/dist/{chunk-G7B7ZCBF.js → chunk-WY5H4S4I.js} +1 -1
  9. package/dist/{contributions-BhOBRenr.d.cts → contributions-BY3zSYiZ.d.ts} +56 -5
  10. package/dist/{contributions-HGqnNb_P.d.ts → contributions-DOm40g5-.d.cts} +56 -5
  11. package/dist/index.cjs +2583 -828
  12. package/dist/index.d.cts +9 -15
  13. package/dist/index.d.ts +9 -15
  14. package/dist/index.js +4 -4
  15. package/dist/{options-lMUwmRwh.d.cts → options-CSXbjMM5.d.cts} +64 -4
  16. package/dist/{options-lMUwmRwh.d.ts → options-CSXbjMM5.d.ts} +64 -4
  17. package/dist/{plugin-Cr2Pj8q8.d.ts → plugin-BDxUhGO3.d.ts} +3 -3
  18. package/dist/{plugin-Do5J5xuF.d.cts → plugin-CiQVyETg.d.cts} +3 -3
  19. package/dist/plugin.cjs +555 -17
  20. package/dist/plugin.d.cts +4 -4
  21. package/dist/plugin.d.ts +4 -4
  22. package/dist/plugin.js +2 -2
  23. package/dist/providers/binance.d.cts +2 -2
  24. package/dist/providers/binance.d.ts +2 -2
  25. package/dist/providers/coinbase.d.cts +2 -2
  26. package/dist/providers/coinbase.d.ts +2 -2
  27. package/dist/providers/hyperliquid.d.cts +2 -2
  28. package/dist/providers/hyperliquid.d.ts +2 -2
  29. package/dist/{statusline-model-B-2xGlB_.d.cts → statusline-model-C9tYXuux.d.ts} +19 -4
  30. package/dist/{statusline-model-CY1wzxHg.d.ts → statusline-model-DUBX6Fib.d.cts} +19 -4
  31. package/dist/ui.d.cts +1 -1
  32. package/dist/ui.d.ts +1 -1
  33. package/dist/ui.js +3 -3
  34. package/dist/vela.global.js +2590 -835
  35. package/dist/vela.global.min.js +124 -54
  36. package/dist/widget.cjs +2807 -969
  37. package/dist/widget.d.cts +6 -6
  38. package/dist/widget.d.ts +6 -6
  39. package/dist/widget.js +7 -7
  40. package/dist/workspace.cjs +2807 -969
  41. package/dist/workspace.d.cts +19 -5
  42. package/dist/workspace.d.ts +19 -5
  43. package/dist/workspace.js +6 -6
  44. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-G7B7ZCBF.js';
2
- import { injectStyles, holdForExit, announceSurface } from './chunk-VHGACEHO.js';
1
+ import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-WY5H4S4I.js';
2
+ import { injectStyles, holdForExit, announceSurface } from './chunk-I2U4NZD2.js';
3
3
  import * as tooltip from '@zag-js/tooltip';
4
4
  import * as dialog from '@zag-js/dialog';
5
5
 
@@ -239,6 +239,12 @@ function mix(base, top, alpha) {
239
239
  const c = (x, y) => Math.round(x + (y - x) * alpha);
240
240
  return `rgb(${c(b.r, t.r)},${c(b.g, t.g)},${c(b.b, t.b)})`;
241
241
  }
242
+ function toHex6(color, fallback = "#888888") {
243
+ const c = parseRgb(color);
244
+ if (!c) return fallback;
245
+ const h = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
246
+ return `#${h(c.r)}${h(c.g)}${h(c.b)}`;
247
+ }
242
248
  function isDarkColor(color) {
243
249
  const c = parseRgb(color);
244
250
  if (!c) return true;
@@ -331,4 +337,4 @@ function holdForExit(els, done, opts = {}) {
331
337
  };
332
338
  }
333
339
 
334
- export { ACCENT, ACCENT_BRIGHT, BEARISH, BULLISH, CATEGORICAL, CHIP_PLATE, CROSSHAIR, FIELD_FOCUS_CSS, FIELD_FOCUS_RING, HIGHLIGHT, INFO, INVALID, MARKER, NEUTRAL, SERIES_LINE, SESSION_OFF, SESSION_POST, SESSION_PRE, SLATE, SLATE_DEEP, SURFACE_CLOSE_EVENT, SURFACE_OPEN_EVENT, TRADE_EXIT, TRADE_LONG, TRADE_SHORT, VALID, WARNING, announceSurface, categoricalColor, holdForExit, icon, iconAt, iconEl, iconMarkup, injectStyles, isDarkColor, mix, overlayScrollbarCss, registerIcon, svg16, svg24, svg24Solid, withAlpha };
340
+ export { ACCENT, ACCENT_BRIGHT, BEARISH, BULLISH, CATEGORICAL, CHIP_PLATE, CROSSHAIR, FIELD_FOCUS_CSS, FIELD_FOCUS_RING, HIGHLIGHT, INFO, INVALID, MARKER, NEUTRAL, SERIES_LINE, SESSION_OFF, SESSION_POST, SESSION_PRE, SLATE, SLATE_DEEP, SURFACE_CLOSE_EVENT, SURFACE_OPEN_EVENT, TRADE_EXIT, TRADE_LONG, TRADE_SHORT, VALID, WARNING, announceSurface, categoricalColor, holdForExit, icon, iconAt, iconEl, iconMarkup, injectStyles, isDarkColor, mix, overlayScrollbarCss, registerIcon, svg16, svg24, svg24Solid, toHex6, withAlpha };
@@ -1,8 +1,8 @@
1
- import { parseSymbol, priceStyleIds, BUILTIN_PRICE_STYLES, SecondClock, isGroupRow, defaultMemberOf, groupKeyOf, groupMembers, LEGEND_AT_TOP_ATTR, normalizeSession, Vela, TypedEventBus, timeframeToMs, MultiProviderFeed, registerBuiltinChartTypes, resolveTheme, buildToolbar, createCustomMark, createAttributionMark, DrawingToolbar, applyAttributionMarkTheme, sharedBarStore, CANDLE_OVERRIDE_KEYS } from './chunk-HMHA733L.js';
2
- import { chartType, resolveTopbarComposition, topbarActionOverride, TOPBAR_BUILTIN_IDS, widgetActions, tzButtonLabel, resolveTimezone, timezoneMenuRows, SidePanel, sidePanels, DEFAULT_PANEL_ORDER, symbolRanking, paneScaleAt, composeMenu, priceAxisItems, scaleChoiceOf, timeAxisItems, bodyItems, scaleWrites, invertWrite, settingsSectionOf, resolveEngines, legendActionsProviderFor, legendCalloutsProviderFor, normalizeTimezone, isExchangeTimezone, statePersistenceHandlers, topbarHas, rendererDefaults, mobilePlacement, widgetAttachments, getDrawingType, inputDeltas } from './chunk-KWI3YDBW.js';
3
- import { Tooltip, KeymapManager, isEditableTarget, Drawer } from './chunk-TO3GIK7Z.js';
4
- import { Menu, Dialog, CalloutBubble, applyPlotOverlayTokens, ensureUIHost } from './chunk-G7B7ZCBF.js';
5
- import { registerIcon, svg16, injectStyles, iconEl, iconMarkup, iconAt, SESSION_OFF, SESSION_POST, SESSION_PRE, announceSurface, holdForExit, icon, categoricalColor } from './chunk-VHGACEHO.js';
1
+ import { parseSymbol, priceStyleIds, BUILTIN_PRICE_STYLES, SecondClock, isGroupRow, defaultMemberOf, groupKeyOf, groupMembers, LEGEND_AT_TOP_ATTR, normalizeSession, Vela, TypedEventBus, timeframeToMs, MultiProviderFeed, registerBuiltinChartTypes, resolveTheme, buildToolbar, createCustomMark, createAttributionMark, DrawingToolbar, applyAttributionMarkTheme, sharedBarStore, CANDLE_OVERRIDE_KEYS } from './chunk-UNUVPQFW.js';
2
+ import { chartType, resolveTopbarComposition, topbarActionOverride, TOPBAR_BUILTIN_IDS, widgetActions, tzButtonLabel, resolveTimezone, timezoneMenuRows, SidePanel, sidePanels, DEFAULT_PANEL_ORDER, symbolRanking, paneScaleAt, composeMenu, priceAxisItems, scaleChoiceOf, timeAxisItems, bodyItems, scaleWrites, invertWrite, settingsSectionOf, resolveEngines, legendActionsProviderFor, legendCalloutsProviderFor, normalizeTimezone, isExchangeTimezone, statePersistenceHandlers, topbarHas, rendererDefaults, mobilePlacement, widgetAttachments, getDrawingType, inputDeltas } from './chunk-ALTGHKIM.js';
3
+ import { Tooltip, KeymapManager, isEditableTarget, Drawer } from './chunk-AUOB7A5Y.js';
4
+ import { Menu, Dialog, CalloutBubble, applyPlotOverlayTokens, ensureUIHost } from './chunk-WY5H4S4I.js';
5
+ import { registerIcon, svg16, injectStyles, iconEl, iconMarkup, iconAt, SESSION_OFF, SESSION_POST, SESSION_PRE, announceSurface, holdForExit, icon, categoricalColor } from './chunk-I2U4NZD2.js';
6
6
  import { baseOf } from './chunk-W4EJWLEO.js';
7
7
 
8
8
  // src/widget/timeframe.ts
@@ -3931,6 +3931,8 @@ function sanitizeState(doc) {
3931
3931
  const favs = d.timeframeFavorites.filter((f) => typeof f === "string");
3932
3932
  if (favs.length > 0) out.timeframeFavorites = favs;
3933
3933
  }
3934
+ const tools = sanitizeDrawingTools(d.drawingTools);
3935
+ if (tools) out.drawingTools = tools;
3934
3936
  const sync = sanitizeSync(d.sync);
3935
3937
  if (sync) out.sync = sync;
3936
3938
  const tracks = sanitizeTrackSizes(d.trackSizes);
@@ -3949,6 +3951,28 @@ function sanitizeExt(raw) {
3949
3951
  }
3950
3952
  return Object.keys(out).length > 0 ? out : null;
3951
3953
  }
3954
+ function sanitizeDrawingTools(raw) {
3955
+ if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return null;
3956
+ const r = raw;
3957
+ const out = {};
3958
+ if (r.defaults != null && typeof r.defaults === "object" && !Array.isArray(r.defaults)) {
3959
+ const defaults = {};
3960
+ for (const [type, value] of Object.entries(r.defaults)) {
3961
+ if (type.length > 0 && value != null && typeof value === "object" && !Array.isArray(value)) defaults[type] = value;
3962
+ }
3963
+ if (Object.keys(defaults).length > 0) out.defaults = defaults;
3964
+ }
3965
+ if (r.templates != null && typeof r.templates === "object" && !Array.isArray(r.templates)) {
3966
+ const templates = {};
3967
+ for (const [type, list] of Object.entries(r.templates)) {
3968
+ if (type.length > 0 && Array.isArray(list) && list.length > 0) templates[type] = list;
3969
+ }
3970
+ if (Object.keys(templates).length > 0) out.templates = templates;
3971
+ }
3972
+ if (r.magnet === "off" || r.magnet === "weak" || r.magnet === "strong") out.magnet = r.magnet;
3973
+ if (typeof r.stay === "boolean") out.stay = r.stay;
3974
+ return Object.keys(out).length > 0 ? out : null;
3975
+ }
3952
3976
  function sanitizeCell(raw) {
3953
3977
  if (raw == null || typeof raw !== "object") return null;
3954
3978
  const c = raw;
@@ -8794,6 +8818,12 @@ var VelaWorkspace = class {
8794
8818
  this.historyUnsub = null;
8795
8819
  /** Favorite drawing tools — a WORKSPACE preference (one star set, every cell). */
8796
8820
  this.favs = [];
8821
+ /** Every drawing tool's remembered settings — a SHARED pref, mirrored onto every cell. */
8822
+ this.toolDefs = {};
8823
+ /** Every drawing tool's saved looks — a SHARED pref like the remembered settings. */
8824
+ this.toolTemplates = {};
8825
+ /** Re-entrancy guard while one cell's remembered settings fan out to the others. */
8826
+ this.toolDefsBusy = false;
8797
8827
  /** Favorite timeframes — the shared topbar's quick-switch chips, one set for the grid. */
8798
8828
  this.tfFavs = [];
8799
8829
  /** Live sync configuration (mutable copy of the option). */
@@ -8897,6 +8927,7 @@ var VelaWorkspace = class {
8897
8927
  this.timezone = boot?.timezone ?? opts.timezone ?? "Etc/UTC";
8898
8928
  if (boot?.favorites) this.favs = [...boot.favorites];
8899
8929
  if (boot?.timeframeFavorites) this.tfFavs = [...boot.timeframeFavorites];
8930
+ if (boot?.drawingTools) this.adoptDrawingTools(boot.drawingTools);
8900
8931
  const sync = boot?.sync ?? opts.sync;
8901
8932
  for (const kind of SYNC_KINDS) this.applySyncSetting(kind, sync?.[kind]);
8902
8933
  this.monoLayout = opts.layout === false;
@@ -9304,6 +9335,8 @@ var VelaWorkspace = class {
9304
9335
  if (this.activeId) state.activeCellId = this.activeId;
9305
9336
  if (this.favs.length > 0) state.favorites = [...this.favs];
9306
9337
  if (this.tfFavs.length > 0) state.timeframeFavorites = [...this.tfFavs];
9338
+ const tools = this.drawingToolsState();
9339
+ if (tools) state.drawingTools = tools;
9307
9340
  if (this.trackSizes.size > 0) state.trackSizes = Object.fromEntries([...this.trackSizes].map(([k, v]) => [k, { ...v }]));
9308
9341
  const panels = this.dock.getState();
9309
9342
  if (panels) state.panels = panels;
@@ -9337,6 +9370,7 @@ var VelaWorkspace = class {
9337
9370
  const st = sanitizeState(state);
9338
9371
  if (!st) return;
9339
9372
  if (st.favorites) this.favs = [...st.favorites];
9373
+ if (st.drawingTools) this.adoptDrawingTools(st.drawingTools);
9340
9374
  if (st.timeframeFavorites) {
9341
9375
  this.tfFavs = [...st.timeframeFavorites];
9342
9376
  this.topbar.setTimeframeFavorites(this.tfFavs);
@@ -9352,6 +9386,7 @@ var VelaWorkspace = class {
9352
9386
  if (st.favorites) {
9353
9387
  for (const cell of this.cellsById.values()) cell.chart.drawings.setFavorites(this.favs);
9354
9388
  }
9389
+ if (st.drawingTools) this.pushToolDefaults(null);
9355
9390
  this.drawingLinks.clear();
9356
9391
  this.styleSyncBusy = true;
9357
9392
  try {
@@ -9667,6 +9702,37 @@ var VelaWorkspace = class {
9667
9702
  refocusActive() {
9668
9703
  if (this.activeId) this.cellsById.get(this.activeId)?.chart.renderer.focus();
9669
9704
  }
9705
+ /** Take a document's drawing-tool prefs as the shared mirrors (cells pick them up as they
9706
+ * are built, or from {@link pushToolDefaults} / the active-cell projection). */
9707
+ adoptDrawingTools(tools) {
9708
+ if (tools.defaults) this.toolDefs = { ...tools.defaults };
9709
+ if (tools.templates) this.toolTemplates = { ...tools.templates };
9710
+ if (tools.magnet) this.globalSnap = tools.magnet;
9711
+ if (tools.stay !== void 0) this.globalStay = tools.stay;
9712
+ }
9713
+ /** Mirror the shared remembered settings onto every cell but `from` (the cell they came from).
9714
+ * Receiving them is not an edit: the cells' `drawing:defaults` echoes are ignored. */
9715
+ pushToolDefaults(from, cells = this.cellsById.values()) {
9716
+ this.toolDefsBusy = true;
9717
+ try {
9718
+ for (const other of cells) {
9719
+ if (other === from) continue;
9720
+ other.chart.drawings.setToolDefaults(this.toolDefs);
9721
+ other.chart.drawings.setToolTemplates(this.toolTemplates);
9722
+ }
9723
+ } finally {
9724
+ this.toolDefsBusy = false;
9725
+ }
9726
+ }
9727
+ /** The drawing-tool prefs worth saving; null when every one is at its default. */
9728
+ drawingToolsState() {
9729
+ const out = {};
9730
+ if (Object.keys(this.toolDefs).length > 0) out.defaults = { ...this.toolDefs };
9731
+ if (Object.keys(this.toolTemplates).length > 0) out.templates = { ...this.toolTemplates };
9732
+ if (this.globalSnap !== "off") out.magnet = this.globalSnap;
9733
+ if (this.globalStay) out.stay = true;
9734
+ return Object.keys(out).length > 0 ? out : null;
9735
+ }
9670
9736
  /** Debounced dirty mark: one `state:changed` (+ one storage write in persist mode)
9671
9737
  * per burst of edits, flushed hard on unload/destroy. */
9672
9738
  markStateDirty() {
@@ -9889,6 +9955,7 @@ var VelaWorkspace = class {
9889
9955
  cell.chart.renderer.setWallClock(this.clock);
9890
9956
  cell.setControlsSuspended(this.layoutCtl.current === "mobile");
9891
9957
  if (this.favs.length > 0) cell.chart.drawings.setFavorites(this.favs);
9958
+ if (Object.keys(this.toolDefs).length > 0 || Object.keys(this.toolTemplates).length > 0) this.pushToolDefaults(null, [cell]);
9892
9959
  cell.setManifest(this.manifest, pooled?.indicators == null);
9893
9960
  cell.restorePersistedExt();
9894
9961
  this.events.emit("cell:created", { id });
@@ -9921,6 +9988,18 @@ var VelaWorkspace = class {
9921
9988
  this.drawToolbar?.setFavorites(favorites);
9922
9989
  this.markStateDirty();
9923
9990
  });
9991
+ chart.on("drawing:defaults", () => {
9992
+ if (this.toolDefsBusy) return;
9993
+ this.toolDefs = chart.drawings.toolDefaults();
9994
+ this.pushToolDefaults(cell);
9995
+ this.markStateDirty();
9996
+ });
9997
+ chart.on("drawing:templates", () => {
9998
+ if (this.toolDefsBusy) return;
9999
+ this.toolTemplates = chart.drawings.toolTemplates();
10000
+ this.pushToolDefaults(cell);
10001
+ this.markStateDirty();
10002
+ });
9924
10003
  chart.renderer.onCrosshairMove((e) => this.propagateCrosshair(cell.id, e.time, e.paneKind === "price" ? e.price : null));
9925
10004
  chart.on("drawing:created", ({ id }) => {
9926
10005
  this.propagateDrawing(cell.id, id);
@@ -9942,13 +10021,17 @@ var VelaWorkspace = class {
9942
10021
  });
9943
10022
  chart.on("drawing:snap", ({ mode }) => {
9944
10023
  if (cell.id !== this.activeId) return;
10024
+ const changed = mode !== this.globalSnap;
9945
10025
  this.globalSnap = mode;
9946
10026
  this.drawToolbar?.setMagnetMode(mode);
10027
+ if (changed) this.markStateDirty();
9947
10028
  });
9948
10029
  chart.on("drawing:stay", ({ on }) => {
9949
10030
  if (cell.id !== this.activeId) return;
10031
+ const changed = on !== this.globalStay;
9950
10032
  this.globalStay = on;
9951
10033
  this.drawToolbar?.setStayMode(on);
10034
+ if (changed) this.markStateDirty();
9952
10035
  });
9953
10036
  chart.on("drawing:mode", ({ mode }) => {
9954
10037
  if (cell.id !== this.activeId) return;