@specverse/engines 4.1.30 → 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/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/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/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/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/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,321 +0,0 @@
|
|
|
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
|
-
};
|