@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,38 +0,0 @@
1
- /**
2
- * Vite Configuration Generator
3
- *
4
- * Generates vite.config.ts for React application with backend proxy
5
- */
6
-
7
- import type { TemplateContext } from '@specverse/types';
8
-
9
- /**
10
- * Generate vite.config.ts
11
- */
12
- export default function generateViteConfig(context: TemplateContext): string {
13
- const { backendPort = 3000 } = context;
14
-
15
- return `import { defineConfig } from 'vite';
16
- import react from '@vitejs/plugin-react';
17
-
18
- // https://vitejs.dev/config/
19
- export default defineConfig({
20
- plugins: [react()],
21
- server: {
22
- port: 5173,
23
- host: true,
24
- proxy: {
25
- '/api': {
26
- target: 'http://localhost:${backendPort}',
27
- changeOrigin: true,
28
- rewrite: (path) => path
29
- }
30
- }
31
- },
32
- build: {
33
- outDir: 'dist',
34
- sourcemap: true
35
- }
36
- });
37
- `;
38
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-view-renderer.d.ts","sourceRoot":"","sources":["runtime-view-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAsD,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,eAAe,EACf,eAAe,EAGf,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAMnE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACnD,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;CAC7B;AAMD;;;;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;OAEG;IACK,UAAU,CAAC,GAAW;QAC5B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAyB,EACzB,MAAuC;IAEvC,MAAM,aAAa,GAA0B;QAC3C,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,CAAC;QACX,cAAc,EAAE,IAAI;KACrB,CAAC;IAEF,MAAM,WAAW,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAA2B,CAAC;IAE7E,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,QAAkB,EAClB,OAAyB,EACzB,OAAqC;IAErC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAkB,EAClB,OAAyB;IAEzB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC"}
@@ -1,474 +0,0 @@
1
- /**
2
- * Runtime View Renderer
3
- *
4
- * Dynamically renders SpecVerse views at runtime using React.createElement.
5
- * Used by app-demo for live view rendering without code generation.
6
- *
7
- * Architecture:
8
- * - No code generation - creates React elements directly
9
- * - Uses component-metadata for runtime hints
10
- * - Integrates with BaseComponentGenerator for shared logic
11
- * - Supports dynamic state and event binding
12
- * - Real-time view updates
13
- */
14
-
15
- import React, { createElement, useState, useEffect, useMemo } from 'react';
16
- import {
17
- BaseComponentGenerator,
18
- ViewSpec,
19
- StateDefinition,
20
- EventDefinition,
21
- UIComponent,
22
- RenderContext,
23
- GeneratorConfig
24
- } from '../shared/base-generator.js';
25
- import { mapProperties } from '../shared/property-mapper.js';
26
- import { getComponentMetadata } from '../shared/component-metadata.js';
27
- import type { ComponentAdapter } from '../shared/adapter-types.js';
28
-
29
- // ============================================================================
30
- // Types
31
- // ============================================================================
32
-
33
- /**
34
- * Runtime renderer configuration
35
- */
36
- export interface RuntimeRendererConfig extends GeneratorConfig {
37
- framework: 'runtime';
38
- target: 'runtime';
39
- /**
40
- * Enable live reload on spec changes
41
- */
42
- liveReload?: boolean;
43
- /**
44
- * Debug mode with console logging
45
- */
46
- debug?: boolean;
47
- }
48
-
49
- /**
50
- * Runtime component props
51
- */
52
- export interface RuntimeComponentProps {
53
- [key: string]: any;
54
- children?: React.ReactNode;
55
- }
56
-
57
- /**
58
- * Runtime state manager
59
- */
60
- export interface RuntimeState {
61
- [key: string]: any;
62
- }
63
-
64
- /**
65
- * Runtime event handlers
66
- */
67
- export interface RuntimeEventHandlers {
68
- [key: string]: (...args: any[]) => void;
69
- }
70
-
71
- /**
72
- * Runtime view context
73
- */
74
- export interface RuntimeViewContext {
75
- state: RuntimeState;
76
- setState: (updates: Partial<RuntimeState>) => void;
77
- handlers: RuntimeEventHandlers;
78
- data: Record<string, any[]>; // Model data for lists
79
- }
80
-
81
- // ============================================================================
82
- // Runtime View Renderer
83
- // ============================================================================
84
-
85
- /**
86
- * Renders SpecVerse views dynamically at runtime
87
- *
88
- * Unlike code generators, this creates React elements directly without
89
- * generating .tsx files. Used by app-demo for live view rendering.
90
- */
91
- export class RuntimeViewRenderer extends BaseComponentGenerator {
92
- private readonly runtimeConfig: RuntimeRendererConfig;
93
- private viewContext?: RuntimeViewContext;
94
-
95
- constructor(adapter: ComponentAdapter, config: RuntimeRendererConfig) {
96
- super(adapter, config);
97
- this.runtimeConfig = config;
98
- }
99
-
100
- // ============================================================================
101
- // Public API - Runtime Rendering
102
- // ============================================================================
103
-
104
- /**
105
- * Render view as React element (runtime)
106
- *
107
- * @param viewSpec - View specification
108
- * @param context - Runtime context (state, data, handlers)
109
- * @returns React element
110
- */
111
- public renderRuntime(
112
- viewSpec: ViewSpec,
113
- context?: Partial<RuntimeViewContext>
114
- ): React.ReactElement {
115
- // Initialize runtime context
116
- this.viewContext = this.initializeContext(viewSpec, context);
117
-
118
- // Create root element
119
- const components = this.renderComponentsRuntime(viewSpec.components);
120
-
121
- return createElement(
122
- 'div',
123
- { className: 'specverse-runtime-view', 'data-view': viewSpec.name },
124
- components
125
- );
126
- }
127
-
128
- /**
129
- * Create a React component from view spec
130
- *
131
- * Returns a React component function that can be used directly
132
- *
133
- * @param viewSpec - View specification
134
- * @returns React component function
135
- */
136
- public createRuntimeComponent(viewSpec: ViewSpec): React.FC<any> {
137
- const renderer = this;
138
-
139
- return function RuntimeViewComponent(props: any) {
140
- // Initialize state from view spec
141
- const [state, setState] = useState<RuntimeState>(() =>
142
- renderer.initializeState(viewSpec.state)
143
- );
144
-
145
- // Initialize event handlers
146
- const handlers = useMemo(() =>
147
- renderer.createEventHandlers(viewSpec.events, state, setState),
148
- [state]
149
- );
150
-
151
- // Create runtime context
152
- const context: RuntimeViewContext = {
153
- state,
154
- setState: (updates) => setState(prev => ({ ...prev, ...updates })),
155
- handlers,
156
- data: props.data || {}
157
- };
158
-
159
- // Render view
160
- return renderer.renderRuntime(viewSpec, context);
161
- };
162
- }
163
-
164
- // ============================================================================
165
- // Abstract Method Implementations (Not Used in Runtime)
166
- // ============================================================================
167
-
168
- protected generateImports(viewSpec: ViewSpec): string {
169
- // Runtime doesn't generate code
170
- return '';
171
- }
172
-
173
- protected generateComponent(parts: any): string {
174
- // Runtime doesn't generate code
175
- return '';
176
- }
177
-
178
- protected generateState(state: Record<string, StateDefinition>): string {
179
- // Runtime doesn't generate code
180
- return '';
181
- }
182
-
183
- protected generateEvents(events: Record<string, EventDefinition>): string {
184
- // Runtime doesn't generate code
185
- return '';
186
- }
187
-
188
- public getFileExtension(): string {
189
- return ''; // No files generated
190
- }
191
-
192
- public getAdditionalFiles(viewSpec: ViewSpec): Record<string, string> {
193
- return {}; // No files generated
194
- }
195
-
196
- // ============================================================================
197
- // Runtime-Specific Methods
198
- // ============================================================================
199
-
200
- /**
201
- * Initialize runtime context
202
- */
203
- private initializeContext(
204
- viewSpec: ViewSpec,
205
- context?: Partial<RuntimeViewContext>
206
- ): RuntimeViewContext {
207
- return {
208
- state: context?.state || this.initializeState(viewSpec.state),
209
- setState: context?.setState || (() => {}),
210
- handlers: context?.handlers || this.createEventHandlers(viewSpec.events),
211
- data: context?.data || {}
212
- };
213
- }
214
-
215
- /**
216
- * Initialize state from view spec
217
- */
218
- private initializeState(state?: Record<string, StateDefinition>): RuntimeState {
219
- if (!state) return {};
220
-
221
- const initialState: RuntimeState = {};
222
-
223
- for (const [name, def] of Object.entries(state)) {
224
- initialState[name] = def.initial;
225
- }
226
-
227
- return initialState;
228
- }
229
-
230
- /**
231
- * Create event handlers from view spec
232
- */
233
- private createEventHandlers(
234
- events?: Record<string, EventDefinition>,
235
- state?: RuntimeState,
236
- setState?: (updates: Partial<RuntimeState>) => void
237
- ): RuntimeEventHandlers {
238
- if (!events) return {};
239
-
240
- const handlers: RuntimeEventHandlers = {};
241
-
242
- for (const [name, def] of Object.entries(events)) {
243
- // Create handler function
244
- handlers[`handle${this.capitalize(name)}`] = (...args: any[]) => {
245
- if (this.runtimeConfig.debug) {
246
- console.log(`[RuntimeView] Event: ${name}`, args);
247
- }
248
-
249
- // Execute event body
250
- try {
251
- // Create function from body
252
- const fn = new Function('state', 'setState', 'args', def.body);
253
- fn(state, setState, args);
254
- } catch (error) {
255
- console.error(`[RuntimeView] Event handler error (${name}):`, error);
256
- }
257
- };
258
- }
259
-
260
- return handlers;
261
- }
262
-
263
- /**
264
- * Render components as React elements
265
- */
266
- private renderComponentsRuntime(components: Record<string, UIComponent>): React.ReactNode[] {
267
- return Object.entries(components).map(([name, component]) =>
268
- this.renderComponentRuntime(component, {
269
- depth: 0,
270
- path: [name]
271
- })
272
- );
273
- }
274
-
275
- /**
276
- * Render single component as React element
277
- */
278
- private renderComponentRuntime(
279
- component: UIComponent,
280
- context: RenderContext
281
- ): React.ReactElement | null {
282
- // Depth enforcement
283
- if (context.depth > this.MAX_DEPTH) {
284
- if (this.runtimeConfig.debug) {
285
- console.warn(`[RuntimeView] Max depth exceeded at ${context.path.join('.')}`);
286
- }
287
- return null;
288
- }
289
-
290
- // Get component metadata
291
- const metadata = getComponentMetadata(component.type);
292
- if (!metadata) {
293
- console.warn(`[RuntimeView] Unknown component type: ${component.type}`);
294
- return null;
295
- }
296
-
297
- // Map properties
298
- const mappedProps = component.properties
299
- ? mapProperties(component.type, component.properties, 'runtime')
300
- : {};
301
-
302
- // Add key for React
303
- const props: RuntimeComponentProps = {
304
- ...mappedProps,
305
- key: context.path.join('-')
306
- };
307
-
308
- // Handle conditional rendering
309
- if (component.condition && this.viewContext) {
310
- const condition = this.evaluateCondition(component.condition, this.viewContext);
311
- if (!condition) return null;
312
- }
313
-
314
- // Handle list rendering
315
- if (component.dataSource && this.viewContext) {
316
- return this.renderListRuntime(component, props, context);
317
- }
318
-
319
- // Render children
320
- let children: React.ReactNode = null;
321
- if (component.children && component.children.length > 0) {
322
- children = component.children.map((child, index) =>
323
- this.renderComponentRuntime(child, {
324
- ...context,
325
- depth: context.depth + 1,
326
- path: [...context.path, `child_${index}`]
327
- })
328
- );
329
- }
330
-
331
- // Get adapter component render function
332
- const adapterComponent = this.adapter.components[component.type];
333
- if (!adapterComponent) {
334
- console.warn(`[RuntimeView] No adapter for component: ${component.type}`);
335
- return null;
336
- }
337
-
338
- // For runtime, we need to create actual React elements
339
- // The adapter render function returns JSX string, so we need to convert it
340
- // For now, create a simple wrapper
341
- return this.createElementFromAdapter(component.type, props, children);
342
- }
343
-
344
- /**
345
- * Render list of items
346
- */
347
- private renderListRuntime(
348
- component: UIComponent,
349
- props: RuntimeComponentProps,
350
- context: RenderContext
351
- ): React.ReactElement | null {
352
- if (!this.viewContext) return null;
353
-
354
- const dataArray = this.viewContext.data[component.dataSource!];
355
- if (!Array.isArray(dataArray)) {
356
- console.warn(`[RuntimeView] Data source not found: ${component.dataSource}`);
357
- return null;
358
- }
359
-
360
- const items = dataArray.map((item, index) => {
361
- const itemProps = {
362
- ...props,
363
- ...item,
364
- key: `${context.path.join('-')}-${index}`
365
- };
366
-
367
- return this.createElementFromAdapter(component.type, itemProps, null);
368
- });
369
-
370
- return createElement(React.Fragment, null, ...items);
371
- }
372
-
373
- /**
374
- * Create React element from adapter component
375
- */
376
- private createElementFromAdapter(
377
- type: string,
378
- props: RuntimeComponentProps,
379
- children: React.ReactNode
380
- ): React.ReactElement {
381
- // For runtime, we create a simple div wrapper with className
382
- // In actual implementation, this would integrate with a component library
383
- return createElement(
384
- 'div',
385
- {
386
- ...props,
387
- className: `specverse-runtime-${type} ${props.className || ''}`.trim(),
388
- 'data-component': type
389
- },
390
- children
391
- );
392
- }
393
-
394
- /**
395
- * Evaluate condition expression
396
- */
397
- private evaluateCondition(condition: string, context: RuntimeViewContext): boolean {
398
- try {
399
- const fn = new Function('state', 'data', `return ${condition}`);
400
- return fn(context.state, context.data);
401
- } catch (error) {
402
- console.error(`[RuntimeView] Condition evaluation error:`, error);
403
- return false;
404
- }
405
- }
406
-
407
- /**
408
- * Capitalize first letter
409
- */
410
- private capitalize(str: string): string {
411
- return str.charAt(0).toUpperCase() + str.slice(1);
412
- }
413
- }
414
-
415
- // ============================================================================
416
- // Factory Functions
417
- // ============================================================================
418
-
419
- /**
420
- * Create a RuntimeViewRenderer instance
421
- *
422
- * @param adapter - Component adapter (runtime adapter)
423
- * @param config - Optional configuration
424
- * @returns RuntimeViewRenderer instance
425
- */
426
- export function createRuntimeRenderer(
427
- adapter: ComponentAdapter,
428
- config?: Partial<RuntimeRendererConfig>
429
- ): RuntimeViewRenderer {
430
- const defaultConfig: RuntimeRendererConfig = {
431
- framework: 'runtime',
432
- target: 'runtime',
433
- liveReload: false,
434
- debug: false,
435
- maxDepth: 3,
436
- enableWarnings: true
437
- };
438
-
439
- const finalConfig = { ...defaultConfig, ...config } as RuntimeRendererConfig;
440
-
441
- return new RuntimeViewRenderer(adapter, finalConfig);
442
- }
443
-
444
- /**
445
- * Render view at runtime (convenience function)
446
- *
447
- * @param viewSpec - View specification
448
- * @param adapter - Component adapter
449
- * @param context - Runtime context
450
- * @returns React element
451
- */
452
- export function renderView(
453
- viewSpec: ViewSpec,
454
- adapter: ComponentAdapter,
455
- context?: Partial<RuntimeViewContext>
456
- ): React.ReactElement {
457
- const renderer = createRuntimeRenderer(adapter);
458
- return renderer.renderRuntime(viewSpec, context);
459
- }
460
-
461
- /**
462
- * Create runtime component (convenience function)
463
- *
464
- * @param viewSpec - View specification
465
- * @param adapter - Component adapter
466
- * @returns React component function
467
- */
468
- export function createViewComponent(
469
- viewSpec: ViewSpec,
470
- adapter: ComponentAdapter
471
- ): React.FC<any> {
472
- const renderer = createRuntimeRenderer(adapter);
473
- return renderer.createRuntimeComponent(viewSpec);
474
- }