@marko/runtime-tags 6.0.129 → 6.0.130
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
|
@@ -3290,16 +3290,17 @@ function getScopeExpression(section, targetSection) {
|
|
|
3290
3290
|
}
|
|
3291
3291
|
return scope;
|
|
3292
3292
|
}
|
|
3293
|
-
function createScopeReadExpression(reference, section) {
|
|
3293
|
+
function createScopeReadExpression(reference, section = reference.section) {
|
|
3294
3294
|
const propName = toPropertyName(getScopeAccessor(reference));
|
|
3295
|
-
const scope = section && reference.type !== 4 /* local */ ? getScopeExpression(section, reference.section) : scopeIdentifier;
|
|
3296
3295
|
const expr = import_compiler19.types.memberExpression(
|
|
3297
|
-
|
|
3296
|
+
reference.type === 4 /* local */ ? scopeIdentifier : getScopeExpression(section, reference.section),
|
|
3298
3297
|
propName,
|
|
3299
3298
|
propName.type !== "Identifier"
|
|
3300
3299
|
);
|
|
3301
|
-
if (
|
|
3302
|
-
|
|
3300
|
+
if (section === reference.section && reference.type !== 0 /* dom */) {
|
|
3301
|
+
const exprExtra = expr.extra ??= {};
|
|
3302
|
+
exprExtra.read = createRead(reference, void 0);
|
|
3303
|
+
exprExtra.section = section;
|
|
3303
3304
|
}
|
|
3304
3305
|
return expr;
|
|
3305
3306
|
}
|
|
@@ -3431,9 +3432,13 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
|
3431
3432
|
renderReferencedBindings: void 0,
|
|
3432
3433
|
effect: [],
|
|
3433
3434
|
effectReferencedBindings: void 0,
|
|
3434
|
-
subscribers: [],
|
|
3435
3435
|
build: void 0,
|
|
3436
|
-
export: !!exportName
|
|
3436
|
+
export: !!exportName,
|
|
3437
|
+
hasSideEffect: !!(referencedBindings && (Array.isArray(referencedBindings) || referencedBindings.type === 0 /* dom */ || referencedBindings.type === 1 /* let */ || referencedBindings.section !== section || referencedBindings.closureSections || referencedBindings.hoists.size)),
|
|
3438
|
+
hasDynamicSubscribers: false,
|
|
3439
|
+
extraArgs: void 0,
|
|
3440
|
+
prependStatements: void 0,
|
|
3441
|
+
buildAssignment: void 0
|
|
3437
3442
|
}
|
|
3438
3443
|
);
|
|
3439
3444
|
if (isOutputHTML()) {
|
|
@@ -3678,7 +3683,6 @@ function getSignalFn(signal) {
|
|
|
3678
3683
|
}
|
|
3679
3684
|
if (signal.effect.length) {
|
|
3680
3685
|
const effectIdentifier = import_compiler22.types.identifier(`${signal.identifier.name}__script`);
|
|
3681
|
-
signal.hasSideEffect = true;
|
|
3682
3686
|
signal.render.push(
|
|
3683
3687
|
import_compiler22.types.expressionStatement(
|
|
3684
3688
|
import_compiler22.types.callExpression(effectIdentifier, [scopeIdentifier])
|
|
@@ -3735,6 +3739,7 @@ function subscribe(references, subscriber) {
|
|
|
3735
3739
|
if (binding.type !== 7 /* constant */) {
|
|
3736
3740
|
const source = binding.property === void 0 && binding.excludeProperties === void 0 && binding.upstreamAlias || binding;
|
|
3737
3741
|
const providerSignal = getSignal(subscriber.section, source);
|
|
3742
|
+
providerSignal.hasSideEffect = true;
|
|
3738
3743
|
providerSignal.intersection = push(
|
|
3739
3744
|
providerSignal.intersection,
|
|
3740
3745
|
subscriber
|
|
@@ -3897,12 +3902,6 @@ function writeSignals(section) {
|
|
|
3897
3902
|
traverseReplace(value, "value", replaceRenderNode);
|
|
3898
3903
|
}
|
|
3899
3904
|
forEach(signal.intersection, writeSignal);
|
|
3900
|
-
if (!signal.hasSideEffect) {
|
|
3901
|
-
const binding = signal.referencedBindings;
|
|
3902
|
-
if (binding && (signal.intersection || Array.isArray(binding) || binding.type === 1 /* let */ || binding.closureSections || binding.hoists.size || binding.section !== signal.section)) {
|
|
3903
|
-
signal.hasSideEffect = true;
|
|
3904
|
-
}
|
|
3905
|
-
}
|
|
3906
3905
|
let effectDeclarator;
|
|
3907
3906
|
if (signal.effect.length) {
|
|
3908
3907
|
traverseReplace(signal, "effect", replaceEffectNode);
|
|
@@ -6946,7 +6945,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6946
6945
|
if (attrTagLookup) {
|
|
6947
6946
|
for (const name2 in attrTagLookup) {
|
|
6948
6947
|
const attrTagMeta = attrTagLookup[name2];
|
|
6949
|
-
if (!seen.has(
|
|
6948
|
+
if (!seen.has(attrTagMeta.name) && usesExport(templateExports, attrTagMeta.name)) {
|
|
6950
6949
|
seen.add(attrTagMeta.name);
|
|
6951
6950
|
if (attrTagMeta.dynamic) {
|
|
6952
6951
|
statements.push(
|
|
@@ -6969,6 +6968,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6969
6968
|
if (child.isMarkoTag()) {
|
|
6970
6969
|
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
6971
6970
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6971
|
+
if (skip2?.has(attrTagMeta.name)) continue;
|
|
6972
6972
|
if (attrTagMeta.dynamic) {
|
|
6973
6973
|
i = addDynamicAttrTagStatements(
|
|
6974
6974
|
attrTags2,
|
|
@@ -7712,7 +7712,9 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7712
7712
|
} else if (import_compiler37.types.isMarkoSpreadAttribute(attr)) {
|
|
7713
7713
|
knownSpreadBinding = getSingleKnownSpreadBinding(attributes);
|
|
7714
7714
|
if (knownSpreadBinding) {
|
|
7715
|
-
|
|
7715
|
+
if (!propTree.rest || propTree.rest.props) {
|
|
7716
|
+
dropRead(attr.value.extra);
|
|
7717
|
+
}
|
|
7716
7718
|
} else {
|
|
7717
7719
|
spreadReferenceNodes = [attr.value];
|
|
7718
7720
|
}
|
|
@@ -7730,7 +7732,6 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7730
7732
|
known[prop] = { value: propExtra };
|
|
7731
7733
|
rootAttrExprs.add(propExtra);
|
|
7732
7734
|
addRead(propExtra, propExtra, propBinding, section);
|
|
7733
|
-
setBindingDownstream(propBinding, propExtra);
|
|
7734
7735
|
}
|
|
7735
7736
|
}
|
|
7736
7737
|
} else if (spreadReferenceNodes) {
|
|
@@ -7753,14 +7754,15 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7753
7754
|
);
|
|
7754
7755
|
}
|
|
7755
7756
|
if (propTree.rest) {
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
tag.node,
|
|
7761
|
-
unknownReferences.flat()
|
|
7762
|
-
)
|
|
7757
|
+
const restExtra = inputExpr.value = mergeReferences(
|
|
7758
|
+
section,
|
|
7759
|
+
tag.node,
|
|
7760
|
+
unknownReferences.flat()
|
|
7763
7761
|
);
|
|
7762
|
+
setBindingDownstream(propTree.binding, restExtra);
|
|
7763
|
+
if (knownSpreadBinding && !propTree.rest.props) {
|
|
7764
|
+
addRead(restExtra, void 0, knownSpreadBinding, section);
|
|
7765
|
+
}
|
|
7764
7766
|
} else {
|
|
7765
7767
|
unknownReferences.forEach(dropReferences);
|
|
7766
7768
|
}
|
|
@@ -8178,7 +8180,9 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
8178
8180
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8179
8181
|
translatedProps
|
|
8180
8182
|
])
|
|
8181
|
-
)
|
|
8183
|
+
),
|
|
8184
|
+
void 0,
|
|
8185
|
+
true
|
|
8182
8186
|
);
|
|
8183
8187
|
}
|
|
8184
8188
|
}
|
|
@@ -8306,7 +8310,9 @@ function trackDomVarReferences(tag, binding) {
|
|
|
8306
8310
|
const refSection = getOrCreateSection(ref);
|
|
8307
8311
|
setReferencesScope(ref);
|
|
8308
8312
|
if (isSameOrChildSection(binding.section, refSection)) {
|
|
8309
|
-
|
|
8313
|
+
const refExtra = ref.node.extra ??= {};
|
|
8314
|
+
refExtra.read = createRead(binding, void 0);
|
|
8315
|
+
refExtra.section = refSection;
|
|
8310
8316
|
if (!isInvokedFunction(ref)) {
|
|
8311
8317
|
section.domGetterBindings.set(
|
|
8312
8318
|
binding,
|
|
@@ -9597,6 +9603,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9597
9603
|
if (extra === (0, import_babel_utils26.getProgram)().node.extra?.returnValueExpr) {
|
|
9598
9604
|
reason = true;
|
|
9599
9605
|
} else {
|
|
9606
|
+
serializeReasonCache.set(extra, false);
|
|
9600
9607
|
forEach(extra.downstream, (binding) => {
|
|
9601
9608
|
reason = mergeSerializeReasons(
|
|
9602
9609
|
reason,
|
|
@@ -9604,7 +9611,9 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9604
9611
|
);
|
|
9605
9612
|
});
|
|
9606
9613
|
}
|
|
9607
|
-
|
|
9614
|
+
if (reason) {
|
|
9615
|
+
serializeReasonCache.set(extra, reason);
|
|
9616
|
+
}
|
|
9608
9617
|
}
|
|
9609
9618
|
return reason;
|
|
9610
9619
|
}
|
|
@@ -9614,6 +9623,9 @@ function getAllSerializeReasonsForBinding(binding) {
|
|
|
9614
9623
|
if (reason === void 0) {
|
|
9615
9624
|
reason = getSerializeReason(binding.section, binding);
|
|
9616
9625
|
if (reason !== true) {
|
|
9626
|
+
if (!reason) {
|
|
9627
|
+
serializeReasonCache.set(binding, false);
|
|
9628
|
+
}
|
|
9617
9629
|
for (const expr of binding.downstreamExpressions) {
|
|
9618
9630
|
reason = expr.isEffect || mergeSerializeReasons(reason, getAllSerializeReasonsForExtra(expr));
|
|
9619
9631
|
if (reason === true) break;
|
|
@@ -9637,7 +9649,9 @@ function getAllSerializeReasonsForBinding(binding) {
|
|
|
9637
9649
|
}
|
|
9638
9650
|
}
|
|
9639
9651
|
}
|
|
9640
|
-
|
|
9652
|
+
if (reason) {
|
|
9653
|
+
serializeReasonCache.set(binding, reason);
|
|
9654
|
+
}
|
|
9641
9655
|
}
|
|
9642
9656
|
return reason;
|
|
9643
9657
|
}
|
|
@@ -10040,15 +10054,18 @@ var define_default = {
|
|
|
10040
10054
|
}
|
|
10041
10055
|
}
|
|
10042
10056
|
if (hasDirectReferences) {
|
|
10043
|
-
const
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10057
|
+
const bodySection = getSectionForBody(tag.get("body"));
|
|
10058
|
+
if (bodySection) {
|
|
10059
|
+
const signal = getSignal(bodySection, void 0);
|
|
10060
|
+
signal.build = () => {
|
|
10061
|
+
if (signalHasStatements(signal)) {
|
|
10062
|
+
return callRuntime("_child_setup", getSignalFn(signal));
|
|
10063
|
+
}
|
|
10064
|
+
};
|
|
10065
|
+
if (allDirectReferences) {
|
|
10066
|
+
tag.remove();
|
|
10067
|
+
return;
|
|
10047
10068
|
}
|
|
10048
|
-
};
|
|
10049
|
-
if (allDirectReferences) {
|
|
10050
|
-
tag.remove();
|
|
10051
|
-
return;
|
|
10052
10069
|
}
|
|
10053
10070
|
}
|
|
10054
10071
|
}
|
|
@@ -3,4 +3,4 @@ import { type Binding, type ReferencedBindings } from "./references";
|
|
|
3
3
|
import type { Section } from "./sections";
|
|
4
4
|
export declare function createScopeReadPattern(section: Section, referencedBindings: ReferencedBindings): t.ObjectPattern;
|
|
5
5
|
export declare function getScopeExpression(section: Section, targetSection: Section): t.Identifier | t.MemberExpression;
|
|
6
|
-
export declare function createScopeReadExpression(reference: Binding, section?: Section
|
|
6
|
+
export declare function createScopeReadExpression(reference: Binding, section?: Section): t.MemberExpression;
|
|
@@ -3,7 +3,7 @@ import { type AccessorPrefix, AccessorProp } from "../../common/types";
|
|
|
3
3
|
import { type Opt } from "./optional";
|
|
4
4
|
import { type Binding, type ReferencedBindings } from "./references";
|
|
5
5
|
import { type Section } from "./sections";
|
|
6
|
-
export
|
|
6
|
+
export interface Signal {
|
|
7
7
|
identifier: t.Identifier;
|
|
8
8
|
referencedBindings: ReferencedBindings;
|
|
9
9
|
section: Section;
|
|
@@ -18,13 +18,13 @@ export type Signal = {
|
|
|
18
18
|
renderReferencedBindings: ReferencedBindings;
|
|
19
19
|
effect: t.Statement[];
|
|
20
20
|
effectReferencedBindings: ReferencedBindings;
|
|
21
|
-
hasDynamicSubscribers
|
|
22
|
-
hasSideEffect
|
|
21
|
+
hasDynamicSubscribers: boolean;
|
|
22
|
+
hasSideEffect: boolean;
|
|
23
23
|
export: boolean;
|
|
24
|
-
extraArgs
|
|
25
|
-
prependStatements
|
|
26
|
-
buildAssignment
|
|
27
|
-
}
|
|
24
|
+
extraArgs: t.Expression[] | undefined;
|
|
25
|
+
prependStatements: t.Statement[] | undefined;
|
|
26
|
+
buildAssignment: ((valueSection: Section, value: t.Expression) => t.Expression | undefined) | undefined;
|
|
27
|
+
}
|
|
28
28
|
type closureSignalBuilder = (closure: Binding, render: t.Expression) => t.Expression;
|
|
29
29
|
export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
|
|
30
30
|
export declare const getTryHasPlaceholder: (section: Section) => true | undefined, setTryHasPlaceholder: (section: Section, value: true | undefined) => void;
|