@vue-jsx-vapor/macros 2.6.1 → 2.6.3

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.
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-Egmm6BVJ.cjs";
2
- import * as esbuild1 from "esbuild";
2
+ import * as esbuild12 from "esbuild";
3
3
 
4
4
  //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
5
+ declare const _default: (options?: Options | undefined) => esbuild12.Plugin;
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/esbuild.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as esbuild1 from "esbuild";
2
+ import * as esbuild7 from "esbuild";
3
3
 
4
4
  //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
5
+ declare const _default: (options?: Options | undefined) => esbuild7.Plugin;
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/nuxt.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Options } from "./options-Egmm6BVJ.cjs";
2
- import * as _nuxt_schema2 from "@nuxt/schema";
2
+ import * as _nuxt_schema1 from "@nuxt/schema";
3
3
 
4
4
  //#region src/nuxt.d.ts
5
5
  interface ModuleOptions extends Options {}
6
- declare const _default: _nuxt_schema2.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
+ declare const _default: _nuxt_schema1.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
7
  //#endregion
8
8
  export { ModuleOptions, _default as default };
package/dist/nuxt.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as _nuxt_schema2 from "@nuxt/schema";
2
+ import * as _nuxt_schema14 from "@nuxt/schema";
3
3
 
4
4
  //#region src/nuxt.d.ts
5
5
  interface ModuleOptions extends Options {}
6
- declare const _default: _nuxt_schema2.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
+ declare const _default: _nuxt_schema14.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
7
  //#endregion
8
8
  export { ModuleOptions, _default as default };
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-Egmm6BVJ.cjs";
2
- import * as unplugin4 from "unplugin";
2
+ import * as unplugin3 from "unplugin";
3
3
 
4
4
  //#region src/rolldown.d.ts
5
- declare const _default: (options?: Options | undefined) => unplugin4.RolldownPlugin<any> | unplugin4.RolldownPlugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => unplugin3.RolldownPlugin<any> | unplugin3.RolldownPlugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as unplugin4 from "unplugin";
2
+ import * as unplugin1 from "unplugin";
3
3
 
4
4
  //#region src/rolldown.d.ts
5
- declare const _default: (options?: Options | undefined) => unplugin4.RolldownPlugin<any> | unplugin4.RolldownPlugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => unplugin1.RolldownPlugin<any> | unplugin1.RolldownPlugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/rollup.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-Egmm6BVJ.cjs";
2
- import * as rollup7 from "rollup";
2
+ import * as rollup6 from "rollup";
3
3
 
4
4
  //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => rollup7.Plugin<any> | rollup7.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => rollup6.Plugin<any> | rollup6.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as rollup7 from "rollup";
2
+ import * as rollup4 from "rollup";
3
3
 
4
4
  //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => rollup7.Plugin<any> | rollup7.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => rollup4.Plugin<any> | rollup4.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/vite.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-Egmm6BVJ.cjs";
2
- import * as vite11 from "vite";
2
+ import * as vite9 from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
5
- declare const _default: (options?: Options | undefined) => vite11.Plugin<any> | vite11.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => vite9.Plugin<any> | vite9.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as vite11 from "vite";
2
+ import * as vite12 from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
5
- declare const _default: (options?: Options | undefined) => vite11.Plugin<any> | vite11.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => vite12.Plugin<any> | vite12.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/volar.cjs CHANGED
@@ -14,28 +14,23 @@ function transformDefineComponent(node, parent, options) {
14
14
  const __setup = `);
15
15
  const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
16
16
  `
17
- type __Props = Parameters<typeof __setup>[0]
18
- type __Slots = Parameters<typeof __setup>[1] extends { slots?: infer Slots } | undefined ? Slots : {}
19
- type __Exposed = Parameters<typeof __setup>[1] extends { expose?: (exposed: infer Exposed) => any } | undefined ? Exposed : {}`,
17
+ type __Setup = typeof __setup
18
+ type __Props = Parameters<__Setup>[0]
19
+ type __Slots = Parameters<__Setup>[1] extends { slots?: infer Slots } | undefined ? Slots : {}
20
+ type __Exposed = Parameters<__Setup>[1] extends { expose?: (exposed: infer Exposed) => any } | undefined ? Exposed : {}`,
20
21
  "\n const __component = ",
22
+ isVapor ? `// @ts-ignore\n(defineVaporComponent,await import('vue-jsx-vapor')).` : "",
21
23
  [node.expression.getText(ast), node.expression.getStart(ast)],
22
- `({`,
23
- isVapor ? "" : `...{} as {
24
- setup: () => __Exposed,
25
- slots: import('vue').SlotsType<__Slots>
24
+ `({\n`,
25
+ `...{} as {
26
+ setup: (props: __Props) => __Exposed,
27
+ render: () => ReturnType<__Setup>
28
+ slots: ${isVapor ? "__Slots" : `import('vue').SlotsType<__Slots>`}
26
29
  },`,
27
30
  ...compOptions ? ["...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
28
31
  `})
29
- type __Instance = {${isVapor ? "\n/** @deprecated This is only a type when used in Vapor Instances. */" : ""}
30
- $props: __Props
31
- } & (typeof __component extends new (...args: any) => any ? InstanceType<typeof __component> : typeof __component)
32
- return {} as {
33
- new (props: __Props): __Instance,
34
- setup: (props: __Props, ctx?: {
35
- attrs?: Record<string, any>
36
- slots?: __Slots,
37
- expose?: (exposed: keyof __Exposed extends never ? __Instance : __Exposed) => any
38
- }) => {},
32
+ return {} as Omit<typeof __component, 'constructor'> & {
33
+ new (props?: __Props): InstanceType<typeof __component> & {${isVapor ? "\n/** @deprecated This is only a type when used in Vapor Instances. */\n$props: __Props" : ""}},
39
34
  }`
40
35
  ];
41
36
  codes.replaceRange(node.end, node.end, ...result, `\n})()`);
@@ -131,14 +126,18 @@ function transformJsxMacros(rootMap, options) {
131
126
  });
132
127
  props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
133
128
  }
134
- codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const __render`, macros.defineComponent ? macros.defineComponent?.expression.getText(ast) === "defineVaporComponent" ? ": import(\"vue-jsx-vapor\").NodeChild" : ": () => import(\"vue\").VNodeChild" : "", ` = `);
129
+ codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), "const ", [
130
+ `__render`,
131
+ node.getStart(ast) - 1,
132
+ { verification: true }
133
+ ], macros.defineComponent ? macros.defineComponent?.expression.getText(ast) === "defineVaporComponent" ? "" : ": () => JSX.Element" : "", " = ");
135
134
  codes.replaceRange(node.expression.end, node.expression.end, `
136
135
  return {} as {
137
136
  props: {${props.join(", ")}},
138
- context: {
139
- slots?: ${macros.defineSlots ?? "{}"},
140
- expose?: (exposed: import('vue').ShallowUnwrapRef<${macros.defineExpose ?? "{}"}>) => void,
141
- attrs?: Record<string, any>
137
+ context: ${root.parameters[1]?.type ? root.parameters[1].type.getText(ast) : "{}"} & {
138
+ slots: ${macros.defineSlots ?? "{}"},
139
+ expose: (exposed: ${macros.defineExpose ?? "{}"}) => void,
140
+ attrs: Record<string, any>
142
141
  },
143
142
  render: typeof __render
144
143
  }`);
@@ -181,6 +180,7 @@ function getMacro(node, ts, options) {
181
180
  const expression = getMacroExpression(initializer);
182
181
  if (expression) return {
183
182
  expression,
183
+ variableDeclaration: decl,
184
184
  initializer: decl.initializer,
185
185
  isRequired: ts.isNonNullExpression(initializer)
186
186
  };
@@ -220,7 +220,7 @@ function getRootMap(options) {
220
220
  }
221
221
  const macro = getMacro(node, ts, options);
222
222
  if (macro) {
223
- const { expression, initializer } = macro;
223
+ const { expression, initializer, variableDeclaration } = macro;
224
224
  let isRequired = macro.isRequired;
225
225
  if (!rootMap.has(root)) rootMap.set(root, {});
226
226
  const macroName = expression.expression.getText(ast);
@@ -248,12 +248,12 @@ function getRootMap(options) {
248
248
  const defineModel = rootMap.get(root).defineModel ??= [];
249
249
  defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
250
250
  if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${(0, ts_macro.getText)(expression.typeArguments[1], ast, ts)}, boolean>>`);
251
- codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
251
+ codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), variableDeclaration ? `// @ts-ignore\n${id};\n` : "", `let ${id} = `);
252
252
  } else if (options.defineSlots.alias.includes(macroName)) {
253
- codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__slots;\nconst __slots = `);
253
+ codes.replaceRange(expression.getStart(ast), expression.getStart(ast), variableDeclaration ? "// @ts-ignore\n__slots;\n" : "", `const __slots = `);
254
254
  rootMap.get(root).defineSlots = `Partial<typeof __slots>`;
255
255
  } else if (options.defineExpose.alias.includes(macroName)) {
256
- codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__exposed;\nconst __exposed = `);
256
+ codes.replaceRange(expression.getStart(ast), expression.getStart(ast), variableDeclaration ? "// @ts-ignore\n__exposed;\n" : "", `const __exposed = `);
257
257
  rootMap.get(root).defineExpose = `typeof __exposed`;
258
258
  }
259
259
  }
package/dist/volar.js CHANGED
@@ -12,28 +12,23 @@ function transformDefineComponent(node, parent, options) {
12
12
  const __setup = `);
13
13
  const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
14
14
  `
15
- type __Props = Parameters<typeof __setup>[0]
16
- type __Slots = Parameters<typeof __setup>[1] extends { slots?: infer Slots } | undefined ? Slots : {}
17
- type __Exposed = Parameters<typeof __setup>[1] extends { expose?: (exposed: infer Exposed) => any } | undefined ? Exposed : {}`,
15
+ type __Setup = typeof __setup
16
+ type __Props = Parameters<__Setup>[0]
17
+ type __Slots = Parameters<__Setup>[1] extends { slots?: infer Slots } | undefined ? Slots : {}
18
+ type __Exposed = Parameters<__Setup>[1] extends { expose?: (exposed: infer Exposed) => any } | undefined ? Exposed : {}`,
18
19
  "\n const __component = ",
20
+ isVapor ? `// @ts-ignore\n(defineVaporComponent,await import('vue-jsx-vapor')).` : "",
19
21
  [node.expression.getText(ast), node.expression.getStart(ast)],
20
- `({`,
21
- isVapor ? "" : `...{} as {
22
- setup: () => __Exposed,
23
- slots: import('vue').SlotsType<__Slots>
22
+ `({\n`,
23
+ `...{} as {
24
+ setup: (props: __Props) => __Exposed,
25
+ render: () => ReturnType<__Setup>
26
+ slots: ${isVapor ? "__Slots" : `import('vue').SlotsType<__Slots>`}
24
27
  },`,
25
28
  ...compOptions ? ["...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
26
29
  `})
27
- type __Instance = {${isVapor ? "\n/** @deprecated This is only a type when used in Vapor Instances. */" : ""}
28
- $props: __Props
29
- } & (typeof __component extends new (...args: any) => any ? InstanceType<typeof __component> : typeof __component)
30
- return {} as {
31
- new (props: __Props): __Instance,
32
- setup: (props: __Props, ctx?: {
33
- attrs?: Record<string, any>
34
- slots?: __Slots,
35
- expose?: (exposed: keyof __Exposed extends never ? __Instance : __Exposed) => any
36
- }) => {},
30
+ return {} as Omit<typeof __component, 'constructor'> & {
31
+ new (props?: __Props): InstanceType<typeof __component> & {${isVapor ? "\n/** @deprecated This is only a type when used in Vapor Instances. */\n$props: __Props" : ""}},
37
32
  }`
38
33
  ];
39
34
  codes.replaceRange(node.end, node.end, ...result, `\n})()`);
@@ -129,14 +124,18 @@ function transformJsxMacros(rootMap, options) {
129
124
  });
130
125
  props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
131
126
  }
132
- codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const __render`, macros.defineComponent ? macros.defineComponent?.expression.getText(ast) === "defineVaporComponent" ? ": import(\"vue-jsx-vapor\").NodeChild" : ": () => import(\"vue\").VNodeChild" : "", ` = `);
127
+ codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), "const ", [
128
+ `__render`,
129
+ node.getStart(ast) - 1,
130
+ { verification: true }
131
+ ], macros.defineComponent ? macros.defineComponent?.expression.getText(ast) === "defineVaporComponent" ? "" : ": () => JSX.Element" : "", " = ");
133
132
  codes.replaceRange(node.expression.end, node.expression.end, `
134
133
  return {} as {
135
134
  props: {${props.join(", ")}},
136
- context: {
137
- slots?: ${macros.defineSlots ?? "{}"},
138
- expose?: (exposed: import('vue').ShallowUnwrapRef<${macros.defineExpose ?? "{}"}>) => void,
139
- attrs?: Record<string, any>
135
+ context: ${root.parameters[1]?.type ? root.parameters[1].type.getText(ast) : "{}"} & {
136
+ slots: ${macros.defineSlots ?? "{}"},
137
+ expose: (exposed: ${macros.defineExpose ?? "{}"}) => void,
138
+ attrs: Record<string, any>
140
139
  },
141
140
  render: typeof __render
142
141
  }`);
@@ -179,6 +178,7 @@ function getMacro(node, ts, options) {
179
178
  const expression = getMacroExpression(initializer);
180
179
  if (expression) return {
181
180
  expression,
181
+ variableDeclaration: decl,
182
182
  initializer: decl.initializer,
183
183
  isRequired: ts.isNonNullExpression(initializer)
184
184
  };
@@ -218,7 +218,7 @@ function getRootMap(options) {
218
218
  }
219
219
  const macro = getMacro(node, ts, options);
220
220
  if (macro) {
221
- const { expression, initializer } = macro;
221
+ const { expression, initializer, variableDeclaration } = macro;
222
222
  let isRequired = macro.isRequired;
223
223
  if (!rootMap.has(root)) rootMap.set(root, {});
224
224
  const macroName = expression.expression.getText(ast);
@@ -246,12 +246,12 @@ function getRootMap(options) {
246
246
  const defineModel = rootMap.get(root).defineModel ??= [];
247
247
  defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
248
248
  if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${getText(expression.typeArguments[1], ast, ts)}, boolean>>`);
249
- codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
249
+ codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), variableDeclaration ? `// @ts-ignore\n${id};\n` : "", `let ${id} = `);
250
250
  } else if (options.defineSlots.alias.includes(macroName)) {
251
- codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__slots;\nconst __slots = `);
251
+ codes.replaceRange(expression.getStart(ast), expression.getStart(ast), variableDeclaration ? "// @ts-ignore\n__slots;\n" : "", `const __slots = `);
252
252
  rootMap.get(root).defineSlots = `Partial<typeof __slots>`;
253
253
  } else if (options.defineExpose.alias.includes(macroName)) {
254
- codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__exposed;\nconst __exposed = `);
254
+ codes.replaceRange(expression.getStart(ast), expression.getStart(ast), variableDeclaration ? "// @ts-ignore\n__exposed;\n" : "", `const __exposed = `);
255
255
  rootMap.get(root).defineExpose = `typeof __exposed`;
256
256
  }
257
257
  }
package/dist/webpack.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-K4yleEdU.js";
2
- import * as webpack14 from "webpack";
2
+ import * as webpack10 from "webpack";
3
3
 
4
4
  //#region src/webpack.d.ts
5
- declare const _default: (options?: Options | undefined) => webpack14.WebpackPluginInstance;
5
+ declare const _default: (options?: Options | undefined) => webpack10.WebpackPluginInstance;
6
6
  //#endregion
7
7
  export { _default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/macros",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Macros for Vue JSX Vapor",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -131,18 +131,18 @@
131
131
  }
132
132
  },
133
133
  "dependencies": {
134
- "@vue-macros/common": "^3.0.0-beta.20",
134
+ "@vue-macros/common": "^3.0.0-beta.23",
135
135
  "@vue/compiler-sfc": "3.6.0-alpha.2",
136
136
  "hash-sum": "^2.0.0",
137
- "ts-macro": "^0.3.2",
138
- "unplugin": "^2.3.5"
137
+ "ts-macro": "^0.3.4",
138
+ "unplugin": "^2.3.10"
139
139
  },
140
140
  "devDependencies": {
141
- "@babel/types": "^7.28.0",
142
- "@nuxt/kit": "^3.18.1",
143
- "@nuxt/schema": "^3.18.1",
141
+ "@babel/types": "^7.28.4",
142
+ "@nuxt/kit": "^3.19.1",
143
+ "@nuxt/schema": "^3.19.1",
144
144
  "@types/hash-sum": "^1.0.2",
145
- "@vue-macros/test-utils": "^3.0.0-beta.20",
145
+ "@vue-macros/test-utils": "^3.0.0-beta.23",
146
146
  "vue": "3.6.0-alpha.2"
147
147
  },
148
148
  "scripts": {