@specverse/engines 4.1.28 → 4.2.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 (237) hide show
  1. package/assets/examples/manifests/frontend-only.yaml +3 -6
  2. package/assets/examples/manifests/fullstack-app.yaml +5 -7
  3. package/assets/examples/manifests/fullstack-monorepo.yaml +3 -6
  4. package/dist/inference/comprehensive-engine.d.ts.map +1 -1
  5. package/dist/inference/comprehensive-engine.js +3 -19
  6. package/dist/inference/comprehensive-engine.js.map +1 -1
  7. package/dist/inference/core/rule-engine.d.ts +31 -0
  8. package/dist/inference/core/rule-engine.d.ts.map +1 -1
  9. package/dist/inference/core/rule-engine.js +117 -33
  10. package/dist/inference/core/rule-engine.js.map +1 -1
  11. package/dist/inference/core/rule-file-types.d.ts +0 -2
  12. package/dist/inference/core/rule-file-types.d.ts.map +1 -1
  13. package/dist/inference/core/rule-file-types.js +3 -6
  14. package/dist/inference/core/rule-file-types.js.map +1 -1
  15. package/dist/inference/core/rule-loader.d.ts +5 -15
  16. package/dist/inference/core/rule-loader.d.ts.map +1 -1
  17. package/dist/inference/core/rule-loader.js +43 -132
  18. package/dist/inference/core/rule-loader.js.map +1 -1
  19. package/dist/inference/core/types.d.ts +0 -6
  20. package/dist/inference/core/types.d.ts.map +1 -1
  21. package/dist/inference/core/types.js +0 -4
  22. package/dist/inference/core/types.js.map +1 -1
  23. package/dist/inference/logical/generators/component-type-resolver.d.ts +0 -26
  24. package/dist/inference/logical/generators/component-type-resolver.d.ts.map +1 -1
  25. package/dist/inference/logical/generators/component-type-resolver.js +0 -19
  26. package/dist/inference/logical/generators/component-type-resolver.js.map +1 -1
  27. package/dist/inference/logical/generators/specialist-view-expander.d.ts +1 -17
  28. package/dist/inference/logical/generators/specialist-view-expander.d.ts.map +1 -1
  29. package/dist/inference/logical/generators/specialist-view-expander.js +0 -15
  30. package/dist/inference/logical/generators/specialist-view-expander.js.map +1 -1
  31. package/dist/inference/logical/generators/view-generator.d.ts +4 -14
  32. package/dist/inference/logical/generators/view-generator.d.ts.map +1 -1
  33. package/dist/inference/logical/generators/view-generator.js +6 -26
  34. package/dist/inference/logical/generators/view-generator.js.map +1 -1
  35. package/dist/inference/logical/index.d.ts +2 -2
  36. package/dist/inference/logical/index.d.ts.map +1 -1
  37. package/dist/inference/logical/logical-engine.d.ts.map +1 -1
  38. package/dist/inference/logical/logical-engine.js +17 -80
  39. package/dist/inference/logical/logical-engine.js.map +1 -1
  40. package/dist/inference/quint-transpiler.d.ts +5 -3
  41. package/dist/inference/quint-transpiler.d.ts.map +1 -1
  42. package/dist/inference/quint-transpiler.js +11 -6
  43. package/dist/inference/quint-transpiler.js.map +1 -1
  44. package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +3 -3
  45. package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +16 -6
  46. package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +110 -0
  47. package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +121 -0
  48. package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +78 -0
  49. package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +190 -0
  50. package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +45 -0
  51. package/dist/libs/instance-factories/applications/templates/react-starter/html-to-jsx.js +192 -0
  52. package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +46 -0
  53. package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +30 -0
  54. package/dist/libs/instance-factories/applications/templates/react-starter/package-json-generator.js +38 -0
  55. package/dist/libs/instance-factories/applications/templates/react-starter/regen-safety.js +89 -0
  56. package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +56 -0
  57. package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
  58. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +14 -11
  59. package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +11 -3
  60. package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +27 -17
  61. package/dist/libs/instance-factories/shared/path-resolver.js +1 -1
  62. package/dist/realize/index.d.ts.map +1 -1
  63. package/dist/realize/index.js +15 -22
  64. package/dist/realize/index.js.map +1 -1
  65. package/dist/registry/utils/manifest-adapter.d.ts +8 -1
  66. package/dist/registry/utils/manifest-adapter.d.ts.map +1 -1
  67. package/dist/registry/utils/manifest-adapter.js +8 -1
  68. package/dist/registry/utils/manifest-adapter.js.map +1 -1
  69. package/libs/instance-factories/applications/react-app-starter.yaml +150 -0
  70. package/libs/instance-factories/applications/templates/generic/main-generator.ts +3 -3
  71. package/libs/instance-factories/applications/templates/react/api-client-generator.ts +16 -6
  72. package/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
  73. package/libs/instance-factories/applications/templates/react-starter/__tests__/dashboard-body-composer.test.ts +153 -0
  74. package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +145 -0
  75. package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +175 -0
  76. package/libs/instance-factories/applications/templates/react-starter/__tests__/helpers-emitter.test.ts +55 -0
  77. package/libs/instance-factories/applications/templates/react-starter/__tests__/html-to-jsx.test.ts +140 -0
  78. package/libs/instance-factories/applications/templates/react-starter/__tests__/list-body-composer.test.ts +146 -0
  79. package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +163 -0
  80. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p2-factory-imports.test.ts +116 -0
  81. package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p3-rendered-output.test.ts +183 -0
  82. package/libs/instance-factories/applications/templates/react-starter/__tests__/regen-safety.test.ts +144 -0
  83. package/libs/instance-factories/applications/templates/react-starter/__tests__/starter-generators.test.ts +114 -0
  84. package/libs/instance-factories/applications/templates/react-starter/__tests__/view-emitter.test.ts +107 -0
  85. package/libs/instance-factories/applications/templates/react-starter/__tests__/views-generator.test.ts +139 -0
  86. package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
  87. package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +174 -0
  88. package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +135 -0
  89. package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +306 -0
  90. package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +60 -0
  91. package/libs/instance-factories/applications/templates/react-starter/html-to-jsx.ts +334 -0
  92. package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +120 -0
  93. package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +80 -0
  94. package/libs/instance-factories/applications/templates/react-starter/package-json-generator.ts +57 -0
  95. package/libs/instance-factories/applications/templates/react-starter/regen-safety.ts +157 -0
  96. package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +47 -0
  97. package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +94 -0
  98. package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +114 -0
  99. package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +72 -0
  100. package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +151 -0
  101. package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
  102. package/libs/instance-factories/cli/templates/commander/command-generator.ts +14 -11
  103. package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +11 -3
  104. package/libs/instance-factories/services/templates/prisma/controller-generator.ts +27 -17
  105. package/libs/instance-factories/shared/path-resolver.ts +8 -2
  106. package/package.json +3 -3
  107. package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +0 -530
  108. package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +0 -73
  109. package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +0 -99
  110. package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +0 -49
  111. package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +0 -156
  112. package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +0 -935
  113. package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +0 -143
  114. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +0 -646
  115. package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +0 -65
  116. package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +0 -143
  117. package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +0 -143
  118. package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +0 -355
  119. package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +0 -91
  120. package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +0 -79
  121. package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js.bak +0 -244
  122. package/dist/libs/instance-factories/views/index.js +0 -48
  123. package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +0 -742
  124. package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +0 -824
  125. package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +0 -719
  126. package/dist/libs/instance-factories/views/templates/react/app-generator.js +0 -45
  127. package/dist/libs/instance-factories/views/templates/react/components-generator.js +0 -820
  128. package/dist/libs/instance-factories/views/templates/react/forms-generator.js +0 -275
  129. package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +0 -46
  130. package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +0 -81
  131. package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +0 -9
  132. package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +0 -23
  133. package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +0 -21
  134. package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +0 -299
  135. package/dist/libs/instance-factories/views/templates/react/router-generator.js +0 -136
  136. package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +0 -107
  137. package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +0 -187
  138. package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +0 -7
  139. package/dist/libs/instance-factories/views/templates/react/types-generator.js +0 -56
  140. package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +0 -27
  141. package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +0 -29
  142. package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +0 -261
  143. package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +0 -34
  144. package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -800
  145. package/dist/libs/instance-factories/views/templates/shared/base-generator.js +0 -305
  146. package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +0 -517
  147. package/dist/libs/instance-factories/views/templates/shared/composite-pattern-types.js +0 -0
  148. package/dist/libs/instance-factories/views/templates/shared/composite-patterns.js +0 -445
  149. package/dist/libs/instance-factories/views/templates/shared/index.js +0 -80
  150. package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +0 -210
  151. package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +0 -492
  152. package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -321
  153. package/dist/realize/index.js.bak +0 -758
  154. package/libs/instance-factories/applications/react-app.yaml +0 -186
  155. package/libs/instance-factories/applications/templates/react/_view-components-source.ts +0 -555
  156. package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +0 -94
  157. package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +0 -106
  158. package/libs/instance-factories/applications/templates/react/package-json-generator.ts +0 -57
  159. package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +0 -179
  160. package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +0 -1347
  161. package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +0 -150
  162. package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +0 -704
  163. package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +0 -84
  164. package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +0 -150
  165. package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +0 -150
  166. package/libs/instance-factories/applications/templates/react/view-form-generator.ts +0 -362
  167. package/libs/instance-factories/applications/templates/react/view-list-generator.ts +0 -98
  168. package/libs/instance-factories/applications/templates/react/view-router-generator.ts +0 -89
  169. package/libs/instance-factories/views/README.md +0 -62
  170. package/libs/instance-factories/views/index.d.ts +0 -13
  171. package/libs/instance-factories/views/index.d.ts.map +0 -1
  172. package/libs/instance-factories/views/index.js +0 -18
  173. package/libs/instance-factories/views/index.js.map +0 -1
  174. package/libs/instance-factories/views/index.ts +0 -45
  175. package/libs/instance-factories/views/react-components.yaml +0 -129
  176. package/libs/instance-factories/views/templates/ARCHITECTURE.md +0 -198
  177. package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +0 -869
  178. package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +0 -953
  179. package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +0 -806
  180. package/libs/instance-factories/views/templates/react/app-generator.ts +0 -55
  181. package/libs/instance-factories/views/templates/react/components-generator.ts +0 -938
  182. package/libs/instance-factories/views/templates/react/forms-generator.ts +0 -325
  183. package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +0 -57
  184. package/libs/instance-factories/views/templates/react/hooks-generator.ts +0 -106
  185. package/libs/instance-factories/views/templates/react/index-css-generator.ts +0 -14
  186. package/libs/instance-factories/views/templates/react/index-html-generator.ts +0 -34
  187. package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +0 -29
  188. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +0 -152
  189. package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +0 -1
  190. package/libs/instance-factories/views/templates/react/react-component-generator.js +0 -398
  191. package/libs/instance-factories/views/templates/react/react-component-generator.js.map +0 -1
  192. package/libs/instance-factories/views/templates/react/react-component-generator.ts +0 -533
  193. package/libs/instance-factories/views/templates/react/router-generator.ts +0 -197
  194. package/libs/instance-factories/views/templates/react/router-generic-generator.ts +0 -132
  195. package/libs/instance-factories/views/templates/react/shared-utils-generator.ts +0 -196
  196. package/libs/instance-factories/views/templates/react/spec-json-generator.ts +0 -17
  197. package/libs/instance-factories/views/templates/react/types-generator.ts +0 -76
  198. package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +0 -42
  199. package/libs/instance-factories/views/templates/react/vite-config-generator.ts +0 -38
  200. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +0 -1
  201. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +0 -1
  202. package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +0 -474
  203. package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +0 -242
  204. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +0 -77
  205. package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +0 -1
  206. package/libs/instance-factories/views/templates/shared/adapter-types.js +0 -47
  207. package/libs/instance-factories/views/templates/shared/adapter-types.js.map +0 -1
  208. package/libs/instance-factories/views/templates/shared/adapter-types.ts +0 -142
  209. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +0 -63
  210. package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +0 -1
  211. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -822
  212. package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +0 -1
  213. package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +0 -908
  214. package/libs/instance-factories/views/templates/shared/base-generator.d.ts +0 -247
  215. package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +0 -1
  216. package/libs/instance-factories/views/templates/shared/base-generator.js +0 -363
  217. package/libs/instance-factories/views/templates/shared/base-generator.js.map +0 -1
  218. package/libs/instance-factories/views/templates/shared/base-generator.ts +0 -608
  219. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +0 -254
  220. package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +0 -1
  221. package/libs/instance-factories/views/templates/shared/component-metadata.js +0 -602
  222. package/libs/instance-factories/views/templates/shared/component-metadata.js.map +0 -1
  223. package/libs/instance-factories/views/templates/shared/component-metadata.ts +0 -803
  224. package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +0 -250
  225. package/libs/instance-factories/views/templates/shared/composite-patterns.ts +0 -535
  226. package/libs/instance-factories/views/templates/shared/index.ts +0 -68
  227. package/libs/instance-factories/views/templates/shared/pattern-validator.ts +0 -279
  228. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +0 -149
  229. package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +0 -1
  230. package/libs/instance-factories/views/templates/shared/property-mapper.js +0 -580
  231. package/libs/instance-factories/views/templates/shared/property-mapper.js.map +0 -1
  232. package/libs/instance-factories/views/templates/shared/property-mapper.ts +0 -700
  233. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +0 -143
  234. package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +0 -1
  235. package/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -420
  236. package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +0 -1
  237. package/libs/instance-factories/views/templates/shared/syntax-mapper.ts +0 -539
@@ -1,305 +0,0 @@
1
- import { mapProperties } from "./property-mapper.js";
2
- import { getSyntaxPattern } from "./syntax-mapper.js";
3
- import { ATOMIC_COMPONENTS_REGISTRY } from "./atomic-components-registry.js";
4
- class BaseComponentGenerator {
5
- // Configuration
6
- config;
7
- adapter;
8
- // Architectural constraints
9
- MAX_DEPTH;
10
- ENABLE_WARNINGS;
11
- // Tracking
12
- warnings = [];
13
- imports = /* @__PURE__ */ new Set();
14
- constructor(adapter, config) {
15
- this.adapter = adapter;
16
- this.config = config;
17
- this.MAX_DEPTH = config.maxDepth ?? 3;
18
- this.ENABLE_WARNINGS = config.enableWarnings ?? true;
19
- }
20
- // ============================================================================
21
- // Public API
22
- // ============================================================================
23
- /**
24
- * Generate code for a complete view specification
25
- *
26
- * @param viewSpec - View specification from SpecVerse
27
- * @returns Generation result with code, imports, and warnings
28
- */
29
- generate(viewSpec) {
30
- this.reset();
31
- const importStatements = this.generateImports(viewSpec);
32
- const stateCode = viewSpec.state ? this.generateState(viewSpec.state) : "";
33
- const eventsCode = viewSpec.events ? this.generateEvents(viewSpec.events) : "";
34
- const componentsCode = this.generateComponentTree(viewSpec.components);
35
- const code = this.generateComponent({
36
- name: viewSpec.name,
37
- imports: importStatements,
38
- state: stateCode,
39
- events: eventsCode,
40
- components: componentsCode
41
- });
42
- return {
43
- code,
44
- imports: Array.from(this.imports),
45
- warnings: this.warnings
46
- };
47
- }
48
- // ============================================================================
49
- // Shared Component Rendering (Framework-Agnostic)
50
- // ============================================================================
51
- /**
52
- * Render all components in the view
53
- */
54
- generateComponentTree(components) {
55
- const rendered = Object.entries(components).map(([name, component]) => {
56
- return this.renderComponent(component, {
57
- depth: 0,
58
- path: [name],
59
- dataContext: void 0
60
- });
61
- });
62
- return rendered.join("\n\n");
63
- }
64
- /**
65
- * Render a single component with depth tracking and nesting enforcement
66
- *
67
- * This is the core shared logic - applies to ALL frameworks
68
- */
69
- renderComponent(component, context) {
70
- if (context.depth > this.MAX_DEPTH) {
71
- this.addWarning(
72
- `Component at path ${context.path.join(".")} exceeds max depth (${this.MAX_DEPTH}). Flattening to maintain readability.`
73
- );
74
- return this.renderFlattened(component, context);
75
- }
76
- const componentDef = ATOMIC_COMPONENTS_REGISTRY[component.type];
77
- if (!componentDef) {
78
- this.addWarning(`Unknown component type: ${component.type}`);
79
- return `<!-- Unknown component: ${component.type} -->`;
80
- }
81
- const mappedProps = this.mapComponentProperties(component, componentDef);
82
- if (component.condition) {
83
- return this.renderConditional(component, mappedProps, context);
84
- }
85
- if (component.dataSource) {
86
- return this.renderList(component, mappedProps, context);
87
- }
88
- const children = component.children ? this.renderChildren(component.children, context) : void 0;
89
- return this.renderAdapterComponent(
90
- component.type,
91
- mappedProps,
92
- children,
93
- context
94
- );
95
- }
96
- /**
97
- * Map component properties using property-mapper
98
- */
99
- mapComponentProperties(component, componentDef) {
100
- if (!component.properties) {
101
- return {};
102
- }
103
- return mapProperties(
104
- component.type,
105
- component.properties,
106
- this.config.target
107
- );
108
- }
109
- /**
110
- * Render child components with incremented depth
111
- */
112
- renderChildren(children, parentContext) {
113
- const childContext = {
114
- ...parentContext,
115
- depth: parentContext.depth + 1
116
- };
117
- return children.map((child, index) => {
118
- const childPath = [...parentContext.path, `child_${index}`];
119
- return this.renderComponent(child, {
120
- ...childContext,
121
- path: childPath
122
- });
123
- }).join("\n");
124
- }
125
- /**
126
- * Render conditional component using syntax-mapper
127
- */
128
- renderConditional(component, mappedProps, context) {
129
- const innerComponent = this.renderAdapterComponent(
130
- component.type,
131
- mappedProps,
132
- component.children ? this.renderChildren(component.children, context) : void 0,
133
- context
134
- );
135
- return getSyntaxPattern("conditionalRender", this.config.framework, {
136
- condition: component.condition,
137
- Component: this.getComponentName(component.type),
138
- props: this.formatProps(mappedProps)
139
- });
140
- }
141
- /**
142
- * Render list (loop) component using syntax-mapper
143
- */
144
- renderList(component, mappedProps, context) {
145
- const itemName = this.getItemName(component.dataSource);
146
- const keyProperty = this.getKeyProperty(component);
147
- const childContext = {
148
- ...context,
149
- depth: context.depth + 1,
150
- dataContext: itemName
151
- };
152
- return getSyntaxPattern("loopRender", this.config.framework, {
153
- array: component.dataSource,
154
- item: itemName,
155
- key: keyProperty,
156
- Component: this.getComponentName(component.type)
157
- });
158
- }
159
- /**
160
- * Flatten component when depth exceeded
161
- *
162
- * Extracts nested children into sibling components to reduce nesting
163
- */
164
- renderFlattened(component, context) {
165
- const componentDef = ATOMIC_COMPONENTS_REGISTRY[component.type];
166
- const mappedProps = this.mapComponentProperties(component, componentDef);
167
- const flatComponent = this.renderAdapterComponent(
168
- component.type,
169
- mappedProps,
170
- void 0,
171
- // No children
172
- context
173
- );
174
- const flattenedChildren = component.children ? component.children.map((child, index) => {
175
- return this.renderComponent(child, {
176
- depth: context.depth,
177
- // Same depth (sibling)
178
- path: [...context.path, `flattened_${index}`]
179
- });
180
- }).join("\n") : "";
181
- return flatComponent + "\n" + flattenedChildren;
182
- }
183
- /**
184
- * Delegate to adapter for actual component rendering
185
- */
186
- renderAdapterComponent(type, properties, children, context) {
187
- const adapterComponent = this.adapter.components[type];
188
- if (!adapterComponent) {
189
- this.addWarning(`Adapter missing component: ${type}`);
190
- return `<!-- Missing adapter for: ${type} -->`;
191
- }
192
- return adapterComponent.render({
193
- properties,
194
- children
195
- });
196
- }
197
- // ============================================================================
198
- // Helper Methods
199
- // ============================================================================
200
- /**
201
- * Get component name for import/usage
202
- */
203
- getComponentName(type) {
204
- const componentDef = ATOMIC_COMPONENTS_REGISTRY[type];
205
- return componentDef?.name || type.charAt(0).toUpperCase() + type.slice(1);
206
- }
207
- /**
208
- * Get item variable name for loop rendering
209
- */
210
- getItemName(dataSource) {
211
- if (dataSource.endsWith("s")) {
212
- return dataSource.slice(0, -1);
213
- }
214
- return dataSource + "Item";
215
- }
216
- /**
217
- * Get key property for list items
218
- */
219
- getKeyProperty(component) {
220
- return component.properties?.keyProperty || "id";
221
- }
222
- /**
223
- * Format properties for inline rendering
224
- */
225
- formatProps(properties) {
226
- return Object.entries(properties).map(([key, value]) => {
227
- if (typeof value === "string") {
228
- return `${key}="${value}"`;
229
- }
230
- return `${key}={${JSON.stringify(value)}}`;
231
- }).join(" ");
232
- }
233
- /**
234
- * Add warning message
235
- */
236
- addWarning(message) {
237
- if (this.ENABLE_WARNINGS) {
238
- this.warnings.push(message);
239
- }
240
- }
241
- /**
242
- * Reset generator state for new generation
243
- */
244
- reset() {
245
- this.warnings = [];
246
- this.imports = /* @__PURE__ */ new Set();
247
- }
248
- /**
249
- * Add import statement
250
- */
251
- addImport(importStatement) {
252
- this.imports.add(importStatement);
253
- }
254
- }
255
- function validateNestingDepth(component, maxDepth = 3) {
256
- const issues = [];
257
- function calculateDepth(comp, currentDepth) {
258
- if (!comp.children || comp.children.length === 0) {
259
- return currentDepth;
260
- }
261
- const childDepths = comp.children.map(
262
- (child) => calculateDepth(child, currentDepth + 1)
263
- );
264
- return Math.max(...childDepths);
265
- }
266
- const actualDepth = calculateDepth(component, 0);
267
- if (actualDepth > maxDepth) {
268
- issues.push(
269
- `Component nesting depth (${actualDepth}) exceeds maximum (${maxDepth})`
270
- );
271
- }
272
- return {
273
- valid: actualDepth <= maxDepth,
274
- actualDepth,
275
- issues
276
- };
277
- }
278
- function extractComponentTypes(components) {
279
- const types = /* @__PURE__ */ new Set();
280
- function walk(component) {
281
- types.add(component.type);
282
- if (component.children) {
283
- component.children.forEach(walk);
284
- }
285
- }
286
- Object.values(components).forEach(walk);
287
- return types;
288
- }
289
- function countComponents(components) {
290
- let count = 0;
291
- function walk(component) {
292
- count++;
293
- if (component.children) {
294
- component.children.forEach(walk);
295
- }
296
- }
297
- Object.values(components).forEach(walk);
298
- return count;
299
- }
300
- export {
301
- BaseComponentGenerator,
302
- countComponents,
303
- extractComponentTypes,
304
- validateNestingDepth
305
- };