@auscope/angular2parse 20.0.2 → 21.0.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/.editorconfig +13 -0
- package/LICENSE +21 -0
- package/README.md +66 -49
- package/angular.json +56 -0
- package/package.json +41 -33
- package/projects/angular2parse/README.md +49 -0
- package/projects/angular2parse/ng-package.json +7 -0
- package/projects/angular2parse/package.json +19 -0
- package/projects/angular2parse/src/lib/angular/compiler/assertions.d.ts +10 -0
- package/projects/angular2parse/src/lib/angular/compiler/assertions.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/assertions.js +45 -0
- package/projects/angular2parse/src/lib/angular/compiler/assertions.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/assertions.ts +49 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.d.ts +243 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.js +393 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.ts +393 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.d.ts +70 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.js +78 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.ts +89 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.d.ts +15 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.js +24 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.ts +25 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.d.ts +45 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.js +344 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.ts +383 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.d.ts +93 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.js +735 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.ts +825 -0
- package/projects/angular2parse/src/lib/angular/compiler.d.ts +7 -0
- package/projects/angular2parse/src/lib/angular/compiler.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler.js +7 -0
- package/projects/angular2parse/src/lib/angular/compiler.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/compiler.ts +6 -0
- package/projects/angular2parse/src/lib/angular/facade/lang.d.ts +45 -0
- package/projects/angular2parse/src/lib/angular/facade/lang.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/facade/lang.js +85 -0
- package/projects/angular2parse/src/lib/angular/facade/lang.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/facade/lang.ts +124 -0
- package/projects/angular2parse/src/lib/angular/facade.d.ts +2 -0
- package/projects/angular2parse/src/lib/angular/facade.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular/facade.js +2 -0
- package/projects/angular2parse/src/lib/angular/facade.js.map +1 -0
- package/projects/angular2parse/src/lib/angular/facade.ts +1 -0
- package/projects/angular2parse/src/lib/angular.d.ts +3 -0
- package/projects/angular2parse/src/lib/angular.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/angular.js +3 -0
- package/projects/angular2parse/src/lib/angular.js.map +1 -0
- package/projects/angular2parse/src/lib/angular.ts +2 -0
- package/projects/angular2parse/src/lib/module.d.ts +6 -0
- package/projects/angular2parse/src/lib/module.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/module.js +17 -0
- package/projects/angular2parse/src/lib/module.js.map +1 -0
- package/projects/angular2parse/src/lib/module.ts +12 -0
- package/projects/angular2parse/src/lib/parse.d.ts +19 -0
- package/projects/angular2parse/src/lib/parse.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/parse.js +61 -0
- package/projects/angular2parse/src/lib/parse.js.map +1 -0
- package/projects/angular2parse/src/lib/parse.ts +78 -0
- package/projects/angular2parse/src/lib/util/binary-operations.d.ts +2 -0
- package/projects/angular2parse/src/lib/util/binary-operations.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/util/binary-operations.js +18 -0
- package/projects/angular2parse/src/lib/util/binary-operations.js.map +1 -0
- package/projects/angular2parse/src/lib/util/binary-operations.ts +17 -0
- package/projects/angular2parse/src/lib/util/lang.d.ts +5 -0
- package/projects/angular2parse/src/lib/util/lang.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/util/lang.js +13 -0
- package/projects/angular2parse/src/lib/util/lang.js.map +1 -0
- package/projects/angular2parse/src/lib/util/lang.ts +15 -0
- package/projects/angular2parse/src/lib/util.d.ts +3 -0
- package/projects/angular2parse/src/lib/util.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/util.js +3 -0
- package/projects/angular2parse/src/lib/util.js.map +1 -0
- package/projects/angular2parse/src/lib/util.ts +2 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.d.ts +24 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.js +96 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.js.map +1 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.ts +149 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.d.ts +26 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.js +141 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.js.map +1 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.ts +208 -0
- package/projects/angular2parse/src/lib/visitors.d.ts +3 -0
- package/projects/angular2parse/src/lib/visitors.d.ts.map +1 -0
- package/projects/angular2parse/src/lib/visitors.js +3 -0
- package/projects/angular2parse/src/lib/visitors.js.map +1 -0
- package/projects/angular2parse/src/lib/visitors.ts +2 -0
- package/projects/angular2parse/src/public-api.d.ts +3 -0
- package/projects/angular2parse/src/public-api.d.ts.map +1 -0
- package/projects/angular2parse/src/public-api.js +6 -0
- package/projects/angular2parse/src/public-api.js.map +1 -0
- package/projects/angular2parse/src/public-api.ts +5 -0
- package/projects/angular2parse/tsconfig.lib.json +22 -0
- package/projects/angular2parse/tsconfig.lib.prod.json +15 -0
- package/tsconfig.json +21 -0
- package/fesm2022/auscope-angular2parse.mjs +0 -2033
- package/fesm2022/auscope-angular2parse.mjs.map +0 -1
- package/index.d.ts +0 -32
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AST,
|
|
3
|
+
RecursiveAstVisitor,
|
|
4
|
+
PropertyRead,
|
|
5
|
+
MethodCall,
|
|
6
|
+
KeyedRead,
|
|
7
|
+
ImplicitReceiver,
|
|
8
|
+
LiteralPrimitive,
|
|
9
|
+
Binary,
|
|
10
|
+
Chain,
|
|
11
|
+
Conditional,
|
|
12
|
+
BindingPipe,
|
|
13
|
+
FunctionCall,
|
|
14
|
+
Interpolation,
|
|
15
|
+
KeyedWrite,
|
|
16
|
+
LiteralArray,
|
|
17
|
+
LiteralMap,
|
|
18
|
+
PrefixNot,
|
|
19
|
+
PropertyWrite,
|
|
20
|
+
SafePropertyRead,
|
|
21
|
+
SafeMethodCall,
|
|
22
|
+
Quote
|
|
23
|
+
} from '../angular';
|
|
24
|
+
import * as util from '../util';
|
|
25
|
+
import { BinaryOperations } from '../util/binary-operations';
|
|
26
|
+
|
|
27
|
+
export class ParseVisitorResolver extends RecursiveAstVisitor {
|
|
28
|
+
|
|
29
|
+
constructor(private pipes: Map<string, any>) {
|
|
30
|
+
super();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
visitBinary(ast: Binary, context: any): any {
|
|
34
|
+
const execFn = BinaryOperations.get(ast.operation);
|
|
35
|
+
|
|
36
|
+
if (!execFn) {
|
|
37
|
+
throw new Error(`Parse ERROR: on visitBinary, unknown operator ${ast.operation}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return execFn(ast.left.visit(this, context), ast.right.visit(this, context));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// TODO
|
|
44
|
+
visitChain(ast: Chain, context: any): any {
|
|
45
|
+
return this.visitAll(ast.expressions, context);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
visitConditional(ast: Conditional, context: any): any {
|
|
49
|
+
if (ast.condition.visit(this, context)) {
|
|
50
|
+
return ast.trueExp.visit(this, context);
|
|
51
|
+
}
|
|
52
|
+
else if (util.isPresent(ast.falseExp)) {
|
|
53
|
+
return ast.falseExp.visit(this, context);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
visitPipe(ast: BindingPipe, context: any): any {
|
|
60
|
+
const pipe = this.pipes.get(ast.name);
|
|
61
|
+
|
|
62
|
+
if (!pipe) {
|
|
63
|
+
throw new Error(`pipe ${ast.name} not found.`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!pipe.transform) {
|
|
67
|
+
throw new Error(`Parse ERROR: on visitPipe, transform method doesn't exist on pipe ${ast.name}.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const value = ast.exp.visit(this, context);
|
|
71
|
+
const pipeArgs = this.visitAll(ast.args, context);
|
|
72
|
+
|
|
73
|
+
pipeArgs.unshift(value);
|
|
74
|
+
|
|
75
|
+
return pipe.transform.apply(null, pipeArgs);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// TODO
|
|
79
|
+
visitFunctionCall(ast: FunctionCall, context: any): any {
|
|
80
|
+
const target = ast.target.visit(this, context);
|
|
81
|
+
|
|
82
|
+
if (!util.isFunction(target)) {
|
|
83
|
+
throw new Error(`Parse ERROR: on visitFunctionCall, target is not a function.`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const args = this.visitAll(ast.args, context);
|
|
87
|
+
return target.apply(target, args);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
visitImplicitReceiver(ast: ImplicitReceiver, context: any): any {
|
|
91
|
+
return context;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
visitInterpolation(ast: Interpolation, context: any): any {
|
|
95
|
+
return this.visitAll(ast.expressions, context)[0];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
visitKeyedRead(ast: KeyedRead, context: any): any {
|
|
99
|
+
const obj = ast.obj.visit(this, context);
|
|
100
|
+
const key = ast.key.visit(this, context);
|
|
101
|
+
return obj[key];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
visitKeyedWrite(ast: KeyedWrite, context: any): any {
|
|
105
|
+
const obj = ast.obj.visit(this, context);
|
|
106
|
+
const key = ast.key.visit(this, context);
|
|
107
|
+
const value = ast.value.visit(this, context);
|
|
108
|
+
obj[key] = value;
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
visitLiteralArray(ast: LiteralArray, context: any): any {
|
|
113
|
+
return this.visitAll(ast.expressions, context);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
visitLiteralMap(ast: LiteralMap, context: any): any {
|
|
117
|
+
const result: any = {};
|
|
118
|
+
const keys = ast.keys;
|
|
119
|
+
const values = this.visitAll(ast.values, context);
|
|
120
|
+
|
|
121
|
+
for (let i = 0, length = keys.length; i < length; i++) {
|
|
122
|
+
result[keys[i]] = values[i];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any {
|
|
129
|
+
return ast.value;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
visitMethodCall(ast: MethodCall, context: any): any {
|
|
133
|
+
const receiver = ast.receiver.visit(this, context);
|
|
134
|
+
|
|
135
|
+
if (!util.isJsObject(receiver)) {
|
|
136
|
+
throw new Error(`Parse ERROR: on visitMethodCall, invalid method receiver.`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const method = receiver[ast.name];
|
|
140
|
+
|
|
141
|
+
if (!util.isFunction(method)) {
|
|
142
|
+
throw new Error(`Parse ERROR: on visitMethodCall, method ${ast.name} doesn't exist on receiver.`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const args = this.visitAll(ast.args, context);
|
|
146
|
+
return method.apply(receiver, args);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
visitPrefixNot(ast: PrefixNot, context: any): any {
|
|
150
|
+
return ast.expression.visit(this, context);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
visitPropertyRead(ast: PropertyRead, context: any): any {
|
|
154
|
+
const receiver = ast.receiver.visit(this, context);
|
|
155
|
+
|
|
156
|
+
if (!util.isJsObject(receiver)) {
|
|
157
|
+
throw new Error(`Parse ERROR: on visitPropertyRead, invalid property receiver.`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return receiver[ast.name];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
visitPropertyWrite(ast: PropertyWrite, context: any): any {
|
|
164
|
+
const receiver = ast.receiver.visit(this, context);
|
|
165
|
+
|
|
166
|
+
if (!util.isJsObject(receiver)) {
|
|
167
|
+
throw new Error(`Parse ERROR: on visitPropertyRead, invalid property receiver.`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
receiver[ast.name] = ast.value.visit(this, context);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
visitSafePropertyRead(ast: SafePropertyRead, context: any): any {
|
|
175
|
+
const receiver = ast.receiver.visit(this, context);
|
|
176
|
+
|
|
177
|
+
if (!util.isJsObject(receiver)) {
|
|
178
|
+
throw new Error(`Parse ERROR: on visitSafePropertyRead, invalid property receiver.`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return receiver[ast.name];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
visitSafeMethodCall(ast: SafeMethodCall, context: any): any {
|
|
185
|
+
const receiver = ast.receiver.visit(this, context);
|
|
186
|
+
|
|
187
|
+
if (!util.isJsObject(receiver)) {
|
|
188
|
+
throw new Error(`Parse ERROR: on visitSafeMethodCall, invalid method receiver.`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const method = receiver[ast.name];
|
|
192
|
+
|
|
193
|
+
if (!util.isFunction(method)) {
|
|
194
|
+
throw new Error(`Parse ERROR: on visitSafeMethodCall, method ${ast.name} doesn't exist on receiver.`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const args = this.visitAll(ast.args, context);
|
|
198
|
+
return method.apply(receiver, args);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
visitAll(asts: AST[], context: any): any {
|
|
202
|
+
return asts.map(ast => ast.visit(this, context));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
visitQuote(ast: Quote, context: any): any {
|
|
206
|
+
throw new Error(`Parse ERROR: on visitQuote, quote expression not allowed.`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitors.d.ts","sourceRoot":"","sources":["visitors.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitors.js","sourceRoot":"","sources":["visitors.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC","sourcesContent":["export * from './visitors/parse-visitor-compiler';\r\nexport * from './visitors/parse-visitor-resolver';"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["public-api.ts"],"names":[],"mappings":"AAGA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAA","sourcesContent":["/*\r\n * Public API Surface of angular2parse\r\n */\r\nexport * from './lib/module';\r\nexport * from './lib/parse'\r\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/lib",
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"inlineSources": true,
|
|
8
|
+
"types": []
|
|
9
|
+
},
|
|
10
|
+
"angularCompilerOptions": {
|
|
11
|
+
"skipTemplateCodegen": true,
|
|
12
|
+
"extendedDiagnostics": {
|
|
13
|
+
"checks": {
|
|
14
|
+
"nullishCoalescingNotNullable": "suppress",
|
|
15
|
+
"optionalChainNotNullable": "suppress"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"strictMetadataEmit": true,
|
|
19
|
+
"enableResourceInlining": true,
|
|
20
|
+
"strictTemplates": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.lib.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declarationMap": false
|
|
5
|
+
},
|
|
6
|
+
"angularCompilerOptions": {
|
|
7
|
+
"compilationMode": "partial",
|
|
8
|
+
"extendedDiagnostics": {
|
|
9
|
+
"checks": {
|
|
10
|
+
"nullishCoalescingNotNullable": "suppress",
|
|
11
|
+
"optionalChainNotNullable": "suppress"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"sourceMap": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"declaration": false,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"importHelpers": true,
|
|
11
|
+
"target": "ES2022",
|
|
12
|
+
"typeRoots": [
|
|
13
|
+
"node_modules/@types"
|
|
14
|
+
],
|
|
15
|
+
"useDefineForClassFields": false
|
|
16
|
+
},
|
|
17
|
+
"angularCompilerOptions": {
|
|
18
|
+
"fullTemplateTypeCheck": true,
|
|
19
|
+
"strictInjectionParameters": true
|
|
20
|
+
}
|
|
21
|
+
}
|