@allternit/ix 0.1.0 → 0.1.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/README.md +6 -6
- package/dist/adapters/json-render.d.ts +5 -5
- package/dist/adapters/json-render.js +12 -12
- package/dist/collab/visual-editor.d.ts +1 -1
- package/dist/collab/visual-editor.js +4 -4
- package/dist/collab/visual-editor.js.map +1 -1
- package/dist/collab/yjs-adapter.d.ts +1 -1
- package/dist/collab/yjs-adapter.js +2 -2
- package/dist/collab/yjs-adapter.js.map +1 -1
- package/dist/collab/yjs-client.js +1 -1
- package/dist/collab/yjs-client.js.map +1 -1
- package/dist/collab/yjs-types.js +1 -1
- package/dist/collab/yjs-types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pipeline/llm-to-ix.d.ts +5 -5
- package/dist/pipeline/llm-to-ix.d.ts.map +1 -1
- package/dist/pipeline/llm-to-ix.js +6 -6
- package/dist/react/renderer.d.ts +2 -2
- package/dist/react/renderer.js +3 -3
- package/dist/react/renderer.js.map +1 -1
- package/dist/renderer/renderer.d.ts +1 -1
- package/dist/renderer/renderer.js +1 -1
- package/dist/runtime/capsule-runtime.d.ts +1 -1
- package/dist/runtime/capsule-runtime.js +1 -1
- package/dist/sdk/api.d.ts +3 -3
- package/dist/sdk/api.js +3 -3
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +2 -2
- package/dist/sdk/react.d.ts +2 -2
- package/dist/sdk/react.js +2 -2
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -1
- package/dist/state/store.d.ts +1 -1
- package/dist/state/store.js +3 -3
- package/dist/state/store.js.map +1 -1
- package/dist/svelte/index.d.ts +1 -1
- package/dist/svelte/index.js +1 -1
- package/dist/svelte/renderer.d.ts +3 -3
- package/dist/svelte/renderer.js +4 -4
- package/dist/svelte/renderer.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/dist/vue/renderer.d.ts +3 -3
- package/dist/vue/renderer.js +5 -5
- package/dist/vue/renderer.js.map +1 -1
- package/package.json +8 -8
- package/dist/adapters/json-render.d.ts.bak +0 -211
- package/dist/adapters/json-render.js.bak +0 -576
- package/dist/catalog/registry.d.ts.bak +0 -65
- package/dist/catalog/registry.js.bak +0 -388
- package/dist/collab/capsule-registry.d.ts.bak +0 -114
- package/dist/collab/capsule-registry.js.bak +0 -271
- package/dist/collab/index.d.ts.bak +0 -21
- package/dist/collab/index.js.bak +0 -32
- package/dist/collab/visual-editor.d.ts.bak +0 -199
- package/dist/collab/visual-editor.js.bak +0 -259
- package/dist/collab/yjs-adapter.d.ts.bak +0 -95
- package/dist/collab/yjs-adapter.js.bak +0 -282
- package/dist/collab/yjs-client.d.ts.bak +0 -101
- package/dist/collab/yjs-client.js.bak +0 -193
- package/dist/collab/yjs-protocols.d.ts.bak +0 -128
- package/dist/collab/yjs-protocols.js.bak +0 -245
- package/dist/collab/yjs-types.d.ts.bak +0 -201
- package/dist/collab/yjs-types.js.bak +0 -45
- package/dist/index.d.ts.bak +0 -38
- package/dist/index.js.bak +0 -48
- package/dist/pipeline/llm-to-ix.d.ts.bak +0 -249
- package/dist/pipeline/llm-to-ix.js.bak +0 -992
- package/dist/react/index.d.ts.bak +0 -18
- package/dist/react/index.js.bak +0 -18
- package/dist/react/renderer.d.ts.bak +0 -47
- package/dist/react/renderer.js.bak +0 -420
- package/dist/renderer/renderer.d.ts.bak +0 -55
- package/dist/renderer/renderer.js.bak +0 -232
- package/dist/runtime/capsule-runtime.d.ts.bak +0 -227
- package/dist/runtime/capsule-runtime.js.bak +0 -563
- package/dist/runtime/policy-gates.d.ts.bak +0 -116
- package/dist/runtime/policy-gates.js.bak +0 -317
- package/dist/schema/ui-ir.d.ts.bak +0 -26
- package/dist/schema/ui-ir.js.bak +0 -51
- package/dist/sdk/api.d.ts.bak +0 -101
- package/dist/sdk/api.js.bak +0 -177
- package/dist/sdk/index.d.ts.bak +0 -9
- package/dist/sdk/index.js.bak +0 -10
- package/dist/sdk/react.d.ts.bak +0 -63
- package/dist/sdk/react.js.bak +0 -161
- package/dist/state/index.d.ts.bak +0 -8
- package/dist/state/index.js.bak +0 -8
- package/dist/state/patch.d.ts.bak +0 -73
- package/dist/state/patch.js.bak +0 -437
- package/dist/state/store.d.ts.bak +0 -50
- package/dist/state/store.js.bak +0 -246
- package/dist/svelte/index.d.ts.bak +0 -15
- package/dist/svelte/index.js.bak +0 -15
- package/dist/svelte/renderer.d.ts.bak +0 -35
- package/dist/svelte/renderer.js.bak +0 -317
- package/dist/types/index.d.ts.bak +0 -349
- package/dist/types/index.js.bak +0 -152
- package/dist/vue/index.d.ts.bak +0 -18
- package/dist/vue/index.js.bak +0 -18
- package/dist/vue/renderer.d.ts.bak +0 -46
- package/dist/vue/renderer.js.bak +0 -302
package/dist/vue/renderer.js.bak
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vue Renderer for A2R-IX
|
|
3
|
-
*
|
|
4
|
-
* Renders A2R-IX UI IR to Vue 3 components.
|
|
5
|
-
*/
|
|
6
|
-
import { createDefaultCatalog } from '../catalog/registry';
|
|
7
|
-
/**
|
|
8
|
-
* Create Vue renderer
|
|
9
|
-
*/
|
|
10
|
-
export function createVueRenderer(config) {
|
|
11
|
-
const catalog = config.catalog ?? createDefaultCatalog();
|
|
12
|
-
/**
|
|
13
|
-
* Generate component definition
|
|
14
|
-
*/
|
|
15
|
-
function generateComponent(root) {
|
|
16
|
-
const name = 'A2RIXRoot';
|
|
17
|
-
// Generate props from state variables
|
|
18
|
-
const props = {};
|
|
19
|
-
root.state.variables.forEach((variable) => {
|
|
20
|
-
props[sanitizeName(variable.path)] = {
|
|
21
|
-
type: getVueType(variable.type),
|
|
22
|
-
default: variable.default,
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
// Generate setup function
|
|
26
|
-
const setupLines = [
|
|
27
|
-
'// A2R-IX Generated Component',
|
|
28
|
-
"import { ref, computed, watch } from 'vue';",
|
|
29
|
-
'',
|
|
30
|
-
'// State',
|
|
31
|
-
];
|
|
32
|
-
// State refs
|
|
33
|
-
root.state.variables.forEach((variable) => {
|
|
34
|
-
const varName = sanitizeName(variable.path);
|
|
35
|
-
setupLines.push(`const ${varName} = ref(props.${varName});`);
|
|
36
|
-
});
|
|
37
|
-
// Computed values
|
|
38
|
-
if (root.state.computed) {
|
|
39
|
-
setupLines.push('');
|
|
40
|
-
setupLines.push('// Computed values');
|
|
41
|
-
root.state.computed.forEach((computed) => {
|
|
42
|
-
const deps = computed.deps.map(sanitizeName).join(', ');
|
|
43
|
-
const expr = generateExpression(computed.compute);
|
|
44
|
-
setupLines.push(`const ${computed.name} = computed(() => {`);
|
|
45
|
-
setupLines.push(` return ${expr};`);
|
|
46
|
-
setupLines.push('});');
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
// Event handlers
|
|
50
|
-
setupLines.push('');
|
|
51
|
-
setupLines.push('// Event handlers');
|
|
52
|
-
root.actions.forEach((action) => {
|
|
53
|
-
setupLines.push(`const ${action.id} = (payload) => {`);
|
|
54
|
-
setupLines.push(` emit('${action.id}', payload);`);
|
|
55
|
-
setupLines.push('};');
|
|
56
|
-
});
|
|
57
|
-
// Expose
|
|
58
|
-
setupLines.push('');
|
|
59
|
-
setupLines.push('return {');
|
|
60
|
-
root.state.variables.forEach((variable) => {
|
|
61
|
-
setupLines.push(` ${sanitizeName(variable.path)},`);
|
|
62
|
-
});
|
|
63
|
-
root.state.computed?.forEach((computed) => {
|
|
64
|
-
setupLines.push(` ${computed.name},`);
|
|
65
|
-
});
|
|
66
|
-
root.actions.forEach((action) => {
|
|
67
|
-
setupLines.push(` ${action.id},`);
|
|
68
|
-
});
|
|
69
|
-
setupLines.push('};');
|
|
70
|
-
// Generate template
|
|
71
|
-
const template = root.components.map((c) => generateTemplate(c)).join('\n');
|
|
72
|
-
return {
|
|
73
|
-
name,
|
|
74
|
-
props,
|
|
75
|
-
setup: setupLines.join('\n'),
|
|
76
|
-
template,
|
|
77
|
-
styles: root.css,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Generate template for component
|
|
82
|
-
*/
|
|
83
|
-
function generateTemplate(component, depth = 0) {
|
|
84
|
-
const indent = ' '.repeat(depth);
|
|
85
|
-
const tag = getComponentTag(component.type);
|
|
86
|
-
// Handle condition
|
|
87
|
-
if (component.condition) {
|
|
88
|
-
const condition = generateExpression(component.condition);
|
|
89
|
-
const inner = generateSingleTemplate(component, depth + 1);
|
|
90
|
-
return `${indent}<template v-if="${condition}">\n${inner}\n${indent}</template>`;
|
|
91
|
-
}
|
|
92
|
-
// Handle repeat
|
|
93
|
-
if (component.repeat) {
|
|
94
|
-
return generateRepeatTemplate(component, depth);
|
|
95
|
-
}
|
|
96
|
-
return generateSingleTemplate(component, depth);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Generate single component template
|
|
100
|
-
*/
|
|
101
|
-
function generateSingleTemplate(component, depth) {
|
|
102
|
-
const indent = ' '.repeat(depth);
|
|
103
|
-
const tag = getComponentTag(component.type);
|
|
104
|
-
const props = generateProps(component);
|
|
105
|
-
const events = generateEvents(component);
|
|
106
|
-
const propString = [...props, ...events].join(' ');
|
|
107
|
-
if (component.children && component.children.length > 0) {
|
|
108
|
-
const children = component.children.map((c) => generateTemplate(c, depth + 1)).join('\n');
|
|
109
|
-
return `${indent}<${tag}${propString ? ' ' + propString : ''}>\n${children}\n${indent}</${tag}>`;
|
|
110
|
-
}
|
|
111
|
-
// Self-closing or with text
|
|
112
|
-
const textContent = component.props?.children ? escapeHtml(String(component.props.children)) : '';
|
|
113
|
-
if (textContent) {
|
|
114
|
-
return `${indent}<${tag}${propString ? ' ' + propString : ''}>${textContent}</${tag}>`;
|
|
115
|
-
}
|
|
116
|
-
return `${indent}<${tag}${propString ? ' ' + propString : ''} />`;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Generate repeat template
|
|
120
|
-
*/
|
|
121
|
-
function generateRepeatTemplate(component, depth) {
|
|
122
|
-
const indent = ' '.repeat(depth);
|
|
123
|
-
const repeat = component.repeat;
|
|
124
|
-
const tag = getComponentTag(component.type);
|
|
125
|
-
const props = generateProps(component);
|
|
126
|
-
const events = generateEvents(component);
|
|
127
|
-
const propString = [...props, ...events].join(' ');
|
|
128
|
-
const itemsVar = sanitizeName(repeat.items);
|
|
129
|
-
const asVar = sanitizeName(repeat.as);
|
|
130
|
-
const indexVar = repeat.indexAs ? sanitizeName(repeat.indexAs) : 'index';
|
|
131
|
-
let eachBlock = `${indent}<${tag}`;
|
|
132
|
-
eachBlock += ` v-for="(${asVar}, ${indexVar}) in ${itemsVar}"`;
|
|
133
|
-
eachBlock += ` :key="${indexVar}"`;
|
|
134
|
-
if (propString) {
|
|
135
|
-
eachBlock += ' ' + propString;
|
|
136
|
-
}
|
|
137
|
-
if (component.children && component.children.length > 0) {
|
|
138
|
-
const children = component.children.map((c) => generateTemplate(c, depth + 1)).join('\n');
|
|
139
|
-
eachBlock += `>\n${children}\n${indent}</${tag}>`;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
eachBlock += ' />';
|
|
143
|
-
}
|
|
144
|
-
return eachBlock;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Generate props string
|
|
148
|
-
*/
|
|
149
|
-
function generateProps(component) {
|
|
150
|
-
const props = [];
|
|
151
|
-
// Regular props
|
|
152
|
-
Object.entries(component.props || {}).forEach(([key, value]) => {
|
|
153
|
-
if (key !== 'children') {
|
|
154
|
-
if (typeof value === 'string') {
|
|
155
|
-
props.push(`${key}="${escapeHtml(value)}"`);
|
|
156
|
-
}
|
|
157
|
-
else if (typeof value === 'boolean') {
|
|
158
|
-
if (value)
|
|
159
|
-
props.push(key);
|
|
160
|
-
}
|
|
161
|
-
else if (typeof value === 'number') {
|
|
162
|
-
props.push(`:${key}="${value}"`);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
props.push(`:${key}="${JSON.stringify(value).replace(/"/g, '"')}"`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
// Bindings
|
|
170
|
-
component.bindings?.forEach((binding) => {
|
|
171
|
-
const stateVar = sanitizeName(binding.statePath);
|
|
172
|
-
if (binding.direction === 'two-way') {
|
|
173
|
-
props.push(`v-model:${binding.prop}="${stateVar}"`);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
props.push(`:${binding.prop}="${stateVar}"`);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
return props;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Generate event handlers
|
|
183
|
-
*/
|
|
184
|
-
function generateEvents(component) {
|
|
185
|
-
const events = [];
|
|
186
|
-
component.events?.forEach((event) => {
|
|
187
|
-
const vueEvent = getVueEventName(event.event);
|
|
188
|
-
events.push(`@${vueEvent}="${event.action}($event)"`);
|
|
189
|
-
});
|
|
190
|
-
return events;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Get component tag
|
|
194
|
-
*/
|
|
195
|
-
function getComponentTag(type) {
|
|
196
|
-
const tagMap = {
|
|
197
|
-
Box: 'div',
|
|
198
|
-
Stack: 'div',
|
|
199
|
-
Text: 'span',
|
|
200
|
-
Heading: 'h1',
|
|
201
|
-
Paragraph: 'p',
|
|
202
|
-
Button: 'button',
|
|
203
|
-
Input: 'input',
|
|
204
|
-
TextArea: 'textarea',
|
|
205
|
-
Select: 'select',
|
|
206
|
-
Card: 'div',
|
|
207
|
-
Image: 'img',
|
|
208
|
-
Icon: 'span',
|
|
209
|
-
Badge: 'span',
|
|
210
|
-
List: 'ul',
|
|
211
|
-
Table: 'table',
|
|
212
|
-
};
|
|
213
|
-
return tagMap[type] || type.toLowerCase();
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get Vue type from schema type
|
|
217
|
-
*/
|
|
218
|
-
function getVueType(type) {
|
|
219
|
-
const typeMap = {
|
|
220
|
-
string: 'String',
|
|
221
|
-
number: 'Number',
|
|
222
|
-
boolean: 'Boolean',
|
|
223
|
-
array: 'Array',
|
|
224
|
-
object: 'Object',
|
|
225
|
-
any: 'null',
|
|
226
|
-
};
|
|
227
|
-
return typeMap[type] || 'null';
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Convert event name to Vue format
|
|
231
|
-
*/
|
|
232
|
-
function getVueEventName(event) {
|
|
233
|
-
if (event.startsWith('on')) {
|
|
234
|
-
return event.slice(2).toLowerCase();
|
|
235
|
-
}
|
|
236
|
-
return event.toLowerCase();
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Generate expression
|
|
240
|
-
*/
|
|
241
|
-
function generateExpression(expr) {
|
|
242
|
-
if (expr === null)
|
|
243
|
-
return 'null';
|
|
244
|
-
if (typeof expr === 'string')
|
|
245
|
-
return sanitizeName(expr);
|
|
246
|
-
if (typeof expr === 'number')
|
|
247
|
-
return String(expr);
|
|
248
|
-
if (typeof expr === 'boolean')
|
|
249
|
-
return String(expr);
|
|
250
|
-
if (typeof expr === 'object') {
|
|
251
|
-
if ('$path' in expr) {
|
|
252
|
-
return sanitizeName(expr.$path);
|
|
253
|
-
}
|
|
254
|
-
if ('$expr' in expr) {
|
|
255
|
-
return expr.$expr;
|
|
256
|
-
}
|
|
257
|
-
if ('$cond' in expr) {
|
|
258
|
-
const [cond, trueVal, falseVal] = expr.$cond;
|
|
259
|
-
return `${generateExpression(cond)} ? ${generateExpression(trueVal)} : ${generateExpression(falseVal)}`;
|
|
260
|
-
}
|
|
261
|
-
if ('$and' in expr) {
|
|
262
|
-
return expr.$and.map(generateExpression).join(' && ');
|
|
263
|
-
}
|
|
264
|
-
if ('$or' in expr) {
|
|
265
|
-
return expr.$or.map(generateExpression).join(' || ');
|
|
266
|
-
}
|
|
267
|
-
if ('$eq' in expr) {
|
|
268
|
-
const [a, b] = expr.$eq;
|
|
269
|
-
return `${generateExpression(a)} === ${generateExpression(b)}`;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return String(expr);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Sanitize variable name
|
|
276
|
-
*/
|
|
277
|
-
function sanitizeName(path) {
|
|
278
|
-
return path.replace(/\./g, '_').replace(/[^a-zA-Z0-9_]/g, '');
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Escape HTML
|
|
282
|
-
*/
|
|
283
|
-
function escapeHtml(text) {
|
|
284
|
-
return text
|
|
285
|
-
.replace(/&/g, '&')
|
|
286
|
-
.replace(/</g, '<')
|
|
287
|
-
.replace(/>/g, '>')
|
|
288
|
-
.replace(/"/g, '"')
|
|
289
|
-
.replace(/'/g, ''');
|
|
290
|
-
}
|
|
291
|
-
return {
|
|
292
|
-
generateComponent,
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Compile A2R-IX UI to Vue component definition
|
|
297
|
-
*/
|
|
298
|
-
export function compileToVue(root, config = {}) {
|
|
299
|
-
const renderer = createVueRenderer(config);
|
|
300
|
-
return renderer.generateComponent(root);
|
|
301
|
-
}
|
|
302
|
-
//# sourceMappingURL=renderer.js.map
|