@supersolutions/super-chart-core 0.1.0 → 0.3.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-5EZU3YKZ.js → chunk-KRGZKWFA.js} +218 -2
- package/dist/index.d.ts +46 -0
- package/dist/index.js +5 -1
- package/dist/native.d.ts +46 -0
- package/dist/native.js +5 -1
- package/package.json +1 -1
|
@@ -4649,7 +4649,8 @@ function projectDrawing(value, project, bounds, context) {
|
|
|
4649
4649
|
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
4650
|
primitives.push({ kind: "image", source: value.image, bounds: box, clip: { ...bounds } });
|
|
4651
4651
|
}
|
|
4652
|
-
const
|
|
4652
|
+
const freehand = value.type === "brush" || value.type === "highlighter";
|
|
4653
|
+
const handles = value.locked || freehand ? [] : points.flatMap((point, anchorIndex) => inside(point, bounds) ? [{ point, anchorIndex }] : []);
|
|
4653
4654
|
return { id: value.id, type: value.type, locked: value.locked, primitives, handles, ...analysis === void 0 ? {} : { analysis } };
|
|
4654
4655
|
}
|
|
4655
4656
|
function lineDistance(point, from, to) {
|
|
@@ -5371,7 +5372,7 @@ var WORKSPACE_DOCUMENT_LIMITS = Object.freeze({
|
|
|
5371
5372
|
});
|
|
5372
5373
|
var BUILTINS2 = /* @__PURE__ */ new Set(["MA", "EMA", "BOLL", "VOL", "MACD", "RSI", "KDJ"]);
|
|
5373
5374
|
var SYMBOL_KEYS = ["ticker", "name", "shortName", "exchange", "market", "pricePrecision", "volumePrecision", "priceCurrency", "type", "logo", "timezone"];
|
|
5374
|
-
var RENDER_KEYS = ["chartType", "candleDensity", "baseline", "background", "grid", "text", "up", "down", "line", "font", "pricePrecision", "timeZone"];
|
|
5375
|
+
var RENDER_KEYS = ["chartType", "candleDensity", "baseline", "background", "grid", "text", "up", "down", "line", "font", "pricePrecision", "timeZone", "theme"];
|
|
5375
5376
|
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
5376
5377
|
function object(value, allowed, required, label) {
|
|
5377
5378
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
@@ -5492,6 +5493,8 @@ function renderOf(value) {
|
|
|
5492
5493
|
integer(input.pricePrecision, "render price precision", 0, 20);
|
|
5493
5494
|
if (input.timeZone !== void 0)
|
|
5494
5495
|
timezone(input.timeZone, "display timezone");
|
|
5496
|
+
if (input.theme !== void 0 && input.theme !== "dark" && input.theme !== "light")
|
|
5497
|
+
throw new RangeError("Unknown render theme");
|
|
5495
5498
|
for (const key of ["background", "grid", "text", "up", "down", "line", "font"]) {
|
|
5496
5499
|
if (input[key] !== void 0)
|
|
5497
5500
|
text(input[key], `render ${key}`, 256);
|
|
@@ -5852,6 +5855,217 @@ function projectMarketOverlays(frame, rawBars, options = {}) {
|
|
|
5852
5855
|
return finish();
|
|
5853
5856
|
}
|
|
5854
5857
|
|
|
5858
|
+
// packages/core/src/model/shapeRecognition.ts
|
|
5859
|
+
var SHAPE_RECOGNITION_LIMITS = Object.freeze({
|
|
5860
|
+
/** Longest stroke considered; longer ones are thinned first. */
|
|
5861
|
+
maxPoints: 2048,
|
|
5862
|
+
/** A stroke shorter than this many pixels (path length) is a tap, not a shape. */
|
|
5863
|
+
minLength: 24,
|
|
5864
|
+
/** Candidates below this score are never offered. */
|
|
5865
|
+
minScore: 0.62,
|
|
5866
|
+
/** Direction reversals that make a scribble. */
|
|
5867
|
+
scribbleReversals: 4
|
|
5868
|
+
});
|
|
5869
|
+
var SAMPLES = 64;
|
|
5870
|
+
var dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
5871
|
+
var clamp01 = (value) => value < 0 ? 0 : value > 1 ? 1 : value;
|
|
5872
|
+
function clean(input) {
|
|
5873
|
+
const points = [];
|
|
5874
|
+
const stride = Math.max(1, Math.ceil(input.length / SHAPE_RECOGNITION_LIMITS.maxPoints));
|
|
5875
|
+
for (let i = 0; i < input.length; i += stride) {
|
|
5876
|
+
const point = input[i];
|
|
5877
|
+
if (!Number.isFinite(point.x) || !Number.isFinite(point.y))
|
|
5878
|
+
continue;
|
|
5879
|
+
const last = points[points.length - 1];
|
|
5880
|
+
if (last === void 0 || dist(last, point) >= 0.5)
|
|
5881
|
+
points.push({ x: point.x, y: point.y });
|
|
5882
|
+
}
|
|
5883
|
+
const final = input[input.length - 1];
|
|
5884
|
+
if (final !== void 0 && Number.isFinite(final.x) && Number.isFinite(final.y) && points.length > 0 && dist(points[points.length - 1], final) > 0)
|
|
5885
|
+
points.push({ x: final.x, y: final.y });
|
|
5886
|
+
return points;
|
|
5887
|
+
}
|
|
5888
|
+
function pathLength(points) {
|
|
5889
|
+
let length = 0;
|
|
5890
|
+
for (let i = 1; i < points.length; i++)
|
|
5891
|
+
length += dist(points[i - 1], points[i]);
|
|
5892
|
+
return length;
|
|
5893
|
+
}
|
|
5894
|
+
function resample(points, length) {
|
|
5895
|
+
const step = length / (SAMPLES - 1), out = [points[0]];
|
|
5896
|
+
let carried = 0, previous = points[0];
|
|
5897
|
+
for (let i = 1; i < points.length; i++) {
|
|
5898
|
+
const current = points[i];
|
|
5899
|
+
let gap = dist(previous, current);
|
|
5900
|
+
while (carried + gap >= step && gap > 0) {
|
|
5901
|
+
const t = (step - carried) / gap;
|
|
5902
|
+
const next = { x: previous.x + (current.x - previous.x) * t, y: previous.y + (current.y - previous.y) * t };
|
|
5903
|
+
out.push(next);
|
|
5904
|
+
previous = next;
|
|
5905
|
+
gap = dist(previous, current);
|
|
5906
|
+
carried = 0;
|
|
5907
|
+
if (out.length >= SAMPLES)
|
|
5908
|
+
return out;
|
|
5909
|
+
}
|
|
5910
|
+
carried += gap;
|
|
5911
|
+
previous = current;
|
|
5912
|
+
}
|
|
5913
|
+
while (out.length < SAMPLES)
|
|
5914
|
+
out.push(points[points.length - 1]);
|
|
5915
|
+
return out;
|
|
5916
|
+
}
|
|
5917
|
+
function reversals(points, size) {
|
|
5918
|
+
const threshold = Math.max(3, size * 0.12);
|
|
5919
|
+
let count = 0, axisX = 0, axisY = 0, anchor = points[0], direction = 0;
|
|
5920
|
+
for (const point of points) {
|
|
5921
|
+
const dx = point.x - anchor.x, dy = point.y - anchor.y;
|
|
5922
|
+
if (Math.hypot(dx, dy) < threshold)
|
|
5923
|
+
continue;
|
|
5924
|
+
if (axisX === 0 && axisY === 0) {
|
|
5925
|
+
const length = Math.hypot(dx, dy);
|
|
5926
|
+
axisX = dx / length;
|
|
5927
|
+
axisY = dy / length;
|
|
5928
|
+
}
|
|
5929
|
+
const along2 = dx * axisX + dy * axisY, sign = along2 > 0 ? 1 : -1;
|
|
5930
|
+
if (direction !== 0 && sign !== direction)
|
|
5931
|
+
count++;
|
|
5932
|
+
direction = sign;
|
|
5933
|
+
anchor = point;
|
|
5934
|
+
}
|
|
5935
|
+
return count;
|
|
5936
|
+
}
|
|
5937
|
+
function simplify(points, epsilon) {
|
|
5938
|
+
if (points.length < 3)
|
|
5939
|
+
return [...points];
|
|
5940
|
+
const first = points[0], last = points[points.length - 1];
|
|
5941
|
+
let index = -1, farthest = 0;
|
|
5942
|
+
const dx = last.x - first.x, dy = last.y - first.y, length = Math.hypot(dx, dy);
|
|
5943
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
5944
|
+
const d = length === 0 ? dist(points[i], first) : Math.abs(dy * points[i].x - dx * points[i].y + last.x * first.y - last.y * first.x) / length;
|
|
5945
|
+
if (d > farthest) {
|
|
5946
|
+
farthest = d;
|
|
5947
|
+
index = i;
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
if (index < 0 || farthest <= epsilon)
|
|
5951
|
+
return [first, last];
|
|
5952
|
+
const left = simplify(points.slice(0, index + 1), epsilon), right = simplify(points.slice(index), epsilon);
|
|
5953
|
+
return [...left.slice(0, -1), ...right];
|
|
5954
|
+
}
|
|
5955
|
+
function segmentDistance(p, a, b) {
|
|
5956
|
+
const dx = b.x - a.x, dy = b.y - a.y, length2 = dx * dx + dy * dy;
|
|
5957
|
+
const t = length2 === 0 ? 0 : clamp01(((p.x - a.x) * dx + (p.y - a.y) * dy) / length2);
|
|
5958
|
+
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
|
|
5959
|
+
}
|
|
5960
|
+
function outlineError(samples, outline, scale) {
|
|
5961
|
+
let total = 0;
|
|
5962
|
+
for (const point of samples) {
|
|
5963
|
+
let best = Infinity;
|
|
5964
|
+
for (let i = 0; i < outline.length; i++)
|
|
5965
|
+
best = Math.min(best, segmentDistance(point, outline[i], outline[(i + 1) % outline.length]));
|
|
5966
|
+
total += best;
|
|
5967
|
+
}
|
|
5968
|
+
return total / samples.length / scale;
|
|
5969
|
+
}
|
|
5970
|
+
function coverage(samples, outline, tolerance) {
|
|
5971
|
+
const probes = 48;
|
|
5972
|
+
let perimeter = 0;
|
|
5973
|
+
for (let i = 0; i < outline.length; i++)
|
|
5974
|
+
perimeter += dist(outline[i], outline[(i + 1) % outline.length]);
|
|
5975
|
+
if (perimeter === 0)
|
|
5976
|
+
return 0;
|
|
5977
|
+
let hit = 0;
|
|
5978
|
+
for (let k = 0; k < probes; k++) {
|
|
5979
|
+
let target = perimeter * k / probes, point = outline[0];
|
|
5980
|
+
for (let i = 0; i < outline.length; i++) {
|
|
5981
|
+
const a = outline[i], b = outline[(i + 1) % outline.length], edge = dist(a, b);
|
|
5982
|
+
if (target <= edge || i === outline.length - 1) {
|
|
5983
|
+
const t = edge === 0 ? 0 : target / edge;
|
|
5984
|
+
point = { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };
|
|
5985
|
+
break;
|
|
5986
|
+
}
|
|
5987
|
+
target -= edge;
|
|
5988
|
+
}
|
|
5989
|
+
if (samples.some((sample) => dist(sample, point) <= tolerance))
|
|
5990
|
+
hit++;
|
|
5991
|
+
}
|
|
5992
|
+
return hit / probes;
|
|
5993
|
+
}
|
|
5994
|
+
function recognizeStroke(input) {
|
|
5995
|
+
const points = clean(input);
|
|
5996
|
+
if (points.length < 3)
|
|
5997
|
+
return { kind: "none", reason: "too-short" };
|
|
5998
|
+
const length = pathLength(points);
|
|
5999
|
+
let left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity;
|
|
6000
|
+
for (const point of points) {
|
|
6001
|
+
left = Math.min(left, point.x);
|
|
6002
|
+
right = Math.max(right, point.x);
|
|
6003
|
+
top = Math.min(top, point.y);
|
|
6004
|
+
bottom = Math.max(bottom, point.y);
|
|
6005
|
+
}
|
|
6006
|
+
const width = right - left, height = bottom - top, diagonal = Math.hypot(width, height);
|
|
6007
|
+
if (length < SHAPE_RECOGNITION_LIMITS.minLength || diagonal < 12)
|
|
6008
|
+
return { kind: "none", reason: "too-short" };
|
|
6009
|
+
const samples = resample(points, length);
|
|
6010
|
+
if (length / diagonal > 3.2 && reversals(samples, diagonal) >= SHAPE_RECOGNITION_LIMITS.scribbleReversals) {
|
|
6011
|
+
return { kind: "scribble", bounds: { left, top, right, bottom }, path: Object.freeze(points) };
|
|
6012
|
+
}
|
|
6013
|
+
const start = points[0], end = points[points.length - 1];
|
|
6014
|
+
const chord = dist(start, end);
|
|
6015
|
+
const candidates = [];
|
|
6016
|
+
const add = (type, anchors2, score) => {
|
|
6017
|
+
if (score >= SHAPE_RECOGNITION_LIMITS.minScore)
|
|
6018
|
+
candidates.push({ type, points: Object.freeze(anchors2.map((point) => Object.freeze({ x: point.x, y: point.y }))), score });
|
|
6019
|
+
};
|
|
6020
|
+
if (chord <= Math.max(10, diagonal * 0.3) && length > diagonal * 1.8) {
|
|
6021
|
+
const scale = Math.max(1, Math.min(width, height));
|
|
6022
|
+
const ratio = Math.max(width, height) / scale;
|
|
6023
|
+
const box = [{ x: left, y: top }, { x: right, y: top }, { x: right, y: bottom }, { x: left, y: bottom }];
|
|
6024
|
+
if (scale >= 8) {
|
|
6025
|
+
const rectError = outlineError(samples, box, scale), rectCover = coverage(samples, box, Math.max(6, scale * 0.18));
|
|
6026
|
+
const cornersVisited = box.every((corner) => samples.some((sample) => dist(sample, corner) <= scale * 0.18));
|
|
6027
|
+
add("rectangle", [{ x: left, y: top }, { x: right, y: bottom }], clamp01(1 - rectError * 3) * clamp01(rectCover * 1.15) * (cornersVisited ? 1 : 0.5));
|
|
6028
|
+
const cx = (left + right) / 2, cy = (top + bottom) / 2, rx = width / 2, ry = height / 2;
|
|
6029
|
+
let ellipseTotal = 0;
|
|
6030
|
+
for (const sample of samples)
|
|
6031
|
+
ellipseTotal += Math.abs(Math.hypot((sample.x - cx) / rx, (sample.y - cy) / ry) - 1);
|
|
6032
|
+
const round = clamp01(1 - ellipseTotal / samples.length * 2.2);
|
|
6033
|
+
const nearlyRound = ratio < 1.12;
|
|
6034
|
+
add("ellipse", [{ x: left, y: top }, { x: right, y: bottom }], nearlyRound ? round * 0.98 : round);
|
|
6035
|
+
if (ratio < 1.25)
|
|
6036
|
+
add("circle", [{ x: cx, y: cy }, { x: cx + (width + height) / 4, y: cy }], nearlyRound ? round : round * 0.96);
|
|
6037
|
+
}
|
|
6038
|
+
const closed = [...samples.slice(0, -1)];
|
|
6039
|
+
const corners = simplify([...closed, closed[0]], diagonal * 0.12).slice(0, -1);
|
|
6040
|
+
if (corners.length === 3) {
|
|
6041
|
+
const area = Math.abs((corners[1].x - corners[0].x) * (corners[2].y - corners[0].y) - (corners[2].x - corners[0].x) * (corners[1].y - corners[0].y)) / 2;
|
|
6042
|
+
if (area > diagonal * diagonal * 0.04) {
|
|
6043
|
+
const error = outlineError(samples, corners, Math.max(1, diagonal / 2)), cover = coverage(samples, corners, Math.max(6, diagonal * 0.07));
|
|
6044
|
+
add("triangle", corners, clamp01(1 - error * 3.2) * clamp01(cover * 1.1));
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
} else if (chord > Math.max(16, length * 0.5)) {
|
|
6048
|
+
let deviation = 0;
|
|
6049
|
+
for (const sample of samples)
|
|
6050
|
+
deviation = Math.max(deviation, segmentDistance(sample, start, end));
|
|
6051
|
+
const straight = clamp01(1 - deviation / chord * 4.5);
|
|
6052
|
+
const angle = Math.atan2(end.y - start.y, end.x - start.x) * 180 / Math.PI;
|
|
6053
|
+
const flat = Math.min(Math.abs(angle), 180 - Math.abs(angle)), upright = Math.abs(90 - Math.abs(angle));
|
|
6054
|
+
const ordered = flat <= 4 ? "horizontal-segment" : upright <= 4 ? "vertical-segment" : null;
|
|
6055
|
+
const snapped = ordered === "horizontal-segment" ? { x: end.x, y: start.y } : ordered === "vertical-segment" ? { x: start.x, y: end.y } : end;
|
|
6056
|
+
if (ordered !== null)
|
|
6057
|
+
add(ordered, [start, snapped], straight);
|
|
6058
|
+
add("trend-line", [start, end], straight * (ordered !== null ? 0.97 : 1));
|
|
6059
|
+
add("segment", [start, end], straight * 0.95);
|
|
6060
|
+
add("ray", [start, end], straight * 0.93);
|
|
6061
|
+
add("arrow", [start, end], straight * 0.91);
|
|
6062
|
+
}
|
|
6063
|
+
if (candidates.length === 0)
|
|
6064
|
+
return { kind: "none", reason: "unrecognized" };
|
|
6065
|
+
candidates.sort((a, b) => b.score - a.score);
|
|
6066
|
+
return { kind: "shape", candidates: Object.freeze(candidates) };
|
|
6067
|
+
}
|
|
6068
|
+
|
|
5855
6069
|
// packages/core/src/formatBarDate.ts
|
|
5856
6070
|
var DTF_OPTIONS = {
|
|
5857
6071
|
hour12: false,
|
|
@@ -6107,6 +6321,8 @@ export {
|
|
|
6107
6321
|
detectOrderBlocks,
|
|
6108
6322
|
MARKET_ZONE_SCAN_LIMIT,
|
|
6109
6323
|
projectMarketOverlays,
|
|
6324
|
+
SHAPE_RECOGNITION_LIMITS,
|
|
6325
|
+
recognizeStroke,
|
|
6110
6326
|
formatBarDate,
|
|
6111
6327
|
ta
|
|
6112
6328
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1681,6 +1681,8 @@ export interface EngineRenderOptions {
|
|
|
1681
1681
|
candleDensity?: "raw" | "pixel-envelope";
|
|
1682
1682
|
/** Baseline chart reference price; defaults to the first visible close. */
|
|
1683
1683
|
baseline?: number;
|
|
1684
|
+
/** Selects the Super Chart light or dark palette; the single colours below override it. Default dark. */
|
|
1685
|
+
theme?: "light" | "dark";
|
|
1684
1686
|
background?: string;
|
|
1685
1687
|
grid?: string;
|
|
1686
1688
|
text?: string;
|
|
@@ -2098,6 +2100,50 @@ export declare function projectFreehandDrawing(drawing: {
|
|
|
2098
2100
|
readonly hidden: boolean;
|
|
2099
2101
|
readonly strokeWidth?: number;
|
|
2100
2102
|
}, project: DrawingProjector, bounds: DrawingBounds): FreehandPrimitive | null;
|
|
2103
|
+
/**
|
|
2104
|
+
* Turns one hand-drawn stroke (pixel points) into the geometric drawing it was meant to be.
|
|
2105
|
+
*
|
|
2106
|
+
* Pure and deterministic: no DOM, no clock, no random numbers. It only ever proposes drawing types the
|
|
2107
|
+
* store already owns, with their pixel anchors in the order the type expects, so the caller unprojects them
|
|
2108
|
+
* and stores an ordinary drawing. It recognizes straight lines (trend, horizontal, vertical), rectangles,
|
|
2109
|
+
* ellipses, circles and triangles, and tells a scribble apart so the host can offer to erase. Everything
|
|
2110
|
+
* else is reported as unrecognized rather than guessed.
|
|
2111
|
+
*/
|
|
2112
|
+
export type RecognizedShape = "trend-line" | "horizontal-segment" | "vertical-segment" | "segment" | "ray" | "arrow" | "rectangle" | "ellipse" | "circle" | "triangle";
|
|
2113
|
+
export interface ShapeCandidate {
|
|
2114
|
+
readonly type: Extract<DrawingType, RecognizedShape>;
|
|
2115
|
+
/** Anchors in pixel space, in the order the drawing type expects. */
|
|
2116
|
+
readonly points: readonly DrawingPoint[];
|
|
2117
|
+
/** 0 to 1; how well the stroke fits, comparable across the candidates of one stroke. */
|
|
2118
|
+
readonly score: number;
|
|
2119
|
+
}
|
|
2120
|
+
export type StrokeResult = {
|
|
2121
|
+
readonly kind: "shape";
|
|
2122
|
+
readonly candidates: readonly ShapeCandidate[];
|
|
2123
|
+
} | {
|
|
2124
|
+
readonly kind: "scribble";
|
|
2125
|
+
readonly bounds: {
|
|
2126
|
+
readonly left: number;
|
|
2127
|
+
readonly top: number;
|
|
2128
|
+
readonly right: number;
|
|
2129
|
+
readonly bottom: number;
|
|
2130
|
+
};
|
|
2131
|
+
readonly path: readonly DrawingPoint[];
|
|
2132
|
+
} | {
|
|
2133
|
+
readonly kind: "none";
|
|
2134
|
+
readonly reason: "too-short" | "unrecognized";
|
|
2135
|
+
};
|
|
2136
|
+
export declare const SHAPE_RECOGNITION_LIMITS: Readonly<{
|
|
2137
|
+
/** Longest stroke considered; longer ones are thinned first. */
|
|
2138
|
+
maxPoints: 2048;
|
|
2139
|
+
/** A stroke shorter than this many pixels (path length) is a tap, not a shape. */
|
|
2140
|
+
minLength: 24;
|
|
2141
|
+
/** Candidates below this score are never offered. */
|
|
2142
|
+
minScore: 0.62;
|
|
2143
|
+
/** Direction reversals that make a scribble. */
|
|
2144
|
+
scribbleReversals: 4;
|
|
2145
|
+
}>;
|
|
2146
|
+
export declare function recognizeStroke(input: readonly DrawingPoint[]): StrokeResult;
|
|
2101
2147
|
/** The context requesting a financial date label. */
|
|
2102
2148
|
export type BarDateRequestType = "xAxis" | "crosshair" | "tooltip";
|
|
2103
2149
|
export interface FormatBarDateParams {
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
REPLAY_BASE_STEP_MS,
|
|
17
17
|
RealtimeSeries,
|
|
18
18
|
RealtimeView,
|
|
19
|
+
SHAPE_RECOGNITION_LIMITS,
|
|
19
20
|
TickCoalescer,
|
|
20
21
|
UNIT_MS,
|
|
21
22
|
WORKSPACE_DOCUMENT_LIMITS,
|
|
@@ -80,6 +81,7 @@ import {
|
|
|
80
81
|
pxToBars,
|
|
81
82
|
railSegment,
|
|
82
83
|
raster,
|
|
84
|
+
recognizeStroke,
|
|
83
85
|
replayApply,
|
|
84
86
|
replayAtEnd,
|
|
85
87
|
replayBars,
|
|
@@ -106,7 +108,7 @@ import {
|
|
|
106
108
|
workspaceMarketKey,
|
|
107
109
|
zoomContinuousViewport,
|
|
108
110
|
zoomViewport
|
|
109
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-KRGZKWFA.js";
|
|
110
112
|
import {
|
|
111
113
|
previousRangeHighLow
|
|
112
114
|
} from "./chunk-B2X7UKEZ.js";
|
|
@@ -128,6 +130,7 @@ export {
|
|
|
128
130
|
REPLAY_BASE_STEP_MS,
|
|
129
131
|
RealtimeSeries,
|
|
130
132
|
RealtimeView,
|
|
133
|
+
SHAPE_RECOGNITION_LIMITS,
|
|
131
134
|
TickCoalescer,
|
|
132
135
|
UNIT_MS,
|
|
133
136
|
WORKSPACE_DOCUMENT_LIMITS,
|
|
@@ -193,6 +196,7 @@ export {
|
|
|
193
196
|
pxToBars,
|
|
194
197
|
railSegment,
|
|
195
198
|
raster,
|
|
199
|
+
recognizeStroke,
|
|
196
200
|
replayApply,
|
|
197
201
|
replayAtEnd,
|
|
198
202
|
replayBars,
|
package/dist/native.d.ts
CHANGED
|
@@ -1681,6 +1681,8 @@ export interface EngineRenderOptions {
|
|
|
1681
1681
|
candleDensity?: "raw" | "pixel-envelope";
|
|
1682
1682
|
/** Baseline chart reference price; defaults to the first visible close. */
|
|
1683
1683
|
baseline?: number;
|
|
1684
|
+
/** Selects the Super Chart light or dark palette; the single colours below override it. Default dark. */
|
|
1685
|
+
theme?: "light" | "dark";
|
|
1684
1686
|
background?: string;
|
|
1685
1687
|
grid?: string;
|
|
1686
1688
|
text?: string;
|
|
@@ -2098,6 +2100,50 @@ export declare function projectFreehandDrawing(drawing: {
|
|
|
2098
2100
|
readonly hidden: boolean;
|
|
2099
2101
|
readonly strokeWidth?: number;
|
|
2100
2102
|
}, project: DrawingProjector, bounds: DrawingBounds): FreehandPrimitive | null;
|
|
2103
|
+
/**
|
|
2104
|
+
* Turns one hand-drawn stroke (pixel points) into the geometric drawing it was meant to be.
|
|
2105
|
+
*
|
|
2106
|
+
* Pure and deterministic: no DOM, no clock, no random numbers. It only ever proposes drawing types the
|
|
2107
|
+
* store already owns, with their pixel anchors in the order the type expects, so the caller unprojects them
|
|
2108
|
+
* and stores an ordinary drawing. It recognizes straight lines (trend, horizontal, vertical), rectangles,
|
|
2109
|
+
* ellipses, circles and triangles, and tells a scribble apart so the host can offer to erase. Everything
|
|
2110
|
+
* else is reported as unrecognized rather than guessed.
|
|
2111
|
+
*/
|
|
2112
|
+
export type RecognizedShape = "trend-line" | "horizontal-segment" | "vertical-segment" | "segment" | "ray" | "arrow" | "rectangle" | "ellipse" | "circle" | "triangle";
|
|
2113
|
+
export interface ShapeCandidate {
|
|
2114
|
+
readonly type: Extract<DrawingType, RecognizedShape>;
|
|
2115
|
+
/** Anchors in pixel space, in the order the drawing type expects. */
|
|
2116
|
+
readonly points: readonly DrawingPoint[];
|
|
2117
|
+
/** 0 to 1; how well the stroke fits, comparable across the candidates of one stroke. */
|
|
2118
|
+
readonly score: number;
|
|
2119
|
+
}
|
|
2120
|
+
export type StrokeResult = {
|
|
2121
|
+
readonly kind: "shape";
|
|
2122
|
+
readonly candidates: readonly ShapeCandidate[];
|
|
2123
|
+
} | {
|
|
2124
|
+
readonly kind: "scribble";
|
|
2125
|
+
readonly bounds: {
|
|
2126
|
+
readonly left: number;
|
|
2127
|
+
readonly top: number;
|
|
2128
|
+
readonly right: number;
|
|
2129
|
+
readonly bottom: number;
|
|
2130
|
+
};
|
|
2131
|
+
readonly path: readonly DrawingPoint[];
|
|
2132
|
+
} | {
|
|
2133
|
+
readonly kind: "none";
|
|
2134
|
+
readonly reason: "too-short" | "unrecognized";
|
|
2135
|
+
};
|
|
2136
|
+
export declare const SHAPE_RECOGNITION_LIMITS: Readonly<{
|
|
2137
|
+
/** Longest stroke considered; longer ones are thinned first. */
|
|
2138
|
+
maxPoints: 2048;
|
|
2139
|
+
/** A stroke shorter than this many pixels (path length) is a tap, not a shape. */
|
|
2140
|
+
minLength: 24;
|
|
2141
|
+
/** Candidates below this score are never offered. */
|
|
2142
|
+
minScore: 0.62;
|
|
2143
|
+
/** Direction reversals that make a scribble. */
|
|
2144
|
+
scribbleReversals: 4;
|
|
2145
|
+
}>;
|
|
2146
|
+
export declare function recognizeStroke(input: readonly DrawingPoint[]): StrokeResult;
|
|
2101
2147
|
/** The context requesting a financial date label. */
|
|
2102
2148
|
export type BarDateRequestType = "xAxis" | "crosshair" | "tooltip";
|
|
2103
2149
|
export interface FormatBarDateParams {
|
package/dist/native.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
REPLAY_BASE_STEP_MS,
|
|
17
17
|
RealtimeSeries,
|
|
18
18
|
RealtimeView,
|
|
19
|
+
SHAPE_RECOGNITION_LIMITS,
|
|
19
20
|
TickCoalescer,
|
|
20
21
|
UNIT_MS,
|
|
21
22
|
WORKSPACE_DOCUMENT_LIMITS,
|
|
@@ -80,6 +81,7 @@ import {
|
|
|
80
81
|
pxToBars,
|
|
81
82
|
railSegment,
|
|
82
83
|
raster,
|
|
84
|
+
recognizeStroke,
|
|
83
85
|
replayApply,
|
|
84
86
|
replayAtEnd,
|
|
85
87
|
replayBars,
|
|
@@ -106,7 +108,7 @@ import {
|
|
|
106
108
|
workspaceMarketKey,
|
|
107
109
|
zoomContinuousViewport,
|
|
108
110
|
zoomViewport
|
|
109
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-KRGZKWFA.js";
|
|
110
112
|
import {
|
|
111
113
|
previousRangeHighLow
|
|
112
114
|
} from "./chunk-B2X7UKEZ.js";
|
|
@@ -212,6 +214,7 @@ export {
|
|
|
212
214
|
REPLAY_BASE_STEP_MS,
|
|
213
215
|
RealtimeSeries,
|
|
214
216
|
RealtimeView,
|
|
217
|
+
SHAPE_RECOGNITION_LIMITS,
|
|
215
218
|
TickCoalescer,
|
|
216
219
|
UNIT_MS,
|
|
217
220
|
WORKSPACE_DOCUMENT_LIMITS,
|
|
@@ -279,6 +282,7 @@ export {
|
|
|
279
282
|
pxToBars,
|
|
280
283
|
railSegment,
|
|
281
284
|
raster,
|
|
285
|
+
recognizeStroke,
|
|
282
286
|
replayApply,
|
|
283
287
|
replayAtEnd,
|
|
284
288
|
replayBars,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supersolutions/super-chart-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|