@vue-jsx-vapor/macros 2.3.3 → 2.3.5
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/api.cjs +1 -1
- package/dist/api.d.cts +9 -6
- package/dist/api.d.ts +9 -6
- package/dist/api.js +1 -1
- package/dist/astro.cjs +4 -4
- package/dist/astro.d.cts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +4 -4
- package/dist/{core-CdPKEM79.cjs → core-C740HxiF.cjs} +36 -23
- package/dist/{core-B_EM_kTA.js → core-CHBxRAvb.js} +36 -23
- package/dist/esbuild.cjs +4 -4
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/nuxt.cjs +6 -6
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +6 -6
- package/dist/{options-CNIhAQHD.cjs → options-BSX_vMxh.cjs} +8 -5
- package/dist/options-BWRkHmm5.js +23 -0
- package/dist/options.cjs +1 -1
- package/dist/options.d-CXMsJZSo.d.cts +37 -0
- package/dist/options.d-DNWXuL_g.d.ts +37 -0
- package/dist/options.d.cts +1 -1
- package/dist/options.d.ts +1 -1
- package/dist/options.js +1 -1
- package/dist/{raw-oJpqvj1N.cjs → raw-BXpT71mV.cjs} +2 -2
- package/dist/{raw-9H5vTeLe.js → raw-Hr7QYA0U.js} +2 -2
- package/dist/raw.cjs +3 -3
- package/dist/raw.d.cts +1 -1
- package/dist/raw.d.ts +1 -1
- package/dist/raw.js +3 -3
- package/dist/rolldown.cjs +4 -4
- package/dist/rolldown.d.cts +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +4 -4
- package/dist/rollup.cjs +4 -4
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +4 -4
- package/dist/rspack.cjs +4 -4
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +4 -4
- package/dist/{src-CY9FOMwg.cjs → src-2EUAmvRo.cjs} +1 -1
- package/dist/{src-CjDaDFw_.js → src-BDMVJUXS.js} +1 -1
- package/dist/{vite-HbXTfQl_.js → vite-CS2vynmi.js} +1 -1
- package/dist/{vite-CtRiheet.cjs → vite-DP98E6od.cjs} +1 -1
- package/dist/vite.cjs +5 -5
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +5 -5
- package/dist/volar.cjs +70 -57
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +70 -57
- package/dist/{webpack-5inEmXrh.js → webpack-C78RZrII.js} +1 -1
- package/dist/{webpack-YO7qm0E9.cjs → webpack-qmJC3FBB.cjs} +1 -1
- package/dist/webpack.cjs +5 -5
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +5 -5
- package/package.json +1 -2
- package/dist/options-pbSvpKdV.js +0 -20
- package/dist/options.d-B3WOiT_L.d.cts +0 -26
- package/dist/options.d-DtyRfe-9.d.ts +0 -26
package/dist/api.cjs
CHANGED
package/dist/api.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OptionsResolved } from "./options.d-
|
|
1
|
+
import { OptionsResolved } from "./options.d-CXMsJZSo.cjs";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
|
-
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, Node } from "@babel/types";
|
|
3
|
+
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node } from "@babel/types";
|
|
4
4
|
|
|
5
5
|
//#region src/core/restructure.d.ts
|
|
6
6
|
type Options = {
|
|
@@ -22,16 +22,19 @@ declare function restructure(s: MagicStringAST, node: FunctionalNode, options?:
|
|
|
22
22
|
type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
|
23
23
|
type DefineStyle = {
|
|
24
24
|
expression: CallExpression;
|
|
25
|
-
|
|
25
|
+
isCssModules: boolean;
|
|
26
26
|
lang: string;
|
|
27
27
|
};
|
|
28
|
-
type
|
|
28
|
+
type Macros = {
|
|
29
29
|
defineComponent?: CallExpression;
|
|
30
30
|
defineModel?: {
|
|
31
31
|
expression: CallExpression;
|
|
32
32
|
isRequired: boolean;
|
|
33
33
|
}[];
|
|
34
|
-
defineSlots?:
|
|
34
|
+
defineSlots?: {
|
|
35
|
+
expression: CallExpression;
|
|
36
|
+
id?: LVal;
|
|
37
|
+
};
|
|
35
38
|
defineExpose?: CallExpression;
|
|
36
39
|
defineStyle?: DefineStyle[];
|
|
37
40
|
};
|
|
@@ -41,4 +44,4 @@ declare function getMacroExpression(node: Node, options: OptionsResolved): CallE
|
|
|
41
44
|
declare function getParamsStart(node: FunctionalNode, code: string): number;
|
|
42
45
|
|
|
43
46
|
//#endregion
|
|
44
|
-
export { DefineStyle, FunctionalNode,
|
|
47
|
+
export { DefineStyle, FunctionalNode, Macros, getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OptionsResolved } from "./options.d-
|
|
1
|
+
import { OptionsResolved } from "./options.d-DNWXuL_g.js";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
|
-
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, Node } from "@babel/types";
|
|
3
|
+
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node } from "@babel/types";
|
|
4
4
|
|
|
5
5
|
//#region src/core/restructure.d.ts
|
|
6
6
|
type Options = {
|
|
@@ -22,16 +22,19 @@ declare function restructure(s: MagicStringAST, node: FunctionalNode, options?:
|
|
|
22
22
|
type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
|
23
23
|
type DefineStyle = {
|
|
24
24
|
expression: CallExpression;
|
|
25
|
-
|
|
25
|
+
isCssModules: boolean;
|
|
26
26
|
lang: string;
|
|
27
27
|
};
|
|
28
|
-
type
|
|
28
|
+
type Macros = {
|
|
29
29
|
defineComponent?: CallExpression;
|
|
30
30
|
defineModel?: {
|
|
31
31
|
expression: CallExpression;
|
|
32
32
|
isRequired: boolean;
|
|
33
33
|
}[];
|
|
34
|
-
defineSlots?:
|
|
34
|
+
defineSlots?: {
|
|
35
|
+
expression: CallExpression;
|
|
36
|
+
id?: LVal;
|
|
37
|
+
};
|
|
35
38
|
defineExpose?: CallExpression;
|
|
36
39
|
defineStyle?: DefineStyle[];
|
|
37
40
|
};
|
|
@@ -41,4 +44,4 @@ declare function getMacroExpression(node: Node, options: OptionsResolved): CallE
|
|
|
41
44
|
declare function getParamsStart(node: FunctionalNode, code: string): number;
|
|
42
45
|
|
|
43
46
|
//#endregion
|
|
44
|
-
export { DefineStyle, FunctionalNode,
|
|
47
|
+
export { DefineStyle, FunctionalNode, Macros, getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros } from "./core-
|
|
1
|
+
import { getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros } from "./core-CHBxRAvb.js";
|
|
2
2
|
|
|
3
3
|
export { getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/astro.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
require('./core-
|
|
4
|
-
require('./raw-
|
|
5
|
-
require('./options-
|
|
6
|
-
const require_src = require('./src-
|
|
3
|
+
require('./core-C740HxiF.cjs');
|
|
4
|
+
require('./raw-BXpT71mV.cjs');
|
|
5
|
+
require('./options-BSX_vMxh.cjs');
|
|
6
|
+
const require_src = require('./src-2EUAmvRo.cjs');
|
|
7
7
|
|
|
8
8
|
//#region src/astro.ts
|
|
9
9
|
var astro_default = (options) => ({
|
package/dist/astro.d.cts
CHANGED
package/dist/astro.d.ts
CHANGED
package/dist/astro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
3
|
-
import "./options-
|
|
4
|
-
import { src_default } from "./src-
|
|
1
|
+
import "./core-CHBxRAvb.js";
|
|
2
|
+
import "./raw-Hr7QYA0U.js";
|
|
3
|
+
import "./options-BWRkHmm5.js";
|
|
4
|
+
import { src_default } from "./src-BDMVJUXS.js";
|
|
5
5
|
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -163,9 +163,9 @@ function transformReturn(root, s) {
|
|
|
163
163
|
|
|
164
164
|
//#endregion
|
|
165
165
|
//#region src/core/define-component/index.ts
|
|
166
|
-
function transformDefineComponent(root, propsName,
|
|
167
|
-
if (!
|
|
168
|
-
const defineComponentName = s.sliceNode(
|
|
166
|
+
function transformDefineComponent(root, propsName, macros, s, autoReturnFunction = false) {
|
|
167
|
+
if (!macros.defineComponent) return;
|
|
168
|
+
const defineComponentName = s.sliceNode(macros.defineComponent.callee);
|
|
169
169
|
if (defineComponentName && !["defineComponent", "defineVaporComponent"].includes(defineComponentName)) (0, __vue_macros_common.importHelperFn)(s, 0, "defineComponent", defineComponentName);
|
|
170
170
|
let hasRestProp = false;
|
|
171
171
|
const props = {};
|
|
@@ -205,10 +205,10 @@ function transformDefineComponent(root, propsName, map, s, autoReturnFunction =
|
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
transformDefineModel$1(s,
|
|
208
|
+
transformDefineModel$1(s, macros.defineModel, props);
|
|
209
209
|
const propsString = Object.entries(props).map(([key, value]) => `'${key}': ${value}`).join(", \n");
|
|
210
210
|
if (propsString) {
|
|
211
|
-
const argument =
|
|
211
|
+
const argument = macros.defineComponent.arguments[1];
|
|
212
212
|
if (!argument) s.appendRight(root.end, `, {${hasRestProp ? "inheritAttrs: false," : ""} props: {\n${propsString}\n} }`);
|
|
213
213
|
else if (argument.type === "ObjectExpression") {
|
|
214
214
|
prependObjectExpression(argument, "props", `{\n${propsString}\n}`, s);
|
|
@@ -317,8 +317,8 @@ function transformDefineSlots(node, s) {
|
|
|
317
317
|
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/core/define-style.ts
|
|
320
|
-
function transformDefineStyle(defineStyle, index, root, s, importMap) {
|
|
321
|
-
const { expression, lang,
|
|
320
|
+
function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSlots }) {
|
|
321
|
+
const { expression, lang, isCssModules } = defineStyle;
|
|
322
322
|
if (expression.arguments[0]?.type !== "TemplateLiteral") return;
|
|
323
323
|
let css = s.sliceNode(expression.arguments[0]).slice(1, -1);
|
|
324
324
|
const scopeId = (0, hash_sum.default)(css);
|
|
@@ -340,15 +340,25 @@ function transformDefineStyle(defineStyle, index, root, s, importMap) {
|
|
|
340
340
|
if (expression.arguments[1]?.type === "ObjectExpression") {
|
|
341
341
|
for (const prop of expression.arguments[1].properties) if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "scoped" && prop.value.type === "BooleanLiteral") scoped = prop.value.value;
|
|
342
342
|
}
|
|
343
|
-
if (scoped &&
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
if (scoped && root) {
|
|
344
|
+
const slotNames = defineSlots?.id ? defineSlots.id.type === "Identifier" ? defineSlots.id.name : defineSlots.id.type === "ObjectPattern" ? defineSlots.id.properties.map((prop) => s.sliceNode(prop.type === "RestElement" ? prop.argument : prop.value)) : [] : [];
|
|
345
|
+
(0, __vue_macros_common.walkAST)(root, { enter(node) {
|
|
346
|
+
if (node.type === "JSXElement" && s.sliceNode(node.openingElement.name) !== "template") {
|
|
347
|
+
let subfix = "";
|
|
348
|
+
if (slotNames.length) {
|
|
349
|
+
const name = s.sliceNode(node.openingElement.name.type === "JSXMemberExpression" ? node.openingElement.name.object : node.openingElement.name);
|
|
350
|
+
subfix = slotNames.includes(name) ? "-s" : "";
|
|
351
|
+
}
|
|
352
|
+
s.appendRight(node.openingElement.name.end, ` data-v-${scopeId}${subfix}=""`);
|
|
353
|
+
}
|
|
354
|
+
} });
|
|
355
|
+
}
|
|
346
356
|
css = s.sliceNode(expression.arguments[0]).slice(1, -1).replaceAll(/\/\/(.*)(?=\n)/g, "/*$1*/");
|
|
347
|
-
const module$1 =
|
|
357
|
+
const module$1 = isCssModules ? "module." : "";
|
|
348
358
|
const importId = `${helperPrefix}/define-style/${index}?scopeId=${scopeId}&scoped=${scoped}&lang.${module$1}${lang}`;
|
|
349
359
|
importMap.set(importId, css);
|
|
350
|
-
s.appendLeft(0,
|
|
351
|
-
s.overwriteNode(expression,
|
|
360
|
+
s.appendLeft(0, isCssModules ? `import style${index} from "${importId}";` : `import "${importId}";`);
|
|
361
|
+
s.overwriteNode(expression, isCssModules ? `style${index}` : "");
|
|
352
362
|
}
|
|
353
363
|
function getReturnStatement(root) {
|
|
354
364
|
if (root.body.type === "BlockStatement") {
|
|
@@ -369,9 +379,9 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
369
379
|
const ast = (0, __vue_macros_common.babelParse)(s.original, (0, __vue_macros_common.getLang)(id));
|
|
370
380
|
const rootMap = getRootMap(ast, s, options);
|
|
371
381
|
let defineStyleIndex = 0;
|
|
372
|
-
for (const [root,
|
|
373
|
-
|
|
374
|
-
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap);
|
|
382
|
+
for (const [root, macros] of rootMap) {
|
|
383
|
+
macros.defineStyle?.forEach((defineStyle) => {
|
|
384
|
+
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap, macros);
|
|
375
385
|
});
|
|
376
386
|
if (root === void 0) continue;
|
|
377
387
|
let propsName = `${__vue_macros_common.HELPER_PREFIX}props`;
|
|
@@ -379,16 +389,16 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
379
389
|
if (root.params[0].type === "Identifier") propsName = root.params[0].name;
|
|
380
390
|
else if (root.params[0].type === "ObjectPattern") {
|
|
381
391
|
const lastProp = root.params[0].properties.at(-1);
|
|
382
|
-
if (!
|
|
392
|
+
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
383
393
|
else s.appendRight(root.params[0].extra?.trailingComma ? root.params[0].extra?.trailingComma + 1 : lastProp?.end || root.params[0].end - 1, `${!root.params[0].extra?.trailingComma && root.params[0].properties.length ? "," : ""} ...${__vue_macros_common.HELPER_PREFIX}props`);
|
|
384
394
|
}
|
|
385
395
|
} else s.appendRight(getParamsStart(root, s.original), propsName);
|
|
386
|
-
if (
|
|
387
|
-
if (
|
|
396
|
+
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s, options.defineComponent?.autoReturnFunction);
|
|
397
|
+
if (macros.defineModel?.length) macros.defineModel.forEach(({ expression }) => {
|
|
388
398
|
transformDefineModel(expression, propsName, s);
|
|
389
399
|
});
|
|
390
|
-
if (
|
|
391
|
-
if (
|
|
400
|
+
if (macros.defineSlots) transformDefineSlots(macros.defineSlots.expression, s);
|
|
401
|
+
if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s, options.version);
|
|
392
402
|
}
|
|
393
403
|
return (0, __vue_macros_common.generateTransform)(s, id);
|
|
394
404
|
}
|
|
@@ -418,10 +428,13 @@ function getRootMap(ast, s, options) {
|
|
|
418
428
|
const lang = macroExpression.callee.type === "MemberExpression" && macroExpression.callee.property.type === "Identifier" ? macroExpression.callee.property.name : "css";
|
|
419
429
|
(rootMap.get(root).defineStyle ??= []).push({
|
|
420
430
|
expression: macroExpression,
|
|
421
|
-
|
|
431
|
+
isCssModules: node.type === "VariableDeclaration",
|
|
422
432
|
lang
|
|
423
433
|
});
|
|
424
|
-
} else if (options.defineSlots.alias.includes(macroName)) rootMap.get(root).defineSlots =
|
|
434
|
+
} else if (options.defineSlots.alias.includes(macroName)) rootMap.get(root).defineSlots = {
|
|
435
|
+
expression: macroExpression,
|
|
436
|
+
id: node.type === "VariableDeclaration" ? node.declarations[0].id : void 0
|
|
437
|
+
};
|
|
425
438
|
else if (options.defineExpose.alias.includes(macroName)) rootMap.get(root).defineExpose = macroExpression;
|
|
426
439
|
}
|
|
427
440
|
},
|
|
@@ -161,9 +161,9 @@ function transformReturn(root, s) {
|
|
|
161
161
|
|
|
162
162
|
//#endregion
|
|
163
163
|
//#region src/core/define-component/index.ts
|
|
164
|
-
function transformDefineComponent(root, propsName,
|
|
165
|
-
if (!
|
|
166
|
-
const defineComponentName = s.sliceNode(
|
|
164
|
+
function transformDefineComponent(root, propsName, macros, s, autoReturnFunction = false) {
|
|
165
|
+
if (!macros.defineComponent) return;
|
|
166
|
+
const defineComponentName = s.sliceNode(macros.defineComponent.callee);
|
|
167
167
|
if (defineComponentName && !["defineComponent", "defineVaporComponent"].includes(defineComponentName)) importHelperFn(s, 0, "defineComponent", defineComponentName);
|
|
168
168
|
let hasRestProp = false;
|
|
169
169
|
const props = {};
|
|
@@ -203,10 +203,10 @@ function transformDefineComponent(root, propsName, map, s, autoReturnFunction =
|
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
transformDefineModel$1(s,
|
|
206
|
+
transformDefineModel$1(s, macros.defineModel, props);
|
|
207
207
|
const propsString = Object.entries(props).map(([key, value]) => `'${key}': ${value}`).join(", \n");
|
|
208
208
|
if (propsString) {
|
|
209
|
-
const argument =
|
|
209
|
+
const argument = macros.defineComponent.arguments[1];
|
|
210
210
|
if (!argument) s.appendRight(root.end, `, {${hasRestProp ? "inheritAttrs: false," : ""} props: {\n${propsString}\n} }`);
|
|
211
211
|
else if (argument.type === "ObjectExpression") {
|
|
212
212
|
prependObjectExpression(argument, "props", `{\n${propsString}\n}`, s);
|
|
@@ -315,8 +315,8 @@ function transformDefineSlots(node, s) {
|
|
|
315
315
|
|
|
316
316
|
//#endregion
|
|
317
317
|
//#region src/core/define-style.ts
|
|
318
|
-
function transformDefineStyle(defineStyle, index, root, s, importMap) {
|
|
319
|
-
const { expression, lang,
|
|
318
|
+
function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSlots }) {
|
|
319
|
+
const { expression, lang, isCssModules } = defineStyle;
|
|
320
320
|
if (expression.arguments[0]?.type !== "TemplateLiteral") return;
|
|
321
321
|
let css = s.sliceNode(expression.arguments[0]).slice(1, -1);
|
|
322
322
|
const scopeId = hash(css);
|
|
@@ -338,15 +338,25 @@ function transformDefineStyle(defineStyle, index, root, s, importMap) {
|
|
|
338
338
|
if (expression.arguments[1]?.type === "ObjectExpression") {
|
|
339
339
|
for (const prop of expression.arguments[1].properties) if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "scoped" && prop.value.type === "BooleanLiteral") scoped = prop.value.value;
|
|
340
340
|
}
|
|
341
|
-
if (scoped &&
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
if (scoped && root) {
|
|
342
|
+
const slotNames = defineSlots?.id ? defineSlots.id.type === "Identifier" ? defineSlots.id.name : defineSlots.id.type === "ObjectPattern" ? defineSlots.id.properties.map((prop) => s.sliceNode(prop.type === "RestElement" ? prop.argument : prop.value)) : [] : [];
|
|
343
|
+
walkAST(root, { enter(node) {
|
|
344
|
+
if (node.type === "JSXElement" && s.sliceNode(node.openingElement.name) !== "template") {
|
|
345
|
+
let subfix = "";
|
|
346
|
+
if (slotNames.length) {
|
|
347
|
+
const name = s.sliceNode(node.openingElement.name.type === "JSXMemberExpression" ? node.openingElement.name.object : node.openingElement.name);
|
|
348
|
+
subfix = slotNames.includes(name) ? "-s" : "";
|
|
349
|
+
}
|
|
350
|
+
s.appendRight(node.openingElement.name.end, ` data-v-${scopeId}${subfix}=""`);
|
|
351
|
+
}
|
|
352
|
+
} });
|
|
353
|
+
}
|
|
344
354
|
css = s.sliceNode(expression.arguments[0]).slice(1, -1).replaceAll(/\/\/(.*)(?=\n)/g, "/*$1*/");
|
|
345
|
-
const module =
|
|
355
|
+
const module = isCssModules ? "module." : "";
|
|
346
356
|
const importId = `${helperPrefix}/define-style/${index}?scopeId=${scopeId}&scoped=${scoped}&lang.${module}${lang}`;
|
|
347
357
|
importMap.set(importId, css);
|
|
348
|
-
s.appendLeft(0,
|
|
349
|
-
s.overwriteNode(expression,
|
|
358
|
+
s.appendLeft(0, isCssModules ? `import style${index} from "${importId}";` : `import "${importId}";`);
|
|
359
|
+
s.overwriteNode(expression, isCssModules ? `style${index}` : "");
|
|
350
360
|
}
|
|
351
361
|
function getReturnStatement(root) {
|
|
352
362
|
if (root.body.type === "BlockStatement") {
|
|
@@ -367,9 +377,9 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
367
377
|
const ast = babelParse(s.original, getLang(id));
|
|
368
378
|
const rootMap = getRootMap(ast, s, options);
|
|
369
379
|
let defineStyleIndex = 0;
|
|
370
|
-
for (const [root,
|
|
371
|
-
|
|
372
|
-
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap);
|
|
380
|
+
for (const [root, macros] of rootMap) {
|
|
381
|
+
macros.defineStyle?.forEach((defineStyle) => {
|
|
382
|
+
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap, macros);
|
|
373
383
|
});
|
|
374
384
|
if (root === void 0) continue;
|
|
375
385
|
let propsName = `${HELPER_PREFIX}props`;
|
|
@@ -377,16 +387,16 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
377
387
|
if (root.params[0].type === "Identifier") propsName = root.params[0].name;
|
|
378
388
|
else if (root.params[0].type === "ObjectPattern") {
|
|
379
389
|
const lastProp = root.params[0].properties.at(-1);
|
|
380
|
-
if (!
|
|
390
|
+
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
381
391
|
else s.appendRight(root.params[0].extra?.trailingComma ? root.params[0].extra?.trailingComma + 1 : lastProp?.end || root.params[0].end - 1, `${!root.params[0].extra?.trailingComma && root.params[0].properties.length ? "," : ""} ...${HELPER_PREFIX}props`);
|
|
382
392
|
}
|
|
383
393
|
} else s.appendRight(getParamsStart(root, s.original), propsName);
|
|
384
|
-
if (
|
|
385
|
-
if (
|
|
394
|
+
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s, options.defineComponent?.autoReturnFunction);
|
|
395
|
+
if (macros.defineModel?.length) macros.defineModel.forEach(({ expression }) => {
|
|
386
396
|
transformDefineModel(expression, propsName, s);
|
|
387
397
|
});
|
|
388
|
-
if (
|
|
389
|
-
if (
|
|
398
|
+
if (macros.defineSlots) transformDefineSlots(macros.defineSlots.expression, s);
|
|
399
|
+
if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s, options.version);
|
|
390
400
|
}
|
|
391
401
|
return generateTransform(s, id);
|
|
392
402
|
}
|
|
@@ -416,10 +426,13 @@ function getRootMap(ast, s, options) {
|
|
|
416
426
|
const lang = macroExpression.callee.type === "MemberExpression" && macroExpression.callee.property.type === "Identifier" ? macroExpression.callee.property.name : "css";
|
|
417
427
|
(rootMap.get(root).defineStyle ??= []).push({
|
|
418
428
|
expression: macroExpression,
|
|
419
|
-
|
|
429
|
+
isCssModules: node.type === "VariableDeclaration",
|
|
420
430
|
lang
|
|
421
431
|
});
|
|
422
|
-
} else if (options.defineSlots.alias.includes(macroName)) rootMap.get(root).defineSlots =
|
|
432
|
+
} else if (options.defineSlots.alias.includes(macroName)) rootMap.get(root).defineSlots = {
|
|
433
|
+
expression: macroExpression,
|
|
434
|
+
id: node.type === "VariableDeclaration" ? node.declarations[0].id : void 0
|
|
435
|
+
};
|
|
423
436
|
else if (options.defineExpose.alias.includes(macroName)) rootMap.get(root).defineExpose = macroExpression;
|
|
424
437
|
}
|
|
425
438
|
},
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
require('./core-
|
|
4
|
-
require('./raw-
|
|
5
|
-
require('./options-
|
|
6
|
-
const require_src = require('./src-
|
|
3
|
+
require('./core-C740HxiF.cjs');
|
|
4
|
+
require('./raw-BXpT71mV.cjs');
|
|
5
|
+
require('./options-BSX_vMxh.cjs');
|
|
6
|
+
const require_src = require('./src-2EUAmvRo.cjs');
|
|
7
7
|
|
|
8
8
|
//#region src/esbuild.ts
|
|
9
9
|
var esbuild_default = require_src.src_default.esbuild;
|
package/dist/esbuild.d.cts
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
3
|
-
import "./options-
|
|
4
|
-
import { src_default } from "./src-
|
|
1
|
+
import "./core-CHBxRAvb.js";
|
|
2
|
+
import "./raw-Hr7QYA0U.js";
|
|
3
|
+
import "./options-BWRkHmm5.js";
|
|
4
|
+
import { src_default } from "./src-BDMVJUXS.js";
|
|
5
5
|
|
|
6
6
|
//#region src/esbuild.ts
|
|
7
7
|
var esbuild_default = src_default.esbuild;
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
4
|
-
const require_options = require('./options-
|
|
5
|
-
const require_src = require('./src-
|
|
2
|
+
require('./core-C740HxiF.cjs');
|
|
3
|
+
require('./raw-BXpT71mV.cjs');
|
|
4
|
+
const require_options = require('./options-BSX_vMxh.cjs');
|
|
5
|
+
const require_src = require('./src-2EUAmvRo.cjs');
|
|
6
6
|
|
|
7
7
|
exports.default = require_src.src_default
|
|
8
8
|
exports.resolveOptions = require_options.resolveOptions
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options, OptionsResolved, resolveOptions$1 as resolveOptions } from "./options.d-
|
|
1
|
+
import { Options, OptionsResolved, resolveOptions$1 as resolveOptions } from "./options.d-DNWXuL_g.js";
|
|
2
2
|
import { UnpluginInstance } from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
3
|
-
import { resolveOptions } from "./options-
|
|
4
|
-
import { src_default } from "./src-
|
|
1
|
+
import "./core-CHBxRAvb.js";
|
|
2
|
+
import "./raw-Hr7QYA0U.js";
|
|
3
|
+
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
4
|
+
import { src_default } from "./src-BDMVJUXS.js";
|
|
5
5
|
|
|
6
6
|
export { src_default as default, resolveOptions };
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
const require_chunk = require('./chunk-BCwAaXi7.cjs');
|
|
4
|
-
require('./core-
|
|
5
|
-
require('./raw-
|
|
6
|
-
require('./options-
|
|
7
|
-
require('./src-
|
|
8
|
-
const require_vite = require('./vite-
|
|
9
|
-
const require_webpack = require('./webpack-
|
|
4
|
+
require('./core-C740HxiF.cjs');
|
|
5
|
+
require('./raw-BXpT71mV.cjs');
|
|
6
|
+
require('./options-BSX_vMxh.cjs');
|
|
7
|
+
require('./src-2EUAmvRo.cjs');
|
|
8
|
+
const require_vite = require('./vite-DP98E6od.cjs');
|
|
9
|
+
const require_webpack = require('./webpack-qmJC3FBB.cjs');
|
|
10
10
|
const __nuxt_kit = require_chunk.__toESM(require("@nuxt/kit"));
|
|
11
11
|
require("@nuxt/schema");
|
|
12
12
|
|
package/dist/nuxt.d.cts
CHANGED
package/dist/nuxt.d.ts
CHANGED
package/dist/nuxt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
3
|
-
import "./options-
|
|
4
|
-
import "./src-
|
|
5
|
-
import { vite_default } from "./vite-
|
|
6
|
-
import { webpack_default } from "./webpack-
|
|
1
|
+
import "./core-CHBxRAvb.js";
|
|
2
|
+
import "./raw-Hr7QYA0U.js";
|
|
3
|
+
import "./options-BWRkHmm5.js";
|
|
4
|
+
import "./src-BDMVJUXS.js";
|
|
5
|
+
import { vite_default } from "./vite-CS2vynmi.js";
|
|
6
|
+
import { webpack_default } from "./webpack-C78RZrII.js";
|
|
7
7
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
8
8
|
import "@nuxt/schema";
|
|
9
9
|
|
|
@@ -10,11 +10,14 @@ function resolveOptions(options) {
|
|
|
10
10
|
exclude: [__vue_macros_common.REGEX_SETUP_SFC, __vue_macros_common.REGEX_NODE_MODULES],
|
|
11
11
|
...options,
|
|
12
12
|
version,
|
|
13
|
-
defineComponent: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
defineComponent: {
|
|
14
|
+
...options.defineComponent,
|
|
15
|
+
alias: options.defineComponent?.alias ?? ["defineComponent", "defineVaporComponent"]
|
|
16
|
+
},
|
|
17
|
+
defineModel: { alias: options.defineModel?.alias ?? ["defineModel"] },
|
|
18
|
+
defineSlots: { alias: options.defineSlots?.alias ?? ["defineSlots"] },
|
|
19
|
+
defineExpose: { alias: options.defineExpose?.alias ?? ["defineExpose"] },
|
|
20
|
+
defineStyle: { alias: options.defineStyle?.alias ?? ["defineStyle"] }
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { REGEX_NODE_MODULES, REGEX_SETUP_SFC, REGEX_SRC_FILE } from "@vue-macros/common";
|
|
2
|
+
|
|
3
|
+
//#region src/options.ts
|
|
4
|
+
function resolveOptions(options) {
|
|
5
|
+
const version = options.version || 3.6;
|
|
6
|
+
return {
|
|
7
|
+
include: [REGEX_SRC_FILE],
|
|
8
|
+
exclude: [REGEX_SETUP_SFC, REGEX_NODE_MODULES],
|
|
9
|
+
...options,
|
|
10
|
+
version,
|
|
11
|
+
defineComponent: {
|
|
12
|
+
...options.defineComponent,
|
|
13
|
+
alias: options.defineComponent?.alias ?? ["defineComponent", "defineVaporComponent"]
|
|
14
|
+
},
|
|
15
|
+
defineModel: { alias: options.defineModel?.alias ?? ["defineModel"] },
|
|
16
|
+
defineSlots: { alias: options.defineSlots?.alias ?? ["defineSlots"] },
|
|
17
|
+
defineExpose: { alias: options.defineExpose?.alias ?? ["defineExpose"] },
|
|
18
|
+
defineStyle: { alias: options.defineStyle?.alias ?? ["defineStyle"] }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { resolveOptions };
|
package/dist/options.cjs
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseOptions, MarkRequired } from "@vue-macros/common";
|
|
2
|
+
|
|
3
|
+
//#region src/options.d.ts
|
|
4
|
+
type DefineComponentOptions = {
|
|
5
|
+
alias?: string[];
|
|
6
|
+
autoReturnFunction?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type DefineModelOptions = {
|
|
9
|
+
alias?: string[];
|
|
10
|
+
};
|
|
11
|
+
type DefineExposeOptions = {
|
|
12
|
+
alias?: string[];
|
|
13
|
+
};
|
|
14
|
+
type DefineSlotsOptions = {
|
|
15
|
+
alias?: string[];
|
|
16
|
+
};
|
|
17
|
+
type DefineStyleOptions = {
|
|
18
|
+
alias?: string[];
|
|
19
|
+
};
|
|
20
|
+
type Options = BaseOptions & {
|
|
21
|
+
defineComponent?: DefineComponentOptions;
|
|
22
|
+
defineModel?: DefineModelOptions;
|
|
23
|
+
defineExpose?: DefineExposeOptions;
|
|
24
|
+
defineSlots?: DefineSlotsOptions;
|
|
25
|
+
defineStyle?: DefineStyleOptions;
|
|
26
|
+
};
|
|
27
|
+
type OptionsResolved = MarkRequired<Options, 'include' | 'version'> & {
|
|
28
|
+
defineComponent: MarkRequired<DefineComponentOptions, 'alias'>;
|
|
29
|
+
defineModel: MarkRequired<DefineModelOptions, 'alias'>;
|
|
30
|
+
defineExpose: MarkRequired<DefineExposeOptions, 'alias'>;
|
|
31
|
+
defineSlots: MarkRequired<DefineSlotsOptions, 'alias'>;
|
|
32
|
+
defineStyle: MarkRequired<DefineStyleOptions, 'alias'>;
|
|
33
|
+
};
|
|
34
|
+
declare function resolveOptions(options: Options): OptionsResolved;
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Options, OptionsResolved, resolveOptions };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseOptions, MarkRequired } from "@vue-macros/common";
|
|
2
|
+
|
|
3
|
+
//#region src/options.d.ts
|
|
4
|
+
type DefineComponentOptions = {
|
|
5
|
+
alias?: string[];
|
|
6
|
+
autoReturnFunction?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type DefineModelOptions = {
|
|
9
|
+
alias?: string[];
|
|
10
|
+
};
|
|
11
|
+
type DefineExposeOptions = {
|
|
12
|
+
alias?: string[];
|
|
13
|
+
};
|
|
14
|
+
type DefineSlotsOptions = {
|
|
15
|
+
alias?: string[];
|
|
16
|
+
};
|
|
17
|
+
type DefineStyleOptions = {
|
|
18
|
+
alias?: string[];
|
|
19
|
+
};
|
|
20
|
+
type Options = BaseOptions & {
|
|
21
|
+
defineComponent?: DefineComponentOptions;
|
|
22
|
+
defineModel?: DefineModelOptions;
|
|
23
|
+
defineExpose?: DefineExposeOptions;
|
|
24
|
+
defineSlots?: DefineSlotsOptions;
|
|
25
|
+
defineStyle?: DefineStyleOptions;
|
|
26
|
+
};
|
|
27
|
+
type OptionsResolved = MarkRequired<Options, 'include' | 'version'> & {
|
|
28
|
+
defineComponent: MarkRequired<DefineComponentOptions, 'alias'>;
|
|
29
|
+
defineModel: MarkRequired<DefineModelOptions, 'alias'>;
|
|
30
|
+
defineExpose: MarkRequired<DefineExposeOptions, 'alias'>;
|
|
31
|
+
defineSlots: MarkRequired<DefineSlotsOptions, 'alias'>;
|
|
32
|
+
defineStyle: MarkRequired<DefineStyleOptions, 'alias'>;
|
|
33
|
+
};
|
|
34
|
+
declare function resolveOptions(options: Options): OptionsResolved;
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Options, OptionsResolved, resolveOptions as resolveOptions$1 };
|