@simahfud/pine-to-kline 0.1.1 → 0.1.3

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.
Files changed (117) hide show
  1. package/dist/index.d.ts +696 -21
  2. package/dist/pine-to-kline.js +17 -14
  3. package/dist/pine-to-kline.js.map +1 -1
  4. package/dist/pine-to-kline.umd.js +1 -1
  5. package/dist/pine-to-kline.umd.js.map +1 -1
  6. package/package.json +1 -1
  7. package/dist/PineInterpreter.d.ts +0 -19
  8. package/dist/PineInterpreter.d.ts.map +0 -1
  9. package/dist/PineInterpreter.js +0 -89
  10. package/dist/PineInterpreter.js.map +0 -1
  11. package/dist/adapter/FigureMapper.d.ts +0 -8
  12. package/dist/adapter/FigureMapper.d.ts.map +0 -1
  13. package/dist/adapter/FigureMapper.js +0 -22
  14. package/dist/adapter/FigureMapper.js.map +0 -1
  15. package/dist/adapter/KlineAdapter.d.ts +0 -11
  16. package/dist/adapter/KlineAdapter.d.ts.map +0 -1
  17. package/dist/adapter/KlineAdapter.js +0 -88
  18. package/dist/adapter/KlineAdapter.js.map +0 -1
  19. package/dist/adapter/StyleMapper.d.ts +0 -10
  20. package/dist/adapter/StyleMapper.d.ts.map +0 -1
  21. package/dist/adapter/StyleMapper.js +0 -28
  22. package/dist/adapter/StyleMapper.js.map +0 -1
  23. package/dist/builtins/color/constants.d.ts +0 -7
  24. package/dist/builtins/color/constants.d.ts.map +0 -1
  25. package/dist/builtins/color/constants.js +0 -25
  26. package/dist/builtins/color/constants.js.map +0 -1
  27. package/dist/builtins/color/functions.d.ts +0 -21
  28. package/dist/builtins/color/functions.d.ts.map +0 -1
  29. package/dist/builtins/color/functions.js +0 -52
  30. package/dist/builtins/color/functions.js.map +0 -1
  31. package/dist/builtins/index.d.ts +0 -15
  32. package/dist/builtins/index.d.ts.map +0 -1
  33. package/dist/builtins/index.js +0 -32
  34. package/dist/builtins/index.js.map +0 -1
  35. package/dist/builtins/input/functions.d.ts +0 -28
  36. package/dist/builtins/input/functions.d.ts.map +0 -1
  37. package/dist/builtins/input/functions.js +0 -114
  38. package/dist/builtins/input/functions.js.map +0 -1
  39. package/dist/builtins/math/functions.d.ts +0 -9
  40. package/dist/builtins/math/functions.d.ts.map +0 -1
  41. package/dist/builtins/math/functions.js +0 -57
  42. package/dist/builtins/math/functions.js.map +0 -1
  43. package/dist/builtins/ta/crossover.d.ts +0 -18
  44. package/dist/builtins/ta/crossover.d.ts.map +0 -1
  45. package/dist/builtins/ta/crossover.js +0 -59
  46. package/dist/builtins/ta/crossover.js.map +0 -1
  47. package/dist/builtins/ta/index.d.ts +0 -12
  48. package/dist/builtins/ta/index.d.ts.map +0 -1
  49. package/dist/builtins/ta/index.js +0 -61
  50. package/dist/builtins/ta/index.js.map +0 -1
  51. package/dist/builtins/ta/momentum.d.ts +0 -22
  52. package/dist/builtins/ta/momentum.d.ts.map +0 -1
  53. package/dist/builtins/ta/momentum.js +0 -81
  54. package/dist/builtins/ta/momentum.js.map +0 -1
  55. package/dist/builtins/ta/moving-averages.d.ts +0 -24
  56. package/dist/builtins/ta/moving-averages.d.ts.map +0 -1
  57. package/dist/builtins/ta/moving-averages.js +0 -108
  58. package/dist/builtins/ta/moving-averages.js.map +0 -1
  59. package/dist/builtins/ta/utility.d.ts +0 -28
  60. package/dist/builtins/ta/utility.d.ts.map +0 -1
  61. package/dist/builtins/ta/utility.js +0 -156
  62. package/dist/builtins/ta/utility.js.map +0 -1
  63. package/dist/builtins/ta/volatility.d.ts +0 -21
  64. package/dist/builtins/ta/volatility.d.ts.map +0 -1
  65. package/dist/builtins/ta/volatility.js +0 -71
  66. package/dist/builtins/ta/volatility.js.map +0 -1
  67. package/dist/index.d.ts.map +0 -1
  68. package/dist/index.js +0 -24
  69. package/dist/index.js.map +0 -1
  70. package/dist/lexer/Lexer.d.ts +0 -40
  71. package/dist/lexer/Lexer.d.ts.map +0 -1
  72. package/dist/lexer/Lexer.js +0 -383
  73. package/dist/lexer/Lexer.js.map +0 -1
  74. package/dist/lexer/Token.d.ts +0 -16
  75. package/dist/lexer/Token.d.ts.map +0 -1
  76. package/dist/lexer/Token.js +0 -26
  77. package/dist/lexer/Token.js.map +0 -1
  78. package/dist/lexer/TokenType.d.ts +0 -74
  79. package/dist/lexer/TokenType.d.ts.map +0 -1
  80. package/dist/lexer/TokenType.js +0 -111
  81. package/dist/lexer/TokenType.js.map +0 -1
  82. package/dist/parser/Parser.d.ts +0 -55
  83. package/dist/parser/Parser.d.ts.map +0 -1
  84. package/dist/parser/Parser.js +0 -569
  85. package/dist/parser/Parser.js.map +0 -1
  86. package/dist/parser/nodes/index.d.ts +0 -215
  87. package/dist/parser/nodes/index.d.ts.map +0 -1
  88. package/dist/parser/nodes/index.js +0 -7
  89. package/dist/parser/nodes/index.js.map +0 -1
  90. package/dist/plugin/KlineChartProPlugin.d.ts +0 -43
  91. package/dist/plugin/KlineChartProPlugin.d.ts.map +0 -1
  92. package/dist/plugin/KlineChartProPlugin.js +0 -44
  93. package/dist/plugin/KlineChartProPlugin.js.map +0 -1
  94. package/dist/runtime/BarContext.d.ts +0 -23
  95. package/dist/runtime/BarContext.d.ts.map +0 -1
  96. package/dist/runtime/BarContext.js +0 -41
  97. package/dist/runtime/BarContext.js.map +0 -1
  98. package/dist/runtime/PineRuntime.d.ts +0 -51
  99. package/dist/runtime/PineRuntime.d.ts.map +0 -1
  100. package/dist/runtime/PineRuntime.js +0 -471
  101. package/dist/runtime/PineRuntime.js.map +0 -1
  102. package/dist/runtime/SeriesEmulator.d.ts +0 -21
  103. package/dist/runtime/SeriesEmulator.d.ts.map +0 -1
  104. package/dist/runtime/SeriesEmulator.js +0 -32
  105. package/dist/runtime/SeriesEmulator.js.map +0 -1
  106. package/dist/runtime/VarPersistence.d.ts +0 -20
  107. package/dist/runtime/VarPersistence.d.ts.map +0 -1
  108. package/dist/runtime/VarPersistence.js +0 -28
  109. package/dist/runtime/VarPersistence.js.map +0 -1
  110. package/dist/types.d.ts +0 -97
  111. package/dist/types.d.ts.map +0 -1
  112. package/dist/types.js +0 -6
  113. package/dist/types.js.map +0 -1
  114. package/dist/utils/errors.d.ts +0 -24
  115. package/dist/utils/errors.d.ts.map +0 -1
  116. package/dist/utils/errors.js +0 -46
  117. package/dist/utils/errors.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,21 +1,696 @@
1
- /**
2
- * pine-to-kline — Public API
3
- * PineScript v5/v6 interpreter for KlineChart registerIndicator
4
- * @license Apache-2.0
5
- */
6
- export { PineInterpreter } from './PineInterpreter';
7
- export { createPinePlugin } from './plugin/KlineChartProPlugin';
8
- export type { PineAPI, PinePluginOptions } from './plugin/KlineChartProPlugin';
9
- export { Lexer } from './lexer/Lexer';
10
- export { Token } from './lexer/Token';
11
- export { TokenType } from './lexer/TokenType';
12
- export { Parser } from './parser/Parser';
13
- export { PineRuntime } from './runtime/PineRuntime';
14
- export { KlineAdapter } from './adapter/KlineAdapter';
15
- export { SeriesEmulator } from './runtime/SeriesEmulator';
16
- export { BarContext } from './runtime/BarContext';
17
- export { TA_REGISTRY } from './builtins/ta/index';
18
- export { ALL_BUILTINS, ALL_CONSTANTS } from './builtins/index';
19
- export type { PineInterpreterOptions, CompileResult, ValidationResult, IndicatorConfig, IndicatorFigure, KlineData, PineInput, PinePlot, PineHline, PineMeta, PineIR, } from './types';
20
- export { PineError, LexerError, ParseError, RuntimeError, AdapterError } from './utils/errors';
21
- //# sourceMappingURL=index.d.ts.map
1
+ export declare class AdapterError extends PineError {
2
+ constructor(message: string);
3
+ }
4
+
5
+ /** Combined registry of ALL built-in functions */
6
+ export declare const ALL_BUILTINS: Record<string, Function>;
7
+
8
+ /** Combined registry of ALL built-in constants */
9
+ export declare const ALL_CONSTANTS: Record<string, any>;
10
+
11
+ declare interface AnnotationNode {
12
+ type: 'Annotation';
13
+ value: string;
14
+ line: number;
15
+ }
16
+
17
+ declare interface ArrayLiteral {
18
+ type: 'ArrayLiteral';
19
+ elements: ExprNode[];
20
+ line: number;
21
+ }
22
+
23
+ declare interface AssignNode {
24
+ type: 'Assign';
25
+ target: string;
26
+ operator: '=' | ':=' | '+=' | '-=' | '*=' | '/=' | '%=';
27
+ value: ExprNode;
28
+ line: number;
29
+ }
30
+
31
+ /**
32
+ * pine-to-kline — AST Node Definitions
33
+ * All node types for the PineScript Abstract Syntax Tree
34
+ * @license Apache-2.0
35
+ */
36
+ declare type ASTNode = ProgramNode | AnnotationNode | IndicatorNode | VarDeclNode | AssignNode | IfNode | ForNode | ForInNode | WhileNode | SwitchNode | FunctionDefNode | ReturnNode | BreakNode | ContinueNode | ExpressionStatement | PlotCallNode | HlineCallNode | ExprNode;
37
+
38
+ export declare class BarContext {
39
+ readonly dataList: KlineData[];
40
+ readonly open: number[];
41
+ readonly high: number[];
42
+ readonly low: number[];
43
+ readonly close: number[];
44
+ readonly volume: number[];
45
+ readonly hl2: number[];
46
+ readonly hlc3: number[];
47
+ readonly ohlc4: number[];
48
+ readonly time: number[];
49
+ readonly barCount: number;
50
+ constructor(dataList: KlineData[]);
51
+ /** Resolve a Pine source name to the data array */
52
+ resolveSource(name: string): number[];
53
+ }
54
+
55
+ declare interface BinaryExpr {
56
+ type: 'BinaryExpr';
57
+ operator: string;
58
+ left: ExprNode;
59
+ right: ExprNode;
60
+ line: number;
61
+ }
62
+
63
+ declare interface BoolLiteral {
64
+ type: 'BoolLiteral';
65
+ value: boolean;
66
+ line: number;
67
+ }
68
+
69
+ declare interface BreakNode {
70
+ type: 'Break';
71
+ line: number;
72
+ }
73
+
74
+ declare interface ColorLiteral {
75
+ type: 'ColorLiteral';
76
+ value: string;
77
+ line: number;
78
+ }
79
+
80
+ export declare interface CompileResult {
81
+ success: boolean;
82
+ indicatorConfig: IndicatorConfig;
83
+ name: string;
84
+ warnings: string[];
85
+ errors: Error[];
86
+ }
87
+
88
+ declare interface ContinueNode {
89
+ type: 'Continue';
90
+ line: number;
91
+ }
92
+
93
+ /**
94
+ * Create a Pine interpreter plugin for KlineChartPro.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { createPinePlugin } from 'pine-to-kline/plugin'
99
+ * import { registerCustomIndicator } from '@simahfud/klinecharts-pro'
100
+ *
101
+ * const pine = createPinePlugin()
102
+ *
103
+ * // Compile and register a Pine indicator
104
+ * const name = pine.run(`
105
+ * //@version=5
106
+ * indicator("RSI", overlay=false)
107
+ * length = input.int(14, "Length")
108
+ * plot(ta.rsi(close, length), "RSI", color=color.purple)
109
+ * hline(70, "OB", color=color.red)
110
+ * hline(30, "OS", color=color.green)
111
+ * `)
112
+ *
113
+ * // The indicator is now registered and can be added to a chart
114
+ * ```
115
+ */
116
+ export declare function createPinePlugin(options?: PinePluginOptions): PineAPI;
117
+
118
+ declare interface ExpressionStatement {
119
+ type: 'ExpressionStatement';
120
+ expression: ExprNode;
121
+ line: number;
122
+ }
123
+
124
+ declare type ExprNode = NumberLiteral | StringLiteral | BoolLiteral | ColorLiteral | NaLiteral | Identifier | BinaryExpr | UnaryExpr | TernaryExpr | FunctionCallExpr | MemberExpr | SeriesAccessExpr | TupleExpr | ArrayLiteral;
125
+
126
+ declare interface ForInNode {
127
+ type: 'ForIn';
128
+ variable: string;
129
+ iterable: ExprNode;
130
+ body: ASTNode[];
131
+ line: number;
132
+ }
133
+
134
+ declare interface ForNode {
135
+ type: 'For';
136
+ variable: string;
137
+ start: ExprNode;
138
+ end: ExprNode;
139
+ step: ExprNode | null;
140
+ body: ASTNode[];
141
+ line: number;
142
+ }
143
+
144
+ declare interface FunctionCallExpr {
145
+ type: 'FunctionCall';
146
+ callee: string;
147
+ args: ExprNode[];
148
+ kwargs: {
149
+ key: string;
150
+ value: ExprNode;
151
+ }[];
152
+ line: number;
153
+ }
154
+
155
+ declare interface FunctionDefNode {
156
+ type: 'FunctionDef';
157
+ name: string;
158
+ params: {
159
+ name: string;
160
+ defaultValue: ExprNode | null;
161
+ }[];
162
+ body: ASTNode[];
163
+ line: number;
164
+ }
165
+
166
+ declare interface HlineCallNode {
167
+ type: 'HlineCall';
168
+ price: ExprNode;
169
+ args: ExprNode[];
170
+ kwargs: {
171
+ key: string;
172
+ value: ExprNode;
173
+ }[];
174
+ line: number;
175
+ }
176
+
177
+ declare interface Identifier {
178
+ type: 'Identifier';
179
+ name: string;
180
+ line: number;
181
+ }
182
+
183
+ declare interface IfNode {
184
+ type: 'If';
185
+ condition: ExprNode;
186
+ body: ASTNode[];
187
+ elseIf: {
188
+ condition: ExprNode;
189
+ body: ASTNode[];
190
+ }[];
191
+ elseBody: ASTNode[] | null;
192
+ line: number;
193
+ }
194
+
195
+ export declare interface IndicatorConfig {
196
+ name: string;
197
+ shortName: string;
198
+ series?: string;
199
+ calcParams: any[];
200
+ figures: IndicatorFigure[];
201
+ regenerateFigures?: (params: any[]) => IndicatorFigure[];
202
+ calc: (dataList: KlineData[], indicator: any) => Record<string, any>[];
203
+ draw?: (params: any) => boolean;
204
+ createTooltipDataSource?: (params: any) => any;
205
+ extendData?: any;
206
+ }
207
+
208
+ export declare interface IndicatorFigure {
209
+ key: string;
210
+ title: string;
211
+ type: 'line' | 'bar' | 'circle';
212
+ styles?: (data: any, indicator: any, defaultStyles: any) => any;
213
+ }
214
+
215
+ declare interface IndicatorNode {
216
+ type: 'Indicator';
217
+ name: ExprNode;
218
+ args: {
219
+ key: string;
220
+ value: ExprNode;
221
+ }[];
222
+ line: number;
223
+ }
224
+
225
+ export declare class KlineAdapter {
226
+ toIndicatorTemplate(ir: PineIR): IndicatorConfig;
227
+ private mapFigures;
228
+ }
229
+
230
+ /**
231
+ * pine-to-kline — Core Type Definitions
232
+ * @license Apache-2.0
233
+ */
234
+ export declare interface KlineData {
235
+ timestamp: number;
236
+ open: number;
237
+ high: number;
238
+ low: number;
239
+ close: number;
240
+ volume?: number;
241
+ turnover?: number;
242
+ }
243
+
244
+ export declare class Lexer {
245
+ private source;
246
+ private tokens;
247
+ private pos;
248
+ private line;
249
+ private column;
250
+ private indentStack;
251
+ private atLineStart;
252
+ constructor(source: string);
253
+ tokenize(): Token[];
254
+ private handleIndentation;
255
+ private emitNewline;
256
+ private readComment;
257
+ private readNumber;
258
+ private readString;
259
+ private readColor;
260
+ private readIdentifier;
261
+ private readOperator;
262
+ /**
263
+ * Filter out meaningless tokens and handle line continuation.
264
+ * Pine uses implicit line continuation after certain tokens:
265
+ * binary operators, commas, opening brackets/parens.
266
+ */
267
+ private filterTokens;
268
+ private current;
269
+ private peek;
270
+ private advance;
271
+ private isDigit;
272
+ private isAlpha;
273
+ private isAlphaNumeric;
274
+ private isHexDigit;
275
+ }
276
+
277
+ export declare class LexerError extends PineError {
278
+ constructor(message: string, line?: number, column?: number);
279
+ }
280
+
281
+ declare interface MemberExpr {
282
+ type: 'MemberExpr';
283
+ object: ExprNode;
284
+ property: string;
285
+ line: number;
286
+ }
287
+
288
+ declare interface NaLiteral {
289
+ type: 'NaLiteral';
290
+ line: number;
291
+ }
292
+
293
+ declare interface NumberLiteral {
294
+ type: 'NumberLiteral';
295
+ value: number;
296
+ line: number;
297
+ }
298
+
299
+ export declare class ParseError extends PineError {
300
+ constructor(message: string, line?: number, column?: number);
301
+ }
302
+
303
+ export declare class Parser {
304
+ private tokens;
305
+ private pos;
306
+ constructor(tokens: Token[]);
307
+ parse(): ProgramNode;
308
+ private parseStatement;
309
+ private parseIdentifierStatement;
310
+ private parseIndicator;
311
+ private parseVarDecl;
312
+ private parseTypedDecl;
313
+ private parseAssignment;
314
+ private parseTupleAssign;
315
+ private parseIf;
316
+ private parseFor;
317
+ private parseWhile;
318
+ private parseSwitch;
319
+ private parseReturn;
320
+ private isFunctionDef;
321
+ private parseFunctionDef;
322
+ private parsePlotCall;
323
+ private parseHlineCall;
324
+ private parseExpression;
325
+ private parseTernary;
326
+ private parseOr;
327
+ private parseAnd;
328
+ private parseComparison;
329
+ private parseAddition;
330
+ private parseMultiplication;
331
+ private parsePower;
332
+ private parseUnary;
333
+ private parsePostfix;
334
+ private parsePrimary;
335
+ private parseCallArgs;
336
+ private parseBlock;
337
+ private parseBlockOrExpr;
338
+ private buildCalleeName;
339
+ private peek;
340
+ private peekAt;
341
+ private previous;
342
+ private isAtEnd;
343
+ private advance;
344
+ private check;
345
+ private checkAny;
346
+ private match;
347
+ private expect;
348
+ private skipNewlines;
349
+ }
350
+
351
+ export declare interface PineAPI {
352
+ /** Compile + register + return indicator name */
353
+ run: (pineCode: string) => string;
354
+ /** Validate syntax only */
355
+ validate: (pineCode: string) => ValidationResult;
356
+ /** Compile without adding to chart */
357
+ compile: (pineCode: string) => CompileResult;
358
+ }
359
+
360
+ /**
361
+ * pine-to-kline — Error Classes
362
+ * @license Apache-2.0
363
+ */
364
+ export declare class PineError extends Error {
365
+ readonly line?: number | undefined;
366
+ readonly column?: number | undefined;
367
+ readonly source?: string | undefined;
368
+ constructor(message: string, line?: number | undefined, column?: number | undefined, source?: string | undefined);
369
+ toString(): string;
370
+ }
371
+
372
+ export declare interface PineHline {
373
+ price: number;
374
+ title: string | null;
375
+ color: string | null;
376
+ linestyle: string | null;
377
+ linewidth: number;
378
+ }
379
+
380
+ export declare interface PineInput {
381
+ id: string;
382
+ type: 'int' | 'float' | 'bool' | 'string' | 'color' | 'source';
383
+ title: string | null;
384
+ defaultValue: any;
385
+ minval?: number;
386
+ maxval?: number;
387
+ step?: number;
388
+ options?: any[];
389
+ }
390
+
391
+ export declare class PineInterpreter {
392
+ private options;
393
+ constructor(options?: PineInterpreterOptions);
394
+ /** Full compile: PineScript source → IndicatorConfig (IndicatorTemplate) */
395
+ compile(source: string): CompileResult;
396
+ /** Validate syntax only (no execution) */
397
+ validate(source: string): ValidationResult;
398
+ /** Compile + register to KlineChart (global or instance) */
399
+ register(source: string, registerFn?: (config: any) => void): string;
400
+ /** Execute directly with data (for testing/preview) */
401
+ execute(source: string, dataList: KlineData[], params?: any[]): Record<string, any>[];
402
+ }
403
+
404
+ export declare interface PineInterpreterOptions {
405
+ /** Target Pine Script version */
406
+ version?: 'v5' | 'v6';
407
+ /** Strict mode — error on unsupported features */
408
+ strict?: boolean;
409
+ /** Enable sandbox isolation */
410
+ sandbox?: boolean;
411
+ /** Warning callback */
412
+ onWarning?: (msg: string) => void;
413
+ /** Error callback */
414
+ onError?: (err: Error) => void;
415
+ }
416
+
417
+ export declare interface PineIR {
418
+ meta: PineMeta;
419
+ inputs: PineInput[];
420
+ plots: PinePlot[];
421
+ hlines: PineHline[];
422
+ calcFn: (dataList: KlineData[], params: any[]) => Record<string, any>[];
423
+ warnings: string[];
424
+ errors: Error[];
425
+ }
426
+
427
+ export declare interface PineMeta {
428
+ name: string;
429
+ shortName: string | null;
430
+ overlay: boolean;
431
+ format: string | null;
432
+ precision: number | null;
433
+ scale: string | null;
434
+ max_bars_back: number | null;
435
+ }
436
+
437
+ export declare interface PinePlot {
438
+ id: string;
439
+ title: string | null;
440
+ color: string | null;
441
+ linewidth: number;
442
+ style: string | null;
443
+ editable?: boolean;
444
+ }
445
+
446
+ export declare interface PinePluginOptions extends PineInterpreterOptions {
447
+ /** Persist Pine scripts in layout JSON */
448
+ persistToLayout?: boolean;
449
+ }
450
+
451
+ export declare class PineRuntime {
452
+ private ctx;
453
+ private vars;
454
+ private scope;
455
+ private functions;
456
+ private meta;
457
+ private inputs;
458
+ private plots;
459
+ private hlines;
460
+ private plotResults;
461
+ private warnings;
462
+ private inputIndex;
463
+ execute(ast: ProgramNode, dataList: KlineData[], params?: any[]): RuntimeResult;
464
+ private firstPass;
465
+ private runCalc;
466
+ private runOnce;
467
+ private evalNode;
468
+ private evalIndicator;
469
+ private evalVarDecl;
470
+ private evalAssign;
471
+ private evalIf;
472
+ private evalFor;
473
+ private evalWhile;
474
+ private evalPlot;
475
+ private evalHline;
476
+ evalExpr(node: ExprNode, sources?: Record<string, number[]>, params?: any[], inputs?: PineInput[]): any;
477
+ private evalFunctionCall;
478
+ private callUserFunction;
479
+ private evalBinary;
480
+ private scalarBinary;
481
+ private resolveColor;
482
+ private buildMemberName;
483
+ }
484
+
485
+ declare interface PlotCallNode {
486
+ type: 'PlotCall';
487
+ function: string;
488
+ args: ExprNode[];
489
+ kwargs: {
490
+ key: string;
491
+ value: ExprNode;
492
+ }[];
493
+ line: number;
494
+ }
495
+
496
+ declare interface ProgramNode {
497
+ type: 'Program';
498
+ body: ASTNode[];
499
+ annotations: AnnotationNode[];
500
+ }
501
+
502
+ declare interface ReturnNode {
503
+ type: 'Return';
504
+ value: ExprNode | null;
505
+ line: number;
506
+ }
507
+
508
+ export declare class RuntimeError extends PineError {
509
+ constructor(message: string, line?: number, column?: number);
510
+ }
511
+
512
+ declare interface RuntimeResult {
513
+ meta: PineMeta;
514
+ inputs: PineInput[];
515
+ plots: PinePlot[];
516
+ hlines: PineHline[];
517
+ calcFn: (dataList: KlineData[], params: any[]) => Record<string, any>[];
518
+ warnings: string[];
519
+ errors: Error[];
520
+ }
521
+
522
+ declare interface SeriesAccessExpr {
523
+ type: 'SeriesAccess';
524
+ series: ExprNode;
525
+ offset: ExprNode;
526
+ line: number;
527
+ }
528
+
529
+ /**
530
+ * pine-to-kline — Series Emulator
531
+ * Emulates Pine's bar-by-bar series model using cursor-indexed arrays
532
+ * @license Apache-2.0
533
+ */
534
+ export declare class SeriesEmulator<T = number> {
535
+ private _data;
536
+ private _cursor;
537
+ constructor(data: T[]);
538
+ setCursor(index: number): void;
539
+ /** Access value with lookback: series[0] = current, series[1] = previous */
540
+ get(lookback?: number): T;
541
+ /** Set value at current cursor */
542
+ set(value: T): void;
543
+ get length(): number;
544
+ get current(): T;
545
+ get all(): T[];
546
+ /** Get the full underlying array */
547
+ toArray(): T[];
548
+ }
549
+
550
+ declare interface StringLiteral {
551
+ type: 'StringLiteral';
552
+ value: string;
553
+ line: number;
554
+ }
555
+
556
+ declare interface SwitchNode {
557
+ type: 'Switch';
558
+ expression: ExprNode | null;
559
+ cases: {
560
+ condition: ExprNode | null;
561
+ body: ASTNode[];
562
+ }[];
563
+ defaultBody: ASTNode[] | null;
564
+ line: number;
565
+ }
566
+
567
+ /** Registry map: 'ta.sma' → implementation function */
568
+ export declare const TA_REGISTRY: Record<string, Function>;
569
+
570
+ declare interface TernaryExpr {
571
+ type: 'TernaryExpr';
572
+ condition: ExprNode;
573
+ consequent: ExprNode;
574
+ alternate: ExprNode;
575
+ line: number;
576
+ }
577
+
578
+ export declare class Token {
579
+ readonly type: TokenType;
580
+ readonly value: string;
581
+ readonly line: number;
582
+ readonly column: number;
583
+ constructor(type: TokenType, value: string, line: number, column: number);
584
+ is(type: TokenType): boolean;
585
+ isAny(...types: TokenType[]): boolean;
586
+ toString(): string;
587
+ }
588
+
589
+ /**
590
+ * pine-to-kline — Token Types
591
+ * All PineScript v5/v6 token categories
592
+ * @license Apache-2.0
593
+ */
594
+ export declare enum TokenType {
595
+ NUMBER = "NUMBER",
596
+ STRING = "STRING",
597
+ COLOR_LITERAL = "COLOR_LITERAL",// #RRGGBB or #RRGGBBAA
598
+ IDENTIFIER = "IDENTIFIER",
599
+ IF = "IF",
600
+ ELSE = "ELSE",
601
+ FOR = "FOR",
602
+ TO = "TO",
603
+ BY = "BY",
604
+ IN = "IN",
605
+ WHILE = "WHILE",
606
+ SWITCH = "SWITCH",
607
+ VAR = "VAR",
608
+ VARIP = "VARIP",
609
+ TRUE = "TRUE",
610
+ FALSE = "FALSE",
611
+ NA = "NA",
612
+ AND = "AND",
613
+ OR = "OR",
614
+ NOT = "NOT",
615
+ IMPORT = "IMPORT",
616
+ EXPORT = "EXPORT",
617
+ TYPE = "TYPE",
618
+ METHOD = "METHOD",
619
+ BREAK = "BREAK",
620
+ CONTINUE = "CONTINUE",
621
+ RETURN = "RETURN",
622
+ INDICATOR = "INDICATOR",
623
+ STRATEGY = "STRATEGY",
624
+ LIBRARY = "LIBRARY",
625
+ PLUS = "PLUS",// +
626
+ MINUS = "MINUS",// -
627
+ STAR = "STAR",// *
628
+ SLASH = "SLASH",// /
629
+ PERCENT = "PERCENT",// %
630
+ POWER = "POWER",// ** (NEW in Pine — not ^)
631
+ EQ = "EQ",// ==
632
+ NEQ = "NEQ",// !=
633
+ LT = "LT",// <
634
+ GT = "GT",// >
635
+ LTE = "LTE",// <=
636
+ GTE = "GTE",// >=
637
+ ASSIGN = "ASSIGN",// =
638
+ REASSIGN = "REASSIGN",// :=
639
+ PLUS_ASSIGN = "PLUS_ASSIGN",// +=
640
+ MINUS_ASSIGN = "MINUS_ASSIGN",// -=
641
+ STAR_ASSIGN = "STAR_ASSIGN",// *=
642
+ SLASH_ASSIGN = "SLASH_ASSIGN",// /=
643
+ PERCENT_ASSIGN = "PERCENT_ASSIGN",// %=
644
+ LPAREN = "LPAREN",// (
645
+ RPAREN = "RPAREN",// )
646
+ LBRACKET = "LBRACKET",// [
647
+ RBRACKET = "RBRACKET",// ]
648
+ COMMA = "COMMA",// ,
649
+ DOT = "DOT",// .
650
+ COLON = "COLON",// :
651
+ QUESTION = "QUESTION",// ?
652
+ ARROW = "ARROW",// =>
653
+ NEWLINE = "NEWLINE",
654
+ INDENT = "INDENT",
655
+ DEDENT = "DEDENT",
656
+ EOF = "EOF",
657
+ COMMENT = "COMMENT",
658
+ COMPILER_ANNOTATION = "COMPILER_ANNOTATION"
659
+ }
660
+
661
+ declare interface TupleExpr {
662
+ type: 'TupleExpr';
663
+ elements: ExprNode[];
664
+ line: number;
665
+ }
666
+
667
+ declare interface UnaryExpr {
668
+ type: 'UnaryExpr';
669
+ operator: string;
670
+ operand: ExprNode;
671
+ line: number;
672
+ }
673
+
674
+ export declare interface ValidationResult {
675
+ valid: boolean;
676
+ errors: Error[];
677
+ }
678
+
679
+ declare interface VarDeclNode {
680
+ type: 'VarDecl';
681
+ persistent: boolean;
682
+ persistentTick: boolean;
683
+ name: string | string[];
684
+ typeAnnotation: string | null;
685
+ value: ExprNode;
686
+ line: number;
687
+ }
688
+
689
+ declare interface WhileNode {
690
+ type: 'While';
691
+ condition: ExprNode;
692
+ body: ASTNode[];
693
+ line: number;
694
+ }
695
+
696
+ export { }