@forgecharts/sdk 1.5.68 → 1.5.70
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/core/Chart.d.ts +2 -0
- package/dist/core/Chart.d.ts.map +1 -1
- package/dist/core/__tests__/cursorTime.test.d.ts +2 -0
- package/dist/core/__tests__/cursorTime.test.d.ts.map +1 -0
- package/dist/core/cursorTime.d.ts +27 -0
- package/dist/core/cursorTime.d.ts.map +1 -0
- package/dist/datafeed/DatafeedConnector.d.ts +5 -3
- package/dist/datafeed/DatafeedConnector.d.ts.map +1 -1
- package/dist/index.js +95 -65
- package/dist/index.js.map +1 -1
- package/dist/internal.js +95 -65
- package/dist/internal.js.map +1 -1
- package/dist/pixi/PixiChart.d.ts +2 -0
- package/dist/pixi/PixiChart.d.ts.map +1 -1
- package/dist/pixi/PixiCrosshairRenderer.d.ts +9 -1
- package/dist/pixi/PixiCrosshairRenderer.d.ts.map +1 -1
- package/dist/react/index.js +95 -65
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +95 -65
- package/dist/react/internal.js.map +1 -1
- package/package.json +1 -1
package/dist/core/Chart.d.ts
CHANGED
|
@@ -127,6 +127,8 @@ export declare class Chart implements ChartBackend {
|
|
|
127
127
|
time: number;
|
|
128
128
|
closeY?: number;
|
|
129
129
|
};
|
|
130
|
+
/** Bucket time for a cursor x — see core/cursorTime.ts for the rule. */
|
|
131
|
+
private _cursorBucketTime;
|
|
130
132
|
private _computeViewport;
|
|
131
133
|
private _onResize;
|
|
132
134
|
private _handleKeyAction;
|
package/dist/core/Chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/core/Chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA2C,OAAO,EAAE,WAAW,EAAuB,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"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|
2
|
+
* The one derivation of "what time is the cursor pointing at".
|
|
3
|
+
*
|
|
4
|
+
* A cursor x maps, via the ordinal transform, to a time interpolated BETWEEN
|
|
5
|
+
* bar positions — 10:02 inside a 1h bar's column. That raw value is never the
|
|
6
|
+
* right thing to show or to store: a time between buckets does not correspond
|
|
7
|
+
* to anything that exists. Yet three consumers derived it independently — the
|
|
8
|
+
* canvas crosshair (floored), the Pixi crosshair (raw — the reported bug:
|
|
9
|
+
* every pointer style's time label leaked minute-level noise on 5m+), and the
|
|
10
|
+
* drawing anchors (raw, so a drawing stored a time its own label would never
|
|
11
|
+
* display).
|
|
12
|
+
*
|
|
13
|
+
* The rule, in TradingView's shape: the cursor's time is the NEAREST BAR's
|
|
14
|
+
* timestamp — bars carry the true, session-aligned bucket starts for whatever
|
|
15
|
+
* timeframe produced them, custom intervals included — and only beyond the
|
|
16
|
+
* data does it fall back to flooring the raw time onto the timeframe grid,
|
|
17
|
+
* which the ordinal transform already extrapolates in bucket steps.
|
|
18
|
+
*
|
|
19
|
+
* Renderers and anchor writers consume this; none of them derives its own.
|
|
20
|
+
*/
|
|
21
|
+
import type { OHLCV } from '@forgecharts/types';
|
|
22
|
+
export interface CursorTimeTransform {
|
|
23
|
+
xToTime(x: number): number;
|
|
24
|
+
timeToX(time: number): number;
|
|
25
|
+
}
|
|
26
|
+
export declare function cursorBucketTime(bars: readonly OHLCV[] | null, transform: CursorTimeTransform, interval: string, x: number): number;
|
|
27
|
+
//# sourceMappingURL=cursorTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorTime.d.ts","sourceRoot":"","sources":["../../src/core/cursorTime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI,EAC7B,SAAS,EAAE,mBAAmB,EAC9B,QAAQ,EAAE,MAAM,EAChB,CAAC,EAAE,MAAM,GACR,MAAM,CAmCR"}
|
|
@@ -69,9 +69,11 @@ export declare class DatafeedConnector {
|
|
|
69
69
|
*/
|
|
70
70
|
private _emptyPageStreak;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* Nothing arms this any more — live-tick suppression went with the rest of
|
|
73
|
+
* the client-side stitching once history became authoritative through the
|
|
74
|
+
* forming bar. Kept (with its clear helper) because reconnect paths call
|
|
75
|
+
* the helper and older subclasses may too; clearing a never-set timer is
|
|
76
|
+
* free. Remove both in the next breaking cleanup.
|
|
75
77
|
*/
|
|
76
78
|
private _batchSafetyTimer;
|
|
77
79
|
constructor(datafeed: IDatafeed, series: ISeries, callbacks: ConnectorCallbacks);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatafeedConnector.d.ts","sourceRoot":"","sources":["../../src/datafeed/DatafeedConnector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DatafeedConnector.d.ts","sourceRoot":"","sources":["../../src/datafeed/DatafeedConnector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA8EhD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,MAAM,EAAE,M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AG,IAAI;IAyLnD;;;;OAIG;IACH,UAAU,IAAI,IAAI;IAIlB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAKrD;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAOf;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IA0G3D,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,aAAa;CAoBtB"}
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,36 @@ function isGLBXDailyBreak(nowMs = Date.now()) {
|
|
|
100
100
|
return weekday === "Mon" || weekday === "Tue" || weekday === "Wed" || weekday === "Thu";
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
// src/core/cursorTime.ts
|
|
104
|
+
function cursorBucketTime(bars, transform, interval, x) {
|
|
105
|
+
const raw = transform.xToTime(x);
|
|
106
|
+
const tfSec = parseTfSeconds(interval) ?? 0;
|
|
107
|
+
const floored = tfSec > 0 ? Math.floor(raw / tfSec) * tfSec : raw;
|
|
108
|
+
if (!bars || bars.length === 0) return floored;
|
|
109
|
+
let lo = 0, hi = bars.length - 1;
|
|
110
|
+
while (lo < hi) {
|
|
111
|
+
const mid = lo + hi >>> 1;
|
|
112
|
+
if (bars[mid].time < raw) lo = mid + 1;
|
|
113
|
+
else hi = mid;
|
|
114
|
+
}
|
|
115
|
+
let nearest = lo;
|
|
116
|
+
let best = Math.abs(transform.timeToX(bars[lo].time) - x);
|
|
117
|
+
for (const i of [lo - 1, lo + 1]) {
|
|
118
|
+
if (i < 0 || i >= bars.length) continue;
|
|
119
|
+
const d = Math.abs(transform.timeToX(bars[i].time) - x);
|
|
120
|
+
if (d < best) {
|
|
121
|
+
best = d;
|
|
122
|
+
nearest = i;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const first = bars[0].time;
|
|
126
|
+
const last = bars[bars.length - 1].time;
|
|
127
|
+
const halfCol = bars.length > 1 ? Math.abs(transform.timeToX(bars[1].time) - transform.timeToX(first)) / 2 : Infinity;
|
|
128
|
+
const edgeX = raw > last ? transform.timeToX(last) : raw < first ? transform.timeToX(first) : null;
|
|
129
|
+
if (edgeX !== null && Math.abs(x - edgeX) > halfCol) return floored;
|
|
130
|
+
return bars[nearest].time;
|
|
131
|
+
}
|
|
132
|
+
|
|
103
133
|
// src/core/CanvasLayer.ts
|
|
104
134
|
var CanvasLayer = class {
|
|
105
135
|
canvas;
|
|
@@ -4792,10 +4822,7 @@ var Chart = class {
|
|
|
4792
4822
|
onCrosshairMove: (x, y) => {
|
|
4793
4823
|
if (!this._crosshairEnabled) return;
|
|
4794
4824
|
if (this._magnetMode === "off") {
|
|
4795
|
-
|
|
4796
|
-
const rawTime = this._transform.xToTime(x);
|
|
4797
|
-
const flooredTime = Math.floor(rawTime / tfSec) * tfSec;
|
|
4798
|
-
this._crosshair.update(x, y, flooredTime);
|
|
4825
|
+
this._crosshair.update(x, y, this._cursorBucketTime(x));
|
|
4799
4826
|
} else {
|
|
4800
4827
|
const snap = this.snapXToBar(x);
|
|
4801
4828
|
const sy = this._magnetMode === "snap-xy" ? snap.closeY ?? y : y;
|
|
@@ -4836,7 +4863,8 @@ var Chart = class {
|
|
|
4836
4863
|
},
|
|
4837
4864
|
onDrawPointerMove: (x, y) => {
|
|
4838
4865
|
this._drawingCursorPt = {
|
|
4839
|
-
time:
|
|
4866
|
+
// Bucket time, not raw: the label and the stored anchor agree.
|
|
4867
|
+
time: this._cursorBucketTime(x),
|
|
4840
4868
|
price: this._transform.yToPrice(y)
|
|
4841
4869
|
};
|
|
4842
4870
|
this._dirty = true;
|
|
@@ -5109,9 +5137,19 @@ var Chart = class {
|
|
|
5109
5137
|
closeY: this._transform.priceToY(bar.close)
|
|
5110
5138
|
};
|
|
5111
5139
|
}
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5140
|
+
return { x, time: this._cursorBucketTime(x) };
|
|
5141
|
+
}
|
|
5142
|
+
/** Bucket time for a cursor x — see core/cursorTime.ts for the rule. */
|
|
5143
|
+
_cursorBucketTime(x) {
|
|
5144
|
+
let bars = null;
|
|
5145
|
+
for (const s of this._series) {
|
|
5146
|
+
const data = s.data();
|
|
5147
|
+
if (data.length > 0) {
|
|
5148
|
+
bars = data;
|
|
5149
|
+
break;
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
return cursorBucketTime(bars, this._transform, this._interval, x);
|
|
5115
5153
|
}
|
|
5116
5154
|
_computeViewport() {
|
|
5117
5155
|
return {
|
|
@@ -5588,7 +5626,7 @@ var Chart = class {
|
|
|
5588
5626
|
const MAGNET_PX = 15;
|
|
5589
5627
|
const t = this._transform;
|
|
5590
5628
|
const price = t.yToPrice(y);
|
|
5591
|
-
const time =
|
|
5629
|
+
const time = this._cursorBucketTime(x);
|
|
5592
5630
|
if (this._magnetMode === "off") return { time, price };
|
|
5593
5631
|
let bestBar = null;
|
|
5594
5632
|
let bestDist = SNAP_PX;
|
|
@@ -6287,7 +6325,16 @@ var PixiCrosshairRenderer = class {
|
|
|
6287
6325
|
interval = "1h";
|
|
6288
6326
|
/** IANA timezone for the time label. Falls back to UTC. */
|
|
6289
6327
|
timezone = "UTC";
|
|
6290
|
-
|
|
6328
|
+
/**
|
|
6329
|
+
* The time the chart computed for this cursor position — nearest bar, else
|
|
6330
|
+
* floored to the timeframe grid. This renderer must never derive its own:
|
|
6331
|
+
* it once did (raw xToTime), and every pointer style's time label showed
|
|
6332
|
+
* interpolated minute noise (10:02 on an hourly chart) on any timeframe
|
|
6333
|
+
* wider than the interpolation error.
|
|
6334
|
+
*/
|
|
6335
|
+
_snapTime = null;
|
|
6336
|
+
update(x, y, snapTime) {
|
|
6337
|
+
this._snapTime = snapTime ?? null;
|
|
6291
6338
|
this._x = x;
|
|
6292
6339
|
this._y = y;
|
|
6293
6340
|
}
|
|
@@ -6329,7 +6376,7 @@ var PixiCrosshairRenderer = class {
|
|
|
6329
6376
|
this._priceLabel.text = priceText;
|
|
6330
6377
|
this._priceLabel.x = pw + 4;
|
|
6331
6378
|
this._priceLabel.y = y - this._priceLabel.height / 2;
|
|
6332
|
-
const time = transform.xToTime(x);
|
|
6379
|
+
const time = this._snapTime ?? transform.xToTime(x);
|
|
6333
6380
|
const timeText = this._formatTime(time);
|
|
6334
6381
|
const tlw = DAILY_INTERVALS.has(this.interval) ? 120 : 170;
|
|
6335
6382
|
const tlh = tsh - 4;
|
|
@@ -8726,11 +8773,11 @@ var PixiChart = class {
|
|
|
8726
8773
|
onCrosshairMove: (x, y) => {
|
|
8727
8774
|
if (!this._crosshairEnabled) return;
|
|
8728
8775
|
if (this._magnetMode === "off") {
|
|
8729
|
-
this._crosshairRenderer.update(x, y);
|
|
8776
|
+
this._crosshairRenderer.update(x, y, this._cursorBucketTime(x));
|
|
8730
8777
|
} else {
|
|
8731
8778
|
const snap = this.snapXToBar(x);
|
|
8732
8779
|
const sy = this._magnetMode === "snap-xy" ? snap.closeY ?? y : y;
|
|
8733
|
-
this._crosshairRenderer.update(snap.x, sy);
|
|
8780
|
+
this._crosshairRenderer.update(snap.x, sy, snap.time);
|
|
8734
8781
|
}
|
|
8735
8782
|
const ah = this._interaction.axisHover;
|
|
8736
8783
|
if (ah !== this._lastAxisHover) {
|
|
@@ -8776,7 +8823,9 @@ var PixiChart = class {
|
|
|
8776
8823
|
},
|
|
8777
8824
|
onDrawPointerMove: (x, y) => {
|
|
8778
8825
|
this._drawingCursorPt = {
|
|
8779
|
-
time:
|
|
8826
|
+
// Bucket time, not raw: what the crosshair label shows is what a
|
|
8827
|
+
// drawing placed here will store.
|
|
8828
|
+
time: this._cursorBucketTime(x),
|
|
8780
8829
|
price: this._transform.yToPrice(y)
|
|
8781
8830
|
};
|
|
8782
8831
|
this._layers.dirty.mark(3 /* Drawing */);
|
|
@@ -9343,6 +9392,18 @@ var PixiChart = class {
|
|
|
9343
9392
|
setNativeCursorHidden(hidden) {
|
|
9344
9393
|
this._interaction.setHideCursor(hidden);
|
|
9345
9394
|
}
|
|
9395
|
+
/** Bucket time for a cursor x — see core/cursorTime.ts for the rule. */
|
|
9396
|
+
_cursorBucketTime(x) {
|
|
9397
|
+
let bars = null;
|
|
9398
|
+
for (const s of this._series) {
|
|
9399
|
+
const data = s.data();
|
|
9400
|
+
if (data.length > 0) {
|
|
9401
|
+
bars = data;
|
|
9402
|
+
break;
|
|
9403
|
+
}
|
|
9404
|
+
}
|
|
9405
|
+
return cursorBucketTime(bars, this._transform, this._interval, x);
|
|
9406
|
+
}
|
|
9346
9407
|
snapXToBar(x) {
|
|
9347
9408
|
const SNAP_PX = 20;
|
|
9348
9409
|
let bars = null;
|
|
@@ -9386,7 +9447,7 @@ var PixiChart = class {
|
|
|
9386
9447
|
closeY: t.priceToY(bar.close)
|
|
9387
9448
|
};
|
|
9388
9449
|
}
|
|
9389
|
-
return { x, time:
|
|
9450
|
+
return { x, time: this._cursorBucketTime(x) };
|
|
9390
9451
|
}
|
|
9391
9452
|
setIndicatorsVisible(v) {
|
|
9392
9453
|
this._indicatorsVisible = v;
|
|
@@ -10359,14 +10420,13 @@ function toOHLCV(bar) {
|
|
|
10359
10420
|
function _historyWindow(tf) {
|
|
10360
10421
|
return 500 * (parseTfSeconds(tf) ?? 3600);
|
|
10361
10422
|
}
|
|
10362
|
-
var
|
|
10423
|
+
var REFETCH_ON_DOUBT_DELAY_MS = 3e3;
|
|
10363
10424
|
function tfSeconds(tf) {
|
|
10364
10425
|
const m = /^(\d+)\s*(s|m|h|D|W|M)$/.exec(tf);
|
|
10365
10426
|
if (!m) return 0;
|
|
10366
10427
|
const mult = { s: 1, m: 60, h: 3600, D: 86400, W: 604800, M: 2592e3 }[m[2]];
|
|
10367
10428
|
return parseInt(m[1], 10) * mult;
|
|
10368
10429
|
}
|
|
10369
|
-
var LIVE_GAP_REPAIR_DELAY_MS = 3e3;
|
|
10370
10430
|
function _pageSize(tf) {
|
|
10371
10431
|
return 500 * (parseTfSeconds(tf) ?? 3600);
|
|
10372
10432
|
}
|
|
@@ -10402,9 +10462,11 @@ var DatafeedConnector = class {
|
|
|
10402
10462
|
*/
|
|
10403
10463
|
_emptyPageStreak = 0;
|
|
10404
10464
|
/**
|
|
10405
|
-
*
|
|
10406
|
-
*
|
|
10407
|
-
*
|
|
10465
|
+
* Nothing arms this any more — live-tick suppression went with the rest of
|
|
10466
|
+
* the client-side stitching once history became authoritative through the
|
|
10467
|
+
* forming bar. Kept (with its clear helper) because reconnect paths call
|
|
10468
|
+
* the helper and older subclasses may too; clearing a never-set timer is
|
|
10469
|
+
* free. Remove both in the next breaking cleanup.
|
|
10408
10470
|
*/
|
|
10409
10471
|
_batchSafetyTimer = null;
|
|
10410
10472
|
constructor(datafeed, series, callbacks) {
|
|
@@ -10428,12 +10490,10 @@ var DatafeedConnector = class {
|
|
|
10428
10490
|
const to = Math.floor(Date.now() / 1e3);
|
|
10429
10491
|
const from = to - _historyWindow(timeframe);
|
|
10430
10492
|
this._clearBatchTimer();
|
|
10431
|
-
let batchPending = false;
|
|
10432
10493
|
const engine = new CandleEngine({
|
|
10433
10494
|
// Every live tick mutates the engine's bar array and the chart series.
|
|
10434
10495
|
onBarUpdated: (bar) => {
|
|
10435
10496
|
if (this._activeUID !== uid) return;
|
|
10436
|
-
if (batchPending) return;
|
|
10437
10497
|
const ohlcv = toOHLCV(bar);
|
|
10438
10498
|
this._series.update(ohlcv);
|
|
10439
10499
|
this._cb.onUpdate?.(ohlcv);
|
|
@@ -10487,54 +10547,33 @@ var DatafeedConnector = class {
|
|
|
10487
10547
|
}).catch(() => {
|
|
10488
10548
|
});
|
|
10489
10549
|
if (this._activeUID !== uid) return;
|
|
10490
|
-
if (lastBarTime != null) {
|
|
10491
|
-
batchPending = true;
|
|
10492
|
-
this._batchSafetyTimer = setTimeout(() => {
|
|
10493
|
-
batchPending = false;
|
|
10494
|
-
this._batchSafetyTimer = null;
|
|
10495
|
-
}, BATCH_SUPPRESSION_MS);
|
|
10496
|
-
}
|
|
10497
10550
|
const tfSec = tfSeconds(timeframe);
|
|
10498
10551
|
let lastSeenBarTime = lastBarTime ?? 0;
|
|
10499
|
-
let
|
|
10500
|
-
const
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
if (repairTimer) clearTimeout(repairTimer);
|
|
10505
|
-
repairTimer = setTimeout(() => {
|
|
10506
|
-
repairTimer = null;
|
|
10552
|
+
let refetchTimer = null;
|
|
10553
|
+
const refetchOnDoubt = (fromTime, toTime) => {
|
|
10554
|
+
if (refetchTimer) clearTimeout(refetchTimer);
|
|
10555
|
+
refetchTimer = setTimeout(() => {
|
|
10556
|
+
refetchTimer = null;
|
|
10507
10557
|
if (this._activeUID !== uid || this._destroyed) return;
|
|
10508
10558
|
void this._datafeed.getHistoricalBars(symbol, timeframe, fromTime, toTime).then(({ bars: filled }) => {
|
|
10509
|
-
if (this._activeUID !== uid) return;
|
|
10510
|
-
|
|
10511
|
-
const newest = filled
|
|
10512
|
-
|
|
10513
|
-
if (!covered && repairAttempts < REPAIR_MAX_ATTEMPTS) {
|
|
10514
|
-
repairAttempts += 1;
|
|
10515
|
-
if (repairTimer) clearTimeout(repairTimer);
|
|
10516
|
-
repairTimer = setTimeout(() => {
|
|
10517
|
-
repairTimer = null;
|
|
10518
|
-
repairGap(fromTime, toTime);
|
|
10519
|
-
}, REPAIR_RETRY_MS);
|
|
10520
|
-
} else if (covered) {
|
|
10521
|
-
repairAttempts = 0;
|
|
10522
|
-
}
|
|
10559
|
+
if (this._activeUID !== uid || filled.length === 0) return;
|
|
10560
|
+
engine.backfillGap(filled);
|
|
10561
|
+
const newest = filled[filled.length - 1].time;
|
|
10562
|
+
if (newest > lastSeenBarTime) lastSeenBarTime = newest;
|
|
10523
10563
|
}).catch(() => {
|
|
10524
10564
|
});
|
|
10525
|
-
},
|
|
10565
|
+
}, REFETCH_ON_DOUBT_DELAY_MS);
|
|
10526
10566
|
};
|
|
10527
10567
|
this._datafeed.subscribeBars(symbol, timeframe, (bar) => {
|
|
10528
10568
|
if (this._activeUID !== uid) return;
|
|
10529
10569
|
const t = bar.time;
|
|
10530
10570
|
if (tfSec > 0 && lastSeenBarTime > 0 && t > lastSeenBarTime + tfSec) {
|
|
10531
|
-
|
|
10571
|
+
refetchOnDoubt(lastSeenBarTime, t);
|
|
10532
10572
|
}
|
|
10533
10573
|
if (t > lastSeenBarTime) lastSeenBarTime = t;
|
|
10534
10574
|
engine.applyLiveUpdate(bar);
|
|
10535
10575
|
}, uid, lastBarTime, (bars) => {
|
|
10536
10576
|
this._clearBatchTimer();
|
|
10537
|
-
batchPending = false;
|
|
10538
10577
|
if (this._activeUID === uid) {
|
|
10539
10578
|
engine.backfillGap(bars);
|
|
10540
10579
|
const newest = bars.length > 0 ? bars[bars.length - 1].time : 0;
|
|
@@ -10542,16 +10581,7 @@ var DatafeedConnector = class {
|
|
|
10542
10581
|
}
|
|
10543
10582
|
fireLoaded();
|
|
10544
10583
|
});
|
|
10545
|
-
if (result.filling)
|
|
10546
|
-
setTimeout(() => {
|
|
10547
|
-
if (this._activeUID !== uid || this._destroyed) return;
|
|
10548
|
-
void this._datafeed.getHistoricalBars(symbol, timeframe, from, to).then(({ bars: refetchedBars }) => {
|
|
10549
|
-
if (this._activeUID !== uid) return;
|
|
10550
|
-
engine.backfillGap(refetchedBars);
|
|
10551
|
-
}).catch(() => {
|
|
10552
|
-
});
|
|
10553
|
-
}, 8e3);
|
|
10554
|
-
}
|
|
10584
|
+
if (result.filling) refetchOnDoubt(from, to);
|
|
10555
10585
|
}).catch((err) => {
|
|
10556
10586
|
if (this._activeUID !== uid) return;
|
|
10557
10587
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -25575,7 +25605,7 @@ var demonstrationTool = {
|
|
|
25575
25605
|
};
|
|
25576
25606
|
|
|
25577
25607
|
// src/version.ts
|
|
25578
|
-
var FORGECHARTS_VERSION = "1.5.
|
|
25608
|
+
var FORGECHARTS_VERSION = "1.5.70" ;
|
|
25579
25609
|
|
|
25580
25610
|
// src/compatibility.ts
|
|
25581
25611
|
var MIN_KIT_API = 1;
|