@vue-jsx-vapor/macros 3.0.4 → 3.1.1
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 +1 -1
- package/dist/api.d.ts +1 -1
- 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-BjuLGmtM.js → core-BVfDFJ0y.js} +35 -28
- package/dist/{core-DI7PhQUs.cjs → core-D-A12ijt.cjs} +93 -55
- 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 +10 -12
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +6 -6
- package/dist/{options-CQy8quq_.cjs → options-nk0sI1tl.cjs} +4 -5
- package/dist/options.cjs +1 -1
- package/dist/options.d.cts +1 -1
- package/dist/options.d.ts +1 -1
- package/dist/options.js +1 -1
- package/dist/{raw-BBO_BQmg.cjs → raw-9Uamse-H.cjs} +9 -12
- package/dist/{raw-CSj3YtCv.js → raw-P3NIxBoI.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 +3 -3
- package/dist/rolldown.d.ts +3 -3
- package/dist/rolldown.js +4 -4
- package/dist/rollup.cjs +4 -4
- package/dist/rollup.d.cts +3 -3
- package/dist/rollup.d.ts +3 -3
- 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-BhIWqP4c.js → src-DZKWkIh7.js} +1 -1
- package/dist/{src-BCG8IRsQ.cjs → src-a8io3VxL.cjs} +2 -3
- package/dist/vite.cjs +9 -6
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +8 -5
- package/dist/volar.cjs +27 -29
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +23 -23
- package/dist/webpack.cjs +9 -6
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +8 -5
- package/package.json +25 -25
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/vite-6TwpceHf.cjs +0 -12
- package/dist/vite-CofFUcrB.js +0 -7
- package/dist/webpack-CKNASzmV.js +0 -7
- package/dist/webpack-nxGFB4Vm.cjs +0 -12
- /package/dist/{options-58c0LE2P.d.ts → options-DQnbL7dH.d.ts} +0 -0
- /package/dist/{options-BuPPJCpP.d.cts → options-GMWSYHT2.d.cts} +0 -0
- /package/dist/{options-BjmC0ExR.js → options-kv1xT1jX.js} +0 -0
package/dist/api.cjs
CHANGED
package/dist/api.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as OptionsResolved } from "./options-
|
|
1
|
+
import { n as OptionsResolved } from "./options-GMWSYHT2.cjs";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
3
|
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node, VoidPattern } from "@babel/types";
|
|
4
4
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as OptionsResolved } from "./options-
|
|
1
|
+
import { n as OptionsResolved } from "./options-DQnbL7dH.js";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
3
|
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node, VoidPattern } from "@babel/types";
|
|
4
4
|
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-
|
|
1
|
+
import { i as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-BVfDFJ0y.js";
|
|
2
2
|
|
|
3
3
|
export { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/astro.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
4
|
-
require('./options-
|
|
5
|
-
const require_src = require('./src-
|
|
2
|
+
require('./core-D-A12ijt.cjs');
|
|
3
|
+
require('./raw-9Uamse-H.cjs');
|
|
4
|
+
require('./options-nk0sI1tl.cjs');
|
|
5
|
+
const require_src = require('./src-a8io3VxL.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/astro.ts
|
|
8
8
|
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 { t as src_default } from "./src-
|
|
1
|
+
import "./core-BVfDFJ0y.js";
|
|
2
|
+
import "./raw-P3NIxBoI.js";
|
|
3
|
+
import "./options-kv1xT1jX.js";
|
|
4
|
+
import { t as src_default } from "./src-DZKWkIh7.js";
|
|
5
5
|
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -6,7 +6,7 @@ var use_model_default = "import { customRef, watchSyncEffect } from \"vue\";\nco
|
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/core/helper/with-defaults.ts?raw
|
|
9
|
-
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of
|
|
9
|
+
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of /* @__PURE__ */ new Set([\n ...Object.keys(props),\n ...Object.keys(defaultProps)\n ])) {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => props[key] === void 0 ? defaultProps[key] : props[key]\n });\n }\n return result;\n}\n";
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/core/helper/index.ts
|
|
@@ -19,7 +19,7 @@ const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
|
19
19
|
function prependFunctionalNode(node, s, result) {
|
|
20
20
|
const isBlockStatement = node.body.type === "BlockStatement";
|
|
21
21
|
const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
|
|
22
|
-
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${
|
|
22
|
+
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${isBlockStatement ? "" : "return "}`);
|
|
23
23
|
if (!isBlockStatement) {
|
|
24
24
|
s.appendLeft(start, "{");
|
|
25
25
|
s.appendRight(node.end, "}");
|
|
@@ -169,7 +169,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
169
169
|
if (root.params[0]) {
|
|
170
170
|
if (root.params[0].type === "Identifier") {
|
|
171
171
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
172
|
-
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, 0, "useFullProps", void 0, "vue-jsx-vapor")}()`);
|
|
172
|
+
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, 0, "useFullProps", void 0, "/vue-jsx-vapor/props")}()`);
|
|
173
173
|
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${HELPER_PREFIX}props` : root.start === root.params[0].start ? "()" : "");
|
|
174
174
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
175
175
|
const restructuredProps = root.params[0];
|
|
@@ -265,30 +265,37 @@ function getTypeAndValue(s, node) {
|
|
|
265
265
|
let value = "";
|
|
266
266
|
let type = "";
|
|
267
267
|
let skipFactory = false;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
268
|
+
switch (node.type) {
|
|
269
|
+
case "StringLiteral":
|
|
270
|
+
type = "String";
|
|
271
|
+
value = `'${node.value}'`;
|
|
272
|
+
break;
|
|
273
|
+
case "BooleanLiteral":
|
|
274
|
+
type = "Boolean";
|
|
275
|
+
value = String(node.value);
|
|
276
|
+
break;
|
|
277
|
+
case "NumericLiteral":
|
|
278
|
+
type = "Number";
|
|
279
|
+
value = String(node.value);
|
|
280
|
+
break;
|
|
281
|
+
case "ObjectExpression":
|
|
282
|
+
type = "Object";
|
|
283
|
+
value = `() => (${s.sliceNode(node)})`;
|
|
284
|
+
break;
|
|
285
|
+
case "ArrayExpression":
|
|
286
|
+
type = "Array";
|
|
287
|
+
value = `() => (${s.sliceNode(node)})`;
|
|
288
|
+
break;
|
|
289
|
+
default: if (isFunctionalNode(node)) {
|
|
290
|
+
type = "Function";
|
|
291
|
+
value = s.sliceNode(node);
|
|
292
|
+
} else if (node.type === "Identifier") if (node.name === "undefined") value = "undefined";
|
|
293
|
+
else {
|
|
294
|
+
skipFactory = true;
|
|
295
|
+
value = s.sliceNode(node);
|
|
296
|
+
}
|
|
297
|
+
else if (node.type === "NullLiteral") value = "null";
|
|
290
298
|
}
|
|
291
|
-
else if (node.type === "NullLiteral") value = "null";
|
|
292
299
|
return {
|
|
293
300
|
value,
|
|
294
301
|
type,
|
|
@@ -300,14 +307,14 @@ function getTypeAndValue(s, node) {
|
|
|
300
307
|
//#region src/core/define-expose.ts
|
|
301
308
|
function transformDefineExpose(node, s) {
|
|
302
309
|
s.overwriteNode(node.callee, ";");
|
|
303
|
-
s.appendRight(node.arguments[0]?.start || node.end - 1, `${importHelperFn(s, 0, "getCurrentInstance", void 0, "vue-jsx-vapor")}().exposed = `);
|
|
310
|
+
s.appendRight(node.arguments[0]?.start || node.end - 1, `${importHelperFn(s, 0, "getCurrentInstance", void 0, "/vue-jsx-vapor/props")}().exposed = `);
|
|
304
311
|
}
|
|
305
312
|
|
|
306
313
|
//#endregion
|
|
307
314
|
//#region src/core/define-model.ts
|
|
308
315
|
function transformDefineModel(node, propsName, s) {
|
|
309
316
|
s.overwriteNode(node.callee, importHelperFn(s, 0, "useModel", void 0, useModelHelperId));
|
|
310
|
-
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type
|
|
317
|
+
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type === "StringLiteral" ? "" : `'modelValue',`}`);
|
|
311
318
|
}
|
|
312
319
|
|
|
313
320
|
//#endregion
|
|
@@ -1,15 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let _vue_macros_common = require("@vue-macros/common");
|
|
4
29
|
let hash_sum = require("hash-sum");
|
|
5
|
-
hash_sum =
|
|
30
|
+
hash_sum = __toESM(hash_sum);
|
|
6
31
|
|
|
7
32
|
//#region src/core/helper/use-model.ts?raw
|
|
8
33
|
var use_model_default = "import { customRef, watchSyncEffect } from \"vue\";\nconst EMPTY_OBJ = {};\nexport function useModel(props, name, options = {}) {\n const res = customRef((track, trigger) => {\n let localValue = options && options.default;\n let prevSetValue = EMPTY_OBJ;\n watchSyncEffect(() => {\n let propValue = props[name];\n if (propValue === void 0) {\n propValue = options && options.default;\n }\n if (!Object.is(localValue, propValue)) {\n localValue = propValue;\n trigger();\n }\n });\n return {\n get() {\n track();\n return options.get ? options.get(localValue) : localValue;\n },\n set(value) {\n const emittedValue = options.set ? options.set(value) : value;\n if (Object.is(emittedValue, localValue) && (prevSetValue === EMPTY_OBJ || Object.is(value, prevSetValue)))\n return;\n localValue = emittedValue;\n trigger();\n for (const emit of [props[`onUpdate:${name}`]].flat()) {\n if (typeof emit === \"function\") emit(emittedValue);\n }\n prevSetValue = value;\n }\n };\n });\n res[Symbol.iterator] = () => {\n let i = 0;\n return {\n next() {\n if (i < 2) {\n return {\n value: i++ ? props[`${name}Modifiers`] || {} : res,\n done: false\n };\n } else {\n return { done: true };\n }\n }\n };\n };\n return res;\n}\n";
|
|
9
34
|
|
|
10
35
|
//#endregion
|
|
11
36
|
//#region src/core/helper/with-defaults.ts?raw
|
|
12
|
-
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of
|
|
37
|
+
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of /* @__PURE__ */ new Set([\n ...Object.keys(props),\n ...Object.keys(defaultProps)\n ])) {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => props[key] === void 0 ? defaultProps[key] : props[key]\n });\n }\n return result;\n}\n";
|
|
13
38
|
|
|
14
39
|
//#endregion
|
|
15
40
|
//#region src/core/helper/index.ts
|
|
@@ -22,7 +47,7 @@ const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
|
22
47
|
function prependFunctionalNode(node, s, result) {
|
|
23
48
|
const isBlockStatement = node.body.type === "BlockStatement";
|
|
24
49
|
const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
|
|
25
|
-
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${
|
|
50
|
+
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${isBlockStatement ? "" : "return "}`);
|
|
26
51
|
if (!isBlockStatement) {
|
|
27
52
|
s.appendLeft(start, "{");
|
|
28
53
|
s.appendRight(node.end, "}");
|
|
@@ -46,7 +71,7 @@ function restructure(s, node, options = {}) {
|
|
|
46
71
|
let index = 0;
|
|
47
72
|
const propList = [];
|
|
48
73
|
for (const param of node.params) {
|
|
49
|
-
const path = `${
|
|
74
|
+
const path = `${_vue_macros_common.HELPER_PREFIX}props${index++ || ""}`;
|
|
50
75
|
const props = getProps(s, options, param, path);
|
|
51
76
|
if (props) {
|
|
52
77
|
s.overwrite(param.start, param.end, path);
|
|
@@ -63,9 +88,9 @@ function restructure(s, node, options = {}) {
|
|
|
63
88
|
if (!options.skipDefaultProps || paths.length !== 1) (defaultValues[paths[0]] ??= []).push(prop);
|
|
64
89
|
}
|
|
65
90
|
}
|
|
66
|
-
for (const [index$1, rest] of rests.entries()) prependFunctionalNode(node, s, options.generateRestProps?.(rest.name, index$1, rests) ?? `\nconst ${rest.name} = ${(0,
|
|
67
|
-
for (const [path, values] of Object.entries(defaultValues)) prependFunctionalNode(node, s, `\n${path} = ${(0,
|
|
68
|
-
(0,
|
|
91
|
+
for (const [index$1, rest] of rests.entries()) prependFunctionalNode(node, s, options.generateRestProps?.(rest.name, index$1, rests) ?? `\nconst ${rest.name} = ${(0, _vue_macros_common.importHelperFn)(s, 0, "createPropsRestProxy")}(${rest.path}, [${rest.value}])`);
|
|
92
|
+
for (const [path, values] of Object.entries(defaultValues)) prependFunctionalNode(node, s, `\n${path} = ${(0, _vue_macros_common.importHelperFn)(s, 0, "createPropsDefaultProxy", void 0, options.withDefaultsFrom ?? withDefaultsHelperId)}(${path}, {${values.map((i) => `'${i.path.replace(path, "")}${i.value}': ${i.defaultValue}`).join(", ")}})`);
|
|
93
|
+
(0, _vue_macros_common.walkIdentifiers)(node.body, (id, parent) => {
|
|
69
94
|
const prop = propList.find((i) => i.name === id.name);
|
|
70
95
|
if (prop && !prop.isRest) s.overwrite(id.start, id.end, `${parent?.type === "ObjectProperty" && parent.shorthand ? `${id.name}: ` : ""}${prop.path}${prop.value}`);
|
|
71
96
|
}, false);
|
|
@@ -109,7 +134,7 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
109
134
|
});
|
|
110
135
|
}
|
|
111
136
|
propNames.push(`'${prop.key.name}'`);
|
|
112
|
-
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`${
|
|
137
|
+
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`${_vue_macros_common.HELPER_PREFIX}props`)) props.push({
|
|
113
138
|
path,
|
|
114
139
|
name: prop.argument.name,
|
|
115
140
|
value: propNames.join(", "),
|
|
@@ -127,9 +152,9 @@ function transformAwait(root, s) {
|
|
|
127
152
|
let hasAwait = false;
|
|
128
153
|
for (const node of root.body.body) if (node.type === "VariableDeclaration" && !node.declare || node.type.endsWith("Statement")) {
|
|
129
154
|
const scope = [root.body.body];
|
|
130
|
-
(0,
|
|
155
|
+
(0, _vue_macros_common.walkAST)(node, {
|
|
131
156
|
enter(child, parent) {
|
|
132
|
-
if ((0,
|
|
157
|
+
if ((0, _vue_macros_common.isFunctionType)(child)) this.skip();
|
|
133
158
|
if (child.type === "BlockStatement") scope.push(child.body);
|
|
134
159
|
if (child.type === "AwaitExpression") {
|
|
135
160
|
hasAwait = true;
|
|
@@ -149,7 +174,7 @@ function processAwait(s, node, needSemi, isStatement) {
|
|
|
149
174
|
const argumentStart = node.argument.extra && node.argument.extra.parenthesized ? node.argument.extra.parenStart : node.argument.start;
|
|
150
175
|
const argumentStr = s.slice(argumentStart, node.argument.end);
|
|
151
176
|
const containsNestedAwait = /\bawait\b/.test(argumentStr);
|
|
152
|
-
s.overwrite(node.start, argumentStart, `${needSemi ? `;` : ``}(\n ([__temp,__restore] = ${(0,
|
|
177
|
+
s.overwrite(node.start, argumentStart, `${needSemi ? `;` : ``}(\n ([__temp,__restore] = ${(0, _vue_macros_common.importHelperFn)(s, 0, `withAsyncContext`)}(${containsNestedAwait ? `async ` : ``}() => `);
|
|
153
178
|
s.appendLeft(node.end, `)),\n ${isStatement ? `` : `__temp = `}await __temp,\n __restore()${isStatement ? `` : `,\n __temp`}\n)`);
|
|
154
179
|
}
|
|
155
180
|
|
|
@@ -166,14 +191,14 @@ function transformReturn(root, s) {
|
|
|
166
191
|
function transformDefineComponent(root, propsName, macros, s, autoReturnFunction = false) {
|
|
167
192
|
if (!macros.defineComponent) return;
|
|
168
193
|
const defineComponentName = s.sliceNode(macros.defineComponent.callee);
|
|
169
|
-
if (defineComponentName && !["defineComponent", "defineVaporComponent"].includes(defineComponentName)) (0,
|
|
194
|
+
if (defineComponentName && !["defineComponent", "defineVaporComponent"].includes(defineComponentName)) (0, _vue_macros_common.importHelperFn)(s, 0, "defineComponent", defineComponentName);
|
|
170
195
|
let hasRestProp = false;
|
|
171
196
|
const props = {};
|
|
172
197
|
if (root.params[0]) {
|
|
173
198
|
if (root.params[0].type === "Identifier") {
|
|
174
199
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
175
|
-
prependFunctionalNode(root, s, `const ${propsName} = ${(0,
|
|
176
|
-
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${
|
|
200
|
+
prependFunctionalNode(root, s, `const ${propsName} = ${(0, _vue_macros_common.importHelperFn)(s, 0, "useFullProps", void 0, "/vue-jsx-vapor/props")}()`);
|
|
201
|
+
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${_vue_macros_common.HELPER_PREFIX}props` : root.start === root.params[0].start ? "()" : "");
|
|
177
202
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
178
203
|
const restructuredProps = root.params[0];
|
|
179
204
|
for (const prop of restructuredProps.properties) {
|
|
@@ -185,7 +210,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
185
210
|
}
|
|
186
211
|
const defaultValue = getDefaultValue(prop.value.right);
|
|
187
212
|
let isRequired = false;
|
|
188
|
-
(0,
|
|
213
|
+
(0, _vue_macros_common.walkAST)(prop.value.right, { enter(node) {
|
|
189
214
|
if (node.type === "TSNonNullExpression") {
|
|
190
215
|
isRequired = true;
|
|
191
216
|
this.skip();
|
|
@@ -207,7 +232,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
207
232
|
generateRestProps: (restPropsName, index, list) => {
|
|
208
233
|
if (index === list.length - 1) {
|
|
209
234
|
hasRestProp = true;
|
|
210
|
-
return `const ${restPropsName} = ${(0,
|
|
235
|
+
return `const ${restPropsName} = ${(0, _vue_macros_common.importHelperFn)(s, 0, "useAttrs")}()`;
|
|
211
236
|
}
|
|
212
237
|
}
|
|
213
238
|
});
|
|
@@ -229,7 +254,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
229
254
|
}
|
|
230
255
|
function getWalkedIds(root, propsName) {
|
|
231
256
|
const walkedIds = /* @__PURE__ */ new Set();
|
|
232
|
-
(0,
|
|
257
|
+
(0, _vue_macros_common.walkIdentifiers)(root.body, (id, parent) => {
|
|
233
258
|
if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "JSXMemberExpression" || parent?.type === "OptionalMemberExpression")) {
|
|
234
259
|
const prop = parent.property.type === "Identifier" || parent.property.type === "JSXIdentifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
|
|
235
260
|
if (prop) walkedIds.add(prop);
|
|
@@ -268,30 +293,37 @@ function getTypeAndValue(s, node) {
|
|
|
268
293
|
let value = "";
|
|
269
294
|
let type = "";
|
|
270
295
|
let skipFactory = false;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
switch (node.type) {
|
|
297
|
+
case "StringLiteral":
|
|
298
|
+
type = "String";
|
|
299
|
+
value = `'${node.value}'`;
|
|
300
|
+
break;
|
|
301
|
+
case "BooleanLiteral":
|
|
302
|
+
type = "Boolean";
|
|
303
|
+
value = String(node.value);
|
|
304
|
+
break;
|
|
305
|
+
case "NumericLiteral":
|
|
306
|
+
type = "Number";
|
|
307
|
+
value = String(node.value);
|
|
308
|
+
break;
|
|
309
|
+
case "ObjectExpression":
|
|
310
|
+
type = "Object";
|
|
311
|
+
value = `() => (${s.sliceNode(node)})`;
|
|
312
|
+
break;
|
|
313
|
+
case "ArrayExpression":
|
|
314
|
+
type = "Array";
|
|
315
|
+
value = `() => (${s.sliceNode(node)})`;
|
|
316
|
+
break;
|
|
317
|
+
default: if (isFunctionalNode(node)) {
|
|
318
|
+
type = "Function";
|
|
319
|
+
value = s.sliceNode(node);
|
|
320
|
+
} else if (node.type === "Identifier") if (node.name === "undefined") value = "undefined";
|
|
321
|
+
else {
|
|
322
|
+
skipFactory = true;
|
|
323
|
+
value = s.sliceNode(node);
|
|
324
|
+
}
|
|
325
|
+
else if (node.type === "NullLiteral") value = "null";
|
|
293
326
|
}
|
|
294
|
-
else if (node.type === "NullLiteral") value = "null";
|
|
295
327
|
return {
|
|
296
328
|
value,
|
|
297
329
|
type,
|
|
@@ -303,21 +335,21 @@ function getTypeAndValue(s, node) {
|
|
|
303
335
|
//#region src/core/define-expose.ts
|
|
304
336
|
function transformDefineExpose(node, s) {
|
|
305
337
|
s.overwriteNode(node.callee, ";");
|
|
306
|
-
s.appendRight(node.arguments[0]?.start || node.end - 1, `${(0,
|
|
338
|
+
s.appendRight(node.arguments[0]?.start || node.end - 1, `${(0, _vue_macros_common.importHelperFn)(s, 0, "getCurrentInstance", void 0, "/vue-jsx-vapor/props")}().exposed = `);
|
|
307
339
|
}
|
|
308
340
|
|
|
309
341
|
//#endregion
|
|
310
342
|
//#region src/core/define-model.ts
|
|
311
343
|
function transformDefineModel(node, propsName, s) {
|
|
312
|
-
s.overwriteNode(node.callee, (0,
|
|
313
|
-
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type
|
|
344
|
+
s.overwriteNode(node.callee, (0, _vue_macros_common.importHelperFn)(s, 0, "useModel", void 0, useModelHelperId));
|
|
345
|
+
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type === "StringLiteral" ? "" : `'modelValue',`}`);
|
|
314
346
|
}
|
|
315
347
|
|
|
316
348
|
//#endregion
|
|
317
349
|
//#region src/core/define-slots.ts
|
|
318
350
|
function transformDefineSlots(node, s) {
|
|
319
351
|
s.overwrite(node.start, node.arguments[0]?.start && node.arguments[0].start - 1 || node.typeArguments?.end || node.callee.end, `Object.assign`);
|
|
320
|
-
const slots = `${(0,
|
|
352
|
+
const slots = `${(0, _vue_macros_common.importHelperFn)(s, 0, "useSlots")}()`;
|
|
321
353
|
s.appendLeft(node.end - 1, `${node.arguments[0] ? "," : "{}, "}${slots}`);
|
|
322
354
|
}
|
|
323
355
|
|
|
@@ -348,7 +380,7 @@ function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSl
|
|
|
348
380
|
}
|
|
349
381
|
if (scoped && root) {
|
|
350
382
|
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)) : [] : [];
|
|
351
|
-
(0,
|
|
383
|
+
(0, _vue_macros_common.walkAST)(root, { enter(node) {
|
|
352
384
|
if (node.type === "JSXElement" && s.sliceNode(node.openingElement.name) !== "template") {
|
|
353
385
|
let subfix = "";
|
|
354
386
|
if (slotNames.length) {
|
|
@@ -380,23 +412,23 @@ function toCssVarId(name, prefix = "") {
|
|
|
380
412
|
//#endregion
|
|
381
413
|
//#region src/core/index.ts
|
|
382
414
|
function transformJsxMacros(code, id, importMap, options) {
|
|
383
|
-
const s = new
|
|
384
|
-
const lang = (0,
|
|
415
|
+
const s = new _vue_macros_common.MagicStringAST(code);
|
|
416
|
+
const lang = (0, _vue_macros_common.getLang)(id);
|
|
385
417
|
if (lang === "dts") return;
|
|
386
|
-
const rootMap = getRootMap((0,
|
|
418
|
+
const rootMap = getRootMap((0, _vue_macros_common.babelParse)(s.original, lang), s, options);
|
|
387
419
|
let defineStyleIndex = 0;
|
|
388
420
|
for (const [root, macros] of rootMap) {
|
|
389
421
|
macros.defineStyle?.forEach((defineStyle) => {
|
|
390
422
|
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap, macros);
|
|
391
423
|
});
|
|
392
424
|
if (root === void 0) continue;
|
|
393
|
-
let propsName = `${
|
|
425
|
+
let propsName = `${_vue_macros_common.HELPER_PREFIX}props`;
|
|
394
426
|
if (root.params[0]) {
|
|
395
427
|
if (root.params[0].type === "Identifier") propsName = root.params[0].name;
|
|
396
428
|
else if (root.params[0].type === "ObjectPattern") {
|
|
397
429
|
const lastProp = root.params[0].properties.at(-1);
|
|
398
430
|
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
399
|
-
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 ? "," : ""} ...${
|
|
431
|
+
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`);
|
|
400
432
|
}
|
|
401
433
|
} else if (macros.defineModel?.length) s.appendRight(getParamsStart(root, s.original), propsName);
|
|
402
434
|
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s, options.defineComponent?.autoReturnFunction);
|
|
@@ -406,12 +438,12 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
406
438
|
if (macros.defineSlots) transformDefineSlots(macros.defineSlots.expression, s);
|
|
407
439
|
if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s);
|
|
408
440
|
}
|
|
409
|
-
return (0,
|
|
441
|
+
return (0, _vue_macros_common.generateTransform)(s, id);
|
|
410
442
|
}
|
|
411
443
|
function getRootMap(ast, s, options) {
|
|
412
444
|
const parents = [];
|
|
413
445
|
const rootMap = /* @__PURE__ */ new Map();
|
|
414
|
-
(0,
|
|
446
|
+
(0, _vue_macros_common.walkAST)(ast, {
|
|
415
447
|
enter(node, parent) {
|
|
416
448
|
parents.unshift(parent);
|
|
417
449
|
const root = isFunctionalNode(parents[1]) ? parents[1] : void 0;
|
|
@@ -465,6 +497,12 @@ function getMacroExpression(node, options) {
|
|
|
465
497
|
}
|
|
466
498
|
|
|
467
499
|
//#endregion
|
|
500
|
+
Object.defineProperty(exports, '__toESM', {
|
|
501
|
+
enumerable: true,
|
|
502
|
+
get: function () {
|
|
503
|
+
return __toESM;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
468
506
|
Object.defineProperty(exports, 'getMacroExpression', {
|
|
469
507
|
enumerable: true,
|
|
470
508
|
get: function () {
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
4
|
-
require('./options-
|
|
5
|
-
const require_src = require('./src-
|
|
2
|
+
require('./core-D-A12ijt.cjs');
|
|
3
|
+
require('./raw-9Uamse-H.cjs');
|
|
4
|
+
require('./options-nk0sI1tl.cjs');
|
|
5
|
+
const require_src = require('./src-a8io3VxL.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/esbuild.ts
|
|
8
8
|
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 { t as src_default } from "./src-
|
|
1
|
+
import "./core-BVfDFJ0y.js";
|
|
2
|
+
import "./raw-P3NIxBoI.js";
|
|
3
|
+
import "./options-kv1xT1jX.js";
|
|
4
|
+
import { t as src_default } from "./src-DZKWkIh7.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-D-A12ijt.cjs');
|
|
3
|
+
require('./raw-9Uamse-H.cjs');
|
|
4
|
+
const require_options = require('./options-nk0sI1tl.cjs');
|
|
5
|
+
const require_src = require('./src-a8io3VxL.cjs');
|
|
6
6
|
|
|
7
7
|
exports.default = require_src.src_default;
|
|
8
8
|
exports.resolveOptions = require_options.resolveOptions;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as OptionsResolved, r as resolveOptions, t as Options } from "./options-
|
|
1
|
+
import { n as OptionsResolved, r as resolveOptions, t as Options } from "./options-GMWSYHT2.cjs";
|
|
2
2
|
import { UnpluginInstance } from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
3
|
-
import { t as resolveOptions } from "./options-
|
|
4
|
-
import { t as src_default } from "./src-
|
|
1
|
+
import "./core-BVfDFJ0y.js";
|
|
2
|
+
import "./raw-P3NIxBoI.js";
|
|
3
|
+
import { t as resolveOptions } from "./options-kv1xT1jX.js";
|
|
4
|
+
import { t as src_default } from "./src-DZKWkIh7.js";
|
|
5
5
|
|
|
6
6
|
export { src_default as default, resolveOptions };
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
require('./
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
6
|
-
require('./
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
let __nuxt_kit = require("@nuxt/kit");
|
|
10
|
-
__nuxt_kit = require_chunk.__toESM(__nuxt_kit);
|
|
2
|
+
const require_core = require('./core-D-A12ijt.cjs');
|
|
3
|
+
require('./raw-9Uamse-H.cjs');
|
|
4
|
+
require('./options-nk0sI1tl.cjs');
|
|
5
|
+
require('./src-a8io3VxL.cjs');
|
|
6
|
+
const require_vite = require('./vite.cjs');
|
|
7
|
+
const require_webpack = require('./webpack.cjs');
|
|
8
|
+
let _nuxt_kit = require("@nuxt/kit");
|
|
11
9
|
require("@nuxt/schema");
|
|
12
10
|
|
|
13
11
|
//#region src/nuxt.ts
|
|
14
|
-
var nuxt_default = (0,
|
|
12
|
+
var nuxt_default = (0, _nuxt_kit.defineNuxtModule)({
|
|
15
13
|
meta: {
|
|
16
14
|
name: "nuxt-vue-jsx-vapor",
|
|
17
15
|
configKey: "unpluginStarter"
|
|
18
16
|
},
|
|
19
17
|
setup(options) {
|
|
20
|
-
(0,
|
|
21
|
-
(0,
|
|
18
|
+
(0, _nuxt_kit.addVitePlugin)(() => require_vite.default(options));
|
|
19
|
+
(0, _nuxt_kit.addWebpackPlugin)(() => require_webpack.default(options));
|
|
22
20
|
}
|
|
23
21
|
});
|
|
24
22
|
|
package/dist/nuxt.d.cts
CHANGED
package/dist/nuxt.d.ts
CHANGED