@auscope/angular2parse 19.0.0 → 20.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 +65 -49
- package/angular.json +56 -0
- package/package.json +29 -21
- 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.ts +49 -0
- package/projects/angular2parse/src/lib/angular/compiler/ast.ts +393 -0
- package/projects/angular2parse/src/lib/angular/compiler/chars.ts +89 -0
- package/projects/angular2parse/src/lib/angular/compiler/interpolation-config.ts +25 -0
- package/projects/angular2parse/src/lib/angular/compiler/lexer.ts +383 -0
- package/projects/angular2parse/src/lib/angular/compiler/parser.ts +811 -0
- package/{lib/angular/compiler.d.ts → projects/angular2parse/src/lib/angular/compiler.ts} +1 -1
- package/projects/angular2parse/src/lib/angular/facade/lang.ts +124 -0
- package/projects/angular2parse/src/lib/angular/facade.ts +1 -0
- package/{lib/angular.d.ts → projects/angular2parse/src/lib/angular.ts} +1 -1
- package/projects/angular2parse/src/lib/module.ts +12 -0
- package/projects/angular2parse/src/lib/parse.ts +78 -0
- package/projects/angular2parse/src/lib/util/binary-operations.ts +17 -0
- package/projects/angular2parse/src/lib/util/lang.ts +15 -0
- package/{lib/util.d.ts → projects/angular2parse/src/lib/util.ts} +1 -1
- package/projects/angular2parse/src/lib/visitors/parse-visitor-compiler.ts +149 -0
- package/projects/angular2parse/src/lib/visitors/parse-visitor-resolver.ts +208 -0
- package/{lib/visitors.d.ts → projects/angular2parse/src/lib/visitors.ts} +1 -1
- package/projects/angular2parse/src/public-api.ts +5 -0
- package/projects/angular2parse/tsconfig.lib.json +19 -0
- package/projects/angular2parse/tsconfig.lib.prod.json +9 -0
- package/tsconfig.json +33 -0
- package/fesm2022/auscope-angular2parse.mjs +0 -2033
- package/fesm2022/auscope-angular2parse.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/angular/compiler/assertions.d.ts +0 -9
- package/lib/angular/compiler/ast.d.ts +0 -242
- package/lib/angular/compiler/chars.d.ts +0 -69
- package/lib/angular/compiler/interpolation-config.d.ts +0 -14
- package/lib/angular/compiler/lexer.d.ts +0 -44
- package/lib/angular/compiler/parser.d.ts +0 -92
- package/lib/angular/facade/lang.d.ts +0 -44
- package/lib/angular/facade.d.ts +0 -1
- package/lib/module.d.ts +0 -9
- package/lib/parse.d.ts +0 -21
- package/lib/util/binary-operations.d.ts +0 -1
- package/lib/util/lang.d.ts +0 -4
- package/lib/visitors/parse-visitor-compiler.d.ts +0 -23
- package/lib/visitors/parse-visitor-resolver.d.ts +0 -25
- package/public-api.d.ts +0 -2
package/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
max_line_length = off
|
|
13
|
+
trim_trailing_whitespace = false
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Articode 2017
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,49 +1,65 @@
|
|
|
1
|
-
# angular2parse
|
|
2
|
-
Parse util for angular expressions: html string -> angular
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# angular2parse
|
|
2
|
+
Parse util for angular expressions: html string -> angular template
|
|
3
|
+
|
|
4
|
+
**This is a fork of Articode's [angular2parse](https://github.com/articodeltd/angular2parse), adapted for Angular v12 - v19**
|
|
5
|
+
|
|
6
|
+
**Available from 'npmjs' https://www.npmjs.com/package/@auscope/angular2parse**
|
|
7
|
+
|
|
8
|
+
| Angular Version | Branch |
|
|
9
|
+
|-----------------|-------------|
|
|
10
|
+
| v19 | upgrade-v19 |
|
|
11
|
+
| v18 | upgrade-v18 |
|
|
12
|
+
| v17 | upgrade-v17 |
|
|
13
|
+
| v16 | upgrade-v16 |
|
|
14
|
+
| v15 | upgrade-v15 |
|
|
15
|
+
| v14 | upgrade-v14 |
|
|
16
|
+
| v13 | upgrade-v13 |
|
|
17
|
+
| v12 | upgrade-v12 |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# install
|
|
21
|
+
`npm install angular2parse`
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// app.module.ts
|
|
25
|
+
@NgModule({
|
|
26
|
+
imports: [Angular2ParseModule, ...],
|
|
27
|
+
// ...
|
|
28
|
+
})
|
|
29
|
+
class AppModule {}
|
|
30
|
+
```
|
|
31
|
+
# usage
|
|
32
|
+
```typescript
|
|
33
|
+
import { Parse } from 'angular2parse';
|
|
34
|
+
|
|
35
|
+
@Injectable()
|
|
36
|
+
class MyService {
|
|
37
|
+
constructor(private parser: Parse) {}
|
|
38
|
+
|
|
39
|
+
parseAngularString() {
|
|
40
|
+
const expression = `{
|
|
41
|
+
positions: track.positions,
|
|
42
|
+
cornerType: getCornerType(),
|
|
43
|
+
material: track.color,
|
|
44
|
+
width : 200000.0 }`;
|
|
45
|
+
|
|
46
|
+
const expressionEvalFn = this.parser.eval(expression)
|
|
47
|
+
|
|
48
|
+
const context = {
|
|
49
|
+
getCornerType: () => 'value',
|
|
50
|
+
track: {
|
|
51
|
+
positions: [1,2,3],
|
|
52
|
+
color: 'red',
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const result = expressionEvalFn(context);
|
|
58
|
+
console.log(result);
|
|
59
|
+
// {positions: [1,2,3], cornerType: 'value', material: 'red', width: 2000}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```
|
package/angular.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"angular2parse": {
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"root": "projects/angular2parse",
|
|
9
|
+
"sourceRoot": "projects/angular2parse/src",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"tsConfig": "projects/angular2parse/tsconfig.lib.json",
|
|
16
|
+
"project": "projects/angular2parse/ng-package.json"
|
|
17
|
+
},
|
|
18
|
+
"configurations": {
|
|
19
|
+
"production": {
|
|
20
|
+
"tsConfig": "projects/angular2parse/tsconfig.lib.prod.json"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"cli": {
|
|
28
|
+
"analytics": false
|
|
29
|
+
},
|
|
30
|
+
"schematics": {
|
|
31
|
+
"@schematics/angular:component": {
|
|
32
|
+
"type": "component"
|
|
33
|
+
},
|
|
34
|
+
"@schematics/angular:directive": {
|
|
35
|
+
"type": "directive"
|
|
36
|
+
},
|
|
37
|
+
"@schematics/angular:service": {
|
|
38
|
+
"type": "service"
|
|
39
|
+
},
|
|
40
|
+
"@schematics/angular:guard": {
|
|
41
|
+
"typeSeparator": "."
|
|
42
|
+
},
|
|
43
|
+
"@schematics/angular:interceptor": {
|
|
44
|
+
"typeSeparator": "."
|
|
45
|
+
},
|
|
46
|
+
"@schematics/angular:module": {
|
|
47
|
+
"typeSeparator": "."
|
|
48
|
+
},
|
|
49
|
+
"@schematics/angular:pipe": {
|
|
50
|
+
"typeSeparator": "."
|
|
51
|
+
},
|
|
52
|
+
"@schematics/angular:resolver": {
|
|
53
|
+
"typeSeparator": "."
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auscope/angular2parse",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
|
+
"author": "Articode",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"description": "Fork of articode repo for Angular v19",
|
|
6
7
|
"bugs": {
|
|
7
8
|
"url": "https://github.com/AuScope/angular2parse/issues"
|
|
8
9
|
},
|
|
10
|
+
"homepage": "https://github.com/AuScope/angular2parse#readme",
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/AuScope/angular2parse.git"
|
|
12
|
-
"directory": "projects/angular2parse"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/AuScope/angular2parse#readme",
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"@angular/common": "^19.2.11",
|
|
17
|
-
"@angular/core": "^19.2.11"
|
|
13
|
+
"url": "git+https://github.com/AuScope/angular2parse.git"
|
|
18
14
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
".": {
|
|
26
|
-
"types": "./index.d.ts",
|
|
27
|
-
"default": "./fesm2022/auscope-angular2parse.mjs"
|
|
28
|
-
}
|
|
15
|
+
"scripts": {
|
|
16
|
+
"ng": "ng",
|
|
17
|
+
"build": "ng build",
|
|
18
|
+
"build:prod": "ng build --configuration production",
|
|
19
|
+
"lib:publish": "npm run build:prod && cd dist/angular2parse && npm publish"
|
|
29
20
|
},
|
|
30
|
-
"sideEffects": false,
|
|
31
21
|
"dependencies": {
|
|
32
|
-
"
|
|
22
|
+
"@angular/common": "^20.1.6",
|
|
23
|
+
"@angular/compiler": "^20.1.6",
|
|
24
|
+
"@angular/core": "^20.1.6",
|
|
25
|
+
"@angular/localize": "^20.1.6",
|
|
26
|
+
"@angular/platform-browser": "^20.1.6",
|
|
27
|
+
"@angular/platform-browser-dynamic": "^20.1.6",
|
|
28
|
+
"rxjs": "~6.6.7",
|
|
29
|
+
"tslib": "^2.4.1",
|
|
30
|
+
"zone.js": "~0.15.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@angular-devkit/build-angular": "^20.1.5",
|
|
34
|
+
"@angular/cli": "^20.1.5",
|
|
35
|
+
"@angular/compiler-cli": "^20.1.6",
|
|
36
|
+
"@angular/language-service": "^20.1.6",
|
|
37
|
+
"@types/node": "^13.13.52",
|
|
38
|
+
"ng-packagr": "^20.1.0",
|
|
39
|
+
"ts-node": "~8.10.2",
|
|
40
|
+
"typescript": "~5.8.3"
|
|
33
41
|
}
|
|
34
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# angular2parse
|
|
2
|
+
Parse util for angular expressions: html string -> angular temaplte
|
|
3
|
+
|
|
4
|
+
# install
|
|
5
|
+
`npm install angular2parse`
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// app.module.ts
|
|
9
|
+
@NgModule({
|
|
10
|
+
imports: [Angular2ParseModule, ...],
|
|
11
|
+
// ...
|
|
12
|
+
})
|
|
13
|
+
class AppModule {}
|
|
14
|
+
```
|
|
15
|
+
# usage
|
|
16
|
+
```typescript
|
|
17
|
+
import { Parse } from 'angular2parse';
|
|
18
|
+
|
|
19
|
+
@Injectable()
|
|
20
|
+
class MyService {
|
|
21
|
+
constructor(private parser: Parse) {}
|
|
22
|
+
|
|
23
|
+
parseAngularString() {
|
|
24
|
+
const expression = `{
|
|
25
|
+
positions: track.positions,
|
|
26
|
+
cornerType: getCornerType(),
|
|
27
|
+
material: track.color,
|
|
28
|
+
width : 200000.0 }`;
|
|
29
|
+
|
|
30
|
+
const expressionEvalFn = this.parser.eval(expression)
|
|
31
|
+
|
|
32
|
+
const context = {
|
|
33
|
+
getCornerType: () => 'value',
|
|
34
|
+
track: {
|
|
35
|
+
positions: [1,2,3],
|
|
36
|
+
color: 'red',
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const result = expressionEvalFn(context);
|
|
42
|
+
console.log(result);
|
|
43
|
+
// {positions: [1,2,3], cornerType: 'value', material: 'red', width: 2000}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@auscope/angular2parse",
|
|
3
|
+
"version": "19.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Fork of articode repo for Angular v19",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/AuScope/angular2parse/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/AuScope/angular2parse.git",
|
|
12
|
+
"directory": "projects/angular2parse"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/AuScope/angular2parse#readme",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@angular/common": "^19.2.11",
|
|
17
|
+
"@angular/core": "^19.2.11"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import {isBlank, isPresent} from '../facade/lang';
|
|
11
|
+
|
|
12
|
+
const isDevMode = () => false;
|
|
13
|
+
|
|
14
|
+
export function assertArrayOfStrings(identifier: string, value: any) {
|
|
15
|
+
if (!isDevMode() || isBlank(value)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!Array.isArray(value)) {
|
|
19
|
+
throw new Error(`Expected '${identifier}' to be an array of strings.`);
|
|
20
|
+
}
|
|
21
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
22
|
+
if (typeof value[i] !== 'string') {
|
|
23
|
+
throw new Error(`Expected '${identifier}' to be an array of strings.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const INTERPOLATION_BLACKLIST_REGEXPS = [
|
|
29
|
+
/^\s*$/, // empty
|
|
30
|
+
/[<>]/, // html tag
|
|
31
|
+
/^[{}]$/, // i18n expansion
|
|
32
|
+
/&(#|[a-z])/i, // character reference,
|
|
33
|
+
/^\/\//, // comment
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export function assertInterpolationSymbols(identifier: string, value: any): void {
|
|
37
|
+
if (isPresent(value) && !(Array.isArray(value) && value.length == 2)) {
|
|
38
|
+
throw new Error(`Expected '${identifier}' to be an array, [start, end].`);
|
|
39
|
+
} else if (isDevMode() && !isBlank(value)) {
|
|
40
|
+
const start = value[0] as string;
|
|
41
|
+
const end = value[1] as string;
|
|
42
|
+
// black list checking
|
|
43
|
+
INTERPOLATION_BLACKLIST_REGEXPS.forEach(regexp => {
|
|
44
|
+
if (regexp.test(start) || regexp.test(end)) {
|
|
45
|
+
throw new Error(`['${start}', '${end}'] contains unusable interpolation symbol.`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|