@rxap/ts-morph 1.1.0-dev.0 → 1.1.0-dev.2
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/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/index.d.ts +11 -0
- package/src/index.js +11 -0
- package/src/index.js.map +1 -1
- package/src/lib/angular/coerce-component-import.d.ts +11 -0
- package/src/lib/angular/coerce-component-import.js +31 -0
- package/src/lib/angular/coerce-component-import.js.map +1 -0
- package/src/lib/angular/coerce-component-input.d.ts +18 -0
- package/src/lib/angular/coerce-component-input.js +67 -0
- package/src/lib/angular/coerce-component-input.js.map +1 -0
- package/src/lib/angular/coerce-component.d.ts +2 -2
- package/src/lib/angular/coerce-component.js +33 -20
- package/src/lib/angular/coerce-component.js.map +1 -1
- package/src/lib/angular/get-component-class.d.ts +2 -0
- package/src/lib/angular/get-component-class.js +12 -0
- package/src/lib/angular/get-component-class.js.map +1 -0
- package/src/lib/angular/get-component-decorator-object.d.ts +2 -0
- package/src/lib/angular/get-component-decorator-object.js +19 -0
- package/src/lib/angular/get-component-decorator-object.js.map +1 -0
- package/src/lib/coerce-accessor-declaration.d.ts +19 -0
- package/src/lib/coerce-accessor-declaration.js +38 -0
- package/src/lib/coerce-accessor-declaration.js.map +1 -0
- package/src/lib/coerce-array-element.d.ts +2 -1
- package/src/lib/coerce-array-element.js +14 -2
- package/src/lib/coerce-array-element.js.map +1 -1
- package/src/lib/coerce-class-property.d.ts +3 -0
- package/src/lib/coerce-class-property.js +3 -0
- package/src/lib/coerce-class-property.js.map +1 -1
- package/src/lib/coerce-default-class-export.d.ts +2 -0
- package/src/lib/coerce-default-class-export.js +27 -0
- package/src/lib/coerce-default-class-export.js.map +1 -0
- package/src/lib/coerce-property-declaration.d.ts +3 -0
- package/src/lib/coerce-property-declaration.js +13 -0
- package/src/lib/coerce-property-declaration.js.map +1 -0
- package/src/lib/data-property.d.ts +15 -0
- package/src/lib/data-property.js +63 -0
- package/src/lib/data-property.js.map +1 -0
- package/src/lib/has-constructor-parameter.d.ts +10 -0
- package/src/lib/has-constructor-parameter.js +17 -0
- package/src/lib/has-constructor-parameter.js.map +1 -0
- package/src/lib/nest/operation-id-utilities.d.ts +4 -4
- package/src/lib/nest/operation-id-utilities.js +9 -9
- package/src/lib/nest/operation-id-utilities.js.map +1 -1
- package/src/lib/type-import.d.ts +11 -0
- package/src/lib/type-import.js +46 -1
- package/src/lib/type-import.js.map +1 -1
- package/src/lib/upstream-options.d.ts +43 -0
- package/src/lib/upstream-options.js +53 -0
- package/src/lib/upstream-options.js.map +1 -0
- package/src/lib/write-type.d.ts +18 -0
- package/src/lib/write-type.js +74 -0
- package/src/lib/write-type.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.1.0-dev.2](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.1.0-dev.1...@rxap/ts-morph@1.1.0-dev.2) (2024-02-25)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- use namedImport before name ([eb33f27](https://gitlab.com/rxap/packages/commit/eb33f276c69aaddbb73e8e93a781d08986f56136))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- add NormalizeTypeImportList function ([8887b8e](https://gitlab.com/rxap/packages/commit/8887b8e92a32f88d2f1703253a12d68a0ed36294))
|
|
15
|
+
- support upstream configurations ([3c972cf](https://gitlab.com/rxap/packages/commit/3c972cfc1aea45d9cabca07f24f4627f4aff03aa))
|
|
16
|
+
|
|
17
|
+
# [1.1.0-dev.1](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.1.0-dev.0...@rxap/ts-morph@1.1.0-dev.1) (2024-02-22)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- change property order ([8266705](https://gitlab.com/rxap/packages/commit/8266705b791f8d3ca65c8b804b449cf47b2751b7))
|
|
22
|
+
- check if type import is required ([8dcd733](https://gitlab.com/rxap/packages/commit/8dcd733deab33097ef89f1ff8625864b5ead0235))
|
|
23
|
+
- initial component class creation ([070552a](https://gitlab.com/rxap/packages/commit/070552a35cd3a8a01e0c27f2d5316c9083ad72b3))
|
|
24
|
+
- simplify function use ([8ad2237](https://gitlab.com/rxap/packages/commit/8ad2237aff141651d7cfe09e09ae6ec88780d186))
|
|
25
|
+
- simplify function use ([3d1c202](https://gitlab.com/rxap/packages/commit/3d1c20272faf7bc7ae473a438a7d2393590f0a02))
|
|
26
|
+
- small issues ([93f69c5](https://gitlab.com/rxap/packages/commit/93f69c5e2f445994db265360c6dd4a1e8228bfdb))
|
|
27
|
+
- support type guessing ([90a8624](https://gitlab.com/rxap/packages/commit/90a8624fb704a98d2cfbf9cc13f77a598b52d50c))
|
|
28
|
+
- type import and data property to ts morph library ([91f9abc](https://gitlab.com/rxap/packages/commit/91f9abc3f43f82419b9b8d9b056af5d2e88e3a2c))
|
|
29
|
+
- unify coerce component functions ([3bc1701](https://gitlab.com/rxap/packages/commit/3bc170116d7e794b94ef323251c59579a7887355))
|
|
30
|
+
- unify type import concept ([9cb2f7b](https://gitlab.com/rxap/packages/commit/9cb2f7b07e28eb36849b1f3afdba15989ba17c72))
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
- add CoerceDefaultClassExport function ([a3c89f7](https://gitlab.com/rxap/packages/commit/a3c89f7a7079bcde09980e632fe8edb25fef1ce7))
|
|
35
|
+
- add default find existing element function ([ee18576](https://gitlab.com/rxap/packages/commit/ee18576b1cfd2af4d67ae4b4022d794760115165))
|
|
36
|
+
- add new utility functions ([fbb52c6](https://gitlab.com/rxap/packages/commit/fbb52c60844a0113677094ae5fa6620be2df73b8))
|
|
37
|
+
- add new utility functions ([026e266](https://gitlab.com/rxap/packages/commit/026e266821485602e84030a9e68cd0352c6c0a1e))
|
|
38
|
+
- move WriteType to ts-morph package ([af6357a](https://gitlab.com/rxap/packages/commit/af6357a2f642199dc7807e21e5e369395872d595))
|
|
39
|
+
|
|
6
40
|
# [1.1.0-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.0.1...@rxap/ts-morph@1.1.0-dev.0) (2024-02-09)
|
|
7
41
|
|
|
8
42
|
### Features
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.0-dev.
|
|
2
|
+
"version": "1.1.0-dev.2",
|
|
3
3
|
"name": "@rxap/ts-morph",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "2.6.2"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@rxap/utilities": "^16.0.0",
|
|
9
|
+
"@rxap/utilities": "^16.1.0-dev.0",
|
|
10
10
|
"ts-morph": "^18.0.0",
|
|
11
11
|
"tslib": "2.6.2"
|
|
12
12
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"packageGroup": [
|
|
29
29
|
{
|
|
30
30
|
"package": "@rxap/utilities",
|
|
31
|
-
"version": "16.0.0"
|
|
31
|
+
"version": "16.1.0-dev.0"
|
|
32
32
|
}
|
|
33
33
|
]
|
|
34
34
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"directory": "packages/ts-morph"
|
|
43
43
|
},
|
|
44
44
|
"type": "commonjs",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "58070f2586b30e6bb1a13247cef1330da97279a1",
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"types": "./src/index.d.ts"
|
|
48
48
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -28,25 +28,36 @@ export * from './lib/nest/operation-id-utilities';
|
|
|
28
28
|
export * from './lib/nest/remove-nest-module-provider';
|
|
29
29
|
export * from './lib/nest/remove-nest-provider-to-array';
|
|
30
30
|
export * from './lib/angular/coerce-app-config-provider';
|
|
31
|
+
export * from './lib/angular/coerce-component-import';
|
|
32
|
+
export * from './lib/angular/coerce-component-input';
|
|
31
33
|
export * from './lib/angular/coerce-component';
|
|
34
|
+
export * from './lib/angular/get-component-class';
|
|
35
|
+
export * from './lib/angular/get-component-decorator-object';
|
|
32
36
|
export * from './lib/add-provider-to-array';
|
|
37
|
+
export * from './lib/coerce-accessor-declaration';
|
|
33
38
|
export * from './lib/coerce-array-element';
|
|
34
39
|
export * from './lib/coerce-class-constructor';
|
|
35
40
|
export * from './lib/coerce-class-method';
|
|
36
41
|
export * from './lib/coerce-class-property';
|
|
37
42
|
export * from './lib/coerce-class';
|
|
38
43
|
export * from './lib/coerce-decorator';
|
|
44
|
+
export * from './lib/coerce-default-class-export';
|
|
39
45
|
export * from './lib/coerce-dependency-injection';
|
|
40
46
|
export * from './lib/coerce-imports';
|
|
41
47
|
export * from './lib/coerce-mapping-class-method';
|
|
48
|
+
export * from './lib/coerce-property-declaration';
|
|
42
49
|
export * from './lib/coerce-source-file';
|
|
43
50
|
export * from './lib/coerce-statements';
|
|
44
51
|
export * from './lib/coerce-variable-declaration';
|
|
45
52
|
export * from './lib/create-project';
|
|
53
|
+
export * from './lib/data-property';
|
|
46
54
|
export * from './lib/find-function';
|
|
47
55
|
export * from './lib/get-class-decorator-arguments';
|
|
48
56
|
export * from './lib/get-class';
|
|
49
57
|
export * from './lib/get-coerce-array-literal-form-object-literal';
|
|
58
|
+
export * from './lib/has-constructor-parameter';
|
|
50
59
|
export * from './lib/provider-object';
|
|
51
60
|
export * from './lib/to-mapping-object';
|
|
52
61
|
export * from './lib/type-import';
|
|
62
|
+
export * from './lib/upstream-options';
|
|
63
|
+
export * from './lib/write-type';
|
package/src/index.js
CHANGED
|
@@ -34,29 +34,40 @@ tslib_1.__exportStar(require("./lib/nest/remove-nest-provider-to-array"), export
|
|
|
34
34
|
// endregion
|
|
35
35
|
// region angular
|
|
36
36
|
tslib_1.__exportStar(require("./lib/angular/coerce-app-config-provider"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./lib/angular/coerce-component-import"), exports);
|
|
38
|
+
tslib_1.__exportStar(require("./lib/angular/coerce-component-input"), exports);
|
|
37
39
|
tslib_1.__exportStar(require("./lib/angular/coerce-component"), exports);
|
|
40
|
+
tslib_1.__exportStar(require("./lib/angular/get-component-class"), exports);
|
|
41
|
+
tslib_1.__exportStar(require("./lib/angular/get-component-decorator-object"), exports);
|
|
38
42
|
// endregion
|
|
39
43
|
// region
|
|
40
44
|
tslib_1.__exportStar(require("./lib/add-provider-to-array"), exports);
|
|
45
|
+
tslib_1.__exportStar(require("./lib/coerce-accessor-declaration"), exports);
|
|
41
46
|
tslib_1.__exportStar(require("./lib/coerce-array-element"), exports);
|
|
42
47
|
tslib_1.__exportStar(require("./lib/coerce-class-constructor"), exports);
|
|
43
48
|
tslib_1.__exportStar(require("./lib/coerce-class-method"), exports);
|
|
44
49
|
tslib_1.__exportStar(require("./lib/coerce-class-property"), exports);
|
|
45
50
|
tslib_1.__exportStar(require("./lib/coerce-class"), exports);
|
|
46
51
|
tslib_1.__exportStar(require("./lib/coerce-decorator"), exports);
|
|
52
|
+
tslib_1.__exportStar(require("./lib/coerce-default-class-export"), exports);
|
|
47
53
|
tslib_1.__exportStar(require("./lib/coerce-dependency-injection"), exports);
|
|
48
54
|
tslib_1.__exportStar(require("./lib/coerce-imports"), exports);
|
|
49
55
|
tslib_1.__exportStar(require("./lib/coerce-mapping-class-method"), exports);
|
|
56
|
+
tslib_1.__exportStar(require("./lib/coerce-property-declaration"), exports);
|
|
50
57
|
tslib_1.__exportStar(require("./lib/coerce-source-file"), exports);
|
|
51
58
|
tslib_1.__exportStar(require("./lib/coerce-statements"), exports);
|
|
52
59
|
tslib_1.__exportStar(require("./lib/coerce-variable-declaration"), exports);
|
|
53
60
|
tslib_1.__exportStar(require("./lib/create-project"), exports);
|
|
61
|
+
tslib_1.__exportStar(require("./lib/data-property"), exports);
|
|
54
62
|
tslib_1.__exportStar(require("./lib/find-function"), exports);
|
|
55
63
|
tslib_1.__exportStar(require("./lib/get-class-decorator-arguments"), exports);
|
|
56
64
|
tslib_1.__exportStar(require("./lib/get-class"), exports);
|
|
57
65
|
tslib_1.__exportStar(require("./lib/get-coerce-array-literal-form-object-literal"), exports);
|
|
66
|
+
tslib_1.__exportStar(require("./lib/has-constructor-parameter"), exports);
|
|
58
67
|
tslib_1.__exportStar(require("./lib/provider-object"), exports);
|
|
59
68
|
tslib_1.__exportStar(require("./lib/to-mapping-object"), exports);
|
|
60
69
|
tslib_1.__exportStar(require("./lib/type-import"), exports);
|
|
70
|
+
tslib_1.__exportStar(require("./lib/upstream-options"), exports);
|
|
71
|
+
tslib_1.__exportStar(require("./lib/write-type"), exports);
|
|
61
72
|
// endregion
|
|
62
73
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,yEAA+C;AAC/C,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,YAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,gFAAsD;AACtD,+EAAqD;AACrD,yEAA+C;AAC/C,4EAAkD;AAClD,uFAA6D;AAC7D,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,4EAAkD;AAClD,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,0EAAgD;AAChD,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,iEAAuC;AACvC,2DAAiC;AACjC,YAAY"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TypeImport } from '@rxap/ts-morph';
|
|
2
|
+
import { ClassDeclaration, SourceFile } from 'ts-morph';
|
|
3
|
+
/**
|
|
4
|
+
* Coerces the component import by adding it to the imports array of the component decorator object.
|
|
5
|
+
* If a module specifier is provided, the import is also coerced at the file level.
|
|
6
|
+
*
|
|
7
|
+
* @param sourceFileOrClassDeclaration - The source file or class declaration that contains the component import.
|
|
8
|
+
* @param componentImport - The name or TypeImport of the import to coerce.
|
|
9
|
+
* @returns - The updated imports array after coercing the import.
|
|
10
|
+
*/
|
|
11
|
+
export declare function CoerceComponentImport(sourceFileOrClassDeclaration: SourceFile | ClassDeclaration, componentImport: string | TypeImport): import("ts-morph").ArrayLiteralExpression;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceComponentImport = void 0;
|
|
4
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
5
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
6
|
+
const ts_morph_2 = require("ts-morph");
|
|
7
|
+
const get_coerce_array_literal_form_object_literal_1 = require("../get-coerce-array-literal-form-object-literal");
|
|
8
|
+
const get_component_decorator_object_1 = require("./get-component-decorator-object");
|
|
9
|
+
/**
|
|
10
|
+
* Coerces the component import by adding it to the imports array of the component decorator object.
|
|
11
|
+
* If a module specifier is provided, the import is also coerced at the file level.
|
|
12
|
+
*
|
|
13
|
+
* @param sourceFileOrClassDeclaration - The source file or class declaration that contains the component import.
|
|
14
|
+
* @param componentImport - The name or TypeImport of the import to coerce.
|
|
15
|
+
* @returns - The updated imports array after coercing the import.
|
|
16
|
+
*/
|
|
17
|
+
function CoerceComponentImport(sourceFileOrClassDeclaration, componentImport) {
|
|
18
|
+
var _a;
|
|
19
|
+
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_2.ClassDeclaration ? sourceFileOrClassDeclaration : (0, ts_morph_1.GetComponentClass)(sourceFileOrClassDeclaration);
|
|
20
|
+
const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_2.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
|
|
21
|
+
const importName = typeof componentImport === 'string' ? componentImport : (_a = componentImport.namedImport) !== null && _a !== void 0 ? _a : componentImport.name;
|
|
22
|
+
if ((0, ts_morph_1.IsTypeImport)(componentImport)) {
|
|
23
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, (0, ts_morph_1.TypeImportToImportStructure)(componentImport));
|
|
24
|
+
}
|
|
25
|
+
const componentDecoratorObject = (0, get_component_decorator_object_1.GetComponentDecoratorObject)(classDeclaration);
|
|
26
|
+
const importsArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'imports');
|
|
27
|
+
(0, ts_morph_1.CoerceArrayElement)(importsArray, importName);
|
|
28
|
+
return importsArray;
|
|
29
|
+
}
|
|
30
|
+
exports.CoerceComponentImport = CoerceComponentImport;
|
|
31
|
+
//# sourceMappingURL=coerce-component-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-component-import.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-import.ts"],"names":[],"mappings":";;;AAAA,6CAMwB;AACxB,sDAAkD;AAClD,uCAGkB;AAClB,kHAAyG;AACzG,qFAA+E;AAE/E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,4BAA2D,EAC3D,eAAoC;;IAGpC,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,4BAAiB,EAAC,4BAA4B,CAAC,CAAC;IACnK,MAAM,UAAU,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B,CAAC,aAAa,EAAE,CAAC;IAEpJ,MAAM,UAAU,GAAG,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,eAAe,CAAC,WAAW,mCAAI,eAAe,CAAC,IAAI,CAAC;IAE/H,IAAI,IAAA,uBAAY,EAAC,eAAe,CAAC,EAAE;QACjC,IAAA,8BAAa,EAAC,UAAU,EAAE,IAAA,sCAA2B,EAAC,eAAe,CAAC,CAAC,CAAC;KACzE;IAED,MAAM,wBAAwB,GAAG,IAAA,4DAA2B,EAAC,gBAAgB,CAAC,CAAC;IAE/E,MAAM,YAAY,GAAG,IAAA,qFAAsC,EAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;IAEjG,IAAA,6BAAkB,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAE7C,OAAO,YAAY,CAAC;AAEtB,CAAC;AAtBD,sDAsBC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ClassDeclaration, DecoratableNode, PropertyDeclaration, PropertyNamedNode, SetAccessorDeclaration, SourceFile, WriterFunction } from 'ts-morph';
|
|
2
|
+
import { TypeImport } from '../type-import';
|
|
3
|
+
export interface ComponentInputDefinition {
|
|
4
|
+
alias?: string;
|
|
5
|
+
isRequired?: boolean;
|
|
6
|
+
initializer?: string | WriterFunction;
|
|
7
|
+
asSetAccessor?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SetComponentInputDefinition extends ComponentInputDefinition {
|
|
10
|
+
asSetAccessor: true;
|
|
11
|
+
}
|
|
12
|
+
export type PropertyComponentInputDefinition = Omit<ComponentInputDefinition, 'asSetAccessor'>;
|
|
13
|
+
export declare function CoerceComponentInput(classDeclaration: ClassDeclaration, name: string, type: string | TypeImport | WriterFunction, options?: PropertyComponentInputDefinition): PropertyDeclaration;
|
|
14
|
+
export declare function CoerceComponentInput(sourceFile: SourceFile, name: string, type: string | TypeImport | WriterFunction, options?: PropertyComponentInputDefinition): PropertyDeclaration;
|
|
15
|
+
export declare function CoerceComponentInput(classDeclaration: ClassDeclaration, name: string, type: string | TypeImport | WriterFunction, options?: SetComponentInputDefinition): SetAccessorDeclaration;
|
|
16
|
+
export declare function CoerceComponentInput(sourceFile: SourceFile, name: string, type: string | TypeImport | WriterFunction, options?: SetComponentInputDefinition): SetAccessorDeclaration;
|
|
17
|
+
export declare function CoerceComponentInput(classDeclaration: ClassDeclaration, name: string, type: string | TypeImport | WriterFunction, options?: ComponentInputDefinition): PropertyNamedNode & DecoratableNode;
|
|
18
|
+
export declare function CoerceComponentInput(sourceFile: SourceFile, name: string, type: string | TypeImport | WriterFunction, options?: ComponentInputDefinition): PropertyNamedNode & DecoratableNode;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceComponentInput = void 0;
|
|
4
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
5
|
+
const coerce_accessor_declaration_1 = require("../coerce-accessor-declaration");
|
|
6
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
7
|
+
const ts_morph_2 = require("ts-morph");
|
|
8
|
+
const coerce_property_declaration_1 = require("../coerce-property-declaration");
|
|
9
|
+
const has_constructor_parameter_1 = require("../has-constructor-parameter");
|
|
10
|
+
const get_component_class_1 = require("./get-component-class");
|
|
11
|
+
const write_type_1 = require("../write-type");
|
|
12
|
+
function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initializer, alias, isRequired, asSetAccessor } = {}) {
|
|
13
|
+
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_2.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
|
|
14
|
+
const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_2.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
|
|
15
|
+
if ((0, has_constructor_parameter_1.HasConstructorParameter)(classDeclaration, name, true)) {
|
|
16
|
+
throw new Error(`The component '${classDeclaration.getName()}' already has a constructor parameter that is a class member with the name '${name}'. Cannot add an input with the same name!`);
|
|
17
|
+
}
|
|
18
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
19
|
+
namedImports: ['Input'],
|
|
20
|
+
moduleSpecifier: '@angular/core',
|
|
21
|
+
});
|
|
22
|
+
const inputDecoratorStructure = {
|
|
23
|
+
name: 'Input',
|
|
24
|
+
arguments: [],
|
|
25
|
+
};
|
|
26
|
+
if (alias || isRequired) {
|
|
27
|
+
const inputArgument = {};
|
|
28
|
+
if (alias) {
|
|
29
|
+
inputArgument['alias'] = w => w.quote(alias);
|
|
30
|
+
}
|
|
31
|
+
if (isRequired) {
|
|
32
|
+
inputArgument['required'] = 'true';
|
|
33
|
+
}
|
|
34
|
+
inputDecoratorStructure.arguments = [ts_morph_2.Writers.object(inputArgument)];
|
|
35
|
+
}
|
|
36
|
+
let propertyNode;
|
|
37
|
+
if (asSetAccessor) {
|
|
38
|
+
propertyNode = (0, coerce_accessor_declaration_1.CoerceSetAccessorDeclaration)(classDeclaration, name, { statements: `this._${name} = ${name};` }).set({
|
|
39
|
+
scope: ts_morph_2.Scope.Public,
|
|
40
|
+
parameters: [
|
|
41
|
+
{
|
|
42
|
+
name: name,
|
|
43
|
+
type: (0, write_type_1.WriteType)(type, sourceFile),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
(0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, '_' + name, { scope: ts_morph_2.Scope.Private }).set({
|
|
48
|
+
type: (0, write_type_1.WriteType)(type, sourceFile),
|
|
49
|
+
initializer: initializer,
|
|
50
|
+
hasQuestionToken: !initializer && !isRequired,
|
|
51
|
+
hasExclamationToken: !initializer && isRequired,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
propertyNode = (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, name).set({
|
|
56
|
+
scope: ts_morph_2.Scope.Public,
|
|
57
|
+
type: (0, write_type_1.WriteType)(type, sourceFile),
|
|
58
|
+
initializer,
|
|
59
|
+
hasQuestionToken: !initializer && !isRequired,
|
|
60
|
+
hasExclamationToken: !initializer && isRequired,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
(0, ts_morph_1.CoerceDecorator)(propertyNode, 'Input', inputDecoratorStructure);
|
|
64
|
+
return propertyNode;
|
|
65
|
+
}
|
|
66
|
+
exports.CoerceComponentInput = CoerceComponentInput;
|
|
67
|
+
//# sourceMappingURL=coerce-component-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-component-input.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-input.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AACjD,gFAA8E;AAE9E,sDAE2B;AAC3B,uCAYkB;AAClB,gFAA2E;AAC3E,4EAAuE;AACvE,+DAA0D;AAE1D,8CAA0C;AAoD1C,SAAgB,oBAAoB,CAClC,4BAA2D,EAC3D,IAAY,EACZ,IAA0C,EAC1C,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,KAA+B,EAAE;IAGhF,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,uCAAiB,EAAC,4BAA4B,CAAC,CAAC;IACnK,MAAM,UAAU,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B,CAAC,aAAa,EAA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,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;YACpF,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW,EAAE,WAAW;YACxB,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;SAAM;QAEL,YAAY,GAAG,IAAA,uDAAyB,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC;YACnE,KAAK,EAAE,gBAAK,CAAC,MAAM;YACnB,IAAI,EAAE,IAAA,sBAAS,EAAC,IAAI,EAAE,UAAU,CAAC;YACjC,WAAW;YACX,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;IAED,IAAA,0BAAe,EAAC,YAAY,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC;AAEtB,CAAC;AAxED,oDAwEC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClassDeclarationStructure, ObjectLiteralExpression, OptionalKind, SourceFile } from 'ts-morph';
|
|
2
2
|
export interface CoerceComponentOptions {
|
|
3
3
|
selector?: string;
|
|
4
|
+
prefix?: string;
|
|
4
5
|
template?: string;
|
|
5
6
|
styles?: string;
|
|
6
7
|
/**
|
|
@@ -11,10 +12,9 @@ export interface CoerceComponentOptions {
|
|
|
11
12
|
* true - use the component name to generate a styleUrl
|
|
12
13
|
*/
|
|
13
14
|
styleUrls?: string | string[] | true;
|
|
15
|
+
changeDetection?: 'OnPush' | 'Default';
|
|
14
16
|
}
|
|
15
17
|
export declare function CoerceComponent(sourceFile: SourceFile, name: string, options?: CoerceComponentOptions, classStructure?: Omit<OptionalKind<ClassDeclarationStructure>, 'name'>): {
|
|
16
18
|
classDeclaration: import("ts-morph").ClassDeclaration;
|
|
17
19
|
componentDecoratorObject: ObjectLiteralExpression;
|
|
18
|
-
providersArray: import("ts-morph").ArrayLiteralExpression;
|
|
19
|
-
importsArray: import("ts-morph").ArrayLiteralExpression;
|
|
20
20
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceComponent = void 0;
|
|
4
|
-
const coerce_decorator_1 = require("../coerce-decorator");
|
|
5
4
|
const utilities_1 = require("@rxap/utilities");
|
|
6
5
|
const ts_morph_1 = require("ts-morph");
|
|
7
6
|
const coerce_class_1 = require("../coerce-class");
|
|
8
|
-
const
|
|
7
|
+
const coerce_decorator_1 = require("../coerce-decorator");
|
|
8
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
9
9
|
function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
10
10
|
var _a;
|
|
11
|
-
const className = (0, utilities_1.CoerceSuffix)((0, utilities_1.dasherize)(name), '-component');
|
|
11
|
+
const className = (0, utilities_1.classify)((0, utilities_1.CoerceSuffix)((0, utilities_1.dasherize)(name), '-component'));
|
|
12
|
+
const { prefix, changeDetection, } = options;
|
|
12
13
|
let { selector, template, templateUrl, styles, styleUrls, } = options;
|
|
13
|
-
selector !== null && selector !== void 0 ? selector : (selector = (0, utilities_1.dasherize)(name));
|
|
14
|
-
if (templateUrl === true) {
|
|
14
|
+
selector !== null && selector !== void 0 ? selector : (selector = prefix ? `${prefix}-${(0, utilities_1.dasherize)(name)}` : (0, utilities_1.dasherize)(name));
|
|
15
|
+
if (templateUrl === true || !template) {
|
|
15
16
|
template = undefined;
|
|
16
17
|
templateUrl = `./${(0, utilities_1.dasherize)(name)}.component.html`;
|
|
17
18
|
}
|
|
18
|
-
if (styleUrls === true) {
|
|
19
|
+
if (styleUrls === true || !styles) {
|
|
19
20
|
styles = undefined;
|
|
20
21
|
styleUrls = [`./${(0, utilities_1.dasherize)(name)}.component.scss`];
|
|
21
22
|
}
|
|
@@ -28,23 +29,37 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
|
28
29
|
if (Array.isArray(styleUrls)) {
|
|
29
30
|
styleUrls = `['${styleUrls.join('\',\n\'')}']`;
|
|
30
31
|
}
|
|
31
|
-
if (!(styleUrls === null || styleUrls === void 0 ? void 0 : styleUrls.startsWith('['))) {
|
|
32
|
+
if (styleUrls && !(styleUrls === null || styleUrls === void 0 ? void 0 : styleUrls.startsWith('['))) {
|
|
32
33
|
styleUrls = `[${styleUrls}]`;
|
|
33
34
|
}
|
|
34
35
|
(_a = classStructure.isExported) !== null && _a !== void 0 ? _a : (classStructure.isExported = true);
|
|
35
36
|
const classDeclaration = (0, coerce_class_1.CoerceClass)(sourceFile, className, classStructure);
|
|
37
|
+
const componentOptions = {
|
|
38
|
+
standalone: 'true',
|
|
39
|
+
selector: w => w.quote(selector),
|
|
40
|
+
};
|
|
41
|
+
if (changeDetection) {
|
|
42
|
+
componentOptions['changeDetection'] = `ChangeDetectionStrategy.${changeDetection}`;
|
|
43
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
44
|
+
namedImports: ['Component', 'ChangeDetectionStrategy'],
|
|
45
|
+
moduleSpecifier: '@angular/core',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (template) {
|
|
49
|
+
componentOptions['template'] = w => w.quote(template);
|
|
50
|
+
}
|
|
51
|
+
if (templateUrl) {
|
|
52
|
+
componentOptions['templateUrl'] = w => w.quote(templateUrl);
|
|
53
|
+
}
|
|
54
|
+
if (styles) {
|
|
55
|
+
componentOptions['styles'] = w => w.quote(styles);
|
|
56
|
+
}
|
|
57
|
+
if (styleUrls) {
|
|
58
|
+
componentOptions['styleUrls'] = styleUrls;
|
|
59
|
+
}
|
|
36
60
|
const componentDecoratorDeclaration = (0, coerce_decorator_1.CoerceDecorator)(classDeclaration, 'Component', {
|
|
37
61
|
arguments: [
|
|
38
|
-
ts_morph_1.Writers.object(
|
|
39
|
-
standalone: 'true',
|
|
40
|
-
selector: w => w.quote(selector),
|
|
41
|
-
template: template !== undefined ? w => w.quote(template) : undefined,
|
|
42
|
-
templateUrl: templateUrl !== undefined ? w => w.quote(templateUrl) : undefined,
|
|
43
|
-
styles: styles !== undefined ? w => w.quote(styles) : undefined,
|
|
44
|
-
styleUrls: styleUrls !== undefined ? w => w.quote(styleUrls) : undefined,
|
|
45
|
-
providers: '[]',
|
|
46
|
-
imports: '[]',
|
|
47
|
-
}),
|
|
62
|
+
ts_morph_1.Writers.object(componentOptions),
|
|
48
63
|
]
|
|
49
64
|
});
|
|
50
65
|
const componentDecoratorObject = componentDecoratorDeclaration.getArguments()[0];
|
|
@@ -54,9 +69,7 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
|
54
69
|
if (!(componentDecoratorObject instanceof ts_morph_1.ObjectLiteralExpression)) {
|
|
55
70
|
throw new Error(`Component decorator object for component '${className}' is not an object literal expression`);
|
|
56
71
|
}
|
|
57
|
-
|
|
58
|
-
const importsArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'providers');
|
|
59
|
-
return { classDeclaration, componentDecoratorObject, providersArray, importsArray };
|
|
72
|
+
return { classDeclaration, componentDecoratorObject };
|
|
60
73
|
}
|
|
61
74
|
exports.CoerceComponent = CoerceComponent;
|
|
62
75
|
//# sourceMappingURL=coerce-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAOkB;AAClB,kDAA8C;AAC9C,0DAAsD;AACtD,sDAAkD;AAmBlD,SAAg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;QACnF,SAAS,EAAE;YACT,kBAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;SACjC;KACF,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,6BAA6B,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,CAAC,wBAAwB,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,4DAA6D,SAAU,GAAG,CAAC,CAAC;KAC7F;IACD,IAAI,CAAC,CAAC,wBAAwB,YAAY,kCAAuB,CAAC,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,6CAA8C,SAAU,uCAAuC,CAAC,CAAC;KAClH;IAED,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;AACxD,CAAC;AAzFD,0CAyFC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetComponentClass = void 0;
|
|
4
|
+
function GetComponentClass(sourceFile) {
|
|
5
|
+
const classWithComponent = sourceFile.getClasses().find(cls => cls.getDecorator('Component'));
|
|
6
|
+
if (!classWithComponent) {
|
|
7
|
+
throw new Error('Could not find class with Component decorator!');
|
|
8
|
+
}
|
|
9
|
+
return classWithComponent;
|
|
10
|
+
}
|
|
11
|
+
exports.GetComponentClass = GetComponentClass;
|
|
12
|
+
//# sourceMappingURL=get-component-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-class.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/get-component-class.ts"],"names":[],"mappings":";;;AAKA,SAAgB,iBAAiB,CAAC,UAAsB;IACtD,MAAM,kBAAkB,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;IAE9F,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AARD,8CAQC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetComponentDecoratorObject = void 0;
|
|
4
|
+
const ts_morph_1 = require("@rxap/ts-morph");
|
|
5
|
+
const ts_morph_2 = require("ts-morph");
|
|
6
|
+
function GetComponentDecoratorObject(sourceFileOrClassDeclaration) {
|
|
7
|
+
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_2.ClassDeclaration ? sourceFileOrClassDeclaration : (0, ts_morph_1.GetComponentClass)(sourceFileOrClassDeclaration);
|
|
8
|
+
const componentDecorator = classDeclaration.getDecorator('Component');
|
|
9
|
+
let componentOptions = componentDecorator.getArguments()[0];
|
|
10
|
+
if (!componentOptions) {
|
|
11
|
+
componentOptions = componentDecorator.addArgument(ts_morph_2.Writers.object({}));
|
|
12
|
+
}
|
|
13
|
+
if (!(componentOptions instanceof ts_morph_2.ObjectLiteralExpression)) {
|
|
14
|
+
throw new Error('The Component options is not an object literal expression');
|
|
15
|
+
}
|
|
16
|
+
return componentOptions;
|
|
17
|
+
}
|
|
18
|
+
exports.GetComponentDecoratorObject = GetComponentDecoratorObject;
|
|
19
|
+
//# sourceMappingURL=get-component-decorator-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-decorator-object.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/get-component-decorator-object.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AACnD,uCAKkB;AAElB,SAAgB,2BAA2B,CACzC,4BAA2D;IAG3D,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,4BAAiB,EAAC,4BAA4B,CAAC,CAAC;IAGnK,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,CAAC,WAAW,CAAE,CAAC;IACvE,IAAI,gBAAgB,GAAG,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5D,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,CAAC,kBAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;KACvE;IAED,IAAI,CAAC,CAAC,gBAAgB,YAAY,kCAAuB,CAAC,EAAE;QAC1D,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAC9E;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAnBD,kEAmBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ClassLikeDeclarationBase, GetAccessorDeclaration, GetAccessorDeclarationStructure, SetAccessorDeclaration, SetAccessorDeclarationStructure } from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* Coerces a set accessor declaration within a class-like declaration.
|
|
4
|
+
*
|
|
5
|
+
* @param {ClassLikeDeclarationBase} classLikeDeclaration - The class-like declaration that should contain the set accessor.
|
|
6
|
+
* @param {string} name - The name of the set accessor.
|
|
7
|
+
* @param {Partial<SetAccessorDeclarationStructure>} [structure={}] - Optional structure to set on the set accessor.
|
|
8
|
+
* @returns {SetAccessorDeclaration} - The coerced or added set accessor declaration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function CoerceSetAccessorDeclaration(classLikeDeclaration: ClassLikeDeclarationBase, name: string, structure?: Partial<SetAccessorDeclarationStructure>): SetAccessorDeclaration;
|
|
11
|
+
/**
|
|
12
|
+
* Coerces a get accessor declaration for a class-like declaration.
|
|
13
|
+
*
|
|
14
|
+
* @param {ClassLikeDeclarationBase} classLikeDeclaration - The class-like declaration to coerce the get accessor for.
|
|
15
|
+
* @param {string} name - The name of the get accessor.
|
|
16
|
+
* @param {Partial<GetAccessorDeclarationStructure>} structure - The structure to set on the get accessor declaration. (Optional)
|
|
17
|
+
* @returns {GetAccessorDeclaration} - The coerced or created get accessor declaration.
|
|
18
|
+
*/
|
|
19
|
+
export declare function CoerceGetAccessorDeclaration(classLikeDeclaration: ClassLikeDeclarationBase, name: string, structure?: Partial<GetAccessorDeclarationStructure>): GetAccessorDeclaration;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceGetAccessorDeclaration = exports.CoerceSetAccessorDeclaration = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Coerces a set accessor declaration within a class-like declaration.
|
|
6
|
+
*
|
|
7
|
+
* @param {ClassLikeDeclarationBase} classLikeDeclaration - The class-like declaration that should contain the set accessor.
|
|
8
|
+
* @param {string} name - The name of the set accessor.
|
|
9
|
+
* @param {Partial<SetAccessorDeclarationStructure>} [structure={}] - Optional structure to set on the set accessor.
|
|
10
|
+
* @returns {SetAccessorDeclaration} - The coerced or added set accessor declaration.
|
|
11
|
+
*/
|
|
12
|
+
function CoerceSetAccessorDeclaration(classLikeDeclaration, name, structure = {}) {
|
|
13
|
+
let setAccessorDeclaration = classLikeDeclaration.getSetAccessor(name);
|
|
14
|
+
if (!setAccessorDeclaration) {
|
|
15
|
+
setAccessorDeclaration = classLikeDeclaration.addSetAccessor({ name });
|
|
16
|
+
setAccessorDeclaration.set(structure);
|
|
17
|
+
}
|
|
18
|
+
return setAccessorDeclaration;
|
|
19
|
+
}
|
|
20
|
+
exports.CoerceSetAccessorDeclaration = CoerceSetAccessorDeclaration;
|
|
21
|
+
/**
|
|
22
|
+
* Coerces a get accessor declaration for a class-like declaration.
|
|
23
|
+
*
|
|
24
|
+
* @param {ClassLikeDeclarationBase} classLikeDeclaration - The class-like declaration to coerce the get accessor for.
|
|
25
|
+
* @param {string} name - The name of the get accessor.
|
|
26
|
+
* @param {Partial<GetAccessorDeclarationStructure>} structure - The structure to set on the get accessor declaration. (Optional)
|
|
27
|
+
* @returns {GetAccessorDeclaration} - The coerced or created get accessor declaration.
|
|
28
|
+
*/
|
|
29
|
+
function CoerceGetAccessorDeclaration(classLikeDeclaration, name, structure = {}) {
|
|
30
|
+
let getAccessorDeclaration = classLikeDeclaration.getGetAccessor(name);
|
|
31
|
+
if (!getAccessorDeclaration) {
|
|
32
|
+
getAccessorDeclaration = classLikeDeclaration.addGetAccessor({ name });
|
|
33
|
+
getAccessorDeclaration.set(structure);
|
|
34
|
+
}
|
|
35
|
+
return getAccessorDeclaration;
|
|
36
|
+
}
|
|
37
|
+
exports.CoerceGetAccessorDeclaration = CoerceGetAccessorDeclaration;
|
|
38
|
+
//# sourceMappingURL=coerce-accessor-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-accessor-declaration.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-accessor-declaration.ts"],"names":[],"mappings":";;;AAQA;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,oBAA8C,EAC9C,IAAY,EACZ,YAAsD,EAAE;IAExD,IAAI,sBAAsB,GAAG,oBAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACvE,IAAI,CAAC,sBAAsB,EAAE;QAC3B,sBAAsB,GAAG,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KACvC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAXD,oEAWC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,oBAA8C,EAC9C,IAAY,EACZ,YAAsD,EAAE;IAExD,IAAI,sBAAsB,GAAG,oBAAoB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACvE,IAAI,CAAC,sBAAsB,EAAE;QAC3B,sBAAsB,GAAG,oBAAoB,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KACvC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAXD,oEAWC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ArrayLiteralExpression, Expression, WriterFunction } from 'ts-morph';
|
|
2
2
|
export declare function FindArrayElementByObjectProperty(property: string, value: string): (e: Expression) => boolean;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function DefaultFindExistingElement(element: string): (e: Expression) => boolean;
|
|
4
|
+
export declare function CoerceArrayElement(array: ArrayLiteralExpression, element: string | WriterFunction, findExisting?: (e: Expression) => boolean, insertAt?: (array: ArrayLiteralExpression) => number): Expression;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CoerceArrayElement = exports.FindArrayElementByObjectProperty = void 0;
|
|
3
|
+
exports.CoerceArrayElement = exports.DefaultFindExistingElement = exports.FindArrayElementByObjectProperty = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
5
|
function FindArrayElementByObjectProperty(property, value) {
|
|
6
6
|
return (e) => {
|
|
@@ -17,7 +17,19 @@ function FindArrayElementByObjectProperty(property, value) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
exports.FindArrayElementByObjectProperty = FindArrayElementByObjectProperty;
|
|
20
|
-
function
|
|
20
|
+
function DefaultFindExistingElement(element) {
|
|
21
|
+
return (e) => e.getText().trim() === element;
|
|
22
|
+
}
|
|
23
|
+
exports.DefaultFindExistingElement = DefaultFindExistingElement;
|
|
24
|
+
function CoerceArrayElement(array, element, findExisting, insertAt) {
|
|
25
|
+
if (!findExisting) {
|
|
26
|
+
if (typeof element === 'string') {
|
|
27
|
+
findExisting = DefaultFindExistingElement(element);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error('The findExisting function is required or the element must be a string!');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
21
33
|
for (const e of array.getElements()) {
|
|
22
34
|
if (findExisting(e)) {
|
|
23
35
|
return e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-array-element.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-array-element.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,SAAgB,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,CAAC,CAAa,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,kCAAuB,EAAE;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,YAAY,6BAAkB,EAAE;gBACxC,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC;gBAC3D,IAAI,CAAC,EAAE;oBACL,OAAO,CAAC,CAAC,cAAc,EAAE,KAAK,KAAK,CAAC;iBACrC;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,4EAaC;AAED,SAAgB,kBAAkB,CAChC,KAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"coerce-array-element.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-array-element.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,SAAgB,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,CAAC,CAAa,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,kCAAuB,EAAE;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,YAAY,6BAAkB,EAAE;gBACxC,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC;gBAC3D,IAAI,CAAC,EAAE;oBACL,OAAO,CAAC,CAAC,cAAc,EAAE,KAAK,KAAK,CAAC;iBACrC;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,4EAaC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,OAAO,CAAC;AAC3D,CAAC;AAFD,gEAEC;AAED,SAAgB,kBAAkB,CAChC,KAA6B,EAC7B,OAAgC,EAChC,YAAyC,EACzC,QAAoD;IAGpD,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;SACpD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;SAC3F;KACF;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;QACnC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE;YACnB,OAAO,CAAC,CAAC;SACV;KACF;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAEnC,CAAC;AA3BD,gDA2BC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { ClassDeclaration, OptionalKind, PropertyDeclaration, PropertyDeclarationStructure } from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated instead use the CoercePropertyDeclaration function from @rxap/ts-morph
|
|
4
|
+
*/
|
|
2
5
|
export declare function CoerceClassProperty(classDeclaration: ClassDeclaration, propertyName: string, propertyStructure: Omit<OptionalKind<PropertyDeclarationStructure>, 'name'>): PropertyDeclaration;
|