@luxalgo/vela 0.5.4 → 0.6.1

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 (37) hide show
  1. package/dist/{DataProvider-DgS2UyMc.d.cts → DataProvider-BNKtYU5V.d.cts} +22 -3
  2. package/dist/{DataProvider-Cqc_BaJ9.d.ts → DataProvider-gJjN_0eh.d.ts} +22 -3
  3. package/dist/{chunk-D6WM5IUE.js → chunk-4MQEG67Z.js} +77 -18
  4. package/dist/{chunk-JBQUY2RI.js → chunk-6LZJRO2S.js} +48 -18
  5. package/dist/{contributions-DuIxJWeH.d.ts → contributions-D64UA74H.d.cts} +9 -2
  6. package/dist/{contributions-4Nh1jbvb.d.cts → contributions-lPAgo9Cu.d.ts} +9 -2
  7. package/dist/{history-FsmvCIo4.d.ts → history-CVoFDJ2D.d.ts} +21 -3
  8. package/dist/{history-HofqYEh2.d.cts → history-fSMXVLt1.d.cts} +21 -3
  9. package/dist/index.cjs +77 -18
  10. package/dist/index.d.cts +14 -6
  11. package/dist/index.d.ts +14 -6
  12. package/dist/index.js +1 -1
  13. package/dist/{options-BlQ00Fju.d.cts → options-BqGeFHtp.d.cts} +15 -1
  14. package/dist/{options-BlQ00Fju.d.ts → options-BqGeFHtp.d.ts} +15 -1
  15. package/dist/{plugin-DJR6z3e0.d.cts → plugin-D5ni4WEJ.d.cts} +3 -3
  16. package/dist/{plugin-N_EaXN4-.d.ts → plugin-o5HJH46Z.d.ts} +3 -3
  17. package/dist/plugin.d.cts +4 -4
  18. package/dist/plugin.d.ts +4 -4
  19. package/dist/providers/binance.d.cts +2 -2
  20. package/dist/providers/binance.d.ts +2 -2
  21. package/dist/providers/coinbase.d.cts +2 -2
  22. package/dist/providers/coinbase.d.ts +2 -2
  23. package/dist/providers/hyperliquid.d.cts +2 -2
  24. package/dist/providers/hyperliquid.d.ts +2 -2
  25. package/dist/ui.d.cts +1 -1
  26. package/dist/ui.d.ts +1 -1
  27. package/dist/vela.global.js +77 -18
  28. package/dist/vela.global.min.js +29 -29
  29. package/dist/widget.cjs +175 -40
  30. package/dist/widget.d.cts +23 -15
  31. package/dist/widget.d.ts +23 -15
  32. package/dist/widget.js +56 -10
  33. package/dist/workspace.cjs +172 -36
  34. package/dist/workspace.d.cts +20 -5
  35. package/dist/workspace.d.ts +20 -5
  36. package/dist/workspace.js +52 -5
  37. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { O as OHLCV, U as Unsubscribe } from '../options-BlQ00Fju.js';
2
- import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-Cqc_BaJ9.js';
1
+ import { O as OHLCV, U as Unsubscribe } from '../options-BqGeFHtp.js';
2
+ import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-gJjN_0eh.js';
3
3
 
4
4
  /**
5
5
  * Binance market-data provider, built from scratch on the public REST + WebSocket
@@ -1,5 +1,5 @@
1
- import { O as OHLCV, U as Unsubscribe } from '../options-BlQ00Fju.cjs';
2
- import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-DgS2UyMc.cjs';
1
+ import { O as OHLCV, U as Unsubscribe } from '../options-BqGeFHtp.cjs';
2
+ import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-BNKtYU5V.cjs';
3
3
 
4
4
  /**
5
5
  * Coinbase market-data provider, built from scratch on the public Exchange REST + WebSocket APIs
@@ -1,5 +1,5 @@
1
- import { O as OHLCV, U as Unsubscribe } from '../options-BlQ00Fju.js';
2
- import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-Cqc_BaJ9.js';
1
+ import { O as OHLCV, U as Unsubscribe } from '../options-BqGeFHtp.js';
2
+ import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-gJjN_0eh.js';
3
3
 
4
4
  /**
5
5
  * Coinbase market-data provider, built from scratch on the public Exchange REST + WebSocket APIs
@@ -1,5 +1,5 @@
1
- import { O as OHLCV, U as Unsubscribe } from '../options-BlQ00Fju.cjs';
2
- import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-DgS2UyMc.cjs';
1
+ import { O as OHLCV, U as Unsubscribe } from '../options-BqGeFHtp.cjs';
2
+ import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-BNKtYU5V.cjs';
3
3
 
4
4
  /**
5
5
  * Hyperliquid market-data provider, built from scratch on the public info API — no
@@ -1,5 +1,5 @@
1
- import { O as OHLCV, U as Unsubscribe } from '../options-BlQ00Fju.js';
2
- import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-Cqc_BaJ9.js';
1
+ import { O as OHLCV, U as Unsubscribe } from '../options-BqGeFHtp.js';
2
+ import { D as DataProvider, P as ProviderInfo, B as BarRange, S as SymbolInfo, a as SymbolDescriptor } from '../DataProvider-gJjN_0eh.js';
3
3
 
4
4
  /**
5
5
  * Hyperliquid market-data provider, built from scratch on the public info API — no
package/dist/ui.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as VelaTheme } from './options-BlQ00Fju.cjs';
1
+ import { c as VelaTheme } from './options-BqGeFHtp.cjs';
2
2
  import { MachineSchema, Service, Machine } from '@zag-js/core';
3
3
  export { a as KeyBindingDescriptor, K as KeymapManager, b as KeymapOptions, R as ResolvedBinding } from './keymap-CGOz5F5f.cjs';
4
4
  import * as tooltip from '@zag-js/tooltip';
package/dist/ui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as VelaTheme } from './options-BlQ00Fju.js';
1
+ import { c as VelaTheme } from './options-BqGeFHtp.js';
2
2
  import { MachineSchema, Service, Machine } from '@zag-js/core';
3
3
  export { a as KeyBindingDescriptor, K as KeymapManager, b as KeymapOptions, R as ResolvedBinding } from './keymap-CGOz5F5f.js';
4
4
  import * as tooltip from '@zag-js/tooltip';
@@ -6916,7 +6916,7 @@ var Vela = (function (exports) {
6916
6916
  /** Register (or replace) a provider; returns a promise that settles when its index is built. */
6917
6917
  register(rawName, provider) {
6918
6918
  const name = normName(rawName);
6919
- const entry = { name, provider, index: null, descriptors: [], settled: false, settle: Promise.resolve() };
6919
+ const entry = { name, provider, index: null, prefixIndex: null, byTicker: null, descriptors: [], settled: false, settle: Promise.resolve() };
6920
6920
  this.entries.set(name, entry);
6921
6921
  entry.settle = this.buildIndex(entry);
6922
6922
  queueMicrotask(() => this.notify(false));
@@ -6929,6 +6929,9 @@ var Vela = (function (exports) {
6929
6929
  const symbols = await entry.provider.listSymbols();
6930
6930
  entry.descriptors = symbols;
6931
6931
  entry.index = new Set(symbols.map((s) => normTicker(s.ticker)));
6932
+ entry.byTicker = new Map(symbols.map((s) => [normTicker(s.ticker), s]));
6933
+ entry.prefixIndex = /* @__PURE__ */ new Map();
6934
+ for (const s of symbols) if (s.prefix) entry.prefixIndex.set(`${normName(s.prefix)}:${normTicker(s.ticker)}`, s);
6932
6935
  }
6933
6936
  } catch {
6934
6937
  entry.index = null;
@@ -6964,14 +6967,25 @@ var Vela = (function (exports) {
6964
6967
  }
6965
6968
  /**
6966
6969
  * Resolve a symbol to `{ provider, ticker }`, or null when nothing can serve it
6967
- * yet. Explicit prefix → that provider (must be registered). Bare first
6968
- * indexed provider (registration order, `opts.default` first) that contains the
6969
- * ticker; `opts.lenient` additionally allows a sole registered provider before
6970
- * its index exists.
6970
+ * yet. Explicit prefix → that provider (must be registered), else a provider whose
6971
+ * index declares that LISTING prefix for that ticker (`NASDAQ:AAPL` routes to the
6972
+ * provider serving Nasdaq-listed AAPL TradingView-strict, so `NYSE:AAPL` resolves
6973
+ * to nothing rather than auto-correcting). Bare → first indexed provider
6974
+ * (registration order, `opts.default` first) that contains the ticker;
6975
+ * `opts.lenient` additionally allows a sole registered provider before its index
6976
+ * exists.
6971
6977
  */
6972
6978
  resolve(raw, opts = {}) {
6973
6979
  const { provider, ticker } = this.parse(raw);
6974
- if (provider) return this.entries.has(provider) ? { provider, ticker } : null;
6980
+ if (provider) {
6981
+ if (this.entries.has(provider)) return { provider, ticker };
6982
+ const key = `${provider}:${normTicker(ticker)}`;
6983
+ for (const name of this.candidateOrder(opts.default)) {
6984
+ const d = this.entries.get(name).prefixIndex?.get(key);
6985
+ if (d) return { provider: name, ticker: d.ticker };
6986
+ }
6987
+ return null;
6988
+ }
6975
6989
  const norm = normTicker(ticker);
6976
6990
  for (const name of this.candidateOrder(opts.default)) {
6977
6991
  if (this.entries.get(name).index?.has(norm)) return { provider: name, ticker };
@@ -7037,6 +7051,22 @@ var Vela = (function (exports) {
7037
7051
  }
7038
7052
  return names;
7039
7053
  }
7054
+ /**
7055
+ * The DISPLAY prefix for a resolved symbol — the descriptor's LISTING prefix when the
7056
+ * data declares one, else the provider name. This is the single seam every label
7057
+ * (legend chip, committed/persisted `PREFIX:TICKER` strings) derives from, which is
7058
+ * what makes a non-canonical spelling impossible to display: the form always comes
7059
+ * from the data, never from what was typed.
7060
+ */
7061
+ displayPrefixOf(resolved) {
7062
+ const d = this.entries.get(resolved.provider)?.byTicker?.get(normTicker(resolved.ticker));
7063
+ return d?.prefix ?? resolved.provider;
7064
+ }
7065
+ /** The canonical `PREFIX:TICKER` string for a resolved symbol (descriptor spellings). */
7066
+ canonicalSymbol(resolved) {
7067
+ const d = this.entries.get(resolved.provider)?.byTicker?.get(normTicker(resolved.ticker));
7068
+ return `${d?.prefix ?? resolved.provider}:${d?.ticker ?? resolved.ticker}`;
7069
+ }
7040
7070
  /** Indexed symbols for one provider (or all, concatenated) — for autocomplete. */
7041
7071
  symbolsOf(rawName) {
7042
7072
  if (rawName != null) return this.entries.get(normName(rawName))?.descriptors ?? [];
@@ -7499,7 +7529,7 @@ var Vela = (function (exports) {
7499
7529
  * an in-flight `setMarket` immediately (the config mutates before the load). */
7500
7530
  marketSnapshot() {
7501
7531
  const m = this.config.market;
7502
- return { symbol: m.symbol, provider: parseSymbol(m.symbol ?? "").provider ?? void 0, timeframe: m.timeframe, bars: m.bars, offline: m.data !== void 0 };
7532
+ return { symbol: m.symbol, provider: parseSymbol(m.symbol ?? "").provider ?? void 0, timeframe: m.timeframe, bars: m.bars, session: m.session, offline: m.data !== void 0 };
7503
7533
  }
7504
7534
  /**
7505
7535
  * Switch the chart's market IN PLACE — no destroy/recreate. The renderer stays
@@ -7518,7 +7548,9 @@ var Vela = (function (exports) {
7518
7548
  */
7519
7549
  async setMarket(next) {
7520
7550
  const m = this.config.market;
7521
- const identityChanged = next.symbol !== void 0 && next.symbol !== m.symbol || next.timeframe !== void 0 && next.timeframe !== m.timeframe || next.data !== void 0;
7551
+ const identityChanged = next.symbol !== void 0 && next.symbol !== m.symbol || next.timeframe !== void 0 && next.timeframe !== m.timeframe || // A session switch changes WHICH bars exist (RTH vs ETH) — a full reload,
7552
+ // exactly like a timeframe change; the cache keys the sessions apart.
7553
+ next.session !== void 0 && next.session !== m.session || next.data !== void 0;
7522
7554
  const depthChanged = next.bars !== void 0 && next.bars !== m.bars;
7523
7555
  const depthOnly = depthChanged && !identityChanged && this.rawBars.length > 0 && !m.data?.length && ((next.bars ?? 0) <= this.rawBars.length || typeof this.feed.loadRange === "function");
7524
7556
  if (!identityChanged && !depthChanged) {
@@ -7540,6 +7572,7 @@ var Vela = (function (exports) {
7540
7572
  if (next.symbol !== void 0) m.symbol = next.symbol;
7541
7573
  if (next.timeframe !== void 0) m.timeframe = next.timeframe;
7542
7574
  if (next.bars !== void 0) m.bars = next.bars;
7575
+ if (next.session !== void 0) m.session = next.session;
7543
7576
  if (next.data !== void 0) m.data = next.data;
7544
7577
  else if (next.symbol !== void 0) delete m.data;
7545
7578
  m.visibleRange = next.visibleRange;
@@ -8904,8 +8937,8 @@ var Vela = (function (exports) {
8904
8937
  };
8905
8938
 
8906
8939
  // src/data/BarStore.ts
8907
- function seriesKey(provider, symbol, timeframe) {
8908
- return `${provider}|${symbol}|${timeframe}`;
8940
+ function seriesKey(provider, symbol, timeframe, session) {
8941
+ return `${provider}|${symbol}|${timeframe}${session && session !== "regular" ? `|${session}` : ""}`;
8909
8942
  }
8910
8943
  function symbolOf(key) {
8911
8944
  return key.split("|")[1] ?? "";
@@ -8988,9 +9021,9 @@ var Vela = (function (exports) {
8988
9021
  var sharedBarStore = new BarStore();
8989
9022
 
8990
9023
  // src/data/CachingDataFeed.ts
8991
- function cacheKey(symbol, timeframe) {
9024
+ function cacheKey(symbol, timeframe, session) {
8992
9025
  const { provider, ticker } = parseSymbol(symbol);
8993
- return seriesKey(provider ?? "", ticker, timeframe);
9026
+ return seriesKey(provider ?? "", ticker, timeframe, session);
8994
9027
  }
8995
9028
  var PAGE_BARS = 1e4;
8996
9029
  var SINGLE_FETCH_BARS = PAGE_BARS + 1;
@@ -9002,7 +9035,7 @@ var Vela = (function (exports) {
9002
9035
  async load(cfg) {
9003
9036
  if (cfg.data && cfg.data.length > 0) return this.inner.load(cfg);
9004
9037
  const symbol = cfg.symbol ?? "TEST";
9005
- const key = cacheKey(symbol, cfg.timeframe ?? "60");
9038
+ const key = cacheKey(symbol, cfg.timeframe ?? "60", cfg.session);
9006
9039
  this.store.retainSymbol(symbol);
9007
9040
  const cached = this.store.get(key);
9008
9041
  const n = cfg.bars ?? 500;
@@ -9031,7 +9064,7 @@ var Vela = (function (exports) {
9031
9064
  */
9032
9065
  async loadRange(cfg, range) {
9033
9066
  if (!this.inner.loadRange) return this.inner.load(cfg);
9034
- const key = cacheKey(cfg.symbol ?? "TEST", cfg.timeframe ?? "60");
9067
+ const key = cacheKey(cfg.symbol ?? "TEST", cfg.timeframe ?? "60", cfg.session);
9035
9068
  let cached = this.store.get(key);
9036
9069
  let newest = cached?.[cached.length - 1];
9037
9070
  if (range.to != null && newest && range.to < newest.time) {
@@ -9189,6 +9222,20 @@ var Vela = (function (exports) {
9189
9222
  resolveSymbol(raw) {
9190
9223
  return this.registry.resolve(raw, { default: this.primaryProvider });
9191
9224
  }
9225
+ /**
9226
+ * The DISPLAY prefix for `raw` — the descriptor's LISTING prefix when the data
9227
+ * declares one (`NASDAQ` for AAPL), else the resolved provider name. Null while
9228
+ * nothing resolves the symbol.
9229
+ */
9230
+ displayPrefix(raw) {
9231
+ const resolved = this.resolveSymbol(raw);
9232
+ return resolved ? this.registry.displayPrefixOf(resolved) : null;
9233
+ }
9234
+ /** The canonical `PREFIX:TICKER` form of `raw`, or null while unresolvable. */
9235
+ canonicalSymbol(raw) {
9236
+ const resolved = this.resolveSymbol(raw);
9237
+ return resolved ? this.registry.canonicalSymbol(resolved) : null;
9238
+ }
9192
9239
  /** The registered provider INSTANCE under `name` (undefined if unknown). */
9193
9240
  providerInstance(name) {
9194
9241
  return this.registry.get(name);
@@ -9324,13 +9371,13 @@ var Vela = (function (exports) {
9324
9371
  const { provider: name, ticker } = parseSymbol(cfg.symbol ?? "");
9325
9372
  const provider = this.registry.get(name ?? "");
9326
9373
  if (!provider) return Promise.resolve([]);
9327
- return safeBars(provider, ticker, cfg.timeframe ?? "60", { limit: cfg.bars ?? 500 });
9374
+ return safeBars(provider, ticker, cfg.timeframe ?? "60", { limit: cfg.bars ?? 500, session: cfg.session });
9328
9375
  }
9329
9376
  loadRange(cfg, range) {
9330
9377
  const { provider: name, ticker } = parseSymbol(cfg.symbol ?? "");
9331
9378
  const provider = this.registry.get(name ?? "");
9332
9379
  if (!provider) return Promise.resolve([]);
9333
- return safeBars(provider, ticker, cfg.timeframe ?? "60", range);
9380
+ return safeBars(provider, ticker, cfg.timeframe ?? "60", { ...range, session: cfg.session });
9334
9381
  }
9335
9382
  subscribe(cfg, onBar) {
9336
9383
  const { provider: name, ticker } = parseSymbol(cfg.symbol ?? "");
@@ -9338,13 +9385,13 @@ var Vela = (function (exports) {
9338
9385
  if (!provider) return () => {
9339
9386
  };
9340
9387
  const tf = cfg.timeframe ?? "60";
9341
- if (provider.subscribe) return provider.subscribe(ticker, tf, onBar);
9388
+ if (provider.subscribe) return provider.subscribe(ticker, tf, onBar, cfg.session ? { session: cfg.session } : void 0);
9342
9389
  let stopped = false;
9343
9390
  let timer = null;
9344
9391
  const poll = async () => {
9345
9392
  if (stopped) return;
9346
9393
  try {
9347
- const bars = await provider.getBars(ticker, tf, { limit: 2 });
9394
+ const bars = await provider.getBars(ticker, tf, { limit: 2, session: cfg.session });
9348
9395
  if (stopped) return;
9349
9396
  for (const b of bars) onBar(b);
9350
9397
  } catch {
@@ -9394,6 +9441,17 @@ var Vela = (function (exports) {
9394
9441
  resolve(symbol) {
9395
9442
  return this.registry?.resolveSymbol(symbol) ?? null;
9396
9443
  }
9444
+ /**
9445
+ * The DISPLAY prefix for `symbol` — the listing venue its descriptor declares
9446
+ * (`NASDAQ` for AAPL) or the resolved provider name. Null while unresolvable.
9447
+ */
9448
+ displayPrefix(symbol) {
9449
+ return this.registry?.displayPrefix(symbol) ?? null;
9450
+ }
9451
+ /** The canonical `PREFIX:TICKER` form of `symbol`, or null while unresolvable. */
9452
+ canonicalSymbol(symbol) {
9453
+ return this.registry?.canonicalSymbol(symbol) ?? null;
9454
+ }
9397
9455
  /**
9398
9456
  * The registered provider INSTANCE under `name` — the seam for EXTENDED provider
9399
9457
  * surfaces: a provider may implement interfaces beyond the `DataProvider` port
@@ -27614,6 +27672,7 @@ void main() {
27614
27672
  symbol: options.symbol,
27615
27673
  timeframe: options.timeframe,
27616
27674
  bars: options.bars,
27675
+ session: options.session,
27617
27676
  visibleRange: options.visibleRange,
27618
27677
  data: options.data
27619
27678
  },