marko 6.0.14 → 6.0.16
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/dom.js +194 -189
- package/dist/debug/dom.mjs +194 -189
- package/dist/debug/html.js +47 -169
- package/dist/debug/html.mjs +47 -165
- package/dist/dom/renderer.d.ts +9 -11
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +140 -138
- package/dist/dom.mjs +140 -138
- package/dist/html/writer.d.ts +4 -8
- package/dist/html.d.ts +1 -1
- package/dist/html.js +30 -134
- package/dist/html.mjs +30 -130
- package/dist/translator/index.js +168 -100
- package/dist/translator/util/references.d.ts +3 -2
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/signals.d.ts +2 -1
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -1987,6 +1987,7 @@ function startSection(path5) {
|
|
1987
1987
|
parent: parentSection,
|
1988
1988
|
sectionAccessor: void 0,
|
1989
1989
|
params: void 0,
|
1990
|
+
referencedLocalClosures: void 0,
|
1990
1991
|
referencedClosures: void 0,
|
1991
1992
|
referencedHoists: void 0,
|
1992
1993
|
bindings: void 0,
|
@@ -2008,7 +2009,7 @@ function getOrCreateSection(path5) {
|
|
2008
2009
|
let cur = path5;
|
2009
2010
|
while (true) {
|
2010
2011
|
if (cur.type === "Program" || cur.type === "MarkoTagBody" && !cur.node.attributeTags && !isNativeNode(cur.parentPath)) {
|
2011
|
-
return startSection(cur);
|
2012
|
+
return (path5.node.extra ??= {}).section = startSection(cur);
|
2012
2013
|
}
|
2013
2014
|
cur = cur.parentPath;
|
2014
2015
|
}
|
@@ -3048,9 +3049,6 @@ function getHoistFunctionIdentifier(hoistedBinding) {
|
|
3048
3049
|
}
|
3049
3050
|
return identifier;
|
3050
3051
|
}
|
3051
|
-
var unimplementedBuild = () => {
|
3052
|
-
return import_compiler20.types.stringLiteral("SIGNAL NOT INITIALIZED");
|
3053
|
-
};
|
3054
3052
|
function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
|
3055
3053
|
const signals = getSignals(section);
|
3056
3054
|
let signal = signals.get(referencedBindings);
|
@@ -3069,7 +3067,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3069
3067
|
effect: [],
|
3070
3068
|
effectReferencedBindings: void 0,
|
3071
3069
|
subscribers: [],
|
3072
|
-
build:
|
3070
|
+
build: void 0,
|
3073
3071
|
export: !!exportName
|
3074
3072
|
}
|
3075
3073
|
);
|
@@ -3113,7 +3111,7 @@ function initValue(binding, runtimeHelper = "value") {
|
|
3113
3111
|
const signal = getSignal(section, binding);
|
3114
3112
|
signal.build = () => {
|
3115
3113
|
const fn = getSignalFn(signal);
|
3116
|
-
const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 2 /* input */);
|
3114
|
+
const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 4 /* local */ || binding.type === 2 /* input */);
|
3117
3115
|
const isNakedAlias = binding.upstreamAlias && !binding.property;
|
3118
3116
|
const needsGuard = !isNakedAlias && (binding.closureSections || binding.downstreamExpressions.size || fn.type === "ArrowFunctionExpression" && fn.body.body.length > 0);
|
3119
3117
|
const needsCache = needsGuard || signal.intersection;
|
@@ -3208,7 +3206,7 @@ function getSignalFn(signal) {
|
|
3208
3206
|
)
|
3209
3207
|
);
|
3210
3208
|
});
|
3211
|
-
if (isValue && binding.sources) {
|
3209
|
+
if (isValue && binding.sources && binding.type !== 4 /* local */) {
|
3212
3210
|
let dynamicClosureArgs;
|
3213
3211
|
let dynamicClosureSignalIdentifier;
|
3214
3212
|
if (binding.sources) {
|
@@ -3286,6 +3284,9 @@ function getSignalFn(signal) {
|
|
3286
3284
|
}
|
3287
3285
|
}
|
3288
3286
|
if (i === -1) {
|
3287
|
+
if (expression.callee.type === "MemberExpression" && expression.callee.property.type === "Identifier" && expression.callee.property.name === "_") {
|
3288
|
+
return expression.callee.object;
|
3289
|
+
}
|
3289
3290
|
return expression.callee;
|
3290
3291
|
}
|
3291
3292
|
}
|
@@ -3441,7 +3442,7 @@ function writeSignals(section) {
|
|
3441
3442
|
writeSignal(signal);
|
3442
3443
|
}
|
3443
3444
|
function writeSignal(signal) {
|
3444
|
-
if (seen.has(signal)) return;
|
3445
|
+
if (!signal.build || seen.has(signal)) return;
|
3445
3446
|
seen.add(signal);
|
3446
3447
|
for (const value2 of signal.values) {
|
3447
3448
|
writeSignal(value2.signal);
|
@@ -3740,11 +3741,13 @@ function writeHTMLResumeStatements(path5) {
|
|
3740
3741
|
);
|
3741
3742
|
}
|
3742
3743
|
}
|
3744
|
+
const debug = !isOptimize();
|
3745
|
+
const writeScopeBuilder = getSectionWriteScopeBuilder(section);
|
3743
3746
|
const serializedLookup = getSerializedAccessors(section);
|
3744
3747
|
const serializedProperties = [];
|
3745
3748
|
const sectionSerializeReason = nonAnalyzedForceSerializedSection.has(section) ? true : section.serializeReason;
|
3746
|
-
|
3747
|
-
|
3749
|
+
let debugVars;
|
3750
|
+
const writeSerializedBinding = (binding) => {
|
3748
3751
|
const reason = getBindingSerializeReason(section, binding);
|
3749
3752
|
if (!reason) return;
|
3750
3753
|
const accessor = getScopeAccessor(binding);
|
@@ -3755,7 +3758,25 @@ function writeHTMLResumeStatements(path5) {
|
|
3755
3758
|
sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSources(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(reason, getDeclaredBindingExpression(binding))
|
3756
3759
|
)
|
3757
3760
|
);
|
3761
|
+
if (debug) {
|
3762
|
+
const { root, access } = getDebugScopeAccess(binding);
|
3763
|
+
const locExpr = root.loc && import_compiler20.types.stringLiteral(`${root.loc.start.line}:${root.loc.start.column + 1}`);
|
3764
|
+
(debugVars ||= []).push(
|
3765
|
+
toObjectProperty(
|
3766
|
+
getScopeAccessor(binding),
|
3767
|
+
root !== binding ? import_compiler20.types.arrayExpression(
|
3768
|
+
locExpr ? [import_compiler20.types.stringLiteral(root.name + access), locExpr] : [import_compiler20.types.stringLiteral(root.name + access)]
|
3769
|
+
) : locExpr || import_compiler20.types.numericLiteral(0)
|
3770
|
+
)
|
3771
|
+
);
|
3772
|
+
}
|
3773
|
+
};
|
3774
|
+
forEach(section.bindings, (binding) => {
|
3775
|
+
if (binding.type !== 0 /* dom */ && binding.type !== 4 /* local */) {
|
3776
|
+
writeSerializedBinding(binding);
|
3777
|
+
}
|
3758
3778
|
});
|
3779
|
+
forEach(section.referencedLocalClosures, writeSerializedBinding);
|
3759
3780
|
if (section.parent) {
|
3760
3781
|
const ownerAccessor = getAccessorProp().Owner;
|
3761
3782
|
const ownerReason = getSectionSerializeReason(section, ownerAccessor);
|
@@ -3778,7 +3799,6 @@ function writeHTMLResumeStatements(path5) {
|
|
3778
3799
|
toObjectProperty(key, getExprIfSerialized(reason, expression))
|
3779
3800
|
);
|
3780
3801
|
}
|
3781
|
-
const writeScopeBuilder = getSectionWriteScopeBuilder(section);
|
3782
3802
|
if (sectionSerializeReason) {
|
3783
3803
|
for (const prop of serializedProperties) {
|
3784
3804
|
if (prop.key.type === "Identifier" && prop.value.type === "Identifier" && prop.key.name === prop.value.name) {
|
@@ -3789,25 +3809,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3789
3809
|
scopeIdIdentifier,
|
3790
3810
|
import_compiler20.types.objectExpression(serializedProperties)
|
3791
3811
|
];
|
3792
|
-
if (
|
3793
|
-
let debugVars;
|
3794
|
-
forEach(section.bindings, (binding) => {
|
3795
|
-
if (binding.type === 0 /* dom */) return;
|
3796
|
-
const serializeReason = getBindingSerializeReason(section, binding);
|
3797
|
-
if (!serializeReason) return;
|
3798
|
-
const { root, access } = getDebugScopeAccess(binding);
|
3799
|
-
const locExpr = root.loc && import_compiler20.types.stringLiteral(
|
3800
|
-
`${root.loc.start.line}:${root.loc.start.column + 1}`
|
3801
|
-
);
|
3802
|
-
(debugVars ||= []).push(
|
3803
|
-
toObjectProperty(
|
3804
|
-
getScopeAccessor(binding),
|
3805
|
-
root !== binding ? import_compiler20.types.arrayExpression(
|
3806
|
-
locExpr ? [import_compiler20.types.stringLiteral(root.name + access), locExpr] : [import_compiler20.types.stringLiteral(root.name + access)]
|
3807
|
-
) : locExpr || import_compiler20.types.numericLiteral(0)
|
3808
|
-
)
|
3809
|
-
);
|
3810
|
-
});
|
3812
|
+
if (debug) {
|
3811
3813
|
writeScopeArgs.push(
|
3812
3814
|
import_compiler20.types.stringLiteral(path5.hub.file.opts.filenameRelative),
|
3813
3815
|
section.loc && section.loc.start.line != null ? import_compiler20.types.stringLiteral(
|
@@ -4037,34 +4039,33 @@ var dom_default = {
|
|
4037
4039
|
}
|
4038
4040
|
forEachSectionReverse((childSection) => {
|
4039
4041
|
if (childSection !== section) {
|
4042
|
+
forEach(childSection.referencedClosures, (closure) => {
|
4043
|
+
const closureSignal = getSignal(childSection, closure);
|
4044
|
+
addStatement(
|
4045
|
+
"render",
|
4046
|
+
childSection,
|
4047
|
+
void 0,
|
4048
|
+
import_compiler21.types.expressionStatement(
|
4049
|
+
import_compiler21.types.callExpression(
|
4050
|
+
isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler21.types.memberExpression(
|
4051
|
+
closureSignal.identifier,
|
4052
|
+
import_compiler21.types.identifier(getAccessorProp().Owner)
|
4053
|
+
),
|
4054
|
+
[scopeIdentifier]
|
4055
|
+
)
|
4056
|
+
)
|
4057
|
+
);
|
4058
|
+
});
|
4040
4059
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
4041
4060
|
const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
|
4042
4061
|
const identifier = import_compiler21.types.identifier(childSection.name);
|
4043
|
-
|
4044
|
-
[scopeIdentifier],
|
4045
|
-
toFirstExpressionOrBlock(
|
4046
|
-
toArray(childSection.referencedClosures, (closure) => {
|
4047
|
-
const closureSignal = getSignal(childSection, closure);
|
4048
|
-
return import_compiler21.types.expressionStatement(
|
4049
|
-
import_compiler21.types.callExpression(
|
4050
|
-
isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler21.types.memberExpression(
|
4051
|
-
closureSignal.identifier,
|
4052
|
-
import_compiler21.types.identifier(getAccessorProp().Owner)
|
4053
|
-
),
|
4054
|
-
[scopeIdentifier]
|
4055
|
-
)
|
4056
|
-
);
|
4057
|
-
})
|
4058
|
-
)
|
4059
|
-
) : getSignal(childSection, childSection.referencedClosures).identifier : void 0;
|
4060
|
-
const renderer = getSectionParentIsOwner(childSection) ? callRuntime(
|
4062
|
+
let renderer = getSectionParentIsOwner(childSection) ? callRuntime(
|
4061
4063
|
"createRenderer",
|
4062
4064
|
...replaceNullishAndEmptyFunctionsWith0([
|
4063
4065
|
writes2,
|
4064
4066
|
walks2,
|
4065
4067
|
setup2,
|
4066
|
-
tagParamsSignal?.identifier
|
4067
|
-
referencedClosures
|
4068
|
+
tagParamsSignal?.identifier
|
4068
4069
|
])
|
4069
4070
|
) : callRuntime(
|
4070
4071
|
isSerializedSection(childSection) ? "registerContent" : "createContent",
|
@@ -4074,10 +4075,30 @@ var dom_default = {
|
|
4074
4075
|
walks2,
|
4075
4076
|
setup2,
|
4076
4077
|
tagParamsSignal?.identifier,
|
4077
|
-
referencedClosures,
|
4078
4078
|
childSection.hoisted || childSection.isHoistThrough ? getSectionInstancesAccessorLiteral(childSection) : void 0
|
4079
4079
|
])
|
4080
4080
|
);
|
4081
|
+
if (childSection.referencedLocalClosures) {
|
4082
|
+
renderer = callRuntime(
|
4083
|
+
"localClosures",
|
4084
|
+
renderer,
|
4085
|
+
import_compiler21.types.objectExpression(
|
4086
|
+
toArray(childSection.referencedLocalClosures, (closure) => {
|
4087
|
+
const expr = getSignalFn(getSignal(childSection, closure));
|
4088
|
+
const key = toPropertyName(getScopeAccessor(closure));
|
4089
|
+
if (import_compiler21.types.isFunction(expr) && import_compiler21.types.isBlockStatement(expr.body)) {
|
4090
|
+
return import_compiler21.types.objectMethod(
|
4091
|
+
"method",
|
4092
|
+
key,
|
4093
|
+
expr.params,
|
4094
|
+
expr.body
|
4095
|
+
);
|
4096
|
+
}
|
4097
|
+
return import_compiler21.types.objectProperty(key, expr);
|
4098
|
+
})
|
4099
|
+
)
|
4100
|
+
);
|
4101
|
+
}
|
4081
4102
|
writeSignals(childSection);
|
4082
4103
|
program.node.body.push(
|
4083
4104
|
import_compiler21.types.variableDeclaration("const", [
|
@@ -4272,7 +4293,7 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
4272
4293
|
const propertyKey = getScopeAccessor(ref);
|
4273
4294
|
const isShorthand = propertyKey === propertyValue;
|
4274
4295
|
let pattern = rootPattern;
|
4275
|
-
if (ref.section !== section) {
|
4296
|
+
if (ref.section !== section && ref.type !== 4 /* local */) {
|
4276
4297
|
if (!nestedPatterns) nestedPatterns = [rootPattern];
|
4277
4298
|
const relativeDepth = rootDepth - ref.section.depth;
|
4278
4299
|
let i = nestedPatterns.length;
|
@@ -4443,7 +4464,7 @@ function trackHoistedReference(referencePath, binding) {
|
|
4443
4464
|
hoistSection,
|
4444
4465
|
hoistedBinding = createBinding(
|
4445
4466
|
generateUid("hoisted_" + referencePath.node.name),
|
4446
|
-
|
4467
|
+
6 /* hoist */,
|
4447
4468
|
hoistSection,
|
4448
4469
|
void 0,
|
4449
4470
|
void 0,
|
@@ -4769,16 +4790,23 @@ function finalizeReferences() {
|
|
4769
4790
|
canonicalUpstreamAlias.closureSections,
|
4770
4791
|
section2
|
4771
4792
|
);
|
4772
|
-
|
4773
|
-
section2.
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4793
|
+
if (binding.type === 4 /* local */) {
|
4794
|
+
section2.referencedLocalClosures = bindingUtil.add(
|
4795
|
+
section2.referencedLocalClosures,
|
4796
|
+
binding
|
4797
|
+
);
|
4798
|
+
} else {
|
4799
|
+
section2.referencedClosures = bindingUtil.add(
|
4800
|
+
section2.referencedClosures,
|
4801
|
+
binding
|
4802
|
+
);
|
4803
|
+
addOwnersSerializeReason(
|
4804
|
+
section2,
|
4805
|
+
canonicalUpstreamAlias.section,
|
4806
|
+
!!isEffect || canonicalUpstreamAlias.sources,
|
4807
|
+
getAccessorProp().Owner
|
4808
|
+
);
|
4809
|
+
}
|
4782
4810
|
}
|
4783
4811
|
if (isEffect) {
|
4784
4812
|
forEach(
|
@@ -4871,6 +4899,32 @@ function finalizeReferences() {
|
|
4871
4899
|
}
|
4872
4900
|
}
|
4873
4901
|
}
|
4902
|
+
forEach(section.referencedLocalClosures, (closure) => {
|
4903
|
+
if (!isBindingForceSerialized(section, closure)) {
|
4904
|
+
const sourceSection = closure.section;
|
4905
|
+
let serializeReason;
|
4906
|
+
let currentSection = section;
|
4907
|
+
while (currentSection !== sourceSection) {
|
4908
|
+
const upstreamReason = !currentSection.upstreamExpression || getSerializeSourcesForExpr(currentSection.upstreamExpression);
|
4909
|
+
if (upstreamReason === true) {
|
4910
|
+
serializeReason = true;
|
4911
|
+
break;
|
4912
|
+
}
|
4913
|
+
serializeReason = mergeSerializeReasons(
|
4914
|
+
serializeReason,
|
4915
|
+
upstreamReason
|
4916
|
+
);
|
4917
|
+
currentSection = currentSection.parent;
|
4918
|
+
}
|
4919
|
+
addBindingSerializeReason(section, closure, serializeReason);
|
4920
|
+
}
|
4921
|
+
if (closure.sources) {
|
4922
|
+
addSectionSerializeReason(
|
4923
|
+
section,
|
4924
|
+
getBindingSerializeReason(section, closure)
|
4925
|
+
);
|
4926
|
+
}
|
4927
|
+
});
|
4874
4928
|
forEach(section.referencedClosures, (closure) => {
|
4875
4929
|
if (!isBindingForceSerialized(closure.section, closure)) {
|
4876
4930
|
const sourceSection = closure.section;
|
@@ -5187,7 +5241,7 @@ function getReadReplacement(node) {
|
|
5187
5241
|
}
|
5188
5242
|
if (binding) {
|
5189
5243
|
if (node.type === "Identifier") {
|
5190
|
-
if (binding.type ===
|
5244
|
+
if (binding.type === 6 /* hoist */) {
|
5191
5245
|
replacement = node.extra?.[kIsInvoked] ? import_compiler24.types.callExpression(getHoistFunctionIdentifier(binding), [
|
5192
5246
|
getScopeExpression(node.extra.section, binding.section)
|
5193
5247
|
]) : import_compiler24.types.identifier(getScopeAccessor(binding));
|
@@ -5523,7 +5577,7 @@ var const_default = {
|
|
5523
5577
|
if (upstreamAlias) {
|
5524
5578
|
valueExtra.pruned = true;
|
5525
5579
|
}
|
5526
|
-
const binding = trackVarReferences(tag,
|
5580
|
+
const binding = trackVarReferences(tag, 5 /* derived */, upstreamAlias);
|
5527
5581
|
if (binding) {
|
5528
5582
|
if (!valueExtra.nullable) binding.nullable = false;
|
5529
5583
|
setBindingValueExpr(binding, valueExtra);
|
@@ -6617,7 +6671,13 @@ function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
|
|
6617
6671
|
// src/translator/core/for.ts
|
6618
6672
|
var for_default = {
|
6619
6673
|
analyze(tag) {
|
6674
|
+
const tagSection = getOrCreateSection(tag);
|
6620
6675
|
const isAttrTag = tag.node.body.attributeTags;
|
6676
|
+
const tagBody = tag.get("body");
|
6677
|
+
const paramsBinding = trackParamsReferences(
|
6678
|
+
tagBody,
|
6679
|
+
isAttrTag ? 4 /* local */ : 3 /* param */
|
6680
|
+
);
|
6621
6681
|
let allowAttrs;
|
6622
6682
|
(0, import_babel_utils25.assertNoVar)(tag);
|
6623
6683
|
(0, import_babel_utils25.assertNoArgs)(tag);
|
@@ -6642,15 +6702,12 @@ var for_default = {
|
|
6642
6702
|
}
|
6643
6703
|
(0, import_babel_utils25.assertAllowedAttributes)(tag, allowAttrs);
|
6644
6704
|
if (isAttrTag) return;
|
6645
|
-
const tagBody = tag.get("body");
|
6646
6705
|
const bodySection = startSection(tagBody);
|
6647
6706
|
if (!bodySection) {
|
6648
6707
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
6649
6708
|
return;
|
6650
6709
|
}
|
6651
|
-
const tagSection = getOrCreateSection(tag);
|
6652
6710
|
const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
|
6653
|
-
const paramsBinding = trackParamsReferences(tagBody, 3 /* param */);
|
6654
6711
|
const tagExtra = mergeReferences(
|
6655
6712
|
tagSection,
|
6656
6713
|
tag.node,
|
@@ -6708,7 +6765,7 @@ var for_default = {
|
|
6708
6765
|
flushInto(tag);
|
6709
6766
|
writeHTMLResumeStatements(tagBody);
|
6710
6767
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
6711
|
-
const forTagHTMLRuntime = branchSerializeReason ? forTypeToHTMLResumeRuntime(forType
|
6768
|
+
const forTagHTMLRuntime = branchSerializeReason ? forTypeToHTMLResumeRuntime(forType) : forTypeToRuntime(forType);
|
6712
6769
|
forTagArgs.push(
|
6713
6770
|
import_compiler33.types.arrowFunctionExpression(params, import_compiler33.types.blockStatement(bodyStatements))
|
6714
6771
|
);
|
@@ -6716,7 +6773,7 @@ var for_default = {
|
|
6716
6773
|
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
6717
6774
|
const markerSerializeArg = getSerializeGuard(
|
6718
6775
|
markerSerializeReason,
|
6719
|
-
!skipParentEnd
|
6776
|
+
!(skipParentEnd || singleNodeOptimization)
|
6720
6777
|
);
|
6721
6778
|
forTagArgs.push(
|
6722
6779
|
forAttrs.by || import_compiler33.types.numericLiteral(0),
|
@@ -6729,6 +6786,12 @@ var for_default = {
|
|
6729
6786
|
getParentTag(tag).node.extra[kSkipEndTag] = true;
|
6730
6787
|
forTagArgs.push(import_compiler33.types.stringLiteral(`</${onlyChildParentTagName}>`));
|
6731
6788
|
}
|
6789
|
+
if (singleNodeOptimization) {
|
6790
|
+
if (!skipParentEnd) {
|
6791
|
+
forTagArgs.push(import_compiler33.types.numericLiteral(0));
|
6792
|
+
}
|
6793
|
+
forTagArgs.push(import_compiler33.types.numericLiteral(1));
|
6794
|
+
}
|
6732
6795
|
}
|
6733
6796
|
statements.push(
|
6734
6797
|
import_compiler33.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
@@ -6884,25 +6947,14 @@ function forTypeToRuntime(type) {
|
|
6884
6947
|
return "forTo";
|
6885
6948
|
}
|
6886
6949
|
}
|
6887
|
-
function forTypeToHTMLResumeRuntime(type
|
6888
|
-
|
6889
|
-
|
6890
|
-
|
6891
|
-
|
6892
|
-
|
6893
|
-
|
6894
|
-
|
6895
|
-
return "resumeSingleNodeForTo";
|
6896
|
-
}
|
6897
|
-
} else {
|
6898
|
-
switch (type) {
|
6899
|
-
case "of":
|
6900
|
-
return "resumeForOf";
|
6901
|
-
case "in":
|
6902
|
-
return "resumeForIn";
|
6903
|
-
case "to":
|
6904
|
-
return "resumeForTo";
|
6905
|
-
}
|
6950
|
+
function forTypeToHTMLResumeRuntime(type) {
|
6951
|
+
switch (type) {
|
6952
|
+
case "of":
|
6953
|
+
return "resumeForOf";
|
6954
|
+
case "in":
|
6955
|
+
return "resumeForIn";
|
6956
|
+
case "to":
|
6957
|
+
return "resumeForTo";
|
6906
6958
|
}
|
6907
6959
|
}
|
6908
6960
|
function forTypeToDOMRuntime(type) {
|
@@ -7255,9 +7307,24 @@ function buildContent(body) {
|
|
7255
7307
|
) : void 0
|
7256
7308
|
);
|
7257
7309
|
} else {
|
7258
|
-
return import_compiler34.types.callExpression(
|
7259
|
-
|
7260
|
-
|
7310
|
+
return import_compiler34.types.callExpression(
|
7311
|
+
import_compiler34.types.identifier(bodySection.name),
|
7312
|
+
bodySection.referencedLocalClosures ? [
|
7313
|
+
scopeIdentifier,
|
7314
|
+
import_compiler34.types.objectExpression(
|
7315
|
+
toArray(bodySection.referencedLocalClosures, (ref) => {
|
7316
|
+
const accessor = getScopeAccessor(ref);
|
7317
|
+
const isShorthand = accessor === ref.name;
|
7318
|
+
return import_compiler34.types.objectProperty(
|
7319
|
+
toPropertyName(accessor),
|
7320
|
+
import_compiler34.types.identifier(ref.name),
|
7321
|
+
false,
|
7322
|
+
isShorthand
|
7323
|
+
);
|
7324
|
+
})
|
7325
|
+
)
|
7326
|
+
] : [scopeIdentifier]
|
7327
|
+
);
|
7261
7328
|
}
|
7262
7329
|
}
|
7263
7330
|
}
|
@@ -7278,7 +7345,7 @@ var define_default = {
|
|
7278
7345
|
}
|
7279
7346
|
const tagBody = tag.get("body");
|
7280
7347
|
const bodySection = startSection(tagBody);
|
7281
|
-
const varBinding = trackVarReferences(tag,
|
7348
|
+
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
7282
7349
|
if (bodySection) {
|
7283
7350
|
if (varBinding) {
|
7284
7351
|
bodySection.downstreamBinding = varBinding.propertyAliases.get("content") || varBinding;
|
@@ -8425,7 +8492,7 @@ var id_default = {
|
|
8425
8492
|
if (!import_compiler40.types.isIdentifier(node.var)) {
|
8426
8493
|
throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
|
8427
8494
|
}
|
8428
|
-
const binding = trackVarReferences(tag,
|
8495
|
+
const binding = trackVarReferences(tag, 5 /* derived */);
|
8429
8496
|
if (binding) {
|
8430
8497
|
setBindingValueExpr(binding, false);
|
8431
8498
|
}
|
@@ -8601,7 +8668,7 @@ var IfTag = {
|
|
8601
8668
|
}
|
8602
8669
|
const markerSerializeArg = getSerializeGuard(
|
8603
8670
|
markerSerializeReason,
|
8604
|
-
!skipParentEnd
|
8671
|
+
!(skipParentEnd || singleNodeOptimization)
|
8605
8672
|
);
|
8606
8673
|
const cbNode = import_compiler42.types.arrowFunctionExpression(
|
8607
8674
|
[],
|
@@ -8609,7 +8676,7 @@ var IfTag = {
|
|
8609
8676
|
);
|
8610
8677
|
statement = import_compiler42.types.expressionStatement(
|
8611
8678
|
callRuntime(
|
8612
|
-
|
8679
|
+
"resumeConditional",
|
8613
8680
|
cbNode,
|
8614
8681
|
getScopeIdIdentifier(ifTagSection),
|
8615
8682
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -8618,7 +8685,8 @@ var IfTag = {
|
|
8618
8685
|
!markerSerializeArg
|
8619
8686
|
),
|
8620
8687
|
markerSerializeArg,
|
8621
|
-
skipParentEnd
|
8688
|
+
skipParentEnd ? import_compiler42.types.stringLiteral(`</${onlyChildParentTagName}>`) : singleNodeOptimization ? import_compiler42.types.numericLiteral(0) : void 0,
|
8689
|
+
singleNodeOptimization ? import_compiler42.types.numericLiteral(1) : void 0
|
8622
8690
|
)
|
8623
8691
|
);
|
8624
8692
|
}
|
@@ -8963,7 +9031,7 @@ var lifecycle_default = {
|
|
8963
9031
|
);
|
8964
9032
|
tagExtra[kRef] = createBinding(
|
8965
9033
|
generateUid("lifecycle"),
|
8966
|
-
|
9034
|
+
5 /* derived */,
|
8967
9035
|
section
|
8968
9036
|
);
|
8969
9037
|
if (node.attributes.length === 0) {
|
@@ -10018,7 +10086,7 @@ var custom_tag_default = {
|
|
10018
10086
|
if (!childFile) {
|
10019
10087
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
10020
10088
|
}
|
10021
|
-
const varBinding = trackVarReferences(tag,
|
10089
|
+
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
10022
10090
|
if (varBinding) {
|
10023
10091
|
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding("#scopeOffset", 0 /* dom */, section);
|
10024
10092
|
}
|
@@ -10819,7 +10887,7 @@ var dynamic_tag_default = {
|
|
10819
10887
|
tagSection
|
10820
10888
|
);
|
10821
10889
|
if (hasVar) {
|
10822
|
-
trackVarReferences(tag,
|
10890
|
+
trackVarReferences(tag, 5 /* derived */);
|
10823
10891
|
tag.node.var.extra.binding.scopeOffset = tagExtra[kChildOffsetScopeBinding2] = createBinding("#scopeOffset", 0 /* dom */, tagSection);
|
10824
10892
|
}
|
10825
10893
|
startSection(tagBody);
|
@@ -21,6 +21,7 @@ export interface Section {
|
|
21
21
|
prefix: AccessorPrefix;
|
22
22
|
} | undefined;
|
23
23
|
params: undefined | Binding;
|
24
|
+
referencedLocalClosures: ReferencedBindings;
|
24
25
|
referencedClosures: ReferencedBindings;
|
25
26
|
referencedHoists: ReferencedBindings;
|
26
27
|
bindings: ReferencedBindings;
|
@@ -8,7 +8,7 @@ export type Signal = {
|
|
8
8
|
valueAccessor?: t.Expression;
|
9
9
|
referencedBindings: ReferencedBindings;
|
10
10
|
section: Section;
|
11
|
-
build: () => t.Expression;
|
11
|
+
build: undefined | (() => t.Expression);
|
12
12
|
register?: boolean;
|
13
13
|
values: Array<{
|
14
14
|
signal: Signal;
|
@@ -34,6 +34,7 @@ export declare const getHTMLSectionStatements: (section: Section) => t.Statement
|
|
34
34
|
export declare function getHoistFunctionIdentifier(hoistedBinding: Binding): t.Identifier;
|
35
35
|
export declare function getSignal(section: Section, referencedBindings: ReferencedBindings, name?: string): Signal;
|
36
36
|
export declare function initValue(binding: Binding, runtimeHelper?: "value" | "state"): Signal;
|
37
|
+
export declare function getSignalFn(signal: Signal): t.Expression;
|
37
38
|
export declare function subscribe(provider: ReferencedBindings, subscriber: Signal): void;
|
38
39
|
export declare function replaceNullishAndEmptyFunctionsWith0(args: (t.Expression | undefined | false)[]): t.Expression[];
|
39
40
|
export declare function addStatement(type: "render" | "effect", targetSection: Section, referencedBindings: ReferencedBindings, statement: t.Statement | t.Statement[], usedReferences?: ReferencedBindings[] | false): void;
|