@specverse/engines 4.1.30 → 4.2.1
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/assets/templates/default/specs/main.specly +65 -0
- 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/CURVED-INTERFACE.md +278 -0
- package/dist/libs/instance-factories/README.md +73 -0
- package/dist/libs/instance-factories/applications/README.md +51 -0
- package/dist/libs/instance-factories/applications/generic-app.yaml +52 -0
- package/{libs/instance-factories/applications/react-app.yaml → dist/libs/instance-factories/applications/react-app-runtime.yaml} +30 -77
- package/dist/libs/instance-factories/applications/react-app-starter.yaml +143 -0
- package/dist/libs/instance-factories/applications/templates/react/env-example-generator.js +24 -2
- package/dist/libs/instance-factories/applications/templates/react/vite-config-generator.js +54 -33
- package/dist/libs/instance-factories/applications/templates/react-starter/README.md +211 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/api-types-starter-generator.js +69 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.js +110 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/belongs-to.js +40 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.js +129 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/detail-body-composer.js +80 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/form-body-composer.js +217 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/helpers-emitter.js +51 -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 +56 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/orchestrator.js +41 -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/skeletons/dashboard.tsx.template +49 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +96 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +116 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +74 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/use-api-hooks-starter-generator.js +95 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/view-emitter.js +81 -0
- package/dist/libs/instance-factories/applications/templates/react-starter/views-generator.js +66 -0
- package/dist/libs/instance-factories/archived/fastify-prisma.yaml +104 -0
- package/dist/libs/instance-factories/cli/README.md +43 -0
- package/dist/libs/instance-factories/cli/commander-js.yaml +55 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +63 -12
- package/dist/libs/instance-factories/communication/README.md +47 -0
- package/dist/libs/instance-factories/communication/event-emitter.yaml +60 -0
- package/dist/libs/instance-factories/communication/rabbitmq-events.yaml +87 -0
- package/dist/libs/instance-factories/controllers/README.md +42 -0
- package/dist/libs/instance-factories/controllers/fastify.yaml +139 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +29 -2
- package/dist/libs/instance-factories/infrastructure/README.md +29 -0
- package/dist/libs/instance-factories/infrastructure/docker-k8s.yaml +61 -0
- package/dist/libs/instance-factories/orms/README.md +54 -0
- package/dist/libs/instance-factories/orms/prisma.yaml +89 -0
- package/dist/libs/instance-factories/orms/templates/prisma/schema-generator.js +2 -2
- package/dist/libs/instance-factories/scaffolding/README.md +49 -0
- package/dist/libs/instance-factories/scaffolding/generic-scaffold.yaml +65 -0
- package/dist/libs/instance-factories/sdks/README.md +28 -0
- package/dist/libs/instance-factories/sdks/python-sdk.yaml +66 -0
- package/dist/libs/instance-factories/sdks/typescript-sdk.yaml +59 -0
- package/dist/libs/instance-factories/services/README.md +55 -0
- package/dist/libs/instance-factories/services/prisma-services.yaml +71 -0
- package/dist/libs/instance-factories/storage/README.md +34 -0
- package/dist/libs/instance-factories/storage/mongodb.yaml +79 -0
- package/dist/libs/instance-factories/storage/postgresql.yaml +75 -0
- package/dist/libs/instance-factories/storage/redis.yaml +79 -0
- package/dist/libs/instance-factories/testing/README.md +40 -0
- package/dist/libs/instance-factories/testing/vitest-tests.yaml +63 -0
- package/dist/libs/instance-factories/tools/README.md +70 -0
- package/dist/libs/instance-factories/tools/mcp.yaml +36 -0
- package/dist/libs/instance-factories/tools/vscode.yaml +35 -0
- package/dist/libs/instance-factories/validation/README.md +38 -0
- package/dist/libs/instance-factories/validation/zod.yaml +56 -0
- package/dist/realize/engines/code-generator.d.ts.map +1 -1
- package/dist/realize/engines/code-generator.js +3 -0
- package/dist/realize/engines/code-generator.js.map +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 +143 -0
- package/libs/instance-factories/applications/templates/react/env-example-generator.ts +24 -2
- package/libs/instance-factories/applications/templates/react/vite-config-generator.ts +54 -33
- 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 +146 -0
- package/libs/instance-factories/applications/templates/react-starter/__tests__/form-body-composer.test.ts +188 -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 +184 -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/api-types-starter-generator.ts +98 -0
- package/libs/instance-factories/applications/templates/react-starter/app-tsx-generator.ts +141 -0
- package/libs/instance-factories/applications/templates/react-starter/belongs-to.ts +82 -0
- package/libs/instance-factories/applications/templates/react-starter/dashboard-body-composer.ts +189 -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 +383 -0
- package/libs/instance-factories/applications/templates/react-starter/helpers-emitter.ts +66 -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 +146 -0
- package/libs/instance-factories/applications/templates/react-starter/orchestrator.ts +95 -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 +49 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/detail.tsx.template +96 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/form.tsx.template +116 -0
- package/libs/instance-factories/applications/templates/react-starter/skeletons/list.tsx.template +74 -0
- package/libs/instance-factories/applications/templates/react-starter/use-api-hooks-starter-generator.ts +124 -0
- package/libs/instance-factories/applications/templates/react-starter/view-emitter.ts +209 -0
- package/libs/instance-factories/applications/templates/react-starter/views-generator.ts +137 -0
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +63 -12
- package/libs/instance-factories/controllers/fastify.yaml +7 -0
- package/libs/instance-factories/controllers/templates/fastify/server-generator.ts +36 -2
- package/libs/instance-factories/orms/templates/prisma/schema-generator.ts +11 -4
- 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/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/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,533 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Component Generator
|
|
3
|
-
*
|
|
4
|
-
* Extends BaseComponentGenerator to generate React/TypeScript components.
|
|
5
|
-
* Outputs .tsx files with proper imports, hooks, types, and JSX.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - TypeScript with strict typing
|
|
9
|
-
* - React hooks (useState, useEffect)
|
|
10
|
-
* - JSX component rendering
|
|
11
|
-
* - Adapter integration (shadcn, MUI, antd)
|
|
12
|
-
* - Proper file structure and exports
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
BaseComponentGenerator,
|
|
17
|
-
ViewSpec,
|
|
18
|
-
StateDefinition,
|
|
19
|
-
EventDefinition,
|
|
20
|
-
GeneratorConfig
|
|
21
|
-
} from '../shared/base-generator.js';
|
|
22
|
-
import { getSyntaxPattern } from '../shared/syntax-mapper.js';
|
|
23
|
-
import { extractComponentTypes } from '../shared/base-generator.js';
|
|
24
|
-
import type { ComponentAdapter } from '../shared/adapter-types.js';
|
|
25
|
-
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Types
|
|
28
|
-
// ============================================================================
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* React-specific generator configuration
|
|
32
|
-
*/
|
|
33
|
-
export interface ReactGeneratorConfig extends GeneratorConfig {
|
|
34
|
-
framework: 'react';
|
|
35
|
-
target: 'shadcn' | 'mui' | 'antd';
|
|
36
|
-
typescript: boolean;
|
|
37
|
-
strictMode?: boolean;
|
|
38
|
-
includeComments?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* React component props interface
|
|
43
|
-
*/
|
|
44
|
-
export interface ReactComponentProps {
|
|
45
|
-
[key: string]: any;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ============================================================================
|
|
49
|
-
// React Component Generator
|
|
50
|
-
// ============================================================================
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Generates React/TypeScript components from SpecVerse view specifications
|
|
54
|
-
*
|
|
55
|
-
* Output structure:
|
|
56
|
-
* ```tsx
|
|
57
|
-
* import React, { useState, useEffect } from 'react';
|
|
58
|
-
* import { Button } from '@/components/ui/button';
|
|
59
|
-
*
|
|
60
|
-
* interface {ComponentName}Props {
|
|
61
|
-
* // ... props
|
|
62
|
-
* }
|
|
63
|
-
*
|
|
64
|
-
* export function {ComponentName}({ ...props }: {ComponentName}Props) {
|
|
65
|
-
* // State declarations
|
|
66
|
-
* const [count, setCount] = useState(0);
|
|
67
|
-
*
|
|
68
|
-
* // Event handlers
|
|
69
|
-
* const handleClick = () => { ... };
|
|
70
|
-
*
|
|
71
|
-
* // Component tree
|
|
72
|
-
* return (
|
|
73
|
-
* <div>
|
|
74
|
-
* <Button onClick={handleClick}>Click me</Button>
|
|
75
|
-
* </div>
|
|
76
|
-
* );
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export class ReactComponentGenerator extends BaseComponentGenerator {
|
|
81
|
-
private readonly reactConfig: ReactGeneratorConfig;
|
|
82
|
-
|
|
83
|
-
constructor(adapter: ComponentAdapter, config: ReactGeneratorConfig) {
|
|
84
|
-
super(adapter, config);
|
|
85
|
-
this.reactConfig = config;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ============================================================================
|
|
89
|
-
// Abstract Method Implementations
|
|
90
|
-
// ============================================================================
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Generate React imports
|
|
94
|
-
*/
|
|
95
|
-
protected generateImports(viewSpec: ViewSpec): string {
|
|
96
|
-
const imports: string[] = [];
|
|
97
|
-
|
|
98
|
-
// React core imports
|
|
99
|
-
const reactImports = this.getReactCoreImports(viewSpec);
|
|
100
|
-
if (reactImports) {
|
|
101
|
-
imports.push(reactImports);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Component library imports
|
|
105
|
-
const componentTypes = extractComponentTypes(viewSpec.components);
|
|
106
|
-
const componentImports = this.getComponentImports(componentTypes);
|
|
107
|
-
imports.push(...componentImports);
|
|
108
|
-
|
|
109
|
-
return imports.join('\n');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Generate complete React component
|
|
114
|
-
*/
|
|
115
|
-
protected generateComponent(parts: {
|
|
116
|
-
name: string;
|
|
117
|
-
imports: string;
|
|
118
|
-
state: string;
|
|
119
|
-
events: string;
|
|
120
|
-
components: string;
|
|
121
|
-
}): string {
|
|
122
|
-
const lines: string[] = [];
|
|
123
|
-
|
|
124
|
-
// File header comment
|
|
125
|
-
if (this.reactConfig.includeComments) {
|
|
126
|
-
lines.push(`/**`);
|
|
127
|
-
lines.push(` * ${parts.name} Component`);
|
|
128
|
-
lines.push(` * Generated by SpecVerse`);
|
|
129
|
-
lines.push(` */`);
|
|
130
|
-
lines.push('');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Imports
|
|
134
|
-
lines.push(parts.imports);
|
|
135
|
-
lines.push('');
|
|
136
|
-
|
|
137
|
-
// Props interface
|
|
138
|
-
const propsInterface = this.generatePropsInterface(parts.name);
|
|
139
|
-
if (propsInterface) {
|
|
140
|
-
lines.push(propsInterface);
|
|
141
|
-
lines.push('');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Component function
|
|
145
|
-
lines.push(this.generateComponentFunction(parts));
|
|
146
|
-
|
|
147
|
-
return lines.join('\n');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Generate state declarations using React hooks
|
|
152
|
-
*/
|
|
153
|
-
protected generateState(state: Record<string, StateDefinition>): string {
|
|
154
|
-
const stateDeclarations: string[] = [];
|
|
155
|
-
|
|
156
|
-
for (const [name, def] of Object.entries(state)) {
|
|
157
|
-
const declaration = getSyntaxPattern('stateDeclaration', 'react', {
|
|
158
|
-
name,
|
|
159
|
-
Name: this.capitalize(name),
|
|
160
|
-
type: def.type,
|
|
161
|
-
initial: JSON.stringify(def.initial)
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
if (this.reactConfig.includeComments && def.description) {
|
|
165
|
-
stateDeclarations.push(` // ${def.description}`);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
stateDeclarations.push(` ${declaration}`);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return stateDeclarations.join('\n');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Generate event handlers
|
|
176
|
-
*/
|
|
177
|
-
protected generateEvents(events: Record<string, EventDefinition>): string {
|
|
178
|
-
const eventHandlers: string[] = [];
|
|
179
|
-
|
|
180
|
-
for (const [name, def] of Object.entries(events)) {
|
|
181
|
-
const handler = getSyntaxPattern('eventHandler', 'react', {
|
|
182
|
-
Name: this.capitalize(name),
|
|
183
|
-
params: def.params || '',
|
|
184
|
-
body: def.body
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
if (this.reactConfig.includeComments && def.description) {
|
|
188
|
-
eventHandlers.push(` // ${def.description}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
eventHandlers.push(` ${handler}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return eventHandlers.join('\n\n');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Get file extension (.tsx for React/TypeScript)
|
|
199
|
-
*/
|
|
200
|
-
public getFileExtension(): string {
|
|
201
|
-
return this.reactConfig.typescript ? '.tsx' : '.jsx';
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Get additional files (styles, types, etc.)
|
|
206
|
-
*/
|
|
207
|
-
public getAdditionalFiles(viewSpec: ViewSpec): Record<string, string> {
|
|
208
|
-
const files: Record<string, string> = {};
|
|
209
|
-
|
|
210
|
-
// Optional: Generate separate types file
|
|
211
|
-
if (this.reactConfig.typescript && this.reactConfig.strictMode) {
|
|
212
|
-
files[`${viewSpec.name}.types.ts`] = this.generateTypesFile(viewSpec);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return files;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// ============================================================================
|
|
219
|
-
// React-Specific Helper Methods
|
|
220
|
-
// ============================================================================
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Get React core imports (useState, useEffect, etc.)
|
|
224
|
-
*/
|
|
225
|
-
private getReactCoreImports(viewSpec: ViewSpec): string {
|
|
226
|
-
const hooks: string[] = [];
|
|
227
|
-
|
|
228
|
-
// Add useState if component has state
|
|
229
|
-
if (viewSpec.state && Object.keys(viewSpec.state).length > 0) {
|
|
230
|
-
hooks.push('useState');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Add useEffect if needed (detect lifecycle needs)
|
|
234
|
-
// For now, simplified - could be enhanced based on view spec analysis
|
|
235
|
-
if (this.needsUseEffect(viewSpec)) {
|
|
236
|
-
hooks.push('useEffect');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (hooks.length > 0) {
|
|
240
|
-
// Generate: import React, { useState, useEffect } from 'react';
|
|
241
|
-
return `import React, { ${hooks.join(', ')} } from 'react';`;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return `import React from 'react';`;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Get component library imports
|
|
249
|
-
*/
|
|
250
|
-
private getComponentImports(componentTypes: Set<string>): string[] {
|
|
251
|
-
const imports: string[] = [];
|
|
252
|
-
const importMap: Map<string, string[]> = new Map();
|
|
253
|
-
|
|
254
|
-
// Group components by their import source
|
|
255
|
-
for (const type of componentTypes) {
|
|
256
|
-
const adapterComponent = this.adapter.components[type];
|
|
257
|
-
if (adapterComponent && adapterComponent.import) {
|
|
258
|
-
// Parse import to group by source
|
|
259
|
-
const importMatch = adapterComponent.import.match(/from ['"](.+)['"]/);
|
|
260
|
-
if (importMatch) {
|
|
261
|
-
const source = importMatch[1];
|
|
262
|
-
const componentMatch = adapterComponent.import.match(/import \{ (.+) \}/);
|
|
263
|
-
if (componentMatch) {
|
|
264
|
-
const componentName = componentMatch[1];
|
|
265
|
-
if (!importMap.has(source)) {
|
|
266
|
-
importMap.set(source, []);
|
|
267
|
-
}
|
|
268
|
-
importMap.get(source)!.push(componentName);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Generate grouped imports
|
|
275
|
-
for (const [source, components] of importMap) {
|
|
276
|
-
imports.push(getSyntaxPattern('libraryImport', 'react', {
|
|
277
|
-
exports: components.join(', '),
|
|
278
|
-
library: source
|
|
279
|
-
}));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return imports;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Generate props interface for TypeScript
|
|
287
|
-
*/
|
|
288
|
-
private generatePropsInterface(componentName: string): string | null {
|
|
289
|
-
if (!this.reactConfig.typescript) {
|
|
290
|
-
return null;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// For now, generate empty interface (can be enhanced based on view spec)
|
|
294
|
-
const lines: string[] = [];
|
|
295
|
-
|
|
296
|
-
if (this.reactConfig.includeComments) {
|
|
297
|
-
lines.push(`/**`);
|
|
298
|
-
lines.push(` * Props for ${componentName} component`);
|
|
299
|
-
lines.push(` */`);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
lines.push(`interface ${componentName}Props {`);
|
|
303
|
-
lines.push(` // Component props will be added here`);
|
|
304
|
-
lines.push(`}`);
|
|
305
|
-
|
|
306
|
-
return lines.join('\n');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Generate main component function
|
|
311
|
-
*/
|
|
312
|
-
private generateComponentFunction(parts: {
|
|
313
|
-
name: string;
|
|
314
|
-
state: string;
|
|
315
|
-
events: string;
|
|
316
|
-
components: string;
|
|
317
|
-
}): string {
|
|
318
|
-
const lines: string[] = [];
|
|
319
|
-
|
|
320
|
-
// Function signature
|
|
321
|
-
const propsParam = this.reactConfig.typescript
|
|
322
|
-
? `props: ${parts.name}Props`
|
|
323
|
-
: 'props';
|
|
324
|
-
|
|
325
|
-
lines.push(`export function ${parts.name}(${propsParam}) {`);
|
|
326
|
-
|
|
327
|
-
// State declarations
|
|
328
|
-
if (parts.state) {
|
|
329
|
-
lines.push(parts.state);
|
|
330
|
-
lines.push('');
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// Event handlers
|
|
334
|
-
if (parts.events) {
|
|
335
|
-
lines.push(parts.events);
|
|
336
|
-
lines.push('');
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Return JSX
|
|
340
|
-
lines.push(' return (');
|
|
341
|
-
lines.push(' <div className="specverse-view">');
|
|
342
|
-
|
|
343
|
-
// Indent component tree
|
|
344
|
-
const indentedComponents = parts.components
|
|
345
|
-
.split('\n')
|
|
346
|
-
.map(line => line ? ` ${line}` : '')
|
|
347
|
-
.join('\n');
|
|
348
|
-
|
|
349
|
-
lines.push(indentedComponents);
|
|
350
|
-
lines.push(' </div>');
|
|
351
|
-
lines.push(' );');
|
|
352
|
-
lines.push('}');
|
|
353
|
-
|
|
354
|
-
return lines.join('\n');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Generate separate types file
|
|
359
|
-
*/
|
|
360
|
-
private generateTypesFile(viewSpec: ViewSpec): string {
|
|
361
|
-
const lines: string[] = [];
|
|
362
|
-
|
|
363
|
-
lines.push(`/**`);
|
|
364
|
-
lines.push(` * Type definitions for ${viewSpec.name}`);
|
|
365
|
-
lines.push(` * Generated by SpecVerse`);
|
|
366
|
-
lines.push(` */`);
|
|
367
|
-
lines.push('');
|
|
368
|
-
|
|
369
|
-
// State types
|
|
370
|
-
if (viewSpec.state) {
|
|
371
|
-
lines.push(`export interface ${viewSpec.name}State {`);
|
|
372
|
-
for (const [name, def] of Object.entries(viewSpec.state)) {
|
|
373
|
-
if (def.description) {
|
|
374
|
-
lines.push(` /** ${def.description} */`);
|
|
375
|
-
}
|
|
376
|
-
lines.push(` ${name}: ${def.type};`);
|
|
377
|
-
}
|
|
378
|
-
lines.push(`}`);
|
|
379
|
-
lines.push('');
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Event handler types
|
|
383
|
-
if (viewSpec.events) {
|
|
384
|
-
for (const [name, def] of Object.entries(viewSpec.events)) {
|
|
385
|
-
const handlerName = `${this.capitalize(name)}Handler`;
|
|
386
|
-
const params = def.params || '';
|
|
387
|
-
|
|
388
|
-
if (def.description) {
|
|
389
|
-
lines.push(`/** ${def.description} */`);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
lines.push(`export type ${handlerName} = (${params}) => void;`);
|
|
393
|
-
lines.push('');
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return lines.join('\n');
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Check if component needs useEffect hook
|
|
402
|
-
*/
|
|
403
|
-
private needsUseEffect(viewSpec: ViewSpec): boolean {
|
|
404
|
-
// Simplified heuristic - could be enhanced
|
|
405
|
-
// Check if any event has mount/unmount keywords
|
|
406
|
-
if (viewSpec.events) {
|
|
407
|
-
const eventNames = Object.keys(viewSpec.events).map(e => e.toLowerCase());
|
|
408
|
-
return eventNames.some(name =>
|
|
409
|
-
name.includes('mount') ||
|
|
410
|
-
name.includes('init') ||
|
|
411
|
-
name.includes('load')
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Capitalize first letter of string
|
|
419
|
-
*/
|
|
420
|
-
private capitalize(str: string): string {
|
|
421
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// ============================================================================
|
|
425
|
-
// React-Specific Component Rendering
|
|
426
|
-
// ============================================================================
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Override to add React-specific rendering hints
|
|
430
|
-
*/
|
|
431
|
-
protected renderAdapterComponent(
|
|
432
|
-
type: string,
|
|
433
|
-
properties: Record<string, any>,
|
|
434
|
-
children: string | undefined,
|
|
435
|
-
context: any
|
|
436
|
-
): string {
|
|
437
|
-
// Add React-specific className if not present
|
|
438
|
-
if (!properties.className && type !== 'container') {
|
|
439
|
-
properties.className = `specverse-${type}`;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Call parent implementation
|
|
443
|
-
return super.renderAdapterComponent(type, properties, children, context);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// ============================================================================
|
|
448
|
-
// Factory Function
|
|
449
|
-
// ============================================================================
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Create a ReactComponentGenerator instance
|
|
453
|
-
*
|
|
454
|
-
* @param adapter - Component adapter (shadcn, mui, antd)
|
|
455
|
-
* @param config - Generator configuration
|
|
456
|
-
* @returns ReactComponentGenerator instance
|
|
457
|
-
*/
|
|
458
|
-
export function createReactGenerator(
|
|
459
|
-
adapter: ComponentAdapter,
|
|
460
|
-
config?: Partial<ReactGeneratorConfig>
|
|
461
|
-
): ReactComponentGenerator {
|
|
462
|
-
const defaultConfig: ReactGeneratorConfig = {
|
|
463
|
-
framework: 'react',
|
|
464
|
-
target: 'shadcn',
|
|
465
|
-
typescript: true,
|
|
466
|
-
strictMode: false,
|
|
467
|
-
includeComments: true,
|
|
468
|
-
maxDepth: 3,
|
|
469
|
-
enableWarnings: true
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
const finalConfig = { ...defaultConfig, ...config } as ReactGeneratorConfig;
|
|
473
|
-
|
|
474
|
-
return new ReactComponentGenerator(adapter, finalConfig);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// ============================================================================
|
|
478
|
-
// Convenience Functions
|
|
479
|
-
// ============================================================================
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Generate React component from view spec (one-liner)
|
|
483
|
-
*
|
|
484
|
-
* @param viewSpec - View specification
|
|
485
|
-
* @param adapter - Component adapter
|
|
486
|
-
* @param options - Optional configuration
|
|
487
|
-
* @returns Generated component code
|
|
488
|
-
*/
|
|
489
|
-
export function generateReactComponent(
|
|
490
|
-
viewSpec: ViewSpec,
|
|
491
|
-
adapter: ComponentAdapter,
|
|
492
|
-
options?: Partial<ReactGeneratorConfig>
|
|
493
|
-
): string {
|
|
494
|
-
const generator = createReactGenerator(adapter, options);
|
|
495
|
-
const result = generator.generate(viewSpec);
|
|
496
|
-
|
|
497
|
-
if (result.warnings.length > 0) {
|
|
498
|
-
console.warn('Generation warnings:', result.warnings);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
return result.code;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Generate React component with all additional files
|
|
506
|
-
*
|
|
507
|
-
* @param viewSpec - View specification
|
|
508
|
-
* @param adapter - Component adapter
|
|
509
|
-
* @param options - Optional configuration
|
|
510
|
-
* @returns Map of filename to content
|
|
511
|
-
*/
|
|
512
|
-
export function generateReactComponentFiles(
|
|
513
|
-
viewSpec: ViewSpec,
|
|
514
|
-
adapter: ComponentAdapter,
|
|
515
|
-
options?: Partial<ReactGeneratorConfig>
|
|
516
|
-
): Map<string, string> {
|
|
517
|
-
const generator = createReactGenerator(adapter, options);
|
|
518
|
-
const result = generator.generate(viewSpec);
|
|
519
|
-
|
|
520
|
-
const files = new Map<string, string>();
|
|
521
|
-
|
|
522
|
-
// Main component file
|
|
523
|
-
const ext = generator.getFileExtension();
|
|
524
|
-
files.set(`${viewSpec.name}${ext}`, result.code);
|
|
525
|
-
|
|
526
|
-
// Additional files (types, styles, etc.)
|
|
527
|
-
const additionalFiles = generator.getAdditionalFiles(viewSpec);
|
|
528
|
-
for (const [filename, content] of Object.entries(additionalFiles)) {
|
|
529
|
-
files.set(filename, content);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return files;
|
|
533
|
-
}
|