@sprlab/wccompiler 0.10.4 → 0.10.5

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.
@@ -65,11 +65,15 @@ export function wccVuePlugin(options = {}) {
65
65
 
66
66
  let result = code
67
67
 
68
- // NOTE: As of WCC 0.10.3+, v-model:propName works WITHOUT this plugin
69
- // because the compiled component emits 'update:propName' natively (Vue 3.4+ CE support).
70
- // This transform is still useful for:
71
- // 1. v-model modifiers (.trim, .number)Vue doesn't apply modifiers to CE v-model natively
72
- // 2. Older Vue versions (< 3.4) that don't support v-model on CE via update:propName
68
+ // NOTE: As of WCC 0.10.3+, basic events work WITHOUT this plugin because
69
+ // the compiled component emits events in multiple formats (kebab, camelCase, lowercase).
70
+ // However, v-model:propName STILL REQUIRES this plugin because Vue assigns the raw
71
+ // Event object to the ref it doesn't extract .detail automatically.
72
+ // This transform rewrites v-model:prop to @prop-changed="ref = $event.detail".
73
+ //
74
+ // This plugin is needed for:
75
+ // 1. v-model:propName (Vue can't unwrap CustomEvent.detail natively)
76
+ // 2. v-model modifiers (.trim, .number)
73
77
  // 3. Scoped slot syntax transformation ({{prop}} → {%prop%})
74
78
 
75
79
  // Transform v-model:propName="expr" on custom elements (tags with hyphens)
package/lib/codegen.js CHANGED
@@ -1799,11 +1799,14 @@ export function generateComponent(parseResult, options = {}) {
1799
1799
  // _modelSet methods (one per defineModel prop — emits events on internal write)
1800
1800
  // Emits:
1801
1801
  // 1. wcc:model — generic event for vanilla JS and WCC-to-WCC binding
1802
- // 2. propName-changed — kebab-case for direct addEventListener
1802
+ // 2. propName-changed — kebab-case for direct addEventListener and Vue plugin
1803
1803
  // 3. propNameChanged — camelCase for Angular WccEvents / direct binding
1804
1804
  // 4. propnamechanged — lowercase for React 19 (onPropnameChanged → 'propnamechanged')
1805
1805
  // 5. propNameChange — for Angular [(prop)] banana-box syntax
1806
- // 6. update:propName — for Vue v-model:propName on custom elements (Vue 3.4+)
1806
+ //
1807
+ // NOTE: Vue v-model:prop requires the wccVuePlugin because Vue assigns the raw
1808
+ // Event object to the ref (not event.detail). The plugin transforms v-model:prop
1809
+ // to @prop-changed="ref = $event.detail" which correctly extracts the value.
1807
1810
  for (const md of modelDefs) {
1808
1811
  const kebabName = camelToKebab(md.name);
1809
1812
  const camelChanged = `${md.name}Changed`;
@@ -1815,16 +1818,14 @@ export function generateComponent(parseResult, options = {}) {
1815
1818
  lines.push(` bubbles: true,`);
1816
1819
  lines.push(` composed: true`);
1817
1820
  lines.push(` }));`);
1818
- // Kebab-case: prop-name-changed
1821
+ // Kebab-case: prop-name-changed (Vue plugin, addEventListener)
1819
1822
  lines.push(` this.dispatchEvent(new CustomEvent('${kebabName}-changed', { detail: newVal, bubbles: true }));`);
1820
- // camelCase: propNameChanged
1823
+ // camelCase: propNameChanged (Angular, addEventListener)
1821
1824
  lines.push(` this.dispatchEvent(new CustomEvent('${camelChanged}', { detail: newVal, bubbles: true }));`);
1822
1825
  // lowercase: propnamechanged (React 19)
1823
1826
  lines.push(` this.dispatchEvent(new CustomEvent('${camelChanged.toLowerCase()}', { detail: newVal, bubbles: true }));`);
1824
1827
  // Angular banana-box: propNameChange
1825
1828
  lines.push(` this.dispatchEvent(new CustomEvent('${md.name}Change', { detail: newVal, bubbles: true }));`);
1826
- // Vue v-model: update:propName
1827
- lines.push(` this.dispatchEvent(new CustomEvent('update:${md.name}', { detail: newVal, bubbles: true }));`);
1828
1829
  lines.push(' }');
1829
1830
  lines.push('');
1830
1831
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprlab/wccompiler",
3
- "version": "0.10.4",
3
+ "version": "0.10.5",
4
4
  "description": "Zero-runtime compiler that transforms .wcc single-file components into native web components with signals-based reactivity",
5
5
  "type": "module",
6
6
  "exports": {