@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.
@@ -10304,14 +10304,13 @@ function toOHLCV(bar) {
10304
10304
  function _historyWindow(tf) {
10305
10305
  return 500 * (parseTfSeconds(tf) ?? 3600);
10306
10306
  }
10307
- var BATCH_SUPPRESSION_MS = 1e4;
10307
+ var REFETCH_ON_DOUBT_DELAY_MS = 3e3;
10308
10308
  function tfSeconds(tf) {
10309
10309
  const m = /^(\d+)\s*(s|m|h|D|W|M)$/.exec(tf);
10310
10310
  if (!m) return 0;
10311
10311
  const mult = { s: 1, m: 60, h: 3600, D: 86400, W: 604800, M: 2592e3 }[m[2]];
10312
10312
  return parseInt(m[1], 10) * mult;
10313
10313
  }
10314
- var LIVE_GAP_REPAIR_DELAY_MS = 3e3;
10315
10314
  function _pageSize(tf) {
10316
10315
  return 500 * (parseTfSeconds(tf) ?? 3600);
10317
10316
  }
@@ -10347,9 +10346,11 @@ var DatafeedConnector = class {
10347
10346
  */
10348
10347
  _emptyPageStreak = 0;
10349
10348
  /**
10350
- * Safety timer: clears `batchPending` if bar_batch never arrives, so live
10351
- * ticks resume. It no longer gates the chart reveal.
10352
- * Prevents the chart from staying blank when a provider doesn't fire onHistoricalReady.
10349
+ * Nothing arms this any more live-tick suppression went with the rest of
10350
+ * the client-side stitching once history became authoritative through the
10351
+ * forming bar. Kept (with its clear helper) because reconnect paths call
10352
+ * the helper and older subclasses may too; clearing a never-set timer is
10353
+ * free. Remove both in the next breaking cleanup.
10353
10354
  */
10354
10355
  _batchSafetyTimer = null;
10355
10356
  constructor(datafeed, series, callbacks) {
@@ -10373,12 +10374,10 @@ var DatafeedConnector = class {
10373
10374
  const to = Math.floor(Date.now() / 1e3);
10374
10375
  const from = to - _historyWindow(timeframe);
10375
10376
  this._clearBatchTimer();
10376
- let batchPending = false;
10377
10377
  const engine = new CandleEngine({
10378
10378
  // Every live tick mutates the engine's bar array and the chart series.
10379
10379
  onBarUpdated: (bar) => {
10380
10380
  if (this._activeUID !== uid2) return;
10381
- if (batchPending) return;
10382
10381
  const ohlcv = toOHLCV(bar);
10383
10382
  this._series.update(ohlcv);
10384
10383
  this._cb.onUpdate?.(ohlcv);
@@ -10432,54 +10431,33 @@ var DatafeedConnector = class {
10432
10431
  }).catch(() => {
10433
10432
  });
10434
10433
  if (this._activeUID !== uid2) return;
10435
- if (lastBarTime != null) {
10436
- batchPending = true;
10437
- this._batchSafetyTimer = setTimeout(() => {
10438
- batchPending = false;
10439
- this._batchSafetyTimer = null;
10440
- }, BATCH_SUPPRESSION_MS);
10441
- }
10442
10434
  const tfSec = tfSeconds(timeframe);
10443
10435
  let lastSeenBarTime = lastBarTime ?? 0;
10444
- let repairTimer = null;
10445
- const REPAIR_RETRY_MS = 6e4;
10446
- const REPAIR_MAX_ATTEMPTS = 15;
10447
- let repairAttempts = 0;
10448
- const repairGap = (fromTime, toTime) => {
10449
- if (repairTimer) clearTimeout(repairTimer);
10450
- repairTimer = setTimeout(() => {
10451
- repairTimer = null;
10436
+ let refetchTimer = null;
10437
+ const refetchOnDoubt = (fromTime, toTime) => {
10438
+ if (refetchTimer) clearTimeout(refetchTimer);
10439
+ refetchTimer = setTimeout(() => {
10440
+ refetchTimer = null;
10452
10441
  if (this._activeUID !== uid2 || this._destroyed) return;
10453
10442
  void this._datafeed.getHistoricalBars(symbol, timeframe, fromTime, toTime).then(({ bars: filled }) => {
10454
- if (this._activeUID !== uid2) return;
10455
- if (filled.length > 0) engine.backfillGap(filled);
10456
- const newest = filled.length > 0 ? filled[filled.length - 1].time : 0;
10457
- const covered = tfSec > 0 && newest >= toTime - 2 * tfSec;
10458
- if (!covered && repairAttempts < REPAIR_MAX_ATTEMPTS) {
10459
- repairAttempts += 1;
10460
- if (repairTimer) clearTimeout(repairTimer);
10461
- repairTimer = setTimeout(() => {
10462
- repairTimer = null;
10463
- repairGap(fromTime, toTime);
10464
- }, REPAIR_RETRY_MS);
10465
- } else if (covered) {
10466
- repairAttempts = 0;
10467
- }
10443
+ if (this._activeUID !== uid2 || filled.length === 0) return;
10444
+ engine.backfillGap(filled);
10445
+ const newest = filled[filled.length - 1].time;
10446
+ if (newest > lastSeenBarTime) lastSeenBarTime = newest;
10468
10447
  }).catch(() => {
10469
10448
  });
10470
- }, LIVE_GAP_REPAIR_DELAY_MS);
10449
+ }, REFETCH_ON_DOUBT_DELAY_MS);
10471
10450
  };
10472
10451
  this._datafeed.subscribeBars(symbol, timeframe, (bar) => {
10473
10452
  if (this._activeUID !== uid2) return;
10474
10453
  const t = bar.time;
10475
10454
  if (tfSec > 0 && lastSeenBarTime > 0 && t > lastSeenBarTime + tfSec) {
10476
- repairGap(lastSeenBarTime, t);
10455
+ refetchOnDoubt(lastSeenBarTime, t);
10477
10456
  }
10478
10457
  if (t > lastSeenBarTime) lastSeenBarTime = t;
10479
10458
  engine.applyLiveUpdate(bar);
10480
10459
  }, uid2, lastBarTime, (bars) => {
10481
10460
  this._clearBatchTimer();
10482
- batchPending = false;
10483
10461
  if (this._activeUID === uid2) {
10484
10462
  engine.backfillGap(bars);
10485
10463
  const newest = bars.length > 0 ? bars[bars.length - 1].time : 0;
@@ -10487,16 +10465,7 @@ var DatafeedConnector = class {
10487
10465
  }
10488
10466
  fireLoaded();
10489
10467
  });
10490
- if (result.filling) {
10491
- setTimeout(() => {
10492
- if (this._activeUID !== uid2 || this._destroyed) return;
10493
- void this._datafeed.getHistoricalBars(symbol, timeframe, from, to).then(({ bars: refetchedBars }) => {
10494
- if (this._activeUID !== uid2) return;
10495
- engine.backfillGap(refetchedBars);
10496
- }).catch(() => {
10497
- });
10498
- }, 8e3);
10499
- }
10468
+ if (result.filling) refetchOnDoubt(from, to);
10500
10469
  }).catch((err) => {
10501
10470
  if (this._activeUID !== uid2) return;
10502
10471
  const message = err instanceof Error ? err.message : String(err);
@@ -18312,7 +18281,7 @@ var DEMONSTRATION_STROKE = "rgba(255, 200, 50, 0.7)";
18312
18281
  var DEMONSTRATION_COLOR = "var(--crosshair-overlay, rgba(255,255,255,0.75))";
18313
18282
 
18314
18283
  // src/version.ts
18315
- var FORGECHARTS_VERSION = "1.5.67" ;
18284
+ var FORGECHARTS_VERSION = "1.5.69" ;
18316
18285
  function applyRuntimeConfig(caps, config) {
18317
18286
  if (!config) return caps;
18318
18287
  const orderEntry = config.enableOrderEntry === false ? false : caps.orderEntry;