@vue-jsx-vapor/compiler 0.2.6 → 0.2.7
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 +124 -7
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +124 -7
- package/package.json +1 -1
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
|
-
|
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/
|
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 */,
|
@@ -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);
|
@@ -1413,6 +1418,104 @@ var transformVOnce = (node, context) => {
|
|
1413
1418
|
}
|
1414
1419
|
};
|
1415
1420
|
|
1421
|
+
// src/transforms/vIf.ts
|
1422
|
+
|
1423
|
+
|
1424
|
+
|
1425
|
+
|
1426
|
+
|
1427
|
+
|
1428
|
+
var transformVIf = createStructuralDirectiveTransform(
|
1429
|
+
["if", "else", "else-if"],
|
1430
|
+
processIf
|
1431
|
+
);
|
1432
|
+
var transformedIfNode = /* @__PURE__ */ new WeakMap();
|
1433
|
+
function processIf(node, attribute, context) {
|
1434
|
+
const dir = resolveDirectiveNode(attribute, context);
|
1435
|
+
if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
1436
|
+
const loc = dir.exp ? dir.exp.loc : resolveLocation(node.loc, context);
|
1437
|
+
context.options.onError(
|
1438
|
+
_compilerdom.createCompilerError.call(void 0, _compilerdom.ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc)
|
1439
|
+
);
|
1440
|
+
dir.exp = _compilerdom.createSimpleExpression.call(void 0, `true`, false, loc);
|
1441
|
+
}
|
1442
|
+
context.dynamic.flags |= 2 /* NON_TEMPLATE */;
|
1443
|
+
transformedIfNode.set(node, dir);
|
1444
|
+
if (dir.name === "if") {
|
1445
|
+
const id = context.reference();
|
1446
|
+
context.dynamic.flags |= 4 /* INSERT */;
|
1447
|
+
const [branch, onExit] = createBranch(node, context);
|
1448
|
+
return () => {
|
1449
|
+
onExit();
|
1450
|
+
context.registerOperation({
|
1451
|
+
type: 16 /* IF */,
|
1452
|
+
id,
|
1453
|
+
condition: dir.exp,
|
1454
|
+
positive: branch,
|
1455
|
+
once: context.inVOnce || _compilerdom.isConstantNode.call(void 0, attribute.value, context.options.bindingMetadata)
|
1456
|
+
});
|
1457
|
+
};
|
1458
|
+
} else {
|
1459
|
+
const siblingIf = getSiblingIf(context);
|
1460
|
+
const { operation } = context.block;
|
1461
|
+
let lastIfNode = operation.at(-1);
|
1462
|
+
if (
|
1463
|
+
// check if v-if is the sibling node
|
1464
|
+
!siblingIf || // check if IfNode is the last operation and get the root IfNode
|
1465
|
+
!lastIfNode || lastIfNode.type !== 16 /* IF */
|
1466
|
+
) {
|
1467
|
+
context.options.onError(
|
1468
|
+
_compilerdom.createCompilerError.call(void 0,
|
1469
|
+
_compilerdom.ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
|
1470
|
+
resolveLocation(node.loc, context)
|
1471
|
+
)
|
1472
|
+
);
|
1473
|
+
return;
|
1474
|
+
}
|
1475
|
+
while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
|
1476
|
+
lastIfNode = lastIfNode.negative;
|
1477
|
+
}
|
1478
|
+
if (dir.name === "else-if" && lastIfNode.negative) {
|
1479
|
+
context.options.onError(
|
1480
|
+
_compilerdom.createCompilerError.call(void 0,
|
1481
|
+
_compilerdom.ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
|
1482
|
+
resolveLocation(node.loc, context)
|
1483
|
+
)
|
1484
|
+
);
|
1485
|
+
}
|
1486
|
+
context.root.comment = [];
|
1487
|
+
const [branch, onExit] = createBranch(node, context);
|
1488
|
+
if (dir.name === "else") {
|
1489
|
+
lastIfNode.negative = branch;
|
1490
|
+
} else {
|
1491
|
+
lastIfNode.negative = {
|
1492
|
+
type: 16 /* IF */,
|
1493
|
+
id: -1,
|
1494
|
+
condition: dir.exp,
|
1495
|
+
positive: branch,
|
1496
|
+
once: context.inVOnce
|
1497
|
+
};
|
1498
|
+
}
|
1499
|
+
return () => onExit();
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
function getSiblingIf(context) {
|
1503
|
+
const parent = context.parent;
|
1504
|
+
if (!parent) return;
|
1505
|
+
const siblings = parent.node.children;
|
1506
|
+
let sibling;
|
1507
|
+
let i = siblings.indexOf(context.node);
|
1508
|
+
while (--i >= 0) {
|
1509
|
+
if (!isEmptyText(siblings[i])) {
|
1510
|
+
sibling = siblings[i];
|
1511
|
+
break;
|
1512
|
+
}
|
1513
|
+
}
|
1514
|
+
if (sibling && sibling.type === "JSXElement" && transformedIfNode.has(sibling)) {
|
1515
|
+
return sibling;
|
1516
|
+
}
|
1517
|
+
}
|
1518
|
+
|
1416
1519
|
// src/compile.ts
|
1417
1520
|
function compile(source, options = {}) {
|
1418
1521
|
const resolvedOptions = _shared.extend.call(void 0, {}, options, {
|
@@ -1465,6 +1568,7 @@ function getBaseTransformPreset() {
|
|
1465
1568
|
return [
|
1466
1569
|
[
|
1467
1570
|
transformVOnce,
|
1571
|
+
transformVIf,
|
1468
1572
|
transformVFor,
|
1469
1573
|
transformTemplateRef,
|
1470
1574
|
transformText,
|
@@ -1483,6 +1587,19 @@ function getBaseTransformPreset() {
|
|
1483
1587
|
];
|
1484
1588
|
}
|
1485
1589
|
|
1590
|
+
// src/transforms/vText.ts
|
1591
|
+
|
1592
|
+
var transformVText = (dir, node, context) => {
|
1593
|
+
return _compilervapor.transformVText.call(void 0,
|
1594
|
+
resolveDirectiveNode(dir, context),
|
1595
|
+
resolveNode(node, context),
|
1596
|
+
context
|
1597
|
+
);
|
1598
|
+
};
|
1599
|
+
|
1600
|
+
|
1601
|
+
|
1602
|
+
|
1486
1603
|
|
1487
1604
|
|
1488
1605
|
|
@@ -1507,4 +1624,4 @@ function getBaseTransformPreset() {
|
|
1507
1624
|
|
1508
1625
|
|
1509
1626
|
|
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;
|
1627
|
+
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
|
-
|
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
|
-
|
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
|
-
|
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/
|
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 */,
|
@@ -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);
|
@@ -1413,6 +1418,104 @@ var transformVOnce = (node, context) => {
|
|
1413
1418
|
}
|
1414
1419
|
};
|
1415
1420
|
|
1421
|
+
// src/transforms/vIf.ts
|
1422
|
+
import {
|
1423
|
+
ErrorCodes as ErrorCodes5,
|
1424
|
+
createCompilerError as createCompilerError5,
|
1425
|
+
createSimpleExpression as createSimpleExpression4,
|
1426
|
+
isConstantNode as isConstantNode2
|
1427
|
+
} from "@vue/compiler-dom";
|
1428
|
+
var transformVIf = createStructuralDirectiveTransform(
|
1429
|
+
["if", "else", "else-if"],
|
1430
|
+
processIf
|
1431
|
+
);
|
1432
|
+
var transformedIfNode = /* @__PURE__ */ new WeakMap();
|
1433
|
+
function processIf(node, attribute, context) {
|
1434
|
+
const dir = resolveDirectiveNode(attribute, context);
|
1435
|
+
if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
1436
|
+
const loc = dir.exp ? dir.exp.loc : resolveLocation(node.loc, context);
|
1437
|
+
context.options.onError(
|
1438
|
+
createCompilerError5(ErrorCodes5.X_V_IF_NO_EXPRESSION, dir.loc)
|
1439
|
+
);
|
1440
|
+
dir.exp = createSimpleExpression4(`true`, false, loc);
|
1441
|
+
}
|
1442
|
+
context.dynamic.flags |= 2 /* NON_TEMPLATE */;
|
1443
|
+
transformedIfNode.set(node, dir);
|
1444
|
+
if (dir.name === "if") {
|
1445
|
+
const id = context.reference();
|
1446
|
+
context.dynamic.flags |= 4 /* INSERT */;
|
1447
|
+
const [branch, onExit] = createBranch(node, context);
|
1448
|
+
return () => {
|
1449
|
+
onExit();
|
1450
|
+
context.registerOperation({
|
1451
|
+
type: 16 /* IF */,
|
1452
|
+
id,
|
1453
|
+
condition: dir.exp,
|
1454
|
+
positive: branch,
|
1455
|
+
once: context.inVOnce || isConstantNode2(attribute.value, context.options.bindingMetadata)
|
1456
|
+
});
|
1457
|
+
};
|
1458
|
+
} else {
|
1459
|
+
const siblingIf = getSiblingIf(context);
|
1460
|
+
const { operation } = context.block;
|
1461
|
+
let lastIfNode = operation.at(-1);
|
1462
|
+
if (
|
1463
|
+
// check if v-if is the sibling node
|
1464
|
+
!siblingIf || // check if IfNode is the last operation and get the root IfNode
|
1465
|
+
!lastIfNode || lastIfNode.type !== 16 /* IF */
|
1466
|
+
) {
|
1467
|
+
context.options.onError(
|
1468
|
+
createCompilerError5(
|
1469
|
+
ErrorCodes5.X_V_ELSE_NO_ADJACENT_IF,
|
1470
|
+
resolveLocation(node.loc, context)
|
1471
|
+
)
|
1472
|
+
);
|
1473
|
+
return;
|
1474
|
+
}
|
1475
|
+
while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
|
1476
|
+
lastIfNode = lastIfNode.negative;
|
1477
|
+
}
|
1478
|
+
if (dir.name === "else-if" && lastIfNode.negative) {
|
1479
|
+
context.options.onError(
|
1480
|
+
createCompilerError5(
|
1481
|
+
ErrorCodes5.X_V_ELSE_NO_ADJACENT_IF,
|
1482
|
+
resolveLocation(node.loc, context)
|
1483
|
+
)
|
1484
|
+
);
|
1485
|
+
}
|
1486
|
+
context.root.comment = [];
|
1487
|
+
const [branch, onExit] = createBranch(node, context);
|
1488
|
+
if (dir.name === "else") {
|
1489
|
+
lastIfNode.negative = branch;
|
1490
|
+
} else {
|
1491
|
+
lastIfNode.negative = {
|
1492
|
+
type: 16 /* IF */,
|
1493
|
+
id: -1,
|
1494
|
+
condition: dir.exp,
|
1495
|
+
positive: branch,
|
1496
|
+
once: context.inVOnce
|
1497
|
+
};
|
1498
|
+
}
|
1499
|
+
return () => onExit();
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
function getSiblingIf(context) {
|
1503
|
+
const parent = context.parent;
|
1504
|
+
if (!parent) return;
|
1505
|
+
const siblings = parent.node.children;
|
1506
|
+
let sibling;
|
1507
|
+
let i = siblings.indexOf(context.node);
|
1508
|
+
while (--i >= 0) {
|
1509
|
+
if (!isEmptyText(siblings[i])) {
|
1510
|
+
sibling = siblings[i];
|
1511
|
+
break;
|
1512
|
+
}
|
1513
|
+
}
|
1514
|
+
if (sibling && sibling.type === "JSXElement" && transformedIfNode.has(sibling)) {
|
1515
|
+
return sibling;
|
1516
|
+
}
|
1517
|
+
}
|
1518
|
+
|
1416
1519
|
// src/compile.ts
|
1417
1520
|
function compile(source, options = {}) {
|
1418
1521
|
const resolvedOptions = extend5({}, options, {
|
@@ -1465,6 +1568,7 @@ function getBaseTransformPreset() {
|
|
1465
1568
|
return [
|
1466
1569
|
[
|
1467
1570
|
transformVOnce,
|
1571
|
+
transformVIf,
|
1468
1572
|
transformVFor,
|
1469
1573
|
transformTemplateRef,
|
1470
1574
|
transformText,
|
@@ -1482,6 +1586,16 @@ function getBaseTransformPreset() {
|
|
1482
1586
|
}
|
1483
1587
|
];
|
1484
1588
|
}
|
1589
|
+
|
1590
|
+
// src/transforms/vText.ts
|
1591
|
+
import { transformVText as _transformVText } from "@vue/compiler-vapor";
|
1592
|
+
var transformVText = (dir, node, context) => {
|
1593
|
+
return _transformVText(
|
1594
|
+
resolveDirectiveNode(dir, context),
|
1595
|
+
resolveNode(node, context),
|
1596
|
+
context
|
1597
|
+
);
|
1598
|
+
};
|
1485
1599
|
export {
|
1486
1600
|
DynamicFlag,
|
1487
1601
|
IRDynamicPropsKind,
|
@@ -1502,9 +1616,12 @@ export {
|
|
1502
1616
|
transformVBind,
|
1503
1617
|
transformVFor,
|
1504
1618
|
transformVHtml,
|
1619
|
+
transformVIf,
|
1505
1620
|
transformVModel,
|
1506
1621
|
transformVOn,
|
1622
|
+
transformVOnce,
|
1507
1623
|
transformVShow,
|
1508
1624
|
transformVSlot,
|
1509
|
-
transformVSlots
|
1625
|
+
transformVSlots,
|
1626
|
+
transformVText
|
1510
1627
|
};
|