@vue-jsx-vapor/macros 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -1
- package/dist/api.js +1 -1
- package/dist/astro.cjs +3 -3
- package/dist/astro.js +3 -3
- package/dist/{core-BnOBUOXo.cjs → core-BGMj1zaw.cjs} +6 -15
- package/dist/{core-CzkzlWGo.js → core-u2ydd_-y.js} +6 -15
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/nuxt.cjs +5 -5
- package/dist/nuxt.js +5 -5
- package/dist/{raw-Cs8E-0N5.js → raw-Dprh1tIQ.js} +1 -1
- package/dist/{raw-DKCRm2ff.cjs → raw-V1VJGrnC.cjs} +1 -1
- package/dist/raw.cjs +2 -2
- package/dist/raw.js +2 -2
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.js +3 -3
- package/dist/{src-BMmuQ4rG.js → src-9_QEflZu.js} +1 -1
- package/dist/{src-DJK4pxUR.cjs → src-Zbpeaztk.cjs} +1 -1
- package/dist/{vite-DRkDbCPE.cjs → vite-BX_gYdbF.cjs} +1 -1
- package/dist/{vite-DbwHYLPn.js → vite-DMiSdzmA.js} +1 -1
- package/dist/vite.cjs +4 -4
- package/dist/vite.js +4 -4
- package/dist/volar.cjs +30 -16
- package/dist/volar.js +30 -16
- package/dist/{webpack-CsAn2U-j.cjs → webpack-337kgHM4.cjs} +1 -1
- package/dist/{webpack-WGax0jDH.js → webpack-BijR4yVK.js} +1 -1
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.js +4 -4
- package/package.json +6 -6
package/dist/api.cjs
CHANGED
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-u2ydd_-y.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-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/astro.ts
|
|
8
8
|
var astro_default = (options) => ({
|
package/dist/astro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.js";
|
|
5
5
|
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -221,26 +221,17 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
221
221
|
transformDefineModel$1(s, macros.defineModel, props);
|
|
222
222
|
const propsString = Object.entries(props).map(([key, value]) => `'${key}': ${value}`).join(", \n");
|
|
223
223
|
if (propsString) {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
s.appendLeft(prop.value.start, `{...${resolvedPropsString}, ...`);
|
|
231
|
-
s.appendRight(prop.value.end, "}");
|
|
232
|
-
}
|
|
233
|
-
if (hasRestProp) prependObjectExpression(argument, "inheritAttrs", "false", s);
|
|
224
|
+
const resolvedPropsString = `${hasRestProp ? "inheritAttrs: false, " : ""}props: {\n${propsString}\n}`;
|
|
225
|
+
const compOptions = macros.defineComponent.arguments[1];
|
|
226
|
+
if (!compOptions) s.appendRight(root.end, `, { ${resolvedPropsString} }`);
|
|
227
|
+
else if (compOptions.type === "ObjectExpression") {
|
|
228
|
+
s.appendLeft(compOptions.start, `{ ${resolvedPropsString}, ...`);
|
|
229
|
+
s.appendRight(compOptions.end, " }");
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
transformAwait(root, s);
|
|
237
233
|
if (autoReturnFunction) transformReturn(root, s);
|
|
238
234
|
}
|
|
239
|
-
function prependObjectExpression(argument, name, value, s) {
|
|
240
|
-
const prop = argument.properties?.find((prop$1) => prop$1.type === "ObjectProperty" && prop$1.key.type === "Identifier" && prop$1.key.name === name);
|
|
241
|
-
if (!prop) s.appendRight(argument.start + 1, `${name}: ${value},`);
|
|
242
|
-
return prop;
|
|
243
|
-
}
|
|
244
235
|
function getWalkedIds(root, propsName) {
|
|
245
236
|
const walkedIds = /* @__PURE__ */ new Set();
|
|
246
237
|
(0, __vue_macros_common.walkIdentifiers)(root.body, (id, parent) => {
|
|
@@ -220,26 +220,17 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
220
220
|
transformDefineModel$1(s, macros.defineModel, props);
|
|
221
221
|
const propsString = Object.entries(props).map(([key, value]) => `'${key}': ${value}`).join(", \n");
|
|
222
222
|
if (propsString) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
s.appendLeft(prop.value.start, `{...${resolvedPropsString}, ...`);
|
|
230
|
-
s.appendRight(prop.value.end, "}");
|
|
231
|
-
}
|
|
232
|
-
if (hasRestProp) prependObjectExpression(argument, "inheritAttrs", "false", s);
|
|
223
|
+
const resolvedPropsString = `${hasRestProp ? "inheritAttrs: false, " : ""}props: {\n${propsString}\n}`;
|
|
224
|
+
const compOptions = macros.defineComponent.arguments[1];
|
|
225
|
+
if (!compOptions) s.appendRight(root.end, `, { ${resolvedPropsString} }`);
|
|
226
|
+
else if (compOptions.type === "ObjectExpression") {
|
|
227
|
+
s.appendLeft(compOptions.start, `{ ${resolvedPropsString}, ...`);
|
|
228
|
+
s.appendRight(compOptions.end, " }");
|
|
233
229
|
}
|
|
234
230
|
}
|
|
235
231
|
transformAwait(root, s);
|
|
236
232
|
if (autoReturnFunction) transformReturn(root, s);
|
|
237
233
|
}
|
|
238
|
-
function prependObjectExpression(argument, name, value, s) {
|
|
239
|
-
const prop = argument.properties?.find((prop$1) => prop$1.type === "ObjectProperty" && prop$1.key.type === "Identifier" && prop$1.key.name === name);
|
|
240
|
-
if (!prop) s.appendRight(argument.start + 1, `${name}: ${value},`);
|
|
241
|
-
return prop;
|
|
242
|
-
}
|
|
243
234
|
function getWalkedIds(root, propsName) {
|
|
244
235
|
const walkedIds = /* @__PURE__ */ new Set();
|
|
245
236
|
walkIdentifiers(root.body, (id, parent) => {
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/esbuild.ts
|
|
8
8
|
var esbuild_default = require_src.src_default.esbuild;
|
package/dist/esbuild.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.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-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
const require_options = require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
exports.default = require_src.src_default;
|
|
8
8
|
exports.resolveOptions = require_options.resolveOptions;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.js";
|
|
5
5
|
|
|
6
6
|
export { src_default as default, resolveOptions };
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
|
-
require('./core-
|
|
4
|
-
require('./raw-
|
|
3
|
+
require('./core-BGMj1zaw.cjs');
|
|
4
|
+
require('./raw-V1VJGrnC.cjs');
|
|
5
5
|
require('./options-BejTnOdM.cjs');
|
|
6
|
-
require('./src-
|
|
7
|
-
const require_vite = require('./vite-
|
|
8
|
-
const require_webpack = require('./webpack-
|
|
6
|
+
require('./src-Zbpeaztk.cjs');
|
|
7
|
+
const require_vite = require('./vite-BX_gYdbF.cjs');
|
|
8
|
+
const require_webpack = require('./webpack-337kgHM4.cjs');
|
|
9
9
|
const __nuxt_kit = require_chunk.__toESM(require("@nuxt/kit"));
|
|
10
10
|
require("@nuxt/schema");
|
|
11
11
|
|
package/dist/nuxt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.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-9_QEflZu.js";
|
|
5
|
+
import { vite_default } from "./vite-DMiSdzmA.js";
|
|
6
|
+
import { webpack_default } from "./webpack-BijR4yVK.js";
|
|
7
7
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
8
8
|
import "@nuxt/schema";
|
|
9
9
|
|
|
@@ -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-u2ydd_-y.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,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_core = require('./core-
|
|
2
|
+
const require_core = require('./core-BGMj1zaw.cjs');
|
|
3
3
|
const require_options = require('./options-BejTnOdM.cjs');
|
|
4
4
|
const __vue_macros_common = require_chunk.__toESM(require("@vue-macros/common"));
|
|
5
5
|
const __vue_compiler_sfc = require_chunk.__toESM(require("@vue/compiler-sfc"));
|
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-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
const require_raw = require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
5
|
|
|
6
6
|
exports.default = require_raw.raw_default;
|
package/dist/raw.js
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/rolldown.ts
|
|
8
8
|
var rolldown_default = require_src.src_default.rolldown;
|
package/dist/rolldown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.js";
|
|
5
5
|
|
|
6
6
|
//#region src/rolldown.ts
|
|
7
7
|
var rolldown_default = src_default.rolldown;
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/rollup.ts
|
|
8
8
|
var rollup_default = require_src.src_default.rollup;
|
package/dist/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.js";
|
|
5
5
|
|
|
6
6
|
//#region src/rollup.ts
|
|
7
7
|
var rollup_default = src_default.rollup;
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-Zbpeaztk.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/rspack.ts
|
|
8
8
|
var rspack_default = require_src.src_default.rspack;
|
package/dist/rspack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-9_QEflZu.js";
|
|
5
5
|
|
|
6
6
|
//#region src/rspack.ts
|
|
7
7
|
var rspack_default = src_default.rspack;
|
package/dist/vite.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
require('./src-
|
|
6
|
-
const require_vite = require('./vite-
|
|
5
|
+
require('./src-Zbpeaztk.cjs');
|
|
6
|
+
const require_vite = require('./vite-BX_gYdbF.cjs');
|
|
7
7
|
|
|
8
8
|
exports.default = require_vite.vite_default;
|
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import "./src-
|
|
5
|
-
import { vite_default } from "./vite-
|
|
4
|
+
import "./src-9_QEflZu.js";
|
|
5
|
+
import { vite_default } from "./vite-DMiSdzmA.js";
|
|
6
6
|
|
|
7
7
|
export { vite_default as default };
|
package/dist/volar.cjs
CHANGED
|
@@ -8,22 +8,37 @@ const ts_macro = require_chunk.__toESM(require("ts-macro"));
|
|
|
8
8
|
function transformDefineComponent(node, parent, options) {
|
|
9
9
|
const { codes, ast, ts } = options;
|
|
10
10
|
const [comp, compOptions] = node.arguments;
|
|
11
|
+
const isVapor = node.expression.getText(ast) === "defineVaporComponent";
|
|
11
12
|
codes.replaceRange(comp.end, node.end - 1);
|
|
12
13
|
codes.replaceRange(node.getStart(ast), node.expression.end, ts.isExpressionStatement(parent) ? ";" : "", `(() => {
|
|
13
14
|
const __setup = `);
|
|
14
|
-
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["__setup"] : [
|
|
15
|
-
[node.expression.getText(ast), node.expression.getStart(ast)],
|
|
16
|
-
`({
|
|
17
|
-
__typeProps: {} as Parameters<typeof __setup>[0],
|
|
18
|
-
...{} as Parameters<typeof __setup>[1] extends { slots?: infer S, expose?: infer E } | undefined ? {
|
|
19
|
-
setup: E extends (exposed: infer Exposed) => any ? () => Exposed : never,
|
|
20
|
-
slots: S extends Record<string, any> ? import('vue').SlotsType<S> : never
|
|
21
|
-
} : {},`,
|
|
22
|
-
...compOptions ? ["\n ...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
|
|
15
|
+
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
|
|
23
16
|
`
|
|
24
|
-
|
|
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 : {}`,
|
|
20
|
+
"\n const __component = ",
|
|
21
|
+
[node.expression.getText(ast), node.expression.getStart(ast)],
|
|
22
|
+
`({`,
|
|
23
|
+
isVapor ? "" : `...{} as {
|
|
24
|
+
setup: () => __Exposed,
|
|
25
|
+
slots: import('vue').SlotsType<__Slots>
|
|
26
|
+
},`,
|
|
27
|
+
...compOptions ? ["...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
|
|
28
|
+
`})
|
|
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
|
+
}) => {},
|
|
39
|
+
}`
|
|
25
40
|
];
|
|
26
|
-
codes.replaceRange(node.end, node.end,
|
|
41
|
+
codes.replaceRange(node.end, node.end, ...result, `\n})()`);
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
//#endregion
|
|
@@ -98,7 +113,7 @@ function transformJsxMacros(rootMap, options) {
|
|
|
98
113
|
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
99
114
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
100
115
|
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
101
|
-
const result =
|
|
116
|
+
const result = macros.defineComponent && root.typeParameters?.length ? "({}) as JSX.Element" : "__ctx.render";
|
|
102
117
|
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
103
118
|
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "", `__props: typeof __ctx.props & ${propsType}, `, `__context?: typeof __ctx.context, `, `__ctx = {} as Awaited<ReturnType<typeof __fn>>, `, `__fn = (${asyncModifier ? "async" : ""}(`);
|
|
104
119
|
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
@@ -116,9 +131,8 @@ function transformJsxMacros(rootMap, options) {
|
|
|
116
131
|
});
|
|
117
132
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
118
133
|
}
|
|
119
|
-
|
|
120
|
-
codes.replaceRange(node.
|
|
121
|
-
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
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" : "", ` = `);
|
|
135
|
+
codes.replaceRange(node.expression.end, node.expression.end, `
|
|
122
136
|
return {} as {
|
|
123
137
|
props: {${props.join(", ")}},
|
|
124
138
|
context: {
|
|
@@ -200,7 +214,7 @@ function getRootMap(options) {
|
|
|
200
214
|
if (root && parents[2] && ts.isCallExpression(parents[2]) && !parents[2].typeArguments && options.defineComponent.alias.includes(parents[2].expression.getText(ast))) {
|
|
201
215
|
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
202
216
|
if (!rootMap.get(root).defineComponent) {
|
|
203
|
-
rootMap.get(root).defineComponent =
|
|
217
|
+
rootMap.get(root).defineComponent = parents[2];
|
|
204
218
|
transformDefineComponent(parents[2], parents[3], options);
|
|
205
219
|
}
|
|
206
220
|
}
|
package/dist/volar.js
CHANGED
|
@@ -6,22 +6,37 @@ import { allCodeFeatures, createPlugin, getText } from "ts-macro";
|
|
|
6
6
|
function transformDefineComponent(node, parent, options) {
|
|
7
7
|
const { codes, ast, ts } = options;
|
|
8
8
|
const [comp, compOptions] = node.arguments;
|
|
9
|
+
const isVapor = node.expression.getText(ast) === "defineVaporComponent";
|
|
9
10
|
codes.replaceRange(comp.end, node.end - 1);
|
|
10
11
|
codes.replaceRange(node.getStart(ast), node.expression.end, ts.isExpressionStatement(parent) ? ";" : "", `(() => {
|
|
11
12
|
const __setup = `);
|
|
12
|
-
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["__setup"] : [
|
|
13
|
-
[node.expression.getText(ast), node.expression.getStart(ast)],
|
|
14
|
-
`({
|
|
15
|
-
__typeProps: {} as Parameters<typeof __setup>[0],
|
|
16
|
-
...{} as Parameters<typeof __setup>[1] extends { slots?: infer S, expose?: infer E } | undefined ? {
|
|
17
|
-
setup: E extends (exposed: infer Exposed) => any ? () => Exposed : never,
|
|
18
|
-
slots: S extends Record<string, any> ? import('vue').SlotsType<S> : never
|
|
19
|
-
} : {},`,
|
|
20
|
-
...compOptions ? ["\n ...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
|
|
13
|
+
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
|
|
21
14
|
`
|
|
22
|
-
|
|
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 : {}`,
|
|
18
|
+
"\n const __component = ",
|
|
19
|
+
[node.expression.getText(ast), node.expression.getStart(ast)],
|
|
20
|
+
`({`,
|
|
21
|
+
isVapor ? "" : `...{} as {
|
|
22
|
+
setup: () => __Exposed,
|
|
23
|
+
slots: import('vue').SlotsType<__Slots>
|
|
24
|
+
},`,
|
|
25
|
+
...compOptions ? ["...", [compOptions.getText(ast), compOptions.getStart(ast)]] : [],
|
|
26
|
+
`})
|
|
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
|
+
}) => {},
|
|
37
|
+
}`
|
|
23
38
|
];
|
|
24
|
-
codes.replaceRange(node.end, node.end,
|
|
39
|
+
codes.replaceRange(node.end, node.end, ...result, `\n})()`);
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
//#endregion
|
|
@@ -96,7 +111,7 @@ function transformJsxMacros(rootMap, options) {
|
|
|
96
111
|
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
97
112
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
98
113
|
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
99
|
-
const result =
|
|
114
|
+
const result = macros.defineComponent && root.typeParameters?.length ? "({}) as JSX.Element" : "__ctx.render";
|
|
100
115
|
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
101
116
|
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "", `__props: typeof __ctx.props & ${propsType}, `, `__context?: typeof __ctx.context, `, `__ctx = {} as Awaited<ReturnType<typeof __fn>>, `, `__fn = (${asyncModifier ? "async" : ""}(`);
|
|
102
117
|
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
@@ -114,9 +129,8 @@ function transformJsxMacros(rootMap, options) {
|
|
|
114
129
|
});
|
|
115
130
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
116
131
|
}
|
|
117
|
-
|
|
118
|
-
codes.replaceRange(node.
|
|
119
|
-
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
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" : "", ` = `);
|
|
133
|
+
codes.replaceRange(node.expression.end, node.expression.end, `
|
|
120
134
|
return {} as {
|
|
121
135
|
props: {${props.join(", ")}},
|
|
122
136
|
context: {
|
|
@@ -198,7 +212,7 @@ function getRootMap(options) {
|
|
|
198
212
|
if (root && parents[2] && ts.isCallExpression(parents[2]) && !parents[2].typeArguments && options.defineComponent.alias.includes(parents[2].expression.getText(ast))) {
|
|
199
213
|
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
200
214
|
if (!rootMap.get(root).defineComponent) {
|
|
201
|
-
rootMap.get(root).defineComponent =
|
|
215
|
+
rootMap.get(root).defineComponent = parents[2];
|
|
202
216
|
transformDefineComponent(parents[2], parents[3], options);
|
|
203
217
|
}
|
|
204
218
|
}
|
package/dist/webpack.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
require('./core-
|
|
3
|
-
require('./raw-
|
|
2
|
+
require('./core-BGMj1zaw.cjs');
|
|
3
|
+
require('./raw-V1VJGrnC.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
require('./src-
|
|
6
|
-
const require_webpack = require('./webpack-
|
|
5
|
+
require('./src-Zbpeaztk.cjs');
|
|
6
|
+
const require_webpack = require('./webpack-337kgHM4.cjs');
|
|
7
7
|
|
|
8
8
|
exports.default = require_webpack.webpack_default;
|
package/dist/webpack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-u2ydd_-y.js";
|
|
2
|
+
import "./raw-Dprh1tIQ.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import "./src-
|
|
5
|
-
import { webpack_default } from "./webpack-
|
|
4
|
+
import "./src-9_QEflZu.js";
|
|
5
|
+
import { webpack_default } from "./webpack-BijR4yVK.js";
|
|
6
6
|
|
|
7
7
|
export { webpack_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-jsx-vapor/macros",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
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.
|
|
134
|
+
"@vue-macros/common": "^3.0.0-beta.20",
|
|
135
135
|
"@vue/compiler-sfc": "3.6.0-alpha.2",
|
|
136
136
|
"hash-sum": "^2.0.0",
|
|
137
|
-
"ts-macro": "^0.3.
|
|
137
|
+
"ts-macro": "^0.3.2",
|
|
138
138
|
"unplugin": "^2.3.5"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
141
141
|
"@babel/types": "^7.28.0",
|
|
142
|
-
"@nuxt/kit": "^3.18.
|
|
143
|
-
"@nuxt/schema": "^3.18.
|
|
142
|
+
"@nuxt/kit": "^3.18.1",
|
|
143
|
+
"@nuxt/schema": "^3.18.1",
|
|
144
144
|
"@types/hash-sum": "^1.0.2",
|
|
145
|
-
"@vue-macros/test-utils": "^3.0.0-beta.
|
|
145
|
+
"@vue-macros/test-utils": "^3.0.0-beta.20",
|
|
146
146
|
"vue": "3.6.0-alpha.2"
|
|
147
147
|
},
|
|
148
148
|
"scripts": {
|