@forgecharts/sdk 1.5.54 → 1.5.56

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.
@@ -485,9 +485,17 @@ var TimeScale = class {
485
485
  const toIdx = this.timeToIndex(this._visibleRange.to);
486
486
  const idxSpan = toIdx - fromIdx;
487
487
  const idxStep = Math.max(1, Math.round(idxSpan / approxTicks));
488
- const span = this._visibleRange.to - this._visibleRange.from;
489
- const step = this._niceTimeStep(span / approxTicks);
490
488
  const startIdx = Math.ceil(fromIdx / idxStep) * idxStep;
489
+ const _tickDeltas = [];
490
+ for (let i = Math.max(0, startIdx); i + idxStep <= Math.min(toIdx, this._barTimes.length - 1); i += idxStep) {
491
+ const a = this._barTimes[Math.round(i)];
492
+ const b = this._barTimes[Math.round(i + idxStep)];
493
+ if (a != null && b != null && b > a) _tickDeltas.push(b - a);
494
+ if (_tickDeltas.length >= 12) break;
495
+ }
496
+ _tickDeltas.sort((p, q) => p - q);
497
+ const _perTick = _tickDeltas.length > 0 ? _tickDeltas[Math.floor(_tickDeltas.length / 2)] : (this._visibleRange.to - this._visibleRange.from) / approxTicks;
498
+ const step = this._niceTimeStep(_perTick);
491
499
  for (let i = startIdx; i <= toIdx; i += idxStep) {
492
500
  const bIdx = Math.round(i);
493
501
  if (bIdx < 0) continue;
@@ -5733,8 +5741,16 @@ var PixiGridRenderer = class {
5733
5741
  const idxStep = Math.max(1, Math.round(rawIdxStep));
5734
5742
  const barTimes = this._timeScale.barTimes;
5735
5743
  const startIdx = Math.ceil(fromIdx / idxStep) * idxStep;
5736
- const span = timeTo - timeFrom;
5737
- const step = this._niceTimeStep(span / approxTicks);
5744
+ const _tickDeltas = [];
5745
+ for (let i = Math.max(0, startIdx); i + idxStep <= Math.min(toIdx, barTimes.length - 1); i += idxStep) {
5746
+ const a = barTimes[Math.round(i)];
5747
+ const b = barTimes[Math.round(i + idxStep)];
5748
+ if (a != null && b != null && b > a) _tickDeltas.push(b - a);
5749
+ if (_tickDeltas.length >= 12) break;
5750
+ }
5751
+ _tickDeltas.sort((p, q) => p - q);
5752
+ const _perTick = _tickDeltas.length > 0 ? _tickDeltas[Math.floor(_tickDeltas.length / 2)] : (timeTo - timeFrom) / approxTicks;
5753
+ const step = this._niceTimeStep(_perTick);
5738
5754
  for (let i = startIdx; i <= toIdx; i += idxStep) {
5739
5755
  const bIdx = Math.round(i);
5740
5756
  if (bIdx < 0) continue;
@@ -10289,6 +10305,13 @@ function _historyWindow(tf) {
10289
10305
  return 500 * (parseTfSeconds(tf) ?? 3600);
10290
10306
  }
10291
10307
  var BATCH_SUPPRESSION_MS = 1e4;
10308
+ function tfSeconds(tf) {
10309
+ const m = /^(\d+)\s*(s|m|h|D|W|M)$/.exec(tf);
10310
+ if (!m) return 0;
10311
+ const mult = { s: 1, m: 60, h: 3600, D: 86400, W: 604800, M: 2592e3 }[m[2]];
10312
+ return parseInt(m[1], 10) * mult;
10313
+ }
10314
+ var LIVE_GAP_REPAIR_DELAY_MS = 3e3;
10292
10315
  function _pageSize(tf) {
10293
10316
  return 500 * (parseTfSeconds(tf) ?? 3600);
10294
10317
  }
@@ -10416,15 +10439,36 @@ var DatafeedConnector = class {
10416
10439
  this._batchSafetyTimer = null;
10417
10440
  }, BATCH_SUPPRESSION_MS);
10418
10441
  }
10442
+ const tfSec = tfSeconds(timeframe);
10443
+ let lastSeenBarTime = lastBarTime ?? 0;
10444
+ let repairTimer = null;
10445
+ const repairGap = (fromTime, toTime) => {
10446
+ if (repairTimer) clearTimeout(repairTimer);
10447
+ repairTimer = setTimeout(() => {
10448
+ repairTimer = null;
10449
+ if (this._activeUID !== uid2 || this._destroyed) return;
10450
+ void this._datafeed.getHistoricalBars(symbol, timeframe, fromTime, toTime).then(({ bars: filled }) => {
10451
+ if (this._activeUID !== uid2 || filled.length === 0) return;
10452
+ engine.backfillGap(filled);
10453
+ }).catch(() => {
10454
+ });
10455
+ }, LIVE_GAP_REPAIR_DELAY_MS);
10456
+ };
10419
10457
  this._datafeed.subscribeBars(symbol, timeframe, (bar) => {
10420
- if (this._activeUID === uid2) {
10421
- engine.applyLiveUpdate(bar);
10458
+ if (this._activeUID !== uid2) return;
10459
+ const t = bar.time;
10460
+ if (tfSec > 0 && lastSeenBarTime > 0 && t > lastSeenBarTime + tfSec) {
10461
+ repairGap(lastSeenBarTime, t);
10422
10462
  }
10463
+ if (t > lastSeenBarTime) lastSeenBarTime = t;
10464
+ engine.applyLiveUpdate(bar);
10423
10465
  }, uid2, lastBarTime, (bars) => {
10424
10466
  this._clearBatchTimer();
10425
10467
  batchPending = false;
10426
10468
  if (this._activeUID === uid2) {
10427
10469
  engine.backfillGap(bars);
10470
+ const newest = bars.length > 0 ? bars[bars.length - 1].time : 0;
10471
+ if (newest > lastSeenBarTime) lastSeenBarTime = newest;
10428
10472
  }
10429
10473
  fireLoaded();
10430
10474
  });
@@ -18253,7 +18297,7 @@ var DEMONSTRATION_STROKE = "rgba(255, 200, 50, 0.7)";
18253
18297
  var DEMONSTRATION_COLOR = "var(--crosshair-overlay, rgba(255,255,255,0.75))";
18254
18298
 
18255
18299
  // src/version.ts
18256
- var FORGECHARTS_VERSION = "1.5.54" ;
18300
+ var FORGECHARTS_VERSION = "1.5.56" ;
18257
18301
  function applyRuntimeConfig(caps, config) {
18258
18302
  if (!config) return caps;
18259
18303
  const orderEntry = config.enableOrderEntry === false ? false : caps.orderEntry;