@vue-jsx-vapor/compiler 0.2.6 → 0.2.8

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
@@ -248,10 +248,11 @@ function resolveNode(node, context) {
248
248
  var namespaceRE = /^(?:\$([\w-]+)\$)?([\w-]+)?/;
249
249
  function resolveDirectiveNode(node, context, withFn = false) {
250
250
  const { value, name } = node;
251
- const nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
251
+ let nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
252
252
  let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
253
253
  if (name.type !== "JSXNamespacedName" && !argString) {
254
- const [, modifiers2] = nameString.split("_");
254
+ const [newName, modifiers2] = nameString.split("_");
255
+ nameString = newName;
255
256
  argString = `_${modifiers2}`;
256
257
  }
257
258
  let modifiers = [];
@@ -274,7 +275,7 @@ function resolveDirectiveNode(node, context, withFn = false) {
274
275
  const exp = value ? withFn && value.type === "JSXExpressionContainer" ? resolveExpressionWithFn(value.expression, context) : resolveExpression(value, context) : void 0;
275
276
  return {
276
277
  type: _compilerdom.NodeTypes.DIRECTIVE,
277
- name: nameString,
278
+ name: nameString.slice(2),
278
279
  rawName: `${nameString}:${argString}`,
279
280
  exp,
280
281
  arg,
@@ -852,7 +853,7 @@ var transformTemplateRef = (node, context) => {
852
853
  };
853
854
  };
854
855
 
855
- // src/transforms/vIf.ts
856
+ // src/transforms/expression.ts
856
857
 
857
858
  function processConditionalExpression(node, context) {
858
859
  const { test, consequent, alternate } = node;
@@ -948,8 +949,12 @@ function processTextLike(context) {
948
949
  const nexts = _optionalChain([context, 'access', _11 => _11.parent, 'access', _12 => _12.node, 'access', _13 => _13.children, 'optionalAccess', _14 => _14.slice, 'call', _15 => _15(context.index)]);
949
950
  const idx = nexts.findIndex((n) => !isTextLike(n));
950
951
  const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
951
- const id = context.reference();
952
952
  const values = createTextLikeExpressions(nodes, context);
953
+ if (!values.length) {
954
+ context.dynamic.flags |= 2 /* NON_TEMPLATE */;
955
+ return;
956
+ }
957
+ const id = context.reference();
953
958
  context.dynamic.flags |= 4 /* INSERT */ | 2 /* NON_TEMPLATE */;
954
959
  context.registerOperation({
955
960
  type: 11 /* CREATE_TEXT_NODE */,
@@ -1200,7 +1205,7 @@ function transformComponentSlot(node, dir, context) {
1200
1205
  const { children } = node;
1201
1206
  const arg = dir && dir.arg;
1202
1207
  const nonSlotTemplateChildren = children.filter(
1203
- (n) => isNonWhitespaceContent(n) && !(n.type === "JSXElement" && findProp(n, "v-slot"))
1208
+ (n) => !isEmptyText(n) && !(n.type === "JSXElement" && findProp(n, "v-slot"))
1204
1209
  );
1205
1210
  const [block, onExit] = createSlotBlock(node, dir, context);
1206
1211
  const { slots } = context;
@@ -1230,7 +1235,7 @@ function transformComponentSlot(node, dir, context) {
1230
1235
  }
1231
1236
  };
1232
1237
  }
1233
- var elseIfRE = /^else(-if)?$/;
1238
+ var elseIfRE = /^v-else(-if)?$/;
1234
1239
  function transformTemplateSlot(node, dir, context) {
1235
1240
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
1236
1241
  const arg = dir.arg && resolveSimpleExpressionNode(dir.arg);
@@ -1337,10 +1342,6 @@ function createSlotBlock(slotNode, dir, context) {
1337
1342
  const exitBlock = context.enterBlock(block);
1338
1343
  return [block, exitBlock];
1339
1344
  }
1340
- function isNonWhitespaceContent(node) {
1341
- if (node.type !== "JSXText") return true;
1342
- return !!node.value.trim();
1343
- }
1344
1345
 
1345
1346
  // src/transforms/vSlots.ts
1346
1347
 
@@ -1413,6 +1414,104 @@ var transformVOnce = (node, context) => {
1413
1414
  }
1414
1415
  };
1415
1416
 
1417
+ // src/transforms/vIf.ts
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+ var transformVIf = createStructuralDirectiveTransform(
1425
+ ["if", "else", "else-if"],
1426
+ processIf
1427
+ );
1428
+ var transformedIfNode = /* @__PURE__ */ new WeakMap();
1429
+ function processIf(node, attribute, context) {
1430
+ const dir = resolveDirectiveNode(attribute, context);
1431
+ if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
1432
+ const loc = dir.exp ? dir.exp.loc : resolveLocation(node.loc, context);
1433
+ context.options.onError(
1434
+ _compilerdom.createCompilerError.call(void 0, _compilerdom.ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc)
1435
+ );
1436
+ dir.exp = _compilerdom.createSimpleExpression.call(void 0, `true`, false, loc);
1437
+ }
1438
+ context.dynamic.flags |= 2 /* NON_TEMPLATE */;
1439
+ transformedIfNode.set(node, dir);
1440
+ if (dir.name === "if") {
1441
+ const id = context.reference();
1442
+ context.dynamic.flags |= 4 /* INSERT */;
1443
+ const [branch, onExit] = createBranch(node, context);
1444
+ return () => {
1445
+ onExit();
1446
+ context.registerOperation({
1447
+ type: 16 /* IF */,
1448
+ id,
1449
+ condition: dir.exp,
1450
+ positive: branch,
1451
+ once: context.inVOnce || _compilerdom.isConstantNode.call(void 0, attribute.value, context.options.bindingMetadata)
1452
+ });
1453
+ };
1454
+ } else {
1455
+ const siblingIf = getSiblingIf(context);
1456
+ const { operation } = context.block;
1457
+ let lastIfNode = operation.at(-1);
1458
+ if (
1459
+ // check if v-if is the sibling node
1460
+ !siblingIf || // check if IfNode is the last operation and get the root IfNode
1461
+ !lastIfNode || lastIfNode.type !== 16 /* IF */
1462
+ ) {
1463
+ context.options.onError(
1464
+ _compilerdom.createCompilerError.call(void 0,
1465
+ _compilerdom.ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
1466
+ resolveLocation(node.loc, context)
1467
+ )
1468
+ );
1469
+ return;
1470
+ }
1471
+ while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
1472
+ lastIfNode = lastIfNode.negative;
1473
+ }
1474
+ if (dir.name === "else-if" && lastIfNode.negative) {
1475
+ context.options.onError(
1476
+ _compilerdom.createCompilerError.call(void 0,
1477
+ _compilerdom.ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
1478
+ resolveLocation(node.loc, context)
1479
+ )
1480
+ );
1481
+ }
1482
+ context.root.comment = [];
1483
+ const [branch, onExit] = createBranch(node, context);
1484
+ if (dir.name === "else") {
1485
+ lastIfNode.negative = branch;
1486
+ } else {
1487
+ lastIfNode.negative = {
1488
+ type: 16 /* IF */,
1489
+ id: -1,
1490
+ condition: dir.exp,
1491
+ positive: branch,
1492
+ once: context.inVOnce
1493
+ };
1494
+ }
1495
+ return () => onExit();
1496
+ }
1497
+ }
1498
+ function getSiblingIf(context) {
1499
+ const parent = context.parent;
1500
+ if (!parent) return;
1501
+ const siblings = parent.node.children;
1502
+ let sibling;
1503
+ let i = siblings.indexOf(context.node);
1504
+ while (--i >= 0) {
1505
+ if (!isEmptyText(siblings[i])) {
1506
+ sibling = siblings[i];
1507
+ break;
1508
+ }
1509
+ }
1510
+ if (sibling && sibling.type === "JSXElement" && transformedIfNode.has(sibling)) {
1511
+ return sibling;
1512
+ }
1513
+ }
1514
+
1416
1515
  // src/compile.ts
1417
1516
  function compile(source, options = {}) {
1418
1517
  const resolvedOptions = _shared.extend.call(void 0, {}, options, {
@@ -1465,6 +1564,7 @@ function getBaseTransformPreset() {
1465
1564
  return [
1466
1565
  [
1467
1566
  transformVOnce,
1567
+ transformVIf,
1468
1568
  transformVFor,
1469
1569
  transformTemplateRef,
1470
1570
  transformText,
@@ -1483,6 +1583,19 @@ function getBaseTransformPreset() {
1483
1583
  ];
1484
1584
  }
1485
1585
 
1586
+ // src/transforms/vText.ts
1587
+
1588
+ var transformVText = (dir, node, context) => {
1589
+ return _compilervapor.transformVText.call(void 0,
1590
+ resolveDirectiveNode(dir, context),
1591
+ resolveNode(node, context),
1592
+ context
1593
+ );
1594
+ };
1595
+
1596
+
1597
+
1598
+
1486
1599
 
1487
1600
 
1488
1601
 
@@ -1507,4 +1620,4 @@ function getBaseTransformPreset() {
1507
1620
 
1508
1621
 
1509
1622
 
1510
- exports.DynamicFlag = DynamicFlag; exports.IRDynamicPropsKind = IRDynamicPropsKind; exports.IRNodeTypes = IRNodeTypes; exports.IRSlotType = IRSlotType; exports.TransformContext = TransformContext; exports.compile = compile; exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform; exports.generate = _compilervapor.generate; exports.resolveDirectiveNode = resolveDirectiveNode; exports.resolveNode = resolveNode; exports.transform = transform; exports.transformChildren = transformChildren; exports.transformElement = transformElement; exports.transformNode = transformNode; exports.transformTemplateRef = transformTemplateRef; exports.transformText = transformText; exports.transformVBind = transformVBind; exports.transformVFor = transformVFor; exports.transformVHtml = transformVHtml; exports.transformVModel = transformVModel; exports.transformVOn = transformVOn; exports.transformVShow = transformVShow; exports.transformVSlot = transformVSlot; exports.transformVSlots = transformVSlots;
1623
+ exports.DynamicFlag = DynamicFlag; exports.IRDynamicPropsKind = IRDynamicPropsKind; exports.IRNodeTypes = IRNodeTypes; exports.IRSlotType = IRSlotType; exports.TransformContext = TransformContext; exports.compile = compile; exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform; exports.generate = _compilervapor.generate; exports.resolveDirectiveNode = resolveDirectiveNode; exports.resolveNode = resolveNode; exports.transform = transform; exports.transformChildren = transformChildren; exports.transformElement = transformElement; exports.transformNode = transformNode; exports.transformTemplateRef = transformTemplateRef; exports.transformText = transformText; exports.transformVBind = transformVBind; exports.transformVFor = transformVFor; exports.transformVHtml = transformVHtml; exports.transformVIf = transformVIf; exports.transformVModel = transformVModel; exports.transformVOn = transformVOn; exports.transformVOnce = transformVOnce; exports.transformVShow = transformVShow; exports.transformVSlot = transformVSlot; exports.transformVSlots = transformVSlots; exports.transformVText = transformVText;
package/dist/index.d.cts CHANGED
@@ -360,4 +360,10 @@ declare const transformVHtml: DirectiveTransform;
360
360
 
361
361
  declare const transformVFor: NodeTransform;
362
362
 
363
- export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVModel, transformVOn, transformVShow, transformVSlot, transformVSlots };
363
+ declare const transformVIf: NodeTransform;
364
+
365
+ declare const transformVOnce: NodeTransform;
366
+
367
+ declare const transformVText: DirectiveTransform;
368
+
369
+ export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
package/dist/index.d.ts CHANGED
@@ -360,4 +360,10 @@ declare const transformVHtml: DirectiveTransform;
360
360
 
361
361
  declare const transformVFor: NodeTransform;
362
362
 
363
- export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVModel, transformVOn, transformVShow, transformVSlot, transformVSlots };
363
+ declare const transformVIf: NodeTransform;
364
+
365
+ declare const transformVOnce: NodeTransform;
366
+
367
+ declare const transformVText: DirectiveTransform;
368
+
369
+ export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
package/dist/index.js CHANGED
@@ -248,10 +248,11 @@ function resolveNode(node, context) {
248
248
  var namespaceRE = /^(?:\$([\w-]+)\$)?([\w-]+)?/;
249
249
  function resolveDirectiveNode(node, context, withFn = false) {
250
250
  const { value, name } = node;
251
- const nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
251
+ let nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
252
252
  let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
253
253
  if (name.type !== "JSXNamespacedName" && !argString) {
254
- const [, modifiers2] = nameString.split("_");
254
+ const [newName, modifiers2] = nameString.split("_");
255
+ nameString = newName;
255
256
  argString = `_${modifiers2}`;
256
257
  }
257
258
  let modifiers = [];
@@ -274,7 +275,7 @@ function resolveDirectiveNode(node, context, withFn = false) {
274
275
  const exp = value ? withFn && value.type === "JSXExpressionContainer" ? resolveExpressionWithFn(value.expression, context) : resolveExpression(value, context) : void 0;
275
276
  return {
276
277
  type: NodeTypes.DIRECTIVE,
277
- name: nameString,
278
+ name: nameString.slice(2),
278
279
  rawName: `${nameString}:${argString}`,
279
280
  exp,
280
281
  arg,
@@ -852,7 +853,7 @@ var transformTemplateRef = (node, context) => {
852
853
  };
853
854
  };
854
855
 
855
- // src/transforms/vIf.ts
856
+ // src/transforms/expression.ts
856
857
  import { isStaticNode } from "@vue/compiler-dom";
857
858
  function processConditionalExpression(node, context) {
858
859
  const { test, consequent, alternate } = node;
@@ -948,8 +949,12 @@ function processTextLike(context) {
948
949
  const nexts = context.parent.node.children?.slice(context.index);
949
950
  const idx = nexts.findIndex((n) => !isTextLike(n));
950
951
  const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
951
- const id = context.reference();
952
952
  const values = createTextLikeExpressions(nodes, context);
953
+ if (!values.length) {
954
+ context.dynamic.flags |= 2 /* NON_TEMPLATE */;
955
+ return;
956
+ }
957
+ const id = context.reference();
953
958
  context.dynamic.flags |= 4 /* INSERT */ | 2 /* NON_TEMPLATE */;
954
959
  context.registerOperation({
955
960
  type: 11 /* CREATE_TEXT_NODE */,
@@ -1200,7 +1205,7 @@ function transformComponentSlot(node, dir, context) {
1200
1205
  const { children } = node;
1201
1206
  const arg = dir && dir.arg;
1202
1207
  const nonSlotTemplateChildren = children.filter(
1203
- (n) => isNonWhitespaceContent(n) && !(n.type === "JSXElement" && findProp(n, "v-slot"))
1208
+ (n) => !isEmptyText(n) && !(n.type === "JSXElement" && findProp(n, "v-slot"))
1204
1209
  );
1205
1210
  const [block, onExit] = createSlotBlock(node, dir, context);
1206
1211
  const { slots } = context;
@@ -1230,7 +1235,7 @@ function transformComponentSlot(node, dir, context) {
1230
1235
  }
1231
1236
  };
1232
1237
  }
1233
- var elseIfRE = /^else(-if)?$/;
1238
+ var elseIfRE = /^v-else(-if)?$/;
1234
1239
  function transformTemplateSlot(node, dir, context) {
1235
1240
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
1236
1241
  const arg = dir.arg && resolveSimpleExpressionNode(dir.arg);
@@ -1337,10 +1342,6 @@ function createSlotBlock(slotNode, dir, context) {
1337
1342
  const exitBlock = context.enterBlock(block);
1338
1343
  return [block, exitBlock];
1339
1344
  }
1340
- function isNonWhitespaceContent(node) {
1341
- if (node.type !== "JSXText") return true;
1342
- return !!node.value.trim();
1343
- }
1344
1345
 
1345
1346
  // src/transforms/vSlots.ts
1346
1347
  import { ErrorCodes as ErrorCodes4, createCompilerError as createCompilerError4 } from "@vue/compiler-dom";
@@ -1413,6 +1414,104 @@ var transformVOnce = (node, context) => {
1413
1414
  }
1414
1415
  };
1415
1416
 
1417
+ // src/transforms/vIf.ts
1418
+ import {
1419
+ ErrorCodes as ErrorCodes5,
1420
+ createCompilerError as createCompilerError5,
1421
+ createSimpleExpression as createSimpleExpression4,
1422
+ isConstantNode as isConstantNode2
1423
+ } from "@vue/compiler-dom";
1424
+ var transformVIf = createStructuralDirectiveTransform(
1425
+ ["if", "else", "else-if"],
1426
+ processIf
1427
+ );
1428
+ var transformedIfNode = /* @__PURE__ */ new WeakMap();
1429
+ function processIf(node, attribute, context) {
1430
+ const dir = resolveDirectiveNode(attribute, context);
1431
+ if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
1432
+ const loc = dir.exp ? dir.exp.loc : resolveLocation(node.loc, context);
1433
+ context.options.onError(
1434
+ createCompilerError5(ErrorCodes5.X_V_IF_NO_EXPRESSION, dir.loc)
1435
+ );
1436
+ dir.exp = createSimpleExpression4(`true`, false, loc);
1437
+ }
1438
+ context.dynamic.flags |= 2 /* NON_TEMPLATE */;
1439
+ transformedIfNode.set(node, dir);
1440
+ if (dir.name === "if") {
1441
+ const id = context.reference();
1442
+ context.dynamic.flags |= 4 /* INSERT */;
1443
+ const [branch, onExit] = createBranch(node, context);
1444
+ return () => {
1445
+ onExit();
1446
+ context.registerOperation({
1447
+ type: 16 /* IF */,
1448
+ id,
1449
+ condition: dir.exp,
1450
+ positive: branch,
1451
+ once: context.inVOnce || isConstantNode2(attribute.value, context.options.bindingMetadata)
1452
+ });
1453
+ };
1454
+ } else {
1455
+ const siblingIf = getSiblingIf(context);
1456
+ const { operation } = context.block;
1457
+ let lastIfNode = operation.at(-1);
1458
+ if (
1459
+ // check if v-if is the sibling node
1460
+ !siblingIf || // check if IfNode is the last operation and get the root IfNode
1461
+ !lastIfNode || lastIfNode.type !== 16 /* IF */
1462
+ ) {
1463
+ context.options.onError(
1464
+ createCompilerError5(
1465
+ ErrorCodes5.X_V_ELSE_NO_ADJACENT_IF,
1466
+ resolveLocation(node.loc, context)
1467
+ )
1468
+ );
1469
+ return;
1470
+ }
1471
+ while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
1472
+ lastIfNode = lastIfNode.negative;
1473
+ }
1474
+ if (dir.name === "else-if" && lastIfNode.negative) {
1475
+ context.options.onError(
1476
+ createCompilerError5(
1477
+ ErrorCodes5.X_V_ELSE_NO_ADJACENT_IF,
1478
+ resolveLocation(node.loc, context)
1479
+ )
1480
+ );
1481
+ }
1482
+ context.root.comment = [];
1483
+ const [branch, onExit] = createBranch(node, context);
1484
+ if (dir.name === "else") {
1485
+ lastIfNode.negative = branch;
1486
+ } else {
1487
+ lastIfNode.negative = {
1488
+ type: 16 /* IF */,
1489
+ id: -1,
1490
+ condition: dir.exp,
1491
+ positive: branch,
1492
+ once: context.inVOnce
1493
+ };
1494
+ }
1495
+ return () => onExit();
1496
+ }
1497
+ }
1498
+ function getSiblingIf(context) {
1499
+ const parent = context.parent;
1500
+ if (!parent) return;
1501
+ const siblings = parent.node.children;
1502
+ let sibling;
1503
+ let i = siblings.indexOf(context.node);
1504
+ while (--i >= 0) {
1505
+ if (!isEmptyText(siblings[i])) {
1506
+ sibling = siblings[i];
1507
+ break;
1508
+ }
1509
+ }
1510
+ if (sibling && sibling.type === "JSXElement" && transformedIfNode.has(sibling)) {
1511
+ return sibling;
1512
+ }
1513
+ }
1514
+
1416
1515
  // src/compile.ts
1417
1516
  function compile(source, options = {}) {
1418
1517
  const resolvedOptions = extend5({}, options, {
@@ -1465,6 +1564,7 @@ function getBaseTransformPreset() {
1465
1564
  return [
1466
1565
  [
1467
1566
  transformVOnce,
1567
+ transformVIf,
1468
1568
  transformVFor,
1469
1569
  transformTemplateRef,
1470
1570
  transformText,
@@ -1482,6 +1582,16 @@ function getBaseTransformPreset() {
1482
1582
  }
1483
1583
  ];
1484
1584
  }
1585
+
1586
+ // src/transforms/vText.ts
1587
+ import { transformVText as _transformVText } from "@vue/compiler-vapor";
1588
+ var transformVText = (dir, node, context) => {
1589
+ return _transformVText(
1590
+ resolveDirectiveNode(dir, context),
1591
+ resolveNode(node, context),
1592
+ context
1593
+ );
1594
+ };
1485
1595
  export {
1486
1596
  DynamicFlag,
1487
1597
  IRDynamicPropsKind,
@@ -1502,9 +1612,12 @@ export {
1502
1612
  transformVBind,
1503
1613
  transformVFor,
1504
1614
  transformVHtml,
1615
+ transformVIf,
1505
1616
  transformVModel,
1506
1617
  transformVOn,
1618
+ transformVOnce,
1507
1619
  transformVShow,
1508
1620
  transformVSlot,
1509
- transformVSlots
1621
+ transformVSlots,
1622
+ transformVText
1510
1623
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Vue JSX Vapor Compiler",
5
5
  "type": "module",
6
6
  "keywords": [