@vue-jsx/macros 3.3.0-beta.0 → 3.3.0-rc.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.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { r as OptionsResolved } from "./options-CtTcew0x.js";
1
+ import { r as OptionsResolved } from "./options-BjEfS--F.js";
2
2
  import MagicString from "magic-string";
3
-
4
3
  //#region ../../node_modules/.pnpm/@babel+types@7.29.0/node_modules/@babel/types/lib/index-legacy.d.ts
5
4
  // NOTE: This file is autogenerated. Do not modify.
6
5
  // See packages/babel-types/scripts/generators/typescript-legacy.ts for script used.
@@ -1500,7 +1499,7 @@ type ModuleDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | Expor
1500
1499
  //#endregion
1501
1500
  //#region src/core/utils.d.ts
1502
1501
  type FunctionalNode = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
1503
- declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
1502
+ export declare function isFunctionalNode(node?: Node | null): node is FunctionalNode;
1504
1503
  //#endregion
1505
1504
  //#region src/core/restructure.d.ts
1506
1505
  type Options = {
@@ -1515,19 +1514,19 @@ type Prop = {
1515
1514
  defaultValue?: string;
1516
1515
  isRest?: boolean;
1517
1516
  };
1518
- declare function restructure(s: MagicString, node: FunctionalNode, options?: Options): Prop[];
1517
+ export declare function restructure(s: MagicString, node: FunctionalNode, options?: Options): Prop[];
1519
1518
  //#endregion
1520
1519
  //#region src/core/index.d.ts
1521
1520
  interface CodeTransform {
1522
1521
  code: string;
1523
1522
  map: any;
1524
1523
  }
1525
- type DefineStyle = {
1524
+ export type DefineStyle = {
1526
1525
  expression: CallExpression;
1527
1526
  isCssModules: boolean;
1528
1527
  lang: string;
1529
1528
  };
1530
- type Macros = {
1529
+ export type Macros = {
1531
1530
  defineComponent?: CallExpression;
1532
1531
  defineModel?: {
1533
1532
  expression: CallExpression;
@@ -1540,7 +1539,6 @@ type Macros = {
1540
1539
  defineExpose?: CallExpression;
1541
1540
  defineStyle?: DefineStyle[];
1542
1541
  };
1543
- declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): Promise<CodeTransform | undefined>;
1544
- declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
1545
- //#endregion
1546
- export { DefineStyle, Macros, getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
1542
+ export declare function transformJsxMacros(code: string, id: string, importMap: Map<string, string>, options: OptionsResolved): Promise<CodeTransform | undefined>;
1543
+ export declare function getMacroExpression(node: Node, options: OptionsResolved): CallExpression | undefined;
1544
+ //#endregion
package/dist/api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-BRE2gjfq.js";
1
+ import { a as isFunctionalNode, n as transformJsxMacros, r as restructure, t as getMacroExpression } from "./core-aGhdCREk.js";
2
2
  export { getMacroExpression, isFunctionalNode, restructure, transformJsxMacros };
package/dist/astro.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
3
2
  //#region src/astro.d.ts
4
- declare const _default: (options: Options) => {
3
+ declare function _default(options: Options): {
5
4
  name: string;
6
5
  hooks: {
7
6
  'astro:config:setup': (astro: any) => void;
package/dist/astro.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import unplugin from "./index.js";
2
2
  //#region src/astro.ts
3
3
  var astro_default = (options) => ({
4
- name: "vue-jsx-vapor",
4
+ name: "vue-jsx-macros",
5
5
  hooks: { "astro:config:setup": (astro) => {
6
6
  astro.config.vite.plugins ||= [];
7
7
  astro.config.vite.plugins.push(unplugin.vite(options));
package/dist/bun.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
3
2
  //#region src/bun.d.ts
4
3
  declare const _default: (options?: Options | undefined) => BunPlugin;
5
4
  //#endregion
@@ -155,9 +155,7 @@ function extractIdentifiers(node, identifiers = []) {
155
155
  case "RestElement":
156
156
  extractIdentifiers(node.argument, identifiers);
157
157
  break;
158
- case "AssignmentPattern":
159
- extractIdentifiers(node.left, identifiers);
160
- break;
158
+ case "AssignmentPattern": extractIdentifiers(node.left, identifiers);
161
159
  }
162
160
  return identifiers;
163
161
  }
@@ -440,18 +438,10 @@ function markScopeIdentifier(node, child, knownIds) {
440
438
  markKnownIds(name, knownIds);
441
439
  (node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
442
440
  }
443
- //#endregion
444
- //#region src/core/helper/use-model.ts?raw
445
- 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";
446
- //#endregion
447
- //#region src/core/helper/use-slots.ts?raw
448
- 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";
449
- //#endregion
450
- //#region src/core/helper/with-defaults.ts?raw
451
- 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";
441
+ /* v8 ignore file -- @preserve */
452
442
  //#endregion
453
443
  //#region src/core/helper/index.ts
454
- const helperPrefix = "/vue-jsx-vapor/macros";
444
+ const helperPrefix = "/vue-jsx/macros";
455
445
  const useModelHelperId = `${helperPrefix}/use-model`;
456
446
  const withDefaultsHelperId = `${helperPrefix}/with-defaults`;
457
447
  const useSlotsHelperId = `${helperPrefix}/use-slots`;
@@ -493,7 +483,7 @@ function importHelperFn(s, imported, local = imported, from = "vue") {
493
483
  if (!importedMap.get(s)?.has(cacheKey)) {
494
484
  s.appendLeft(0, `\nimport ${imported === "default" ? "__" + local : `{ ${imported} as ${"__" + local} }`} from ${JSON.stringify(from)};`);
495
485
  if (importedMap.has(s)) importedMap.get(s).add(cacheKey);
496
- else importedMap.set(s, new Set([cacheKey]));
486
+ else importedMap.set(s, /* @__PURE__ */ new Set([cacheKey]));
497
487
  }
498
488
  return `__${local}`;
499
489
  }
@@ -504,7 +494,7 @@ function restructure(s, node, options = {}) {
504
494
  const propList = [];
505
495
  for (const param of node.params) {
506
496
  const path = `__props${index++ || ""}`;
507
- const props = getProps(s, options, param, path);
497
+ const props = getProps(s, param, path);
508
498
  if (props) {
509
499
  s.overwrite(param.start, param.end, path);
510
500
  propList.push(...props);
@@ -529,7 +519,7 @@ function restructure(s, node, options = {}) {
529
519
  }
530
520
  return propList;
531
521
  }
532
- function getProps(s, options, node, path = "", props = []) {
522
+ function getProps(s, node, path = "", props = []) {
533
523
  const properties = node.type === "ObjectPattern" ? node.properties : node.type === "ArrayPattern" ? node.elements : [];
534
524
  if (!properties.length) return;
535
525
  const propNames = [];
@@ -551,16 +541,17 @@ function getProps(s, options, node, path = "", props = []) {
551
541
  });
552
542
  propNames.push(`'${prop.left.name}'`);
553
543
  } else if (prop?.type === "ObjectProperty" && prop.key.type === "Identifier") {
554
- if (prop.value.type === "AssignmentPattern") if (prop.value.left.type === "Identifier") {
555
- const defaultValue = getDefaultValue(prop.value.right);
556
- props.push({
557
- path,
558
- name: prop.value.left.name,
559
- value: `.${prop.key.name}`,
560
- defaultValue: s.slice(defaultValue.start, defaultValue.end)
561
- });
562
- } else getProps(s, options, prop.value.left, `${path}.${prop.key.name}`, props);
563
- else if (!getProps(s, options, prop.value, `${path}.${prop.key.name}`, props)) {
544
+ if (prop.value.type === "AssignmentPattern") {
545
+ if (prop.value.left.type === "Identifier") {
546
+ const defaultValue = getDefaultValue(prop.value.right);
547
+ props.push({
548
+ path,
549
+ name: prop.value.left.name,
550
+ value: `.${prop.key.name}`,
551
+ defaultValue: s.slice(defaultValue.start, defaultValue.end)
552
+ });
553
+ } else getProps(s, prop.value.left, `${path}.${prop.key.name}`, props);
554
+ } else if (!getProps(s, prop.value, `${path}.${prop.key.name}`, props)) {
564
555
  const name = prop.value.type === "Identifier" ? prop.value.name : prop.key.name;
565
556
  props.push({
566
557
  path,
@@ -575,7 +566,7 @@ function getProps(s, options, node, path = "", props = []) {
575
566
  value: propNames.join(", "),
576
567
  isRest: true
577
568
  });
578
- else if (prop) getProps(s, options, prop, `${path}[${index}]`, props);
569
+ else if (prop) getProps(s, prop, `${path}[${index}]`, props);
579
570
  });
580
571
  return props.length ? props : void 0;
581
572
  }
@@ -620,7 +611,7 @@ function transformDefineComponent(root, propsName, macros, s) {
620
611
  if (root.params[0]) {
621
612
  if (root.params[0].type === "Identifier") {
622
613
  getWalkedIds(root, propsName).forEach((id) => props[id] = null);
623
- prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, "useFullProps", void 0, "/vue-jsx-vapor/props")}()`);
614
+ prependFunctionalNode(root, s, `const ${propsName} = ${importHelperFn(s, "useFullProps", void 0, "/vue-jsx/props")}()`);
624
615
  s.overwrite(root.params[0].start, root.params[0].end, root.params.length > 1 ? `__props` : root.start === root.params[0].start ? "()" : "");
625
616
  } else if (root.params[0].type === "ObjectPattern") {
626
617
  const restructuredProps = root.params[0];
@@ -732,12 +723,13 @@ function getTypeAndValue(s, node) {
732
723
  default: if (isFunctionalNode(node)) {
733
724
  type = "Function";
734
725
  value = s.slice(node.start, node.end);
735
- } else if (node.type === "Identifier") if (node.name === "undefined") value = "undefined";
736
- else {
737
- skipFactory = true;
738
- value = s.slice(node.start, node.end);
739
- }
740
- else if (node.type === "NullLiteral") value = "null";
726
+ } else if (node.type === "Identifier") {
727
+ if (node.name === "undefined") value = "undefined";
728
+ else {
729
+ skipFactory = true;
730
+ value = s.slice(node.start, node.end);
731
+ }
732
+ } else if (node.type === "NullLiteral") value = "null";
741
733
  }
742
734
  return {
743
735
  value,
@@ -751,7 +743,7 @@ function transformDefineExpose(node, s) {
751
743
  const argument = node.arguments[0];
752
744
  const typeParameters = node.typeParameters ?? node.typeArguments;
753
745
  s.overwrite(node.callee.start, typeParameters?.end ?? node.callee.end, ";");
754
- s.appendRight(argument?.start ?? node.end - 1, `${importHelperFn(s, "getCurrentInstance", void 0, "/vue-jsx-vapor/props")}().exposed = ${argument ? "" : "{}"}`);
746
+ s.appendRight(argument?.start ?? node.end - 1, `${importHelperFn(s, "getCurrentInstance", void 0, "/vue-jsx/props")}().exposed = ${argument ? "" : "{}"}`);
755
747
  }
756
748
  //#endregion
757
749
  //#region src/core/define-model.ts
@@ -932,4 +924,4 @@ function getMacroExpression(node, options) {
932
924
  }
933
925
  }
934
926
  //#endregion
935
- 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 };
927
+ export { isFunctionalNode as a, withDefaultsHelperId as c, getRequire as i, transformJsxMacros as n, useModelHelperId as o, restructure as r, useSlotsHelperId as s, getMacroExpression as t };
package/dist/esbuild.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$esbuild from "esbuild";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
4
2
  //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => _$esbuild.Plugin;
3
+ declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
6
4
  //#endregion
7
5
  export { _default as default };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { i as resolveOptions, n as Options, r as OptionsResolved, t as BaseOptions } from "./options-CtTcew0x.js";
1
+ import { i as resolveOptions, n as Options, r as OptionsResolved, t as BaseOptions } from "./options-BjEfS--F.js";
2
2
  import { UnpluginInstance } from "unplugin";
3
-
4
3
  //#region src/index.d.ts
5
4
  declare const unplugin: UnpluginInstance<Options | undefined>;
6
5
  //#endregion
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as plugin } from "./raw-Qfl50r_v.js";
1
+ import { t as plugin } from "./raw-CJo05-Hm.js";
2
2
  import { resolveOptions } from "./options.js";
3
3
  import { createUnplugin } from "unplugin";
4
4
  //#region src/index.ts
package/dist/nuxt.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$_nuxt_schema0 from "@nuxt/schema";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
2
+ import "@nuxt/schema";
4
3
  //#region src/nuxt.d.ts
5
- interface ModuleOptions extends Options {}
6
- declare const _default: _$_nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
4
+ export interface ModuleOptions extends Options {}
5
+ declare const _default: import("@nuxt/schema").NuxtModule<ModuleOptions, ModuleOptions, false>;
7
6
  //#endregion
8
- export { ModuleOptions, _default as default };
7
+ export { _default as default };
package/dist/nuxt.js CHANGED
@@ -5,8 +5,8 @@ import "@nuxt/schema";
5
5
  //#region src/nuxt.ts
6
6
  var nuxt_default = defineNuxtModule({
7
7
  meta: {
8
- name: "nuxt-vue-jsx-vapor-macros",
9
- configKey: "unpluginStarter"
8
+ name: "@vue-jsx/macros",
9
+ configKey: "vueJsxMacros"
10
10
  },
11
11
  setup(options) {
12
12
  addVitePlugin(() => vite_default(options));
@@ -1,5 +1,4 @@
1
1
  import { FilterPattern } from "unplugin";
2
-
3
2
  //#region src/options.d.ts
4
3
  interface BaseOptions {
5
4
  include?: FilterPattern;
package/dist/options.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as resolveOptions, n as Options, r as OptionsResolved, t as BaseOptions } from "./options-CtTcew0x.js";
1
+ import { i as resolveOptions, n as Options, r as OptionsResolved, t as BaseOptions } from "./options-BjEfS--F.js";
2
2
  export { BaseOptions, Options, OptionsResolved, resolveOptions };
@@ -0,0 +1,101 @@
1
+ import { c as withDefaultsHelperId, i as getRequire, n as transformJsxMacros, o as useModelHelperId, s as useSlotsHelperId } from "./core-aGhdCREk.js";
2
+ import { resolveOptions } from "./options.js";
3
+ //#region src/core/helper/use-model.ts?raw
4
+ 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";
5
+ //#endregion
6
+ //#region src/core/helper/use-slots.ts?raw
7
+ 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";
8
+ //#endregion
9
+ //#region src/core/helper/with-defaults.ts?raw
10
+ 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([...Object.keys(props), ...Object.keys(defaultProps)])) {\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";
11
+ //#endregion
12
+ //#region src/core/style.ts
13
+ let compileStyleAsync;
14
+ async function getCompileStyleAsync() {
15
+ if (compileStyleAsync) return compileStyleAsync;
16
+ const require = getRequire();
17
+ try {
18
+ return compileStyleAsync = require ? require("vue/compiler-sfc").compileStyleAsync : (await import("https://esm.sh/@vue/compiler-sfc")).compileStyleAsync;
19
+ } catch {}
20
+ }
21
+ async function transformStyle(code, id, options) {
22
+ const query = new URLSearchParams(id.split("?")[1]);
23
+ const compileStyleAsync = await getCompileStyleAsync();
24
+ if (!compileStyleAsync) {
25
+ console.warn(`Cannot require vue/compiler-sfc, please install Vue first.`);
26
+ return "";
27
+ }
28
+ return (await compileStyleAsync({
29
+ filename: id,
30
+ id: `data-v-${query.get("scopeId")}`,
31
+ isProd: options.isProduction,
32
+ source: code,
33
+ scoped: query.get("scoped") === "true"
34
+ })).code;
35
+ }
36
+ //#endregion
37
+ //#region src/raw.ts
38
+ const plugin = (userOptions = {}) => {
39
+ const options = resolveOptions(userOptions);
40
+ const importMap = /* @__PURE__ */ new Map();
41
+ const macrosHelperId = /^\/vue-jsx\/macros\//;
42
+ const defineStyleHelperId = /^\/vue-jsx\/macros\/define-style/;
43
+ return [{
44
+ name: "@vue-jsx/macros",
45
+ enforce: "pre",
46
+ resolveId: {
47
+ filter: { id: macrosHelperId },
48
+ handler(id) {
49
+ return id;
50
+ }
51
+ },
52
+ load: {
53
+ filter: { id: macrosHelperId },
54
+ handler(id) {
55
+ if (id === useModelHelperId) return use_model_default;
56
+ if (id === withDefaultsHelperId) return with_defaults_default;
57
+ if (id === useSlotsHelperId) return use_slots_default;
58
+ }
59
+ },
60
+ transform: {
61
+ filter: {
62
+ id: {
63
+ include: options.include,
64
+ exclude: options.exclude
65
+ },
66
+ code: [
67
+ ...options.defineComponent.alias,
68
+ ...options.defineExpose.alias,
69
+ ...options.defineModel.alias,
70
+ ...options.defineSlots.alias,
71
+ ...options.defineStyle.alias
72
+ ]
73
+ },
74
+ handler(code, id) {
75
+ return transformJsxMacros(code, id, importMap, options);
76
+ }
77
+ }
78
+ }, {
79
+ name: "@vue-jsx/macros/define-style",
80
+ resolveId: {
81
+ filter: { id: defineStyleHelperId },
82
+ handler(id) {
83
+ return id;
84
+ }
85
+ },
86
+ load: {
87
+ filter: { id: defineStyleHelperId },
88
+ handler(id) {
89
+ return importMap.get(id);
90
+ }
91
+ },
92
+ transform: {
93
+ filter: { id: defineStyleHelperId },
94
+ handler(code, id) {
95
+ return transformStyle(code, id, options);
96
+ }
97
+ }
98
+ }];
99
+ };
100
+ //#endregion
101
+ export { plugin as t };
package/dist/raw.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
1
+ import { n as Options } from "./options-BjEfS--F.js";
2
2
  import { UnpluginOptions } from "unplugin";
3
-
4
3
  //#region src/raw.d.ts
5
4
  declare const plugin: (userOptions?: Options) => UnpluginOptions[];
6
5
  //#endregion
package/dist/raw.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as plugin } from "./raw-Qfl50r_v.js";
1
+ import { t as plugin } from "./raw-CJo05-Hm.js";
2
2
  export { plugin as default };
@@ -1,7 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$unplugin from "unplugin";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
4
2
  //#region src/rolldown.d.ts
5
- declare const _default: (options?: Options | undefined) => _$unplugin.RolldownPlugin<any>[] | _$unplugin.RolldownPlugin<any>;
3
+ declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any>[] | import("rolldown").Plugin<any>;
6
4
  //#endregion
7
5
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$rollup from "rollup";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
4
2
  //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => _$rollup.Plugin<any>[] | _$rollup.Plugin<any>;
3
+ declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any>[] | import("rollup").Plugin<any>;
6
4
  //#endregion
7
5
  export { _default as default };
package/dist/rsbuild.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
3
2
  //#region src/rsbuild.d.ts
4
- declare const _default: (options?: Options) => {
3
+ declare function _default(options?: Options): {
5
4
  name: string;
6
5
  setup(api: any): void;
7
6
  };
package/dist/rsbuild.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import unplugin from "./index.js";
2
2
  //#region src/rsbuild.ts
3
3
  var rsbuild_default = (options = {}) => ({
4
- name: "rsbuild:vue-jsx-vapor-macros",
4
+ name: "rsbuild:vue-jsx-macros",
5
5
  setup(api) {
6
6
  api.modifyBundlerChain((chain) => {
7
- chain.plugin("vue-jsx-vapor-macros").use(unplugin.rspack(options));
7
+ chain.plugin("vue-jsx-macros").use(unplugin.rspack(options));
8
8
  });
9
9
  }
10
10
  });
package/dist/rspack.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
3
2
  //#region src/rspack.d.ts
4
3
  declare const _default: (options?: Options | undefined) => RspackPluginInstance;
5
4
  //#endregion
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$vite from "vite";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
4
2
  //#region src/vite.d.ts
5
- declare const _default: (options?: Options | undefined) => _$vite.Plugin<any>[] | _$vite.Plugin<any>;
3
+ declare const _default: (options?: Options | undefined) => import("vite").Plugin<any>[] | import("vite").Plugin<any>;
6
4
  //#endregion
7
5
  export { _default as default };
package/dist/volar.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$ts_macro0 from "ts-macro";
3
- import { PluginReturn } from "ts-macro";
4
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
2
+ import { PluginReturn, createPlugin } from "ts-macro";
5
3
  //#region src/volar/jsx-element.d.ts
6
- declare const _default: _$ts_macro0.PluginReturn<unknown, boolean>;
4
+ declare const _default: import("ts-macro").PluginReturn<unknown, boolean>;
7
5
  //#endregion
8
6
  //#region src/volar.d.ts
9
7
  declare const plugin: PluginReturn<Options | undefined>;
10
8
  //#endregion
11
- export { plugin as default, plugin as "module.exports", _default as jsxElement };
9
+ export { type PluginReturn, createPlugin, plugin as default, plugin as "module.exports", _default as jsxElement };
package/dist/volar.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolveOptions } from "./options.js";
2
- import { allCodeFeatures, createPlugin, getText } from "ts-macro";
2
+ import { allCodeFeatures, createPlugin, createPlugin as createPlugin$1, getText } from "ts-macro";
3
3
  import { createFilter } from "unplugin-utils";
4
4
  //#region src/volar/define-component.ts
5
5
  function transformDefineComponent(node, parent, options) {
@@ -172,11 +172,7 @@ function transformJsxMacros(rootMap, options) {
172
172
  props.push(`${element.name.escapedText}${isRequired ? ":" : "?:"} typeof ${element.name.escapedText}`);
173
173
  }
174
174
  const isDefineComponent = macros.defineComponent && ["defineComponent", "defineCustomElement"].includes(macros.defineComponent.expression.getText(ast));
175
- codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), "const ", [
176
- `__rndr`,
177
- node.getStart(ast),
178
- { verification: true }
179
- ], isDefineComponent ? macros.slots ? " = (" : ": () => JSX.Element = " : " = ");
175
+ codes.replaceRange(node.getStart(ast), node.expression.getStart(ast), "const __render = ", isDefineComponent && macros.slots ? "(" : "");
180
176
  codes.replaceRange(node.expression.end, node.expression.end, isDefineComponent && macros.slots ? ")()" : "", `
181
177
  return {} as {
182
178
  props: {${props.join(", ")}},
@@ -185,7 +181,7 @@ return {} as {
185
181
  expose: (exposed: import('vue').ShallowUnwrapRef<${macros.defineExpose ?? "Record<string, any>"}>) => void,
186
182
  attrs: Record<string, any>
187
183
  },
188
- render: ${isDefineComponent ? `ReturnType<` : ""}typeof __rndr${isDefineComponent ? ">" : ""}
184
+ render: ${isDefineComponent ? `ReturnType<` : ""}typeof __render${isDefineComponent ? ">" : ""}
189
185
  }`);
190
186
  }
191
187
  });
@@ -318,7 +314,7 @@ function toValidAssetId(name, type) {
318
314
  //#endregion
319
315
  //#region src/volar/jsx-element.ts
320
316
  const isCompRex = /^[\W_]/;
321
- var jsx_element_default = createPlugin(({ ts }) => {
317
+ var jsx_element_default = createPlugin$1(({ ts }) => {
322
318
  return {
323
319
  name: "@vue-jsx/jsx-element",
324
320
  resolveVirtualCode({ ast, codes }) {
@@ -350,7 +346,7 @@ type __InferJsxElement<T> = T extends keyof HTMLElementTagNameMap
350
346
  ? Instance extends { $: any }
351
347
  ? import('vue').VNode
352
348
  : Instance
353
- : JSX.Element
349
+ : import('vue').VNode
354
350
  `);
355
351
  }
356
352
  };
@@ -382,4 +378,4 @@ const plugin = createPlugin(({ ts }, userOptions = {}) => {
382
378
  };
383
379
  });
384
380
  //#endregion
385
- export { plugin as default, plugin as "module.exports", jsx_element_default as jsxElement };
381
+ export { createPlugin, plugin as default, plugin as "module.exports", jsx_element_default as jsxElement };
package/dist/webpack.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { n as Options } from "./options-CtTcew0x.js";
2
- import * as _$webpack from "webpack";
3
-
1
+ import { n as Options } from "./options-BjEfS--F.js";
4
2
  //#region src/webpack.d.ts
5
- declare const _default: (options?: Options | undefined) => _$webpack.WebpackPluginInstance;
3
+ declare const _default: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
6
4
  //#endregion
7
5
  export { _default as default };
package/package.json CHANGED
@@ -1,24 +1,37 @@
1
1
  {
2
2
  "name": "@vue-jsx/macros",
3
- "type": "module",
4
- "version": "3.3.0-beta.0",
3
+ "version": "3.3.0-rc.1",
5
4
  "description": "Macros for Vue JSX",
6
- "license": "MIT",
5
+ "keywords": [
6
+ "macros",
7
+ "transform",
8
+ "vapor",
9
+ "volar",
10
+ "vue-jsx"
11
+ ],
7
12
  "homepage": "https://github.com/vuejs/vue-jsx-vapor#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/vuejs/vue-jsx-vapor/issues"
15
+ },
16
+ "license": "MIT",
8
17
  "repository": {
9
18
  "type": "git",
10
19
  "url": "git+https://github.com/vuejs/vue-jsx-vapor.git"
11
20
  },
12
- "bugs": {
13
- "url": "https://github.com/vuejs/vue-jsx-vapor/issues"
14
- },
15
- "keywords": [
16
- "transform",
17
- "vue-jsx",
18
- "macros",
19
- "volar",
20
- "vapor"
21
+ "files": [
22
+ "dist"
21
23
  ],
24
+ "type": "module",
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "typesVersions": {
28
+ "*": {
29
+ "*": [
30
+ "./dist/*",
31
+ "./*"
32
+ ]
33
+ }
34
+ },
22
35
  "exports": {
23
36
  ".": "./dist/index.js",
24
37
  "./astro": "./dist/astro.js",
@@ -35,23 +48,34 @@
35
48
  "./volar": "./dist/volar.js",
36
49
  "./*": "./*"
37
50
  },
38
- "main": "dist/index.js",
39
- "types": "dist/index.d.ts",
40
- "typesVersions": {
41
- "*": {
42
- "*": [
43
- "./dist/*",
44
- "./*"
45
- ]
46
- }
51
+ "dependencies": {
52
+ "hash-sum": "^2.0.0",
53
+ "magic-string": "^0.30.21",
54
+ "ts-macro": "^0.3.7",
55
+ "unplugin": "^3.0.0",
56
+ "unplugin-utils": "^0.3.1"
57
+ },
58
+ "devDependencies": {
59
+ "@babel/parser": "^7.29.3",
60
+ "@babel/types": "^7.29.0",
61
+ "@nuxt/kit": "^4.5.2",
62
+ "@nuxt/schema": "^4.5.2",
63
+ "@shikijs/vitepress-twoslash": "^4.0.2",
64
+ "@ts-macro/tsc": "^0.3.7",
65
+ "@ts-macro/twoslash": "^0.0.5",
66
+ "@types/hash-sum": "^1.0.2",
67
+ "@vitejs/plugin-vue": "^6.0.6",
68
+ "@vue-macros/volar": "^3.1.4",
69
+ "ast-kit": "^2.2.0",
70
+ "typescript": "^6.0.3",
71
+ "vite-plugin-inspect": "^11.3.3",
72
+ "vue": "3.6.0-rc.8"
47
73
  },
48
- "files": [
49
- "dist"
50
- ],
51
74
  "peerDependencies": {
52
75
  "@nuxt/kit": "^3",
53
76
  "@nuxt/schema": "^3",
54
77
  "esbuild": "*",
78
+ "rolldown": "*",
55
79
  "rollup": "^3",
56
80
  "vite": ">=3",
57
81
  "vue": ">=3",
@@ -67,6 +91,9 @@
67
91
  "esbuild": {
68
92
  "optional": true
69
93
  },
94
+ "rolldown": {
95
+ "optional": true
96
+ },
70
97
  "rollup": {
71
98
  "optional": true
72
99
  },
@@ -77,24 +104,11 @@
77
104
  "optional": true
78
105
  }
79
106
  },
80
- "dependencies": {
81
- "hash-sum": "^2.0.0",
82
- "magic-string": "^0.30.21",
83
- "ts-macro": "^0.3.7",
84
- "unplugin": "^3.0.0",
85
- "unplugin-utils": "^0.3.1"
86
- },
87
- "devDependencies": {
88
- "@babel/parser": "^7.29.3",
89
- "@babel/types": "^7.29.0",
90
- "@nuxt/kit": "^3.21.4",
91
- "@nuxt/schema": "^3.21.4",
92
- "@types/hash-sum": "^1.0.2",
93
- "ast-kit": "^2.2.0",
94
- "vue": "3.6.0-rc.5"
95
- },
96
107
  "scripts": {
97
- "build": "tsdown",
98
- "dev": "DEV=true tsdown"
108
+ "build": "vp pack",
109
+ "dev": "DEV=true vp pack",
110
+ "typecheck": "tsmc --noEmit && tsmc -p playground --noEmit",
111
+ "play": "vp ./playground",
112
+ "play:build": "vp build ./playground"
99
113
  }
100
114
  }
@@ -1,92 +0,0 @@
1
- import { c as withDefaultsHelperId, d as use_model_default, i as getRequire, l as with_defaults_default, n as transformJsxMacros, o as useModelHelperId, s as useSlotsHelperId, u as use_slots_default } from "./core-BRE2gjfq.js";
2
- import { resolveOptions } from "./options.js";
3
- //#region src/core/style.ts
4
- let compileStyleAsync;
5
- async function getCompileStyleAsync() {
6
- if (compileStyleAsync) return compileStyleAsync;
7
- const require = getRequire();
8
- try {
9
- return compileStyleAsync = require ? require("vue/compiler-sfc").compileStyleAsync : (await import("https://esm.sh/@vue/compiler-sfc")).compileStyleAsync;
10
- } catch {}
11
- }
12
- async function transformStyle(code, id, options) {
13
- const query = new URLSearchParams(id.split("?")[1]);
14
- const compileStyleAsync = await getCompileStyleAsync();
15
- if (!compileStyleAsync) {
16
- console.warn(`Cannot require vue/compiler-sfc, please install Vue first.`);
17
- return "";
18
- }
19
- return (await compileStyleAsync({
20
- filename: id,
21
- id: `data-v-${query.get("scopeId")}`,
22
- isProd: options.isProduction,
23
- source: code,
24
- scoped: query.get("scoped") === "true"
25
- })).code;
26
- }
27
- //#endregion
28
- //#region src/raw.ts
29
- const plugin = (userOptions = {}) => {
30
- const options = resolveOptions(userOptions);
31
- const importMap = /* @__PURE__ */ new Map();
32
- const macrosHelperId = /^\/vue-jsx-vapor\/macros\//;
33
- const defineStyleHelperId = /^\/vue-jsx-vapor\/macros\/define-style/;
34
- return [{
35
- name: "@vue-jsx/macros",
36
- enforce: "pre",
37
- resolveId: {
38
- filter: { id: macrosHelperId },
39
- handler(id) {
40
- return id;
41
- }
42
- },
43
- load: {
44
- filter: { id: macrosHelperId },
45
- handler(id) {
46
- if (id === useModelHelperId) return use_model_default;
47
- if (id === withDefaultsHelperId) return with_defaults_default;
48
- if (id === useSlotsHelperId) return use_slots_default;
49
- }
50
- },
51
- transform: {
52
- filter: {
53
- id: {
54
- include: options.include,
55
- exclude: options.exclude
56
- },
57
- code: [
58
- ...options.defineComponent.alias,
59
- ...options.defineExpose.alias,
60
- ...options.defineModel.alias,
61
- ...options.defineSlots.alias,
62
- ...options.defineStyle.alias
63
- ]
64
- },
65
- handler(code, id) {
66
- return transformJsxMacros(code, id, importMap, options);
67
- }
68
- }
69
- }, {
70
- name: "@vue-jsx/macros/define-style",
71
- resolveId: {
72
- filter: { id: defineStyleHelperId },
73
- handler(id) {
74
- return id;
75
- }
76
- },
77
- load: {
78
- filter: { id: defineStyleHelperId },
79
- handler(id) {
80
- return importMap.get(id);
81
- }
82
- },
83
- transform: {
84
- filter: { id: defineStyleHelperId },
85
- handler(code, id) {
86
- return transformStyle(code, id, options);
87
- }
88
- }
89
- }];
90
- };
91
- //#endregion
92
- export { plugin as t };