@forgecharts/sdk 1.5.35 → 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 +101 -78
- package/dist/index.js.map +1 -1
- package/dist/internal.js +101 -78
- package/dist/internal.js.map +1 -1
- package/dist/pixi/PixiLastPriceRenderer.d.ts.map +1 -1
- package/dist/react/index.js +102 -79
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +102 -79
- package/dist/react/internal.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PixiLastPriceRenderer.d.ts","sourceRoot":"","sources":["../../src/pixi/PixiLastPriceRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA+B7C;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAO;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAK;IACrB,yDAAyD;IACzD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAa;IAC/C,2CAA2C;IAC3C,aAAa,UAAQ;gBAET,KAAK,EAAE,SAAS;IAyB5B,OAAO,IAAI,IAAI;IAOf;;;;OAIG;IACH,IAAI,CACF,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,SAAS,GAClB,OAAO;
|
|
1
|
+
{"version":3,"file":"PixiLastPriceRenderer.d.ts","sourceRoot":"","sources":["../../src/pixi/PixiLastPriceRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA+B7C;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAO;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;IACtC,OAAO,CAAC,QAAQ,CAAK;IACrB,yDAAyD;IACzD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAa;IAC/C,2CAA2C;IAC3C,aAAa,UAAQ;gBAET,KAAK,EAAE,SAAS;IAyB5B,OAAO,IAAI,IAAI;IAOf;;;;OAIG;IACH,IAAI,CACF,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,SAAS,GAClB,OAAO;IA8EV,6EAA6E;IAC7E,WAAW,IAAI,OAAO;CAIvB"}
|
package/dist/react/index.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;
|
|
@@ -26559,7 +26582,7 @@ function _guessFrontMonth(product, months) {
|
|
|
26559
26582
|
}
|
|
26560
26583
|
|
|
26561
26584
|
// src/version.ts
|
|
26562
|
-
var FORGECHARTS_VERSION = "1.5.
|
|
26585
|
+
var FORGECHARTS_VERSION = "1.5.36" ;
|
|
26563
26586
|
var TIMEZONE_OPTIONS = [
|
|
26564
26587
|
{ label: "UTC", value: "UTC" },
|
|
26565
26588
|
{ label: "Exchange", value: "exchange" },
|