@ngx-formbar/core 0.11.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.
Files changed (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/fesm2022/ngx-formbar-core.mjs +2429 -0
  4. package/fesm2022/ngx-formbar-core.mjs.map +1 -0
  5. package/index.d.ts +5 -0
  6. package/lib/components/form/ngxfb-form.component.d.ts +28 -0
  7. package/lib/composables/computed-value.d.ts +8 -0
  8. package/lib/composables/disabled.state.d.ts +36 -0
  9. package/lib/composables/dynamic-label.d.ts +9 -0
  10. package/lib/composables/dynamic-title.d.ts +9 -0
  11. package/lib/composables/hidden.state.d.ts +68 -0
  12. package/lib/composables/readonly.state.d.ts +19 -0
  13. package/lib/composables/testId.d.ts +16 -0
  14. package/lib/composables/update-strategy.d.ts +20 -0
  15. package/lib/composables/validators.d.ts +22 -0
  16. package/lib/config/config.d.ts +7 -0
  17. package/lib/config/provide-formbar.d.ts +38 -0
  18. package/lib/directives/ngxfb-abstract-control.directive.d.ts +53 -0
  19. package/lib/directives/ngxfb-block.directive.d.ts +124 -0
  20. package/lib/directives/ngxfb-control.directive.d.ts +203 -0
  21. package/lib/directives/ngxfb-group.directive.d.ts +253 -0
  22. package/lib/helper/control-container-view-providers.d.ts +33 -0
  23. package/lib/index.d.ts +23 -0
  24. package/lib/services/component-registration.service.d.ts +8 -0
  25. package/lib/services/configuration.service.d.ts +8 -0
  26. package/lib/services/expression.service.d.ts +148 -0
  27. package/lib/services/form.service.d.ts +10 -0
  28. package/lib/services/validator-registration.service.d.ts +10 -0
  29. package/lib/tokens/component-registrations.d.ts +2 -0
  30. package/lib/tokens/component-resolver.d.ts +3 -0
  31. package/lib/tokens/default-update-strategy.d.ts +3 -0
  32. package/lib/tokens/global-config.d.ts +5 -0
  33. package/lib/tokens/validator-registrations.d.ts +8 -0
  34. package/lib/tokens/validator-resolver.d.ts +3 -0
  35. package/lib/types/component-resolver.type.d.ts +4 -0
  36. package/lib/types/content.type.d.ts +137 -0
  37. package/lib/types/expression.type.d.ts +2 -0
  38. package/lib/types/form.type.d.ts +4 -0
  39. package/lib/types/functions.type.d.ts +4 -0
  40. package/lib/types/global-configuration.type.d.ts +4 -0
  41. package/lib/types/provide.type.d.ts +42 -0
  42. package/lib/types/registration.type.d.ts +18 -0
  43. package/lib/types/validation.type.d.ts +59 -0
  44. package/lib/types/validator-resolver.type.d.ts +6 -0
  45. package/package.json +52 -0
  46. package/public-api.d.ts +1 -0
  47. package/schematics/block/files/__componentName@dasherize__.component.html.template +1 -0
  48. package/schematics/block/files/__componentName@dasherize__.component.ts.template +29 -0
  49. package/schematics/block/files/__interfaceName@dasherize__.type.ts.template +6 -0
  50. package/schematics/block/index.d.ts +3 -0
  51. package/schematics/block/index.js +11 -0
  52. package/schematics/block/index.js.map +1 -0
  53. package/schematics/block/schema.json +62 -0
  54. package/schematics/collection.json +31 -0
  55. package/schematics/control/files/__componentName@dasherize__.component.html.template +0 -0
  56. package/schematics/control/files/__componentName@dasherize__.component.ts.template +29 -0
  57. package/schematics/control/files/__interfaceName@dasherize__.type.ts.template +6 -0
  58. package/schematics/control/index.d.ts +3 -0
  59. package/schematics/control/index.js +11 -0
  60. package/schematics/control/index.js.map +1 -0
  61. package/schematics/control/schema.json +61 -0
  62. package/schematics/group/files/__componentName@dasherize__.component.html.template +5 -0
  63. package/schematics/group/files/__componentName@dasherize__.component.ts.template +29 -0
  64. package/schematics/group/files/__interfaceName@dasherize__.type.ts.template +5 -0
  65. package/schematics/group/index.d.ts +3 -0
  66. package/schematics/group/index.js +11 -0
  67. package/schematics/group/index.js.map +1 -0
  68. package/schematics/group/schema.json +62 -0
  69. package/schematics/ng-add/files/config-registrations/async-validator-registrations.ts.template +4 -0
  70. package/schematics/ng-add/files/config-registrations/component-registrations.ts.template +4 -0
  71. package/schematics/ng-add/files/config-registrations/index.ts.template +3 -0
  72. package/schematics/ng-add/files/config-registrations/validator-registrations.ts.template +4 -0
  73. package/schematics/ng-add/files/helper/block.host-directive.ts.template +6 -0
  74. package/schematics/ng-add/files/helper/control.host-directive.ts.template +6 -0
  75. package/schematics/ng-add/files/helper/group.host-directive.ts.template +6 -0
  76. package/schematics/ng-add/files/helper/index.ts.template +4 -0
  77. package/schematics/ng-add/files/helper/view-provider.ts.template +9 -0
  78. package/schematics/ng-add/files/provider-config/config/__providerConfigFileName__.ts.template +9 -0
  79. package/schematics/ng-add/files/provider-config/inline/__providerConfigFileName__.ts.template +8 -0
  80. package/schematics/ng-add/files/provider-config/token/__providerConfigFileName__.ts.template +4 -0
  81. package/schematics/ng-add/files/schematics-config/__schematicConfigFileName__.json.template +1 -0
  82. package/schematics/ng-add/files/token-registrations/async-validator-registrations.ts.template +8 -0
  83. package/schematics/ng-add/files/token-registrations/component-registrations.ts.template +8 -0
  84. package/schematics/ng-add/files/token-registrations/index.ts.template +3 -0
  85. package/schematics/ng-add/files/token-registrations/validator-registrations.ts.template +8 -0
  86. package/schematics/ng-add/helper.d.ts +11 -0
  87. package/schematics/ng-add/helper.js +198 -0
  88. package/schematics/ng-add/helper.js.map +1 -0
  89. package/schematics/ng-add/index.d.ts +3 -0
  90. package/schematics/ng-add/index.js +68 -0
  91. package/schematics/ng-add/index.js.map +1 -0
  92. package/schematics/ng-add/rules/create-config-registration-files.rule.d.ts +3 -0
  93. package/schematics/ng-add/rules/create-config-registration-files.rule.js +32 -0
  94. package/schematics/ng-add/rules/create-config-registration-files.rule.js.map +1 -0
  95. package/schematics/ng-add/rules/create-formbar-registration-config.rule.d.ts +3 -0
  96. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js +30 -0
  97. package/schematics/ng-add/rules/create-formbar-registration-config.rule.js.map +1 -0
  98. package/schematics/ng-add/rules/create-helper-files.rule.d.ts +6 -0
  99. package/schematics/ng-add/rules/create-helper-files.rule.js +22 -0
  100. package/schematics/ng-add/rules/create-helper-files.rule.js.map +1 -0
  101. package/schematics/ng-add/rules/create-schematics-config.rule.d.ts +3 -0
  102. package/schematics/ng-add/rules/create-schematics-config.rule.js +42 -0
  103. package/schematics/ng-add/rules/create-schematics-config.rule.js.map +1 -0
  104. package/schematics/ng-add/rules/create-token-registration-files.rule.d.ts +3 -0
  105. package/schematics/ng-add/rules/create-token-registration-files.rule.js +32 -0
  106. package/schematics/ng-add/rules/create-token-registration-files.rule.js.map +1 -0
  107. package/schematics/ng-add/rules/include-templates.rule.d.ts +3 -0
  108. package/schematics/ng-add/rules/include-templates.rule.js +11 -0
  109. package/schematics/ng-add/rules/include-templates.rule.js.map +1 -0
  110. package/schematics/ng-add/rules/install-dependencies.rule.d.ts +2 -0
  111. package/schematics/ng-add/rules/install-dependencies.rule.js +12 -0
  112. package/schematics/ng-add/rules/install-dependencies.rule.js.map +1 -0
  113. package/schematics/ng-add/rules/update-app-config.rule.d.ts +3 -0
  114. package/schematics/ng-add/rules/update-app-config.rule.js +48 -0
  115. package/schematics/ng-add/rules/update-app-config.rule.js.map +1 -0
  116. package/schematics/ng-add/rules/update-schematics-config.rule.d.ts +6 -0
  117. package/schematics/ng-add/rules/update-schematics-config.rule.js +28 -0
  118. package/schematics/ng-add/rules/update-schematics-config.rule.js.map +1 -0
  119. package/schematics/ng-add/schema.d.ts +23 -0
  120. package/schematics/ng-add/schema.js +3 -0
  121. package/schematics/ng-add/schema.js.map +1 -0
  122. package/schematics/ng-add/schema.json +81 -0
  123. package/schematics/register/component-info.type.d.ts +11 -0
  124. package/schematics/register/component-info.type.js +3 -0
  125. package/schematics/register/component-info.type.js.map +1 -0
  126. package/schematics/register/discover-components.d.ts +19 -0
  127. package/schematics/register/discover-components.js +267 -0
  128. package/schematics/register/discover-components.js.map +1 -0
  129. package/schematics/register/index.d.ts +3 -0
  130. package/schematics/register/index.js +49 -0
  131. package/schematics/register/index.js.map +1 -0
  132. package/schematics/register/register-components.d.ts +3 -0
  133. package/schematics/register/register-components.js +38 -0
  134. package/schematics/register/register-components.js.map +1 -0
  135. package/schematics/register/schema.d.ts +14 -0
  136. package/schematics/register/schema.js +3 -0
  137. package/schematics/register/schema.js.map +1 -0
  138. package/schematics/register/schema.json +44 -0
  139. package/schematics/shared/ast/decorators.d.ts +9 -0
  140. package/schematics/shared/ast/decorators.js +182 -0
  141. package/schematics/shared/ast/decorators.js.map +1 -0
  142. package/schematics/shared/ast/imports.d.ts +3 -0
  143. package/schematics/shared/ast/imports.js +93 -0
  144. package/schematics/shared/ast/imports.js.map +1 -0
  145. package/schematics/shared/ast/parse.d.ts +3 -0
  146. package/schematics/shared/ast/parse.js +17 -0
  147. package/schematics/shared/ast/parse.js.map +1 -0
  148. package/schematics/shared/ast/registrations.d.ts +22 -0
  149. package/schematics/shared/ast/registrations.js +654 -0
  150. package/schematics/shared/ast/registrations.js.map +1 -0
  151. package/schematics/shared/ast/types.d.ts +3 -0
  152. package/schematics/shared/ast/types.js +58 -0
  153. package/schematics/shared/ast/types.js.map +1 -0
  154. package/schematics/shared/file.d.ts +4 -0
  155. package/schematics/shared/file.js +60 -0
  156. package/schematics/shared/file.js.map +1 -0
  157. package/schematics/shared/helper.d.ts +2 -0
  158. package/schematics/shared/helper.js +29 -0
  159. package/schematics/shared/helper.js.map +1 -0
  160. package/schematics/shared/rules/create-component.rule.d.ts +3 -0
  161. package/schematics/shared/rules/create-component.rule.js +15 -0
  162. package/schematics/shared/rules/create-component.rule.js.map +1 -0
  163. package/schematics/shared/rules/register-control.rule.d.ts +3 -0
  164. package/schematics/shared/rules/register-control.rule.js +30 -0
  165. package/schematics/shared/rules/register-control.rule.js.map +1 -0
  166. package/schematics/shared/rules/register-type-map.rule.d.ts +3 -0
  167. package/schematics/shared/rules/register-type-map.rule.js +46 -0
  168. package/schematics/shared/rules/register-type-map.rule.js.map +1 -0
  169. package/schematics/shared/rules/register-type-token.rule.d.ts +3 -0
  170. package/schematics/shared/rules/register-type-token.rule.js +49 -0
  171. package/schematics/shared/rules/register-type-token.rule.js.map +1 -0
  172. package/schematics/shared/rules/scaffold-and-register.rule.d.ts +3 -0
  173. package/schematics/shared/rules/scaffold-and-register.rule.js +134 -0
  174. package/schematics/shared/rules/scaffold-and-register.rule.js.map +1 -0
  175. package/schematics/shared/schema.d.ts +32 -0
  176. package/schematics/shared/schema.js +3 -0
  177. package/schematics/shared/schema.js.map +1 -0
  178. package/schematics/tests/generators.spec.d.ts +1 -0
  179. package/schematics/tests/generators.spec.js +450 -0
  180. package/schematics/tests/generators.spec.js.map +1 -0
  181. package/schematics/tests/helper.d.ts +20 -0
  182. package/schematics/tests/helper.js +275 -0
  183. package/schematics/tests/helper.js.map +1 -0
  184. package/schematics/tests/ng-add.spec.d.ts +1 -0
  185. package/schematics/tests/ng-add.spec.js +380 -0
  186. package/schematics/tests/ng-add.spec.js.map +1 -0
  187. package/schematics/tests/register.spec.d.ts +1 -0
  188. package/schematics/tests/register.spec.js +340 -0
  189. package/schematics/tests/register.spec.js.map +1 -0
  190. package/schematics/tests/workspace-setup.d.ts +21 -0
  191. package/schematics/tests/workspace-setup.js +255 -0
  192. package/schematics/tests/workspace-setup.js.map +1 -0
  193. package/shared/ast.d.ts +10 -0
  194. package/shared/ast.js +93 -0
  195. package/shared/ast.js.map +1 -0
  196. package/shared/constants.d.ts +16 -0
  197. package/shared/constants.js +20 -0
  198. package/shared/constants.js.map +1 -0
  199. package/shared/shared-config.type.d.ts +20 -0
  200. package/shared/shared-config.type.js +3 -0
  201. package/shared/shared-config.type.js.map +1 -0
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discoverComponents = discoverComponents;
4
+ exports.findPotentialControlComponents = findPotentialControlComponents;
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const typescript_1 = require("typescript");
7
+ const strings_1 = require("@angular-devkit/core/src/utils/strings");
8
+ const alwaysExclude = ['**/node_modules/**', '**/*.spec.ts'];
9
+ const defaultIncludes = ['**/*.ts'];
10
+ function discoverComponents(tree, registerContext, context) {
11
+ const { exclude = [], include = [...defaultIncludes] } = registerContext;
12
+ const resolvedExcludes = [...exclude, ...alwaysExclude];
13
+ const files = findPotentialControlComponents(tree, include, resolvedExcludes);
14
+ registerContext.components = toComponentInfo(tree, files, context);
15
+ context.logger.info(`${registerContext.components.length.toString()} components discovered`);
16
+ return registerContext;
17
+ }
18
+ function toComponentInfo(tree, files, context) {
19
+ const components = [];
20
+ for (const filePath of files) {
21
+ try {
22
+ const buffer = tree.read(filePath);
23
+ if (!buffer) {
24
+ continue;
25
+ }
26
+ const fileContent = buffer.toString('utf-8');
27
+ // Fast prefilter: only parse likely candidates
28
+ if (!fileContent.includes('@Component')) {
29
+ continue;
30
+ }
31
+ const hasNgxFbHints = fileContent.includes('hostDirectives') ||
32
+ fileContent.toLowerCase().includes('ngxfb');
33
+ if (!hasNgxFbHints) {
34
+ continue;
35
+ }
36
+ const sourceFile = (0, typescript_1.createSourceFile)(filePath, fileContent, typescript_1.ScriptTarget.Latest, false);
37
+ const discoveredComponents = analyzeSourceFile(sourceFile, filePath);
38
+ if (discoveredComponents.length > 0) {
39
+ components.push(...discoveredComponents);
40
+ }
41
+ }
42
+ catch (error) {
43
+ context.logger.error(`Error processing file ${filePath}:`, error);
44
+ }
45
+ }
46
+ return components;
47
+ }
48
+ /**
49
+ * Find files whose paths match any of the *glob* include patterns
50
+ * and none of the *glob* exclude patterns.
51
+ *
52
+ * Supported glob features:
53
+ * - ** : recursive across path segments
54
+ * - * : any sequence within a single path segment (excludes '/')
55
+ * - ? : any single char within a segment (excludes '/')
56
+ * - [] : character class / ranges (e.g., [a-zA-Z0-9_])
57
+ *
58
+ * Notes:
59
+ * - Matching is done against the full POSIX-like path from Tree (e.g., "/src/app/a.ts").
60
+ * - Patterns are compiled once to RegExp for speed.
61
+ * - No extra dependencies.
62
+ */
63
+ function findPotentialControlComponents(tree, include, exclude = []) {
64
+ if (include.length === 0) {
65
+ return [];
66
+ }
67
+ const includeRegs = compileGlobs(include, 'include');
68
+ const excludeRegs = compileGlobs(exclude, 'exclude');
69
+ const out = new Set();
70
+ const quickReject = (p) => {
71
+ if (p.includes('/node_modules/')) {
72
+ return true;
73
+ }
74
+ return p.endsWith('.spec.ts');
75
+ };
76
+ tree.getDir('/').visit((path) => {
77
+ if (quickReject(path)) {
78
+ return;
79
+ }
80
+ if (excludeRegs.length > 0 && someRegMatch(excludeRegs, path)) {
81
+ return;
82
+ }
83
+ if (!someRegMatch(includeRegs, path)) {
84
+ return;
85
+ }
86
+ out.add(path);
87
+ });
88
+ return Array.from(out).sort();
89
+ }
90
+ /** Compile glob patterns to anchored RegExp. */
91
+ function compileGlobs(patterns, kind) {
92
+ const regs = [];
93
+ if (patterns.length === 0) {
94
+ return regs;
95
+ }
96
+ for (const raw of patterns) {
97
+ if (!raw || raw.trim() === '') {
98
+ throw new schematics_1.SchematicsException(`Empty ${kind} glob pattern is not allowed.`);
99
+ }
100
+ const rx = globToRegExp(raw);
101
+ if (!rx) {
102
+ throw new schematics_1.SchematicsException(`Invalid ${kind} glob "${raw}".`);
103
+ }
104
+ regs.push(rx);
105
+ }
106
+ return regs;
107
+ }
108
+ function someRegMatch(regs, input) {
109
+ if (regs.length === 0) {
110
+ return false;
111
+ }
112
+ for (const r of regs) {
113
+ if (r.test(input)) {
114
+ return true;
115
+ }
116
+ }
117
+ return false;
118
+ }
119
+ /**
120
+ * Convert a glob into a **path-aware** RegExp.
121
+ * Rules:
122
+ * - '**' -> '.*' (may cross '/')
123
+ * - '*' -> '[^/]*'
124
+ * - '?' -> '[^/]'
125
+ * - '[]' -> preserved (with minimal validation)
126
+ * - escape regex metachars elsewhere
127
+ * - anchored with ^...$ for full-path match
128
+ */
129
+ function globToRegExp(glob) {
130
+ if (!glob) {
131
+ return undefined;
132
+ }
133
+ let rx = '^';
134
+ let i = 0;
135
+ while (i < glob.length) {
136
+ const ch = glob[i];
137
+ // Handle '**' specially (before '*').
138
+ if (ch === '*' && i + 1 < glob.length && glob[i + 1] === '*') {
139
+ while (i + 1 < glob.length && glob[i] === '*' && glob[i + 1] === '*') {
140
+ i += 1;
141
+ }
142
+ rx += '.*';
143
+ i += 2;
144
+ continue;
145
+ }
146
+ switch (ch) {
147
+ case '*': {
148
+ rx += '[^/]*';
149
+ i += 1;
150
+ break;
151
+ }
152
+ case '?': {
153
+ rx += '[^/]';
154
+ i += 1;
155
+ break;
156
+ }
157
+ case '[': {
158
+ const end = glob.indexOf(']', i + 1);
159
+ if (end === -1) {
160
+ rx += '\\[';
161
+ i += 1;
162
+ break;
163
+ }
164
+ const cls = glob.slice(i, end + 1);
165
+ if (cls.includes('/')) {
166
+ rx += '\\[';
167
+ i += 1;
168
+ break;
169
+ }
170
+ rx += cls;
171
+ i = end + 1;
172
+ break;
173
+ }
174
+ case '\\':
175
+ case '.':
176
+ case '+':
177
+ case '^':
178
+ case '$':
179
+ case '{':
180
+ case '}':
181
+ case '(':
182
+ case ')':
183
+ case '|': {
184
+ rx += '\\' + ch;
185
+ i += 1;
186
+ break;
187
+ }
188
+ default: {
189
+ rx += ch;
190
+ i += 1;
191
+ break;
192
+ }
193
+ }
194
+ }
195
+ rx += '$';
196
+ try {
197
+ return new RegExp(rx);
198
+ }
199
+ catch (_a) {
200
+ return undefined;
201
+ }
202
+ }
203
+ /**
204
+ * Analyzes a TypeScript source file to find components with Ngx Formbar directives
205
+ */
206
+ function analyzeSourceFile(sourceFile, filePath) {
207
+ const components = [];
208
+ for (const stmt of sourceFile.statements) {
209
+ if (!(0, typescript_1.isClassDeclaration)(stmt)) {
210
+ continue;
211
+ }
212
+ const decorators = (0, typescript_1.getDecorators)(stmt);
213
+ if (!decorators || decorators.length === 0) {
214
+ continue;
215
+ }
216
+ const componentDecorator = decorators.find((decorator) => {
217
+ const decoratorName = getDecoratorName(decorator);
218
+ return decoratorName === 'Component';
219
+ });
220
+ if (!componentDecorator || !stmt.name) {
221
+ continue;
222
+ }
223
+ const componentInfo = extractComponentInfo(stmt, componentDecorator, filePath);
224
+ if (componentInfo) {
225
+ components.push(componentInfo);
226
+ }
227
+ }
228
+ return components;
229
+ }
230
+ /** Get a decorator's identifier name (e.g., 'Component') */
231
+ function getDecoratorName(decorator) {
232
+ if (!(0, typescript_1.isCallExpression)(decorator.expression)) {
233
+ return undefined;
234
+ }
235
+ const callee = decorator.expression.expression;
236
+ if ((0, typescript_1.isIdentifier)(callee)) {
237
+ return callee.text;
238
+ }
239
+ return undefined;
240
+ }
241
+ /**
242
+ * Extracts component information from a component declaration.
243
+ */
244
+ function extractComponentInfo(classNode, componentDecorator, filePath) {
245
+ var _a;
246
+ if (!(0, typescript_1.isCallExpression)(componentDecorator.expression)) {
247
+ return undefined;
248
+ }
249
+ const className = (_a = classNode.name) === null || _a === void 0 ? void 0 : _a.text;
250
+ if (!className) {
251
+ return undefined;
252
+ }
253
+ const keyBase = stripComponentSuffix(className);
254
+ const key = (0, strings_1.dasherize)(keyBase);
255
+ return {
256
+ componentFilePath: filePath,
257
+ componentClassName: className,
258
+ key,
259
+ };
260
+ }
261
+ function stripComponentSuffix(name) {
262
+ if (!name.endsWith('Component')) {
263
+ return name;
264
+ }
265
+ return name.slice(0, name.length - 'Component'.length);
266
+ }
267
+ //# sourceMappingURL=discover-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover-components.js","sourceRoot":"","sources":["../../../../projects/core/automation/schematics/register/discover-components.ts"],"names":[],"mappings":";;AAwBA,gDAgBC;AAoED,wEAsCC;AAlJD,2DAIoC;AAEpC,2CAUoB;AAEpB,oEAAmE;AAGnE,MAAM,aAAa,GAAG,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG,CAAC,SAAS,CAAC,CAAC;AAEpC,SAAgB,kBAAkB,CAChC,IAAU,EACV,eAAgC,EAChC,OAAyB;IAEzB,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,EAAE,GAAG,eAAe,CAAC;IACzE,MAAM,gBAAgB,GAAG,CAAC,GAAG,OAAO,EAAE,GAAG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CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,IAAA,mBAAS,EAAC,OAAO,CAAC,CAAC;IAE/B,OAAO;QACL,iBAAiB,EAAE,QAAQ;QAC3B,kBAAkB,EAAE,SAAS;QAC7B,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { DiscoverOptions } from './schema';
3
+ export declare function register(options: DiscoverOptions): Rule;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.register = register;
13
+ const schematics_1 = require("@angular-devkit/schematics");
14
+ const discover_components_1 = require("./discover-components");
15
+ const register_components_1 = require("./register-components");
16
+ const file_1 = require("../shared/file");
17
+ const constants_1 = require("../../shared/constants");
18
+ const helper_1 = require("../shared/helper");
19
+ function register(options) {
20
+ let registerContext;
21
+ const mergeConfigs = (tree) => __awaiter(this, void 0, void 0, function* () {
22
+ const project = yield (0, helper_1.getProject)(tree, options.project);
23
+ registerContext = mergeOptions(options, project, tree);
24
+ return tree;
25
+ });
26
+ const discover = (tree, context) => {
27
+ registerContext = (0, discover_components_1.discoverComponents)(tree, registerContext, context);
28
+ return tree;
29
+ };
30
+ const register = (tree, context) => {
31
+ return (0, register_components_1.registerComponents)(tree, registerContext, context);
32
+ };
33
+ return (0, schematics_1.chain)([mergeConfigs, discover, register]);
34
+ }
35
+ function mergeOptions(options, project, tree) {
36
+ var _a, _b;
37
+ const projectRoot = (_a = project.sourceRoot) !== null && _a !== void 0 ? _a : project.root;
38
+ const automationConfigPath = options.schematicsConfig
39
+ ? `/${projectRoot}/${options.schematicsConfig}`
40
+ : (0, file_1.findSchematicsConfig)(tree);
41
+ const automationConfig = (0, file_1.readFile)(tree, automationConfigPath);
42
+ const discoverConfig = automationConfig ? automationConfig.discovery : {};
43
+ const controlRegistrations = (automationConfig === null || automationConfig === void 0 ? void 0 : automationConfig.controlRegistrationsPath)
44
+ ? `/${projectRoot}/${automationConfig.controlRegistrationsPath}`
45
+ : (0, file_1.findConfigPath)(tree, projectRoot);
46
+ const mergedConfig = Object.assign(Object.assign(Object.assign({}, options), discoverConfig), { controlRegistrations, registrationType: (_b = automationConfig === null || automationConfig === void 0 ? void 0 : automationConfig.registrationType) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_REGISTRATION_TYPE, components: [] });
47
+ return mergedConfig;
48
+ }
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/core/automation/schematics/register/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAgBA,4BAmBC;AAnCD,2DAKoC;AAEpC,+DAA2D;AAE3D,+DAA2D;AAE3D,yCAAgF;AAChF,sDAAmE;AACnE,6CAA8C;AAG9C,SAAgB,QAAQ,CAAC,OAAwB;IAC/C,IAAI,eAAgC,CAAC;IAErC,MAAM,YAAY,GAAS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,gBAAgB,CAAE,wBAAwB;QACrE,CAAC,CAAC,IAAI,WAAW,IAAI,gBAAgB,CAAC,wBAAwB,EAAE;QAChE,CAAC,CAAC,IAAA,qBAAc,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEtC,MAAM,YAAY,iDACb,OAAO,GACP,cAAc,KACjB,oBAAoB,EACpB,gBAAgB,EACd,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,gBAAgB,mCAAI,qCAAyB,EACjE,UAAU,EAAE,EAAE,GACf,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
+ import { RegisterContext } from './schema';
3
+ export declare function registerComponents(tree: Tree, registerContext: RegisterContext | undefined, context: SchematicContext): import("@angular-devkit/schematics/src/tree/interface").Tree | Rule | undefined;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerComponents = registerComponents;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const register_type_token_rule_1 = require("../shared/rules/register-type-token.rule");
6
+ const register_type_map_rule_1 = require("../shared/rules/register-type-map.rule");
7
+ function registerComponents(tree, registerContext, context) {
8
+ if (!registerContext) {
9
+ context.logger.error('Component registration failed, because no proper context was generated!');
10
+ return;
11
+ }
12
+ const { controlRegistrations } = registerContext;
13
+ if (!controlRegistrations) {
14
+ context.logger.warn('No file for registrations could be found. Skipping registration.');
15
+ return tree;
16
+ }
17
+ return registerComponentsByComponentInfo(registerContext);
18
+ }
19
+ function registerComponentsByComponentInfo(registerContext) {
20
+ const { components, registrationType, controlRegistrations } = registerContext;
21
+ const registrations = components.map((component) => {
22
+ const { key, componentFilePath, componentClassName } = component;
23
+ const registerComponentContext = {
24
+ controlRegistrationsPath: controlRegistrations,
25
+ key,
26
+ componentFilePath,
27
+ componentClassName,
28
+ };
29
+ switch (registrationType) {
30
+ case 'token':
31
+ return (0, register_type_token_rule_1.registerTypeToken)(registerComponentContext);
32
+ case 'config':
33
+ return (0, register_type_map_rule_1.registerTypeConfig)(registerComponentContext);
34
+ }
35
+ });
36
+ return (0, schematics_1.chain)(registrations);
37
+ }
38
+ //# sourceMappingURL=register-components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-components.js","sourceRoot":"","sources":["../../../../projects/core/automation/schematics/register/register-components.ts"],"names":[],"mappings":";;AAWA,gDAsBC;AAjCD,2DAKoC;AAGpC,uFAA6E;AAC7E,mFAA4E;AAE5E,SAAgB,kBAAkB,CAChC,IAAU,EACV,eAA4C,EAC5C,OAAyB;IAEzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yEAAyE,CAC1E,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,EAAE,oBAAoB,EAAE,GAAG,eAAe,CAAC;IAEjD,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,IAAI,CACjB,kEAAkE,CACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,iCAAiC,CAAC,eAAe,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,iCAAiC,CACxC,eAAgC;IAEhC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,GAC1D,eAAe,CAAC;IAElB,MAAM,aAAa,GAAW,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACzD,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;QAEjE,MAAM,wBAAwB,GAA6B;YACzD,wBAAwB,EAAE,oBAAoB;YAC9C,GAAG;YACH,iBAAiB;YACjB,kBAAkB;SACnB,CAAC;QAEF,QAAQ,gBAAgB,EAAE,CAAC;YACzB,KAAK,OAAO;gBACV,OAAO,IAAA,4CAAiB,EAAC,wBAAwB,CAAC,CAAC;YACrD,KAAK,QAAQ;gBACX,OAAO,IAAA,2CAAkB,EAAC,wBAAwB,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,kBAAK,EAAC,aAAa,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { RegistrationType } from '../../shared/shared-config.type';
2
+ import { FormbarComponentInfo } from './component-info.type';
3
+ export interface DiscoverOptions {
4
+ project?: string;
5
+ registrationType?: RegistrationType;
6
+ controlRegistrations?: string | null;
7
+ schematicsConfig?: string;
8
+ include?: string[];
9
+ exclude?: string[];
10
+ }
11
+ export interface RegisterContext extends DiscoverOptions {
12
+ components: FormbarComponentInfo[];
13
+ registrationType: RegistrationType;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../projects/core/automation/schematics/register/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NgxFormbarControl",
4
+ "title": "Register controls",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the project to add ngx-formbar to.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "registrationStyle": {
15
+ "type": "string",
16
+ "description": "How components will be registered. Possible values: token, map",
17
+ "default": "token"
18
+ },
19
+ "controlRegistrations": {
20
+ "type": "string",
21
+ "description": "Path to the registration file that should be used."
22
+ },
23
+ "schematicsConfig": {
24
+ "type": "string",
25
+ "description": "Path of the configuration that is to be used by this schematic"
26
+ },
27
+ "include": {
28
+ "type": "array",
29
+ "description": "Glob patterns to include when searching for components",
30
+ "default": ["**/*.ts"],
31
+ "items": {
32
+ "type": "string"
33
+ }
34
+ },
35
+ "exclude": {
36
+ "type": "array",
37
+ "description": "Glob patterns to exclude when searching for components (node_modules and spec files will always be excluded",
38
+ "default": [],
39
+ "items": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,9 @@
1
+ import { Expression, ObjectLiteralExpression, SourceFile } from 'typescript';
2
+ export declare function isCallee(expr: Expression, callee: string): boolean;
3
+ export declare function getDecoratorObject(sf: SourceFile, decoratorName: string): ObjectLiteralExpression | undefined;
4
+ export declare function decoratorPropInitializerIsIdentifier(sf: SourceFile, decoratorName: string, propName: string, identifierName: string): boolean;
5
+ export declare function getDecoratorArrayProp(sf: SourceFile, decoratorName: string, propName: string): import("typescript").ArrayLiteralExpression | undefined;
6
+ export declare function decoratorArrayPropContainsIdentifier(sf: SourceFile, decoratorName: string, propName: string, identifierName: string): boolean;
7
+ export declare function decoratorArrayPropContainsProviderObject(sf: SourceFile, decoratorName: string, propName: string, tokenName: string): boolean;
8
+ export declare function decoratorHostDirectivesHasInlineDirectiveWithInputs(sf: SourceFile, directiveIdentifier?: string, expectedInputs?: string[]): boolean;
9
+ export declare function componentSelectorEquals(sf: SourceFile, expected: string): boolean;
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCallee = isCallee;
4
+ exports.getDecoratorObject = getDecoratorObject;
5
+ exports.decoratorPropInitializerIsIdentifier = decoratorPropInitializerIsIdentifier;
6
+ exports.getDecoratorArrayProp = getDecoratorArrayProp;
7
+ exports.decoratorArrayPropContainsIdentifier = decoratorArrayPropContainsIdentifier;
8
+ exports.decoratorArrayPropContainsProviderObject = decoratorArrayPropContainsProviderObject;
9
+ exports.decoratorHostDirectivesHasInlineDirectiveWithInputs = decoratorHostDirectivesHasInlineDirectiveWithInputs;
10
+ exports.componentSelectorEquals = componentSelectorEquals;
11
+ const typescript_1 = require("typescript");
12
+ function isCallee(expr, callee) {
13
+ if ((0, typescript_1.isIdentifier)(expr)) {
14
+ return expr.text === callee;
15
+ }
16
+ if ((0, typescript_1.isPropertyAccessExpression)(expr)) {
17
+ return expr.name.text === callee;
18
+ }
19
+ return false;
20
+ }
21
+ function getDecoratorObject(sf, decoratorName) {
22
+ let found;
23
+ const visit = (node) => {
24
+ if (found) {
25
+ return;
26
+ }
27
+ if ((0, typescript_1.isCallExpression)(node) &&
28
+ isCallee(node.expression, decoratorName) &&
29
+ node.arguments.length > 0) {
30
+ const [firstArg] = node.arguments;
31
+ if ((0, typescript_1.isObjectLiteralExpression)(firstArg)) {
32
+ found = firstArg;
33
+ return;
34
+ }
35
+ }
36
+ node.forEachChild(visit);
37
+ };
38
+ sf.forEachChild(visit);
39
+ return found;
40
+ }
41
+ function decoratorPropInitializerIsIdentifier(sf, decoratorName, propName, identifierName) {
42
+ const obj = getDecoratorObject(sf, decoratorName);
43
+ if (!obj) {
44
+ return false;
45
+ }
46
+ const prop = obj.properties.find((p) => {
47
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
48
+ return false;
49
+ }
50
+ const n = p.name;
51
+ return (((0, typescript_1.isIdentifier)(n) && n.text === propName) ||
52
+ ((0, typescript_1.isStringLiteral)(n) && n.text === propName));
53
+ });
54
+ if (!prop || !(0, typescript_1.isPropertyAssignment)(prop)) {
55
+ return false;
56
+ }
57
+ return ((0, typescript_1.isIdentifier)(prop.initializer) && prop.initializer.text === identifierName);
58
+ }
59
+ function getDecoratorArrayProp(sf, decoratorName, propName) {
60
+ const obj = getDecoratorObject(sf, decoratorName);
61
+ if (!obj) {
62
+ return undefined;
63
+ }
64
+ const prop = obj.properties.find((p) => {
65
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
66
+ return false;
67
+ }
68
+ const n = p.name;
69
+ return (((0, typescript_1.isIdentifier)(n) && n.text === propName) ||
70
+ ((0, typescript_1.isStringLiteral)(n) && n.text === propName));
71
+ });
72
+ if (!prop || !(0, typescript_1.isPropertyAssignment)(prop)) {
73
+ return undefined;
74
+ }
75
+ return (0, typescript_1.isArrayLiteralExpression)(prop.initializer)
76
+ ? prop.initializer
77
+ : undefined;
78
+ }
79
+ function decoratorArrayPropContainsIdentifier(sf, decoratorName, propName, identifierName) {
80
+ const arr = getDecoratorArrayProp(sf, decoratorName, propName);
81
+ if (!arr) {
82
+ return false;
83
+ }
84
+ return arr.elements.some((el) => {
85
+ if (!(0, typescript_1.isIdentifier)(el)) {
86
+ return false;
87
+ }
88
+ return el.text === identifierName;
89
+ });
90
+ }
91
+ function decoratorArrayPropContainsProviderObject(sf, decoratorName, propName, tokenName) {
92
+ const arr = getDecoratorArrayProp(sf, decoratorName, propName);
93
+ if (!arr) {
94
+ return false;
95
+ }
96
+ return arr.elements.some((el) => {
97
+ if (!(0, typescript_1.isObjectLiteralExpression)(el)) {
98
+ return false;
99
+ }
100
+ const provideProp = el.properties.find((p) => {
101
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
102
+ return false;
103
+ }
104
+ const n = p.name;
105
+ const isProvide = ((0, typescript_1.isIdentifier)(n) && n.text === 'provide') ||
106
+ ((0, typescript_1.isStringLiteral)(n) && n.text === 'provide');
107
+ if (!isProvide) {
108
+ return false;
109
+ }
110
+ return (0, typescript_1.isIdentifier)(p.initializer) && p.initializer.text === tokenName;
111
+ });
112
+ return !!provideProp;
113
+ });
114
+ }
115
+ function decoratorHostDirectivesHasInlineDirectiveWithInputs(sf, directiveIdentifier = 'NgxfbControlDirective', expectedInputs = ['content', 'name']) {
116
+ const arr = getDecoratorArrayProp(sf, 'Component', 'hostDirectives');
117
+ if (!arr) {
118
+ return false;
119
+ }
120
+ return arr.elements.some((el) => {
121
+ if (!(0, typescript_1.isObjectLiteralExpression)(el)) {
122
+ return false;
123
+ }
124
+ const directiveProp = el.properties.find((p) => {
125
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
126
+ return false;
127
+ }
128
+ const n = p.name;
129
+ const isDirectiveKey = ((0, typescript_1.isIdentifier)(n) && n.text === 'directive') ||
130
+ ((0, typescript_1.isStringLiteral)(n) && n.text === 'directive');
131
+ if (!isDirectiveKey) {
132
+ return false;
133
+ }
134
+ return ((0, typescript_1.isIdentifier)(p.initializer) &&
135
+ p.initializer.text === directiveIdentifier);
136
+ });
137
+ if (!directiveProp) {
138
+ return false;
139
+ }
140
+ const inputsProp = el.properties.find((p) => {
141
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
142
+ return false;
143
+ }
144
+ const n = p.name;
145
+ const isInputsKey = ((0, typescript_1.isIdentifier)(n) && n.text === 'inputs') ||
146
+ ((0, typescript_1.isStringLiteral)(n) && n.text === 'inputs');
147
+ if (!isInputsKey) {
148
+ return false;
149
+ }
150
+ const init = p.initializer;
151
+ if (!(0, typescript_1.isArrayLiteralExpression)(init)) {
152
+ return false;
153
+ }
154
+ const values = init.elements.filter(typescript_1.isStringLiteral).map((s) => s.text);
155
+ return expectedInputs.every((i) => values.includes(i));
156
+ });
157
+ return !!inputsProp;
158
+ });
159
+ }
160
+ function componentSelectorEquals(sf, expected) {
161
+ const obj = getDecoratorObject(sf, 'Component');
162
+ if (!obj) {
163
+ return false;
164
+ }
165
+ const prop = obj.properties.find((p) => {
166
+ if (!(0, typescript_1.isPropertyAssignment)(p)) {
167
+ return false;
168
+ }
169
+ const n = p.name;
170
+ return (((0, typescript_1.isIdentifier)(n) && n.text === 'selector') ||
171
+ ((0, typescript_1.isStringLiteral)(n) && n.text === 'selector'));
172
+ });
173
+ if (!prop || !(0, typescript_1.isPropertyAssignment)(prop)) {
174
+ return false;
175
+ }
176
+ const init = prop.initializer;
177
+ if (!(0, typescript_1.isStringLiteral)(init)) {
178
+ return false;
179
+ }
180
+ return init.text === expected;
181
+ }
182
+ //# sourceMappingURL=decorators.js.map