marko 6.0.135 → 6.0.136
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 +77 -26
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
|
@@ -3626,7 +3626,13 @@ function getSignalFn(signal) {
|
|
|
3626
3626
|
...getTranslatedExtraArgs(aliasSignal)
|
|
3627
3627
|
])
|
|
3628
3628
|
),
|
|
3629
|
-
[
|
|
3629
|
+
[
|
|
3630
|
+
binding.nullable ? import_compiler22.types.logicalExpression(
|
|
3631
|
+
"||",
|
|
3632
|
+
createScopeReadExpression(binding),
|
|
3633
|
+
import_compiler22.types.objectExpression([])
|
|
3634
|
+
) : createScopeReadExpression(binding)
|
|
3635
|
+
]
|
|
3630
3636
|
)
|
|
3631
3637
|
)
|
|
3632
3638
|
);
|
|
@@ -5580,34 +5586,77 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
5580
5586
|
if (!tagVar) {
|
|
5581
5587
|
return;
|
|
5582
5588
|
}
|
|
5589
|
+
const tagSection = getOrCreateSection(tag);
|
|
5583
5590
|
forEachIdentifierPath(tag.get("var"), (id) => {
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5591
|
+
if (id.node === tagVar) return;
|
|
5592
|
+
const idExtra = id.node.extra;
|
|
5593
|
+
if (!idExtra) return;
|
|
5594
|
+
const binding = idExtra.binding;
|
|
5595
|
+
if (!binding?.upstreamAlias) return;
|
|
5596
|
+
if (binding.assignmentSections && binding.property !== void 0) {
|
|
5597
|
+
const changeName = binding.property + "Change";
|
|
5598
|
+
const changeBinding = binding.upstreamAlias.propertyAliases.get(changeName);
|
|
5599
|
+
if (changeBinding && changeName !== changeBinding.name) {
|
|
5600
|
+
const pattern = getDestructurePattern(id);
|
|
5601
|
+
if (pattern) {
|
|
5602
|
+
pattern.unshiftContainer(
|
|
5603
|
+
"properties",
|
|
5604
|
+
import_compiler32.types.objectProperty(
|
|
5605
|
+
import_compiler32.types.identifier(changeName),
|
|
5606
|
+
import_compiler32.types.identifier(changeBinding.name)
|
|
5607
|
+
)
|
|
5608
|
+
);
|
|
5609
|
+
const lastProperty = pattern.get("properties").at(-1);
|
|
5610
|
+
if (lastProperty?.node.type === "RestElement") {
|
|
5611
|
+
const restBinding = lastProperty.node.argument.extra?.binding;
|
|
5612
|
+
if (restBinding) {
|
|
5613
|
+
restBinding.excludeProperties = propsUtil.add(
|
|
5614
|
+
restBinding.excludeProperties,
|
|
5615
|
+
changeName
|
|
5616
|
+
);
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5587
5621
|
}
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
pattern.unshiftContainer(
|
|
5594
|
-
"properties",
|
|
5595
|
-
import_compiler32.types.objectProperty(
|
|
5596
|
-
import_compiler32.types.identifier(changeName),
|
|
5597
|
-
import_compiler32.types.identifier(changeBinding.name)
|
|
5598
|
-
)
|
|
5622
|
+
if (binding.section !== tagSection && binding.excludeProperties !== void 0 && getSerializeReason(binding.section, binding)) {
|
|
5623
|
+
const restPath = id.parentPath;
|
|
5624
|
+
if (restPath.type !== "RestElement") {
|
|
5625
|
+
throw restPath.buildCodeFrameError(
|
|
5626
|
+
"Invalid compiler state, found a rest binding outside of a rest element."
|
|
5599
5627
|
);
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5628
|
+
}
|
|
5629
|
+
let curPath = tag.parentPath;
|
|
5630
|
+
while (curPath) {
|
|
5631
|
+
if (curPath.node.extra?.section === binding.section) {
|
|
5632
|
+
const canonicalUpstreamAlias = getCanonicalBinding(
|
|
5633
|
+
binding.upstreamAlias
|
|
5634
|
+
);
|
|
5635
|
+
const props = toArray(
|
|
5636
|
+
binding.excludeProperties,
|
|
5637
|
+
(name2) => import_compiler32.types.objectProperty(
|
|
5638
|
+
toPropertyName(name2),
|
|
5639
|
+
generateUidIdentifier(name2)
|
|
5640
|
+
)
|
|
5641
|
+
);
|
|
5642
|
+
props.push(restPath.node);
|
|
5643
|
+
curPath.insertBefore(
|
|
5644
|
+
import_compiler32.types.variableDeclaration(kind, [
|
|
5645
|
+
import_compiler32.types.variableDeclarator(
|
|
5646
|
+
import_compiler32.types.objectPattern(props),
|
|
5647
|
+
canonicalUpstreamAlias.nullable ? import_compiler32.types.logicalExpression(
|
|
5648
|
+
"||",
|
|
5649
|
+
getDeclaredBindingExpression(canonicalUpstreamAlias),
|
|
5650
|
+
import_compiler32.types.objectExpression([])
|
|
5651
|
+
) : getDeclaredBindingExpression(canonicalUpstreamAlias)
|
|
5652
|
+
)
|
|
5653
|
+
])
|
|
5654
|
+
);
|
|
5655
|
+
break;
|
|
5609
5656
|
}
|
|
5657
|
+
curPath = curPath.parentPath;
|
|
5610
5658
|
}
|
|
5659
|
+
restPath.remove();
|
|
5611
5660
|
}
|
|
5612
5661
|
});
|
|
5613
5662
|
tag.insertBefore(
|
|
@@ -8485,7 +8534,8 @@ var [getNextBindingId, setNextBindingId] = createProgramState(() => 0);
|
|
|
8485
8534
|
function createBinding(name2, type, refSection, upstreamAlias, property, excludeProperties, loc = null, refDeclared = false) {
|
|
8486
8535
|
const id = getNextBindingId();
|
|
8487
8536
|
const section = upstreamAlias ? upstreamAlias.section : refSection;
|
|
8488
|
-
const
|
|
8537
|
+
const sameSection = refSection === section;
|
|
8538
|
+
const declared = sameSection && refDeclared;
|
|
8489
8539
|
const binding = {
|
|
8490
8540
|
id,
|
|
8491
8541
|
name: name2,
|
|
@@ -8506,7 +8556,7 @@ function createBinding(name2, type, refSection, upstreamAlias, property, exclude
|
|
|
8506
8556
|
scopeOffset: void 0,
|
|
8507
8557
|
scopeAccessor: void 0,
|
|
8508
8558
|
export: void 0,
|
|
8509
|
-
nullable: excludeProperties === void 0,
|
|
8559
|
+
nullable: !sameSection || excludeProperties === void 0,
|
|
8510
8560
|
pruned: void 0
|
|
8511
8561
|
};
|
|
8512
8562
|
if (property) {
|
|
@@ -8761,6 +8811,7 @@ function trackAssignment(assignment, binding) {
|
|
|
8761
8811
|
if (id.node.name === binding.name) {
|
|
8762
8812
|
const idExtra = id.node.extra ??= {};
|
|
8763
8813
|
idExtra.assignment = binding;
|
|
8814
|
+
idExtra.section = section;
|
|
8764
8815
|
binding.assignmentSections = sectionUtil.add(
|
|
8765
8816
|
binding.assignmentSections,
|
|
8766
8817
|
section
|