@vue-jsx-vapor/macros 2.5.4-beta.1 → 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 +53 -24
- package/dist/volar.js +54 -25
- 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
|
@@ -7,9 +7,38 @@ const ts_macro = require_chunk.__toESM(require("ts-macro"));
|
|
|
7
7
|
//#region src/volar/define-component.ts
|
|
8
8
|
function transformDefineComponent(node, parent, options) {
|
|
9
9
|
const { codes, ast, ts } = options;
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
codes.replaceRange(
|
|
10
|
+
const [comp, compOptions] = node.arguments;
|
|
11
|
+
const isVapor = node.expression.getText(ast) === "defineVaporComponent";
|
|
12
|
+
codes.replaceRange(comp.end, node.end - 1);
|
|
13
|
+
codes.replaceRange(node.getStart(ast), node.expression.end, ts.isExpressionStatement(parent) ? ";" : "", `(() => {
|
|
14
|
+
const __setup = `);
|
|
15
|
+
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
|
|
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 : {}`,
|
|
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
|
+
}`
|
|
40
|
+
];
|
|
41
|
+
codes.replaceRange(node.end, node.end, ...result, `\n})()`);
|
|
13
42
|
}
|
|
14
43
|
|
|
15
44
|
//#endregion
|
|
@@ -84,9 +113,9 @@ function transformJsxMacros(rootMap, options) {
|
|
|
84
113
|
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
85
114
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
86
115
|
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
87
|
-
const result =
|
|
116
|
+
const result = macros.defineComponent && root.typeParameters?.length ? "({}) as JSX.Element" : "__ctx.render";
|
|
88
117
|
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
89
|
-
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "",
|
|
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" : ""}(`);
|
|
90
119
|
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
91
120
|
else {
|
|
92
121
|
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
@@ -102,14 +131,16 @@ function transformJsxMacros(rootMap, options) {
|
|
|
102
131
|
});
|
|
103
132
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
104
133
|
}
|
|
105
|
-
|
|
106
|
-
codes.replaceRange(node.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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, `
|
|
136
|
+
return {} as {
|
|
137
|
+
props: {${props.join(", ")}},
|
|
138
|
+
context: {
|
|
139
|
+
slots?: ${macros.defineSlots ?? "{}"},
|
|
140
|
+
expose?: (exposed: import('vue').ShallowUnwrapRef<${macros.defineExpose ?? "{}"}>) => void,
|
|
141
|
+
attrs?: Record<string, any>
|
|
142
|
+
},
|
|
143
|
+
render: typeof __render
|
|
113
144
|
}`);
|
|
114
145
|
}
|
|
115
146
|
});
|
|
@@ -121,8 +152,8 @@ return {
|
|
|
121
152
|
function getGlobalTypes(rootMap, options) {
|
|
122
153
|
let defineStyle = "";
|
|
123
154
|
if (options.defineSlots.alias) {
|
|
124
|
-
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args:
|
|
125
|
-
defineStyle += `\ntype
|
|
155
|
+
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args: __StyleArgs): T; scss: <T>(...args: __StyleArgs)=> T; sass: <T>(...args: __StyleArgs)=> T; stylus: <T>(...args: __StyleArgs)=> T; less: <T>(...args: __StyleArgs)=> T; postcss: <T>(...args: __StyleArgs)=> T };`).join("\n");
|
|
156
|
+
defineStyle += `\ntype __StyleArgs = [style: string, options?: { scoped?: boolean }];`;
|
|
126
157
|
}
|
|
127
158
|
if (!rootMap.size) return `\n${defineStyle}`;
|
|
128
159
|
const defineSlots = options.defineSlots.alias.flatMap((alias) => [`declare function ${alias}<T extends Record<string, any>>(): Partial<T>;`, `declare function ${alias}<T extends Record<string, any>>(slots: T): T;`]).join("\n");
|
|
@@ -135,8 +166,6 @@ ${VueMacros ? `declare const { ${VueMacros} }: typeof import('vue');` : ""}
|
|
|
135
166
|
${defineSlots}
|
|
136
167
|
${defineExpose}
|
|
137
168
|
${defineStyle}
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
140
169
|
`;
|
|
141
170
|
}
|
|
142
171
|
|
|
@@ -185,7 +214,7 @@ function getRootMap(options) {
|
|
|
185
214
|
if (root && parents[2] && ts.isCallExpression(parents[2]) && !parents[2].typeArguments && options.defineComponent.alias.includes(parents[2].expression.getText(ast))) {
|
|
186
215
|
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
187
216
|
if (!rootMap.get(root).defineComponent) {
|
|
188
|
-
rootMap.get(root).defineComponent =
|
|
217
|
+
rootMap.get(root).defineComponent = parents[2];
|
|
189
218
|
transformDefineComponent(parents[2], parents[3], options);
|
|
190
219
|
}
|
|
191
220
|
}
|
|
@@ -214,18 +243,18 @@ function getRootMap(options) {
|
|
|
214
243
|
}
|
|
215
244
|
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
216
245
|
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
217
|
-
const id = toValidAssetId(modelName,
|
|
246
|
+
const id = toValidAssetId(modelName, `__model`);
|
|
218
247
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
219
248
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
220
249
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
221
250
|
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${(0, ts_macro.getText)(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
222
|
-
|
|
251
|
+
codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
223
252
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
224
|
-
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\
|
|
225
|
-
rootMap.get(root).defineSlots = `Partial<typeof
|
|
253
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__slots;\nconst __slots = `);
|
|
254
|
+
rootMap.get(root).defineSlots = `Partial<typeof __slots>`;
|
|
226
255
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
227
|
-
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\
|
|
228
|
-
rootMap.get(root).defineExpose = `typeof
|
|
256
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__exposed;\nconst __exposed = `);
|
|
257
|
+
rootMap.get(root).defineExpose = `typeof __exposed`;
|
|
229
258
|
}
|
|
230
259
|
}
|
|
231
260
|
}
|
package/dist/volar.js
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
1
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
2
|
-
import {
|
|
2
|
+
import { REGEX_VUE_SFC, createFilter } from "@vue-macros/common";
|
|
3
3
|
import { allCodeFeatures, createPlugin, getText } from "ts-macro";
|
|
4
4
|
|
|
5
5
|
//#region src/volar/define-component.ts
|
|
6
6
|
function transformDefineComponent(node, parent, options) {
|
|
7
7
|
const { codes, ast, ts } = options;
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
codes.replaceRange(
|
|
8
|
+
const [comp, compOptions] = node.arguments;
|
|
9
|
+
const isVapor = node.expression.getText(ast) === "defineVaporComponent";
|
|
10
|
+
codes.replaceRange(comp.end, node.end - 1);
|
|
11
|
+
codes.replaceRange(node.getStart(ast), node.expression.end, ts.isExpressionStatement(parent) ? ";" : "", `(() => {
|
|
12
|
+
const __setup = `);
|
|
13
|
+
const result = (ts.isArrowFunction(comp) || ts.isFunctionExpression(comp)) && comp.typeParameters?.length ? ["\nreturn __setup"] : [
|
|
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 : {}`,
|
|
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
|
+
}`
|
|
38
|
+
];
|
|
39
|
+
codes.replaceRange(node.end, node.end, ...result, `\n})()`);
|
|
11
40
|
}
|
|
12
41
|
|
|
13
42
|
//#endregion
|
|
@@ -82,9 +111,9 @@ function transformJsxMacros(rootMap, options) {
|
|
|
82
111
|
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
83
112
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
84
113
|
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
85
|
-
const result =
|
|
114
|
+
const result = macros.defineComponent && root.typeParameters?.length ? "({}) as JSX.Element" : "__ctx.render";
|
|
86
115
|
const propsType = root.parameters[0]?.type ? root.parameters[0].type.getText(ast) : "{}";
|
|
87
|
-
codes.replaceRange(root.parameters.pos, root.parameters.pos, ts.isArrowFunction(root) && root.parameters.pos === root.pos ? "(" : "",
|
|
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" : ""}(`);
|
|
88
117
|
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
89
118
|
else {
|
|
90
119
|
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
@@ -100,14 +129,16 @@ function transformJsxMacros(rootMap, options) {
|
|
|
100
129
|
});
|
|
101
130
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
102
131
|
}
|
|
103
|
-
|
|
104
|
-
codes.replaceRange(node.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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, `
|
|
134
|
+
return {} as {
|
|
135
|
+
props: {${props.join(", ")}},
|
|
136
|
+
context: {
|
|
137
|
+
slots?: ${macros.defineSlots ?? "{}"},
|
|
138
|
+
expose?: (exposed: import('vue').ShallowUnwrapRef<${macros.defineExpose ?? "{}"}>) => void,
|
|
139
|
+
attrs?: Record<string, any>
|
|
140
|
+
},
|
|
141
|
+
render: typeof __render
|
|
111
142
|
}`);
|
|
112
143
|
}
|
|
113
144
|
});
|
|
@@ -119,8 +150,8 @@ return {
|
|
|
119
150
|
function getGlobalTypes(rootMap, options) {
|
|
120
151
|
let defineStyle = "";
|
|
121
152
|
if (options.defineSlots.alias) {
|
|
122
|
-
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args:
|
|
123
|
-
defineStyle += `\ntype
|
|
153
|
+
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args: __StyleArgs): T; scss: <T>(...args: __StyleArgs)=> T; sass: <T>(...args: __StyleArgs)=> T; stylus: <T>(...args: __StyleArgs)=> T; less: <T>(...args: __StyleArgs)=> T; postcss: <T>(...args: __StyleArgs)=> T };`).join("\n");
|
|
154
|
+
defineStyle += `\ntype __StyleArgs = [style: string, options?: { scoped?: boolean }];`;
|
|
124
155
|
}
|
|
125
156
|
if (!rootMap.size) return `\n${defineStyle}`;
|
|
126
157
|
const defineSlots = options.defineSlots.alias.flatMap((alias) => [`declare function ${alias}<T extends Record<string, any>>(): Partial<T>;`, `declare function ${alias}<T extends Record<string, any>>(slots: T): T;`]).join("\n");
|
|
@@ -133,8 +164,6 @@ ${VueMacros ? `declare const { ${VueMacros} }: typeof import('vue');` : ""}
|
|
|
133
164
|
${defineSlots}
|
|
134
165
|
${defineExpose}
|
|
135
166
|
${defineStyle}
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
138
167
|
`;
|
|
139
168
|
}
|
|
140
169
|
|
|
@@ -183,7 +212,7 @@ function getRootMap(options) {
|
|
|
183
212
|
if (root && parents[2] && ts.isCallExpression(parents[2]) && !parents[2].typeArguments && options.defineComponent.alias.includes(parents[2].expression.getText(ast))) {
|
|
184
213
|
if (!rootMap.has(root)) rootMap.set(root, {});
|
|
185
214
|
if (!rootMap.get(root).defineComponent) {
|
|
186
|
-
rootMap.get(root).defineComponent =
|
|
215
|
+
rootMap.get(root).defineComponent = parents[2];
|
|
187
216
|
transformDefineComponent(parents[2], parents[3], options);
|
|
188
217
|
}
|
|
189
218
|
}
|
|
@@ -212,18 +241,18 @@ function getRootMap(options) {
|
|
|
212
241
|
}
|
|
213
242
|
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
214
243
|
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
215
|
-
const id = toValidAssetId(modelName,
|
|
244
|
+
const id = toValidAssetId(modelName, `__model`);
|
|
216
245
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
217
246
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
218
247
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
219
248
|
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${getText(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
220
|
-
|
|
249
|
+
codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
221
250
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
222
|
-
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\
|
|
223
|
-
rootMap.get(root).defineSlots = `Partial<typeof
|
|
251
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__slots;\nconst __slots = `);
|
|
252
|
+
rootMap.get(root).defineSlots = `Partial<typeof __slots>`;
|
|
224
253
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
225
|
-
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\
|
|
226
|
-
rootMap.get(root).defineExpose = `typeof
|
|
254
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n__exposed;\nconst __exposed = `);
|
|
255
|
+
rootMap.get(root).defineExpose = `typeof __exposed`;
|
|
227
256
|
}
|
|
228
257
|
}
|
|
229
258
|
}
|
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.
|
|
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.2
|
|
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.
|
|
143
|
-
"@nuxt/schema": "^3.
|
|
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": {
|