@funnest/charts 0.6.2 → 0.6.3
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/chart.d.ts +8 -0
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/chart.d.ts
CHANGED
|
@@ -209,6 +209,14 @@ export declare class Chart {
|
|
|
209
209
|
private connectionState;
|
|
210
210
|
private readonly displayTimezone;
|
|
211
211
|
private loadingHistory;
|
|
212
|
+
/**
|
|
213
|
+
* Bumped by every data replacement (setData) and history request: a page answers only if it
|
|
214
|
+
* is still the latest request for the bars on screen. (The load token alone isn't enough — a
|
|
215
|
+
* page requested while setSymbol() awaits carries the new token but the old symbol's bars.)
|
|
216
|
+
*/
|
|
217
|
+
private historyRequest;
|
|
218
|
+
/** setSymbol() is between its request and setData(). */
|
|
219
|
+
private symbolLoading;
|
|
212
220
|
private noMoreHistory;
|
|
213
221
|
private historyRequestedFor;
|
|
214
222
|
private countdownLabel;
|
package/dist/index.js
CHANGED
|
@@ -2684,6 +2684,14 @@ var Chart = class {
|
|
|
2684
2684
|
connectionState = null;
|
|
2685
2685
|
displayTimezone;
|
|
2686
2686
|
loadingHistory = false;
|
|
2687
|
+
/**
|
|
2688
|
+
* Bumped by every data replacement (setData) and history request: a page answers only if it
|
|
2689
|
+
* is still the latest request for the bars on screen. (The load token alone isn't enough — a
|
|
2690
|
+
* page requested while setSymbol() awaits carries the new token but the old symbol's bars.)
|
|
2691
|
+
*/
|
|
2692
|
+
historyRequest = 0;
|
|
2693
|
+
/** setSymbol() is between its request and setData(). */
|
|
2694
|
+
symbolLoading = false;
|
|
2687
2695
|
noMoreHistory = false;
|
|
2688
2696
|
historyRequestedFor = Number.NaN;
|
|
2689
2697
|
countdownLabel = null;
|
|
@@ -2765,6 +2773,8 @@ var Chart = class {
|
|
|
2765
2773
|
this.volumeScale.autoScale = true;
|
|
2766
2774
|
this.noMoreHistory = false;
|
|
2767
2775
|
this.historyRequestedFor = Number.NaN;
|
|
2776
|
+
this.historyRequest++;
|
|
2777
|
+
this.loadingHistory = false;
|
|
2768
2778
|
this.dataVersion++;
|
|
2769
2779
|
this.invalidate();
|
|
2770
2780
|
}
|
|
@@ -2817,6 +2827,7 @@ var Chart = class {
|
|
|
2817
2827
|
this.quoteSymbol = null;
|
|
2818
2828
|
}
|
|
2819
2829
|
this.emitter.emit("loadingChange", true);
|
|
2830
|
+
this.symbolLoading = true;
|
|
2820
2831
|
let info;
|
|
2821
2832
|
let result;
|
|
2822
2833
|
try {
|
|
@@ -2831,7 +2842,10 @@ var Chart = class {
|
|
|
2831
2842
|
});
|
|
2832
2843
|
if (token !== this.loadToken) return;
|
|
2833
2844
|
} finally {
|
|
2834
|
-
if (token === this.loadToken)
|
|
2845
|
+
if (token === this.loadToken) {
|
|
2846
|
+
this.symbolLoading = false;
|
|
2847
|
+
this.emitter.emit("loadingChange", false);
|
|
2848
|
+
}
|
|
2835
2849
|
}
|
|
2836
2850
|
const previous = this.symbol?.symbol ?? "";
|
|
2837
2851
|
if (previous !== info.symbol) {
|
|
@@ -4036,6 +4050,7 @@ var Chart = class {
|
|
|
4036
4050
|
requestHistory() {
|
|
4037
4051
|
const oldest = this.store.first();
|
|
4038
4052
|
if (!oldest || this.loadingHistory || this.noMoreHistory || oldest.time === this.historyRequestedFor) return;
|
|
4053
|
+
if (this.symbolLoading) return;
|
|
4039
4054
|
this.historyRequestedFor = oldest.time;
|
|
4040
4055
|
const feed = this.datafeed;
|
|
4041
4056
|
if (!feed || !this.symbol || !this.resolution) {
|
|
@@ -4043,6 +4058,8 @@ var Chart = class {
|
|
|
4043
4058
|
return;
|
|
4044
4059
|
}
|
|
4045
4060
|
const token = this.loadToken;
|
|
4061
|
+
const request = ++this.historyRequest;
|
|
4062
|
+
const current = () => token === this.loadToken && request === this.historyRequest;
|
|
4046
4063
|
this.loadingHistory = true;
|
|
4047
4064
|
const to = oldest.time - 1;
|
|
4048
4065
|
feed.getBars(this.symbol, this.resolution, {
|
|
@@ -4050,13 +4067,13 @@ var Chart = class {
|
|
|
4050
4067
|
to,
|
|
4051
4068
|
countBack: this.historyBatchSize
|
|
4052
4069
|
}).then((result) => {
|
|
4053
|
-
if (
|
|
4070
|
+
if (!current()) return;
|
|
4054
4071
|
this.prependData(result.bars, { noMoreData: result.noMoreData || result.bars.length === 0 });
|
|
4055
4072
|
const first = this.store.first();
|
|
4056
4073
|
if (first) void this.tradingSync.loadOlder(first.time);
|
|
4057
4074
|
for (const entry of this.compares.values()) void this.loadOlderCompare(entry);
|
|
4058
4075
|
}).catch((error) => this.emitter.emit("error", error)).finally(() => {
|
|
4059
|
-
if (
|
|
4076
|
+
if (current()) this.loadingHistory = false;
|
|
4060
4077
|
});
|
|
4061
4078
|
}
|
|
4062
4079
|
// ── Crosshair ──────────────────────────────────────────────────────
|