@forgecharts/sdk 1.5.34 → 1.5.36
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.map +1 -1
- package/dist/index.js +104 -81
- package/dist/index.js.map +1 -1
- package/dist/internal.js +104 -81
- package/dist/internal.js.map +1 -1
- package/dist/pixi/PixiLastPriceRenderer.d.ts.map +1 -1
- package/dist/react/canvas/ChartCanvas.d.ts +10 -2
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
- package/dist/react/index.js +116 -85
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +118 -87
- package/dist/react/internal.js.map +1 -1
- package/dist/react/workspace/TabBar.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/internal.js
CHANGED
|
@@ -5,6 +5,103 @@ import ReactDOM from 'react-dom';
|
|
|
5
5
|
|
|
6
6
|
// src/react/canvas/ChartCanvas.tsx
|
|
7
7
|
|
|
8
|
+
// ../shared/src/time/timeframeRegistry.ts
|
|
9
|
+
function isCalendarTimeframe(key) {
|
|
10
|
+
return key === "1w" || key === "1M" || key === "3M" || key === "6M" || key === "12M";
|
|
11
|
+
}
|
|
12
|
+
function isTickTimeframe(key) {
|
|
13
|
+
return /^\d+t$/i.test(key);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ../shared/src/time/timeUtils.ts
|
|
17
|
+
var MONDAY_EPOCH_OFFSET_MS = 3456e5;
|
|
18
|
+
var WEEK_MS = 6048e5;
|
|
19
|
+
function timeframeToMs(tf) {
|
|
20
|
+
if (isCalendarTimeframe(tf)) return null;
|
|
21
|
+
if (isTickTimeframe(tf)) return null;
|
|
22
|
+
const secs = parseTfSeconds(tf);
|
|
23
|
+
return secs !== null ? secs * 1e3 : null;
|
|
24
|
+
}
|
|
25
|
+
function parseTfSeconds(tf) {
|
|
26
|
+
const m = /^(\d+)(s|m|h|d|w|M)$/.exec(tf);
|
|
27
|
+
if (!m) return null;
|
|
28
|
+
const n = parseInt(m[1], 10);
|
|
29
|
+
const unit = m[2];
|
|
30
|
+
const UNIT_SECONDS = {
|
|
31
|
+
s: 1,
|
|
32
|
+
m: 60,
|
|
33
|
+
h: 3600,
|
|
34
|
+
d: 86400,
|
|
35
|
+
w: 604800,
|
|
36
|
+
M: 2592e3
|
|
37
|
+
};
|
|
38
|
+
const unitSec = UNIT_SECONDS[unit];
|
|
39
|
+
return unitSec !== void 0 ? n * unitSec : null;
|
|
40
|
+
}
|
|
41
|
+
function getBucketStart(timeMs, timeframe) {
|
|
42
|
+
if (timeframe === "1w") return getWeekBucketStart(timeMs);
|
|
43
|
+
if (timeframe === "1M") return getMonthBucketStart(timeMs);
|
|
44
|
+
if (timeframe === "3M") return getQuarterBucketStart(timeMs);
|
|
45
|
+
if (timeframe === "6M") return getHalfYearBucketStart(timeMs);
|
|
46
|
+
if (timeframe === "12M") return getYearBucketStart(timeMs);
|
|
47
|
+
const secs = parseTfSeconds(timeframe);
|
|
48
|
+
if (secs && secs > 0) return Math.floor(timeMs / (secs * 1e3)) * (secs * 1e3);
|
|
49
|
+
return Math.floor(timeMs / 6e4) * 6e4;
|
|
50
|
+
}
|
|
51
|
+
function getWeekBucketStart(timeMs) {
|
|
52
|
+
return Math.floor((timeMs - MONDAY_EPOCH_OFFSET_MS) / WEEK_MS) * WEEK_MS + MONDAY_EPOCH_OFFSET_MS;
|
|
53
|
+
}
|
|
54
|
+
function getMonthBucketStart(timeMs) {
|
|
55
|
+
const d = new Date(timeMs);
|
|
56
|
+
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1);
|
|
57
|
+
}
|
|
58
|
+
function getQuarterBucketStart(timeMs) {
|
|
59
|
+
const d = new Date(timeMs);
|
|
60
|
+
const quarterMonth = Math.floor(d.getUTCMonth() / 3) * 3;
|
|
61
|
+
return Date.UTC(d.getUTCFullYear(), quarterMonth, 1);
|
|
62
|
+
}
|
|
63
|
+
function getHalfYearBucketStart(timeMs) {
|
|
64
|
+
const d = new Date(timeMs);
|
|
65
|
+
const halfMonth = d.getUTCMonth() < 6 ? 0 : 6;
|
|
66
|
+
return Date.UTC(d.getUTCFullYear(), halfMonth, 1);
|
|
67
|
+
}
|
|
68
|
+
function getYearBucketStart(timeMs) {
|
|
69
|
+
return Date.UTC(new Date(timeMs).getUTCFullYear(), 0, 1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ../shared/src/marketHours.ts
|
|
73
|
+
function isGLBXWeekend(nowMs = Date.now()) {
|
|
74
|
+
const d = new Date(nowMs);
|
|
75
|
+
const day = d.getUTCDay();
|
|
76
|
+
const hour = d.getUTCHours();
|
|
77
|
+
if (day === 6) return true;
|
|
78
|
+
if (day === 0 && hour < 22) return true;
|
|
79
|
+
if (day === 5 && hour >= 21) return true;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
function centralParts(nowMs) {
|
|
83
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
84
|
+
timeZone: "America/Chicago",
|
|
85
|
+
weekday: "short",
|
|
86
|
+
hour: "2-digit",
|
|
87
|
+
minute: "2-digit",
|
|
88
|
+
// h23 rather than hour12:false — the latter yields '24' for midnight in
|
|
89
|
+
// some ICU builds, which would parse as an hour that never matches.
|
|
90
|
+
hourCycle: "h23"
|
|
91
|
+
}).formatToParts(new Date(nowMs));
|
|
92
|
+
const get = (t) => parts.find((p) => p.type === t)?.value ?? "";
|
|
93
|
+
return {
|
|
94
|
+
weekday: get("weekday"),
|
|
95
|
+
hour: parseInt(get("hour"), 10),
|
|
96
|
+
minute: parseInt(get("minute"), 10)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function isGLBXDailyBreak(nowMs = Date.now()) {
|
|
100
|
+
const { weekday, hour } = centralParts(nowMs);
|
|
101
|
+
if (hour !== 16) return false;
|
|
102
|
+
return weekday === "Mon" || weekday === "Tue" || weekday === "Wed" || weekday === "Thu";
|
|
103
|
+
}
|
|
104
|
+
|
|
8
105
|
// src/core/CanvasLayer.ts
|
|
9
106
|
var CanvasLayer = class {
|
|
10
107
|
canvas;
|
|
@@ -98,81 +195,6 @@ function computeTicks(min, max, targetCount) {
|
|
|
98
195
|
return ticks;
|
|
99
196
|
}
|
|
100
197
|
|
|
101
|
-
// ../shared/src/time/timeframeRegistry.ts
|
|
102
|
-
function isCalendarTimeframe(key) {
|
|
103
|
-
return key === "1w" || key === "1M" || key === "3M" || key === "6M" || key === "12M";
|
|
104
|
-
}
|
|
105
|
-
function isTickTimeframe(key) {
|
|
106
|
-
return /^\d+t$/i.test(key);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ../shared/src/time/timeUtils.ts
|
|
110
|
-
var MONDAY_EPOCH_OFFSET_MS = 3456e5;
|
|
111
|
-
var WEEK_MS = 6048e5;
|
|
112
|
-
function timeframeToMs(tf) {
|
|
113
|
-
if (isCalendarTimeframe(tf)) return null;
|
|
114
|
-
if (isTickTimeframe(tf)) return null;
|
|
115
|
-
const secs = parseTfSeconds(tf);
|
|
116
|
-
return secs !== null ? secs * 1e3 : null;
|
|
117
|
-
}
|
|
118
|
-
function parseTfSeconds(tf) {
|
|
119
|
-
const m = /^(\d+)(s|m|h|d|w|M)$/.exec(tf);
|
|
120
|
-
if (!m) return null;
|
|
121
|
-
const n = parseInt(m[1], 10);
|
|
122
|
-
const unit = m[2];
|
|
123
|
-
const UNIT_SECONDS = {
|
|
124
|
-
s: 1,
|
|
125
|
-
m: 60,
|
|
126
|
-
h: 3600,
|
|
127
|
-
d: 86400,
|
|
128
|
-
w: 604800,
|
|
129
|
-
M: 2592e3
|
|
130
|
-
};
|
|
131
|
-
const unitSec = UNIT_SECONDS[unit];
|
|
132
|
-
return unitSec !== void 0 ? n * unitSec : null;
|
|
133
|
-
}
|
|
134
|
-
function getBucketStart(timeMs, timeframe) {
|
|
135
|
-
if (timeframe === "1w") return getWeekBucketStart(timeMs);
|
|
136
|
-
if (timeframe === "1M") return getMonthBucketStart(timeMs);
|
|
137
|
-
if (timeframe === "3M") return getQuarterBucketStart(timeMs);
|
|
138
|
-
if (timeframe === "6M") return getHalfYearBucketStart(timeMs);
|
|
139
|
-
if (timeframe === "12M") return getYearBucketStart(timeMs);
|
|
140
|
-
const secs = parseTfSeconds(timeframe);
|
|
141
|
-
if (secs && secs > 0) return Math.floor(timeMs / (secs * 1e3)) * (secs * 1e3);
|
|
142
|
-
return Math.floor(timeMs / 6e4) * 6e4;
|
|
143
|
-
}
|
|
144
|
-
function getWeekBucketStart(timeMs) {
|
|
145
|
-
return Math.floor((timeMs - MONDAY_EPOCH_OFFSET_MS) / WEEK_MS) * WEEK_MS + MONDAY_EPOCH_OFFSET_MS;
|
|
146
|
-
}
|
|
147
|
-
function getMonthBucketStart(timeMs) {
|
|
148
|
-
const d = new Date(timeMs);
|
|
149
|
-
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1);
|
|
150
|
-
}
|
|
151
|
-
function getQuarterBucketStart(timeMs) {
|
|
152
|
-
const d = new Date(timeMs);
|
|
153
|
-
const quarterMonth = Math.floor(d.getUTCMonth() / 3) * 3;
|
|
154
|
-
return Date.UTC(d.getUTCFullYear(), quarterMonth, 1);
|
|
155
|
-
}
|
|
156
|
-
function getHalfYearBucketStart(timeMs) {
|
|
157
|
-
const d = new Date(timeMs);
|
|
158
|
-
const halfMonth = d.getUTCMonth() < 6 ? 0 : 6;
|
|
159
|
-
return Date.UTC(d.getUTCFullYear(), halfMonth, 1);
|
|
160
|
-
}
|
|
161
|
-
function getYearBucketStart(timeMs) {
|
|
162
|
-
return Date.UTC(new Date(timeMs).getUTCFullYear(), 0, 1);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ../shared/src/marketHours.ts
|
|
166
|
-
function isGLBXWeekend(nowMs = Date.now()) {
|
|
167
|
-
const d = new Date(nowMs);
|
|
168
|
-
const day = d.getUTCDay();
|
|
169
|
-
const hour = d.getUTCHours();
|
|
170
|
-
if (day === 6) return true;
|
|
171
|
-
if (day === 0 && hour < 22) return true;
|
|
172
|
-
if (day === 5 && hour >= 21) return true;
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
198
|
// ../utils/src/time.ts
|
|
177
199
|
function parseTimeframeSeconds(tf) {
|
|
178
200
|
return parseTfSeconds(tf);
|
|
@@ -5137,7 +5159,7 @@ var Chart = class {
|
|
|
5137
5159
|
const tfSecs = _tfToSeconds(this._interval);
|
|
5138
5160
|
const now = Math.floor(exchangeNow() / 1e3);
|
|
5139
5161
|
const remaining = tfSecs - now % tfSecs;
|
|
5140
|
-
const showCd = this._options.showCountdown !== false;
|
|
5162
|
+
const showCd = this._options.showCountdown !== false && !isGLBXDailyBreak(now * 1e3);
|
|
5141
5163
|
const priceLabel = _formatLastPrice(price, this._options.pricePrecision);
|
|
5142
5164
|
const lineH = 15;
|
|
5143
5165
|
const boxH = showCd ? lineH * 2 + 1 : lineH;
|
|
@@ -7659,9 +7681,10 @@ var PixiLastPriceRenderer = class {
|
|
|
7659
7681
|
cx += dashLen + gapLen;
|
|
7660
7682
|
}
|
|
7661
7683
|
this._lineGfx.stroke();
|
|
7662
|
-
const showCd = this.showCountdown;
|
|
7663
|
-
const tfSecs = tfToSeconds(interval);
|
|
7664
7684
|
const now = Math.floor(exchangeNow() / 1e3);
|
|
7685
|
+
const halted = isGLBXDailyBreak(now * 1e3);
|
|
7686
|
+
const showCd = this.showCountdown && !halted;
|
|
7687
|
+
const tfSecs = tfToSeconds(interval);
|
|
7665
7688
|
const remaining = tfSecs - now % tfSecs;
|
|
7666
7689
|
this._lastSec = now;
|
|
7667
7690
|
const lineH = 15;
|
|
@@ -19928,7 +19951,7 @@ function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavo
|
|
|
19928
19951
|
/* @__PURE__ */ jsx(
|
|
19929
19952
|
MagnetTool,
|
|
19930
19953
|
{
|
|
19931
|
-
mode: magnetMode ?? "snap-
|
|
19954
|
+
mode: magnetMode ?? "snap-x",
|
|
19932
19955
|
...onMagnetModeChange ? { onChange: onMagnetModeChange } : {}
|
|
19933
19956
|
}
|
|
19934
19957
|
),
|
|
@@ -22959,7 +22982,7 @@ var ChartCanvas = forwardRef(
|
|
|
22959
22982
|
const [indicators, setIndicators] = useState([]);
|
|
22960
22983
|
const [totalHeight, setTotalHeight] = useState(600);
|
|
22961
22984
|
const [activeTool, setActiveTool] = useState(initialActiveTool ?? "cursor");
|
|
22962
|
-
const [magnetMode, setMagnetMode] = useState(initialMagnetMode ?? "snap-
|
|
22985
|
+
const [magnetMode, setMagnetMode] = useState(initialMagnetMode ?? "snap-x");
|
|
22963
22986
|
const [drawingFavorites, setDrawingFavorites] = useState(drawingFavoritesProp ?? []);
|
|
22964
22987
|
const [ctxMenu, setCtxMenu] = useState(null);
|
|
22965
22988
|
const [chartCtxMenu, setChartCtxMenu] = useState(null);
|
|
@@ -23239,7 +23262,7 @@ var ChartCanvas = forwardRef(
|
|
|
23239
23262
|
const initTool = initialActiveTool ?? "cursor";
|
|
23240
23263
|
chart.setCrosshairEnabled(initTool === "crosshair");
|
|
23241
23264
|
chart.setNativeCursorHidden(initTool !== "cursor");
|
|
23242
|
-
chart.setMagnetMode(initialMagnetMode ?? "snap-
|
|
23265
|
+
chart.setMagnetMode(initialMagnetMode ?? "snap-x");
|
|
23243
23266
|
syncChartState();
|
|
23244
23267
|
return () => {
|
|
23245
23268
|
chart.destroy();
|
|
@@ -24568,14 +24591,22 @@ function TabBar({ tabs, activeId, onSelect, onAdd, onClose, onRename, showAddTab
|
|
|
24568
24591
|
setCanScrollLeft(el.scrollLeft > 0);
|
|
24569
24592
|
setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
24570
24593
|
}, []);
|
|
24594
|
+
const tabsKey = tabs.map((t) => t.id).join("|");
|
|
24571
24595
|
useEffect(() => {
|
|
24572
24596
|
updateArrows();
|
|
24573
24597
|
const el = scrollRef.current;
|
|
24574
24598
|
if (!el) return;
|
|
24575
|
-
|
|
24599
|
+
let frame = 0;
|
|
24600
|
+
const ro = new ResizeObserver(() => {
|
|
24601
|
+
cancelAnimationFrame(frame);
|
|
24602
|
+
frame = requestAnimationFrame(updateArrows);
|
|
24603
|
+
});
|
|
24576
24604
|
ro.observe(el);
|
|
24577
|
-
return () =>
|
|
24578
|
-
|
|
24605
|
+
return () => {
|
|
24606
|
+
cancelAnimationFrame(frame);
|
|
24607
|
+
ro.disconnect();
|
|
24608
|
+
};
|
|
24609
|
+
}, [tabsKey, updateArrows]);
|
|
24579
24610
|
useEffect(() => {
|
|
24580
24611
|
const el = scrollRef.current;
|
|
24581
24612
|
if (!el) return;
|
|
@@ -26776,7 +26807,7 @@ function _guessFrontMonth(product, months) {
|
|
|
26776
26807
|
}
|
|
26777
26808
|
|
|
26778
26809
|
// src/version.ts
|
|
26779
|
-
var FORGECHARTS_VERSION = "1.5.
|
|
26810
|
+
var FORGECHARTS_VERSION = "1.5.36" ;
|
|
26780
26811
|
var TIMEZONE_OPTIONS = [
|
|
26781
26812
|
{ label: "UTC", value: "UTC" },
|
|
26782
26813
|
{ label: "Exchange", value: "exchange" },
|
|
@@ -34629,7 +34660,7 @@ var DEFAULT_WORKSPACE = {
|
|
|
34629
34660
|
rollRule: "v",
|
|
34630
34661
|
theme: "dark",
|
|
34631
34662
|
activeTool: "cursor",
|
|
34632
|
-
magnetMode: "snap-
|
|
34663
|
+
magnetMode: "snap-x",
|
|
34633
34664
|
canvasSettings: {
|
|
34634
34665
|
background: "#000000",
|
|
34635
34666
|
gridColor: "#ffffff",
|
|
@@ -34682,7 +34713,7 @@ function workspaceFromPrefs(raw) {
|
|
|
34682
34713
|
rollRule: p["rollRule"] === "c" || p["rollRule"] === "n" ? p["rollRule"] : "v",
|
|
34683
34714
|
theme: p["theme"] === "light" ? "light" : "dark",
|
|
34684
34715
|
activeTool: ["cursor", "crosshair", "dot", "demonstration"].includes(p["activeTool"]) ? p["activeTool"] : "cursor",
|
|
34685
|
-
magnetMode: ["off", "snap-x", "snap-xy"].includes(p["magnetMode"]) ? p["magnetMode"] : "snap-
|
|
34716
|
+
magnetMode: ["off", "snap-x", "snap-xy"].includes(p["magnetMode"]) ? p["magnetMode"] : "snap-x",
|
|
34686
34717
|
canvasSettings: _parseCanvasSettings(p["canvasSettings"])
|
|
34687
34718
|
};
|
|
34688
34719
|
}
|