nexa-compiler 0.7.5 → 0.7.7

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.
@@ -181,7 +181,7 @@ export function generateComponentCode(sfc, filename) {
181
181
  const componentBindings = renderBindings.map(b => /^[A-Z]/.test(b) ? `${b}: _ntc_${b}` : b);
182
182
  const allRenderBindings = [...componentBindings, ...usedBuiltIns.map(b => `${b}: _ntc_${b}`)];
183
183
  if (allRenderBindings.length > 0) {
184
- lines.push(` const { ${allRenderBindings.join(', ')} } = ctx`);
184
+ lines.push(` let { ${allRenderBindings.join(', ')} } = ctx`);
185
185
  }
186
186
  lines.push(generateRenderCode(sfc.template, scopeId || undefined));
187
187
  lines.push('}');
@@ -12,7 +12,7 @@ function transformNode(node, scopeId) {
12
12
  const slotProps = dynamicAttrs.length > 0
13
13
  ? dynamicAttrs.map(a => `${a.name}: ${a.value}`).join(', ')
14
14
  : undefined;
15
- return { type: 'slot', name: node.attrs.find(a => a.name === 'name')?.value || 'default', slotProps, children: node.children?.map(c => transformNode(c)) };
15
+ return { type: 'slot', name: node.attrs.find(a => a.name === 'name')?.value || 'default', slotProps, children: node.children?.map(c => transformNode(c, scopeId)) };
16
16
  }
17
17
  const vForAttr = node.attrs.find(a => a.name === 'v-for');
18
18
  const vIfAttr = node.attrs.find(a => a.name === 'v-if');
@@ -43,7 +43,7 @@ function transformNode(node, scopeId) {
43
43
  const slotProps = dynamicAttrs.length > 0
44
44
  ? dynamicAttrs.map(a => `${a.name}: ${a.value}`).join(', ')
45
45
  : undefined;
46
- return { type: 'slot', name: node.name, slotProps, children: node.children?.map(c => transformNode(c)) };
46
+ return { type: 'slot', name: node.name, slotProps, children: node.children?.map(c => transformNode(c, scopeId)) };
47
47
  }
48
48
  case 'if': {
49
49
  const then = transformChildren(node.then, scopeId);
@@ -156,9 +156,29 @@ function genProps(attrs, tag) {
156
156
  const parts_name = propName.split('.');
157
157
  const realName = parts_name[0];
158
158
  const modifiers = parts_name.slice(1);
159
- let handler = typeof attr.value === 'string' && /^\w+$/.test(attr.value)
160
- ? attr.value
161
- : `($event) => { ${attr.value} }`;
159
+ let handler;
160
+ if (typeof attr.value === 'string' && /^\w+$/.test(attr.value)) {
161
+ handler = attr.value;
162
+ }
163
+ else if (typeof attr.value === 'string') {
164
+ const eqIdx = attr.value.indexOf('=');
165
+ if (eqIdx > 0) {
166
+ const lhs = attr.value.slice(0, eqIdx).trim();
167
+ const rhs = attr.value.slice(eqIdx + 1).trim();
168
+ if (/^[a-zA-Z_$]\w*$/.test(lhs)) {
169
+ handler = `($event) => { ${lhs}.value = ${rhs} }`;
170
+ }
171
+ else {
172
+ handler = `($event) => { ${attr.value} }`;
173
+ }
174
+ }
175
+ else {
176
+ handler = `($event) => { ${attr.value} }`;
177
+ }
178
+ }
179
+ else {
180
+ handler = `($event) => { ${attr.value} }`;
181
+ }
162
182
  const keyMap = {
163
183
  enter: 'Enter', esc: 'Escape', tab: 'Tab',
164
184
  space: ' ', up: 'ArrowUp', down: 'ArrowDown',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexa-compiler",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",