@supersolutions/super-chart-core 0.2.0 → 0.4.0
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/{chunk-PY4XSYVS.js → chunk-U2Z26OW4.js} +115 -15
- package/dist/index.d.ts +39 -5
- package/dist/index.js +3 -1
- package/dist/native.d.ts +39 -5
- package/dist/native.js +3 -1
- package/package.json +1 -1
|
@@ -1879,6 +1879,7 @@ function isHeikinAshiUp(bar) {
|
|
|
1879
1879
|
}
|
|
1880
1880
|
|
|
1881
1881
|
// packages/core/src/realtimeSeries.ts
|
|
1882
|
+
var OLDER_REQUEST_EXPIRY_MS = 3e3;
|
|
1882
1883
|
var RealtimeSeries = class {
|
|
1883
1884
|
_bars = [];
|
|
1884
1885
|
_ha = null;
|
|
@@ -1891,6 +1892,8 @@ var RealtimeSeries = class {
|
|
|
1891
1892
|
_version = 0;
|
|
1892
1893
|
_more = false;
|
|
1893
1894
|
_loadMore = null;
|
|
1895
|
+
/** A request for older bars is out. Several callers (edge, prefetch, button) must not start the same page twice. */
|
|
1896
|
+
_olderSince = -Infinity;
|
|
1894
1897
|
_listeners = /* @__PURE__ */ new Set();
|
|
1895
1898
|
_referenceIndicators;
|
|
1896
1899
|
/** Hosts with their own indicator registry can omit the native reference MA/EMA. */
|
|
@@ -1936,10 +1939,16 @@ var RealtimeSeries = class {
|
|
|
1936
1939
|
}
|
|
1937
1940
|
/** Host calls this when its own viewport reaches the oldest loaded bar. */
|
|
1938
1941
|
requestMore() {
|
|
1939
|
-
if (this._more)
|
|
1940
|
-
|
|
1942
|
+
if (!this._more || this._loadMore === null)
|
|
1943
|
+
return;
|
|
1944
|
+
const now = Date.now();
|
|
1945
|
+
if (now - this._olderSince < OLDER_REQUEST_EXPIRY_MS)
|
|
1946
|
+
return;
|
|
1947
|
+
this._olderSince = now;
|
|
1948
|
+
this._loadMore(this._bars[0]?.timestamp ?? null);
|
|
1941
1949
|
}
|
|
1942
1950
|
applyNewData(bars, more = false) {
|
|
1951
|
+
this._olderSince = -Infinity;
|
|
1943
1952
|
this._bars = this._copyValidated(bars);
|
|
1944
1953
|
this._more = more;
|
|
1945
1954
|
this._rebuild();
|
|
@@ -1960,6 +1969,7 @@ var RealtimeSeries = class {
|
|
|
1960
1969
|
return true;
|
|
1961
1970
|
}
|
|
1962
1971
|
applyMoreData(bars, more = false) {
|
|
1972
|
+
this._olderSince = -Infinity;
|
|
1963
1973
|
this._validate(bars);
|
|
1964
1974
|
const first = this._bars[0]?.timestamp ?? Infinity;
|
|
1965
1975
|
const older = bars.filter((bar) => bar.timestamp < first).map((bar) => ({ ...bar }));
|
|
@@ -2101,6 +2111,10 @@ function zoomContinuousViewport(value, length, factor, anchor, limits) {
|
|
|
2101
2111
|
var RealtimeView = class {
|
|
2102
2112
|
constructor(_series, options = {}) {
|
|
2103
2113
|
this._series = _series;
|
|
2114
|
+
const prefetch = options.prefetchBars;
|
|
2115
|
+
if (prefetch !== void 0 && (!Number.isFinite(prefetch) || prefetch < 0))
|
|
2116
|
+
throw new RangeError("prefetchBars must be zero or a positive number");
|
|
2117
|
+
this._prefetchBars = prefetch;
|
|
2104
2118
|
const historyLimit = options.navigationHistory ?? 32;
|
|
2105
2119
|
if (!Number.isSafeInteger(historyLimit) || historyLimit < 0 || historyLimit > 100)
|
|
2106
2120
|
throw new RangeError("Navigation history must be an integer from 0 to 100");
|
|
@@ -2130,6 +2144,7 @@ var RealtimeView = class {
|
|
|
2130
2144
|
_limits;
|
|
2131
2145
|
_openingCount;
|
|
2132
2146
|
_historyLimit;
|
|
2147
|
+
_prefetchBars;
|
|
2133
2148
|
_past = [];
|
|
2134
2149
|
_future = [];
|
|
2135
2150
|
_navigationStart = null;
|
|
@@ -2174,6 +2189,7 @@ var RealtimeView = class {
|
|
|
2174
2189
|
if (before !== null)
|
|
2175
2190
|
this._recordNavigation(before);
|
|
2176
2191
|
this._publish();
|
|
2192
|
+
this.prefetchHistory();
|
|
2177
2193
|
}
|
|
2178
2194
|
pan(bars) {
|
|
2179
2195
|
if (!Number.isFinite(bars) || bars === 0)
|
|
@@ -2273,6 +2289,14 @@ var RealtimeView = class {
|
|
|
2273
2289
|
if (!this._disposed)
|
|
2274
2290
|
this._series.requestMore();
|
|
2275
2291
|
}
|
|
2292
|
+
/** Ask for the next older page when the viewport is within the prefetch distance of the oldest loaded bar. */
|
|
2293
|
+
prefetchHistory() {
|
|
2294
|
+
if (this._disposed || !this._series.hasMore)
|
|
2295
|
+
return;
|
|
2296
|
+
const ahead = this._prefetchBars ?? Math.ceil(viewportSpan(this._viewport) * 1.5) + 50;
|
|
2297
|
+
if (this._viewport.i0 <= ahead)
|
|
2298
|
+
this._series.requestMore();
|
|
2299
|
+
}
|
|
2276
2300
|
dispose() {
|
|
2277
2301
|
if (this._disposed)
|
|
2278
2302
|
return;
|
|
@@ -2335,6 +2359,9 @@ var RealtimeView = class {
|
|
|
2335
2359
|
} else if (change2.kind === "prepend") {
|
|
2336
2360
|
const added = this._length - oldLength;
|
|
2337
2361
|
this._viewport = this._clamp({ i0: this._viewport.i0 + added, i1: this._viewport.i1 + added });
|
|
2362
|
+
void Promise.resolve().then(() => {
|
|
2363
|
+
this.prefetchHistory();
|
|
2364
|
+
});
|
|
2338
2365
|
} else {
|
|
2339
2366
|
this._viewport = this._clamp(this._viewport);
|
|
2340
2367
|
}
|
|
@@ -3926,20 +3953,19 @@ function position(value, type, project, bounds, sink) {
|
|
|
3926
3953
|
if (value.anchors.length !== 3)
|
|
3927
3954
|
return result(type, "invalid-position");
|
|
3928
3955
|
const [entry, target, stop] = value.anchors.map((anchor) => anchor.price), long = type === "position-long";
|
|
3929
|
-
if (![entry, target, stop].every(Number.isFinite)
|
|
3956
|
+
if (![entry, target, stop].every(Number.isFinite))
|
|
3930
3957
|
return result(type, "invalid-position");
|
|
3958
|
+
const ordered = long ? target > entry && stop < entry : target < entry && stop > entry;
|
|
3931
3959
|
const rewardRiskRatio = Math.abs(target - entry) / Math.abs(entry - stop);
|
|
3932
|
-
if (!Number.isFinite(rewardRiskRatio))
|
|
3933
|
-
return result(type, "invalid-position");
|
|
3934
3960
|
const percentage = (price) => {
|
|
3935
3961
|
const number = (price - entry) / Math.abs(entry) * 100;
|
|
3936
3962
|
return entry !== 0 && Number.isFinite(number) ? number : void 0;
|
|
3937
3963
|
};
|
|
3938
3964
|
const targetChangePercent = percentage(target), stopChangePercent = percentage(stop);
|
|
3939
|
-
const statistics = { rewardRiskRatio, ...targetChangePercent === void 0 ? {} : { targetChangePercent }, ...stopChangePercent === void 0 ? {} : { stopChangePercent } };
|
|
3965
|
+
const statistics = Number.isFinite(rewardRiskRatio) ? { rewardRiskRatio, ...targetChangePercent === void 0 ? {} : { targetChangePercent }, ...stopChangePercent === void 0 ? {} : { stopChangePercent } } : void 0;
|
|
3940
3966
|
const points = value.anchors.map((anchor) => project(anchor.timestamp, anchor.price));
|
|
3941
3967
|
if (!points.every(finitePoint))
|
|
3942
|
-
return result(type, "unprojectable", { statistics });
|
|
3968
|
+
return result(type, "unprojectable", statistics === void 0 ? void 0 : { statistics });
|
|
3943
3969
|
const left = Math.min(...points.map((point) => point.x)), right = Math.max(...points.map((point) => point.x));
|
|
3944
3970
|
for (const next of [points[1], points[2]])
|
|
3945
3971
|
sink.polygon([{ x: left, y: points[0].y }, { x: right, y: points[0].y }, { x: right, y: next.y }, { x: left, y: next.y }]);
|
|
@@ -3951,9 +3977,11 @@ function position(value, type, project, bounds, sink) {
|
|
|
3951
3977
|
sink.text(place, text2, price, "center");
|
|
3952
3978
|
};
|
|
3953
3979
|
const percent = (number) => number === void 0 ? "" : ` ${number >= 0 ? "+" : ""}${number.toFixed(2)}%`;
|
|
3954
|
-
caption(points[0], `${long ? "Long" : "Short"} R/R ${rewardRiskRatio.toFixed(2)}`);
|
|
3980
|
+
caption(points[0], `${long ? "Long" : "Short"}${statistics === void 0 ? "" : ` R/R ${rewardRiskRatio.toFixed(2)}`}`);
|
|
3955
3981
|
caption(points[1], `Target${percent(targetChangePercent)}`, target);
|
|
3956
3982
|
caption(points[2], `Stop${percent(stopChangePercent)}`, stop);
|
|
3983
|
+
if (!ordered || statistics === void 0)
|
|
3984
|
+
return result(type, "invalid-position");
|
|
3957
3985
|
return result(type, "ready", { statistics });
|
|
3958
3986
|
}
|
|
3959
3987
|
function projectDataDrivenDrawing(value, project, bounds, context, sink) {
|
|
@@ -4321,8 +4349,39 @@ function anchors(value, type) {
|
|
|
4321
4349
|
result2[1].timestamp = result2[0].timestamp;
|
|
4322
4350
|
return Object.freeze(result2.map((point) => Object.freeze(point)));
|
|
4323
4351
|
}
|
|
4352
|
+
var COLOR = /^#(?:[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
4353
|
+
function drawingStyle(value) {
|
|
4354
|
+
if (value === void 0 || value === null)
|
|
4355
|
+
return void 0;
|
|
4356
|
+
const input = record(value, ["color", "width", "dash", "fillColor", "fillOpacity", "textColor"], "drawing style");
|
|
4357
|
+
const style = {};
|
|
4358
|
+
for (const key of ["color", "fillColor", "textColor"]) {
|
|
4359
|
+
const colour = input[key];
|
|
4360
|
+
if (colour === void 0)
|
|
4361
|
+
continue;
|
|
4362
|
+
if (typeof colour !== "string" || !COLOR.test(colour))
|
|
4363
|
+
throw new TypeError(`Invalid drawing style ${key}: use #rrggbb or #rrggbbaa`);
|
|
4364
|
+
style[key] = colour.toLowerCase();
|
|
4365
|
+
}
|
|
4366
|
+
if (input.width !== void 0) {
|
|
4367
|
+
if (typeof input.width !== "number" || !Number.isFinite(input.width) || input.width < 1 || input.width > 8)
|
|
4368
|
+
throw new TypeError("Invalid drawing style width: 1 to 8");
|
|
4369
|
+
style.width = input.width;
|
|
4370
|
+
}
|
|
4371
|
+
if (input.dash !== void 0) {
|
|
4372
|
+
if (input.dash !== "solid" && input.dash !== "dashed" && input.dash !== "dotted")
|
|
4373
|
+
throw new TypeError("Invalid drawing style dash");
|
|
4374
|
+
style.dash = input.dash;
|
|
4375
|
+
}
|
|
4376
|
+
if (input.fillOpacity !== void 0) {
|
|
4377
|
+
if (typeof input.fillOpacity !== "number" || !Number.isFinite(input.fillOpacity) || input.fillOpacity < 0 || input.fillOpacity > 1)
|
|
4378
|
+
throw new TypeError("Invalid drawing style fillOpacity: 0 to 1");
|
|
4379
|
+
style.fillOpacity = input.fillOpacity;
|
|
4380
|
+
}
|
|
4381
|
+
return Object.keys(style).length === 0 ? void 0 : Object.freeze(style);
|
|
4382
|
+
}
|
|
4324
4383
|
function drawing(value) {
|
|
4325
|
-
const input = record(value, ["id", "type", "anchors", "locked", "hidden", "text", "image", "strokeWidth"], "drawing");
|
|
4384
|
+
const input = record(value, ["id", "type", "anchors", "locked", "hidden", "text", "image", "strokeWidth", "style"], "drawing");
|
|
4326
4385
|
if (typeof input.id !== "string" || input.id.trim() === "" || input.id.length > 128)
|
|
4327
4386
|
throw new TypeError("Invalid drawing id");
|
|
4328
4387
|
if (!DRAWING_TYPES.includes(input.type))
|
|
@@ -4347,10 +4406,11 @@ function drawing(value) {
|
|
|
4347
4406
|
throw new TypeError("Invalid freehand stroke width");
|
|
4348
4407
|
content.strokeWidth = input.strokeWidth;
|
|
4349
4408
|
}
|
|
4350
|
-
|
|
4409
|
+
const style = drawingStyle(input.style);
|
|
4410
|
+
return Object.freeze({ id: input.id, type, anchors: anchors(input.anchors, type), locked: flag(input.locked, "locked"), hidden: flag(input.hidden, "hidden"), ...content, ...style === void 0 ? {} : { style } });
|
|
4351
4411
|
}
|
|
4352
4412
|
function same(a, b) {
|
|
4353
|
-
return a.id === b.id && a.type === b.type && a.locked === b.locked && a.hidden === b.hidden && a.text === b.text && a.image === b.image && a.strokeWidth === b.strokeWidth && a.anchors.length === b.anchors.length && a.anchors.every((point, i) => point.timestamp === b.anchors[i].timestamp && point.price === b.anchors[i].price);
|
|
4413
|
+
return a.id === b.id && a.type === b.type && a.locked === b.locked && a.hidden === b.hidden && a.text === b.text && a.image === b.image && a.strokeWidth === b.strokeWidth && JSON.stringify(a.style) === JSON.stringify(b.style) && a.anchors.length === b.anchors.length && a.anchors.every((point, i) => point.timestamp === b.anchors[i].timestamp && point.price === b.anchors[i].price);
|
|
4354
4414
|
}
|
|
4355
4415
|
function finitePoint2(point) {
|
|
4356
4416
|
return point !== null && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
@@ -4649,8 +4709,47 @@ function projectDrawing(value, project, bounds, context) {
|
|
|
4649
4709
|
if (box.left < bounds.right && box.right > bounds.left && box.top < bounds.bottom && box.bottom > bounds.top && box.left < box.right && box.top < box.bottom)
|
|
4650
4710
|
primitives.push({ kind: "image", source: value.image, bounds: box, clip: { ...bounds } });
|
|
4651
4711
|
}
|
|
4652
|
-
const
|
|
4653
|
-
|
|
4712
|
+
const freehand = value.type === "brush" || value.type === "highlighter";
|
|
4713
|
+
let handlePoints = points;
|
|
4714
|
+
if (BOX_TYPES.includes(value.type) && points.length === 2 && points.every(finitePoint2)) {
|
|
4715
|
+
const [p1, p2] = points, mx = (p1.x + p2.x) / 2, my = (p1.y + p2.y) / 2;
|
|
4716
|
+
handlePoints = [p1, p2, { x: p1.x, y: p2.y }, { x: p2.x, y: p1.y }, { x: mx, y: p1.y }, { x: mx, y: p2.y }, { x: p1.x, y: my }, { x: p2.x, y: my }];
|
|
4717
|
+
}
|
|
4718
|
+
const handles = value.locked || freehand ? [] : handlePoints.flatMap((point, anchorIndex) => inside(point, bounds) ? [{ point, anchorIndex }] : []);
|
|
4719
|
+
return { id: value.id, type: value.type, locked: value.locked, primitives, handles, ...value.style === void 0 ? {} : { style: value.style }, ...analysis === void 0 ? {} : { analysis } };
|
|
4720
|
+
}
|
|
4721
|
+
var BOX_TYPES = ["rectangle", "price-range", "time-range", "ellipse", "image"];
|
|
4722
|
+
function moveDrawingHandle(value, handleIndex, next) {
|
|
4723
|
+
const anchors2 = value.anchors.map((item) => ({ ...item }));
|
|
4724
|
+
if (BOX_TYPES.includes(value.type) && anchors2.length === 2 && handleIndex >= 2) {
|
|
4725
|
+
const [a, b] = anchors2;
|
|
4726
|
+
switch (handleIndex) {
|
|
4727
|
+
case 2:
|
|
4728
|
+
a.timestamp = next.timestamp;
|
|
4729
|
+
b.price = next.price;
|
|
4730
|
+
break;
|
|
4731
|
+
case 3:
|
|
4732
|
+
b.timestamp = next.timestamp;
|
|
4733
|
+
a.price = next.price;
|
|
4734
|
+
break;
|
|
4735
|
+
case 4:
|
|
4736
|
+
a.price = next.price;
|
|
4737
|
+
break;
|
|
4738
|
+
case 5:
|
|
4739
|
+
b.price = next.price;
|
|
4740
|
+
break;
|
|
4741
|
+
case 6:
|
|
4742
|
+
a.timestamp = next.timestamp;
|
|
4743
|
+
break;
|
|
4744
|
+
case 7:
|
|
4745
|
+
b.timestamp = next.timestamp;
|
|
4746
|
+
break;
|
|
4747
|
+
}
|
|
4748
|
+
return anchors2;
|
|
4749
|
+
}
|
|
4750
|
+
if (handleIndex >= 0 && handleIndex < anchors2.length)
|
|
4751
|
+
anchors2[handleIndex] = { ...next };
|
|
4752
|
+
return anchors2;
|
|
4654
4753
|
}
|
|
4655
4754
|
function lineDistance(point, from, to) {
|
|
4656
4755
|
const dx = to.x - from.x, dy = to.y - from.y, square = dx * dx + dy * dy;
|
|
@@ -4744,13 +4843,13 @@ var DrawingStore = class {
|
|
|
4744
4843
|
}
|
|
4745
4844
|
/** Locked anchors are unchanged until explicitly unlocked. Visibility remains editable. */
|
|
4746
4845
|
update(id, patch) {
|
|
4747
|
-
const fields = record(patch, ["anchors", "locked", "hidden", "text", "image", "strokeWidth"], "drawing patch");
|
|
4846
|
+
const fields = record(patch, ["anchors", "locked", "hidden", "text", "image", "strokeWidth", "style"], "drawing patch");
|
|
4748
4847
|
const index = this.drawings.findIndex((item) => item.id === id);
|
|
4749
4848
|
if (index < 0)
|
|
4750
4849
|
return false;
|
|
4751
4850
|
const current = this.drawings[index];
|
|
4752
4851
|
const value = drawing({ ...current, ...fields });
|
|
4753
|
-
if (current.locked && (fields.anchors !== void 0 || fields.text !== void 0 || fields.image !== void 0 || fields.strokeWidth !== void 0))
|
|
4852
|
+
if (current.locked && (fields.anchors !== void 0 || fields.text !== void 0 || fields.image !== void 0 || fields.strokeWidth !== void 0 || fields.style !== void 0))
|
|
4754
4853
|
return false;
|
|
4755
4854
|
if (same(current, value))
|
|
4756
4855
|
return false;
|
|
@@ -6299,6 +6398,7 @@ export {
|
|
|
6299
6398
|
drawingUsesText,
|
|
6300
6399
|
drawingAnchorCount,
|
|
6301
6400
|
projectDrawing,
|
|
6401
|
+
moveDrawingHandle,
|
|
6302
6402
|
hitTestDrawingGeometry,
|
|
6303
6403
|
DrawingStore,
|
|
6304
6404
|
ENGINE_CHART_TYPES,
|
package/dist/index.d.ts
CHANGED
|
@@ -1006,11 +1006,6 @@ export interface RealtimeSeriesChange {
|
|
|
1006
1006
|
length: number;
|
|
1007
1007
|
version: number;
|
|
1008
1008
|
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Renderer-free sink for DataLoader. MA20 and EMA21 use the native first-close
|
|
1011
|
-
* EMA seed (not the Web SMA seed). Inputs must be normalized, ascending bars.
|
|
1012
|
-
* History changes rebuild; live updates only calculate the changed tail.
|
|
1013
|
-
*/
|
|
1014
1009
|
export declare class RealtimeSeries implements ChartDataPort {
|
|
1015
1010
|
private _bars;
|
|
1016
1011
|
private _ha;
|
|
@@ -1023,6 +1018,8 @@ export declare class RealtimeSeries implements ChartDataPort {
|
|
|
1023
1018
|
private _version;
|
|
1024
1019
|
private _more;
|
|
1025
1020
|
private _loadMore;
|
|
1021
|
+
/** A request for older bars is out. Several callers (edge, prefetch, button) must not start the same page twice. */
|
|
1022
|
+
private _olderSince;
|
|
1026
1023
|
private readonly _listeners;
|
|
1027
1024
|
private readonly _referenceIndicators;
|
|
1028
1025
|
/** Hosts with their own indicator registry can omit the native reference MA/EMA. */
|
|
@@ -1095,6 +1092,7 @@ export declare class RealtimeView {
|
|
|
1095
1092
|
private _limits;
|
|
1096
1093
|
private readonly _openingCount;
|
|
1097
1094
|
private readonly _historyLimit;
|
|
1095
|
+
private readonly _prefetchBars;
|
|
1098
1096
|
private readonly _past;
|
|
1099
1097
|
private readonly _future;
|
|
1100
1098
|
private _navigationStart;
|
|
@@ -1104,6 +1102,11 @@ export declare class RealtimeView {
|
|
|
1104
1102
|
continuous?: boolean;
|
|
1105
1103
|
limits?: ViewportLimits;
|
|
1106
1104
|
navigationHistory?: number;
|
|
1105
|
+
/**
|
|
1106
|
+
* Ask for older bars while this many bars are still left of the viewport, so the next page arrives before the
|
|
1107
|
+
* person reaches the oldest loaded bar. `0` asks only at the very edge. Default: one and a half screens plus 50.
|
|
1108
|
+
*/
|
|
1109
|
+
prefetchBars?: number;
|
|
1107
1110
|
});
|
|
1108
1111
|
/** Stable function and object identity until the visible state changes. */
|
|
1109
1112
|
readonly getSnapshot: () => RealtimeViewSnapshot;
|
|
@@ -1132,6 +1135,8 @@ export declare class RealtimeView {
|
|
|
1132
1135
|
/** Jump to the nearest loaded candle. Does not fetch history outside the loaded range. */
|
|
1133
1136
|
seek(timestamp: number, anchor?: number): boolean;
|
|
1134
1137
|
requestMore(): void;
|
|
1138
|
+
/** Ask for the next older page when the viewport is within the prefetch distance of the oldest loaded bar. */
|
|
1139
|
+
prefetchHistory(): void;
|
|
1135
1140
|
dispose(): void;
|
|
1136
1141
|
private _navigationState;
|
|
1137
1142
|
private _recordNavigation;
|
|
@@ -1432,6 +1437,23 @@ export interface DrawingAnchor {
|
|
|
1432
1437
|
readonly timestamp: number;
|
|
1433
1438
|
readonly price: number;
|
|
1434
1439
|
}
|
|
1440
|
+
/**
|
|
1441
|
+
* How one drawing looks. Every field is optional: what is missing comes from the chart's theme (ink colour, default
|
|
1442
|
+
* width, a translucent fill of the line colour), so a drawing without a style follows the theme and one with a style
|
|
1443
|
+
* keeps it across themes. Colours are `#rrggbb` or `#rrggbbaa` only.
|
|
1444
|
+
*/
|
|
1445
|
+
export interface DrawingStyle {
|
|
1446
|
+
readonly color?: string;
|
|
1447
|
+
/** Line width in CSS pixels, 1 to 8. Freehand strokes use `strokeWidth` instead. */
|
|
1448
|
+
readonly width?: number;
|
|
1449
|
+
readonly dash?: "solid" | "dashed" | "dotted";
|
|
1450
|
+
/** Fill of closed shapes. */
|
|
1451
|
+
readonly fillColor?: string;
|
|
1452
|
+
/** 0 (no fill) to 1. */
|
|
1453
|
+
readonly fillOpacity?: number;
|
|
1454
|
+
/** Colour of the text and labels of the drawing. */
|
|
1455
|
+
readonly textColor?: string;
|
|
1456
|
+
}
|
|
1435
1457
|
export interface Drawing {
|
|
1436
1458
|
readonly id: string;
|
|
1437
1459
|
readonly type: DrawingType;
|
|
@@ -1442,6 +1464,7 @@ export interface Drawing {
|
|
|
1442
1464
|
readonly text?: string;
|
|
1443
1465
|
readonly image?: string;
|
|
1444
1466
|
readonly strokeWidth?: number;
|
|
1467
|
+
readonly style?: DrawingStyle;
|
|
1445
1468
|
}
|
|
1446
1469
|
export interface DrawingInput {
|
|
1447
1470
|
id: string;
|
|
@@ -1452,7 +1475,9 @@ export interface DrawingInput {
|
|
|
1452
1475
|
text?: string;
|
|
1453
1476
|
image?: string;
|
|
1454
1477
|
strokeWidth?: number;
|
|
1478
|
+
style?: DrawingStyle;
|
|
1455
1479
|
}
|
|
1480
|
+
/** `style: null` clears the style; any other value replaces it whole (spread the old one to change one field). */
|
|
1456
1481
|
export interface DrawingPatch {
|
|
1457
1482
|
anchors?: readonly DrawingAnchor[];
|
|
1458
1483
|
locked?: boolean;
|
|
@@ -1460,6 +1485,7 @@ export interface DrawingPatch {
|
|
|
1460
1485
|
text?: string;
|
|
1461
1486
|
image?: string;
|
|
1462
1487
|
strokeWidth?: number;
|
|
1488
|
+
style?: DrawingStyle | null;
|
|
1463
1489
|
}
|
|
1464
1490
|
export interface DrawingPoint {
|
|
1465
1491
|
readonly x: number;
|
|
@@ -1542,6 +1568,7 @@ export interface DrawingGeometry {
|
|
|
1542
1568
|
readonly id: string;
|
|
1543
1569
|
readonly type: DrawingType;
|
|
1544
1570
|
readonly locked: boolean;
|
|
1571
|
+
readonly style?: DrawingStyle;
|
|
1545
1572
|
readonly primitives: readonly DrawingPrimitive[];
|
|
1546
1573
|
readonly handles: readonly DrawingHandle[];
|
|
1547
1574
|
readonly analysis?: DataDrivenDrawingResult;
|
|
@@ -1561,6 +1588,13 @@ export declare function drawingUsesText(type: DrawingType): boolean;
|
|
|
1561
1588
|
export declare function drawingAnchorCount(type: DrawingType): number;
|
|
1562
1589
|
/** Projection never edits retained anchors or history. Hosts may call it after any data/layout change. */
|
|
1563
1590
|
export declare function projectDrawing(value: Drawing, project: DrawingProjector, bounds: DrawingBounds, context?: DrawingContext): DrawingGeometry | null;
|
|
1591
|
+
/**
|
|
1592
|
+
* The anchors after the handle `handleIndex` (the `anchorIndex` of a `DrawingHandle`) is dragged to `next`. For most
|
|
1593
|
+
* drawings a handle is an anchor and it moves there. A box has eight: 0 and 1 are the two anchors, 2 and 3 the other
|
|
1594
|
+
* corners, 4 to 7 the middles of the edges (anchor 0's price, anchor 1's price, anchor 0's time, anchor 1's time), and an
|
|
1595
|
+
* edge handle moves only along its own axis.
|
|
1596
|
+
*/
|
|
1597
|
+
export declare function moveDrawingHandle(value: Drawing, handleIndex: number, next: DrawingAnchor): readonly DrawingAnchor[];
|
|
1564
1598
|
/** Only selected handles are interactive. Text labels have no arbitrary font-size hit boxes. */
|
|
1565
1599
|
export declare function hitTestDrawingGeometry(geometries: readonly DrawingGeometry[], selectedId: string | null, point: DrawingPoint, tolerance?: number): DrawingHit | null;
|
|
1566
1600
|
/** Immutable drawing snapshots share unchanged entries; bounded undo contains user edits only. */
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
isHeikinAshiUp,
|
|
61
61
|
mergeBar,
|
|
62
62
|
mergeKind,
|
|
63
|
+
moveDrawingHandle,
|
|
63
64
|
nearestBarIndex,
|
|
64
65
|
nearestChartIndex,
|
|
65
66
|
nextBarClose,
|
|
@@ -108,7 +109,7 @@ import {
|
|
|
108
109
|
workspaceMarketKey,
|
|
109
110
|
zoomContinuousViewport,
|
|
110
111
|
zoomViewport
|
|
111
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-U2Z26OW4.js";
|
|
112
113
|
import {
|
|
113
114
|
previousRangeHighLow
|
|
114
115
|
} from "./chunk-B2X7UKEZ.js";
|
|
@@ -173,6 +174,7 @@ export {
|
|
|
173
174
|
isHeikinAshiUp,
|
|
174
175
|
mergeBar,
|
|
175
176
|
mergeKind,
|
|
177
|
+
moveDrawingHandle,
|
|
176
178
|
indicatorSeries as nativeIndicatorSeries,
|
|
177
179
|
nearestBarIndex,
|
|
178
180
|
nearestChartIndex,
|
package/dist/native.d.ts
CHANGED
|
@@ -1006,11 +1006,6 @@ export interface RealtimeSeriesChange {
|
|
|
1006
1006
|
length: number;
|
|
1007
1007
|
version: number;
|
|
1008
1008
|
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Renderer-free sink for DataLoader. MA20 and EMA21 use the native first-close
|
|
1011
|
-
* EMA seed (not the Web SMA seed). Inputs must be normalized, ascending bars.
|
|
1012
|
-
* History changes rebuild; live updates only calculate the changed tail.
|
|
1013
|
-
*/
|
|
1014
1009
|
export declare class RealtimeSeries implements ChartDataPort {
|
|
1015
1010
|
private _bars;
|
|
1016
1011
|
private _ha;
|
|
@@ -1023,6 +1018,8 @@ export declare class RealtimeSeries implements ChartDataPort {
|
|
|
1023
1018
|
private _version;
|
|
1024
1019
|
private _more;
|
|
1025
1020
|
private _loadMore;
|
|
1021
|
+
/** A request for older bars is out. Several callers (edge, prefetch, button) must not start the same page twice. */
|
|
1022
|
+
private _olderSince;
|
|
1026
1023
|
private readonly _listeners;
|
|
1027
1024
|
private readonly _referenceIndicators;
|
|
1028
1025
|
/** Hosts with their own indicator registry can omit the native reference MA/EMA. */
|
|
@@ -1095,6 +1092,7 @@ export declare class RealtimeView {
|
|
|
1095
1092
|
private _limits;
|
|
1096
1093
|
private readonly _openingCount;
|
|
1097
1094
|
private readonly _historyLimit;
|
|
1095
|
+
private readonly _prefetchBars;
|
|
1098
1096
|
private readonly _past;
|
|
1099
1097
|
private readonly _future;
|
|
1100
1098
|
private _navigationStart;
|
|
@@ -1104,6 +1102,11 @@ export declare class RealtimeView {
|
|
|
1104
1102
|
continuous?: boolean;
|
|
1105
1103
|
limits?: ViewportLimits;
|
|
1106
1104
|
navigationHistory?: number;
|
|
1105
|
+
/**
|
|
1106
|
+
* Ask for older bars while this many bars are still left of the viewport, so the next page arrives before the
|
|
1107
|
+
* person reaches the oldest loaded bar. `0` asks only at the very edge. Default: one and a half screens plus 50.
|
|
1108
|
+
*/
|
|
1109
|
+
prefetchBars?: number;
|
|
1107
1110
|
});
|
|
1108
1111
|
/** Stable function and object identity until the visible state changes. */
|
|
1109
1112
|
readonly getSnapshot: () => RealtimeViewSnapshot;
|
|
@@ -1132,6 +1135,8 @@ export declare class RealtimeView {
|
|
|
1132
1135
|
/** Jump to the nearest loaded candle. Does not fetch history outside the loaded range. */
|
|
1133
1136
|
seek(timestamp: number, anchor?: number): boolean;
|
|
1134
1137
|
requestMore(): void;
|
|
1138
|
+
/** Ask for the next older page when the viewport is within the prefetch distance of the oldest loaded bar. */
|
|
1139
|
+
prefetchHistory(): void;
|
|
1135
1140
|
dispose(): void;
|
|
1136
1141
|
private _navigationState;
|
|
1137
1142
|
private _recordNavigation;
|
|
@@ -1432,6 +1437,23 @@ export interface DrawingAnchor {
|
|
|
1432
1437
|
readonly timestamp: number;
|
|
1433
1438
|
readonly price: number;
|
|
1434
1439
|
}
|
|
1440
|
+
/**
|
|
1441
|
+
* How one drawing looks. Every field is optional: what is missing comes from the chart's theme (ink colour, default
|
|
1442
|
+
* width, a translucent fill of the line colour), so a drawing without a style follows the theme and one with a style
|
|
1443
|
+
* keeps it across themes. Colours are `#rrggbb` or `#rrggbbaa` only.
|
|
1444
|
+
*/
|
|
1445
|
+
export interface DrawingStyle {
|
|
1446
|
+
readonly color?: string;
|
|
1447
|
+
/** Line width in CSS pixels, 1 to 8. Freehand strokes use `strokeWidth` instead. */
|
|
1448
|
+
readonly width?: number;
|
|
1449
|
+
readonly dash?: "solid" | "dashed" | "dotted";
|
|
1450
|
+
/** Fill of closed shapes. */
|
|
1451
|
+
readonly fillColor?: string;
|
|
1452
|
+
/** 0 (no fill) to 1. */
|
|
1453
|
+
readonly fillOpacity?: number;
|
|
1454
|
+
/** Colour of the text and labels of the drawing. */
|
|
1455
|
+
readonly textColor?: string;
|
|
1456
|
+
}
|
|
1435
1457
|
export interface Drawing {
|
|
1436
1458
|
readonly id: string;
|
|
1437
1459
|
readonly type: DrawingType;
|
|
@@ -1442,6 +1464,7 @@ export interface Drawing {
|
|
|
1442
1464
|
readonly text?: string;
|
|
1443
1465
|
readonly image?: string;
|
|
1444
1466
|
readonly strokeWidth?: number;
|
|
1467
|
+
readonly style?: DrawingStyle;
|
|
1445
1468
|
}
|
|
1446
1469
|
export interface DrawingInput {
|
|
1447
1470
|
id: string;
|
|
@@ -1452,7 +1475,9 @@ export interface DrawingInput {
|
|
|
1452
1475
|
text?: string;
|
|
1453
1476
|
image?: string;
|
|
1454
1477
|
strokeWidth?: number;
|
|
1478
|
+
style?: DrawingStyle;
|
|
1455
1479
|
}
|
|
1480
|
+
/** `style: null` clears the style; any other value replaces it whole (spread the old one to change one field). */
|
|
1456
1481
|
export interface DrawingPatch {
|
|
1457
1482
|
anchors?: readonly DrawingAnchor[];
|
|
1458
1483
|
locked?: boolean;
|
|
@@ -1460,6 +1485,7 @@ export interface DrawingPatch {
|
|
|
1460
1485
|
text?: string;
|
|
1461
1486
|
image?: string;
|
|
1462
1487
|
strokeWidth?: number;
|
|
1488
|
+
style?: DrawingStyle | null;
|
|
1463
1489
|
}
|
|
1464
1490
|
export interface DrawingPoint {
|
|
1465
1491
|
readonly x: number;
|
|
@@ -1542,6 +1568,7 @@ export interface DrawingGeometry {
|
|
|
1542
1568
|
readonly id: string;
|
|
1543
1569
|
readonly type: DrawingType;
|
|
1544
1570
|
readonly locked: boolean;
|
|
1571
|
+
readonly style?: DrawingStyle;
|
|
1545
1572
|
readonly primitives: readonly DrawingPrimitive[];
|
|
1546
1573
|
readonly handles: readonly DrawingHandle[];
|
|
1547
1574
|
readonly analysis?: DataDrivenDrawingResult;
|
|
@@ -1561,6 +1588,13 @@ export declare function drawingUsesText(type: DrawingType): boolean;
|
|
|
1561
1588
|
export declare function drawingAnchorCount(type: DrawingType): number;
|
|
1562
1589
|
/** Projection never edits retained anchors or history. Hosts may call it after any data/layout change. */
|
|
1563
1590
|
export declare function projectDrawing(value: Drawing, project: DrawingProjector, bounds: DrawingBounds, context?: DrawingContext): DrawingGeometry | null;
|
|
1591
|
+
/**
|
|
1592
|
+
* The anchors after the handle `handleIndex` (the `anchorIndex` of a `DrawingHandle`) is dragged to `next`. For most
|
|
1593
|
+
* drawings a handle is an anchor and it moves there. A box has eight: 0 and 1 are the two anchors, 2 and 3 the other
|
|
1594
|
+
* corners, 4 to 7 the middles of the edges (anchor 0's price, anchor 1's price, anchor 0's time, anchor 1's time), and an
|
|
1595
|
+
* edge handle moves only along its own axis.
|
|
1596
|
+
*/
|
|
1597
|
+
export declare function moveDrawingHandle(value: Drawing, handleIndex: number, next: DrawingAnchor): readonly DrawingAnchor[];
|
|
1564
1598
|
/** Only selected handles are interactive. Text labels have no arbitrary font-size hit boxes. */
|
|
1565
1599
|
export declare function hitTestDrawingGeometry(geometries: readonly DrawingGeometry[], selectedId: string | null, point: DrawingPoint, tolerance?: number): DrawingHit | null;
|
|
1566
1600
|
/** Immutable drawing snapshots share unchanged entries; bounded undo contains user edits only. */
|
package/dist/native.js
CHANGED
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
isHeikinAshiUp,
|
|
61
61
|
mergeBar,
|
|
62
62
|
mergeKind,
|
|
63
|
+
moveDrawingHandle,
|
|
63
64
|
nearestBarIndex,
|
|
64
65
|
nearestChartIndex,
|
|
65
66
|
nextBarClose,
|
|
@@ -108,7 +109,7 @@ import {
|
|
|
108
109
|
workspaceMarketKey,
|
|
109
110
|
zoomContinuousViewport,
|
|
110
111
|
zoomViewport
|
|
111
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-U2Z26OW4.js";
|
|
112
113
|
import {
|
|
113
114
|
previousRangeHighLow
|
|
114
115
|
} from "./chunk-B2X7UKEZ.js";
|
|
@@ -259,6 +260,7 @@ export {
|
|
|
259
260
|
isHeikinAshiUp,
|
|
260
261
|
mergeBar,
|
|
261
262
|
mergeKind,
|
|
263
|
+
moveDrawingHandle,
|
|
262
264
|
indicatorSeries as nativeIndicatorSeries,
|
|
263
265
|
nearestBarIndex,
|
|
264
266
|
nearestChartIndex,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supersolutions/super-chart-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Renderer-free chart core: market data, loader, indicators, drawings, frame and workspace models. No DOM.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|