@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.
- package/assets/examples/manifests/frontend-only.yaml +3 -6
- package/assets/examples/manifests/fullstack-app.yaml +5 -7
- package/assets/examples/manifests/fullstack-monorepo.yaml +3 -6
- package/dist/inference/comprehensive-engine.d.ts.map +1 -1
- package/dist/inference/comprehensive-engine.js +3 -19
- package/dist/inference/comprehensive-engine.js.map +1 -1
- package/dist/inference/core/rule-engine.d.ts +31 -0
- package/dist/inference/core/rule-engine.d.ts.map +1 -1
- package/dist/inference/core/rule-engine.js +117 -33
- package/dist/inference/core/rule-engine.js.map +1 -1
- package/dist/inference/core/rule-file-types.d.ts +0 -2
- package/dist/inference/core/rule-file-types.d.ts.map +1 -1
- package/dist/inference/core/rule-file-types.js +3 -6
- package/dist/inference/core/rule-file-types.js.map +1 -1
- package/dist/inference/core/rule-loader.d.ts +5 -15
- package/dist/inference/core/rule-loader.d.ts.map +1 -1
- package/dist/inference/core/rule-loader.js +43 -132
- package/dist/inference/core/rule-loader.js.map +1 -1
- package/dist/inference/core/types.d.ts +0 -6
- package/dist/inference/core/types.d.ts.map +1 -1
- package/dist/inference/core/types.js +0 -4
- package/dist/inference/core/types.js.map +1 -1
- package/dist/inference/logical/generators/component-type-resolver.d.ts +0 -26
- package/dist/inference/logical/generators/component-type-resolver.d.ts.map +1 -1
- package/dist/inference/logical/generators/component-type-resolver.js +0 -19
- package/dist/inference/logical/generators/component-type-resolver.js.map +1 -1
- package/dist/inference/logical/generators/specialist-view-expander.d.ts +1 -17
- package/dist/inference/logical/generators/specialist-view-expander.d.ts.map +1 -1
- package/dist/inference/logical/generators/specialist-view-expander.js +0 -15
- package/dist/inference/logical/generators/specialist-view-expander.js.map +1 -1
- package/dist/inference/logical/generators/view-generator.d.ts +4 -14
- package/dist/inference/logical/generators/view-generator.d.ts.map +1 -1
- package/dist/inference/logical/generators/view-generator.js +6 -26
- package/dist/inference/logical/generators/view-generator.js.map +1 -1
- package/dist/inference/logical/index.d.ts +2 -2
- package/dist/inference/logical/index.d.ts.map +1 -1
- package/dist/inference/logical/logical-engine.d.ts.map +1 -1
- package/dist/inference/logical/logical-engine.js +17 -80
- package/dist/inference/logical/logical-engine.js.map +1 -1
- package/dist/inference/quint-transpiler.d.ts +5 -3
- package/dist/inference/quint-transpiler.d.ts.map +1 -1
- package/dist/inference/quint-transpiler.js +11 -6
- package/dist/inference/quint-transpiler.js.map +1 -1
- package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +3 -3
- package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +16 -6
- package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +110 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +121 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +78 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +190 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +45 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/html-to-jsx.js +192 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/list-body-composer.js +46 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +30 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/package-json-generator.js +38 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/regen-safety.js +89 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +56 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +14 -11
- package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +11 -3
- package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +27 -17
- package/dist/libs/instance-factories/shared/path-resolver.js +1 -1
- package/dist/realize/index.d.ts.map +1 -1
- package/dist/realize/index.js +15 -22
- package/dist/realize/index.js.map +1 -1
- package/dist/registry/utils/manifest-adapter.d.ts +8 -1
- package/dist/registry/utils/manifest-adapter.d.ts.map +1 -1
- package/dist/registry/utils/manifest-adapter.js +8 -1
- package/dist/registry/utils/manifest-adapter.js.map +1 -1
- package/libs/instance-factories/applications/react-app-starter.yaml +150 -0
- package/libs/instance-factories/applications/templates/generic/main-generator.ts +3 -3
- package/libs/instance-factories/applications/templates/react/api-client-generator.ts +16 -6
- package/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/dashboard-body-composer.test.ts +153 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/detail-body-composer.test.ts +145 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +175 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/helpers-emitter.test.ts +55 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/html-to-jsx.test.ts +140 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/list-body-composer.test.ts +146 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/orchestrator.test.ts +163 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p2-factory-imports.test.ts +116 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/parity-p3-rendered-output.test.ts +183 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/regen-safety.test.ts +144 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/starter-generators.test.ts +114 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/view-emitter.test.ts +107 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/views-generator.test.ts +139 -0
- package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
- package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +174 -0
- package/libs/instance-factories/applications/templates/react-starter/detail-body-composer.ts +135 -0
- package/libs/instance-factories/applications/templates/react-starter/form-body-composer.ts +306 -0
- package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +60 -0
- package/libs/instance-factories/applications/templates/react-starter/html-to-jsx.ts +334 -0
- package/libs/instance-factories/applications/templates/react-starter/list-body-composer.ts +120 -0
- package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +80 -0
- package/libs/instance-factories/applications/templates/react-starter/package-json-generator.ts +57 -0
- package/libs/instance-factories/applications/templates/react-starter/regen-safety.ts +157 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/dashboard.tsx.template +47 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +94 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +114 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +72 -0
- package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +151 -0
- package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +14 -11
- package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +11 -3
- package/libs/instance-factories/services/templates/prisma/controller-generator.ts +27 -17
- package/libs/instance-factories/shared/path-resolver.ts +8 -2
- package/package.json +3 -3
- package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +0 -530
- package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +0 -73
- package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +0 -99
- package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +0 -49
- package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +0 -156
- package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +0 -935
- package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +0 -646
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +0 -65
- package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +0 -143
- package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +0 -355
- package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +0 -91
- package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +0 -79
- package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js.bak +0 -244
- package/dist/libs/instance-factories/views/index.js +0 -48
- package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +0 -742
- package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +0 -824
- package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +0 -719
- package/dist/libs/instance-factories/views/templates/react/app-generator.js +0 -45
- package/dist/libs/instance-factories/views/templates/react/components-generator.js +0 -820
- package/dist/libs/instance-factories/views/templates/react/forms-generator.js +0 -275
- package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +0 -46
- package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +0 -81
- package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +0 -9
- package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +0 -23
- package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +0 -21
- package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +0 -299
- package/dist/libs/instance-factories/views/templates/react/router-generator.js +0 -136
- package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +0 -107
- package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +0 -187
- package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +0 -7
- package/dist/libs/instance-factories/views/templates/react/types-generator.js +0 -56
- package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +0 -27
- package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +0 -29
- package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +0 -261
- package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +0 -34
- package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -800
- package/dist/libs/instance-factories/views/templates/shared/base-generator.js +0 -305
- package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +0 -517
- package/dist/libs/instance-factories/views/templates/shared/composite-pattern-types.js +0 -0
- package/dist/libs/instance-factories/views/templates/shared/composite-patterns.js +0 -445
- package/dist/libs/instance-factories/views/templates/shared/index.js +0 -80
- package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +0 -210
- package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +0 -492
- package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -321
- package/dist/realize/index.js.bak +0 -758
- package/libs/instance-factories/applications/react-app.yaml +0 -186
- package/libs/instance-factories/applications/templates/react/_view-components-source.ts +0 -555
- package/libs/instance-factories/applications/templates/react/app-tsx-generator.ts +0 -94
- package/libs/instance-factories/applications/templates/react/field-helpers-generator.ts +0 -106
- package/libs/instance-factories/applications/templates/react/package-json-generator.ts +0 -57
- package/libs/instance-factories/applications/templates/react/pattern-adapter-generator.ts +0 -179
- package/libs/instance-factories/applications/templates/react/react-pattern-adapter.tsx +0 -1347
- package/libs/instance-factories/applications/templates/react/relationship-field-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.ts +0 -704
- package/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.ts +0 -84
- package/libs/instance-factories/applications/templates/react/view-dashboard-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/view-detail-generator.ts +0 -150
- package/libs/instance-factories/applications/templates/react/view-form-generator.ts +0 -362
- package/libs/instance-factories/applications/templates/react/view-list-generator.ts +0 -98
- package/libs/instance-factories/applications/templates/react/view-router-generator.ts +0 -89
- package/libs/instance-factories/views/README.md +0 -62
- package/libs/instance-factories/views/index.d.ts +0 -13
- package/libs/instance-factories/views/index.d.ts.map +0 -1
- package/libs/instance-factories/views/index.js +0 -18
- package/libs/instance-factories/views/index.js.map +0 -1
- package/libs/instance-factories/views/index.ts +0 -45
- package/libs/instance-factories/views/react-components.yaml +0 -129
- package/libs/instance-factories/views/templates/ARCHITECTURE.md +0 -198
- package/libs/instance-factories/views/templates/react/adapters/antd-adapter.ts +0 -869
- package/libs/instance-factories/views/templates/react/adapters/mui-adapter.ts +0 -953
- package/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.ts +0 -806
- package/libs/instance-factories/views/templates/react/app-generator.ts +0 -55
- package/libs/instance-factories/views/templates/react/components-generator.ts +0 -938
- package/libs/instance-factories/views/templates/react/forms-generator.ts +0 -325
- package/libs/instance-factories/views/templates/react/frontend-package-json-generator.ts +0 -57
- package/libs/instance-factories/views/templates/react/hooks-generator.ts +0 -106
- package/libs/instance-factories/views/templates/react/index-css-generator.ts +0 -14
- package/libs/instance-factories/views/templates/react/index-html-generator.ts +0 -34
- package/libs/instance-factories/views/templates/react/main-tsx-generator.ts +0 -29
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts +0 -152
- package/libs/instance-factories/views/templates/react/react-component-generator.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/react/react-component-generator.js +0 -398
- package/libs/instance-factories/views/templates/react/react-component-generator.js.map +0 -1
- package/libs/instance-factories/views/templates/react/react-component-generator.ts +0 -533
- package/libs/instance-factories/views/templates/react/router-generator.ts +0 -197
- package/libs/instance-factories/views/templates/react/router-generic-generator.ts +0 -132
- package/libs/instance-factories/views/templates/react/shared-utils-generator.ts +0 -196
- package/libs/instance-factories/views/templates/react/spec-json-generator.ts +0 -17
- package/libs/instance-factories/views/templates/react/types-generator.ts +0 -76
- package/libs/instance-factories/views/templates/react/views-metadata-generator.ts +0 -42
- package/libs/instance-factories/views/templates/react/vite-config-generator.ts +0 -38
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js.map +0 -1
- package/libs/instance-factories/views/templates/runtime/runtime-view-renderer.ts +0 -474
- package/libs/instance-factories/views/templates/shared/__tests__/composite-patterns.test.ts +0 -242
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts +0 -77
- package/libs/instance-factories/views/templates/shared/adapter-types.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/adapter-types.js +0 -47
- package/libs/instance-factories/views/templates/shared/adapter-types.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/adapter-types.ts +0 -142
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts +0 -63
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js +0 -822
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/atomic-components-registry.ts +0 -908
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts +0 -247
- package/libs/instance-factories/views/templates/shared/base-generator.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/base-generator.js +0 -363
- package/libs/instance-factories/views/templates/shared/base-generator.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/base-generator.ts +0 -608
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts +0 -254
- package/libs/instance-factories/views/templates/shared/component-metadata.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/component-metadata.js +0 -602
- package/libs/instance-factories/views/templates/shared/component-metadata.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/component-metadata.ts +0 -803
- package/libs/instance-factories/views/templates/shared/composite-pattern-types.ts +0 -250
- package/libs/instance-factories/views/templates/shared/composite-patterns.ts +0 -535
- package/libs/instance-factories/views/templates/shared/index.ts +0 -68
- package/libs/instance-factories/views/templates/shared/pattern-validator.ts +0 -279
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts +0 -149
- package/libs/instance-factories/views/templates/shared/property-mapper.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/property-mapper.js +0 -580
- package/libs/instance-factories/views/templates/shared/property-mapper.js.map +0 -1
- package/libs/instance-factories/views/templates/shared/property-mapper.ts +0 -700
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts +0 -143
- package/libs/instance-factories/views/templates/shared/syntax-mapper.d.ts.map +0 -1
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js +0 -420
- package/libs/instance-factories/views/templates/shared/syntax-mapper.js.map +0 -1
- 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
|
-
};
|