oakscriptjs 0.9.6 → 0.10.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/README.md +1 -1
- package/dist/cjs/array/index.d.ts +9 -23
- package/dist/cjs/array/index.d.ts.map +1 -1
- package/dist/cjs/array/index.js +4 -0
- package/dist/cjs/array/index.js.map +2 -2
- package/dist/cjs/drawing/bar-time.d.ts +24 -0
- package/dist/cjs/drawing/bar-time.d.ts.map +1 -0
- package/dist/cjs/drawing/bar-time.js +47 -0
- package/dist/cjs/drawing/bar-time.js.map +7 -0
- package/dist/cjs/drawing/output.d.ts +32 -0
- package/dist/cjs/drawing/output.d.ts.map +1 -0
- package/dist/cjs/drawing/output.js +184 -0
- package/dist/cjs/drawing/output.js.map +7 -0
- package/dist/cjs/drawing/registry.d.ts +5 -4
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +11 -2
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +6 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +3 -5
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js +0 -5
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/types.d.ts +22 -0
- package/dist/cjs/runtime/types.d.ts.map +1 -1
- package/dist/cjs/runtime/types.js.map +1 -1
- package/dist/cjs/script/index.d.ts +82 -5
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +141 -26
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/table/index.d.ts +87 -0
- package/dist/cjs/table/index.d.ts.map +1 -0
- package/dist/cjs/table/index.js +150 -0
- package/dist/cjs/table/index.js.map +7 -0
- package/dist/cjs/text/index.d.ts +17 -2
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js +15 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +30 -1
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -0
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/types/metadata.d.ts +258 -26
- package/dist/cjs/types/metadata.d.ts.map +1 -1
- package/dist/cjs/types/metadata.js.map +1 -1
- package/dist/esm/array/index.d.ts +9 -23
- package/dist/esm/array/index.d.ts.map +1 -1
- package/dist/esm/array/index.js +10 -22
- package/dist/esm/array/index.js.map +1 -1
- package/dist/esm/drawing/bar-time.d.ts +24 -0
- package/dist/esm/drawing/bar-time.d.ts.map +1 -0
- package/dist/esm/drawing/bar-time.js +44 -0
- package/dist/esm/drawing/bar-time.js.map +1 -0
- package/dist/esm/drawing/output.d.ts +32 -0
- package/dist/esm/drawing/output.d.ts.map +1 -0
- package/dist/esm/drawing/output.js +190 -0
- package/dist/esm/drawing/output.js.map +1 -0
- package/dist/esm/drawing/registry.d.ts +5 -4
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +12 -2
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +6 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +3 -5
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +3 -9
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/types.d.ts +22 -0
- package/dist/esm/runtime/types.d.ts.map +1 -1
- package/dist/esm/script/index.d.ts +82 -5
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +167 -21
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/table/index.d.ts +87 -0
- package/dist/esm/table/index.d.ts.map +1 -0
- package/dist/esm/table/index.js +169 -0
- package/dist/esm/table/index.js.map +1 -0
- package/dist/esm/text/index.d.ts +17 -2
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +17 -2
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +30 -1
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +14 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/metadata.d.ts +258 -26
- package/dist/esm/types/metadata.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/array/index.ts +12 -23
- package/src/drawing/bar-time.ts +42 -0
- package/src/drawing/output.ts +214 -0
- package/src/drawing/registry.ts +16 -6
- package/src/index.ts +9 -3
- package/src/polyline/index.ts +3 -12
- package/src/runtime/types.ts +23 -0
- package/src/script/index.ts +254 -24
- package/src/table/index.ts +221 -0
- package/src/text/index.ts +18 -2
- package/src/types/index.ts +32 -1
- package/src/types/metadata.ts +325 -26
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all2) => {
|
|
7
|
+
for (var name in all2)
|
|
8
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var output_exports = {};
|
|
20
|
+
__export(output_exports, {
|
|
21
|
+
drawingOutputs: () => drawingOutputs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(output_exports);
|
|
24
|
+
var import_registry = require("./registry.js");
|
|
25
|
+
var import_bar_time = require("./bar-time.js");
|
|
26
|
+
function colorOut(c) {
|
|
27
|
+
if (c === void 0) return void 0;
|
|
28
|
+
if (c === null || typeof c === "number" && Number.isNaN(c)) return "transparent";
|
|
29
|
+
return typeof c === "number" ? `#${(c & 16777215).toString(16).padStart(6, "0")}` : c;
|
|
30
|
+
}
|
|
31
|
+
function compact(obj) {
|
|
32
|
+
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
const overlay = (flag) => flag ? true : void 0;
|
|
36
|
+
function drawingOutputs(bars, timeUnit = "s") {
|
|
37
|
+
const interval = (0, import_bar_time.barInterval)(bars);
|
|
38
|
+
const msUnit = timeUnit === "ms" ? 1 : 1e3;
|
|
39
|
+
const xTime = (x, xloc) => xloc === "bar_time" ? x / msUnit : (0, import_bar_time.barTime)(bars, x, interval);
|
|
40
|
+
const ok = (...values) => values.every(Number.isFinite);
|
|
41
|
+
const lineData = (l) => {
|
|
42
|
+
const time1 = xTime(l.x1, l.xloc);
|
|
43
|
+
const time2 = xTime(l.x2, l.xloc);
|
|
44
|
+
if (!ok(time1, time2, l.y1, l.y2)) return void 0;
|
|
45
|
+
return compact({
|
|
46
|
+
time1,
|
|
47
|
+
price1: l.y1,
|
|
48
|
+
time2,
|
|
49
|
+
price2: l.y2,
|
|
50
|
+
color: colorOut(l.color),
|
|
51
|
+
width: l.width,
|
|
52
|
+
style: l.style,
|
|
53
|
+
extend: l.extend,
|
|
54
|
+
forceOverlay: overlay(l.force_overlay)
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const labelData = (l) => {
|
|
58
|
+
const time = xTime(l.x, l.xloc);
|
|
59
|
+
if (!ok(time) || l.yloc === "price" && !ok(l.y)) return void 0;
|
|
60
|
+
return compact({
|
|
61
|
+
time,
|
|
62
|
+
price: l.y,
|
|
63
|
+
text: l.text ?? "",
|
|
64
|
+
color: colorOut(l.color),
|
|
65
|
+
textColor: colorOut(l.textcolor),
|
|
66
|
+
style: l.style,
|
|
67
|
+
size: l.size,
|
|
68
|
+
yloc: l.yloc,
|
|
69
|
+
textAlign: l.textalign,
|
|
70
|
+
tooltip: l.tooltip,
|
|
71
|
+
fontFamily: l.text_font_family,
|
|
72
|
+
textFormatting: l.text_formatting,
|
|
73
|
+
forceOverlay: overlay(l.force_overlay)
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const boxData = (b) => {
|
|
77
|
+
const time1 = xTime(b.left, b.xloc);
|
|
78
|
+
const time2 = xTime(b.right, b.xloc);
|
|
79
|
+
if (!ok(time1, time2, b.top, b.bottom)) return void 0;
|
|
80
|
+
return compact({
|
|
81
|
+
time1,
|
|
82
|
+
price1: b.top,
|
|
83
|
+
time2,
|
|
84
|
+
price2: b.bottom,
|
|
85
|
+
bgColor: colorOut(b.bgcolor),
|
|
86
|
+
borderColor: colorOut(b.border_color),
|
|
87
|
+
borderWidth: b.border_width,
|
|
88
|
+
borderStyle: b.border_style,
|
|
89
|
+
text: b.text,
|
|
90
|
+
textColor: colorOut(b.text_color),
|
|
91
|
+
textSize: b.text_size,
|
|
92
|
+
textHAlign: b.text_halign,
|
|
93
|
+
textVAlign: b.text_valign,
|
|
94
|
+
textWrap: b.text_wrap,
|
|
95
|
+
fontFamily: b.text_font_family,
|
|
96
|
+
textFormatting: b.text_formatting,
|
|
97
|
+
extend: b.extend,
|
|
98
|
+
forceOverlay: overlay(b.force_overlay)
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const polylineData = (p) => {
|
|
102
|
+
const points = [];
|
|
103
|
+
for (const point of p.points) {
|
|
104
|
+
const x = p.xloc === "bar_time" ? point.time : point.index;
|
|
105
|
+
const time = x === null ? NaN : xTime(x, p.xloc);
|
|
106
|
+
if (ok(time, point.price)) points.push({ time, price: point.price });
|
|
107
|
+
}
|
|
108
|
+
if (points.length === 0) return void 0;
|
|
109
|
+
return compact({
|
|
110
|
+
points,
|
|
111
|
+
curved: p.curved,
|
|
112
|
+
closed: p.closed,
|
|
113
|
+
lineColor: colorOut(p.line_color),
|
|
114
|
+
fillColor: p.fill_color === null ? void 0 : colorOut(p.fill_color),
|
|
115
|
+
lineStyle: p.line_style,
|
|
116
|
+
lineWidth: p.line_width,
|
|
117
|
+
forceOverlay: overlay(p.force_overlay)
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const tableData = (t) => {
|
|
121
|
+
const cells = [];
|
|
122
|
+
for (const [key, c] of t.cells ?? []) {
|
|
123
|
+
const [column, row] = key.split(",").map(Number);
|
|
124
|
+
cells.push(
|
|
125
|
+
compact({
|
|
126
|
+
row,
|
|
127
|
+
column,
|
|
128
|
+
text: c.text ?? "",
|
|
129
|
+
bgColor: colorOut(c.bgcolor),
|
|
130
|
+
textColor: colorOut(c.text_color),
|
|
131
|
+
textSize: c.text_size,
|
|
132
|
+
width: c.width,
|
|
133
|
+
height: c.height,
|
|
134
|
+
textHAlign: c.text_halign,
|
|
135
|
+
textVAlign: c.text_valign,
|
|
136
|
+
tooltip: c.tooltip,
|
|
137
|
+
fontFamily: c.text_font_family,
|
|
138
|
+
textFormatting: c.text_formatting
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
cells.sort((a, b) => a.row - b.row || a.column - b.column);
|
|
143
|
+
const merges = (t.merges ?? []).map((m) => ({
|
|
144
|
+
startColumn: m.start_column,
|
|
145
|
+
startRow: m.start_row,
|
|
146
|
+
endColumn: m.end_column,
|
|
147
|
+
endRow: m.end_row
|
|
148
|
+
}));
|
|
149
|
+
return compact({
|
|
150
|
+
position: t.position,
|
|
151
|
+
columns: t.columns,
|
|
152
|
+
rows: t.rows,
|
|
153
|
+
cells,
|
|
154
|
+
merges: merges.length ? merges : void 0,
|
|
155
|
+
bgColor: colorOut(t.bgcolor),
|
|
156
|
+
frameColor: colorOut(t.frame_color),
|
|
157
|
+
frameWidth: t.frame_width,
|
|
158
|
+
borderColor: colorOut(t.border_color),
|
|
159
|
+
borderWidth: t.border_width,
|
|
160
|
+
forceOverlay: overlay(t.force_overlay)
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const convert = (items, fn) => {
|
|
164
|
+
const out = [];
|
|
165
|
+
for (const item of items) {
|
|
166
|
+
const r = fn(item);
|
|
167
|
+
if (r !== void 0) out.push(r);
|
|
168
|
+
}
|
|
169
|
+
return out.length ? out : void 0;
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
labels: convert((0, import_registry.all)("label"), labelData),
|
|
173
|
+
lines: convert((0, import_registry.all)("line"), lineData),
|
|
174
|
+
boxes: convert((0, import_registry.all)("box"), boxData),
|
|
175
|
+
linefills: convert((0, import_registry.all)("linefill"), (f) => {
|
|
176
|
+
const line1 = lineData(f.line1);
|
|
177
|
+
const line2 = lineData(f.line2);
|
|
178
|
+
return line1 && line2 ? compact({ line1, line2, color: colorOut(f.color) }) : void 0;
|
|
179
|
+
}),
|
|
180
|
+
polylines: convert((0, import_registry.all)("polyline"), polylineData),
|
|
181
|
+
tables: convert((0, import_registry.all)("table"), tableData)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/drawing/output.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Renderable form of the live drawing objects (labels, lines, boxes, linefills, polylines, tables): the\n * `IndicatorResult` fields `labels`, `lines`, `boxes`, `linefills`, `polylines` and `tables`.\n *\n * Conversion rules:\n * - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar\n * (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times\n * - an object with an `na` coordinate (or a bar index before the first bar) is not drawn, as in PineScript\n * - a property the script did not set is omitted (the renderer uses the PineScript default); a colour set to `na`\n * is 'transparent'\n * - `force_overlay` is kept only when true\n *\n * @module drawing/output\n */\n\nimport { all } from './registry.js';\nimport { barInterval, barTime } from './bar-time.js';\nimport type { Box, ChartPoint, Label, Line, Polyline, Table, color } from '../types/index.js';\nimport type {\n BoxData,\n LabelData,\n LineDrawingData,\n LinefillData,\n PolylineData,\n TableCellData,\n TableData,\n} from '../types/metadata.js';\n\n/** Drawing fields of an IndicatorResult; a kind without live objects is undefined. */\nexport interface DrawingOutputs {\n labels?: LabelData[];\n lines?: LineDrawingData[];\n boxes?: BoxData[];\n linefills?: LinefillData[];\n polylines?: PolylineData[];\n tables?: TableData[];\n}\n\n/** A colour of the result: 'transparent' for na (null), '#rrggbb' for a numeric colour. */\nfunction colorOut(c: color | null | undefined): string | undefined {\n if (c === undefined) return undefined;\n if (c === null || (typeof c === 'number' && Number.isNaN(c))) return 'transparent';\n return typeof c === 'number' ? `#${(c & 0xffffff).toString(16).padStart(6, '0')}` : c;\n}\n\n/** The object without its undefined fields (so that the result has only the properties that were set). */\nfunction compact<T extends object>(obj: T): T {\n for (const k of Object.keys(obj) as Array<keyof T>) if (obj[k] === undefined) delete obj[k];\n return obj;\n}\n\nconst overlay = (flag: boolean | undefined): true | undefined => (flag ? true : undefined);\n\n/**\n * Converts the live drawing objects of the registry. `bars` are the chart bars (their `time` in `timeUnit`, 's' by\n * default as lightweight-charts); they give the time of a bar index.\n */\nexport function drawingOutputs(bars: ReadonlyArray<{ time: number }>, timeUnit: 's' | 'ms' = 's'): DrawingOutputs {\n const interval = barInterval(bars);\n const msUnit = timeUnit === 'ms' ? 1 : 1000;\n const xTime = (x: number, xloc: 'bar_index' | 'bar_time'): number =>\n xloc === 'bar_time' ? x / msUnit : barTime(bars, x, interval);\n const ok = (...values: number[]): boolean => values.every(Number.isFinite);\n\n const lineData = (l: Line): LineDrawingData | undefined => {\n const time1 = xTime(l.x1, l.xloc);\n const time2 = xTime(l.x2, l.xloc);\n if (!ok(time1, time2, l.y1, l.y2)) return undefined;\n return compact({\n time1,\n price1: l.y1,\n time2,\n price2: l.y2,\n color: colorOut(l.color),\n width: l.width,\n style: l.style,\n extend: l.extend,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const labelData = (l: Label): LabelData | undefined => {\n const time = xTime(l.x, l.xloc);\n // abovebar / belowbar labels are placed at the bar, not at y\n if (!ok(time) || (l.yloc === 'price' && !ok(l.y))) return undefined;\n return compact({\n time,\n price: l.y,\n text: l.text ?? '',\n color: colorOut(l.color),\n textColor: colorOut(l.textcolor),\n style: l.style,\n size: l.size as LabelData['size'],\n yloc: l.yloc,\n textAlign: l.textalign,\n tooltip: l.tooltip,\n fontFamily: l.text_font_family,\n textFormatting: l.text_formatting,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const boxData = (b: Box): BoxData | undefined => {\n const time1 = xTime(b.left, b.xloc);\n const time2 = xTime(b.right, b.xloc);\n if (!ok(time1, time2, b.top, b.bottom)) return undefined;\n return compact({\n time1,\n price1: b.top,\n time2,\n price2: b.bottom,\n bgColor: colorOut(b.bgcolor),\n borderColor: colorOut(b.border_color),\n borderWidth: b.border_width,\n borderStyle: b.border_style,\n text: b.text,\n textColor: colorOut(b.text_color),\n textSize: b.text_size as BoxData['textSize'],\n textHAlign: b.text_halign,\n textVAlign: b.text_valign,\n textWrap: b.text_wrap,\n fontFamily: b.text_font_family,\n textFormatting: b.text_formatting,\n extend: b.extend,\n forceOverlay: overlay(b.force_overlay),\n });\n };\n\n const polylineData = (p: Polyline): PolylineData | undefined => {\n const points: PolylineData['points'] = [];\n for (const point of p.points as ChartPoint[]) {\n const x = p.xloc === 'bar_time' ? point.time : point.index;\n const time = x === null ? NaN : xTime(x, p.xloc);\n if (ok(time, point.price)) points.push({ time, price: point.price });\n }\n if (points.length === 0) return undefined;\n return compact({\n points,\n curved: p.curved,\n closed: p.closed,\n lineColor: colorOut(p.line_color),\n fillColor: p.fill_color === null ? undefined : colorOut(p.fill_color),\n lineStyle: p.line_style,\n lineWidth: p.line_width,\n forceOverlay: overlay(p.force_overlay),\n });\n };\n\n const tableData = (t: Table): TableData => {\n const cells: TableCellData[] = [];\n for (const [key, c] of t.cells ?? []) {\n const [column, row] = key.split(',').map(Number) as [number, number];\n cells.push(\n compact({\n row,\n column,\n text: c.text ?? '',\n bgColor: colorOut(c.bgcolor),\n textColor: colorOut(c.text_color),\n textSize: c.text_size as TableCellData['textSize'],\n width: c.width,\n height: c.height,\n textHAlign: c.text_halign,\n textVAlign: c.text_valign,\n tooltip: c.tooltip,\n fontFamily: c.text_font_family,\n textFormatting: c.text_formatting,\n })\n );\n }\n cells.sort((a, b) => a.row - b.row || a.column - b.column);\n const merges = (t.merges ?? []).map((m) => ({\n startColumn: m.start_column,\n startRow: m.start_row,\n endColumn: m.end_column,\n endRow: m.end_row,\n }));\n return compact({\n position: t.position,\n columns: t.columns,\n rows: t.rows,\n cells,\n merges: merges.length ? merges : undefined,\n bgColor: colorOut(t.bgcolor),\n frameColor: colorOut(t.frame_color),\n frameWidth: t.frame_width,\n borderColor: colorOut(t.border_color),\n borderWidth: t.border_width,\n forceOverlay: overlay(t.force_overlay),\n });\n };\n\n const convert = <T, R>(items: T[], fn: (item: T) => R | undefined): R[] | undefined => {\n const out: R[] = [];\n for (const item of items) {\n const r = fn(item);\n if (r !== undefined) out.push(r);\n }\n return out.length ? out : undefined;\n };\n\n return {\n labels: convert(all('label'), labelData),\n lines: convert(all('line'), lineData),\n boxes: convert(all('box'), boxData),\n linefills: convert(all('linefill'), (f): LinefillData | undefined => {\n const line1 = lineData(f.line1);\n const line2 = lineData(f.line2);\n return line1 && line2 ? compact({ line1, line2, color: colorOut(f.color) }) : undefined;\n }),\n polylines: convert(all('polyline'), polylineData),\n tables: convert(all('table'), tableData),\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;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,UAAU,GAAG,YAAY;AAAA,IAChD,QAAQ,YAAQ,qBAAI,OAAO,GAAG,SAAS;AAAA,EACzC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Registry of the live drawing objects (lines, labels, boxes, polylines, linefills), as PineScript
|
|
2
|
+
* Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript
|
|
3
3
|
* keeps them. PineScript rules:
|
|
4
4
|
*
|
|
5
5
|
* - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)
|
|
@@ -14,18 +14,19 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @module drawing/registry
|
|
16
16
|
*/
|
|
17
|
-
import type { Box, Label, Line, Linefill, Polyline } from '../types/index.js';
|
|
18
|
-
export type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill';
|
|
17
|
+
import type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';
|
|
18
|
+
export type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';
|
|
19
19
|
interface DrawingTypes {
|
|
20
20
|
line: Line;
|
|
21
21
|
label: Label;
|
|
22
22
|
box: Box;
|
|
23
23
|
polyline: Polyline;
|
|
24
24
|
linefill: Linefill;
|
|
25
|
+
table: Table;
|
|
25
26
|
}
|
|
26
27
|
/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */
|
|
27
28
|
export declare const DEFAULT_MAX_COUNT = 50;
|
|
28
|
-
export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill'>, number>>;
|
|
29
|
+
export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;
|
|
29
30
|
/** Records a new object and deletes the oldest objects of its kind when the count is too high. */
|
|
30
31
|
export declare function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K];
|
|
31
32
|
/** Deletes an object (no effect when it is already deleted). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEvF,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAoChG,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAS9F;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAKjF;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED,mEAAmE;AACnE,wBAAgB,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,SAAS,GAAE,aAAkB,GAAG,IAAI,CAQjE;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAE/D"}
|
|
@@ -29,7 +29,14 @@ __export(registry_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(registry_exports);
|
|
30
30
|
const DEFAULT_MAX_COUNT = 50;
|
|
31
31
|
const SLACK = 5;
|
|
32
|
-
const live = {
|
|
32
|
+
const live = {
|
|
33
|
+
line: [],
|
|
34
|
+
label: [],
|
|
35
|
+
box: [],
|
|
36
|
+
polyline: [],
|
|
37
|
+
linefill: [],
|
|
38
|
+
table: []
|
|
39
|
+
};
|
|
33
40
|
let limits = {
|
|
34
41
|
line: DEFAULT_MAX_COUNT,
|
|
35
42
|
label: DEFAULT_MAX_COUNT,
|
|
@@ -42,7 +49,8 @@ const COORDINATES = {
|
|
|
42
49
|
label: ["x", "y"],
|
|
43
50
|
box: ["left", "top", "right", "bottom"],
|
|
44
51
|
polyline: [],
|
|
45
|
-
linefill: []
|
|
52
|
+
linefill: [],
|
|
53
|
+
table: []
|
|
46
54
|
};
|
|
47
55
|
function markDeleted(kind, obj, explicit) {
|
|
48
56
|
deleted.add(obj);
|
|
@@ -54,6 +62,7 @@ function markDeleted(kind, obj, explicit) {
|
|
|
54
62
|
function register(kind, obj) {
|
|
55
63
|
const list = live[kind];
|
|
56
64
|
list.push(obj);
|
|
65
|
+
if (kind === "table") return obj;
|
|
57
66
|
const max = limits[kind === "linefill" ? "line" : kind];
|
|
58
67
|
if (list.length > max + SLACK) {
|
|
59
68
|
for (const old of list.splice(0, list.length - max)) markDeleted(kind, old, false);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/drawing/registry.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n table: Table;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = {\n line: [],\n label: [],\n box: [],\n polyline: [],\n linefill: [],\n table: [],\n};\nlet limits: Required<DrawingLimits> = {\n line: DEFAULT_MAX_COUNT,\n label: DEFAULT_MAX_COUNT,\n box: DEFAULT_MAX_COUNT,\n polyline: DEFAULT_MAX_COUNT,\n};\nconst deleted = new WeakSet<object>();\n\n/** Numeric fields that become NaN when an object is deleted, so that its getters return `na`. */\nconst COORDINATES: { [K in DrawingKind]: Array<keyof DrawingTypes[K]> } = {\n line: ['x1', 'y1', 'x2', 'y2'],\n label: ['x', 'y'],\n box: ['left', 'top', 'right', 'bottom'],\n polyline: [],\n linefill: [],\n table: [],\n};\n\nfunction markDeleted<K extends DrawingKind>(kind: K, obj: DrawingTypes[K], explicit: boolean): void {\n deleted.add(obj);\n for (const field of COORDINATES[kind]) (obj as unknown as Record<string, unknown>)[field as string] = NaN;\n if (kind === 'line' && explicit) {\n for (const fill of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove('linefill', fill);\n }\n}\n\n/** Records a new object and deletes the oldest objects of its kind when the count is too high. */\nexport function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n const list = live[kind];\n list.push(obj);\n if (kind === 'table') return obj; // tables have no maximum count\n const max = limits[kind === 'linefill' ? 'line' : (kind as keyof DrawingLimits)];\n if (list.length > max + SLACK) {\n for (const old of list.splice(0, list.length - max)) markDeleted(kind, old, false);\n }\n return obj;\n}\n\n/** Deletes an object (no effect when it is already deleted). */\nexport function remove<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): void {\n const list = live[kind];\n const index = list.indexOf(obj);\n if (index !== -1) list.splice(index, 1);\n if (!deleted.has(obj)) markDeleted(kind, obj, true);\n}\n\n/** True when the object was deleted (by `delete` or by the maximum count). */\nexport function isDeleted(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && deleted.has(obj);\n}\n\n/** The live objects of a kind, in creation order (a new array). */\nexport function all<K extends DrawingKind>(kind: K): Array<DrawingTypes[K]> {\n return [...live[kind]] as Array<DrawingTypes[K]>;\n}\n\n/** Forgets all objects (without deleting them) and sets the maximum counts (default 50). */\nexport function resetDrawings(newLimits: DrawingLimits = {}): void {\n for (const kind of Object.keys(live) as DrawingKind[]) live[kind].length = 0;\n limits = {\n line: newLimits.line ?? DEFAULT_MAX_COUNT,\n label: newLimits.label ?? DEFAULT_MAX_COUNT,\n box: newLimits.box ?? DEFAULT_MAX_COUNT,\n polyline: newLimits.polyline ?? DEFAULT_MAX_COUNT,\n };\n}\n\n/** Changes the maximum counts without forgetting the objects (PineScript `indicator(max_*_count)`). */\nexport function setDrawingLimits(newLimits: DrawingLimits): void {\n limits = { ...limits, ...Object.fromEntries(Object.entries(newLim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SAAS,GAAG,EAAG,aAAY,MAAM,KAAK,KAAK;AAAA,EACnF;AACA,SAAO;AACT;AAGO,SAAS,OAA8B,MAAS,KAA4B;AACjF,QAAM,OAAO,KAAK,IAAI;AACtB,QAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,MAAI,UAAU,GAAI,MAAK,OAAO,OAAO,CAAC;AACtC,MAAI,CAAC,QAAQ,IAAI,GAAG,EAAG,aAAY,MAAM,KAAK,IAAI;AACpD;AAGO,SAAS,UAAU,KAAuB;AAC/C,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,IAAI,GAAG;AACnE;AAGO,SAAS,IAA2B,MAAiC;AAC1E,SAAO,CAAC,GAAG,KAAK,IAAI,CAAC;AACvB;AAGO,SAAS,cAAc,YAA2B,CAAC,GAAS;AACjE,aAAW,QAAQ,OAAO,KAAK,IAAI,EAAoB,MAAK,IAAI,EAAE,SAAS;AAC3E,WAAS;AAAA,IACP,MAAM,UAAU,QAAQ;AAAA,IACxB,OAAO,UAAU,SAAS;AAAA,IAC1B,KAAK,UAAU,OAAO;AAAA,IACtB,UAAU,UAAU,YAAY;AAAA,EAClC;AACF;AAGO,SAAS,iBAAiB,WAAgC;AAC/D,WAAS,EAAE,GAAG,QAAQ,GAAG,OAAO,YAAY,OAAO,QAAQ,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC,EAAE;AAC5G;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -28,10 +28,13 @@ import * as label from './label/index.js';
|
|
|
28
28
|
import * as linefill from './linefill/index.js';
|
|
29
29
|
import * as chartPoint from './chartpoint/index.js';
|
|
30
30
|
import * as polyline from './polyline/index.js';
|
|
31
|
+
import * as table from './table/index.js';
|
|
31
32
|
import * as text from './text/index.js';
|
|
32
33
|
import * as compare from './compare/index.js';
|
|
33
34
|
import * as callsite from './callsite/index.js';
|
|
34
|
-
export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, text, compare, callsite };
|
|
35
|
+
export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };
|
|
36
|
+
export { drawingOutputs, type DrawingOutputs } from './drawing/output.js';
|
|
37
|
+
export { barInterval, barTime } from './drawing/bar-time.js';
|
|
35
38
|
export { Series, BarData } from './runtime/series.js';
|
|
36
39
|
export type { SeriesExtractor } from './runtime/series.js';
|
|
37
40
|
import * as ta from './ta-series.js';
|
|
@@ -48,13 +51,13 @@ export { input, type InputValue, type IntInputOptions, type FloatInputOptions, t
|
|
|
48
51
|
export { plot as plotHelper, createPlot, type Time, type TimeValuePair, type PlotOptions as PlotHelperOptions, type PlotResult, } from './plot.js';
|
|
49
52
|
export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
|
|
50
53
|
export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, } from './runtime/inputs.js';
|
|
51
|
-
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, } from './runtime/types.js';
|
|
54
|
+
export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, } from './runtime/types.js';
|
|
52
55
|
export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
|
|
53
56
|
export type * from './strategy/index.js';
|
|
54
57
|
export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
55
58
|
export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
|
|
56
59
|
export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
|
|
57
|
-
export declare const VERSION = "0.
|
|
60
|
+
export declare const VERSION = "0.10.0";
|
|
58
61
|
/**
|
|
59
62
|
* Library information
|
|
60
63
|
*/
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,E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AC;AAG5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,YAAY,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAKF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAE5F"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -44,6 +44,8 @@ __export(index_exports, {
|
|
|
44
44
|
at: () => import_utils.at,
|
|
45
45
|
atr: () => import_ta_series.atr,
|
|
46
46
|
avg: () => import_math.avg,
|
|
47
|
+
barInterval: () => import_bar_time.barInterval,
|
|
48
|
+
barTime: () => import_bar_time.barTime,
|
|
47
49
|
bb: () => import_ta_series.bb,
|
|
48
50
|
box: () => box,
|
|
49
51
|
callsite: () => callsite,
|
|
@@ -61,6 +63,7 @@ __export(index_exports, {
|
|
|
61
63
|
crossunder: () => import_ta_series.crossunder,
|
|
62
64
|
cum: () => import_ta_series.cum,
|
|
63
65
|
div: () => import_utils.div,
|
|
66
|
+
drawingOutputs: () => import_output.drawingOutputs,
|
|
64
67
|
ema: () => import_ta_series.ema,
|
|
65
68
|
exp: () => import_math.exp,
|
|
66
69
|
fixnan: () => import_utils2.fixnan,
|
|
@@ -116,6 +119,7 @@ __export(index_exports, {
|
|
|
116
119
|
sum: () => import_math.sum,
|
|
117
120
|
ta: () => ta,
|
|
118
121
|
taCore: () => taCore,
|
|
122
|
+
table: () => table,
|
|
119
123
|
tan: () => import_math.tan,
|
|
120
124
|
text: () => text,
|
|
121
125
|
time: () => time,
|
|
@@ -141,9 +145,12 @@ var label = __toESM(require("./label/index.js"), 1);
|
|
|
141
145
|
var linefill = __toESM(require("./linefill/index.js"), 1);
|
|
142
146
|
var chartPoint = __toESM(require("./chartpoint/index.js"), 1);
|
|
143
147
|
var polyline = __toESM(require("./polyline/index.js"), 1);
|
|
148
|
+
var table = __toESM(require("./table/index.js"), 1);
|
|
144
149
|
var text = __toESM(require("./text/index.js"), 1);
|
|
145
150
|
var compare = __toESM(require("./compare/index.js"), 1);
|
|
146
151
|
var callsite = __toESM(require("./callsite/index.js"), 1);
|
|
152
|
+
var import_output = require("./drawing/output.js");
|
|
153
|
+
var import_bar_time = require("./drawing/bar-time.js");
|
|
147
154
|
var import_series = require("./runtime/series.js");
|
|
148
155
|
var ta = __toESM(require("./ta-series.js"), 1);
|
|
149
156
|
var import_ta_series = require("./ta-series.js");
|
|
@@ -160,7 +167,7 @@ var import_inputs = require("./runtime/inputs.js");
|
|
|
160
167
|
var import_strategy = require("./strategy/index.js");
|
|
161
168
|
var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
|
|
162
169
|
var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
|
|
163
|
-
const VERSION = "0.
|
|
170
|
+
const VERSION = "0.10.0";
|
|
164
171
|
const info = {
|
|
165
172
|
name: "OakScriptJS",
|
|
166
173
|
version: VERSION,
|
|
@@ -174,7 +181,7 @@ const info = {
|
|
|
174
181
|
},
|
|
175
182
|
namespaces: {
|
|
176
183
|
core: ["ta", "math", "array", "map", "str", "color", "time", "timeframe", "matrix"],
|
|
177
|
-
drawing: ["line", "box", "label", "linefill", "chartPoint", "polyline", "text"],
|
|
184
|
+
drawing: ["line", "box", "label", "linefill", "chartPoint", "polyline", "table", "text"],
|
|
178
185
|
runtime: ["setContext", "plot", "hline", "input_*"],
|
|
179
186
|
indicator: ["indicator", "input", "plotHelper", "createPlot"]
|
|
180
187
|
}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, text, compare, callsite };\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_source,\n input_timeframe,\n input_session,\n input_time,\n} from './runtime/inputs.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,0BAAc,6BAfd;AAgBA,0BAAc,gCAhBd;AAmBA,aAAwB;AACxB,WAAsB;AACtB,YAAuB;AACvB,UAAqB;AACrB,UAAqB;AACrB,YAAuB;AACvB,WAAsB;AACtB,gBAA2B;AAC3B,aAAwB;AACxB,WAAsB;AACtB,UAAqB;AACrB,YAAuB;AACvB,eAA0B;AAC1B,iBAA4B;AAC5B,eAA0B;AAC1B,WAAsB;AACtB,cAAyB;AACzB,eAA0B;AAK1B,oBAAgC;AAIhC,SAAoB;AAyBpB,uBAAkG;AAClG,kBAAgG;AAChG,mBAA2D;AAG3D,mBAAsG;AAGtG,0BAAc,
|
|
4
|
+
"sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_source,\n input_timeframe,\n input_session,\n input_time,\n} from './runtime/inputs.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.10.0';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAA,EACb;AAAA,EACA,YAAY;AAAA,IACV,MAAM,CAAC,MAAM,QAAQ,SAAS,OAAO,OAAO,SAAS,QAAQ,aAAa,QAAQ;AAAA,IAClF,SAAS,CAAC,QAAQ,OAAO,SAAS,YAAY,cAAc,YAAY,SAAS,MAAM;AAAA,IACvF,SAAS,CAAC,cAAc,QAAQ,SAAS,SAAS;AAAA,IAClD,WAAW,CAAC,aAAa,SAAS,cAAc,YAAY;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
|
|
6
6
|
"names": ["import_utils"]
|
|
7
7
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Polylines allow connecting multiple points with line segments, enabling complex chart drawings
|
|
7
|
-
* like trend channels, patterns, and custom shapes.
|
|
8
|
-
* polylines
|
|
7
|
+
* like trend channels, patterns, and custom shapes. The `curved` flag goes to the renderer
|
|
8
|
+
* (`result.polylines` of the script API), which draws the curve.
|
|
9
9
|
*
|
|
10
10
|
* @version 6
|
|
11
11
|
*/
|
|
@@ -15,7 +15,7 @@ export type { Polyline };
|
|
|
15
15
|
* Creates a new polyline connecting all points.
|
|
16
16
|
*
|
|
17
17
|
* @param points - Array of chart.point objects to connect
|
|
18
|
-
* @param curved - If true, use curved line segments (default: false
|
|
18
|
+
* @param curved - If true, use curved line segments (default: false)
|
|
19
19
|
* @param closed - If true, connect first point to last point (default: false)
|
|
20
20
|
* @param xloc - X-coordinate mode: 'bar_index' or 'bar_time' (default: 'bar_index')
|
|
21
21
|
* @param line_color - Color of line segments (default: '#2196F3' - blue)
|
|
@@ -26,8 +26,6 @@ export type { Polyline };
|
|
|
26
26
|
* @returns New Polyline object
|
|
27
27
|
*
|
|
28
28
|
* @remarks
|
|
29
|
-
* - The curved parameter is accepted but currently logs a warning as curved lines
|
|
30
|
-
* are not yet supported. Straight-line connections are used instead.
|
|
31
29
|
* - For meaningful polylines, provide at least 2 points.
|
|
32
30
|
* - Closed polylines can be filled with a color by setting fill_color.
|
|
33
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/polyline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIrE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAYzB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/polyline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAIrE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAYzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAAE,EACpB,MAAM,GAAE,OAAe,EACvB,MAAM,GAAE,OAAe,EACvB,IAAI,GAAE,WAAW,GAAG,UAAwB,EAC5C,UAAU,GAAE,KAAiB,EAC7B,UAAU,GAAE,KAAK,GAAG,IAAW,EAC/B,UAAU,GAAE,OAAO,GAAG,QAAQ,GAAG,QAAkB,EACnD,UAAU,GAAE,MAAU,EACtB,aAAa,GAAE,OAAe,GAC7B,QAAQ,CAqBV;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAElD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,IAAI,SAAS,QAAQ,EAAE,CAE7C;AAED;;GAEG;AACH,wBAAgB,GAAG,IAAI,QAAQ,EAAE,CAEhC;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAGD,OAAO,EAAE,YAAY,IAAI,GAAG,EAAE,CAAC;AAC/B,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -34,11 +34,6 @@ function generateId() {
|
|
|
34
34
|
return `polyline_${++polylineIdCounter}`;
|
|
35
35
|
}
|
|
36
36
|
function new_polyline(points, curved = false, closed = false, xloc = "bar_index", line_color = "#2196F3", fill_color = null, line_style = "solid", line_width = 1, force_overlay = false) {
|
|
37
|
-
if (curved) {
|
|
38
|
-
console.warn(
|
|
39
|
-
"polyline.new(): curved polylines are not yet supported. Using straight-line connections."
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
37
|
if (line_width < 1) {
|
|
43
38
|
console.warn("polyline.new(): line_width must be at least 1. Using 1.");
|
|
44
39
|
line_width = 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/polyline/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Polyline namespace\n * Functions for creating and manipulating polyline drawing objects.\n *\n * @remarks\n * Polylines allow connecting multiple points with line segments, enabling complex chart drawings\n * like trend channels, patterns, and custom shapes.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,sBAAqD;AAMrD,IAAI,oBAAoB;AAKxB,SAAS,aAAqB;AAC5B,SAAO,YAAY,EAAE,iBAAiB;AACxC;
|
|
4
|
+
"sourcesContent": ["/**\n * Polyline namespace\n * Functions for creating and manipulating polyline drawing objects.\n *\n * @remarks\n * Polylines allow connecting multiple points with line segments, enabling complex chart drawings\n * like trend channels, patterns, and custom shapes. The `curved` flag goes to the renderer\n * (`result.polylines` of the script API), which draws the curve.\n *\n * @version 6\n */\n\nimport type { ChartPoint, Polyline, color } from '../types/index.js';\nimport { all as allDrawings, register, remove } from '../drawing/registry.js';\n\n// Re-export the Polyline type for convenience\nexport type { Polyline };\n\n// Internal counter for generating unique IDs\nlet polylineIdCounter = 0;\n\n/**\n * Generates a unique ID for a polyline\n */\nfunction generateId(): string {\n return `polyline_${++polylineIdCounter}`;\n}\n\n/**\n * Creates a new polyline connecting all points.\n *\n * @param points - Array of chart.point objects to connect\n * @param curved - If true, use curved line segments (default: false)\n * @param closed - If true, connect first point to last point (default: false)\n * @param xloc - X-coordinate mode: 'bar_index' or 'bar_time' (default: 'bar_index')\n * @param line_color - Color of line segments (default: '#2196F3' - blue)\n * @param fill_color - Fill color for closed polylines (default: null)\n * @param line_style - Line style (default: 'solid')\n * @param line_width - Line width in pixels (default: 1)\n * @param force_overlay - Force display on main pane (default: false)\n * @returns New Polyline object\n *\n * @remarks\n * - For meaningful polylines, provide at least 2 points.\n * - Closed polylines can be filled with a color by setting fill_color.\n *\n * @example\n * ```typescript\n * import { chartPoint, polyline } from 'oakscriptjs';\n *\n * // Create points\n * const points = [\n * chartPoint.from_index(0, 100),\n * chartPoint.from_index(10, 120),\n * chartPoint.from_index(20, 110)\n * ];\n *\n * // Create a basic polyline\n * const myPolyline = polyline.new(points);\n *\n * // Create a closed polygon with fill\n * const polygon = polyline.new(\n * points,\n * false, // curved\n * true, // closed\n * 'bar_index', // xloc\n * '#FF5722', // line_color\n * 'rgba(255, 87, 34, 0.3)' // fill_color\n * );\n * ```\n */\nexport function new_polyline(\n points: ChartPoint[],\n curved: boolean = false,\n closed: boolean = false,\n xloc: 'bar_index' | 'bar_time' = 'bar_index',\n line_color: color = '#2196F3',\n fill_color: color | null = null,\n line_style: 'solid' | 'dotted' | 'dashed' = 'solid',\n line_width: number = 1,\n force_overlay: boolean = false\n): Polyline {\n // Validate line_width is positive\n if (line_width < 1) {\n console.warn('polyline.new(): line_width must be at least 1. Using 1.');\n line_width = 1;\n }\n\n const polyline: Polyline = {\n id: generateId(),\n points: [...points], // Create a copy of the points array\n curved,\n closed,\n xloc,\n line_color,\n fill_color,\n line_style,\n line_width,\n force_overlay,\n };\n\n return register('polyline', polyline);\n}\n\n/**\n * Deletes a polyline.\n *\n * @param id - Polyline object to delete\n *\n * @remarks\n * Removes the polyline from `polyline.all()` (the drawing registry, see drawing/registry).\n *\n * @example\n * ```typescript\n * const myPolyline = polyline.new(points);\n * polyline.delete(myPolyline);\n * ```\n */\nexport function delete_polyline(id: Polyline): void {\n remove('polyline', id);\n}\n\n/**\n * Gets all active polylines.\n *\n * @returns Array of all active polylines\n *\n * @remarks\n * Returns a copy of the internal polylines array to prevent external modification.\n *\n * @example\n * ```typescript\n * console.log('Total polylines:', polyline.all.length);\n *\n * for (const p of polyline.all) {\n * console.log('Polyline ID:', p.id, 'Points:', p.points.length);\n * }\n * ```\n */\nexport function get_all(): readonly Polyline[] {\n return allDrawings('polyline');\n}\n\n/**\n * All live polylines, in creation order (PineScript `polyline.all`). A new array.\n */\nexport function all(): Polyline[] {\n return allDrawings('polyline');\n}\n\n/**\n * Deletes all polylines.\n *\n * @remarks\n * This is useful for resetting state, especially in tests.\n * Not part of the PineScript API.\n */\nexport function clear_all(): void {\n for (const p of allDrawings('polyline')) remove('polyline', p);\n}\n\n/**\n * Resets the polyline ID counter.\n *\n * @remarks\n * This is useful for resetting state, especially in tests.\n * Not part of the PineScript API.\n */\nexport function reset_id_counter(): void {\n polylineIdCounter = 0;\n}\n\n// Aliases to match PineScript API\nexport { new_polyline as new };\nexport { delete_polyline as delete };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,sBAAqD;AAMrD,IAAI,oBAAoB;AAKxB,SAAS,aAAqB;AAC5B,SAAO,YAAY,EAAE,iBAAiB;AACxC;AA6CO,SAAS,aACd,QACA,SAAkB,OAClB,SAAkB,OAClB,OAAiC,aACjC,aAAoB,WACpB,aAA2B,MAC3B,aAA4C,SAC5C,aAAqB,GACrB,gBAAyB,OACf;AAEV,MAAI,aAAa,GAAG;AAClB,YAAQ,KAAK,yDAAyD;AACtE,iBAAa;AAAA,EACf;AAEA,QAAM,WAAqB;AAAA,IACzB,IAAI,WAAW;AAAA,IACf,QAAQ,CAAC,GAAG,MAAM;AAAA;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,aAAO,0BAAS,YAAY,QAAQ;AACtC;AAgBO,SAAS,gBAAgB,IAAoB;AAClD,8BAAO,YAAY,EAAE;AACvB;AAmBO,SAAS,UAA+B;AAC7C,aAAO,gBAAAA,KAAY,UAAU;AAC/B;AAKO,SAAS,MAAkB;AAChC,aAAO,gBAAAA,KAAY,UAAU;AAC/B;AASO,SAAS,YAAkB;AAChC,aAAW,SAAK,gBAAAA,KAAY,UAAU,EAAG,6BAAO,YAAY,CAAC;AAC/D;AASO,SAAS,mBAAyB;AACvC,sBAAoB;AACtB;",
|
|
6
6
|
"names": ["allDrawings"]
|
|
7
7
|
}
|
|
@@ -134,6 +134,28 @@ export interface ArrowConfig {
|
|
|
134
134
|
/** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
|
|
135
135
|
forceOverlay?: boolean;
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Configuration of a PineScript `plotcandle()` (kind 'candle') or `plotbar()` (kind 'bar') declaration. The candles
|
|
139
|
+
* are in `result.plotCandles[id]`, the bars in `result.plotBars[id]`.
|
|
140
|
+
*/
|
|
141
|
+
export interface CandleConfig {
|
|
142
|
+
/** Unique identifier (key of the data in the result) */
|
|
143
|
+
id: string;
|
|
144
|
+
/** 'candle' for plotcandle, 'bar' for plotbar */
|
|
145
|
+
kind: 'candle' | 'bar';
|
|
146
|
+
/** Display title */
|
|
147
|
+
title?: string;
|
|
148
|
+
/** Static body colour (plotcandle) or bar colour (plotbar) */
|
|
149
|
+
color?: string;
|
|
150
|
+
/** Static wick colour (plotcandle only) */
|
|
151
|
+
wickColor?: string;
|
|
152
|
+
/** Static border colour (plotcandle only) */
|
|
153
|
+
borderColor?: string;
|
|
154
|
+
/** Display mode */
|
|
155
|
+
display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';
|
|
156
|
+
/** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
|
|
157
|
+
forceOverlay?: boolean;
|
|
158
|
+
}
|
|
137
159
|
/**
|
|
138
160
|
* Configuration for horizontal line outputs in generated indicators
|
|
139
161
|
* Matches PineScript hline() function parameters
|