@vue-macros/volar
Advanced tools
Comparing version 0.6.0 to 0.6.1
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } | ||
var _chunkPXLCEAZ5js = require('./chunk-PXLCEAZ5.js'); | ||
@@ -22,3 +23,7 @@ | ||
]; | ||
mergeProps() || addProps(); | ||
mergeProps() || _chunkPXLCEAZ5js.addProps.call(void 0, | ||
codes, | ||
["__VLS_TypePropsToRuntimeProps<__VLS_ModelToProps<", seg, ">>"], | ||
vueLibName | ||
); | ||
mergeEmits() || addEmits(); | ||
@@ -40,20 +45,2 @@ codes.push( | ||
} | ||
function addProps() { | ||
const idx = codes.indexOf("setup() {\n"); | ||
if (idx === -1) | ||
return false; | ||
const segs = [ | ||
"props: ({} as __VLS_TypePropsToRuntimeProps<__VLS_ModelToProps<", | ||
seg, | ||
">>),\n" | ||
]; | ||
codes.splice(idx, 0, ...segs); | ||
codes.push( | ||
`type __VLS_NonUndefinedable<T> = T extends undefined ? never : T; | ||
`, | ||
`type __VLS_TypePropsToRuntimeProps<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? { type: import('${vueLibName}').PropType<__VLS_NonUndefinedable<T[K]>> } : { type: import('${vueLibName}').PropType<T[K]>, required: true } }; | ||
` | ||
); | ||
return true; | ||
} | ||
function mergeEmits() { | ||
@@ -60,0 +47,0 @@ const idx = codes.indexOf( |
@@ -17,5 +17,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
const props = {}; | ||
const sources = []; | ||
let source = file.content[idx + 1][0]; | ||
let cursor = 0; | ||
let changed = false; | ||
for (const stmt of sfc.scriptSetupAst.statements) { | ||
@@ -30,8 +29,6 @@ if (!ts.isVariableStatement(stmt)) | ||
const start = exportModifier.getFullStart(); | ||
const width = exportModifier.getFullWidth(); | ||
const end = exportModifier.getEnd(); | ||
if (cursor > 0) { | ||
sources.push([cursor, source.slice(0, start - cursor)]); | ||
} | ||
source = source.slice(end - cursor); | ||
cursor = end; | ||
changed = true; | ||
source = `${source.slice(0, start)}${" ".repeat(width)}${source.slice(end)}`; | ||
for (const decl of stmt.declarationList.declarations) { | ||
@@ -43,11 +40,5 @@ if (!ts.isIdentifier(decl.name)) | ||
} | ||
if (sources.length > 0) { | ||
sources.push([cursor, source]); | ||
file.content.splice( | ||
idx + 1, | ||
1, | ||
...sources.map(([offset, content]) => { | ||
return [content, "scriptSetup", offset, _languagecore.FileRangeCapabilities.full]; | ||
}) | ||
); | ||
if (changed) { | ||
; | ||
file.content[idx + 1][0] = source; | ||
} | ||
@@ -54,0 +45,0 @@ _chunkPXLCEAZ5js.addProps.call(void 0, |
{ | ||
"name": "@vue-macros/volar", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"packageManager": "pnpm@7.25.1", | ||
@@ -5,0 +5,0 @@ "description": "Volar plugin for Vue Macros.", |
13287
313