@vue-jsx-vapor/compiler 2.5.0 → 2.5.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.
Files changed (3) hide show
  1. package/dist/index.cjs +164 -18
  2. package/dist/index.js +166 -20
  3. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -801,7 +801,7 @@ function processInlineHandlers(props, context) {
801
801
  prop.values.forEach((value, i) => {
802
802
  const isMemberExp = (0, __vue_compiler_dom.isMemberExpression)(value, context.options);
803
803
  if (!isMemberExp) {
804
- const name = getUniqueHandlerName(context, `_on_${prop.key.content}`);
804
+ const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
805
805
  handlers.push({
806
806
  name,
807
807
  value
@@ -1068,7 +1068,29 @@ function genFor(oper, context) {
1068
1068
  idMap[rawIndex] = `${indexVar}.value`;
1069
1069
  idMap[indexVar] = null;
1070
1070
  }
1071
- const blockFn = context.withId(() => genBlock(render, context, args), idMap);
1071
+ const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1072
+ const patternFrag = [];
1073
+ for (const [i, { selector }] of selectorPatterns.entries()) {
1074
+ const selectorName = `_selector${id}_${i}`;
1075
+ patternFrag.push(NEWLINE, `const ${selectorName} = `, ...genCall(`n${id}.useSelector`, [`() => `, ...genExpression(selector, context)]));
1076
+ }
1077
+ const blockFn = context.withId(() => {
1078
+ const frag = [];
1079
+ frag.push("(", ...args, ") => {", INDENT_START);
1080
+ if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
1081
+ const patternFrag$1 = [];
1082
+ 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, `})`);
1086
+ }
1087
+ for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1088
+ return patternFrag$1;
1089
+ }));
1090
+ else frag.push(...genBlockContent(render, context));
1091
+ frag.push(INDENT_END, NEWLINE, "}");
1092
+ return frag;
1093
+ }, idMap);
1072
1094
  exitScope();
1073
1095
  let flags = 0;
1074
1096
  if (onlyChild) flags |= VaporVForFlags.FAST_REMOVE;
@@ -1077,7 +1099,8 @@ function genFor(oper, context) {
1077
1099
  return [
1078
1100
  NEWLINE,
1079
1101
  `const n${id} = `,
1080
- ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0)
1102
+ ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1103
+ ...patternFrag
1081
1104
  ];
1082
1105
  function parseValueDestructure() {
1083
1106
  const map = /* @__PURE__ */ new Map();
@@ -1151,6 +1174,131 @@ function genFor(oper, context) {
1151
1174
  return idMap$1;
1152
1175
  }
1153
1176
  }
1177
+ function matchPatterns(render, keyProp, idMap) {
1178
+ const selectorPatterns = [];
1179
+ const keyOnlyBindingPatterns = [];
1180
+ render.effect = render.effect.filter((effect) => {
1181
+ if (keyProp !== void 0) {
1182
+ const selector = matchSelectorPattern(effect, keyProp.ast, idMap);
1183
+ if (selector) {
1184
+ selectorPatterns.push(selector);
1185
+ return false;
1186
+ }
1187
+ const keyOnly = matchKeyOnlyBindingPattern(effect, keyProp.ast);
1188
+ if (keyOnly) {
1189
+ keyOnlyBindingPatterns.push(keyOnly);
1190
+ return false;
1191
+ }
1192
+ }
1193
+ return true;
1194
+ });
1195
+ return {
1196
+ keyOnlyBindingPatterns,
1197
+ selectorPatterns
1198
+ };
1199
+ }
1200
+ function matchKeyOnlyBindingPattern(effect, keyAst) {
1201
+ if (effect.expressions.length === 1) {
1202
+ const ast = effect.expressions[0].ast;
1203
+ if (typeof ast === "object" && ast !== null && isKeyOnlyBinding(ast, keyAst)) return { effect };
1204
+ }
1205
+ }
1206
+ function matchSelectorPattern(effect, keyAst, idMap) {
1207
+ if (effect.expressions.length === 1) {
1208
+ const ast = effect.expressions[0].ast;
1209
+ const offset = effect.expressions[0].loc.start.offset;
1210
+ if (typeof ast === "object" && ast) {
1211
+ const matcheds = [];
1212
+ (0, ast_kit.walkAST)(ast, { enter(node) {
1213
+ if (typeof node === "object" && node && node.type === "BinaryExpression" && node.operator === "===" && node.left.type !== "PrivateName") {
1214
+ const { left, right } = node;
1215
+ for (const [a, b] of [[left, right], [right, left]]) {
1216
+ const aIsKey = isKeyOnlyBinding(a, keyAst);
1217
+ const bIsKey = isKeyOnlyBinding(b, keyAst);
1218
+ const bVars = analyzeVariableScopes(b, idMap);
1219
+ if (aIsKey && !bIsKey && !bVars.locals.length) matcheds.push([a, b]);
1220
+ }
1221
+ }
1222
+ } });
1223
+ if (matcheds.length === 1) {
1224
+ const [key, selector] = matcheds[0];
1225
+ const content$1 = effect.expressions[0].content;
1226
+ let hasExtraId = false;
1227
+ const parentStackMap = /* @__PURE__ */ new Map();
1228
+ const parentStack = [];
1229
+ (0, __vue_compiler_dom.walkIdentifiers)(ast, (id) => {
1230
+ if (id.start !== key.start && id.start !== selector.start) hasExtraId = true;
1231
+ parentStackMap.set(id, parentStack.slice());
1232
+ }, false, parentStack);
1233
+ if (!hasExtraId) {
1234
+ const name = content$1.slice(selector.start - offset, selector.end - offset);
1235
+ return {
1236
+ effect,
1237
+ selector: {
1238
+ content: name,
1239
+ ast: (0, __vue_shared.extend)({}, selector, {
1240
+ start: 1,
1241
+ end: name.length + 1
1242
+ }),
1243
+ loc: selector.loc,
1244
+ isStatic: false
1245
+ }
1246
+ };
1247
+ }
1248
+ }
1249
+ }
1250
+ const content = effect.expressions[0].content;
1251
+ if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && (0, __vue_compiler_dom.isStaticNode)(ast.consequent) && (0, __vue_compiler_dom.isStaticNode)(ast.alternate)) {
1252
+ const left = ast.test.left;
1253
+ const right = ast.test.right;
1254
+ for (const [a, b] of [[left, right], [right, left]]) {
1255
+ const aIsKey = isKeyOnlyBinding(a, keyAst);
1256
+ const bIsKey = isKeyOnlyBinding(b, keyAst);
1257
+ const bVars = analyzeVariableScopes(b, idMap);
1258
+ if (aIsKey && !bIsKey && !bVars.locals.length) return {
1259
+ effect,
1260
+ selector: {
1261
+ content: content.slice(b.start - offset, b.end - offset),
1262
+ ast: b,
1263
+ loc: b.loc,
1264
+ isStatic: false
1265
+ }
1266
+ };
1267
+ }
1268
+ }
1269
+ }
1270
+ }
1271
+ function analyzeVariableScopes(ast, idMap) {
1272
+ const globals = [];
1273
+ const locals = [];
1274
+ const ids = [];
1275
+ const parentStackMap = /* @__PURE__ */ new Map();
1276
+ const parentStack = [];
1277
+ (0, __vue_compiler_dom.walkIdentifiers)(ast, (id) => {
1278
+ ids.push(id);
1279
+ parentStackMap.set(id, parentStack.slice());
1280
+ }, false, parentStack);
1281
+ for (const id of ids) {
1282
+ if ((0, __vue_shared.isGloballyAllowed)(id.name)) continue;
1283
+ if (idMap[id.name]) locals.push(id.name);
1284
+ else globals.push(id.name);
1285
+ }
1286
+ return {
1287
+ globals,
1288
+ locals
1289
+ };
1290
+ }
1291
+ function isKeyOnlyBinding(expr, keyAst) {
1292
+ let only = true;
1293
+ (0, ast_kit.walkAST)(expr, { enter(node) {
1294
+ if ((0, __babel_types.isNodesEquivalent)(node, keyAst)) {
1295
+ this.skip();
1296
+ return;
1297
+ }
1298
+ if (node.type === "Identifier") only = false;
1299
+ } });
1300
+ return only;
1301
+ }
1154
1302
 
1155
1303
  //#endregion
1156
1304
  //#region src/generators/html.ts
@@ -1267,7 +1415,7 @@ function genOperation(oper, context) {
1267
1415
  }
1268
1416
  }
1269
1417
  }
1270
- function genEffects(effects, context) {
1418
+ function genEffects(effects, context, genExtraFrag) {
1271
1419
  const { helper } = context;
1272
1420
  const [frag, push, unshift] = buildCodeFragment();
1273
1421
  let operationsCount = 0;
@@ -1287,6 +1435,7 @@ function genEffects(effects, context) {
1287
1435
  unshift(NEWLINE, `${helper("renderEffect")}(() => `);
1288
1436
  push(`)`);
1289
1437
  }
1438
+ if (genExtraFrag) push(...context.withId(genExtraFrag, {}));
1290
1439
  return frag;
1291
1440
  }
1292
1441
  function genEffect({ operations }, context) {
@@ -1353,19 +1502,19 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1353
1502
 
1354
1503
  //#endregion
1355
1504
  //#region src/generators/block.ts
1356
- function genBlock(oper, context, args = [], root, customReturns) {
1505
+ function genBlock(oper, context, args = [], root) {
1357
1506
  return [
1358
1507
  "(",
1359
1508
  ...args,
1360
1509
  ") => {",
1361
1510
  INDENT_START,
1362
- ...genBlockContent(oper, context, root, customReturns),
1511
+ ...genBlockContent(oper, context, root),
1363
1512
  INDENT_END,
1364
1513
  NEWLINE,
1365
1514
  "}"
1366
1515
  ];
1367
1516
  }
1368
- function genBlockContent(block, context, root, customReturns) {
1517
+ function genBlockContent(block, context, root, genEffectsExtraFrag) {
1369
1518
  const [frag, push] = buildCodeFragment();
1370
1519
  const { dynamic, effect, operation, returns } = block;
1371
1520
  const resetBlock = context.enterBlock(block);
@@ -1381,11 +1530,11 @@ function genBlockContent(block, context, root, customReturns) {
1381
1530
  for (const child of dynamic.children) push(...genSelf(child, context));
1382
1531
  for (const child of dynamic.children) push(...genChildren(child, context, push, `n${child.id}`));
1383
1532
  push(...genOperations(operation, context));
1384
- push(...genEffects(effect, context));
1533
+ push(...genEffects(effect, context, genEffectsExtraFrag));
1385
1534
  push(NEWLINE, `return `);
1386
1535
  const returnNodes = returns.map((n) => `n${n}`);
1387
1536
  const returnsCode = returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "null"];
1388
- push(...customReturns ? customReturns(returnsCode) : returnsCode);
1537
+ push(...returnsCode);
1389
1538
  resetBlock();
1390
1539
  return frag;
1391
1540
  function genResolveAssets(kind, helper) {
@@ -2273,9 +2422,9 @@ function hasDynamicKeyVBind(node) {
2273
2422
  const delegatedEvents = /* @__PURE__ */ (0, __vue_shared.makeMap)("beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart");
2274
2423
  const transformVOn = (dir, node, context) => {
2275
2424
  const { name, loc, value } = dir;
2276
- if (name.type === "JSXNamespacedName") return;
2425
+ if (!name) return;
2277
2426
  const isComponent = isJSXComponent(node);
2278
- const [nameString, ...modifiers] = name.name.replace(/^on([A-Z])/, (_, $1) => $1.toLowerCase()).split("_");
2427
+ const [nameString, ...modifiers] = context.ir.source.slice(name.start, name.end).replace(/^on([A-Z])/, (_, $1) => $1.toLowerCase()).split("_");
2279
2428
  if (!value && !modifiers.length) context.options.onError((0, __vue_compiler_dom.createCompilerError)(__vue_compiler_dom.ErrorCodes.X_V_ON_NO_EXPRESSION, resolveLocation(loc, context)));
2280
2429
  let arg = resolveSimpleExpression(nameString, true, dir.name.loc);
2281
2430
  const exp = resolveExpression(dir.value, context);
@@ -2473,13 +2622,10 @@ function createSlotBlock(slotNode, dir, context) {
2473
2622
  //#region src/transforms/vSlots.ts
2474
2623
  const transformVSlots = (dir, node, context) => {
2475
2624
  if (!isJSXComponent(node)) return;
2476
- if (dir.value?.type === "JSXExpressionContainer") {
2477
- context.slots = [{
2478
- slotType: IRSlotType.EXPRESSION,
2479
- slots: resolveExpression(dir.value.expression, context)
2480
- }];
2481
- if (node.children.length) context.options.onError((0, __vue_compiler_dom.createCompilerError)(__vue_compiler_dom.ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, resolveLocation(node.children[0].loc, context)));
2482
- }
2625
+ if (dir.value?.type === "JSXExpressionContainer") context.slots = [{
2626
+ slotType: IRSlotType.EXPRESSION,
2627
+ slots: resolveExpression(dir.value.expression, context)
2628
+ }];
2483
2629
  };
2484
2630
 
2485
2631
  //#endregion
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { parse, parseExpression } from "@babel/parser";
2
2
  import { NOOP, camelize, canSetValueDirectly, capitalize, extend, isArray, isBuiltInDirective, isGloballyAllowed, isHTMLTag, isSVGTag, isString, isVoidTag, makeMap, remove, shouldSetAsAttr, toHandlerKey } from "@vue/shared";
3
3
  import { DOMErrorCodes, ErrorCodes, NewlineType, NodeTypes, TS_NODE_TYPES, advancePositionWithClone, advancePositionWithMutation, createCompilerError, createDOMCompilerError, createSimpleExpression, defaultOnError, defaultOnWarn, isConstantNode, isFnExpression, isLiteralWhitelisted, isMemberExpression, isSimpleIdentifier, isStaticNode, isStaticProperty, isValidHTMLNesting, locStub, resolveModifiers, toValidAssetId, unwrapTSNode, walkIdentifiers } from "@vue/compiler-dom";
4
- import { walkIdentifiers as walkIdentifiers$1 } from "ast-kit";
5
- import { isLiteral, jsxClosingFragment, jsxExpressionContainer, jsxFragment, jsxOpeningFragment } from "@babel/types";
4
+ import { walkAST, walkIdentifiers as walkIdentifiers$1 } from "ast-kit";
5
+ import { isLiteral, isNodesEquivalent, jsxClosingFragment, jsxExpressionContainer, jsxFragment, jsxOpeningFragment } from "@babel/types";
6
6
  import { SourceMapGenerator } from "source-map-js";
7
7
 
8
8
  //#region src/ir/component.ts
@@ -778,7 +778,7 @@ function processInlineHandlers(props, context) {
778
778
  prop.values.forEach((value, i) => {
779
779
  const isMemberExp = isMemberExpression(value, context.options);
780
780
  if (!isMemberExp) {
781
- const name = getUniqueHandlerName(context, `_on_${prop.key.content}`);
781
+ const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
782
782
  handlers.push({
783
783
  name,
784
784
  value
@@ -1045,7 +1045,29 @@ function genFor(oper, context) {
1045
1045
  idMap[rawIndex] = `${indexVar}.value`;
1046
1046
  idMap[indexVar] = null;
1047
1047
  }
1048
- const blockFn = context.withId(() => genBlock(render, context, args), idMap);
1048
+ const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1049
+ const patternFrag = [];
1050
+ for (const [i, { selector }] of selectorPatterns.entries()) {
1051
+ const selectorName = `_selector${id}_${i}`;
1052
+ patternFrag.push(NEWLINE, `const ${selectorName} = `, ...genCall(`n${id}.useSelector`, [`() => `, ...genExpression(selector, context)]));
1053
+ }
1054
+ const blockFn = context.withId(() => {
1055
+ const frag = [];
1056
+ frag.push("(", ...args, ") => {", INDENT_START);
1057
+ if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
1058
+ const patternFrag$1 = [];
1059
+ 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, `})`);
1063
+ }
1064
+ for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag$1.push(...genOperation(oper$1, context));
1065
+ return patternFrag$1;
1066
+ }));
1067
+ else frag.push(...genBlockContent(render, context));
1068
+ frag.push(INDENT_END, NEWLINE, "}");
1069
+ return frag;
1070
+ }, idMap);
1049
1071
  exitScope();
1050
1072
  let flags = 0;
1051
1073
  if (onlyChild) flags |= VaporVForFlags.FAST_REMOVE;
@@ -1054,7 +1076,8 @@ function genFor(oper, context) {
1054
1076
  return [
1055
1077
  NEWLINE,
1056
1078
  `const n${id} = `,
1057
- ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0)
1079
+ ...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1080
+ ...patternFrag
1058
1081
  ];
1059
1082
  function parseValueDestructure() {
1060
1083
  const map = /* @__PURE__ */ new Map();
@@ -1128,6 +1151,131 @@ function genFor(oper, context) {
1128
1151
  return idMap$1;
1129
1152
  }
1130
1153
  }
1154
+ function matchPatterns(render, keyProp, idMap) {
1155
+ const selectorPatterns = [];
1156
+ const keyOnlyBindingPatterns = [];
1157
+ render.effect = render.effect.filter((effect) => {
1158
+ if (keyProp !== void 0) {
1159
+ const selector = matchSelectorPattern(effect, keyProp.ast, idMap);
1160
+ if (selector) {
1161
+ selectorPatterns.push(selector);
1162
+ return false;
1163
+ }
1164
+ const keyOnly = matchKeyOnlyBindingPattern(effect, keyProp.ast);
1165
+ if (keyOnly) {
1166
+ keyOnlyBindingPatterns.push(keyOnly);
1167
+ return false;
1168
+ }
1169
+ }
1170
+ return true;
1171
+ });
1172
+ return {
1173
+ keyOnlyBindingPatterns,
1174
+ selectorPatterns
1175
+ };
1176
+ }
1177
+ function matchKeyOnlyBindingPattern(effect, keyAst) {
1178
+ if (effect.expressions.length === 1) {
1179
+ const ast = effect.expressions[0].ast;
1180
+ if (typeof ast === "object" && ast !== null && isKeyOnlyBinding(ast, keyAst)) return { effect };
1181
+ }
1182
+ }
1183
+ function matchSelectorPattern(effect, keyAst, idMap) {
1184
+ if (effect.expressions.length === 1) {
1185
+ const ast = effect.expressions[0].ast;
1186
+ const offset = effect.expressions[0].loc.start.offset;
1187
+ if (typeof ast === "object" && ast) {
1188
+ const matcheds = [];
1189
+ walkAST(ast, { enter(node) {
1190
+ if (typeof node === "object" && node && node.type === "BinaryExpression" && node.operator === "===" && node.left.type !== "PrivateName") {
1191
+ const { left, right } = node;
1192
+ for (const [a, b] of [[left, right], [right, left]]) {
1193
+ const aIsKey = isKeyOnlyBinding(a, keyAst);
1194
+ const bIsKey = isKeyOnlyBinding(b, keyAst);
1195
+ const bVars = analyzeVariableScopes(b, idMap);
1196
+ if (aIsKey && !bIsKey && !bVars.locals.length) matcheds.push([a, b]);
1197
+ }
1198
+ }
1199
+ } });
1200
+ if (matcheds.length === 1) {
1201
+ const [key, selector] = matcheds[0];
1202
+ const content$1 = effect.expressions[0].content;
1203
+ let hasExtraId = false;
1204
+ const parentStackMap = /* @__PURE__ */ new Map();
1205
+ const parentStack = [];
1206
+ walkIdentifiers(ast, (id) => {
1207
+ if (id.start !== key.start && id.start !== selector.start) hasExtraId = true;
1208
+ parentStackMap.set(id, parentStack.slice());
1209
+ }, false, parentStack);
1210
+ if (!hasExtraId) {
1211
+ const name = content$1.slice(selector.start - offset, selector.end - offset);
1212
+ return {
1213
+ effect,
1214
+ selector: {
1215
+ content: name,
1216
+ ast: extend({}, selector, {
1217
+ start: 1,
1218
+ end: name.length + 1
1219
+ }),
1220
+ loc: selector.loc,
1221
+ isStatic: false
1222
+ }
1223
+ };
1224
+ }
1225
+ }
1226
+ }
1227
+ const content = effect.expressions[0].content;
1228
+ if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && isStaticNode(ast.consequent) && isStaticNode(ast.alternate)) {
1229
+ const left = ast.test.left;
1230
+ const right = ast.test.right;
1231
+ for (const [a, b] of [[left, right], [right, left]]) {
1232
+ const aIsKey = isKeyOnlyBinding(a, keyAst);
1233
+ const bIsKey = isKeyOnlyBinding(b, keyAst);
1234
+ const bVars = analyzeVariableScopes(b, idMap);
1235
+ if (aIsKey && !bIsKey && !bVars.locals.length) return {
1236
+ effect,
1237
+ selector: {
1238
+ content: content.slice(b.start - offset, b.end - offset),
1239
+ ast: b,
1240
+ loc: b.loc,
1241
+ isStatic: false
1242
+ }
1243
+ };
1244
+ }
1245
+ }
1246
+ }
1247
+ }
1248
+ function analyzeVariableScopes(ast, idMap) {
1249
+ const globals = [];
1250
+ const locals = [];
1251
+ const ids = [];
1252
+ const parentStackMap = /* @__PURE__ */ new Map();
1253
+ const parentStack = [];
1254
+ walkIdentifiers(ast, (id) => {
1255
+ ids.push(id);
1256
+ parentStackMap.set(id, parentStack.slice());
1257
+ }, false, parentStack);
1258
+ for (const id of ids) {
1259
+ if (isGloballyAllowed(id.name)) continue;
1260
+ if (idMap[id.name]) locals.push(id.name);
1261
+ else globals.push(id.name);
1262
+ }
1263
+ return {
1264
+ globals,
1265
+ locals
1266
+ };
1267
+ }
1268
+ function isKeyOnlyBinding(expr, keyAst) {
1269
+ let only = true;
1270
+ walkAST(expr, { enter(node) {
1271
+ if (isNodesEquivalent(node, keyAst)) {
1272
+ this.skip();
1273
+ return;
1274
+ }
1275
+ if (node.type === "Identifier") only = false;
1276
+ } });
1277
+ return only;
1278
+ }
1131
1279
 
1132
1280
  //#endregion
1133
1281
  //#region src/generators/html.ts
@@ -1244,7 +1392,7 @@ function genOperation(oper, context) {
1244
1392
  }
1245
1393
  }
1246
1394
  }
1247
- function genEffects(effects, context) {
1395
+ function genEffects(effects, context, genExtraFrag) {
1248
1396
  const { helper } = context;
1249
1397
  const [frag, push, unshift] = buildCodeFragment();
1250
1398
  let operationsCount = 0;
@@ -1264,6 +1412,7 @@ function genEffects(effects, context) {
1264
1412
  unshift(NEWLINE, `${helper("renderEffect")}(() => `);
1265
1413
  push(`)`);
1266
1414
  }
1415
+ if (genExtraFrag) push(...context.withId(genExtraFrag, {}));
1267
1416
  return frag;
1268
1417
  }
1269
1418
  function genEffect({ operations }, context) {
@@ -1330,19 +1479,19 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
1330
1479
 
1331
1480
  //#endregion
1332
1481
  //#region src/generators/block.ts
1333
- function genBlock(oper, context, args = [], root, customReturns) {
1482
+ function genBlock(oper, context, args = [], root) {
1334
1483
  return [
1335
1484
  "(",
1336
1485
  ...args,
1337
1486
  ") => {",
1338
1487
  INDENT_START,
1339
- ...genBlockContent(oper, context, root, customReturns),
1488
+ ...genBlockContent(oper, context, root),
1340
1489
  INDENT_END,
1341
1490
  NEWLINE,
1342
1491
  "}"
1343
1492
  ];
1344
1493
  }
1345
- function genBlockContent(block, context, root, customReturns) {
1494
+ function genBlockContent(block, context, root, genEffectsExtraFrag) {
1346
1495
  const [frag, push] = buildCodeFragment();
1347
1496
  const { dynamic, effect, operation, returns } = block;
1348
1497
  const resetBlock = context.enterBlock(block);
@@ -1358,11 +1507,11 @@ function genBlockContent(block, context, root, customReturns) {
1358
1507
  for (const child of dynamic.children) push(...genSelf(child, context));
1359
1508
  for (const child of dynamic.children) push(...genChildren(child, context, push, `n${child.id}`));
1360
1509
  push(...genOperations(operation, context));
1361
- push(...genEffects(effect, context));
1510
+ push(...genEffects(effect, context, genEffectsExtraFrag));
1362
1511
  push(NEWLINE, `return `);
1363
1512
  const returnNodes = returns.map((n) => `n${n}`);
1364
1513
  const returnsCode = returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "null"];
1365
- push(...customReturns ? customReturns(returnsCode) : returnsCode);
1514
+ push(...returnsCode);
1366
1515
  resetBlock();
1367
1516
  return frag;
1368
1517
  function genResolveAssets(kind, helper) {
@@ -2250,9 +2399,9 @@ function hasDynamicKeyVBind(node) {
2250
2399
  const delegatedEvents = /* @__PURE__ */ makeMap("beforeinput,click,dblclick,contextmenu,focusin,focusout,input,keydown,keyup,mousedown,mousemove,mouseout,mouseover,mouseup,pointerdown,pointermove,pointerout,pointerover,pointerup,touchend,touchmove,touchstart");
2251
2400
  const transformVOn = (dir, node, context) => {
2252
2401
  const { name, loc, value } = dir;
2253
- if (name.type === "JSXNamespacedName") return;
2402
+ if (!name) return;
2254
2403
  const isComponent = isJSXComponent(node);
2255
- const [nameString, ...modifiers] = name.name.replace(/^on([A-Z])/, (_, $1) => $1.toLowerCase()).split("_");
2404
+ const [nameString, ...modifiers] = context.ir.source.slice(name.start, name.end).replace(/^on([A-Z])/, (_, $1) => $1.toLowerCase()).split("_");
2256
2405
  if (!value && !modifiers.length) context.options.onError(createCompilerError(ErrorCodes.X_V_ON_NO_EXPRESSION, resolveLocation(loc, context)));
2257
2406
  let arg = resolveSimpleExpression(nameString, true, dir.name.loc);
2258
2407
  const exp = resolveExpression(dir.value, context);
@@ -2450,13 +2599,10 @@ function createSlotBlock(slotNode, dir, context) {
2450
2599
  //#region src/transforms/vSlots.ts
2451
2600
  const transformVSlots = (dir, node, context) => {
2452
2601
  if (!isJSXComponent(node)) return;
2453
- if (dir.value?.type === "JSXExpressionContainer") {
2454
- context.slots = [{
2455
- slotType: IRSlotType.EXPRESSION,
2456
- slots: resolveExpression(dir.value.expression, context)
2457
- }];
2458
- if (node.children.length) context.options.onError(createCompilerError(ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, resolveLocation(node.children[0].loc, context)));
2459
- }
2602
+ if (dir.value?.type === "JSXExpressionContainer") context.slots = [{
2603
+ slotType: IRSlotType.EXPRESSION,
2604
+ slots: resolveExpression(dir.value.expression, context)
2605
+ }];
2460
2606
  };
2461
2607
 
2462
2608
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
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@51677cd",
40
- "@vue/shared": "https://pkg.pr.new/@vue/shared@51677cd",
39
+ "@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@73bceb2",
40
+ "@vue/shared": "https://pkg.pr.new/@vue/shared@73bceb2",
41
41
  "ast-kit": "^2.1.1",
42
42
  "source-map-js": "^1.2.1"
43
43
  },