@vue-jsx-vapor/macros 2.3.6 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/api.cjs +5 -6
  2. package/dist/api.d.cts +28 -27
  3. package/dist/api.d.ts +28 -27
  4. package/dist/api.js +2 -2
  5. package/dist/astro.cjs +5 -6
  6. package/dist/astro.d.cts +6 -8
  7. package/dist/astro.d.ts +6 -8
  8. package/dist/astro.js +3 -3
  9. package/dist/{chunk-BCwAaXi7.cjs → chunk-CUT6urMc.cjs} +0 -1
  10. package/dist/{core-C740HxiF.cjs → core-Bcy1Ov-P.cjs} +236 -44
  11. package/dist/{core-CHBxRAvb.js → core-CVDOxdBq.js} +234 -35
  12. package/dist/esbuild.cjs +5 -6
  13. package/dist/esbuild.d.cts +3 -3
  14. package/dist/esbuild.d.ts +3 -3
  15. package/dist/esbuild.js +3 -3
  16. package/dist/index.cjs +6 -6
  17. package/dist/index.d.cts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +3 -3
  20. package/dist/nuxt.cjs +8 -9
  21. package/dist/nuxt.d.cts +4 -5
  22. package/dist/nuxt.d.ts +4 -5
  23. package/dist/nuxt.js +5 -5
  24. package/dist/{options-BSX_vMxh.cjs → options-BejTnOdM.cjs} +1 -2
  25. package/dist/options-BxlJkUDe.d.cts +37 -0
  26. package/dist/options-QKLCzlvG.d.ts +37 -0
  27. package/dist/options.cjs +2 -2
  28. package/dist/options.d.cts +1 -2
  29. package/dist/options.d.ts +1 -2
  30. package/dist/{raw-Hr7QYA0U.js → raw-BYuezyBg.js} +1 -1
  31. package/dist/{raw-BXpT71mV.cjs → raw-CWSp77B1.cjs} +3 -4
  32. package/dist/raw.cjs +4 -4
  33. package/dist/raw.d.cts +1 -1
  34. package/dist/raw.d.ts +1 -1
  35. package/dist/raw.js +2 -2
  36. package/dist/rolldown.cjs +5 -6
  37. package/dist/rolldown.d.cts +3 -2
  38. package/dist/rolldown.d.ts +3 -2
  39. package/dist/rolldown.js +3 -3
  40. package/dist/rollup.cjs +5 -6
  41. package/dist/rollup.d.cts +3 -3
  42. package/dist/rollup.d.ts +3 -3
  43. package/dist/rollup.js +3 -3
  44. package/dist/rspack.cjs +5 -6
  45. package/dist/rspack.d.cts +1 -1
  46. package/dist/rspack.d.ts +1 -1
  47. package/dist/rspack.js +3 -3
  48. package/dist/{src-2EUAmvRo.cjs → src-B6eLwniY.cjs} +2 -3
  49. package/dist/{src-BDMVJUXS.js → src-CLt7j2eU.js} +1 -1
  50. package/dist/{vite-DP98E6od.cjs → vite-TO-g3dBi.cjs} +1 -2
  51. package/dist/{vite-CS2vynmi.js → vite-YbByXTNo.js} +1 -1
  52. package/dist/vite.cjs +6 -6
  53. package/dist/vite.d.cts +3 -3
  54. package/dist/vite.d.ts +3 -3
  55. package/dist/vite.js +4 -4
  56. package/dist/volar.cjs +30 -29
  57. package/dist/volar.d.cts +1 -1
  58. package/dist/volar.d.ts +1 -1
  59. package/dist/volar.js +27 -25
  60. package/dist/{webpack-C78RZrII.js → webpack-BtB3goNy.js} +1 -1
  61. package/dist/{webpack-qmJC3FBB.cjs → webpack-DoPd9jaB.cjs} +1 -2
  62. package/dist/webpack.cjs +6 -6
  63. package/dist/webpack.d.cts +3 -3
  64. package/dist/webpack.d.ts +3 -3
  65. package/dist/webpack.js +4 -4
  66. package/package.json +25 -69
  67. package/dist/options.d-CXMsJZSo.d.cts +0 -37
  68. package/dist/options.d-DNWXuL_g.d.ts +0 -37
package/dist/api.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_core = require('./core-C740HxiF.cjs');
1
+ const require_core = require('./core-Bcy1Ov-P.cjs');
2
2
 
3
- exports.getMacroExpression = require_core.getMacroExpression
4
- exports.getParamsStart = require_core.getParamsStart
5
- exports.isFunctionalNode = require_core.isFunctionalNode
6
- exports.restructure = require_core.restructure
7
- exports.transformJsxMacros = require_core.transformJsxMacros
3
+ exports.getMacroExpression = require_core.getMacroExpression;
4
+ exports.isFunctionalNode = require_core.isFunctionalNode;
5
+ exports.restructure = require_core.restructure;
6
+ exports.transformJsxMacros = require_core.transformJsxMacros;
package/dist/api.d.cts CHANGED
@@ -1,47 +1,48 @@
1
- import { OptionsResolved } from "./options.d-CXMsJZSo.cjs";
1
+ import { OptionsResolved } from "./options-BxlJkUDe.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/babel-utils.d.ts
6
+
7
+ type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
8
+ declare function isFunctionalNode(node?: Node | null): node is FunctionalNode; //#endregion
5
9
  //#region src/core/restructure.d.ts
6
10
  type Options = {
7
- withDefaultsFrom?: string;
8
- skipDefaultProps?: boolean;
9
- generateRestProps?: (restPropsName: string, index: number, list: Prop[]) => string | undefined;
11
+ withDefaultsFrom?: string;
12
+ skipDefaultProps?: boolean;
13
+ generateRestProps?: (restPropsName: string, index: number, list: Prop[]) => string | undefined;
10
14
  };
11
15
  type Prop = {
12
- path: string;
13
- name: string;
14
- value: string;
15
- defaultValue?: string;
16
- isRest?: boolean;
16
+ path: string;
17
+ name: string;
18
+ value: string;
19
+ defaultValue?: string;
20
+ isRest?: boolean;
17
21
  };
18
22
  declare function restructure(s: MagicStringAST, node: FunctionalNode, options?: Options): Prop[];
19
23
 
20
24
  //#endregion
21
25
  //#region src/core/index.d.ts
22
- type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
23
26
  type DefineStyle = {
24
- expression: CallExpression;
25
- isCssModules: boolean;
26
- lang: string;
27
+ expression: CallExpression;
28
+ isCssModules: boolean;
29
+ lang: string;
27
30
  };
28
31
  type Macros = {
29
- defineComponent?: CallExpression;
30
- defineModel?: {
31
- expression: CallExpression;
32
- isRequired: boolean;
33
- }[];
34
- defineSlots?: {
35
- expression: CallExpression;
36
- id?: LVal;
37
- };
38
- defineExpose?: CallExpression;
39
- defineStyle?: DefineStyle[];
32
+ defineComponent?: CallExpression;
33
+ defineModel?: {
34
+ expression: CallExpression;
35
+ isRequired: boolean;
36
+ }[];
37
+ defineSlots?: {
38
+ expression: CallExpression;
39
+ id?: LVal;
40
+ };
41
+ defineExpose?: CallExpression;
42
+ defineStyle?: DefineStyle[];
40
43
  };
41
44
  declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): CodeTransform | undefined;
42
- declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
43
45
  declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
44
- declare function getParamsStart(node: FunctionalNode, code: string): number;
45
46
 
46
47
  //#endregion
47
- export { DefineStyle, FunctionalNode, Macros, getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
48
+ export { DefineStyle, Macros, getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
package/dist/api.d.ts CHANGED
@@ -1,47 +1,48 @@
1
- import { OptionsResolved } from "./options.d-DNWXuL_g.js";
1
+ import { OptionsResolved } from "./options-QKLCzlvG.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/babel-utils.d.ts
6
+
7
+ type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
8
+ declare function isFunctionalNode(node?: Node | null): node is FunctionalNode; //#endregion
5
9
  //#region src/core/restructure.d.ts
6
10
  type Options = {
7
- withDefaultsFrom?: string;
8
- skipDefaultProps?: boolean;
9
- generateRestProps?: (restPropsName: string, index: number, list: Prop[]) => string | undefined;
11
+ withDefaultsFrom?: string;
12
+ skipDefaultProps?: boolean;
13
+ generateRestProps?: (restPropsName: string, index: number, list: Prop[]) => string | undefined;
10
14
  };
11
15
  type Prop = {
12
- path: string;
13
- name: string;
14
- value: string;
15
- defaultValue?: string;
16
- isRest?: boolean;
16
+ path: string;
17
+ name: string;
18
+ value: string;
19
+ defaultValue?: string;
20
+ isRest?: boolean;
17
21
  };
18
22
  declare function restructure(s: MagicStringAST, node: FunctionalNode, options?: Options): Prop[];
19
23
 
20
24
  //#endregion
21
25
  //#region src/core/index.d.ts
22
- type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
23
26
  type DefineStyle = {
24
- expression: CallExpression;
25
- isCssModules: boolean;
26
- lang: string;
27
+ expression: CallExpression;
28
+ isCssModules: boolean;
29
+ lang: string;
27
30
  };
28
31
  type Macros = {
29
- defineComponent?: CallExpression;
30
- defineModel?: {
31
- expression: CallExpression;
32
- isRequired: boolean;
33
- }[];
34
- defineSlots?: {
35
- expression: CallExpression;
36
- id?: LVal;
37
- };
38
- defineExpose?: CallExpression;
39
- defineStyle?: DefineStyle[];
32
+ defineComponent?: CallExpression;
33
+ defineModel?: {
34
+ expression: CallExpression;
35
+ isRequired: boolean;
36
+ }[];
37
+ defineSlots?: {
38
+ expression: CallExpression;
39
+ id?: LVal;
40
+ };
41
+ defineExpose?: CallExpression;
42
+ defineStyle?: DefineStyle[];
40
43
  };
41
44
  declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): CodeTransform | undefined;
42
- declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
43
45
  declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
44
- declare function getParamsStart(node: FunctionalNode, code: string): number;
45
46
 
46
47
  //#endregion
47
- export { DefineStyle, FunctionalNode, Macros, getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
48
+ export { DefineStyle, Macros, getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros } from "./core-CHBxRAvb.js";
1
+ import { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros } from "./core-CVDOxdBq.js";
2
2
 
3
- export { getMacroExpression, getParamsStart, isFunctionalNode, restructure, transformJsxMacros };
3
+ export { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
package/dist/astro.cjs CHANGED
@@ -1,9 +1,8 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, '__esModule', { value: true });
3
- require('./core-C740HxiF.cjs');
4
- require('./raw-BXpT71mV.cjs');
5
- require('./options-BSX_vMxh.cjs');
6
- const require_src = require('./src-2EUAmvRo.cjs');
2
+ require('./core-Bcy1Ov-P.cjs');
3
+ require('./raw-CWSp77B1.cjs');
4
+ require('./options-BejTnOdM.cjs');
5
+ const require_src = require('./src-B6eLwniY.cjs');
7
6
 
8
7
  //#region src/astro.ts
9
8
  var astro_default = (options) => ({
@@ -15,4 +14,4 @@ var astro_default = (options) => ({
15
14
  });
16
15
 
17
16
  //#endregion
18
- exports.default = astro_default
17
+ exports.default = astro_default;
package/dist/astro.d.cts CHANGED
@@ -1,12 +1,10 @@
1
- import { Options } from "./options.d-CXMsJZSo.cjs";
1
+ import { Options } from "./options-BxlJkUDe.cjs";
2
2
 
3
3
  //#region src/astro.d.ts
4
4
  declare const _default: (options: Options) => {
5
- name: string;
6
- hooks: {
7
- 'astro:config:setup': (astro: any) => void;
8
- };
9
- };
10
-
11
- //#endregion
5
+ name: string;
6
+ hooks: {
7
+ 'astro:config:setup': (astro: any) => void;
8
+ };
9
+ }; //#endregion
12
10
  export { _default as default };
package/dist/astro.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { Options } from "./options.d-DNWXuL_g.js";
1
+ import { Options } from "./options-QKLCzlvG.js";
2
2
 
3
3
  //#region src/astro.d.ts
4
4
  declare const _default: (options: Options) => {
5
- name: string;
6
- hooks: {
7
- 'astro:config:setup': (astro: any) => void;
8
- };
9
- };
10
-
11
- //#endregion
5
+ name: string;
6
+ hooks: {
7
+ 'astro:config:setup': (astro: any) => void;
8
+ };
9
+ }; //#endregion
12
10
  export { _default as default };
package/dist/astro.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./core-CHBxRAvb.js";
2
- import "./raw-Hr7QYA0U.js";
1
+ import "./core-CVDOxdBq.js";
2
+ import "./raw-BYuezyBg.js";
3
3
  import "./options-BWRkHmm5.js";
4
- import { src_default } from "./src-BDMVJUXS.js";
4
+ import { src_default } from "./src-CLt7j2eU.js";
5
5
 
6
6
  //#region src/astro.ts
7
7
  var astro_default = (options) => ({
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  //#region rolldown:runtime
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -1,9 +1,220 @@
1
- "use strict";
2
- const require_chunk = require('./chunk-BCwAaXi7.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
3
2
  const __vue_macros_common = require_chunk.__toESM(require("@vue-macros/common"));
4
- const __vue_compiler_sfc = require_chunk.__toESM(require("@vue/compiler-sfc"));
5
3
  const hash_sum = require_chunk.__toESM(require("hash-sum"));
6
4
 
5
+ //#region src/core/babel-utils.ts
6
+ /**
7
+ * Return value indicates whether the AST walked can be a constant
8
+ */
9
+ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = Object.create(null)) {
10
+ const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
11
+ (0, __vue_macros_common.walkAST)(root, {
12
+ enter(node, parent) {
13
+ parent && parentStack.push(parent);
14
+ if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) return this.skip();
15
+ if (node.type === "Identifier" || node.type === "JSXIdentifier") {
16
+ const isLocal = !!knownIds[node.name];
17
+ const isRefed = isReferencedIdentifier(node, parent, parentStack);
18
+ if (includeAll || isRefed && !isLocal) onIdentifier(node, parent, parentStack, isRefed, isLocal);
19
+ } else if (node.type === "ObjectProperty" && parent?.type === "ObjectPattern") node.inPattern = true;
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
+ ];
196
+ function prependFunctionalNode(node, s, result) {
197
+ const isBlockStatement = node.body.type === "BlockStatement";
198
+ const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
199
+ s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${!isBlockStatement ? "return " : ""}`);
200
+ if (!isBlockStatement) {
201
+ s.appendLeft(start, "{");
202
+ s.appendRight(node.end, "}");
203
+ }
204
+ }
205
+ function isFunctionalNode(node) {
206
+ return !!(node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression"));
207
+ }
208
+ function getParamsStart(node, code) {
209
+ return node.params[0] ? node.params[0].start : node.start + (code.slice(node.start, node.body.start).match(/\(\s*\)/)?.index || 0) + 1;
210
+ }
211
+ function getDefaultValue(node) {
212
+ if (node.type === "TSNonNullExpression") return getDefaultValue(node.expression);
213
+ if (node.type === "TSAsExpression") return getDefaultValue(node.expression);
214
+ return node;
215
+ }
216
+
217
+ //#endregion
7
218
  //#region src/core/helper/use-model.ts?raw
8
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";
9
220
 
@@ -46,7 +257,7 @@ function restructure(s, node, options = {}) {
46
257
  const resolvedValues = values.map((i) => `'${i.path.replace(path, "")}${i.value}': ${i.defaultValue}`).join(", ");
47
258
  prependFunctionalNode(node, s, `\n${path} = ${createPropsDefaultProxy}(${path}, {${resolvedValues}})`);
48
259
  }
49
- (0, __vue_compiler_sfc.walkIdentifiers)(node.body, (id, parent) => {
260
+ walkIdentifiers(node.body, (id, parent) => {
50
261
  const prop = propList.find((i) => i.name === id.name);
51
262
  if (prop && !prop.isRest) s.overwrite(id.start, id.end, `${parent?.type === "ObjectProperty" && parent.shorthand ? `${id.name}: ` : ""}${prop.path}${prop.value}`);
52
263
  }, false);
@@ -100,26 +311,9 @@ function getProps(s, options, node, path = "", props = []) {
100
311
  });
101
312
  return props.length ? props : void 0;
102
313
  }
103
- function getDefaultValue(node) {
104
- if (node.type === "TSNonNullExpression") return getDefaultValue(node.expression);
105
- if (node.type === "TSAsExpression") return getDefaultValue(node.expression);
106
- return node;
107
- }
108
- function prependFunctionalNode(node, s, result) {
109
- const isBlockStatement = node.body.type === "BlockStatement";
110
- const start = node.body.extra?.parenthesized ? node.body.extra.parenStart : node.body.start;
111
- s.appendRight(start + (isBlockStatement ? 1 : 0), `${result};${!isBlockStatement ? "return " : ""}`);
112
- if (!isBlockStatement) {
113
- s.appendLeft(start, "{");
114
- s.appendRight(node.end, "}");
115
- }
116
- }
117
314
 
118
315
  //#endregion
119
316
  //#region src/core/define-component/await.ts
120
- const isFunctionType = (node) => {
121
- return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
122
- };
123
317
  function transformAwait(root, s) {
124
318
  if (root.body.type !== "BlockStatement") return;
125
319
  let hasAwait = false;
@@ -127,7 +321,7 @@ function transformAwait(root, s) {
127
321
  const scope = [root.body.body];
128
322
  (0, __vue_macros_common.walkAST)(node, {
129
323
  enter(child, parent) {
130
- if (isFunctionType(child)) this.skip();
324
+ if ((0, __vue_macros_common.isFunctionType)(child)) this.skip();
131
325
  if (child.type === "BlockStatement") scope.push(child.body);
132
326
  if (child.type === "AwaitExpression") {
133
327
  hasAwait = true;
@@ -170,8 +364,11 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
170
364
  let hasRestProp = false;
171
365
  const props = {};
172
366
  if (root.params[0]) {
173
- if (root.params[0].type === "Identifier") getWalkedIds(root, propsName).forEach((id) => props[id] = null);
174
- else if (root.params[0].type === "ObjectPattern") {
367
+ if (root.params[0].type === "Identifier") {
368
+ getWalkedIds(root, propsName).forEach((id) => props[id] = null);
369
+ prependFunctionalNode(root, s, `const ${propsName} = ${(0, __vue_macros_common.importHelperFn)(s, 0, "useFullProps", void 0, "vue-jsx-vapor")}()`);
370
+ s.overwrite(root.params[0].start, root.params[0].end, `${__vue_macros_common.HELPER_PREFIX}props`);
371
+ } else if (root.params[0].type === "ObjectPattern") {
175
372
  const restructuredProps = root.params[0];
176
373
  for (const prop of restructuredProps.properties) {
177
374
  if (prop.type !== "ObjectProperty" || prop.key.type !== "Identifier") continue;
@@ -211,7 +408,12 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
211
408
  const argument = macros.defineComponent.arguments[1];
212
409
  if (!argument) s.appendRight(root.end, `, {${hasRestProp ? "inheritAttrs: false," : ""} props: {\n${propsString}\n} }`);
213
410
  else if (argument.type === "ObjectExpression") {
214
- prependObjectExpression(argument, "props", `{\n${propsString}\n}`, s);
411
+ const resolvedPropsString = `{\n${propsString}\n}`;
412
+ const prop = prependObjectExpression(argument, "props", resolvedPropsString, s);
413
+ if (prop && prop.type === "ObjectProperty" && prop.value.type === "ObjectExpression") {
414
+ s.appendLeft(prop.value.start, `{...${resolvedPropsString}, ...`);
415
+ s.appendRight(prop.value.end, "}");
416
+ }
215
417
  if (hasRestProp) prependObjectExpression(argument, "inheritAttrs", "false", s);
216
418
  }
217
419
  }
@@ -219,13 +421,15 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
219
421
  if (autoReturnFunction) transformReturn(root, s);
220
422
  }
221
423
  function prependObjectExpression(argument, name, value, s) {
222
- if (!argument.properties?.find((prop) => prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === name)) s.appendRight(argument.start + 1, `${name}: ${value},`);
424
+ const prop = argument.properties?.find((prop$1) => prop$1.type === "ObjectProperty" && prop$1.key.type === "Identifier" && prop$1.key.name === name);
425
+ if (!prop) s.appendRight(argument.start + 1, `${name}: ${value},`);
426
+ return prop;
223
427
  }
224
428
  function getWalkedIds(root, propsName) {
225
429
  const walkedIds = new Set();
226
- (0, __vue_compiler_sfc.walkIdentifiers)(root.body, (id, parent) => {
227
- if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "OptionalMemberExpression")) {
228
- const prop = parent.property.type === "Identifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
430
+ walkIdentifiers(root.body, (id, parent) => {
431
+ if (id.name === propsName && (parent?.type === "MemberExpression" || parent?.type === "JSXMemberExpression" || parent?.type === "OptionalMemberExpression")) {
432
+ const prop = parent.property.type === "Identifier" || parent.property.type === "JSXIdentifier" ? parent.property.name : parent.property.type === "StringLiteral" ? parent.property.value : "";
229
433
  if (prop) walkedIds.add(prop);
230
434
  }
231
435
  });
@@ -295,9 +499,9 @@ function getTypeAndValue(s, node) {
295
499
 
296
500
  //#endregion
297
501
  //#region src/core/define-expose.ts
298
- function transformDefineExpose(node, s, version) {
502
+ function transformDefineExpose(node, s) {
299
503
  s.overwriteNode(node.callee, ";");
300
- s.appendRight(node.arguments[0]?.start || node.end - 1, version >= 3.6 ? `${(0, __vue_macros_common.importHelperFn)(s, 0, "currentInstance")}.exposed = ` : `${(0, __vue_macros_common.importHelperFn)(s, 0, "getCurrentInstance")}().exposed = `);
504
+ s.appendRight(node.arguments[0]?.start || node.end - 1, `${(0, __vue_macros_common.importHelperFn)(s, 0, "getCurrentInstance", void 0, "vue-jsx-vapor")}().exposed = `);
301
505
  }
302
506
 
303
507
  //#endregion
@@ -398,7 +602,7 @@ function transformJsxMacros(code, id, importMap, options) {
398
602
  transformDefineModel(expression, propsName, s);
399
603
  });
400
604
  if (macros.defineSlots) transformDefineSlots(macros.defineSlots.expression, s);
401
- if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s, options.version);
605
+ if (macros.defineExpose) transformDefineExpose(macros.defineExpose, s);
402
606
  }
403
607
  return (0, __vue_macros_common.generateTransform)(s, id);
404
608
  }
@@ -444,9 +648,6 @@ function getRootMap(ast, s, options) {
444
648
  });
445
649
  return rootMap;
446
650
  }
447
- function isFunctionalNode(node) {
448
- return !!(node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression"));
449
- }
450
651
  function getMacroExpression(node, options) {
451
652
  if (node.type === "TSNonNullExpression") node = node.expression;
452
653
  if (node.type === "CallExpression") {
@@ -460,9 +661,6 @@ function getMacroExpression(node, options) {
460
661
  ].includes(node.callee.name)) return node;
461
662
  }
462
663
  }
463
- function getParamsStart(node, code) {
464
- return node.params[0] ? node.params[0].start : node.start + (code.slice(node.start, node.body.start).match(/\(\s*\)/)?.index || 0) + 1;
465
- }
466
664
 
467
665
  //#endregion
468
666
  Object.defineProperty(exports, 'getMacroExpression', {
@@ -471,12 +669,6 @@ Object.defineProperty(exports, 'getMacroExpression', {
471
669
  return getMacroExpression;
472
670
  }
473
671
  });
474
- Object.defineProperty(exports, 'getParamsStart', {
475
- enumerable: true,
476
- get: function () {
477
- return getParamsStart;
478
- }
479
- });
480
672
  Object.defineProperty(exports, 'helperPrefix', {
481
673
  enumerable: true,
482
674
  get: function () {