@luxalgo/vela 0.5.3 → 0.6.0

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 (47) hide show
  1. package/README.md +3 -2
  2. package/dist/{DataProvider-gnzv-dgc.d.cts → DataProvider-Ce6PuCzQ.d.cts} +10 -1
  3. package/dist/{DataProvider-DTOEXKTI.d.ts → DataProvider-DNx9ntBD.d.ts} +10 -1
  4. package/dist/{chunk-EY63XBFZ.js → chunk-7ROONW6H.js} +132 -23
  5. package/dist/{chunk-L5NTMWPP.js → chunk-CA3N3PYT.js} +785 -857
  6. package/dist/{chunk-LJLZR44Y.js → chunk-EMS6PO2T.js} +5 -7
  7. package/dist/chunk-OGRQW3M6.js +1328 -0
  8. package/dist/{chunk-P556H6EA.js → chunk-QWIEKZRE.js} +59 -34
  9. package/dist/{chunk-WJKLBYRM.js → chunk-ZNL2X6U2.js} +1 -1
  10. package/dist/{contributions-Ci_i3IN2.d.cts → contributions-DToMhiw3.d.ts} +9 -2
  11. package/dist/{contributions-b6AVrqqG.d.ts → contributions-Dlc7ZWZz.d.cts} +9 -2
  12. package/dist/{history-Ci3M0xLV.d.ts → history-BZADxpKx.d.cts} +5 -3
  13. package/dist/{history-Cf1lVsap.d.cts → history-BuHXJZJ2.d.ts} +5 -3
  14. package/dist/index.cjs +2761 -1597
  15. package/dist/index.d.cts +14 -6
  16. package/dist/index.d.ts +14 -6
  17. package/dist/index.js +4 -4
  18. package/dist/{options-XTBpbx0s.d.ts → options-BlQ00Fju.d.cts} +3 -1
  19. package/dist/{options-XTBpbx0s.d.cts → options-BlQ00Fju.d.ts} +3 -1
  20. package/dist/{plugin-DlidwMj6.d.cts → plugin-BNPLOQO1.d.cts} +3 -3
  21. package/dist/{plugin-DP6A4t4o.d.ts → plugin-BqjEa5r3.d.ts} +3 -3
  22. package/dist/plugin.cjs +4 -0
  23. package/dist/plugin.d.cts +4 -4
  24. package/dist/plugin.d.ts +4 -4
  25. package/dist/plugin.js +2 -2
  26. package/dist/providers/binance.d.cts +2 -2
  27. package/dist/providers/binance.d.ts +2 -2
  28. package/dist/providers/coinbase.d.cts +2 -2
  29. package/dist/providers/coinbase.d.ts +2 -2
  30. package/dist/providers/hyperliquid.d.cts +2 -2
  31. package/dist/providers/hyperliquid.d.ts +2 -2
  32. package/dist/ui.cjs +1318 -4
  33. package/dist/ui.d.cts +383 -2
  34. package/dist/ui.d.ts +383 -2
  35. package/dist/ui.js +3 -3
  36. package/dist/vela.global.js +3729 -2565
  37. package/dist/vela.global.min.js +315 -66
  38. package/dist/widget.cjs +2359 -1054
  39. package/dist/widget.d.cts +30 -16
  40. package/dist/widget.d.ts +30 -16
  41. package/dist/widget.js +37 -14
  42. package/dist/workspace.cjs +2259 -944
  43. package/dist/workspace.d.cts +10 -5
  44. package/dist/workspace.d.ts +10 -5
  45. package/dist/workspace.js +29 -8
  46. package/package.json +1 -1
  47. package/dist/chunk-ATPU5CI6.js +0 -81
@@ -1,38 +1,10 @@
1
- import { STATIC_TOKENS, themeTokens } from './chunk-ATPU5CI6.js';
2
- import { injectStyles, iconEl } from './chunk-LJLZR44Y.js';
1
+ import { injectStyles, iconEl } from './chunk-EMS6PO2T.js';
3
2
  import { VanillaMachine, normalizeProps, spreadProps } from '@zag-js/vanilla';
4
3
  export { normalizeProps, spreadProps } from '@zag-js/vanilla';
5
4
  import * as tooltip from '@zag-js/tooltip';
6
5
  import * as menu from '@zag-js/menu';
7
6
  import * as dialog from '@zag-js/dialog';
8
7
 
9
- // src/ui/tokens.ts
10
- var STATIC_ID = "vela-ui-tokens";
11
- var STATIC_DECLS = Object.entries(STATIC_TOKENS).map(([k, v]) => ` ${k}: ${v};`).join("\n");
12
- var STATIC_CSS = `
13
- .vela-ui, .vela-ui-layer {
14
- ${STATIC_DECLS}
15
- font-family: var(--vela-font, -apple-system, system-ui, sans-serif);
16
- box-sizing: border-box;
17
- }
18
- .vela-ui *, .vela-ui-layer * { box-sizing: border-box; }
19
- .vela-icon { display: inline-flex; align-items: center; flex: none; }
20
- .vela-icon svg { display: block; }
21
- `;
22
- function applyThemeTokens(el, t) {
23
- const tokens = themeTokens(t);
24
- for (const key in tokens) el.style.setProperty(key, tokens[key]);
25
- }
26
- function applyPlotOverlayTokens(host, base, config) {
27
- const layout = config?.layout;
28
- const t = layout?.background && layout.textColor ? { ...base, background: layout.background, textColor: layout.textColor } : base;
29
- applyThemeTokens(host, t);
30
- }
31
- function ensureUIHost(el, theme) {
32
- injectStyles(STATIC_ID, STATIC_CSS, el.getRootNode());
33
- el.classList.add("vela-ui");
34
- if (theme) applyThemeTokens(el, theme);
35
- }
36
8
  function runMachine(machine5, props, render) {
37
9
  const m = new VanillaMachine(machine5, props);
38
10
  const unsub = m.subscribe(render);
@@ -274,7 +246,10 @@ function menuController(opts) {
274
246
  props: {
275
247
  id: opts.id ?? nextUid("vela-menu"),
276
248
  ids: opts.triggerId ? { trigger: opts.triggerId } : void 0,
277
- positioning: { placement: opts.placement ?? "bottom-start" },
249
+ positioning: {
250
+ placement: opts.placement ?? "bottom-start",
251
+ ...opts.getAnchorRect ? { getAnchorRect: () => opts.getAnchorRect() } : {}
252
+ },
278
253
  onSelect: (d) => opts.onSelect?.(d.value),
279
254
  onOpenChange: (d) => opts.onOpenChange?.(d.open)
280
255
  },
@@ -356,6 +331,22 @@ var MENU_CSS = `
356
331
  }
357
332
  .vela-menu-switch.on { background: var(--vela-accent-bright, var(--vela-accent)); border-color: var(--vela-accent-bright, var(--vela-accent)); }
358
333
  .vela-menu-switch.on::after { transform: translateX(16px); background: var(--vela-bg); }
334
+ /* Favorite star (rows carrying \`favorite\`): reserved space always \u2014 it fades in on row
335
+ hover instead of shifting the layout \u2014 and a starred row keeps its filled star visible.
336
+ Same control language as the drawing toolbar's flyout stars. */
337
+ .vela-menu-item .vela-menu-star {
338
+ order: 98;
339
+ /* Pad the 16px icon slot into a bigger hit target without moving the row's layout. */
340
+ margin: -3px -5px -3px 0;
341
+ padding: 3px 5px;
342
+ box-sizing: content-box;
343
+ border-radius: var(--vela-radius-sm);
344
+ opacity: 0;
345
+ transition: opacity 0.1s ease, background 0.1s ease;
346
+ }
347
+ .vela-menu-item[data-highlighted] .vela-menu-star { opacity: 0.55; }
348
+ .vela-menu-item .vela-menu-star:hover { opacity: 1; background: var(--vela-hover-strong); }
349
+ .vela-menu-item .vela-menu-star.vela-fav { opacity: 0.95; color: var(--vela-highlight); }
359
350
  .vela-menu-sep { height: 1px; margin: 4px 6px; background: var(--vela-border); }
360
351
  /* Submenu trigger row: a right-aligned chevron, and it stays highlighted while its own
361
352
  list is open so the path you came down remains readable. */
@@ -374,9 +365,13 @@ var Surface = class _Surface {
374
365
  this.items = [];
375
366
  /** Branch item id → the surface it opens. */
376
367
  this.subs = /* @__PURE__ */ new Map();
368
+ /** Trigger rect captured when this level opened — the list stays put if the
369
+ * trigger then moves (favorite chips shifting the caret). */
370
+ this.pinnedAnchor = null;
377
371
  this.doc = doc;
378
372
  this.host = opts.host;
379
373
  this.onSelect = opts.onSelect;
374
+ this.onFavorite = opts.onFavorite;
380
375
  this.positioner = doc.createElement("div");
381
376
  this.positioner.className = "vela-ui-layer";
382
377
  this.list = doc.createElement("ul");
@@ -384,16 +379,25 @@ var Surface = class _Surface {
384
379
  if (opts.minWidth) this.list.style.minWidth = opts.minWidth;
385
380
  this.positioner.appendChild(this.list);
386
381
  this.host.appendChild(this.positioner);
382
+ const trigger = opts.trigger;
387
383
  this.ctrl = menuController({
388
384
  items: [],
389
385
  id: opts.id,
390
386
  placement: opts.placement,
391
387
  onSelect: (id) => this.onSelect(id),
392
- onOpenChange: opts.onOpenChange,
388
+ getAnchorRect: () => this.pinnedAnchor,
389
+ onOpenChange: (open) => {
390
+ if (open && trigger) {
391
+ const r = trigger.getBoundingClientRect();
392
+ this.pinnedAnchor = { x: r.x, y: r.y, width: r.width, height: r.height };
393
+ } else {
394
+ this.pinnedAnchor = null;
395
+ }
396
+ opts.onOpenChange?.(open);
397
+ },
393
398
  triggerId: opts.triggerId
394
399
  });
395
400
  this.mid = String(this.ctrl.props.id);
396
- const trigger = opts.trigger;
397
401
  if (opts.triggerId && trigger) trigger.id = opts.triggerId;
398
402
  this.handle = runMachine(this.ctrl.machine, this.ctrl.props, (service) => {
399
403
  const api = this.ctrl.connect(service);
@@ -473,6 +477,25 @@ var Surface = class _Surface {
473
477
  hint.textContent = item.hint;
474
478
  li.appendChild(hint);
475
479
  }
480
+ if (item.favorite !== void 0 && this.onFavorite) {
481
+ const on = item.favorite;
482
+ const star = iconEl(on ? "star-filled" : "star", doc);
483
+ star.classList.add("vela-menu-star");
484
+ if (on) star.classList.add("vela-fav");
485
+ star.removeAttribute("aria-hidden");
486
+ star.setAttribute("role", "button");
487
+ star.setAttribute("aria-label", on ? "Remove from favorites" : "Add to favorites");
488
+ star.setAttribute("aria-pressed", on ? "true" : "false");
489
+ for (const ev of ["pointerdown", "pointerup", "mousedown", "mouseup"]) {
490
+ star.addEventListener(ev, (e) => e.stopPropagation());
491
+ }
492
+ star.addEventListener("click", (e) => {
493
+ e.stopPropagation();
494
+ e.preventDefault();
495
+ this.onFavorite?.(item.id, !on);
496
+ });
497
+ li.appendChild(star);
498
+ }
476
499
  if (item.toggle) {
477
500
  const sw = doc.createElement("span");
478
501
  sw.className = "vela-menu-switch" + (item.checked ? " on" : "");
@@ -488,6 +511,7 @@ var Surface = class _Surface {
488
511
  host: this.host,
489
512
  placement: "right-start",
490
513
  onSelect: this.onSelect,
514
+ onFavorite: this.onFavorite,
491
515
  id: `${this.mid}--${item.id}`
492
516
  });
493
517
  sub.setItems(item.submenu ?? []);
@@ -511,7 +535,8 @@ var Menu = class {
511
535
  trigger: opts.trigger,
512
536
  triggerId: opts.triggerId,
513
537
  id: opts.id,
514
- minWidth: opts.minWidth
538
+ minWidth: opts.minWidth,
539
+ onFavorite: opts.onFavorite
515
540
  });
516
541
  this.root.setItems(opts.items);
517
542
  }
@@ -1014,4 +1039,4 @@ var Drawer = class {
1014
1039
  }
1015
1040
  };
1016
1041
 
1017
- export { Dialog, Drawer, KeymapManager, Menu, Tooltip, applyPlotOverlayTokens, applyThemeTokens, dialogController, drawerController, ensureUIHost, isEditableTarget, menuController, nextUid, runMachine, tooltipController };
1042
+ export { Dialog, Drawer, KeymapManager, Menu, Tooltip, dialogController, drawerController, isEditableTarget, menuController, nextUid, runMachine, tooltipController };
@@ -1,4 +1,4 @@
1
- import { svg24, NEUTRAL, BEARISH, WARNING, BULLISH, INFO, ACCENT_BRIGHT, VALID, INVALID, MARKER, ACCENT, injectStyles, iconEl } from './chunk-LJLZR44Y.js';
1
+ import { svg24, NEUTRAL, BEARISH, WARNING, BULLISH, INFO, ACCENT_BRIGHT, VALID, INVALID, MARKER, ACCENT, injectStyles, iconEl } from './chunk-EMS6PO2T.js';
2
2
 
3
3
  // src/core/native-indicators/NativeIndicator.ts
4
4
  var REGISTRY = /* @__PURE__ */ new Map();
@@ -1,5 +1,5 @@
1
- import { s as Millis, ac as InputSchema, ab as IndicatorMeta, P as PriceStyle, O as OHLCV, l as InputValue, j as IndicatorModel, i as MoveTarget, ay as SeriesSpec, a9 as Fill, B as Background, aq as PriceLine, $ as DrawingLine, X as DrawingBox, _ as DrawingLabel, a3 as DrawingPolyline, a0 as DrawingLinefill, a5 as DrawingTable, f as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, u as DrawingTypeKey, t as SnapMode, a1 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, n as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, q as DataWindowReadout, m as SymbolPickerFn, aK as PaneInfo, a8 as DrawingsOption, D as Drawing, b as VelaOptions, w as AddIndicatorOptions, am as MarketSwitch, al as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-XTBpbx0s.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-gnzv-dgc.cjs';
1
+ import { s as Millis, ac as InputSchema, ab as IndicatorMeta, P as PriceStyle, O as OHLCV, l as InputValue, j as IndicatorModel, i as MoveTarget, ay as SeriesSpec, a9 as Fill, B as Background, aq as PriceLine, $ as DrawingLine, X as DrawingBox, _ as DrawingLabel, a3 as DrawingPolyline, a0 as DrawingLinefill, a5 as DrawingTable, f as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, u as DrawingTypeKey, t as SnapMode, a1 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, n as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, q as DataWindowReadout, m as SymbolPickerFn, aK as PaneInfo, a8 as DrawingsOption, D as Drawing, b as VelaOptions, w as AddIndicatorOptions, am as MarketSwitch, al as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-BlQ00Fju.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-DNx9ntBD.js';
3
3
 
4
4
  /**
5
5
  * A strategy's broker state at ONE bar — the flat summary a host reads while a script
@@ -344,6 +344,13 @@ declare class DataControl {
344
344
  providers(): ProviderInfo[];
345
345
  /** Resolve a symbol string to `{ provider, ticker }`, or null if nothing serves it. */
346
346
  resolve(symbol: string): Resolved | null;
347
+ /**
348
+ * The DISPLAY prefix for `symbol` — the listing venue its descriptor declares
349
+ * (`NASDAQ` for AAPL) or the resolved provider name. Null while unresolvable.
350
+ */
351
+ displayPrefix(symbol: string): string | null;
352
+ /** The canonical `PREFIX:TICKER` form of `symbol`, or null while unresolvable. */
353
+ canonicalSymbol(symbol: string): string | null;
347
354
  /**
348
355
  * The registered provider INSTANCE under `name` — the seam for EXTENDED provider
349
356
  * surfaces: a provider may implement interfaces beyond the `DataProvider` port
@@ -1,5 +1,5 @@
1
- import { s as Millis, ac as InputSchema, ab as IndicatorMeta, P as PriceStyle, O as OHLCV, l as InputValue, j as IndicatorModel, i as MoveTarget, ay as SeriesSpec, a9 as Fill, B as Background, aq as PriceLine, $ as DrawingLine, X as DrawingBox, _ as DrawingLabel, a3 as DrawingPolyline, a0 as DrawingLinefill, a5 as DrawingTable, f as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, u as DrawingTypeKey, t as SnapMode, a1 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, n as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, q as DataWindowReadout, m as SymbolPickerFn, aK as PaneInfo, a8 as DrawingsOption, D as Drawing, b as VelaOptions, w as AddIndicatorOptions, am as MarketSwitch, al as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-XTBpbx0s.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-DTOEXKTI.js';
1
+ import { s as Millis, ac as InputSchema, ab as IndicatorMeta, P as PriceStyle, O as OHLCV, l as InputValue, j as IndicatorModel, i as MoveTarget, ay as SeriesSpec, a9 as Fill, B as Background, aq as PriceLine, $ as DrawingLine, X as DrawingBox, _ as DrawingLabel, a3 as DrawingPolyline, a0 as DrawingLinefill, a5 as DrawingTable, f as IndicatorStatus, a as VisibleRange, c as VelaTheme, S as SerializedDrawing, u as DrawingTypeKey, t as SnapMode, a1 as DrawingMode, I as IChartRenderer, R as RendererCapabilities, n as LegendActionView, U as Unsubscribe, C as CrosshairEvent, A as AxisLongPressEvent, q as DataWindowReadout, m as SymbolPickerFn, aK as PaneInfo, a8 as DrawingsOption, D as Drawing, b as VelaOptions, w as AddIndicatorOptions, am as MarketSwitch, al as MarketSnapshot, V as VisibleRangePreset, T as ThemeName } from './options-BlQ00Fju.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-Ce6PuCzQ.cjs';
3
3
 
4
4
  /**
5
5
  * A strategy's broker state at ONE bar — the flat summary a host reads while a script
@@ -344,6 +344,13 @@ declare class DataControl {
344
344
  providers(): ProviderInfo[];
345
345
  /** Resolve a symbol string to `{ provider, ticker }`, or null if nothing serves it. */
346
346
  resolve(symbol: string): Resolved | null;
347
+ /**
348
+ * The DISPLAY prefix for `symbol` — the listing venue its descriptor declares
349
+ * (`NASDAQ` for AAPL) or the resolved provider name. Null while unresolvable.
350
+ */
351
+ displayPrefix(symbol: string): string | null;
352
+ /** The canonical `PREFIX:TICKER` form of `symbol`, or null while unresolvable. */
353
+ canonicalSymbol(symbol: string): string | null;
347
354
  /**
348
355
  * The registered provider INSTANCE under `name` — the seam for EXTENDED provider
349
356
  * surfaces: a provider may implement interfaces beyond the `DataProvider` port
@@ -1,6 +1,6 @@
1
- import { V as VisibleRangePreset } from './options-XTBpbx0s.js';
2
- import { D as DataProvider } from './DataProvider-DTOEXKTI.js';
3
- import { S as ScriptingEngine, V as Vela } from './contributions-b6AVrqqG.js';
1
+ import { V as VisibleRangePreset } from './options-BlQ00Fju.cjs';
2
+ import { D as DataProvider } from './DataProvider-Ce6PuCzQ.cjs';
3
+ import { S as ScriptingEngine, V as Vela } from './contributions-Dlc7ZWZz.cjs';
4
4
 
5
5
  interface RangePreset {
6
6
  /** Button label. */
@@ -168,6 +168,8 @@ interface WorkspaceState {
168
168
  timezone?: string;
169
169
  /** Favorite drawing-tool types — a SHARED preference (one star set per shell). */
170
170
  favorites?: string[];
171
+ /** Favorite timeframes (the topbar's quick-switch chips) — a SHARED preference. */
172
+ timeframeFavorites?: string[];
171
173
  /** The docked side panels: which one is open, and the widths the user dragged. */
172
174
  panels?: PanelsState;
173
175
  /** Per-chart state, one entry per SLOT (a single `c1` entry for the widget).
@@ -1,6 +1,6 @@
1
- import { V as VisibleRangePreset } from './options-XTBpbx0s.cjs';
2
- import { D as DataProvider } from './DataProvider-gnzv-dgc.cjs';
3
- import { S as ScriptingEngine, V as Vela } from './contributions-Ci_i3IN2.cjs';
1
+ import { V as VisibleRangePreset } from './options-BlQ00Fju.js';
2
+ import { D as DataProvider } from './DataProvider-DNx9ntBD.js';
3
+ import { S as ScriptingEngine, V as Vela } from './contributions-DToMhiw3.js';
4
4
 
5
5
  interface RangePreset {
6
6
  /** Button label. */
@@ -168,6 +168,8 @@ interface WorkspaceState {
168
168
  timezone?: string;
169
169
  /** Favorite drawing-tool types — a SHARED preference (one star set per shell). */
170
170
  favorites?: string[];
171
+ /** Favorite timeframes (the topbar's quick-switch chips) — a SHARED preference. */
172
+ timeframeFavorites?: string[];
171
173
  /** The docked side panels: which one is open, and the widths the user dragged. */
172
174
  panels?: PanelsState;
173
175
  /** Per-chart state, one entry per SLOT (a single `c1` entry for the widget).