@forgecharts/sdk 1.5.53 → 1.5.55

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,29 @@ function _historyWindow(tf) {
10289
10305
  return 500 * (parseTfSeconds(tf) ?? 3600);
10290
10306
  }
10291
10307
  var BATCH_SUPPRESSION_MS = 1e4;
10308
+ var TF_SECONDS = {
10309
+ "1s": 1,
10310
+ "5s": 5,
10311
+ "10s": 10,
10312
+ "15s": 15,
10313
+ "30s": 30,
10314
+ "1m": 60,
10315
+ "3m": 180,
10316
+ "5m": 300,
10317
+ "15m": 900,
10318
+ "30m": 1800,
10319
+ "1h": 3600,
10320
+ "2h": 7200,
10321
+ "4h": 14400,
10322
+ "6h": 21600,
10323
+ "8h": 28800,
10324
+ "12h": 43200,
10325
+ "1D": 86400,
10326
+ "3D": 259200,
10327
+ "1W": 604800,
10328
+ "1M": 2592e3
10329
+ };
10330
+ var LIVE_GAP_REPAIR_DELAY_MS = 3e3;
10292
10331
  function _pageSize(tf) {
10293
10332
  return 500 * (parseTfSeconds(tf) ?? 3600);
10294
10333
  }
@@ -10416,15 +10455,36 @@ var DatafeedConnector = class {
10416
10455
  this._batchSafetyTimer = null;
10417
10456
  }, BATCH_SUPPRESSION_MS);
10418
10457
  }
10458
+ const tfSec = TF_SECONDS[timeframe] ?? 0;
10459
+ let lastSeenBarTime = lastBarTime ?? 0;
10460
+ let repairTimer = null;
10461
+ const repairGap = (fromTime, toTime) => {
10462
+ if (repairTimer) clearTimeout(repairTimer);
10463
+ repairTimer = setTimeout(() => {
10464
+ repairTimer = null;
10465
+ if (this._activeUID !== uid2 || this._destroyed) return;
10466
+ void this._datafeed.getHistoricalBars(symbol, timeframe, fromTime, toTime).then(({ bars: filled }) => {
10467
+ if (this._activeUID !== uid2 || filled.length === 0) return;
10468
+ engine.backfillGap(filled);
10469
+ }).catch(() => {
10470
+ });
10471
+ }, LIVE_GAP_REPAIR_DELAY_MS);
10472
+ };
10419
10473
  this._datafeed.subscribeBars(symbol, timeframe, (bar) => {
10420
- if (this._activeUID === uid2) {
10421
- engine.applyLiveUpdate(bar);
10474
+ if (this._activeUID !== uid2) return;
10475
+ const t = bar.time;
10476
+ if (tfSec > 0 && lastSeenBarTime > 0 && t > lastSeenBarTime + tfSec) {
10477
+ repairGap(lastSeenBarTime, t);
10422
10478
  }
10479
+ if (t > lastSeenBarTime) lastSeenBarTime = t;
10480
+ engine.applyLiveUpdate(bar);
10423
10481
  }, uid2, lastBarTime, (bars) => {
10424
10482
  this._clearBatchTimer();
10425
10483
  batchPending = false;
10426
10484
  if (this._activeUID === uid2) {
10427
10485
  engine.backfillGap(bars);
10486
+ const newest = bars.length > 0 ? bars[bars.length - 1].time : 0;
10487
+ if (newest > lastSeenBarTime) lastSeenBarTime = newest;
10428
10488
  }
10429
10489
  fireLoaded();
10430
10490
  });
@@ -18253,7 +18313,7 @@ var DEMONSTRATION_STROKE = "rgba(255, 200, 50, 0.7)";
18253
18313
  var DEMONSTRATION_COLOR = "var(--crosshair-overlay, rgba(255,255,255,0.75))";
18254
18314
 
18255
18315
  // src/version.ts
18256
- var FORGECHARTS_VERSION = "1.5.53" ;
18316
+ var FORGECHARTS_VERSION = "1.5.55" ;
18257
18317
  function applyRuntimeConfig(caps, config) {
18258
18318
  if (!config) return caps;
18259
18319
  const orderEntry = config.enableOrderEntry === false ? false : caps.orderEntry;