@vue-jsx-vapor/macros 1.7.0
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/LICENSE +21 -0
- package/dist/api.cjs +14 -0
- package/dist/api.d.cts +40 -0
- package/dist/api.d.ts +40 -0
- package/dist/api.js +14 -0
- package/dist/astro.cjs +22 -0
- package/dist/astro.d.cts +11 -0
- package/dist/astro.d.ts +11 -0
- package/dist/astro.js +20 -0
- package/dist/chunk-6JTF6MNY.cjs +567 -0
- package/dist/chunk-7SOTCEEO.js +10 -0
- package/dist/chunk-IXJAH75Q.js +12 -0
- package/dist/chunk-KDEA57GU.js +567 -0
- package/dist/chunk-LYT252SL.cjs +65 -0
- package/dist/chunk-PCD5JI3K.js +10 -0
- package/dist/chunk-UCG5RA54.js +65 -0
- package/dist/chunk-UZ426MO6.cjs +32 -0
- package/dist/chunk-XA5RNEAB.cjs +10 -0
- package/dist/chunk-Y4BCVHJT.cjs +12 -0
- package/dist/chunk-ZWDLDNLL.cjs +10 -0
- package/dist/chunk-ZXRSELD6.js +32 -0
- package/dist/esbuild.cjs +14 -0
- package/dist/esbuild.d.cts +7 -0
- package/dist/esbuild.d.ts +7 -0
- package/dist/esbuild.js +12 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/nuxt.cjs +29 -0
- package/dist/nuxt.d.cts +9 -0
- package/dist/nuxt.d.ts +9 -0
- package/dist/nuxt.js +27 -0
- package/dist/options.cjs +6 -0
- package/dist/options.d.cts +24 -0
- package/dist/options.d.ts +24 -0
- package/dist/options.js +6 -0
- package/dist/raw.cjs +10 -0
- package/dist/raw.d.cts +7 -0
- package/dist/raw.d.ts +7 -0
- package/dist/raw.js +8 -0
- package/dist/rolldown.cjs +14 -0
- package/dist/rolldown.d.cts +6 -0
- package/dist/rolldown.d.ts +6 -0
- package/dist/rolldown.js +12 -0
- package/dist/rollup.cjs +14 -0
- package/dist/rollup.d.cts +7 -0
- package/dist/rollup.d.ts +7 -0
- package/dist/rollup.js +12 -0
- package/dist/rspack.cjs +14 -0
- package/dist/rspack.d.cts +6 -0
- package/dist/rspack.d.ts +6 -0
- package/dist/rspack.js +12 -0
- package/dist/vite.cjs +12 -0
- package/dist/vite.d.cts +7 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +10 -0
- package/dist/volar.cjs +394 -0
- package/dist/volar.d.cts +7 -0
- package/dist/volar.d.ts +7 -0
- package/dist/volar.js +392 -0
- package/dist/webpack.cjs +12 -0
- package/dist/webpack.d.cts +7 -0
- package/dist/webpack.d.ts +7 -0
- package/dist/webpack.js +10 -0
- package/package.json +191 -0
package/dist/volar.js
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveOptions
|
|
3
|
+
} from "./chunk-ZXRSELD6.js";
|
|
4
|
+
|
|
5
|
+
// src/volar.ts
|
|
6
|
+
import { createFilter } from "@vue-macros/common";
|
|
7
|
+
import { createPlugin } from "ts-macro";
|
|
8
|
+
|
|
9
|
+
// src/volar/index.ts
|
|
10
|
+
import {
|
|
11
|
+
HELPER_PREFIX as HELPER_PREFIX4
|
|
12
|
+
} from "@vue-macros/common";
|
|
13
|
+
import { toValidAssetId } from "@vue/compiler-dom";
|
|
14
|
+
import { replaceRange as replaceRange4 } from "ts-macro";
|
|
15
|
+
|
|
16
|
+
// src/volar/define-component.ts
|
|
17
|
+
import { allCodeFeatures, replaceRange } from "ts-macro";
|
|
18
|
+
function transformDefineComponent(node, options) {
|
|
19
|
+
const { codes, source, ast } = options;
|
|
20
|
+
replaceRange(codes, node.arguments[0].end, node.end - 1);
|
|
21
|
+
const componentOptions = node.arguments[1];
|
|
22
|
+
replaceRange(
|
|
23
|
+
codes,
|
|
24
|
+
node.getStart(ast),
|
|
25
|
+
node.expression.end + 1,
|
|
26
|
+
"(",
|
|
27
|
+
[node.expression.getText(ast), source, node.getStart(ast), allCodeFeatures],
|
|
28
|
+
"(() => ({}) as any, ",
|
|
29
|
+
componentOptions ? [
|
|
30
|
+
componentOptions.getText(ast),
|
|
31
|
+
source,
|
|
32
|
+
componentOptions.getStart(ast),
|
|
33
|
+
allCodeFeatures
|
|
34
|
+
] : "",
|
|
35
|
+
"), "
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/volar/transform.ts
|
|
40
|
+
import { HELPER_PREFIX as HELPER_PREFIX2 } from "@vue-macros/common";
|
|
41
|
+
import { replaceRange as replaceRange3 } from "ts-macro";
|
|
42
|
+
|
|
43
|
+
// src/volar/define-style.ts
|
|
44
|
+
import { HELPER_PREFIX } from "@vue-macros/common";
|
|
45
|
+
import { generateClassProperty } from "@vue/language-core/lib/codegen/style/classProperty.js";
|
|
46
|
+
import { parseCssClassNames } from "@vue/language-core/lib/utils/parseCssClassNames.js";
|
|
47
|
+
import { replaceRange as replaceRange2 } from "ts-macro";
|
|
48
|
+
function transformDefineStyle(defineStyles, options) {
|
|
49
|
+
if (!defineStyles?.length) return;
|
|
50
|
+
const { ts, codes, ast } = options;
|
|
51
|
+
defineStyles.forEach(({ expression, isCssModules }, index) => {
|
|
52
|
+
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) {
|
|
53
|
+
replaceRange2(
|
|
54
|
+
codes,
|
|
55
|
+
expression.arguments.pos - 1,
|
|
56
|
+
expression.arguments.pos - 1,
|
|
57
|
+
`<${HELPER_PREFIX}PrettifyLocal<{}`,
|
|
58
|
+
...generateCssClassesType(
|
|
59
|
+
expression.arguments[0].getText(ast).slice(1, -1),
|
|
60
|
+
expression.arguments[0].getStart(ast) + 1,
|
|
61
|
+
index
|
|
62
|
+
),
|
|
63
|
+
">>"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
addEmbeddedCode(expression, index, options);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function* generateCssClassesType(css, offset, index) {
|
|
70
|
+
for (const className of [...parseCssClassNames(css)]) {
|
|
71
|
+
yield* generateClassProperty(
|
|
72
|
+
index,
|
|
73
|
+
className.text,
|
|
74
|
+
className.offset + offset,
|
|
75
|
+
"string"
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function addEmbeddedCode(expression, index, options) {
|
|
80
|
+
const { ts, ast } = options;
|
|
81
|
+
const languageId = ts.isPropertyAccessExpression(expression.expression) && ts.isIdentifier(expression.expression.name) ? expression.expression.name.text : "css";
|
|
82
|
+
const style = expression.arguments[0];
|
|
83
|
+
const styleText = style.getText(ast).slice(1, -1).replaceAll(/\$\{.*\}/g, (str) => "_".repeat(str.length));
|
|
84
|
+
options.embeddedCodes.push({
|
|
85
|
+
id: `style_${index}`,
|
|
86
|
+
languageId,
|
|
87
|
+
snapshot: {
|
|
88
|
+
getText: (start, end) => styleText.slice(start, end),
|
|
89
|
+
getLength: () => styleText.length,
|
|
90
|
+
getChangeRange: () => void 0
|
|
91
|
+
},
|
|
92
|
+
mappings: [
|
|
93
|
+
{
|
|
94
|
+
sourceOffsets: [style.getStart(ast) + 1],
|
|
95
|
+
generatedOffsets: [0],
|
|
96
|
+
lengths: [styleText.length],
|
|
97
|
+
data: {
|
|
98
|
+
completion: true,
|
|
99
|
+
format: true,
|
|
100
|
+
navigation: true,
|
|
101
|
+
semantic: true,
|
|
102
|
+
structure: true,
|
|
103
|
+
verification: true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
embeddedCodes: []
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/volar/transform.ts
|
|
112
|
+
function transformJsxMacros(rootMap, options) {
|
|
113
|
+
const { ts, codes, ast } = options;
|
|
114
|
+
for (const [root, map] of rootMap) {
|
|
115
|
+
transformDefineStyle(map.defineStyle, options);
|
|
116
|
+
if (!root?.body) continue;
|
|
117
|
+
const asyncModifier = root.modifiers?.find(
|
|
118
|
+
(modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword
|
|
119
|
+
);
|
|
120
|
+
if (asyncModifier && map.defineComponent)
|
|
121
|
+
replaceRange3(codes, asyncModifier.pos, asyncModifier.end);
|
|
122
|
+
const result = `({}) as __VLS_PickNotAny<Awaited<ReturnType<typeof ${HELPER_PREFIX2}setup>>['render'], {}> & { __ctx: Awaited<ReturnType<typeof ${HELPER_PREFIX2}setup>> }`;
|
|
123
|
+
const propsType = root.parameters[0]?.type ? String(root.parameters[0].type.getText(ast)) : "{}";
|
|
124
|
+
replaceRange3(
|
|
125
|
+
codes,
|
|
126
|
+
root.parameters.pos,
|
|
127
|
+
root.parameters.pos,
|
|
128
|
+
ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "",
|
|
129
|
+
`${HELPER_PREFIX2}props: Awaited<ReturnType<typeof ${HELPER_PREFIX2}setup>>['props'] & ${propsType}, `,
|
|
130
|
+
`${HELPER_PREFIX2}placeholder?: {}, `,
|
|
131
|
+
`${HELPER_PREFIX2}setup = (${asyncModifier ? "async" : ""}(`
|
|
132
|
+
);
|
|
133
|
+
if (ts.isArrowFunction(root)) {
|
|
134
|
+
replaceRange3(
|
|
135
|
+
codes,
|
|
136
|
+
root.end,
|
|
137
|
+
root.end,
|
|
138
|
+
`))${root.pos === root.parameters.pos ? ")" : ""} => `,
|
|
139
|
+
result
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
replaceRange3(
|
|
143
|
+
codes,
|
|
144
|
+
root.body.getStart(ast),
|
|
145
|
+
root.body.getStart(ast),
|
|
146
|
+
"=>"
|
|
147
|
+
);
|
|
148
|
+
replaceRange3(codes, root.end, root.end, `)){ return `, result, "}");
|
|
149
|
+
}
|
|
150
|
+
ts.forEachChild(root.body, (node) => {
|
|
151
|
+
if (ts.isReturnStatement(node) && node.expression) {
|
|
152
|
+
const props = [...map.defineModel ?? []];
|
|
153
|
+
const elements = root.parameters[0] && !root.parameters[0].type && ts.isObjectBindingPattern(root.parameters[0].name) ? root.parameters[0].name.elements : [];
|
|
154
|
+
for (const element of elements) {
|
|
155
|
+
if (ts.isIdentifier(element.name))
|
|
156
|
+
props.push(
|
|
157
|
+
`${element.name.escapedText}${element.initializer && ts.isNonNullExpression(element.initializer) ? ":" : "?:"} typeof ${element.name.escapedText}`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const shouldWrapByCall = (ts.isArrowFunction(node.expression) || ts.isFunctionExpression(node.expression)) && map.defineComponent;
|
|
161
|
+
replaceRange3(
|
|
162
|
+
codes,
|
|
163
|
+
node.getStart(ast),
|
|
164
|
+
node.expression.getStart(ast),
|
|
165
|
+
`return {
|
|
166
|
+
props: {} as { ${props.join(", ")} }`,
|
|
167
|
+
`,
|
|
168
|
+
slots: {} as ${map.defineSlots ?? "{}"}`,
|
|
169
|
+
`,
|
|
170
|
+
expose: (exposed: ${options.lib === "vue" ? `import('vue').ShallowUnwrapRef` : "NonNullable"}<${map.defineExpose ?? "{}"}>) => {}`,
|
|
171
|
+
`,
|
|
172
|
+
render: `,
|
|
173
|
+
shouldWrapByCall ? "(" : ""
|
|
174
|
+
);
|
|
175
|
+
replaceRange3(
|
|
176
|
+
codes,
|
|
177
|
+
node.expression.end,
|
|
178
|
+
node.expression.end,
|
|
179
|
+
shouldWrapByCall ? ")()" : "",
|
|
180
|
+
`
|
|
181
|
+
}`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/volar/global-types.ts
|
|
189
|
+
import { HELPER_PREFIX as HELPER_PREFIX3 } from "@vue-macros/common";
|
|
190
|
+
function getGlobalTypes(options) {
|
|
191
|
+
const defineSlots = options.defineSlots.alias.flatMap((alias) => [
|
|
192
|
+
`declare function ${alias}<T extends Record<string, any>>(): Partial<T>;`,
|
|
193
|
+
`declare function ${alias}<T extends Record<string, any>>(slots: T): T;
|
|
194
|
+
`
|
|
195
|
+
]).join("");
|
|
196
|
+
const defineExpose = options.defineExpose.alias.map(
|
|
197
|
+
(alias) => `declare function ${alias}<Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed): Exposed;`
|
|
198
|
+
).join("");
|
|
199
|
+
const defineStyle = options.defineStyle.alias.map(
|
|
200
|
+
(alias) => `declare const ${alias}: { <T>(...args: ${HELPER_PREFIX3}StyleArgs): T; scss: <T>(...args: ${HELPER_PREFIX3}StyleArgs)=> T; sass: <T>(...args: ${HELPER_PREFIX3}StyleArgs)=> T; stylus: <T>(...args: ${HELPER_PREFIX3}StyleArgs)=> T; less: <T>(...args: ${HELPER_PREFIX3}StyleArgs)=> T; postcss: <T>(...args: ${HELPER_PREFIX3}StyleArgs)=> T };
|
|
201
|
+
`
|
|
202
|
+
).join("");
|
|
203
|
+
const defineModel = options.defineModel.alias.map(
|
|
204
|
+
(alias) => alias === "defineModel" ? "defineModel" : `defineModel: ${alias}`
|
|
205
|
+
).join(", ");
|
|
206
|
+
const defineComponent = options.defineComponent.alias.map(
|
|
207
|
+
(alias) => ["defineComponent", "defineVaporComponent"].includes(alias) ? "" : `defineComponent: ${alias}`
|
|
208
|
+
).filter(Boolean).join(", ");
|
|
209
|
+
return `
|
|
210
|
+
declare const { ${defineModel}, ${defineComponent} }: typeof import('vue')
|
|
211
|
+
${defineSlots}
|
|
212
|
+
${defineExpose}
|
|
213
|
+
${defineStyle}
|
|
214
|
+
type ${HELPER_PREFIX3}StyleArgs = [style: string, options?: { scoped?: boolean }];
|
|
215
|
+
type ${HELPER_PREFIX3}PrettifyLocal<T> = { [K in keyof T]: T[K]; } & {};
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/volar/index.ts
|
|
224
|
+
function getMacro(node, ts, options) {
|
|
225
|
+
if (!node) return;
|
|
226
|
+
if (ts.isVariableStatement(node)) {
|
|
227
|
+
return ts.forEachChild(node.declarationList, (decl) => getExpression(decl));
|
|
228
|
+
} else {
|
|
229
|
+
return getExpression(node);
|
|
230
|
+
}
|
|
231
|
+
function getExpression(decl) {
|
|
232
|
+
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
233
|
+
const initializer = ts.isCallExpression(decl.initializer) && ts.isIdentifier(decl.initializer.expression) && decl.initializer.expression.escapedText === "$" && decl.initializer.arguments[0] ? decl.initializer.arguments[0] : decl.initializer;
|
|
234
|
+
const expression = getMacroExpression(initializer);
|
|
235
|
+
if (expression) {
|
|
236
|
+
return {
|
|
237
|
+
expression,
|
|
238
|
+
initializer: decl.initializer,
|
|
239
|
+
isRequired: ts.isNonNullExpression(initializer)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
} else if (ts.isExpressionStatement(decl)) {
|
|
243
|
+
const expression = getMacroExpression(decl.expression);
|
|
244
|
+
if (expression)
|
|
245
|
+
return {
|
|
246
|
+
expression,
|
|
247
|
+
initializer: decl.expression,
|
|
248
|
+
isRequired: ts.isNonNullExpression(decl.expression)
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function getMacroExpression(node2) {
|
|
253
|
+
if (ts.isNonNullExpression(node2)) {
|
|
254
|
+
node2 = node2.expression;
|
|
255
|
+
}
|
|
256
|
+
if (!ts.isCallExpression(node2)) return;
|
|
257
|
+
const expression = ts.isPropertyAccessExpression(node2.expression) ? node2.expression : node2;
|
|
258
|
+
return ts.isIdentifier(expression.expression) && [
|
|
259
|
+
...options.defineModel.alias,
|
|
260
|
+
...options.defineSlots.alias,
|
|
261
|
+
...options.defineStyle.alias,
|
|
262
|
+
...options.defineExpose.alias,
|
|
263
|
+
...options.defineComponent.alias
|
|
264
|
+
].includes(expression.expression.escapedText) && node2;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function getRootMap(options) {
|
|
268
|
+
const { ts, ast, codes } = options;
|
|
269
|
+
const rootMap = /* @__PURE__ */ new Map();
|
|
270
|
+
function walk(node, parents) {
|
|
271
|
+
ts.forEachChild(node, (child) => {
|
|
272
|
+
parents.unshift(node);
|
|
273
|
+
walk(child, parents);
|
|
274
|
+
parents.shift();
|
|
275
|
+
});
|
|
276
|
+
const root = parents[1] && (ts.isArrowFunction(parents[1]) || ts.isFunctionExpression(parents[1]) || ts.isFunctionDeclaration(parents[1])) ? parents[1] : void 0;
|
|
277
|
+
if (root && parents[2] && ts.isCallExpression(parents[2]) && !parents[2].typeArguments && options.defineComponent.alias.includes(parents[2].expression.getText(ast))) {
|
|
278
|
+
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
279
|
+
if (!rootMap.get(root).defineComponent) {
|
|
280
|
+
rootMap.get(root).defineComponent = true;
|
|
281
|
+
transformDefineComponent(parents[2], options);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const macro = getMacro(node, ts, options);
|
|
285
|
+
if (!macro) return;
|
|
286
|
+
const { expression, initializer } = macro;
|
|
287
|
+
let isRequired = macro.isRequired;
|
|
288
|
+
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
289
|
+
const macroName = expression.expression.getText(ast);
|
|
290
|
+
if (macroName.startsWith("defineStyle")) {
|
|
291
|
+
;
|
|
292
|
+
(rootMap.get(root).defineStyle ??= []).push({
|
|
293
|
+
expression,
|
|
294
|
+
isCssModules: !!ts.isVariableStatement(node)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (!root) return;
|
|
298
|
+
if (options.defineModel.alias.includes(macroName)) {
|
|
299
|
+
const modelName = expression.arguments[0] && ts.isStringLiteralLike(expression.arguments[0]) ? expression.arguments[0].text : "modelValue";
|
|
300
|
+
const modelOptions = expression.arguments[0] && ts.isStringLiteralLike(expression.arguments[0]) ? expression.arguments[1] : expression.arguments[0];
|
|
301
|
+
if (modelOptions && ts.isObjectLiteralExpression(modelOptions)) {
|
|
302
|
+
let hasRequired = false;
|
|
303
|
+
for (const prop of modelOptions.properties) {
|
|
304
|
+
if (ts.isPropertyAssignment(prop) && prop.name.getText(ast) === "required") {
|
|
305
|
+
hasRequired = true;
|
|
306
|
+
isRequired = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (!hasRequired && isRequired) {
|
|
310
|
+
replaceRange4(
|
|
311
|
+
codes,
|
|
312
|
+
modelOptions.end - 1,
|
|
313
|
+
modelOptions.end - 1,
|
|
314
|
+
`${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
} else if (isRequired) {
|
|
318
|
+
replaceRange4(
|
|
319
|
+
codes,
|
|
320
|
+
expression.arguments.end,
|
|
321
|
+
expression.arguments.end,
|
|
322
|
+
`${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
const id = toValidAssetId(modelName, `${HELPER_PREFIX4}model`);
|
|
326
|
+
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
327
|
+
(rootMap.get(root).defineModel ??= []).push(
|
|
328
|
+
`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`,
|
|
329
|
+
`'onUpdate:${modelName}'?: ($event: ${typeString}) => any`
|
|
330
|
+
);
|
|
331
|
+
replaceRange4(
|
|
332
|
+
codes,
|
|
333
|
+
initializer.getStart(ast),
|
|
334
|
+
initializer.getStart(ast),
|
|
335
|
+
`// @ts-ignore
|
|
336
|
+
${id};
|
|
337
|
+
let ${id} =`
|
|
338
|
+
);
|
|
339
|
+
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
340
|
+
replaceRange4(
|
|
341
|
+
codes,
|
|
342
|
+
expression.getStart(ast),
|
|
343
|
+
expression.getStart(ast),
|
|
344
|
+
`// @ts-ignore
|
|
345
|
+
${HELPER_PREFIX4}slots;
|
|
346
|
+
const ${HELPER_PREFIX4}slots = `
|
|
347
|
+
);
|
|
348
|
+
rootMap.get(root).defineSlots = `Partial<typeof ${HELPER_PREFIX4}slots>`;
|
|
349
|
+
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
350
|
+
replaceRange4(
|
|
351
|
+
codes,
|
|
352
|
+
expression.getStart(ast),
|
|
353
|
+
expression.getStart(ast),
|
|
354
|
+
`// @ts-ignore
|
|
355
|
+
${HELPER_PREFIX4}exposed;
|
|
356
|
+
const ${HELPER_PREFIX4}exposed = `
|
|
357
|
+
);
|
|
358
|
+
rootMap.get(root).defineExpose = `typeof ${HELPER_PREFIX4}exposed`;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
ts.forEachChild(ast, (node) => walk(node, []));
|
|
362
|
+
return rootMap;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/volar.ts
|
|
366
|
+
var plugin = createPlugin(
|
|
367
|
+
({ ts }, userOptions = {}) => {
|
|
368
|
+
const resolvedOptions = resolveOptions(userOptions);
|
|
369
|
+
const filter = createFilter(resolvedOptions);
|
|
370
|
+
return {
|
|
371
|
+
name: "@vue-jsx-vapor/macros",
|
|
372
|
+
resolveVirtualCode(virtualCode) {
|
|
373
|
+
const { filePath, codes } = virtualCode;
|
|
374
|
+
if (!filter(filePath)) return;
|
|
375
|
+
const options = {
|
|
376
|
+
ts,
|
|
377
|
+
...virtualCode,
|
|
378
|
+
...resolvedOptions
|
|
379
|
+
};
|
|
380
|
+
const rootMap = getRootMap(options);
|
|
381
|
+
if (rootMap.size) {
|
|
382
|
+
transformJsxMacros(rootMap, options);
|
|
383
|
+
codes.push(getGlobalTypes(options));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
var volar_default = plugin;
|
|
390
|
+
export {
|
|
391
|
+
volar_default as default
|
|
392
|
+
};
|
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkXA5RNEABcjs = require('./chunk-XA5RNEAB.cjs');
|
|
4
|
+
require('./chunk-Y4BCVHJT.cjs');
|
|
5
|
+
require('./chunk-LYT252SL.cjs');
|
|
6
|
+
require('./chunk-6JTF6MNY.cjs');
|
|
7
|
+
require('./chunk-UZ426MO6.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.default = _chunkXA5RNEABcjs.webpack_default;
|
|
11
|
+
|
|
12
|
+
module.exports = exports.default;
|
package/dist/webpack.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vue-jsx-vapor/macros",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"description": "Macros for Vue JSX Vapor",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"transform",
|
|
8
|
+
"vue-jsx",
|
|
9
|
+
"macros",
|
|
10
|
+
"volar",
|
|
11
|
+
"vapor"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"homepage": "https://github.com/unplugin/unplugin-vue-jsx-vapor#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/unplugin/unplugin-vue-jsx-vapor/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/unplugin/unplugin-vue-jsx-vapor.git"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"main": "dist/index.cjs",
|
|
26
|
+
"module": "dist/index.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"dev": "./src/index.ts",
|
|
31
|
+
"require": "./dist/index.cjs",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./astro": {
|
|
35
|
+
"dev": "./src/astro.ts",
|
|
36
|
+
"require": "./dist/astro.cjs",
|
|
37
|
+
"import": "./dist/astro.js"
|
|
38
|
+
},
|
|
39
|
+
"./rspack": {
|
|
40
|
+
"dev": "./src/rspack.ts",
|
|
41
|
+
"require": "./dist/rspack.cjs",
|
|
42
|
+
"import": "./dist/rspack.js"
|
|
43
|
+
},
|
|
44
|
+
"./vite": {
|
|
45
|
+
"dev": "./src/vite.ts",
|
|
46
|
+
"require": "./dist/vite.cjs",
|
|
47
|
+
"import": "./dist/vite.js"
|
|
48
|
+
},
|
|
49
|
+
"./webpack": {
|
|
50
|
+
"dev": "./src/webpack.ts",
|
|
51
|
+
"require": "./dist/webpack.cjs",
|
|
52
|
+
"import": "./dist/webpack.js"
|
|
53
|
+
},
|
|
54
|
+
"./rollup": {
|
|
55
|
+
"dev": "./src/rollup.ts",
|
|
56
|
+
"require": "./dist/rollup.cjs",
|
|
57
|
+
"import": "./dist/rollup.js"
|
|
58
|
+
},
|
|
59
|
+
"./esbuild": {
|
|
60
|
+
"dev": "./src/esbuild.ts",
|
|
61
|
+
"require": "./dist/esbuild.cjs",
|
|
62
|
+
"import": "./dist/esbuild.js"
|
|
63
|
+
},
|
|
64
|
+
"./nuxt": {
|
|
65
|
+
"dev": "./src/nuxt.ts",
|
|
66
|
+
"require": "./dist/nuxt.cjs",
|
|
67
|
+
"import": "./dist/nuxt.js"
|
|
68
|
+
},
|
|
69
|
+
"./api": {
|
|
70
|
+
"dev": "./src/api.ts",
|
|
71
|
+
"require": "./dist/api.cjs",
|
|
72
|
+
"import": "./dist/api.js"
|
|
73
|
+
},
|
|
74
|
+
"./raw": {
|
|
75
|
+
"dev": "./src/raw.ts",
|
|
76
|
+
"require": "./dist/raw.cjs",
|
|
77
|
+
"import": "./dist/raw.js"
|
|
78
|
+
},
|
|
79
|
+
"./volar": {
|
|
80
|
+
"dev": "./src/volar.ts",
|
|
81
|
+
"require": "./dist/volar.cjs",
|
|
82
|
+
"import": "./dist/volar.js"
|
|
83
|
+
},
|
|
84
|
+
"./*": "./*"
|
|
85
|
+
},
|
|
86
|
+
"typesVersions": {
|
|
87
|
+
"*": {
|
|
88
|
+
"*": [
|
|
89
|
+
"./dist/*",
|
|
90
|
+
"./*"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"publishConfig": {
|
|
95
|
+
".": {
|
|
96
|
+
"require": "./dist/index.cjs",
|
|
97
|
+
"import": "./dist/index.js"
|
|
98
|
+
},
|
|
99
|
+
"./astro": {
|
|
100
|
+
"require": "./dist/astro.cjs",
|
|
101
|
+
"import": "./dist/astro.js"
|
|
102
|
+
},
|
|
103
|
+
"./rspack": {
|
|
104
|
+
"require": "./dist/rspack.cjs",
|
|
105
|
+
"import": "./dist/rspack.js"
|
|
106
|
+
},
|
|
107
|
+
"./vite": {
|
|
108
|
+
"require": "./dist/vite.cjs",
|
|
109
|
+
"import": "./dist/vite.js"
|
|
110
|
+
},
|
|
111
|
+
"./webpack": {
|
|
112
|
+
"require": "./dist/webpack.cjs",
|
|
113
|
+
"import": "./dist/webpack.js"
|
|
114
|
+
},
|
|
115
|
+
"./rollup": {
|
|
116
|
+
"require": "./dist/rollup.cjs",
|
|
117
|
+
"import": "./dist/rollup.js"
|
|
118
|
+
},
|
|
119
|
+
"./esbuild": {
|
|
120
|
+
"require": "./dist/esbuild.cjs",
|
|
121
|
+
"import": "./dist/esbuild.js"
|
|
122
|
+
},
|
|
123
|
+
"./nuxt": {
|
|
124
|
+
"require": "./dist/nuxt.cjs",
|
|
125
|
+
"import": "./dist/nuxt.js"
|
|
126
|
+
},
|
|
127
|
+
"./api": {
|
|
128
|
+
"require": "./dist/api.cjs",
|
|
129
|
+
"import": "./dist/api.js"
|
|
130
|
+
},
|
|
131
|
+
"./raw": {
|
|
132
|
+
"require": "./dist/raw.cjs",
|
|
133
|
+
"import": "./dist/raw.js"
|
|
134
|
+
},
|
|
135
|
+
"./volar": {
|
|
136
|
+
"require": "./dist/volar.cjs",
|
|
137
|
+
"import": "./dist/volar.js"
|
|
138
|
+
},
|
|
139
|
+
"./*": "./*"
|
|
140
|
+
},
|
|
141
|
+
"peerDependencies": {
|
|
142
|
+
"@nuxt/kit": "^3",
|
|
143
|
+
"@nuxt/schema": "^3",
|
|
144
|
+
"esbuild": "*",
|
|
145
|
+
"rollup": "^3",
|
|
146
|
+
"vite": ">=3",
|
|
147
|
+
"webpack": "^4 || ^5"
|
|
148
|
+
},
|
|
149
|
+
"peerDependenciesMeta": {
|
|
150
|
+
"@nuxt/kit": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"@nuxt/schema": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"esbuild": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"rollup": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"vite": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"webpack": {
|
|
166
|
+
"optional": true
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"dependencies": {
|
|
170
|
+
"@vue-macros/common": "3.0.0-beta.4",
|
|
171
|
+
"@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@ce35a8c",
|
|
172
|
+
"@vue/compiler-sfc": "https://pkg.pr.new/@vue/compiler-sfc@ce35a8c",
|
|
173
|
+
"@vue/language-core": "^2.2.8",
|
|
174
|
+
"hash-sum": "^2.0.0",
|
|
175
|
+
"ts-macro": "0.1.21",
|
|
176
|
+
"unplugin": "^1.16.1"
|
|
177
|
+
},
|
|
178
|
+
"devDependencies": {
|
|
179
|
+
"@babel/types": "^7.26.8",
|
|
180
|
+
"@nuxt/kit": "^3.16.0",
|
|
181
|
+
"@nuxt/schema": "^3.16.0",
|
|
182
|
+
"@types/hash-sum": "^1.0.2",
|
|
183
|
+
"@vue-macros/test-utils": "3.0.0-beta.4",
|
|
184
|
+
"vitest": "^3.0.8",
|
|
185
|
+
"vue": "https://pkg.pr.new/vue@ce35a8c"
|
|
186
|
+
},
|
|
187
|
+
"scripts": {
|
|
188
|
+
"build": "tsup",
|
|
189
|
+
"dev": "DEV=true tsup"
|
|
190
|
+
}
|
|
191
|
+
}
|