marko 6.0.0-next.3.73 → 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/debug/html.js +30 -7
- package/dist/debug/html.mjs +30 -7
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.js +22 -9
- package/dist/html.mjs +22 -9
- package/dist/translator/index.js +670 -629
- package/dist/translator/util/is-non-html-text.d.ts +2 -0
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -1251,11 +1251,14 @@ function escapeStyle(val) {
|
|
1251
1251
|
}
|
1252
1252
|
|
1253
1253
|
// src/html/serializer.ts
|
1254
|
+
var kTouchedIterator = Symbol();
|
1254
1255
|
var { hasOwnProperty } = {};
|
1255
1256
|
var Generator = function* () {
|
1256
1257
|
}().constructor;
|
1257
1258
|
var AsyncGenerator = async function* () {
|
1258
1259
|
}().constructor;
|
1260
|
+
patchIteratorNext(Generator.prototype);
|
1261
|
+
patchIteratorNext(AsyncGenerator.prototype);
|
1259
1262
|
var KNOWN_SYMBOLS = (() => {
|
1260
1263
|
const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
|
1261
1264
|
for (const name2 of Object.getOwnPropertyNames(Symbol)) {
|
@@ -1501,6 +1504,13 @@ function toAccess(accessor) {
|
|
1501
1504
|
const start = accessor[0];
|
1502
1505
|
return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
1503
1506
|
}
|
1507
|
+
function patchIteratorNext(proto) {
|
1508
|
+
const { next } = proto;
|
1509
|
+
proto.next = function(value) {
|
1510
|
+
this[kTouchedIterator] = 1;
|
1511
|
+
return next.call(this, value);
|
1512
|
+
};
|
1513
|
+
}
|
1504
1514
|
|
1505
1515
|
// src/html/writer.ts
|
1506
1516
|
var K_SCOPE_ID = Symbol("Scope ID");
|
@@ -1604,7 +1614,7 @@ function toMemberExpression(object, key, optional) {
|
|
1604
1614
|
}
|
1605
1615
|
|
1606
1616
|
// src/translator/util/runtime.ts
|
1607
|
-
var
|
1617
|
+
var pureDOMFunctions = /* @__PURE__ */ new Set([
|
1608
1618
|
"awaitTag",
|
1609
1619
|
"conditional",
|
1610
1620
|
"conditionalClosure",
|
@@ -1622,7 +1632,7 @@ var pureFunctions = [
|
|
1622
1632
|
"loopTo",
|
1623
1633
|
"state",
|
1624
1634
|
"value"
|
1625
|
-
];
|
1635
|
+
]);
|
1626
1636
|
function importRuntime(name2) {
|
1627
1637
|
const { output } = getMarkoOpts();
|
1628
1638
|
return toMemberExpression(
|
@@ -1635,7 +1645,7 @@ function callRuntime(name2, ...args) {
|
|
1635
1645
|
importRuntime(name2),
|
1636
1646
|
filterArguments(args)
|
1637
1647
|
);
|
1638
|
-
if (
|
1648
|
+
if (isOutputDOM() && pureDOMFunctions.has(name2)) {
|
1639
1649
|
callExpression2.leadingComments = [
|
1640
1650
|
{
|
1641
1651
|
type: "CommentBlock",
|
@@ -6493,115 +6503,121 @@ var html_comment_default = {
|
|
6493
6503
|
}
|
6494
6504
|
tag.skip();
|
6495
6505
|
},
|
6496
|
-
translate
|
6497
|
-
|
6498
|
-
|
6499
|
-
|
6500
|
-
|
6501
|
-
|
6502
|
-
|
6503
|
-
|
6504
|
-
|
6505
|
-
|
6506
|
-
|
6507
|
-
|
6508
|
-
|
6509
|
-
|
6510
|
-
|
6511
|
-
} else {
|
6512
|
-
const varName = tag.node.var.name;
|
6513
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
6514
|
-
let getterFnIdentifier;
|
6515
|
-
if (getterId) {
|
6516
|
-
getterFnIdentifier = (0, import_compiler38.getProgram)().scope.generateUidIdentifier(
|
6517
|
-
`get_${varName}`
|
6518
|
-
);
|
6519
|
-
(0, import_compiler38.getProgram)().node.body.push(
|
6520
|
-
import_compiler38.types.variableDeclaration("const", [
|
6521
|
-
import_compiler38.types.variableDeclarator(
|
6522
|
-
getterFnIdentifier,
|
6523
|
-
callRuntime(
|
6524
|
-
"nodeRef",
|
6525
|
-
import_compiler38.types.stringLiteral(getterId),
|
6526
|
-
getScopeAccessorLiteral(commentBinding)
|
6527
|
-
)
|
6528
|
-
)
|
6529
|
-
])
|
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
|
+
)
|
6530
6521
|
);
|
6531
|
-
}
|
6532
|
-
|
6533
|
-
const
|
6534
|
-
|
6535
|
-
|
6536
|
-
|
6537
|
-
|
6538
|
-
)
|
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}`
|
6539
6529
|
);
|
6540
|
-
|
6541
|
-
|
6542
|
-
|
6543
|
-
|
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
|
+
)
|
6544
6540
|
])
|
6545
6541
|
);
|
6546
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
|
+
}
|
6547
6559
|
}
|
6548
6560
|
}
|
6549
|
-
|
6550
|
-
|
6551
|
-
visit(tag, 32 /* Get */);
|
6552
|
-
}
|
6553
|
-
const write2 = writeTo(tag);
|
6554
|
-
enter2(tag);
|
6555
|
-
write2`<!--`;
|
6556
|
-
if (isOutputHTML()) {
|
6557
|
-
for (const child of tag.node.body.body) {
|
6558
|
-
if (import_compiler38.types.isMarkoText(child)) {
|
6559
|
-
write2`${child.value}`;
|
6560
|
-
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
6561
|
-
write2`${callRuntime("escapeXML", child.value)}`;
|
6562
|
-
}
|
6561
|
+
if (tagExtra[kCommentTagBinding]) {
|
6562
|
+
visit(tag, 32 /* Get */);
|
6563
6563
|
}
|
6564
|
-
|
6565
|
-
|
6566
|
-
|
6567
|
-
|
6568
|
-
|
6569
|
-
|
6570
|
-
|
6571
|
-
|
6572
|
-
|
6573
|
-
|
6574
|
-
|
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
|
+
}
|
6575
6578
|
}
|
6576
|
-
}
|
6577
|
-
if (templateExpressions.length === 0) {
|
6578
|
-
write2`${currentQuasi}`;
|
6579
6579
|
} else {
|
6580
|
-
templateQuasis
|
6581
|
-
|
6582
|
-
|
6583
|
-
|
6584
|
-
|
6585
|
-
|
6586
|
-
|
6587
|
-
|
6588
|
-
|
6589
|
-
|
6590
|
-
|
6591
|
-
|
6592
|
-
|
6593
|
-
|
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
|
+
)
|
6594
6610
|
)
|
6595
|
-
)
|
6596
|
-
|
6611
|
+
);
|
6612
|
+
}
|
6597
6613
|
}
|
6614
|
+
exit2(tag);
|
6615
|
+
write2`-->`;
|
6616
|
+
if (commentBinding) {
|
6617
|
+
markNode(tag, commentBinding);
|
6618
|
+
}
|
6619
|
+
tag.remove();
|
6598
6620
|
}
|
6599
|
-
exit2(tag);
|
6600
|
-
write2`-->`;
|
6601
|
-
if (commentBinding) {
|
6602
|
-
markNode(tag, commentBinding);
|
6603
|
-
}
|
6604
|
-
tag.remove();
|
6605
6621
|
},
|
6606
6622
|
parseOptions: {
|
6607
6623
|
text: true
|
@@ -6703,124 +6719,167 @@ var html_script_default = {
|
|
6703
6719
|
}
|
6704
6720
|
}
|
6705
6721
|
},
|
6706
|
-
translate
|
6707
|
-
|
6708
|
-
|
6709
|
-
|
6710
|
-
|
6711
|
-
|
6712
|
-
|
6713
|
-
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
|
6718
|
-
|
6719
|
-
|
6720
|
-
|
6721
|
-
|
6722
|
-
|
6723
|
-
|
6724
|
-
|
6725
|
-
|
6726
|
-
|
6727
|
-
|
6728
|
-
|
6729
|
-
} else {
|
6730
|
-
const varName = tag.node.var.name;
|
6731
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
6732
|
-
let getterFnIdentifier;
|
6733
|
-
if (getterId) {
|
6734
|
-
getterFnIdentifier = (0, import_compiler39.getProgram)().scope.generateUidIdentifier(
|
6735
|
-
`get_${varName}`
|
6736
|
-
);
|
6737
|
-
(0, import_compiler39.getProgram)().node.body.push(
|
6738
|
-
import_compiler39.types.variableDeclaration("const", [
|
6739
|
-
import_compiler39.types.variableDeclarator(
|
6740
|
-
getterFnIdentifier,
|
6741
|
-
callRuntime(
|
6742
|
-
"nodeRef",
|
6743
|
-
import_compiler39.types.stringLiteral(getterId),
|
6744
|
-
getScopeAccessorLiteral(nodeRef2)
|
6745
|
-
)
|
6746
|
-
)
|
6747
|
-
])
|
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
|
+
)
|
6748
6745
|
);
|
6749
|
-
}
|
6750
|
-
|
6751
|
-
const
|
6752
|
-
|
6753
|
-
|
6754
|
-
|
6755
|
-
|
6756
|
-
)
|
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}`
|
6757
6753
|
);
|
6758
|
-
|
6759
|
-
|
6760
|
-
|
6761
|
-
|
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
|
+
)
|
6762
6764
|
])
|
6763
6765
|
);
|
6764
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
|
+
}
|
6765
6783
|
}
|
6766
6784
|
}
|
6767
|
-
|
6768
|
-
|
6769
|
-
|
6770
|
-
|
6771
|
-
|
6772
|
-
|
6773
|
-
|
6774
|
-
|
6775
|
-
|
6776
|
-
|
6777
|
-
|
6778
|
-
|
6779
|
-
|
6780
|
-
|
6781
|
-
|
6782
|
-
|
6783
|
-
|
6784
|
-
|
6785
|
-
|
6786
|
-
|
6787
|
-
|
6788
|
-
|
6789
|
-
|
6790
|
-
|
6791
|
-
|
6792
|
-
|
6793
|
-
|
6794
|
-
|
6795
|
-
|
6796
|
-
|
6797
|
-
|
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
|
+
)
|
6798
6816
|
)
|
6799
|
-
)
|
6800
|
-
|
6817
|
+
);
|
6818
|
+
}
|
6819
|
+
break;
|
6801
6820
|
}
|
6802
|
-
|
6803
|
-
|
6804
|
-
|
6805
|
-
|
6806
|
-
|
6807
|
-
|
6808
|
-
|
6809
|
-
|
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
|
+
);
|
6810
6844
|
} else {
|
6811
|
-
|
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
|
+
);
|
6812
6858
|
}
|
6813
|
-
|
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) {
|
6814
6872
|
addStatement(
|
6815
|
-
"
|
6873
|
+
"render",
|
6816
6874
|
section,
|
6817
|
-
|
6875
|
+
tagExtra.referencedBindings,
|
6818
6876
|
import_compiler39.types.expressionStatement(
|
6819
6877
|
callRuntime(
|
6820
|
-
"
|
6821
|
-
|
6822
|
-
|
6823
|
-
|
6878
|
+
"partialAttrs",
|
6879
|
+
scopeIdentifier,
|
6880
|
+
visitAccessor,
|
6881
|
+
spreadExpression,
|
6882
|
+
skipExpression
|
6824
6883
|
)
|
6825
6884
|
)
|
6826
6885
|
);
|
@@ -6828,119 +6887,84 @@ var html_script_default = {
|
|
6828
6887
|
addStatement(
|
6829
6888
|
"render",
|
6830
6889
|
section,
|
6831
|
-
|
6890
|
+
tagExtra.referencedBindings,
|
6832
6891
|
import_compiler39.types.expressionStatement(
|
6833
6892
|
callRuntime(
|
6834
|
-
"
|
6835
|
-
|
6836
|
-
|
6837
|
-
|
6893
|
+
"attrs",
|
6894
|
+
scopeIdentifier,
|
6895
|
+
visitAccessor,
|
6896
|
+
spreadExpression
|
6838
6897
|
)
|
6839
6898
|
)
|
6840
6899
|
);
|
6841
6900
|
}
|
6842
|
-
break;
|
6843
|
-
}
|
6844
|
-
}
|
6845
|
-
if (spreadExpression) {
|
6846
|
-
if (isHTML) {
|
6847
|
-
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6848
|
-
if (skipExpression) {
|
6849
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6850
|
-
} else {
|
6851
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler39.types.stringLiteral("script"))}`;
|
6852
|
-
}
|
6853
|
-
} else {
|
6854
|
-
if (skipExpression) {
|
6855
6901
|
addStatement(
|
6856
|
-
"
|
6902
|
+
"effect",
|
6857
6903
|
section,
|
6858
6904
|
tagExtra.referencedBindings,
|
6859
6905
|
import_compiler39.types.expressionStatement(
|
6860
|
-
callRuntime(
|
6861
|
-
|
6862
|
-
|
6863
|
-
visitAccessor,
|
6864
|
-
spreadExpression,
|
6865
|
-
skipExpression
|
6866
|
-
)
|
6867
|
-
)
|
6906
|
+
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6907
|
+
),
|
6908
|
+
false
|
6868
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}`;
|
6869
6945
|
} else {
|
6946
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6870
6947
|
addStatement(
|
6871
6948
|
"render",
|
6872
|
-
|
6873
|
-
|
6949
|
+
getSection(tag),
|
6950
|
+
referencePlaceholder.value.extra?.referencedBindings,
|
6874
6951
|
import_compiler39.types.expressionStatement(
|
6875
6952
|
callRuntime(
|
6876
|
-
"
|
6877
|
-
scopeIdentifier,
|
6878
|
-
|
6879
|
-
spreadExpression
|
6953
|
+
"textContent",
|
6954
|
+
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6955
|
+
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
6880
6956
|
)
|
6881
6957
|
)
|
6882
6958
|
);
|
6883
6959
|
}
|
6884
|
-
addStatement(
|
6885
|
-
"effect",
|
6886
|
-
section,
|
6887
|
-
tagExtra.referencedBindings,
|
6888
|
-
import_compiler39.types.expressionStatement(
|
6889
|
-
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6890
|
-
),
|
6891
|
-
false
|
6892
|
-
);
|
6893
|
-
}
|
6894
|
-
}
|
6895
|
-
write2`>`;
|
6896
|
-
enter2(tag);
|
6897
|
-
if (isOutputHTML()) {
|
6898
|
-
for (const child of tag.node.body.body) {
|
6899
|
-
if (import_compiler39.types.isMarkoText(child)) {
|
6900
|
-
write2`${child.value}`;
|
6901
|
-
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6902
|
-
write2`${callRuntime("escapeScript", child.value)}`;
|
6903
|
-
}
|
6904
6960
|
}
|
6905
|
-
|
6906
|
-
|
6907
|
-
|
6908
|
-
let currentQuasi = "";
|
6909
|
-
let referencePlaceholder;
|
6910
|
-
for (const child of tag.node.body.body) {
|
6911
|
-
if (import_compiler39.types.isMarkoText(child)) {
|
6912
|
-
currentQuasi += child.value;
|
6913
|
-
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6914
|
-
referencePlaceholder ||= child;
|
6915
|
-
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6916
|
-
templateExpressions.push(child.value);
|
6917
|
-
currentQuasi = "";
|
6918
|
-
}
|
6919
|
-
}
|
6920
|
-
if (!referencePlaceholder) {
|
6921
|
-
write2`${currentQuasi}`;
|
6922
|
-
} else {
|
6923
|
-
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6924
|
-
addStatement(
|
6925
|
-
"render",
|
6926
|
-
getSection(tag),
|
6927
|
-
referencePlaceholder.value.extra?.referencedBindings,
|
6928
|
-
import_compiler39.types.expressionStatement(
|
6929
|
-
callRuntime(
|
6930
|
-
"textContent",
|
6931
|
-
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6932
|
-
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
6933
|
-
)
|
6934
|
-
)
|
6935
|
-
);
|
6961
|
+
write2`</script>`;
|
6962
|
+
if (nodeRef2) {
|
6963
|
+
markNode(tag, nodeRef2);
|
6936
6964
|
}
|
6965
|
+
exit2(tag);
|
6966
|
+
tag.remove();
|
6937
6967
|
}
|
6938
|
-
write2`</script>`;
|
6939
|
-
if (nodeRef2) {
|
6940
|
-
markNode(tag, nodeRef2);
|
6941
|
-
}
|
6942
|
-
exit2(tag);
|
6943
|
-
tag.remove();
|
6944
6968
|
},
|
6945
6969
|
"@async": "#html-async",
|
6946
6970
|
"@crossorigin": "#html-crossorigin",
|
@@ -7088,124 +7112,167 @@ var html_style_default = {
|
|
7088
7112
|
}
|
7089
7113
|
}
|
7090
7114
|
},
|
7091
|
-
translate
|
7092
|
-
|
7093
|
-
|
7094
|
-
|
7095
|
-
|
7096
|
-
|
7097
|
-
|
7098
|
-
|
7099
|
-
|
7100
|
-
|
7101
|
-
|
7102
|
-
|
7103
|
-
|
7104
|
-
|
7105
|
-
|
7106
|
-
|
7107
|
-
|
7108
|
-
|
7109
|
-
|
7110
|
-
|
7111
|
-
|
7112
|
-
|
7113
|
-
|
7114
|
-
} else {
|
7115
|
-
const varName = tag.node.var.name;
|
7116
|
-
const references = tag.scope.getBinding(varName).referencePaths;
|
7117
|
-
let getterFnIdentifier;
|
7118
|
-
if (getterId) {
|
7119
|
-
getterFnIdentifier = (0, import_compiler40.getProgram)().scope.generateUidIdentifier(
|
7120
|
-
`get_${varName}`
|
7121
|
-
);
|
7122
|
-
(0, import_compiler40.getProgram)().node.body.push(
|
7123
|
-
import_compiler40.types.variableDeclaration("const", [
|
7124
|
-
import_compiler40.types.variableDeclarator(
|
7125
|
-
getterFnIdentifier,
|
7126
|
-
callRuntime(
|
7127
|
-
"nodeRef",
|
7128
|
-
import_compiler40.types.stringLiteral(getterId),
|
7129
|
-
getScopeAccessorLiteral(nodeRef2)
|
7130
|
-
)
|
7131
|
-
)
|
7132
|
-
])
|
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
|
+
)
|
7133
7138
|
);
|
7134
|
-
}
|
7135
|
-
|
7136
|
-
const
|
7137
|
-
|
7138
|
-
|
7139
|
-
|
7140
|
-
|
7141
|
-
)
|
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}`
|
7142
7146
|
);
|
7143
|
-
|
7144
|
-
|
7145
|
-
|
7146
|
-
|
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
|
+
)
|
7147
7157
|
])
|
7148
7158
|
);
|
7149
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
|
+
}
|
7150
7176
|
}
|
7151
7177
|
}
|
7152
|
-
|
7153
|
-
|
7154
|
-
|
7155
|
-
|
7156
|
-
|
7157
|
-
|
7158
|
-
|
7159
|
-
|
7160
|
-
|
7161
|
-
|
7162
|
-
|
7163
|
-
|
7164
|
-
|
7165
|
-
|
7166
|
-
|
7167
|
-
|
7168
|
-
|
7169
|
-
|
7170
|
-
|
7171
|
-
|
7172
|
-
|
7173
|
-
|
7174
|
-
|
7175
|
-
|
7176
|
-
|
7177
|
-
|
7178
|
-
|
7179
|
-
|
7180
|
-
|
7181
|
-
|
7182
|
-
|
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
|
+
)
|
7183
7209
|
)
|
7184
|
-
)
|
7185
|
-
|
7210
|
+
);
|
7211
|
+
}
|
7212
|
+
break;
|
7186
7213
|
}
|
7187
|
-
|
7188
|
-
|
7189
|
-
|
7190
|
-
|
7191
|
-
|
7192
|
-
|
7193
|
-
|
7194
|
-
|
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
|
+
);
|
7195
7237
|
} else {
|
7196
|
-
|
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
|
+
);
|
7197
7251
|
}
|
7198
|
-
|
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) {
|
7199
7265
|
addStatement(
|
7200
|
-
"
|
7266
|
+
"render",
|
7201
7267
|
section,
|
7202
|
-
|
7268
|
+
tagExtra.referencedBindings,
|
7203
7269
|
import_compiler40.types.expressionStatement(
|
7204
7270
|
callRuntime(
|
7205
|
-
"
|
7206
|
-
|
7207
|
-
|
7208
|
-
|
7271
|
+
"partialAttrs",
|
7272
|
+
scopeIdentifier,
|
7273
|
+
visitAccessor,
|
7274
|
+
spreadExpression,
|
7275
|
+
skipExpression
|
7209
7276
|
)
|
7210
7277
|
)
|
7211
7278
|
);
|
@@ -7213,119 +7280,84 @@ var html_style_default = {
|
|
7213
7280
|
addStatement(
|
7214
7281
|
"render",
|
7215
7282
|
section,
|
7216
|
-
|
7283
|
+
tagExtra.referencedBindings,
|
7217
7284
|
import_compiler40.types.expressionStatement(
|
7218
7285
|
callRuntime(
|
7219
|
-
"
|
7220
|
-
|
7221
|
-
|
7222
|
-
|
7286
|
+
"attrs",
|
7287
|
+
scopeIdentifier,
|
7288
|
+
visitAccessor,
|
7289
|
+
spreadExpression
|
7223
7290
|
)
|
7224
7291
|
)
|
7225
7292
|
);
|
7226
7293
|
}
|
7227
|
-
break;
|
7228
|
-
}
|
7229
|
-
}
|
7230
|
-
if (spreadExpression) {
|
7231
|
-
if (isHTML) {
|
7232
|
-
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
7233
|
-
if (skipExpression) {
|
7234
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7235
|
-
} else {
|
7236
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("style"))}`;
|
7237
|
-
}
|
7238
|
-
} else {
|
7239
|
-
if (skipExpression) {
|
7240
7294
|
addStatement(
|
7241
|
-
"
|
7295
|
+
"effect",
|
7242
7296
|
section,
|
7243
7297
|
tagExtra.referencedBindings,
|
7244
7298
|
import_compiler40.types.expressionStatement(
|
7245
|
-
callRuntime(
|
7246
|
-
|
7247
|
-
|
7248
|
-
visitAccessor,
|
7249
|
-
spreadExpression,
|
7250
|
-
skipExpression
|
7251
|
-
)
|
7252
|
-
)
|
7299
|
+
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
7300
|
+
),
|
7301
|
+
false
|
7253
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}`;
|
7254
7338
|
} else {
|
7339
|
+
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7255
7340
|
addStatement(
|
7256
7341
|
"render",
|
7257
|
-
|
7258
|
-
|
7342
|
+
getSection(tag),
|
7343
|
+
referencePlaceholder.value.extra?.referencedBindings,
|
7259
7344
|
import_compiler40.types.expressionStatement(
|
7260
7345
|
callRuntime(
|
7261
|
-
"
|
7262
|
-
scopeIdentifier,
|
7263
|
-
|
7264
|
-
spreadExpression
|
7346
|
+
"textContent",
|
7347
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7348
|
+
import_compiler40.types.templateLiteral(templateQuasis, templateExpressions)
|
7265
7349
|
)
|
7266
7350
|
)
|
7267
7351
|
);
|
7268
7352
|
}
|
7269
|
-
addStatement(
|
7270
|
-
"effect",
|
7271
|
-
section,
|
7272
|
-
tagExtra.referencedBindings,
|
7273
|
-
import_compiler40.types.expressionStatement(
|
7274
|
-
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
7275
|
-
),
|
7276
|
-
false
|
7277
|
-
);
|
7278
|
-
}
|
7279
|
-
}
|
7280
|
-
write2`>`;
|
7281
|
-
enter2(tag);
|
7282
|
-
if (isOutputHTML()) {
|
7283
|
-
for (const child of tag.node.body.body) {
|
7284
|
-
if (import_compiler40.types.isMarkoText(child)) {
|
7285
|
-
write2`${child.value}`;
|
7286
|
-
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7287
|
-
write2`${callRuntime("escapeStyle", child.value)}`;
|
7288
|
-
}
|
7289
|
-
}
|
7290
|
-
} else {
|
7291
|
-
const templateQuasis = [];
|
7292
|
-
const templateExpressions = [];
|
7293
|
-
let currentQuasi = "";
|
7294
|
-
let referencePlaceholder;
|
7295
|
-
for (const child of tag.node.body.body) {
|
7296
|
-
if (import_compiler40.types.isMarkoText(child)) {
|
7297
|
-
currentQuasi += child.value;
|
7298
|
-
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
7299
|
-
referencePlaceholder ||= child;
|
7300
|
-
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7301
|
-
templateExpressions.push(child.value);
|
7302
|
-
currentQuasi = "";
|
7303
|
-
}
|
7304
7353
|
}
|
7305
|
-
|
7306
|
-
|
7307
|
-
|
7308
|
-
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
7309
|
-
addStatement(
|
7310
|
-
"render",
|
7311
|
-
getSection(tag),
|
7312
|
-
referencePlaceholder.value.extra?.referencedBindings,
|
7313
|
-
import_compiler40.types.expressionStatement(
|
7314
|
-
callRuntime(
|
7315
|
-
"textContent",
|
7316
|
-
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7317
|
-
import_compiler40.types.templateLiteral(templateQuasis, templateExpressions)
|
7318
|
-
)
|
7319
|
-
)
|
7320
|
-
);
|
7354
|
+
write2`</style>`;
|
7355
|
+
if (nodeRef2) {
|
7356
|
+
markNode(tag, nodeRef2);
|
7321
7357
|
}
|
7358
|
+
exit2(tag);
|
7359
|
+
tag.remove();
|
7322
7360
|
}
|
7323
|
-
write2`</style>`;
|
7324
|
-
if (nodeRef2) {
|
7325
|
-
markNode(tag, nodeRef2);
|
7326
|
-
}
|
7327
|
-
exit2(tag);
|
7328
|
-
tag.remove();
|
7329
7361
|
},
|
7330
7362
|
"@disabled": "#html-disabled",
|
7331
7363
|
"@media": "#html-media",
|
@@ -8142,6 +8174,8 @@ var script_default = {
|
|
8142
8174
|
};
|
8143
8175
|
function isAwaitExpression(node) {
|
8144
8176
|
switch (node.type) {
|
8177
|
+
case "ForOfStatement":
|
8178
|
+
return node.await;
|
8145
8179
|
case "FunctionDeclaration":
|
8146
8180
|
case "FunctionExpression":
|
8147
8181
|
case "ArrowFunctionExpression":
|
@@ -8620,12 +8654,29 @@ var import_declaration_default = {
|
|
8620
8654
|
};
|
8621
8655
|
|
8622
8656
|
// src/translator/visitors/placeholder.ts
|
8657
|
+
var import_compiler54 = require("@marko/compiler");
|
8658
|
+
|
8659
|
+
// src/translator/util/is-non-html-text.ts
|
8623
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
|
8624
8675
|
var kBinding = Symbol("placeholder node binding");
|
8625
8676
|
var kSiblingText = Symbol("placeholder has sibling text");
|
8626
8677
|
var placeholder_default = {
|
8627
8678
|
analyze(placeholder) {
|
8628
|
-
if (
|
8679
|
+
if (isNonHTMLText(placeholder)) return;
|
8629
8680
|
const { node } = placeholder;
|
8630
8681
|
const { confident, computed } = evaluate(node.value);
|
8631
8682
|
if (!(confident && (node.escape || isVoid2(computed)))) {
|
@@ -8641,6 +8692,7 @@ var placeholder_default = {
|
|
8641
8692
|
},
|
8642
8693
|
translate: {
|
8643
8694
|
exit(placeholder) {
|
8695
|
+
if (isNonHTMLText(placeholder)) return;
|
8644
8696
|
const { node } = placeholder;
|
8645
8697
|
const { value } = node;
|
8646
8698
|
const { confident, computed, referencedBindings } = evaluate(value);
|
@@ -8680,10 +8732,10 @@ var placeholder_default = {
|
|
8680
8732
|
"render",
|
8681
8733
|
getSection(placeholder),
|
8682
8734
|
value.extra?.referencedBindings,
|
8683
|
-
|
8735
|
+
import_compiler54.types.expressionStatement(
|
8684
8736
|
method === "data" ? callRuntime(
|
8685
8737
|
"data",
|
8686
|
-
|
8738
|
+
import_compiler54.types.memberExpression(
|
8687
8739
|
scopeIdentifier,
|
8688
8740
|
getScopeAccessorLiteral(nodeBinding),
|
8689
8741
|
true
|
@@ -8720,7 +8772,7 @@ function analyzeSiblingText(placeholder) {
|
|
8720
8772
|
break;
|
8721
8773
|
}
|
8722
8774
|
}
|
8723
|
-
if (!prev.node &&
|
8775
|
+
if (!prev.node && import_compiler54.types.isProgram(placeholder.parentPath)) {
|
8724
8776
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
8725
8777
|
}
|
8726
8778
|
let next = placeholder.getNextSibling();
|
@@ -8737,29 +8789,17 @@ function analyzeSiblingText(placeholder) {
|
|
8737
8789
|
break;
|
8738
8790
|
}
|
8739
8791
|
}
|
8740
|
-
if (!next.node &&
|
8792
|
+
if (!next.node && import_compiler54.types.isProgram(placeholder.parentPath)) {
|
8741
8793
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
8742
8794
|
}
|
8743
8795
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
8744
8796
|
}
|
8745
|
-
function isNonHTMLPlaceholder(placeholder) {
|
8746
|
-
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
8747
|
-
if (parentTag && isCoreTag(parentTag)) {
|
8748
|
-
switch (parentTag.node.name.value) {
|
8749
|
-
case "html-comment":
|
8750
|
-
case "html-script":
|
8751
|
-
case "html-style":
|
8752
|
-
return true;
|
8753
|
-
}
|
8754
|
-
}
|
8755
|
-
return false;
|
8756
|
-
}
|
8757
8797
|
function isVoid2(value) {
|
8758
8798
|
return value == null || value === false;
|
8759
8799
|
}
|
8760
8800
|
|
8761
8801
|
// src/translator/visitors/referenced-identifier.ts
|
8762
|
-
var
|
8802
|
+
var import_compiler55 = require("@marko/compiler");
|
8763
8803
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
8764
8804
|
var referenced_identifier_default = {
|
8765
8805
|
migrate(identifier) {
|
@@ -8767,8 +8807,8 @@ var referenced_identifier_default = {
|
|
8767
8807
|
if (identifier.scope.hasBinding(name2)) return;
|
8768
8808
|
switch (name2) {
|
8769
8809
|
case "out":
|
8770
|
-
if (
|
8771
|
-
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"));
|
8772
8812
|
} else {
|
8773
8813
|
throw identifier.buildCodeFrameError(
|
8774
8814
|
"Only `out.global` is supported for compatibility."
|
@@ -8795,24 +8835,24 @@ var referenced_identifier_default = {
|
|
8795
8835
|
case "$global":
|
8796
8836
|
if (isOutputHTML()) {
|
8797
8837
|
identifier.replaceWith(
|
8798
|
-
|
8838
|
+
import_compiler55.types.callExpression(importRuntime("$global"), [])
|
8799
8839
|
);
|
8800
8840
|
} else {
|
8801
8841
|
identifier.replaceWith(
|
8802
|
-
|
8842
|
+
import_compiler55.types.memberExpression(scopeIdentifier, import_compiler55.types.identifier("$global"))
|
8803
8843
|
);
|
8804
8844
|
}
|
8805
8845
|
break;
|
8806
8846
|
case "$signal":
|
8807
8847
|
if (isOutputHTML()) {
|
8808
8848
|
identifier.replaceWith(
|
8809
|
-
|
8810
|
-
|
8849
|
+
import_compiler55.types.callExpression(
|
8850
|
+
import_compiler55.types.arrowFunctionExpression(
|
8811
8851
|
[],
|
8812
|
-
|
8813
|
-
|
8814
|
-
|
8815
|
-
|
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.")
|
8816
8856
|
])
|
8817
8857
|
)
|
8818
8858
|
])
|
@@ -8838,19 +8878,19 @@ var referenced_identifier_default = {
|
|
8838
8878
|
"render",
|
8839
8879
|
section,
|
8840
8880
|
exprRoot.node.extra?.referencedBindings,
|
8841
|
-
|
8842
|
-
|
8881
|
+
import_compiler55.types.expressionStatement(
|
8882
|
+
import_compiler55.types.callExpression(importRuntime("resetAbortSignal"), [
|
8843
8883
|
scopeIdentifier,
|
8844
|
-
|
8884
|
+
import_compiler55.types.numericLiteral(exprId)
|
8845
8885
|
])
|
8846
8886
|
),
|
8847
8887
|
false
|
8848
8888
|
);
|
8849
8889
|
}
|
8850
8890
|
identifier.replaceWith(
|
8851
|
-
|
8891
|
+
import_compiler55.types.callExpression(importRuntime("getAbortSignal"), [
|
8852
8892
|
scopeIdentifier,
|
8853
|
-
|
8893
|
+
import_compiler55.types.numericLiteral(exprId)
|
8854
8894
|
])
|
8855
8895
|
);
|
8856
8896
|
}
|
@@ -8890,11 +8930,11 @@ var scriptlet_default = {
|
|
8890
8930
|
};
|
8891
8931
|
|
8892
8932
|
// src/translator/visitors/tag/index.ts
|
8893
|
-
var
|
8933
|
+
var import_compiler59 = require("@marko/compiler");
|
8894
8934
|
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
8895
8935
|
|
8896
8936
|
// src/translator/visitors/tag/attribute-tag.ts
|
8897
|
-
var
|
8937
|
+
var import_compiler56 = require("@marko/compiler");
|
8898
8938
|
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8899
8939
|
var attribute_tag_default = {
|
8900
8940
|
analyze: {
|
@@ -8925,7 +8965,7 @@ var attribute_tag_default = {
|
|
8925
8965
|
};
|
8926
8966
|
|
8927
8967
|
// src/translator/visitors/tag/custom-tag.ts
|
8928
|
-
var
|
8968
|
+
var import_compiler57 = require("@marko/compiler");
|
8929
8969
|
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
8930
8970
|
var import_path4 = __toESM(require("path"));
|
8931
8971
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
@@ -8980,7 +9020,7 @@ var custom_tag_default = {
|
|
8980
9020
|
tag,
|
8981
9021
|
childProgramExtra?.domExports.input
|
8982
9022
|
);
|
8983
|
-
(0,
|
9023
|
+
(0, import_compiler57.getProgram)().node.extra.hasInteractiveChild = childProgramExtra?.isInteractive || childProgramExtra?.hasInteractiveChild || false;
|
8984
9024
|
}
|
8985
9025
|
}
|
8986
9026
|
},
|
@@ -9007,9 +9047,9 @@ function translateHTML(tag) {
|
|
9007
9047
|
let tagIdentifier;
|
9008
9048
|
flushInto(tag);
|
9009
9049
|
writeHTMLResumeStatements(tagBody);
|
9010
|
-
if (
|
9050
|
+
if (import_compiler57.types.isStringLiteral(node.name)) {
|
9011
9051
|
const relativePath = getTagRelativePath(tag);
|
9012
|
-
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));
|
9013
9053
|
} else {
|
9014
9054
|
tagIdentifier = node.name;
|
9015
9055
|
}
|
@@ -9027,8 +9067,8 @@ function translateHTML(tag) {
|
|
9027
9067
|
childScopeBinding?.name
|
9028
9068
|
);
|
9029
9069
|
tag.insertBefore(
|
9030
|
-
|
9031
|
-
|
9070
|
+
import_compiler57.types.variableDeclaration("const", [
|
9071
|
+
import_compiler57.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
9032
9072
|
])
|
9033
9073
|
);
|
9034
9074
|
setSerializedProperty(
|
@@ -9039,13 +9079,13 @@ function translateHTML(tag) {
|
|
9039
9079
|
);
|
9040
9080
|
if (tagVar) {
|
9041
9081
|
statements.push(
|
9042
|
-
|
9082
|
+
import_compiler57.types.expressionStatement(
|
9043
9083
|
callRuntime(
|
9044
9084
|
"setTagVar",
|
9045
9085
|
getScopeIdIdentifier(section),
|
9046
9086
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
9047
9087
|
peekScopeId,
|
9048
|
-
|
9088
|
+
import_compiler57.types.stringLiteral(
|
9049
9089
|
getResumeRegisterId(
|
9050
9090
|
section,
|
9051
9091
|
node.var.extra?.binding,
|
@@ -9065,8 +9105,8 @@ function translateHTML(tag) {
|
|
9065
9105
|
const contentExpression = contentProp.value;
|
9066
9106
|
contentProp.value = contentId = tag.scope.generateUidIdentifier("content");
|
9067
9107
|
const [contentPath] = tag.insertBefore(
|
9068
|
-
|
9069
|
-
|
9108
|
+
import_compiler57.types.variableDeclaration("const", [
|
9109
|
+
import_compiler57.types.variableDeclarator(
|
9070
9110
|
contentId,
|
9071
9111
|
// TODO: only register if needed (child template analysis)
|
9072
9112
|
contentExpression
|
@@ -9080,13 +9120,13 @@ function translateHTML(tag) {
|
|
9080
9120
|
propsToExpression(properties)
|
9081
9121
|
);
|
9082
9122
|
if (tagVar) {
|
9083
|
-
translateVar(tag,
|
9084
|
-
renderTagExpr =
|
9123
|
+
translateVar(tag, import_compiler57.types.unaryExpression("void", import_compiler57.types.numericLiteral(0)), "let");
|
9124
|
+
renderTagExpr = import_compiler57.types.assignmentExpression("=", tagVar, renderTagExpr);
|
9085
9125
|
}
|
9086
9126
|
statements.push(
|
9087
|
-
|
9127
|
+
import_compiler57.types.ifStatement(
|
9088
9128
|
tagIdentifier,
|
9089
|
-
|
9129
|
+
import_compiler57.types.expressionStatement(renderTagExpr),
|
9090
9130
|
contentId && callStatement(contentId)
|
9091
9131
|
)
|
9092
9132
|
);
|
@@ -9112,7 +9152,7 @@ function translateDOM(tag) {
|
|
9112
9152
|
const childScopeBinding = extra[kChildScopeBinding];
|
9113
9153
|
const write2 = writeTo(tag);
|
9114
9154
|
const { file } = tag.hub;
|
9115
|
-
const tagName =
|
9155
|
+
const tagName = import_compiler57.types.isIdentifier(node.name) ? node.name.name : import_compiler57.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
9116
9156
|
const relativePath = getTagRelativePath(tag);
|
9117
9157
|
const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
|
9118
9158
|
const childExports = childFile.ast.program.extra.domExports;
|
@@ -9144,7 +9184,7 @@ function translateDOM(tag) {
|
|
9144
9184
|
);
|
9145
9185
|
source.register = true;
|
9146
9186
|
source.buildAssignment = (valueSection, value) => {
|
9147
|
-
return
|
9187
|
+
return import_compiler57.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9148
9188
|
createScopeReadExpression(valueSection, childScopeBinding),
|
9149
9189
|
value
|
9150
9190
|
]);
|
@@ -9153,7 +9193,7 @@ function translateDOM(tag) {
|
|
9153
9193
|
"render",
|
9154
9194
|
tagSection,
|
9155
9195
|
void 0,
|
9156
|
-
|
9196
|
+
import_compiler57.types.expressionStatement(
|
9157
9197
|
callRuntime(
|
9158
9198
|
"setTagVar",
|
9159
9199
|
scopeIdentifier,
|
@@ -9167,8 +9207,8 @@ function translateDOM(tag) {
|
|
9167
9207
|
"render",
|
9168
9208
|
tagSection,
|
9169
9209
|
void 0,
|
9170
|
-
|
9171
|
-
|
9210
|
+
import_compiler57.types.expressionStatement(
|
9211
|
+
import_compiler57.types.callExpression(tagIdentifier, [
|
9172
9212
|
createScopeReadExpression(tagSection, childScopeBinding)
|
9173
9213
|
])
|
9174
9214
|
)
|
@@ -9181,7 +9221,7 @@ function getTagRelativePath(tag) {
|
|
9181
9221
|
hub: { file }
|
9182
9222
|
} = tag;
|
9183
9223
|
let relativePath;
|
9184
|
-
if (
|
9224
|
+
if (import_compiler57.types.isStringLiteral(node.name)) {
|
9185
9225
|
const template = (0, import_babel_utils41.getTagTemplate)(tag);
|
9186
9226
|
relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
|
9187
9227
|
} else if (node.extra?.tagNameImported) {
|
@@ -9274,7 +9314,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9274
9314
|
let spreadReferenceNodes;
|
9275
9315
|
for (let i = attributes.length; i--; ) {
|
9276
9316
|
const attr2 = attributes[i];
|
9277
|
-
if (
|
9317
|
+
if (import_compiler57.types.isMarkoAttribute(attr2)) {
|
9278
9318
|
if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
|
9279
9319
|
dropReferences(attr2.value);
|
9280
9320
|
continue;
|
@@ -9283,7 +9323,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9283
9323
|
}
|
9284
9324
|
if (spreadReferenceNodes) {
|
9285
9325
|
spreadReferenceNodes.push(attr2.value);
|
9286
|
-
} else if (
|
9326
|
+
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr2)) {
|
9287
9327
|
spreadReferenceNodes = [attr2.value];
|
9288
9328
|
} else {
|
9289
9329
|
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
@@ -9308,7 +9348,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9308
9348
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
9309
9349
|
tag.node.extra?.referencedBindings,
|
9310
9350
|
identifierToSignal(tagInputIdentifier),
|
9311
|
-
|
9351
|
+
import_compiler57.types.isSpreadElement(arg) ? import_compiler57.types.memberExpression(arg.argument, import_compiler57.types.numericLiteral(0), true) : arg,
|
9312
9352
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9313
9353
|
);
|
9314
9354
|
return;
|
@@ -9356,7 +9396,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9356
9396
|
} else {
|
9357
9397
|
attrTagCallsForTag.set(
|
9358
9398
|
attrTagName,
|
9359
|
-
translatedProps =
|
9399
|
+
translatedProps = import_compiler57.types.parenthesizedExpression(
|
9360
9400
|
callRuntime("attrTag", translatedProps)
|
9361
9401
|
)
|
9362
9402
|
);
|
@@ -9441,7 +9481,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9441
9481
|
childAttrExports.id,
|
9442
9482
|
`${importAlias}_${attrTagMeta.name}`
|
9443
9483
|
);
|
9444
|
-
decls.push(
|
9484
|
+
decls.push(import_compiler57.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
9445
9485
|
addValue(
|
9446
9486
|
info.tagSection,
|
9447
9487
|
referencedBindings,
|
@@ -9451,7 +9491,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9451
9491
|
);
|
9452
9492
|
}
|
9453
9493
|
addStatement("render", info.tagSection, referencedBindings, [
|
9454
|
-
|
9494
|
+
import_compiler57.types.variableDeclaration("let", decls),
|
9455
9495
|
...statements
|
9456
9496
|
]);
|
9457
9497
|
}
|
@@ -9471,7 +9511,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9471
9511
|
void 0,
|
9472
9512
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
9473
9513
|
identifierToSignal(contentExportIdentifier),
|
9474
|
-
|
9514
|
+
import_compiler57.types.callExpression(import_compiler57.types.identifier(bodySection.name), [scopeIdentifier]),
|
9475
9515
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9476
9516
|
);
|
9477
9517
|
}
|
@@ -9481,7 +9521,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9481
9521
|
let spreadProps;
|
9482
9522
|
for (let i = attributes.length; i--; ) {
|
9483
9523
|
const attr2 = attributes[i];
|
9484
|
-
if (
|
9524
|
+
if (import_compiler57.types.isMarkoAttribute(attr2)) {
|
9485
9525
|
const childAttrExports = templateExport.props[attr2.name];
|
9486
9526
|
if (!childAttrExports || seen.has(attr2.name)) continue;
|
9487
9527
|
seen.add(attr2.name);
|
@@ -9491,9 +9531,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9491
9531
|
}
|
9492
9532
|
staticAttrs.push(attr2);
|
9493
9533
|
} else if (spreadProps) {
|
9494
|
-
spreadProps.push(
|
9534
|
+
spreadProps.push(import_compiler57.types.spreadElement(attr2.value));
|
9495
9535
|
} else {
|
9496
|
-
spreadProps = [
|
9536
|
+
spreadProps = [import_compiler57.types.spreadElement(attr2.value)];
|
9497
9537
|
}
|
9498
9538
|
}
|
9499
9539
|
for (const attr2 of staticAttrs.reverse()) {
|
@@ -9522,8 +9562,8 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9522
9562
|
spreadProps.reverse();
|
9523
9563
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
9524
9564
|
addStatement("render", info.tagSection, referencedBindings, [
|
9525
|
-
|
9526
|
-
|
9565
|
+
import_compiler57.types.variableDeclaration("const", [
|
9566
|
+
import_compiler57.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
9527
9567
|
])
|
9528
9568
|
]);
|
9529
9569
|
}
|
@@ -9547,7 +9587,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9547
9587
|
}
|
9548
9588
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
9549
9589
|
if (isCircularRequest(file, request)) {
|
9550
|
-
return
|
9590
|
+
return import_compiler57.types.identifier(name2);
|
9551
9591
|
}
|
9552
9592
|
return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
|
9553
9593
|
}
|
@@ -9556,10 +9596,10 @@ function isCircularRequest(file, request) {
|
|
9556
9596
|
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
9557
9597
|
}
|
9558
9598
|
function callStatement(id, ...args) {
|
9559
|
-
return
|
9599
|
+
return import_compiler57.types.expressionStatement(callExpression(id, ...args));
|
9560
9600
|
}
|
9561
9601
|
function callExpression(id, ...args) {
|
9562
|
-
return
|
9602
|
+
return import_compiler57.types.callExpression(id, args.filter(Boolean));
|
9563
9603
|
}
|
9564
9604
|
function identifierToSignal(identifier) {
|
9565
9605
|
return {
|
@@ -9568,14 +9608,14 @@ function identifierToSignal(identifier) {
|
|
9568
9608
|
};
|
9569
9609
|
}
|
9570
9610
|
function buildUndefined2() {
|
9571
|
-
return
|
9611
|
+
return import_compiler57.types.unaryExpression("void", import_compiler57.types.numericLiteral(0));
|
9572
9612
|
}
|
9573
9613
|
function always() {
|
9574
9614
|
return true;
|
9575
9615
|
}
|
9576
9616
|
|
9577
9617
|
// src/translator/visitors/tag/dynamic-tag.ts
|
9578
|
-
var
|
9618
|
+
var import_compiler58 = require("@marko/compiler");
|
9579
9619
|
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
9580
9620
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
9581
9621
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
@@ -9631,7 +9671,7 @@ var dynamic_tag_default = {
|
|
9631
9671
|
const isClassAPI = tagExtra.featureType === "class";
|
9632
9672
|
const referencedBindings = tagExtra.referencedBindings;
|
9633
9673
|
let tagExpression = node.name;
|
9634
|
-
if (
|
9674
|
+
if (import_compiler58.types.isStringLiteral(tagExpression)) {
|
9635
9675
|
tagExpression = (0, import_babel_utils42.importDefault)(
|
9636
9676
|
tag.hub.file,
|
9637
9677
|
getTagRelativePath(tag),
|
@@ -9640,15 +9680,15 @@ var dynamic_tag_default = {
|
|
9640
9680
|
}
|
9641
9681
|
if (isClassAPI) {
|
9642
9682
|
if (isOutputHTML()) {
|
9643
|
-
(0,
|
9644
|
-
|
9683
|
+
(0, import_compiler58.getProgram)().node.body.push(
|
9684
|
+
import_compiler58.types.markoScriptlet(
|
9645
9685
|
[
|
9646
|
-
|
9647
|
-
|
9686
|
+
import_compiler58.types.expressionStatement(
|
9687
|
+
import_compiler58.types.callExpression(
|
9648
9688
|
(0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
9649
9689
|
[
|
9650
|
-
|
9651
|
-
|
9690
|
+
import_compiler58.types.identifier(tagExpression.name),
|
9691
|
+
import_compiler58.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
|
9652
9692
|
]
|
9653
9693
|
)
|
9654
9694
|
)
|
@@ -9657,12 +9697,12 @@ var dynamic_tag_default = {
|
|
9657
9697
|
)
|
9658
9698
|
);
|
9659
9699
|
} else {
|
9660
|
-
(0,
|
9661
|
-
|
9700
|
+
(0, import_compiler58.getProgram)().node.body.push(
|
9701
|
+
import_compiler58.types.expressionStatement(
|
9662
9702
|
callRuntime(
|
9663
9703
|
"register",
|
9664
|
-
|
9665
|
-
|
9704
|
+
import_compiler58.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
|
9705
|
+
import_compiler58.types.identifier(tagExpression.name)
|
9666
9706
|
)
|
9667
9707
|
)
|
9668
9708
|
);
|
@@ -9682,7 +9722,7 @@ var dynamic_tag_default = {
|
|
9682
9722
|
hasMultipleArgs = true;
|
9683
9723
|
args.push(propsToExpression(properties));
|
9684
9724
|
} else {
|
9685
|
-
hasMultipleArgs = node.arguments.length > 1 ||
|
9725
|
+
hasMultipleArgs = node.arguments.length > 1 || import_compiler58.types.isSpreadElement(node.arguments[0]);
|
9686
9726
|
}
|
9687
9727
|
} else {
|
9688
9728
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
@@ -9702,35 +9742,35 @@ var dynamic_tag_default = {
|
|
9702
9742
|
getScopeIdIdentifier(section),
|
9703
9743
|
getScopeAccessorLiteral(nodeRef2),
|
9704
9744
|
tagExpression,
|
9705
|
-
|
9706
|
-
|
9707
|
-
|
9708
|
-
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
|
9709
9749
|
) : callRuntime(
|
9710
9750
|
"dynamicTag",
|
9711
9751
|
getScopeIdIdentifier(section),
|
9712
9752
|
getScopeAccessorLiteral(nodeRef2),
|
9713
9753
|
tagExpression,
|
9714
9754
|
args[0],
|
9715
|
-
args[1] || (serializeReason ?
|
9716
|
-
serializeReason ?
|
9717
|
-
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
|
9718
9758
|
);
|
9719
9759
|
if (node.var) {
|
9720
|
-
const dynamicScopeIdentifier = (0,
|
9760
|
+
const dynamicScopeIdentifier = (0, import_compiler58.getProgram)().scope.generateUidIdentifier("dynamicScope");
|
9721
9761
|
statements.push(
|
9722
|
-
|
9723
|
-
|
9762
|
+
import_compiler58.types.variableDeclaration("const", [
|
9763
|
+
import_compiler58.types.variableDeclarator(
|
9724
9764
|
dynamicScopeIdentifier,
|
9725
9765
|
callRuntime("peekNextScope")
|
9726
9766
|
)
|
9727
9767
|
])
|
9728
9768
|
);
|
9729
9769
|
statements.push(
|
9730
|
-
|
9731
|
-
|
9770
|
+
import_compiler58.types.variableDeclaration("const", [
|
9771
|
+
import_compiler58.types.variableDeclarator(node.var, dynamicTagExpr)
|
9732
9772
|
]),
|
9733
|
-
|
9773
|
+
import_compiler58.types.expressionStatement(
|
9734
9774
|
callRuntime(
|
9735
9775
|
"setTagVar",
|
9736
9776
|
getScopeIdIdentifier(section),
|
@@ -9738,7 +9778,7 @@ var dynamic_tag_default = {
|
|
9738
9778
|
tag.node.extra[kChildOffsetScopeBinding2]
|
9739
9779
|
),
|
9740
9780
|
dynamicScopeIdentifier,
|
9741
|
-
|
9781
|
+
import_compiler58.types.stringLiteral(
|
9742
9782
|
getResumeRegisterId(
|
9743
9783
|
section,
|
9744
9784
|
node.var.extra?.binding,
|
@@ -9750,7 +9790,7 @@ var dynamic_tag_default = {
|
|
9750
9790
|
)
|
9751
9791
|
);
|
9752
9792
|
} else {
|
9753
|
-
statements.push(
|
9793
|
+
statements.push(import_compiler58.types.expressionStatement(dynamicTagExpr));
|
9754
9794
|
}
|
9755
9795
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
9756
9796
|
replacement.skip();
|
@@ -9767,10 +9807,10 @@ var dynamic_tag_default = {
|
|
9767
9807
|
);
|
9768
9808
|
tagVarSignal.register = true;
|
9769
9809
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
9770
|
-
return
|
9771
|
-
|
9810
|
+
return import_compiler58.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9811
|
+
import_compiler58.types.memberExpression(
|
9772
9812
|
getScopeExpression(tagVarSignal.section, valueSection),
|
9773
|
-
|
9813
|
+
import_compiler58.types.stringLiteral(
|
9774
9814
|
getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
|
9775
9815
|
),
|
9776
9816
|
true
|
@@ -9783,19 +9823,19 @@ var dynamic_tag_default = {
|
|
9783
9823
|
return callRuntime(
|
9784
9824
|
"dynamicTag",
|
9785
9825
|
getScopeAccessorLiteral(nodeRef2),
|
9786
|
-
bodySection &&
|
9787
|
-
tagVarSignal ?
|
9788
|
-
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)
|
9789
9829
|
);
|
9790
9830
|
};
|
9791
9831
|
if (args.length) {
|
9792
|
-
const argsOrInput = hasMultipleArgs ?
|
9793
|
-
if (!
|
9832
|
+
const argsOrInput = hasMultipleArgs ? import_compiler58.types.arrayExpression(args) : args[0];
|
9833
|
+
if (!import_compiler58.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
9794
9834
|
signal.extraArgs = [
|
9795
|
-
|
9835
|
+
import_compiler58.types.arrowFunctionExpression(
|
9796
9836
|
[],
|
9797
|
-
statements.length ?
|
9798
|
-
statements.concat(
|
9837
|
+
statements.length ? import_compiler58.types.blockStatement(
|
9838
|
+
statements.concat(import_compiler58.types.returnStatement(argsOrInput))
|
9799
9839
|
) : argsOrInput
|
9800
9840
|
)
|
9801
9841
|
];
|
@@ -9818,16 +9858,16 @@ var tag_default = {
|
|
9818
9858
|
const { node } = tag;
|
9819
9859
|
const { name: name2, attributes } = tag.node;
|
9820
9860
|
let crawl = false;
|
9821
|
-
if (
|
9861
|
+
if (import_compiler59.types.isStringLiteral(name2)) {
|
9822
9862
|
const tagName = name2.value;
|
9823
9863
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
9824
|
-
node.name = withPreviousLocation(
|
9864
|
+
node.name = withPreviousLocation(import_compiler59.types.identifier(tagName), name2);
|
9825
9865
|
crawl = true;
|
9826
9866
|
}
|
9827
9867
|
}
|
9828
9868
|
for (let i = 0; i < attributes.length; i++) {
|
9829
9869
|
const attr2 = attributes[i];
|
9830
|
-
if (
|
9870
|
+
if (import_compiler59.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9831
9871
|
attr2.bound = false;
|
9832
9872
|
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
9833
9873
|
crawl = true;
|
@@ -9903,8 +9943,8 @@ var tag_default = {
|
|
9903
9943
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
9904
9944
|
const tagNameId = tag.scope.generateUidIdentifier("tagName");
|
9905
9945
|
const [tagNameVarPath] = tag.insertBefore(
|
9906
|
-
|
9907
|
-
|
9946
|
+
import_compiler59.types.variableDeclaration("const", [
|
9947
|
+
import_compiler59.types.variableDeclarator(tagNameId, tag.node.name)
|
9908
9948
|
])
|
9909
9949
|
);
|
9910
9950
|
tagNameVarPath.skip();
|
@@ -9951,16 +9991,16 @@ var tag_default = {
|
|
9951
9991
|
function getChangeHandler(tag, attr2) {
|
9952
9992
|
const attrName = attr2.name;
|
9953
9993
|
const changeAttrName = attrName + "Change";
|
9954
|
-
if (
|
9994
|
+
if (import_compiler59.types.isIdentifier(attr2.value)) {
|
9955
9995
|
const binding = tag.scope.getBinding(attr2.value.name);
|
9956
9996
|
if (!binding)
|
9957
|
-
return
|
9997
|
+
return import_compiler59.types.markoAttribute(
|
9958
9998
|
changeAttrName,
|
9959
9999
|
buildChangeHandlerFunction(attr2.value)
|
9960
10000
|
);
|
9961
10001
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
9962
10002
|
if (!existingChangedAttr) {
|
9963
|
-
const changeHandlerAttr =
|
10003
|
+
const changeHandlerAttr = import_compiler59.types.markoAttribute(
|
9964
10004
|
changeAttrName,
|
9965
10005
|
buildChangeHandlerFunction(attr2.value)
|
9966
10006
|
);
|
@@ -9968,10 +10008,10 @@ function getChangeHandler(tag, attr2) {
|
|
9968
10008
|
return changeHandlerAttr;
|
9969
10009
|
}
|
9970
10010
|
if (existingChangedAttr.type === "Identifier") {
|
9971
|
-
return
|
10011
|
+
return import_compiler59.types.markoAttribute(
|
9972
10012
|
changeAttrName,
|
9973
10013
|
withPreviousLocation(
|
9974
|
-
|
10014
|
+
import_compiler59.types.identifier(existingChangedAttr.name),
|
9975
10015
|
attr2.value
|
9976
10016
|
)
|
9977
10017
|
);
|
@@ -9981,37 +10021,37 @@ function getChangeHandler(tag, attr2) {
|
|
9981
10021
|
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
9982
10022
|
}
|
9983
10023
|
const changeHandlerId = markoRoot.scope.generateUid(changeAttrName);
|
9984
|
-
const changeHandlerConst =
|
9985
|
-
|
9986
|
-
[
|
9987
|
-
|
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([]),
|
9988
10028
|
null,
|
9989
|
-
|
10029
|
+
import_compiler59.types.identifier(changeHandlerId)
|
9990
10030
|
);
|
9991
10031
|
BINDING_CHANGE_HANDLER.set(
|
9992
10032
|
binding.identifier,
|
9993
|
-
existingChangedAttr.value =
|
10033
|
+
existingChangedAttr.value = import_compiler59.types.identifier(changeHandlerId)
|
9994
10034
|
);
|
9995
10035
|
if (markoRoot.isMarkoTag()) {
|
9996
10036
|
markoRoot.insertAfter(changeHandlerConst);
|
9997
10037
|
} else {
|
9998
10038
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
9999
10039
|
}
|
10000
|
-
return
|
10040
|
+
return import_compiler59.types.markoAttribute(
|
10001
10041
|
changeAttrName,
|
10002
|
-
withPreviousLocation(
|
10042
|
+
withPreviousLocation(import_compiler59.types.identifier(changeHandlerId), attr2.value)
|
10003
10043
|
);
|
10004
|
-
} else if (
|
10044
|
+
} else if (import_compiler59.types.isMemberExpression(attr2.value)) {
|
10005
10045
|
const prop = attr2.value.property;
|
10006
|
-
if (!
|
10007
|
-
return
|
10046
|
+
if (!import_compiler59.types.isPrivateName(attr2.value.property)) {
|
10047
|
+
return import_compiler59.types.markoAttribute(
|
10008
10048
|
changeAttrName,
|
10009
|
-
|
10010
|
-
|
10011
|
-
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(
|
10012
10052
|
"+",
|
10013
|
-
|
10014
|
-
|
10053
|
+
import_compiler59.types.cloneNode(prop),
|
10054
|
+
import_compiler59.types.stringLiteral("Change")
|
10015
10055
|
),
|
10016
10056
|
prop.type !== "Identifier"
|
10017
10057
|
)
|
@@ -10025,14 +10065,14 @@ function getChangeHandler(tag, attr2) {
|
|
10025
10065
|
}
|
10026
10066
|
function buildChangeHandlerFunction(id) {
|
10027
10067
|
const newId = "_new_" + id.name;
|
10028
|
-
return
|
10029
|
-
[withPreviousLocation(
|
10030
|
-
|
10031
|
-
|
10032
|
-
|
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(
|
10033
10073
|
"=",
|
10034
|
-
withPreviousLocation(
|
10035
|
-
withPreviousLocation(
|
10074
|
+
withPreviousLocation(import_compiler59.types.identifier(id.name), id),
|
10075
|
+
withPreviousLocation(import_compiler59.types.identifier(newId), id)
|
10036
10076
|
)
|
10037
10077
|
)
|
10038
10078
|
])
|
@@ -10040,10 +10080,11 @@ function buildChangeHandlerFunction(id) {
|
|
10040
10080
|
}
|
10041
10081
|
|
10042
10082
|
// src/translator/visitors/text.ts
|
10043
|
-
var
|
10083
|
+
var import_compiler60 = require("@marko/compiler");
|
10044
10084
|
var text_default = {
|
10045
10085
|
translate: {
|
10046
10086
|
exit(text) {
|
10087
|
+
if (isNonHTMLText(text)) return;
|
10047
10088
|
writeTo(text)`${text.node.value}`;
|
10048
10089
|
enterShallow(text);
|
10049
10090
|
text.remove();
|