pinets 0.5.0 → 0.7.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 +150 -35
- package/dist/pinets.min.browser.es.js +117 -0
- package/dist/pinets.min.browser.es.js.map +1 -0
- package/dist/pinets.min.browser.js +96 -15
- package/dist/pinets.min.browser.js.map +1 -0
- package/dist/pinets.min.cjs +96 -14
- package/dist/pinets.min.cjs.map +1 -0
- package/dist/pinets.min.es.js +99 -4
- package/dist/pinets.min.es.js.map +1 -0
- package/dist/types/Context.class.d.ts +7 -13
- package/dist/types/PineTS.class.d.ts +2 -0
- package/dist/types/marketData/Binance/BinanceProvider.class.d.ts +2 -1
- package/dist/types/marketData/IProvider.d.ts +43 -0
- package/dist/types/marketData/Mock/MockProvider.class.d.ts +13 -1
- package/dist/types/namespaces/Barstate.d.ts +13 -0
- package/dist/types/namespaces/Core.d.ts +23 -3
- package/dist/types/namespaces/Log.d.ts +10 -0
- package/dist/types/namespaces/Plot.helper.d.ts +16 -0
- package/dist/types/namespaces/Plots.d.ts +16 -0
- package/dist/types/namespaces/Str.d.ts +23 -0
- package/dist/types/namespaces/Timeframe.d.ts +17 -0
- package/dist/types/namespaces/Types.d.ts +86 -0
- package/dist/types/namespaces/array/PineArrayObject.d.ts +102 -1
- package/dist/types/namespaces/array/array.index.d.ts +1 -129
- package/dist/types/namespaces/array/methods/avg.d.ts +2 -1
- package/dist/types/namespaces/array/methods/binary_search.d.ts +2 -0
- package/dist/types/namespaces/array/methods/binary_search_leftmost.d.ts +2 -0
- package/dist/types/namespaces/array/methods/binary_search_rightmost.d.ts +2 -0
- package/dist/types/namespaces/array/methods/covariance.d.ts +2 -1
- package/dist/types/namespaces/array/methods/every.d.ts +1 -1
- package/dist/types/namespaces/array/methods/fill.d.ts +2 -1
- package/dist/types/namespaces/array/methods/join.d.ts +5 -0
- package/dist/types/namespaces/array/methods/median.d.ts +2 -0
- package/dist/types/namespaces/array/methods/mode.d.ts +2 -0
- package/dist/types/namespaces/array/methods/new.d.ts +2 -1
- package/dist/types/namespaces/array/methods/new_float.d.ts +2 -1
- package/dist/types/namespaces/array/methods/new_int.d.ts +2 -1
- package/dist/types/namespaces/array/methods/percentile_linear_interpolation.d.ts +3 -0
- package/dist/types/namespaces/array/methods/percentile_nearest_rank.d.ts +2 -0
- package/dist/types/namespaces/array/methods/percentrank.d.ts +2 -0
- package/dist/types/namespaces/array/methods/push.d.ts +2 -1
- package/dist/types/namespaces/array/methods/range.d.ts +2 -1
- package/dist/types/namespaces/array/methods/set.d.ts +2 -1
- package/dist/types/namespaces/array/methods/some.d.ts +1 -1
- package/dist/types/namespaces/array/methods/sort.d.ts +2 -1
- package/dist/types/namespaces/array/methods/sort_indices.d.ts +2 -1
- package/dist/types/namespaces/array/methods/stdev.d.ts +2 -1
- package/dist/types/namespaces/array/methods/sum.d.ts +2 -1
- package/dist/types/namespaces/array/methods/unshift.d.ts +2 -1
- package/dist/types/namespaces/array/methods/variance.d.ts +2 -1
- package/dist/types/namespaces/array/utils.d.ts +5 -0
- package/dist/types/namespaces/input/methods/any.d.ts +1 -2
- package/dist/types/namespaces/input/methods/bool.d.ts +1 -2
- package/dist/types/namespaces/input/methods/color.d.ts +1 -2
- package/dist/types/namespaces/input/methods/enum.d.ts +1 -2
- package/dist/types/namespaces/input/methods/float.d.ts +1 -2
- package/dist/types/namespaces/input/methods/int.d.ts +1 -2
- package/dist/types/namespaces/input/methods/param.d.ts +1 -1
- package/dist/types/namespaces/input/methods/price.d.ts +1 -2
- package/dist/types/namespaces/input/methods/session.d.ts +1 -2
- package/dist/types/namespaces/input/methods/source.d.ts +1 -2
- package/dist/types/namespaces/input/methods/string.d.ts +1 -2
- package/dist/types/namespaces/input/methods/symbol.d.ts +1 -2
- package/dist/types/namespaces/input/methods/text_area.d.ts +1 -2
- package/dist/types/namespaces/input/methods/time.d.ts +1 -2
- package/dist/types/namespaces/input/methods/timeframe.d.ts +1 -2
- package/dist/types/namespaces/input/types.d.ts +12 -1
- package/dist/types/namespaces/input/utils.d.ts +2 -0
- package/dist/types/namespaces/map/PineMapObject.d.ts +26 -0
- package/dist/types/namespaces/map/map.index.d.ts +7 -0
- package/dist/types/namespaces/map/methods/clear.d.ts +3 -0
- package/dist/types/namespaces/map/methods/contains.d.ts +3 -0
- package/dist/types/namespaces/map/methods/copy.d.ts +3 -0
- package/dist/types/namespaces/map/methods/get.d.ts +3 -0
- package/dist/types/namespaces/map/methods/keys.d.ts +4 -0
- package/dist/types/namespaces/map/methods/new.d.ts +3 -0
- package/dist/types/namespaces/map/methods/param.d.ts +1 -0
- package/dist/types/namespaces/map/methods/put.d.ts +3 -0
- package/dist/types/namespaces/map/methods/put_all.d.ts +3 -0
- package/dist/types/namespaces/map/methods/remove.d.ts +3 -0
- package/dist/types/namespaces/map/methods/size.d.ts +3 -0
- package/dist/types/namespaces/map/methods/values.d.ts +4 -0
- package/dist/types/namespaces/math/math.index.d.ts +18 -0
- package/dist/types/namespaces/math/methods/abs.d.ts +2 -1
- package/dist/types/namespaces/math/methods/e.d.ts +5 -0
- package/dist/types/namespaces/math/methods/phi.d.ts +5 -0
- package/dist/types/namespaces/math/methods/pi.d.ts +5 -0
- package/dist/types/namespaces/math/methods/round_to_mintick.d.ts +2 -0
- package/dist/types/namespaces/math/methods/rphi.d.ts +5 -0
- package/dist/types/namespaces/math/methods/sign.d.ts +2 -0
- package/dist/types/namespaces/matrix/PineMatrixObject.d.ts +102 -0
- package/dist/types/namespaces/matrix/matrix.index.d.ts +7 -0
- package/dist/types/namespaces/matrix/methods/add_col.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/add_row.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/avg.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/col.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/columns.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/concat.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/copy.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/det.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/diff.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/eigenvalues.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/eigenvectors.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/elements_count.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/fill.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/get.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/inv.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_antidiagonal.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_antisymmetric.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_binary.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_diagonal.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_identity.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_square.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_stochastic.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_symmetric.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_triangular.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/is_zero.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/kron.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/max.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/median.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/min.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/mode.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/mult.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/new.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/param.d.ts +1 -0
- package/dist/types/namespaces/matrix/methods/pinv.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/pow.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/rank.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/remove_col.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/remove_row.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/reshape.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/reverse.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/row.d.ts +4 -0
- package/dist/types/namespaces/matrix/methods/rows.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/set.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/sort.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/submatrix.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/sum.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/swap_columns.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/swap_rows.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/trace.d.ts +3 -0
- package/dist/types/namespaces/matrix/methods/transpose.d.ts +3 -0
- package/dist/types/namespaces/request/methods/security_lower_tf.d.ts +9 -0
- package/dist/types/namespaces/request/request.index.d.ts +3 -0
- package/dist/types/namespaces/ta/methods/atr.d.ts +2 -1
- package/dist/types/namespaces/ta/methods/pivothigh.d.ts +1 -1
- package/dist/types/namespaces/ta/methods/pivotlow.d.ts +1 -1
- package/dist/types/namespaces/ta/methods/tr.d.ts +2 -1
- package/dist/types/namespaces/utils.d.ts +12 -0
- package/dist/types/transpiler/index.d.ts +1 -1
- package/dist/types/transpiler/pineToJS/ast.d.ts +167 -0
- package/dist/types/transpiler/pineToJS/codegen.d.ts +53 -0
- package/dist/types/transpiler/pineToJS/lexer.d.ts +31 -0
- package/dist/types/transpiler/pineToJS/parser.d.ts +45 -0
- package/dist/types/transpiler/pineToJS/pineToJS.index.d.ts +32 -0
- package/dist/types/transpiler/pineToJS/tokens.d.ts +34 -0
- package/dist/types/transpiler/settings.d.ts +6 -0
- package/dist/types/transpiler/transformers/WrapperTransformer.d.ts +5 -3
- package/dist/types/transpiler/utils/ASTFactory.d.ts +1 -0
- package/dist/types/types/PineTypes.d.ts +30 -15
- package/package.json +27 -6
- package/dist/pinets.dev.browser.js +0 -13887
- package/dist/pinets.dev.cjs +0 -14024
- package/dist/pinets.dev.cjs.map +0 -1
- package/dist/pinets.dev.es.js +0 -6375
- package/dist/pinets.dev.es.js.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PineMatrixObject } from '../PineMatrixObject';
|
|
2
|
+
import { Context } from '../../../Context.class';
|
|
3
|
+
import { PineArrayObject } from '../../array/PineArrayObject';
|
|
4
|
+
export declare function mult(context: Context): (id: PineMatrixObject, id2: PineMatrixObject | number | PineArrayObject) => PineMatrixObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function param(context: any): (source: any, index?: number) => any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PineMatrixObject } from '../PineMatrixObject';
|
|
2
|
+
import { Context } from '../../../Context.class';
|
|
3
|
+
import { PineArrayObject } from '../../array/PineArrayObject';
|
|
4
|
+
export declare function remove_col(context: Context): (id: PineMatrixObject, column_index: number) => PineArrayObject;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PineMatrixObject } from '../PineMatrixObject';
|
|
2
|
+
import { Context } from '../../../Context.class';
|
|
3
|
+
import { PineArrayObject } from '../../array/PineArrayObject';
|
|
4
|
+
export declare function remove_row(context: Context): (id: PineMatrixObject, row_index: number) => PineArrayObject;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PineMatrixObject } from '../PineMatrixObject';
|
|
2
|
+
import { Context } from '../../../Context.class';
|
|
3
|
+
import { PineArrayObject } from '../../array/PineArrayObject';
|
|
4
|
+
export declare function row(context: Context): (id: PineMatrixObject, row: number) => PineArrayObject;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requests the results of an expression from a specified symbol on a timeframe lower than or equal to the chart's timeframe.
|
|
3
|
+
* It returns an array containing one element for each lower-timeframe bar within the chart bar.
|
|
4
|
+
* On a 5-minute chart, requesting data using a timeframe argument of "1" typically returns an array with five elements representing
|
|
5
|
+
* the value of the expression on each 1-minute bar, ordered by time with the earliest value first.
|
|
6
|
+
* @param context
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function security_lower_tf(context: any): (symbol: any, timeframe: any, expression: any, ignore_invalid_symbol?: boolean | any[], currency?: any, ignore_invalid_timeframe?: boolean | any[], calc_bars_count?: number | any[]) => Promise<any>;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { param } from './methods/param';
|
|
2
2
|
import { security } from './methods/security';
|
|
3
|
+
import { security_lower_tf } from './methods/security_lower_tf';
|
|
3
4
|
declare const methods: {
|
|
4
5
|
param: typeof param;
|
|
5
6
|
security: typeof security;
|
|
7
|
+
security_lower_tf: typeof security_lower_tf;
|
|
6
8
|
};
|
|
7
9
|
export declare class PineRequest {
|
|
8
10
|
private context;
|
|
9
11
|
private _cache;
|
|
10
12
|
param: ReturnType<typeof methods.param>;
|
|
11
13
|
security: ReturnType<typeof methods.security>;
|
|
14
|
+
security_lower_tf: ReturnType<typeof methods.security_lower_tf>;
|
|
12
15
|
constructor(context: any);
|
|
13
16
|
}
|
|
14
17
|
export default PineRequest;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Series } from '../../../Series';
|
|
2
|
+
export declare function atr(context: any): (length: number) => Series;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function pivothigh(context: any): (source: any, _leftbars: any, _rightbars: any) => any;
|
|
1
|
+
export declare function pivothigh(context: any): (source: any, _leftbars: any, _rightbars: any, _callId?: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function pivotlow(context: any): (source: any, _leftbars: any, _rightbars: any) => any;
|
|
1
|
+
export declare function pivotlow(context: any): (source: any, _leftbars: any, _rightbars: any, _callId?: string) => any;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Context } from '../../../Context.class';
|
|
2
|
+
export declare function tr(context: Context): (handle_na?: boolean, _callId?: string) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Series } from '../Series';
|
|
2
|
+
export type PineTypeMap<T> = {
|
|
3
|
+
[K in keyof T]-?: T[K] extends number ? 'number' : T[K] extends string ? 'string' : T[K] extends boolean ? 'boolean' : T[K] extends Series ? 'series' : T[K] extends Array<any> ? 'array' : never;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* This function is used to parse the arguments for a Pine params.
|
|
7
|
+
* @param args - The arguments to parse.
|
|
8
|
+
* @param signatures - The signatures to parse, each signature is an array of argument names.
|
|
9
|
+
* @param types - The types to parse, each type is a string representing the type of the argument.
|
|
10
|
+
* @returns The parsed arguments, the arguments are parsed according to the signatures and types.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseArgsForPineParams<T>(args: any[], signatures: any[], types: Record<string, string>): Partial<T> & T;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export declare class ASTNode {
|
|
2
|
+
type: string;
|
|
3
|
+
constructor(type: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class Program extends ASTNode {
|
|
6
|
+
body: any[];
|
|
7
|
+
constructor(body: any[]);
|
|
8
|
+
}
|
|
9
|
+
export declare class ExpressionStatement extends ASTNode {
|
|
10
|
+
expression: any;
|
|
11
|
+
constructor(expression: any);
|
|
12
|
+
}
|
|
13
|
+
export declare enum VariableDeclarationKind {
|
|
14
|
+
VAR = "var",
|
|
15
|
+
LET = "let",
|
|
16
|
+
CONST = "const"
|
|
17
|
+
}
|
|
18
|
+
export declare class VariableDeclaration extends ASTNode {
|
|
19
|
+
declarations: any[];
|
|
20
|
+
kind: VariableDeclarationKind;
|
|
21
|
+
constructor(declarations: any[], kind?: VariableDeclarationKind);
|
|
22
|
+
}
|
|
23
|
+
export declare class VariableDeclarator extends ASTNode {
|
|
24
|
+
id: any;
|
|
25
|
+
init: any;
|
|
26
|
+
varType: any;
|
|
27
|
+
constructor(id: any, init: any, varType?: any);
|
|
28
|
+
}
|
|
29
|
+
export declare class FunctionDeclaration extends ASTNode {
|
|
30
|
+
id: any;
|
|
31
|
+
params: any[];
|
|
32
|
+
body: any;
|
|
33
|
+
returnType: any;
|
|
34
|
+
constructor(id: any, params: any[], body: any, returnType?: any);
|
|
35
|
+
}
|
|
36
|
+
export declare class TypeDefinition extends ASTNode {
|
|
37
|
+
name: string;
|
|
38
|
+
fields: any[];
|
|
39
|
+
constructor(name: string, fields: any[]);
|
|
40
|
+
}
|
|
41
|
+
export declare class IfStatement extends ASTNode {
|
|
42
|
+
test: any;
|
|
43
|
+
consequent: any;
|
|
44
|
+
alternate: any | null;
|
|
45
|
+
_line: number;
|
|
46
|
+
constructor(test: any, consequent: any, alternate?: any | null);
|
|
47
|
+
}
|
|
48
|
+
export declare class ForStatement extends ASTNode {
|
|
49
|
+
init: any;
|
|
50
|
+
test: any;
|
|
51
|
+
update: any;
|
|
52
|
+
body: any;
|
|
53
|
+
isForIn: boolean;
|
|
54
|
+
constructor(init: any, test: any, update: any, body: any);
|
|
55
|
+
}
|
|
56
|
+
export declare class WhileStatement extends ASTNode {
|
|
57
|
+
test: any;
|
|
58
|
+
body: any;
|
|
59
|
+
constructor(test: any, body: any);
|
|
60
|
+
}
|
|
61
|
+
export declare class BlockStatement extends ASTNode {
|
|
62
|
+
body: any[];
|
|
63
|
+
constructor(body: any[]);
|
|
64
|
+
}
|
|
65
|
+
export declare class ReturnStatement extends ASTNode {
|
|
66
|
+
argument: any;
|
|
67
|
+
constructor(argument: any);
|
|
68
|
+
}
|
|
69
|
+
export declare class Identifier extends ASTNode {
|
|
70
|
+
name: string;
|
|
71
|
+
varType: string;
|
|
72
|
+
returnType: any;
|
|
73
|
+
isMethod: boolean;
|
|
74
|
+
constructor(name: string);
|
|
75
|
+
}
|
|
76
|
+
export declare class Literal extends ASTNode {
|
|
77
|
+
value: any;
|
|
78
|
+
raw: string;
|
|
79
|
+
constructor(value: any, raw?: string);
|
|
80
|
+
}
|
|
81
|
+
export declare class BinaryExpression extends ASTNode {
|
|
82
|
+
operator: string;
|
|
83
|
+
left: any;
|
|
84
|
+
right: any;
|
|
85
|
+
constructor(operator: string, left: any, right: any);
|
|
86
|
+
}
|
|
87
|
+
export declare class UnaryExpression extends ASTNode {
|
|
88
|
+
operator: string;
|
|
89
|
+
argument: any;
|
|
90
|
+
prefix: boolean;
|
|
91
|
+
constructor(operator: string, argument: any, prefix?: boolean);
|
|
92
|
+
}
|
|
93
|
+
export declare class AssignmentExpression extends ASTNode {
|
|
94
|
+
operator: string;
|
|
95
|
+
left: any;
|
|
96
|
+
right: any;
|
|
97
|
+
constructor(operator: string, left: any, right: any);
|
|
98
|
+
}
|
|
99
|
+
export declare class UpdateExpression extends ASTNode {
|
|
100
|
+
operator: string;
|
|
101
|
+
argument: any;
|
|
102
|
+
prefix: boolean;
|
|
103
|
+
constructor(operator: string, argument: any, prefix?: boolean);
|
|
104
|
+
}
|
|
105
|
+
export declare class CallExpression extends ASTNode {
|
|
106
|
+
callee: any;
|
|
107
|
+
args: any[];
|
|
108
|
+
arguments: any[];
|
|
109
|
+
constructor(callee: any, args: any[]);
|
|
110
|
+
}
|
|
111
|
+
export declare class MemberExpression extends ASTNode {
|
|
112
|
+
object: any;
|
|
113
|
+
property: any;
|
|
114
|
+
computed: boolean;
|
|
115
|
+
constructor(object: any, property: any, computed?: boolean);
|
|
116
|
+
}
|
|
117
|
+
export declare class ConditionalExpression extends ASTNode {
|
|
118
|
+
test: any;
|
|
119
|
+
consequent: any;
|
|
120
|
+
alternate: any;
|
|
121
|
+
needsIIFE: boolean;
|
|
122
|
+
consequentStmts: any[];
|
|
123
|
+
alternateStmts: any[];
|
|
124
|
+
constructor(test: any, consequent: any, alternate: any);
|
|
125
|
+
}
|
|
126
|
+
export declare class ArrayExpression extends ASTNode {
|
|
127
|
+
elements: any[];
|
|
128
|
+
constructor(elements: any[]);
|
|
129
|
+
}
|
|
130
|
+
export declare class ObjectExpression extends ASTNode {
|
|
131
|
+
properties: any[];
|
|
132
|
+
constructor(properties: any[]);
|
|
133
|
+
}
|
|
134
|
+
export declare class Property extends ASTNode {
|
|
135
|
+
key: any;
|
|
136
|
+
value: any;
|
|
137
|
+
kind: string;
|
|
138
|
+
method: boolean;
|
|
139
|
+
shorthand: boolean;
|
|
140
|
+
computed: boolean;
|
|
141
|
+
constructor(key: any, value: any);
|
|
142
|
+
}
|
|
143
|
+
export declare class ArrayPattern extends ASTNode {
|
|
144
|
+
elements: any[];
|
|
145
|
+
constructor(elements: any[]);
|
|
146
|
+
}
|
|
147
|
+
export declare class AssignmentPattern extends ASTNode {
|
|
148
|
+
left: any;
|
|
149
|
+
right: any;
|
|
150
|
+
constructor(left: any, right: any);
|
|
151
|
+
}
|
|
152
|
+
export declare class ArrowFunctionExpression extends ASTNode {
|
|
153
|
+
params: any[];
|
|
154
|
+
body: any;
|
|
155
|
+
expression: boolean;
|
|
156
|
+
constructor(params: any[], body: any, expression?: boolean);
|
|
157
|
+
}
|
|
158
|
+
export declare class SwitchExpression extends ASTNode {
|
|
159
|
+
discriminant: any;
|
|
160
|
+
cases: any[];
|
|
161
|
+
constructor(discriminant: any, cases: any[]);
|
|
162
|
+
}
|
|
163
|
+
export declare class SwitchCase extends ASTNode {
|
|
164
|
+
test: any;
|
|
165
|
+
consequent: any;
|
|
166
|
+
constructor(test: any, consequent: any);
|
|
167
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare class CodeGenerator {
|
|
2
|
+
private indent;
|
|
3
|
+
private indentStr;
|
|
4
|
+
private output;
|
|
5
|
+
private sourceCode;
|
|
6
|
+
private sourceLines;
|
|
7
|
+
private lastCommentedLine;
|
|
8
|
+
private includeSourceComments;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
indentStr?: string;
|
|
11
|
+
sourceCode?: string;
|
|
12
|
+
includeSourceComments?: boolean;
|
|
13
|
+
});
|
|
14
|
+
generate(ast: any): string;
|
|
15
|
+
writeSourceComment(startLine: any, endLine?: any): void;
|
|
16
|
+
write(str: any): void;
|
|
17
|
+
writeLine(str?: string): void;
|
|
18
|
+
increaseIndent(): void;
|
|
19
|
+
decreaseIndent(): void;
|
|
20
|
+
generateProgram(node: any): void;
|
|
21
|
+
generateStatement(node: any): void;
|
|
22
|
+
generateTypeDefinition(node: any): void;
|
|
23
|
+
generateFunctionDeclaration(node: any): void;
|
|
24
|
+
generateVariableDeclaration(node: any): void;
|
|
25
|
+
generateExpressionStatement(node: any): void;
|
|
26
|
+
generateIfStatement(node: any): void;
|
|
27
|
+
generateIfStatementWithAssignment(condExpr: any, varName: any): void;
|
|
28
|
+
generateNestedIfWithAssignments(node: any, varName: any): void;
|
|
29
|
+
generateNestedIfAlternatesWithAssignments(alternate: any, varName: any): void;
|
|
30
|
+
generateForStatement(node: any): void;
|
|
31
|
+
generateWhileStatement(node: any): void;
|
|
32
|
+
generateReturnStatement(node: any): void;
|
|
33
|
+
generateBlockStatement(node: any, addIndent?: boolean): void;
|
|
34
|
+
generateExpression(node: any): void;
|
|
35
|
+
generateLiteral(node: any): void;
|
|
36
|
+
generateBinaryExpression(node: any): void;
|
|
37
|
+
generateUnaryExpression(node: any): void;
|
|
38
|
+
generateAssignmentExpression(node: any): void;
|
|
39
|
+
generateUpdateExpression(node: any): void;
|
|
40
|
+
generateCallExpression(node: any): void;
|
|
41
|
+
generateMemberExpression(node: any): void;
|
|
42
|
+
generateConditionalExpression(node: any): void;
|
|
43
|
+
generateIIFEConditional(node: any): void;
|
|
44
|
+
generateIIFEIfBlock(node: any): void;
|
|
45
|
+
generateNestedIfWithReturns(node: any): void;
|
|
46
|
+
generateNestedIfAlternates(alternate: any): void;
|
|
47
|
+
generateNestedIfAsExpression(node: any): void;
|
|
48
|
+
generateArrayExpression(node: any): void;
|
|
49
|
+
generateObjectExpression(node: any): void;
|
|
50
|
+
generateSwitchExpression(node: any): void;
|
|
51
|
+
generateSequenceExpression(node: any): void;
|
|
52
|
+
needsParentheses(node: any): boolean;
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Token } from './tokens';
|
|
2
|
+
export declare class Lexer {
|
|
3
|
+
private source;
|
|
4
|
+
private pos;
|
|
5
|
+
private line;
|
|
6
|
+
private column;
|
|
7
|
+
private tokens;
|
|
8
|
+
private indentStack;
|
|
9
|
+
private atLineStart;
|
|
10
|
+
private parenDepth;
|
|
11
|
+
private bracketDepth;
|
|
12
|
+
private braceDepth;
|
|
13
|
+
constructor(source: string);
|
|
14
|
+
tokenize(): Token[];
|
|
15
|
+
handleNewline(): void;
|
|
16
|
+
handleIndentation(): void;
|
|
17
|
+
readComment(): void;
|
|
18
|
+
readString(): void;
|
|
19
|
+
readColorLiteral(): void;
|
|
20
|
+
readNumber(): void;
|
|
21
|
+
readIdentifier(): void;
|
|
22
|
+
readOperatorOrPunctuation(): boolean;
|
|
23
|
+
peek(offset?: number): string;
|
|
24
|
+
advance(): string;
|
|
25
|
+
skipWhitespaceInline(): void;
|
|
26
|
+
isDigit(ch: any): boolean;
|
|
27
|
+
isIdentifierStart(ch: any): boolean;
|
|
28
|
+
isIdentifierChar(ch: any): boolean;
|
|
29
|
+
getCurrentIndent(): number;
|
|
30
|
+
addToken(type: any, value: any, indent?: any): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Token } from './tokens';
|
|
2
|
+
import { Program, VariableDeclaration, FunctionDeclaration, TypeDefinition, IfStatement, ForStatement, WhileStatement, BlockStatement, CallExpression, ArrayExpression, SwitchExpression } from './ast';
|
|
3
|
+
export declare class Parser {
|
|
4
|
+
private tokens;
|
|
5
|
+
private pos;
|
|
6
|
+
constructor(tokens: Token[]);
|
|
7
|
+
peek(offset?: number): Token;
|
|
8
|
+
advance(): Token;
|
|
9
|
+
match(type: any, value?: any): boolean;
|
|
10
|
+
expect(type: any, value?: any): Token;
|
|
11
|
+
skipNewlines(): void;
|
|
12
|
+
parse(): Program;
|
|
13
|
+
parseStatement(): any;
|
|
14
|
+
isFunctionDeclaration(): boolean;
|
|
15
|
+
parseTypeDefinition(): TypeDefinition;
|
|
16
|
+
parseVarDeclaration(): VariableDeclaration;
|
|
17
|
+
parseTypedVarDeclaration(): VariableDeclaration;
|
|
18
|
+
parseFunctionDeclaration(): FunctionDeclaration;
|
|
19
|
+
parseMethodDeclaration(): FunctionDeclaration;
|
|
20
|
+
parseFunctionBody(): BlockStatement;
|
|
21
|
+
parseStatementOrSequence(): any;
|
|
22
|
+
parseIfStatement(): IfStatement;
|
|
23
|
+
parseForStatement(): ForStatement;
|
|
24
|
+
parseWhileStatement(): WhileStatement;
|
|
25
|
+
parseBlock(): BlockStatement;
|
|
26
|
+
isTupleDestructuring(): boolean;
|
|
27
|
+
parseTupleDestructuring(): VariableDeclaration;
|
|
28
|
+
parseExpression(): any;
|
|
29
|
+
parseTernary(): any;
|
|
30
|
+
parseLogicalOr(): any;
|
|
31
|
+
parseLogicalAnd(): any;
|
|
32
|
+
parseEquality(): any;
|
|
33
|
+
parseComparison(): any;
|
|
34
|
+
parseAdditive(): any;
|
|
35
|
+
parseMultiplicative(): any;
|
|
36
|
+
parseUnary(): any;
|
|
37
|
+
parsePostfix(): any;
|
|
38
|
+
parseCallExpression(callee: any): CallExpression;
|
|
39
|
+
parsePrimary(): any;
|
|
40
|
+
parseArrayLiteral(): ArrayExpression;
|
|
41
|
+
parseIfExpression(): any;
|
|
42
|
+
needsIIFE(consequentStmts: any, alternateStmts: any): any;
|
|
43
|
+
parseSwitchExpression(): SwitchExpression;
|
|
44
|
+
getBlockValue(statements: any): any;
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract Pine Script version from source code
|
|
3
|
+
* Looks for //@version=X comment on its own line (can be anywhere in the file)
|
|
4
|
+
* The line must start with // and contain only @version=X (with optional whitespace)
|
|
5
|
+
* Returns the version number or null if not found
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractPineScriptVersion(sourceCode: string): number | null;
|
|
8
|
+
export declare function pineToJS(sourceCode: string, options?: any): {
|
|
9
|
+
success: boolean;
|
|
10
|
+
version: number;
|
|
11
|
+
error: string;
|
|
12
|
+
code?: undefined;
|
|
13
|
+
ast?: undefined;
|
|
14
|
+
tokens?: undefined;
|
|
15
|
+
stack?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
success: boolean;
|
|
18
|
+
version: number;
|
|
19
|
+
code: string;
|
|
20
|
+
ast: import("./ast").Program;
|
|
21
|
+
tokens: import("./tokens").Token[];
|
|
22
|
+
error?: undefined;
|
|
23
|
+
stack?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
success: boolean;
|
|
26
|
+
version: number;
|
|
27
|
+
error: any;
|
|
28
|
+
stack: any;
|
|
29
|
+
code?: undefined;
|
|
30
|
+
ast?: undefined;
|
|
31
|
+
tokens?: undefined;
|
|
32
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const TokenType: {
|
|
2
|
+
NUMBER: string;
|
|
3
|
+
STRING: string;
|
|
4
|
+
BOOLEAN: string;
|
|
5
|
+
IDENTIFIER: string;
|
|
6
|
+
KEYWORD: string;
|
|
7
|
+
OPERATOR: string;
|
|
8
|
+
LPAREN: string;
|
|
9
|
+
RPAREN: string;
|
|
10
|
+
LBRACKET: string;
|
|
11
|
+
RBRACKET: string;
|
|
12
|
+
LBRACE: string;
|
|
13
|
+
RBRACE: string;
|
|
14
|
+
COMMA: string;
|
|
15
|
+
DOT: string;
|
|
16
|
+
COLON: string;
|
|
17
|
+
SEMICOLON: string;
|
|
18
|
+
INDENT: string;
|
|
19
|
+
DEDENT: string;
|
|
20
|
+
NEWLINE: string;
|
|
21
|
+
COMMENT: string;
|
|
22
|
+
EOF: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const Keywords: Set<string>;
|
|
25
|
+
export declare const MultiCharOperators: string[];
|
|
26
|
+
export declare class Token {
|
|
27
|
+
type: string;
|
|
28
|
+
value: any;
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
indent: number;
|
|
32
|
+
constructor(type: string, value: any, line: number, column: number, indent?: number);
|
|
33
|
+
toString(): string;
|
|
34
|
+
}
|