@vue-jsx-vapor/macros 2.4.2 → 2.4.4
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 +4 -6
- package/dist/api.d.ts +4 -6
- package/dist/api.js +1 -1
- package/dist/astro.cjs +3 -3
- package/dist/astro.d.cts +3 -2
- package/dist/astro.d.ts +3 -2
- package/dist/astro.js +3 -3
- package/dist/{core-BP7HnDkZ.cjs → core-BQThMqcW.cjs} +20 -210
- package/dist/{core-Bo9gAeWA.js → core-DNI6OWXg.js} +19 -209
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.d.cts +3 -4
- package/dist/esbuild.d.ts +1 -2
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +3 -3
- package/dist/nuxt.cjs +5 -5
- package/dist/nuxt.d.cts +3 -4
- package/dist/nuxt.d.ts +1 -2
- package/dist/nuxt.js +5 -5
- package/dist/{options-BxlJkUDe.d.cts → options-Egmm6BVJ.d.cts} +0 -1
- package/dist/{options-QKLCzlvG.d.ts → options-K4yleEdU.d.ts} +1 -2
- package/dist/options.d.cts +1 -1
- package/dist/options.d.ts +1 -1
- package/dist/{raw-DrrIS86r.cjs → raw-1tKjLen5.cjs} +2 -2
- package/dist/{raw-BLYamp8z.js → raw-D9bTtojC.js} +2 -2
- package/dist/raw.cjs +2 -2
- package/dist/raw.d.cts +1 -2
- package/dist/raw.d.ts +1 -2
- package/dist/raw.js +2 -2
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.d.cts +3 -4
- package/dist/rolldown.d.ts +1 -2
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +3 -4
- package/dist/rollup.d.ts +1 -2
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +1 -2
- package/dist/rspack.d.ts +1 -2
- package/dist/rspack.js +3 -3
- package/dist/{src-DyWBtz6W.js → src-Cf1P9kTp.js} +1 -1
- package/dist/{src-HPKL-RKa.cjs → src-CoejG7EN.cjs} +1 -1
- package/dist/{vite-Dh79M9Hy.cjs → vite-Bxyo1gXJ.cjs} +1 -1
- package/dist/{vite-C3qfPxM8.js → vite-DElZQ-WP.js} +1 -1
- package/dist/vite.cjs +4 -4
- package/dist/vite.d.cts +3 -4
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +4 -4
- package/dist/volar.cjs +1 -1
- package/dist/volar.d.cts +1 -2
- package/dist/volar.d.ts +1 -2
- package/dist/volar.js +1 -1
- package/dist/{webpack-D9QKBbTH.cjs → webpack-9NZmGyue.cjs} +1 -1
- package/dist/{webpack-DJtxInME.js → webpack-C9K1h8eA.js} +1 -1
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +3 -4
- package/dist/webpack.d.ts +1 -2
- package/dist/webpack.js +4 -4
- package/package.json +10 -10
package/dist/api.cjs
CHANGED
package/dist/api.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { OptionsResolved } from "./options-
|
|
1
|
+
import { OptionsResolved } from "./options-Egmm6BVJ.cjs";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
3
|
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node } from "@babel/types";
|
|
4
4
|
|
|
5
|
-
//#region src/core/
|
|
6
|
-
|
|
5
|
+
//#region src/core/utils.d.ts
|
|
7
6
|
type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
|
8
|
-
declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
|
|
7
|
+
declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
|
|
8
|
+
//#endregion
|
|
9
9
|
//#region src/core/restructure.d.ts
|
|
10
10
|
type Options = {
|
|
11
11
|
withDefaultsFrom?: string;
|
|
@@ -20,7 +20,6 @@ type Prop = {
|
|
|
20
20
|
isRest?: boolean;
|
|
21
21
|
};
|
|
22
22
|
declare function restructure(s: MagicStringAST, node: FunctionalNode, options?: Options): Prop[];
|
|
23
|
-
|
|
24
23
|
//#endregion
|
|
25
24
|
//#region src/core/index.d.ts
|
|
26
25
|
type DefineStyle = {
|
|
@@ -43,6 +42,5 @@ type Macros = {
|
|
|
43
42
|
};
|
|
44
43
|
declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): CodeTransform | undefined;
|
|
45
44
|
declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
46
|
export { DefineStyle, Macros, getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/api.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { OptionsResolved } from "./options-
|
|
1
|
+
import { OptionsResolved } from "./options-K4yleEdU.js";
|
|
2
2
|
import { CodeTransform, MagicStringAST } from "@vue-macros/common";
|
|
3
3
|
import { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, LVal, Node } from "@babel/types";
|
|
4
4
|
|
|
5
|
-
//#region src/core/
|
|
6
|
-
|
|
5
|
+
//#region src/core/utils.d.ts
|
|
7
6
|
type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
|
8
|
-
declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
|
|
7
|
+
declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
|
|
8
|
+
//#endregion
|
|
9
9
|
//#region src/core/restructure.d.ts
|
|
10
10
|
type Options = {
|
|
11
11
|
withDefaultsFrom?: string;
|
|
@@ -20,7 +20,6 @@ type Prop = {
|
|
|
20
20
|
isRest?: boolean;
|
|
21
21
|
};
|
|
22
22
|
declare function restructure(s: MagicStringAST, node: FunctionalNode, options?: Options): Prop[];
|
|
23
|
-
|
|
24
23
|
//#endregion
|
|
25
24
|
//#region src/core/index.d.ts
|
|
26
25
|
type DefineStyle = {
|
|
@@ -43,6 +42,5 @@ type Macros = {
|
|
|
43
42
|
};
|
|
44
43
|
declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): CodeTransform | undefined;
|
|
45
44
|
declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
46
|
export { DefineStyle, Macros, getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros } from "./core-
|
|
1
|
+
import { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros } from "./core-DNI6OWXg.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-
|
|
2
|
+
require('./core-BQThMqcW.cjs');
|
|
3
|
+
require('./raw-1tKjLen5.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-CoejG7EN.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/astro.ts
|
|
8
8
|
var astro_default = (options) => ({
|
package/dist/astro.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options } from "./options-
|
|
1
|
+
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/astro.d.ts
|
|
4
4
|
declare const _default: (options: Options) => {
|
|
@@ -6,5 +6,6 @@ declare const _default: (options: Options) => {
|
|
|
6
6
|
hooks: {
|
|
7
7
|
'astro:config:setup': (astro: any) => void;
|
|
8
8
|
};
|
|
9
|
-
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
10
11
|
export { _default as default };
|
package/dist/astro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options } from "./options-
|
|
1
|
+
import { Options } from "./options-K4yleEdU.js";
|
|
2
2
|
|
|
3
3
|
//#region src/astro.d.ts
|
|
4
4
|
declare const _default: (options: Options) => {
|
|
@@ -6,5 +6,6 @@ declare const _default: (options: Options) => {
|
|
|
6
6
|
hooks: {
|
|
7
7
|
'astro:config:setup': (astro: any) => void;
|
|
8
8
|
};
|
|
9
|
-
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
10
11
|
export { _default as default };
|
package/dist/astro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-DNI6OWXg.js";
|
|
2
|
+
import "./raw-D9bTtojC.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-Cf1P9kTp.js";
|
|
5
5
|
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -2,197 +2,21 @@ const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
|
2
2
|
const __vue_macros_common = require_chunk.__toESM(require("@vue-macros/common"));
|
|
3
3
|
const hash_sum = require_chunk.__toESM(require("hash-sum"));
|
|
4
4
|
|
|
5
|
-
//#region src/core/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else if (isFunctionType$1(node)) if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
21
|
-
else walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
22
|
-
else if (node.type === "BlockStatement") if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
23
|
-
else walkBlockDeclarations(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
24
|
-
else if (node.type === "CatchClause" && node.param) for (const id of extractIdentifiers(node.param)) markScopeIdentifier(node, id, knownIds);
|
|
25
|
-
else if (isForStatement(node)) walkForStatement(node, false, (id) => markScopeIdentifier(node, id, knownIds));
|
|
26
|
-
},
|
|
27
|
-
leave(node, parent) {
|
|
28
|
-
parent && parentStack.pop();
|
|
29
|
-
if (node !== rootExp && node.scopeIds) for (const id of node.scopeIds) {
|
|
30
|
-
knownIds[id]--;
|
|
31
|
-
if (knownIds[id] === 0) delete knownIds[id];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function isReferencedIdentifier(id, parent, parentStack) {
|
|
37
|
-
if (!parent) return true;
|
|
38
|
-
if (id.name === "arguments") return false;
|
|
39
|
-
if (isReferenced(id, parent)) return true;
|
|
40
|
-
switch (parent.type) {
|
|
41
|
-
case "AssignmentExpression":
|
|
42
|
-
case "AssignmentPattern": return true;
|
|
43
|
-
case "ObjectPattern":
|
|
44
|
-
case "ArrayPattern": return isInDestructureAssignment(parent, parentStack);
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
function isInDestructureAssignment(parent, parentStack) {
|
|
49
|
-
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
50
|
-
let i = parentStack.length;
|
|
51
|
-
while (i--) {
|
|
52
|
-
const p = parentStack[i];
|
|
53
|
-
if (p.type === "AssignmentExpression") return true;
|
|
54
|
-
else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
function walkFunctionParams(node, onIdent) {
|
|
60
|
-
for (const p of node.params) for (const id of extractIdentifiers(p)) onIdent(id);
|
|
61
|
-
}
|
|
62
|
-
function walkBlockDeclarations(block, onIdent) {
|
|
63
|
-
for (const stmt of block.body) if (stmt.type === "VariableDeclaration") {
|
|
64
|
-
if (stmt.declare) continue;
|
|
65
|
-
for (const decl of stmt.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
66
|
-
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
67
|
-
if (stmt.declare || !stmt.id) continue;
|
|
68
|
-
onIdent(stmt.id);
|
|
69
|
-
} else if (isForStatement(stmt)) walkForStatement(stmt, true, onIdent);
|
|
70
|
-
}
|
|
71
|
-
function isForStatement(stmt) {
|
|
72
|
-
return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
|
|
73
|
-
}
|
|
74
|
-
function walkForStatement(stmt, isVar, onIdent) {
|
|
75
|
-
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
76
|
-
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);
|
|
77
|
-
}
|
|
78
|
-
function extractIdentifiers(param, nodes = []) {
|
|
79
|
-
switch (param.type) {
|
|
80
|
-
case "Identifier":
|
|
81
|
-
nodes.push(param);
|
|
82
|
-
break;
|
|
83
|
-
case "MemberExpression": {
|
|
84
|
-
let object = param;
|
|
85
|
-
while (object.type === "MemberExpression") object = object.object;
|
|
86
|
-
nodes.push(object);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case "JSXMemberExpression": {
|
|
90
|
-
let object = param;
|
|
91
|
-
while (object.type === "JSXMemberExpression") object = object.object;
|
|
92
|
-
nodes.push(object);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "ObjectPattern":
|
|
96
|
-
for (const prop of param.properties) if (prop.type === "RestElement") extractIdentifiers(prop.argument, nodes);
|
|
97
|
-
else extractIdentifiers(prop.value, nodes);
|
|
98
|
-
break;
|
|
99
|
-
case "ArrayPattern":
|
|
100
|
-
param.elements.forEach((element) => {
|
|
101
|
-
if (element) extractIdentifiers(element, nodes);
|
|
102
|
-
});
|
|
103
|
-
break;
|
|
104
|
-
case "RestElement":
|
|
105
|
-
extractIdentifiers(param.argument, nodes);
|
|
106
|
-
break;
|
|
107
|
-
case "AssignmentPattern":
|
|
108
|
-
extractIdentifiers(param.left, nodes);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
return nodes;
|
|
112
|
-
}
|
|
113
|
-
function markKnownIds(name, knownIds) {
|
|
114
|
-
if (name in knownIds) knownIds[name]++;
|
|
115
|
-
else knownIds[name] = 1;
|
|
116
|
-
}
|
|
117
|
-
function markScopeIdentifier(node, child, knownIds) {
|
|
118
|
-
const { name } = child;
|
|
119
|
-
if (node.scopeIds && node.scopeIds.has(name)) return;
|
|
120
|
-
markKnownIds(name, knownIds);
|
|
121
|
-
(node.scopeIds || (node.scopeIds = new Set())).add(name);
|
|
122
|
-
}
|
|
123
|
-
const isFunctionType$1 = (node) => {
|
|
124
|
-
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
|
|
128
|
-
* To avoid runtime dependency on @babel/types (which includes process references)
|
|
129
|
-
* This file should not change very often in babel but we may need to keep it
|
|
130
|
-
* up-to-date from time to time.
|
|
131
|
-
*
|
|
132
|
-
* https://github.com/babel/babel/blob/main/LICENSE
|
|
133
|
-
*
|
|
134
|
-
*/
|
|
135
|
-
function isReferenced(node, parent, grandparent) {
|
|
136
|
-
switch (parent.type) {
|
|
137
|
-
case "MemberExpression":
|
|
138
|
-
case "OptionalMemberExpression":
|
|
139
|
-
if (parent.property === node) return !!parent.computed;
|
|
140
|
-
return parent.object === node;
|
|
141
|
-
case "JSXMemberExpression": return parent.object === node;
|
|
142
|
-
case "VariableDeclarator": return parent.init === node;
|
|
143
|
-
case "ArrowFunctionExpression": return parent.body === node;
|
|
144
|
-
case "PrivateName": return false;
|
|
145
|
-
case "ClassMethod":
|
|
146
|
-
case "ClassPrivateMethod":
|
|
147
|
-
case "ObjectMethod":
|
|
148
|
-
if (parent.key === node) return !!parent.computed;
|
|
149
|
-
return false;
|
|
150
|
-
case "ObjectProperty":
|
|
151
|
-
if (parent.key === node) return !!parent.computed;
|
|
152
|
-
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
153
|
-
case "ClassProperty":
|
|
154
|
-
if (parent.key === node) return !!parent.computed;
|
|
155
|
-
return true;
|
|
156
|
-
case "ClassPrivateProperty": return parent.key !== node;
|
|
157
|
-
case "ClassDeclaration":
|
|
158
|
-
case "ClassExpression": return parent.superClass === node;
|
|
159
|
-
case "AssignmentExpression": return parent.right === node;
|
|
160
|
-
case "AssignmentPattern": return parent.right === node;
|
|
161
|
-
case "LabeledStatement": return false;
|
|
162
|
-
case "CatchClause": return false;
|
|
163
|
-
case "RestElement": return false;
|
|
164
|
-
case "BreakStatement":
|
|
165
|
-
case "ContinueStatement": return false;
|
|
166
|
-
case "FunctionDeclaration":
|
|
167
|
-
case "FunctionExpression": return false;
|
|
168
|
-
case "ExportNamespaceSpecifier":
|
|
169
|
-
case "ExportDefaultSpecifier": return false;
|
|
170
|
-
case "ExportSpecifier":
|
|
171
|
-
if (grandparent?.source) return false;
|
|
172
|
-
return parent.local === node;
|
|
173
|
-
case "ImportDefaultSpecifier":
|
|
174
|
-
case "ImportNamespaceSpecifier":
|
|
175
|
-
case "ImportSpecifier": return false;
|
|
176
|
-
case "ImportAttribute": return false;
|
|
177
|
-
case "JSXAttribute": return false;
|
|
178
|
-
case "ObjectPattern":
|
|
179
|
-
case "ArrayPattern": return false;
|
|
180
|
-
case "MetaProperty": return false;
|
|
181
|
-
case "ObjectTypeProperty": return parent.key !== node;
|
|
182
|
-
case "TSEnumMember": return parent.id !== node;
|
|
183
|
-
case "TSPropertySignature":
|
|
184
|
-
if (parent.key === node) return !!parent.computed;
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
const TS_NODE_TYPES = [
|
|
190
|
-
"TSAsExpression",
|
|
191
|
-
"TSTypeAssertion",
|
|
192
|
-
"TSNonNullExpression",
|
|
193
|
-
"TSInstantiationExpression",
|
|
194
|
-
"TSSatisfiesExpression"
|
|
195
|
-
];
|
|
5
|
+
//#region src/core/helper/use-model.ts?raw
|
|
6
|
+
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
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/core/helper/with-defaults.ts?raw
|
|
10
|
+
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 [\n .../* @__PURE__ */ new Set([...Object.keys(props), ...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";
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/core/helper/index.ts
|
|
14
|
+
const helperPrefix = "vue-jsx-vapor/macros";
|
|
15
|
+
const useModelHelperId = `${helperPrefix}/use-model`;
|
|
16
|
+
const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/core/utils.ts
|
|
196
20
|
function prependFunctionalNode(node, s, result) {
|
|
197
21
|
const isBlockStatement = node.body.type === "BlockStatement";
|
|
198
22
|
const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
|
|
@@ -214,20 +38,6 @@ function getDefaultValue(node) {
|
|
|
214
38
|
return node;
|
|
215
39
|
}
|
|
216
40
|
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/core/helper/use-model.ts?raw
|
|
219
|
-
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";
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/core/helper/with-defaults.ts?raw
|
|
223
|
-
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 [\n .../* @__PURE__ */ new Set([...Object.keys(props), ...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";
|
|
224
|
-
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region src/core/helper/index.ts
|
|
227
|
-
const helperPrefix = "vue-jsx-vapor/macros";
|
|
228
|
-
const useModelHelperId = `${helperPrefix}/use-model`;
|
|
229
|
-
const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
230
|
-
|
|
231
41
|
//#endregion
|
|
232
42
|
//#region src/core/restructure.ts
|
|
233
43
|
function restructure(s, node, options = {}) {
|
|
@@ -257,7 +67,7 @@ function restructure(s, node, options = {}) {
|
|
|
257
67
|
const resolvedValues = values.map((i) => `'${i.path.replace(path, "")}${i.value}': ${i.defaultValue}`).join(", ");
|
|
258
68
|
prependFunctionalNode(node, s, `\n${path} = ${createPropsDefaultProxy}(${path}, {${resolvedValues}})`);
|
|
259
69
|
}
|
|
260
|
-
walkIdentifiers(node.body, (id, parent) => {
|
|
70
|
+
(0, __vue_macros_common.walkIdentifiers)(node.body, (id, parent) => {
|
|
261
71
|
const prop = propList.find((i) => i.name === id.name);
|
|
262
72
|
if (prop && !prop.isRest) s.overwrite(id.start, id.end, `${parent?.type === "ObjectProperty" && parent.shorthand ? `${id.name}: ` : ""}${prop.path}${prop.value}`);
|
|
263
73
|
}, false);
|
|
@@ -426,8 +236,8 @@ function prependObjectExpression(argument, name, value, s) {
|
|
|
426
236
|
return prop;
|
|
427
237
|
}
|
|
428
238
|
function getWalkedIds(root, propsName) {
|
|
429
|
-
const walkedIds = new Set();
|
|
430
|
-
walkIdentifiers(root.body, (id, parent) => {
|
|
239
|
+
const walkedIds = /* @__PURE__ */ new Set();
|
|
240
|
+
(0, __vue_macros_common.walkIdentifiers)(root.body, (id, parent) => {
|
|
431
241
|
if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "JSXMemberExpression" || parent?.type === "OptionalMemberExpression")) {
|
|
432
242
|
const prop = parent.property.type === "Identifier" || parent.property.type === "JSXIdentifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
|
|
433
243
|
if (prop) walkedIds.add(prop);
|
|
@@ -526,7 +336,7 @@ function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSl
|
|
|
526
336
|
if (expression.arguments[0]?.type !== "TemplateLiteral") return;
|
|
527
337
|
let css = s.sliceNode(expression.arguments[0]).slice(1, -1);
|
|
528
338
|
const scopeId = (0, hash_sum.default)(css);
|
|
529
|
-
const vars = new Map();
|
|
339
|
+
const vars = /* @__PURE__ */ new Map();
|
|
530
340
|
expression.arguments[0].expressions.forEach((exp) => {
|
|
531
341
|
const cssVar = s.sliceNode(exp);
|
|
532
342
|
const cssVarId = toCssVarId(cssVar, `--${scopeId}-`);
|
|
@@ -608,7 +418,7 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
608
418
|
}
|
|
609
419
|
function getRootMap(ast, s, options) {
|
|
610
420
|
const parents = [];
|
|
611
|
-
const rootMap = new Map();
|
|
421
|
+
const rootMap = /* @__PURE__ */ new Map();
|
|
612
422
|
(0, __vue_macros_common.walkAST)(ast, {
|
|
613
423
|
enter(node, parent) {
|
|
614
424
|
parents.unshift(parent);
|