@forgecharts/sdk 1.5.67 → 1.5.69

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.
package/dist/internal.js CHANGED
@@ -10369,14 +10369,13 @@ function toOHLCV(bar) {
10369
10369
  function _historyWindow(tf) {
10370
10370
  return 500 * (parseTfSeconds(tf) ?? 3600);
10371
10371
  }
10372
- var BATCH_SUPPRESSION_MS = 1e4;
10372
+ var REFETCH_ON_DOUBT_DELAY_MS = 3e3;
10373
10373
  function tfSeconds(tf) {
10374
10374
  const m = /^(\d+)\s*(s|m|h|D|W|M)$/.exec(tf);
10375
10375
  if (!m) return 0;
10376
10376
  const mult = { s: 1, m: 60, h: 3600, D: 86400, W: 604800, M: 2592e3 }[m[2]];
10377
10377
  return parseInt(m[1], 10) * mult;
10378
10378
  }
10379
- var LIVE_GAP_REPAIR_DELAY_MS = 3e3;
10380
10379
  function _pageSize(tf) {
10381
10380
  return 500 * (parseTfSeconds(tf) ?? 3600);
10382
10381
  }
@@ -10412,9 +10411,11 @@ var DatafeedConnector = class {
10412
10411
  */
10413
10412
  _emptyPageStreak = 0;
10414
10413
  /**
10415
- * Safety timer: clears `batchPending` if bar_batch never arrives, so live
10416
- * ticks resume. It no longer gates the chart reveal.
10417
- * Prevents the chart from staying blank when a provider doesn't fire onHistoricalReady.
10414
+ * Nothing arms this any more live-tick suppression went with the rest of
10415
+ * the client-side stitching once history became authoritative through the
10416
+ * forming bar. Kept (with its clear helper) because reconnect paths call
10417
+ * the helper and older subclasses may too; clearing a never-set timer is
10418
+ * free. Remove both in the next breaking cleanup.
10418
10419
  */
10419
10420
  _batchSafetyTimer = null;
10420
10421
  constructor(datafeed, series, callbacks) {
@@ -10438,12 +10439,10 @@ var DatafeedConnector = class {
10438
10439
  const to = Math.floor(Date.now() / 1e3);
10439
10440
  const from = to - _historyWindow(timeframe);
10440
10441
  this._clearBatchTimer();
10441
- let batchPending = false;
10442
10442
  const engine = new CandleEngine({
10443
10443
  // Every live tick mutates the engine's bar array and the chart series.
10444
10444
  onBarUpdated: (bar) => {
10445
10445
  if (this._activeUID !== uid) return;
10446
- if (batchPending) return;
10447
10446
  const ohlcv = toOHLCV(bar);
10448
10447
  this._series.update(ohlcv);
10449
10448
  this._cb.onUpdate?.(ohlcv);
@@ -10497,54 +10496,33 @@ var DatafeedConnector = class {
10497
10496
  }).catch(() => {
10498
10497
  });
10499
10498
  if (this._activeUID !== uid) return;
10500
- if (lastBarTime != null) {
10501
- batchPending = true;
10502
- this._batchSafetyTimer = setTimeout(() => {
10503
- batchPending = false;
10504
- this._batchSafetyTimer = null;
10505
- }, BATCH_SUPPRESSION_MS);
10506
- }
10507
10499
  const tfSec = tfSeconds(timeframe);
10508
10500
  let lastSeenBarTime = lastBarTime ?? 0;
10509
- let repairTimer = null;
10510
- const REPAIR_RETRY_MS = 6e4;
10511
- const REPAIR_MAX_ATTEMPTS = 15;
10512
- let repairAttempts = 0;
10513
- const repairGap = (fromTime, toTime) => {
10514
- if (repairTimer) clearTimeout(repairTimer);
10515
- repairTimer = setTimeout(() => {
10516
- repairTimer = null;
10501
+ let refetchTimer = null;
10502
+ const refetchOnDoubt = (fromTime, toTime) => {
10503
+ if (refetchTimer) clearTimeout(refetchTimer);
10504
+ refetchTimer = setTimeout(() => {
10505
+ refetchTimer = null;
10517
10506
  if (this._activeUID !== uid || this._destroyed) return;
10518
10507
  void this._datafeed.getHistoricalBars(symbol, timeframe, fromTime, toTime).then(({ bars: filled }) => {
10519
- if (this._activeUID !== uid) return;
10520
- if (filled.length > 0) engine.backfillGap(filled);
10521
- const newest = filled.length > 0 ? filled[filled.length - 1].time : 0;
10522
- const covered = tfSec > 0 && newest >= toTime - 2 * tfSec;
10523
- if (!covered && repairAttempts < REPAIR_MAX_ATTEMPTS) {
10524
- repairAttempts += 1;
10525
- if (repairTimer) clearTimeout(repairTimer);
10526
- repairTimer = setTimeout(() => {
10527
- repairTimer = null;
10528
- repairGap(fromTime, toTime);
10529
- }, REPAIR_RETRY_MS);
10530
- } else if (covered) {
10531
- repairAttempts = 0;
10532
- }
10508
+ if (this._activeUID !== uid || filled.length === 0) return;
10509
+ engine.backfillGap(filled);
10510
+ const newest = filled[filled.length - 1].time;
10511
+ if (newest > lastSeenBarTime) lastSeenBarTime = newest;
10533
10512
  }).catch(() => {
10534
10513
  });
10535
- }, LIVE_GAP_REPAIR_DELAY_MS);
10514
+ }, REFETCH_ON_DOUBT_DELAY_MS);
10536
10515
  };
10537
10516
  this._datafeed.subscribeBars(symbol, timeframe, (bar) => {
10538
10517
  if (this._activeUID !== uid) return;
10539
10518
  const t = bar.time;
10540
10519
  if (tfSec > 0 && lastSeenBarTime > 0 && t > lastSeenBarTime + tfSec) {
10541
- repairGap(lastSeenBarTime, t);
10520
+ refetchOnDoubt(lastSeenBarTime, t);
10542
10521
  }
10543
10522
  if (t > lastSeenBarTime) lastSeenBarTime = t;
10544
10523
  engine.applyLiveUpdate(bar);
10545
10524
  }, uid, lastBarTime, (bars) => {
10546
10525
  this._clearBatchTimer();
10547
- batchPending = false;
10548
10526
  if (this._activeUID === uid) {
10549
10527
  engine.backfillGap(bars);
10550
10528
  const newest = bars.length > 0 ? bars[bars.length - 1].time : 0;
@@ -10552,16 +10530,7 @@ var DatafeedConnector = class {
10552
10530
  }
10553
10531
  fireLoaded();
10554
10532
  });
10555
- if (result.filling) {
10556
- setTimeout(() => {
10557
- if (this._activeUID !== uid || this._destroyed) return;
10558
- void this._datafeed.getHistoricalBars(symbol, timeframe, from, to).then(({ bars: refetchedBars }) => {
10559
- if (this._activeUID !== uid) return;
10560
- engine.backfillGap(refetchedBars);
10561
- }).catch(() => {
10562
- });
10563
- }, 8e3);
10564
- }
10533
+ if (result.filling) refetchOnDoubt(from, to);
10565
10534
  }).catch((err) => {
10566
10535
  if (this._activeUID !== uid) return;
10567
10536
  const message = err instanceof Error ? err.message : String(err);
@@ -25585,7 +25554,7 @@ var demonstrationTool = {
25585
25554
  };
25586
25555
 
25587
25556
  // src/version.ts
25588
- var FORGECHARTS_VERSION = "1.5.67" ;
25557
+ var FORGECHARTS_VERSION = "1.5.69" ;
25589
25558
 
25590
25559
  // src/compatibility.ts
25591
25560
  var MIN_KIT_API = 1;