@angular-wave/angular.ts 0.0.49 → 0.0.51

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.
@@ -1,57 +1,211 @@
1
- export function ASTInterpreter($filter: any): void;
1
+ /**
2
+ * @param {import("./ast").ASTNode} ast
3
+ * @returns {boolean}
4
+ */
5
+ export function isAssignable(ast: import("./ast").ASTNode): boolean;
6
+ export const PURITY_ABSOLUTE: 1;
7
+ export const PURITY_RELATIVE: 2;
2
8
  export class ASTInterpreter {
3
- constructor($filter: any);
4
- $filter: any;
5
- compile(ast: any): any;
6
- recurse(ast: any, context: any, create: any): any;
7
- "unary+": (argument: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
8
- "unary-": (argument: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
9
- "unary!": (argument: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
10
- value: boolean;
11
- };
12
- "binary+": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
13
- "binary-": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => number | {
14
- value: number;
15
- };
16
- "binary*": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => number | {
17
- value: number;
18
- };
19
- "binary/": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => number | {
20
- value: number;
21
- };
22
- "binary%": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => number | {
9
+ /**
10
+ * @param {function(any):any} $filter
11
+ */
12
+ constructor($filter: (arg0: any) => any);
13
+ $filter: (arg0: any) => any;
14
+ /**
15
+ * Compiles the AST into a function.
16
+ * @param {import("./ast").ASTNode} ast - The AST to compile.
17
+ * @returns {import("./parse").CompiledExpression}
18
+ */
19
+ compile(ast: import("./ast").ASTNode): import("./parse").CompiledExpression;
20
+ /**
21
+ * Recurses the AST nodes.
22
+ * @param {import("./ast").ASTNode} ast - The AST node.
23
+ * @param {Object} [context] - The context.
24
+ * @param {boolean|1} [create] - The create flag.
25
+ * @returns {import("./parse").CompiledExpressionFunction} The recursive function.
26
+ */
27
+ recurse(ast: import("./ast").ASTNode, context?: any, create?: boolean | 1): import("./parse").CompiledExpressionFunction;
28
+ /**
29
+ * Unary plus operation.
30
+ * @param {function} argument - The argument function.
31
+ * @param {Object} [context] - The context.
32
+ * @returns {function} The unary plus function.
33
+ */
34
+ "unary+"(argument: Function, context?: any): Function;
35
+ /**
36
+ * Unary minus operation.
37
+ * @param {function} argument - The argument function.
38
+ * @param {Object} [context] - The context.
39
+ * @returns {function} The unary minus function.
40
+ */
41
+ "unary-"(argument: Function, context?: any): Function;
42
+ /**
43
+ * Unary negation operation.
44
+ * @param {function} argument - The argument function.
45
+ * @param {Object} [context] - The context.
46
+ * @returns {function} The unary negation function.
47
+ */
48
+ "unary!"(argument: Function, context?: any): Function;
49
+ /**
50
+ * Binary plus operation.
51
+ * @param {function} left - The left operand function.
52
+ * @param {function} right - The right operand function.
53
+ * @param {Object} [context] - The context.
54
+ * @returns {function} The binary plus function.
55
+ */
56
+ "binary+"(left: Function, right: Function, context?: any): Function;
57
+ /**
58
+ * Binary minus operation.
59
+ * @param {function} left - The left operand function.
60
+ * @param {function} right - The right operand function.
61
+ * @param {Object} [context] - The context.
62
+ * @returns {function} The binary minus function.
63
+ */
64
+ "binary-"(left: Function, right: Function, context?: any): Function;
65
+ /**
66
+ * Binary multiplication operation.
67
+ * @param {function} left - The left operand function.
68
+ * @param {function} right - The right operand function.
69
+ * @param {Object} [context] - The context.
70
+ * @returns {function} The binary multiplication function.
71
+ */
72
+ "binary*"(left: Function, right: Function, context?: any): Function;
73
+ "binary/"(left: any, right: any, context: any): (scope: any, locals: any, assign: any) => number | {
23
74
  value: number;
24
75
  };
25
- "binary===": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
26
- value: boolean;
27
- };
28
- "binary!==": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
29
- value: boolean;
30
- };
31
- "binary==": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
32
- value: boolean;
33
- };
34
- "binary!=": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
35
- value: boolean;
36
- };
37
- "binary<": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
38
- value: boolean;
39
- };
40
- "binary>": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
41
- value: boolean;
42
- };
43
- "binary<=": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
44
- value: boolean;
45
- };
46
- "binary>=": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => boolean | {
47
- value: boolean;
48
- };
49
- "binary&&": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
50
- "binary||": (left: any, right: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
51
- "ternary?:": (test: any, alternate: any, consequent: any, context: any) => (scope: any, locals: any, assign: any, inputs: any) => any;
52
- value(value: any, context: any): () => any;
53
- identifier(name: any, context: any, create: any): (scope: any, locals: any) => any;
54
- computedMember(left: any, right: any, context: any, create: any): (scope: any, locals: any, assign: any, inputs: any) => any;
55
- nonComputedMember(left: any, right: any, context: any, create: any): (scope: any, locals: any, assign: any, inputs: any) => any;
56
- inputs(input: any, watchId: any): (scope: any, value: any, locals: any, inputs: any) => any;
76
+ /**
77
+ * Binary division operation.
78
+ * @param {function} left - The left operand function.
79
+ * @param {function} right - The right operand function.
80
+ * @param {Object} [context] - The context.
81
+ * @returns {function} The binary division function.
82
+ */
83
+ "binary%"(left: Function, right: Function, context?: any): Function;
84
+ /**
85
+ * Binary strict equality operation.
86
+ * @param {function} left - The left operand function.
87
+ * @param {function} right - The right operand function.
88
+ * @param {Object} [context] - The context.
89
+ * @returns {function} The binary strict equality function.
90
+ */
91
+ "binary==="(left: Function, right: Function, context?: any): Function;
92
+ /**
93
+ * Binary strict inequality operation.
94
+ * @param {function} left - The left operand function.
95
+ * @param {function} right - The right operand function.
96
+ * @param {Object} [context] - The context.
97
+ * @returns {function} The binary strict inequality function.
98
+ */
99
+ "binary!=="(left: Function, right: Function, context?: any): Function;
100
+ /**
101
+ * Binary equality operation.
102
+ * @param {function} left - The left operand function.
103
+ * @param {function} right - The right operand function.
104
+ * @param {Object} [context] - The context.
105
+ * @returns {function} The binary equality function.
106
+ */
107
+ "binary=="(left: Function, right: Function, context?: any): Function;
108
+ /**
109
+ * Binary inequality operation.
110
+ * @param {function} left - The left operand function.
111
+ * @param {function} right - The right operand function.
112
+ * @param {Object} [context] - The context.
113
+ * @returns {function} The binary inequality function.
114
+ */
115
+ "binary!="(left: Function, right: Function, context?: any): Function;
116
+ /**
117
+ * Binary less-than operation.
118
+ * @param {function} left - The left operand function.
119
+ * @param {function} right - The right operand function.
120
+ * @param {Object} [context] - The context.
121
+ * @returns {function} The binary less-than function.
122
+ */
123
+ "binary<"(left: Function, right: Function, context?: any): Function;
124
+ /**
125
+ * Binary greater-than operation.
126
+ * @param {function} left - The left operand function.
127
+ * @param {function} right - The right operand function.
128
+ * @param {Object} [context] - The context.
129
+ * @returns {function} The binary greater-than function.
130
+ */
131
+ "binary>"(left: Function, right: Function, context?: any): Function;
132
+ /**
133
+ * Binary less-than-or-equal-to operation.
134
+ * @param {function} left - The left operand function.
135
+ * @param {function} right - The right operand function.
136
+ * @param {Object} [context] - The context.
137
+ * @returns {function} The binary less-than-or-equal-to function.
138
+ */
139
+ "binary<="(left: Function, right: Function, context?: any): Function;
140
+ /**
141
+ * Binary greater-than-or-equal-to operation.
142
+ * @param {function} left - The left operand function.
143
+ * @param {function} right - The right operand function.
144
+ * @param {Object} [context] - The context.
145
+ * @returns {function} The binary greater-than-or-equal-to function.
146
+ */
147
+ "binary>="(left: Function, right: Function, context?: any): Function;
148
+ /**
149
+ * Binary logical AND operation.
150
+ * @param {function} left - The left operand function.
151
+ * @param {function} right - The right operand function.
152
+ * @param {Object} [context] - The context.
153
+ * @returns {function} The binary logical AND function.
154
+ */
155
+ "binary&&"(left: Function, right: Function, context?: any): Function;
156
+ /**
157
+ * Binary logical OR operation.
158
+ * @param {function} left - The left operand function.
159
+ * @param {function} right - The right operand function.
160
+ * @param {Object} [context] - The context.
161
+ * @returns {function} The binary logical OR function.
162
+ */
163
+ "binary||"(left: Function, right: Function, context?: any): Function;
164
+ /**
165
+ * Ternary conditional operation.
166
+ * @param {function} test - The test function.
167
+ * @param {function} alternate - The alternate function.
168
+ * @param {function} consequent - The consequent function.
169
+ * @param {Object} [context] - The context.
170
+ * @returns {function} The ternary conditional function.
171
+ */
172
+ "ternary?:"(test: Function, alternate: Function, consequent: Function, context?: any): Function;
173
+ /**
174
+ * Returns the value of a literal.
175
+ * @param {*} value - The literal value.
176
+ * @param {Object} [context] - The context.
177
+ * @returns {function} The function returning the literal value.
178
+ */
179
+ value(value: any, context?: any): Function;
180
+ /**
181
+ * Returns the value of an identifier.
182
+ * @param {string} name - The identifier name.
183
+ * @param {Object} [context] - The context.
184
+ * @param {boolean|1} [create] - Whether to create the identifier if it does not exist.
185
+ * @returns {function} The function returning the identifier value.
186
+ */
187
+ identifier(name: string, context?: any, create?: boolean | 1): Function;
188
+ /**
189
+ * Returns the value of a computed member expression.
190
+ * @param {function} left - The left operand function.
191
+ * @param {function} right - The right operand function.
192
+ * @param {Object} [context] - The context.
193
+ * @param {boolean|1} [create] - Whether to create the member if it does not exist.
194
+ * @returns {function} The function returning the computed member value.
195
+ */
196
+ computedMember(left: Function, right: Function, context?: any, create?: boolean | 1): Function;
197
+ /**
198
+ * Returns the value of a non-computed member expression.
199
+ * @param {function} left - The left operand function.
200
+ * @param {string} right - The right operand function.
201
+ * @param {Object} [context] - The context.
202
+ * @param {boolean|1} [create] - Whether to create the member if it does not exist.
203
+ * @returns {function} The function returning the non-computed member value.
204
+ */
205
+ nonComputedMember(left: Function, right: string, context?: any, create?: boolean | 1): Function;
57
206
  }
207
+ export type DecoratedASTNode = import("./ast").ASTNode & {
208
+ isPure: boolean | number;
209
+ constant: boolean;
210
+ toWatch: any[];
211
+ };
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @typedef {Object} LexerOptions
3
- * @property {(ch: string, codePoint: number) => boolean} [isIdentifierStart] Custom function to determine if a character is a valid identifier start.
4
- * @property {(ch: string, codePoint: number) => boolean} [isIdentifierContinue] Custom function to determine if a character is a valid identifier continuation.
3
+ * @property {(ch: string, codePoint: number) => boolean} [isIdentifierStart] - Custom function to determine if a character is a valid identifier start.
4
+ * @property {(ch: string, codePoint: number) => boolean} [isIdentifierContinue] - Custom function to determine if a character is a valid identifier continuation.
5
5
  */
6
6
  /**
7
- * Represents a token produced by the lexer.
7
+ * Represents a token produced by the lexer, which will be used by the AST to construct an abstract syntax tree.
8
8
  * @typedef {Object} Token
9
- * @property {number} index Index of the token.
10
- * @property {string} text Text of the token.
11
- * @property {boolean} [identifier] Indicates if token is an identifier.
12
- * @property {boolean} [constant] Indicates if token is a constant.
13
- * @property {string|number} [value] Value of the token if it's a constant.
14
- * @property {boolean} [operator] Indicates if token is an operator.
9
+ * @property {number} index - Index of the token.
10
+ * @property {string} text - Text of the token.
11
+ * @property {boolean} [identifier] - Indicates if token is an identifier.
12
+ * @property {boolean} [constant] - Indicates if token is a constant.
13
+ * @property {string|number} [value] - Value of the token if it's a constant.
14
+ * @property {boolean} [operator] - Indicates if token is an operator.
15
15
  */
16
16
  /**
17
17
  * Represents a lexer that tokenizes input text. The Lexer takes the original expression string and returns an array of tokens parsed from that string.
@@ -20,7 +20,7 @@
20
20
  export class Lexer {
21
21
  /**
22
22
  * Creates an instance of Lexer.
23
- * @param {LexerOptions} options Lexer options.
23
+ * @param {LexerOptions} options - Lexer options.
24
24
  */
25
25
  constructor(options: LexerOptions);
26
26
  /** @type {LexerOptions} */
@@ -99,6 +99,7 @@ export class Lexer {
99
99
  throwError(error: string, start?: number, end?: number): void;
100
100
  /**
101
101
  * Reads and tokenizes a number from the text.
102
+ * @return {void}
102
103
  */
103
104
  readNumber(): void;
104
105
  /**
@@ -110,44 +111,47 @@ export class Lexer {
110
111
  * @param {string} quote Quote character used for the string.
111
112
  */
112
113
  readString(quote: string): void;
114
+ /**
115
+ * @returns {string}
116
+ */
113
117
  handleUnicodeEscape(): string;
114
118
  }
115
119
  export type LexerOptions = {
116
120
  /**
117
- * Custom function to determine if a character is a valid identifier start.
121
+ * - Custom function to determine if a character is a valid identifier start.
118
122
  */
119
123
  isIdentifierStart?: (ch: string, codePoint: number) => boolean;
120
124
  /**
121
- * Custom function to determine if a character is a valid identifier continuation.
125
+ * - Custom function to determine if a character is a valid identifier continuation.
122
126
  */
123
127
  isIdentifierContinue?: (ch: string, codePoint: number) => boolean;
124
128
  };
125
129
  /**
126
- * Represents a token produced by the lexer.
130
+ * Represents a token produced by the lexer, which will be used by the AST to construct an abstract syntax tree.
127
131
  */
128
132
  export type Token = {
129
133
  /**
130
- * Index of the token.
134
+ * - Index of the token.
131
135
  */
132
136
  index: number;
133
137
  /**
134
- * Text of the token.
138
+ * - Text of the token.
135
139
  */
136
140
  text: string;
137
141
  /**
138
- * Indicates if token is an identifier.
142
+ * - Indicates if token is an identifier.
139
143
  */
140
144
  identifier?: boolean;
141
145
  /**
142
- * Indicates if token is a constant.
146
+ * - Indicates if token is a constant.
143
147
  */
144
148
  constant?: boolean;
145
149
  /**
146
- * Value of the token if it's a constant.
150
+ * - Value of the token if it's a constant.
147
151
  */
148
152
  value?: string | number;
149
153
  /**
150
- * Indicates if token is an operator.
154
+ * - Indicates if token is an operator.
151
155
  */
152
156
  operator?: boolean;
153
157
  };
@@ -1,23 +1,31 @@
1
+ /**
2
+ * @typedef {Object} CompiledExpressionProps
3
+ * @property {boolean} literal - Indicates if the expression is a literal.
4
+ * @property {boolean} constant - Indicates if the expression is constant.
5
+ * @property {boolean} isPure
6
+ * @property {boolean} oneTime
7
+ * @property {any[]} inputs
8
+ * @property {function(any, any): any} assign - Assigns a value to a context. If value is not provided,
9
+ */
10
+ /**
11
+ * @typedef {function } CompiledExpressionFunction
12
+ * @param {import('../scope/scope').Scope} context - An object against which any expressions embedded in the strings are evaluated against (typically a scope object).
13
+ * @param {object} [locals] - local variables context object, useful for overriding values in `context`.
14
+ * @param {any} [assign]
15
+ * @returns {any}
16
+ * undefined is gonna be used since the implementation
17
+ * does not check the parameter. Let's force a value for consistency. If consumer
18
+ * wants to undefine it, pass the undefined value explicitly.
19
+ */
20
+ /**
21
+ * @typedef {CompiledExpressionFunction & CompiledExpressionProps} CompiledExpression
22
+ */
23
+ /**
24
+ * @typedef {function(string|function(import('../scope/scope').Scope):any, function(any, import('../scope/scope').Scope, any):any=, boolean=): CompiledExpression} ParseService
25
+ */
1
26
  export function $ParseProvider(): void;
2
27
  export class $ParseProvider {
3
28
  /**
4
- * @ngdoc method
5
- * @name $parseProvider#addLiteral
6
- * @description
7
- *
8
- * Configure $parse service to add literal values that will be present as literal at expressions.
9
- *
10
- * @param {string} literalName Token for the literal value. The literal name value must be a valid literal name.
11
- * @param {*} literalValue Value for this literal. All literal values must be primitives or `undefined`.
12
- *
13
- **/
14
- addLiteral: (literalName: string, literalValue: any) => void;
15
- /**
16
- * @ngdoc method
17
- * @name $parseProvider#setIdentifierFns
18
- *
19
- * @description
20
- *
21
29
  * Allows defining the set of characters that are allowed in AngularJS expressions. The function
22
30
  * `identifierStart` will get called to know if a given character is a valid character to be the
23
31
  * first character for an identifier. The function `identifierContinue` will get called to know if
@@ -31,38 +39,36 @@ export class $ParseProvider {
31
39
  * Since this function will be called extensively, keep the implementation of these functions fast,
32
40
  * as the performance of these functions have a direct impact on the expressions parsing speed.
33
41
  *
34
- * @param {function(any):boolean=} identifierStart The function that will decide whether the given character is
42
+ * @param {function(any):boolean} [identifierStart] The function that will decide whether the given character is
35
43
  * a valid identifier start character.
36
- * @param {function(any):boolean=} identifierContinue The function that will decide whether the given character is
44
+ * @param {function(any):boolean} [identifierContinue] The function that will decide whether the given character is
37
45
  * a valid identifier continue character.
46
+ * @returns {$ParseProvider}
38
47
  */
39
- setIdentifierFns: (identifierStart?: ((arg0: any) => boolean) | undefined, identifierContinue?: ((arg0: any) => boolean) | undefined) => this;
48
+ setIdentifierFns: (identifierStart?: (arg0: any) => boolean, identifierContinue?: (arg0: any) => boolean) => $ParseProvider;
40
49
  $get: (string | (($filter: any) => {
41
50
  (exp: any, interceptorFn: any): any;
42
- $$getAst: (exp: any) => {
43
- type: string;
44
- body: {
45
- type: string;
46
- expression: any;
47
- }[];
48
- };
51
+ $$getAst: (exp: string) => import("./ast").ASTNode;
49
52
  }))[];
50
53
  }
51
- export function inputsWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
52
- export function oneTimeWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
53
- export function chainInterceptors(first: any, second: any): {
54
- (value: any): any;
55
- $stateful: any;
56
- $$pure: any;
54
+ export function constantWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
55
+ export type CompiledExpressionProps = {
56
+ /**
57
+ * - Indicates if the expression is a literal.
58
+ */
59
+ literal: boolean;
60
+ /**
61
+ * - Indicates if the expression is constant.
62
+ */
63
+ constant: boolean;
64
+ isPure: boolean;
65
+ oneTime: boolean;
66
+ inputs: any[];
67
+ /**
68
+ * - Assigns a value to a context. If value is not provided,
69
+ */
70
+ assign: (arg0: any, arg1: any) => any;
57
71
  };
58
- export const $parseMinErr: (arg0: string, ...arg1: any[]) => Error;
59
- export namespace literals {
60
- let _true: boolean;
61
- export { _true as true };
62
- let _false: boolean;
63
- export { _false as false };
64
- let _null: any;
65
- export { _null as null };
66
- export let undefined: any;
67
- }
68
- export type ParseService = (arg0: string | ((arg0: import("../scope/scope").Scope) => any), arg1: ((arg0: any, arg1: import("../scope/scope").Scope, arg2: any) => any) | undefined, arg2: boolean | undefined) => import("../../types").CompiledExpression;
72
+ export type CompiledExpressionFunction = Function;
73
+ export type CompiledExpression = CompiledExpressionFunction & CompiledExpressionProps;
74
+ export type ParseService = (arg0: string | ((arg0: import("../scope/scope").Scope) => any), arg1: ((arg0: any, arg1: import("../scope/scope").Scope, arg2: any) => any) | undefined, arg2: boolean | undefined) => CompiledExpression;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {Object} ParsedAST
3
+ * @property {import("./ast").ASTNode} ast - AST representation of expression
4
+ * @property {boolean} oneTime - True if expression should be evaluated only once
5
+ */
1
6
  /**
2
7
  * @constructor
3
8
  */
@@ -5,24 +10,34 @@ export class Parser {
5
10
  /**
6
11
  *
7
12
  * @param {import('./lexer').Lexer} lexer
8
- * @param {*} $filter
9
- * @param {*} options
13
+ * @param {function(any):any} $filter
10
14
  */
11
- constructor(lexer: import("./lexer").Lexer, $filter: any, options: any);
15
+ constructor(lexer: import("./lexer").Lexer, $filter: (arg0: any) => any);
16
+ /** @type {AST} */
12
17
  ast: AST;
13
- astCompiler: ASTInterpreter | ASTCompiler;
14
- parse(text: any): any;
15
- getAst(exp: any): {
16
- ast: {
17
- type: string;
18
- body: {
19
- type: string;
20
- expression: any;
21
- }[];
22
- };
23
- oneTime: boolean;
24
- };
18
+ /** @type {ASTInterpreter} */
19
+ astCompiler: ASTInterpreter;
20
+ /**
21
+ *
22
+ * @param {string} exp - Expression to be parsed
23
+ * @returns
24
+ */
25
+ parse(exp: string): import("./parse").CompiledExpression;
26
+ /**
27
+ * @param {string} exp - Expression to be parsed
28
+ * @returns {ParsedAST}
29
+ */
30
+ getAst(exp: string): ParsedAST;
25
31
  }
32
+ export type ParsedAST = {
33
+ /**
34
+ * - AST representation of expression
35
+ */
36
+ ast: import("./ast").ASTNode;
37
+ /**
38
+ * - True if expression should be evaluated only once
39
+ */
40
+ oneTime: boolean;
41
+ };
26
42
  import { AST } from "./ast";
27
43
  import { ASTInterpreter } from "./interpreter";
28
- import { ASTCompiler } from "./compiler";