oakscriptjs 0.9.5 → 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 +93 -50
- package/dist/cjs/array/index.d.ts.map +1 -1
- package/dist/cjs/array/index.js +239 -78
- package/dist/cjs/array/index.js.map +3 -3
- package/dist/cjs/callsite/index.d.ts +81 -2
- package/dist/cjs/callsite/index.d.ts.map +1 -1
- package/dist/cjs/callsite/index.js +62 -1
- package/dist/cjs/callsite/index.js.map +2 -2
- package/dist/cjs/color/index.d.ts +7 -3
- package/dist/cjs/color/index.d.ts.map +1 -1
- package/dist/cjs/color/index.js +6 -1
- package/dist/cjs/color/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/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js +2 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js +1 -0
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/math/index.d.ts +76 -21
- package/dist/cjs/math/index.d.ts.map +1 -1
- package/dist/cjs/math/index.js +155 -41
- package/dist/cjs/math/index.js.map +3 -3
- package/dist/cjs/matrix/index.d.ts.map +1 -1
- package/dist/cjs/matrix/index.js +42 -36
- package/dist/cjs/matrix/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/series.d.ts +9 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +16 -2
- package/dist/cjs/runtime/series.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 +97 -36
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +173 -26
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/session/calendar.d.ts.map +1 -1
- package/dist/cjs/session/calendar.js +15 -2
- package/dist/cjs/session/calendar.js.map +2 -2
- package/dist/cjs/str/index.d.ts +50 -38
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +43 -15
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/str/messageformat.d.ts +2 -1
- package/dist/cjs/str/messageformat.d.ts.map +1 -1
- package/dist/cjs/str/messageformat.js +4 -1
- package/dist/cjs/str/messageformat.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts +4 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +26 -4
- package/dist/cjs/str/numberformat.js.map +3 -3
- package/dist/cjs/ta/index.d.ts +86 -43
- package/dist/cjs/ta/index.d.ts.map +1 -1
- package/dist/cjs/ta/index.js +173 -267
- package/dist/cjs/ta/index.js.map +3 -3
- package/dist/cjs/ta/running-sum.d.ts +54 -2
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +132 -52
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/ta-series.d.ts +4 -4
- package/dist/cjs/ta-series.d.ts.map +1 -1
- package/dist/cjs/ta-series.js +4 -3
- package/dist/cjs/ta-series.js.map +2 -2
- 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/time/datestring.d.ts +1 -0
- package/dist/cjs/time/datestring.d.ts.map +1 -1
- package/dist/cjs/time/datestring.js +7 -0
- package/dist/cjs/time/datestring.js.map +2 -2
- package/dist/cjs/time/index.d.ts.map +1 -1
- package/dist/cjs/time/index.js +2 -1
- package/dist/cjs/time/index.js.map +2 -2
- package/dist/cjs/time/session.d.ts +28 -9
- package/dist/cjs/time/session.d.ts.map +1 -1
- package/dist/cjs/time/session.js +74 -28
- package/dist/cjs/time/session.js.map +2 -2
- package/dist/cjs/time/timezone.d.ts +5 -0
- package/dist/cjs/time/timezone.d.ts.map +1 -1
- package/dist/cjs/time/timezone.js +15 -1
- package/dist/cjs/time/timezone.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 +93 -50
- package/dist/esm/array/index.d.ts.map +1 -1
- package/dist/esm/array/index.js +383 -133
- package/dist/esm/array/index.js.map +1 -1
- package/dist/esm/callsite/index.d.ts +81 -2
- package/dist/esm/callsite/index.d.ts.map +1 -1
- package/dist/esm/callsite/index.js +145 -3
- package/dist/esm/callsite/index.js.map +1 -1
- package/dist/esm/color/index.d.ts +7 -3
- package/dist/esm/color/index.d.ts.map +1 -1
- package/dist/esm/color/index.js +15 -3
- package/dist/esm/color/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/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js +2 -1
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +3 -0
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/math/index.d.ts +76 -21
- package/dist/esm/math/index.d.ts.map +1 -1
- package/dist/esm/math/index.js +227 -61
- package/dist/esm/math/index.js.map +1 -1
- package/dist/esm/matrix/index.d.ts.map +1 -1
- package/dist/esm/matrix/index.js +57 -43
- package/dist/esm/matrix/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/series.d.ts +9 -0
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +18 -1
- package/dist/esm/runtime/series.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 +97 -36
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +211 -22
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/session/calendar.d.ts.map +1 -1
- package/dist/esm/session/calendar.js +22 -2
- package/dist/esm/session/calendar.js.map +1 -1
- package/dist/esm/str/index.d.ts +50 -38
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +103 -52
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/str/messageformat.d.ts +2 -1
- package/dist/esm/str/messageformat.d.ts.map +1 -1
- package/dist/esm/str/messageformat.js +7 -2
- package/dist/esm/str/messageformat.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts +4 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +38 -4
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/ta/index.d.ts +86 -43
- package/dist/esm/ta/index.d.ts.map +1 -1
- package/dist/esm/ta/index.js +296 -348
- package/dist/esm/ta/index.js.map +1 -1
- package/dist/esm/ta/running-sum.d.ts +54 -2
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +166 -71
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/ta-series.d.ts +4 -4
- package/dist/esm/ta-series.d.ts.map +1 -1
- package/dist/esm/ta-series.js +5 -4
- package/dist/esm/ta-series.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/time/datestring.d.ts +1 -0
- package/dist/esm/time/datestring.d.ts.map +1 -1
- package/dist/esm/time/datestring.js +12 -0
- package/dist/esm/time/datestring.js.map +1 -1
- package/dist/esm/time/index.d.ts.map +1 -1
- package/dist/esm/time/index.js +3 -1
- package/dist/esm/time/index.js.map +1 -1
- package/dist/esm/time/session.d.ts +28 -9
- package/dist/esm/time/session.d.ts.map +1 -1
- package/dist/esm/time/session.js +113 -42
- package/dist/esm/time/session.js.map +1 -1
- package/dist/esm/time/timezone.d.ts +5 -0
- package/dist/esm/time/timezone.d.ts.map +1 -1
- package/dist/esm/time/timezone.js +21 -1
- package/dist/esm/time/timezone.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 +364 -150
- package/src/callsite/index.ts +147 -3
- package/src/color/index.ts +15 -5
- 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/label/index.ts +2 -1
- package/src/linefill/index.ts +2 -0
- package/src/math/index.ts +256 -74
- package/src/matrix/index.ts +52 -52
- package/src/polyline/index.ts +3 -12
- package/src/runtime/series.ts +22 -1
- package/src/runtime/types.ts +23 -0
- package/src/script/index.ts +307 -25
- package/src/session/calendar.ts +22 -2
- package/src/str/index.ts +95 -51
- package/src/str/messageformat.ts +7 -2
- package/src/str/numberformat.ts +39 -4
- package/src/ta/index.ts +306 -386
- package/src/ta/running-sum.ts +187 -74
- package/src/ta-series.ts +8 -7
- package/src/table/index.ts +221 -0
- package/src/text/index.ts +18 -2
- package/src/time/datestring.ts +10 -0
- package/src/time/index.ts +3 -1
- package/src/time/session.ts +97 -47
- package/src/time/timezone.ts +21 -1
- package/src/types/index.ts +32 -1
- package/src/types/metadata.ts +325 -26
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table namespace
|
|
3
|
+
* Functions for creating and filling table drawing objects.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A table is drawn at a fixed position of the pane (`position.*`), not at a bar. Tables have no getters in
|
|
7
|
+
* PineScript; the script API returns the live tables in `result.tables`.
|
|
8
|
+
*
|
|
9
|
+
* PineScript rules:
|
|
10
|
+
* - `table.cell` defines a cell: the arguments it does not give get their default, a previous definition of the
|
|
11
|
+
* cell is replaced
|
|
12
|
+
* - `table.cell_set_*` changes one property of a cell (a cell that was not defined is created)
|
|
13
|
+
* - a column or row outside the table is a runtime error
|
|
14
|
+
* - a deleted table is `na`: its functions do nothing
|
|
15
|
+
*
|
|
16
|
+
* @version 6
|
|
17
|
+
*/
|
|
18
|
+
import type { Table, color } from '../types/index.js';
|
|
19
|
+
type TablePosition = Table['position'];
|
|
20
|
+
type HAlign = 'left' | 'center' | 'right';
|
|
21
|
+
type VAlign = 'top' | 'center' | 'bottom';
|
|
22
|
+
type FontFamily = 'default' | 'monospace';
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new table (PineScript `table.new`).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const t = table.new(position.top_right, 2, 3, '#131722', '#787B86', 1);
|
|
29
|
+
* table.cell(t, 0, 0, 'RSI', 0, 0, '#FFFFFF');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function new_table(position: TablePosition, columns: number, rows: number, bgcolor?: color, frame_color?: color, frame_width?: number, border_color?: color, border_width?: number, force_overlay?: boolean): Table;
|
|
33
|
+
/**
|
|
34
|
+
* Defines a cell (PineScript `table.cell`): its text and properties. Omitted properties get their default.
|
|
35
|
+
*/
|
|
36
|
+
export declare function cell(table_id: Table, column: number, row: number, text?: string, width?: number, height?: number, text_color?: color, text_halign?: HAlign, text_valign?: VAlign, text_size?: string | number, bgcolor?: color, tooltip?: string, text_font_family?: FontFamily, text_formatting?: number): void;
|
|
37
|
+
/** Sets the text of a cell. */
|
|
38
|
+
export declare const cell_set_text: (table_id: Table, column: number, row: number, value: string | undefined) => void;
|
|
39
|
+
/** Sets the width of a cell (% of the chart width; 0 fits the text). */
|
|
40
|
+
export declare const cell_set_width: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
41
|
+
/** Sets the height of a cell (% of the chart height; 0 fits the text). */
|
|
42
|
+
export declare const cell_set_height: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
43
|
+
/** Sets the text colour of a cell. */
|
|
44
|
+
export declare const cell_set_text_color: (table_id: Table, column: number, row: number, value: color | undefined) => void;
|
|
45
|
+
/** Sets the horizontal text alignment of a cell. */
|
|
46
|
+
export declare const cell_set_text_halign: (table_id: Table, column: number, row: number, value: "left" | "right" | "center" | undefined) => void;
|
|
47
|
+
/** Sets the vertical text alignment of a cell. */
|
|
48
|
+
export declare const cell_set_text_valign: (table_id: Table, column: number, row: number, value: "center" | "top" | "bottom" | undefined) => void;
|
|
49
|
+
/** Sets the text size of a cell. */
|
|
50
|
+
export declare const cell_set_text_size: (table_id: Table, column: number, row: number, value: string | number | undefined) => void;
|
|
51
|
+
/** Sets the background colour of a cell. */
|
|
52
|
+
export declare const cell_set_bgcolor: (table_id: Table, column: number, row: number, value: color | undefined) => void;
|
|
53
|
+
/** Sets the tooltip of a cell. */
|
|
54
|
+
export declare const cell_set_tooltip: (table_id: Table, column: number, row: number, value: string | undefined) => void;
|
|
55
|
+
/** Sets the font family of a cell. */
|
|
56
|
+
export declare const cell_set_text_font_family: (table_id: Table, column: number, row: number, value: "default" | "monospace" | undefined) => void;
|
|
57
|
+
/** Sets the text formatting of a cell (`text.format_*` flags). */
|
|
58
|
+
export declare const cell_set_text_formatting: (table_id: Table, column: number, row: number, value: number | undefined) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Merges the cells from start_column / start_row to end_column / end_row (PineScript `table.merge_cells`). The
|
|
61
|
+
* merged cell shows the content of the start cell.
|
|
62
|
+
*/
|
|
63
|
+
export declare function merge_cells(table_id: Table, start_column: number, start_row: number, end_column: number, end_row: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Removes the cells from start_column / start_row to end_column / end_row (PineScript `table.clear`; default end:
|
|
66
|
+
* the start cell), and the merges that start in that range.
|
|
67
|
+
*/
|
|
68
|
+
export declare function clear(table_id: Table, start_column: number, start_row: number, end_column?: number, end_row?: number): void;
|
|
69
|
+
/** Moves the table to another position (`position.*`). */
|
|
70
|
+
export declare const set_position: (table_id: Table, value: "top_left" | "top_center" | "top_right" | "middle_left" | "middle_center" | "middle_right" | "bottom_left" | "bottom_center" | "bottom_right") => void;
|
|
71
|
+
/** Sets the background colour of the table. */
|
|
72
|
+
export declare const set_bgcolor: (table_id: Table, value: color | undefined) => void;
|
|
73
|
+
/** Sets the colour of the outer frame. */
|
|
74
|
+
export declare const set_frame_color: (table_id: Table, value: color | undefined) => void;
|
|
75
|
+
/** Sets the width of the outer frame. */
|
|
76
|
+
export declare const set_frame_width: (table_id: Table, value: number | undefined) => void;
|
|
77
|
+
/** Sets the colour of the cell borders. */
|
|
78
|
+
export declare const set_border_color: (table_id: Table, value: color | undefined) => void;
|
|
79
|
+
/** Sets the width of the cell borders. */
|
|
80
|
+
export declare const set_border_width: (table_id: Table, value: number | undefined) => void;
|
|
81
|
+
/** Deletes the table (PineScript `table.delete`). */
|
|
82
|
+
export declare function delete_table(table_id: Table): void;
|
|
83
|
+
/** All live tables, in creation order (PineScript `table.all`). A new array. */
|
|
84
|
+
export declare function all(): Table[];
|
|
85
|
+
export { new_table as new };
|
|
86
|
+
export { delete_table as delete };
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAa,KAAK,EAAE,M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0DAA0D;AAC1D,eAAO,MAAM,YAAY,aAPL,KAAK,2JAAoB,IAOG,CAAC;AACjD,+CAA+C;AAC/C,eAAO,MAAM,WAAW,aATJ,KAAK,+BAAoB,IASC,CAAC;AAC/C,0CAA0C;AAC1C,eAAO,MAAM,eAAe,aAXR,KAAK,+BAAoB,IAWS,CAAC;AACvD,yCAAyC;AACzC,eAAO,MAAM,eAAe,aAbR,KAAK,gCAAoB,IAaS,CAAC;AACvD,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,aAfT,KAAK,+BAAoB,IAeW,CAAC;AACzD,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,aAjBT,KAAK,gCAAoB,IAiBW,CAAC;AAEzD,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAElD;AAED,gFAAgF;AAChF,wBAAgB,GAAG,IAAI,KAAK,EAAE,CAE7B;AAGD,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC;AAC5B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table namespace
|
|
3
|
+
* Functions for creating and filling table drawing objects.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A table is drawn at a fixed position of the pane (`position.*`), not at a bar. Tables have no getters in
|
|
7
|
+
* PineScript; the script API returns the live tables in `result.tables`.
|
|
8
|
+
*
|
|
9
|
+
* PineScript rules:
|
|
10
|
+
* - `table.cell` defines a cell: the arguments it does not give get their default, a previous definition of the
|
|
11
|
+
* cell is replaced
|
|
12
|
+
* - `table.cell_set_*` changes one property of a cell (a cell that was not defined is created)
|
|
13
|
+
* - a column or row outside the table is a runtime error
|
|
14
|
+
* - a deleted table is `na`: its functions do nothing
|
|
15
|
+
*
|
|
16
|
+
* @version 6
|
|
17
|
+
*/
|
|
18
|
+
import { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new table (PineScript `table.new`).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const t = table.new(position.top_right, 2, 3, '#131722', '#787B86', 1);
|
|
25
|
+
* table.cell(t, 0, 0, 'RSI', 0, 0, '#FFFFFF');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function new_table(position, columns, rows, bgcolor, frame_color, frame_width, border_color, border_width, force_overlay) {
|
|
29
|
+
return register('table', {
|
|
30
|
+
position,
|
|
31
|
+
columns,
|
|
32
|
+
rows,
|
|
33
|
+
bgcolor,
|
|
34
|
+
frame_color,
|
|
35
|
+
frame_width,
|
|
36
|
+
border_color,
|
|
37
|
+
border_width,
|
|
38
|
+
force_overlay: force_overlay ?? false,
|
|
39
|
+
cells: new Map(),
|
|
40
|
+
merges: [],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function checkCell(caller, id, column, row) {
|
|
44
|
+
if (!(column >= 0 && column < id.columns && row >= 0 && row < id.rows)) {
|
|
45
|
+
throw new RangeError(`${caller}: column ${column}, row ${row} is outside the table (${id.columns} columns, ${id.rows} rows).`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const key = (column, row) => `${column},${row}`;
|
|
49
|
+
/** The cell at column / row, created when it was not defined. */
|
|
50
|
+
function cellOf(caller, id, column, row) {
|
|
51
|
+
checkCell(caller, id, column, row);
|
|
52
|
+
const cells = (id.cells ??= new Map());
|
|
53
|
+
let cell = cells.get(key(column, row));
|
|
54
|
+
if (!cell)
|
|
55
|
+
cells.set(key(column, row), (cell = { text: '' }));
|
|
56
|
+
return cell;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Defines a cell (PineScript `table.cell`): its text and properties. Omitted properties get their default.
|
|
60
|
+
*/
|
|
61
|
+
export function cell(table_id, column, row, text, width, height, text_color, text_halign, text_valign, text_size, bgcolor, tooltip, text_font_family, text_formatting) {
|
|
62
|
+
if (isDeleted(table_id))
|
|
63
|
+
return;
|
|
64
|
+
checkCell('table.cell()', table_id, column, row);
|
|
65
|
+
(table_id.cells ??= new Map()).set(key(column, row), {
|
|
66
|
+
text: text ?? '',
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
text_color,
|
|
70
|
+
text_halign,
|
|
71
|
+
text_valign,
|
|
72
|
+
text_size,
|
|
73
|
+
bgcolor,
|
|
74
|
+
tooltip,
|
|
75
|
+
text_font_family,
|
|
76
|
+
text_formatting,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function setCell(name, field) {
|
|
80
|
+
return (table_id, column, row, value) => {
|
|
81
|
+
if (isDeleted(table_id))
|
|
82
|
+
return;
|
|
83
|
+
cellOf(`table.${name}()`, table_id, column, row)[field] = value;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Sets the text of a cell. */
|
|
87
|
+
export const cell_set_text = setCell('cell_set_text', 'text');
|
|
88
|
+
/** Sets the width of a cell (% of the chart width; 0 fits the text). */
|
|
89
|
+
export const cell_set_width = setCell('cell_set_width', 'width');
|
|
90
|
+
/** Sets the height of a cell (% of the chart height; 0 fits the text). */
|
|
91
|
+
export const cell_set_height = setCell('cell_set_height', 'height');
|
|
92
|
+
/** Sets the text colour of a cell. */
|
|
93
|
+
export const cell_set_text_color = setCell('cell_set_text_color', 'text_color');
|
|
94
|
+
/** Sets the horizontal text alignment of a cell. */
|
|
95
|
+
export const cell_set_text_halign = setCell('cell_set_text_halign', 'text_halign');
|
|
96
|
+
/** Sets the vertical text alignment of a cell. */
|
|
97
|
+
export const cell_set_text_valign = setCell('cell_set_text_valign', 'text_valign');
|
|
98
|
+
/** Sets the text size of a cell. */
|
|
99
|
+
export const cell_set_text_size = setCell('cell_set_text_size', 'text_size');
|
|
100
|
+
/** Sets the background colour of a cell. */
|
|
101
|
+
export const cell_set_bgcolor = setCell('cell_set_bgcolor', 'bgcolor');
|
|
102
|
+
/** Sets the tooltip of a cell. */
|
|
103
|
+
export const cell_set_tooltip = setCell('cell_set_tooltip', 'tooltip');
|
|
104
|
+
/** Sets the font family of a cell. */
|
|
105
|
+
export const cell_set_text_font_family = setCell('cell_set_text_font_family', 'text_font_family');
|
|
106
|
+
/** Sets the text formatting of a cell (`text.format_*` flags). */
|
|
107
|
+
export const cell_set_text_formatting = setCell('cell_set_text_formatting', 'text_formatting');
|
|
108
|
+
/**
|
|
109
|
+
* Merges the cells from start_column / start_row to end_column / end_row (PineScript `table.merge_cells`). The
|
|
110
|
+
* merged cell shows the content of the start cell.
|
|
111
|
+
*/
|
|
112
|
+
export function merge_cells(table_id, start_column, start_row, end_column, end_row) {
|
|
113
|
+
if (isDeleted(table_id))
|
|
114
|
+
return;
|
|
115
|
+
checkCell('table.merge_cells()', table_id, start_column, start_row);
|
|
116
|
+
checkCell('table.merge_cells()', table_id, end_column, end_row);
|
|
117
|
+
if (end_column < start_column || end_row < start_row) {
|
|
118
|
+
throw new RangeError('table.merge_cells(): the end cell is before the start cell.');
|
|
119
|
+
}
|
|
120
|
+
(table_id.merges ??= []).push({ start_column, start_row, end_column, end_row });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Removes the cells from start_column / start_row to end_column / end_row (PineScript `table.clear`; default end:
|
|
124
|
+
* the start cell), and the merges that start in that range.
|
|
125
|
+
*/
|
|
126
|
+
export function clear(table_id, start_column, start_row, end_column = start_column, end_row = start_row) {
|
|
127
|
+
if (isDeleted(table_id))
|
|
128
|
+
return;
|
|
129
|
+
checkCell('table.clear()', table_id, start_column, start_row);
|
|
130
|
+
checkCell('table.clear()', table_id, end_column, end_row);
|
|
131
|
+
const inside = (column, row) => column >= start_column && column <= end_column && row >= start_row && row <= end_row;
|
|
132
|
+
for (let column = start_column; column <= end_column; column++) {
|
|
133
|
+
for (let row = start_row; row <= end_row; row++)
|
|
134
|
+
table_id.cells?.delete(key(column, row));
|
|
135
|
+
}
|
|
136
|
+
if (table_id.merges)
|
|
137
|
+
table_id.merges = table_id.merges.filter((m) => !inside(m.start_column, m.start_row));
|
|
138
|
+
}
|
|
139
|
+
function setTable(field) {
|
|
140
|
+
return (table_id, value) => {
|
|
141
|
+
if (isDeleted(table_id))
|
|
142
|
+
return;
|
|
143
|
+
table_id[field] = value;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/** Moves the table to another position (`position.*`). */
|
|
147
|
+
export const set_position = setTable('position');
|
|
148
|
+
/** Sets the background colour of the table. */
|
|
149
|
+
export const set_bgcolor = setTable('bgcolor');
|
|
150
|
+
/** Sets the colour of the outer frame. */
|
|
151
|
+
export const set_frame_color = setTable('frame_color');
|
|
152
|
+
/** Sets the width of the outer frame. */
|
|
153
|
+
export const set_frame_width = setTable('frame_width');
|
|
154
|
+
/** Sets the colour of the cell borders. */
|
|
155
|
+
export const set_border_color = setTable('border_color');
|
|
156
|
+
/** Sets the width of the cell borders. */
|
|
157
|
+
export const set_border_width = setTable('border_width');
|
|
158
|
+
/** Deletes the table (PineScript `table.delete`). */
|
|
159
|
+
export function delete_table(table_id) {
|
|
160
|
+
remove('table', table_id);
|
|
161
|
+
}
|
|
162
|
+
/** All live tables, in creation order (PineScript `table.all`). A new array. */
|
|
163
|
+
export function all() {
|
|
164
|
+
return allDrawings('table');
|
|
165
|
+
}
|
|
166
|
+
// Alias to match PineScript API
|
|
167
|
+
export { new_table as new };
|
|
168
|
+
export { delete_table as delete };
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAQzF;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,QAAuB,EACvB,OAAe,EACf,IAAY,E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AQ;IAC/C,OAAO,CAAC,QAAe,EAAE,KAAe,EAAQ,EAAE;QAChD,IAAI,SAAS,CAAC,QAAQ,CAAC;YAAE,OAAO;QAChC,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AACjD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC/C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AACvD,yCAAyC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AACvD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AACzD,0CAA0C;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AAEzD,qDAAqD;AACrD,MAAM,UAAU,YAAY,CAAC,QAAe;IAC1C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5B,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,GAAG;IACjB,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,gCAAgC;AAChC,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC;AAC5B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC"}
|
package/dist/esm/text/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Text namespace
|
|
3
|
-
* PineScript `text.format_*` constants for `label.set_text_formatting` and `box.set_text_formatting
|
|
3
|
+
* PineScript `text.format_*` constants for `label.set_text_formatting` and `box.set_text_formatting`, and the
|
|
4
|
+
* `text.align_*` / `text.wrap_*` constants.
|
|
4
5
|
*
|
|
5
|
-
* The values are flags that add up, as in PineScript (`text.format_bold + text.format_italic`).
|
|
6
|
+
* The format values are flags that add up, as in PineScript (`text.format_bold + text.format_italic`).
|
|
6
7
|
* They are the values PineScript uses for drawn labels and boxes.
|
|
7
8
|
*/
|
|
8
9
|
/** No formatting. */
|
|
@@ -11,4 +12,18 @@ export declare const format_none = 0;
|
|
|
11
12
|
export declare const format_bold = 1;
|
|
12
13
|
/** Italic text. */
|
|
13
14
|
export declare const format_italic = 2;
|
|
15
|
+
/** Text aligned to the left (`table.cell`, `box.new`, `label.new` textalign). */
|
|
16
|
+
export declare const align_left: "left";
|
|
17
|
+
/** Text centred horizontally or vertically. */
|
|
18
|
+
export declare const align_center: "center";
|
|
19
|
+
/** Text aligned to the right. */
|
|
20
|
+
export declare const align_right: "right";
|
|
21
|
+
/** Text aligned to the top (`table.cell`, `box.new` text_valign). */
|
|
22
|
+
export declare const align_top: "top";
|
|
23
|
+
/** Text aligned to the bottom. */
|
|
24
|
+
export declare const align_bottom: "bottom";
|
|
25
|
+
/** Text wrapped to the box width (`box.new` text_wrap). */
|
|
26
|
+
export declare const wrap_auto: "auto";
|
|
27
|
+
/** Text not wrapped. */
|
|
28
|
+
export declare const wrap_none: "none";
|
|
14
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/text/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/text/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAqB;AACrB,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,iBAAiB;AACjB,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,mBAAmB;AACnB,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,iFAAiF;AACjF,eAAO,MAAM,UAAU,EAAG,MAAe,CAAC;AAC1C,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,QAAiB,CAAC;AAC9C,iCAAiC;AACjC,eAAO,MAAM,WAAW,EAAG,OAAgB,CAAC;AAC5C,qEAAqE;AACrE,eAAO,MAAM,SAAS,EAAG,KAAc,CAAC;AACxC,kCAAkC;AAClC,eAAO,MAAM,YAAY,EAAG,QAAiB,CAAC;AAC9C,2DAA2D;AAC3D,eAAO,MAAM,SAAS,EAAG,MAAe,CAAC;AACzC,wBAAwB;AACxB,eAAO,MAAM,SAAS,EAAG,MAAe,CAAC"}
|
package/dist/esm/text/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Text namespace
|
|
3
|
-
* PineScript `text.format_*` constants for `label.set_text_formatting` and `box.set_text_formatting
|
|
3
|
+
* PineScript `text.format_*` constants for `label.set_text_formatting` and `box.set_text_formatting`, and the
|
|
4
|
+
* `text.align_*` / `text.wrap_*` constants.
|
|
4
5
|
*
|
|
5
|
-
* The values are flags that add up, as in PineScript (`text.format_bold + text.format_italic`).
|
|
6
|
+
* The format values are flags that add up, as in PineScript (`text.format_bold + text.format_italic`).
|
|
6
7
|
* They are the values PineScript uses for drawn labels and boxes.
|
|
7
8
|
*/
|
|
8
9
|
/** No formatting. */
|
|
@@ -11,4 +12,18 @@ export const format_none = 0;
|
|
|
11
12
|
export const format_bold = 1;
|
|
12
13
|
/** Italic text. */
|
|
13
14
|
export const format_italic = 2;
|
|
15
|
+
/** Text aligned to the left (`table.cell`, `box.new`, `label.new` textalign). */
|
|
16
|
+
export const align_left = 'left';
|
|
17
|
+
/** Text centred horizontally or vertically. */
|
|
18
|
+
export const align_center = 'center';
|
|
19
|
+
/** Text aligned to the right. */
|
|
20
|
+
export const align_right = 'right';
|
|
21
|
+
/** Text aligned to the top (`table.cell`, `box.new` text_valign). */
|
|
22
|
+
export const align_top = 'top';
|
|
23
|
+
/** Text aligned to the bottom. */
|
|
24
|
+
export const align_bottom = 'bottom';
|
|
25
|
+
/** Text wrapped to the box width (`box.new` text_wrap). */
|
|
26
|
+
export const wrap_auto = 'auto';
|
|
27
|
+
/** Text not wrapped. */
|
|
28
|
+
export const wrap_none = 'none';
|
|
14
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/text/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/text/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAqB;AACrB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,iBAAiB;AACjB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,mBAAmB;AACnB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,iFAAiF;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAe,CAAC;AAC1C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAiB,CAAC;AAC9C,iCAAiC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAgB,CAAC;AAC5C,qEAAqE;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG,KAAc,CAAC;AACxC,kCAAkC;AAClC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAiB,CAAC;AAC9C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAG,MAAe,CAAC;AACzC,wBAAwB;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,MAAe,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Time zones: "UT", "UTC", "GMT", "+0530", "-05:00", "GMT+5", "UTC-0300", and the RFC 2822
|
|
11
11
|
* names EST, EDT, CST, CDT, MST, MDT, PST, PDT. After a "T" time, only numeric offsets.
|
|
12
12
|
* Without a time the time is 00:00. Without a time zone the time zone is GMT+0.
|
|
13
|
+
* "2025" and "2025-06" are the first day of the year / month. "01 Jan 2022 GMT+3" (a zone without a time) gives na.
|
|
13
14
|
* "24:00" is midnight at the end of the day.
|
|
14
15
|
*
|
|
15
16
|
* "Z", "2024-01-01T09:30:00 GMT", "24:30" and "09:30:60" are compile errors in PineScript, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datestring.d.ts","sourceRoot":"","sources":["../../../src/time/datestring.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"datestring.d.ts","sourceRoot":"","sources":["../../../src/time/datestring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA6CH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAuC1D"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Time zones: "UT", "UTC", "GMT", "+0530", "-05:00", "GMT+5", "UTC-0300", and the RFC 2822
|
|
11
11
|
* names EST, EDT, CST, CDT, MST, MDT, PST, PDT. After a "T" time, only numeric offsets.
|
|
12
12
|
* Without a time the time is 00:00. Without a time zone the time zone is GMT+0.
|
|
13
|
+
* "2025" and "2025-06" are the first day of the year / month. "01 Jan 2022 GMT+3" (a zone without a time) gives na.
|
|
13
14
|
* "24:00" is midnight at the end of the day.
|
|
14
15
|
*
|
|
15
16
|
* "Z", "2024-01-01T09:30:00 GMT", "24:30" and "09:30:60" are compile errors in PineScript, and
|
|
@@ -30,6 +31,7 @@ const ZONE = String.raw `(ut|utc|gmt|[ecmp][sd]t|(?:utc|gmt)?\s*[+-]\d{1,2}(?::?
|
|
|
30
31
|
const NUMERIC_ZONE = String.raw `([+-]\d{2}(?::?\d{2})?)`;
|
|
31
32
|
const DATE = String.raw `(\d{4})([-/])(\d{1,2})\2(\d{1,2})`;
|
|
32
33
|
const WEEKDAY = String.raw `(?:[a-z]{3,9},?\s+)?`;
|
|
34
|
+
const YEAR_MONTH = /^(\d{4})(?:-(\d{1,2}))?$/;
|
|
33
35
|
const ISO_T = new RegExp(String.raw `^${DATE}t${TIME}\s*${NUMERIC_ZONE}?$`, 'i');
|
|
34
36
|
const ISO = new RegExp(String.raw `^${DATE}(?:\s+${TIME})?\s*${ZONE}?$`, 'i');
|
|
35
37
|
const DAY_FIRST = new RegExp(String.raw `^${WEEKDAY}(\d{1,2})(?:\s+|-)([a-z]+)\.?,?(?:\s+|-)(\d{4})(?:,?\s+${TIME})?\s*${ZONE}?$`, 'i');
|
|
@@ -63,6 +65,13 @@ export function parseDateString(dateString) {
|
|
|
63
65
|
let year, month, day;
|
|
64
66
|
let rest;
|
|
65
67
|
let m;
|
|
68
|
+
// "2025" and "2025-06": the first day of the year / month, 00:00 UTC (PineScript)
|
|
69
|
+
if ((m = YEAR_MONTH.exec(text))) {
|
|
70
|
+
const mo = m[2] ? Number(m[2]) : 1;
|
|
71
|
+
if (mo < 1 || mo > 12)
|
|
72
|
+
throw new SyntaxError(`Invalid date string "${dateString}": a field is out of range`);
|
|
73
|
+
return Date.UTC(Number(m[1]), mo - 1, 1);
|
|
74
|
+
}
|
|
66
75
|
if ((m = ISO_T.exec(text) ?? ISO.exec(text))) {
|
|
67
76
|
[year, month, day] = [m[1], Number(m[3]), m[4]];
|
|
68
77
|
rest = m.slice(5);
|
|
@@ -70,6 +79,9 @@ export function parseDateString(dateString) {
|
|
|
70
79
|
else if ((m = DAY_FIRST.exec(text))) {
|
|
71
80
|
[day, month, year] = [m[1], monthNumber(m[2]), m[3]];
|
|
72
81
|
rest = m.slice(4);
|
|
82
|
+
// a time zone without a time ("01 Jan 2022 GMT+3") gives na in PineScript
|
|
83
|
+
if (rest[0] === undefined && rest[4] !== undefined)
|
|
84
|
+
return NaN;
|
|
73
85
|
}
|
|
74
86
|
else if ((m = MONTH_FIRST.exec(text))) {
|
|
75
87
|
[month, day, year] = [monthNumber(m[1]), m[2], m[3]];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datestring.js","sourceRoot":"","sources":["../../../src/time/datestring.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"datestring.js","sourceRoot":"","sources":["../../../src/time/datestring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACpG,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM;IACtD,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU;CACjE,CAAC;AAEF,uDAAuD;AACvD,MAAM,UAAU,GAA2B;IACzC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;IACrB,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;CACvE,CAAC;AAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,mDAAmD,CAAC;AAC3E,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,iEAAiE,CAAC;AACzF,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA,yBAAyB,CAAC;AACzD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,mCAAmC,CAAC;AAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA,sBAAsB,CAAC;AAEjD,MAAM,UAAU,G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AK,EAAE,UAAU,EACjB,GAAG,EAAE,UAAU,EACf,IAAI,CAAC,EAAE,UAAU,EACjB,MAAM,CAAC,EAAE,UAAU,EACnB,MAAM,CAAC,EAAE,UAAU,GAClB,GAAG,CAAC;AAmBP;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAErD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAEtD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAE3D;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAQ3D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAErD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAEvD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAEvD;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/E"}
|
package/dist/esm/time/index.js
CHANGED
|
@@ -19,8 +19,10 @@ export function timestamp(first, ...rest) {
|
|
|
19
19
|
if (typeof first === 'string') {
|
|
20
20
|
if (rest.length === 0)
|
|
21
21
|
return parseDateString(first);
|
|
22
|
+
// PineScript: an na field counts as 0 (day na of January 2020 is 2019-12-31)
|
|
23
|
+
const f = (v) => (v === undefined || v === null || Number.isNaN(v) ? 0 : v);
|
|
22
24
|
const [year, month, day, hour, minute, second] = rest;
|
|
23
|
-
return zonedToUnix(first, year, month, day, hour
|
|
25
|
+
return zonedToUnix(first, f(year), f(month), f(day), f(hour), f(minute), f(second));
|
|
24
26
|
}
|
|
25
27
|
const [month, day, hour, minute, second] = rest;
|
|
26
28
|
return new Date(first, month - 1, day, hour || 0, minute || 0, second || 0).getTime();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC;AAyCD,MAAM,UAAU,SAAS,CAAC,KAA0B,EAAE,GAAG,IAAmC;IAC1F,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAA2D,CAAC;QAC7G,OAAO,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,WAA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EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PineScript session strings ("0930-1600", "0930-1600:23456", "1000-1100,1400-1500:23456", "0930-1600|1000-1300:7",
|
|
3
|
+
* "24x7").
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* - a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Grammar (measured on PineScript): `range[,range...][:days]`, several sections joined by "|".
|
|
6
|
+
* - a range is exactly "HHMM-HHMM"; hours and minutes are minute counts taken modulo one day ("0930-2500" runs
|
|
7
|
+
* 09:30 to 01:00, "0960-1600" 10:00 to 16:00); a start of 24:00 or later must open a run of at most a day
|
|
8
|
+
* - days are digits 1 (Sunday) to 7 (Saturday), the day each run ends on
|
|
9
|
+
* - a lone range without days runs every day; otherwise a section without days is the default section, which runs
|
|
10
|
+
* on the weekdays (2-6) no other section names, and a later section naming a day replaces the earlier ones on that
|
|
11
|
+
* day ("1100-1400|1200-1300:7": 11:00-14:00 Monday to Friday, 12:00-13:00 Saturday)
|
|
12
|
+
* - a trailing ",", ":" or "|" ends its list ("1100-1400," is "1100-1400" Monday to Friday)
|
|
13
|
+
* - an end before the start is an overnight run that belongs to the day it ends; equal ends are 24 hours;
|
|
14
|
+
* "0000-0000" and "24x7" are the whole day, every day
|
|
15
|
+
* - a string that is empty or does not start with a digit ("regular", "extended") is the symbol's own session
|
|
16
|
+
* - a malformed string ("1100 -1400", "0930-16", ":8") is an error, as the PineScript runtime error
|
|
11
17
|
*/
|
|
18
|
+
/** A run of a session: minutes after midnight (0-1439) and the days it ends on (1 = Sunday ... 7 = Saturday). */
|
|
19
|
+
export interface SessionRange {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
days: Set<number>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs of a PineScript session string, or null for the symbol's own session (empty or not starting with a digit).
|
|
26
|
+
* @throws SyntaxError when the string is malformed (a PineScript runtime error)
|
|
27
|
+
*/
|
|
28
|
+
export declare function parsePineSession(session: string): SessionRange[] | null;
|
|
12
29
|
/**
|
|
13
30
|
* True when `time` falls inside `session`, with the session hours read in `timezone`.
|
|
14
|
-
* A
|
|
31
|
+
* A run includes its start minute and excludes its end minute.
|
|
32
|
+
* @throws Error for the symbol's own session ("regular", "extended", ""), which this function does not know: use
|
|
33
|
+
* `time(timeframe, session)` in a script with the chart session
|
|
15
34
|
*/
|
|
16
35
|
export declare function inSession(time: number, session: string, timezone: string): boolean;
|
|
17
36
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/time/session.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/time/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH,iHAAiH;AACjH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnB;AA+BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,IAAI,CAuCvE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAiBlF"}
|