marko 6.0.56 → 6.0.57
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
@@ -1880,13 +1880,9 @@ var function_default = {
|
|
1880
1880
|
};
|
1881
1881
|
function finalizeFunctionRegistry() {
|
1882
1882
|
for (const [fnExtra, exprExtras] of getReferencesByFn()) {
|
1883
|
-
const seenExtras = /* @__PURE__ */ new Set();
|
1884
1883
|
let shouldRegister = false;
|
1885
1884
|
for (const exprExtra of exprExtras) {
|
1886
|
-
|
1887
|
-
if (seenExtras.has(refExtra)) continue;
|
1888
|
-
seenExtras.add(refExtra);
|
1889
|
-
if (couldSerializeDownstream(refExtra.downstream)) {
|
1885
|
+
if (couldSerializeExtra(getCanonicalExtra(exprExtra))) {
|
1890
1886
|
shouldRegister = true;
|
1891
1887
|
break;
|
1892
1888
|
}
|
@@ -1896,36 +1892,6 @@ function finalizeFunctionRegistry() {
|
|
1896
1892
|
}
|
1897
1893
|
}
|
1898
1894
|
}
|
1899
|
-
function couldSerializeDownstream(downstream) {
|
1900
|
-
if (downstream) {
|
1901
|
-
return Array.isArray(downstream.bindings) ? downstream.bindings.some((binding) => couldSerializeBinding(binding)) : couldSerializeBinding(
|
1902
|
-
downstream.bindings,
|
1903
|
-
downstream.excludeProperties
|
1904
|
-
);
|
1905
|
-
}
|
1906
|
-
return false;
|
1907
|
-
}
|
1908
|
-
function couldSerializeBinding(binding, excludeProperties) {
|
1909
|
-
if (getBindingSerializeReason(binding.section, binding)) {
|
1910
|
-
return true;
|
1911
|
-
}
|
1912
|
-
for (const expr of binding.downstreamExpressions) {
|
1913
|
-
if (expr.isEffect || couldSerializeDownstream(expr.downstream)) {
|
1914
|
-
return true;
|
1915
|
-
}
|
1916
|
-
}
|
1917
|
-
for (const alias of binding.aliases) {
|
1918
|
-
if (couldSerializeBinding(alias)) {
|
1919
|
-
return true;
|
1920
|
-
}
|
1921
|
-
}
|
1922
|
-
for (const [name2, propBinding] of binding.propertyAliases) {
|
1923
|
-
if (!excludeProperties?.has(name2) && couldSerializeBinding(propBinding)) {
|
1924
|
-
return true;
|
1925
|
-
}
|
1926
|
-
}
|
1927
|
-
return false;
|
1928
|
-
}
|
1929
1895
|
function canIgnoreRegister(markoRoot, exprRoot) {
|
1930
1896
|
return (
|
1931
1897
|
// bail within a placeholder
|
@@ -3151,6 +3117,7 @@ var return_default = {
|
|
3151
3117
|
throw tag.get("name").buildCodeFrameError("The `return` tag requires a value.");
|
3152
3118
|
}
|
3153
3119
|
if (attrs2.valueChange) {
|
3120
|
+
(attrs2.valueChange.extra ??= {}).isEffect = true;
|
3154
3121
|
forceSectionSerialize(
|
3155
3122
|
getOrCreateSection(tag),
|
3156
3123
|
getAccessorProp().TagVariableChange
|
@@ -3569,7 +3536,7 @@ function getSignalFn(signal) {
|
|
3569
3536
|
}
|
3570
3537
|
if (isIntersection && signal.renderReferencedBindings) {
|
3571
3538
|
signal.render.unshift(
|
3572
|
-
import_compiler21.types.variableDeclaration("
|
3539
|
+
import_compiler21.types.variableDeclaration("let", [
|
3573
3540
|
import_compiler21.types.variableDeclarator(
|
3574
3541
|
createScopeReadPattern(section, signal.renderReferencedBindings),
|
3575
3542
|
scopeIdentifier
|
@@ -5040,10 +5007,10 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
5040
5007
|
void 0
|
5041
5008
|
);
|
5042
5009
|
if (lVal.left.extra?.binding) {
|
5043
|
-
(
|
5044
|
-
|
5045
|
-
|
5046
|
-
|
5010
|
+
setBindingDownstream(
|
5011
|
+
lVal.left.extra.binding,
|
5012
|
+
lVal.right.extra ??= {}
|
5013
|
+
);
|
5047
5014
|
}
|
5048
5015
|
break;
|
5049
5016
|
}
|
@@ -5147,17 +5114,6 @@ function finalizeReferences() {
|
|
5147
5114
|
});
|
5148
5115
|
}
|
5149
5116
|
}
|
5150
|
-
for (const [fn, reads] of readsByFn) {
|
5151
|
-
fn.referencedBindingsInFunction = resolveReferencedBindings(
|
5152
|
-
fn,
|
5153
|
-
reads,
|
5154
|
-
intersectionsBySection
|
5155
|
-
);
|
5156
|
-
forEach(
|
5157
|
-
fn.referencedBindingsInFunction,
|
5158
|
-
(binding) => forceBindingSerialize(binding.section, binding)
|
5159
|
-
);
|
5160
|
-
}
|
5161
5117
|
for (const binding of bindings) {
|
5162
5118
|
if (binding.type !== 0 /* dom */ && !binding.upstreamAlias) {
|
5163
5119
|
pruneBinding(bindings, binding);
|
@@ -5417,6 +5373,19 @@ function finalizeReferences() {
|
|
5417
5373
|
}
|
5418
5374
|
});
|
5419
5375
|
finalizeFunctionRegistry();
|
5376
|
+
for (const [fn, reads] of readsByFn) {
|
5377
|
+
fn.referencedBindingsInFunction = resolveReferencedBindings(
|
5378
|
+
fn,
|
5379
|
+
reads,
|
5380
|
+
intersectionsBySection
|
5381
|
+
);
|
5382
|
+
if (fn.registerId) {
|
5383
|
+
forEach(
|
5384
|
+
fn.referencedBindingsInFunction,
|
5385
|
+
(binding) => forceBindingSerialize(binding.section, binding)
|
5386
|
+
);
|
5387
|
+
}
|
5388
|
+
}
|
5420
5389
|
mergedReferences.clear();
|
5421
5390
|
readsByExpression.clear();
|
5422
5391
|
readsByFn.clear();
|
@@ -5437,8 +5406,13 @@ function getMaxOwnSourceOffset(intersection, section) {
|
|
5437
5406
|
return scopeOffset;
|
5438
5407
|
}
|
5439
5408
|
var intersectionMeta = /* @__PURE__ */ new WeakMap();
|
5440
|
-
function
|
5441
|
-
bindingValueExprs.set(binding,
|
5409
|
+
function setBindingDownstream(binding, expr) {
|
5410
|
+
bindingValueExprs.set(binding, expr || false);
|
5411
|
+
if (expr && expr !== true) {
|
5412
|
+
forEach(expr, (expr2) => {
|
5413
|
+
expr2.downstream = bindingUtil.add(expr2.downstream, binding);
|
5414
|
+
});
|
5415
|
+
}
|
5442
5416
|
}
|
5443
5417
|
var resolvedSources = /* @__PURE__ */ new WeakSet();
|
5444
5418
|
var bindingValueExprs = /* @__PURE__ */ new WeakMap();
|
@@ -5805,6 +5779,50 @@ function getCanonicalExtra(extra) {
|
|
5805
5779
|
}
|
5806
5780
|
return extra;
|
5807
5781
|
}
|
5782
|
+
var couldSerializeLookup = /* @__PURE__ */ new WeakMap();
|
5783
|
+
function couldSerializeExtra(extra) {
|
5784
|
+
let couldSerialize = couldSerializeLookup.get(extra);
|
5785
|
+
if (couldSerialize === void 0) {
|
5786
|
+
couldSerializeLookup.set(
|
5787
|
+
extra,
|
5788
|
+
couldSerialize = extra === (0, import_babel_utils19.getProgram)().node.extra?.returnValueExpr || !!find(extra.downstream, couldSerializeBinding)
|
5789
|
+
);
|
5790
|
+
}
|
5791
|
+
return couldSerialize;
|
5792
|
+
}
|
5793
|
+
function couldSerializeBinding(binding) {
|
5794
|
+
let couldSerialize = couldSerializeLookup.get(binding);
|
5795
|
+
if (couldSerialize === void 0) {
|
5796
|
+
if (getBindingSerializeReason(binding.section, binding)) {
|
5797
|
+
couldSerialize = true;
|
5798
|
+
} else {
|
5799
|
+
for (const expr of binding.downstreamExpressions) {
|
5800
|
+
if (expr.isEffect || couldSerializeExtra(expr)) {
|
5801
|
+
couldSerialize = true;
|
5802
|
+
break;
|
5803
|
+
}
|
5804
|
+
}
|
5805
|
+
if (!couldSerialize) {
|
5806
|
+
for (const alias of binding.aliases) {
|
5807
|
+
if (couldSerializeBinding(alias)) {
|
5808
|
+
couldSerialize = true;
|
5809
|
+
break;
|
5810
|
+
}
|
5811
|
+
}
|
5812
|
+
if (!couldSerialize) {
|
5813
|
+
for (const [, propBinding] of binding.propertyAliases) {
|
5814
|
+
if (couldSerializeBinding(propBinding)) {
|
5815
|
+
couldSerialize = true;
|
5816
|
+
break;
|
5817
|
+
}
|
5818
|
+
}
|
5819
|
+
}
|
5820
|
+
}
|
5821
|
+
}
|
5822
|
+
couldSerializeLookup.set(binding, couldSerialize ??= false);
|
5823
|
+
}
|
5824
|
+
return couldSerialize;
|
5825
|
+
}
|
5808
5826
|
function setCanonicalExtra(extra, merged) {
|
5809
5827
|
extra.merged = merged;
|
5810
5828
|
}
|
@@ -5851,7 +5869,7 @@ var await_default = {
|
|
5851
5869
|
getOrCreateSection(tag);
|
5852
5870
|
const paramsBinding = trackParamsReferences(tagBody, 3 /* param */);
|
5853
5871
|
if (paramsBinding) {
|
5854
|
-
|
5872
|
+
setBindingDownstream(paramsBinding, valueExtra);
|
5855
5873
|
}
|
5856
5874
|
bodySection.upstreamExpression = valueAttr.value.extra;
|
5857
5875
|
},
|
@@ -6045,11 +6063,7 @@ var const_default = {
|
|
6045
6063
|
const binding = trackVarReferences(tag, 5 /* derived */, upstreamAlias);
|
6046
6064
|
if (binding) {
|
6047
6065
|
if (!valueExtra.nullable) binding.nullable = false;
|
6048
|
-
|
6049
|
-
valueExtra.downstream = {
|
6050
|
-
bindings: binding,
|
6051
|
-
excludeProperties: void 0
|
6052
|
-
};
|
6066
|
+
setBindingDownstream(binding, valueExtra);
|
6053
6067
|
}
|
6054
6068
|
},
|
6055
6069
|
translate: {
|
@@ -7261,7 +7275,7 @@ var for_default = {
|
|
7261
7275
|
getAllTagReferenceNodes(tag.node)
|
7262
7276
|
);
|
7263
7277
|
if (paramsBinding) {
|
7264
|
-
|
7278
|
+
setBindingDownstream(paramsBinding, tagExtra);
|
7265
7279
|
}
|
7266
7280
|
bodySection.sectionAccessor = {
|
7267
7281
|
binding: nodeBinding,
|
@@ -7899,11 +7913,7 @@ var define_default = {
|
|
7899
7913
|
getAllTagReferenceNodes(tag.node)
|
7900
7914
|
);
|
7901
7915
|
if (varBinding) {
|
7902
|
-
|
7903
|
-
tagExtra.downstream = {
|
7904
|
-
bindings: varBinding,
|
7905
|
-
excludeProperties: void 0
|
7906
|
-
};
|
7916
|
+
setBindingDownstream(varBinding, tagExtra);
|
7907
7917
|
}
|
7908
7918
|
},
|
7909
7919
|
translate: {
|
@@ -9044,7 +9054,7 @@ var id_default = {
|
|
9044
9054
|
}
|
9045
9055
|
const binding = trackVarReferences(tag, 5 /* derived */);
|
9046
9056
|
if (binding) {
|
9047
|
-
|
9057
|
+
setBindingDownstream(binding, false);
|
9048
9058
|
}
|
9049
9059
|
},
|
9050
9060
|
translate: {
|
@@ -9497,7 +9507,7 @@ var let_default = {
|
|
9497
9507
|
}
|
9498
9508
|
const tagSection = getOrCreateSection(tag);
|
9499
9509
|
const binding = trackVarReferences(tag, 1 /* let */);
|
9500
|
-
|
9510
|
+
setBindingDownstream(
|
9501
9511
|
binding,
|
9502
9512
|
mergeReferences(tagSection, tag.node, [
|
9503
9513
|
valueAttr?.value,
|
@@ -10646,7 +10656,7 @@ var custom_tag_default = {
|
|
10646
10656
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
10647
10657
|
if (varBinding) {
|
10648
10658
|
const varSerializeReason = (0, import_babel_utils49.getProgram)().node.extra.returnValueExpr;
|
10649
|
-
|
10659
|
+
setBindingDownstream(varBinding, varSerializeReason);
|
10650
10660
|
addBindingSerializeReasonExpr(
|
10651
10661
|
section,
|
10652
10662
|
childScopeBinding,
|
@@ -10672,7 +10682,7 @@ var custom_tag_default = {
|
|
10672
10682
|
childInputBinding,
|
10673
10683
|
inputExpr
|
10674
10684
|
);
|
10675
|
-
|
10685
|
+
setBindingDownstream(varBinding, varSerializeReason);
|
10676
10686
|
addBindingSerializeReasonExpr(
|
10677
10687
|
section,
|
10678
10688
|
childScopeBinding,
|
@@ -10979,10 +10989,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport, rootAttrExprs,
|
|
10979
10989
|
tag.node,
|
10980
10990
|
getAllTagReferenceNodes(tag.node)
|
10981
10991
|
);
|
10982
|
-
|
10983
|
-
bindings: templateExport.binding,
|
10984
|
-
excludeProperties: void 0
|
10985
|
-
};
|
10992
|
+
setBindingDownstream(templateExport.binding, extra);
|
10986
10993
|
return;
|
10987
10994
|
}
|
10988
10995
|
const known = inputExpr.known = {};
|
@@ -11065,10 +11072,9 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport, rootAttrExprs,
|
|
11065
11072
|
bindings = bindingUtil.add(bindings, templateExportAttr.binding);
|
11066
11073
|
}
|
11067
11074
|
if (bindings) {
|
11068
|
-
|
11069
|
-
|
11070
|
-
|
11071
|
-
};
|
11075
|
+
forEach(bindings, (binding) => {
|
11076
|
+
setBindingDownstream(binding, groupExtra);
|
11077
|
+
});
|
11072
11078
|
}
|
11073
11079
|
for (const name2 of group) {
|
11074
11080
|
known[attrTagLookup[name2].name] = groupKnownValue;
|
@@ -11094,10 +11100,10 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport, rootAttrExprs,
|
|
11094
11100
|
continue;
|
11095
11101
|
}
|
11096
11102
|
seen.add(attr2.name);
|
11097
|
-
(
|
11098
|
-
|
11099
|
-
|
11100
|
-
|
11103
|
+
setBindingDownstream(
|
11104
|
+
templateExportAttr.binding,
|
11105
|
+
attr2.value.extra ??= {}
|
11106
|
+
);
|
11101
11107
|
}
|
11102
11108
|
if (spreadReferenceNodes) {
|
11103
11109
|
spreadReferenceNodes.push(attr2.value);
|
@@ -11115,10 +11121,20 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport, rootAttrExprs,
|
|
11115
11121
|
tag.node,
|
11116
11122
|
spreadReferenceNodes
|
11117
11123
|
);
|
11118
|
-
|
11119
|
-
|
11120
|
-
|
11121
|
-
|
11124
|
+
let spreadBinding = templateExport.binding;
|
11125
|
+
if (seen.size) {
|
11126
|
+
spreadBinding = createBinding(
|
11127
|
+
generateUid(`${getTagName(tag)}_attrs`),
|
11128
|
+
spreadBinding.type,
|
11129
|
+
spreadBinding.section,
|
11130
|
+
spreadBinding,
|
11131
|
+
void 0,
|
11132
|
+
fromIter(seen),
|
11133
|
+
spreadReferenceNodes[0].loc,
|
11134
|
+
true
|
11135
|
+
);
|
11136
|
+
}
|
11137
|
+
setBindingDownstream(spreadBinding, extra);
|
11122
11138
|
}
|
11123
11139
|
}
|
11124
11140
|
function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
@@ -11606,7 +11622,7 @@ var dynamic_tag_default = {
|
|
11606
11622
|
])
|
11607
11623
|
);
|
11608
11624
|
statements.push(
|
11609
|
-
import_compiler57.types.variableDeclaration("
|
11625
|
+
import_compiler57.types.variableDeclaration("let", [
|
11610
11626
|
import_compiler57.types.variableDeclarator(node.var, dynamicTagExpr)
|
11611
11627
|
]),
|
11612
11628
|
import_compiler57.types.expressionStatement(
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
|
-
import { type Many, type
|
2
|
+
import { type Many, type Opt, Sorted } from "./optional";
|
3
3
|
import { type Section } from "./sections";
|
4
4
|
declare const kIsInvoked: unique symbol;
|
5
5
|
export declare const kBranchSerializeReason: unique symbol;
|
@@ -52,10 +52,7 @@ declare module "@marko/compiler/dist/types" {
|
|
52
52
|
interface NodeExtra {
|
53
53
|
section?: Section;
|
54
54
|
referencedBindings?: ReferencedBindings;
|
55
|
-
downstream?:
|
56
|
-
bindings: OneMany<Binding>;
|
57
|
-
excludeProperties: undefined | Set<string>;
|
58
|
-
};
|
55
|
+
downstream?: Opt<Binding>;
|
59
56
|
binding?: Binding;
|
60
57
|
assignment?: Binding;
|
61
58
|
assignmentTo?: Binding;
|
@@ -89,7 +86,7 @@ export declare const intersectionMeta: WeakMap<Intersection, {
|
|
89
86
|
id: number;
|
90
87
|
scopeOffset: Binding | undefined;
|
91
88
|
}>;
|
92
|
-
export declare function
|
89
|
+
export declare function setBindingDownstream(binding: Binding, expr: boolean | Opt<t.NodeExtra>): void;
|
93
90
|
export declare function createSources(state: Sources["state"], input: Sources["input"]): Sources;
|
94
91
|
export declare function compareSources(a: Sources, b: Sources): number;
|
95
92
|
export declare function mergeSources(a: undefined | Sources, b: undefined | Sources): Sources | undefined;
|
@@ -125,4 +122,6 @@ export interface RegisteredFnExtra extends ReferencedExtra {
|
|
125
122
|
}
|
126
123
|
export declare function isRegisteredFnExtra(extra: t.NodeExtra | undefined): extra is RegisteredFnExtra;
|
127
124
|
export declare function getCanonicalExtra<T extends t.NodeExtra>(extra: T): T;
|
125
|
+
export declare function couldSerializeExtra(extra: t.NodeExtra): boolean;
|
126
|
+
export declare function couldSerializeBinding(binding: Binding): boolean;
|
128
127
|
export {};
|