@angular-wave/angular.ts 0.16.0 → 0.16.1
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/@types/core/parse/ast/ast-node.d.ts +75 -38
- package/@types/core/parse/ast/ast.d.ts +0 -3
- package/@types/core/parse/interface.d.ts +2 -2
- package/@types/core/parse/interpreter.d.ts +22 -10
- package/@types/core/scope/scope.d.ts +7 -0
- package/dist/angular-ts.esm.js +294 -152
- package/dist/angular-ts.umd.js +294 -152
- package/dist/angular-ts.umd.min.js +1 -1
- package/dist/angular-ts.umd.min.js.gz +0 -0
- package/dist/angular-ts.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { ASTType } from "../ast-type.js";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
|
|
2
|
+
/** The kind of an object property */
|
|
3
|
+
export type PropertyKind = "init" | "get" | "set";
|
|
4
|
+
/** Base properties for all AST nodes */
|
|
5
|
+
interface BaseNode {
|
|
6
6
|
/** The type of the AST node. */
|
|
7
7
|
type: ASTType;
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
/** Indicates whether the node depends on non-shallow state. */
|
|
9
|
+
isPure?: boolean;
|
|
10
|
+
/** Indicates whether the expression is a constant. */
|
|
11
|
+
constant?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A node that contains a list of statements, e.g., Program or BlockStatement */
|
|
14
|
+
export interface BodyNode extends BaseNode {
|
|
15
|
+
/** The body of the program or block. Always present; empty if no statements. */
|
|
16
|
+
body: ASTNode[];
|
|
17
|
+
/** Optional list of expressions to observe for changes (Angular-specific). */
|
|
18
|
+
toWatch: ASTNode[];
|
|
19
|
+
}
|
|
20
|
+
/** Expression nodes, e.g., BinaryExpression, UnaryExpression, ConditionalExpression, CallExpression, MemberExpression */
|
|
21
|
+
export interface ExpressionNode extends BaseNode {
|
|
22
|
+
/** The single expression contained by an ExpressionStatement. */
|
|
23
|
+
expression?: ASTNode;
|
|
24
|
+
/** The left-hand side of a binary or logical expression. */
|
|
21
25
|
left?: ASTNode;
|
|
22
|
-
/** The right-hand side of a binary expression. */
|
|
26
|
+
/** The right-hand side of a binary or logical expression. */
|
|
23
27
|
right?: ASTNode;
|
|
24
28
|
/** The argument of a unary expression. */
|
|
25
29
|
argument?: ASTNode;
|
|
@@ -29,30 +33,63 @@ export type ASTNode = {
|
|
|
29
33
|
alternate?: ASTNode;
|
|
30
34
|
/** The consequent expression of a conditional expression. */
|
|
31
35
|
consequent?: ASTNode;
|
|
32
|
-
/** The
|
|
33
|
-
body?: ASTNode[];
|
|
34
|
-
/** A list of expressions to observe in a program or block statement. */
|
|
35
|
-
toWatch?: ASTNode[];
|
|
36
|
-
/** The expression of an expression statement. */
|
|
37
|
-
expression?: ASTNode;
|
|
38
|
-
/** The callee of a call expression. */
|
|
36
|
+
/** The callee of a function or method call expression. */
|
|
39
37
|
callee?: ASTNode;
|
|
40
|
-
/** The arguments of a call expression. */
|
|
38
|
+
/** The arguments of a function or method call expression. */
|
|
41
39
|
arguments?: ASTNode[];
|
|
42
|
-
/**
|
|
43
|
-
prefix?: boolean;
|
|
44
|
-
/** The object of a member expression. */
|
|
40
|
+
/** The object of a member expression (e.g., `obj` in `obj.prop`). */
|
|
45
41
|
object?: ASTNode;
|
|
46
|
-
/** The property of a member expression. */
|
|
42
|
+
/** The property of a member expression (e.g., `prop` in `obj.prop`). */
|
|
47
43
|
property?: ASTNode;
|
|
48
|
-
/** Indicates if
|
|
44
|
+
/** Indicates if the member expression is computed (`obj[prop]` vs `obj.prop`). */
|
|
49
45
|
computed?: boolean;
|
|
50
|
-
/** The operator of a binary or logical expression. */
|
|
46
|
+
/** The operator of a binary or logical expression, e.g., "+", "*", "&&". */
|
|
51
47
|
operator?: string;
|
|
52
|
-
/** Indicates if the expression should be filtered. */
|
|
48
|
+
/** Indicates if the expression should be filtered (Angular-specific). */
|
|
53
49
|
filter?: boolean;
|
|
54
|
-
/** Indicates
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
/** Indicates if the unary operator is a prefix, e.g., `++i` vs `i++`. */
|
|
51
|
+
prefix?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Leaf node representing a literal or identifier */
|
|
54
|
+
export interface LiteralNode extends BaseNode {
|
|
55
|
+
/** The value of a literal node, e.g., number, string, boolean. */
|
|
56
|
+
value?: any;
|
|
57
|
+
/** The name of an identifier node. */
|
|
58
|
+
name?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Node representing an array literal */
|
|
61
|
+
export interface ArrayNode extends BaseNode {
|
|
62
|
+
/** The elements of the array. */
|
|
63
|
+
elements: ASTNode[];
|
|
64
|
+
}
|
|
65
|
+
/** Node representing an object literal */
|
|
66
|
+
export interface ObjectNode extends BaseNode {
|
|
67
|
+
/** The properties of the object. */
|
|
68
|
+
properties: ASTNode[];
|
|
69
|
+
}
|
|
70
|
+
/** Node representing a single property of an object literal */
|
|
71
|
+
export interface ObjectPropertyNode extends BaseNode {
|
|
72
|
+
/** Property kind (only "init" is used in Angular expressions) */
|
|
73
|
+
kind: "init";
|
|
74
|
+
/** Property key: identifier, literal, or expression */
|
|
75
|
+
key: ASTNode;
|
|
76
|
+
/** Property value expression */
|
|
77
|
+
value: ASTNode;
|
|
78
|
+
/** Whether the property key is computed (`{ [expr]: value }`) */
|
|
79
|
+
computed: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Statement node that wraps an expression */
|
|
82
|
+
export interface ExpressionStatementNode extends BaseNode {
|
|
83
|
+
/** The expression contained in this statement. */
|
|
84
|
+
expression: ASTNode;
|
|
85
|
+
}
|
|
86
|
+
/** The union type covering all AST nodes */
|
|
87
|
+
export type ASTNode =
|
|
88
|
+
| BodyNode
|
|
89
|
+
| ExpressionNode
|
|
90
|
+
| LiteralNode
|
|
91
|
+
| ArrayNode
|
|
92
|
+
| ObjectNode
|
|
93
|
+
| ObjectPropertyNode
|
|
94
|
+
| ExpressionStatementNode;
|
|
95
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DecoratedASTNode } from "./interpreter.js";
|
|
2
1
|
import type { Scope } from "../scope/scope.js";
|
|
2
|
+
import { BodyNode } from "./ast/ast-node.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Describes metadata and behavior for a compiled AngularTS expression.
|
|
5
5
|
*/
|
|
@@ -11,7 +11,7 @@ export interface CompiledExpressionProps {
|
|
|
11
11
|
/** Optional flag for pure expressions. */
|
|
12
12
|
_isPure?: boolean;
|
|
13
13
|
/** AST node decorated with metadata. */
|
|
14
|
-
_decoratedNode:
|
|
14
|
+
_decoratedNode: BodyNode;
|
|
15
15
|
/** Expression inputs; may be an array or a function. */
|
|
16
16
|
_inputs?: any[] | Function;
|
|
17
17
|
/**
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
* @returns {boolean}
|
|
4
4
|
*/
|
|
5
5
|
export function isAssignable(ast: any): boolean;
|
|
6
|
+
/** @typedef {import("./ast/ast-node.ts").ASTNode} ASTNode */
|
|
7
|
+
/** @typedef {import("./ast/ast-node.ts").BodyNode} BodyNode */
|
|
8
|
+
/** @typedef {import("./ast/ast-node.ts").ExpressionNode} ExpressionNode */
|
|
9
|
+
/** @typedef {import("./ast/ast-node.ts").ArrayNode} ArrayNode */
|
|
10
|
+
/** @typedef {import("./ast/ast-node.ts").LiteralNode} LiteralNode */
|
|
11
|
+
/** @typedef {import("./ast/ast-node.ts").ObjectNode} ObjectNode */
|
|
12
|
+
/** @typedef {import("./ast/ast-node.ts").ObjectPropertyNode} ObjectPropertyNode */
|
|
13
|
+
/** @typedef {import("./interface.ts").CompiledExpression} CompiledExpression */
|
|
14
|
+
/** @typedef {import("./interface.ts").CompiledExpressionFunction} CompiledExpressionFunction */
|
|
6
15
|
export const PURITY_ABSOLUTE: 1;
|
|
7
16
|
export const PURITY_RELATIVE: 2;
|
|
8
17
|
export class ASTInterpreter {
|
|
@@ -14,12 +23,10 @@ export class ASTInterpreter {
|
|
|
14
23
|
_$filter: ng.FilterService;
|
|
15
24
|
/**
|
|
16
25
|
* Compiles the AST into a function.
|
|
17
|
-
* @param {
|
|
18
|
-
* @returns {
|
|
26
|
+
* @param {ASTNode} ast - The AST to compile.
|
|
27
|
+
* @returns {CompiledExpression}
|
|
19
28
|
*/
|
|
20
|
-
compile(
|
|
21
|
-
ast: import("./ast/ast.js").ASTNode,
|
|
22
|
-
): import("./interface.ts").CompiledExpression;
|
|
29
|
+
compile(ast: ASTNode): CompiledExpression;
|
|
23
30
|
/**
|
|
24
31
|
* Unary plus operation.
|
|
25
32
|
* @param {function} argument - The argument function.
|
|
@@ -218,8 +225,13 @@ export class ASTInterpreter {
|
|
|
218
225
|
): Function;
|
|
219
226
|
#private;
|
|
220
227
|
}
|
|
221
|
-
export type
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
228
|
+
export type ASTNode = import("./ast/ast-node.ts").ASTNode;
|
|
229
|
+
export type BodyNode = import("./ast/ast-node.ts").BodyNode;
|
|
230
|
+
export type ExpressionNode = import("./ast/ast-node.ts").ExpressionNode;
|
|
231
|
+
export type ArrayNode = import("./ast/ast-node.ts").ArrayNode;
|
|
232
|
+
export type LiteralNode = import("./ast/ast-node.ts").LiteralNode;
|
|
233
|
+
export type ObjectNode = import("./ast/ast-node.ts").ObjectNode;
|
|
234
|
+
export type ObjectPropertyNode = import("./ast/ast-node.ts").ObjectPropertyNode;
|
|
235
|
+
export type CompiledExpression = import("./interface.ts").CompiledExpression;
|
|
236
|
+
export type CompiledExpressionFunction =
|
|
237
|
+
import("./interface.ts").CompiledExpressionFunction;
|
|
@@ -182,3 +182,10 @@ export class Scope {
|
|
|
182
182
|
$searchByName(name: string): ng.Scope | undefined;
|
|
183
183
|
#private;
|
|
184
184
|
}
|
|
185
|
+
export type ExpressionNode = import("../parse/ast/ast-node.ts").ExpressionNode;
|
|
186
|
+
export type LiteralNode = import("../parse/ast/ast-node.ts").LiteralNode;
|
|
187
|
+
export type BodyNode = import("../parse/ast/ast-node.ts").BodyNode;
|
|
188
|
+
export type ArrayNode = import("../parse/ast/ast-node.ts").ArrayNode;
|
|
189
|
+
export type ObjectNode = import("../parse/ast/ast-node.ts").ObjectNode;
|
|
190
|
+
export type ObjectPropertyNode =
|
|
191
|
+
import("../parse/ast/ast-node.ts").ObjectPropertyNode;
|