@vue-jsx-vapor/macros 2.5.1 → 2.5.2
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.
- package/dist/esbuild.d.cts +2 -2
- package/dist/nuxt.d.cts +2 -2
- package/dist/rolldown.d.cts +2 -2
- package/dist/rollup.d.cts +2 -2
- package/dist/vite.d.cts +2 -2
- package/dist/volar.cjs +26 -32
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +27 -34
- package/dist/webpack.d.cts +2 -2
- package/package.json +6 -6
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as esbuild1 from "esbuild";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/nuxt.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _nuxt_schema5 from "@nuxt/schema";
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
5
|
interface ModuleOptions extends Options {}
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: _nuxt_schema5.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { ModuleOptions, _default as default };
|
package/dist/rolldown.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as unplugin8 from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/rolldown.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => unplugin8.RolldownPlugin<any> | unplugin8.RolldownPlugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/rollup.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as rollup3 from "rollup";
|
|
3
3
|
|
|
4
4
|
//#region src/rollup.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => rollup3.Plugin<any> | rollup3.Plugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vite11 from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => vite11.Plugin<any> | vite11.Plugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/volar.cjs
CHANGED
|
@@ -7,24 +7,16 @@ const ts_macro = require_chunk.__toESM(require("ts-macro"));
|
|
|
7
7
|
//#region src/volar/define-component.ts
|
|
8
8
|
function transformDefineComponent(node, parent, options) {
|
|
9
9
|
const { codes, ast, ts } = options;
|
|
10
|
-
|
|
10
|
+
codes.replaceRange(node.arguments[0].end, node.end - 1);
|
|
11
11
|
const componentOptions = node.arguments[1];
|
|
12
|
-
|
|
13
|
-
node.expression.getText(ast),
|
|
14
|
-
node.getStart(ast),
|
|
15
|
-
ts_macro.allCodeFeatures
|
|
16
|
-
], "(() => ({}) as any, ", componentOptions ? [
|
|
17
|
-
componentOptions.getText(ast),
|
|
18
|
-
componentOptions.getStart(ast),
|
|
19
|
-
ts_macro.allCodeFeatures
|
|
20
|
-
] : "", "), ");
|
|
12
|
+
codes.replaceRange(node.getStart(ast), node.expression.end + 1, ts.isExpressionStatement(parent) ? ";" : "", "(", [node.expression.getText(ast), node.getStart(ast)], "(() => ({}) as any,", componentOptions ? [componentOptions.getText(ast), componentOptions.getStart(ast)] : "", "), ");
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
//#endregion
|
|
24
16
|
//#region src/volar/define-style.ts
|
|
25
17
|
function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
26
18
|
const { ts, codes, ast } = options;
|
|
27
|
-
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0]))
|
|
19
|
+
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) codes.replaceRange(expression.arguments.pos - 1, expression.arguments.pos - 1, `<{`, ...parseCssClassNames(expression.arguments[0].getText(ast).slice(1, -1)).flatMap(({ text, offset }) => [
|
|
28
20
|
`\n`,
|
|
29
21
|
[
|
|
30
22
|
`'${text.slice(1)}'`,
|
|
@@ -84,28 +76,28 @@ function transformJsxMacros(rootMap, options) {
|
|
|
84
76
|
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, options));
|
|
85
77
|
if (!root?.body) continue;
|
|
86
78
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
87
|
-
if (asyncModifier && macros.defineComponent)
|
|
79
|
+
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
88
80
|
const result = `({}) as __VLS_PickNotAny<typeof ${__vue_macros_common.HELPER_PREFIX}ctx.render, {}> & { __ctx: typeof ${__vue_macros_common.HELPER_PREFIX}ctx }`;
|
|
89
|
-
const propsType = root.parameters[0]?.type ?
|
|
90
|
-
|
|
91
|
-
if (ts.isArrowFunction(root))
|
|
81
|
+
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
82
|
+
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "", `${__vue_macros_common.HELPER_PREFIX}props: typeof ${__vue_macros_common.HELPER_PREFIX}ctx.props & ${propsType}, `, `${__vue_macros_common.HELPER_PREFIX}placeholder?: {}, `, `${__vue_macros_common.HELPER_PREFIX}ctx = {} as Awaited<ReturnType<typeof ${__vue_macros_common.HELPER_PREFIX}setup>>, `, `${__vue_macros_common.HELPER_PREFIX}setup = (${asyncModifier ? "async" : ""}(`);
|
|
83
|
+
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
92
84
|
else {
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
86
|
+
codes.replaceRange(root.end, root.end, `)){ return `, result, "}");
|
|
95
87
|
}
|
|
96
|
-
|
|
88
|
+
root.body.forEachChild((node) => {
|
|
97
89
|
if (ts.isReturnStatement(node) && node.expression) {
|
|
98
90
|
const props = [...macros.defineModel ?? []];
|
|
99
91
|
const elements = root.parameters[0] && !root.parameters[0].type && ts.isObjectBindingPattern(root.parameters[0].name) ? root.parameters[0].name.elements : [];
|
|
100
92
|
for (const element of elements) if (ts.isIdentifier(element.name)) {
|
|
101
|
-
const isRequired =
|
|
102
|
-
return ts.isNonNullExpression(node$1) || !!
|
|
93
|
+
const isRequired = element.forEachChild(function isNonNullExpression(node$1) {
|
|
94
|
+
return ts.isNonNullExpression(node$1) || !!node$1.forEachChild(isNonNullExpression);
|
|
103
95
|
});
|
|
104
96
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
105
97
|
}
|
|
106
98
|
const shouldWrapByCall = (ts.isArrowFunction(node.expression) || ts.isFunctionExpression(node.expression)) && macros.defineComponent;
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const ${__vue_macros_common.HELPER_PREFIX}render = `, shouldWrapByCall ? "(" : "");
|
|
100
|
+
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
109
101
|
return {
|
|
110
102
|
props: {} as {${props.join(", ")}},
|
|
111
103
|
slots: {} as ${macros.defineSlots ?? "{}"},
|
|
@@ -140,7 +132,7 @@ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B
|
|
|
140
132
|
//#region src/volar/index.ts
|
|
141
133
|
function getMacro(node, ts, options) {
|
|
142
134
|
if (!node) return;
|
|
143
|
-
if (ts.isVariableStatement(node)) return
|
|
135
|
+
if (ts.isVariableStatement(node)) return node.declarationList.forEachChild((decl) => getExpression(decl));
|
|
144
136
|
else return getExpression(node);
|
|
145
137
|
function getExpression(decl) {
|
|
146
138
|
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
@@ -208,30 +200,30 @@ function getRootMap(options) {
|
|
|
208
200
|
hasRequired = true;
|
|
209
201
|
isRequired = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;
|
|
210
202
|
}
|
|
211
|
-
if (!hasRequired && isRequired)
|
|
212
|
-
} else if (isRequired)
|
|
203
|
+
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
204
|
+
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
213
205
|
const id = toValidAssetId(modelName, `${__vue_macros_common.HELPER_PREFIX}model`);
|
|
214
206
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
215
207
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
216
208
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
217
|
-
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${expression.typeArguments[1]
|
|
218
|
-
if (ts.isVariableStatement(node))
|
|
209
|
+
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${(0, ts_macro.getText)(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
210
|
+
if (ts.isVariableStatement(node)) codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
219
211
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
220
|
-
|
|
212
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${__vue_macros_common.HELPER_PREFIX}slots;\nconst ${__vue_macros_common.HELPER_PREFIX}slots = `);
|
|
221
213
|
rootMap.get(root).defineSlots = `Partial<typeof ${__vue_macros_common.HELPER_PREFIX}slots>`;
|
|
222
214
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
223
|
-
|
|
215
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${__vue_macros_common.HELPER_PREFIX}exposed;\nconst ${__vue_macros_common.HELPER_PREFIX}exposed = `);
|
|
224
216
|
rootMap.get(root).defineExpose = `typeof ${__vue_macros_common.HELPER_PREFIX}exposed`;
|
|
225
217
|
}
|
|
226
218
|
}
|
|
227
219
|
}
|
|
228
|
-
|
|
220
|
+
node.forEachChild((child) => {
|
|
229
221
|
parents.unshift(node);
|
|
230
222
|
walk(child, parents);
|
|
231
223
|
parents.shift();
|
|
232
224
|
});
|
|
233
225
|
}
|
|
234
|
-
|
|
226
|
+
ast.forEachChild((node) => walk(node, []));
|
|
235
227
|
return rootMap;
|
|
236
228
|
}
|
|
237
229
|
function toValidAssetId(name, type) {
|
|
@@ -244,6 +236,7 @@ function toValidAssetId(name, type) {
|
|
|
244
236
|
//#region src/volar.ts
|
|
245
237
|
const plugin = (0, ts_macro.createPlugin)(({ ts }, userOptions = {}) => {
|
|
246
238
|
const resolvedOptions = require_options.resolveOptions(userOptions);
|
|
239
|
+
resolvedOptions.include.push(__vue_macros_common.REGEX_VUE_SFC);
|
|
247
240
|
const filter = (0, __vue_macros_common.createFilter)(resolvedOptions);
|
|
248
241
|
return {
|
|
249
242
|
name: "@vue-jsx-vapor/macros",
|
|
@@ -266,4 +259,5 @@ const plugin = (0, ts_macro.createPlugin)(({ ts }, userOptions = {}) => {
|
|
|
266
259
|
var volar_default = plugin;
|
|
267
260
|
|
|
268
261
|
//#endregion
|
|
269
|
-
exports.default = volar_default;
|
|
262
|
+
exports.default = volar_default;
|
|
263
|
+
exports["module.exports"] = plugin;
|
package/dist/volar.d.cts
CHANGED
package/dist/volar.d.ts
CHANGED
package/dist/volar.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
2
|
-
import { HELPER_PREFIX, createFilter } from "@vue-macros/common";
|
|
3
|
-
import { allCodeFeatures, createPlugin,
|
|
2
|
+
import { HELPER_PREFIX, REGEX_VUE_SFC, createFilter } from "@vue-macros/common";
|
|
3
|
+
import { allCodeFeatures, createPlugin, getText } from "ts-macro";
|
|
4
4
|
|
|
5
5
|
//#region src/volar/define-component.ts
|
|
6
6
|
function transformDefineComponent(node, parent, options) {
|
|
7
7
|
const { codes, ast, ts } = options;
|
|
8
|
-
replaceRange(
|
|
8
|
+
codes.replaceRange(node.arguments[0].end, node.end - 1);
|
|
9
9
|
const componentOptions = node.arguments[1];
|
|
10
|
-
replaceRange(
|
|
11
|
-
node.expression.getText(ast),
|
|
12
|
-
node.getStart(ast),
|
|
13
|
-
allCodeFeatures
|
|
14
|
-
], "(() => ({}) as any, ", componentOptions ? [
|
|
15
|
-
componentOptions.getText(ast),
|
|
16
|
-
componentOptions.getStart(ast),
|
|
17
|
-
allCodeFeatures
|
|
18
|
-
] : "", "), ");
|
|
10
|
+
codes.replaceRange(node.getStart(ast), node.expression.end + 1, ts.isExpressionStatement(parent) ? ";" : "", "(", [node.expression.getText(ast), node.getStart(ast)], "(() => ({}) as any,", componentOptions ? [componentOptions.getText(ast), componentOptions.getStart(ast)] : "", "), ");
|
|
19
11
|
}
|
|
20
12
|
|
|
21
13
|
//#endregion
|
|
22
14
|
//#region src/volar/define-style.ts
|
|
23
15
|
function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
24
16
|
const { ts, codes, ast } = options;
|
|
25
|
-
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) replaceRange(
|
|
17
|
+
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) codes.replaceRange(expression.arguments.pos - 1, expression.arguments.pos - 1, `<{`, ...parseCssClassNames(expression.arguments[0].getText(ast).slice(1, -1)).flatMap(({ text, offset }) => [
|
|
26
18
|
`\n`,
|
|
27
19
|
[
|
|
28
20
|
`'${text.slice(1)}'`,
|
|
@@ -82,28 +74,28 @@ function transformJsxMacros(rootMap, options) {
|
|
|
82
74
|
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, options));
|
|
83
75
|
if (!root?.body) continue;
|
|
84
76
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
85
|
-
if (asyncModifier && macros.defineComponent) replaceRange(
|
|
77
|
+
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
86
78
|
const result = `({}) as __VLS_PickNotAny<typeof ${HELPER_PREFIX}ctx.render, {}> & { __ctx: typeof ${HELPER_PREFIX}ctx }`;
|
|
87
|
-
const propsType = root.parameters[0]?.type ?
|
|
88
|
-
replaceRange(
|
|
89
|
-
if (ts.isArrowFunction(root)) replaceRange(
|
|
79
|
+
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
80
|
+
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "", `${HELPER_PREFIX}props: typeof ${HELPER_PREFIX}ctx.props & ${propsType}, `, `${HELPER_PREFIX}placeholder?: {}, `, `${HELPER_PREFIX}ctx = {} as Awaited<ReturnType<typeof ${HELPER_PREFIX}setup>>, `, `${HELPER_PREFIX}setup = (${asyncModifier ? "async" : ""}(`);
|
|
81
|
+
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
90
82
|
else {
|
|
91
|
-
replaceRange(
|
|
92
|
-
replaceRange(
|
|
83
|
+
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
84
|
+
codes.replaceRange(root.end, root.end, `)){ return `, result, "}");
|
|
93
85
|
}
|
|
94
|
-
|
|
86
|
+
root.body.forEachChild((node) => {
|
|
95
87
|
if (ts.isReturnStatement(node) && node.expression) {
|
|
96
88
|
const props = [...macros.defineModel ?? []];
|
|
97
89
|
const elements = root.parameters[0] && !root.parameters[0].type && ts.isObjectBindingPattern(root.parameters[0].name) ? root.parameters[0].name.elements : [];
|
|
98
90
|
for (const element of elements) if (ts.isIdentifier(element.name)) {
|
|
99
|
-
const isRequired =
|
|
100
|
-
return ts.isNonNullExpression(node$1) || !!
|
|
91
|
+
const isRequired = element.forEachChild(function isNonNullExpression(node$1) {
|
|
92
|
+
return ts.isNonNullExpression(node$1) || !!node$1.forEachChild(isNonNullExpression);
|
|
101
93
|
});
|
|
102
94
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
103
95
|
}
|
|
104
96
|
const shouldWrapByCall = (ts.isArrowFunction(node.expression) || ts.isFunctionExpression(node.expression)) && macros.defineComponent;
|
|
105
|
-
replaceRange(
|
|
106
|
-
replaceRange(
|
|
97
|
+
codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const ${HELPER_PREFIX}render = `, shouldWrapByCall ? "(" : "");
|
|
98
|
+
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
107
99
|
return {
|
|
108
100
|
props: {} as {${props.join(", ")}},
|
|
109
101
|
slots: {} as ${macros.defineSlots ?? "{}"},
|
|
@@ -138,7 +130,7 @@ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B
|
|
|
138
130
|
//#region src/volar/index.ts
|
|
139
131
|
function getMacro(node, ts, options) {
|
|
140
132
|
if (!node) return;
|
|
141
|
-
if (ts.isVariableStatement(node)) return
|
|
133
|
+
if (ts.isVariableStatement(node)) return node.declarationList.forEachChild((decl) => getExpression(decl));
|
|
142
134
|
else return getExpression(node);
|
|
143
135
|
function getExpression(decl) {
|
|
144
136
|
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
@@ -206,30 +198,30 @@ function getRootMap(options) {
|
|
|
206
198
|
hasRequired = true;
|
|
207
199
|
isRequired = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;
|
|
208
200
|
}
|
|
209
|
-
if (!hasRequired && isRequired) replaceRange(
|
|
210
|
-
} else if (isRequired) replaceRange(
|
|
201
|
+
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
202
|
+
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
211
203
|
const id = toValidAssetId(modelName, `${HELPER_PREFIX}model`);
|
|
212
204
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
213
205
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
214
206
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
215
|
-
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${expression.typeArguments[1]
|
|
216
|
-
if (ts.isVariableStatement(node)) replaceRange(
|
|
207
|
+
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${getText(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
208
|
+
if (ts.isVariableStatement(node)) codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
217
209
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
218
|
-
replaceRange(
|
|
210
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${HELPER_PREFIX}slots;\nconst ${HELPER_PREFIX}slots = `);
|
|
219
211
|
rootMap.get(root).defineSlots = `Partial<typeof ${HELPER_PREFIX}slots>`;
|
|
220
212
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
221
|
-
replaceRange(
|
|
213
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${HELPER_PREFIX}exposed;\nconst ${HELPER_PREFIX}exposed = `);
|
|
222
214
|
rootMap.get(root).defineExpose = `typeof ${HELPER_PREFIX}exposed`;
|
|
223
215
|
}
|
|
224
216
|
}
|
|
225
217
|
}
|
|
226
|
-
|
|
218
|
+
node.forEachChild((child) => {
|
|
227
219
|
parents.unshift(node);
|
|
228
220
|
walk(child, parents);
|
|
229
221
|
parents.shift();
|
|
230
222
|
});
|
|
231
223
|
}
|
|
232
|
-
|
|
224
|
+
ast.forEachChild((node) => walk(node, []));
|
|
233
225
|
return rootMap;
|
|
234
226
|
}
|
|
235
227
|
function toValidAssetId(name, type) {
|
|
@@ -242,6 +234,7 @@ function toValidAssetId(name, type) {
|
|
|
242
234
|
//#region src/volar.ts
|
|
243
235
|
const plugin = createPlugin(({ ts }, userOptions = {}) => {
|
|
244
236
|
const resolvedOptions = resolveOptions(userOptions);
|
|
237
|
+
resolvedOptions.include.push(REGEX_VUE_SFC);
|
|
245
238
|
const filter = createFilter(resolvedOptions);
|
|
246
239
|
return {
|
|
247
240
|
name: "@vue-jsx-vapor/macros",
|
|
@@ -264,4 +257,4 @@ const plugin = createPlugin(({ ts }, userOptions = {}) => {
|
|
|
264
257
|
var volar_default = plugin;
|
|
265
258
|
|
|
266
259
|
//#endregion
|
|
267
|
-
export { volar_default as default };
|
|
260
|
+
export { volar_default as default, plugin as "module.exports" };
|
package/dist/webpack.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as webpack14 from "webpack";
|
|
3
3
|
|
|
4
4
|
//#region src/webpack.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => webpack14.WebpackPluginInstance;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-jsx-vapor/macros",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Macros for Vue JSX Vapor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -131,10 +131,10 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@vue-macros/common": "^3.0.0-beta.
|
|
135
|
-
"@vue/compiler-sfc": "https://pkg.pr.new/@vue/compiler-sfc@
|
|
134
|
+
"@vue-macros/common": "^3.0.0-beta.17",
|
|
135
|
+
"@vue/compiler-sfc": "https://pkg.pr.new/@vue/compiler-sfc@5771104",
|
|
136
136
|
"hash-sum": "^2.0.0",
|
|
137
|
-
"ts-macro": "^0.
|
|
137
|
+
"ts-macro": "^0.2.7",
|
|
138
138
|
"unplugin": "^2.3.5"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"@nuxt/kit": "^3.17.6",
|
|
143
143
|
"@nuxt/schema": "^3.17.6",
|
|
144
144
|
"@types/hash-sum": "^1.0.2",
|
|
145
|
-
"@vue-macros/test-utils": "^3.0.0-beta.
|
|
146
|
-
"vue": "https://pkg.pr.new/vue@
|
|
145
|
+
"@vue-macros/test-utils": "^3.0.0-beta.17",
|
|
146
|
+
"vue": "https://pkg.pr.new/vue@5771104"
|
|
147
147
|
},
|
|
148
148
|
"scripts": {
|
|
149
149
|
"build": "tsdown",
|