@specverse/engines 4.1.5 → 4.1.6
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/dist/libs/instance-factories/applications/templates/generic/backend-env-generator.js +22 -0
- package/dist/libs/instance-factories/applications/templates/generic/backend-package-json-generator.js +66 -0
- package/dist/libs/instance-factories/applications/templates/generic/backend-tsconfig-generator.js +54 -0
- package/dist/libs/instance-factories/applications/templates/generic/main-generator.js +290 -0
- package/dist/libs/instance-factories/applications/templates/react/_view-components-source.js +530 -0
- package/dist/libs/instance-factories/applications/templates/react/api-client-generator.js +437 -0
- package/dist/libs/instance-factories/applications/templates/react/api-types-generator.js +146 -0
- package/dist/libs/instance-factories/applications/templates/react/app-tsx-generator.js +73 -0
- package/dist/libs/instance-factories/applications/templates/react/env-example-generator.js +18 -0
- package/dist/libs/instance-factories/applications/templates/react/field-helpers-generator.js +99 -0
- package/dist/libs/instance-factories/applications/templates/react/gitignore-generator.js +35 -0
- package/dist/libs/instance-factories/applications/templates/react/index-css-generator.js +9 -0
- package/dist/libs/instance-factories/applications/templates/react/index-html-generator.js +23 -0
- package/dist/libs/instance-factories/applications/templates/react/main-tsx-generator.js +29 -0
- package/dist/libs/instance-factories/applications/templates/react/package-json-generator.js +49 -0
- package/dist/libs/instance-factories/applications/templates/react/pattern-adapter-generator.js +156 -0
- package/dist/libs/instance-factories/applications/templates/react/react-pattern-adapter.js +935 -0
- package/dist/libs/instance-factories/applications/templates/react/relationship-field-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/runtime-app-tsx-generator.js +101 -0
- package/dist/libs/instance-factories/applications/templates/react/runtime-package-json-generator.js +50 -0
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-generator.js +646 -0
- package/dist/libs/instance-factories/applications/templates/react/tailwind-adapter-wrapper-generator.js +65 -0
- package/dist/libs/instance-factories/applications/templates/react/tsconfig-generator.js +28 -0
- package/dist/libs/instance-factories/applications/templates/react/use-api-hooks-generator.js +132 -0
- package/dist/libs/instance-factories/applications/templates/react/view-dashboard-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/view-detail-generator.js +143 -0
- package/dist/libs/instance-factories/applications/templates/react/view-form-generator.js +355 -0
- package/dist/libs/instance-factories/applications/templates/react/view-list-generator.js +91 -0
- package/dist/libs/instance-factories/applications/templates/react/view-router-generator.js +79 -0
- package/dist/libs/instance-factories/applications/templates/react/vite-config-generator.js +42 -0
- package/dist/libs/instance-factories/cli/templates/commander/cli-bin-wrapper-generator.js +11 -0
- package/dist/libs/instance-factories/cli/templates/commander/cli-entry-generator.js +111 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +928 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/bus-generator.js +83 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/publisher-generator.js +91 -0
- package/dist/libs/instance-factories/communication/templates/eventemitter/subscriber-generator.js +86 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/meta-routes-generator.js +93 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/routes-generator.js +280 -0
- package/dist/libs/instance-factories/controllers/templates/fastify/server-generator.js +125 -0
- package/dist/libs/instance-factories/infrastructure/templates/docker-k8s/infrastructure-generator.js +25 -0
- package/dist/libs/instance-factories/orms/templates/prisma/schema-generator.js +371 -0
- package/dist/libs/instance-factories/orms/templates/prisma/services-generator.js +266 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/env-example-generator.js +51 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/env-generator.js +61 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/gitignore-generator.js +59 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/package-json-generator.js +126 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/readme-generator.js +159 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/tsconfig-generator.js +56 -0
- package/dist/libs/instance-factories/scaffolding/templates/generic/tsconfig-react-generator.js +37 -0
- package/dist/libs/instance-factories/sdks/templates/python/sdk-generator.js +29 -0
- package/dist/libs/instance-factories/sdks/templates/typescript/sdk-generator.js +28 -0
- package/dist/libs/instance-factories/services/templates/memory/generate-interpreter.js +14 -0
- package/dist/libs/instance-factories/services/templates/memory/step-conventions-memory.js +415 -0
- package/dist/libs/instance-factories/services/templates/prisma/behavior-generator.js +177 -0
- package/dist/libs/instance-factories/services/templates/prisma/controller-generator.js +413 -0
- package/dist/libs/instance-factories/services/templates/prisma/service-generator.js +243 -0
- package/dist/libs/instance-factories/services/templates/prisma/step-conventions.js +264 -0
- package/dist/libs/instance-factories/services/templates/shared-patterns.js +24 -0
- package/dist/libs/instance-factories/shared/path-resolver.js +59 -0
- package/dist/libs/instance-factories/storage/templates/mongodb/config-generator.js +13 -0
- package/dist/libs/instance-factories/storage/templates/mongodb/docker-generator.js +16 -0
- package/dist/libs/instance-factories/storage/templates/postgresql/config-generator.js +45 -0
- package/dist/libs/instance-factories/storage/templates/postgresql/docker-generator.js +46 -0
- package/dist/libs/instance-factories/storage/templates/redis/config-generator.js +14 -0
- package/dist/libs/instance-factories/storage/templates/redis/docker-generator.js +16 -0
- package/dist/libs/instance-factories/test-generation.js +145 -0
- package/dist/libs/instance-factories/testing/templates/vitest/tests-generator.js +30 -0
- package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +149 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/controllers/MCPServerController.js +232 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/events/EventEmitter.js +49 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/index.js +18 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/interfaces/ResourceProvider.js +0 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/models/LibrarySuggestion.js +97 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/models/SpecVerseResource.js +64 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/server/mcp-server.js +182 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/CLIProxyService.js +1210 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/EmbeddedResourcesAdapter.js +172 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/EntityModuleService.js +240 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/HybridResourcesProvider.js +147 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/LibraryToolsService.js +281 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorBridge.js +409 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/OrchestratorToolsService.js +414 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/PromptToolsService.js +467 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/services/ResourcesProviderService.js +135 -0
- package/dist/libs/instance-factories/tools/templates/mcp/static/src/types/index.js +0 -0
- package/dist/libs/instance-factories/tools/templates/vscode/static/extension.js +965 -0
- package/dist/libs/instance-factories/tools/templates/vscode/vscode-extension-generator.js +238 -0
- package/dist/libs/instance-factories/validation/templates/zod/validation-generator.js +25 -0
- package/dist/libs/instance-factories/views/index.js +48 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/antd-adapter.js +742 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/mui-adapter.js +824 -0
- package/dist/libs/instance-factories/views/templates/react/adapters/shadcn-adapter.js +719 -0
- package/dist/libs/instance-factories/views/templates/react/app-generator.js +45 -0
- package/dist/libs/instance-factories/views/templates/react/components-generator.js +779 -0
- package/dist/libs/instance-factories/views/templates/react/forms-generator.js +285 -0
- package/dist/libs/instance-factories/views/templates/react/frontend-package-json-generator.js +46 -0
- package/dist/libs/instance-factories/views/templates/react/hooks-generator.js +111 -0
- package/dist/libs/instance-factories/views/templates/react/index-css-generator.js +9 -0
- package/dist/libs/instance-factories/views/templates/react/index-html-generator.js +23 -0
- package/dist/libs/instance-factories/views/templates/react/main-tsx-generator.js +21 -0
- package/dist/libs/instance-factories/views/templates/react/react-component-generator.js +299 -0
- package/dist/libs/instance-factories/views/templates/react/router-generator.js +136 -0
- package/dist/libs/instance-factories/views/templates/react/router-generic-generator.js +107 -0
- package/dist/libs/instance-factories/views/templates/react/shared-utils-generator.js +179 -0
- package/dist/libs/instance-factories/views/templates/react/spec-json-generator.js +7 -0
- package/dist/libs/instance-factories/views/templates/react/types-generator.js +56 -0
- package/dist/libs/instance-factories/views/templates/react/views-metadata-generator.js +27 -0
- package/dist/libs/instance-factories/views/templates/react/vite-config-generator.js +29 -0
- package/dist/libs/instance-factories/views/templates/runtime/runtime-view-renderer.js +261 -0
- package/dist/libs/instance-factories/views/templates/shared/adapter-types.js +34 -0
- package/dist/libs/instance-factories/views/templates/shared/atomic-components-registry.js +800 -0
- package/dist/libs/instance-factories/views/templates/shared/base-generator.js +305 -0
- package/dist/libs/instance-factories/views/templates/shared/component-metadata.js +517 -0
- 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 +445 -0
- package/dist/libs/instance-factories/views/templates/shared/index.js +80 -0
- package/dist/libs/instance-factories/views/templates/shared/pattern-validator.js +210 -0
- package/dist/libs/instance-factories/views/templates/shared/property-mapper.js +492 -0
- package/dist/libs/instance-factories/views/templates/shared/syntax-mapper.js +321 -0
- package/package.json +3 -2
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
const STATE_PATTERNS = {
|
|
2
|
+
/**
|
|
3
|
+
* Declare a state variable
|
|
4
|
+
* Variables: name, Name (capitalized), type (optional), initial
|
|
5
|
+
*/
|
|
6
|
+
stateDeclaration: {
|
|
7
|
+
react: "const [${name}, set${Name}] = useState<${type}>(${initial});",
|
|
8
|
+
vue: "const ${name} = ref<${type}>(${initial});",
|
|
9
|
+
svelte: "let ${name}: ${type} = ${initial};",
|
|
10
|
+
angular: "${name}: ${type} = ${initial};",
|
|
11
|
+
runtime: "const [${name}, set${Name}] = useState<${type}>(${initial});"
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Update a state variable
|
|
15
|
+
* Variables: name, Name (capitalized), value
|
|
16
|
+
*/
|
|
17
|
+
stateUpdate: {
|
|
18
|
+
react: "set${Name}(${value});",
|
|
19
|
+
vue: "${name}.value = ${value};",
|
|
20
|
+
svelte: "${name} = ${value};",
|
|
21
|
+
angular: "this.${name} = ${value};",
|
|
22
|
+
runtime: "set${Name}(${value});"
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Access a state variable value
|
|
26
|
+
* Variables: name
|
|
27
|
+
*/
|
|
28
|
+
stateGetter: {
|
|
29
|
+
react: "${name}",
|
|
30
|
+
vue: "${name}.value",
|
|
31
|
+
svelte: "${name}",
|
|
32
|
+
angular: "this.${name}",
|
|
33
|
+
runtime: "${name}"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const RENDER_PATTERNS = {
|
|
37
|
+
/**
|
|
38
|
+
* Render array of items with loop
|
|
39
|
+
* Variables: array, item, key, Component
|
|
40
|
+
*/
|
|
41
|
+
loopRender: {
|
|
42
|
+
react: "{${array}.map((${item}) => <${Component} key={${item}.${key}} ${item}={${item}} />)}",
|
|
43
|
+
vue: '<${Component} v-for="${item} in ${array}" :key="${item}.${key}" :${item}="${item}" />',
|
|
44
|
+
svelte: "{#each ${array} as ${item} (${item}.${key})}<${Component} ${item}={${item}} />{/each}",
|
|
45
|
+
angular: '<${component} *ngFor="let ${item} of ${array}; trackBy: track${Item}" [${item}]="${item}"></${component}>',
|
|
46
|
+
runtime: "{${array}.map((${item}) => createElement(${Component}, { key: ${item}.${key}, ${item} }))}"
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Conditional rendering
|
|
50
|
+
* Variables: condition, Component, props (optional)
|
|
51
|
+
*/
|
|
52
|
+
conditionalRender: {
|
|
53
|
+
react: "{${condition} && <${Component} ${props} />}",
|
|
54
|
+
vue: '<${Component} v-if="${condition}" ${props} />',
|
|
55
|
+
svelte: "{#if ${condition}}<${Component} ${props} />{/if}",
|
|
56
|
+
angular: '<${component} *ngIf="${condition}" ${props}></${component}>',
|
|
57
|
+
runtime: "{${condition} && createElement(${Component}, ${props})}"
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Render a component with props
|
|
61
|
+
* Variables: Component, props
|
|
62
|
+
*/
|
|
63
|
+
componentRender: {
|
|
64
|
+
react: "<${Component} ${props} />",
|
|
65
|
+
vue: "<${Component} ${props} />",
|
|
66
|
+
svelte: "<${Component} ${props} />",
|
|
67
|
+
angular: "<${component} ${props}></${component}>",
|
|
68
|
+
runtime: "createElement(${Component}, ${props})"
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const EVENT_PATTERNS = {
|
|
72
|
+
/**
|
|
73
|
+
* Declare event handler function
|
|
74
|
+
* Variables: name, Name (capitalized), params, body
|
|
75
|
+
*/
|
|
76
|
+
eventHandler: {
|
|
77
|
+
react: "const handle${Name} = (${params}) => {\n ${body}\n};",
|
|
78
|
+
vue: "const handle${Name} = (${params}) => {\n ${body}\n};",
|
|
79
|
+
svelte: "function handle${Name}(${params}) {\n ${body}\n}",
|
|
80
|
+
angular: "handle${Name}(${params}): void {\n ${body}\n}",
|
|
81
|
+
runtime: "const handle${Name} = (${params}) => {\n ${body}\n};"
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Bind event to handler
|
|
85
|
+
* Variables: event, handler
|
|
86
|
+
*/
|
|
87
|
+
eventBinding: {
|
|
88
|
+
react: "${event}={${handler}}",
|
|
89
|
+
vue: '@${event}="${handler}"',
|
|
90
|
+
svelte: "on:${event}={${handler}}",
|
|
91
|
+
angular: '(${event})="${handler}($event)"',
|
|
92
|
+
runtime: "${event}: ${handler}"
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const LIFECYCLE_PATTERNS = {
|
|
96
|
+
/**
|
|
97
|
+
* Component mount lifecycle
|
|
98
|
+
* Variables: body
|
|
99
|
+
*/
|
|
100
|
+
onMount: {
|
|
101
|
+
react: "useEffect(() => {\n ${body}\n}, []);",
|
|
102
|
+
vue: "onMounted(() => {\n ${body}\n});",
|
|
103
|
+
svelte: "onMount(() => {\n ${body}\n});",
|
|
104
|
+
angular: "ngOnInit(): void {\n ${body}\n}",
|
|
105
|
+
runtime: "useEffect(() => {\n ${body}\n}, []);"
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Component unmount lifecycle
|
|
109
|
+
* Variables: body
|
|
110
|
+
*/
|
|
111
|
+
onUnmount: {
|
|
112
|
+
react: "useEffect(() => {\n return () => {\n ${body}\n };\n}, []);",
|
|
113
|
+
vue: "onUnmounted(() => {\n ${body}\n});",
|
|
114
|
+
svelte: "onDestroy(() => {\n ${body}\n});",
|
|
115
|
+
angular: "ngOnDestroy(): void {\n ${body}\n}",
|
|
116
|
+
runtime: "useEffect(() => {\n return () => {\n ${body}\n };\n}, []);"
|
|
117
|
+
},
|
|
118
|
+
/**
|
|
119
|
+
* Value change/update lifecycle
|
|
120
|
+
* Variables: dependencies, body
|
|
121
|
+
*/
|
|
122
|
+
onUpdate: {
|
|
123
|
+
react: "useEffect(() => {\n ${body}\n}, [${dependencies}]);",
|
|
124
|
+
vue: "watch([${dependencies}], () => {\n ${body}\n});",
|
|
125
|
+
svelte: "$: if (${dependencies}) {\n ${body}\n}",
|
|
126
|
+
angular: "ngOnChanges(changes: SimpleChanges): void {\n ${body}\n}",
|
|
127
|
+
runtime: "useEffect(() => {\n ${body}\n}, [${dependencies}]);"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const PROP_PATTERNS = {
|
|
131
|
+
/**
|
|
132
|
+
* Declare component props/properties
|
|
133
|
+
* Variables: name, type, required (boolean)
|
|
134
|
+
*/
|
|
135
|
+
propDeclaration: {
|
|
136
|
+
react: '${name}${required ? "" : "?"}: ${type}',
|
|
137
|
+
vue: "${name}: { type: ${type}, required: ${required} }",
|
|
138
|
+
svelte: 'export let ${name}: ${type}${required ? "" : " | undefined"};',
|
|
139
|
+
angular: '@Input() ${name}${required ? "!" : "?"}: ${type};',
|
|
140
|
+
runtime: '${name}${required ? "" : "?"}: ${type}'
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Access props inside component
|
|
144
|
+
* Variables: name
|
|
145
|
+
*/
|
|
146
|
+
propAccess: {
|
|
147
|
+
react: "${name}",
|
|
148
|
+
vue: "props.${name}",
|
|
149
|
+
svelte: "${name}",
|
|
150
|
+
angular: "this.${name}",
|
|
151
|
+
runtime: "${name}"
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Bind prop value to component
|
|
155
|
+
* Variables: name, value
|
|
156
|
+
*/
|
|
157
|
+
propBinding: {
|
|
158
|
+
react: "${name}={${value}}",
|
|
159
|
+
vue: ':${name}="${value}"',
|
|
160
|
+
svelte: "${name}={${value}}",
|
|
161
|
+
angular: '[${name}]="${value}"',
|
|
162
|
+
runtime: "${name}: ${value}"
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const IMPORT_PATTERNS = {
|
|
166
|
+
/**
|
|
167
|
+
* Import a component
|
|
168
|
+
* Variables: Component, path
|
|
169
|
+
*/
|
|
170
|
+
componentImport: {
|
|
171
|
+
react: "import ${Component} from '${path}';",
|
|
172
|
+
vue: "import ${Component} from '${path}';",
|
|
173
|
+
svelte: "import ${Component} from '${path}';",
|
|
174
|
+
angular: "import { ${Component} } from '${path}';",
|
|
175
|
+
runtime: "import ${Component} from '${path}';"
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Import hooks/composables
|
|
179
|
+
* Variables: hooks (comma-separated), source
|
|
180
|
+
*/
|
|
181
|
+
hookImport: {
|
|
182
|
+
react: "import { ${hooks} } from '${source}';",
|
|
183
|
+
vue: "import { ${hooks} } from '${source}';",
|
|
184
|
+
svelte: "import { ${hooks} } from '${source}';",
|
|
185
|
+
angular: "import { ${hooks} } from '${source}';",
|
|
186
|
+
runtime: "import { ${hooks} } from '${source}';"
|
|
187
|
+
},
|
|
188
|
+
/**
|
|
189
|
+
* Import from library
|
|
190
|
+
* Variables: exports, library
|
|
191
|
+
*/
|
|
192
|
+
libraryImport: {
|
|
193
|
+
react: "import { ${exports} } from '${library}';",
|
|
194
|
+
vue: "import { ${exports} } from '${library}';",
|
|
195
|
+
svelte: "import { ${exports} } from '${library}';",
|
|
196
|
+
angular: "import { ${exports} } from '${library}';",
|
|
197
|
+
runtime: "import { ${exports} } from '${library}';"
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const SYNTAX_PATTERNS = {
|
|
201
|
+
// State
|
|
202
|
+
stateDeclaration: STATE_PATTERNS.stateDeclaration,
|
|
203
|
+
stateUpdate: STATE_PATTERNS.stateUpdate,
|
|
204
|
+
stateGetter: STATE_PATTERNS.stateGetter,
|
|
205
|
+
// Rendering
|
|
206
|
+
loopRender: RENDER_PATTERNS.loopRender,
|
|
207
|
+
conditionalRender: RENDER_PATTERNS.conditionalRender,
|
|
208
|
+
componentRender: RENDER_PATTERNS.componentRender,
|
|
209
|
+
// Events
|
|
210
|
+
eventHandler: EVENT_PATTERNS.eventHandler,
|
|
211
|
+
eventBinding: EVENT_PATTERNS.eventBinding,
|
|
212
|
+
// Lifecycle
|
|
213
|
+
onMount: LIFECYCLE_PATTERNS.onMount,
|
|
214
|
+
onUnmount: LIFECYCLE_PATTERNS.onUnmount,
|
|
215
|
+
onUpdate: LIFECYCLE_PATTERNS.onUpdate,
|
|
216
|
+
// Props
|
|
217
|
+
propDeclaration: PROP_PATTERNS.propDeclaration,
|
|
218
|
+
propAccess: PROP_PATTERNS.propAccess,
|
|
219
|
+
propBinding: PROP_PATTERNS.propBinding,
|
|
220
|
+
// Imports
|
|
221
|
+
componentImport: IMPORT_PATTERNS.componentImport,
|
|
222
|
+
hookImport: IMPORT_PATTERNS.hookImport,
|
|
223
|
+
libraryImport: IMPORT_PATTERNS.libraryImport
|
|
224
|
+
};
|
|
225
|
+
function replaceTemplateVariables(template, variables) {
|
|
226
|
+
let result = template;
|
|
227
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
228
|
+
const capitalizedKey = key.charAt(0).toUpperCase() + key.slice(1);
|
|
229
|
+
const capitalizedPattern = new RegExp(`\\$\\{${capitalizedKey}\\}`, "g");
|
|
230
|
+
result = result.replace(capitalizedPattern, String(value).charAt(0).toUpperCase() + String(value).slice(1));
|
|
231
|
+
const normalPattern = new RegExp(`\\$\\{${key}\\}`, "g");
|
|
232
|
+
result = result.replace(normalPattern, String(value));
|
|
233
|
+
}
|
|
234
|
+
result = result.replace(/\$\{(\w+)\s*\?\s*"([^"]*)"\s*:\s*"([^"]*)"\}/g, (match, varName, trueVal, falseVal) => {
|
|
235
|
+
const varValue = variables[varName];
|
|
236
|
+
return varValue ? trueVal : falseVal;
|
|
237
|
+
});
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
function getSyntaxPattern(pattern, framework, variables) {
|
|
241
|
+
const syntaxPattern = SYNTAX_PATTERNS[pattern];
|
|
242
|
+
if (!syntaxPattern) {
|
|
243
|
+
throw new Error(`Unknown syntax pattern: ${pattern}`);
|
|
244
|
+
}
|
|
245
|
+
const template = syntaxPattern[framework];
|
|
246
|
+
if (!template) {
|
|
247
|
+
throw new Error(`Framework ${framework} not supported for pattern ${pattern}`);
|
|
248
|
+
}
|
|
249
|
+
return replaceTemplateVariables(template, variables);
|
|
250
|
+
}
|
|
251
|
+
function getAllFrameworkSyntax(pattern, variables) {
|
|
252
|
+
const frameworks = ["react", "vue", "svelte", "angular", "runtime"];
|
|
253
|
+
const result = {};
|
|
254
|
+
for (const framework of frameworks) {
|
|
255
|
+
result[framework] = getSyntaxPattern(pattern, framework, variables);
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
function hasPattern(pattern, framework) {
|
|
260
|
+
const syntaxPattern = SYNTAX_PATTERNS[pattern];
|
|
261
|
+
return Boolean(syntaxPattern && syntaxPattern[framework] !== void 0);
|
|
262
|
+
}
|
|
263
|
+
function getAllPatternKeys() {
|
|
264
|
+
return Object.keys(SYNTAX_PATTERNS);
|
|
265
|
+
}
|
|
266
|
+
function getPatternsByCategory(category) {
|
|
267
|
+
const categoryMap = {
|
|
268
|
+
state: ["stateDeclaration", "stateUpdate", "stateGetter"],
|
|
269
|
+
render: ["loopRender", "conditionalRender", "componentRender"],
|
|
270
|
+
event: ["eventHandler", "eventBinding"],
|
|
271
|
+
lifecycle: ["onMount", "onUnmount", "onUpdate"],
|
|
272
|
+
prop: ["propDeclaration", "propAccess", "propBinding"],
|
|
273
|
+
import: ["componentImport", "hookImport", "libraryImport"]
|
|
274
|
+
};
|
|
275
|
+
return categoryMap[category] || [];
|
|
276
|
+
}
|
|
277
|
+
function generateStateCode(framework, stateName, stateType, initialValue) {
|
|
278
|
+
const declaration = getSyntaxPattern("stateDeclaration", framework, {
|
|
279
|
+
name: stateName,
|
|
280
|
+
Name: stateName.charAt(0).toUpperCase() + stateName.slice(1),
|
|
281
|
+
type: stateType,
|
|
282
|
+
initial: initialValue
|
|
283
|
+
});
|
|
284
|
+
const update = (value) => getSyntaxPattern("stateUpdate", framework, {
|
|
285
|
+
name: stateName,
|
|
286
|
+
Name: stateName.charAt(0).toUpperCase() + stateName.slice(1),
|
|
287
|
+
value
|
|
288
|
+
});
|
|
289
|
+
const get = getSyntaxPattern("stateGetter", framework, { name: stateName });
|
|
290
|
+
return { declaration, update, get };
|
|
291
|
+
}
|
|
292
|
+
function generateEventCode(framework, eventName, handlerName, params, body) {
|
|
293
|
+
const handler = getSyntaxPattern("eventHandler", framework, {
|
|
294
|
+
name: handlerName,
|
|
295
|
+
Name: handlerName.charAt(0).toUpperCase() + handlerName.slice(1),
|
|
296
|
+
params,
|
|
297
|
+
body
|
|
298
|
+
});
|
|
299
|
+
const binding = getSyntaxPattern("eventBinding", framework, {
|
|
300
|
+
event: eventName,
|
|
301
|
+
handler: `handle${handlerName.charAt(0).toUpperCase() + handlerName.slice(1)}`
|
|
302
|
+
});
|
|
303
|
+
return { handler, binding };
|
|
304
|
+
}
|
|
305
|
+
export {
|
|
306
|
+
EVENT_PATTERNS,
|
|
307
|
+
IMPORT_PATTERNS,
|
|
308
|
+
LIFECYCLE_PATTERNS,
|
|
309
|
+
PROP_PATTERNS,
|
|
310
|
+
RENDER_PATTERNS,
|
|
311
|
+
STATE_PATTERNS,
|
|
312
|
+
SYNTAX_PATTERNS,
|
|
313
|
+
generateEventCode,
|
|
314
|
+
generateStateCode,
|
|
315
|
+
getAllFrameworkSyntax,
|
|
316
|
+
getAllPatternKeys,
|
|
317
|
+
getPatternsByCategory,
|
|
318
|
+
getSyntaxPattern,
|
|
319
|
+
hasPattern,
|
|
320
|
+
replaceTemplateVariables
|
|
321
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specverse/engines",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
4
|
"description": "SpecVerse toolchain — parser, inference, realize, generators, AI, registry",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "tsc",
|
|
41
|
+
"build": "tsc && node scripts/compile-libs.mjs",
|
|
42
42
|
"clean": "rm -rf dist"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^25.5.0",
|
|
56
|
+
"esbuild": "^0.25.0",
|
|
56
57
|
"typescript": "^5.4.0"
|
|
57
58
|
},
|
|
58
59
|
"files": [
|