@vue-macros/volar
Advanced tools
Comparing version
@@ -11,5 +11,5 @@ // src/define-models.ts | ||
function addProps(content, decl, vueLibName) { | ||
(0, import_language_core.replace)( | ||
(0, import_language_core.replaceAll)( | ||
content, | ||
/setup\(\) {/, | ||
/setup\(\) {/g, | ||
"props: ({} as ", | ||
@@ -29,8 +29,5 @@ ...decl, | ||
function addEmits(content, decl) { | ||
const idx = content.indexOf("setup() {\n"); | ||
if (idx === -1) | ||
return false; | ||
(0, import_language_core.replace)( | ||
(0, import_language_core.replaceAll)( | ||
content, | ||
/setup\(\) {/, | ||
/setup\(\) {/g, | ||
"emits: ({} as ", | ||
@@ -77,15 +74,23 @@ ...decl, | ||
function mergeProps() { | ||
const idx = codes.indexOf("__VLS_TypePropsToRuntimeProps<"); | ||
if (idx === -1) | ||
const indexes = codes.reduce((res, code, index) => { | ||
if (code === "__VLS_TypePropsToRuntimeProps<") | ||
res.unshift(index); | ||
return res; | ||
}, []); | ||
if (indexes.length === 0) | ||
return false; | ||
codes.splice(idx + 2, 0, " & __VLS_ModelToProps<", seg, ">"); | ||
for (const idx of indexes) | ||
codes.splice(idx + 2, 0, " & __VLS_ModelToProps<", seg, ">"); | ||
return true; | ||
} | ||
function mergeEmits() { | ||
const idx = codes.indexOf( | ||
"emits: ({} as __VLS_UnionToIntersection<__VLS_ConstructorOverloads<" | ||
); | ||
if (idx === -1) | ||
const indexes = codes.reduce((res, code, index) => { | ||
if (code === "emits: ({} as __VLS_NormalizeEmits<typeof ") | ||
res.unshift(index); | ||
return res; | ||
}, []); | ||
if (indexes.length === 0) | ||
return false; | ||
codes.splice(idx + 2, 1, ">> & __VLS_ModelToEmits<", seg, ">),\n"); | ||
for (const idx of indexes) | ||
codes.splice(idx + 2, 1, " & __VLS_ModelToEmits<", seg, ">>),\n"); | ||
return true; | ||
@@ -92,0 +97,0 @@ } |
@@ -55,5 +55,5 @@ // src/export-expose.ts | ||
]); | ||
(0, import_language_core3.replace)( | ||
(0, import_language_core3.replaceAll)( | ||
file.content, | ||
"return {\n", | ||
/return {\n/g, | ||
"return {\n...{ ", | ||
@@ -60,0 +60,0 @@ ...exposedStrings, |
@@ -12,5 +12,5 @@ // src/export-props.ts | ||
function addProps(content, decl, vueLibName) { | ||
(0, import_language_core.replace)( | ||
(0, import_language_core.replaceAll)( | ||
content, | ||
/setup\(\) {/, | ||
/setup\(\) {/g, | ||
"props: ({} as ", | ||
@@ -17,0 +17,0 @@ ...decl, |
{ | ||
"name": "@vue-macros/volar", | ||
"version": "0.16.0", | ||
"packageManager": "pnpm@8.7.6", | ||
"version": "0.16.1", | ||
"packageManager": "pnpm@8.8.0", | ||
"description": "Volar plugin for Vue Macros.", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@rollup/pluginutils": "^5.0.4", | ||
"@rollup/pluginutils": "^5.0.5", | ||
"@volar/language-core": "1.10.1", | ||
@@ -50,0 +50,0 @@ "@vue/language-core": "1.8.14", |
31040
0.61%917
0.55%Updated