@simahfud/pine-to-kline 0.1.3 → 0.1.4
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 +7 -0
- package/dist/index.d.ts +43 -1
- package/dist/pine-to-kline.js +196 -116
- package/dist/pine-to-kline.js.map +1 -1
- package/dist/pine-to-kline.umd.js +29 -29
- package/dist/pine-to-kline.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,13 @@ klineChart.createIndicator(indicatorName, true, { id: 'pane_1' })
|
|
|
83
83
|
### Inputs
|
|
84
84
|
- `input()`, `input.int()`, `input.float()`, `input.bool()`, `input.string()`, `input.color()`, `input.source()`
|
|
85
85
|
|
|
86
|
+
### Advanced Features (V5 / V6)
|
|
87
|
+
- **User-Defined Types (Structs)**: `type` definitions with strong typing
|
|
88
|
+
- **User-Defined Methods**: `method` definitions extending native or custom types
|
|
89
|
+
- **Array / Matrix**: Generic type support (`array.new<Type>()`) and array literal syntax (`[a, b, c]`)
|
|
90
|
+
- **Modules**: `import` and `export` statements
|
|
91
|
+
- **Expressions**: `if` and `switch` statements evaluated as expressions
|
|
92
|
+
|
|
86
93
|
## Architecture
|
|
87
94
|
|
|
88
95
|
The interpreter pipeline works in 4 phases:
|
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare interface AssignNode {
|
|
|
33
33
|
* All node types for the PineScript Abstract Syntax Tree
|
|
34
34
|
* @license Apache-2.0
|
|
35
35
|
*/
|
|
36
|
-
declare type ASTNode = ProgramNode | AnnotationNode | IndicatorNode | VarDeclNode | AssignNode | IfNode | ForNode | ForInNode | WhileNode | SwitchNode | FunctionDefNode | ReturnNode | BreakNode | ContinueNode | ExpressionStatement | PlotCallNode | HlineCallNode | ExprNode;
|
|
36
|
+
declare type ASTNode = ProgramNode | AnnotationNode | IndicatorNode | VarDeclNode | AssignNode | IfNode | ForNode | ForInNode | WhileNode | SwitchNode | FunctionDefNode | TypeDefNode | MethodDefNode | ImportNode | ExportNode | ReturnNode | BreakNode | ContinueNode | ExpressionStatement | PlotCallNode | HlineCallNode | ExprNode;
|
|
37
37
|
|
|
38
38
|
export declare class BarContext {
|
|
39
39
|
readonly dataList: KlineData[];
|
|
@@ -115,6 +115,12 @@ declare interface ContinueNode {
|
|
|
115
115
|
*/
|
|
116
116
|
export declare function createPinePlugin(options?: PinePluginOptions): PineAPI;
|
|
117
117
|
|
|
118
|
+
declare interface ExportNode {
|
|
119
|
+
type: 'Export';
|
|
120
|
+
declaration: ASTNode;
|
|
121
|
+
line: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
declare interface ExpressionStatement {
|
|
119
125
|
type: 'ExpressionStatement';
|
|
120
126
|
expression: ExprNode;
|
|
@@ -192,6 +198,13 @@ declare interface IfNode {
|
|
|
192
198
|
line: number;
|
|
193
199
|
}
|
|
194
200
|
|
|
201
|
+
declare interface ImportNode {
|
|
202
|
+
type: 'Import';
|
|
203
|
+
path: string;
|
|
204
|
+
alias: string | null;
|
|
205
|
+
line: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
195
208
|
export declare interface IndicatorConfig {
|
|
196
209
|
name: string;
|
|
197
210
|
shortName: string;
|
|
@@ -285,6 +298,18 @@ declare interface MemberExpr {
|
|
|
285
298
|
line: number;
|
|
286
299
|
}
|
|
287
300
|
|
|
301
|
+
declare interface MethodDefNode {
|
|
302
|
+
type: 'MethodDef';
|
|
303
|
+
name: string;
|
|
304
|
+
params: {
|
|
305
|
+
name: string;
|
|
306
|
+
typeAnnotation: string | null;
|
|
307
|
+
defaultValue: ExprNode | null;
|
|
308
|
+
}[];
|
|
309
|
+
body: ASTNode[];
|
|
310
|
+
line: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
288
313
|
declare interface NaLiteral {
|
|
289
314
|
type: 'NaLiteral';
|
|
290
315
|
line: number;
|
|
@@ -317,6 +342,10 @@ export declare class Parser {
|
|
|
317
342
|
private parseWhile;
|
|
318
343
|
private parseSwitch;
|
|
319
344
|
private parseReturn;
|
|
345
|
+
private parseImport;
|
|
346
|
+
private parseExport;
|
|
347
|
+
private parseTypeDef;
|
|
348
|
+
private parseMethodDef;
|
|
320
349
|
private isFunctionDef;
|
|
321
350
|
private parseFunctionDef;
|
|
322
351
|
private parsePlotCall;
|
|
@@ -335,6 +364,8 @@ export declare class Parser {
|
|
|
335
364
|
private parseCallArgs;
|
|
336
365
|
private parseBlock;
|
|
337
366
|
private parseBlockOrExpr;
|
|
367
|
+
private isTypeAnnotation;
|
|
368
|
+
private parseTypeAnnotationString;
|
|
338
369
|
private buildCalleeName;
|
|
339
370
|
private peek;
|
|
340
371
|
private peekAt;
|
|
@@ -664,6 +695,17 @@ declare interface TupleExpr {
|
|
|
664
695
|
line: number;
|
|
665
696
|
}
|
|
666
697
|
|
|
698
|
+
declare interface TypeDefNode {
|
|
699
|
+
type: 'TypeDef';
|
|
700
|
+
name: string;
|
|
701
|
+
fields: {
|
|
702
|
+
name: string;
|
|
703
|
+
typeAnnotation: string | null;
|
|
704
|
+
defaultValue: ExprNode | null;
|
|
705
|
+
}[];
|
|
706
|
+
line: number;
|
|
707
|
+
}
|
|
708
|
+
|
|
667
709
|
declare interface UnaryExpr {
|
|
668
710
|
type: 'UnaryExpr';
|
|
669
711
|
operator: string;
|