@forgecharts/sdk 1.5.69 → 1.5.71
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/index.js +84 -16
- package/dist/index.js.map +1 -1
- package/dist/internal.js +84 -16
- 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/canvas/ChartCanvas.d.ts +6 -0
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +111 -18
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +111 -18
- package/dist/react/internal.js.map +1 -1
- package/dist/react/persistence/kitPreferencesApi.d.ts +23 -0
- package/dist/react/persistence/kitPreferencesApi.d.ts.map +1 -0
- 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":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version":3,"file":"cursorTime.test.d.ts","sourceRoot":"","sources":["../../../src/core/__tests__/cursorTime.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
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"}
|
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;
|
|
@@ -23170,6 +23231,7 @@ var ChartCanvas = forwardRef(
|
|
|
23170
23231
|
providerKey,
|
|
23171
23232
|
initialActiveTool,
|
|
23172
23233
|
onPointerToolChange,
|
|
23234
|
+
initialPointerTool,
|
|
23173
23235
|
initialMagnetMode,
|
|
23174
23236
|
onMagnetModeChange,
|
|
23175
23237
|
drawingFavorites: drawingFavoritesProp,
|
|
@@ -24306,6 +24368,12 @@ var ChartCanvas = forwardRef(
|
|
|
24306
24368
|
const handleToolSelectRef = useRef(handleToolSelect);
|
|
24307
24369
|
handleToolSelectRef.current = handleToolSelect;
|
|
24308
24370
|
selectPointerToolRef.current = handleToolSelect;
|
|
24371
|
+
const initialPointerAppliedRef = useRef(false);
|
|
24372
|
+
useEffect(() => {
|
|
24373
|
+
if (initialPointerAppliedRef.current || !initialPointerTool) return;
|
|
24374
|
+
initialPointerAppliedRef.current = true;
|
|
24375
|
+
selectPointerToolRef.current(initialPointerTool);
|
|
24376
|
+
}, [initialPointerTool]);
|
|
24309
24377
|
const handleMagnetModeChange = useCallback((mode) => {
|
|
24310
24378
|
setMagnetMode(mode);
|
|
24311
24379
|
chartRef.current?.setMagnetMode(mode);
|
|
@@ -25544,7 +25612,7 @@ var demonstrationTool = {
|
|
|
25544
25612
|
};
|
|
25545
25613
|
|
|
25546
25614
|
// src/version.ts
|
|
25547
|
-
var FORGECHARTS_VERSION = "1.5.
|
|
25615
|
+
var FORGECHARTS_VERSION = "1.5.71" ;
|
|
25548
25616
|
|
|
25549
25617
|
// src/compatibility.ts
|
|
25550
25618
|
var MIN_KIT_API = 1;
|