@vue-jsx-vapor/macros 2.5.1 → 2.5.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.
- 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-CJIyaYlk.cjs → core-BnOBUOXo.cjs} +2 -2
- package/dist/{core-CtkYfL-E.js → core-CzkzlWGo.js} +2 -2
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.d.cts +2 -2
- package/dist/esbuild.d.ts +2 -2
- 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.d.cts +2 -2
- package/dist/nuxt.d.ts +2 -2
- package/dist/nuxt.js +5 -5
- package/dist/{raw-CdxUliM8.js → raw-Cs8E-0N5.js} +1 -1
- package/dist/{raw-fnyAVQJZ.cjs → raw-DKCRm2ff.cjs} +1 -1
- package/dist/raw.cjs +2 -2
- package/dist/raw.js +2 -2
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.d.cts +2 -2
- package/dist/rolldown.d.ts +2 -2
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +2 -2
- package/dist/rollup.d.ts +2 -2
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.js +3 -3
- package/dist/{src-CYY_kpUg.js → src-BMmuQ4rG.js} +1 -1
- package/dist/{src-CnMPxcfy.cjs → src-DJK4pxUR.cjs} +1 -1
- package/dist/{vite-55JkDcH_.cjs → vite-DRkDbCPE.cjs} +1 -1
- package/dist/{vite-UTnXGFnz.js → vite-DbwHYLPn.js} +1 -1
- package/dist/vite.cjs +4 -4
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +4 -4
- package/dist/volar.cjs +51 -47
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +52 -49
- package/dist/{webpack-CMEaEJ1m.cjs → webpack-CsAn2U-j.cjs} +1 -1
- package/dist/{webpack-vi_c875X.js → webpack-WGax0jDH.js} +1 -1
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.ts +2 -2
- 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-CzkzlWGo.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.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-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.js";
|
|
5
5
|
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -177,7 +177,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
177
177
|
if (root.params[0].type === "Identifier") {
|
|
178
178
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
179
179
|
prependFunctionalNode(root, s, `const ${propsName} = ${(0, __vue_macros_common.importHelperFn)(s, 0, "useFullProps", void 0, "vue-jsx-vapor")}()`);
|
|
180
|
-
s.overwrite(root.params[0].start, root.params[0].end, `${__vue_macros_common.HELPER_PREFIX}props`);
|
|
180
|
+
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${__vue_macros_common.HELPER_PREFIX}props` : "");
|
|
181
181
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
182
182
|
const restructuredProps = root.params[0];
|
|
183
183
|
for (const prop of restructuredProps.properties) {
|
|
@@ -412,7 +412,7 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
412
412
|
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
413
413
|
else s.appendRight(root.params[0].extra?.trailingComma ? root.params[0].extra?.trailingComma + 1 : lastProp?.end || root.params[0].end - 1, `${!root.params[0].extra?.trailingComma && root.params[0].properties.length ? "," : ""} ...${__vue_macros_common.HELPER_PREFIX}props`);
|
|
414
414
|
}
|
|
415
|
-
} else s.appendRight(getParamsStart(root, s.original), propsName);
|
|
415
|
+
} else if (macros.defineModel?.length) s.appendRight(getParamsStart(root, s.original), propsName);
|
|
416
416
|
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s, options.defineComponent?.autoReturnFunction);
|
|
417
417
|
if (macros.defineModel?.length) macros.defineModel.forEach(({ expression }) => {
|
|
418
418
|
transformDefineModel(expression, propsName, s);
|
|
@@ -176,7 +176,7 @@ function transformDefineComponent(root, propsName, macros, s, autoReturnFunction
|
|
|
176
176
|
if (root.params[0].type === "Identifier") {
|
|
177
177
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
178
178
|
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, 0, "useFullProps", void 0, "vue-jsx-vapor")}()`);
|
|
179
|
-
s.overwrite(root.params[0].start, root.params[0].end, `${HELPER_PREFIX}props`);
|
|
179
|
+
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${HELPER_PREFIX}props` : "");
|
|
180
180
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
181
181
|
const restructuredProps = root.params[0];
|
|
182
182
|
for (const prop of restructuredProps.properties) {
|
|
@@ -411,7 +411,7 @@ function transformJsxMacros(code, id, importMap, options) {
|
|
|
411
411
|
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
412
412
|
else s.appendRight(root.params[0].extra?.trailingComma ? root.params[0].extra?.trailingComma + 1 : lastProp?.end || root.params[0].end - 1, `${!root.params[0].extra?.trailingComma && root.params[0].properties.length ? "," : ""} ...${HELPER_PREFIX}props`);
|
|
413
413
|
}
|
|
414
|
-
} else s.appendRight(getParamsStart(root, s.original), propsName);
|
|
414
|
+
} else if (macros.defineModel?.length) s.appendRight(getParamsStart(root, s.original), propsName);
|
|
415
415
|
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s, options.defineComponent?.autoReturnFunction);
|
|
416
416
|
if (macros.defineModel?.length) macros.defineModel.forEach(({ expression }) => {
|
|
417
417
|
transformDefineModel(expression, propsName, s);
|
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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/esbuild.ts
|
|
8
8
|
var esbuild_default = require_src.src_default.esbuild;
|
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as esbuild1 from "esbuild";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => esbuild1.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
|
|
2
|
+
import * as esbuild14 from "esbuild";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => esbuild14.Plugin;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/esbuild.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
const require_options = require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.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-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.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-BnOBUOXo.cjs');
|
|
4
|
+
require('./raw-DKCRm2ff.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-DJK4pxUR.cjs');
|
|
7
|
+
const require_vite = require('./vite-DRkDbCPE.cjs');
|
|
8
|
+
const require_webpack = require('./webpack-CsAn2U-j.cjs');
|
|
9
9
|
const __nuxt_kit = require_chunk.__toESM(require("@nuxt/kit"));
|
|
10
10
|
require("@nuxt/schema");
|
|
11
11
|
|
package/dist/nuxt.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _nuxt_schema2 from "@nuxt/schema";
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
5
|
interface ModuleOptions extends Options {}
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: _nuxt_schema2.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
|
|
2
|
+
import * as _nuxt_schema7 from "@nuxt/schema";
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
5
|
interface ModuleOptions extends Options {}
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: _nuxt_schema7.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { ModuleOptions, _default as default };
|
package/dist/nuxt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.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-BMmuQ4rG.js";
|
|
5
|
+
import { vite_default } from "./vite-DbwHYLPn.js";
|
|
6
|
+
import { webpack_default } from "./webpack-WGax0jDH.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-CzkzlWGo.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-BnOBUOXo.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-BnOBUOXo.cjs');
|
|
3
|
+
const require_raw = require('./raw-DKCRm2ff.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/rolldown.ts
|
|
8
8
|
var rolldown_default = require_src.src_default.rolldown;
|
package/dist/rolldown.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as unplugin4 from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/rolldown.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => unplugin4.RolldownPlugin<any> | unplugin4.RolldownPlugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-K4yleEdU.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as unplugin1 from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/rolldown.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => unplugin1.RolldownPlugin<any> | unplugin1.RolldownPlugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/rolldown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/rollup.ts
|
|
8
8
|
var rollup_default = require_src.src_default.rollup;
|
package/dist/rollup.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as rollup7 from "rollup";
|
|
3
3
|
|
|
4
4
|
//#region src/rollup.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => rollup7.Plugin<any> | rollup7.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
|
|
2
|
+
import * as rollup4 from "rollup";
|
|
3
3
|
|
|
4
4
|
//#region src/rollup.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => rollup4.Plugin<any> | rollup4.Plugin<any>[];
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
const require_src = require('./src-
|
|
5
|
+
const require_src = require('./src-DJK4pxUR.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-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import { src_default } from "./src-
|
|
4
|
+
import { src_default } from "./src-BMmuQ4rG.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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
require('./src-
|
|
6
|
-
const require_vite = require('./vite-
|
|
5
|
+
require('./src-DJK4pxUR.cjs');
|
|
6
|
+
const require_vite = require('./vite-DRkDbCPE.cjs');
|
|
7
7
|
|
|
8
8
|
exports.default = require_vite.vite_default;
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vite11 from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => vite11.Plugin<any> | vite11.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
|
|
2
|
+
import * as vite9 from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import "./src-
|
|
5
|
-
import { vite_default } from "./vite-
|
|
4
|
+
import "./src-BMmuQ4rG.js";
|
|
5
|
+
import { vite_default } from "./vite-DbwHYLPn.js";
|
|
6
6
|
|
|
7
7
|
export { vite_default as default };
|
package/dist/volar.cjs
CHANGED
|
@@ -7,24 +7,16 @@ 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
|
-
|
|
10
|
+
codes.replaceRange(node.arguments[0].end, node.end - 1);
|
|
11
11
|
const componentOptions = node.arguments[1];
|
|
12
|
-
|
|
13
|
-
node.expression.getText(ast),
|
|
14
|
-
node.getStart(ast),
|
|
15
|
-
ts_macro.allCodeFeatures
|
|
16
|
-
], "(() => ({}) as any, ", componentOptions ? [
|
|
17
|
-
componentOptions.getText(ast),
|
|
18
|
-
componentOptions.getStart(ast),
|
|
19
|
-
ts_macro.allCodeFeatures
|
|
20
|
-
] : "", "), ");
|
|
12
|
+
codes.replaceRange(node.getStart(ast), node.expression.end + 1, ts.isExpressionStatement(parent) ? ";" : "", "(", [node.expression.getText(ast), node.getStart(ast)], "(() => ({}) as any,", componentOptions ? [componentOptions.getText(ast), componentOptions.getStart(ast)] : "", "), ");
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
//#endregion
|
|
24
16
|
//#region src/volar/define-style.ts
|
|
25
|
-
function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
17
|
+
function transformDefineStyle({ expression, isCssModules }, index, root, options) {
|
|
26
18
|
const { ts, codes, ast } = options;
|
|
27
|
-
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0]))
|
|
19
|
+
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) codes.replaceRange(expression.arguments.pos - 1, expression.arguments.pos - 1, `<{`, ...parseCssClassNames(expression.arguments[0].getText(ast).slice(1, -1)).flatMap(({ text, offset }) => [
|
|
28
20
|
`\n`,
|
|
29
21
|
[
|
|
30
22
|
`'${text.slice(1)}'`,
|
|
@@ -34,6 +26,13 @@ function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
|
34
26
|
],
|
|
35
27
|
`: string`
|
|
36
28
|
]), "\n}>");
|
|
29
|
+
else if (root?.body) {
|
|
30
|
+
const returnNode = root.body.forEachChild((node) => ts.isReturnStatement(node) ? node : void 0);
|
|
31
|
+
if (returnNode) {
|
|
32
|
+
codes.replaceRange(expression.getStart(ast), expression.getEnd());
|
|
33
|
+
codes.replaceRange(returnNode.pos, returnNode.pos, ";", [expression.getText(ast), expression.getStart(ast)]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
37
36
|
addEmbeddedCode(expression, index, options);
|
|
38
37
|
}
|
|
39
38
|
const commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
@@ -81,31 +80,31 @@ function transformJsxMacros(rootMap, options) {
|
|
|
81
80
|
const { ts, codes, ast } = options;
|
|
82
81
|
let defineStyleIndex = 0;
|
|
83
82
|
for (const [root, macros] of rootMap) {
|
|
84
|
-
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, options));
|
|
85
|
-
if (!root?.body) continue;
|
|
83
|
+
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, root, options));
|
|
84
|
+
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
86
85
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
87
|
-
if (asyncModifier && macros.defineComponent)
|
|
86
|
+
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
88
87
|
const result = `({}) as __VLS_PickNotAny<typeof ${__vue_macros_common.HELPER_PREFIX}ctx.render, {}> & { __ctx: typeof ${__vue_macros_common.HELPER_PREFIX}ctx }`;
|
|
89
|
-
const propsType = root.parameters[0]?.type ?
|
|
90
|
-
|
|
91
|
-
if (ts.isArrowFunction(root))
|
|
88
|
+
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 ? "(" : "", `${__vue_macros_common.HELPER_PREFIX}props: typeof ${__vue_macros_common.HELPER_PREFIX}ctx.props & ${propsType}, `, `${__vue_macros_common.HELPER_PREFIX}placeholder?: {}, `, `${__vue_macros_common.HELPER_PREFIX}ctx = {} as Awaited<ReturnType<typeof ${__vue_macros_common.HELPER_PREFIX}setup>>, `, `${__vue_macros_common.HELPER_PREFIX}setup = (${asyncModifier ? "async" : ""}(`);
|
|
90
|
+
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
92
91
|
else {
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
93
|
+
codes.replaceRange(root.end, root.end, `)){ return `, result, "}");
|
|
95
94
|
}
|
|
96
|
-
|
|
95
|
+
root.body.forEachChild((node) => {
|
|
97
96
|
if (ts.isReturnStatement(node) && node.expression) {
|
|
98
97
|
const props = [...macros.defineModel ?? []];
|
|
99
98
|
const elements = root.parameters[0] && !root.parameters[0].type && ts.isObjectBindingPattern(root.parameters[0].name) ? root.parameters[0].name.elements : [];
|
|
100
99
|
for (const element of elements) if (ts.isIdentifier(element.name)) {
|
|
101
|
-
const isRequired =
|
|
102
|
-
return ts.isNonNullExpression(node$1) || !!
|
|
100
|
+
const isRequired = element.forEachChild(function isNonNullExpression(node$1) {
|
|
101
|
+
return ts.isNonNullExpression(node$1) || !!node$1.forEachChild(isNonNullExpression);
|
|
103
102
|
});
|
|
104
103
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
105
104
|
}
|
|
106
105
|
const shouldWrapByCall = (ts.isArrowFunction(node.expression) || ts.isFunctionExpression(node.expression)) && macros.defineComponent;
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const ${__vue_macros_common.HELPER_PREFIX}render = `, shouldWrapByCall ? "(" : "");
|
|
107
|
+
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
109
108
|
return {
|
|
110
109
|
props: {} as {${props.join(", ")}},
|
|
111
110
|
slots: {} as ${macros.defineSlots ?? "{}"},
|
|
@@ -119,18 +118,23 @@ return {
|
|
|
119
118
|
|
|
120
119
|
//#endregion
|
|
121
120
|
//#region src/volar/global-types.ts
|
|
122
|
-
function getGlobalTypes(options) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
function getGlobalTypes(rootMap, options) {
|
|
122
|
+
let defineStyle = "";
|
|
123
|
+
if (options.defineSlots.alias) {
|
|
124
|
+
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs): T; scss: <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs)=> T; sass: <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs)=> T; stylus: <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs)=> T; less: <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs)=> T; postcss: <T>(...args: ${__vue_macros_common.HELPER_PREFIX}StyleArgs)=> T };`).join("\n");
|
|
125
|
+
defineStyle += `\ntype ${__vue_macros_common.HELPER_PREFIX}StyleArgs = [style: string, options?: { scoped?: boolean }];`;
|
|
126
|
+
}
|
|
127
|
+
if (!rootMap.size) return `\n${defineStyle}`;
|
|
128
|
+
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");
|
|
129
|
+
const defineExpose = options.defineExpose.alias.map((alias) => `declare function ${alias}<Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed): Exposed;`).join("\n");
|
|
130
|
+
const defineModel = options.defineModel.alias.map((alias) => alias === "defineModel" ? "defineModel" : `defineModel: ${alias}`);
|
|
131
|
+
const defineComponent = options.defineComponent.alias.map((alias) => ["defineComponent", "defineVaporComponent"].includes(alias) ? "" : `defineComponent: ${alias}`);
|
|
132
|
+
const VueMacros = [...defineModel, ...defineComponent].filter(Boolean).join(",");
|
|
128
133
|
return `
|
|
129
|
-
declare const { ${
|
|
134
|
+
${VueMacros ? `declare const { ${VueMacros} }: typeof import('vue');` : ""}
|
|
130
135
|
${defineSlots}
|
|
131
136
|
${defineExpose}
|
|
132
137
|
${defineStyle}
|
|
133
|
-
type ${__vue_macros_common.HELPER_PREFIX}StyleArgs = [style: string, options?: { scoped?: boolean }];
|
|
134
138
|
// @ts-ignore
|
|
135
139
|
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
136
140
|
`;
|
|
@@ -140,7 +144,7 @@ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B
|
|
|
140
144
|
//#region src/volar/index.ts
|
|
141
145
|
function getMacro(node, ts, options) {
|
|
142
146
|
if (!node) return;
|
|
143
|
-
if (ts.isVariableStatement(node)) return
|
|
147
|
+
if (ts.isVariableStatement(node)) return node.declarationList.forEachChild((decl) => getExpression(decl));
|
|
144
148
|
else return getExpression(node);
|
|
145
149
|
function getExpression(decl) {
|
|
146
150
|
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
@@ -208,30 +212,30 @@ function getRootMap(options) {
|
|
|
208
212
|
hasRequired = true;
|
|
209
213
|
isRequired = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;
|
|
210
214
|
}
|
|
211
|
-
if (!hasRequired && isRequired)
|
|
212
|
-
} else if (isRequired)
|
|
215
|
+
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
216
|
+
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
213
217
|
const id = toValidAssetId(modelName, `${__vue_macros_common.HELPER_PREFIX}model`);
|
|
214
218
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
215
219
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
216
220
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
217
|
-
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${expression.typeArguments[1]
|
|
218
|
-
if (ts.isVariableStatement(node))
|
|
221
|
+
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${(0, ts_macro.getText)(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
222
|
+
if (ts.isVariableStatement(node)) codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
219
223
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
220
|
-
|
|
224
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${__vue_macros_common.HELPER_PREFIX}slots;\nconst ${__vue_macros_common.HELPER_PREFIX}slots = `);
|
|
221
225
|
rootMap.get(root).defineSlots = `Partial<typeof ${__vue_macros_common.HELPER_PREFIX}slots>`;
|
|
222
226
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
223
|
-
|
|
227
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${__vue_macros_common.HELPER_PREFIX}exposed;\nconst ${__vue_macros_common.HELPER_PREFIX}exposed = `);
|
|
224
228
|
rootMap.get(root).defineExpose = `typeof ${__vue_macros_common.HELPER_PREFIX}exposed`;
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
|
-
|
|
232
|
+
node.forEachChild((child) => {
|
|
229
233
|
parents.unshift(node);
|
|
230
234
|
walk(child, parents);
|
|
231
235
|
parents.shift();
|
|
232
236
|
});
|
|
233
237
|
}
|
|
234
|
-
|
|
238
|
+
ast.forEachChild((node) => walk(node, []));
|
|
235
239
|
return rootMap;
|
|
236
240
|
}
|
|
237
241
|
function toValidAssetId(name, type) {
|
|
@@ -244,6 +248,7 @@ function toValidAssetId(name, type) {
|
|
|
244
248
|
//#region src/volar.ts
|
|
245
249
|
const plugin = (0, ts_macro.createPlugin)(({ ts }, userOptions = {}) => {
|
|
246
250
|
const resolvedOptions = require_options.resolveOptions(userOptions);
|
|
251
|
+
resolvedOptions.include.push(__vue_macros_common.REGEX_VUE_SFC);
|
|
247
252
|
const filter = (0, __vue_macros_common.createFilter)(resolvedOptions);
|
|
248
253
|
return {
|
|
249
254
|
name: "@vue-jsx-vapor/macros",
|
|
@@ -256,14 +261,13 @@ const plugin = (0, ts_macro.createPlugin)(({ ts }, userOptions = {}) => {
|
|
|
256
261
|
...resolvedOptions
|
|
257
262
|
};
|
|
258
263
|
const rootMap = getRootMap(options);
|
|
259
|
-
if (rootMap.size)
|
|
260
|
-
|
|
261
|
-
codes.push(getGlobalTypes(options));
|
|
262
|
-
}
|
|
264
|
+
if (rootMap.size) transformJsxMacros(rootMap, options);
|
|
265
|
+
codes.push(getGlobalTypes(rootMap, options));
|
|
263
266
|
}
|
|
264
267
|
};
|
|
265
268
|
});
|
|
266
269
|
var volar_default = plugin;
|
|
267
270
|
|
|
268
271
|
//#endregion
|
|
269
|
-
exports.default = volar_default;
|
|
272
|
+
exports.default = volar_default;
|
|
273
|
+
exports["module.exports"] = plugin;
|
package/dist/volar.d.cts
CHANGED
package/dist/volar.d.ts
CHANGED
package/dist/volar.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { resolveOptions } from "./options-BWRkHmm5.js";
|
|
2
|
-
import { HELPER_PREFIX, createFilter } from "@vue-macros/common";
|
|
3
|
-
import { allCodeFeatures, createPlugin,
|
|
2
|
+
import { HELPER_PREFIX, REGEX_VUE_SFC, createFilter } from "@vue-macros/common";
|
|
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
|
-
replaceRange(
|
|
8
|
+
codes.replaceRange(node.arguments[0].end, node.end - 1);
|
|
9
9
|
const componentOptions = node.arguments[1];
|
|
10
|
-
replaceRange(
|
|
11
|
-
node.expression.getText(ast),
|
|
12
|
-
node.getStart(ast),
|
|
13
|
-
allCodeFeatures
|
|
14
|
-
], "(() => ({}) as any, ", componentOptions ? [
|
|
15
|
-
componentOptions.getText(ast),
|
|
16
|
-
componentOptions.getStart(ast),
|
|
17
|
-
allCodeFeatures
|
|
18
|
-
] : "", "), ");
|
|
10
|
+
codes.replaceRange(node.getStart(ast), node.expression.end + 1, ts.isExpressionStatement(parent) ? ";" : "", "(", [node.expression.getText(ast), node.getStart(ast)], "(() => ({}) as any,", componentOptions ? [componentOptions.getText(ast), componentOptions.getStart(ast)] : "", "), ");
|
|
19
11
|
}
|
|
20
12
|
|
|
21
13
|
//#endregion
|
|
22
14
|
//#region src/volar/define-style.ts
|
|
23
|
-
function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
15
|
+
function transformDefineStyle({ expression, isCssModules }, index, root, options) {
|
|
24
16
|
const { ts, codes, ast } = options;
|
|
25
|
-
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) replaceRange(
|
|
17
|
+
if (isCssModules && expression?.arguments[0] && !expression.typeArguments && ts.isTemplateLiteral(expression.arguments[0])) codes.replaceRange(expression.arguments.pos - 1, expression.arguments.pos - 1, `<{`, ...parseCssClassNames(expression.arguments[0].getText(ast).slice(1, -1)).flatMap(({ text, offset }) => [
|
|
26
18
|
`\n`,
|
|
27
19
|
[
|
|
28
20
|
`'${text.slice(1)}'`,
|
|
@@ -32,6 +24,13 @@ function transformDefineStyle({ expression, isCssModules }, index, options) {
|
|
|
32
24
|
],
|
|
33
25
|
`: string`
|
|
34
26
|
]), "\n}>");
|
|
27
|
+
else if (root?.body) {
|
|
28
|
+
const returnNode = root.body.forEachChild((node) => ts.isReturnStatement(node) ? node : void 0);
|
|
29
|
+
if (returnNode) {
|
|
30
|
+
codes.replaceRange(expression.getStart(ast), expression.getEnd());
|
|
31
|
+
codes.replaceRange(returnNode.pos, returnNode.pos, ";", [expression.getText(ast), expression.getStart(ast)]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
35
34
|
addEmbeddedCode(expression, index, options);
|
|
36
35
|
}
|
|
37
36
|
const commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
@@ -79,31 +78,31 @@ function transformJsxMacros(rootMap, options) {
|
|
|
79
78
|
const { ts, codes, ast } = options;
|
|
80
79
|
let defineStyleIndex = 0;
|
|
81
80
|
for (const [root, macros] of rootMap) {
|
|
82
|
-
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, options));
|
|
83
|
-
if (!root?.body) continue;
|
|
81
|
+
macros.defineStyle?.forEach((defaultStyle) => transformDefineStyle(defaultStyle, defineStyleIndex++, root, options));
|
|
82
|
+
if (!root?.body || Object.keys(macros).length === 1 && macros.defineStyle) continue;
|
|
84
83
|
const asyncModifier = root.modifiers?.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
|
|
85
|
-
if (asyncModifier && macros.defineComponent) replaceRange(
|
|
84
|
+
if (asyncModifier && macros.defineComponent) codes.replaceRange(asyncModifier.pos, asyncModifier.end);
|
|
86
85
|
const result = `({}) as __VLS_PickNotAny<typeof ${HELPER_PREFIX}ctx.render, {}> & { __ctx: typeof ${HELPER_PREFIX}ctx }`;
|
|
87
|
-
const propsType = root.parameters[0]?.type ?
|
|
88
|
-
replaceRange(
|
|
89
|
-
if (ts.isArrowFunction(root)) replaceRange(
|
|
86
|
+
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 ? "(" : "", `${HELPER_PREFIX}props: typeof ${HELPER_PREFIX}ctx.props & ${propsType}, `, `${HELPER_PREFIX}placeholder?: {}, `, `${HELPER_PREFIX}ctx = {} as Awaited<ReturnType<typeof ${HELPER_PREFIX}setup>>, `, `${HELPER_PREFIX}setup = (${asyncModifier ? "async" : ""}(`);
|
|
88
|
+
if (ts.isArrowFunction(root)) codes.replaceRange(root.end, root.end, `))${root.pos === root.parameters.pos ? ")" : ""} => `, result);
|
|
90
89
|
else {
|
|
91
|
-
replaceRange(
|
|
92
|
-
replaceRange(
|
|
90
|
+
codes.replaceRange(root.body.getStart(ast), root.body.getStart(ast), "=>");
|
|
91
|
+
codes.replaceRange(root.end, root.end, `)){ return `, result, "}");
|
|
93
92
|
}
|
|
94
|
-
|
|
93
|
+
root.body.forEachChild((node) => {
|
|
95
94
|
if (ts.isReturnStatement(node) && node.expression) {
|
|
96
95
|
const props = [...macros.defineModel ?? []];
|
|
97
96
|
const elements = root.parameters[0] && !root.parameters[0].type && ts.isObjectBindingPattern(root.parameters[0].name) ? root.parameters[0].name.elements : [];
|
|
98
97
|
for (const element of elements) if (ts.isIdentifier(element.name)) {
|
|
99
|
-
const isRequired =
|
|
100
|
-
return ts.isNonNullExpression(node$1) || !!
|
|
98
|
+
const isRequired = element.forEachChild(function isNonNullExpression(node$1) {
|
|
99
|
+
return ts.isNonNullExpression(node$1) || !!node$1.forEachChild(isNonNullExpression);
|
|
101
100
|
});
|
|
102
101
|
props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
|
|
103
102
|
}
|
|
104
103
|
const shouldWrapByCall = (ts.isArrowFunction(node.expression) || ts.isFunctionExpression(node.expression)) && macros.defineComponent;
|
|
105
|
-
replaceRange(
|
|
106
|
-
replaceRange(
|
|
104
|
+
codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), `const ${HELPER_PREFIX}render = `, shouldWrapByCall ? "(" : "");
|
|
105
|
+
codes.replaceRange(node.expression.end, node.expression.end, shouldWrapByCall ? ")()" : "", `
|
|
107
106
|
return {
|
|
108
107
|
props: {} as {${props.join(", ")}},
|
|
109
108
|
slots: {} as ${macros.defineSlots ?? "{}"},
|
|
@@ -117,18 +116,23 @@ return {
|
|
|
117
116
|
|
|
118
117
|
//#endregion
|
|
119
118
|
//#region src/volar/global-types.ts
|
|
120
|
-
function getGlobalTypes(options) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
function getGlobalTypes(rootMap, options) {
|
|
120
|
+
let defineStyle = "";
|
|
121
|
+
if (options.defineSlots.alias) {
|
|
122
|
+
defineStyle = options.defineStyle.alias.map((alias) => `declare const ${alias}: { <T>(...args: ${HELPER_PREFIX}StyleArgs): T; scss: <T>(...args: ${HELPER_PREFIX}StyleArgs)=> T; sass: <T>(...args: ${HELPER_PREFIX}StyleArgs)=> T; stylus: <T>(...args: ${HELPER_PREFIX}StyleArgs)=> T; less: <T>(...args: ${HELPER_PREFIX}StyleArgs)=> T; postcss: <T>(...args: ${HELPER_PREFIX}StyleArgs)=> T };`).join("\n");
|
|
123
|
+
defineStyle += `\ntype ${HELPER_PREFIX}StyleArgs = [style: string, options?: { scoped?: boolean }];`;
|
|
124
|
+
}
|
|
125
|
+
if (!rootMap.size) return `\n${defineStyle}`;
|
|
126
|
+
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");
|
|
127
|
+
const defineExpose = options.defineExpose.alias.map((alias) => `declare function ${alias}<Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed): Exposed;`).join("\n");
|
|
128
|
+
const defineModel = options.defineModel.alias.map((alias) => alias === "defineModel" ? "defineModel" : `defineModel: ${alias}`);
|
|
129
|
+
const defineComponent = options.defineComponent.alias.map((alias) => ["defineComponent", "defineVaporComponent"].includes(alias) ? "" : `defineComponent: ${alias}`);
|
|
130
|
+
const VueMacros = [...defineModel, ...defineComponent].filter(Boolean).join(",");
|
|
126
131
|
return `
|
|
127
|
-
declare const { ${
|
|
132
|
+
${VueMacros ? `declare const { ${VueMacros} }: typeof import('vue');` : ""}
|
|
128
133
|
${defineSlots}
|
|
129
134
|
${defineExpose}
|
|
130
135
|
${defineStyle}
|
|
131
|
-
type ${HELPER_PREFIX}StyleArgs = [style: string, options?: { scoped?: boolean }];
|
|
132
136
|
// @ts-ignore
|
|
133
137
|
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
134
138
|
`;
|
|
@@ -138,7 +142,7 @@ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B
|
|
|
138
142
|
//#region src/volar/index.ts
|
|
139
143
|
function getMacro(node, ts, options) {
|
|
140
144
|
if (!node) return;
|
|
141
|
-
if (ts.isVariableStatement(node)) return
|
|
145
|
+
if (ts.isVariableStatement(node)) return node.declarationList.forEachChild((decl) => getExpression(decl));
|
|
142
146
|
else return getExpression(node);
|
|
143
147
|
function getExpression(decl) {
|
|
144
148
|
if (ts.isVariableDeclaration(decl) && decl.initializer) {
|
|
@@ -206,30 +210,30 @@ function getRootMap(options) {
|
|
|
206
210
|
hasRequired = true;
|
|
207
211
|
isRequired = prop.initializer.kind === ts.SyntaxKind.TrueKeyword;
|
|
208
212
|
}
|
|
209
|
-
if (!hasRequired && isRequired) replaceRange(
|
|
210
|
-
} else if (isRequired) replaceRange(
|
|
213
|
+
if (!hasRequired && isRequired) codes.replaceRange(modelOptions.end - 1, modelOptions.end - 1, `${!modelOptions.properties.hasTrailingComma && modelOptions.properties.length ? "," : ""} required: true`);
|
|
214
|
+
} else if (isRequired) codes.replaceRange(expression.arguments.end, expression.arguments.end, `${!expression.arguments.hasTrailingComma && expression.arguments.length ? "," : ""} { required: true }`);
|
|
211
215
|
const id = toValidAssetId(modelName, `${HELPER_PREFIX}model`);
|
|
212
216
|
const typeString = `import('vue').UnwrapRef<typeof ${id}>`;
|
|
213
217
|
const defineModel = rootMap.get(root).defineModel ??= [];
|
|
214
218
|
defineModel.push(`${modelName.includes("-") ? `'${modelName}'` : modelName}${isRequired ? ":" : "?:"} ${typeString}`, `'onUpdate:${modelName}'?: ($event: ${typeString}) => any`);
|
|
215
|
-
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${expression.typeArguments[1]
|
|
216
|
-
if (ts.isVariableStatement(node)) replaceRange(
|
|
219
|
+
if (expression.typeArguments?.[1]) defineModel.push(`${modelName}Modifiers?: Partial<Record<${getText(expression.typeArguments[1], ast, ts)}, boolean>>`);
|
|
220
|
+
if (ts.isVariableStatement(node)) codes.replaceRange(initializer.getStart(ast), initializer.getStart(ast), `// @ts-ignore\n${id};\nlet ${id} = `);
|
|
217
221
|
} else if (options.defineSlots.alias.includes(macroName)) {
|
|
218
|
-
replaceRange(
|
|
222
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${HELPER_PREFIX}slots;\nconst ${HELPER_PREFIX}slots = `);
|
|
219
223
|
rootMap.get(root).defineSlots = `Partial<typeof ${HELPER_PREFIX}slots>`;
|
|
220
224
|
} else if (options.defineExpose.alias.includes(macroName)) {
|
|
221
|
-
replaceRange(
|
|
225
|
+
codes.replaceRange(expression.getStart(ast), expression.getStart(ast), `// @ts-ignore\n${HELPER_PREFIX}exposed;\nconst ${HELPER_PREFIX}exposed = `);
|
|
222
226
|
rootMap.get(root).defineExpose = `typeof ${HELPER_PREFIX}exposed`;
|
|
223
227
|
}
|
|
224
228
|
}
|
|
225
229
|
}
|
|
226
|
-
|
|
230
|
+
node.forEachChild((child) => {
|
|
227
231
|
parents.unshift(node);
|
|
228
232
|
walk(child, parents);
|
|
229
233
|
parents.shift();
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
|
-
|
|
236
|
+
ast.forEachChild((node) => walk(node, []));
|
|
233
237
|
return rootMap;
|
|
234
238
|
}
|
|
235
239
|
function toValidAssetId(name, type) {
|
|
@@ -242,6 +246,7 @@ function toValidAssetId(name, type) {
|
|
|
242
246
|
//#region src/volar.ts
|
|
243
247
|
const plugin = createPlugin(({ ts }, userOptions = {}) => {
|
|
244
248
|
const resolvedOptions = resolveOptions(userOptions);
|
|
249
|
+
resolvedOptions.include.push(REGEX_VUE_SFC);
|
|
245
250
|
const filter = createFilter(resolvedOptions);
|
|
246
251
|
return {
|
|
247
252
|
name: "@vue-jsx-vapor/macros",
|
|
@@ -254,14 +259,12 @@ const plugin = createPlugin(({ ts }, userOptions = {}) => {
|
|
|
254
259
|
...resolvedOptions
|
|
255
260
|
};
|
|
256
261
|
const rootMap = getRootMap(options);
|
|
257
|
-
if (rootMap.size)
|
|
258
|
-
|
|
259
|
-
codes.push(getGlobalTypes(options));
|
|
260
|
-
}
|
|
262
|
+
if (rootMap.size) transformJsxMacros(rootMap, options);
|
|
263
|
+
codes.push(getGlobalTypes(rootMap, options));
|
|
261
264
|
}
|
|
262
265
|
};
|
|
263
266
|
});
|
|
264
267
|
var volar_default = plugin;
|
|
265
268
|
|
|
266
269
|
//#endregion
|
|
267
|
-
export { volar_default as default };
|
|
270
|
+
export { volar_default as default, plugin as "module.exports" };
|
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-BnOBUOXo.cjs');
|
|
3
|
+
require('./raw-DKCRm2ff.cjs');
|
|
4
4
|
require('./options-BejTnOdM.cjs');
|
|
5
|
-
require('./src-
|
|
6
|
-
const require_webpack = require('./webpack-
|
|
5
|
+
require('./src-DJK4pxUR.cjs');
|
|
6
|
+
const require_webpack = require('./webpack-CsAn2U-j.cjs');
|
|
7
7
|
|
|
8
8
|
exports.default = require_webpack.webpack_default;
|
package/dist/webpack.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-Egmm6BVJ.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as webpack14 from "webpack";
|
|
3
3
|
|
|
4
4
|
//#region src/webpack.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => webpack14.WebpackPluginInstance;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./options-K4yleEdU.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as webpack12 from "webpack";
|
|
3
3
|
|
|
4
4
|
//#region src/webpack.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => webpack12.WebpackPluginInstance;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
package/dist/webpack.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./core-
|
|
2
|
-
import "./raw-
|
|
1
|
+
import "./core-CzkzlWGo.js";
|
|
2
|
+
import "./raw-Cs8E-0N5.js";
|
|
3
3
|
import "./options-BWRkHmm5.js";
|
|
4
|
-
import "./src-
|
|
5
|
-
import { webpack_default } from "./webpack-
|
|
4
|
+
import "./src-BMmuQ4rG.js";
|
|
5
|
+
import { webpack_default } from "./webpack-WGax0jDH.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.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "Macros for Vue JSX Vapor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -131,10 +131,10 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@vue-macros/common": "^3.0.0-beta.
|
|
135
|
-
"@vue/compiler-sfc": "
|
|
134
|
+
"@vue-macros/common": "^3.0.0-beta.17",
|
|
135
|
+
"@vue/compiler-sfc": "3.6.0-alpha.2",
|
|
136
136
|
"hash-sum": "^2.0.0",
|
|
137
|
-
"ts-macro": "^0.
|
|
137
|
+
"ts-macro": "^0.2.7",
|
|
138
138
|
"unplugin": "^2.3.5"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"@nuxt/kit": "^3.17.6",
|
|
143
143
|
"@nuxt/schema": "^3.17.6",
|
|
144
144
|
"@types/hash-sum": "^1.0.2",
|
|
145
|
-
"@vue-macros/test-utils": "^3.0.0-beta.
|
|
146
|
-
"vue": "
|
|
145
|
+
"@vue-macros/test-utils": "^3.0.0-beta.17",
|
|
146
|
+
"vue": "3.6.0-alpha.2"
|
|
147
147
|
},
|
|
148
148
|
"scripts": {
|
|
149
149
|
"build": "tsdown",
|