@vue-jsx-vapor/macros 3.2.12 → 3.2.14
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 +4 -3
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +3 -2
- package/dist/astro.cjs +7 -6
- package/dist/astro.d.cts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +5 -1
- package/dist/bun.cjs +8 -6
- package/dist/bun.d.cts +1 -1
- package/dist/bun.d.ts +1 -1
- package/dist/bun.js +5 -1
- package/dist/{core-j6kwFyf2.cjs → core-D-SjmK2V.cjs} +98 -76
- package/dist/{core-CspOqTxm.js → core-DN_L2oPP.js} +25 -8
- package/dist/esbuild.cjs +8 -6
- package/dist/esbuild.d.cts +3 -3
- package/dist/esbuild.d.ts +3 -3
- package/dist/esbuild.js +5 -1
- package/dist/index.cjs +10 -9
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/nuxt.cjs +9 -9
- package/dist/nuxt.d.cts +3 -3
- package/dist/nuxt.d.ts +3 -3
- package/dist/nuxt.js +6 -2
- package/dist/options.cjs +4 -2
- package/dist/options.d.cts +41 -1
- package/dist/options.d.ts +41 -1
- package/dist/options.js +2 -1
- package/dist/raw.cjs +71 -6
- package/dist/raw.d.cts +1 -1
- package/dist/raw.d.ts +1 -1
- package/dist/raw.js +70 -2
- package/dist/rolldown.cjs +8 -6
- package/dist/rolldown.d.cts +3 -3
- package/dist/rolldown.d.ts +3 -3
- package/dist/rolldown.js +5 -1
- package/dist/rollup.cjs +8 -6
- package/dist/rollup.d.cts +3 -3
- package/dist/rollup.d.ts +3 -3
- package/dist/rollup.js +5 -1
- package/dist/rsbuild.cjs +17 -0
- package/dist/rsbuild.d.cts +8 -0
- package/dist/rsbuild.d.ts +9 -0
- package/dist/rsbuild.js +16 -0
- package/dist/rspack.cjs +8 -6
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +5 -1
- package/dist/style-CYbYjV0s.cjs +34 -0
- package/dist/style-T_SCIOuW.js +29 -0
- package/dist/vite.cjs +8 -6
- package/dist/vite.d.cts +3 -3
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +5 -1
- package/dist/volar.cjs +12 -7
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/volar.js +9 -1
- package/dist/webpack.cjs +8 -6
- package/dist/webpack.d.cts +3 -3
- package/dist/webpack.d.ts +3 -3
- package/dist/webpack.js +5 -1
- package/package.json +8 -2
- package/dist/options-CtTcew0x.d.ts +0 -42
- package/dist/options-qs66-MV7.d.cts +0 -42
- package/dist/raw-B-nh3eEu.cjs +0 -97
- package/dist/raw-CrS9IkfP.js +0 -92
package/dist/api.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_core = require(
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core = require('./core-D-SjmK2V.cjs');
|
|
3
|
+
|
|
3
4
|
exports.getMacroExpression = require_core.getMacroExpression;
|
|
4
5
|
exports.isFunctionalNode = require_core.isFunctionalNode;
|
|
5
6
|
exports.restructure = require_core.restructure;
|
|
6
|
-
exports.transformJsxMacros = require_core.transformJsxMacros;
|
|
7
|
+
exports.transformJsxMacros = require_core.transformJsxMacros;
|
package/dist/api.d.cts
CHANGED
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { a as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-
|
|
2
|
-
|
|
1
|
+
import { a as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-DN_L2oPP.js";
|
|
2
|
+
|
|
3
|
+
export { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
|
package/dist/astro.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
require('./core-D-SjmK2V.cjs');
|
|
3
|
+
require('./style-CYbYjV0s.cjs');
|
|
4
|
+
const require_index = require('./index.cjs');
|
|
5
|
+
|
|
6
6
|
//#region src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
8
8
|
name: "vue-jsx-vapor",
|
|
@@ -11,5 +11,6 @@ var astro_default = (options) => ({
|
|
|
11
11
|
astro.config.vite.plugins.push(require_index.default.vite(options));
|
|
12
12
|
} }
|
|
13
13
|
});
|
|
14
|
+
|
|
14
15
|
//#endregion
|
|
15
|
-
exports.default = astro_default;
|
|
16
|
+
exports.default = astro_default;
|
package/dist/astro.d.cts
CHANGED
package/dist/astro.d.ts
CHANGED
package/dist/astro.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import "./core-DN_L2oPP.js";
|
|
2
|
+
import "./style-T_SCIOuW.js";
|
|
1
3
|
import unplugin from "./index.js";
|
|
4
|
+
|
|
2
5
|
//#region src/astro.ts
|
|
3
6
|
var astro_default = (options) => ({
|
|
4
7
|
name: "vue-jsx-vapor",
|
|
@@ -7,5 +10,6 @@ var astro_default = (options) => ({
|
|
|
7
10
|
astro.config.vite.plugins.push(unplugin.vite(options));
|
|
8
11
|
} }
|
|
9
12
|
});
|
|
13
|
+
|
|
10
14
|
//#endregion
|
|
11
|
-
export { astro_default as default };
|
|
15
|
+
export { astro_default as default };
|
package/dist/bun.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
require('./core-D-SjmK2V.cjs');
|
|
3
|
+
require('./style-CYbYjV0s.cjs');
|
|
4
|
+
const require_index = require('./index.cjs');
|
|
5
|
+
|
|
5
6
|
//#region src/bun.ts
|
|
6
|
-
var bun_default =
|
|
7
|
+
var bun_default = require_index.default.bun;
|
|
8
|
+
|
|
7
9
|
//#endregion
|
|
8
|
-
exports.default = bun_default;
|
|
10
|
+
exports.default = bun_default;
|
package/dist/bun.d.cts
CHANGED
package/dist/bun.d.ts
CHANGED
package/dist/bun.js
CHANGED
|
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
@@ -19,12 +23,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
23
|
value: mod,
|
|
20
24
|
enumerable: true
|
|
21
25
|
}) : target, mod));
|
|
26
|
+
|
|
22
27
|
//#endregion
|
|
23
28
|
require("@babel/parser");
|
|
24
29
|
let magic_string = require("magic-string");
|
|
25
|
-
magic_string = __toESM(magic_string
|
|
30
|
+
magic_string = __toESM(magic_string);
|
|
26
31
|
let hash_sum = require("hash-sum");
|
|
27
|
-
hash_sum = __toESM(hash_sum
|
|
32
|
+
hash_sum = __toESM(hash_sum);
|
|
33
|
+
|
|
28
34
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
29
35
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
30
36
|
function normalizeWindowsPath(input = "") {
|
|
@@ -37,6 +43,7 @@ const extname = function(p) {
|
|
|
37
43
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
38
44
|
return match && match[1] || "";
|
|
39
45
|
};
|
|
46
|
+
|
|
40
47
|
//#endregion
|
|
41
48
|
//#region ../../node_modules/.pnpm/ast-kit@2.2.0/node_modules/ast-kit/dist/index.js
|
|
42
49
|
/**
|
|
@@ -464,21 +471,26 @@ function markScopeIdentifier(node, child, knownIds) {
|
|
|
464
471
|
markKnownIds(name, knownIds);
|
|
465
472
|
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
466
473
|
}
|
|
474
|
+
|
|
467
475
|
//#endregion
|
|
468
476
|
//#region src/core/helper/use-model.ts?raw
|
|
469
477
|
var use_model_default = "import { customRef, watchSyncEffect } from \"vue\";\nconst EMPTY_OBJ = {};\nexport function useModel(props, name, options = EMPTY_OBJ) {\n const res = customRef((track, trigger) => {\n let localValue = options && options.default;\n let prevSetValue = EMPTY_OBJ;\n watchSyncEffect(() => {\n let propValue = props[name];\n if (propValue === void 0) {\n propValue = options && options.default;\n }\n if (!Object.is(localValue, propValue)) {\n localValue = propValue;\n trigger();\n }\n });\n return {\n get() {\n track();\n return options.get ? options.get(localValue) : localValue;\n },\n set(value) {\n const emittedValue = options.set ? options.set(value) : value;\n if (Object.is(emittedValue, localValue) && (prevSetValue === EMPTY_OBJ || Object.is(value, prevSetValue)))\n return;\n localValue = emittedValue;\n trigger();\n for (const emit of [props[`onUpdate:${name}`]].flat()) {\n if (typeof emit === \"function\") emit(emittedValue);\n }\n prevSetValue = value;\n }\n };\n });\n res[Symbol.iterator] = () => {\n let i = 0;\n return {\n next() {\n if (i < 2) {\n return {\n value: i++ ? props[`${name}Modifiers`] || {} : res,\n done: false\n };\n } else {\n return { done: true };\n }\n }\n };\n };\n return res;\n}\n";
|
|
478
|
+
|
|
470
479
|
//#endregion
|
|
471
480
|
//#region src/core/helper/use-slots.ts?raw
|
|
472
481
|
var use_slots_default = "import { useSlots as _useSlots } from \"vue\";\nexport function useSlots(defaultSlots = {}) {\n const slots = _useSlots();\n return new Proxy(defaultSlots, {\n get(target, key) {\n return key in slots ? slots[key] : target[key];\n }\n });\n}\n";
|
|
482
|
+
|
|
473
483
|
//#endregion
|
|
474
484
|
//#region src/core/helper/with-defaults.ts?raw
|
|
475
485
|
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of /* @__PURE__ */ new Set([\n ...Object.keys(props),\n ...Object.keys(defaultProps)\n ])) {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => props[key] === void 0 ? defaultProps[key] : props[key]\n });\n }\n return result;\n}\n";
|
|
486
|
+
|
|
476
487
|
//#endregion
|
|
477
488
|
//#region src/core/helper/index.ts
|
|
478
489
|
const helperPrefix = "/vue-jsx-vapor/macros";
|
|
479
490
|
const useModelHelperId = `${helperPrefix}/use-model`;
|
|
480
491
|
const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
481
492
|
const useSlotsHelperId = `${helperPrefix}/use-slots`;
|
|
493
|
+
|
|
482
494
|
//#endregion
|
|
483
495
|
//#region src/core/utils.ts
|
|
484
496
|
function prependFunctionalNode(node, s, result) {
|
|
@@ -512,22 +524,24 @@ function getRequire() {
|
|
|
512
524
|
} catch {}
|
|
513
525
|
}
|
|
514
526
|
const importedMap = /* @__PURE__ */ new WeakMap();
|
|
527
|
+
const HELPER_PREFIX = "__";
|
|
515
528
|
function importHelperFn(s, imported, local = imported, from = "vue") {
|
|
516
529
|
const cacheKey = `${from}@${imported}`;
|
|
517
530
|
if (!importedMap.get(s)?.has(cacheKey)) {
|
|
518
|
-
s.appendLeft(0, `\nimport ${imported === "default" ?
|
|
531
|
+
s.appendLeft(0, `\nimport ${imported === "default" ? HELPER_PREFIX + local : `{ ${imported} as ${HELPER_PREFIX + local} }`} from ${JSON.stringify(from)};`);
|
|
519
532
|
if (importedMap.has(s)) importedMap.get(s).add(cacheKey);
|
|
520
533
|
else importedMap.set(s, new Set([cacheKey]));
|
|
521
534
|
}
|
|
522
|
-
return
|
|
535
|
+
return `${HELPER_PREFIX}${local}`;
|
|
523
536
|
}
|
|
537
|
+
|
|
524
538
|
//#endregion
|
|
525
539
|
//#region src/core/restructure.ts
|
|
526
540
|
function restructure(s, node, options = {}) {
|
|
527
541
|
let index = 0;
|
|
528
542
|
const propList = [];
|
|
529
543
|
for (const param of node.params) {
|
|
530
|
-
const path =
|
|
544
|
+
const path = `${HELPER_PREFIX}props${index++ || ""}`;
|
|
531
545
|
const props = getProps(s, options, param, path);
|
|
532
546
|
if (props) {
|
|
533
547
|
s.overwrite(param.start, param.end, path);
|
|
@@ -593,7 +607,7 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
593
607
|
});
|
|
594
608
|
}
|
|
595
609
|
propNames.push(`'${prop.key.name}'`);
|
|
596
|
-
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`
|
|
610
|
+
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`${HELPER_PREFIX}props`)) props.push({
|
|
597
611
|
path,
|
|
598
612
|
name: prop.argument.name,
|
|
599
613
|
value: propNames.join(", "),
|
|
@@ -603,6 +617,7 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
603
617
|
});
|
|
604
618
|
return props.length ? props : void 0;
|
|
605
619
|
}
|
|
620
|
+
|
|
606
621
|
//#endregion
|
|
607
622
|
//#region src/core/define-component/await.ts
|
|
608
623
|
function transformAwait(root, s) {
|
|
@@ -635,6 +650,7 @@ function processAwait(s, node, needSemi, isStatement) {
|
|
|
635
650
|
s.overwrite(node.start, argumentStart, `${needSemi ? `;` : ``}(\n ([__temp,__restore] = ${importHelperFn(s, `withAsyncContext`)}(${containsNestedAwait ? `async ` : ``}() => `);
|
|
636
651
|
s.appendLeft(node.end, `)),\n ${isStatement ? `` : `__temp = `}await __temp,\n __restore()${isStatement ? `` : `,\n __temp`}\n)`);
|
|
637
652
|
}
|
|
653
|
+
|
|
638
654
|
//#endregion
|
|
639
655
|
//#region src/core/define-component/index.ts
|
|
640
656
|
function transformDefineComponent(root, propsName, macros, s) {
|
|
@@ -645,7 +661,7 @@ function transformDefineComponent(root, propsName, macros, s) {
|
|
|
645
661
|
if (root.params[0].type === "Identifier") {
|
|
646
662
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
647
663
|
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, "useFullProps", void 0, "/vue-jsx-vapor/props")}()`);
|
|
648
|
-
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `
|
|
664
|
+
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${HELPER_PREFIX}props` : root.start === root.params[0].start ? "()" : "");
|
|
649
665
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
650
666
|
const restructuredProps = root.params[0];
|
|
651
667
|
for (const prop of restructuredProps.properties) {
|
|
@@ -769,23 +785,27 @@ function getTypeAndValue(s, node) {
|
|
|
769
785
|
skipFactory
|
|
770
786
|
};
|
|
771
787
|
}
|
|
788
|
+
|
|
772
789
|
//#endregion
|
|
773
790
|
//#region src/core/define-expose.ts
|
|
774
791
|
function transformDefineExpose(node, s) {
|
|
775
792
|
s.overwrite(node.callee.start, node.callee.end, ";");
|
|
776
793
|
s.appendRight(node.arguments[0]?.start || node.end - 1, `${importHelperFn(s, "getCurrentInstance", void 0, "/vue-jsx-vapor/props")}().exposed = `);
|
|
777
794
|
}
|
|
795
|
+
|
|
778
796
|
//#endregion
|
|
779
797
|
//#region src/core/define-model.ts
|
|
780
798
|
function transformDefineModel(node, propsName, s) {
|
|
781
799
|
s.overwrite(node.callee.start, node.callee.end, importHelperFn(s, "useModel", void 0, useModelHelperId));
|
|
782
800
|
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type === "StringLiteral" ? "" : `'modelValue',`}`);
|
|
783
801
|
}
|
|
802
|
+
|
|
784
803
|
//#endregion
|
|
785
804
|
//#region src/core/define-slots.ts
|
|
786
805
|
function transformDefineSlots(node, s) {
|
|
787
806
|
s.overwrite(node.callee.start, node.callee.end, importHelperFn(s, "useSlots", void 0, useSlotsHelperId));
|
|
788
807
|
}
|
|
808
|
+
|
|
789
809
|
//#endregion
|
|
790
810
|
//#region src/core/define-style.ts
|
|
791
811
|
function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSlots }) {
|
|
@@ -845,6 +865,7 @@ function toCssVarId(name, prefix = "") {
|
|
|
845
865
|
return searchValue === "." ? "-" : name.charCodeAt(replaceValue).toString();
|
|
846
866
|
});
|
|
847
867
|
}
|
|
868
|
+
|
|
848
869
|
//#endregion
|
|
849
870
|
//#region src/core/index.ts
|
|
850
871
|
let babelParse;
|
|
@@ -870,13 +891,13 @@ async function transformJsxMacros(code, id, importMap, options) {
|
|
|
870
891
|
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap, macros);
|
|
871
892
|
});
|
|
872
893
|
if (root === void 0) continue;
|
|
873
|
-
let propsName =
|
|
894
|
+
let propsName = `${HELPER_PREFIX}props`;
|
|
874
895
|
if (root.params[0]) {
|
|
875
896
|
if (root.params[0].type === "Identifier") propsName = root.params[0].name;
|
|
876
897
|
else if (root.params[0].type === "ObjectPattern") {
|
|
877
898
|
const lastProp = root.params[0].properties.at(-1);
|
|
878
899
|
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
879
|
-
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 ? "," : ""}
|
|
900
|
+
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`);
|
|
880
901
|
}
|
|
881
902
|
} else if (macros.defineModel?.length) s.appendRight(getParamsStart(root, s.original), propsName);
|
|
882
903
|
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s);
|
|
@@ -953,76 +974,77 @@ function getMacroExpression(node, options) {
|
|
|
953
974
|
].includes(node.callee.name)) return node;
|
|
954
975
|
}
|
|
955
976
|
}
|
|
977
|
+
|
|
956
978
|
//#endregion
|
|
957
|
-
Object.defineProperty(exports,
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
979
|
+
Object.defineProperty(exports, '__toESM', {
|
|
980
|
+
enumerable: true,
|
|
981
|
+
get: function () {
|
|
982
|
+
return __toESM;
|
|
983
|
+
}
|
|
962
984
|
});
|
|
963
|
-
Object.defineProperty(exports,
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
985
|
+
Object.defineProperty(exports, 'getMacroExpression', {
|
|
986
|
+
enumerable: true,
|
|
987
|
+
get: function () {
|
|
988
|
+
return getMacroExpression;
|
|
989
|
+
}
|
|
968
990
|
});
|
|
969
|
-
Object.defineProperty(exports,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
991
|
+
Object.defineProperty(exports, 'getRequire', {
|
|
992
|
+
enumerable: true,
|
|
993
|
+
get: function () {
|
|
994
|
+
return getRequire;
|
|
995
|
+
}
|
|
974
996
|
});
|
|
975
|
-
Object.defineProperty(exports,
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
997
|
+
Object.defineProperty(exports, 'isFunctionalNode', {
|
|
998
|
+
enumerable: true,
|
|
999
|
+
get: function () {
|
|
1000
|
+
return isFunctionalNode;
|
|
1001
|
+
}
|
|
980
1002
|
});
|
|
981
|
-
Object.defineProperty(exports,
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1003
|
+
Object.defineProperty(exports, 'restructure', {
|
|
1004
|
+
enumerable: true,
|
|
1005
|
+
get: function () {
|
|
1006
|
+
return restructure;
|
|
1007
|
+
}
|
|
986
1008
|
});
|
|
987
|
-
Object.defineProperty(exports,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
});
|
|
993
|
-
Object.defineProperty(exports, "useModelHelperId", {
|
|
994
|
-
enumerable: true,
|
|
995
|
-
get: function() {
|
|
996
|
-
return useModelHelperId;
|
|
997
|
-
}
|
|
1009
|
+
Object.defineProperty(exports, 'transformJsxMacros', {
|
|
1010
|
+
enumerable: true,
|
|
1011
|
+
get: function () {
|
|
1012
|
+
return transformJsxMacros;
|
|
1013
|
+
}
|
|
998
1014
|
});
|
|
999
|
-
Object.defineProperty(exports,
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1015
|
+
Object.defineProperty(exports, 'useModelHelperId', {
|
|
1016
|
+
enumerable: true,
|
|
1017
|
+
get: function () {
|
|
1018
|
+
return useModelHelperId;
|
|
1019
|
+
}
|
|
1004
1020
|
});
|
|
1005
|
-
Object.defineProperty(exports,
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1021
|
+
Object.defineProperty(exports, 'useSlotsHelperId', {
|
|
1022
|
+
enumerable: true,
|
|
1023
|
+
get: function () {
|
|
1024
|
+
return useSlotsHelperId;
|
|
1025
|
+
}
|
|
1010
1026
|
});
|
|
1011
|
-
Object.defineProperty(exports,
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1027
|
+
Object.defineProperty(exports, 'use_model_default', {
|
|
1028
|
+
enumerable: true,
|
|
1029
|
+
get: function () {
|
|
1030
|
+
return use_model_default;
|
|
1031
|
+
}
|
|
1016
1032
|
});
|
|
1017
|
-
Object.defineProperty(exports,
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1033
|
+
Object.defineProperty(exports, 'use_slots_default', {
|
|
1034
|
+
enumerable: true,
|
|
1035
|
+
get: function () {
|
|
1036
|
+
return use_slots_default;
|
|
1037
|
+
}
|
|
1022
1038
|
});
|
|
1023
|
-
Object.defineProperty(exports,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1039
|
+
Object.defineProperty(exports, 'withDefaultsHelperId', {
|
|
1040
|
+
enumerable: true,
|
|
1041
|
+
get: function () {
|
|
1042
|
+
return withDefaultsHelperId;
|
|
1043
|
+
}
|
|
1028
1044
|
});
|
|
1045
|
+
Object.defineProperty(exports, 'with_defaults_default', {
|
|
1046
|
+
enumerable: true,
|
|
1047
|
+
get: function () {
|
|
1048
|
+
return with_defaults_default;
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "@babel/parser";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
import hash from "hash-sum";
|
|
4
|
+
|
|
4
5
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
5
6
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
6
7
|
function normalizeWindowsPath(input = "") {
|
|
@@ -13,6 +14,7 @@ const extname = function(p) {
|
|
|
13
14
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
14
15
|
return match && match[1] || "";
|
|
15
16
|
};
|
|
17
|
+
|
|
16
18
|
//#endregion
|
|
17
19
|
//#region ../../node_modules/.pnpm/ast-kit@2.2.0/node_modules/ast-kit/dist/index.js
|
|
18
20
|
/**
|
|
@@ -440,21 +442,26 @@ function markScopeIdentifier(node, child, knownIds) {
|
|
|
440
442
|
markKnownIds(name, knownIds);
|
|
441
443
|
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
442
444
|
}
|
|
445
|
+
|
|
443
446
|
//#endregion
|
|
444
447
|
//#region src/core/helper/use-model.ts?raw
|
|
445
448
|
var use_model_default = "import { customRef, watchSyncEffect } from \"vue\";\nconst EMPTY_OBJ = {};\nexport function useModel(props, name, options = EMPTY_OBJ) {\n const res = customRef((track, trigger) => {\n let localValue = options && options.default;\n let prevSetValue = EMPTY_OBJ;\n watchSyncEffect(() => {\n let propValue = props[name];\n if (propValue === void 0) {\n propValue = options && options.default;\n }\n if (!Object.is(localValue, propValue)) {\n localValue = propValue;\n trigger();\n }\n });\n return {\n get() {\n track();\n return options.get ? options.get(localValue) : localValue;\n },\n set(value) {\n const emittedValue = options.set ? options.set(value) : value;\n if (Object.is(emittedValue, localValue) && (prevSetValue === EMPTY_OBJ || Object.is(value, prevSetValue)))\n return;\n localValue = emittedValue;\n trigger();\n for (const emit of [props[`onUpdate:${name}`]].flat()) {\n if (typeof emit === \"function\") emit(emittedValue);\n }\n prevSetValue = value;\n }\n };\n });\n res[Symbol.iterator] = () => {\n let i = 0;\n return {\n next() {\n if (i < 2) {\n return {\n value: i++ ? props[`${name}Modifiers`] || {} : res,\n done: false\n };\n } else {\n return { done: true };\n }\n }\n };\n };\n return res;\n}\n";
|
|
449
|
+
|
|
446
450
|
//#endregion
|
|
447
451
|
//#region src/core/helper/use-slots.ts?raw
|
|
448
452
|
var use_slots_default = "import { useSlots as _useSlots } from \"vue\";\nexport function useSlots(defaultSlots = {}) {\n const slots = _useSlots();\n return new Proxy(defaultSlots, {\n get(target, key) {\n return key in slots ? slots[key] : target[key];\n }\n });\n}\n";
|
|
453
|
+
|
|
449
454
|
//#endregion
|
|
450
455
|
//#region src/core/helper/with-defaults.ts?raw
|
|
451
456
|
var with_defaults_default = "function resolveDefaultProps(paths) {\n const result = {};\n for (const path of Object.keys(paths)) {\n const segments = path.split(/[.?[\\]]/).filter(Boolean);\n let current = result;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n if (i === segments.length - 1) {\n current[segment] = paths[path];\n } else {\n if (!current[segment]) {\n current[segment] = Number.isNaN(Number(segments[i + 1])) ? {} : [];\n }\n current = current[segment];\n }\n }\n }\n return result;\n}\nexport function createPropsDefaultProxy(props, defaults) {\n const defaultProps = resolveDefaultProps(defaults);\n const result = {};\n for (const key of /* @__PURE__ */ new Set([\n ...Object.keys(props),\n ...Object.keys(defaultProps)\n ])) {\n Object.defineProperty(result, key, {\n enumerable: true,\n get: () => props[key] === void 0 ? defaultProps[key] : props[key]\n });\n }\n return result;\n}\n";
|
|
457
|
+
|
|
452
458
|
//#endregion
|
|
453
459
|
//#region src/core/helper/index.ts
|
|
454
460
|
const helperPrefix = "/vue-jsx-vapor/macros";
|
|
455
461
|
const useModelHelperId = `${helperPrefix}/use-model`;
|
|
456
462
|
const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
|
|
457
463
|
const useSlotsHelperId = `${helperPrefix}/use-slots`;
|
|
464
|
+
|
|
458
465
|
//#endregion
|
|
459
466
|
//#region src/core/utils.ts
|
|
460
467
|
function prependFunctionalNode(node, s, result) {
|
|
@@ -488,22 +495,24 @@ function getRequire() {
|
|
|
488
495
|
} catch {}
|
|
489
496
|
}
|
|
490
497
|
const importedMap = /* @__PURE__ */ new WeakMap();
|
|
498
|
+
const HELPER_PREFIX = "__";
|
|
491
499
|
function importHelperFn(s, imported, local = imported, from = "vue") {
|
|
492
500
|
const cacheKey = `${from}@${imported}`;
|
|
493
501
|
if (!importedMap.get(s)?.has(cacheKey)) {
|
|
494
|
-
s.appendLeft(0, `\nimport ${imported === "default" ?
|
|
502
|
+
s.appendLeft(0, `\nimport ${imported === "default" ? HELPER_PREFIX + local : `{ ${imported} as ${HELPER_PREFIX + local} }`} from ${JSON.stringify(from)};`);
|
|
495
503
|
if (importedMap.has(s)) importedMap.get(s).add(cacheKey);
|
|
496
504
|
else importedMap.set(s, new Set([cacheKey]));
|
|
497
505
|
}
|
|
498
|
-
return
|
|
506
|
+
return `${HELPER_PREFIX}${local}`;
|
|
499
507
|
}
|
|
508
|
+
|
|
500
509
|
//#endregion
|
|
501
510
|
//#region src/core/restructure.ts
|
|
502
511
|
function restructure(s, node, options = {}) {
|
|
503
512
|
let index = 0;
|
|
504
513
|
const propList = [];
|
|
505
514
|
for (const param of node.params) {
|
|
506
|
-
const path =
|
|
515
|
+
const path = `${HELPER_PREFIX}props${index++ || ""}`;
|
|
507
516
|
const props = getProps(s, options, param, path);
|
|
508
517
|
if (props) {
|
|
509
518
|
s.overwrite(param.start, param.end, path);
|
|
@@ -569,7 +578,7 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
569
578
|
});
|
|
570
579
|
}
|
|
571
580
|
propNames.push(`'${prop.key.name}'`);
|
|
572
|
-
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`
|
|
581
|
+
} else if (prop?.type === "RestElement" && prop.argument.type === "Identifier" && !prop.argument.name.startsWith(`${HELPER_PREFIX}props`)) props.push({
|
|
573
582
|
path,
|
|
574
583
|
name: prop.argument.name,
|
|
575
584
|
value: propNames.join(", "),
|
|
@@ -579,6 +588,7 @@ function getProps(s, options, node, path = "", props = []) {
|
|
|
579
588
|
});
|
|
580
589
|
return props.length ? props : void 0;
|
|
581
590
|
}
|
|
591
|
+
|
|
582
592
|
//#endregion
|
|
583
593
|
//#region src/core/define-component/await.ts
|
|
584
594
|
function transformAwait(root, s) {
|
|
@@ -611,6 +621,7 @@ function processAwait(s, node, needSemi, isStatement) {
|
|
|
611
621
|
s.overwrite(node.start, argumentStart, `${needSemi ? `;` : ``}(\n ([__temp,__restore] = ${importHelperFn(s, `withAsyncContext`)}(${containsNestedAwait ? `async ` : ``}() => `);
|
|
612
622
|
s.appendLeft(node.end, `)),\n ${isStatement ? `` : `__temp = `}await __temp,\n __restore()${isStatement ? `` : `,\n __temp`}\n)`);
|
|
613
623
|
}
|
|
624
|
+
|
|
614
625
|
//#endregion
|
|
615
626
|
//#region src/core/define-component/index.ts
|
|
616
627
|
function transformDefineComponent(root, propsName, macros, s) {
|
|
@@ -621,7 +632,7 @@ function transformDefineComponent(root, propsName, macros, s) {
|
|
|
621
632
|
if (root.params[0].type === "Identifier") {
|
|
622
633
|
getWalkedIds(root, propsName).forEach((id) => props[id] = null);
|
|
623
634
|
prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, "useFullProps", void 0, "/vue-jsx-vapor/props")}()`);
|
|
624
|
-
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `
|
|
635
|
+
s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `${HELPER_PREFIX}props` : root.start === root.params[0].start ? "()" : "");
|
|
625
636
|
} else if (root.params[0].type === "ObjectPattern") {
|
|
626
637
|
const restructuredProps = root.params[0];
|
|
627
638
|
for (const prop of restructuredProps.properties) {
|
|
@@ -745,23 +756,27 @@ function getTypeAndValue(s, node) {
|
|
|
745
756
|
skipFactory
|
|
746
757
|
};
|
|
747
758
|
}
|
|
759
|
+
|
|
748
760
|
//#endregion
|
|
749
761
|
//#region src/core/define-expose.ts
|
|
750
762
|
function transformDefineExpose(node, s) {
|
|
751
763
|
s.overwrite(node.callee.start, node.callee.end, ";");
|
|
752
764
|
s.appendRight(node.arguments[0]?.start || node.end - 1, `${importHelperFn(s, "getCurrentInstance", void 0, "/vue-jsx-vapor/props")}().exposed = `);
|
|
753
765
|
}
|
|
766
|
+
|
|
754
767
|
//#endregion
|
|
755
768
|
//#region src/core/define-model.ts
|
|
756
769
|
function transformDefineModel(node, propsName, s) {
|
|
757
770
|
s.overwrite(node.callee.start, node.callee.end, importHelperFn(s, "useModel", void 0, useModelHelperId));
|
|
758
771
|
s.appendRight(node.arguments[0]?.start || node.end - 1, `${propsName}, ${node.arguments[0]?.type === "StringLiteral" ? "" : `'modelValue',`}`);
|
|
759
772
|
}
|
|
773
|
+
|
|
760
774
|
//#endregion
|
|
761
775
|
//#region src/core/define-slots.ts
|
|
762
776
|
function transformDefineSlots(node, s) {
|
|
763
777
|
s.overwrite(node.callee.start, node.callee.end, importHelperFn(s, "useSlots", void 0, useSlotsHelperId));
|
|
764
778
|
}
|
|
779
|
+
|
|
765
780
|
//#endregion
|
|
766
781
|
//#region src/core/define-style.ts
|
|
767
782
|
function transformDefineStyle(defineStyle, index, root, s, importMap, { defineSlots }) {
|
|
@@ -821,6 +836,7 @@ function toCssVarId(name, prefix = "") {
|
|
|
821
836
|
return searchValue === "." ? "-" : name.charCodeAt(replaceValue).toString();
|
|
822
837
|
});
|
|
823
838
|
}
|
|
839
|
+
|
|
824
840
|
//#endregion
|
|
825
841
|
//#region src/core/index.ts
|
|
826
842
|
let babelParse;
|
|
@@ -846,13 +862,13 @@ async function transformJsxMacros(code, id, importMap, options) {
|
|
|
846
862
|
transformDefineStyle(defineStyle, defineStyleIndex++, root, s, importMap, macros);
|
|
847
863
|
});
|
|
848
864
|
if (root === void 0) continue;
|
|
849
|
-
let propsName =
|
|
865
|
+
let propsName = `${HELPER_PREFIX}props`;
|
|
850
866
|
if (root.params[0]) {
|
|
851
867
|
if (root.params[0].type === "Identifier") propsName = root.params[0].name;
|
|
852
868
|
else if (root.params[0].type === "ObjectPattern") {
|
|
853
869
|
const lastProp = root.params[0].properties.at(-1);
|
|
854
870
|
if (!macros.defineComponent && lastProp?.type === "RestElement" && lastProp.argument.type === "Identifier") propsName = lastProp.argument.name;
|
|
855
|
-
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 ? "," : ""}
|
|
871
|
+
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`);
|
|
856
872
|
}
|
|
857
873
|
} else if (macros.defineModel?.length) s.appendRight(getParamsStart(root, s.original), propsName);
|
|
858
874
|
if (macros.defineComponent) transformDefineComponent(root, propsName, macros, s);
|
|
@@ -929,5 +945,6 @@ function getMacroExpression(node, options) {
|
|
|
929
945
|
].includes(node.callee.name)) return node;
|
|
930
946
|
}
|
|
931
947
|
}
|
|
948
|
+
|
|
932
949
|
//#endregion
|
|
933
|
-
export { isFunctionalNode as a, withDefaultsHelperId as c, use_model_default as d, getRequire as i, with_defaults_default as l, transformJsxMacros as n, useModelHelperId as o, restructure as r, useSlotsHelperId as s, getMacroExpression as t, use_slots_default as u };
|
|
950
|
+
export { isFunctionalNode as a, withDefaultsHelperId as c, use_model_default as d, getRequire as i, with_defaults_default as l, transformJsxMacros as n, useModelHelperId as o, restructure as r, useSlotsHelperId as s, getMacroExpression as t, use_slots_default as u };
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
require('./core-D-SjmK2V.cjs');
|
|
3
|
+
require('./style-CYbYjV0s.cjs');
|
|
4
|
+
const require_index = require('./index.cjs');
|
|
5
|
+
|
|
5
6
|
//#region src/esbuild.ts
|
|
6
|
-
var esbuild_default =
|
|
7
|
+
var esbuild_default = require_index.default.esbuild;
|
|
8
|
+
|
|
7
9
|
//#endregion
|
|
8
|
-
exports.default = esbuild_default;
|
|
10
|
+
exports.default = esbuild_default;
|
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
1
|
+
import { Options } from "./options.cjs";
|
|
2
|
+
import * as unplugin from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/esbuild.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => unplugin.EsbuildPlugin;
|
|
6
6
|
export = _default;
|