marko 6.0.0-next.3.22 → 6.0.0-next.3.23
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/common/for.d.ts +3 -4
- package/dist/common/types.d.ts +18 -17
- package/dist/debug/dom.js +696 -740
- package/dist/debug/dom.mjs +696 -740
- package/dist/debug/html.js +256 -99
- package/dist/debug/html.mjs +247 -95
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/compat.d.ts +1 -0
- package/dist/dom/control-flow.d.ts +6 -8
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/reconcile.d.ts +2 -2
- package/dist/dom/renderer.d.ts +7 -8
- package/dist/dom/resume.d.ts +3 -3
- package/dist/dom/scope.d.ts +4 -4
- package/dist/dom/signals.d.ts +13 -26
- package/dist/dom/template.d.ts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +441 -482
- package/dist/dom.mjs +441 -482
- package/dist/html/dynamic-tag.d.ts +3 -3
- package/dist/html/writer.d.ts +12 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +202 -65
- package/dist/html.mjs +193 -61
- package/dist/translator/core/for.d.ts +0 -2
- package/dist/translator/index.js +189 -224
- package/dist/translator/util/runtime.d.ts +1 -2
- package/dist/translator/util/sections.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +2 -2
- package/package.json +2 -2
- package/tags-html.d.ts +152 -152
package/dist/translator/index.js
CHANGED
@@ -546,6 +546,7 @@ var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
|
546
546
|
// src/html/writer.ts
|
547
547
|
var K_SCOPE_ID = Symbol("Scope ID");
|
548
548
|
var kPendingContexts = Symbol("Pending Contexts");
|
549
|
+
var branchIdKey = Symbol();
|
549
550
|
var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb));
|
550
551
|
|
551
552
|
// src/html/attrs.ts
|
@@ -626,7 +627,8 @@ var pureFunctions = [
|
|
626
627
|
"value",
|
627
628
|
"state",
|
628
629
|
"intersection",
|
629
|
-
"
|
630
|
+
"loopClosure",
|
631
|
+
"conditionalClosure",
|
630
632
|
"dynamicClosure",
|
631
633
|
"loopOf",
|
632
634
|
"loopIn",
|
@@ -857,9 +859,6 @@ function find(data, cb) {
|
|
857
859
|
}
|
858
860
|
}
|
859
861
|
}
|
860
|
-
function map(data, cb) {
|
861
|
-
return data ? Array.isArray(data) ? data.map(cb) : [cb(data, 0)] : [];
|
862
|
-
}
|
863
862
|
function findSorted(compare, data, item) {
|
864
863
|
let max = data.length;
|
865
864
|
let pos = 0;
|
@@ -936,17 +935,17 @@ function joinRepeatable(compare, a, b) {
|
|
936
935
|
|
937
936
|
// src/translator/util/state.ts
|
938
937
|
var createProgramState = (init) => {
|
939
|
-
const
|
938
|
+
const map = /* @__PURE__ */ new WeakMap();
|
940
939
|
return [
|
941
940
|
() => {
|
942
|
-
let state =
|
941
|
+
let state = map.get(currentProgramPath);
|
943
942
|
if (!state) {
|
944
|
-
|
943
|
+
map.set(currentProgramPath, state = init());
|
945
944
|
}
|
946
945
|
return state;
|
947
946
|
},
|
948
947
|
(value) => {
|
949
|
-
|
948
|
+
map.set(currentProgramPath, value);
|
950
949
|
}
|
951
950
|
];
|
952
951
|
};
|
@@ -1124,7 +1123,8 @@ function startSection(path5) {
|
|
1124
1123
|
bindings: void 0,
|
1125
1124
|
content: getContentInfo(path5),
|
1126
1125
|
upstreamExpression: void 0,
|
1127
|
-
|
1126
|
+
hasAbortSignal: false,
|
1127
|
+
isBranch: false
|
1128
1128
|
};
|
1129
1129
|
sections.push(section);
|
1130
1130
|
}
|
@@ -1963,9 +1963,9 @@ var [getSignals] = createSectionState(
|
|
1963
1963
|
"signals",
|
1964
1964
|
() => /* @__PURE__ */ new Map()
|
1965
1965
|
);
|
1966
|
-
var [
|
1967
|
-
function
|
1968
|
-
|
1966
|
+
var [getClosureSignalBuilder, _setClosureSignalBuilder] = createSectionState("queue");
|
1967
|
+
function setClosureSignalBuilder(tag, builder) {
|
1968
|
+
_setClosureSignalBuilder(getSectionForBody(tag.get("body")), builder);
|
1969
1969
|
}
|
1970
1970
|
var [forceResumeScope, _setForceResumeScope] = createSectionState("forceResumeScope");
|
1971
1971
|
function setForceResumeScope(section) {
|
@@ -1997,7 +1997,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
1997
1997
|
subscribers: [],
|
1998
1998
|
closures: /* @__PURE__ */ new Map(),
|
1999
1999
|
hasDownstreamIntersections: () => {
|
2000
|
-
let hasDownstreamIntersections = !!
|
2000
|
+
let hasDownstreamIntersections = !!signal.intersection;
|
2001
2001
|
if (!hasDownstreamIntersections) {
|
2002
2002
|
for (const value of signal.values) {
|
2003
2003
|
if (value.signal.hasDownstreamIntersections()) {
|
@@ -2051,24 +2051,41 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2051
2051
|
signal
|
2052
2052
|
);
|
2053
2053
|
signal.build = () => {
|
2054
|
-
const builder =
|
2054
|
+
const builder = getClosureSignalBuilder(section);
|
2055
2055
|
const ownerScope = getScopeExpression(
|
2056
2056
|
section,
|
2057
2057
|
referencedBindings.section
|
2058
2058
|
);
|
2059
2059
|
const isImmediateOwner = ownerScope.object === scopeIdentifier;
|
2060
|
-
const isDynamicClosure =
|
2061
|
-
|
2062
|
-
|
2060
|
+
const isDynamicClosure = !isImmediateOwner || !builder;
|
2061
|
+
const render = getSignalFn(signal, [
|
2062
|
+
scopeIdentifier,
|
2063
|
+
import_compiler17.types.identifier(referencedBindings.name)
|
2064
|
+
]);
|
2065
|
+
signal.isDynamicClosure = isDynamicClosure;
|
2066
|
+
const intersection = buildSignalIntersections(signal);
|
2067
|
+
return isDynamicClosure ? callRuntime(
|
2068
|
+
"dynamicClosure",
|
2063
2069
|
getScopeAccessorLiteral(referencedBindings),
|
2064
|
-
|
2065
|
-
scopeIdentifier,
|
2066
|
-
import_compiler17.types.identifier(referencedBindings.name)
|
2067
|
-
]),
|
2070
|
+
render,
|
2068
2071
|
isImmediateOwner ? null : import_compiler17.types.arrowFunctionExpression([scopeIdentifier], ownerScope),
|
2069
|
-
|
2070
|
-
);
|
2072
|
+
intersection
|
2073
|
+
) : builder(signal, render, intersection);
|
2071
2074
|
};
|
2075
|
+
addStatement(
|
2076
|
+
"render",
|
2077
|
+
section,
|
2078
|
+
void 0,
|
2079
|
+
import_compiler17.types.expressionStatement(
|
2080
|
+
import_compiler17.types.callExpression(
|
2081
|
+
import_compiler17.types.memberExpression(signal.identifier, import_compiler17.types.identifier("_")),
|
2082
|
+
[
|
2083
|
+
scopeIdentifier,
|
2084
|
+
createScopeReadExpression(section, referencedBindings)
|
2085
|
+
]
|
2086
|
+
)
|
2087
|
+
)
|
2088
|
+
);
|
2072
2089
|
}
|
2073
2090
|
}
|
2074
2091
|
return signal;
|
@@ -2106,8 +2123,9 @@ function initValue(binding, runtimeHelper = "value") {
|
|
2106
2123
|
function getSignalFn(signal, params, referencedBindings) {
|
2107
2124
|
const section = signal.section;
|
2108
2125
|
const binding = signal.referencedBindings;
|
2109
|
-
|
2110
|
-
|
2126
|
+
const [scopeIdentifier2, valueIdentifier] = params;
|
2127
|
+
const isValueSignal = binding && !Array.isArray(binding) && binding.section === section;
|
2128
|
+
if (isValueSignal) {
|
2111
2129
|
for (const alias of binding.aliases) {
|
2112
2130
|
const aliasSignal = getSignal(alias.section, alias);
|
2113
2131
|
signal.render.push(
|
@@ -2144,12 +2162,29 @@ function getSignalFn(signal, params, referencedBindings) {
|
|
2144
2162
|
)
|
2145
2163
|
);
|
2146
2164
|
}
|
2165
|
+
if (isValueSignal) {
|
2166
|
+
const closureEntries = Array.from(signal.closures.entries()).sort(
|
2167
|
+
([a], [b]) => a.id - b.id
|
2168
|
+
);
|
2169
|
+
for (const [_closureSection, closureSignal] of closureEntries) {
|
2170
|
+
if (isStatefulReferences(closureSignal.referencedBindings)) {
|
2171
|
+
signal.render.push(
|
2172
|
+
import_compiler17.types.expressionStatement(
|
2173
|
+
import_compiler17.types.callExpression(closureSignal.identifier, [
|
2174
|
+
scopeIdentifier2,
|
2175
|
+
valueIdentifier
|
2176
|
+
])
|
2177
|
+
)
|
2178
|
+
);
|
2179
|
+
}
|
2180
|
+
}
|
2181
|
+
}
|
2147
2182
|
if (referencedBindings) {
|
2148
2183
|
signal.render.unshift(
|
2149
2184
|
import_compiler17.types.variableDeclaration("const", [
|
2150
2185
|
import_compiler17.types.variableDeclarator(
|
2151
2186
|
createScopeReadPattern(section, referencedBindings),
|
2152
|
-
|
2187
|
+
scopeIdentifier2
|
2153
2188
|
)
|
2154
2189
|
])
|
2155
2190
|
);
|
@@ -2169,7 +2204,6 @@ function getTranslatedExtraArgs(signal) {
|
|
2169
2204
|
return emptyExtraArgs;
|
2170
2205
|
}
|
2171
2206
|
function buildSignalIntersections(signal) {
|
2172
|
-
const section = signal.section;
|
2173
2207
|
let intersections = signal.intersection;
|
2174
2208
|
const binding = signal.referencedBindings;
|
2175
2209
|
if (binding && !Array.isArray(binding) && binding.section === signal.section) {
|
@@ -2200,24 +2234,6 @@ function buildSignalIntersections(signal) {
|
|
2200
2234
|
);
|
2201
2235
|
}
|
2202
2236
|
}
|
2203
|
-
const closureEntries = Array.from(signal.closures.entries()).sort(
|
2204
|
-
([a], [b]) => a.id - b.id
|
2205
|
-
);
|
2206
|
-
for (const [closureSection, closureSignal] of closureEntries) {
|
2207
|
-
const builder = getSubscribeBuilder(closureSection);
|
2208
|
-
const isImmediateOwner = closureSection.parent === section;
|
2209
|
-
if (builder && isImmediateOwner) {
|
2210
|
-
intersections = push(intersections, builder(closureSignal.identifier));
|
2211
|
-
} else if (!signal.hasDynamicSubscribers) {
|
2212
|
-
signal.hasDynamicSubscribers = true;
|
2213
|
-
}
|
2214
|
-
}
|
2215
|
-
if (signal.hasDynamicSubscribers) {
|
2216
|
-
intersections = push(
|
2217
|
-
intersections,
|
2218
|
-
callRuntime("dynamicSubscribers", signal.valueAccessor)
|
2219
|
-
);
|
2220
|
-
}
|
2221
2237
|
return intersections && import_compiler17.types.arrowFunctionExpression(
|
2222
2238
|
[],
|
2223
2239
|
Array.isArray(intersections) ? callRuntime("intersections", import_compiler17.types.arrayExpression(intersections)) : intersections
|
@@ -2530,7 +2546,7 @@ function writeHTMLResumeStatements(path5, tagVarIdentifier) {
|
|
2530
2546
|
}
|
2531
2547
|
setForceResumeScope(closure.section);
|
2532
2548
|
const isImmediateOwner = section.parent?.id === closure.section.id;
|
2533
|
-
const isDynamicClosure = !
|
2549
|
+
const isDynamicClosure = !getClosureSignalBuilder(section) || !isImmediateOwner;
|
2534
2550
|
if (isDynamicClosure) {
|
2535
2551
|
path5.pushContainer(
|
2536
2552
|
"body",
|
@@ -2602,6 +2618,15 @@ function writeHTMLResumeStatements(path5, tagVarIdentifier) {
|
|
2602
2618
|
)
|
2603
2619
|
);
|
2604
2620
|
}
|
2621
|
+
const resumeClosestBranch2 = !section.isBranch && (section.hasAbortSignal || !!section.closures || !!find(section.bindings, (binding) => binding.type === 1 /* let */));
|
2622
|
+
if (resumeClosestBranch2) {
|
2623
|
+
path5.pushContainer(
|
2624
|
+
"body",
|
2625
|
+
import_compiler17.types.expressionStatement(
|
2626
|
+
callRuntime("resumeClosestBranch", scopeIdIdentifier)
|
2627
|
+
)
|
2628
|
+
);
|
2629
|
+
}
|
2605
2630
|
if (path5.get("body").length) {
|
2606
2631
|
path5.unshiftContainer(
|
2607
2632
|
"body",
|
@@ -2790,7 +2815,6 @@ var dom_default = {
|
|
2790
2815
|
const templateIdentifier = import_compiler18.types.identifier(domExports.template);
|
2791
2816
|
const walksIdentifier = import_compiler18.types.identifier(domExports.walks);
|
2792
2817
|
const setupIdentifier = import_compiler18.types.identifier(domExports.setup);
|
2793
|
-
const closuresIdentifier = import_compiler18.types.identifier(domExports.closures);
|
2794
2818
|
const paramsBinding = program.node.extra.binding;
|
2795
2819
|
const programParamsSignal = paramsBinding && bindingHasDownstreamExpressions(paramsBinding) ? initValue(paramsBinding) : void 0;
|
2796
2820
|
const styleFile = getStyleFile(program.hub.file);
|
@@ -2801,14 +2825,12 @@ var dom_default = {
|
|
2801
2825
|
if (childSection !== section) {
|
2802
2826
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
2803
2827
|
const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
|
2804
|
-
const closures2 = getSectionClosuresExpr(childSection);
|
2805
2828
|
const identifier = import_compiler18.types.identifier(childSection.name);
|
2806
2829
|
const renderer = callRuntime(
|
2807
2830
|
getSectionParentIsOwner(childSection) ? "createRenderer" : "createRendererWithOwner",
|
2808
2831
|
writes2,
|
2809
2832
|
walks2,
|
2810
2833
|
setup2,
|
2811
|
-
closures2 && import_compiler18.types.arrowFunctionExpression([], closures2),
|
2812
2834
|
tagParamsSignal?.identifier && import_compiler18.types.arrowFunctionExpression([], tagParamsSignal.identifier)
|
2813
2835
|
);
|
2814
2836
|
writeSignals(childSection);
|
@@ -2828,7 +2850,6 @@ var dom_default = {
|
|
2828
2850
|
);
|
2829
2851
|
}
|
2830
2852
|
});
|
2831
|
-
const closures = getSectionClosuresExpr(section);
|
2832
2853
|
writeSignals(section);
|
2833
2854
|
writeRegisteredFns();
|
2834
2855
|
if (!setup) {
|
@@ -2858,15 +2879,6 @@ var dom_default = {
|
|
2858
2879
|
])
|
2859
2880
|
)
|
2860
2881
|
);
|
2861
|
-
if (closures) {
|
2862
|
-
program.node.body.push(
|
2863
|
-
import_compiler18.types.exportNamedDeclaration(
|
2864
|
-
import_compiler18.types.variableDeclaration("const", [
|
2865
|
-
import_compiler18.types.variableDeclarator(closuresIdentifier, closures)
|
2866
|
-
])
|
2867
|
-
)
|
2868
|
-
);
|
2869
|
-
}
|
2870
2882
|
program.node.body.push(
|
2871
2883
|
import_compiler18.types.exportDefaultDeclaration(
|
2872
2884
|
callRuntime(
|
@@ -2875,7 +2887,6 @@ var dom_default = {
|
|
2875
2887
|
templateIdentifier,
|
2876
2888
|
walksIdentifier,
|
2877
2889
|
setupIdentifier,
|
2878
|
-
closures && import_compiler18.types.arrowFunctionExpression([], closuresIdentifier),
|
2879
2890
|
programParamsSignal?.identifier && import_compiler18.types.arrowFunctionExpression([], programParamsSignal.identifier)
|
2880
2891
|
)
|
2881
2892
|
)
|
@@ -2883,16 +2894,6 @@ var dom_default = {
|
|
2883
2894
|
}
|
2884
2895
|
}
|
2885
2896
|
};
|
2886
|
-
function getSectionClosuresExpr(section) {
|
2887
|
-
if (section.closures) {
|
2888
|
-
return import_compiler18.types.arrayExpression(
|
2889
|
-
map(
|
2890
|
-
section.closures,
|
2891
|
-
(closure) => getSignal(section, closure).identifier
|
2892
|
-
).reverse()
|
2893
|
-
);
|
2894
|
-
}
|
2895
|
-
}
|
2896
2897
|
|
2897
2898
|
// src/translator/visitors/program/html.ts
|
2898
2899
|
var import_compiler19 = require("@marko/compiler");
|
@@ -3947,8 +3948,6 @@ var await_default = {
|
|
3947
3948
|
setForceResumeScope(bodySection);
|
3948
3949
|
}
|
3949
3950
|
flushInto(tag);
|
3950
|
-
setSubscriberBuilder(tag, () => {
|
3951
|
-
});
|
3952
3951
|
writeHTMLResumeStatements(tagBody);
|
3953
3952
|
tag.replaceWith(
|
3954
3953
|
import_compiler22.types.expressionStatement(
|
@@ -3973,7 +3972,6 @@ var await_default = {
|
|
3973
3972
|
return;
|
3974
3973
|
}
|
3975
3974
|
setSectionParentIsOwner(bodySection, true);
|
3976
|
-
setSubscriberBuilder(tag, (signal) => signal);
|
3977
3975
|
},
|
3978
3976
|
exit(tag) {
|
3979
3977
|
tag.remove();
|
@@ -4936,7 +4934,6 @@ function isInvokedFunction(expr) {
|
|
4936
4934
|
|
4937
4935
|
// src/translator/core/for.ts
|
4938
4936
|
var kForMarkerBinding = Symbol("for marker binding");
|
4939
|
-
var kForScopeStartIndex = Symbol("for scope start index");
|
4940
4937
|
var kOnlyChildInParent = Symbol("only child in parent");
|
4941
4938
|
var for_default = {
|
4942
4939
|
analyze(tag) {
|
@@ -4972,6 +4969,7 @@ var for_default = {
|
|
4972
4969
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
4973
4970
|
return;
|
4974
4971
|
}
|
4972
|
+
bodySection.isBranch = true;
|
4975
4973
|
const section = getOrCreateSection(tag);
|
4976
4974
|
if (isOnlyChildInParent(tag)) {
|
4977
4975
|
const parentTag = getParentTag(tag).node;
|
@@ -5002,22 +5000,12 @@ var for_default = {
|
|
5002
5000
|
tag.remove();
|
5003
5001
|
return;
|
5004
5002
|
}
|
5005
|
-
const tagExtra = tag.node.extra;
|
5006
|
-
const isStateful = isStatefulReferences(tagExtra.referencedBindings);
|
5007
5003
|
setSectionParentIsOwner(bodySection, true);
|
5008
5004
|
if (!isOnlyChildInParent(tag)) {
|
5009
5005
|
visit(tag, 37 /* Replace */);
|
5010
5006
|
enterShallow(tag);
|
5011
5007
|
}
|
5012
5008
|
flushBefore(tag);
|
5013
|
-
if (isStateful && !bodySection.content?.singleChild) {
|
5014
|
-
tagExtra[kForScopeStartIndex] = tag.scope.generateUidIdentifier("k");
|
5015
|
-
writeTo(tagBody)`${callRuntime(
|
5016
|
-
"markResumeScopeStart",
|
5017
|
-
getScopeIdIdentifier(bodySection),
|
5018
|
-
import_compiler29.types.updateExpression("++", tagExtra[kForScopeStartIndex])
|
5019
|
-
)}`;
|
5020
|
-
}
|
5021
5009
|
},
|
5022
5010
|
exit(tag) {
|
5023
5011
|
if (tag.node.body.attributeTags) return;
|
@@ -5035,22 +5023,12 @@ var for_default = {
|
|
5035
5023
|
const statements = [];
|
5036
5024
|
const bodyStatements = node.body.body;
|
5037
5025
|
const hasStatefulClosures = checkStatefulClosures(bodySection, true);
|
5026
|
+
const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild;
|
5038
5027
|
let keyExpression;
|
5039
5028
|
if (isStateful && isOnlyChildInParent(tag)) {
|
5040
5029
|
parentTag.node.extra[kSerializeMarker] = true;
|
5041
5030
|
}
|
5042
|
-
if (tagExtra[kForScopeStartIndex]) {
|
5043
|
-
statements.push(
|
5044
|
-
import_compiler29.types.variableDeclaration("let", [
|
5045
|
-
import_compiler29.types.variableDeclarator(
|
5046
|
-
tagExtra[kForScopeStartIndex],
|
5047
|
-
import_compiler29.types.numericLiteral(0)
|
5048
|
-
)
|
5049
|
-
])
|
5050
|
-
);
|
5051
|
-
}
|
5052
5031
|
if (isStateful || hasStatefulClosures) {
|
5053
|
-
const singleNodeOptimization = bodySection.content === null || bodySection.content.singleChild;
|
5054
5032
|
const defaultParamNames = {
|
5055
5033
|
of: ["list", "index"],
|
5056
5034
|
in: ["key", "value"],
|
@@ -5101,50 +5079,33 @@ var for_default = {
|
|
5101
5079
|
} else {
|
5102
5080
|
keyExpression = params[defaultByParamIndex];
|
5103
5081
|
}
|
5104
|
-
const write2 = writeTo(tag);
|
5105
|
-
const forScopeIdsIdentifier = tag.scope.generateUidIdentifier("forScopeIds");
|
5106
5082
|
const forScopesIdentifier = getScopeIdentifier(bodySection);
|
5107
5083
|
statements.push(
|
5108
|
-
import_compiler29.types.variableDeclaration(
|
5109
|
-
|
5110
|
-
|
5111
|
-
|
5112
|
-
|
5113
|
-
|
5114
|
-
),
|
5115
|
-
import_compiler29.types.variableDeclarator(
|
5116
|
-
forScopesIdentifier,
|
5117
|
-
import_compiler29.types.newExpression(import_compiler29.types.identifier("Map"), [])
|
5118
|
-
)
|
5119
|
-
].filter(Boolean)
|
5120
|
-
)
|
5084
|
+
import_compiler29.types.variableDeclaration("const", [
|
5085
|
+
import_compiler29.types.variableDeclarator(
|
5086
|
+
forScopesIdentifier,
|
5087
|
+
import_compiler29.types.newExpression(import_compiler29.types.identifier("Map"), [])
|
5088
|
+
)
|
5089
|
+
])
|
5121
5090
|
);
|
5122
|
-
if (isStateful) {
|
5123
|
-
|
5124
|
-
|
5125
|
-
import_compiler29.types.
|
5126
|
-
import_compiler29.types.
|
5127
|
-
|
5128
|
-
|
5129
|
-
|
5130
|
-
|
5131
|
-
|
5132
|
-
|
5091
|
+
if (keyExpression && (isStateful || hasStatefulClosures)) {
|
5092
|
+
bodyStatements.push(
|
5093
|
+
import_compiler29.types.expressionStatement(
|
5094
|
+
import_compiler29.types.callExpression(
|
5095
|
+
import_compiler29.types.memberExpression(
|
5096
|
+
getScopeIdentifier(bodySection),
|
5097
|
+
import_compiler29.types.identifier("set")
|
5098
|
+
),
|
5099
|
+
[
|
5100
|
+
keyExpression,
|
5101
|
+
callRuntime(
|
5102
|
+
"ensureScopeWithId",
|
5103
|
+
getScopeIdIdentifier(bodySection)
|
5104
|
+
)
|
5105
|
+
]
|
5133
5106
|
)
|
5134
|
-
)
|
5135
|
-
|
5136
|
-
"markResumeControlSingleNodeEnd",
|
5137
|
-
getScopeIdIdentifier(tagSection),
|
5138
|
-
getScopeAccessorLiteral(nodeRef2),
|
5139
|
-
forScopeIdsIdentifier
|
5140
|
-
)}`;
|
5141
|
-
} else {
|
5142
|
-
write2`${callRuntime(
|
5143
|
-
"markResumeControlEnd",
|
5144
|
-
getScopeIdIdentifier(tagSection),
|
5145
|
-
getScopeAccessorLiteral(nodeRef2)
|
5146
|
-
)}`;
|
5147
|
-
}
|
5107
|
+
)
|
5108
|
+
);
|
5148
5109
|
}
|
5149
5110
|
getSerializedScopeProperties(tagSection).set(
|
5150
5111
|
import_compiler29.types.stringLiteral(
|
@@ -5158,30 +5119,22 @@ var for_default = {
|
|
5158
5119
|
);
|
5159
5120
|
}
|
5160
5121
|
flushInto(tag);
|
5161
|
-
|
5122
|
+
setClosureSignalBuilder(tag, () => {
|
5162
5123
|
});
|
5163
5124
|
writeHTMLResumeStatements(tagBody);
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5170
|
-
|
5171
|
-
|
5172
|
-
|
5173
|
-
keyExpression,
|
5174
|
-
callRuntime(
|
5175
|
-
"getScopeById",
|
5176
|
-
getScopeIdIdentifier(bodySection)
|
5177
|
-
)
|
5178
|
-
]
|
5179
|
-
)
|
5180
|
-
)
|
5125
|
+
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
5126
|
+
const forTagHTMLRuntime = isStateful ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
|
5127
|
+
forTagArgs.push(
|
5128
|
+
import_compiler29.types.arrowFunctionExpression(params, import_compiler29.types.blockStatement(bodyStatements))
|
5129
|
+
);
|
5130
|
+
if (isStateful) {
|
5131
|
+
forTagArgs.push(
|
5132
|
+
getScopeIdIdentifier(tagSection),
|
5133
|
+
getScopeAccessorLiteral(nodeRef2)
|
5181
5134
|
);
|
5182
5135
|
}
|
5183
5136
|
statements.push(
|
5184
|
-
|
5137
|
+
import_compiler29.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
5185
5138
|
);
|
5186
5139
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
5187
5140
|
replacement.skip();
|
@@ -5212,11 +5165,12 @@ var for_default = {
|
|
5212
5165
|
const tagExtra = node.extra;
|
5213
5166
|
const { referencedBindings } = tagExtra;
|
5214
5167
|
const nodeRef2 = isOnlyChildInParent(tag) ? getParentTag(tag).node.extra[kNativeTagBinding] : tag.node.extra[kForMarkerBinding];
|
5215
|
-
|
5168
|
+
setClosureSignalBuilder(tag, (_closureSignal, render, intersection) => {
|
5216
5169
|
return callRuntime(
|
5217
|
-
"
|
5218
|
-
|
5219
|
-
|
5170
|
+
"loopClosure",
|
5171
|
+
getScopeAccessorLiteral(nodeRef2),
|
5172
|
+
render,
|
5173
|
+
intersection
|
5220
5174
|
);
|
5221
5175
|
});
|
5222
5176
|
const forType = getForType(node);
|
@@ -5355,6 +5309,27 @@ function forTypeToRuntime(type) {
|
|
5355
5309
|
return "forTo";
|
5356
5310
|
}
|
5357
5311
|
}
|
5312
|
+
function forTypeToHTMLResumeRuntime(type, singleNodeOptimization) {
|
5313
|
+
if (singleNodeOptimization) {
|
5314
|
+
switch (type) {
|
5315
|
+
case "of":
|
5316
|
+
return "resumeSingleNodeForOf";
|
5317
|
+
case "in":
|
5318
|
+
return "resumeSingleNodeForIn";
|
5319
|
+
case "to":
|
5320
|
+
return "resumeSingleNodeForTo";
|
5321
|
+
}
|
5322
|
+
} else {
|
5323
|
+
switch (type) {
|
5324
|
+
case "of":
|
5325
|
+
return "resumeForOf";
|
5326
|
+
case "in":
|
5327
|
+
return "resumeForIn";
|
5328
|
+
case "to":
|
5329
|
+
return "resumeForTo";
|
5330
|
+
}
|
5331
|
+
}
|
5332
|
+
}
|
5358
5333
|
function forTypeToDOMRuntime(type) {
|
5359
5334
|
switch (type) {
|
5360
5335
|
case "of":
|
@@ -6899,6 +6874,7 @@ var IfTag = {
|
|
6899
6874
|
let singleNodeOptimization = true;
|
6900
6875
|
for (const [branchTag, branchBodySection] of branches) {
|
6901
6876
|
if (branchBodySection) {
|
6877
|
+
branchBodySection.isBranch = true;
|
6902
6878
|
branchBodySection.upstreamExpression = rootExtra;
|
6903
6879
|
if (!(branchBodySection.content === null || branchBodySection.content?.singleChild)) {
|
6904
6880
|
singleNodeOptimization = false;
|
@@ -6926,9 +6902,6 @@ var IfTag = {
|
|
6926
6902
|
if (tag.node.body.attributeTags) return;
|
6927
6903
|
const tagBody = tag.get("body");
|
6928
6904
|
const bodySection = getSectionForBody(tagBody);
|
6929
|
-
const rootExtra = getRoot(tag).node.extra;
|
6930
|
-
const isStateful = isStatefulReferences(rootExtra.referencedBindings);
|
6931
|
-
const singleNodeOptimization = rootExtra.singleNodeOptimization;
|
6932
6905
|
if (isRoot(tag)) {
|
6933
6906
|
visit(tag, 37 /* Replace */);
|
6934
6907
|
}
|
@@ -6936,12 +6909,6 @@ var IfTag = {
|
|
6936
6909
|
flushBefore(tag);
|
6937
6910
|
if (bodySection) {
|
6938
6911
|
setSectionParentIsOwner(bodySection, true);
|
6939
|
-
if (isStateful && !singleNodeOptimization) {
|
6940
|
-
writeTo(tagBody)`${callRuntime(
|
6941
|
-
"markResumeScopeStart",
|
6942
|
-
getScopeIdIdentifier(bodySection)
|
6943
|
-
)}`;
|
6944
|
-
}
|
6945
6912
|
}
|
6946
6913
|
},
|
6947
6914
|
exit(tag) {
|
@@ -6960,12 +6927,11 @@ var IfTag = {
|
|
6960
6927
|
setForceResumeScope(bodySection);
|
6961
6928
|
}
|
6962
6929
|
flushInto(tag);
|
6963
|
-
|
6930
|
+
setClosureSignalBuilder(tag, () => {
|
6964
6931
|
});
|
6965
6932
|
writeHTMLResumeStatements(tagBody);
|
6966
6933
|
}
|
6967
6934
|
if (isLast) {
|
6968
|
-
const write2 = writeTo(tag);
|
6969
6935
|
const nextTag = tag.getNextSibling();
|
6970
6936
|
const ifScopeIdIdentifier = tag.scope.generateUidIdentifier("ifScopeId");
|
6971
6937
|
const ifRendererIdentifier = tag.scope.generateUidIdentifier("ifRenderer");
|
@@ -7026,6 +6992,31 @@ var IfTag = {
|
|
7026
6992
|
if (!(isStateful || hasStatefulClosures)) {
|
7027
6993
|
nextTag.insertBefore(statement);
|
7028
6994
|
} else {
|
6995
|
+
if (isStateful) {
|
6996
|
+
getSerializedScopeProperties(section).set(
|
6997
|
+
import_compiler38.types.stringLiteral(
|
6998
|
+
getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
|
6999
|
+
),
|
7000
|
+
ifRendererIdentifier
|
7001
|
+
);
|
7002
|
+
const cbNode = import_compiler38.types.arrowFunctionExpression(
|
7003
|
+
[],
|
7004
|
+
import_compiler38.types.blockStatement([statement])
|
7005
|
+
);
|
7006
|
+
statement = import_compiler38.types.expressionStatement(
|
7007
|
+
singleNodeOptimization ? callRuntime(
|
7008
|
+
"resumeSingleNodeConditional",
|
7009
|
+
cbNode,
|
7010
|
+
getScopeIdIdentifier(section),
|
7011
|
+
getScopeAccessorLiteral(nodeRef2)
|
7012
|
+
) : callRuntime(
|
7013
|
+
"resumeConditional",
|
7014
|
+
cbNode,
|
7015
|
+
getScopeIdIdentifier(section),
|
7016
|
+
getScopeAccessorLiteral(nodeRef2)
|
7017
|
+
)
|
7018
|
+
);
|
7019
|
+
}
|
7029
7020
|
nextTag.insertBefore([
|
7030
7021
|
import_compiler38.types.variableDeclaration(
|
7031
7022
|
"let",
|
@@ -7036,28 +7027,6 @@ var IfTag = {
|
|
7036
7027
|
),
|
7037
7028
|
statement
|
7038
7029
|
]);
|
7039
|
-
if (isStateful) {
|
7040
|
-
if (singleNodeOptimization) {
|
7041
|
-
write2`${callRuntime(
|
7042
|
-
"markResumeControlSingleNodeEnd",
|
7043
|
-
getScopeIdIdentifier(section),
|
7044
|
-
getScopeAccessorLiteral(nodeRef2),
|
7045
|
-
ifScopeIdIdentifier
|
7046
|
-
)}`;
|
7047
|
-
} else {
|
7048
|
-
write2`${callRuntime(
|
7049
|
-
"markResumeControlEnd",
|
7050
|
-
getScopeIdIdentifier(section),
|
7051
|
-
getScopeAccessorLiteral(nodeRef2)
|
7052
|
-
)}`;
|
7053
|
-
}
|
7054
|
-
getSerializedScopeProperties(section).set(
|
7055
|
-
import_compiler38.types.stringLiteral(
|
7056
|
-
getScopeAccessorLiteral(nodeRef2).value + "(" /* ConditionalRenderer */
|
7057
|
-
),
|
7058
|
-
ifRendererIdentifier
|
7059
|
-
);
|
7060
|
-
}
|
7061
7030
|
getSerializedScopeProperties(section).set(
|
7062
7031
|
import_compiler38.types.stringLiteral(
|
7063
7032
|
getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
|
@@ -7096,14 +7065,21 @@ var IfTag = {
|
|
7096
7065
|
const [branchTag, branchBodySection] = branches[i];
|
7097
7066
|
const [testAttr] = branchTag.node.attributes;
|
7098
7067
|
const consequent = branchBodySection ? import_compiler38.types.identifier(branchBodySection.name) : import_compiler38.types.numericLiteral(0);
|
7099
|
-
|
7100
|
-
|
7101
|
-
|
7102
|
-
|
7103
|
-
|
7104
|
-
|
7105
|
-
|
7106
|
-
|
7068
|
+
setClosureSignalBuilder(
|
7069
|
+
branchTag,
|
7070
|
+
(_closureSignal, render, intersection) => {
|
7071
|
+
return callRuntime(
|
7072
|
+
"conditionalClosure",
|
7073
|
+
getScopeAccessorLiteral(nodeRef2),
|
7074
|
+
import_compiler38.types.arrowFunctionExpression(
|
7075
|
+
[],
|
7076
|
+
import_compiler38.types.identifier(branchBodySection.name)
|
7077
|
+
),
|
7078
|
+
render,
|
7079
|
+
intersection
|
7080
|
+
);
|
7081
|
+
}
|
7082
|
+
);
|
7107
7083
|
branchTag.remove();
|
7108
7084
|
expr = testAttr ? import_compiler38.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
7109
7085
|
}
|
@@ -7235,9 +7211,6 @@ function getBranches(tag, bodySection) {
|
|
7235
7211
|
}
|
7236
7212
|
return [isLast, branches];
|
7237
7213
|
}
|
7238
|
-
function getRoot(tag) {
|
7239
|
-
return isRoot(tag) ? tag : BRANCHES_LOOKUP.get(tag)[0][0];
|
7240
|
-
}
|
7241
7214
|
function isRoot(tag) {
|
7242
7215
|
return isCoreTagName(tag, "if");
|
7243
7216
|
}
|
@@ -7751,27 +7724,27 @@ var style_default = {
|
|
7751
7724
|
const start = (0, import_babel_utils35.getStart)(file, markoText);
|
7752
7725
|
const end = (0, import_babel_utils35.getEnd)(file, markoText);
|
7753
7726
|
let code = markoText.value;
|
7754
|
-
let
|
7727
|
+
let map;
|
7755
7728
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
7756
7729
|
const magicString = new import_magic_string.default(file.code, { filename });
|
7757
7730
|
magicString.remove(0, start);
|
7758
7731
|
magicString.remove(end, file.code.length);
|
7759
|
-
|
7732
|
+
map = magicString.generateMap({
|
7760
7733
|
source: filename,
|
7761
7734
|
includeContent: true
|
7762
7735
|
});
|
7763
7736
|
if (sourceMaps === "inline" || sourceMaps === "both") {
|
7764
7737
|
code += `
|
7765
|
-
/*# sourceMappingURL=${
|
7738
|
+
/*# sourceMappingURL=${map.toUrl()}*/`;
|
7766
7739
|
if (sourceMaps === "inline") {
|
7767
|
-
|
7740
|
+
map = void 0;
|
7768
7741
|
}
|
7769
7742
|
}
|
7770
7743
|
}
|
7771
7744
|
const importPath = resolveVirtualDependency?.(filename, {
|
7772
7745
|
virtualPath: `./${import_path3.default.basename(filename) + ext}`,
|
7773
7746
|
code,
|
7774
|
-
map
|
7747
|
+
map
|
7775
7748
|
});
|
7776
7749
|
if (importPath) {
|
7777
7750
|
if (!node.var) {
|
@@ -7881,7 +7854,6 @@ function setAllSectionsParentIsOwner(tag) {
|
|
7881
7854
|
const bodySection = getSectionForBody(tag.get("body"));
|
7882
7855
|
if (bodySection) {
|
7883
7856
|
setSectionParentIsOwner(bodySection, true);
|
7884
|
-
setSubscriberBuilder(tag, (signal) => signal);
|
7885
7857
|
}
|
7886
7858
|
}
|
7887
7859
|
|
@@ -8197,7 +8169,11 @@ var referenced_identifier_default = {
|
|
8197
8169
|
analyze(identifier) {
|
8198
8170
|
const { name: name2 } = identifier.node;
|
8199
8171
|
if (identifier.scope.hasBinding(name2)) return;
|
8200
|
-
if (name2 === "$global"
|
8172
|
+
if (name2 === "$global") {
|
8173
|
+
setReferencesScope(identifier);
|
8174
|
+
} else if (name2 === "$signal") {
|
8175
|
+
const section = getOrCreateSection(identifier);
|
8176
|
+
section.hasAbortSignal = true;
|
8201
8177
|
setReferencesScope(identifier);
|
8202
8178
|
}
|
8203
8179
|
},
|
@@ -8218,13 +8194,6 @@ var referenced_identifier_default = {
|
|
8218
8194
|
break;
|
8219
8195
|
case "$signal":
|
8220
8196
|
if (isOutputHTML()) {
|
8221
|
-
const section = getSection(identifier);
|
8222
|
-
if (!section.hasCleanup) {
|
8223
|
-
section.hasCleanup = true;
|
8224
|
-
const exprRoot = getExprRoot(identifier);
|
8225
|
-
const write2 = writeTo(exprRoot);
|
8226
|
-
write2`${callRuntime("markResumeCleanup", getScopeIdIdentifier(section))}`;
|
8227
|
-
}
|
8228
8197
|
identifier.replaceWith(
|
8229
8198
|
import_compiler49.types.callExpression(
|
8230
8199
|
import_compiler49.types.arrowFunctionExpression(
|
@@ -9059,7 +9028,6 @@ var dynamic_tag_default = {
|
|
9059
9028
|
if (isOutputHTML()) {
|
9060
9029
|
flushInto(tag);
|
9061
9030
|
writeHTMLResumeStatements(tag.get("body"));
|
9062
|
-
const write2 = writeTo(tag);
|
9063
9031
|
if (node.var) {
|
9064
9032
|
if (!hasMultipleArgs && args.length === 1) {
|
9065
9033
|
args.push(import_compiler52.types.unaryExpression("void", import_compiler52.types.numericLiteral(0)));
|
@@ -9083,12 +9051,14 @@ var dynamic_tag_default = {
|
|
9083
9051
|
const dynamicScopeIdentifier = currentProgramPath.scope.generateUidIdentifier("dynamicScope");
|
9084
9052
|
const dynamicTagExpr = hasMultipleArgs ? callRuntime(
|
9085
9053
|
"dynamicTagArgs",
|
9086
|
-
|
9054
|
+
getScopeIdIdentifier(section),
|
9055
|
+
getScopeAccessorLiteral(nodeRef2),
|
9087
9056
|
tagExpression,
|
9088
9057
|
import_compiler52.types.arrayExpression(args)
|
9089
9058
|
) : callRuntime(
|
9090
9059
|
"dynamicTagInput",
|
9091
|
-
|
9060
|
+
getScopeIdIdentifier(section),
|
9061
|
+
getScopeAccessorLiteral(nodeRef2),
|
9092
9062
|
tagExpression,
|
9093
9063
|
...args
|
9094
9064
|
);
|
@@ -9105,11 +9075,6 @@ var dynamic_tag_default = {
|
|
9105
9075
|
import_compiler52.types.variableDeclarator(node.var, dynamicTagExpr)
|
9106
9076
|
]) : import_compiler52.types.expressionStatement(dynamicTagExpr)
|
9107
9077
|
);
|
9108
|
-
write2`${callRuntime(
|
9109
|
-
"markResumeControlEnd",
|
9110
|
-
getScopeIdIdentifier(section),
|
9111
|
-
getScopeAccessorLiteral(nodeRef2)
|
9112
|
-
)}`;
|
9113
9078
|
getSerializedScopeProperties(section).set(
|
9114
9079
|
import_compiler52.types.stringLiteral(
|
9115
9080
|
getScopeAccessorLiteral(nodeRef2).value + "!" /* ConditionalScope */
|