marko 6.0.0-next.3.74 → 6.0.0-next.3.75
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/translator/index.js
CHANGED
@@ -6503,115 +6503,121 @@ var html_comment_default = {
|
|
6503
6503
|
}
|
6504
6504
|
tag.skip();
|
6505
6505
|
},
|
6506
|
-
translate
|
6507
|
-
|
6508
|
-
|
6509
|
-
|
6510
|
-
|
6511
|
-
|
6512
|
-
|
6513
|
-
|
6514
|
-
|
6515
|
-
|
6516
|
-
|
6517
|
-
|
6518
|
-
|
6519
|
-
|
6520
|
-
|
6521
|
-
} else {
|
6522
|
-
const varName = tag.node.var.name;
|
6523
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
6524
|
-
let getterFnIdentifier;
|
6525
|
-
if (getterId) {
|
6526
|
-
getterFnIdentifier = (0, import_compiler38.getProgram)().scope.generateUidIdentifier(
|
6527
|
-
`get_${varName}`
|
6528
|
-
);
|
6529
|
-
(0, import_compiler38.getProgram)().node.body.push(
|
6530
|
-
import_compiler38.types.variableDeclaration("const", [
|
6531
|
-
import_compiler38.types.variableDeclarator(
|
6532
|
-
getterFnIdentifier,
|
6533
|
-
callRuntime(
|
6534
|
-
"nodeRef",
|
6535
|
-
import_compiler38.types.stringLiteral(getterId),
|
6536
|
-
getScopeAccessorLiteral(commentBinding)
|
6537
|
-
)
|
6538
|
-
)
|
6539
|
-
])
|
6506
|
+
translate: {
|
6507
|
+
enter(tag) {
|
6508
|
+
const tagExtra = tag.node.extra;
|
6509
|
+
const commentBinding = tagExtra[kCommentTagBinding];
|
6510
|
+
const hasVar = !!tag.node.var;
|
6511
|
+
if (hasVar) {
|
6512
|
+
const getterId = tagExtra[kGetterId2];
|
6513
|
+
if (isOutputHTML()) {
|
6514
|
+
translateVar(
|
6515
|
+
tag,
|
6516
|
+
callRuntime(
|
6517
|
+
"nodeRef",
|
6518
|
+
getterId && getScopeIdIdentifier(getSection(tag)),
|
6519
|
+
getterId && import_compiler38.types.stringLiteral(getterId)
|
6520
|
+
)
|
6540
6521
|
);
|
6541
|
-
}
|
6542
|
-
|
6543
|
-
const
|
6544
|
-
|
6545
|
-
|
6546
|
-
|
6547
|
-
|
6548
|
-
)
|
6522
|
+
} else {
|
6523
|
+
const varName = tag.node.var.name;
|
6524
|
+
const references = tag.scope.getBinding(varName).referencePaths;
|
6525
|
+
let getterFnIdentifier;
|
6526
|
+
if (getterId) {
|
6527
|
+
getterFnIdentifier = (0, import_compiler38.getProgram)().scope.generateUidIdentifier(
|
6528
|
+
`get_${varName}`
|
6549
6529
|
);
|
6550
|
-
|
6551
|
-
|
6552
|
-
|
6553
|
-
|
6530
|
+
(0, import_compiler38.getProgram)().node.body.push(
|
6531
|
+
import_compiler38.types.variableDeclaration("const", [
|
6532
|
+
import_compiler38.types.variableDeclarator(
|
6533
|
+
getterFnIdentifier,
|
6534
|
+
callRuntime(
|
6535
|
+
"nodeRef",
|
6536
|
+
import_compiler38.types.stringLiteral(getterId),
|
6537
|
+
getScopeAccessorLiteral(commentBinding)
|
6538
|
+
)
|
6539
|
+
)
|
6554
6540
|
])
|
6555
6541
|
);
|
6556
6542
|
}
|
6543
|
+
for (const reference of references) {
|
6544
|
+
const referenceSection = getSection(reference);
|
6545
|
+
if (isInvokedFunction(reference)) {
|
6546
|
+
reference.parentPath.replaceWith(
|
6547
|
+
import_compiler38.types.expressionStatement(
|
6548
|
+
createScopeReadExpression(referenceSection, commentBinding)
|
6549
|
+
)
|
6550
|
+
);
|
6551
|
+
} else if (getterFnIdentifier) {
|
6552
|
+
reference.replaceWith(
|
6553
|
+
import_compiler38.types.callExpression(getterFnIdentifier, [
|
6554
|
+
getScopeExpression(referenceSection, getSection(tag))
|
6555
|
+
])
|
6556
|
+
);
|
6557
|
+
}
|
6558
|
+
}
|
6557
6559
|
}
|
6558
6560
|
}
|
6559
|
-
|
6560
|
-
|
6561
|
-
visit(tag, 32 /* Get */);
|
6562
|
-
}
|
6563
|
-
const write2 = writeTo(tag);
|
6564
|
-
enter2(tag);
|
6565
|
-
write2`<!--`;
|
6566
|
-
if (isOutputHTML()) {
|
6567
|
-
for (const child of tag.node.body.body) {
|
6568
|
-
if (import_compiler38.types.isMarkoText(child)) {
|
6569
|
-
write2`${child.value}`;
|
6570
|
-
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
6571
|
-
write2`${callRuntime("escapeXML", child.value)}`;
|
6572
|
-
}
|
6561
|
+
if (tagExtra[kCommentTagBinding]) {
|
6562
|
+
visit(tag, 32 /* Get */);
|
6573
6563
|
}
|
6574
|
-
|
6575
|
-
|
6576
|
-
|
6577
|
-
|
6578
|
-
|
6579
|
-
|
6580
|
-
|
6581
|
-
|
6582
|
-
|
6583
|
-
|
6584
|
-
|
6564
|
+
enter2(tag);
|
6565
|
+
writeTo(tag)`<!--`;
|
6566
|
+
},
|
6567
|
+
exit(tag) {
|
6568
|
+
const tagExtra = tag.node.extra;
|
6569
|
+
const commentBinding = tagExtra[kCommentTagBinding];
|
6570
|
+
const write2 = writeTo(tag);
|
6571
|
+
if (isOutputHTML()) {
|
6572
|
+
for (const child of tag.node.body.body) {
|
6573
|
+
if (import_compiler38.types.isMarkoText(child)) {
|
6574
|
+
write2`${child.value}`;
|
6575
|
+
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
6576
|
+
write2`${callRuntime("escapeXML", child.value)}`;
|
6577
|
+
}
|
6585
6578
|
}
|
6586
|
-
}
|
6587
|
-
if (templateExpressions.length === 0) {
|
6588
|
-
write2`${currentQuasi}`;
|
6589
6579
|
} else {
|
6590
|
-
templateQuasis
|
6591
|
-
|
6592
|
-
|
6593
|
-
|
6594
|
-
|
6595
|
-
|
6596
|
-
|
6597
|
-
|
6598
|
-
|
6599
|
-
|
6600
|
-
|
6601
|
-
|
6602
|
-
|
6603
|
-
|
6580
|
+
const templateQuasis = [];
|
6581
|
+
const templateExpressions = [];
|
6582
|
+
let currentQuasi = "";
|
6583
|
+
for (const child of tag.node.body.body) {
|
6584
|
+
if (import_compiler38.types.isMarkoText(child)) {
|
6585
|
+
currentQuasi += child.value;
|
6586
|
+
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
6587
|
+
templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
|
6588
|
+
templateExpressions.push(child.value);
|
6589
|
+
currentQuasi = "";
|
6590
|
+
}
|
6591
|
+
}
|
6592
|
+
if (templateExpressions.length === 0) {
|
6593
|
+
write2`${currentQuasi}`;
|
6594
|
+
} else {
|
6595
|
+
templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
|
6596
|
+
addStatement(
|
6597
|
+
"render",
|
6598
|
+
getSection(tag),
|
6599
|
+
tagExtra.referencedBindings,
|
6600
|
+
import_compiler38.types.expressionStatement(
|
6601
|
+
callRuntime(
|
6602
|
+
"data",
|
6603
|
+
import_compiler38.types.memberExpression(
|
6604
|
+
scopeIdentifier,
|
6605
|
+
getScopeAccessorLiteral(commentBinding),
|
6606
|
+
true
|
6607
|
+
),
|
6608
|
+
import_compiler38.types.templateLiteral(templateQuasis, templateExpressions)
|
6609
|
+
)
|
6604
6610
|
)
|
6605
|
-
)
|
6606
|
-
|
6611
|
+
);
|
6612
|
+
}
|
6607
6613
|
}
|
6614
|
+
exit2(tag);
|
6615
|
+
write2`-->`;
|
6616
|
+
if (commentBinding) {
|
6617
|
+
markNode(tag, commentBinding);
|
6618
|
+
}
|
6619
|
+
tag.remove();
|
6608
6620
|
}
|
6609
|
-
exit2(tag);
|
6610
|
-
write2`-->`;
|
6611
|
-
if (commentBinding) {
|
6612
|
-
markNode(tag, commentBinding);
|
6613
|
-
}
|
6614
|
-
tag.remove();
|
6615
6621
|
},
|
6616
6622
|
parseOptions: {
|
6617
6623
|
text: true
|
@@ -6713,124 +6719,167 @@ var html_script_default = {
|
|
6713
6719
|
}
|
6714
6720
|
}
|
6715
6721
|
},
|
6716
|
-
translate
|
6717
|
-
|
6718
|
-
|
6719
|
-
|
6720
|
-
|
6721
|
-
|
6722
|
-
|
6723
|
-
|
6724
|
-
|
6725
|
-
|
6726
|
-
|
6727
|
-
|
6728
|
-
|
6729
|
-
|
6730
|
-
|
6731
|
-
|
6732
|
-
|
6733
|
-
|
6734
|
-
|
6735
|
-
|
6736
|
-
|
6737
|
-
|
6738
|
-
|
6739
|
-
} else {
|
6740
|
-
const varName = tag.node.var.name;
|
6741
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
6742
|
-
let getterFnIdentifier;
|
6743
|
-
if (getterId) {
|
6744
|
-
getterFnIdentifier = (0, import_compiler39.getProgram)().scope.generateUidIdentifier(
|
6745
|
-
`get_${varName}`
|
6746
|
-
);
|
6747
|
-
(0, import_compiler39.getProgram)().node.body.push(
|
6748
|
-
import_compiler39.types.variableDeclaration("const", [
|
6749
|
-
import_compiler39.types.variableDeclarator(
|
6750
|
-
getterFnIdentifier,
|
6751
|
-
callRuntime(
|
6752
|
-
"nodeRef",
|
6753
|
-
import_compiler39.types.stringLiteral(getterId),
|
6754
|
-
getScopeAccessorLiteral(nodeRef2)
|
6755
|
-
)
|
6756
|
-
)
|
6757
|
-
])
|
6722
|
+
translate: {
|
6723
|
+
enter(tag) {
|
6724
|
+
const tagExtra = tag.node.extra;
|
6725
|
+
const nodeRef2 = tagExtra[kNativeTagBinding];
|
6726
|
+
const isHTML = isOutputHTML();
|
6727
|
+
const write2 = writeTo(tag);
|
6728
|
+
const section = getSection(tag);
|
6729
|
+
const hasVar = !!tag.node.var;
|
6730
|
+
if (hasVar) {
|
6731
|
+
const getterId = tagExtra[kGetterId3];
|
6732
|
+
if (isHTML) {
|
6733
|
+
const varName = tag.node.var.name;
|
6734
|
+
const references = tag.scope.getBinding(varName).referencePaths;
|
6735
|
+
for (const reference of references) {
|
6736
|
+
serializeOwners(getSection(reference), section);
|
6737
|
+
}
|
6738
|
+
translateVar(
|
6739
|
+
tag,
|
6740
|
+
callRuntime(
|
6741
|
+
"nodeRef",
|
6742
|
+
getterId && getScopeIdIdentifier(section),
|
6743
|
+
getterId && import_compiler39.types.stringLiteral(getterId)
|
6744
|
+
)
|
6758
6745
|
);
|
6759
|
-
}
|
6760
|
-
|
6761
|
-
const
|
6762
|
-
|
6763
|
-
|
6764
|
-
|
6765
|
-
|
6766
|
-
)
|
6746
|
+
} else {
|
6747
|
+
const varName = tag.node.var.name;
|
6748
|
+
const references = tag.scope.getBinding(varName).referencePaths;
|
6749
|
+
let getterFnIdentifier;
|
6750
|
+
if (getterId) {
|
6751
|
+
getterFnIdentifier = (0, import_compiler39.getProgram)().scope.generateUidIdentifier(
|
6752
|
+
`get_${varName}`
|
6767
6753
|
);
|
6768
|
-
|
6769
|
-
|
6770
|
-
|
6771
|
-
|
6754
|
+
(0, import_compiler39.getProgram)().node.body.push(
|
6755
|
+
import_compiler39.types.variableDeclaration("const", [
|
6756
|
+
import_compiler39.types.variableDeclarator(
|
6757
|
+
getterFnIdentifier,
|
6758
|
+
callRuntime(
|
6759
|
+
"nodeRef",
|
6760
|
+
import_compiler39.types.stringLiteral(getterId),
|
6761
|
+
getScopeAccessorLiteral(nodeRef2)
|
6762
|
+
)
|
6763
|
+
)
|
6772
6764
|
])
|
6773
6765
|
);
|
6774
6766
|
}
|
6767
|
+
for (const reference of references) {
|
6768
|
+
const referenceSection = getSection(reference);
|
6769
|
+
if (isInvokedFunction(reference)) {
|
6770
|
+
reference.parentPath.replaceWith(
|
6771
|
+
import_compiler39.types.expressionStatement(
|
6772
|
+
createScopeReadExpression(referenceSection, nodeRef2)
|
6773
|
+
)
|
6774
|
+
);
|
6775
|
+
} else if (getterFnIdentifier) {
|
6776
|
+
reference.replaceWith(
|
6777
|
+
import_compiler39.types.callExpression(getterFnIdentifier, [
|
6778
|
+
getScopeExpression(referenceSection, getSection(tag))
|
6779
|
+
])
|
6780
|
+
);
|
6781
|
+
}
|
6782
|
+
}
|
6775
6783
|
}
|
6776
6784
|
}
|
6777
|
-
|
6778
|
-
|
6779
|
-
|
6780
|
-
|
6781
|
-
|
6782
|
-
|
6783
|
-
|
6784
|
-
|
6785
|
-
|
6786
|
-
|
6787
|
-
|
6788
|
-
|
6789
|
-
|
6790
|
-
|
6791
|
-
|
6792
|
-
|
6793
|
-
|
6794
|
-
|
6795
|
-
|
6796
|
-
|
6797
|
-
|
6798
|
-
|
6799
|
-
|
6800
|
-
|
6801
|
-
|
6802
|
-
|
6803
|
-
|
6804
|
-
|
6805
|
-
|
6806
|
-
|
6807
|
-
|
6785
|
+
let visitAccessor;
|
6786
|
+
if (nodeRef2) {
|
6787
|
+
visitAccessor = getScopeAccessorLiteral(nodeRef2);
|
6788
|
+
visit(tag, 32 /* Get */);
|
6789
|
+
}
|
6790
|
+
write2`<script`;
|
6791
|
+
const usedAttrs = getUsedAttrs2(tag.node);
|
6792
|
+
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
6793
|
+
for (const attr2 of staticAttrs) {
|
6794
|
+
const { name: name2, value } = attr2;
|
6795
|
+
const { confident, computed } = value.extra || {};
|
6796
|
+
const valueReferences = value.extra?.referencedBindings;
|
6797
|
+
switch (name2) {
|
6798
|
+
case "class":
|
6799
|
+
case "style": {
|
6800
|
+
const helper = `${name2}Attr`;
|
6801
|
+
if (confident) {
|
6802
|
+
write2`${getHTMLRuntime()[helper](computed)}`;
|
6803
|
+
} else if (isHTML) {
|
6804
|
+
write2`${callRuntime(helper, value)}`;
|
6805
|
+
} else {
|
6806
|
+
addStatement(
|
6807
|
+
"render",
|
6808
|
+
section,
|
6809
|
+
valueReferences,
|
6810
|
+
import_compiler39.types.expressionStatement(
|
6811
|
+
callRuntime(
|
6812
|
+
helper,
|
6813
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6814
|
+
value
|
6815
|
+
)
|
6808
6816
|
)
|
6809
|
-
)
|
6810
|
-
|
6817
|
+
);
|
6818
|
+
}
|
6819
|
+
break;
|
6811
6820
|
}
|
6812
|
-
|
6813
|
-
|
6814
|
-
|
6815
|
-
|
6816
|
-
|
6817
|
-
|
6818
|
-
|
6819
|
-
|
6821
|
+
default:
|
6822
|
+
if (confident) {
|
6823
|
+
write2`${getHTMLRuntime().attr(name2, computed)}`;
|
6824
|
+
} else if (isHTML) {
|
6825
|
+
if (isEventHandler(name2)) {
|
6826
|
+
addHTMLEffectCall(section, valueReferences);
|
6827
|
+
} else {
|
6828
|
+
write2`${callRuntime("attr", import_compiler39.types.stringLiteral(name2), value)}`;
|
6829
|
+
}
|
6830
|
+
} else if (isEventHandler(name2)) {
|
6831
|
+
addStatement(
|
6832
|
+
"effect",
|
6833
|
+
section,
|
6834
|
+
valueReferences,
|
6835
|
+
import_compiler39.types.expressionStatement(
|
6836
|
+
callRuntime(
|
6837
|
+
"on",
|
6838
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6839
|
+
import_compiler39.types.stringLiteral(getEventHandlerName(name2)),
|
6840
|
+
value
|
6841
|
+
)
|
6842
|
+
)
|
6843
|
+
);
|
6820
6844
|
} else {
|
6821
|
-
|
6845
|
+
addStatement(
|
6846
|
+
"render",
|
6847
|
+
section,
|
6848
|
+
valueReferences,
|
6849
|
+
import_compiler39.types.expressionStatement(
|
6850
|
+
callRuntime(
|
6851
|
+
"attr",
|
6852
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6853
|
+
import_compiler39.types.stringLiteral(name2),
|
6854
|
+
value
|
6855
|
+
)
|
6856
|
+
)
|
6857
|
+
);
|
6822
6858
|
}
|
6823
|
-
|
6859
|
+
break;
|
6860
|
+
}
|
6861
|
+
}
|
6862
|
+
if (spreadExpression) {
|
6863
|
+
if (isHTML) {
|
6864
|
+
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6865
|
+
if (skipExpression) {
|
6866
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6867
|
+
} else {
|
6868
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6869
|
+
}
|
6870
|
+
} else {
|
6871
|
+
if (skipExpression) {
|
6824
6872
|
addStatement(
|
6825
|
-
"
|
6873
|
+
"render",
|
6826
6874
|
section,
|
6827
|
-
|
6875
|
+
tagExtra.referencedBindings,
|
6828
6876
|
import_compiler39.types.expressionStatement(
|
6829
6877
|
callRuntime(
|
6830
|
-
"
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
6878
|
+
"partialAttrs",
|
6879
|
+
scopeIdentifier,
|
6880
|
+
visitAccessor,
|
6881
|
+
spreadExpression,
|
6882
|
+
skipExpression
|
6834
6883
|
)
|
6835
6884
|
)
|
6836
6885
|
);
|
@@ -6838,119 +6887,84 @@ var html_script_default = {
|
|
6838
6887
|
addStatement(
|
6839
6888
|
"render",
|
6840
6889
|
section,
|
6841
|
-
|
6890
|
+
tagExtra.referencedBindings,
|
6842
6891
|
import_compiler39.types.expressionStatement(
|
6843
6892
|
callRuntime(
|
6844
|
-
"
|
6845
|
-
|
6846
|
-
|
6847
|
-
|
6893
|
+
"attrs",
|
6894
|
+
scopeIdentifier,
|
6895
|
+
visitAccessor,
|
6896
|
+
spreadExpression
|
6848
6897
|
)
|
6849
6898
|
)
|
6850
6899
|
);
|
6851
6900
|
}
|
6852
|
-
break;
|
6853
|
-
}
|
6854
|
-
}
|
6855
|
-
if (spreadExpression) {
|
6856
|
-
if (isHTML) {
|
6857
|
-
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6858
|
-
if (skipExpression) {
|
6859
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6860
|
-
} else {
|
6861
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6862
|
-
}
|
6863
|
-
} else {
|
6864
|
-
if (skipExpression) {
|
6865
6901
|
addStatement(
|
6866
|
-
"
|
6902
|
+
"effect",
|
6867
6903
|
section,
|
6868
6904
|
tagExtra.referencedBindings,
|
6869
6905
|
import_compiler39.types.expressionStatement(
|
6870
|
-
callRuntime(
|
6871
|
-
|
6872
|
-
|
6873
|
-
visitAccessor,
|
6874
|
-
spreadExpression,
|
6875
|
-
skipExpression
|
6876
|
-
)
|
6877
|
-
)
|
6906
|
+
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6907
|
+
),
|
6908
|
+
false
|
6878
6909
|
);
|
6910
|
+
}
|
6911
|
+
}
|
6912
|
+
write2`>`;
|
6913
|
+
enter2(tag);
|
6914
|
+
},
|
6915
|
+
exit(tag) {
|
6916
|
+
const tagExtra = tag.node.extra;
|
6917
|
+
const nodeRef2 = tagExtra[kNativeTagBinding];
|
6918
|
+
const write2 = writeTo(tag);
|
6919
|
+
const visitAccessor = nodeRef2 && getScopeAccessorLiteral(nodeRef2);
|
6920
|
+
if (isOutputHTML()) {
|
6921
|
+
for (const child of tag.node.body.body) {
|
6922
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
6923
|
+
write2`${child.value}`;
|
6924
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6925
|
+
write2`${callRuntime("escapeScript", child.value)}`;
|
6926
|
+
}
|
6927
|
+
}
|
6928
|
+
} else {
|
6929
|
+
const templateQuasis = [];
|
6930
|
+
const templateExpressions = [];
|
6931
|
+
let currentQuasi = "";
|
6932
|
+
let referencePlaceholder;
|
6933
|
+
for (const child of tag.node.body.body) {
|
6934
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
6935
|
+
currentQuasi += child.value;
|
6936
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6937
|
+
referencePlaceholder ||= child;
|
6938
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6939
|
+
templateExpressions.push(child.value);
|
6940
|
+
currentQuasi = "";
|
6941
|
+
}
|
6942
|
+
}
|
6943
|
+
if (!referencePlaceholder) {
|
6944
|
+
write2`${currentQuasi}`;
|
6879
6945
|
} else {
|
6946
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6880
6947
|
addStatement(
|
6881
6948
|
"render",
|
6882
|
-
|
6883
|
-
|
6949
|
+
getSection(tag),
|
6950
|
+
referencePlaceholder.value.extra?.referencedBindings,
|
6884
6951
|
import_compiler39.types.expressionStatement(
|
6885
6952
|
callRuntime(
|
6886
|
-
"
|
6887
|
-
scopeIdentifier,
|
6888
|
-
|
6889
|
-
spreadExpression
|
6953
|
+
"textContent",
|
6954
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6955
|
+
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
6890
6956
|
)
|
6891
6957
|
)
|
6892
6958
|
);
|
6893
6959
|
}
|
6894
|
-
addStatement(
|
6895
|
-
"effect",
|
6896
|
-
section,
|
6897
|
-
tagExtra.referencedBindings,
|
6898
|
-
import_compiler39.types.expressionStatement(
|
6899
|
-
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6900
|
-
),
|
6901
|
-
false
|
6902
|
-
);
|
6903
|
-
}
|
6904
|
-
}
|
6905
|
-
write2`>`;
|
6906
|
-
enter2(tag);
|
6907
|
-
if (isOutputHTML()) {
|
6908
|
-
for (const child of tag.node.body.body) {
|
6909
|
-
if (import_compiler39.types.isMarkoText(child)) {
|
6910
|
-
write2`${child.value}`;
|
6911
|
-
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6912
|
-
write2`${callRuntime("escapeScript", child.value)}`;
|
6913
|
-
}
|
6914
|
-
}
|
6915
|
-
} else {
|
6916
|
-
const templateQuasis = [];
|
6917
|
-
const templateExpressions = [];
|
6918
|
-
let currentQuasi = "";
|
6919
|
-
let referencePlaceholder;
|
6920
|
-
for (const child of tag.node.body.body) {
|
6921
|
-
if (import_compiler39.types.isMarkoText(child)) {
|
6922
|
-
currentQuasi += child.value;
|
6923
|
-
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6924
|
-
referencePlaceholder ||= child;
|
6925
|
-
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6926
|
-
templateExpressions.push(child.value);
|
6927
|
-
currentQuasi = "";
|
6928
|
-
}
|
6929
6960
|
}
|
6930
|
-
|
6931
|
-
|
6932
|
-
|
6933
|
-
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6934
|
-
addStatement(
|
6935
|
-
"render",
|
6936
|
-
getSection(tag),
|
6937
|
-
referencePlaceholder.value.extra?.referencedBindings,
|
6938
|
-
import_compiler39.types.expressionStatement(
|
6939
|
-
callRuntime(
|
6940
|
-
"textContent",
|
6941
|
-
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6942
|
-
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
6943
|
-
)
|
6944
|
-
)
|
6945
|
-
);
|
6961
|
+
write2`</script>`;
|
6962
|
+
if (nodeRef2) {
|
6963
|
+
markNode(tag, nodeRef2);
|
6946
6964
|
}
|
6965
|
+
exit2(tag);
|
6966
|
+
tag.remove();
|
6947
6967
|
}
|
6948
|
-
write2`</script>`;
|
6949
|
-
if (nodeRef2) {
|
6950
|
-
markNode(tag, nodeRef2);
|
6951
|
-
}
|
6952
|
-
exit2(tag);
|
6953
|
-
tag.remove();
|
6954
6968
|
},
|
6955
6969
|
"@async": "#html-async",
|
6956
6970
|
"@crossorigin": "#html-crossorigin",
|
@@ -7098,124 +7112,167 @@ var html_style_default = {
|
|
7098
7112
|
}
|
7099
7113
|
}
|
7100
7114
|
},
|
7101
|
-
translate
|
7102
|
-
|
7103
|
-
|
7104
|
-
|
7105
|
-
|
7106
|
-
|
7107
|
-
|
7108
|
-
|
7109
|
-
|
7110
|
-
|
7111
|
-
|
7112
|
-
|
7113
|
-
|
7114
|
-
|
7115
|
-
|
7116
|
-
|
7117
|
-
|
7118
|
-
|
7119
|
-
|
7120
|
-
|
7121
|
-
|
7122
|
-
|
7123
|
-
|
7124
|
-
} else {
|
7125
|
-
const varName = tag.node.var.name;
|
7126
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
7127
|
-
let getterFnIdentifier;
|
7128
|
-
if (getterId) {
|
7129
|
-
getterFnIdentifier = (0, import_compiler40.getProgram)().scope.generateUidIdentifier(
|
7130
|
-
`get_${varName}`
|
7131
|
-
);
|
7132
|
-
(0, import_compiler40.getProgram)().node.body.push(
|
7133
|
-
import_compiler40.types.variableDeclaration("const", [
|
7134
|
-
import_compiler40.types.variableDeclarator(
|
7135
|
-
getterFnIdentifier,
|
7136
|
-
callRuntime(
|
7137
|
-
"nodeRef",
|
7138
|
-
import_compiler40.types.stringLiteral(getterId),
|
7139
|
-
getScopeAccessorLiteral(nodeRef2)
|
7140
|
-
)
|
7141
|
-
)
|
7142
|
-
])
|
7115
|
+
translate: {
|
7116
|
+
enter(tag) {
|
7117
|
+
const tagExtra = tag.node.extra;
|
7118
|
+
const nodeRef2 = tagExtra[kNativeTagBinding];
|
7119
|
+
const isHTML = isOutputHTML();
|
7120
|
+
const write2 = writeTo(tag);
|
7121
|
+
const section = getSection(tag);
|
7122
|
+
const hasVar = !!tag.node.var;
|
7123
|
+
if (hasVar) {
|
7124
|
+
const getterId = tagExtra[kGetterId4];
|
7125
|
+
if (isHTML) {
|
7126
|
+
const varName = tag.node.var.name;
|
7127
|
+
const references = tag.scope.getBinding(varName).referencePaths;
|
7128
|
+
for (const reference of references) {
|
7129
|
+
serializeOwners(getSection(reference), section);
|
7130
|
+
}
|
7131
|
+
translateVar(
|
7132
|
+
tag,
|
7133
|
+
callRuntime(
|
7134
|
+
"nodeRef",
|
7135
|
+
getterId && getScopeIdIdentifier(section),
|
7136
|
+
getterId && import_compiler40.types.stringLiteral(getterId)
|
7137
|
+
)
|
7143
7138
|
);
|
7144
|
-
}
|
7145
|
-
|
7146
|
-
const
|
7147
|
-
|
7148
|
-
|
7149
|
-
|
7150
|
-
|
7151
|
-
)
|
7139
|
+
} else {
|
7140
|
+
const varName = tag.node.var.name;
|
7141
|
+
const references = tag.scope.getBinding(varName).referencePaths;
|
7142
|
+
let getterFnIdentifier;
|
7143
|
+
if (getterId) {
|
7144
|
+
getterFnIdentifier = (0, import_compiler40.getProgram)().scope.generateUidIdentifier(
|
7145
|
+
`get_${varName}`
|
7152
7146
|
);
|
7153
|
-
|
7154
|
-
|
7155
|
-
|
7156
|
-
|
7147
|
+
(0, import_compiler40.getProgram)().node.body.push(
|
7148
|
+
import_compiler40.types.variableDeclaration("const", [
|
7149
|
+
import_compiler40.types.variableDeclarator(
|
7150
|
+
getterFnIdentifier,
|
7151
|
+
callRuntime(
|
7152
|
+
"nodeRef",
|
7153
|
+
import_compiler40.types.stringLiteral(getterId),
|
7154
|
+
getScopeAccessorLiteral(nodeRef2)
|
7155
|
+
)
|
7156
|
+
)
|
7157
7157
|
])
|
7158
7158
|
);
|
7159
7159
|
}
|
7160
|
+
for (const reference of references) {
|
7161
|
+
const referenceSection = getSection(reference);
|
7162
|
+
if (isInvokedFunction(reference)) {
|
7163
|
+
reference.parentPath.replaceWith(
|
7164
|
+
import_compiler40.types.expressionStatement(
|
7165
|
+
createScopeReadExpression(referenceSection, nodeRef2)
|
7166
|
+
)
|
7167
|
+
);
|
7168
|
+
} else if (getterFnIdentifier) {
|
7169
|
+
reference.replaceWith(
|
7170
|
+
import_compiler40.types.callExpression(getterFnIdentifier, [
|
7171
|
+
getScopeExpression(referenceSection, getSection(tag))
|
7172
|
+
])
|
7173
|
+
);
|
7174
|
+
}
|
7175
|
+
}
|
7160
7176
|
}
|
7161
7177
|
}
|
7162
|
-
|
7163
|
-
|
7164
|
-
|
7165
|
-
|
7166
|
-
|
7167
|
-
|
7168
|
-
|
7169
|
-
|
7170
|
-
|
7171
|
-
|
7172
|
-
|
7173
|
-
|
7174
|
-
|
7175
|
-
|
7176
|
-
|
7177
|
-
|
7178
|
-
|
7179
|
-
|
7180
|
-
|
7181
|
-
|
7182
|
-
|
7183
|
-
|
7184
|
-
|
7185
|
-
|
7186
|
-
|
7187
|
-
|
7188
|
-
|
7189
|
-
|
7190
|
-
|
7191
|
-
|
7192
|
-
|
7178
|
+
let visitAccessor;
|
7179
|
+
if (nodeRef2) {
|
7180
|
+
visitAccessor = getScopeAccessorLiteral(nodeRef2);
|
7181
|
+
visit(tag, 32 /* Get */);
|
7182
|
+
}
|
7183
|
+
write2`<style`;
|
7184
|
+
const usedAttrs = getUsedAttrs3(tag.node);
|
7185
|
+
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
7186
|
+
for (const attr2 of staticAttrs) {
|
7187
|
+
const { name: name2, value } = attr2;
|
7188
|
+
const { confident, computed } = value.extra || {};
|
7189
|
+
const valueReferences = value.extra?.referencedBindings;
|
7190
|
+
switch (name2) {
|
7191
|
+
case "class":
|
7192
|
+
case "style": {
|
7193
|
+
const helper = `${name2}Attr`;
|
7194
|
+
if (confident) {
|
7195
|
+
write2`${getHTMLRuntime()[helper](computed)}`;
|
7196
|
+
} else if (isHTML) {
|
7197
|
+
write2`${callRuntime(helper, value)}`;
|
7198
|
+
} else {
|
7199
|
+
addStatement(
|
7200
|
+
"render",
|
7201
|
+
section,
|
7202
|
+
valueReferences,
|
7203
|
+
import_compiler40.types.expressionStatement(
|
7204
|
+
callRuntime(
|
7205
|
+
helper,
|
7206
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7207
|
+
value
|
7208
|
+
)
|
7193
7209
|
)
|
7194
|
-
)
|
7195
|
-
|
7210
|
+
);
|
7211
|
+
}
|
7212
|
+
break;
|
7196
7213
|
}
|
7197
|
-
|
7198
|
-
|
7199
|
-
|
7200
|
-
|
7201
|
-
|
7202
|
-
|
7203
|
-
|
7204
|
-
|
7214
|
+
default:
|
7215
|
+
if (confident) {
|
7216
|
+
write2`${getHTMLRuntime().attr(name2, computed)}`;
|
7217
|
+
} else if (isHTML) {
|
7218
|
+
if (isEventHandler(name2)) {
|
7219
|
+
addHTMLEffectCall(section, valueReferences);
|
7220
|
+
} else {
|
7221
|
+
write2`${callRuntime("attr", import_compiler40.types.stringLiteral(name2), value)}`;
|
7222
|
+
}
|
7223
|
+
} else if (isEventHandler(name2)) {
|
7224
|
+
addStatement(
|
7225
|
+
"effect",
|
7226
|
+
section,
|
7227
|
+
valueReferences,
|
7228
|
+
import_compiler40.types.expressionStatement(
|
7229
|
+
callRuntime(
|
7230
|
+
"on",
|
7231
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7232
|
+
import_compiler40.types.stringLiteral(getEventHandlerName(name2)),
|
7233
|
+
value
|
7234
|
+
)
|
7235
|
+
)
|
7236
|
+
);
|
7205
7237
|
} else {
|
7206
|
-
|
7238
|
+
addStatement(
|
7239
|
+
"render",
|
7240
|
+
section,
|
7241
|
+
valueReferences,
|
7242
|
+
import_compiler40.types.expressionStatement(
|
7243
|
+
callRuntime(
|
7244
|
+
"attr",
|
7245
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7246
|
+
import_compiler40.types.stringLiteral(name2),
|
7247
|
+
value
|
7248
|
+
)
|
7249
|
+
)
|
7250
|
+
);
|
7207
7251
|
}
|
7208
|
-
|
7252
|
+
break;
|
7253
|
+
}
|
7254
|
+
}
|
7255
|
+
if (spreadExpression) {
|
7256
|
+
if (isHTML) {
|
7257
|
+
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
7258
|
+
if (skipExpression) {
|
7259
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7260
|
+
} else {
|
7261
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7262
|
+
}
|
7263
|
+
} else {
|
7264
|
+
if (skipExpression) {
|
7209
7265
|
addStatement(
|
7210
|
-
"
|
7266
|
+
"render",
|
7211
7267
|
section,
|
7212
|
-
|
7268
|
+
tagExtra.referencedBindings,
|
7213
7269
|
import_compiler40.types.expressionStatement(
|
7214
7270
|
callRuntime(
|
7215
|
-
"
|
7216
|
-
|
7217
|
-
|
7218
|
-
|
7271
|
+
"partialAttrs",
|
7272
|
+
scopeIdentifier,
|
7273
|
+
visitAccessor,
|
7274
|
+
spreadExpression,
|
7275
|
+
skipExpression
|
7219
7276
|
)
|
7220
7277
|
)
|
7221
7278
|
);
|
@@ -7223,119 +7280,84 @@ var html_style_default = {
|
|
7223
7280
|
addStatement(
|
7224
7281
|
"render",
|
7225
7282
|
section,
|
7226
|
-
|
7283
|
+
tagExtra.referencedBindings,
|
7227
7284
|
import_compiler40.types.expressionStatement(
|
7228
7285
|
callRuntime(
|
7229
|
-
"
|
7230
|
-
|
7231
|
-
|
7232
|
-
|
7286
|
+
"attrs",
|
7287
|
+
scopeIdentifier,
|
7288
|
+
visitAccessor,
|
7289
|
+
spreadExpression
|
7233
7290
|
)
|
7234
7291
|
)
|
7235
7292
|
);
|
7236
7293
|
}
|
7237
|
-
break;
|
7238
|
-
}
|
7239
|
-
}
|
7240
|
-
if (spreadExpression) {
|
7241
|
-
if (isHTML) {
|
7242
|
-
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
7243
|
-
if (skipExpression) {
|
7244
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7245
|
-
} else {
|
7246
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7247
|
-
}
|
7248
|
-
} else {
|
7249
|
-
if (skipExpression) {
|
7250
7294
|
addStatement(
|
7251
|
-
"
|
7295
|
+
"effect",
|
7252
7296
|
section,
|
7253
7297
|
tagExtra.referencedBindings,
|
7254
7298
|
import_compiler40.types.expressionStatement(
|
7255
|
-
callRuntime(
|
7256
|
-
|
7257
|
-
|
7258
|
-
visitAccessor,
|
7259
|
-
spreadExpression,
|
7260
|
-
skipExpression
|
7261
|
-
)
|
7262
|
-
)
|
7299
|
+
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
7300
|
+
),
|
7301
|
+
false
|
7263
7302
|
);
|
7303
|
+
}
|
7304
|
+
}
|
7305
|
+
},
|
7306
|
+
exit(tag) {
|
7307
|
+
const tagExtra = tag.node.extra;
|
7308
|
+
const nodeRef2 = tagExtra[kNativeTagBinding];
|
7309
|
+
const write2 = writeTo(tag);
|
7310
|
+
const visitAccessor = nodeRef2 && getScopeAccessorLiteral(nodeRef2);
|
7311
|
+
write2`>`;
|
7312
|
+
enter2(tag);
|
7313
|
+
if (isOutputHTML()) {
|
7314
|
+
for (const child of tag.node.body.body) {
|
7315
|
+
if (import_compiler40.types.isMarkoText(child)) {
|
7316
|
+
write2`${child.value}`;
|
7317
|
+
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7318
|
+
write2`${callRuntime("escapeStyle", child.value)}`;
|
7319
|
+
}
|
7320
|
+
}
|
7321
|
+
} else {
|
7322
|
+
const templateQuasis = [];
|
7323
|
+
const templateExpressions = [];
|
7324
|
+
let currentQuasi = "";
|
7325
|
+
let referencePlaceholder;
|
7326
|
+
for (const child of tag.node.body.body) {
|
7327
|
+
if (import_compiler40.types.isMarkoText(child)) {
|
7328
|
+
currentQuasi += child.value;
|
7329
|
+
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7330
|
+
referencePlaceholder ||= child;
|
7331
|
+
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7332
|
+
templateExpressions.push(child.value);
|
7333
|
+
currentQuasi = "";
|
7334
|
+
}
|
7335
|
+
}
|
7336
|
+
if (!referencePlaceholder) {
|
7337
|
+
write2`${currentQuasi}`;
|
7264
7338
|
} else {
|
7339
|
+
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7265
7340
|
addStatement(
|
7266
7341
|
"render",
|
7267
|
-
|
7268
|
-
|
7342
|
+
getSection(tag),
|
7343
|
+
referencePlaceholder.value.extra?.referencedBindings,
|
7269
7344
|
import_compiler40.types.expressionStatement(
|
7270
7345
|
callRuntime(
|
7271
|
-
"
|
7272
|
-
scopeIdentifier,
|
7273
|
-
|
7274
|
-
spreadExpression
|
7346
|
+
"textContent",
|
7347
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7348
|
+
import_compiler40.types.templateLiteral(templateQuasis, templateExpressions)
|
7275
7349
|
)
|
7276
7350
|
)
|
7277
7351
|
);
|
7278
7352
|
}
|
7279
|
-
addStatement(
|
7280
|
-
"effect",
|
7281
|
-
section,
|
7282
|
-
tagExtra.referencedBindings,
|
7283
|
-
import_compiler40.types.expressionStatement(
|
7284
|
-
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
7285
|
-
),
|
7286
|
-
false
|
7287
|
-
);
|
7288
|
-
}
|
7289
|
-
}
|
7290
|
-
write2`>`;
|
7291
|
-
enter2(tag);
|
7292
|
-
if (isOutputHTML()) {
|
7293
|
-
for (const child of tag.node.body.body) {
|
7294
|
-
if (import_compiler40.types.isMarkoText(child)) {
|
7295
|
-
write2`${child.value}`;
|
7296
|
-
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7297
|
-
write2`${callRuntime("escapeStyle", child.value)}`;
|
7298
|
-
}
|
7299
|
-
}
|
7300
|
-
} else {
|
7301
|
-
const templateQuasis = [];
|
7302
|
-
const templateExpressions = [];
|
7303
|
-
let currentQuasi = "";
|
7304
|
-
let referencePlaceholder;
|
7305
|
-
for (const child of tag.node.body.body) {
|
7306
|
-
if (import_compiler40.types.isMarkoText(child)) {
|
7307
|
-
currentQuasi += child.value;
|
7308
|
-
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7309
|
-
referencePlaceholder ||= child;
|
7310
|
-
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7311
|
-
templateExpressions.push(child.value);
|
7312
|
-
currentQuasi = "";
|
7313
|
-
}
|
7314
7353
|
}
|
7315
|
-
|
7316
|
-
|
7317
|
-
|
7318
|
-
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7319
|
-
addStatement(
|
7320
|
-
"render",
|
7321
|
-
getSection(tag),
|
7322
|
-
referencePlaceholder.value.extra?.referencedBindings,
|
7323
|
-
import_compiler40.types.expressionStatement(
|
7324
|
-
callRuntime(
|
7325
|
-
"textContent",
|
7326
|
-
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7327
|
-
import_compiler40.types.templateLiteral(templateQuasis, templateExpressions)
|
7328
|
-
)
|
7329
|
-
)
|
7330
|
-
);
|
7354
|
+
write2`</style>`;
|
7355
|
+
if (nodeRef2) {
|
7356
|
+
markNode(tag, nodeRef2);
|
7331
7357
|
}
|
7358
|
+
exit2(tag);
|
7359
|
+
tag.remove();
|
7332
7360
|
}
|
7333
|
-
write2`</style>`;
|
7334
|
-
if (nodeRef2) {
|
7335
|
-
markNode(tag, nodeRef2);
|
7336
|
-
}
|
7337
|
-
exit2(tag);
|
7338
|
-
tag.remove();
|
7339
7361
|
},
|
7340
7362
|
"@disabled": "#html-disabled",
|
7341
7363
|
"@media": "#html-media",
|
@@ -8632,12 +8654,29 @@ var import_declaration_default = {
|
|
8632
8654
|
};
|
8633
8655
|
|
8634
8656
|
// src/translator/visitors/placeholder.ts
|
8657
|
+
var import_compiler54 = require("@marko/compiler");
|
8658
|
+
|
8659
|
+
// src/translator/util/is-non-html-text.ts
|
8635
8660
|
var import_compiler53 = require("@marko/compiler");
|
8661
|
+
function isNonHTMLText(placeholder) {
|
8662
|
+
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
8663
|
+
if (parentTag && isCoreTag(parentTag)) {
|
8664
|
+
switch (parentTag.node.name.value) {
|
8665
|
+
case "html-comment":
|
8666
|
+
case "html-script":
|
8667
|
+
case "html-style":
|
8668
|
+
return true;
|
8669
|
+
}
|
8670
|
+
}
|
8671
|
+
return false;
|
8672
|
+
}
|
8673
|
+
|
8674
|
+
// src/translator/visitors/placeholder.ts
|
8636
8675
|
var kBinding = Symbol("placeholder node binding");
|
8637
8676
|
var kSiblingText = Symbol("placeholder has sibling text");
|
8638
8677
|
var placeholder_default = {
|
8639
8678
|
analyze(placeholder) {
|
8640
|
-
if (
|
8679
|
+
if (isNonHTMLText(placeholder)) return;
|
8641
8680
|
const { node } = placeholder;
|
8642
8681
|
const { confident, computed } = evaluate(node.value);
|
8643
8682
|
if (!(confident && (node.escape || isVoid2(computed)))) {
|
@@ -8653,6 +8692,7 @@ var placeholder_default = {
|
|
8653
8692
|
},
|
8654
8693
|
translate: {
|
8655
8694
|
exit(placeholder) {
|
8695
|
+
if (isNonHTMLText(placeholder)) return;
|
8656
8696
|
const { node } = placeholder;
|
8657
8697
|
const { value } = node;
|
8658
8698
|
const { confident, computed, referencedBindings } = evaluate(value);
|
@@ -8692,10 +8732,10 @@ var placeholder_default = {
|
|
8692
8732
|
"render",
|
8693
8733
|
getSection(placeholder),
|
8694
8734
|
value.extra?.referencedBindings,
|
8695
|
-
|
8735
|
+
import_compiler54.types.expressionStatement(
|
8696
8736
|
method === "data" ? callRuntime(
|
8697
8737
|
"data",
|
8698
|
-
|
8738
|
+
import_compiler54.types.memberExpression(
|
8699
8739
|
scopeIdentifier,
|
8700
8740
|
getScopeAccessorLiteral(nodeBinding),
|
8701
8741
|
true
|
@@ -8732,7 +8772,7 @@ function analyzeSiblingText(placeholder) {
|
|
8732
8772
|
break;
|
8733
8773
|
}
|
8734
8774
|
}
|
8735
|
-
if (!prev.node &&
|
8775
|
+
if (!prev.node && import_compiler54.types.isProgram(placeholder.parentPath)) {
|
8736
8776
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
8737
8777
|
}
|
8738
8778
|
let next = placeholder.getNextSibling();
|
@@ -8749,29 +8789,17 @@ function analyzeSiblingText(placeholder) {
|
|
8749
8789
|
break;
|
8750
8790
|
}
|
8751
8791
|
}
|
8752
|
-
if (!next.node &&
|
8792
|
+
if (!next.node && import_compiler54.types.isProgram(placeholder.parentPath)) {
|
8753
8793
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
8754
8794
|
}
|
8755
8795
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
8756
8796
|
}
|
8757
|
-
function isNonHTMLPlaceholder(placeholder) {
|
8758
|
-
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
8759
|
-
if (parentTag && isCoreTag(parentTag)) {
|
8760
|
-
switch (parentTag.node.name.value) {
|
8761
|
-
case "html-comment":
|
8762
|
-
case "html-script":
|
8763
|
-
case "html-style":
|
8764
|
-
return true;
|
8765
|
-
}
|
8766
|
-
}
|
8767
|
-
return false;
|
8768
|
-
}
|
8769
8797
|
function isVoid2(value) {
|
8770
8798
|
return value == null || value === false;
|
8771
8799
|
}
|
8772
8800
|
|
8773
8801
|
// src/translator/visitors/referenced-identifier.ts
|
8774
|
-
var
|
8802
|
+
var import_compiler55 = require("@marko/compiler");
|
8775
8803
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
8776
8804
|
var referenced_identifier_default = {
|
8777
8805
|
migrate(identifier) {
|
@@ -8779,8 +8807,8 @@ var referenced_identifier_default = {
|
|
8779
8807
|
if (identifier.scope.hasBinding(name2)) return;
|
8780
8808
|
switch (name2) {
|
8781
8809
|
case "out":
|
8782
|
-
if (
|
8783
|
-
identifier.parentPath.replaceWith(
|
8810
|
+
if (import_compiler55.types.isMemberExpression(identifier.parent) && import_compiler55.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
8811
|
+
identifier.parentPath.replaceWith(import_compiler55.types.identifier("$global"));
|
8784
8812
|
} else {
|
8785
8813
|
throw identifier.buildCodeFrameError(
|
8786
8814
|
"Only `out.global` is supported for compatibility."
|
@@ -8807,24 +8835,24 @@ var referenced_identifier_default = {
|
|
8807
8835
|
case "$global":
|
8808
8836
|
if (isOutputHTML()) {
|
8809
8837
|
identifier.replaceWith(
|
8810
|
-
|
8838
|
+
import_compiler55.types.callExpression(importRuntime("$global"), [])
|
8811
8839
|
);
|
8812
8840
|
} else {
|
8813
8841
|
identifier.replaceWith(
|
8814
|
-
|
8842
|
+
import_compiler55.types.memberExpression(scopeIdentifier, import_compiler55.types.identifier("$global"))
|
8815
8843
|
);
|
8816
8844
|
}
|
8817
8845
|
break;
|
8818
8846
|
case "$signal":
|
8819
8847
|
if (isOutputHTML()) {
|
8820
8848
|
identifier.replaceWith(
|
8821
|
-
|
8822
|
-
|
8849
|
+
import_compiler55.types.callExpression(
|
8850
|
+
import_compiler55.types.arrowFunctionExpression(
|
8823
8851
|
[],
|
8824
|
-
|
8825
|
-
|
8826
|
-
|
8827
|
-
|
8852
|
+
import_compiler55.types.blockStatement([
|
8853
|
+
import_compiler55.types.throwStatement(
|
8854
|
+
import_compiler55.types.newExpression(import_compiler55.types.identifier("Error"), [
|
8855
|
+
import_compiler55.types.stringLiteral("Cannot use $signal in a server render.")
|
8828
8856
|
])
|
8829
8857
|
)
|
8830
8858
|
])
|
@@ -8850,19 +8878,19 @@ var referenced_identifier_default = {
|
|
8850
8878
|
"render",
|
8851
8879
|
section,
|
8852
8880
|
exprRoot.node.extra?.referencedBindings,
|
8853
|
-
|
8854
|
-
|
8881
|
+
import_compiler55.types.expressionStatement(
|
8882
|
+
import_compiler55.types.callExpression(importRuntime("resetAbortSignal"), [
|
8855
8883
|
scopeIdentifier,
|
8856
|
-
|
8884
|
+
import_compiler55.types.numericLiteral(exprId)
|
8857
8885
|
])
|
8858
8886
|
),
|
8859
8887
|
false
|
8860
8888
|
);
|
8861
8889
|
}
|
8862
8890
|
identifier.replaceWith(
|
8863
|
-
|
8891
|
+
import_compiler55.types.callExpression(importRuntime("getAbortSignal"), [
|
8864
8892
|
scopeIdentifier,
|
8865
|
-
|
8893
|
+
import_compiler55.types.numericLiteral(exprId)
|
8866
8894
|
])
|
8867
8895
|
);
|
8868
8896
|
}
|
@@ -8902,11 +8930,11 @@ var scriptlet_default = {
|
|
8902
8930
|
};
|
8903
8931
|
|
8904
8932
|
// src/translator/visitors/tag/index.ts
|
8905
|
-
var
|
8933
|
+
var import_compiler59 = require("@marko/compiler");
|
8906
8934
|
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
8907
8935
|
|
8908
8936
|
// src/translator/visitors/tag/attribute-tag.ts
|
8909
|
-
var
|
8937
|
+
var import_compiler56 = require("@marko/compiler");
|
8910
8938
|
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8911
8939
|
var attribute_tag_default = {
|
8912
8940
|
analyze: {
|
@@ -8937,7 +8965,7 @@ var attribute_tag_default = {
|
|
8937
8965
|
};
|
8938
8966
|
|
8939
8967
|
// src/translator/visitors/tag/custom-tag.ts
|
8940
|
-
var
|
8968
|
+
var import_compiler57 = require("@marko/compiler");
|
8941
8969
|
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
8942
8970
|
var import_path4 = __toESM(require("path"));
|
8943
8971
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
@@ -8992,7 +9020,7 @@ var custom_tag_default = {
|
|
8992
9020
|
tag,
|
8993
9021
|
childProgramExtra?.domExports.input
|
8994
9022
|
);
|
8995
|
-
(0,
|
9023
|
+
(0, import_compiler57.getProgram)().node.extra.hasInteractiveChild = childProgramExtra?.isInteractive || childProgramExtra?.hasInteractiveChild || false;
|
8996
9024
|
}
|
8997
9025
|
}
|
8998
9026
|
},
|
@@ -9019,9 +9047,9 @@ function translateHTML(tag) {
|
|
9019
9047
|
let tagIdentifier;
|
9020
9048
|
flushInto(tag);
|
9021
9049
|
writeHTMLResumeStatements(tagBody);
|
9022
|
-
if (
|
9050
|
+
if (import_compiler57.types.isStringLiteral(node.name)) {
|
9023
9051
|
const relativePath = getTagRelativePath(tag);
|
9024
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
9052
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler57.types.identifier(getTemplateContentName()) : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
9025
9053
|
} else {
|
9026
9054
|
tagIdentifier = node.name;
|
9027
9055
|
}
|
@@ -9039,8 +9067,8 @@ function translateHTML(tag) {
|
|
9039
9067
|
childScopeBinding?.name
|
9040
9068
|
);
|
9041
9069
|
tag.insertBefore(
|
9042
|
-
|
9043
|
-
|
9070
|
+
import_compiler57.types.variableDeclaration("const", [
|
9071
|
+
import_compiler57.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
9044
9072
|
])
|
9045
9073
|
);
|
9046
9074
|
setSerializedProperty(
|
@@ -9051,13 +9079,13 @@ function translateHTML(tag) {
|
|
9051
9079
|
);
|
9052
9080
|
if (tagVar) {
|
9053
9081
|
statements.push(
|
9054
|
-
|
9082
|
+
import_compiler57.types.expressionStatement(
|
9055
9083
|
callRuntime(
|
9056
9084
|
"setTagVar",
|
9057
9085
|
getScopeIdIdentifier(section),
|
9058
9086
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
9059
9087
|
peekScopeId,
|
9060
|
-
|
9088
|
+
import_compiler57.types.stringLiteral(
|
9061
9089
|
getResumeRegisterId(
|
9062
9090
|
section,
|
9063
9091
|
node.var.extra?.binding,
|
@@ -9077,8 +9105,8 @@ function translateHTML(tag) {
|
|
9077
9105
|
const contentExpression = contentProp.value;
|
9078
9106
|
contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
|
9079
9107
|
const [contentPath] = tag.insertBefore(
|
9080
|
-
|
9081
|
-
|
9108
|
+
import_compiler57.types.variableDeclaration("const", [
|
9109
|
+
import_compiler57.types.variableDeclarator(
|
9082
9110
|
contentId,
|
9083
9111
|
// TODO: only register if needed (child template analysis)
|
9084
9112
|
contentExpression
|
@@ -9092,13 +9120,13 @@ function translateHTML(tag) {
|
|
9092
9120
|
propsToExpression(properties)
|
9093
9121
|
);
|
9094
9122
|
if (tagVar) {
|
9095
|
-
translateVar(tag,
|
9096
|
-
renderTagExpr =
|
9123
|
+
translateVar(tag, import_compiler57.types.unaryExpression("void", import_compiler57.types.numericLiteral(0)), "let");
|
9124
|
+
renderTagExpr = import_compiler57.types.assignmentExpression("=", tagVar, renderTagExpr);
|
9097
9125
|
}
|
9098
9126
|
statements.push(
|
9099
|
-
|
9127
|
+
import_compiler57.types.ifStatement(
|
9100
9128
|
tagIdentifier,
|
9101
|
-
|
9129
|
+
import_compiler57.types.expressionStatement(renderTagExpr),
|
9102
9130
|
contentId && callStatement(contentId)
|
9103
9131
|
)
|
9104
9132
|
);
|
@@ -9124,7 +9152,7 @@ function translateDOM(tag) {
|
|
9124
9152
|
const childScopeBinding = extra[kChildScopeBinding];
|
9125
9153
|
const write2 = writeTo(tag);
|
9126
9154
|
const { file } = tag.hub;
|
9127
|
-
const tagName =
|
9155
|
+
const tagName = import_compiler57.types.isIdentifier(node.name) ? node.name.name : import_compiler57.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
9128
9156
|
const relativePath = getTagRelativePath(tag);
|
9129
9157
|
const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
|
9130
9158
|
const childExports = childFile.ast.program.extra.domExports;
|
@@ -9156,7 +9184,7 @@ function translateDOM(tag) {
|
|
9156
9184
|
);
|
9157
9185
|
source.register = true;
|
9158
9186
|
source.buildAssignment = (valueSection, value) => {
|
9159
|
-
return
|
9187
|
+
return import_compiler57.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9160
9188
|
createScopeReadExpression(valueSection, childScopeBinding),
|
9161
9189
|
value
|
9162
9190
|
]);
|
@@ -9165,7 +9193,7 @@ function translateDOM(tag) {
|
|
9165
9193
|
"render",
|
9166
9194
|
tagSection,
|
9167
9195
|
void 0,
|
9168
|
-
|
9196
|
+
import_compiler57.types.expressionStatement(
|
9169
9197
|
callRuntime(
|
9170
9198
|
"setTagVar",
|
9171
9199
|
scopeIdentifier,
|
@@ -9179,8 +9207,8 @@ function translateDOM(tag) {
|
|
9179
9207
|
"render",
|
9180
9208
|
tagSection,
|
9181
9209
|
void 0,
|
9182
|
-
|
9183
|
-
|
9210
|
+
import_compiler57.types.expressionStatement(
|
9211
|
+
import_compiler57.types.callExpression(tagIdentifier, [
|
9184
9212
|
createScopeReadExpression(tagSection, childScopeBinding)
|
9185
9213
|
])
|
9186
9214
|
)
|
@@ -9193,7 +9221,7 @@ function getTagRelativePath(tag) {
|
|
9193
9221
|
hub: { file }
|
9194
9222
|
} = tag;
|
9195
9223
|
let relativePath;
|
9196
|
-
if (
|
9224
|
+
if (import_compiler57.types.isStringLiteral(node.name)) {
|
9197
9225
|
const template = (0, import_babel_utils41.getTagTemplate)(tag);
|
9198
9226
|
relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
|
9199
9227
|
} else if (node.extra?.tagNameImported) {
|
@@ -9286,7 +9314,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9286
9314
|
let spreadReferenceNodes;
|
9287
9315
|
for (let i = attributes.length; i--; ) {
|
9288
9316
|
const attr2 = attributes[i];
|
9289
|
-
if (
|
9317
|
+
if (import_compiler57.types.isMarkoAttribute(attr2)) {
|
9290
9318
|
if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
|
9291
9319
|
dropReferences(attr2.value);
|
9292
9320
|
continue;
|
@@ -9295,7 +9323,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9295
9323
|
}
|
9296
9324
|
if (spreadReferenceNodes) {
|
9297
9325
|
spreadReferenceNodes.push(attr2.value);
|
9298
|
-
} else if (
|
9326
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr2)) {
|
9299
9327
|
spreadReferenceNodes = [attr2.value];
|
9300
9328
|
} else {
|
9301
9329
|
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
@@ -9320,7 +9348,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9320
9348
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
9321
9349
|
tag.node.extra?.referencedBindings,
|
9322
9350
|
identifierToSignal(tagInputIdentifier),
|
9323
|
-
|
9351
|
+
import_compiler57.types.isSpreadElement(arg) ? import_compiler57.types.memberExpression(arg.argument, import_compiler57.types.numericLiteral(0), true) : arg,
|
9324
9352
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9325
9353
|
);
|
9326
9354
|
return;
|
@@ -9368,7 +9396,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9368
9396
|
} else {
|
9369
9397
|
attrTagCallsForTag.set(
|
9370
9398
|
attrTagName,
|
9371
|
-
translatedProps =
|
9399
|
+
translatedProps = import_compiler57.types.parenthesizedExpression(
|
9372
9400
|
callRuntime("attrTag", translatedProps)
|
9373
9401
|
)
|
9374
9402
|
);
|
@@ -9453,7 +9481,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9453
9481
|
childAttrExports.id,
|
9454
9482
|
`${importAlias}_${attrTagMeta.name}`
|
9455
9483
|
);
|
9456
|
-
decls.push(
|
9484
|
+
decls.push(import_compiler57.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
9457
9485
|
addValue(
|
9458
9486
|
info.tagSection,
|
9459
9487
|
referencedBindings,
|
@@ -9463,7 +9491,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9463
9491
|
);
|
9464
9492
|
}
|
9465
9493
|
addStatement("render", info.tagSection, referencedBindings, [
|
9466
|
-
|
9494
|
+
import_compiler57.types.variableDeclaration("let", decls),
|
9467
9495
|
...statements
|
9468
9496
|
]);
|
9469
9497
|
}
|
@@ -9483,7 +9511,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9483
9511
|
void 0,
|
9484
9512
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
9485
9513
|
identifierToSignal(contentExportIdentifier),
|
9486
|
-
|
9514
|
+
import_compiler57.types.callExpression(import_compiler57.types.identifier(bodySection.name), [scopeIdentifier]),
|
9487
9515
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9488
9516
|
);
|
9489
9517
|
}
|
@@ -9493,7 +9521,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9493
9521
|
let spreadProps;
|
9494
9522
|
for (let i = attributes.length; i--; ) {
|
9495
9523
|
const attr2 = attributes[i];
|
9496
|
-
if (
|
9524
|
+
if (import_compiler57.types.isMarkoAttribute(attr2)) {
|
9497
9525
|
const childAttrExports = templateExport.props[attr2.name];
|
9498
9526
|
if (!childAttrExports || seen.has(attr2.name)) continue;
|
9499
9527
|
seen.add(attr2.name);
|
@@ -9503,9 +9531,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9503
9531
|
}
|
9504
9532
|
staticAttrs.push(attr2);
|
9505
9533
|
} else if (spreadProps) {
|
9506
|
-
spreadProps.push(
|
9534
|
+
spreadProps.push(import_compiler57.types.spreadElement(attr2.value));
|
9507
9535
|
} else {
|
9508
|
-
spreadProps = [
|
9536
|
+
spreadProps = [import_compiler57.types.spreadElement(attr2.value)];
|
9509
9537
|
}
|
9510
9538
|
}
|
9511
9539
|
for (const attr2 of staticAttrs.reverse()) {
|
@@ -9534,8 +9562,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9534
9562
|
spreadProps.reverse();
|
9535
9563
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
9536
9564
|
addStatement("render", info.tagSection, referencedBindings, [
|
9537
|
-
|
9538
|
-
|
9565
|
+
import_compiler57.types.variableDeclaration("const", [
|
9566
|
+
import_compiler57.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
9539
9567
|
])
|
9540
9568
|
]);
|
9541
9569
|
}
|
@@ -9559,7 +9587,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9559
9587
|
}
|
9560
9588
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
9561
9589
|
if (isCircularRequest(file, request)) {
|
9562
|
-
return
|
9590
|
+
return import_compiler57.types.identifier(name2);
|
9563
9591
|
}
|
9564
9592
|
return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
|
9565
9593
|
}
|
@@ -9568,10 +9596,10 @@ function isCircularRequest(file, request) {
|
|
9568
9596
|
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
9569
9597
|
}
|
9570
9598
|
function callStatement(id, ...args) {
|
9571
|
-
return
|
9599
|
+
return import_compiler57.types.expressionStatement(callExpression(id, ...args));
|
9572
9600
|
}
|
9573
9601
|
function callExpression(id, ...args) {
|
9574
|
-
return
|
9602
|
+
return import_compiler57.types.callExpression(id, args.filter(Boolean));
|
9575
9603
|
}
|
9576
9604
|
function identifierToSignal(identifier) {
|
9577
9605
|
return {
|
@@ -9580,14 +9608,14 @@ function identifierToSignal(identifier) {
|
|
9580
9608
|
};
|
9581
9609
|
}
|
9582
9610
|
function buildUndefined2() {
|
9583
|
-
return
|
9611
|
+
return import_compiler57.types.unaryExpression("void", import_compiler57.types.numericLiteral(0));
|
9584
9612
|
}
|
9585
9613
|
function always() {
|
9586
9614
|
return true;
|
9587
9615
|
}
|
9588
9616
|
|
9589
9617
|
// src/translator/visitors/tag/dynamic-tag.ts
|
9590
|
-
var
|
9618
|
+
var import_compiler58 = require("@marko/compiler");
|
9591
9619
|
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
9592
9620
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
9593
9621
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
@@ -9643,7 +9671,7 @@ var dynamic_tag_default = {
|
|
9643
9671
|
const isClassAPI = tagExtra.featureType === "class";
|
9644
9672
|
const referencedBindings = tagExtra.referencedBindings;
|
9645
9673
|
let tagExpression = node.name;
|
9646
|
-
if (
|
9674
|
+
if (import_compiler58.types.isStringLiteral(tagExpression)) {
|
9647
9675
|
tagExpression = (0, import_babel_utils42.importDefault)(
|
9648
9676
|
tag.hub.file,
|
9649
9677
|
getTagRelativePath(tag),
|
@@ -9652,15 +9680,15 @@ var dynamic_tag_default = {
|
|
9652
9680
|
}
|
9653
9681
|
if (isClassAPI) {
|
9654
9682
|
if (isOutputHTML()) {
|
9655
|
-
(0,
|
9656
|
-
|
9683
|
+
(0, import_compiler58.getProgram)().node.body.push(
|
9684
|
+
import_compiler58.types.markoScriptlet(
|
9657
9685
|
[
|
9658
|
-
|
9659
|
-
|
9686
|
+
import_compiler58.types.expressionStatement(
|
9687
|
+
import_compiler58.types.callExpression(
|
9660
9688
|
(0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
9661
9689
|
[
|
9662
|
-
|
9663
|
-
|
9690
|
+
import_compiler58.types.identifier(tagExpression.name),
|
9691
|
+
import_compiler58.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
|
9664
9692
|
]
|
9665
9693
|
)
|
9666
9694
|
)
|
@@ -9669,12 +9697,12 @@ var dynamic_tag_default = {
|
|
9669
9697
|
)
|
9670
9698
|
);
|
9671
9699
|
} else {
|
9672
|
-
(0,
|
9673
|
-
|
9700
|
+
(0, import_compiler58.getProgram)().node.body.push(
|
9701
|
+
import_compiler58.types.expressionStatement(
|
9674
9702
|
callRuntime(
|
9675
9703
|
"register",
|
9676
|
-
|
9677
|
-
|
9704
|
+
import_compiler58.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
|
9705
|
+
import_compiler58.types.identifier(tagExpression.name)
|
9678
9706
|
)
|
9679
9707
|
)
|
9680
9708
|
);
|
@@ -9694,7 +9722,7 @@ var dynamic_tag_default = {
|
|
9694
9722
|
hasMultipleArgs = true;
|
9695
9723
|
args.push(propsToExpression(properties));
|
9696
9724
|
} else {
|
9697
|
-
hasMultipleArgs = node.arguments.length > 1 ||
|
9725
|
+
hasMultipleArgs = node.arguments.length > 1 || import_compiler58.types.isSpreadElement(node.arguments[0]);
|
9698
9726
|
}
|
9699
9727
|
} else {
|
9700
9728
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
@@ -9714,35 +9742,35 @@ var dynamic_tag_default = {
|
|
9714
9742
|
getScopeIdIdentifier(section),
|
9715
9743
|
getScopeAccessorLiteral(nodeRef2),
|
9716
9744
|
tagExpression,
|
9717
|
-
|
9718
|
-
|
9719
|
-
|
9720
|
-
serializeReason ?
|
9745
|
+
import_compiler58.types.arrayExpression(args),
|
9746
|
+
import_compiler58.types.numericLiteral(0),
|
9747
|
+
import_compiler58.types.numericLiteral(1),
|
9748
|
+
serializeReason ? import_compiler58.types.numericLiteral(1) : void 0
|
9721
9749
|
) : callRuntime(
|
9722
9750
|
"dynamicTag",
|
9723
9751
|
getScopeIdIdentifier(section),
|
9724
9752
|
getScopeAccessorLiteral(nodeRef2),
|
9725
9753
|
tagExpression,
|
9726
9754
|
args[0],
|
9727
|
-
args[1] || (serializeReason ?
|
9728
|
-
serializeReason ?
|
9729
|
-
serializeReason ?
|
9755
|
+
args[1] || (serializeReason ? import_compiler58.types.numericLiteral(0) : void 0),
|
9756
|
+
serializeReason ? import_compiler58.types.numericLiteral(0) : void 0,
|
9757
|
+
serializeReason ? import_compiler58.types.numericLiteral(1) : void 0
|
9730
9758
|
);
|
9731
9759
|
if (node.var) {
|
9732
|
-
const dynamicScopeIdentifier = (0,
|
9760
|
+
const dynamicScopeIdentifier = (0, import_compiler58.getProgram)().scope.generateUidIdentifier("dynamicScope");
|
9733
9761
|
statements.push(
|
9734
|
-
|
9735
|
-
|
9762
|
+
import_compiler58.types.variableDeclaration("const", [
|
9763
|
+
import_compiler58.types.variableDeclarator(
|
9736
9764
|
dynamicScopeIdentifier,
|
9737
9765
|
callRuntime("peekNextScope")
|
9738
9766
|
)
|
9739
9767
|
])
|
9740
9768
|
);
|
9741
9769
|
statements.push(
|
9742
|
-
|
9743
|
-
|
9770
|
+
import_compiler58.types.variableDeclaration("const", [
|
9771
|
+
import_compiler58.types.variableDeclarator(node.var, dynamicTagExpr)
|
9744
9772
|
]),
|
9745
|
-
|
9773
|
+
import_compiler58.types.expressionStatement(
|
9746
9774
|
callRuntime(
|
9747
9775
|
"setTagVar",
|
9748
9776
|
getScopeIdIdentifier(section),
|
@@ -9750,7 +9778,7 @@ var dynamic_tag_default = {
|
|
9750
9778
|
tag.node.extra[kChildOffsetScopeBinding2]
|
9751
9779
|
),
|
9752
9780
|
dynamicScopeIdentifier,
|
9753
|
-
|
9781
|
+
import_compiler58.types.stringLiteral(
|
9754
9782
|
getResumeRegisterId(
|
9755
9783
|
section,
|
9756
9784
|
node.var.extra?.binding,
|
@@ -9762,7 +9790,7 @@ var dynamic_tag_default = {
|
|
9762
9790
|
)
|
9763
9791
|
);
|
9764
9792
|
} else {
|
9765
|
-
statements.push(
|
9793
|
+
statements.push(import_compiler58.types.expressionStatement(dynamicTagExpr));
|
9766
9794
|
}
|
9767
9795
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
9768
9796
|
replacement.skip();
|
@@ -9779,10 +9807,10 @@ var dynamic_tag_default = {
|
|
9779
9807
|
);
|
9780
9808
|
tagVarSignal.register = true;
|
9781
9809
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
9782
|
-
return
|
9783
|
-
|
9810
|
+
return import_compiler58.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9811
|
+
import_compiler58.types.memberExpression(
|
9784
9812
|
getScopeExpression(tagVarSignal.section, valueSection),
|
9785
|
-
|
9813
|
+
import_compiler58.types.stringLiteral(
|
9786
9814
|
getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
|
9787
9815
|
),
|
9788
9816
|
true
|
@@ -9795,19 +9823,19 @@ var dynamic_tag_default = {
|
|
9795
9823
|
return callRuntime(
|
9796
9824
|
"dynamicTag",
|
9797
9825
|
getScopeAccessorLiteral(nodeRef2),
|
9798
|
-
bodySection &&
|
9799
|
-
tagVarSignal ?
|
9800
|
-
hasMultipleArgs &&
|
9826
|
+
bodySection && import_compiler58.types.identifier(bodySection.name),
|
9827
|
+
tagVarSignal ? import_compiler58.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
9828
|
+
hasMultipleArgs && import_compiler58.types.numericLiteral(1)
|
9801
9829
|
);
|
9802
9830
|
};
|
9803
9831
|
if (args.length) {
|
9804
|
-
const argsOrInput = hasMultipleArgs ?
|
9805
|
-
if (!
|
9832
|
+
const argsOrInput = hasMultipleArgs ? import_compiler58.types.arrayExpression(args) : args[0];
|
9833
|
+
if (!import_compiler58.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
9806
9834
|
signal.extraArgs = [
|
9807
|
-
|
9835
|
+
import_compiler58.types.arrowFunctionExpression(
|
9808
9836
|
[],
|
9809
|
-
statements.length ?
|
9810
|
-
statements.concat(
|
9837
|
+
statements.length ? import_compiler58.types.blockStatement(
|
9838
|
+
statements.concat(import_compiler58.types.returnStatement(argsOrInput))
|
9811
9839
|
) : argsOrInput
|
9812
9840
|
)
|
9813
9841
|
];
|
@@ -9830,16 +9858,16 @@ var tag_default = {
|
|
9830
9858
|
const { node } = tag;
|
9831
9859
|
const { name: name2, attributes } = tag.node;
|
9832
9860
|
let crawl = false;
|
9833
|
-
if (
|
9861
|
+
if (import_compiler59.types.isStringLiteral(name2)) {
|
9834
9862
|
const tagName = name2.value;
|
9835
9863
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
9836
|
-
node.name = withPreviousLocation(
|
9864
|
+
node.name = withPreviousLocation(import_compiler59.types.identifier(tagName), name2);
|
9837
9865
|
crawl = true;
|
9838
9866
|
}
|
9839
9867
|
}
|
9840
9868
|
for (let i = 0; i < attributes.length; i++) {
|
9841
9869
|
const attr2 = attributes[i];
|
9842
|
-
if (
|
9870
|
+
if (import_compiler59.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9843
9871
|
attr2.bound = false;
|
9844
9872
|
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
9845
9873
|
crawl = true;
|
@@ -9915,8 +9943,8 @@ var tag_default = {
|
|
9915
9943
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
9916
9944
|
const tagNameId = tag.scope.generateUidIdentifier("tagName");
|
9917
9945
|
const [tagNameVarPath] = tag.insertBefore(
|
9918
|
-
|
9919
|
-
|
9946
|
+
import_compiler59.types.variableDeclaration("const", [
|
9947
|
+
import_compiler59.types.variableDeclarator(tagNameId, tag.node.name)
|
9920
9948
|
])
|
9921
9949
|
);
|
9922
9950
|
tagNameVarPath.skip();
|
@@ -9963,16 +9991,16 @@ var tag_default = {
|
|
9963
9991
|
function getChangeHandler(tag, attr2) {
|
9964
9992
|
const attrName = attr2.name;
|
9965
9993
|
const changeAttrName = attrName + "Change";
|
9966
|
-
if (
|
9994
|
+
if (import_compiler59.types.isIdentifier(attr2.value)) {
|
9967
9995
|
const binding = tag.scope.getBinding(attr2.value.name);
|
9968
9996
|
if (!binding)
|
9969
|
-
return
|
9997
|
+
return import_compiler59.types.markoAttribute(
|
9970
9998
|
changeAttrName,
|
9971
9999
|
buildChangeHandlerFunction(attr2.value)
|
9972
10000
|
);
|
9973
10001
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
9974
10002
|
if (!existingChangedAttr) {
|
9975
|
-
const changeHandlerAttr =
|
10003
|
+
const changeHandlerAttr = import_compiler59.types.markoAttribute(
|
9976
10004
|
changeAttrName,
|
9977
10005
|
buildChangeHandlerFunction(attr2.value)
|
9978
10006
|
);
|
@@ -9980,10 +10008,10 @@ function getChangeHandler(tag, attr2) {
|
|
9980
10008
|
return changeHandlerAttr;
|
9981
10009
|
}
|
9982
10010
|
if (existingChangedAttr.type === "Identifier") {
|
9983
|
-
return
|
10011
|
+
return import_compiler59.types.markoAttribute(
|
9984
10012
|
changeAttrName,
|
9985
10013
|
withPreviousLocation(
|
9986
|
-
|
10014
|
+
import_compiler59.types.identifier(existingChangedAttr.name),
|
9987
10015
|
attr2.value
|
9988
10016
|
)
|
9989
10017
|
);
|
@@ -9993,37 +10021,37 @@ function getChangeHandler(tag, attr2) {
|
|
9993
10021
|
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
9994
10022
|
}
|
9995
10023
|
const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
|
9996
|
-
const changeHandlerConst =
|
9997
|
-
|
9998
|
-
[
|
9999
|
-
|
10024
|
+
const changeHandlerConst = import_compiler59.types.markoTag(
|
10025
|
+
import_compiler59.types.stringLiteral("const"),
|
10026
|
+
[import_compiler59.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
10027
|
+
import_compiler59.types.markoTagBody([]),
|
10000
10028
|
null,
|
10001
|
-
|
10029
|
+
import_compiler59.types.identifier(changeHandlerId)
|
10002
10030
|
);
|
10003
10031
|
BINDING_CHANGE_HANDLER.set(
|
10004
10032
|
binding.identifier,
|
10005
|
-
existingChangedAttr.value =
|
10033
|
+
existingChangedAttr.value = import_compiler59.types.identifier(changeHandlerId)
|
10006
10034
|
);
|
10007
10035
|
if (markoRoot.isMarkoTag()) {
|
10008
10036
|
markoRoot.insertAfter(changeHandlerConst);
|
10009
10037
|
} else {
|
10010
10038
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
10011
10039
|
}
|
10012
|
-
return
|
10040
|
+
return import_compiler59.types.markoAttribute(
|
10013
10041
|
changeAttrName,
|
10014
|
-
withPreviousLocation(
|
10042
|
+
withPreviousLocation(import_compiler59.types.identifier(changeHandlerId), attr2.value)
|
10015
10043
|
);
|
10016
|
-
} else if (
|
10044
|
+
} else if (import_compiler59.types.isMemberExpression(attr2.value)) {
|
10017
10045
|
const prop = attr2.value.property;
|
10018
|
-
if (!
|
10019
|
-
return
|
10046
|
+
if (!import_compiler59.types.isPrivateName(attr2.value.property)) {
|
10047
|
+
return import_compiler59.types.markoAttribute(
|
10020
10048
|
changeAttrName,
|
10021
|
-
|
10022
|
-
|
10023
|
-
prop.type === "Identifier" ? withPreviousLocation(
|
10049
|
+
import_compiler59.types.memberExpression(
|
10050
|
+
import_compiler59.types.cloneNode(attr2.value.object),
|
10051
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler59.types.identifier(prop.name + "Change"), prop) : import_compiler59.types.binaryExpression(
|
10024
10052
|
"+",
|
10025
|
-
|
10026
|
-
|
10053
|
+
import_compiler59.types.cloneNode(prop),
|
10054
|
+
import_compiler59.types.stringLiteral("Change")
|
10027
10055
|
),
|
10028
10056
|
prop.type !== "Identifier"
|
10029
10057
|
)
|
@@ -10037,14 +10065,14 @@ function getChangeHandler(tag, attr2) {
|
|
10037
10065
|
}
|
10038
10066
|
function buildChangeHandlerFunction(id) {
|
10039
10067
|
const newId = "_new_" + id.name;
|
10040
|
-
return
|
10041
|
-
[withPreviousLocation(
|
10042
|
-
|
10043
|
-
|
10044
|
-
|
10068
|
+
return import_compiler59.types.arrowFunctionExpression(
|
10069
|
+
[withPreviousLocation(import_compiler59.types.identifier(newId), id)],
|
10070
|
+
import_compiler59.types.blockStatement([
|
10071
|
+
import_compiler59.types.expressionStatement(
|
10072
|
+
import_compiler59.types.assignmentExpression(
|
10045
10073
|
"=",
|
10046
|
-
withPreviousLocation(
|
10047
|
-
withPreviousLocation(
|
10074
|
+
withPreviousLocation(import_compiler59.types.identifier(id.name), id),
|
10075
|
+
withPreviousLocation(import_compiler59.types.identifier(newId), id)
|
10048
10076
|
)
|
10049
10077
|
)
|
10050
10078
|
])
|
@@ -10052,10 +10080,11 @@ function buildChangeHandlerFunction(id) {
|
|
10052
10080
|
}
|
10053
10081
|
|
10054
10082
|
// src/translator/visitors/text.ts
|
10055
|
-
var
|
10083
|
+
var import_compiler60 = require("@marko/compiler");
|
10056
10084
|
var text_default = {
|
10057
10085
|
translate: {
|
10058
10086
|
exit(text) {
|
10087
|
+
if (isNonHTMLText(text)) return;
|
10059
10088
|
writeTo(text)`${text.node.value}`;
|
10060
10089
|
enterShallow(text);
|
10061
10090
|
text.remove();
|