@vue-jsx-vapor/compiler 2.5.1 → 2.5.2

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/index.cjs CHANGED
@@ -756,21 +756,10 @@ function genCreateComponent(operation, context) {
756
756
  const { helper } = context;
757
757
  const tag = genTag();
758
758
  const { root, props, slots, once } = operation;
759
+ const rawProps = genRawProps(props, context);
759
760
  const rawSlots = genRawSlots(slots, context);
760
- const [ids, handlers] = processInlineHandlers(props, context);
761
- const rawProps = context.withId(() => genRawProps(props, context), ids);
762
- const inlineHandlers = handlers.reduce((acc, { name, value }) => {
763
- const handler = genEventHandler(context, value, void 0, false);
764
- return [
765
- ...acc,
766
- `const ${name} = `,
767
- ...handler,
768
- NEWLINE
769
- ];
770
- }, []);
771
761
  return [
772
762
  NEWLINE,
773
- ...inlineHandlers,
774
763
  `const n${operation.id} = `,
775
764
  ...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
776
765
  ...genDirectivesForElement(operation.id, context)
@@ -786,33 +775,6 @@ function genCreateComponent(operation, context) {
786
775
  else return genExpression((0, __vue_shared.extend)((0, __vue_compiler_dom.createSimpleExpression)(operation.tag, false), { ast: null }), context);
787
776
  }
788
777
  }
789
- function getUniqueHandlerName(context, name) {
790
- const { seenInlineHandlerNames } = context;
791
- const count = seenInlineHandlerNames[name] || 0;
792
- seenInlineHandlerNames[name] = count + 1;
793
- return count === 0 ? name : `${name}${count}`;
794
- }
795
- function processInlineHandlers(props, context) {
796
- const ids = Object.create(null);
797
- const handlers = [];
798
- const staticProps = props[0];
799
- if ((0, __vue_shared.isArray)(staticProps)) for (const prop of staticProps) {
800
- if (!prop.handler) continue;
801
- prop.values.forEach((value, i) => {
802
- const isMemberExp = (0, __vue_compiler_dom.isMemberExpression)(value, context.options);
803
- if (!isMemberExp) {
804
- const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
805
- handlers.push({
806
- name,
807
- value
808
- });
809
- ids[name] = null;
810
- prop.values[i] = (0, __vue_shared.extend)({ ast: null }, (0, __vue_compiler_dom.createSimpleExpression)(name));
811
- }
812
- });
813
- }
814
- return [ids, handlers];
815
- }
816
778
  function genRawProps(props, context) {
817
779
  const staticProps = props[0];
818
780
  if ((0, __vue_shared.isArray)(staticProps)) {
@@ -1069,23 +1031,27 @@ function genFor(oper, context) {
1069
1031
  idMap[indexVar] = null;
1070
1032
  }
1071
1033
  const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1072
- const patternFrag = [];
1034
+ const selectorDeclarations = [];
1035
+ const selectorSetup = [];
1073
1036
  for (const [i, { selector }] of selectorPatterns.entries()) {
1074
1037
  const selectorName = `_selector${id}_${i}`;
1075
- patternFrag.push(NEWLINE, `const ${selectorName} = `, ...genCall(`n${id}.useSelector`, [`() => `, ...genExpression(selector, context)]));
1038
+ selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
1039
+ if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
1040
+ selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
1041
+ if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
1076
1042
  }
1077
1043
  const blockFn = context.withId(() => {
1078
1044
  const frag = [];
1079
1045
  frag.push("(", ...args, ") => {", INDENT_START);
1080
1046
  if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
1081
- const patternFrag$1 = [];
1047
+ const patternFrag = [];
1082
1048
  for (const [i, { effect }] of selectorPatterns.entries()) {
1083
- patternFrag$1.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1084
- for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1085
- patternFrag$1.push(INDENT_END, NEWLINE, `})`);
1049
+ patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1050
+ for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
1051
+ patternFrag.push(INDENT_END, NEWLINE, `})`);
1086
1052
  }
1087
- for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1088
- return patternFrag$1;
1053
+ for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
1054
+ return patternFrag;
1089
1055
  }));
1090
1056
  else frag.push(...genBlockContent(render, context));
1091
1057
  frag.push(INDENT_END, NEWLINE, "}");
@@ -1098,9 +1064,9 @@ function genFor(oper, context) {
1098
1064
  if (once) flags |= VaporVForFlags.ONCE;
1099
1065
  return [
1100
1066
  NEWLINE,
1067
+ ...selectorDeclarations,
1101
1068
  `const n${id} = `,
1102
- ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1103
- ...patternFrag
1069
+ ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
1104
1070
  ];
1105
1071
  function parseValueDestructure() {
1106
1072
  const map = /* @__PURE__ */ new Map();
@@ -1553,7 +1519,6 @@ var CodegenContext = class {
1553
1519
  };
1554
1520
  delegates = /* @__PURE__ */ new Set();
1555
1521
  identifiers = Object.create(null);
1556
- seenInlineHandlerNames = Object.create(null);
1557
1522
  block;
1558
1523
  withId(fn, map) {
1559
1524
  const { identifiers } = this;
package/dist/index.d.cts CHANGED
@@ -353,7 +353,6 @@ declare class CodegenContext {
353
353
  helper: (name: string) => string;
354
354
  delegates: Set<string>;
355
355
  identifiers: Record<string, (string | SimpleExpressionNode)[]>;
356
- seenInlineHandlerNames: Record<string, number>;
357
356
  block: BlockIRNode;
358
357
  withId<T>(fn: () => T, map: Record<string, string | SimpleExpressionNode | null>): T;
359
358
  enterBlock(block: BlockIRNode): () => BlockIRNode;
package/dist/index.d.ts CHANGED
@@ -353,7 +353,6 @@ declare class CodegenContext {
353
353
  helper: (name: string) => string;
354
354
  delegates: Set<string>;
355
355
  identifiers: Record<string, (string | SimpleExpressionNode)[]>;
356
- seenInlineHandlerNames: Record<string, number>;
357
356
  block: BlockIRNode;
358
357
  withId<T>(fn: () => T, map: Record<string, string | SimpleExpressionNode | null>): T;
359
358
  enterBlock(block: BlockIRNode): () => BlockIRNode;
package/dist/index.js CHANGED
@@ -733,21 +733,10 @@ function genCreateComponent(operation, context) {
733
733
  const { helper } = context;
734
734
  const tag = genTag();
735
735
  const { root, props, slots, once } = operation;
736
+ const rawProps = genRawProps(props, context);
736
737
  const rawSlots = genRawSlots(slots, context);
737
- const [ids, handlers] = processInlineHandlers(props, context);
738
- const rawProps = context.withId(() => genRawProps(props, context), ids);
739
- const inlineHandlers = handlers.reduce((acc, { name, value }) => {
740
- const handler = genEventHandler(context, value, void 0, false);
741
- return [
742
- ...acc,
743
- `const ${name} = `,
744
- ...handler,
745
- NEWLINE
746
- ];
747
- }, []);
748
738
  return [
749
739
  NEWLINE,
750
- ...inlineHandlers,
751
740
  `const n${operation.id} = `,
752
741
  ...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
753
742
  ...genDirectivesForElement(operation.id, context)
@@ -763,33 +752,6 @@ function genCreateComponent(operation, context) {
763
752
  else return genExpression(extend(createSimpleExpression(operation.tag, false), { ast: null }), context);
764
753
  }
765
754
  }
766
- function getUniqueHandlerName(context, name) {
767
- const { seenInlineHandlerNames } = context;
768
- const count = seenInlineHandlerNames[name] || 0;
769
- seenInlineHandlerNames[name] = count + 1;
770
- return count === 0 ? name : `${name}${count}`;
771
- }
772
- function processInlineHandlers(props, context) {
773
- const ids = Object.create(null);
774
- const handlers = [];
775
- const staticProps = props[0];
776
- if (isArray(staticProps)) for (const prop of staticProps) {
777
- if (!prop.handler) continue;
778
- prop.values.forEach((value, i) => {
779
- const isMemberExp = isMemberExpression(value, context.options);
780
- if (!isMemberExp) {
781
- const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
782
- handlers.push({
783
- name,
784
- value
785
- });
786
- ids[name] = null;
787
- prop.values[i] = extend({ ast: null }, createSimpleExpression(name));
788
- }
789
- });
790
- }
791
- return [ids, handlers];
792
- }
793
755
  function genRawProps(props, context) {
794
756
  const staticProps = props[0];
795
757
  if (isArray(staticProps)) {
@@ -1046,23 +1008,27 @@ function genFor(oper, context) {
1046
1008
  idMap[indexVar] = null;
1047
1009
  }
1048
1010
  const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1049
- const patternFrag = [];
1011
+ const selectorDeclarations = [];
1012
+ const selectorSetup = [];
1050
1013
  for (const [i, { selector }] of selectorPatterns.entries()) {
1051
1014
  const selectorName = `_selector${id}_${i}`;
1052
- patternFrag.push(NEWLINE, `const ${selectorName} = `, ...genCall(`n${id}.useSelector`, [`() => `, ...genExpression(selector, context)]));
1015
+ selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
1016
+ if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
1017
+ selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
1018
+ if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
1053
1019
  }
1054
1020
  const blockFn = context.withId(() => {
1055
1021
  const frag = [];
1056
1022
  frag.push("(", ...args, ") => {", INDENT_START);
1057
1023
  if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
1058
- const patternFrag$1 = [];
1024
+ const patternFrag = [];
1059
1025
  for (const [i, { effect }] of selectorPatterns.entries()) {
1060
- patternFrag$1.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1061
- for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1062
- patternFrag$1.push(INDENT_END, NEWLINE, `})`);
1026
+ patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1027
+ for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
1028
+ patternFrag.push(INDENT_END, NEWLINE, `})`);
1063
1029
  }
1064
- for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1065
- return patternFrag$1;
1030
+ for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
1031
+ return patternFrag;
1066
1032
  }));
1067
1033
  else frag.push(...genBlockContent(render, context));
1068
1034
  frag.push(INDENT_END, NEWLINE, "}");
@@ -1075,9 +1041,9 @@ function genFor(oper, context) {
1075
1041
  if (once) flags |= VaporVForFlags.ONCE;
1076
1042
  return [
1077
1043
  NEWLINE,
1044
+ ...selectorDeclarations,
1078
1045
  `const n${id} = `,
1079
- ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1080
- ...patternFrag
1046
+ ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
1081
1047
  ];
1082
1048
  function parseValueDestructure() {
1083
1049
  const map = /* @__PURE__ */ new Map();
@@ -1530,7 +1496,6 @@ var CodegenContext = class {
1530
1496
  };
1531
1497
  delegates = /* @__PURE__ */ new Set();
1532
1498
  identifiers = Object.create(null);
1533
- seenInlineHandlerNames = Object.create(null);
1534
1499
  block;
1535
1500
  withId(fn, map) {
1536
1501
  const { identifiers } = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Vue JSX Vapor Compiler",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "@babel/parser": "^7.28.0",
38
38
  "@babel/types": "^7.28.0",
39
- "@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@73bceb2",
40
- "@vue/shared": "https://pkg.pr.new/@vue/shared@73bceb2",
39
+ "@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@5771104",
40
+ "@vue/shared": "https://pkg.pr.new/@vue/shared@5771104",
41
41
  "ast-kit": "^2.1.1",
42
42
  "source-map-js": "^1.2.1"
43
43
  },