@vue-macros/volar
Advanced tools
Comparing version 0.24.0 to 0.24.1
@@ -19,16 +19,53 @@ // src/template-ref.ts | ||
}) { | ||
for (const node of nodes) { | ||
if (ts.isStringLiteralLike(node.arguments[0])) { | ||
(0, import_muggle_string2.replaceSourceRange)( | ||
codes, | ||
"scriptSetup", | ||
node.expression.end, | ||
node.expression.end, | ||
`<Parameters<typeof __VLS_ctx_${node.arguments[0].text}.expose>[0] | null>` | ||
); | ||
const refs = []; | ||
for (const decl of nodes) { | ||
if (decl.initializer && ts.isCallExpression(decl.initializer)) { | ||
const { | ||
expression, | ||
arguments: [argument] | ||
} = decl.initializer; | ||
if (ts.isStringLiteralLike(argument)) { | ||
(0, import_muggle_string2.replaceSourceRange)( | ||
codes, | ||
"scriptSetup", | ||
expression.end, | ||
expression.end, | ||
`<Parameters<Required<typeof __VLS_ctx_${argument.text}>['expose']>[0] | null>` | ||
); | ||
if (ts.isIdentifier(decl.name)) { | ||
const name = decl.name.escapedText; | ||
refs.push(`${name}: ${name}.value`); | ||
(0, import_muggle_string2.replace)(codes, new RegExp(`${name}: ${name} as typeof ${name},`)); | ||
(0, import_muggle_string2.replaceAll)( | ||
codes, | ||
new RegExp(`__VLS_ctx(?=\\.${name})`, "g"), | ||
`__VLS_refs` | ||
); | ||
} | ||
} | ||
} | ||
} | ||
for (const [, tagName, props, ref] of (0, import_muggle_string2.toString)(codes).matchAll( | ||
addCode(codes, `const __VLS_refs = { | ||
${refs.join(",\n")} | ||
}`); | ||
(0, import_muggle_string2.replace)(codes, /function __VLS_template\(\) {/); | ||
(0, import_muggle_string2.replace)(codes, /(?<=__VLS_defineComponent\([\S\s]*?\);)\n}/); | ||
(0, import_muggle_string2.replace)( | ||
codes, | ||
/return __VLS_slots;\n/, | ||
"function __VLS_template(){\nreturn __VLS_slots;\n}" | ||
); | ||
const codeString = (0, import_muggle_string2.toString)(codes); | ||
for (const [, tagName, props, ref] of codeString.matchAll( | ||
/__VLS_asFunctionalComponent\((.*), new \1\({(.*ref: \("(.*)"\).*)}\)\)/g | ||
)) { | ||
if (tagName.startsWith("__VLS_")) { | ||
const result = codeString.match( | ||
new RegExp(`(const ${tagName}) = [\\s\\S]*?; | ||
`) | ||
); | ||
if (result) { | ||
addCode(codes, "// @ts-ignore\n", result[0]); | ||
} | ||
} | ||
addCode( | ||
@@ -51,4 +88,4 @@ codes, | ||
if (ts.isVariableDeclaration(decl) && decl.initializer && ts.isCallExpression(decl.initializer) && ts.isIdentifier(decl.initializer.expression)) { | ||
const node2 = decl.initializer.expression.escapedText === "$" ? decl.initializer.arguments[0] : decl.initializer; | ||
if (isTemplateRefCall(node2)) result.push(node2); | ||
const expression = decl.initializer.expression.escapedText === "$" ? decl.initializer.arguments[0] : decl.initializer; | ||
if (isTemplateRefCall(expression)) result.push(decl); | ||
} | ||
@@ -55,0 +92,0 @@ }); |
{ | ||
"name": "@vue-macros/volar", | ||
"version": "0.24.0", | ||
"version": "0.24.1", | ||
"description": "Volar plugin for Vue Macros.", | ||
@@ -52,5 +52,5 @@ "type": "commonjs", | ||
"muggle-string": "^0.4.1", | ||
"@vue-macros/boolean-prop": "0.4.1", | ||
"@vue-macros/common": "1.11.0", | ||
"@vue-macros/define-props": "2.0.7", | ||
"@vue-macros/boolean-prop": "0.4.1", | ||
"@vue-macros/define-props": "2.0.8", | ||
"@vue-macros/short-bind": "0.2.6", | ||
@@ -57,0 +57,0 @@ "@vue-macros/short-vmodel": "1.4.6" |
64364
1787
+ Added@vue-macros/define-props@2.0.8(transitive)
- Removed@vue-macros/define-props@2.0.7(transitive)