@vue-jsx-vapor/macros 2.3.6 → 2.4.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 +5 -6
- package/dist/api.d.cts +28 -27
- package/dist/api.d.ts +28 -27
- package/dist/api.js +2 -2
- package/dist/astro.cjs +5 -6
- package/dist/astro.d.cts +6 -8
- package/dist/astro.d.ts +6 -8
- package/dist/astro.js +3 -3
- package/dist/{chunk-BCwAaXi7.cjs → chunk-CUT6urMc.cjs} +0 -1
- package/dist/{core-C740HxiF.cjs → core-BP7HnDkZ.cjs} +236 -44
- package/dist/{core-CHBxRAvb.js → core-Bo9gAeWA.js} +234 -35
- package/dist/esbuild.cjs +5 -6
- package/dist/esbuild.d.cts +3 -3
- package/dist/esbuild.d.ts +3 -3
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/nuxt.cjs +8 -9
- package/dist/nuxt.d.cts +4 -5
- package/dist/nuxt.d.ts +4 -5
- package/dist/nuxt.js +5 -5
- package/dist/{options-BSX_vMxh.cjs → options-BejTnOdM.cjs} +1 -2
- package/dist/options-BxlJkUDe.d.cts +37 -0
- package/dist/options-QKLCzlvG.d.ts +37 -0
- package/dist/options.cjs +2 -2
- package/dist/options.d.cts +1 -2
- package/dist/options.d.ts +1 -2
- package/dist/{raw-Hr7QYA0U.js → raw-BLYamp8z.js} +1 -1
- package/dist/{raw-BXpT71mV.cjs → raw-DrrIS86r.cjs} +3 -4
- package/dist/raw.cjs +4 -4
- package/dist/raw.d.cts +1 -1
- package/dist/raw.d.ts +1 -1
- package/dist/raw.js +2 -2
- package/dist/rolldown.cjs +5 -6
- package/dist/rolldown.d.cts +3 -2
- package/dist/rolldown.d.ts +3 -2
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +5 -6
- package/dist/rollup.d.cts +3 -3
- package/dist/rollup.d.ts +3 -3
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +5 -6
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +3 -3
- package/dist/{src-BDMVJUXS.js → src-DyWBtz6W.js} +1 -1
- package/dist/{src-2EUAmvRo.cjs → src-HPKL-RKa.cjs} +2 -3
- package/dist/{vite-CS2vynmi.js → vite-C3qfPxM8.js} +1 -1
- package/dist/{vite-DP98E6od.cjs → vite-Dh79M9Hy.cjs} +1 -2
- package/dist/vite.cjs +6 -6
- package/dist/vite.d.cts +3 -3
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +4 -4
- package/dist/volar.cjs +30 -29
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +27 -25
- package/dist/{webpack-qmJC3FBB.cjs → webpack-D9QKBbTH.cjs} +1 -2
- package/dist/{webpack-C78RZrII.js → webpack-DJtxInME.js} +1 -1
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.d.cts +3 -3
- package/dist/webpack.d.ts +3 -3
- package/dist/webpack.js +4 -4
- package/package.json +25 -69
- package/dist/options.d-CXMsJZSo.d.cts +0 -37
- package/dist/options.d-DNWXuL_g.d.ts +0 -37
|
@@ -1,7 +1,219 @@
|
|
|
1
|
-
import { HELPER_PREFIX, MagicStringAST, babelParse, generateTransform, getLang, importHelperFn, walkAST } from "@vue-macros/common";
|
|
2
|
-
import { walkIdentifiers } from "@vue/compiler-sfc";
|
|
1
|
+
import { HELPER_PREFIX, MagicStringAST, babelParse, generateTransform, getLang, importHelperFn, isFunctionType, walkAST } from "@vue-macros/common";
|
|
3
2
|
import hash from "hash-sum";
|
|
4
3
|
|
|
4
|
+
//#region src/core/babel-utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Return value indicates whether the AST walked can be a constant
|
|
7
|
+
*/
|
|
8
|
+
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = Object.create(null)) {
|
|
9
|
+
const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
|
|
10
|
+
walkAST(root, {
|
|
11
|
+
enter(node, parent) {
|
|
12
|
+
parent && parentStack.push(parent);
|
|
13
|
+
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) return this.skip();
|
|
14
|
+
if (node.type === "Identifier" || node.type === "JSXIdentifier") {
|
|
15
|
+
const isLocal = !!knownIds[node.name];
|
|
16
|
+
const isRefed = isReferencedIdentifier(node, parent, parentStack);
|
|
17
|
+
if (includeAll || isRefed && !isLocal) onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
18
|
+
} else if (node.type === "ObjectProperty" && parent?.type === "ObjectPattern") node.inPattern = true;
|
|
19
|
+
else if (isFunctionType$1(node)) if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
20
|
+
else walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
21
|
+
else if (node.type === "BlockStatement") if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
22
|
+
else walkBlockDeclarations(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
23
|
+
else if (node.type === "CatchClause" && node.param) for (const id of extractIdentifiers(node.param)) markScopeIdentifier(node, id, knownIds);
|
|
24
|
+
else if (isForStatement(node)) walkForStatement(node, false, (id) => markScopeIdentifier(node, id, knownIds));
|
|
25
|
+
},
|
|
26
|
+
leave(node, parent) {
|
|
27
|
+
parent && parentStack.pop();
|
|
28
|
+
if (node !== rootExp && node.scopeIds) for (const id of node.scopeIds) {
|
|
29
|
+
knownIds[id]--;
|
|
30
|
+
if (knownIds[id] === 0) delete knownIds[id];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function isReferencedIdentifier(id, parent, parentStack) {
|
|
36
|
+
if (!parent) return true;
|
|
37
|
+
if (id.name === "arguments") return false;
|
|
38
|
+
if (isReferenced(id, parent)) return true;
|
|
39
|
+
switch (parent.type) {
|
|
40
|
+
case "AssignmentExpression":
|
|
41
|
+
case "AssignmentPattern": return true;
|
|
42
|
+
case "ObjectPattern":
|
|
43
|
+
case "ArrayPattern": return isInDestructureAssignment(parent, parentStack);
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
function isInDestructureAssignment(parent, parentStack) {
|
|
48
|
+
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
49
|
+
let i = parentStack.length;
|
|
50
|
+
while (i--) {
|
|
51
|
+
const p = parentStack[i];
|
|
52
|
+
if (p.type === "AssignmentExpression") return true;
|
|
53
|
+
else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function walkFunctionParams(node, onIdent) {
|
|
59
|
+
for (const p of node.params) for (const id of extractIdentifiers(p)) onIdent(id);
|
|
60
|
+
}
|
|
61
|
+
function walkBlockDeclarations(block, onIdent) {
|
|
62
|
+
for (const stmt of block.body) if (stmt.type === "VariableDeclaration") {
|
|
63
|
+
if (stmt.declare) continue;
|
|
64
|
+
for (const decl of stmt.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
65
|
+
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
66
|
+
if (stmt.declare || !stmt.id) continue;
|
|
67
|
+
onIdent(stmt.id);
|
|
68
|
+
} else if (isForStatement(stmt)) walkForStatement(stmt, true, onIdent);
|
|
69
|
+
}
|
|
70
|
+
function isForStatement(stmt) {
|
|
71
|
+
return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
|
|
72
|
+
}
|
|
73
|
+
function walkForStatement(stmt, isVar, onIdent) {
|
|
74
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
75
|
+
if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) for (const decl of variable.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
76
|
+
}
|
|
77
|
+
function extractIdentifiers(param, nodes = []) {
|
|
78
|
+
switch (param.type) {
|
|
79
|
+
case "Identifier":
|
|
80
|
+
nodes.push(param);
|
|
81
|
+
break;
|
|
82
|
+
case "MemberExpression": {
|
|
83
|
+
let object = param;
|
|
84
|
+
while (object.type === "MemberExpression") object = object.object;
|
|
85
|
+
nodes.push(object);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "JSXMemberExpression": {
|
|
89
|
+
let object = param;
|
|
90
|
+
while (object.type === "JSXMemberExpression") object = object.object;
|
|
91
|
+
nodes.push(object);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "ObjectPattern":
|
|
95
|
+
for (const prop of param.properties) if (prop.type === "RestElement") extractIdentifiers(prop.argument, nodes);
|
|
96
|
+
else extractIdentifiers(prop.value, nodes);
|
|
97
|
+
break;
|
|
98
|
+
case "ArrayPattern":
|
|
99
|
+
param.elements.forEach((element) => {
|
|
100
|
+
if (element) extractIdentifiers(element, nodes);
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
case "RestElement":
|
|
104
|
+
extractIdentifiers(param.argument, nodes);
|
|
105
|
+
break;
|
|
106
|
+
case "AssignmentPattern":
|
|
107
|
+
extractIdentifiers(param.left, nodes);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return nodes;
|
|
111
|
+
}
|
|
112
|
+
function markKnownIds(name, knownIds) {
|
|
113
|
+
if (name in knownIds) knownIds[name]++;
|
|
114
|
+
else knownIds[name] = 1;
|
|
115
|
+
}
|
|
116
|
+
function markScopeIdentifier(node, child, knownIds) {
|
|
117
|
+
const { name } = child;
|
|
118
|
+
if (node.scopeIds && node.scopeIds.has(name)) return;
|
|
119
|
+
markKnownIds(name, knownIds);
|
|
120
|
+
(node.scopeIds || (node.scopeIds = new Set())).add(name);
|
|
121
|
+
}
|
|
122
|
+
const isFunctionType$1 = (node) => {
|
|
123
|
+
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
|
|
127
|
+
* To avoid runtime dependency on @babel/types (which includes process references)
|
|
128
|
+
* This file should not change very often in babel but we may need to keep it
|
|
129
|
+
* up-to-date from time to time.
|
|
130
|
+
*
|
|
131
|
+
* https://github.com/babel/babel/blob/main/LICENSE
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
function isReferenced(node, parent, grandparent) {
|
|
135
|
+
switch (parent.type) {
|
|
136
|
+
case "MemberExpression":
|
|
137
|
+
case "OptionalMemberExpression":
|
|
138
|
+
if (parent.property === node) return !!parent.computed;
|
|
139
|
+
return parent.object === node;
|
|
140
|
+
case "JSXMemberExpression": return parent.object === node;
|
|
141
|
+
case "VariableDeclarator": return parent.init === node;
|
|
142
|
+
case "ArrowFunctionExpression": return parent.body === node;
|
|
143
|
+
case "PrivateName": return false;
|
|
144
|
+
case "ClassMethod":
|
|
145
|
+
case "ClassPrivateMethod":
|
|
146
|
+
case "ObjectMethod":
|
|
147
|
+
if (parent.key === node) return !!parent.computed;
|
|
148
|
+
return false;
|
|
149
|
+
case "ObjectProperty":
|
|
150
|
+
if (parent.key === node) return !!parent.computed;
|
|
151
|
+
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
152
|
+
case "ClassProperty":
|
|
153
|
+
if (parent.key === node) return !!parent.computed;
|
|
154
|
+
return true;
|
|
155
|
+
case "ClassPrivateProperty": return parent.key !== node;
|
|
156
|
+
case "ClassDeclaration":
|
|
157
|
+
case "ClassExpression": return parent.superClass === node;
|
|
158
|
+
case "AssignmentExpression": return parent.right === node;
|
|
159
|
+
case "AssignmentPattern": return parent.right === node;
|
|
160
|
+
case "LabeledStatement": return false;
|
|
161
|
+
case "CatchClause": return false;
|
|
162
|
+
case "RestElement": return false;
|
|
163
|
+
case "BreakStatement":
|
|
164
|
+
case "ContinueStatement": return false;
|
|
165
|
+
case "FunctionDeclaration":
|
|
166
|
+
case "FunctionExpression": return false;
|
|
167
|
+
case "ExportNamespaceSpecifier":
|
|
168
|
+
case "ExportDefaultSpecifier": return false;
|
|
169
|
+
case "ExportSpecifier":
|
|
170
|
+
if (grandparent?.source) return false;
|
|
171
|
+
return parent.local === node;
|
|
172
|
+
case "ImportDefaultSpecifier":
|
|
173
|
+
case "ImportNamespaceSpecifier":
|
|
174
|
+
case "ImportSpecifier": return false;
|
|
175
|
+
case "ImportAttribute": return false;
|
|
176
|
+
case "JSXAttribute": return false;
|
|
177
|
+
case "ObjectPattern":
|
|
178
|
+
case "ArrayPattern": return false;
|
|
179
|
+
case "MetaProperty": return false;
|
|
180
|
+
case "ObjectTypeProperty": return parent.key !== node;
|
|
181
|
+
case "TSEnumMember": return parent.id !== node;
|
|
182
|
+
case "TSPropertySignature":
|
|
183
|
+
if (parent.key === node) return !!parent.computed;
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
const TS_NODE_TYPES = [
|
|
189
|
+
"TSAsExpression",
|
|
190
|
+
"TSTypeAssertion",
|
|
191
|
+
"TSNonNullExpression",
|
|
192
|
+
"TSInstantiationExpression",
|
|
193
|
+
"TSSatisfiesExpression"
|
|
194
|
+
];
|
|
195
|
+
function prependFunctionalNode(node, s, result) {
|
|
196
|
+
const isBlockStatement = node.body.type === "BlockStatement";
|
|
197
|
+
const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
|
|
198
|
+
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${!isBlockStatement ? "return " : ""}`);
|
|
199
|
+
if (!isBlockStatement) {
|
|
200
|
+
s.appendLeft(start, "{");
|
|
201
|
+
s.appendRight(node.end, "}");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function isFunctionalNode(node) {
|
|
205
|
+
return !!(node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression"));
|
|
206
|
+
}
|
|
207
|
+
function getParamsStart(node, code) {
|
|
208
|
+
return node.params[0] ? node.params[0].start : node.start + (code.slice(node.start, node.body.start).match(/\(\s*\)/)?.index || 0) + 1;
|
|
209
|
+
}
|
|
210
|
+
function getDefaultValue(node) {
|
|
211
|
+
if (node.type === "TSNonNullExpression") return getDefaultValue(node.expression);
|
|
212
|
+
if (node.type === "TSAsExpression") return getDefaultValue(node.expression);
|
|
213
|
+
return node;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
5
217
|
//#region src/core/helper/use-model.ts?raw
|
|
6
218
|
var use_model_default = "import { customRef, watchSyncEffect } from \"vue\";\nexport function useModel(props, name, options = {}) {\n const res = customRef((track, trigger) => {\n let localValue = options && options.default;\n let prevEmittedValue;\n watchSyncEffect(() => {\n const propValue = props[name];\n if (!Object.is(prevEmittedValue, 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 if (Object.is(value, localValue)) return;\n localValue = value;\n trigger();\n const emittedValue = prevEmittedValue = options.set ? options.set(value) : value;\n for (const emit of [props[`onUpdate:${name}`]].flat()) {\n if (typeof emit === \"function\") emit(emittedValue);\n }\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";
|
|
7
219
|
|
|
@@ -98,26 +310,9 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
98
310
|
});
|
|
99
311
|
return props.length ? props : void 0;
|
|
100
312
|
}
|
|
101
|
-
function getDefaultValue(node) {
|
|
102
|
-
if (node.type === "TSNonNullExpression") return getDefaultValue(node.expression);
|
|
103
|
-
if (node.type === "TSAsExpression") return getDefaultValue(node.expression);
|
|
104
|
-
return node;
|
|
105
|
-
}
|
|
106
|
-
function prependFunctionalNode(node, s, result) {
|
|
107
|
-
const isBlockStatement = node.body.type === "BlockStatement";
|
|
108
|
-
const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
|
|
109
|
-
s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${!isBlockStatement ? "return " : ""}`);
|
|
110
|
-
if (!isBlockStatement) {
|
|
111
|
-
s.appendLeft(start, "{");
|
|
112
|
-
s.appendRight(node.end, "}");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
313
|
|
|
116
314
|
//#endregion
|
|
117
315
|
//#region src/core/define-component/await.ts
|
|
118
|
-
const isFunctionType = (node) => {
|
|
119
|
-
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
120
|
-
};
|
|
121
316
|
function transformAwait(root, s) {
|
|
122
317
|
if (root.body.type !== "BlockStatement") return;
|
|
123
318
|
let hasAwait = false;
|
|
@@ -168,8 +363,11 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
168
363
|
let hasRestProp = false;
|
|
169
364
|
const props = {};
|
|
170
365
|
if (root.params[0]) {
|
|
171
|
-
if (root.params[0].type === "Identifier")
|
|
172
|
-
|
|
366
|
+
if (root.params[0].type === "Identifier") {
|
|
367
|
+
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
368
|
+
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, 0, "useFullProps", void 0, "vue-jsx-vapor")}()`);
|
|
369
|
+
s.overwrite(root.params[0].start, root.params[0].end, `${HELPER_PREFIX}props`);
|
|
370
|
+
} else if (root.params[0].type === "ObjectPattern") {
|
|
173
371
|
const restructuredProps = root.params[0];
|
|
174
372
|
for (const prop of restructuredProps.properties) {
|
|
175
373
|
if (prop.type !== "ObjectProperty" || prop.key.type !== "Identifier") continue;
|
|
@@ -209,7 +407,12 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
209
407
|
const argument = macros.defineComponent.arguments[1];
|
|
210
408
|
if (!argument) s.appendRight(root.end, `, {${hasRestProp ? "inheritAttrs: false," : ""} props: {\n${propsString}\n} }`);
|
|
211
409
|
else if (argument.type === "ObjectExpression") {
|
|
212
|
-
|
|
410
|
+
const resolvedPropsString = `{\n${propsString}\n}`;
|
|
411
|
+
const prop = prependObjectExpression(argument, "props", resolvedPropsString, s);
|
|
412
|
+
if (prop && prop.type === "ObjectProperty" && prop.value.type === "ObjectExpression") {
|
|
413
|
+
s.appendLeft(prop.value.start, `{...${resolvedPropsString}, ...`);
|
|
414
|
+
s.appendRight(prop.value.end, "}");
|
|
415
|
+
}
|
|
213
416
|
if (hasRestProp) prependObjectExpression(argument, "inheritAttrs", "false", s);
|
|
214
417
|
}
|
|
215
418
|
}
|
|
@@ -217,13 +420,15 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
217
420
|
if (autoReturnFunction) transformReturn(root, s);
|
|
218
421
|
}
|
|
219
422
|
function prependObjectExpression(argument, name, value, s) {
|
|
220
|
-
|
|
423
|
+
const prop = argument.properties?.find((prop$1) => prop$1.type === "ObjectProperty" && prop$1.key.type === "Identifier" && prop$1.key.name === name);
|
|
424
|
+
if (!prop) s.appendRight(argument.start + 1, `${name}: ${value},`);
|
|
425
|
+
return prop;
|
|
221
426
|
}
|
|
222
427
|
function getWalkedIds(root, propsName) {
|
|
223
428
|
const walkedIds = new Set();
|
|
224
429
|
walkIdentifiers(root.body, (id, parent) => {
|
|
225
|
-
if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "OptionalMemberExpression")) {
|
|
226
|
-
const prop = parent.property.type === "Identifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
|
|
430
|
+
if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "JSXMemberExpression" || parent?.type === "OptionalMemberExpression")) {
|
|
431
|
+
const prop = parent.property.type === "Identifier" || parent.property.type === "JSXIdentifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
|
|
227
432
|
if (prop) walkedIds.add(prop);
|
|
228
433
|
}
|
|
229
434
|
});
|
|
@@ -293,9 +498,9 @@ function getTypeAndValue(s, node) {
|
|
|
293
498
|
|
|
294
499
|
//#endregion
|
|
295
500
|
//#region src/core/define-expose.ts
|
|
296
|
-
function transformDefineExpose(node, s
|
|
501
|
+
function transformDefineExpose(node, s) {
|
|
297
502
|
s.overwriteNode(node.callee, ";");
|
|
298
|
-
s.appendRight(node.arguments[0]?.start || node.end - 1,
|
|
503
|
+
s.appendRight(node.arguments[0]?.start || node.end - 1, `${importHelperFn(s, 0, "getCurrentInstance", void 0, "vue-jsx-vapor/runtime")}().exposed = `);
|
|
299
504
|
}
|
|
300
505
|
|
|
301
506
|
//#endregion
|
|
@@ -396,7 +601,7 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
396
601
|
transformDefineModel(expression, propsName, s);
|
|
397
602
|
});
|
|
398
603
|
if (macros.defineSlots) transformDefineSlots(macros.defineSlots.expression, s);
|
|
399
|
-
if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s
|
|
604
|
+
if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s);
|
|
400
605
|
}
|
|
401
606
|
return generateTransform(s, id);
|
|
402
607
|
}
|
|
@@ -442,9 +647,6 @@ function getRootMap(ast, s, options) {
|
|
|
442
647
|
});
|
|
443
648
|
return rootMap;
|
|
444
649
|
}
|
|
445
|
-
function isFunctionalNode(node) {
|
|
446
|
-
return !!(node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression"));
|
|
447
|
-
}
|
|
448
650
|
function getMacroExpression(node, options) {
|
|
449
651
|
if (node.type === "TSNonNullExpression") node = node.expression;
|
|
450
652
|
if (node.type === "CallExpression") {
|
|
@@ -458,9 +660,6 @@ function getMacroExpression(node, options) {
|
|
|
458
660
|
].includes(node.callee.name)) return node;
|
|
459
661
|
}
|
|
460
662
|
}
|
|
461
|
-
function getParamsStart(node, code) {
|
|
462
|
-
return node.params[0] ? node.params[0].start : node.start + (code.slice(node.start, node.body.start).match(/\(\s*\)/)?.index || 0) + 1;
|
|
463
|
-
}
|
|
464
663
|
|
|
465
664
|
//#endregion
|
|
466
|
-
export { getMacroExpression,
|
|
665
|
+
export { getMacroExpression, helperPrefix, isFunctionalNode, restructure, transformJsxMacros, useModelHelperId, use_model_default, withDefaultsHelperId, with_defaults_default };
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
require('./core-
|
|
4
|
-
require('./raw-
|
|
5
|
-
require('./options-
|
|
6
|
-
const require_src = require('./src-
|
|
2
|
+
require('./core-BP7HnDkZ.cjs');
|
|
3
|
+
require('./raw-DrrIS86r.cjs');
|
|
4
|
+
require('./options-BejTnOdM.cjs');
|
|
5
|
+
const require_src = require('./src-HPKL-RKa.cjs');
|
|
7
6
|
|
|
8
7
|
//#region src/esbuild.ts
|
|
9
8
|
var esbuild_default = require_src.src_default.esbuild;
|
|
10
9
|
|
|
11
10
|
//#endregion
|
|
12
|
-
exports.default = esbuild_default
|
|
11
|
+
exports.default = esbuild_default;
|
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Options } from "./options
|
|
2
|
-
import
|
|
1
|
+
import { Options } from "./options-BxlJkUDe.cjs";
|
|
2
|
+
import * as esbuild1 from "esbuild";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) => Plugin;
|
|
5
|
+
declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Options } from "./options
|
|
2
|
-
import
|
|
1
|
+
import { Options } from "./options-QKLCzlvG.js";
|
|
2
|
+
import * as esbuild1 from "esbuild";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) => Plugin;
|
|
5
|
+
declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
package/dist/esbuild.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-Bo9gAeWA.js";
|
|
2
|
+
import "./raw-BLYamp8z.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-DyWBtz6W.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-BP7HnDkZ.cjs');
|
|
3
|
+
require('./raw-DrrIS86r.cjs');
|
|
4
|
+
const require_options = require('./options-BejTnOdM.cjs');
|
|
5
|
+
const require_src = require('./src-HPKL-RKa.cjs');
|
|
6
6
|
|
|
7
|
-
exports.default = require_src.src_default
|
|
8
|
-
exports.resolveOptions = require_options.resolveOptions
|
|
7
|
+
exports.default = require_src.src_default;
|
|
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
|
|
1
|
+
import { Options, OptionsResolved, resolveOptions$1 as resolveOptions } from "./options-QKLCzlvG.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-
|
|
1
|
+
import "./core-Bo9gAeWA.js";
|
|
2
|
+
import "./raw-BLYamp8z.js";
|
|
3
3
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-DyWBtz6W.js";
|
|
5
5
|
|
|
6
6
|
export { src_default as default, resolveOptions };
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const require_chunk = require('./chunk-
|
|
4
|
-
require('./core-
|
|
5
|
-
require('./raw-
|
|
6
|
-
require('./options-
|
|
7
|
-
require('./src-
|
|
8
|
-
const require_vite = require('./vite-
|
|
9
|
-
const require_webpack = require('./webpack-
|
|
2
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
|
+
require('./core-BP7HnDkZ.cjs');
|
|
4
|
+
require('./raw-DrrIS86r.cjs');
|
|
5
|
+
require('./options-BejTnOdM.cjs');
|
|
6
|
+
require('./src-HPKL-RKa.cjs');
|
|
7
|
+
const require_vite = require('./vite-Dh79M9Hy.cjs');
|
|
8
|
+
const require_webpack = require('./webpack-D9QKBbTH.cjs');
|
|
10
9
|
const __nuxt_kit = require_chunk.__toESM(require("@nuxt/kit"));
|
|
11
10
|
require("@nuxt/schema");
|
|
12
11
|
|
|
@@ -23,4 +22,4 @@ var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({
|
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
//#endregion
|
|
26
|
-
exports.default = nuxt_default
|
|
25
|
+
exports.default = nuxt_default;
|
package/dist/nuxt.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Options } from "./options
|
|
2
|
-
import
|
|
1
|
+
import { Options } from "./options-BxlJkUDe.cjs";
|
|
2
|
+
import * as _nuxt_schema14 from "@nuxt/schema";
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
|
-
interface ModuleOptions extends Options {
|
|
6
|
-
|
|
7
|
-
declare const _default: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
5
|
+
interface ModuleOptions extends Options {}
|
|
6
|
+
declare const _default: _nuxt_schema14.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
7
|
|
|
9
8
|
//#endregion
|
|
10
9
|
export { ModuleOptions, _default as default };
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Options } from "./options
|
|
2
|
-
import
|
|
1
|
+
import { Options } from "./options-QKLCzlvG.js";
|
|
2
|
+
import * as _nuxt_schema2 from "@nuxt/schema";
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
|
-
interface ModuleOptions extends Options {
|
|
6
|
-
|
|
7
|
-
declare const _default: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
5
|
+
interface ModuleOptions extends Options {}
|
|
6
|
+
declare const _default: _nuxt_schema2.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
7
|
|
|
9
8
|
//#endregion
|
|
10
9
|
export { ModuleOptions, _default as default };
|
package/dist/nuxt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-Bo9gAeWA.js";
|
|
2
|
+
import "./raw-BLYamp8z.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import "./src-
|
|
5
|
-
import { vite_default } from "./vite-
|
|
6
|
-
import { webpack_default } from "./webpack-
|
|
4
|
+
import "./src-DyWBtz6W.js";
|
|
5
|
+
import { vite_default } from "./vite-C3qfPxM8.js";
|
|
6
|
+
import { webpack_default } from "./webpack-DJtxInME.js";
|
|
7
7
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
8
8
|
import "@nuxt/schema";
|
|
9
9
|
|
|
@@ -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 };
|
package/dist/options.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const require_options = require('./options-
|
|
1
|
+
const require_options = require('./options-BejTnOdM.cjs');
|
|
2
2
|
|
|
3
|
-
exports.resolveOptions = require_options.resolveOptions
|
|
3
|
+
exports.resolveOptions = require_options.resolveOptions;
|
package/dist/options.d.cts
CHANGED
package/dist/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { helperPrefix, transformJsxMacros, useModelHelperId, use_model_default, withDefaultsHelperId, with_defaults_default } from "./core-
|
|
1
|
+
import { helperPrefix, transformJsxMacros, useModelHelperId, use_model_default, withDefaultsHelperId, with_defaults_default } from "./core-Bo9gAeWA.js";
|
|
2
2
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
3
3
|
import { createFilter, normalizePath } from "@vue-macros/common";
|
|
4
4
|
import { compileStyleAsync } from "@vue/compiler-sfc";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_options = require('./options-BSX_vMxh.cjs');
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_core = require('./core-BP7HnDkZ.cjs');
|
|
3
|
+
const require_options = require('./options-BejTnOdM.cjs');
|
|
5
4
|
const __vue_macros_common = require_chunk.__toESM(require("@vue-macros/common"));
|
|
6
5
|
const __vue_compiler_sfc = require_chunk.__toESM(require("@vue/compiler-sfc"));
|
|
7
6
|
|
package/dist/raw.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
const require_raw = require('./raw-
|
|
4
|
-
require('./options-
|
|
2
|
+
require('./core-BP7HnDkZ.cjs');
|
|
3
|
+
const require_raw = require('./raw-DrrIS86r.cjs');
|
|
4
|
+
require('./options-BejTnOdM.cjs');
|
|
5
5
|
|
|
6
|
-
exports.default = require_raw.raw_default
|
|
6
|
+
exports.default = require_raw.raw_default;
|
package/dist/raw.d.cts
CHANGED